1: #include "parms.h"
   2: #include "structs.h"
   3: 
   4: #ifdef  RCSIDENT
   5: static char rcsid[] = "$Header: dropt.c,v 1.9 88/02/10 11:00:14 root Exp $";
   6: #endif	RCSIDENT
   7: 
   8: #define BUFSZ   128
   9: 
  10: /*
  11:  *	this file processes the director options.
  12:  *
  13:  *	call: contains the io pointer to the file.
  14:  *
  15:  *	allows continued access only if the user if a director.
  16:  *
  17:  *	the functions of the director options includes:
  18:  *	1) granting/denial of director priviledges
  19:  *	2) granting/denial of regular access priviledges
  20:  *	3) changing the director message
  21:  *	4) writing a policy note
  22:  *
  23:  *	Returns: -1 normally
  24:  *		 -4 if the user hit cntrl d ( to total exit)
  25:  *
  26:  *	original author/outliner : Ray Essick may 29, 1981
  27:  *      added the "moderated" flag:Rich $alz  aug 19, 1985
  28:  *      added "local" flag, toggle, YorN:    Rich $alz  aug 19, 1985
  29:  *
  30:  */
  31: 
  32: static int  anonrow,                    /* allow anon */
  33:             openrow,                    /* is open */
  34:             archrow,                    /* is archive */
  35:             keeprow,                    /* expire action */
  36:             dirmsgrow,                  /* expire w/dirmsg */
  37:             netrow,                 /* networked */
  38:             expirerow,                  /* expire age */
  39:             longrow,                    /* longest ok text */
  40:             worksetrow,                 /* working set */
  41:         modrow,                 /* moderated flag */
  42:         localrow;                   /* local flag */
  43: static int  lastrow;
  44: 
  45: #define YorN(c)     ((c) != 0 ? YES : NO)
  46: static char YES[] = "YES";
  47: static char NO[] = "NO ";
  48: 
  49: direct (io) struct io_f *io;
  50: {
  51:     int     i;                      /* scratch */
  52:     int     c;
  53:     long    expires;
  54:     long    workset;
  55:     long    textlength;                 /* scratch */
  56:     char    title[DMLEN + 1];               /* hold new director message */
  57:     char    ntitle[NNLEN + 1];              /* hold note file title */
  58:     struct note_f   note;
  59:     struct auth_f   auth;               /* author of policy note */
  60:     struct daddr_f  where;
  61:     char   *r,
  62:             buff[BUFSZ + 1];
  63:     int     buffptr;
  64:     int     start,
  65:             end,
  66:             nnotes,
  67:             nresps;
  68:     int     redraw;                 /* paint screen */
  69: 
  70:     if (allow (io, DRCTOK) == 0)
  71:     {
  72:     at (0, PROMPTMSGX);
  73:     printf ("Sorry, you are not a director");
  74:     fflush (stdout);
  75:     sleep (2);
  76:     return (-1);
  77:     }
  78: 
  79:     redraw = 1;
  80:     while (1)
  81:     {
  82:     if (redraw)
  83:         dirplot (io);
  84: getkey:                         /* suck in a key */
  85:     at (-1, 1);
  86:     printf ("Option:  \010");
  87:     c = gchar ();                   /* get command */
  88:     printf ("\010 ");               /* overwrite the character */
  89:     redraw = 0;                 /* draw if want it */
  90:     switch (c)
  91:     {
  92:         case '?':
  93:         case 'h':
  94:         help (DIRHLP);
  95:         redraw++;
  96:         break;
  97: 
  98:         case 'r':                   /* replot the screen */
  99:         case '\f':                  /* control-L also */
 100:         redraw++;
 101:         break;
 102: 
 103: #ifdef  K_KEY
 104:         case 'k':                   /* same as q */
 105: #endif	K_KEY
 106:         case 'q':                   /* leave */
 107:         return (-1);
 108: 
 109:         case '\004':
 110:         return QUITFAST;            /* Universal exit */
 111: 
 112:         case '!':                   /* give him a shell */
 113:         gshell ();
 114:         redraw++;
 115:         break;
 116: 
 117:         case 'p':                   /* run access lists */
 118:         if (accessedit (io) == QUITFAST)
 119:             return QUITFAST;            /* doit */
 120:         redraw++;
 121:         break;                  /* skipt out of the loop */
 122: 
 123:         case 'a':                   /* toggle anonymous option */
 124:         toggle(io, ANONOK, anonrow);
 125:         break;
 126: 
 127:         case 'A':                   /* Archive option */
 128:         toggle(io, ISARCH, archrow);
 129:         break;
 130: 
 131:         case 'l':                   /* message length */
 132:         while (1)
 133:         {
 134:             at (lastrow, 10);
 135:             printf ("New Maximum Message Size: ");
 136:             ceol ();                /* clear to eol */
 137:             if (gline (buff, BUFSZ) == 1)   /* empty line */
 138:             {
 139:             at (lastrow + 1, 10);
 140:             printf ("Maximum Message Size Unchanged");
 141:             goto getkey;
 142:             }
 143:             if (sscanf (buff, "%ld", &textlength) == 1)
 144:             {
 145:             if (textlength <= HARDMAX)  /* too big? */
 146:                 break;
 147:             else
 148:             {
 149:                 at (lastrow + 1, 10);
 150:                 printf ("Maximum Allowed is %d", HARDMAX);
 151:                 continue;
 152:             }
 153:             }
 154:             at (lastrow + 1, 10);
 155:             printf ("Enter an integer or <return>");
 156:         }
 157:         locknf (io, DSCRLOCK);          /* CRITICAL SECTION */
 158:         getdscr (io, &io -> descr);     /* update descriptor */
 159:         io -> descr.d_longnote = textlength;    /* new value */
 160:         putdscr (io, &io -> descr);
 161:         unlocknf (io, DSCRLOCK);        /* all done ... */
 162:         at (longrow, 27);
 163:         printf ("%ld bytes   ", io -> descr.d_longnote);
 164:         break;
 165: 
 166:         case 'c':                   /* compress the notefile */
 167:         if (io -> descr.d_stat & OPEN)
 168:         {
 169:             at (lastrow, 10);
 170:             printf ("Notefile must be closed to compress");
 171:             break;
 172:         }
 173:         else
 174:         {
 175:             at (lastrow, 10);
 176:             if (askyn ("Really Compress? (y/n) ") != 'y')
 177:             {
 178:             at (lastrow + 1, 10);
 179:             printf ("Compress not done");
 180:             break;
 181:             }
 182:             at (lastrow + 1, 1);
 183:             printf ("Compressing ");
 184:             if (compress (io, LOCKIT, 1, &nnotes, &nresps) >= 0)
 185:             {
 186:             dirplot (io);           /* show it */
 187:             at (-3, 1);
 188:             printf ("Compress left %d notes and %d responses",
 189:                 nnotes, nresps);
 190:             }
 191:             else
 192:             {
 193:             dirplot (io);           /* show page */
 194:             at (-3, 1);
 195:             printf ("Compress not done");
 196:             }
 197:             break;
 198:         }
 199:         break;
 200: 
 201:         case 'e':                   /* change expiration time */
 202:         while (1)
 203:         {
 204:             at (lastrow, 10);
 205:             printf ("New Expiration time: ");
 206:             ceol ();                /* clear to eol */
 207:             if (gline (buff, BUFSZ) == 1)   /* empty line */
 208:             {
 209:             at (lastrow + 1, 10);
 210:             printf ("Expiration Threshold Unchanged");
 211:             goto getkey;
 212:             }
 213:             if (!strcmp (buff, "Never") || !strcmp (buff, "never") ||
 214:                 !strcmp (buff, "NEVER"))
 215:             {
 216:             expires = NEVER;
 217:             break;
 218:             }
 219:             if (!strcmp (buff, "Default") || !strcmp (buff, "default") ||
 220:                 !strcmp (buff, "DEFAULT"))
 221:             {
 222:             expires = 0;
 223:             break;
 224:             }
 225:             if (sscanf (buff, "%ld", &expires) == 1)
 226:             {
 227:             break;
 228:             }
 229: 
 230:             at (lastrow + 1, 10);
 231:             printf ("Want `default', `never', or a number");
 232:             at (lastrow + 2, 10);
 233:             printf ("<return> to leave unchanged");
 234:         }
 235: 
 236:         locknf (io, DSCRLOCK);          /* critical section */
 237:         getdscr (io, &io -> descr);
 238:         io -> descr.d_archtime = expires;   /* update */
 239:         putdscr (io, &io -> descr);     /* replace */
 240:         unlocknf (io, DSCRLOCK);        /* leave critical */
 241:         at (expirerow, 27);
 242:         switch ((int) (io -> descr.d_archtime)) /* update screen */
 243:         {
 244:             case NEVER:
 245:             printf ("Never       ");
 246:             break;
 247:             case 0:
 248:             printf ("Default     ");
 249:             break;
 250:             default:
 251:             printf ("%ld days     ", io -> descr.d_archtime);
 252:             break;
 253:         }
 254:         break;
 255: 
 256:         case 'W':                   /* working Set size */
 257:         while (1)
 258:         {
 259:             at (lastrow, 10);
 260:             printf ("New Working Set Size: ");
 261:             ceol ();                /* clear to eol */
 262:             if (gline (buff, BUFSZ) == 1)   /* empty line */
 263:             {
 264:             at (lastrow + 1, 10);
 265:             printf ("Working Set Size Unchanged");
 266:             goto getkey;
 267:             }
 268:             if (!strcmp (buff, "Default") || !strcmp (buff, "default") ||
 269:                 !strcmp (buff, "DEFAULT"))
 270:             {
 271:             workset = 0;
 272:             break;
 273:             }
 274:             if (sscanf (buff, "%ld", &workset) == 1)
 275:             {
 276:             break;
 277:             }
 278: 
 279:             at (lastrow + 1, 10);
 280:             printf ("Want `default' or a number");
 281:             at (lastrow + 2, 10);
 282:             printf ("<return> to leave unchanged");
 283:         }
 284: 
 285:         locknf (io, DSCRLOCK);          /* critical section */
 286:         getdscr (io, &io -> descr);
 287:         io -> descr.d_workset = workset;    /* update */
 288:         putdscr (io, &io -> descr);     /* replace */
 289:         unlocknf (io, DSCRLOCK);        /* leave critical */
 290:         at (worksetrow, 27);
 291:         switch ((int) io -> descr.d_workset)
 292:         {
 293:             case 0:
 294:             printf ("Default      ");
 295:             break;
 296:             default:
 297:             printf ("%ld Notes    ", io -> descr.d_workset);
 298:         }
 299:         break;
 300: 
 301:         case 'E':                   /* keep/delete/default */
 302:         locknf (io, DSCRLOCK);          /* critical section */
 303:         getdscr (io, &io -> descr);
 304:         switch ((int) io -> descr.d_archkeep)   /* change it */
 305:         {
 306:             case KEEPNO:
 307:             io -> descr.d_archkeep = KEEPYES;
 308:             break;
 309:             case KEEPYES:
 310:             io -> descr.d_archkeep = KEEPDFLT;
 311:             break;
 312:             case KEEPDFLT:
 313:             default:
 314:             io -> descr.d_archkeep = KEEPNO;
 315:             break;
 316:         }
 317:         putdscr (io, &io -> descr);     /* replace */
 318:         unlocknf (io, DSCRLOCK);        /* leave critical */
 319:         at (keeprow, 27);
 320:         switch ((int) io -> descr.d_archkeep)   /* update display */
 321:         {
 322:             case KEEPYES:
 323:             printf ("ARCHIVE");
 324:             break;
 325:             case KEEPNO:
 326:             printf ("DELETE ");
 327:             break;
 328:             case KEEPDFLT:
 329:             printf ("Default");
 330:             break;
 331:             default:
 332:             printf ("UNKNOWN");
 333:             break;
 334:         }
 335:         break;
 336: 
 337:         case 'D':                   /* Archive dirmsg */
 338:         locknf (io, DSCRLOCK);          /* critical section */
 339:         getdscr (io, &io -> descr);
 340:         switch ((int) io -> descr.d_dmesgstat)  /* change it */
 341:         {
 342:             case DIRNOCARE:
 343:             io -> descr.d_dmesgstat = DIRON;
 344:             break;
 345:             case DIRON:
 346:             io -> descr.d_dmesgstat = DIROFF;
 347:             break;
 348:             case DIROFF:
 349:             io -> descr.d_dmesgstat = DIRANYON;
 350:             break;
 351:             case DIRANYON:
 352:             io -> descr.d_dmesgstat = DIRDFLT;
 353:             break;
 354:             case DIRDFLT:
 355:             default:
 356:             io -> descr.d_dmesgstat = DIRNOCARE;
 357:             break;
 358:         }
 359:         putdscr (io, &io -> descr);     /* replace */
 360:         unlocknf (io, DSCRLOCK);        /* leave critical */
 361:         at (dirmsgrow, 27);
 362:         switch ((int) io -> descr.d_dmesgstat)
 363:         {
 364:             case DIRNOCARE:
 365:             printf ("NOCARE   ");
 366:             break;
 367:             case DIRON:
 368:             printf ("ON       ");
 369:             break;
 370:             case DIROFF:
 371:             printf ("OFF      ");
 372:             break;
 373:             case DIRANYON:
 374:             printf ("ANYON     ");
 375:             break;
 376:             case DIRDFLT:
 377:             printf ("Default  ");
 378:             break;
 379:             default:
 380:             printf ("UNKNOWN  ");
 381:             break;
 382:         }
 383:         break;
 384: 
 385:         case 'o':                   /* toggle open status */
 386:         toggle (io, OPEN, openrow);
 387:         break;
 388: 
 389:         case 'M':                   /* toggle moderated status */
 390:         toggle (io, MODERATED, modrow);
 391:         break;
 392: 
 393:         case 'L':                   /* toggle local status */
 394:         toggle(io, LOCAL, localrow);
 395:         break;
 396: 
 397:         case 'n':                   /* toggle network status */
 398:         toggle(io, NETWRKD, netrow);
 399:         break;
 400: 
 401: 
 402:         case 'm':                   /* collect a new director message */
 403:         redraw++;
 404:         at (lastrow, 10);
 405:         printf ("Enter new director message");
 406:         at (lastrow + 2, 10);
 407:         for (i = 0; i < DMLEN; i++)
 408:             printf ("-");
 409:         at (lastrow + 1, 10);
 410:         i = gline (title, DMLEN - 1);       /* grab message */
 411:         if (i <= 1)
 412:             break;              /* no new message */
 413:         locknf (io, DSCRLOCK);          /* mutual exclusion */
 414:         getdscr (io, &io -> descr);     /* get up-to-date */
 415:         strncpy (io -> descr.d_drmes, title, DMLEN);/* replace */
 416:         putdscr (io, &io -> descr);
 417:         unlocknf (io, DSCRLOCK);        /* uncritical now */
 418:         break;
 419: 
 420:         case 't':                   /* write title for note file */
 421:         redraw++;
 422:         at (lastrow, 10);
 423:         printf ("Enter new title for notefile");
 424:         at (lastrow + 2, 10);
 425:         for (i = 0; i < NNLEN; i++)
 426:             printf ("-");
 427:         at (lastrow + 1, 10);
 428:         i = gline (ntitle, NNLEN - 1);      /* suck the title */
 429:         if (i <= 1)
 430:             break;              /* no new message */
 431:         locknf (io, DSCRLOCK);          /* MUTEX */
 432:         getdscr (io, &io -> descr);     /* current descr */
 433:         strncpy (io -> descr.d_title, ntitle, NNLEN);/* update */
 434:         putdscr (io, &io -> descr);     /* and replace */
 435:         unlocknf (io, DSCRLOCK);        /* uncritical now */
 436:         break;
 437: 
 438:         case 'w':                   /* let him write a new policy note */
 439:         if (io -> descr.d_plcy)
 440:         {
 441:             at (0, PROMPTMSGX);
 442:             if (askyn ("Rewrite policy? (y/n) :") == 'n')
 443:             {
 444:             redraw++;
 445:             break;
 446:             }
 447:         }
 448:         at (0, PROMPTMSGX);
 449:         printf ("\nEdit New Policy Text:\n");
 450:         if (gettext (io, &where, (FILE *) NULL, EDIT) == 0)
 451:         {
 452:             redraw++;
 453:             break;
 454:         }
 455:         r = title;
 456:         strcpy (title, "POLICY NOTE");
 457:         gettime (&note.n_date);         /* date of writing */
 458:         getname (&auth, 0);         /* get author */
 459:         putnote (io, &where, title, 0, &note, &auth, 1, 1, 1, System, 1);
 460:         dspnote (io, &note, 0);         /* show it to him */
 461:         redraw++;
 462:         break;
 463: 
 464:         case 'z':                   /* zap a lot of notes/responses */
 465:         case 'u':                   /* undelete a bunch */
 466:         {
 467:             char   *action;         /* del/undel */
 468: 
 469:             redraw++;               /* want to repaint */
 470:             action = c == 'z' ? "delete" : "un-delete";/* for prompts */
 471:             at (lastrow, 1);
 472:             printf ("Enter list of notes to %s: ", action);
 473:             gline (buff, BUFSZ);        /* grab line */
 474:             at (lastrow + 1, 1);
 475:             printf ("Going to %s: %s", action, buff);
 476:             at (lastrow + 2, 1);
 477:             if (askyn ("Do you really want to do that? ") != 'y')
 478:             break;              /* chicken out */
 479:             buffptr = 0;
 480:             at (lastrow + 3, 1);
 481:             while (listget (buff, &buffptr, &start, &end))
 482:             {
 483:             if (start > end)
 484:             {
 485:                 printf ("IGNORING %d-%d", start, end);
 486:                 continue;
 487:             }
 488:             if (start == end)
 489:                 printf ("%d ", start);
 490:             else
 491:                 printf ("%d-%d ", start, end);
 492:             mdelete (io, start, end, c == 'z');/* zap those */
 493:             }
 494:             goto getkey;            /* leave this stuff on screen */
 495:         }
 496: 
 497:         default:
 498:         printf ("\07");
 499:         goto getkey;                /* hit a bad key */
 500: 
 501:     }
 502:     }
 503: }
 504: /*
 505:  *	dirplot - Plot the notesfile status
 506:  */
 507: 
 508: dirplot (io)
 509: struct io_f *io;
 510: {
 511:     int     atrow;
 512:     int     atcol;
 513: 
 514:     erase ();
 515:     center (io -> descr.d_title, NNLEN, 1, 40 - NNLEN / 2);
 516:     center (io -> descr.d_drmes, DMLEN, 2, 40 - DMLEN / 2);
 517:     atrow = 4;                      /* start filling in */
 518:     atcol = 1;
 519:     at (anonrow = atrow++, atcol);
 520:     printf ("(a) Anonymous:   ");           /* at (3,18); */
 521:     printf (io -> descr.d_stat & ANONOK ? "ON" : "OFF");
 522:     at (openrow = atrow++, atcol);
 523:     printf ("(o) Notesfile:   ");           /* at(4,18); */
 524:     printf (io -> descr.d_stat & OPEN ? "OPEN  " : "CLOSED");
 525:     at (netrow = atrow++, atcol);
 526:     printf ("(n) Networked:   ");           /* at(5,18); */
 527:     printf (YorN(io -> descr.d_stat & NETWRKD));
 528:     at (archrow = atrow++, atcol);
 529:     printf ("(A) Is Archive:  ");           /* at(6,18); */
 530:     printf (YorN(io -> descr.d_stat & ISARCH));
 531:     at (modrow = atrow++, atcol);
 532:     printf ("(M) Moderated:   ");
 533:     printf (YorN(io -> descr.d_stat & MODERATED));
 534:     at (localrow = atrow++, atcol);
 535:     printf ("(L) Local:       ");
 536:     printf (YorN(io -> descr.d_stat & LOCAL));
 537:     at (expirerow = atrow++, atcol);
 538:     printf ("(e) Expiration Threshold: ");      /* at (6,27); */
 539:     switch ((int) (io -> descr.d_archtime))
 540:     {
 541:     case NEVER:
 542:         printf ("Never");
 543:         break;
 544:     case 0:
 545:         printf ("Default");
 546:         break;
 547:     default:
 548:         printf ("%ld days", io -> descr.d_archtime);
 549:         break;
 550:     }
 551:     at (keeprow = atrow++, atcol);
 552:     printf ("(E) Expiration Action:    ");      /* at(?,27); */
 553:     switch ((int) io -> descr.d_archkeep)
 554:     {
 555:     case KEEPYES:
 556:         printf ("ARCHIVE");
 557:         break;
 558:     case KEEPNO:
 559:         printf ("DELETE ");
 560:         break;
 561:     case KEEPDFLT:
 562:         printf ("Default");
 563:         break;
 564:     default:
 565:         printf ("UNKNOWN");
 566:         break;
 567:     }
 568:     at (dirmsgrow = atrow++, atcol);
 569:     printf ("(D) Expire with Dirmsg:   ");      /* at (?,27) */
 570:     switch ((int) io -> descr.d_dmesgstat)
 571:     {
 572:     case DIRNOCARE:
 573:         printf ("NOCARE   ");
 574:         break;
 575:     case DIRON:
 576:         printf ("ON       ");
 577:         break;
 578:     case DIROFF:
 579:         printf ("OFF      ");
 580:         break;
 581:     case DIRANYON:
 582:         printf ("ANYON    ");
 583:         break;
 584:     case DIRDFLT:
 585:         printf ("Default  ");
 586:         break;
 587:     default:
 588:         printf ("UNKNOWN  ");
 589:         break;
 590:     }
 591:     at (worksetrow = atrow++, atcol);
 592:     printf ("(W) Working Set Size:     ");      /* at (5,27) */
 593:     switch ((int) io -> descr.d_workset)
 594:     {
 595:     case 0:
 596:         printf ("Default");
 597:         break;
 598:     default:
 599:         printf ("%ld Notes", io -> descr.d_workset);
 600:     }
 601:     at (longrow = atrow++, atcol);
 602:     printf ("(l) Maximum text/article: ");      /* at (6,27) */
 603:     printf ("%ld bytes", io -> descr.d_longnote);
 604: 
 605:     lastrow = atrow;                    /* for queries */
 606: 
 607: /*
 608:  *	Second Column
 609:  */
 610: 
 611:     atrow = 4;
 612:     atcol = 40;
 613:     at (atrow++, atcol);
 614:     printf ("Policy Note Exists: %s", YorN(io -> descr.d_plcy));
 615:     at (atrow++, atcol);
 616:     printf ("Next note in slot: %d", io -> descr.d_nnote + 1);
 617:     at (atrow++, atcol);
 618:     printf ("Deleted Notes (holes): %ld  ", io -> descr.d_delnote);
 619:     at (atrow++, atcol);
 620:     printf ("Deleted Responses (holes): %ld  ", io -> descr.d_delresp);
 621: /*
 622:  *	Should we show more statistics here?
 623:  *	Things like orphans, adoptions, etc.
 624:  */
 625: 
 626:     if (atrow > lastrow)
 627:     lastrow = atrow;
 628:     lastrow++;
 629: }
 630: 
 631: toggle(io, flag, row)
 632:     struct io_f *io;
 633:     int flag;
 634:     int row;
 635: {
 636:     locknf (io, DSCRLOCK);
 637:     getdscr (io, &io -> descr);
 638:     if (io -> descr.d_stat & flag)
 639:     io -> descr.d_stat &= NOT flag;
 640:     else
 641:     io -> descr.d_stat |= flag;
 642:     putdscr (io, &io -> descr);
 643:     unlocknf (io, DSCRLOCK);
 644:     at (row, 18);
 645:     if (flag == OPEN)
 646:         printf (io -> descr.d_stat & OPEN ? "OPEN  " : "CLOSED");
 647:     else
 648:         printf (YorN(io -> descr.d_stat & flag));
 649: }

Defined functions

direct defined in line 49; used 1 times
dirplot defined in line 508; used 3 times
toggle defined in line 631; used 6 times

Defined variables

NO defined in line 47; used 1 times
  • in line 45
YES defined in line 46; used 1 times
  • in line 45
anonrow defined in line 32; used 2 times
archrow defined in line 34; used 2 times
dirmsgrow defined in line 36; used 2 times
expirerow defined in line 38; used 2 times
keeprow defined in line 35; used 2 times
lastrow defined in line 43; used 30 times
localrow defined in line 42; used 2 times
longrow defined in line 39; used 2 times
modrow defined in line 41; used 2 times
netrow defined in line 37; used 2 times
openrow defined in line 33; used 2 times
rcsid defined in line 5; never used
worksetrow defined in line 40; used 2 times

Defined macros

BUFSZ defined in line 8; used 5 times
YorN defined in line 45; used 6 times
Last modified: 1988-02-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4358
Valid CSS Valid XHTML 1.0 Strict