Annotation of 43BSD/contrib/notes/src/newsoutput.c, revision 1.1.1.1

1.1       root        1: #define        MAINLINE
                      2: #include "parms.h"
                      3: #include "structs.h"
                      4: #include "newsgate.h"
                      5: 
                      6: #ifdef RCSIDENT
                      7: static char rcsid[] = "$Header: newsoutput.c,v 1.7.0.1 85/03/22 10:54:22 notes Rel $";
                      8: #endif RCSIDENT
                      9: 
                     10: 
                     11: /*
                     12:  *     newsoutput - place the specified notesfiles out to the
                     13:  *     news susbsystem. 
                     14:  *
                     15:  *     Original Coding:        Ray Essick      April 1982
                     16:  *     Modified to better handle multiple system gateing
                     17:  *                             Ray Essick      September 1982
                     18:  */
                     19: 
                     20: static char *whichsys;                                 /* who dumping for */
                     21: static int  verbosity = 0;                             /* quiet */
                     22: static int  backward = 0;                              /* do old format */
                     23: char    rnewscmd[CMDLEN] = DFLTRNEWS;                  /* how to rnews */
                     24: int     sendclass = 0;                                 /* classes to send */
                     25: int     usetime = NORMSEQ;                             /* user supplied */
                     26: int     gatesyscount = 0;                              /* actives slots in */
                     27: char   *gatesysnames[GATEMAX];                         /* list of names */
                     28: 
                     29: newsone (nfname)
                     30: char   *nfname;
                     31: {
                     32:     if (verbosity)
                     33:     {
                     34:        printf ("\t%s\n", nfname);
                     35:        fflush (stdout);
                     36:     }
                     37:     return newsout (nfname, backward, usetime, verbosity);
                     38: }
                     39: 
                     40: 
                     41: main (argc, argv)
                     42: char  **argv;
                     43: {
                     44:     int     i;
                     45:     struct nflist_f *nfptr;
                     46:     char   *outgoing;
                     47:     struct when_f   ztime;
                     48:     char    fmtdate[DATELEN];                          /* formatted date */
                     49:     int     aflag,
                     50:             cflag,
                     51:             sflag;
                     52: 
                     53:     startup (argc, argv);                              /* common init */
                     54: 
                     55:     if (argc == 1)
                     56:     {
                     57:        printf ("Usage: %s [-ssitename | -a] [-v] [-b] [-f file] topic1 [topic2 ...]\n", argv[0]);
                     58:        exit (BAD);
                     59:     }
                     60: 
                     61:     if (globuid != Notesuid)
                     62:     {
                     63:        printf ("Sorry, only notes 'owner' can send notes to news\n");
                     64:        exit (BAD);
                     65:     }
                     66: 
                     67:     whichsys = System;                                 /* defaults to local */
                     68:     aflag = cflag = sflag = 0;                         /* none done */
                     69:     gatesyscount = 0;                                  /* none there */
                     70:     verbosity = 0;                                     /* no messages */
                     71:     backward = 0;                                      /* just new format */
                     72:     usetime = NORMSEQ;                                 /* non-seq time */
                     73:     strcpy (rnewscmd, DFLTRNEWS);                      /* default rnews */
                     74:     getnet (RNEWSNAME, &outgoing, NULL, NULL);         /* how to get there */
                     75:     if (outgoing != (char *) NULL)                     /* specified? */
                     76:        strcpy (rnewscmd, outgoing);                    /* load it */
                     77: 
                     78:     for (i = 1; i < argc; i++)
                     79:     {
                     80:        if (argv[i][0] == '-')
                     81:            switch (argv[i][1])
                     82:            {
                     83: 
                     84:                case 's':                               /* gateway for */
                     85:                    sflag = 1;
                     86:                    if (argv[i][2] != '\0')             /* -ssite */
                     87:                    {
                     88:                        whichsys = &argv[i][2];
                     89:                    }
                     90:                    else
                     91:                    {                                   /* -s sitename */
                     92:                        if (++i == argc)                /* no sitename */
                     93:                        {
                     94:                            fprintf (stderr, "-s must be followed by a sitename\n");
                     95:                            exit (BAD);
                     96:                        }
                     97:                        whichsys = argv[i];             /* mark site */
                     98:                    }
                     99:                    gatesyscount = 1;                   /* fill in table */
                    100:                    gatesysnames[0] = whichsys;
                    101:                    break;
                    102: 
                    103:                case 'a':                               /* all non-local */
                    104:                    sendclass |= NEWS_ALLSEND;
                    105:                    aflag = 1;
                    106:                    whichsys = NEWSSYS;                 /* it's sequencer */
                    107:                    break;
                    108: 
                    109:                case 'c':                               /* file of systems */
                    110:                    cflag = 1;
                    111:                    whichsys = NEWSSYS;                 /* use the global seq */
                    112:                    if (++i == argc)
                    113:                    {
                    114:                        printf ("%s: -c option must be followed by filename\n", Invokedas);
                    115:                        exit (BAD);
                    116:                    }
                    117:                    loadgate (argv[i]);                 /* load the table */
                    118:                    break;
                    119: 
                    120:                case 'v':                               /* messages per group */
                    121:                    verbosity++;
                    122:                    break;
                    123: 
                    124:                case 'f':                               /* process a file */
                    125:                    if (++i == argc)                    /* no filename */
                    126:                    {
                    127:                        fprintf (stderr, "-f must be followed by a filename\n");
                    128:                        exit (BAD);
                    129:                    }
                    130:                    readrc (argv[i]);                   /* read the file */
                    131:                    break;
                    132: 
                    133:                case 'b':                               /* include old headers */
                    134:                    backward++;
                    135:                    break;
                    136: 
                    137:                case 't':                               /* explicit time */
                    138:                case 'o':                               /* compatibility */
                    139:                    if (++i == argc)
                    140:                    {
                    141:                        fprintf (stderr, "-t option requires following date\n");
                    142:                        exit (BAD);
                    143:                    }
                    144:                    switch (parsetime (argv[i], &ztime))
                    145:                    {
                    146:                        case 0:                         /* ok */
                    147:                            usetime = BASESEQ;          /* use this time */
                    148:                            Basetime = ztime;           /* store it */
                    149:                            sprdate (&ztime, fmtdate);  /* format */
                    150:                            printf ("%s: Sending articles since %s\n",
                    151:                                    Invokedas, fmtdate);
                    152:                            break;
                    153:                        case -1:                        /* no good */
                    154:                            fprintf (stderr, "%s: unable to parse time `%s'\n",
                    155:                                    Invokedas, argv[i]);
                    156:                            exit (BAD);
                    157:                        case -2:                        /* in future */
                    158:                            fprintf (stderr, "%s: parsed date (%s) is in the future\n",
                    159:                                    Invokedas, argv[i]);
                    160:                            exit (BAD);
                    161:                    }
                    162:                    break;
                    163: 
                    164: 
                    165:                default: 
                    166:                    printf ("Bad switch: %c\n", argv[i][1]);
                    167:                    exit (BAD);
                    168:            }
                    169:        else
                    170:            expand (argv[i]);                           /* put it in the list */
                    171:     }
                    172: 
                    173: /*
                    174:  *     now, run down the list and send each notesfile.
                    175:  *     check to make sure some things are used consistently first.
                    176:  */
                    177: 
                    178:     if (aflag + cflag + sflag > 1)
                    179:     {                                                  /* -a and -s */
                    180:        fprintf (stderr, "%s: -a, -c and -s mutually exclusive\n", Invokedas);
                    181:        exit (BAD);
                    182:     }
                    183:     if (gatesyscount == 0 && !cflag)                   /* default to local */
                    184:     {
                    185:        /* 
                    186:         * check against cflag allows empty -c files to "work"
                    187:         */
                    188:        gatesysnames[0] = whichsys;
                    189:        gatesyscount = 1;                               /* just us */
                    190:     }
                    191:     if (1)                                             /* was verbosity */
                    192:     {                                                  /* now always... */
                    193:        printf ("%s: Sending news articles through command: %s\n",
                    194:                Invokedas, rnewscmd);
                    195:        if (sendclass & NEWS_ALLSEND)
                    196:        {
                    197:            printf ("Sending to News for any system\n");
                    198:        }
                    199:        else
                    200:        {
                    201:            int     col;                                /* count columns */
                    202: 
                    203:            /* 
                    204:             * WE WANT TO SORT THE LIST AT THIS POINT
                    205:             * so that the cansend() routine in newsout.c can do a binary
                    206:             * search to make things faster.
                    207:             */
                    208:            printf ("Gateway for the following %d system(s):\n", gatesyscount);
                    209:            for (i = 0, col = 0; i < gatesyscount; i++)
                    210:            {
                    211:                printf (" %16s", gatesysnames[i]);
                    212:                if (++col % 4 == 0)
                    213:                    putc ('\n', stdout);                /* multi-column */
                    214:            }
                    215:        }
                    216:        printf ("\n================\n");
                    217:     }
                    218:     fflush (stdout);                                   /* make sure in order */
                    219:     sprintf (Seqname, "%s:%s", NEWSSEQ, whichsys);
                    220:     while ((nfptr = nextgroup ()) != (struct nflist_f *) NULL)
                    221:        newsone (nfptr -> nf_name);
                    222: 
                    223:     exit (GOOD);                                       /* all done */
                    224: }
                    225: 
                    226: /*
                    227:  *     loadgate(filename)
                    228:  *
                    229:  *     fill in the system table.
                    230:  */
                    231: 
                    232: loadgate (filename)
                    233: char   *filename;
                    234: {
                    235:     FILE * fptr;
                    236:     char    onesystem[256];                            /* system name */
                    237: 
                    238:     if ((fptr = fopen (filename, "r")) == (FILE *) NULL)
                    239:        return (-1);                                    /* bah humbug */
                    240: 
                    241:     while (fscanf (fptr, "%s", onesystem) == 1)
                    242:     {
                    243:        gatesysnames[gatesyscount++] = strsave (onesystem);
                    244:     }
                    245: 
                    246:     fclose (onesystem);
                    247:     return (0);
                    248: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.