home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1147 < prev    next >
Internet Message Format  |  1990-12-28  |  40KB

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1)  part 5 of 11
  4. Message-ID: <427@pcbox.UUCP>
  5. Date: 6 Apr 90 17:39:58 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 5 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file RunPopMenu.c continued
  12. #
  13. CurArch=5
  14. if test ! -r s2_seq_.tmp
  15. then echo "Please unpack part 1 first!"
  16.      exit 1; fi
  17. ( read Scheck
  18.   if test "$Scheck" != $CurArch
  19.   then echo "Please unpack part $Scheck next!"
  20.        exit 1;
  21.   else exit 0; fi
  22. ) < s2_seq_.tmp || exit 1
  23. echo "x - Continuing file RunPopMenu.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> RunPopMenu.c
  25. X    for (i = 0; i < pmenu.optioncount; i++)
  26. X        strcpy (PopMenu[i], pmenu.option[i]->description);
  27. X    strcpy (PopMenu[i], "");
  28. X    popmenu (INITMENU, popmid, row, col, poptitle, HELPFILE,
  29. X            LINES-2, sizeof(PopMenu[0]), PopMenu);
  30. X
  31. X    rc = popmenu (popmid);
  32. X
  33. X    /* run option selected */
  34. X    if (rc > 0)
  35. X    {
  36. X        for (i = 1; i <= MAXKEYS && strcmp (KeyWord[i], "") != 0; i++)
  37. X            if (strcmp (pmenu.option[rc-1]->keyword, 
  38. X                    KeyWord[i]) == 0)
  39. X            {
  40. X                if (RunKey[i] != NULL)
  41. X                {
  42. X                    /*
  43. X                    **  Dim box is option is a .POPMENU or
  44. X                    **  a .GETINPUT or a .SYSTEM GETINPUT
  45. X                    */
  46. X                    comptr = pmenu.option[rc-1]->command;
  47. X                    SKIPJUNK(comptr);
  48. X                       sscanf (comptr, "%s", command);
  49. X                    if (strcmp (pmenu.option[rc-1]->keyword, ".POPMENU") == 0  ||
  50. X                        strcmp (pmenu.option[rc-1]->keyword, ".GETINPUT") == 0 ||
  51. X                        (strcmp (pmenu.option[rc-1]->keyword, ".SYSTEM") == 0 && 
  52. X                         strcmp (command, "GETINPUT") == 0))
  53. X                        popmenu (UNHILIGHTBOX, popmid);
  54. X
  55. X                         rc = (*RunKey[i]) (&pmenu, rc-1,
  56. X                        KeyWord, ParseKey, ShowKey, 
  57. X                        RunKey, gnames, gfiles, gindex);
  58. X                }
  59. X                break;
  60. X            }
  61. X    }
  62. X    else
  63. X        rc = 0;            /* popmenu was cancelled, continue */
  64. X
  65. X    popmid--;
  66. X
  67. X    clean_menu (&pmenu);
  68. X
  69. X    if (DIMFLAG)
  70. X    {
  71. X        /* hilight .BOX */
  72. X        if (menu->boxtype)
  73. X            drawbox (stdscr, 1,1, LINES-1,COLS, 
  74. X                menu->boxtype & 0777, StandoutLine,
  75. X                FALSE, FALSE);
  76. X
  77. X        /* hilight .LINE */
  78. X        if (menu->linetype)
  79. X            drawline (stdscr, menu->titlecount-1,
  80. X                menu->linetype & 0777, StandoutLine,
  81. X                menu->boxtype);
  82. X    }
  83. X
  84. X    touchwin (stdscr);
  85. X
  86. X        if (rc != 0)  
  87. X        return (rc);
  88. X    else
  89. X        return (REPARSE);
  90. X}
  91. X/* Paul J. Condie  10/88 */
  92. SHAR_EOF
  93. echo "File RunPopMenu.c is complete"
  94. chmod 0444 RunPopMenu.c || echo "restore of RunPopMenu.c fails"
  95. echo "x - extracting RunGetI.c (Text)"
  96. sed 's/^X//' << 'SHAR_EOF' > RunGetI.c &&
  97. X#ifndef LINT
  98. Xstatic char Sccsid[] = "@(#)RunGetI.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  99. X#endif
  100. X
  101. X/*  FUNCTION:    RunGetInpt()
  102. X**        Runs keyword ".GETINPUT".
  103. X**  ARGS:    option        option info sturcture
  104. X**  RETURNS:    none
  105. X*/
  106. X
  107. X#include    <curses.h>
  108. X#include    <term.h>
  109. X#include    "menu.h"
  110. X
  111. X
  112. X
  113. XRunGetInput (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
  114. X        gnames, gfiles, gindex)
  115. X    struct MenuInfo        *menu;
  116. X    int            opnumber;
  117. X    int            (*ParseKey[MAXKEYS])(),
  118. X                (*ShowKey[MAXKEYS])(),
  119. X                (*RunKey[MAXKEYS])();
  120. X    char            KeyWord[MAXKEYS][MAXKEYLENGTH];
  121. X    char            gnames[MAXGNAME][15];
  122. X    char            gfiles[MAXGNAME][15];
  123. X    int            gindex;
  124. X{
  125. X    char            screen_name[50];
  126. X    int            rc;        /* return code */
  127. X
  128. X    /*
  129. X    **  The first argument is the screen name
  130. X    */
  131. X       sscanf (menu->option[opnumber]->command, "%s", screen_name);
  132. X    rc = runscreen (screen_name, menu, opnumber);
  133. X    if (rc == KEY_CANCEL)
  134. X        return (0);
  135. X    else
  136. X        return (REPARSE);
  137. X}
  138. SHAR_EOF
  139. chmod 0444 RunGetI.c || echo "restore of RunGetI.c fails"
  140. echo "x - extracting GetOption.c (Text)"
  141. sed 's/^X//' << 'SHAR_EOF' > GetOption.c &&
  142. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  143. X#include    <curses.h>
  144. X#include    <ctype.h>
  145. X#include    "menu.h"
  146. X#include    "terminal.h"
  147. X
  148. Xextern int    HotKeys;
  149. X    int    ch;            /* input character */
  150. X
  151. X
  152. XGetOption (row, col, s)
  153. X
  154. X    int    row;            /* row to get user input */
  155. X    int    col;            /* col to get user input */
  156. X    char    *s;            /* memory string to store input */
  157. X{
  158. X    char    *findfile();
  159. X    char    *getenv();
  160. X    char    *ws;            /* working string */
  161. X    int    cc;            /* column count */
  162. X    int    i;            /* work variable */
  163. X    char    hlpfile[100];
  164. X
  165. X
  166. X    ws = s;                /* set to memory string */
  167. X    cc = col;
  168. X
  169. X    for (i = col; i <= col+3; i++)    /* blank out prompt field */
  170. X       mvaddch (row, i, ' ');
  171. X                    /* display default text */
  172. X    while (*ws)
  173. X    {
  174. X        move (row, cc++);
  175. X        addch (*ws);
  176. X        ws++;
  177. X    }
  178. X                    /* loop until done */
  179. X    for (;;)
  180. X    {
  181. X        move (row, cc);
  182. X        refresh ();
  183. X        ch = getch ();
  184. X        move (ErrRow, 0);  clrtoeol ();
  185. X
  186. X              if (ch == KeyDown)       ch = KEY_DOWN;
  187. X              if (ch == KeyUp)    ch = KEY_UP;
  188. X              if (ch == KeyTab)    ch = KEY_TAB;
  189. X              if (ch == KeyBTab)    ch = KEY_BTAB;
  190. X              if (ch == KeyReturn)    ch = KEY_RETURN;
  191. X        if (ch == KeyBackspace)    ch = KEY_BACKSPACE;
  192. X        if (ch == KeyRedraw)    ch = KEY_REFRESH;
  193. X        if (ch == KeyHelp)    ch = KEY_HELP;
  194. X        if (ch == KeyMainMenu)    ch = KEY_MAINMENU;
  195. X        if (ch == KeyPrevMenu)    ch = KEY_PREVMENU;
  196. X        if (ch == KeyExitMenu)    ch = KEY_EXITMENU;
  197. X        if (ch == KeyGname)    ch = KEY_GNAME;
  198. X        if (ch == KeyPopGname)    ch = KEY_POPGNAME;
  199. X
  200. X        if (ch >= 'a' && ch <= 'z')
  201. X            ch = toupper (ch);
  202. X
  203. X        switch (ch)
  204. X        {
  205. X           case KEY_DOWN:
  206. X           case KEY_UP:
  207. X           case KEY_TAB:
  208. X           case KEY_BTAB:
  209. X            *s = '\0';    /* reset select to null */
  210. X           case KEY_RETURN:
  211. X           case KEY_LINEFEED:
  212. X           case '0':
  213. X           case '1':
  214. X           case '2':
  215. X           case '3':
  216. X           case '4':
  217. X           case '5':
  218. X           case '6':
  219. X           case '7':
  220. X           case '8':
  221. X           case '9':
  222. X            return (ch);
  223. X
  224. X           case '!':
  225. X            if (getenv ("SHELL") != (char *)NULL)
  226. X                return (ch);
  227. X            break;
  228. X
  229. X           case KEY_HELP:
  230. X           case KEY_EXITMENU:
  231. X           case KEY_MAINMENU:
  232. X           case KEY_PREVMENU:
  233. X           case KEY_GNAME:
  234. X            if (HotKeys)
  235. X            {
  236. X                return (ch);
  237. X            }
  238. X            else
  239. X            {
  240. X                if (ch == KEY_HELP)
  241. X                    *ws = KeyHelp;
  242. X                else if (ch == KEY_EXITMENU)
  243. X                    *ws = KeyExitMenu;
  244. X                else if (ch == KEY_MAINMENU)
  245. X                    *ws = KeyMainMenu;
  246. X                else if (ch == KEY_PREVMENU)
  247. X                    *ws = KeyPrevMenu;
  248. X                else if (ch == KEY_GNAME)
  249. X                    *ws = KeyGname;
  250. X                move (row, cc);
  251. X                addch (*ws);
  252. X                ws++;
  253. X                *ws = '\0';
  254. X                cc++;        /*move over one column*/
  255. X            }
  256. X            break;
  257. X            
  258. X           case KEY_BACKSPACE:
  259. X            if (cc == col) 
  260. X                continue;
  261. X            else
  262. X            {
  263. X                move (row, --cc);    /* back up one column */
  264. X                addch (' ');
  265. X                ws--;
  266. X                *ws = '\0';
  267. X            }
  268. X            break;
  269. X
  270. X           case KEY_REFRESH:
  271. X            /* redraw screen */
  272. X            clearok (stdscr, TRUE);
  273. X            refresh ();
  274. X            break;
  275. X
  276. X           case KEY_POPGNAME:
  277. X            return (KeyPopGname);
  278. X
  279. X           case ' ':
  280. X           case 'A':
  281. X           case 'B':
  282. X           case 'C':
  283. X           case 'D':
  284. X           case 'E':
  285. X           case 'F':
  286. X           case 'G':
  287. X           case 'H':
  288. X           case 'I':
  289. X           case 'J':
  290. X           case 'K':
  291. X           case 'L':
  292. X           case 'M':
  293. X           case 'N':
  294. X           case 'O':
  295. X           case 'P':
  296. X           case 'Q':
  297. X           case 'R':
  298. X           case 'S':
  299. X           case 'T':
  300. X           case 'U':
  301. X           case 'V':
  302. X           case 'W':
  303. X           case 'X':
  304. X           case 'Y':
  305. X           case 'Z':
  306. X            return (ch);
  307. X
  308. X           default:
  309. X            if (isprint (ch))
  310. X            {
  311. X                *ws = ch;
  312. X                move (row, cc);
  313. X                addch (*ws);
  314. X                ws++;
  315. X                *ws = '\0';
  316. X                cc++;        /*move over one column*/
  317. X            }
  318. X            break;
  319. X        } /* end switch */
  320. X    } /* end for */
  321. X}
  322. SHAR_EOF
  323. chmod 0644 GetOption.c || echo "restore of GetOption.c fails"
  324. echo "x - extracting EndWindow.c (Text)"
  325. sed 's/^X//' << 'SHAR_EOF' > EndWindow.c &&
  326. Xstatic char Sccsid[] = "@(#)EndWindow.c    1.1   DeltaDate 9/6/87   ExtrDate 1/22/90";
  327. X/*  FUNCTION:    EndWindow()
  328. X**        When a "WINDOW" keyword is found this function
  329. X**        recalculates the row and column to begin 
  330. X**        displaying the next subwindow.
  331. X**  ARGS:    menu    current menu structure
  332. X*/
  333. X
  334. X#include    "menu.h"
  335. X
  336. Xextern    int    swin, ewin, longest;
  337. X
  338. X
  339. XEndWindow (menu)
  340. X
  341. X    struct MenuInfo    *menu;
  342. X{
  343. X    int        i;
  344. X
  345. X
  346. X   if (swin == ewin)  return;
  347. X
  348. X   longest += 5;
  349. X
  350. X/*
  351. X**    Calculate what row and column to display option on.
  352. X*/
  353. X
  354. X   for (i = swin; i < ewin; i++)
  355. X   {
  356. X      menu->option[i]->row = ((menu->wlrow - menu->wfrow) / 2 + menu->wfrow) -
  357. X                  ((ewin - swin) / 2) + i - swin;
  358. X      menu->option[i]->col = (menu->wlcol - menu->wfcol) / 2 - 
  359. X                  longest / 2 + menu->wfcol;
  360. X   }
  361. X}
  362. SHAR_EOF
  363. chmod 0444 EndWindow.c || echo "restore of EndWindow.c fails"
  364. echo "x - extracting displaytxt.c (Text)"
  365. sed 's/^X//' << 'SHAR_EOF' > displaytxt.c &&
  366. Xstatic char Sccsid[] = "@(#)displaytxt.c    1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
  367. X
  368. X/*  FUNCTION:    displaytext()
  369. X**        Displays a string to the screen with atributes.
  370. X**  ARGS:    row    screen row
  371. X**        col    screen col
  372. X**        s    the string
  373. X**  RETURNS:    none
  374. X*/
  375. X
  376. X#include    <curses.h>
  377. X
  378. Xdisplaytext (row, col, s)
  379. X
  380. X    int    row, col;
  381. X    char    s[];
  382. X{
  383. X    int    i;
  384. X
  385. X   move (row, col);
  386. X
  387. X/*
  388. X**    Now display looking for terminal attributes.
  389. X*/
  390. X      for (i = 0; s[i] != '\0'; i++)
  391. X      {
  392. X         if (s[i] == '\\')
  393. X     {
  394. X#ifdef BSD
  395. X        if (s[i+1] != 'N') s[i+1] = 'S';   /* Berk only supports standout */
  396. X#endif
  397. X            switch (s[++i])
  398. X            {
  399. X           case 'S':
  400. X#ifdef BSD
  401. X            standout ();
  402. X#else
  403. X               attrset (stdscr->_attrs|A_STANDOUT);
  404. X#endif
  405. X            break;
  406. X           case 'B':
  407. X#ifdef SYS5
  408. X            attrset (stdscr->_attrs|A_BOLD);
  409. X#endif
  410. X            break;
  411. X           case 'U':
  412. X#ifdef SYS5
  413. X            attrset (stdscr->_attrs|A_UNDERLINE);
  414. X#endif
  415. X            break;
  416. X           case 'D':
  417. X#ifdef SYS5
  418. X            attrset (stdscr->_attrs|A_DIM);
  419. X#endif
  420. X            break;
  421. X           case 'R':
  422. X#ifdef SYS5
  423. X            attrset (stdscr->_attrs|A_REVERSE);
  424. X#endif
  425. X            break;
  426. X           case 'L':
  427. X#ifdef SYS5
  428. X            attrset (stdscr->_attrs|A_BLINK);
  429. X#endif
  430. X            break;
  431. X           case 'N': 
  432. X#ifdef BSD
  433. X            standend ();
  434. X#else
  435. X            attrset (A_NORMAL);
  436. X#endif
  437. X            break;
  438. X        }
  439. X     }
  440. X         else
  441. X            addch (s[i]);
  442. X      }
  443. X}
  444. SHAR_EOF
  445. chmod 0444 displaytxt.c || echo "restore of displaytxt.c fails"
  446. echo "x - extracting SetTerm.c (Text)"
  447. sed 's/^X//' << 'SHAR_EOF' > SetTerm.c &&
  448. X#ifndef LINT
  449. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  450. X#endif
  451. X
  452. X#include    <curses.h>
  453. X#include    "menu.h"
  454. X
  455. X                /* default values for dumb terminals */
  456. X                /* a -1 indicates nokey */
  457. X/* Mover Keys */
  458. Xint    KeyReturn    = '\r';    /* \r - menu & GetInput */
  459. Xint    KeyDown        = 10;    /* \n - menu & GetInput */
  460. Xint    KeyUp        = 11;    /* ^k - menu & GetInput */
  461. Xint    KeyTab        = '\t';    /* \t - menu & GetInput */
  462. Xint    KeyBTab        = -1;    /*    - menu & GetInput */
  463. X
  464. X/* Edit Keys */
  465. Xint    KeyBeg        = 2;    /* ^b - GetInput */
  466. Xint    KeyEnd        = 5;    /* ^e - GetInput */
  467. Xint    KeyRight    = 12;    /* ^l - GetInput */
  468. Xint    KeyLeft        = 8;    /* \b - GetInput */
  469. Xint    KeyBackspace    = '\b';    /* \b - GetInput */
  470. Xint    KeyEOL        = 4;    /* ^d - GetInput clear to end of field */
  471. Xint    KeyDL        = 3;    /* ^c - GetInput clear field and home cursor */
  472. Xint    KeyDC        = 24;    /* ^x - GetInput delete character */
  473. Xint    KeyIC        = 20;    /* ^t - GetInput typeover/insert mode */
  474. X
  475. X/* Other Keys */
  476. Xint    KeyHelp        = '?';    /* ?  - menu & GetInput */
  477. Xint    KeyTOC        = 20;    /* ^t - ShowHelp */
  478. Xint    KeyRedraw    = 18;    /* ^r - menu & GetInput */
  479. Xint    KeyCancel    = 27;    /* ESC - menu & GetInput pop-up menus */
  480. Xint    KeySave        = 6;    /* ^f - GetInput save screen to a file */
  481. Xint    KeyPrint    = 16;    /* ^p - GetInput prints screen to lp */
  482. Xint    KeyAccept    = 1;    /* ^a - GetInput accepts input */
  483. X
  484. X
  485. X/* Menu Specific */
  486. Xint    HotKeys        = 0;    /* for hot keyboard */
  487. Xint    KeyMainMenu    = 'm';    /* goto main menu */
  488. Xint    KeyPrevMenu    = 'p';    /* goto previous menu */
  489. Xint    KeyExitMenu    = 'e';    /* exit menu */
  490. Xint    KeyGname    = 'g';    /* goto a specific menu (dumb) */
  491. Xint    KeyPopGname    = 7;    /* ^g  - goto a specific menu (popmenu) */
  492. X
  493. X
  494. X
  495. XSetTerm ()
  496. X{
  497. X    FILE    *fopen(), *menuinit;
  498. X    char    *getenv();
  499. X    char    *findfile();
  500. X    char    *strchr();
  501. X    char    *ws;
  502. X    char    filename[100], line[BUFSIZE];
  503. X    char    *s1;
  504. X
  505. X
  506. X    char    *terminal;
  507. X
  508. X    /*
  509. X    **  Parse the .menuinit file
  510. X    **  First look in current directory then $HOME then in $MENUDIR
  511. X    */
  512. X    strcpy (filename, findfile (MENUINIT, ".", 
  513. X        (char *)getenv("HOME"), (char *)getenv("MENUDIR"), ""));
  514. X    if ((menuinit = fopen (filename, "r")) == NULL)
  515. X    {
  516. X        /* no file found - use the defaults */
  517. X        return (0);
  518. X    }
  519. X
  520. X    /* set terminal keys */
  521. X    while (fgets (line, BUFSIZE, menuinit) != (char *)NULL)
  522. X    {
  523. X        if (strncmp ("HOTKEYS", line, 7) == 0)
  524. X            HotKeys = 1;
  525. X            
  526. X        /*
  527. X        **  The following keywords require a = sign
  528. X        */
  529. X
  530. X        if ((s1 = strchr (line, '=')) == (char *)NULL)
  531. X            continue;
  532. X
  533. X        s1++;                    /* get past the = */
  534. X
  535. X        /* Mover Keys */
  536. X        if (strncmp ("KEY_RETURN", line, 10) == 0)
  537. X            sscanf (s1, "%d", &KeyReturn);
  538. X        else if (strncmp ("KEY_DOWN", line, 8) == 0)
  539. X            sscanf (s1, "%d", &KeyDown);
  540. X        else if (strncmp ("KEY_UP", line, 6) == 0)
  541. X            sscanf (s1, "%d", &KeyUp);
  542. X        else if (strncmp ("KEY_TAB", line, 7) == 0)
  543. X            sscanf (s1, "%d", &KeyTab);
  544. X        else if (strncmp ("KEY_BTAB", line, 8) == 0)
  545. X            sscanf (s1, "%d", &KeyBTab);
  546. X
  547. X        /* Edit Keys */
  548. X        else if (strncmp ("KEY_BEG", line, 7) == 0)
  549. X            sscanf (s1, "%d", &KeyBeg);
  550. X        else if (strncmp ("KEY_END", line, 7) == 0)
  551. X            sscanf (s1, "%d", &KeyEnd);
  552. X        else if (strncmp ("KEY_RIGHT", line, 9) == 0)
  553. X            sscanf (s1, "%d", &KeyRight);
  554. X        else if (strncmp ("KEY_LEFT", line, 8) == 0)
  555. X            sscanf (s1, "%d", &KeyLeft);
  556. X        else if (strncmp ("KEY_BACKSPACE", line, 13) == 0)
  557. X            sscanf (s1, "%d", &KeyBackspace);
  558. X        else if (strncmp ("KEY_EOL", line, 13) == 0)
  559. X            sscanf (s1, "%d", &KeyEOL);
  560. X        else if (strncmp ("KEY_DL", line, 14) == 0)
  561. X            sscanf (s1, "%d", &KeyDL);
  562. X        else if (strncmp ("KEY_DC", line, 6) == 0)
  563. X            sscanf (s1, "%d", &KeyDC);
  564. X        else if (strncmp ("KEY_IC", line, 6) == 0)
  565. X            sscanf (s1, "%d", &KeyIC);
  566. X
  567. X        /* Other Keys */
  568. X        else if (strncmp ("KEY_HELP", line, 8) == 0)
  569. X            sscanf (s1, "%d", &KeyHelp);
  570. X        else if (strncmp ("KEY_REFRESH", line, 10) == 0)
  571. X            sscanf (s1, "%d", &KeyRedraw);
  572. X        else if (strncmp ("KEY_ACCEPT", line, 10) == 0)
  573. X            sscanf (s1, "%d", &KeyAccept);
  574. X        else if (strncmp ("KEY_CANCEL", line, 10) == 0)
  575. X            sscanf (s1, "%d", &KeyCancel);
  576. X        else if (strncmp ("KEY_SAVE", line, 8) == 0)
  577. X            sscanf (s1, "%d", &KeySave);
  578. X        else if (strncmp ("KEY_PRINT", line, 9) == 0)
  579. X            sscanf (s1, "%d", &KeyPrint);
  580. X        else if (strncmp ("KEY_EXITMENU", line, 12) == 0)
  581. X            sscanf (s1, "%d", &KeyExitMenu);
  582. X        else if (strncmp ("KEY_MAINMENU", line, 12) == 0)
  583. X            sscanf (s1, "%d", &KeyMainMenu);
  584. X        else if (strncmp ("KEY_PREVMENU", line, 12) == 0)
  585. X            sscanf (s1, "%d", &KeyPrevMenu);
  586. X        else if (strncmp ("KEY_GNAME", line, 9) == 0)
  587. X            sscanf (s1, "%d", &KeyGname);
  588. X        else if (strncmp ("KEY_POPGNAME", line, 12) == 0)
  589. X            sscanf (s1, "%d", &KeyPopGname);
  590. X        else if (strncmp ("KEY_TOC", line, 7) == 0)
  591. X            sscanf (s1, "%d", &KeyTOC);
  592. X    }
  593. X    fclose (menuinit);
  594. X    return (0);
  595. X}
  596. X/* Paul J. Condie  11/88 */
  597. SHAR_EOF
  598. chmod 0644 SetTerm.c || echo "restore of SetTerm.c fails"
  599. echo "x - extracting systime.c (Text)"
  600. sed 's/^X//' << 'SHAR_EOF' > systime.c &&
  601. X#ifndef LINT
  602. Xstatic char Sccsid[] = "@(#)systime.c    1.2   DeltaDate 5/6/88   ExtrDate 1/22/90";
  603. X#endif
  604. X
  605. X#include <stdio.h>
  606. X#include <time.h>
  607. X
  608. Xsystime (timeStr, mask)
  609. X
  610. X    char *timeStr, *mask;
  611. X{
  612. X    long        tloc ;
  613. X    struct tm      *ltime, *localtime() ;
  614. X    char         tmpstr[4] ;
  615. X    int        tmpval;
  616. X
  617. X   tloc = time((long *) 0) ;
  618. X   ltime = localtime(&tloc) ;
  619. X
  620. X   ltime->tm_mon++;
  621. X
  622. X   if (mask == NULL)
  623. X   {
  624. X      sprintf (timeStr, "%2d:%02d:%02d", ltime->tm_hour, ltime->tm_min, 
  625. X           ltime->tm_sec) ;
  626. X   }
  627. X   else
  628. X      while (*mask != '\0')
  629. X      {
  630. X         switch (*mask)
  631. X         {
  632. X            case 'H':
  633. X            if (ltime->tm_hour > 12)
  634. X            {
  635. X               tmpval = ltime->tm_hour - 12;
  636. X               sprintf (tmpstr, "%2d", tmpval);
  637. X            }
  638. X            else
  639. X               sprintf (tmpstr, "%2d", ltime->tm_hour);
  640. X                break;
  641. X        case 'M':
  642. X            sprintf (tmpstr, "%02d", ltime->tm_min);
  643. X            break;
  644. X        case 'S':
  645. X            sprintf (tmpstr, "%02d", ltime->tm_sec);
  646. X            break;
  647. X        case 'I':
  648. X            sprintf (tmpstr, "%2d", ltime->tm_hour);
  649. X            break;
  650. X        case 'Z':
  651. X            if (ltime->tm_hour >= 12)
  652. X               strcpy (tmpstr, "PM");
  653. X            else
  654. X               strcpy (tmpstr, "AM");
  655. X            break;
  656. X        case 'z':
  657. X            if (ltime->tm_hour >= 12)
  658. X               strcpy (tmpstr, "pm");
  659. X            else
  660. X               strcpy (tmpstr, "am");
  661. X            break;
  662. X        default:
  663. X            *timeStr = *mask;
  664. X            timeStr++;
  665. X            mask++;
  666. X            continue;
  667. X         }   /* end switch */
  668. X         *timeStr = tmpstr[0];
  669. X     timeStr++;
  670. X         *timeStr = tmpstr[1];
  671. X     timeStr++;
  672. X         mask += 2;
  673. X      }  /* end while */
  674. X
  675. X   *timeStr = '\0';
  676. X   return (0);
  677. X}
  678. SHAR_EOF
  679. chmod 0444 systime.c || echo "restore of systime.c fails"
  680. echo "x - extracting sysdate.c (Text)"
  681. sed 's/^X//' << 'SHAR_EOF' > sysdate.c &&
  682. X#ifndef LINT
  683. Xstatic char Sccsid[] = "@(#)sysdate.c    1.1   DeltaDate 9/6/87   ExtrDate 1/22/90";
  684. X#endif
  685. X
  686. X#include    <time.h>
  687. X
  688. Xsysdate (dateStr, mask)
  689. X
  690. X    char *dateStr, *mask;
  691. X{
  692. X    long        tloc ;
  693. X    struct tm      *ltime, *localtime() ;
  694. X
  695. Xstatic    char        *shortmon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
  696. X                          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  697. X
  698. Xstatic    char        *longmon[]= 
  699. X          {"January","February","March","April","May","June",
  700. X           "July","August","September","October","November","December"};
  701. X
  702. Xstatic    char        *shortday[]= {"sun","mon","tue","wed","thr","fri","sat"};
  703. X
  704. Xstatic    char        *longday[]= {"Sunday","Monday","Tuesday","Wednessday",
  705. X                        "Thursday", "Friday", "Saturday"};
  706. X
  707. X
  708. X   tloc = time ((long *) 0) ;
  709. X   ltime = localtime (&tloc) ;
  710. X
  711. X   while (*mask != '\0')
  712. X   {
  713. X
  714. X/*
  715. X**    Process month
  716. X*/
  717. X      if (strncmp (mask, "mmmmm", 5) == 0)
  718. X      {
  719. X     sprintf (dateStr, "%s", longmon[ltime->tm_mon]);
  720. X     mask += 5;
  721. X     dateStr += strlen (longmon[ltime->tm_mon]);
  722. X     continue;
  723. X      }
  724. X      else
  725. X         if (strncmp (mask, "mmm", 3) == 0)
  726. X         {
  727. X            sprintf (dateStr, "%s", shortmon [ltime->tm_mon]);
  728. X        mask += 3;
  729. X        dateStr += 3;
  730. X        continue;
  731. X         }
  732. X     else
  733. X        if (strncmp (mask, "mm", 2) == 0)
  734. X        {
  735. X           sprintf (dateStr, "%.2d", ltime->tm_mon + 1);
  736. X           mask += 2;
  737. X           dateStr += 2;
  738. X            continue;
  739. X        }
  740. X
  741. X/*
  742. X**    Process day
  743. X*/
  744. X      if (strncmp (mask, "ddddd", 5) == 0)
  745. X      {
  746. X         sprintf (dateStr, "%s", longday [ ltime->tm_wday ]);
  747. X     mask += 5;
  748. X     dateStr += strlen (longday[ltime->tm_wday]);
  749. X     continue;
  750. X      }
  751. X      else
  752. X         if (strncmp (mask, "ddd", 3) == 0)
  753. X         {
  754. X            sprintf (dateStr, "%s", shortday [ltime->tm_wday]);
  755. X        mask += 3;
  756. X        dateStr += 3;
  757. X        continue;
  758. X         }
  759. X         else
  760. X            if (strncmp (mask, "dd", 2) == 0)
  761. X        {
  762. X           sprintf (dateStr, "%.2d", ltime->tm_mday);
  763. X           mask += 2;
  764. X           dateStr += 2;
  765. X           continue;
  766. X        }
  767. X      if (strncmp (mask, "jjj", 3) == 0)
  768. X      {
  769. X         sprintf (dateStr, "%3d", ltime->tm_yday + 1);
  770. X     mask += 3;
  771. X     dateStr += 3;
  772. X     continue;
  773. X      }
  774. X
  775. X/*
  776. X**    Process year
  777. X*/
  778. X      if (strncmp (mask, "yyyy", 4) == 0)
  779. X      {
  780. X         sprintf (dateStr, "19%.2d", ltime->tm_year);
  781. X     mask += 4;
  782. X     dateStr += 4;
  783. X     continue;
  784. X      }
  785. X      else
  786. X         if (strncmp (mask, "yy", 2) == 0)
  787. X     {
  788. X        sprintf (dateStr, "%.2d", ltime->tm_year);
  789. X        mask += 2;
  790. X        dateStr += 2;
  791. X        continue;
  792. X      }
  793. X
  794. X/*
  795. X**    Process mask
  796. X*/
  797. X      *dateStr = *mask;
  798. X      dateStr++;
  799. X      mask++;
  800. X   }
  801. X
  802. X   *dateStr = '\0';
  803. X   return (0);
  804. X}
  805. SHAR_EOF
  806. chmod 0444 sysdate.c || echo "restore of sysdate.c fails"
  807. echo "x - extracting TrapSignal.c (Text)"
  808. sed 's/^X//' << 'SHAR_EOF' > TrapSignal.c &&
  809. X#ifndef LINT
  810. Xstatic char Sccsid[] = "@(#)TrapSignal.c    1.2   DeltaDate 5/6/88   ExtrDate 1/22/90";
  811. X#endif
  812. X
  813. X#include    <signal.h>
  814. X
  815. XTrapSignal (action)
  816. X
  817. X    int    (*action)();
  818. X{
  819. X   if (signal (SIGINT, SIG_IGN) != SIG_IGN)   signal (SIGINT, action);
  820. X   if (signal (SIGQUIT, SIG_IGN) != SIG_IGN)   signal (SIGQUIT, action);
  821. X}
  822. SHAR_EOF
  823. chmod 0444 TrapSignal.c || echo "restore of TrapSignal.c fails"
  824. echo "x - extracting checkmail.c (Text)"
  825. sed 's/^X//' << 'SHAR_EOF' > checkmail.c &&
  826. X#ifndef LINT
  827. Xstatic char Sccsid[] = "@(#)checkmail.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  828. X#endif
  829. X
  830. X#include    <curses.h>
  831. X#include    <signal.h>
  832. X
  833. X#ifndef BELL
  834. X#define    BELL        printf ("%c", 7);
  835. X#endif
  836. X
  837. Xextern    int        mailrow;
  838. Xextern    int        mailcol;
  839. X
  840. Xcheckmail ()
  841. X{
  842. X    int        rc;
  843. X    static int    mailcheck = 30;            /* default */
  844. X
  845. X#ifdef ALARM
  846. X    alarm (0);                    /* turn off alarm */
  847. X#endif
  848. X    if ((rc = anymail()) != FALSE)
  849. X    {
  850. X        /* we got mail */
  851. X        attrset (A_REVERSE);
  852. X        if (rc == 1  ||  rc == 3)
  853. X            mvprintw (mailrow,mailcol, "MAIL");
  854. X        else
  855. X            mvprintw (mailrow,mailcol, "EMAIL");
  856. X        attrset (A_NORMAL);
  857. X#ifdef ALARM
  858. X        BELL;
  859. X#endif
  860. X    }
  861. X    else
  862. X        mvprintw (mailrow,mailcol, "    ");
  863. X
  864. X#ifdef ALARM
  865. X    signal (SIGALRM, checkmail);
  866. X    if ((char *)getenv("MAILCHECK") != (char *)0)
  867. X        sscanf ((char *)getenv("MAILCHECK"), "%d", &mailcheck);
  868. X    if (mailcheck < 10)
  869. X        mailcheck = 10;
  870. X    alarm (mailcheck);                /* set alarm again */
  871. X#endif
  872. X}
  873. X/* Paul J. Condie  4/88 */
  874. SHAR_EOF
  875. chmod 0444 checkmail.c || echo "restore of checkmail.c fails"
  876. echo "x - extracting anymail.c (Text)"
  877. sed 's/^X//' << 'SHAR_EOF' > anymail.c &&
  878. X#ifndef LINT
  879. Xstatic char Sccsid[] = "@(#)anymail.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  880. X#endif
  881. X
  882. X/*    FUNCTION:    anymail()
  883. X**            If the first word in the mail file is Forward it returns
  884. X**            no mail.
  885. X**    RETURNS:    FALSE    - no unix or email.
  886. X**            1    - unix mail.
  887. X**            2    - email
  888. X**            3    - both unix and email
  889. X*/
  890. X#include    <stdio.h>
  891. X#include    <sys/types.h>
  892. X#include    <sys/stat.h>
  893. X
  894. Xanymail ()
  895. X{
  896. X    FILE        *fopen(), *fp;
  897. X    char        *getenv();
  898. X    struct stat    Statbuf;
  899. X    int        rc = 0;                /* return code */
  900. X    char        *mailfile;
  901. X    static int    FIRST_TIME = 1;
  902. X    static int    FORWARDFLAG = 0;
  903. X    char        tmpstr[80];
  904. X
  905. X
  906. X   if ((mailfile = getenv("MAIL")) != (char *)0)
  907. X       if (stat (mailfile, &Statbuf) == 0)  
  908. X       {
  909. X        /* there is a mail file */
  910. X        if (Statbuf.st_size > 0)
  911. X        {
  912. X            /* there is something in the mail file */
  913. X            if (FIRST_TIME)
  914. X            {
  915. X                /* check to see if mail is being Forwarded */
  916. X                FIRST_TIME = 0;
  917. X                if ((fp=fopen (mailfile, "r")) != (FILE *)NULL)
  918. X                {
  919. X                    fscanf (fp, "%s", tmpstr);
  920. X                    if (strcmp (tmpstr, "Forward") == 0)
  921. X                        FORWARDFLAG = 1;
  922. X                    fclose (fp);
  923. X                }
  924. X            }
  925. X            if (!FORWARDFLAG)
  926. X                rc = 1;
  927. X        }
  928. X       }
  929. X   if ((mailfile = getenv("EMAIL")) != (char *)0)
  930. X       if (stat (mailfile, &Statbuf) == 0) 
  931. X       {
  932. X        if (Statbuf.st_size > 0)
  933. X            rc = rc == 1 ? 3 : 2;
  934. X       }
  935. X   return (rc);
  936. X}
  937. SHAR_EOF
  938. chmod 0444 anymail.c || echo "restore of anymail.c fails"
  939. echo "x - extracting setenv.c (Text)"
  940. sed 's/^X//' << 'SHAR_EOF' > setenv.c &&
  941. X#ifndef LINT
  942. Xstatic char Sccsid[] = "@(#)setenv.c    1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
  943. X#endif
  944. X
  945. X/* PROGRAM NAME:  @(#)setenv.c    1.2  
  946. X*  REVISION DATE: 
  947. X*  REVISION LEVEL:
  948. X*  CONTACT PERSON: Library Staff
  949. X*  AUTHOR: Stephen J. Muir 
  950. X*  ABSTRACT: setenv/delenv - add, change or delete environment variables
  951. X*  KEYWORDS: environment, shell, getenv
  952. X*  DESCRIPTION: Setenv allows a program to set environment variables.
  953. X*          delenv allows a program to delete environment variables.
  954. X*  PROJECTS: 
  955. X*  SOFTWARE CATEGORY: application development tools
  956. X*  COPYRIGHT:              Notice
  957. X   This is the confidential, unpublished property of Pacific Bell.
  958. X   Receipt or possession of it does not convey any rights to divulge,
  959. X   reproduce, use, or allow others to use it without the specific written
  960. X   authorization of Pacific Bell and use must conform strictly to
  961. X   the license agreement between user and Pacific Bell.
  962. X
  963. X      COPYRIGHT (c) 1986 Pacific Bell. All Rights Reserved. 
  964. X
  965. X*  OPERATING ENVIRONMENT: all standard AT&T UNIX machines.
  966. X*  SOFTWARE DEPENDENCIES: none.
  967. X*  HARDWARE DEPENDENCIES: 
  968. X*  LIMITATIONS: 
  969. X*  DOCUMENTATION: setenv.3 manual page
  970. X*  COMPILE COMMAND: cc setenv.c 
  971. X*  SIZE: 
  972. X*  SUPPORT LEVEL:
  973. X*  MODULE LIST:
  974. X*/
  975. X# include <string.h>
  976. X
  977. X/* This is the number of extra array elements to allocate each time it becomes
  978. X * necessary.
  979. X */
  980. X# define INC    10
  981. X
  982. Xextern char    **environ, *malloc ();
  983. Xextern int    free ();
  984. X
  985. Xstatic char    **original, **current, **limit;
  986. X
  987. X/* This routine should be called only once (when either "setenv" or "delenv" is
  988. X * called for the first time).  It would only be called again if it fails due
  989. X * to lack of memory.  It makes a copy of the original environment because the
  990. X * original environment array and its elements were not obtained from "malloc"
  991. X * and the "free" routine cannot, therefore, be called with any of its
  992. X * elements.
  993. X *
  994. X * return values:
  995. X *     0: success
  996. X *    -1: out of memory - nothing has changed
  997. X */
  998. Xstatic    /* this is a private routine */
  999. Xinitialise ()
  1000. X    { register char    **old, **new_ptr, *tmp, **new_env;
  1001. X
  1002. X      /* count number of existing strings */
  1003. X      for (old = environ; *old; ++old)
  1004. X        ;
  1005. X
  1006. X      /* make space for extra strings */
  1007. X      if ((new_ptr =
  1008. X           new_env =
  1009. X           (char **)malloc (sizeof (char **) * ((old - environ) + INC + 1))
  1010. X          )
  1011. X          == 0
  1012. X         )
  1013. X        return (-1);
  1014. X
  1015. X      /* "limit" points to the last element of the array -- it is used to
  1016. X       * decide when to recreate it
  1017. X       */
  1018. X      limit = new_env + (old - environ) + INC;
  1019. X
  1020. X      /* copy across old strings */
  1021. X      for (old = environ; *old; ++old)
  1022. X      { if ((tmp = malloc (strlen (*old) + 1)) == 0)
  1023. X        { /* out of memory -- undo everything */
  1024. X          while (new_ptr != new_env)
  1025. X        free (*--new_ptr);
  1026. X          free ((char *)new_ptr);
  1027. X          return (-1);
  1028. X        }
  1029. X        strcpy (tmp, *old);
  1030. X        *new_ptr++ = tmp;
  1031. X      }
  1032. X      /* "current" points to the null pointer at the end of the array */
  1033. X      *(current = new_ptr) = 0;
  1034. X
  1035. X      /* this is really just a flag to say it's initialised */
  1036. X      original = environ;
  1037. X      /* overwrite old environment with new */
  1038. X      environ = new_env;
  1039. X      return (0);
  1040. X    }
  1041. X
  1042. X/* This is a special routine to compare a string "name" of the form "NAME" with
  1043. X * a string "name_value" of the form "NAME=VALUE".  It returns zero if the
  1044. X * comparison is successful
  1045. X */
  1046. Xstatic    /* this is a private routine */
  1047. Xdiffer (name, name_value)
  1048. X    char    *name, *name_value;
  1049. X    { while (*name && *name_value)
  1050. X        if (*name++ != *name_value++)
  1051. X            return (1);
  1052. X      return (*name_value != '=');
  1053. X    }
  1054. X
  1055. X/* This routine deletes an environment variable, e.g. delenv ("SHELL");
  1056. X *
  1057. X * return values:
  1058. X *     0: success
  1059. X *     1: environment variable not found
  1060. X *    -1: out of memory - nothing has changed
  1061. X */
  1062. Xdelenv (name)
  1063. X    char    *name;
  1064. X    { register char    **ptr;
  1065. X
  1066. X      /* initialise if necessary */
  1067. X      if (original == 0 && initialise ())
  1068. X        return (-1);
  1069. X
  1070. X      /* attempt to find it */
  1071. X      for (ptr = environ; *ptr && differ (name, *ptr); ++ptr)
  1072. X        ;
  1073. X      if (*ptr == 0)
  1074. X        return (1);    /* not found */
  1075. X
  1076. X      /* delete it */
  1077. X      free (*ptr);
  1078. X      *ptr = *--current;
  1079. X      *current = 0;
  1080. X      return (0);
  1081. X    }
  1082. X
  1083. X/* This routine sets a new environment variable, replacing an existing one
  1084. X * where appropriate, e.g. setenv ("SHELL", "/bin/csh");
  1085. X *
  1086. X * return values:
  1087. X *     0: success
  1088. X *    -1: out of memory - nothing has changed
  1089. X */
  1090. Xsetenv (name, value)
  1091. X    char    *name, *value;
  1092. X    { register char    **old, **new_ptr, *cp, *tmp, **new_env;
  1093. X
  1094. X      /* initialise if necessary */
  1095. X      if (original == 0 && initialise ())
  1096. X        return (-1);
  1097. X
  1098. X      /* allocate space for the new string */
  1099. X      if ((cp = tmp = malloc (strlen (name) + strlen (value) + 2)) == 0)
  1100. X        return (-1);
  1101. X
  1102. X      /* find an existing one if we can - we do this now as we will lose
  1103. X       * the original "name" pointer in the while loop following
  1104. X       */
  1105. X      for (old = environ; *old && differ (name, *old); ++old)
  1106. X        ;
  1107. X
  1108. X      /* make the new entry */
  1109. X      while (*name)
  1110. X        *cp++ = *name++;
  1111. X      *cp++ = '=';
  1112. X      while (*value)
  1113. X        *cp++ = *value++;
  1114. X      *cp = '\0';
  1115. X
  1116. X      /* case 1: overwrite previous value */
  1117. X      if (*old)
  1118. X      { free (*old);
  1119. X        *old = tmp;
  1120. X      }
  1121. X
  1122. X      /* case 2: no previous value and no space left - allocate more */
  1123. X      else if (current == limit)
  1124. X      { if ((new_ptr =
  1125. X         new_env =
  1126. X         (char **)malloc (sizeof (char **) *
  1127. X                  ((old - environ) + INC + 1)
  1128. X                 )
  1129. X        ) == 0
  1130. X           )
  1131. X        { free (tmp);
  1132. X          return (-1);
  1133. X        }
  1134. X        limit = new_env + (old - environ) + INC;
  1135. X        for (old = environ; *old; )
  1136. X        *new_ptr++ = *old++;
  1137. X        *new_ptr++ = tmp;
  1138. X        *(current = new_ptr) = 0;
  1139. X        free ((char *)environ);
  1140. X        environ = new_env;
  1141. X      }
  1142. X
  1143. X      /* case 3: no previous value and there is enough space */
  1144. X      else
  1145. X      { *current++ = tmp;
  1146. X        *current = 0;
  1147. X      }
  1148. X      return (0);
  1149. X    }
  1150. SHAR_EOF
  1151. chmod 0444 setenv.c || echo "restore of setenv.c fails"
  1152. echo "x - extracting strmatch.c (Text)"
  1153. sed 's/^X//' << 'SHAR_EOF' > strmatch.c &&
  1154. X#ifndef LINT
  1155. Xstatic char Sccsid[] = "@(#)strmatch.c    1.1   DeltaDate 10/20/88   ExtrDate 1/22/90";
  1156. X#endif
  1157. X
  1158. X#ifndef    TRUE
  1159. X#define    TRUE    1
  1160. X#endif
  1161. X#ifndef    FALSE
  1162. X#define    FALSE    0
  1163. X#endif
  1164. X#ifndef    BOOL
  1165. X#define    BOOL    int
  1166. X#endif
  1167. X
  1168. X#define    M_ALL    '*'
  1169. X#define    M_ONE    '?'
  1170. X#define    M_SET    '['
  1171. X#define    M_RNG    '-'
  1172. X#define    M_END    ']'
  1173. X
  1174. X
  1175. XBOOL strmatch (name, pat)
  1176. X
  1177. X    char        *name, *pat;
  1178. X{
  1179. X       char        c, k;
  1180. X    BOOL        ok;
  1181. X
  1182. X
  1183. X   while ((c = *pat++) != '\0')
  1184. X   {
  1185. X      switch (c)
  1186. X      {
  1187. X     case M_ONE:
  1188. X        if (*name++ == '\0')   return (FALSE);
  1189. X        break;
  1190. X    
  1191. X    case M_ALL:
  1192. X        if (*pat == '\0')   return (TRUE);
  1193. X        for (; *name != '\0'; ++name)
  1194. X           if (strmatch (name, pat))   return (TRUE);
  1195. X        return (FALSE);
  1196. X
  1197. X    case M_SET:
  1198. X        ok = FALSE;
  1199. X        k = *name++;
  1200. X        while ((c = *pat++) != M_END)
  1201. X           if (*pat == M_RNG)
  1202. X           {
  1203. X              if (c <= k  &&  k <= pat[1])
  1204. X             ok = TRUE;
  1205. X              pat += 2;
  1206. X           }
  1207. X           else
  1208. X              if (c == k)   ok = TRUE;
  1209. X        if (!ok)   return (FALSE);
  1210. X        break;
  1211. X
  1212. X    default:
  1213. X        if (*name++ != c)   return (FALSE);
  1214. X        break;
  1215. X      }
  1216. X   }
  1217. X   return (*name == '\0');
  1218. X}
  1219. SHAR_EOF
  1220. chmod 0444 strmatch.c || echo "restore of strmatch.c fails"
  1221. echo "x - extracting setvar.c (Text)"
  1222. sed 's/^X//' << 'SHAR_EOF' > setvar.c &&
  1223. X#ifndef LINT
  1224. Xstatic char Sccsid[] = "@(#)setvar.c    1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1225. X#endif
  1226. X
  1227. X#include    <curses.h>
  1228. X#include    <ctype.h>
  1229. X#include    <string.h>
  1230. X#include    "menu.h"
  1231. X
  1232. X
  1233. X
  1234. Xsetvariable (cptr)
  1235. X    char    **cptr;                /* command pointer var=value */
  1236. X{
  1237. X    char    *getenv();
  1238. X    char    *getval();
  1239. X    char    command[BUFSIZ];
  1240. X    char    variable[100];
  1241. X    char    value[100];
  1242. X    int    rc;                /* return code */
  1243. X    int    i, j;
  1244. X
  1245. X    if (*cptr == (char *)NULL)   return (EOF);
  1246. X
  1247. X    /* skip junk characters */
  1248. X    for (;**cptr != '\0' &&  (!isalpha(**cptr)) && (!isdigit(**cptr)); 
  1249. X          (*cptr)++) 
  1250. X        if (**cptr == '!')
  1251. X            break;
  1252. X        ;
  1253. X    if (**cptr == '\0') return (EOF);    /* end of line */
  1254. X
  1255. X    /* get the enviroment variable */
  1256. X    for (i = 0; **cptr != '=' && **cptr != '\0'; i++, (*cptr)++)
  1257. X        variable[i] = **cptr;
  1258. X    variable[i] = '\0';
  1259. X    if (strcmp (variable, "") == 0  ||  **cptr != '=')
  1260. X    {
  1261. X        BEEP;
  1262. X        mvprintw (ErrRow-2, 0, 
  1263. X           "Error occured while setting enviroment variable %s",
  1264. X           command);
  1265. X        shutdown ();
  1266. X    }
  1267. X    (*cptr)++;                    /* get past the = */
  1268. X
  1269. X    strcpy (value, getval (cptr, '0'));
  1270. X
  1271. X    /* set the enviroment variable */
  1272. X    if (variable[0] == '!')
  1273. X    {
  1274. X        /*
  1275. X        **  if !
  1276. X        **     then only set if not already set
  1277. X        */
  1278. X        /* junk ! - shift left one */
  1279. X        for (i = 0; variable[i] != '\0'; i++)
  1280. X            variable[i] = variable[i+1];
  1281. X        rc = 0;
  1282. X        if (getenv(variable) == (char *)NULL)
  1283. X            rc = setenv (variable, value);
  1284. X    }
  1285. X    else
  1286. X        rc = setenv (variable, value);
  1287. X    if (rc != 0)
  1288. X    {
  1289. X        BEEP;
  1290. X        mvprintw (ErrRow-2, 0, 
  1291. X           "Error occured while setting enviroment variable %s",
  1292. X           command);
  1293. X        shutdown ();
  1294. X    }
  1295. X    return (0);
  1296. X}
  1297. X/* Paul J. Condie  10/88 */
  1298. SHAR_EOF
  1299. chmod 0444 setvar.c || echo "restore of setvar.c fails"
  1300. echo "x - extracting findfile.c (Text)"
  1301. sed 's/^X//' << 'SHAR_EOF' > findfile.c &&
  1302. X#ifndef LINT
  1303. Xstatic char Sccsid[] = "@(#)findfile.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1304. X#endif
  1305. X
  1306. X/* Function    findfile()
  1307. X**          Search through a number of directories looking for a file
  1308. X**  RETURNS    a pointer to the file with the directory if found
  1309. X**        otherwise returns a null pointer.
  1310. X*/
  1311. X
  1312. X#include    <stdio.h>
  1313. X#include    <varargs.h>
  1314. X#include    <sys/types.h>
  1315. X#include    <sys/stat.h>
  1316. X
  1317. X/*VARARGS*/
  1318. Xchar *findfile (va_alist)
  1319. X    va_dcl
  1320. X{
  1321. X    va_list        ap;
  1322. X    char        *filename;
  1323. X    char        *directory;
  1324. X    static char    file[200];
  1325. X    char        *fileptr;
  1326. X    struct stat    buf;
  1327. X    int        rc;
  1328. X
  1329. X    va_start (ap);
  1330. X    fileptr = file;
  1331. X
  1332. X    /* get filename to search for */
  1333. X    if ((filename = va_arg (ap, char *)) == (char *)0)
  1334. X    {
  1335. X        va_end (ap);
  1336. X        return ((char *)0);
  1337. X    }
  1338. X
  1339. X    /* loop through each directory looking for file */
  1340. X    while (1)
  1341. X    {
  1342. X        directory = va_arg (ap, char *);
  1343. X        /* getenv() returns a null */
  1344. X        if (directory == (char *)0)
  1345. X            continue;
  1346. X        if (strcmp (directory, "") == 0)
  1347. X            break;
  1348. X        sprintf (file, "%s/%s", directory, filename);
  1349. X        if (stat (file, &buf) == 0)
  1350. X        {
  1351. X            va_end (ap);
  1352. X            return (fileptr);
  1353. X        }
  1354. X    }
  1355. X    va_end (ap);
  1356. X    return ("");
  1357. X}
  1358. X/* Paul J. Condie  10/88 */
  1359. SHAR_EOF
  1360. chmod 0444 findfile.c || echo "restore of findfile.c fails"
  1361. echo "x - extracting drawline.c (Text)"
  1362. sed 's/^X//' << 'SHAR_EOF' > drawline.c &&
  1363. X#ifndef LINT
  1364. Xstatic char Sccsid[] = "@(#)drawline.c    1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1365. X#endif
  1366. X
  1367. X#include    <curses.h>
  1368. X#include    <term.h>
  1369. X
  1370. X#define    DumbLine    1    /* A_NORMAL */
  1371. X#define    StandoutLine    2    /* A_STANDOUT */
  1372. X#define    SingleLine    3    /* A_ALTCHARSET */
  1373. X#define    MosaicLine    4    /* A_ALTCHARSET */
  1374. X#define    DiamondLine    5    /* A_ALTCHARSET */
  1375. X#define    DotLine        6    /* A_ALTCHARSET */
  1376. X#define    PlusLine    7    /* A_ALTCHARSET */
  1377. X
  1378. X#define    CANDRAWGRAPHICS    (enter_alt_charset_mode != NULL  && \
  1379. X             strcmp(enter_alt_charset_mode, "") != 0)
  1380. X
  1381. X
  1382. Xdrawline (win, row, trythis, trythat, box)
  1383. X    WINDOW    *win;
  1384. X    int    row;
  1385. X    int    trythis;
  1386. X    int    trythat;
  1387. X    int    box;
  1388. X{
  1389. X    int    col;
  1390. X    int    hchar;                    /* horizonal char */
  1391. X    int    lchar;                    /* left char */
  1392. X    int    rchar;                    /* right char */
  1393. X    int    attribute;
  1394. X    int    boxtype;
  1395. X
  1396. X
  1397. X    boxtype = trythis;
  1398. X    attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
  1399. X    if (attribute == A_ALTCHARSET)
  1400. X        /* can this terminal do graphics ? */
  1401. X        boxtype = CANDRAWGRAPHICS ? trythis : trythat;
  1402. X
  1403. X    switch (boxtype)
  1404. X    {
  1405. X       case DumbLine:
  1406. X        /* draw a dumb line */
  1407. X        hchar = '-';
  1408. X        lchar = '+';
  1409. X        rchar = '+';
  1410. X        break;
  1411. X
  1412. X       case StandoutLine:
  1413. X        /* draw a standout line */
  1414. X        attribute = A_STANDOUT;
  1415. X        hchar = ' ';
  1416. X        lchar = ' ';
  1417. X        rchar = ' ';
  1418. X        break;
  1419. X
  1420. X       case SingleLine:
  1421. X        /* attempt to draw a graphic single line */
  1422. X        hchar = 'q';
  1423. X        lchar = 't';
  1424. X        rchar = 'u';
  1425. X        break;
  1426. X
  1427. X       case MosaicLine:
  1428. X        hchar = 'a';
  1429. X        lchar = 'a';
  1430. X        rchar = 'a';
  1431. X        break;
  1432. X
  1433. X       case DiamondLine:
  1434. X        hchar = '`';
  1435. X        lchar = '`';
  1436. X        rchar = '`';
  1437. X        break;
  1438. X
  1439. X       case DotLine:
  1440. X        hchar = '~';
  1441. X        lchar = '~';
  1442. X        rchar = '~';
  1443. X        break;
  1444. X
  1445. X       case PlusLine:
  1446. X        hchar = 'n';
  1447. X        lchar = 'n';
  1448. X        rchar = 'n';
  1449. X        break;
  1450. X        break;
  1451. X
  1452. X       default:
  1453. X        return (-1);
  1454. X    }
  1455. X
  1456. X#ifdef BSD
  1457. X       standout ();
  1458. X#else
  1459. X       wattrset (win, attribute);
  1460. X#endif
  1461. X       for (col = 0; col <= COLS-1; col++)
  1462. X              mvwaddch (win, row, col, hchar);
  1463. X
  1464. X    if (box)
  1465. X    {
  1466. X        mvwaddch (win, row, 0, lchar);
  1467. X        mvwaddch (win, row, COLS-1, rchar);
  1468. X    }
  1469. X
  1470. X#ifdef BSD
  1471. X       standend ();
  1472. X#else
  1473. X       wattrset (win, A_NORMAL);
  1474. X#endif
  1475. X    return (0);
  1476. X}
  1477. X/* Paul J. Condie  10/88 */
  1478. SHAR_EOF
  1479. chmod 0444 drawline.c || echo "restore of drawline.c fails"
  1480. echo "x - extracting initmenu.c (Text)"
  1481. sed 's/^X//' << 'SHAR_EOF' > initmenu.c &&
  1482. X#ifndef LINT
  1483. Xstatic char Sccsid[] = "@(#)initmenu.c    1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1484. X#endif
  1485. X
  1486. X#include    <curses.h>
  1487. X#include    "menu.h"
  1488. X
  1489. Xinitmenu (menu)
  1490. X    struct MenuInfo    *menu;
  1491. X{
  1492. X      /* set default menu settings */
  1493. X      menu->row_cursor = LINES - 2;
  1494. X      menu->col_cursor = COLS - 4;
  1495. X      menu->boxtype = 0;
  1496. X      menu->linetype = 0;
  1497. X      menu->srn[0] = (struct ScreenInfo *)NULL;
  1498. X}
  1499. SHAR_EOF
  1500. chmod 0444 initmenu.c || echo "restore of initmenu.c fails"
  1501. echo "x - extracting keyboard.c (Text)"
  1502. sed 's/^X//' << 'SHAR_EOF' > keyboard.c &&
  1503. X#ifndef LINT
  1504. Xstatic char Sccsid[] = "@(#)keyboard.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1505. X#endif
  1506. X
  1507. X#include    <curses.h>
  1508. X#include    <term.h>
  1509. X#include    "menu.h"
  1510. X
  1511. Xkeyboard ()
  1512. X{
  1513. X    char    *getenv();
  1514. X    int    ch;
  1515. X    int    wrow = 0;                /* from row */
  1516. X    int    wcol = 10;                /* from col */
  1517. X    int    sstart;                    /* scrool start row */
  1518. X    int    send;                    /* scrool end row */
  1519. X    int    prow;                    /* print row */
  1520. X    int    dflag=0;
  1521. X    WINDOW    *bwin;
  1522. X
  1523. X
  1524. X    sstart = wrow + 10;
  1525. X    send = wrow + 20;
  1526. X    prow = sstart;
  1527. X
  1528. X    mvprintw (1,0, "Keyboard");
  1529. X    mvprintw (2,4, "Fun");
  1530. X
  1531. X    drawbox (stdscr, wrow+1,wcol, wrow+23,wcol+40, StandoutLine, 
  1532. X        StandoutLine, FALSE, FALSE);
  1533. X    mvprintw (2,wcol+40, "StandoutLine");
  1534. X    drawbox (stdscr, wrow+2,wcol+1, wrow+22,wcol+39, DumbLine, DumbLine,
  1535. X        FALSE, FALSE);
  1536. X    mvprintw (3,wcol+39, "DumbLine");
  1537. X
  1538. X    /* to get around bug in curses of not turning attributes off */
  1539. X    for (ch = 0; ch <= LINES; ch++)
  1540. X    {
  1541. X        mvprintw (ch,70, "hi");
  1542. X        refresh ();
  1543. X        mvprintw (ch,70, "  ");
  1544. X    }
  1545. X
  1546. X    /* terminal type */
  1547. X    mvprintw (wrow+3, wcol+4, "Terminal = %s", getenv("TERM"));
  1548. X
  1549. X    /* DrawLine ? */
  1550. X    if (enter_alt_charset_mode == NULL  ||
  1551. X        strcmp (enter_alt_charset_mode, "") == 0)
  1552. X        mvprintw (wrow+4, wcol+4, "Alternate Characters = No");
  1553. X    else
  1554. X    {
  1555. X        dflag++;
  1556. X        mvprintw (wrow+4, wcol+4, "Alternate Characters = Yes");
  1557. X
  1558. X        mvprintw (5,wcol+44, "Check termcap/terminfo");
  1559. X        mvprintw (6,wcol+44, "setting if the alternate");
  1560. X        mvprintw (7,wcol+44, "character lines below");
  1561. X        mvprintw (8,wcol+44, "don't look right.");
  1562. X
  1563. X        bwin = newwin (13, 27, 10, wcol+43);
  1564. X        drawbox (bwin, 1,1, 13,27, SingleLine, SingleLine, FALSE,FALSE);
  1565. X        drawbox (bwin, 2,2, 12,26, MosaicLine, MosaicLine, FALSE,FALSE);
  1566. X        drawbox (bwin, 3,3, 11,25, DiamondLine, DiamondLine, FALSE,FALSE);
  1567. X        drawbox (bwin, 4,4, 10,24, DotLine, DotLine, FALSE,FALSE);
  1568. X        drawbox (bwin, 5,5, 9,23, PlusLine, PlusLine, FALSE,FALSE);
  1569. X
  1570. X        mvwprintw (bwin, 0,7, " SingleLine ");
  1571. X        mvwprintw (bwin, 1,7, " MosaicLine ");
  1572. X        mvwprintw (bwin, 2,7, " DiamondLine ");
  1573. X        mvwprintw (bwin, 3,7, " DotLine ");
  1574. X        mvwprintw (bwin, 4,7, " PlusLine ");
  1575. X    }
  1576. X
  1577. X    /* Show all attributes */
  1578. X    mvprintw (11,0, "Curses");
  1579. X    mvprintw (12,0, "Attributes");
  1580. X
  1581. X    attrset (A_NORMAL);
  1582. X    mvprintw (14,0, "NORMAL");
  1583. X    attrset (A_STANDOUT);
  1584. X    mvprintw (15,0, "STANDOUT");
  1585. X    attrset (A_REVERSE);
  1586. X    mvprintw (16,0, "REVERSE");
  1587. X    attrset (A_UNDERLINE);
  1588. X    mvprintw (17,0, "UNDERLINE");
  1589. X    attrset (A_BLINK);
  1590. X    mvprintw (18,0, "BLINK");
  1591. X    attrset (A_DIM);
  1592. X    mvprintw (19,0, "DIM");
  1593. X    attrset (A_BOLD);
  1594. X    mvprintw (20,0, "BOLD");
  1595. X
  1596. X    attrset (A_NORMAL);
  1597. X
  1598. X    /* key codes */
  1599. X    mvprintw (wrow+6,wcol+8, "Press a Key");
  1600. X    mvprintw (wrow+7,wcol+8, "Press zero to exit.");
  1601. X
  1602. X    /* set up scroll */
  1603. X    scrollok (stdscr, TRUE);
  1604. X    wsetscrreg (stdscr, sstart, send);
  1605. X
  1606. X    mvprintw (sstart-2, wcol+4, "      (.menuinit)");
  1607. X    attrset (A_BOLD);
  1608. X    mvprintw (sstart-1, wcol+4, "char      dec     hex    octal");
  1609. X    attrset (A_NORMAL);
  1610. X    do
  1611. X    {
  1612. X        refresh ();
  1613. X        if (dflag)
  1614. X        {
  1615. X            touchwin (bwin);
  1616. X            wrefresh (bwin);
  1617. X        }
  1618. X        move (wrow+6, wcol+8+strlen("Press a Key")+1);
  1619. X        refresh ();
  1620. X        ch = getch ();
  1621. X
  1622. X        /*
  1623. X        nodelay (stdscr, TRUE);
  1624. X        while ((ch = getch()) != -1)
  1625. X            print ch
  1626. X        nodelay (stdscr, FALSE);
  1627. X        */
  1628. X
  1629. X        if (prow > send-2)
  1630. X        {
  1631. X            scroll (stdscr);
  1632. X            attrset (A_STANDOUT);
  1633. X            mvprintw (prow+1,wcol-1, " ");
  1634. X            mvprintw (prow+1,wcol+39, " ");
  1635. X            attrset (A_NORMAL);
  1636. X
  1637. X            mvprintw (prow+1,wcol, "|");
  1638. X            mvprintw (prow+1,wcol+38, "|");
  1639. X        }
  1640. X        else
  1641. X            prow++;
  1642. X        if (ch == '\t')
  1643. X            mvprintw (prow,wcol+4, "\t\\t\t%d\t%x\t%o", ch,ch,ch);
  1644. X        else    if (ch == '\n')
  1645. X                mvprintw (prow,wcol+4, "\t\\n\t%d\t%x\t%o", 
  1646. X                        ch,ch,ch);
  1647. X        else    if (ch == '\r')
  1648. X                mvprintw (prow,wcol+4, "\t\\r\t%d\t%x\t%o", 
  1649. X                        ch,ch,ch);
  1650. X        else    if (ch == '\b')
  1651. X                mvprintw (prow,wcol+4, "\t\\b\t%d\t%x\t%o", 
  1652. X                        ch,ch,ch);
  1653. X        else
  1654. X            mvprintw (prow,wcol+4, "\t%c\t%d\t%x\t%o", ch,ch,ch,ch);
  1655. X
  1656. X    } while (ch != '0');
  1657. X    if (dflag)
  1658. X    {
  1659. X        touchwin (bwin);
  1660. X        wrefresh (bwin);
  1661. X    }
  1662. X}
  1663. X/* Paul J. Condie */
  1664. SHAR_EOF
  1665. chmod 0444 keyboard.c || echo "restore of keyboard.c fails"
  1666. echo "x - extracting runscreen.c (Text)"
  1667. sed 's/^X//' << 'SHAR_EOF' > runscreen.c &&
  1668. X#ifndef LINT
  1669. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1670. X#endif
  1671. X
  1672. X/*  FUNCTION:    runscreen()
  1673. X*/
  1674. X
  1675. X#include    <curses.h>
  1676. X#include    "GetInput.h"
  1677. X#include    "menu.h"
  1678. X#include    "terminal.h"
  1679. X
  1680. X#define    SRN    menu->srn[sidx]
  1681. X#define    FLD    menu->srn[sidx]->field[fidx]
  1682. X
  1683. Xextern int debug;
  1684. X
  1685. X
  1686. Xrunscreen (screen_name, menu, opnumber)
  1687. SHAR_EOF
  1688. echo "End of part 5"
  1689. echo "File runscreen.c is continued in part 6"
  1690. echo "6" > s2_seq_.tmp
  1691. exit 0
  1692.