home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / nntp1.5 / part01 / server / list.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-18  |  979 b   |  55 lines

  1. #ifndef lint
  2. static char    *sccsid = "@(#)list.c    1.10    (Berkeley) 2/6/88";
  3. #endif
  4.  
  5. #include "common.h"
  6.  
  7. /*
  8.  * LIST
  9.  *
  10.  * List active newsgroups.
  11.  *
  12.  */
  13.  
  14. list(argc, argv)
  15.     int        argc;
  16.     char        *argv[];
  17. {
  18.     char        line[NNTP_STRLEN];
  19.     char        *grparray[2];
  20.     register char    *cp;
  21.     register FILE    *active_fp;
  22.  
  23.     grparray[0] = line;
  24.     grparray[1] = NULL;
  25.  
  26.     active_fp = fopen(activefile, "r");
  27.  
  28.     if (active_fp == NULL) {
  29.         printf("%d No list of newsgroups available.\r\n", ERR_FAULT);
  30.         (void) fflush(stdout);
  31. #ifdef SYSLOG
  32.         syslog(LOG_ERR, "list: fopen %s: %m", activefile);
  33. #endif
  34.         return;
  35.     }
  36.  
  37.     printf("%d Newsgroups in form \"group high low y/n/m\".\r\n",
  38.         OK_GROUPS);
  39.  
  40.     while (fgets(line, sizeof(line), active_fp) != NULL) {
  41.         if ((cp = index(line, '\n')) != NULL)
  42.             *cp = '\0';
  43.         if (ngpermcount)
  44.             if (ngmatch(s1strneql, ALLBUT,
  45.                 ngpermlist, ngpermcount,
  46.                 grparray, 1) == 0)
  47.                 continue;
  48.         putline(line);
  49.     }
  50.     (void) fclose(active_fp);
  51.  
  52.     putline(".");
  53.     (void) fflush(stdout);
  54. }
  55.