home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / ListSERV1_4.lha / ListSERV / source / faq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-28  |  1.9 KB  |  71 lines

  1. #include "listserv.h"
  2. #include "protos.h"
  3.  
  4. static char rcsid[] = "$Id: faq.c,v 1.1.1.8 1993/12/28 22:16:34 simons Exp simons $";
  5.  
  6. void sendfaq(char *from,
  7.              char *command)
  8. {
  9.         int i;
  10.         char grp[256], tmp[512];
  11.  
  12.         printf("called sendfaq with %s %s\n", from, command);
  13.         i = sscanf(command, "%s%s", tmp, grp);
  14.         if(i != 2)
  15.                 {
  16.                 sendhelp(from, command);
  17.                 return;
  18.                 }
  19.  
  20.         sprintf(tmp, "%s%s/FAQ", LISTDIR, grp);
  21.         callmailer("", from, command);
  22.         LockFile(tmp);
  23.         if(access(tmp,R_OK) == 0) {
  24.                 UnLockFile(tmp);
  25.                 mailcat(tmp, "");
  26.                 fflush(mailer);
  27.                 pclose(mailer);
  28.                 return;
  29.         }
  30.         else {
  31.                 UnLockFile(tmp);
  32.                 fprintf(mailer, "There is no FAQ available for");
  33.                 fprintf(mailer, " mailing list \"%s\".\n", grp);
  34.                 fflush(mailer);
  35.                 pclose(mailer);
  36.                 return;
  37.                 }
  38.         }
  39.  
  40.  
  41. void faqindex(char *from,
  42.               char *request)
  43. {
  44.         DIR *listdir;
  45.         struct dirent *entry;
  46.         char tmp[128];
  47.         printf("called faqindex with %s %s\n", from, request);
  48.  
  49.         if (!(listdir = opendir(LISTDIR))) {
  50.                 perror(LISTDIR);
  51.                 exit(1);
  52.         }
  53.  
  54.         callmailer("", from, request);
  55.         fprintf(mailer, "------------------------ Index of available FAQs ---------------------\n");
  56.  
  57.         while (entry = readdir(listdir)) {
  58.                 sprintf(tmp, "%s%s/FAQ", LISTDIR, entry->d_name);
  59.                 LockFile(tmp);
  60.                 if (!access(tmp, R_OK))
  61.                         fprintf(mailer, "%s\n", entry->d_name);
  62.                 UnLockFile(tmp);
  63.         }
  64.         closedir(listdir);
  65.  
  66.         fprintf(mailer, "----------------------------------------------------------------------\n");
  67.         pclose(mailer);
  68.         return;
  69. }
  70.  
  71.