# 2.11BSD#431 - /usr/src/new/nntp/server/newgroups.c

##### Functions

    newgroups         X

       1: #ifndef lint
       2: static char *sccsid = "@(#)newgroups.c	1.13	(Berkeley) 2/6/88";
       3: #endif
       4:
       5: #include "common.h"
       6: #include "time.h"
       7:
       8: /*
       9:  * NEWGROUPS date time ["GMT"] [<distributions>]
      10:  *
      11:  * Display new newsgroups since a given date and time, but only
      12:  * for those in <distributions>.
      13:  */
      14:
      15: newgroups(argc, argv)
      16:     int     argc;
      17:     char        *argv[];
      18: {
      19:     char        line[NNTP_STRLEN];
      20:     register char   *cp, *temp;
      21:     static char **dist_list = (char **) NULL;
      22:     int     distcount = 0;
      23:     int     i;
      24:     long        date;
      25:     register FILE   *date_fp;
      26:
      27:     if (argc < 3) {
      28: printf("%d Usage: NEWGROUPS yymmdd hhmmss [\"GMT\"] [<distributions>].\r\n",
      29:             ERR_CMDSYN);
      30:         (void) fflush(stdout);
      31:         return;
      32:     }
      33:
      34:     date_fp = fopen(ngdatefile, "r");
      35:     if (date_fp == NULL) {
      36: #ifdef SYSLOG
      37:         syslog(LOG_ERR, "newgroups: fopen %s: %m", ngdatefile);
      38: #endif
      39:         printf("%d Cannot open newsgroup date file.\r\n", ERR_FAULT);
      40:         (void) fflush(stdout);
      41:         return;
      42:     }
      43:
      44:     /*	    YYMMDD		    HHMMSS	*/
      45:     if (strlen(argv[1]) != 6 || strlen(argv[2]) != 6) {
      46:         printf("%d Date/time must be in form YYMMDD HHMMSS.\r\n",
      47:             ERR_CMDSYN);
      48:         (void) fflush(stdout);
      49:         (void) fclose(date_fp);
      50:         return;
      51:     }
      52:
      53:     (void) strcpy(line, argv[1]);           /* yymmdd */
      54:     (void) strcat(line, argv[2]);           /* hhmmss */
      55:
      56:     date = dtol(line);
      57:     if (date < 0) {
      58:         printf("%d Invalid date specification.\r\n", ERR_CMDSYN);
      59:         (void) fflush(stdout);
      60:         (void) fclose(date_fp);
      61:         return;
      62:     }
      63:
      64:     argc -= 3;
      65:     argv += 3;
      66:
      67:     if (argc > 0 && !strcasecmp(*argv, "GMT")) { /* We store stuff in GMT */
      68:             ++argv;         /* anyway, so this is */
      69:             --argc;         /* a "noop" */
      70:     } else                  /* But that means not GMT */
      71:         date = local_to_gmt(date);  /* is a definite "op" */
      72:
      73:     if (argc > 0) {
      74:         distcount = get_distlist(&dist_list, *argv);
      75:         if (distcount < 0) {
      76:             printf("%d Bad distribution list %s:\r\n", *argv);
      77:             (void) fflush(stdout);
      78:             (void) fclose(date_fp);
      79:             return;
      80:         }
      81:     }
      82:
      83:     printf("%d New newsgroups since %s follow.\r\n", OK_NEWGROUPS, line);
      84:
      85:     while (fgets(line, sizeof(line), date_fp) != NULL) {
      86:         if ((cp = index(line, '\n')) != NULL)
      87:             *cp = '\0';
      88:         if ((cp = index(line, ' ')) != NULL)
      89:             *cp = '\0';
      90:         if (atoi(line) < date)
      91:             break;
      92:
      93:         if (distcount == 0) {
      94:             putline(cp + 1);
      95:         } else {
      96:             temp = cp + 1;
      97:             cp = index(temp, '.');
      98:             if (cp == NULL)
      99:                 continue;
     100:             *cp = '\0';
     101:             for (i = 0; i < distcount; ++i)
     102:                 if (strcmp(temp, dist_list[i]) == 0) {
     103:                     *cp = '.';
     104:                     putline(temp);
     105:                     break;
     106:                 }
     107:         }
     108:     }
     109:     putchar('.');
     110:     putchar('\r');
     111:     putchar('\n');
     112:     (void) fflush(stdout);
     113:     (void) fclose(date_fp);
     114: }

#### Defined functions

newgroups defined in line 15; used 2 times

- in /usr/src/new/nntp/server/serve.c line 24, 39

#### Defined variables

sccsid defined in line 2; never used

Last modified: 1988-02-07 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1254 |