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

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1) part 4 of 14
  4. Message-ID: <438@pcbox.UUCP>
  5. Date: 26 Dec 90 20:06:34 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 4 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file rundriver.c continued
  12. #
  13. CurArch=4
  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 rundriver.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> rundriver.c
  25. X                      ++(*option);
  26. X            break;
  27. X
  28. X        case KEY_BTAB:
  29. X            /* A back tab will hop backward 4 options at a time. */
  30. X            if (menu.optioncount > 4)
  31. X            {
  32. X                *option -= 4;
  33. X                if (*option < 0)
  34. X                    *option = menu.optioncount - abs(*option);
  35. X            }
  36. X            else
  37. X                *option = *option <= 1 ? menu.optioncount:--(*option);
  38. X            break;
  39. X
  40. X        /*
  41. X        **    This section is to highlight the selected option 
  42. X        **    before the user presses the return_key to select it.
  43. X        */
  44. X        case '0':
  45. X        case '1':
  46. X        case '2':
  47. X        case '3':
  48. X        case '4':
  49. X        case '5':
  50. X        case '6':
  51. X        case '7':
  52. X        case '8':
  53. X        case '9':
  54. X            sprintf (select, "%s%c", select, exitkey);
  55. X            if (matoi (select) < 1  ||  
  56. X                matoi (select) > lastopnumber)
  57. X            {
  58. X                /* Invalid Option */
  59. X                attrset (A_REVERSE);
  60. X                mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
  61. X                attrset (A_NORMAL);
  62. X                select[0] = '\0';
  63. X            }
  64. X            else
  65. X            {
  66. X                /* find the element cooresponding to opnumber */
  67. X                for (i = 0; i < menu.optioncount; i++)
  68. X                    if (matoi(select) == menu.option[i]->opnumber)
  69. X                    {
  70. X                        *option = i+1;
  71. X                        break;
  72. X                    }
  73. X            }
  74. X            break;
  75. X
  76. X            case 'A':
  77. X            case 'B':
  78. X            case 'C':
  79. X            case 'D':
  80. X            case 'E':
  81. X            case 'F':
  82. X            case 'G':
  83. X            case 'H':
  84. X            case 'I':
  85. X            case 'J':
  86. X            case 'K':
  87. X            case 'L':
  88. X            case 'M':
  89. X            case 'N':
  90. X            case 'O':
  91. X            case 'P':
  92. X            case 'Q':
  93. X            case 'R':
  94. X            case 'S':
  95. X            case 'T':
  96. X            case 'U':
  97. X            case 'V':
  98. X            case 'W':
  99. X            case 'X':
  100. X            case 'Y':
  101. X            case 'Z':
  102. X            case ' ':
  103. X            /* character matching */
  104. X            sprintf (matchstr, "%s%c", matchstr, exitkey);
  105. X            MATCHED = FALSE;
  106. X            for (i = 0; i < menu.optioncount; i++)
  107. X            {
  108. X                strcpy (command, menu.option[i]->description);
  109. X                upper (command);
  110. X                if (strncmp (command, matchstr, 
  111. X                    strlen(matchstr)) == 0)
  112. X                {
  113. X                    MATCHED = TRUE;
  114. X                    sprintf (select, "%d", 
  115. X                        menu.option[i]->opnumber);
  116. X                    *option = i + 1;
  117. X                    break;
  118. X                }
  119. X            }
  120. X            if (!MATCHED)
  121. X                strcpy (matchstr, "");
  122. X            break;
  123. X
  124. X        case KEY_EXITMENU:
  125. X            /* check if we have a .EXIT option */
  126. X            for (i = 0; i < menu.optioncount; i++)
  127. X                if (strcmp (menu.option[i]->keyword, ".EXIT") == 0)
  128. X                    RunExit (&menu, i, KeyWord, ParseKey, ShowKey, 
  129. X                        RunKey, gnames, gfiles, gindex);
  130. X            return (QUIT);
  131. X
  132. X        case KEY_MAINMENU:
  133. X            return (MAINMENU);
  134. X
  135. X        case KEY_PREVMENU:
  136. X            return (PREVIOUSMENU);
  137. X
  138. X        case '!':
  139. X            /*
  140. X        **    Shell Option.
  141. X        **    Prompt user for a command to be executed within a 
  142. X        **      shell (system(1)).
  143. X        */
  144. X            select[0] = '\0';
  145. X            mvaddch (ErrRow, 0, '!');
  146. X            move (ErrRow, 1);
  147. X            echo ();
  148. X            refresh ();
  149. X#ifdef ALARM
  150. X            alarm (0);        /* turn off mail check */
  151. X            signal (SIGALRM, SIG_IGN);
  152. X#endif
  153. X            getstr (select);
  154. X#ifdef ALARM
  155. X            if (MAILCALL)
  156. X                checkmail ();
  157. X#endif
  158. X            noecho ();
  159. X            sprintf (command, "%s;runrealid \"%s\";%s;%s",
  160. X#if BSD || SUN
  161. X                "clear",
  162. X#else
  163. X                "tput clear",
  164. X#endif
  165. X                select,
  166. X                "echo \"\\n[Press return to continue]\\c\"",
  167. X                "read reply");
  168. X            reset_shell_mode ();
  169. X            signal (SIGINT, shutdown);
  170. X            signal (SIGQUIT, shutdown);
  171. X            system (command);
  172. X            if (trapsigs)
  173. X            {
  174. X                signal (SIGINT, SIG_IGN);
  175. X                signal (SIGQUIT, SIG_IGN);
  176. X            }
  177. X            reset_prog_mode ();
  178. X            keypad (stdscr, TRUE);
  179. X            move (ErrRow,0);
  180. X            clrtoeol ();
  181. X            select[0] = '\0';
  182. X            matchstr[0] = '\0';
  183. X            clearok (stdscr, TRUE);
  184. X            break;
  185. X
  186. X        case KEY_HELP:
  187. X        /*
  188. X        **    Show Help Screen Option.
  189. X        **    Search directories for a menu.hlp file.
  190. X        **    If found display to screen.
  191. X        */
  192. X            strcpy (command, findfile ("menu.hlp", ".",
  193. X                getenv("HELPDIR"), getenv("MENUDIR"),
  194. X                ""));
  195. X#ifdef ALARM
  196. X            alarm (0);        /* turn off mail check */
  197. X            signal (SIGALRM, SIG_IGN);
  198. X#endif
  199. X            ShowHelp (command, "menu", ErrRow);
  200. X#ifdef ALARM
  201. X            if (MAILCALL)
  202. X                checkmail ();
  203. X#endif
  204. X            clearok (stdscr, TRUE);
  205. X            select[0] ='\0';
  206. X            matchstr[0] ='\0';
  207. X            break;
  208. X
  209. X        case KEY_GNAME:
  210. X            /*
  211. X            **    Goto Menu option
  212. X            **    Prompt user for the Gname (goto menu name) 
  213. X            **    that the user wants to go to.
  214. X            **    And then return GNAMEOFFSET + gindex to main.  
  215. X            **    The > GNAMEOFFSET indicates a goto menu option.
  216. X            */
  217. X            select[0] = '\0';
  218. X            echo ();
  219. X            mvprintw (ErrRow, 0, "Goto ");
  220. X#ifdef ALARM
  221. X            alarm (0);        /* turn off mail check */
  222. X            signal (SIGALRM, SIG_IGN);
  223. X#endif
  224. X            getstr (select);
  225. X#ifdef ALARM
  226. X            if (MAILCALL)
  227. X                checkmail ();
  228. X#endif
  229. X            noecho ();
  230. X            for (i = 0; i < gindex; i++)
  231. X            {
  232. X                if (strcmp (select, gnames[i]) == 0)
  233. X                    return (GNAMEOFFSET + i);
  234. X            }
  235. X            BEEP;
  236. X            attrset (A_REVERSE);
  237. X            mvprintw (ErrRow, 0, "[%s] not found.", select);
  238. X            attrset (A_NORMAL);
  239. X            select[0] = '\0';
  240. X            matchstr[0] ='\0';
  241. X            break;
  242. X
  243. X        case KEY_RETURN:
  244. X        case KEY_LINEFEED:
  245. X            /*
  246. X            **    We now take an action based upon what is in 
  247. X            **    select - that which the user typed in.
  248. X            */
  249. X            if (select[0] == KeyExitMenu)
  250. X            {
  251. X                /* check if we have a .EXIT option */
  252. X                for (i = 0; i < menu.optioncount; i++)
  253. X                    if (strcmp (menu.option[i]->keyword, 
  254. X                        ".EXIT") == 0)
  255. X                    {
  256. X                        RunExit (&menu, i, KeyWord,
  257. X                            ParseKey, ShowKey, RunKey,
  258. X                            gnames, gfiles, gindex);
  259. X                        break;
  260. X                    }
  261. X                return (QUIT);
  262. X            }
  263. X            if (select[0] == KeyMainMenu)    return (MAINMENU);
  264. X            if (select[0] == KeyPrevMenu)    return (PREVIOUSMENU);
  265. X
  266. X            /*
  267. X            **    Goto Menu option
  268. X            **    Prompt user for the Gname (goto menu name) 
  269. X            **    that the user wants to go to.
  270. X            **    And then return GNAMEOFFSET + gindex to main.  
  271. X            **    The > GNAMEOFFSET indicates a goto menu option.
  272. X            */
  273. X            if (select[0] == KeyGname)
  274. X            {
  275. X                select[0] = '\0';
  276. X                echo ();
  277. X                mvprintw (ErrRow, 0, "Goto ");
  278. X#ifdef ALARM
  279. X                alarm (0);    /* turn off mail check */
  280. X                signal (SIGALRM, SIG_IGN);
  281. X#endif
  282. X                getstr (select);
  283. X#ifdef ALARM
  284. X                if (MAILCALL)
  285. X                    checkmail ();
  286. X#endif
  287. X                noecho ();
  288. X                for (i = 0; i < gindex; i++)
  289. X                {
  290. X                    if (strcmp (select, gnames[i]) == 0)
  291. X                        return (GNAMEOFFSET + i);
  292. X                }
  293. X                BEEP;
  294. X                attrset (A_REVERSE);
  295. X                mvprintw (ErrRow, 0, "[%s] not found.", select);
  296. X                attrset (A_NORMAL);
  297. X                select[0] = '\0';
  298. X                matchstr[0] ='\0';
  299. X                break;
  300. X            }
  301. X
  302. X            /*
  303. X            **    Show Help Screen Option.
  304. X            **    Search directories for a menu.hlp file.
  305. X            **    If found display to screen.
  306. X            */
  307. X            if (select[0] == KeyHelp)
  308. X            {
  309. X                strcpy (command, findfile ("menu.hlp", 
  310. X                    ".", getenv("HELPDIR"), 
  311. X                    getenv("MENUDIR"), ""));
  312. X#ifdef ALARM
  313. X                alarm (0);        /* turn off mail check */
  314. X                signal (SIGALRM, SIG_IGN);
  315. X#endif
  316. X                ShowHelp (command, "menu", ErrRow);
  317. X#ifdef ALARM
  318. X                if (MAILCALL)
  319. X                    checkmail ();
  320. X#endif
  321. X                clearok (stdscr, TRUE);
  322. X                select[0] ='\0';
  323. X                matchstr[0] ='\0';
  324. X                break;
  325. X            }
  326. X
  327. X
  328. X            /*
  329. X            **    The user has manually typed in a option to be 
  330. X            **    executed.  Execute the appropriate option.
  331. X            */
  332. X            if (strlen (select) > 0)
  333. X            {
  334. X                index = matoi (select);
  335. X                if (index < 1  ||  index > lastopnumber)
  336. X                {
  337. X                    /* Invalid Option */
  338. X                    attrset (A_REVERSE);
  339. X                    mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
  340. X                    attrset (A_NORMAL);
  341. X                    select[0] = '\0';
  342. X                    break;
  343. X                }
  344. X                /* find the element cooresponding to opnumber */
  345. X                for (i = 0; i < menu.optioncount; i++)
  346. X                    if (index == menu.option[i]->opnumber)
  347. X                    {
  348. X                        *option = i+1;
  349. X                        break;
  350. X                    }
  351. X            }
  352. X
  353. X            /*
  354. X            **  Run the option the user selected.
  355. X            */
  356. X            for (i = 1; i <= MAXKEYS; i++)
  357. X                if (strcmp (menu.option[*option-1]->keyword, 
  358. X                    KeyWord[i]) == 0)
  359. X                {
  360. X                    if (RunKey[i] != NULL)
  361. X                    {
  362. X#ifdef ALARM
  363. X                        alarm (0); /* turn off mail */
  364. X                        signal (SIGALRM, SIG_IGN);
  365. X#endif
  366. X                        exitkey = (*RunKey[i]) (&menu, *option-1, KeyWord,
  367. X                            ParseKey, ShowKey, RunKey,
  368. X                            gnames, gfiles, gindex);
  369. X                        /* .MENU is a special case */
  370. X                        if (exitkey == SUBMENU)
  371. X                            return (*option-1);
  372. X                        if (exitkey == MAINMENU)
  373. X                            return (MAINMENU);
  374. X                        if (exitkey == PREVIOUSMENU)
  375. X                            return (PREVIOUSMENU);
  376. X                        if (exitkey == QUIT)
  377. X                            return (QUIT);
  378. X                        if (exitkey == REPARSE)
  379. X                            return (REPARSE);
  380. X                        if (exitkey >= GNAMEOFFSET  &&  
  381. X                            exitkey <= GNAMEOFFSET + gindex)
  382. X                            return (exitkey);
  383. X#ifdef ALARM
  384. X                        if (MAILCALL)
  385. X                            checkmail ();
  386. X#endif
  387. X                    }
  388. X                    break;
  389. X                }
  390. X            select[0] = '\0';
  391. X            matchstr[0] = '\0';
  392. X            break;
  393. X
  394. X        default:
  395. X            if (exitkey == KeyPopGname  &&  gindex > 0)
  396. X            {
  397. X                /*
  398. X                **   Popup menu for goto names.
  399. X                */
  400. X#ifdef ALARM
  401. X                alarm (0);    /* turn off mail check */
  402. X                signal (SIGALRM, SIG_IGN);
  403. X#endif
  404. X                popmenu (INITMENU, GOTOMENU, gotorow, gotocol, 
  405. X                    "GOTO MENU", HELPFILE, LINES-2, 
  406. X                    sizeof(gnames[0]), gnames);
  407. X
  408. X                move (ErrRow,0);
  409. X                clrtoeol ();
  410. X                BEEP;
  411. X                mvprintw (ErrRow, 0, "Goto what menu ?");
  412. X                refresh ();
  413. X                exitkey = popmenu (GOTOMENU, (char *)NULL);
  414. X                touchwin (stdscr);
  415. X                refresh ();
  416. X#ifdef ALARM
  417. X                if (MAILCALL)
  418. X                    checkmail ();
  419. X#endif
  420. X                if (exitkey >= 1  &&  exitkey <= gindex)
  421. X                    return (GNAMEOFFSET + exitkey-1);
  422. X            }
  423. X
  424. X            move (ErrRow,0);
  425. X            clrtoeol ();
  426. X            mvprintw (ErrRow, 0, "Say What.");
  427. X            select[0] = '\0';
  428. X            matchstr[0] = '\0';
  429. X            break;
  430. X        }
  431. X    }
  432. X}
  433. X
  434. X
  435. X
  436. X/*
  437. X**  My ascii to integer
  438. X**  Return -1 if string contains more than digits.
  439. X*/
  440. Xmatoi (s)
  441. X    char    *s;
  442. X{
  443. X    int    value;
  444. X
  445. X    value = atoi (s);
  446. X    while (*s)
  447. X    {
  448. X        if (*s < '0' || *s > '9')
  449. X            return (-1);
  450. X        s++;
  451. X    }
  452. X    return (value);
  453. X}
  454. X
  455. X
  456. X
  457. Xsetoption (row, col)
  458. X    int    row;
  459. X    int    col;
  460. X{
  461. X    static int    *saveoption;
  462. X    int        newoption;
  463. X    int        rc;
  464. X    int        j;
  465. X    int        ch;
  466. X    int        found;
  467. X
  468. X    /* find the option associated with this row/col */
  469. X    found = FALSE;
  470. X    for (newoption = 0; newoption < menu.optioncount; newoption++)
  471. X    {
  472. X        if (row == menu.option[newoption]->row &&
  473. X            (col >= menu.option[newoption]->col && 
  474. X             col <= (menu.option[newoption]->col + 
  475. X                 strlen(menu.option[newoption]->description))))
  476. X        {
  477. X            found = TRUE;
  478. X            break;
  479. X        }
  480. X    }
  481. X    newoption++;                    /* base 1 */
  482. X    if (debug)
  483. X    {
  484. X        fprintf (stderr, "\n[%s] newoption %d, %s, row %d, col %d",
  485. X            __FILE__,
  486. X            newoption, menu.option[newoption]->description,
  487. X            row, col);
  488. X        fflush (stderr);
  489. X    }
  490. X    if (!found  ||  newoption == tmpoption)
  491. X        return;
  492. X
  493. X
  494. X
  495. X    /* unhighlight current option */
  496. X#ifdef BSD
  497. X    standend ();
  498. X#else
  499. X    attrset (A_NORMAL);
  500. X#endif
  501. X    if (ShowKey[ckik] != NULL)
  502. X    {
  503. X        mvaddch (menu.option[(tmpoption)-1]->row, 
  504. X                menu.option[(tmpoption)-1]->col-1, ' ');
  505. X        strcat (menu.option[(tmpoption)-1]->description, " ");
  506. X        (*ShowKey[ckik]) (&menu, tmpoption-1);
  507. X        menu.option[(tmpoption)-1]->description[strlen(menu.option[(tmpoption)-1]->description)-1] = '\0';
  508. X    }
  509. X
  510. X
  511. X    tmpoption = newoption;
  512. X    /* highlight new option */
  513. X    for (ckik = 1; ckik <= MAXKEYS  &&  KeyWord[ckik] != NULL; 
  514. X         ckik++)
  515. X    {
  516. X        if (strcmp (menu.option[(tmpoption)-1]->keyword, 
  517. X            KeyWord[ckik]) == 0)
  518. X        {
  519. X            if (ShowKey[ckik] != NULL)
  520. X            {
  521. X                /* display option */
  522. X                (*ShowKey[ckik]) (&menu, (tmpoption)-1);
  523. X                mvaddch (menu.option[(tmpoption)-1]->row,
  524. X                       menu.option[(tmpoption)-1]->col-1, ' ');
  525. X                /*
  526. X                ** turn on reverse video 
  527. X                ** maintaining current attributes
  528. X                */
  529. X                rc =  slength(menu.option[(tmpoption)-1]->description) + menu.option[(tmpoption)-1]->col + 5;
  530. X                for (j = menu.option[(tmpoption)-1]->col-1; j <= rc; j++)
  531. X                {
  532. X                    ch = mvinch (menu.option[(tmpoption)-1]->row, j);
  533. X                    ch |= A_REVERSE;
  534. X                    mvaddch (menu.option[(tmpoption)-1]->row, j, ch);
  535. X                }
  536. X
  537. X            }
  538. X            break;
  539. X        } /* end if */
  540. X    }
  541. X
  542. X#ifdef BSD
  543. X    standend ();
  544. X#else
  545. X    attrset (A_NORMAL);
  546. X#endif
  547. X    refresh ();
  548. X}
  549. SHAR_EOF
  550. echo "File rundriver.c is complete"
  551. chmod 0644 rundriver.c || echo "restore of rundriver.c fails"
  552. echo "x - extracting ParseOpton.c (Text)"
  553. sed 's/^X//' << 'SHAR_EOF' > ParseOpton.c &&
  554. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  555. X
  556. X/*  FUNCTION:    ParseOption()
  557. X**        This function parses user selectable options.
  558. X**  ARGS:    keyword        the keyword found
  559. X**        menufile    the unix menu file
  560. X**        menu        menu structure
  561. X**        gnames        holder of goto menu names
  562. X**        gfiles        holder of goto menu names (menu file)
  563. X**        gindex        # of gnames
  564. X**  RETURNS:    0
  565. X*/
  566. X
  567. X#include    <curses.h>
  568. X#include    "menu.h"
  569. X
  570. Xextern    int    swin, ewin, longest;
  571. Xextern    int    debug;
  572. X
  573. X
  574. XParseOption (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  575. Xgindex, opnumber)
  576. X
  577. X    char        keyword[];
  578. X    FILE        *menufile;
  579. X    struct MenuInfo    *menu;
  580. X    char        KeyWord[][MAXKEYLENGTH];
  581. X    int        (*ParseKey[])();
  582. X    char        gnames[][15], gfiles[][15];
  583. X    int        *gindex;
  584. X    int        *opnumber;
  585. X{
  586. X    struct OptionInfo    *malloc();
  587. X    char            *getval();
  588. X    char        *fgets(), line[MAXLEN+100];
  589. X    int        i = 0;
  590. X    int        j;
  591. X    char        *ws;
  592. X
  593. X
  594. X    if (menu->optioncount >= MAXOPTION)
  595. X    {
  596. X        BEEP;
  597. X        mvprintw (ErrRow-2, 0, "Exceeded maximum allowable options.");
  598. X        shutdown ();
  599. X    }
  600. X    menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
  601. X    if (menu->option[menu->optioncount] == NULL)
  602. X    {
  603. X        BEEP;
  604. X        mvprintw (ErrRow-2, 0, "Unable to allocate memory for option.");
  605. X        shutdown ();
  606. X    }
  607. X
  608. X    strcpy (menu->option[menu->optioncount]->keyword, keyword);
  609. X
  610. X    /*
  611. X    **    Read in option command
  612. X    **    strcat continuation lines
  613. X    */
  614. X    fgets (line, sizeof(line)-1, menufile);
  615. X    line[strlen(line)-1] = '\0';            /* get rid of \n */
  616. X    while (line[strlen(line)-1] == '\\')
  617. X    {
  618. X        if (strlen(line) >= MAXLEN)
  619. X        {
  620. X            BEEP;
  621. X            mvprintw (ErrRow-2, 0, 
  622. X                "Option command is too long.  Max = %d",MAXLEN);
  623. X            shutdown ();
  624. X        }
  625. X        line[strlen(line)-1] = '\n';        /* replace \ with \n */
  626. X        fgets (line+strlen(line), sizeof(line)-1, menufile);
  627. X        line[strlen(line)-1] = '\0';        /* get rid of \n */
  628. X    }
  629. X    menu->option[menu->optioncount]->command = 
  630. X                (char *) malloc (strlen(line)+5);
  631. X    strcpy (menu->option[menu->optioncount]->command, line);
  632. X    if (debug)
  633. X    {
  634. X        fprintf (stderr, "\n[ParseOpton] <%s> command=:%s:",
  635. X            keyword, menu->option[menu->optioncount]->command);
  636. X        fflush (stderr);
  637. X    }
  638. X
  639. X    /*
  640. X    **    Read in option description
  641. X    */
  642. X    fgets (line, BUFSIZE+1, menufile);
  643. X    line[strlen(line)-1] = '\0';
  644. X    for (j = 0, i = 0; i < strlen (line); j++, i++)
  645. X        if (line[i] == '$')
  646. X        {
  647. X            char    *sptr, *b4ptr;
  648. X
  649. X            sptr = b4ptr = line+i;
  650. X            strcpy (menu->option[menu->optioncount]->description+j, 
  651. X                getval (&sptr, '$'));
  652. X            i += (int)(sptr - b4ptr);
  653. X            j += strlen (menu->option[menu->optioncount]->description+j) - 1;
  654. X            i--;
  655. X        }
  656. X        else
  657. X        {
  658. X            menu->option[menu->optioncount]->description[j] = line[i];
  659. X        }
  660. X    menu->option[menu->optioncount]->description[j] = '\0';
  661. X
  662. X
  663. X    /*
  664. X    **    Determine length of longest option
  665. X    */
  666. X    if (slength (menu->option[menu->optioncount]->description) > longest)
  667. X        longest = slength(menu->option[menu->optioncount]->description);
  668. X
  669. X    /* set option number 2b displayed */
  670. X    (*opnumber)++;
  671. X    menu->option[menu->optioncount]->opnumber = *opnumber;
  672. X
  673. X    menu->optioncount++;
  674. X    ewin++;
  675. X    return (0);
  676. X}
  677. SHAR_EOF
  678. chmod 0644 ParseOpton.c || echo "restore of ParseOpton.c fails"
  679. echo "x - extracting ParseBaner.c (Text)"
  680. sed 's/^X//' << 'SHAR_EOF' > ParseBaner.c &&
  681. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  682. X
  683. X/*  FUNCTION:    ParseBanner()
  684. X**        Parses the "BANNER" keyword.
  685. X**  RETURNS:    0
  686. X*/
  687. X
  688. X#include    <curses.h>
  689. X#include    "menu.h"
  690. X
  691. X
  692. XParseBanner (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  693. X    gindex, opnumber)
  694. X
  695. X    char        keyword[];
  696. X    FILE        *menufile;
  697. X    struct MenuInfo    *menu;
  698. X    char        KeyWord[][MAXKEYLENGTH];
  699. X    int        (*ParseKey[])();
  700. X    char        gnames[][15], gfiles[][15];
  701. X    int        *gindex;
  702. X    int        *opnumber;
  703. X{
  704. X    static int    onetime = FALSE;        /* show only 1 time */
  705. X    int    row, col, rstart, rstop, cstart, cstop;
  706. X    int    ulc=0, llc=0, linecount, increment;
  707. X    char    flag[5], tophalf[4][30], lower[4][30];
  708. X
  709. X
  710. X   fscanf (menufile, "%d", &linecount);
  711. X
  712. X/*
  713. X**    Load the input banner text into tophalf and lower arrays.
  714. X*/
  715. X
  716. X   for (row = 1; row <= linecount; row++)
  717. X   {
  718. X      fscanf (menufile, "%s", flag);
  719. X      if (strncmp (flag, ".U", 2) == 0)
  720. X      {
  721. X         fgets (tophalf[ulc], 80, menufile);
  722. X         tophalf[ulc][strlen(tophalf[ulc])-1] = '\0';
  723. X         ulc++;
  724. X      }
  725. X      else
  726. X      {
  727. X         fgets (lower[llc], 80, menufile);
  728. X         lower[llc][strlen(lower[llc])-1] = '\0';
  729. X         llc++;
  730. X      }
  731. X   }
  732. X
  733. X   if (onetime)
  734. X    return (0);
  735. X   onetime++;
  736. X
  737. X#ifdef BSD
  738. X   standout ();
  739. X#else
  740. X   attrset (A_STANDOUT);
  741. X#endif
  742. X   for (rstart = 24/2-1, rstop = 24/2+1, 
  743. X        cstart = COLS/2-2, cstop = COLS/2+1;
  744. X        rstart >= 0 && rstop <= 23 && cstart >= 0 && cstop <= COLS-1;
  745. X        rstart--, rstop++, cstart-=3, cstop+=3)
  746. X   {
  747. X      for (row = rstart; row <= rstop; row++)
  748. X      {
  749. X         if (row == rstart  ||  row == rstop)
  750. X         {
  751. X            for (col = cstart; col <= cstop; col++)
  752. X               mvaddch (row, col, BORDERCHAR);
  753. X         }
  754. X         else
  755. X         {
  756. X            mvaddch (row, cstart, BORDERCHAR);
  757. X            mvaddch (row, cstop, BORDERCHAR);
  758. X         }
  759. X      }
  760. X      refresh ();
  761. X   }
  762. X
  763. X   increment = 2;
  764. X   for (rstart = rstart+3, rstop=rstop-2, cstart = cstart+1, cstop = cstop-1;
  765. X        cstart >= 0  &&  cstop <= COLS-1;
  766. X        rstart++, rstop--, cstart-=increment, cstop+=increment)
  767. X   {
  768. X      for (row = 1; row <= 23; row++)
  769. X      {
  770. X         if (row < rstart  ||  row > rstop)
  771. X         {
  772. X            for (col = cstart; col <= cstart+increment; col++)
  773. X               mvaddch (row, col, BORDERCHAR);
  774. X            for (col = cstop-increment; col <= cstop; col++)
  775. X               mvaddch (row, col, BORDERCHAR);
  776. X         }
  777. X         else
  778. X         {
  779. X            mvaddch (row, cstart, BORDERCHAR);
  780. X            mvaddch (row, cstop, BORDERCHAR);
  781. X         }
  782. X      }
  783. X      refresh ();
  784. X   }
  785. X
  786. X#ifdef BSD
  787. X   standout ();
  788. X#else
  789. X   attrset (A_REVERSE);
  790. X#endif
  791. X   for (row = 0; ulc > 0; row++, ulc--)
  792. X      mvprintw (row+4, COLS/2-strlen(tophalf[row])/2-1, "%s", tophalf[row]);
  793. X   for (row = 0; llc > 0; row++, llc--)
  794. X      mvprintw (row+17, COLS/2-strlen(lower[row])/2-1, "%s", lower[row]);
  795. X
  796. X   mvprintw (23, 27, "Press return to continue");
  797. X   move (23,0);
  798. X   getch ();
  799. X   refresh ();
  800. X#ifdef BSD
  801. X   standend ();
  802. X#else
  803. X   attrset (A_NORMAL);
  804. X#endif
  805. X   move (0,0); clrtobot ();
  806. X   return (0);
  807. X}
  808. SHAR_EOF
  809. chmod 0644 ParseBaner.c || echo "restore of ParseBaner.c fails"
  810. echo "x - extracting ParseTitle.c (Text)"
  811. sed 's/^X//' << 'SHAR_EOF' > ParseTitle.c &&
  812. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  813. X
  814. X/*  FUNCTION:    ParseTitle()
  815. X**        Parses keyword "TITLE".
  816. X**  ARGS:    keyword        the keyword "TITLE"
  817. X**        menufile    the unix menu file
  818. X**        menu        menu structure
  819. X**        gnames        holder of goto menu names
  820. X**        gfiles        holder of goto menu names (menu file)
  821. X**        gindex        # of gnames
  822. X**  RETURNS:    0
  823. X*/
  824. X
  825. X#include    <curses.h>
  826. X#include    "menu.h"
  827. X
  828. X
  829. Xextern int    MAILCALL;
  830. Xextern int    mailrow;
  831. Xextern int    mailcol;
  832. X
  833. X
  834. XParseTitle (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  835. X    gindex, opnumber)
  836. X
  837. X    char        keyword[];
  838. X    FILE        *menufile;
  839. X    struct MenuInfo    *menu;
  840. X    char        KeyWord[][MAXKEYLENGTH];
  841. X    int        (*ParseKey[])();
  842. X    char        gnames[][15], gfiles[][15];
  843. X    int        *gindex;
  844. X    int        *opnumber;
  845. X{
  846. X    char    *fgets(), line[201];
  847. X    char    *getenv();
  848. X    char    *getval();
  849. X    char    section[3][201];          /* section[0] = left justified */
  850. X                          /* section[1] = centered */
  851. X                          /* section[2] = right justified */
  852. X    int    i = 0;                  /* index into line */
  853. X    int    j;                  /* index into section */
  854. X    int    k, row, col;
  855. X    char    *ws;
  856. X    int    mailsection=999;          /* section $MAIL was found */
  857. X                          /* we set to 999 so sub menus */
  858. X                          /* that don't have a $MAIL wont */
  859. X                          /* recalculate mailcol */
  860. X
  861. X
  862. X
  863. X   fgets (line, 200, menufile);
  864. X
  865. X/*
  866. X**    Get title line
  867. X*/
  868. X   fgets (line, 200, menufile);
  869. X   line[strlen(line)-1] = '\0';
  870. X   
  871. X   section[0][0] = section[1][0] = section[2][0] = '\0';
  872. X
  873. X/*
  874. X**    Now we break input line into left, center, and right sections
  875. X**    Loop through each section.
  876. X*/
  877. X
  878. X   for (k = 0; k <= 2; k++)
  879. X   {
  880. X      /* Loop through each character of line until we find next section */
  881. X      for (j = 0; i < strlen (line)  &&  strncmp (line+i, "...", 3) != 0;
  882. X          i++, j++)
  883. X      {
  884. X         if (strncmp (line+i, "$DATE", 5) == 0)
  885. X         {
  886. X            sysdate (section[k]+j, "mm/dd/yy");
  887. X            j += 7;
  888. X            i += 4;
  889. X         }
  890. X         else
  891. X            if (strncmp (line+i, "$TIME", 5) == 0)
  892. X            {
  893. X               systime (section[k]+j, "HH:MM zz");
  894. X               j += 7;
  895. X               i += 4;
  896. X            }
  897. X            else
  898. X               if (strncmp (line+i, "$MAIL", 5) == 0)
  899. X           {
  900. X          /*
  901. X          **  User wants 2b notified when mail arrives.
  902. X          **  The mailfile is located in enviroment $MAIL
  903. X          **  if the mailfile exists and size is greater than zero
  904. X          **  mailfile = getenv("$MAIL")
  905. X          **  We need to process entire line b4 we find mailcol
  906. X          */
  907. X          MAILCALL = TRUE;
  908. X          strcpy (section[k]+j, "mAiL");    /* unique ? */
  909. X          mailrow = menu->titlecount;
  910. X          mailsection = k;
  911. X                  i += 4;                /* get past $MAIL */
  912. X                  j += 3;                /* for "MAIL" */
  913. X           }
  914. X           else
  915. X          /*
  916. X          **  A environment variable
  917. X          */
  918. X                  if (line[i] == '$')
  919. X                 {
  920. X            char    *sptr, *b4ptr;
  921. X
  922. X             sptr = b4ptr = line+i;
  923. X             strcpy (section[k]+j, getval (&sptr, '$'));
  924. X             i += (int)(sptr - b4ptr);
  925. X             j += strlen (section[k]+j) - 1;
  926. X             i--;
  927. X              }
  928. X              else
  929. X                     section[k][j] = line[i];
  930. X      }
  931. X      section[k][j] = '\0';
  932. X      i += 3;
  933. X   }
  934. X
  935. X   if (menu->titlecount >= MAXTITLE)
  936. X   {
  937. X      BEEP;
  938. X      mvprintw (ErrRow, 0, "Number of Title lines exceed the maximim.");
  939. X      shutdown ();
  940. X   }
  941. X   (menu->titlecount)++;
  942. X   (menu->wfrow)++;            /* reduce window size to center in */
  943. X
  944. X
  945. X/*
  946. X**    Now we display the three sections to the screen
  947. X*/
  948. X
  949. X   for (k = 0; k <= 2; k++)
  950. X   {
  951. X/*
  952. X**    First we must find out what column to start displaying on.
  953. X**    Taking into account the terminal attribute characters.
  954. X*/
  955. X      switch (k)
  956. X      {
  957. X         case 0:
  958. X            /* left justified */
  959. X            row = menu->titlecount - 1;
  960. X            col = 0;
  961. X            break;
  962. X     case 1:
  963. X            /* center */
  964. X            for (i = 0, j = 0; section[k][i] != '\0'; i++)
  965. X               if (section[k][i] == '\\') j++;
  966. X            col = COLS/2-(strlen(section[k])-j*2)/2;
  967. X            col -= (((strlen(section[k])-j*2) % 2) == 0) ? 0 : 1;
  968. X            row = menu->titlecount - 1;
  969. X            move (menu->titlecount-1, i); 
  970. X            break;
  971. X     case 2:
  972. X            /* right justify */
  973. X            for (i = 0, j = 0; section[k][i] != '\0'; i++)
  974. X               if (section[k][i] == '\\') j++;
  975. X            row = menu->titlecount - 1;
  976. X            col = COLS-strlen(section[k])+j*2;
  977. X            break;
  978. X      }  /* end switch */
  979. X
  980. X      if (MAILCALL  &&  mailsection == k)
  981. X      {
  982. X         /* find mailcol - remember the attributes */
  983. X         for (i = 0, j = 0; section[k][i] != '\0' &&
  984. X              strncmp (section[k]+i, "mAiL", 4) != 0; i++)
  985. X            if (section[k][i] == '\\') j++;
  986. X         mailcol = i - j*2 + col;        /* for \R */
  987. X     memcpy (section[k]+i, "    ", 4);        /* get rid of mAiL */
  988. X      }
  989. X
  990. X      displaytext (stdscr, row, col, section[k]);
  991. X   }  /* end for loop */
  992. X#ifdef ALARM
  993. X   if (MAILCALL)
  994. X      checkmail ();
  995. X#endif
  996. X   return (0);
  997. X}
  998. SHAR_EOF
  999. chmod 0644 ParseTitle.c || echo "restore of ParseTitle.c fails"
  1000. echo "x - extracting ParseBox.c (Text)"
  1001. sed 's/^X//' << 'SHAR_EOF' > ParseBox.c &&
  1002. Xstatic char Sccsid[] = "@(#)ParseBox.c    1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1003. X
  1004. X/*  FUNCTION:    ParseBox()
  1005. X**        Parses keyword ".BOX".
  1006. X**  ARGS:    keyword        the keyword "BOX"
  1007. X**        menufile    the unix menu file
  1008. X**        menu        menu structure
  1009. X**        gnames        holder of goto menu names
  1010. X**        gfiles        holder of goto menu names (menu file)
  1011. X**        gindex        # of gnames
  1012. X*/
  1013. X
  1014. X#include    <curses.h>
  1015. X#include    <ctype.h>
  1016. X#include    "menu.h"
  1017. X
  1018. X
  1019. XParseBox (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1020. X    gindex, opnumber)
  1021. X
  1022. X    char        keyword[];
  1023. X    FILE        *menufile;
  1024. X    struct MenuInfo    *menu;
  1025. X    char        KeyWord[][MAXKEYLENGTH];
  1026. X    int        (*ParseKey[])();
  1027. X    char        gnames[][15], gfiles[][15];
  1028. X    int        *gindex;
  1029. X    int        *opnumber;
  1030. X{
  1031. X    char        *fgets(), line[BUFSIZE+1];
  1032. X    char        boxtype[30];
  1033. X    char        *sptr;
  1034. X
  1035. X    /* Default Values */
  1036. X    menu->boxtype = StandoutLine;
  1037. X    menu->boxtype = menu->boxtype | (DumbLine << 9);
  1038. X
  1039. X    fgets (line, BUFSIZE, menufile);
  1040. X    sptr = line;
  1041. X    SKIPJUNK(sptr);
  1042. X
  1043. X    /* get border type for active menu */
  1044. X    sscanf (sptr, "%s", boxtype);
  1045. X    sptr += strlen(boxtype);
  1046. X    if (strcmp (boxtype, "DumbLine") == 0)
  1047. X        menu->boxtype = DumbLine;
  1048. X    else    if (strcmp (boxtype, "StandoutLine") == 0)
  1049. X            menu->boxtype = StandoutLine;
  1050. X    else    if (strcmp (boxtype, "SingleLine") == 0 ||
  1051. X            strcmp (boxtype, "DrawLine") == 0)
  1052. X            menu->boxtype = SingleLine;
  1053. X    else    if (strcmp (boxtype, "MosaicLine") == 0)
  1054. X            menu->boxtype = MosaicLine;
  1055. X    else    if (strcmp (boxtype, "DiamondLine") == 0)
  1056. X            menu->boxtype = DiamondLine;
  1057. X    else    if (strcmp (boxtype, "DotLine") == 0)
  1058. X            menu->boxtype = DotLine;
  1059. X    else    if (strcmp (boxtype, "PlusLine") == 0)
  1060. X            menu->boxtype = PlusLine;
  1061. X
  1062. X    /* get border type for inactive menu - dim (high 8 bits) */
  1063. X    sscanf (sptr, "%s", boxtype);
  1064. X    sptr += strlen(boxtype);
  1065. X    if (strcmp (boxtype, "DumbLine") == 0)
  1066. X        menu->boxtype = menu->boxtype | (DumbLine << 9);
  1067. X    else    if (strcmp (boxtype, "StandoutLine") == 0)
  1068. X            menu->boxtype = menu->boxtype | (DumbLine << 9);
  1069. X    else    if (strcmp (boxtype, "SingleLine") == 0 ||
  1070. X            strcmp (boxtype, "DrawLine") == 0)
  1071. X            menu->boxtype = menu->boxtype | (SingleLine << 9);
  1072. X    else    if (strcmp (boxtype, "MosaicLine") == 0)
  1073. X            menu->boxtype = menu->boxtype | (MosaicLine << 9);
  1074. X    else    if (strcmp (boxtype, "DiamondLine") == 0)
  1075. X            menu->boxtype = menu->boxtype | (DiamondLine << 9);
  1076. X    else    if (strcmp (boxtype, "DotLine") == 0)
  1077. X            menu->boxtype = menu->boxtype | (DotLine << 9);
  1078. X    else    if (strcmp (boxtype, "PlusLine") == 0)
  1079. X            menu->boxtype = menu->boxtype | (PlusLine << 9);
  1080. X
  1081. X    drawbox (stdscr, 1,1, LINES-1,COLS, menu->boxtype & 0777, StandoutLine,
  1082. X        FALSE, FALSE);
  1083. X       return (0);
  1084. X}
  1085. SHAR_EOF
  1086. chmod 0444 ParseBox.c || echo "restore of ParseBox.c fails"
  1087. echo "x - extracting ParseWindo.c (Text)"
  1088. sed 's/^X//' << 'SHAR_EOF' > ParseWindo.c &&
  1089. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1090. X
  1091. X/*  FUNCTION:    ParseWindow()
  1092. X**        Parses keyword ".WINDOW".
  1093. X**  ARGS:    keyword        the keyword "WINDOW"
  1094. X**        menufile    the unix menu file
  1095. X**        menu        menu structure
  1096. X**        gnames        holder of goto menu names
  1097. X**        gfiles        holder of goto menu names (menu file)
  1098. X**        gindex        # of gnames
  1099. X**  RETURNS:    0
  1100. X*/
  1101. X
  1102. X#include    <curses.h>
  1103. X#include    "menu.h"
  1104. X
  1105. Xextern    int    swin, ewin, longest;
  1106. X
  1107. XParseWindow (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1108. X    gindex, opnumber)
  1109. X
  1110. X    char        keyword[];
  1111. X    FILE        *menufile;
  1112. X    struct MenuInfo    *menu;
  1113. X    char        KeyWord[][MAXKEYLENGTH];
  1114. X    int        (*ParseKey[])();
  1115. X    char        gnames[][15], gfiles[][15];
  1116. X    int        *gindex;
  1117. X    int        *opnumber;
  1118. X{
  1119. X    int        i, j, row, col;
  1120. X    char        line[BUFSIZE];
  1121. X
  1122. X
  1123. X   EndWindow (menu);
  1124. X
  1125. X   fscanf (menufile, "%d", &menu->wfrow);
  1126. X   if (menu->wfrow < 0)   menu->wfrow = 0;
  1127. X   if (menu->wfrow < menu->titlecount) menu->wfrow = menu->titlecount;
  1128. X   if (menu->wfrow > LINES-1)   menu->wfrow = LINES-1;
  1129. X   fscanf (menufile, "%d", &menu->wlrow);
  1130. X   if (menu->wlrow < 0)   menu->wlrow = 0;
  1131. X   if (menu->wlrow > LINES-1)   menu->wlrow = LINES-1;
  1132. X   fscanf (menufile, "%d", &menu->wfcol);
  1133. X   if (menu->wfcol < 0)   menu->wfcol = 0;
  1134. X   if (menu->wfcol > COLS-1)   menu->wfcol = COLS-1;
  1135. X   fscanf (menufile, "%d", &menu->wlcol);
  1136. X   if (menu->wlcol < 0)   menu->wlcol = 0;
  1137. X   if (menu->wlcol > COLS-1)   menu->wlcol = COLS-1;
  1138. X
  1139. X/*
  1140. X**    Now lets read in the window heading.
  1141. X*/
  1142. X   fgets (line, BUFSIZE+1, menufile);
  1143. X   line[strlen(line)-1] = '\0';
  1144. X
  1145. X/*
  1146. X**    Determine where to display heading.
  1147. X*/
  1148. X   for (i = 0, j = 0; line[i] != '\0'; i++)
  1149. X      if (line[i] == '\\') j++;
  1150. X   row = menu->wfrow - 1;
  1151. X   col = (menu->wlcol - menu->wfcol)/2-(strlen(line)-1-j*2)/2 + menu->wfcol;
  1152. X   col -= (((strlen(line)-1-j*2) % 2) == 0) ? 0 : 1;
  1153. X   if (strlen(line) > 0)   displaytext (stdscr, row, col, line+1);
  1154. X   
  1155. X   longest = 0;
  1156. X   swin = ewin;
  1157. X   return (0);
  1158. X}
  1159. SHAR_EOF
  1160. chmod 0644 ParseWindo.c || echo "restore of ParseWindo.c fails"
  1161. echo "x - extracting ParseLine.c (Text)"
  1162. sed 's/^X//' << 'SHAR_EOF' > ParseLine.c &&
  1163. Xstatic char Sccsid[] = "@(#)ParseLine.c    1.6   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1164. X
  1165. X/*  FUNCTION:    ParseLine()
  1166. X**        Parses keyword "LINE".
  1167. X**  ARGS:    keyword        the keyword "LINE"
  1168. X**        menufile    the unix menu file
  1169. X**        menu        menu structure
  1170. X**        gnames        holder of goto menu names
  1171. X**        gfiles        holder of goto menu names (menu file)
  1172. X**        gindex        # of gnames
  1173. X*/
  1174. X
  1175. X#include    <curses.h>
  1176. X#include    <ctype.h>
  1177. X#include    "menu.h"
  1178. X
  1179. X
  1180. X
  1181. XParseLine (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1182. X    gindex, opnumber)
  1183. X
  1184. X    char        keyword[];
  1185. X    FILE        *menufile;
  1186. X    struct MenuInfo    *menu;
  1187. X    char        KeyWord[][MAXKEYLENGTH];
  1188. X    int        (*ParseKey[])();
  1189. X    char        gnames[][15], gfiles[][15];
  1190. X    int        *gindex;
  1191. X    int        *opnumber;
  1192. X{
  1193. X    int    col;
  1194. X    char        *fgets(), line[BUFSIZE+1];
  1195. X    char        linetype[30];
  1196. X    char        *sptr;
  1197. X
  1198. X
  1199. X    /* default values */
  1200. X    menu->linetype = StandoutLine;
  1201. X    menu->linetype = menu->linetype | (DumbLine << 9);
  1202. X
  1203. X    fgets (line, BUFSIZE, menufile);
  1204. X    sptr = line;
  1205. X    SKIPJUNK(sptr);
  1206. X
  1207. X    /* get border type for active menu */
  1208. X    sscanf (sptr, "%s", linetype);
  1209. X    sptr += strlen(linetype);
  1210. X    if (strcmp (linetype, "DumbLine") == 0)
  1211. X        menu->linetype = DumbLine;
  1212. X    else    if (strcmp (linetype, "StandoutLine") == 0)
  1213. X            menu->linetype = StandoutLine;
  1214. X    else    if (strcmp (linetype, "SingleLine") == 0 ||
  1215. X            strcmp (linetype, "DrawLine") == 0)
  1216. X            menu->linetype = SingleLine;
  1217. X    else    if (strcmp (linetype, "MosaicLine") == 0)
  1218. X            menu->linetype = MosaicLine;
  1219. X    else    if (strcmp (linetype, "DiamondLine") == 0)
  1220. X            menu->linetype = DiamondLine;
  1221. X    else    if (strcmp (linetype, "DotLine") == 0)
  1222. X            menu->linetype = DotLine;
  1223. X    else    if (strcmp (linetype, "PlusLine") == 0)
  1224. X            menu->linetype = PlusLine;
  1225. X
  1226. X    /* get border type for inactive menu - dim (high 8 bits) */
  1227. X    sscanf (sptr, "%s", linetype);
  1228. X    sptr += strlen(linetype);
  1229. X    if (strcmp (linetype, "DumbLine") == 0)
  1230. X        menu->linetype = menu->linetype | (DumbLine << 9);
  1231. X    else    if (strcmp (linetype, "StandoutLine") == 0)
  1232. X            menu->linetype = menu->linetype | (DumbLine << 9);
  1233. X    else    if (strcmp (linetype, "SingleLine") == 0 ||
  1234. X            strcmp (linetype, "DrawLine") == 0)
  1235. X            menu->linetype = menu->linetype | (SingleLine << 9);
  1236. X    else    if (strcmp (linetype, "MosaicLine") == 0)
  1237. X            menu->linetype = menu->linetype | (MosaicLine << 9);
  1238. X    else    if (strcmp (linetype, "DiamondLine") == 0)
  1239. X            menu->linetype = menu->linetype | (DiamondLine << 9);
  1240. X    else    if (strcmp (linetype, "DotLine") == 0)
  1241. X            menu->linetype = menu->linetype | (DotLine << 9);
  1242. X    else    if (strcmp (linetype, "PlusLine") == 0)
  1243. X            menu->linetype = menu->linetype | (PlusLine << 9);
  1244. X
  1245. X    drawline (stdscr, menu->titlecount, menu->linetype&0777, StandoutLine,
  1246. X            menu->boxtype);
  1247. X
  1248. X       menu->titlecount++;
  1249. X       return (0);
  1250. X}
  1251. SHAR_EOF
  1252. chmod 0444 ParseLine.c || echo "restore of ParseLine.c fails"
  1253. echo "x - extracting ParseComnt.c (Text)"
  1254. sed 's/^X//' << 'SHAR_EOF' > ParseComnt.c &&
  1255. Xstatic char Sccsid[] = "@(#)ParseComnt.c    1.5   DeltaDate 11/13/88   ExtrDate 1/22/90";
  1256. X
  1257. X/*  FUNCTION:    ParseComnt()
  1258. X**        Parses keyword "###".
  1259. X##        A comment line.
  1260. X**  ARGS:    keyword        the keyword "###"
  1261. X**        menufile    the unix menu file
  1262. X**        menu        menu structure
  1263. X**        gnames        holder of goto menu names
  1264. X**        gfiles        holder of goto menu names (menu file)
  1265. X**        gindex        # of gnames
  1266. X*/
  1267. X
  1268. X#include    <curses.h>
  1269. X#include    "menu.h"
  1270. X
  1271. X
  1272. XParseComnt (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1273. X    gindex, opnumber)
  1274. X
  1275. X    char        keyword[];
  1276. X    FILE        *menufile;
  1277. X    struct MenuInfo    *menu;
  1278. X    char        KeyWord[][MAXKEYLENGTH];
  1279. X    int        (*ParseKey[])();
  1280. X    char        gnames[][15], gfiles[][15];
  1281. X    int        *gindex;
  1282. X    int        *opnumber;
  1283. X{
  1284. X    char    *fgets(), line[BUFSIZE+1];
  1285. X
  1286. X
  1287. X       fgets (line, BUFSIZE, menufile);
  1288. X    return (0);
  1289. X}
  1290. SHAR_EOF
  1291. chmod 0444 ParseComnt.c || echo "restore of ParseComnt.c fails"
  1292. echo "x - extracting ParseUnix.c (Text)"
  1293. sed 's/^X//' << 'SHAR_EOF' > ParseUnix.c &&
  1294. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1295. X
  1296. X/*  FUNCTION:    ParseUnix()
  1297. X**        Parses keyword ".unix".
  1298. X**  ARGS:    keyword        the keyword "unix"
  1299. X**        menufile    the unix menu file
  1300. X**        menu        menu structure
  1301. X**        gnames        holder of goto menu names
  1302. X**        gfiles        holder of goto menu names (menu file)
  1303. X**        gindex        # of gnames
  1304. X**  RETURNS:    none
  1305. X*/
  1306. X
  1307. X#include    <curses.h>
  1308. X#include    <ctype.h>
  1309. X#include    <signal.h>
  1310. X#include    "menu.h"
  1311. X
  1312. Xextern    int    debug;
  1313. Xextern    int    trapsigs;
  1314. X
  1315. X
  1316. X
  1317. XParseUnix (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1318. X        gindex, opnumber)
  1319. X
  1320. X    char        keyword[];
  1321. X    FILE        *menufile;
  1322. X    struct MenuInfo    *menu;
  1323. X    char        KeyWord[][MAXKEYLENGTH];
  1324. X    int        (*ParseKey[])();
  1325. X    char        gnames[][15], gfiles[][15];
  1326. X    int        *gindex;
  1327. X    int        *opnumber;
  1328. X{
  1329. X    int        shutdown();
  1330. X    char        command[MAXLEN+1];
  1331. X    int        rc;
  1332. X    char        *comptr;
  1333. X    char        tmpstr[80];
  1334. X    int        redrawflag = FALSE;
  1335. X
  1336. X
  1337. X
  1338. X    /*
  1339. X    **    Read in option command
  1340. X    **    strcat continuation lines
  1341. X    */
  1342. X       fgets (command, sizeof(command)-1, menufile);
  1343. X       command[strlen(command)-1] = '\0';        /* get rid of \n */
  1344. X       while (command[strlen(command)-1] == '\\')
  1345. X       {
  1346. X              if (strlen(command) > MAXLEN)
  1347. X              {
  1348. X                 BEEP;
  1349. X                 mvprintw (ErrRow-2, 0, 
  1350. X                ".UNIX command is too long.  Max = %d",MAXLEN);
  1351. X                 shutdown ();
  1352. X              }
  1353. X              command[strlen(command)-1] = '\n';    /* replace \ with \n */
  1354. X              fgets (command+strlen(command), sizeof(command)-1, menufile);
  1355. X              command[strlen(command)-1] = '\0';    /* get rid of \n */
  1356. X       }
  1357. X
  1358. X    comptr = command;
  1359. X    SKIPJUNK(comptr);
  1360. X       sscanf (comptr, "%s", tmpstr);        /* do we have a REDRAW */
  1361. X    if (strcmp (tmpstr, "REDRAW") == 0)
  1362. X    {
  1363. X        redrawflag = TRUE;
  1364. X        comptr += strlen(tmpstr);
  1365. X        SKIPJUNK(comptr);
  1366. X           sscanf (comptr, "%s", tmpstr);    /* do we have a GETINPUT */
  1367. X    }
  1368. X
  1369. X    if (strcmp (tmpstr, "GETINPUT") == 0)
  1370. X    {
  1371. X        /* get screen name */
  1372. X        comptr += strlen(tmpstr);
  1373. X        SKIPJUNK(comptr);
  1374. X           sscanf (comptr, "%s", tmpstr);        /* screen name */
  1375. X        comptr += strlen(tmpstr);
  1376. X        SKIPJUNK(comptr);        /* sitting at system(3) */
  1377. X        rc = runscreen (tmpstr, menu, *opnumber);
  1378. X        if (rc == KEY_CANCEL)
  1379. X            return (0);
  1380. X    }
  1381. X
  1382. X    reset_shell_mode ();
  1383. X    signal (SIGINT, shutdown);
  1384. X    signal (SIGQUIT, shutdown);
  1385. X       rc = system (comptr);
  1386. X    if (trapsigs)
  1387. X    {
  1388. X        signal (SIGINT, SIG_IGN);
  1389. X        signal (SIGQUIT, SIG_IGN);
  1390. X    }
  1391. X    reset_prog_mode ();
  1392. X    keypad (stdscr, TRUE);
  1393. X
  1394. X    /*
  1395. X    **  Going from a shell return code (char) to a c return code (int)
  1396. X    **  the shell return code gets put in the high byte.  So we will
  1397. X    **  shift the int right 8 bytes.
  1398. X    */
  1399. X    rc = rc >> 8;                    /* to get shell rc */
  1400. X    if (debug)
  1401. X    {
  1402. X        fprintf (stderr, "\n[%s] <%s> rc=%d  command=%s", 
  1403. X            __FILE__, keyword, rc, comptr);
  1404. X        fflush (stderr);
  1405. X    }
  1406. X
  1407. X    /*
  1408. X    **  Shell can't handle negative return codes so we will convert 
  1409. X    **  the return code to negative so menu can use it.
  1410. X    **    -1 = QUIT
  1411. X    **    -2 = MAINMENU
  1412. X    **    -3 = PREVMENU
  1413. X    **    -4 = NOWAYJOSE
  1414. X    **    100+offset = GNAME
  1415. X    */
  1416. X    if (rc < GNAMEOFFSET)
  1417. X        rc -= rc * 2;                /* make negative */
  1418. X
  1419. X    if (redrawflag)
  1420. X        clearok (stdscr, TRUE);
  1421. X
  1422. X    return (rc);
  1423. X}
  1424. X/* Paul J. Condie  12/88 */
  1425. SHAR_EOF
  1426. chmod 0644 ParseUnix.c || echo "restore of ParseUnix.c fails"
  1427. echo "x - extracting ParseGname.c (Text)"
  1428. sed 's/^X//' << 'SHAR_EOF' > ParseGname.c &&
  1429. Xstatic char Sccsid[] = "@(#)ParseGname.c    1.5   DeltaDate 11/13/88   ExtrDate 1/22/90";
  1430. X
  1431. X/*  FUNCTION:    ParseGname()
  1432. X**        Parses keyword ".GNAME".
  1433. X**  ARGS:    keyword        the keyword "GNAME"
  1434. X**        menufile    the unix menu file
  1435. X**        menu        menu structure
  1436. X**        gnames        holder of goto menu names
  1437. X**        gfiles        holder of goto menu names (menu file)
  1438. X**        gindex        # of gnames
  1439. X*/
  1440. X
  1441. X#include    <curses.h>
  1442. X#include    "menu.h"
  1443. X
  1444. X
  1445. X
  1446. XParseGname (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1447. X    gindex, opnumber)
  1448. X
  1449. X    char        keyword[];
  1450. X    FILE        *menufile;
  1451. X    struct MenuInfo    *menu;
  1452. X    char        KeyWord[][MAXKEYLENGTH];
  1453. X    int        (*ParseKey[])();
  1454. X    char        gnames[][15], gfiles[][15];
  1455. X    int        *gindex;
  1456. X    int        *opnumber;
  1457. X{
  1458. X    char        name[BUFSIZE+1];
  1459. X    char        file[BUFSIZE+1];
  1460. X    int        i;
  1461. X    int        NameFound;
  1462. X
  1463. X
  1464. X    if (*gindex >= MAXGNAME)
  1465. X    {
  1466. X        BEEP;
  1467. X        mvprintw (20, 0, 
  1468. X           "Exceeded maximum (%d) number of goto menu names", 
  1469. X           MAXGNAME-1);
  1470. X        shutdown ();
  1471. X    }
  1472. X       fscanf (menufile, "%s %s", name, file);
  1473. X    if (strlen(name) >= 15  ||  strlen(file) >= 15)
  1474. X    {
  1475. X        BEEP;
  1476. X        mvprintw (20, 0, 
  1477. X       "The goto menu name and the goto menu file is limited to 14 characters");
  1478. X        shutdown ();
  1479. X    }
  1480. X
  1481. X    /* Check if we already have this menu name */
  1482. X    NameFound = FALSE;
  1483. X    for (i = 0; i < *gindex; i++)
  1484. X    {
  1485. X        if (strcmp (name, gnames[i]) == 0)
  1486. X        {
  1487. X            NameFound = TRUE;
  1488. X            strcpy (gfiles[i], file);    /* new menu file */
  1489. X        }
  1490. X    }
  1491. X    if (!NameFound)
  1492. X    {
  1493. X        /* a new name */
  1494. X        strcpy (gnames[*gindex], name);
  1495. X        strcpy (gfiles[*gindex], file);
  1496. X        (*gindex)++;
  1497. X        strcpy (gnames[*gindex], "");        /* null last one */
  1498. X    }
  1499. X       fgets (name, BUFSIZE, menufile);    /* junk rest of line */
  1500. X    return (0);
  1501. X}
  1502. SHAR_EOF
  1503. chmod 0444 ParseGname.c || echo "restore of ParseGname.c fails"
  1504. echo "x - extracting ParseAuthr.c (Text)"
  1505. sed 's/^X//' << 'SHAR_EOF' > ParseAuthr.c &&
  1506. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1507. X
  1508. X/*  FUNCTION:    ParseAuthr()
  1509. X**        Parses keyword "AUTHORIZE".
  1510. X**        This function determines whether you are authorized
  1511. X**        to run this menu or not.
  1512. X**  ARGS:    keyword        the keyword "AUTHORIZE"
  1513. X**        menufile    the unix menu file
  1514. X**        menu        menu structure
  1515. X**        gnames        holder of goto menu names
  1516. X**        gfiles        holder of goto menu names (menu file)
  1517. X**        gindex        # of gnames
  1518. X**  RETURNS:    0        you are authorized
  1519. X**        NOWAYJOSE    nowayjose
  1520. X*/
  1521. X
  1522. X#include    <curses.h>
  1523. X#include    <pwd.h>
  1524. X#include    "menu.h"
  1525. X
  1526. X
  1527. X
  1528. XParseAuthr (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
  1529. X    gindex, opnumber)
  1530. X
  1531. X    char        keyword[];
  1532. X    FILE        *menufile;
  1533. X    struct MenuInfo    *menu;
  1534. X    char        KeyWord[][MAXKEYLENGTH];
  1535. X    int        (*ParseKey[])();
  1536. X    char        gnames[][15], gfiles[][15];
  1537. X    int        *gindex;
  1538. X    int        *opnumber;
  1539. X{
  1540. X    char        *strchr();
  1541. X    char        line[MAXLEN+100], *lptr, word[15];
  1542. X    char        user[15];
  1543. X    int        OKflag;
  1544. X    struct passwd    *getpwuid();
  1545. X    struct passwd    *pw;                /* password entry */
  1546. X
  1547. X
  1548. X    pw = getpwuid (getuid());            /* get real uid */
  1549. X    strcpy (user, pw->pw_name);
  1550. X
  1551. X    /*
  1552. X    **    Read in option command
  1553. X    **    strcat continuation lines
  1554. X    */
  1555. X       fgets (line, sizeof(line)-1, menufile);
  1556. X       line[strlen(line)-1] = '\0';            /* get rid of \n */
  1557. X       while (line[strlen(line)-1] == '\\')
  1558. X       {
  1559. X              if (strlen(line) >= MAXLEN)
  1560. X              {
  1561. X                 BEEP;
  1562. X                 mvprintw (ErrRow-2, 0, 
  1563. X                "Option command is too long.  Max = %d",MAXLEN);
  1564. X                 shutdown ();
  1565. X              }
  1566. X              line[strlen(line)-1] = '\0';        /* junk \ */
  1567. X              fgets (line+strlen(line), sizeof(line)-1, menufile);
  1568. X              line[strlen(line)-1] = '\0';        /* get rid of \n */
  1569. X       }
  1570. X
  1571. X       lptr = line;
  1572. X       OKflag = FALSE;
  1573. X       while (lptr  &&  (sscanf (lptr, "%s", word) == 1))
  1574. X       {
  1575. SHAR_EOF
  1576. echo "End of part 4"
  1577. echo "File ParseAuthr.c is continued in part 5"
  1578. echo "5" > s2_seq_.tmp
  1579. exit 0
  1580.