1: #include    "parms.h"
   2: #include    "structs.h"
   3: 
   4: #ifdef  RCSIDENT
   5: static char rcsid[] = "$Header: index.c,v 1.8 87/07/01 13:47:37 paul Exp $";
   6: #endif	RCSIDENT
   7: 
   8: /*
   9:  * INPUT KEY PROCESSING FOR INDEX PHASE
  10:  *
  11:  *	Process all keystrokes while the index page is on the screen.
  12:  *	invokes director options also (if user qualified)
  13:  *	Returns: >=0 read note with that number ( 0 is policy)
  14:  *		 -1	reprint the index page
  15:  *		 -2	leave notefiles, update sequencer time
  16:  *		 -3	leave notefile, dont update sequencer
  17:  *		 -4	Universal leave notefiles
  18:  *			(-2 and -3 leave single notefile, -4 leaves
  19:  *			entire package, aborting rest of notefiles.
  20:  *
  21:  *	Original Coding:	Rob Kolstad	Winter 1980
  22:  *	modifications:		Ray Essick	December 1981
  23:  *	added MODERATED code:	Rich $alz	August 1985
  24:  *	added LOCAL flag:	Rich $alz	August 1985
  25:  */
  26: 
  27: static char YES[] = "YES";
  28: static char NO[] = "NO ";
  29: #define YorN(c)     ((c) != 0 ? YES : NO)
  30: 
  31: indx (io, firstdis, lastdis, respnum)
  32: struct io_f *io;
  33: int    *firstdis,
  34:        *lastdis,
  35:        *respnum;
  36: {
  37:     struct io_f io2;                    /* for nested notefiles */
  38:     char    nfname[WDLEN + 1];              /* for nested nfs */
  39:     int     num;                    /* note number */
  40:     int     i;
  41:     int     c;
  42:     int     znote,
  43:             zresp;                  /* for asearch */
  44: 
  45:     *respnum = 0;                   /* init response */
  46:     while (1)
  47:     {
  48:     at (-1, 1);
  49: #ifdef  PROMPT
  50:     printf (PROMPT);                /* issue a prompt */
  51: #endif
  52:     c = gchar ();
  53:     printf ("\10 \10");             /* erase the key */
  54:     switch (c)                  /* what to do? */
  55:     {
  56:         case '?':
  57:         case 'h':
  58:         help (INDXHLP);             /* put the help on screen */
  59:         return (-1);                /* back and display the index */
  60: 
  61:         case 'r':                   /* replot the index page */
  62:         case '\f':                  /* everyone else uses ^L, might as well */
  63:         return (-1);
  64: 
  65:         case 'W':                   /* this too shall write a note */
  66:         case 'w':                   /* write a note */
  67:         if ( ! (io -> descr.d_stat & MODERATED ) )
  68:             return addnote (io, NULL, "Edit Note text:", "Note Title: ", NULL, EDIT);
  69:         if (askyn ("Moderated; send mail to moderator? ") == 'y')
  70:             mailit(io, (struct daddr_f *)0, (struct auth_f *)0,
  71:             (struct when_f *)0, (char *)0, MODERATED, 0);
  72:         return (-1);
  73: 
  74: 
  75:         case 'B':                   /* bitch, bitch, bitch */
  76:         if (init (&io2, GRIPES) < 0)        /* no gripe file */
  77:         {
  78:             at (0, 1);
  79:             printf ("Gripe file not available");
  80:         }
  81:         else
  82:         {
  83:             addnote (&io2, NULL, "Edit Gripe text:", "Gripe Header: ", NULL, EDIT);
  84:                             /* let him put the note in */
  85:             finish (&io2);          /* close up the gripe file */
  86:         }
  87:         return (-1);                /* replot */
  88: 
  89:         case '-':                   /* back up a little */
  90:         case '\b':                  /* add backspace also */
  91:         *firstdis -= Nindex - 1;
  92:         return (-1);
  93: 
  94:         case '=':                   /* back up a lot */
  95:         *firstdis = 1;
  96:         return (-1);
  97: 
  98:         case '+':
  99:         case '\r':
 100:         case '\n':
 101:         case ' ':
 102:         if (*lastdis < io -> descr.d_nnote)
 103:         {
 104:             *firstdis = *lastdis;
 105:             return (-1);
 106:         }
 107:         break;                  /* keep doing what we were */
 108: 
 109:         case '*':                   /* skip to last page */
 110:         if (*lastdis < io -> descr.d_nnote)
 111:         {
 112:             *firstdis = io -> descr.d_nnote - Nindex + 1;
 113:             return (-1);
 114:         }
 115:         break;                  /* already at end */
 116: 
 117:         case 'q':
 118: #ifdef  K_KEY
 119:         case 'k':                   /* can use right hand */
 120: #endif	K_KEY
 121:         return QUITSEQ;
 122: 
 123:         case '\04':                 /* ^D */
 124:         return QUITFAST;            /* total exit */
 125: 
 126:         case 'z':                   /* ^D w/sequencer update */
 127:         return QUITUPD;             /* total exit w/update */
 128: 
 129:         case 'Q':                   /* exit without update of sequencer */
 130: #ifdef  K_KEY
 131:         case 'K':                   /* so can use just right hand */
 132: #endif	K_KEY
 133:         return QUITNOSEQ;
 134: 
 135:         case 'N':                   /* go to an archive */
 136:         sprintf (nfname, "%s/%s", ARCHDIR, io -> nf);/* build dest */
 137:         goto donest;                /* share common code */
 138: 
 139: 
 140: 
 141:         case 'n':                   /* nest notesfiles - a stack */
 142:         at (-1, 10);
 143:         printf ("New notesfile: ");
 144:         printf ("               \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
 145:         if (gline (nfname, WDLEN) == 1)
 146:             return (-1);            /* forget it, replot */
 147:     donest:                     /* used by N */
 148:         closenf (io);               /* save fids */
 149:         if ((i = control (nfname, NOSEQ)) == -1)/* do the other */
 150:             sleep (1);              /* some error there */
 151:         if (opennf (io, 0) < 0)
 152:         {
 153:             at (0, 1);
 154:             printf ("Couldn't reopen notesfile %s", io -> fullname);
 155:             fflush (stdout);
 156:             sleep (2);
 157:             return QUITNOSEQ;           /* don't update */
 158:         }
 159:         if (i == QUITFAST)          /* he in a hurry? */
 160:             return QUITFAST;            /* oblige him */
 161:         return (-1);                /* redisplay index */
 162: 
 163:         case 'p':                   /* to read note 0 */
 164:         if (io -> descr.d_plcy)
 165:             return 0;
 166:         else
 167:         {
 168:             at (0, PROMPTMSGX);
 169:             printf ("There is no policy note");
 170:             continue;               /* grab another key */
 171:         }
 172: 
 173: 
 174: 
 175:         case 'd':                   /* to director options */
 176:         if (allow (io, DRCTOK))
 177:             return direct (io);         /* perform those babies */
 178:         else
 179:         {
 180:             at (0, PROMPTMSGX);
 181:             printf (
 182:          "Anonymous: %s   Networked: %s   Moderated: %s   Local: %s",
 183:                 YorN (io -> descr.d_stat & ANONOK),
 184:                 YorN (io -> descr.d_stat & NETWRKD),
 185:                 YorN (io -> descr.d_stat & MODERATED),
 186:                 YorN (io -> descr.d_stat & LOCAL));
 187: 
 188:             continue;
 189:         }
 190: 
 191:         case 'x':
 192:         case 'X':
 193:         i = tsearch (io, *lastdis, c == 'x');   /* assume lies before here */
 194:         if (i > 0)
 195:             return i;               /* return that one */
 196:         continue;               /* otherwise get another key */
 197: 
 198:         case 'a':
 199:         case 'A':                   /* author search from current spot */
 200:         znote = *lastdis;
 201:         zresp = 0;              /* start at the correct place */
 202:         i = asearch (io, &znote, &zresp, (c == 'a'));
 203:                             /* look */
 204:         if (i > 0)
 205:         {
 206:             *respnum = zresp;           /* return correct value */
 207:             return znote;           /* and such */
 208:         }
 209:         continue;               /* get another command */
 210: 
 211:         case '1':
 212:         case '2':
 213:         case '3':
 214:         case '4':
 215:         case '5':
 216:         case '6':
 217:         case '7':
 218:         case '8':
 219:         case '9':
 220:         at (-1, 1);
 221:         printf ("Read note > ");
 222:         if ((num = getnum (c)) == 0)
 223:         {
 224:             at (-1, 3);
 225:             printf ("                      ");
 226:             continue;
 227:         }
 228: 
 229:         return num;
 230: 
 231:         case 'j':
 232:         case 'J':                   /* goto first unread article */
 233:         return (nxtnote (io, 0, &io -> stime));
 234: 
 235:         case 'l':                   /* leave if no new */
 236:         case 'L':
 237:         if ((i = nxtnote (io, 0, &io -> stime)) < 0)
 238:             return QUITSEQ;         /* nope, leave */
 239:         else
 240:             return (i);             /* go there */
 241: 
 242:         case 'o':                   /* modify sequencer time */
 243:         gdate (&io -> stime);           /* let him hack on the time */
 244:         continue;               /* and go back */
 245: 
 246:         case 'O':                   /* set it for today's notes */
 247:         gettime (&io -> stime);         /* grab current date */
 248:         io -> stime.w_hours = 0;        /* beginning of day */
 249:         io -> stime.w_mins = 0;
 250:         io -> stime.w_gmttime = 0;      /* use formatted */
 251:         at (0, PROMPTMSGX);         /* tell him what we did */
 252:         printf ("Set to read notes since: ");
 253:         prdate (&io -> stime);
 254:         continue;               /* and get the next command */
 255: 
 256: 
 257:         case '!':
 258:         gshell ();              /* give him a shell in right directory */
 259:         return (-1);
 260: 
 261:         default:
 262:         at (0, 5);
 263:         printf ("\07     type ? for help, q to quit     ");
 264:         continue;
 265:     }
 266: 
 267: 
 268: /* end main index page code */
 269:     }
 270: }

Defined functions

indx defined in line 31; used 1 times

Defined variables

NO defined in line 28; used 1 times
  • in line 29
YES defined in line 27; used 1 times
  • in line 29
rcsid defined in line 5; never used

Defined macros

YorN defined in line 29; used 4 times
Last modified: 1987-07-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2898
Valid CSS Valid XHTML 1.0 Strict