1: #include "parms.h"
   2: #include "structs.h"
   3: 
   4: #ifdef  RCSIDENT
   5: static char rcsid[] = "$Header: adnote.c,v 1.7.0.3 85/10/06 01:40:37 notes Rel $";
   6: #endif	RCSIDENT
   7: 
   8: /*
   9:  *	addnote(io, preface, pstr, tprompt, title)
  10:  *	get a note from the terminal and store it in notefile specified by
  11:  *	io. If fid >=0, then prepend text of that file (as positioned) in the
  12:  *	scratch file so the new writer can include it in his note.
  13:  *	Returns:	-1 if no write (empty note, no permissions)
  14:  *			 else the notes number in the notefile.
  15:  *
  16:  *	Originally in index.c, but moved here so other routines could use it.
  17:  *
  18:  *	modifications:	Ray Essick	December 1981
  19:  */
  20: 
  21: addnote (io, preface, pstr, tpstr, title, editflag)
  22: struct io_f *io;
  23: FILE * preface;
  24: char   *pstr;                       /* edit prompt */
  25: char   *tpstr;                      /* title prompt */
  26: char   *title;                      /* title (if specified) */
  27: int     editflag;                   /* interactive? */
  28: {
  29:     struct auth_f   auth;
  30:     struct daddr_f  where;
  31:     struct note_f   note;
  32:     char    ntitle[TITLEN + 1],
  33:             anon;
  34:     int     stat,
  35:             retcode,
  36:             i;
  37: 
  38:     getdscr (io, &io -> descr);             /* get up-to-date */
  39:     if (!allow (io, WRITOK))                /* check writability */
  40:     {
  41:     at (0, PROMPTMSGX);
  42:     printf ("Sorry, you are not allowed to write");
  43:     fflush (stdout);                /* force to tty */
  44:     sleep (2);
  45:     return (-1);
  46:     }
  47: 
  48: #ifndef WRITEARCH                   /* allowing writes */
  49:     if (io -> descr.d_stat & ISARCH && !allow (io, DRCTOK))
  50:     {
  51:     at (0, PROMPTMSGX);
  52:     printf ("Sorry, you can not write in an archive");
  53:     fflush (stdout);
  54:     sleep (2);
  55:     return (-1);
  56:     }
  57: #endif	WRITEARCH
  58:     at (0, PROMPTMSGX);
  59:     if (editflag == EDIT)
  60:     printf ("\n%s\n", pstr);            /* prompt him */
  61:     if (gettext (io, &where, preface, editflag) == 0)   /* and get the text */
  62:     {
  63:     return (-1);
  64:     }
  65:     stat = 0;
  66:     anon = 'n';
  67:     if ((editflag == EDIT) && (io -> descr.d_stat & ANONOK))
  68:     {                           /* see if wants anon */
  69:     anon = askyn ("Do you wish this to be anonymous (y/n): ");
  70:     printf ("\r                                           \r");
  71:     if (anon == 'y')                /* verify true */
  72:     {
  73:         anon = askyn ("Do you REALLY wish this to be anonymous (y/n): ");
  74:         printf ("\r                                                  \r");
  75:     }
  76:     }
  77:     if ((anon == 'n') && (io -> access == (WRITOK + RESPOK)))
  78:     {                           /* only if non-anon */
  79:     stat |= WRITONLY;
  80:     }
  81:     if (editflag && allow (io, DRCTOK))         /* director mesg */
  82:     {
  83:     if (askyn ("Director message (y/n): ") == 'y')
  84:         stat |= DIRMES;
  85:     printf ("\r                         \r");
  86:     }
  87: 
  88:     if (title == NULL)                  /* if no title specified */
  89:     while (1)
  90:     {                       /* force him to type a title */
  91:         at (0, PROMPTMSGX);
  92:         printf ("%s", tpstr);
  93:         i = gline (ntitle, TITLEN - 1);
  94:         if (i != 1)                 /* empty string */
  95:         break;
  96:     }
  97:     else                        /* he specified a title */
  98:     {
  99:     strncpy (ntitle, title, TITLEN);
 100:     ntitle[TITLEN] = '\0';              /* sure it's terminated */
 101:     }
 102:     strclean (ntitle);                  /* zap control characters */
 103:     gettime (&note.n_date);             /* get date of writing */
 104:     getname (&auth, anon == 'y');           /* get author */
 105:     locknf (io, 'n');                   /* lock up for the duration */
 106:     retcode = putnote (io, &where, ntitle, stat, &note, &auth, NOPOLICY, NOLOCKIT, COPYID, System, 1);
 107: 
 108:     unlocknf (io, 'n');                 /* all done critical */
 109:     return (retcode);
 110: }

Defined functions

Defined variables

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