home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / ListSERV2_3.lha / ListSERV / source / faq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-17  |  3.0 KB  |  97 lines

  1. /*
  2.  *      $Filename: faq.c $
  3.  *      $Revision: 2.1 $
  4.  *      $Date: 1994/01/17 12:02:03 $
  5.  *
  6.  *      Copyright (C) 1993 by Peter Simons <simons@peti.GUN.de>
  7.  *
  8.  *      This program is free software; you can redistribute it and/or
  9.  *      modify it under the terms of the GNU General Public License as
  10.  *      published by the Free Software Foundation; either version 2 of
  11.  *      the License, or (at your option) any later version.
  12.  *
  13.  *      This program is distributed in the hope that it will be useful,
  14.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *      General Public License for more details.
  17.  *
  18.  *      You should have received a copy of the GNU General Public License
  19.  *      along with this program; if not, write to the Free Software
  20.  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  *      $Id: faq.c,v 2.1 1994/01/17 12:02:03 simons Exp simons $
  23.  *
  24.  */
  25.  
  26.  
  27. /************************************* includes ***********/
  28. #include "listserv.h"
  29. #include "protos.h"
  30.  
  31. /************************************* global variables ***/
  32. static char rcsid[] = "$Id: faq.c,v 2.1 1994/01/17 12:02:03 simons Exp simons $";
  33.  
  34. /************************************* program ************/
  35. void sendfaq(char *from, char *command)
  36. {
  37.         int i;
  38.         char grp[256], tmp[512];
  39.  
  40.         printf("called sendfaq with %s %s\n", from, command);
  41.         i = sscanf(command, "%s%s", tmp, grp);
  42.         if(i != 2)
  43.                 {
  44.                 sendhelp(from, command);
  45.                 return;
  46.                 }
  47.  
  48.         sprintf(tmp, "%s%s/FAQ", LISTDIR, grp);
  49.         callmailer("", from, command);
  50.         LockFile(tmp);
  51.         if(access(tmp,R_OK) == 0) {
  52.                 UnLockFile(tmp);
  53.                 mailcat(tmp, "");
  54.                 pclose(mailer);
  55.                 return;
  56.         }
  57.         else {
  58.                 UnLockFile(tmp);
  59.                 fprintf(mailer, "There is no FAQ available for");
  60.                 fprintf(mailer, " mailing list \"%s\".\n", grp);
  61.                 pclose(mailer);
  62.                 return;
  63.                 }
  64.         }
  65.  
  66.  
  67. void faqindex(char *from,
  68.               char *request)
  69. {
  70.         DIR *listdir;
  71.         struct dirent *entry;
  72.         char tmp[128];
  73.         printf("called faqindex with %s %s\n", from, request);
  74.  
  75.         if (!(listdir = opendir(LISTDIR))) {
  76.                 perror(LISTDIR);
  77.                 exit(1);
  78.         }
  79.  
  80.         callmailer("", from, request);
  81.         fprintf(mailer, "------------------------ Index of available FAQs ---------------------\n");
  82.  
  83.         while (entry = readdir(listdir)) {
  84.                 sprintf(tmp, "%s%s/FAQ", LISTDIR, entry->d_name);
  85.                 LockFile(tmp);
  86.                 if (!access(tmp, R_OK))
  87.                         fprintf(mailer, "%s\n", entry->d_name);
  88.                 UnLockFile(tmp);
  89.         }
  90.         closedir(listdir);
  91.  
  92.         fprintf(mailer, "----------------------------------------------------------------------\n");
  93.         pclose(mailer);
  94.         return;
  95. }
  96.  
  97.