1: #include    "parms.h"
   2: #include    "structs.h"
   3: 
   4: #ifdef  FASTSEQ
   5: #include    <sys/types.h>
   6: #include    <sys/stat.h>
   7: #endif	FASTSEQ
   8: 
   9: #ifdef  RCSIDENT
  10: static char rcsid[] = "$Header: control.c,v 1.7 85/01/18 15:07:18 notes Rel $";
  11: #endif	RCSIDENT
  12: 
  13: /*
  14:  *	Code in this module ( control.c) is designed to process
  15:  *	a single notefile. Its paramters include the name of
  16:  *	the notefile to process and whether to use the sequencer.
  17:  *
  18:  *	Original author: Rob Kolstad	Winter, 1980.
  19:  *	Modifications:	Ray Essick	December, 1981.
  20:  *
  21:  */
  22: 
  23: 
  24: control (nfname, seqon)
  25: char   *nfname;
  26: {
  27:     struct io_f io;
  28:     struct note_f   note;
  29:     struct when_f   entered;                /* entry time */
  30: 
  31:     int     firstdis,
  32:             lastdis;                    /* display counters */
  33:     int     readnum;                    /* start reading */
  34:     int     respnum;                    /* response to be on */
  35:                             /* currently 0 always */
  36: 
  37:     if (nfname == NULL || nfname[0] == '\0')        /* a name? */
  38:     return (-1);                    /* silly boy */
  39: 
  40:     if (intflag)                    /* did he hit DEL? */
  41:     return (QUITFAST);              /* prejudiced quit */
  42: 
  43: #ifdef  FASTSEQ
  44:     if (seqon != NOSEQ && seqon != EXTSEQ)      /* if sequencing */
  45:     {
  46:     struct when_f   whenvec;
  47:     char    NoteFile[WDLEN];
  48:     struct stat StatBuf;
  49: 
  50:     if (nfname[0] == '/')               /* absolute pathname */
  51:     {
  52:         getlast (&io.stime, rindex (nfname, '/') + 1, seqon, Seqname);
  53:         sprintf (NoteFile, "%s/%s", nfname, TEXT);
  54:     }
  55:     else                        /* relative to Mstdir */
  56:     {
  57:         getlast (&io.stime, nfname, seqon, Seqname);
  58:         sprintf (NoteFile, "%s/%s/%s", Mstdir, nfname, TEXT);
  59:     }
  60:     if (stat (NoteFile, &StatBuf) >= 0)
  61:     {
  62:         maketime (&whenvec, (long) StatBuf.st_mtime);
  63:         if (inorder (&whenvec, &io.stime))
  64:         {
  65:         putchar ('\r');             /* from Brian Redman */
  66:         ceol ();                /* ... harpo!ber */
  67:         printf ("%s...", nfname);
  68:         fflush (stdout);
  69:         return (0);
  70:         }
  71:     }
  72:     }
  73: #endif	FASTSEQ
  74: 
  75:     gettime (&entered);                 /* get the entry time */
  76:     if (init (&io, nfname) < 0)
  77:     {
  78:     fflush (stdout);                /* get it out */
  79:     sleep (1);                  /* let him read it */
  80:     return (-1);
  81:     }
  82:     if (allow (&io, READOK) == 0)
  83:     {
  84:     if (seqon == NOSEQ)             /* skip if sequencing */
  85:     {
  86:         printf ("You aren't allowed to read %s\n", io.fullname);
  87:         if (io.descr.d_plcy)
  88:         {
  89:         if (askyn ("Do you wish to see the policy note (y/n)? ") == 'y')
  90:         {
  91:             getnrec (&io, 0, &note);        /* show the policy */
  92:             dspnote (&io, &note, 0);
  93:         }
  94:         }
  95:         else
  96:         {
  97:         printf ("There is no policy note");
  98:         }
  99:         if (allow (&io, WRITOK))
 100:         {
 101:         printf ("\nYou may leave a note in the notefile\n");
 102:         if (askyn ("Do you wish to leave a note (y/n) ?") == 'y')
 103:         {
 104:             if (addnote (&io, NULL, "Edit Note Text:", "Note title: ", NULL, EDIT) != -1)
 105:             printf ("Your note has been registered\n");
 106:         }
 107:         }
 108:         else
 109:         {
 110:         printf ("\nHit any key to continue");
 111:         gchar ();               /* grab and drop it */
 112:         sleep (2);              /* let him read it */
 113:         }
 114:     }
 115:     finish (&io);
 116:     return (-1);
 117:     }
 118: 
 119:     if ((io.descr.d_stat & OPEN) == 0)
 120:     {
 121:     printf ("Notefile %s is closed\n", nfname);
 122:     fflush (stdout);
 123:     sleep (1);
 124:     }
 125: 
 126:     if (io.descr.d_stat & OPEN || allow (&io, DRCTOK))
 127:     {
 128:     getlast (&io.stime, io.nf, seqon, Seqname); /* last time here */
 129:     firstdis = io.descr.d_nnote - Nindex + 1;
 130:     respnum = 0;                    /* go to base note */
 131: 
 132:     if (inorder (&io.descr.d_lastm, &io.stime) &&
 133:         (seqon != EXTSEQ))          /* always enter mode */
 134: /*	    if sequencer is off, stime is jan 1 1970, so will enter notefile */
 135:     {
 136:         putchar ('\r');             /* from Brian Redman */
 137:         ceol ();                    /* ... harpo!ber */
 138:         printf ("%s...", nfname);
 139:         fflush (stdout);                /* force it out */
 140: #ifdef  FASTSEQ
 141: /*
 142:  *	Update his timestamp here so that he will fall through the
 143:  *	fast processing loop next time. Thanks to Rob Kolstad for
 144:  *	thinking this through.
 145:  */
 146:         fixlast (&entered, io.nf, seqon, Seqname);
 147: #endif	FASTSEQ
 148:         closenf (&io);              /* close nicely */
 149:         return 0;                   /* "normal" quit */
 150:     }
 151:     else                        /* enter the notesfile */
 152:     {
 153:         if (seqon != INDXSEQ && seqon != NOSEQ) /* if to note */
 154:         {
 155:         if ((readnum = nxtnote (&io, 0, &io.stime)) > 0)
 156:             goto seqenter;
 157:         }                       /* else to index */
 158:         while (1)
 159:         {
 160:         prntind (&io, &firstdis, &lastdis);
 161:         if ((readnum = indx (&io, &firstdis, &lastdis, &respnum)) == -1)
 162:             continue;
 163:         if (readnum < -1)
 164:             break;
 165: 
 166:     seqenter:                   /* entry point if sequencer on */
 167:         readnum = readem (&io, readnum, &firstdis, respnum);
 168:         if (readnum < -1)
 169:             break;
 170:         }
 171:         if (readnum == QUITSEQ || readnum == QUITUPD)/* fix his timestamp */
 172:         fixlast (&entered, io.nf, seqon, Seqname);
 173:         intflag = 0;                /* clean for next */
 174:     }
 175: 
 176:     }
 177:     finish (&io);
 178: 
 179:     return readnum;                 /* supplied value */
 180: }

Defined functions

Defined variables

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