1: #define MAINLINE
   2: 
   3: #ifdef  RCSIDENT
   4: static char rcsid[] = "$Header: nfxmit.c,v 1.7 85/01/18 15:31:53 notes Rel $";
   5: #endif	RCSIDENT
   6: 
   7: /*
   8:  *	This program (netsend) will parse off the control card a destination
   9:  *	site, an optional date for sequencing purposes, and then a list
  10:  *	of notefiles. These notefiles are then scanned to send new items
  11:  *	to the destination site. The entire arguement list is scanned once
  12:  *	to pull in the switches and then again to dump the notefiles.
  13:  *	This implies that the switches are indeed global, and that the last
  14:  *	specified ones are the ones which are used.
  15:  *
  16:  *	Original Coding:	Ray Essick	December 1981
  17:  */
  18: #include "parms.h"
  19: #include "structs.h"
  20: #include "net.h"
  21: 
  22: static int  usetime;                    /* whether overriding sequencer time */
  23: static int  sendhim;                    /* classes to send */
  24: static int  callback;                   /* whether to have remote send back */
  25: static char tosite[SYSSZ + 20];             /* with some buffer space */
  26: static char dmpfile[WDLEN];             /* a scratch file name */
  27: 
  28: xmitone (local)
  29: char   *local;
  30: {
  31:     char    cmdline[CMDLEN];                /* build your favorite command */
  32:     char    buf[CMDLEN];
  33:     char    nfname[NNLEN];              /* hold aliased nf name */
  34:     char   *xmit,
  35:            *rply;                   /* for non-standard */
  36:     int     proto;                  /* protocol to use */
  37:     int     queuestat;                  /* Return Value */
  38:     int     sendstat;                   /* nfsend status */
  39: 
  40:     getnet (tosite, &xmit, &rply, &proto);      /* see if non standard */
  41:     nfalias (local, nfname, tosite);            /* get remote file name */
  42: 
  43:     if (callback)
  44:     {
  45:     if (rply == NULL)
  46:         sprintf (cmdline, DFLTRPLY,         /* see net.h defn */
  47:             tosite, NFXMIT, nfname, System);
  48:     else
  49:         sprintf (cmdline, rply, nfname, System);    /* do his */
  50: #ifndef FASTFORK
  51:     dounix (cmdline, 0, 0);             /* do it */
  52: #else
  53:     dounix (0, 0, hisshell, "-c", cmdline, 0, 0);   /* let shell interpret */
  54: #endif	FASTFORK
  55:     }
  56: 
  57: /*
  58:  *	Now see if we have anything to send him.  We don't queue anything
  59:  *	unless we do want to send to him.
  60:  */
  61: 
  62:     if ((sendstat =                 /* WANT ASSIGN */
  63:         nfsend (tosite, local, dmpfile, usetime, sendhim, proto)) > 0)
  64:     {
  65:     if (xmit == NULL)
  66:         sprintf (cmdline, DFLTXMIT,         /* see net.h defn */
  67:             tosite, NFRCV, nfname, System, dmpfile);
  68:     else
  69:     {
  70:         sprintf (buf, xmit, nfname, System);
  71:         sprintf (cmdline, "%s < %s", buf, dmpfile); /* feed stdin to it */
  72:     }
  73: #ifndef FASTFORK
  74:     queuestat = dounix (cmdline, 0, 0);     /* do it */
  75: #else
  76:     queuestat = dounix (0, 0, hisshell, "-c", cmdline, 0, 0);
  77: #endif FASTFORK
  78:     }
  79:     else
  80:     {                           /* error or no data */
  81:     queuestat = 0;                  /* avoid random stack noise */
  82:     }
  83: 
  84: /*
  85:  *	nfsendone cleans up the sequencer entry for that notesfile.
  86:  *	And does logging information also
  87:  *	We only clean up the entry if the command was successful.
  88:  */
  89:     nfsendone (local, tosite, queuestat, sendstat);
  90: 
  91:     return (0);                     /* all is well */
  92: }
  93: 
  94: main (argc, argv)
  95: char  **argv;
  96: {
  97:     int     i;
  98:     struct nflist_f *nfptr;
  99:     char    fmtdate[DATELEN];               /* formatted date */
 100:     struct when_f   ztime;              /* hold date */
 101: 
 102:     startup (argc, argv);               /* common init */
 103: 
 104:     if (argc == 1)
 105:     {
 106:     fprintf (stderr, "Usage: %s -d<site> [-r] [-i] [-a] [-t datespec]  [-f file] nf [nf2 ..]\n", argv[0]);
 107:     exit (BAD);
 108:     }
 109:     sendhim = 0;                    /* default classes */
 110:     usetime = NORMSEQ;                  /* sequencer time */
 111:     callback = 0;                   /* no return messages */
 112:     sprintf (tosite, "*None*");             /* null site */
 113: 
 114:     for (i = 1; i < argc; i++)              /* parse options */
 115:     switch (argv[i][0])
 116:     {
 117:         case '-':                   /* some options oh goody */
 118:         switch (argv[i][1])
 119:         {
 120:             case 'd':
 121:             if (strmove (argv[i] + 2, tosite) > SYSSZ)
 122:             {
 123:                 printf ("System name: %s, too long\n", argv[i] + 2);
 124:                 exit (BAD);
 125:             }
 126:             break;              /* out of this switch statement */
 127: 
 128:             case 'r':               /* force rmt nfxmit */
 129:             callback = 1;
 130:             break;
 131: 
 132:             case 'a':               /* ok, news articles */
 133:             sendhim |= SENDNEWS;
 134:             break;
 135: 
 136:             case 'i':               /* stuff he's seen */
 137:             sendhim |= SENDHIS;
 138:             break;
 139: 
 140:             case 't':               /* explicit time */
 141:             case 'o':               /* compatibility */
 142:             if (++i == argc)
 143:             {
 144:                 fprintf (stderr, "-t option requires following date\n");
 145:                 exit (BAD);
 146:             }
 147:             switch (parsetime (argv[i], &ztime))
 148:             {
 149:                 case 0:             /* ok */
 150:                 usetime = BASESEQ;  /* use this time */
 151:                 Basetime = ztime;   /* store it */
 152:                 sprdate (&ztime, fmtdate);/* format */
 153:                 printf ("%s: Sending articles since %s\n",
 154:                     Invokedas, fmtdate);
 155:                 break;
 156:                 case -1:            /* no good */
 157:                 fprintf (stderr, "%s: unable to parse time `%s'\n",
 158:                     Invokedas, argv[i]);
 159:                 exit (BAD);
 160:                 case -2:            /* in future */
 161:                 fprintf (stderr, "%s: parsed date (%s) is in the future\n",
 162:                     Invokedas, argv[i]);
 163:                 exit (BAD);
 164:             }
 165:             break;
 166: 
 167:             case 'f':               /* next list is a file name */
 168:             if (++i == argc)        /* no filename */
 169:             {
 170:                 fprintf (stderr, "-f must be followed by filename\n");
 171:                 exit (BAD);
 172:             }
 173:             readrc (argv[i]);       /* load it */
 174:             break;
 175: 
 176:             default:
 177:             printf ("Bad switch '%c'\n", argv[i][1]);
 178:             exit (BAD);
 179:         }
 180:         break;
 181: 
 182:         default:                    /* a notefile name */
 183:         expand (argv[i]);           /* add it to the list */
 184:         break;
 185:     }
 186: 
 187:     sprintf (dmpfile, "/tmp/nfxmit%d", getpid ());
 188:     if (strcmp ("*None*", tosite) == 0)
 189:     {
 190:     printf ("Null destination - use -d flag\n");
 191:     exit (BAD);
 192:     }
 193: 
 194: /*	now that we have processed all the parameters, lets dump the
 195:  *	notes and send them to the other people.
 196:  *	This is a 2 step process. First we make a file and then
 197:  *	we 'uucp' it to the other site.
 198:  */
 199: 
 200:     while ((nfptr = nextgroup ()) != (struct nflist_f *) NULL)
 201:     xmitone (nfptr -> nf_name);         /* simple case */
 202: 
 203:     exit (GOOD);
 204: }

Defined functions

main defined in line 94; never used
xmitone defined in line 28; used 1 times

Defined variables

callback defined in line 24; used 3 times
dmpfile defined in line 26; used 4 times
rcsid defined in line 4; never used
sendhim defined in line 23; used 4 times
tosite defined in line 25; used 9 times
usetime defined in line 22; used 3 times

Defined macros

MAINLINE defined in line 1; never used
Last modified: 1985-10-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 779
Valid CSS Valid XHTML 1.0 Strict