1: #define MAINLINE
   2: #include "parms.h"
   3: #include "structs.h"
   4: 
   5: #ifdef  RCSIDENT
   6: static char rcsid[] = "$Header: nfpipe.c,v 1.7.0.1 85/10/06 01:41:35 notes Rel $";
   7: #endif	RCSIDENT
   8: 
   9: /*
  10:  *	nfpipe - allow a user to put this at the end of a pipe
  11:  *	to catch everything that comes at it. The program
  12:  *	merely checks arguement 1 for the name of the notefile,
  13:  *	verifys write permission (exiting if none) and then
  14:  *	places the note into the notefile.
  15:  *	the second arguement is the title to be of the note.
  16:  *	THis can be null in which case the mult routine will insert
  17:  *	a title consisting of the first TITLEN characters or
  18:  *	or so of the note text.
  19:  *
  20:  *	Original coding:	Ray Essick 	January 1982
  21:  */
  22: 
  23: 
  24: main (argc, argv)
  25: char  **argv;
  26: {
  27:     struct io_f io;
  28:     struct note_f   note;
  29:     struct daddr_f  where;
  30:     struct auth_f   auth;
  31:     struct id_f unique;
  32:     char   *nfname,
  33:            *ntitle;
  34:     int     stat,
  35:             anon,
  36:             i;
  37:     char    title[TITLEN];              /* title */
  38: 
  39:     startup (argc, argv);               /* common initialization */
  40: 
  41:     if (argc == 1)                  /* not even a notefile - bad */
  42:     {
  43: 
  44:     printf ("Usage: %s notefile [-t title] [-d] [-a]\n", argv[0]);
  45: 
  46:     exit (BAD);
  47:     }
  48:     stat = anon = 0;                    /* set up flags and such */
  49:     ntitle = NULL;                  /* empty title */
  50:     unique.uniqid = 0;                  /* make mult do assignment */
  51:     for (i = 1; i < argc; i++)
  52:     if (argv[i][0] != '-')
  53:         nfname = argv[i];               /* point notefile name */
  54:     else
  55:         switch (argv[i][1])
  56:         {
  57:         case 'd':
  58:             stat = DIRMES;          /* enable director message */
  59:             break;
  60: 
  61:         case 't':               /* this one is the title */
  62:             ntitle = argv[++i];         /* grab title */
  63:             break;
  64: 
  65: 
  66:         case 'a':
  67:             anon = 1;
  68:             break;
  69: 
  70:         default:
  71:             printf ("Bad switch: %c\n", argv[i][1]);
  72:             exit (BAD);
  73:         }
  74: 
  75:     if (init (&io, nfname) < 0)
  76:     exit (NONF);                    /* no notefile - leave quickly */
  77: 
  78:     if (allow (&io, WRITOK) == 0)
  79:     {
  80:     printf ("You haven't write permission\n ");
  81:     finish (&io);
  82:     exit (BAD);
  83:     }
  84: 
  85:     if (globuid == Anonuid)
  86:     {
  87:     printf ("You have the wrong uid (%d) for notefiles, talk to the system manager\n",
  88:         globuid);
  89:     finish (&io);
  90:     exit (BAD);
  91:     }
  92: 
  93: #ifndef WRITEARCH                   /* allowing writes */
  94:     if ((io.descr.d_stat & ISARCH) && !allow (&io, DRCTOK))
  95:     {
  96:     at (0, 10);
  97:     printf ("Sorry, you can not write in an archive");
  98:     fflush (stdout);
  99:     exit (BAD);
 100:     }
 101: #endif	WRITEARCH
 102: 
 103:     if (allow (&io, DRCTOK) == 0)
 104:     stat &= NOT DIRMES;
 105:     if ((io.descr.d_stat & ANONOK) == 0)
 106:     anon = 0;
 107: 
 108:     getname (&auth, anon);              /* grab name */
 109: 
 110:     gettime (&note.n_date);
 111:     if (ntitle == NULL)                 /* no title given */
 112:     ntitle = "Through nfpipe";
 113:     else
 114:     strclean (ntitle);              /* zap control chars */
 115: 
 116:     for (i = 0; i < TITLEN; i++)
 117:     if ((title[i] = *ntitle++) == '\0')     /* want assignment */
 118:         break;
 119:     title[TITLEN - 1] = '\0';               /* sure it stops */
 120:     pagein (&io, stdin, &where);            /* put it in there */
 121:     putnote (&io, &where, title, stat, &note, &auth, NOPOLICY, LOCKIT, COPYID, System, 1);
 122:     finish (&io);                   /* close shop */
 123:     exit (GOOD);
 124: }

Defined functions

main defined in line 24; never used

Defined variables

rcsid defined in line 6; never used

Defined macros

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