1: #define MAINLINE
   2: 
   3: #ifdef  RCSIDENT
   4: static char rcsid[] = "$Header: nfrcv.c,v 1.7.0.2 86/09/23 08:26:00 notes Rel $";
   5: #endif	RCSIDENT
   6: 
   7: /*
   8:  *	netrcv - load a notefile from the network
   9:  *	accepts 2 parameters (1) the source system
  10:  *			     (2) the notefile to load into
  11:  *
  12:  *	This program should be called only by the netload program
  13:  *	or a suitably informed user/wizard
  14:  *
  15:  *	Original author:	Ray Essick	december 1981
  16:  */
  17: 
  18: #include "parms.h"
  19: #include "structs.h"
  20: #include "net.h"
  21: 
  22: main (argc, argv)
  23: char  **argv;
  24: {
  25:     struct io_f io;
  26:     FILE * log,                     /* network logfile */
  27:     *fopen ();
  28:     char    fn[WDLEN];                  /* network logfile */
  29:     char    nowtime[DATELEN];
  30:     char    buf[CMDLEN];
  31:     struct when_f   atime;
  32:     int     fid;                    /* for close loop */
  33: 
  34:     setuid (geteuid ());                /* force to notes */
  35:     startup (argc, argv);               /* common init */
  36: 
  37: /*
  38:  *	make damn sure we have enough file descriptors
  39:  */
  40:     for (fid = 3; fid < 20; fid++)
  41:     close (fid);
  42: 
  43:     if (argc != 3)
  44:     {
  45:     printf ("Usage: %s notefile fromsystem\n", argv[0]);
  46:     exit (BAD);
  47:     }
  48: 
  49:     sprintf (fn, "%s/%s/%s", Mstdir, UTILITY, NETLOG);
  50:     gettime (&atime);
  51:     sprdate (&atime, nowtime);
  52: 
  53:     if (init (&io, argv[1]) < 0)
  54:     {
  55: #ifdef  AUTOCREATE                  /* if making 'em */
  56:     if (argv[1][0] == '/')              /* absolute? */
  57:     {
  58: #ifdef  NFMAINT
  59:         {
  60:         char    tbuf[128];          /* title */
  61:         sprintf (buf, "%s: non-existent notesfile from %s\nAborted by nfrcv\n",
  62:             argv[1], argv[2]);
  63:         sprintf (tbuf, "Nfrcv ignores %s", argv[1]);
  64:         nfcomment (NFMAINT, buf, tbuf, 0, 0);
  65:         }
  66: #endif	NFMAINT
  67:         printf ("Nfrcv: %s: no autocreate for absolute pathnames\n",
  68:             argv[1]);
  69:         exit (BAD);                 /* abort */
  70:     }
  71:     buildnf (argv[1], Mstdir, 0, 1, 1);     /* no anon, open, networked */
  72:     x (init (&io, argv[1]) < 0, "nfrcv: couldn't create notesfile");
  73: #ifdef  NFMAINT
  74:     {
  75:         char    tbuf[128];              /* title */
  76:         sprintf (buf, "%s: non-existent notesfile from %s created by nfrcv\n",
  77:             argv[1], argv[2]);
  78:         if (strlen (argv[1]) >= 14)
  79:         {
  80:         /*
  81: 		 * could be a truncation error; mark that in the message
  82: 		 */
  83:         sprintf (tbuf, "\n'%s' >= 14 characters long; check for abbreviations\n",
  84:             argv[1]);
  85:         strcat (buf, tbuf);
  86:         }
  87:         sprintf (tbuf, "Nfrcv creates %s", argv[1]);
  88:         nfcomment (NFMAINT, buf, tbuf, TRUE, 0);
  89:     }
  90: #endif	NFMAINT
  91: 
  92: #else                           /* just tell about it */
  93:     x ((log = fopen (fn, "a")) == NULL, "netrcv: bad log open");
  94:     sprintf (buf, "%s: Non-existent notesfile received from %s at %s\n",
  95:         argv[1], argv[2], nowtime);
  96:     fprintf (log, "%s", buf);           /* log it in the log */
  97:     x (fclose (log) == EOF, "netrcv: bad close of log file");
  98: #ifdef  NFMAINT                     /* log it in a nf also? */
  99:     nfcomment (NFMAINT, buf, "non-notesfile to nfrcv", 0, 0);
 100: #endif
 101:     exit (NONF);
 102: #endif	AUTOCREATE					/* of autocreate else clause */
 103:     }
 104: 
 105:     if ((io.descr.d_stat & NETWRKD) == 0)
 106:     {
 107:     printf ("%s is not a networked notefile on %s\n", argv[1], System);
 108:     finish (&io);
 109:     x ((log = fopen (fn, "a")) == NULL, "netrcv: bad log open");
 110:     fprintf (log, "%s: Non-networked notesfile received from %s at %s\n",
 111:         argv[1], argv[2], nowtime);
 112:     x (fclose (log) == EOF, "netrcv: bad close of log file");
 113:     exit (NONF);                    /* un-networked appears not there */
 114:     }
 115: 
 116:     loadem (&io, stdin, LOCKIT, argv[2], NODETAIL, -1);
 117: 
 118:     x ((log = fopen (fn, "a")) == NULL, "netrcv: couldnt open log file");
 119:     fprintf (log, "%s: insert (%d,%d), drop (%d,%d) from %s at %s\n",
 120:         argv[1], io.nnotrcvd, io.nrsprcvd, io.nnotdrop, io.nrspdrop,
 121:         argv[2], nowtime);
 122:     x (fclose (log) == EOF, "netrcv: bad close of log file");
 123: 
 124: #ifdef  STATS
 125:     locknf (&io, DSCRLOCK);             /* bump count of netowrk calls rcvd */
 126:     getdscr (&io, &io.descr);
 127:     io.descr.netwrkins++;               /* bump the count */
 128:     putdscr (&io, &io.descr);
 129:     unlocknf (&io, DSCRLOCK);
 130: #endif	STATS
 131: 
 132:     printf ("%s: Inserted: (%d,%d) Dropped: (%d,%d)\n",
 133:         argv[1], io.nnotrcvd, io.nrsprcvd, io.nnotdrop, io.nrspdrop);
 134: 
 135:     finish (&io);
 136:     exit (GOOD);
 137: }

Defined functions

main defined in line 22; never used

Defined variables

rcsid defined in line 4; never used

Defined macros

MAINLINE defined in line 1; never used
Last modified: 1986-09-23
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2856
Valid CSS Valid XHTML 1.0 Strict