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

Defined functions

main defined in line 101; 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: 1986-01-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 903
Valid CSS Valid XHTML 1.0 Strict