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

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1) part 7 of 14
  4. Message-ID: <441@pcbox.UUCP>
  5. Date: 26 Dec 90 20:09:50 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 7 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file runscreen.c continued
  12. #
  13. CurArch=7
  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 runscreen.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> runscreen.c
  25. X            }
  26. X            rc = runpopen (FLD->before_field, buf);
  27. X            switch (rc)
  28. X            {
  29. X               case 0:
  30. X                /*
  31. X                ** aok accept input
  32. X                ** if buf is not null replace $var
  33. X                */
  34. X                ifvarset (buf, swin, menu->srn[sidx]->field);
  35. X                break;
  36. X               case 1:
  37. X                /*
  38. X                ** aok prompt for input
  39. X                ** if buf display on message line.
  40. X                */
  41. X                move (ErrRow, 0); clrtoeol ();
  42. X                attrset (A_REVERSE);
  43. X                mvprintw (ErrRow, 0, "%s", buf);
  44. X                attrset (A_NORMAL);
  45. X                refresh ();
  46. X                sleep (3);
  47. X                break;
  48. X               case 2:
  49. X                /* skip this field */
  50. X                ifvarset (buf, swin, menu->srn[sidx]->field);
  51. X                NoInput = TRUE;
  52. X                break;
  53. X
  54. X               default:
  55. X                /* do nothing */
  56. X                break;
  57. X            }
  58. X        }
  59. X
  60. X
  61. X        if (getenv(FLD->name) != (char *)NULL)
  62. X            strcpy (input, getenv (FLD->name));
  63. X        else
  64. X            strcpy (input, "");
  65. X           Fld.strVal = input;
  66. X
  67. X
  68. X        /*
  69. X        ** This is so GetInput doesn't overwrite the
  70. X        ** must enter message.
  71. X        */
  72. X        if (promptptr == (char *)NULL)
  73. X            promptptr = FLD->prompt;
  74. X        else if (strcmp (promptptr, "NOMSG") == 0)
  75. X            promptptr = NOMSG;
  76. X
  77. X
  78. X        /* if noinput == FALSE prompt for input */
  79. X        if (!NoInput)
  80. X        {
  81. X               exitkey = GetInput (swin, FLD->row, FLD->col, &Fld, 
  82. X                A_REVERSE, FLD->mask, tmprange[fidx], FLD->length, 
  83. X                FLD->min_input, FLD->type, FLD->adjust, CHAR, 
  84. X                NOAUTO, FLD->mustenter, ErrRow, ErrRow, 
  85. X                promptptr, helpfile, FLD->name);
  86. X            /* set the environment variable */
  87. X            rc = setenv (FLD->name, Fld.strVal);
  88. X            if (rc < 0)
  89. X            {
  90. X                mvwprintw (stdscr, ErrRow,0, 
  91. X                    "Unable to allocate environment memory to set variable %s.",
  92. X                    FLD->name);
  93. X                BEEP;
  94. X            }
  95. X        }
  96. X        else
  97. X        {
  98. X            /* use the exitkey from the last field */
  99. X            if (exitkey != KEY_UP)
  100. X                exitkey = KEY_DOWN;
  101. X        }
  102. X        promptptr = (char *)NULL;
  103. X
  104. X
  105. X
  106. X
  107. X        if (exitkey == KeyReturn)    exitkey = KEY_RETURN;
  108. X        if (exitkey == KeyUp)          exitkey = KEY_UP;
  109. X        if (exitkey == KeyDown)      exitkey = KEY_DOWN;
  110. X        if (exitkey == KeyTab)      exitkey = KEY_TAB;
  111. X        if (exitkey == KeyBTab)      exitkey = KEY_BTAB;
  112. X        if (exitkey == KeyCancel)     exitkey = KEY_CANCEL;
  113. X        if (exitkey == KeyAccept)    exitkey = KEY_ACCEPT;
  114. X
  115. X
  116. X        /* run after_field command */
  117. X        if (exitkey != KEY_CANCEL && FLD->after_field != (char *)NULL)
  118. X        {
  119. X            char    buf[BUFSIZ+1];
  120. X
  121. X            if (promptptr == (char *)NULL  ||
  122. X                strcmp (promptptr, "DONT_CLEAR") != 0)
  123. X            {
  124. X                move (ErrRow,0);  clrtoeol();
  125. X                mvprintw (ErrRow,1, "Working ...");
  126. X                refresh ();
  127. X            }
  128. X            rc = runpopen (FLD->after_field, buf);
  129. X            switch (rc)
  130. X            {
  131. X               case 0:
  132. X                /*
  133. X                ** aok continue to next field
  134. X                ** If buf has var=value set and redisplay
  135. X                */
  136. X                ifvarset (buf, swin, menu->srn[sidx]->field);
  137. X                break;
  138. X               case 1:
  139. X                /*
  140. X                ** aok prompt for input
  141. X                ** if buf display on message line.
  142. X                */
  143. X                move (ErrRow, 0); clrtoeol ();
  144. X                attrset (A_REVERSE);
  145. X                mvprintw (ErrRow, 0, "%s", buf);
  146. X                attrset (A_NORMAL);
  147. X                wnoutrefresh (stdscr);
  148. X                promptptr = "DONT_CLEAR";
  149. X                BELL;
  150. X                continue;
  151. X
  152. X               default:
  153. X                /* do nothing */
  154. X                break;
  155. X            }
  156. X        } /* end after_field */
  157. X
  158. X        /* if exitlastfield accept input and exit on last field */
  159. X        if (SRN->exitlastfield && fidx == fieldcount && 
  160. X            exitkey == KEY_RETURN)
  161. X            exitkey = KEY_ACCEPT;
  162. X
  163. X        switch (exitkey)
  164. X        {
  165. X           case KEY_CANCEL:
  166. X            /* reset $field_name to orginal data */
  167. X            for (fidx = 0; SRN->field[fidx] != 
  168. X                 (struct FieldInfo *)NULL && fidx <= MAXFIELDS; 
  169. X                 fidx++)
  170. X                setenv (FLD->name, fielddata[fidx]);
  171. X            break;
  172. X
  173. X           case KEY_ACCEPT:
  174. X            /* make sure mustenter fields have been entered */
  175. X            for (fidx = 0; fidx <= fieldcount; fidx++)
  176. X            {
  177. X                if (FLD->mustenter  &&  
  178. X                    strlen (getenv(FLD->name)) <= 0)
  179. X                {
  180. X                    mvwprintw (stdscr, ErrRow,1, 
  181. X                       "This is a must enter field.");
  182. X                    BEEP;
  183. X                    wnoutrefresh (stdscr);
  184. X                    promptptr = "DONT_CLEAR";
  185. X                    exitkey = KEY_DOWN;    /* not done */
  186. X                    break;
  187. X                }
  188. X            }
  189. X            /* if mustenter then more input */
  190. X            if (fidx <= fieldcount)
  191. X                break;
  192. X            break;
  193. X
  194. X           case KEY_TAB:
  195. X            fidx += 4;
  196. X            fidx = fidx >= fieldcount ? 0 : ++fidx;
  197. X            break;
  198. X
  199. X           case KEY_BTAB:
  200. X            fidx -= 4;
  201. X            fidx = fidx < 0 ? fieldcount : --fidx;
  202. X            break;
  203. X
  204. X           case KEY_UP:
  205. X            fidx = fidx <= 0 ? fieldcount : --fidx;
  206. X            break;
  207. X
  208. X           case KEY_RETURN:
  209. X           case KEY_DOWN:
  210. X           default:
  211. X            fidx = fidx >= fieldcount ? 0 : ++fidx;
  212. X            break;
  213. X        }
  214. X    } while (exitkey != KEY_CANCEL  &&  exitkey != KEY_ACCEPT);
  215. X
  216. X    if (exitkey != KEY_CANCEL && SRN->after_screen != (char *)NULL)
  217. X    {
  218. X        char    buf[BUFSIZ+1];
  219. X
  220. X        move (ErrRow,0);  clrtoeol();
  221. X        mvprintw (ErrRow,1, "Working ...");
  222. X        refresh ();
  223. X        rc = runpopen (SRN->after_screen, buf);
  224. X        switch (rc)
  225. X        {
  226. X           case 0:
  227. X            /*
  228. X            ** aok 
  229. X            ** if buf display on message line with no bell.
  230. X            */
  231. X            move (ErrRow, 0); clrtoeol ();
  232. X            attrset (A_REVERSE);
  233. X            mvprintw (ErrRow, 0, "%s", buf);
  234. X            attrset (A_NORMAL);
  235. X            wnoutrefresh (stdscr);
  236. X            promptptr = "DONT_CLEAR";
  237. X            break;
  238. X
  239. X           case 1:
  240. X            /*
  241. X            ** aok prompt for input
  242. X            ** if buf display on message line with bell.
  243. X            */
  244. X            move (ErrRow, 0); clrtoeol ();
  245. X            attrset (A_REVERSE);
  246. X            mvprintw (ErrRow, 0, "%s", buf);
  247. X            attrset (A_NORMAL);
  248. X            wnoutrefresh (stdscr);
  249. X            promptptr = "DONT_CLEAR";
  250. X            BELL;
  251. X            break;
  252. X
  253. X           default:
  254. X            /* do nothing */
  255. X            break;
  256. X        }
  257. X    } /* end after_screen */
  258. X        
  259. X    delwin (swin);                    /* junk screen window */
  260. X    if (!SRN->exitoncancel || exitkey == KEY_CANCEL)
  261. X    {
  262. X        wmove (stdscr,LINES-1,0);
  263. X        clrtoeol ();                /* clear field prompt */
  264. X        touchwin (stdscr);
  265. X    }
  266. X
  267. X    /* junk tmp range values */
  268. X    for (i = 0; i < MAXFIELDS; i++)
  269. X    {
  270. X        if (tmprange[i] != (char *)NULL)
  271. X            free (tmprange[i]);
  272. X        tmprange[i] = (char *)NULL;
  273. X    }
  274. X
  275. X    if (SRN->exitoncancel && exitkey != KEY_CANCEL)
  276. X        goto herewegoagain;
  277. X
  278. X    if (exitkey == KEY_CANCEL)
  279. X        return (exitkey);
  280. X    else
  281. X        return (0);
  282. X}
  283. X
  284. X
  285. X
  286. Xchar *format (data, mask, fldtype)
  287. X    char    *data;            /* data 2b formated */
  288. X    char    *mask;                /* mask to format to */
  289. X    char    fldtype;            /* GetInput field type */
  290. X{
  291. X    static char    fmtdefault[100];
  292. X    char        *wsptr;
  293. X    char        *source;
  294. X    int        i;
  295. X
  296. X
  297. X    strcpy (fmtdefault, data);
  298. X    wsptr = fmtdefault;
  299. X    source = data;
  300. X
  301. X    if (strlen(mask) > 0)
  302. X    {
  303. X        for (; *mask != '\0'; mask++, wsptr++)
  304. X        {
  305. X            if (IsMask (fldtype, *mask))
  306. X                *wsptr = *mask;    /* format char */
  307. X            else
  308. X            {
  309. X                if (*source != '\0')
  310. X                {
  311. X                    *wsptr = *source;
  312. X                    source++;
  313. X                } 
  314. X                else
  315. X                    *wsptr = ' ';    /* no data */
  316. X            }
  317. X        }
  318. X            *wsptr = '\0';
  319. X    }
  320. X    wsptr = fmtdefault;
  321. X    return (wsptr);
  322. X}
  323. X
  324. X
  325. X
  326. X/*
  327. X**  if buf contains space separated $var=value
  328. X**     then setenv $var to value
  329. X*/
  330. Xifvarset (buf, swin, field)
  331. X    char    *buf;                /* var=value ... */
  332. X    WINDOW    *swin;                /* window to write to */
  333. X    struct FieldInfo    *field[];
  334. X{
  335. X    char    *substr();
  336. X    char    *wsptr;
  337. X    char    variable[100];            /* name */
  338. X    char    value[200];            /* value to set name to */
  339. X    int    i;
  340. X    int    rc;
  341. X
  342. X
  343. X    wsptr = buf;
  344. X    while ((wsptr = substr (wsptr, "$")) != (char *)NULL)
  345. X    {
  346. X        wsptr++;        /* get past $ */
  347. X        /* get the enviroment variable */
  348. X        for (i = 0; *wsptr != '=' && *wsptr != '\0'; i++, wsptr++)
  349. X            variable[i] = *wsptr;
  350. X        variable[i] = '\0';
  351. X        if (strcmp (variable, "") == 0  ||  *wsptr != '=')
  352. X        {
  353. X            BEEP;
  354. X            mvprintw (ErrRow-2, 0, 
  355. X               "Error occured while setting enviroment variable %s",
  356. X               buf);
  357. X            shutdown ();
  358. X        }
  359. X        wsptr++;    /* get past the = */
  360. X
  361. X        if (*wsptr == '"')
  362. X            strcpy (value, getval (&wsptr, '"'));
  363. X        else
  364. X            strcpy (value, getval (&wsptr, '0'));
  365. X
  366. X        /* find the appropriate field */
  367. X        for (i = 0; field[i] != (struct FieldInfo *)NULL && 
  368. X                 i <= MAXFIELDS; i++)
  369. X        {
  370. X            if (strcmp (field[i]->name, variable) == 0)
  371. X            {
  372. X                /* found field */
  373. X                adjustfield (value, field[i]->adjust, 
  374. X                    field[i]->length);
  375. X
  376. X                /* format value to the mask and display */
  377. X                mvwprintw (swin, field[i]->row, field[i]->col, 
  378. X                    "%s", format (value, field[i]->mask, 
  379. X                    field[i]->type));
  380. X                break;
  381. X            }
  382. X        } /* end for */
  383. X        /* set the enviroment variable */
  384. X        rc = setenv (variable, value);
  385. X        if (rc != 0)
  386. X        {
  387. X            BEEP;
  388. X            mvprintw (ErrRow-2, 0, 
  389. X               "Error occured while setting enviroment variable %s",
  390. X                variable);
  391. X            shutdown ();
  392. X        }
  393. X
  394. X    } /* end while */
  395. X    wnoutrefresh (swin);
  396. X}
  397. X
  398. X
  399. X
  400. X
  401. Xadjustfield (data, fldadjust, fldlength)
  402. X    char    *data;            /* data 2b formated */
  403. X    char    fldadjust;
  404. X    int    fldlength;
  405. X{
  406. X    char        *source;
  407. X    int        i;
  408. X
  409. X
  410. X    switch (fldadjust)
  411. X    {
  412. X       case LFADJ_BFILL:
  413. X        /* get to end of data */
  414. X        for (i = 0, source = data; *source != '\0'; i++, source++)
  415. X            ;
  416. X        /* blank fill rest of field */
  417. X        for (; i < fldlength; i++, source++)
  418. X            *source = ' ';
  419. X        *source = '\0';
  420. X        break;
  421. X    }
  422. X}
  423. X/* Paul J. Condie  11/88 */
  424. SHAR_EOF
  425. echo "File runscreen.c is complete"
  426. chmod 0644 runscreen.c || echo "restore of runscreen.c fails"
  427. echo "x - extracting getval.c (Text)"
  428. sed 's/^X//' << 'SHAR_EOF' > getval.c &&
  429. X#ifndef LINT
  430. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  431. X#endif
  432. X
  433. X/*
  434. X**  getval()
  435. X**  ARGS:
  436. X**    sptr    - pointer to beginning of value 2b parsed
  437. X**    endch    - $ process only the dollar part of value
  438. X**        - ` process only the single quote part of value
  439. X**        - " process only the double quote part of value
  440. X**        - 0 process until a space or invalid is found
  441. X**        - 1 process entire string until '\0' is found
  442. X**  RETURNS:
  443. X**    sptr    - pointer to end of value 2b parsed
  444. X**    rval    - the resulting value.
  445. X**
  446. X**    var=one
  447. X**    var="one"
  448. X**    var=$var
  449. X**    var="one $var"
  450. X**    var=${var}
  451. X**    var=`ls`
  452. X**    var=one"two three"
  453. X**    var=~/
  454. X**    var=~usr/
  455. X*/
  456. X
  457. X#include    <stdio.h>
  458. X#include    <ctype.h>
  459. X#include    <pwd.h>
  460. X
  461. X#define DQUOTE    '"'
  462. X#define SQUOTE    '`'
  463. X#define LITERAL    '\''
  464. X#define DOLLAR    '$'
  465. X#define ESCAPE    '\\'
  466. X#define BRACE    '{'
  467. X#define COMCHAR '#'
  468. X#define    TILDE    '~'
  469. X#ifndef    TRUE
  470. X#define    TRUE    1
  471. X#define    FALSE    0
  472. X#endif
  473. X
  474. X#ifndef    TEST
  475. Xextern int    debug;
  476. X#endif
  477. X
  478. X
  479. Xchar *getval (sptr, endch)
  480. X    char    **sptr;                    /* pointer to $+1 */
  481. X    char    endch;
  482. X{
  483. X    char        *getenv();
  484. X    struct passwd    *getpwnam();
  485. X    FILE        *popen(), *pp;
  486. X    static char    value[400];
  487. X    char        tmpval[400];
  488. X    static char    *rval;                /* pointer for return */
  489. X    int        i;
  490. X    int        EOV = FALSE;            /* End Of Value */
  491. X    int        dqflag = FALSE;            /* double quote flag */
  492. X    struct passwd    *pw;
  493. X
  494. X
  495. X    strcpy (value, "");
  496. X    rval = value;
  497. X    while (!EOV && **sptr)
  498. X    {
  499. X        switch (**sptr)
  500. X        {
  501. X              case SQUOTE:
  502. X            (*sptr)++;                /* get past ' */
  503. X            for (i = 0; **sptr != '`' && **sptr; i++, (*sptr)++)
  504. X                tmpval[i] = **sptr;
  505. X            if (**sptr)
  506. X                (*sptr)++;        /* get past ' */
  507. X            tmpval[i] = '\0';
  508. X            /* open pipe and read results */
  509. X            if ((pp = popen (tmpval, "r")) != NULL)
  510. X            {
  511. X                for (; ((i = fgetc(pp)) != EOF); rval++)
  512. X                {
  513. X                    *rval = i ;
  514. X                    if (!isprint(*rval))
  515. X                        rval--;
  516. X                }
  517. X                pclose (pp);
  518. X            }
  519. X            if (endch == SQUOTE)
  520. X            {
  521. X                *rval = '\0';
  522. X                rval = value;
  523. X                return (rval);
  524. X            }
  525. X            break;
  526. X
  527. X              case DQUOTE:
  528. X            (*sptr)++;
  529. X            dqflag = dqflag == FALSE ? TRUE : FALSE;
  530. X            if (endch == DQUOTE && dqflag == FALSE)
  531. X            {
  532. X                *rval = '\0';
  533. X                rval = value;
  534. X                return (rval);
  535. X            }
  536. X            break;
  537. X
  538. X              case DOLLAR:
  539. X            /* Substitutable parameter */
  540. X
  541. X            (*sptr)++;                /* get past $ */
  542. X
  543. X            /*
  544. X            **  The braces are required only when parameter is
  545. X            **  followed by a letter, digit, or underscore.
  546. X            */
  547. X            if (**sptr == BRACE)
  548. X            {
  549. X                (*sptr)++;            /* get past { */
  550. X                for (i = 0; **sptr != '}' && **sptr; 
  551. X                     i++, (*sptr)++)
  552. X                    tmpval[i] = **sptr;
  553. X                if (**sptr)
  554. X                    (*sptr)++;        /* get past } */
  555. X            }
  556. X            else
  557. X            {
  558. X                for (i = 0; isalnum(**sptr) || **sptr == '_'; 
  559. X                    i++, (*sptr)++)
  560. X                    tmpval[i] = **sptr;
  561. X            }
  562. X            tmpval[i] = '\0';
  563. X            if (getenv(tmpval) != (char *)NULL)
  564. X                strcpy (rval, getenv(tmpval));
  565. X            rval += strlen (rval);
  566. X            if (endch == DOLLAR)
  567. X            {
  568. X                *rval = '\0';
  569. X                rval = value;
  570. X                return (rval);
  571. X            }
  572. X            break;
  573. X
  574. X           case TILDE:
  575. X            (*sptr)++;                /* get past ~ */
  576. X            /*
  577. X            **  ~/ = $HOME
  578. X            **  ~user/ = home(user)
  579. X            */
  580. X            for (i = 0; **sptr != '/' && **sptr; i++, (*sptr)++)
  581. X                tmpval[i] = **sptr;
  582. X            tmpval[i] = '\0';
  583. X            if (strcmp (tmpval, "") == 0)
  584. X                if (getenv("LOGNAME") != (char *)NULL)
  585. X                    strcpy (tmpval, getenv ("LOGNAME"));
  586. X            /*
  587. X            **  tmpval holds the user name
  588. X            **  now we get the password entry
  589. X            */
  590. X            pw = getpwnam (tmpval);
  591. X            strcpy (rval, pw->pw_dir);
  592. X            rval += strlen (pw->pw_dir);
  593. X            break;
  594. X
  595. X              default:
  596. X            if (dqflag || **sptr != ' ' || endch == '1')
  597. X            {
  598. X                *rval++ = **sptr;
  599. X                (*sptr)++;
  600. X            }
  601. X            else
  602. X                EOV = TRUE;
  603. X            break;
  604. X        } /* end switch */
  605. X    } /* end while */
  606. X
  607. X    *rval = '\0';
  608. X    rval = value;
  609. X#ifndef    TEST
  610. X    if (debug)
  611. X    {
  612. X        fprintf (stderr, "\n[%s] value=:%s:, :%s:",
  613. X            __FILE__, value, *sptr);
  614. X        fflush (stderr);
  615. X    }
  616. X#endif
  617. X    return (rval);
  618. X}
  619. X
  620. X
  621. X
  622. X#ifdef    TEST
  623. Xmain (argc, argv)
  624. X    int    argc;
  625. X    char    *argv[];
  626. X{
  627. X    char        *getval();
  628. X    char        *sptr;
  629. X    char        *rval;
  630. X
  631. X    sptr = argv[1];
  632. X    if (argc == 3)
  633. X        rval = getval (&sptr, argv[2][0]);
  634. X    else
  635. X        rval = getval (&sptr, '1');
  636. X    printf ("\nparameter value :%s:", rval);
  637. X    printf ("\narg pointer :%s:", sptr);
  638. X}
  639. X#endif
  640. X/* Paul J. Condie  5/89 */
  641. SHAR_EOF
  642. chmod 0644 getval.c || echo "restore of getval.c fails"
  643. echo "x - extracting clean_menu.c (Text)"
  644. sed 's/^X//' << 'SHAR_EOF' > clean_menu.c &&
  645. X#ifndef LINT
  646. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  647. X#endif
  648. X
  649. X#include    "menu.h"
  650. X
  651. Xclean_menu (menu)
  652. X    struct MenuInfo    *menu;
  653. X{
  654. X    int        i,j;
  655. X    int        textcnt;
  656. X
  657. X
  658. X    /*
  659. X    ** Just to keep things simple, lets start from scratch on the
  660. X    ** next menu selected.
  661. X    */
  662. X
  663. X    /* free options */
  664. X          for (i = 0; i < menu->optioncount; i++)
  665. X    {
  666. X        if (menu->option[i]->command)
  667. X            free (menu->option[i]->command);
  668. X               free (menu->option[i]);
  669. X    }
  670. X
  671. X          /* free screens */
  672. X    for (i = 0; menu->srn[i] != (struct ScreenInfo *)NULL  &&  
  673. X         i <= MAXSCREENS; i++)
  674. X    {
  675. X        /* screen information */
  676. X        if (menu->srn[i]->fielddefaults != (char *)NULL)
  677. X            free (menu->srn[i]->fielddefaults);
  678. X
  679. X        /* text stuff */
  680. X        for (textcnt = 0; 
  681. X             menu->srn[i]->textinfo[textcnt] != (struct TextInfo *)NULL;
  682. X             textcnt++)
  683. X        {
  684. X            free (menu->srn[i]->textinfo[textcnt]->text);
  685. X            free (menu->srn[i]->textinfo[textcnt]);
  686. X        }
  687. X
  688. X        if (menu->srn[i]->after_screen != (char *)NULL)
  689. X            free (menu->srn[i]->after_screen);
  690. X
  691. X
  692. X        /* free field information */
  693. X        for (j = 0; 
  694. X             menu->srn[i]->field[j] != (struct FieldInfo *)NULL &&
  695. X             j <= MAXFIELDS; j++)
  696. X        {
  697. X            if (menu->srn[i]->field[j]->before_field != (char *)NULL)
  698. X                free (menu->srn[i]->field[j]->before_field);
  699. X            if (menu->srn[i]->field[j]->after_field != (char *)NULL)
  700. X                free (menu->srn[i]->field[j]->after_field);
  701. X            free (menu->srn[i]->field[j]);
  702. X        }
  703. X
  704. X
  705. X        free (menu->srn[i]);
  706. X        menu->srn[i] = (struct ScreenInfo *)NULL;
  707. X    } /* end screens */
  708. X
  709. X    if (menu->after_menu != (char *)NULL)
  710. X        free (menu->after_menu);
  711. X}
  712. X/* Paul J. Condie  6/89 */
  713. SHAR_EOF
  714. chmod 0644 clean_menu.c || echo "restore of clean_menu.c fails"
  715. echo "x - extracting slength.c (Text)"
  716. sed 's/^X//' << 'SHAR_EOF' > slength.c &&
  717. X#ifndef LINT
  718. Xstatic char Sccsid[] = "@(#)slength.c    1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
  719. X#endif
  720. X
  721. X/*
  722. X**    How long is a string not counting attributes.
  723. X*/
  724. X
  725. Xslength (s)
  726. X    char        *s;
  727. X{
  728. X    register int    i = 0;
  729. X
  730. X    while (*s)
  731. X    {
  732. X        if (*s == '\\')
  733. X        {
  734. X            s++;
  735. X            s++;
  736. X            continue;
  737. X        }
  738. X        s++;
  739. X        i++;
  740. X    }
  741. X    return (i);
  742. X}
  743. X/* Paul J. Condie  11-89 */
  744. SHAR_EOF
  745. chmod 0444 slength.c || echo "restore of slength.c fails"
  746. echo "x - extracting runpopen.c (Text)"
  747. sed 's/^X//' << 'SHAR_EOF' > runpopen.c &&
  748. X/*
  749. X**  ARGS:
  750. X**    command    - the command to run
  751. X**  RETURNS:
  752. X**    -1    unable to open pope
  753. X**    x    return code from command
  754. X*/
  755. X
  756. X#include    <stdio.h>
  757. X
  758. X#ifndef DEBUG
  759. Xextern     int    debug;
  760. X#else
  761. Xint    debug;
  762. X#endif
  763. Xextern    int    errno;
  764. X
  765. Xrunpopen (command, result)
  766. X    char    *command;                /* command to run */
  767. X    char    *result;                /* from pipe */
  768. X{
  769. X    FILE    *popen(), *pp;
  770. X    char    *fgets();
  771. X    int    rc;
  772. X
  773. X    strcpy (result, "");
  774. X    if ((pp = popen (command, "r")) == (FILE *)NULL)
  775. X    {
  776. X        if (debug)
  777. X        {
  778. X            fprintf (stderr, 
  779. X                "\n[%s] %d Unable to popen command=:%s:",
  780. X                __FILE__, errno, command);
  781. X            fflush (stderr);
  782. X        }
  783. X        return (-1);
  784. X    }
  785. X
  786. X    if (fgets (result, BUFSIZ, pp) == (char *)NULL)
  787. X        strcpy (result, "");
  788. X    else
  789. X        if (result[strlen(result)-1] == '\n')
  790. X            result[strlen(result)-1] = '\0';    /* junk \n */
  791. X
  792. X    rc = pclose (pp);
  793. X    return (rc >> 8);            /* shell rc is in high 8 bits */
  794. X}
  795. X/* Paul J. Condie  4-90 */
  796. X
  797. X
  798. X#ifdef DEBUG
  799. Xmain (argc, argv)
  800. X    int    argc;
  801. X    char    *argv[];
  802. X{
  803. X    int    rc;
  804. X    char    buf[BUFSIZ+1];
  805. X
  806. X    rc = runpopen (argv[1], buf);
  807. X    printf ("\n%d :%s:", rc, buf);
  808. X    exit (rc);
  809. X}
  810. X#endif
  811. SHAR_EOF
  812. chmod 0644 runpopen.c || echo "restore of runpopen.c fails"
  813. echo "x - extracting mygetch.c (Text)"
  814. sed 's/^X//' << 'SHAR_EOF' > mygetch.c &&
  815. X#include    <curses.h>
  816. X
  817. X#ifndef ESC
  818. X#define    ESC    27
  819. X#endif
  820. X
  821. Xextern int    debug;
  822. X
  823. X
  824. Xmygetch ()
  825. X{
  826. X    int    row;                /* row where mouse is at */
  827. X    int    col;                /* col where mouse is at */
  828. X    int    rc;
  829. X
  830. X#ifdef UNIXPC
  831. X    rc = mouse3b1 (&row, &col);
  832. X#else
  833. X    rc = getch();
  834. X#endif
  835. X    return (rc);                /* character inputted */
  836. X}
  837. X
  838. X
  839. X#ifdef UNIXPC
  840. X
  841. X#include    <stdio.h>
  842. X#include    <sys/types.h>
  843. X#include    <sys/stat.h>
  844. X#include    <sys/window.h>
  845. X
  846. Xmouse3b1 (row, col)
  847. X    int    *row;
  848. X    int    *col;
  849. X{
  850. X    char        *readkey();
  851. X    char        *strchr();
  852. X    struct stat    sbuf;
  853. X    struct umdata    umdata;
  854. X    int        wd;            /* window descriptor */
  855. X    int        rc;
  856. X    char        kbuf[80];        /* key buffer */
  857. X    char        *sptr;
  858. X    int        prow;
  859. X    int        pcol;
  860. X
  861. X
  862. X    /* find window (wd) */
  863. X    rc = fstat (0, &sbuf);
  864. X    if (rc != 0)
  865. X        return (getch());
  866. X    wd = sbuf.st_dev;            /* window descriptor */
  867. X
  868. X    umdata.um_flags = MSDOWN|MSIN|MSOUT;
  869. X    /* rectangle in pixels */
  870. X    umdata.um_x = 0;
  871. X    umdata.um_y = 0;
  872. X    umdata.um_w = 100;
  873. X    umdata.um_h = 100;
  874. X    umdata.um_icon = 0;            /* use system cursor icon */
  875. X
  876. X    while (1)
  877. X    {
  878. X        rc = ioctl (0, WIOCSETMOUSE, &umdata);
  879. X        if (rc != 0)
  880. X        {
  881. X            if (debug)
  882. X            {
  883. X                fprintf (stderr, 
  884. X                     "\n[%s] %d=ioctl(%d,WIOCSETMOUSE) failed",
  885. X                    __FILE__, rc, wd);
  886. X                fflush (stderr);
  887. X            }
  888. X            return (getch());
  889. X        }
  890. X        strcpy (kbuf, readkey ());
  891. X        if (kbuf[0] != (char)ESC)
  892. X            return ((int)kbuf[0]);
  893. X        if (debug)
  894. X        {
  895. X            fprintf (stderr, "\n[%s] mouse report = :%s:", __FILE__,
  896. X                kbuf+1);
  897. X            fflush (stderr);
  898. X        }
  899. X
  900. X        /*
  901. X        ** screen size in pixels 720,288 
  902. X        ** one char = 9x12  pixels
  903. X        ** Mouse reports take the form:
  904. X        **    ESC [ ? {x-pos} ; {y-pos} ; {buttons} ; {reason} M
  905. X        */
  906. X        sptr = strchr (kbuf, '?');
  907. X        sptr++;
  908. X        sscanf (sptr, "%d", &pcol);
  909. X        sptr = strchr (sptr, ';');
  910. X        sptr++;
  911. X        sscanf (sptr, "%d", &prow);
  912. X        /* convert from pixel to character row/col the mouse is on */
  913. X        *col = pcol / 9;
  914. X        *row = prow / 12;
  915. X        if (debug)
  916. X        {
  917. X            fprintf (stderr, "\n[%s] mouse row %d, col %d", 
  918. X                __FILE__, *row, *col);
  919. X            fflush (stderr);
  920. X        }
  921. X        setoption (*row, *col);        /* hi-light menu option */
  922. X    }
  923. X}
  924. X
  925. X
  926. X/*
  927. X** readkey()
  928. X** Returns:
  929. X**    the string of characters generated by a key
  930. X*/
  931. X#include    <stdio.h>
  932. X#include    <signal.h>
  933. X#include    <ctype.h>
  934. X
  935. X
  936. Xstatic int    sig_caught;
  937. X
  938. Xchar *readkey ()
  939. X{
  940. X    int    (*oldsig)();
  941. X    int    _Catch_Alarm();
  942. X    int    oldalarm;
  943. X    char    ch;
  944. X    int    rc;
  945. X    static char    keybuf[80];
  946. X    char        *sptr;
  947. X
  948. X    strcpy (keybuf, "");
  949. X    sptr = keybuf;
  950. X    *sptr = getch (); rc = 1;
  951. X    if (*sptr != 27)        /* check for escape */
  952. X    {
  953. X        sptr++;
  954. X        *sptr = '\0';
  955. X        sptr = keybuf;
  956. X        return (sptr);
  957. X    }
  958. X    sptr++;
  959. X
  960. X    /*
  961. X    ** check to see if this is a multi-char key
  962. X    ** loop until read returns -1 (no input) or
  963. X    ** a time out signal occurs indicating no more input
  964. X    **
  965. X    ** The best resolution we have is 1 second, so we set a 1 second alarm
  966. X    ** and try to read.  If we fail for 1 second, we assume there is no
  967. X    ** key waiting.  Problem here is that 1 second is too long, people
  968. X    ** can type faster than this.
  969. X    */
  970. X    while (rc == 1)
  971. X    {
  972. X        oldsig = signal (SIGALRM, _Catch_Alarm);
  973. X        oldalarm = alarm (1);
  974. X        sig_caught = 0;
  975. X        *sptr = getch (); rc = 1;
  976. X        if (sig_caught)
  977. X        {
  978. X            sig_caught = 0;
  979. X            alarm (oldalarm);
  980. X            rc = -2;
  981. X        }
  982. X        signal (SIGALRM, oldsig);
  983. X        alarm (oldalarm);
  984. X        sptr++;
  985. X    }
  986. X    sptr--;
  987. X    *sptr = '\0';
  988. X    sptr = keybuf;
  989. X    return (sptr);
  990. X}
  991. X
  992. X_Catch_Alarm ()
  993. X{
  994. X    sig_caught = 1;
  995. X}
  996. X#endif
  997. X/* Paul J. Condie  5-90 */
  998. SHAR_EOF
  999. chmod 0644 mygetch.c || echo "restore of mygetch.c fails"
  1000. echo "x - extracting menu.h (Text)"
  1001. sed 's/^X//' << 'SHAR_EOF' > menu.h &&
  1002. X#ifndef LINT
  1003. Xstatic char ID_menu[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1004. X#endif
  1005. X
  1006. X#define    VERSION    "3.63"            /* current version */
  1007. X
  1008. X#ifndef BELL
  1009. X#define    BELL    printf ("%c", 7)
  1010. X#endif
  1011. X#ifndef BEEP
  1012. X#define    BEEP    printf ("%c", 7)
  1013. X#endif
  1014. X#ifndef NULL
  1015. X#define    NULL    0
  1016. X#endif
  1017. X#define    null            0
  1018. X#define    MENUINIT    ".menuinit"    /* initialize filename */
  1019. X#define    HELPFILE    "menu.hlp"
  1020. X#define    BORDERCHAR    ' '
  1021. X#define    MAXTITLE    6        /* maximum # of title lines */
  1022. X#define    MAXKEYS        25        /* maximum # of keys */
  1023. X#define    MAXKEYLENGTH    15        /* maximum length of keyword */
  1024. X#define    MAXOPTION    60        /* max # of option 2b displayed */
  1025. X#define    MAXMENU        20        /* max nested menus */
  1026. X#define    MAXGNAME    20        /* max goto menu names */
  1027. X#define    MAXLEN        2048        /* max length of option command */
  1028. X#define    MAXSCREENS    10        /* max .DEFINE_SCREEN per menu */
  1029. X#define    MAXFIELDS    40        /* max fields per .DEFINE_SCREEN */
  1030. X#define    MAXTEXT        20        /* max # of text per .DEFINE_SCREEN */
  1031. X#define    ErrRow        (LINES-1)    /* last line to print error message */
  1032. X#define    GNAMEOFFSET    100        /* Offset return code for gnames */
  1033. X
  1034. X#define    QUIT        -1
  1035. X#define    MAINMENU    -2
  1036. X#define    PREVIOUSMENU    -3
  1037. X#define    NOWAYJOSE    -4        /* not authorized for menu */
  1038. X#define    REPARSE        -5        /* reparse & display the current menu */
  1039. X#define    SUBMENU        -99        /* a submenu was selected */
  1040. X
  1041. X#define    BUFSIZE        512
  1042. X
  1043. X/* Line drawing types */
  1044. X#define    DumbLine    1
  1045. X#define    StandoutLine    2
  1046. X#define    SingleLine    3
  1047. X#define    MosaicLine    4
  1048. X#define    DiamondLine    5
  1049. X#define    DotLine        6
  1050. X#define    PlusLine    7
  1051. X
  1052. X#define    AUTO        999
  1053. X
  1054. X
  1055. X/*
  1056. X**  Keys not defined in some curses.h
  1057. X*/
  1058. X
  1059. X#ifndef KEY_HELP
  1060. X#   define KEY_HELP    0553
  1061. X#endif
  1062. X#ifndef KEY_REFRESH
  1063. X#   define KEY_REFRESH    0565
  1064. X#endif
  1065. X#ifndef KEY_CANCEL
  1066. X#   define KEY_CANCEL    0543
  1067. X#endif
  1068. X#ifndef KEY_TAB
  1069. X#   define KEY_TAB    '\t'
  1070. X#endif
  1071. X#ifndef KEY_BTAB
  1072. X#   define KEY_BTAB    0541
  1073. X#endif
  1074. X#ifndef KEY_RETURN
  1075. X#   define KEY_RETURN    '\r'
  1076. X#endif
  1077. X#ifndef KEY_LINEFEED
  1078. X#   define KEY_LINEFEED    '\n'
  1079. X#endif
  1080. X#ifndef KEY_REFRESH
  1081. X#   define KEY_REFRESH    0565
  1082. X#endif
  1083. X#ifndef KEY_BEG
  1084. X#   define KEY_BEG    0542
  1085. X#endif
  1086. X#ifndef KEY_END
  1087. X#   define KEY_END    0550
  1088. X#endif
  1089. X#ifndef KEY_ACCEPT
  1090. X#define KEY_ACCEPT    1000
  1091. X#endif
  1092. X#ifndef KEY_MAINMENU
  1093. X#define    KEY_MAINMENU    1001
  1094. X#endif
  1095. X#ifndef KEY_PREVMENU
  1096. X#define    KEY_PREVMENU    1002
  1097. X#endif
  1098. X#ifndef KEY_EXITMENU
  1099. X#define    KEY_EXITMENU    1003
  1100. X#endif
  1101. X#ifndef KEY_POPGNAME
  1102. X#define    KEY_POPGNAME    1004
  1103. X#endif
  1104. X#ifndef KEY_GNAME
  1105. X#define    KEY_GNAME    1005
  1106. X#endif
  1107. X
  1108. X/*
  1109. X**  MACROS
  1110. X*/
  1111. X
  1112. X#define    SKIPJUNK(s)     /* \
  1113. X            **  This macro skips over spaces, tabs, etc. \
  1114. X            **  ARGS:  char  *s \
  1115. X            */ \
  1116. X            for (;*s != '\0' && (isspace(*s)); s++) \
  1117. X                ;
  1118. X
  1119. X
  1120. X/*
  1121. X**  STRUCTURES
  1122. X*/
  1123. X
  1124. Xstruct MenuInfo
  1125. X{
  1126. X    char            name    [15];        /* file name */
  1127. X    int            wfrow;            /* window first row */
  1128. X    int            wlrow;            /* window last row */
  1129. X    int            wfcol;            /* window first col */
  1130. X    int            wlcol;            /* window last col */
  1131. X    int            row_cursor;        /* row for cursor */
  1132. X    int            col_cursor;        /* col for cursor */
  1133. X    unsigned        boxtype;        /* 0 = no box */
  1134. X    unsigned        linetype;        /* same as box */
  1135. X    int            titlecount;
  1136. X    int            optioncount;        /* base 0 */
  1137. X    struct OptionInfo    *option    [MAXOPTION];
  1138. X    struct ScreenInfo    *srn    [MAXSCREENS+1];    /* .DEFINE_SCREEN */
  1139. X                            /* NULL = EOL */
  1140. X    char            *after_menu;        /* command to run */
  1141. X};
  1142. X
  1143. X
  1144. Xstruct OptionInfo
  1145. X{
  1146. X    char    keyword        [MAXKEYLENGTH+1];
  1147. X    int    opnumber;                /* option number */
  1148. X    char    description    [200];
  1149. X    char    *command;
  1150. X    int    row;                    /* row to display */
  1151. X    int    col;                    /* col to display */
  1152. X};
  1153. X
  1154. Xstruct ScreenInfo
  1155. X{
  1156. X    char            name    [31];        /* screen name */
  1157. X    char            title    [100];        /* window title */
  1158. X    int            toprow;            /* upper left corner */
  1159. X    char            toprowvar[40];
  1160. X    int            leftcol;
  1161. X    char            leftcolvar[40];
  1162. X    int            rows;            /* # rows in win */
  1163. X    int            cols;            /* # cols in win */
  1164. X    unsigned        boxtype;        /* 0 = no box */
  1165. X    int            exitlastfield;        /* after last field */
  1166. X    int            exitoncancel;        /* only on KEY_CANCEL */
  1167. X    char            helpfile[16];
  1168. X    struct TextInfo        *textinfo[MAXTEXT+1];    /* text information */
  1169. X    char            *fielddefaults;        /* init field command */
  1170. X    char            *after_screen;        /* command to run */
  1171. X    struct FieldInfo    *field    [MAXFIELDS+1];
  1172. X};
  1173. X
  1174. X
  1175. Xstruct FieldInfo
  1176. X{
  1177. X    char    name    [30];                /* field name */
  1178. X    char    label    [50];                /* field label */
  1179. X    int    row;                    /* start position */
  1180. X    int    col;
  1181. X    int    length;
  1182. X    int    min_input;
  1183. X    char    mask    [100];
  1184. X    char    range    [MAXLEN];
  1185. X    char    type;
  1186. X    char    adjust;
  1187. X    int    mustenter;
  1188. X    char    prompt    [100];
  1189. X    char    terminator[3];                /* field terminators */
  1190. X    int    noinput;
  1191. X    char    *before_field;                /* before command */
  1192. X    char    *after_field;                /* after command */
  1193. X};
  1194. X
  1195. Xstruct TextInfo
  1196. X{
  1197. X    int    row;                    /* row to display txt */
  1198. X    int    col;                    /* col to diplay txt */
  1199. X    char    *text;                    /* the text */
  1200. X};
  1201. SHAR_EOF
  1202. chmod 0644 menu.h || echo "restore of menu.h fails"
  1203. echo "x - extracting terminal.h (Text)"
  1204. sed 's/^X//' << 'SHAR_EOF' > terminal.h &&
  1205. X#ifndef LINT
  1206. Xstatic char ID_terminal[] = "@(#)terminal.h    1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1207. X#endif
  1208. X
  1209. X/* Mover Keys */
  1210. Xextern int    KeyReturn;
  1211. Xextern int    KeyDown;
  1212. Xextern int    KeyUp;
  1213. Xextern int    KeyTab;
  1214. Xextern int    KeyBTab;
  1215. X
  1216. X/* Edit Keys */
  1217. Xextern int    KeyBeg;
  1218. Xextern int    KeyEnd;
  1219. Xextern int    KeyRight;
  1220. Xextern int    KeyLeft;
  1221. Xextern int    KeyBackspace;
  1222. Xextern int    KeyEOL;
  1223. Xextern int    KeyDL;
  1224. Xextern int    KeyDC;
  1225. Xextern int    KeyIC;
  1226. X
  1227. X/* Other Keys */
  1228. Xextern int    KeyHelp;
  1229. Xextern int    KeyRedraw;
  1230. Xextern int    KeyCancel;
  1231. Xextern int    KeySave;
  1232. Xextern int    KeyPrint;
  1233. Xextern int    KeyAccept;
  1234. X
  1235. X
  1236. X/* Menu Specific Keys */
  1237. Xextern int    KeyMainMenu;
  1238. Xextern int    KeyPrevMenu;
  1239. Xextern int    KeyExitMenu;
  1240. Xextern int    KeyGname;
  1241. Xextern int    KeyPopGname;
  1242. SHAR_EOF
  1243. chmod 0444 terminal.h || echo "restore of terminal.h fails"
  1244. echo "x - extracting LexDeSrn.l (Text)"
  1245. sed 's/^X//' << 'SHAR_EOF' > LexDeSrn.l &&
  1246. X%{
  1247. X#ifndef LINT
  1248. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1249. X#endif
  1250. X%}
  1251. X
  1252. X%{
  1253. X#include     "y.tab.h"
  1254. X#include    "menu.h"
  1255. X
  1256. X#undef    YYLMAX
  1257. X#define    YYLMAX    MAXLEN
  1258. X
  1259. Xchar    *malloc();
  1260. X%}
  1261. X%%
  1262. X%{
  1263. X/*
  1264. X**    Operators:
  1265. X**    " \ [ ] ^ - ? . * + | ( ) $ / { } % < >
  1266. X**    -    match a range
  1267. X**    ^    match all except or match begining of line if outside []
  1268. X**    .    match any character except \n
  1269. X**    ?    optional  ab?c matches ac or abc
  1270. X**    |    alternation  ab|cd matches either ab or cd
  1271. X**    $    match end of line
  1272. X**    /    trailing context  ab/cd matches ab only if followed by cd
  1273. X**    <>    start conditions
  1274. X**    {}    repetitions a{1,5}  or definition expansion {abc}
  1275. X**    %    separator for source segments
  1276. X**
  1277. X**    object        match one occurence of object
  1278. X**    object*        matches zero or more occurrences of object
  1279. X**    object+        matches one or more occurrences of object
  1280. X**    object{m,n}    match m through n occurrences of object
  1281. X*/
  1282. X%}
  1283. X
  1284. X%{ /* Screen Stuff
  1285. X%}
  1286. X"window_rows"        return (SCREEN_ROWS);
  1287. X"window_title"        return (SCREEN_TITLE);
  1288. X"window_cols"        return (SCREEN_COLS);
  1289. X"window_border"        return (SCREEN_BORDER);
  1290. X"window_pos"        return (SCREEN_POS);
  1291. X"helpfile"        return (SCREEN_HELP);
  1292. X"exit_last_field"    return (EXIT_LAST_FIELD);
  1293. X"exit_on_cancel"    return (EXIT_ON_CANCEL);
  1294. X"text"            return (SCREEN_TEXT);
  1295. X"field_defaults"    return (FIELD_DEFAULTS);
  1296. X"after_screen"        return (AFTER_SCREEN);
  1297. X
  1298. X%{ /* Field Stuff
  1299. X%}
  1300. X"field_name"        return(FIELD_NAME); 
  1301. X"field_label"         return(FIELD_LABEL); 
  1302. X"field_row"        return (FIELD_ROW);
  1303. X"field_col"        return (FIELD_COL);
  1304. X"field_mask"        return (FIELD_MASK);
  1305. X"field_range"        return (FIELD_RANGE);
  1306. X"field_length"        return (FIELD_LENGTH);
  1307. X"field_min"        return (FIELD_MIN);
  1308. X"field_type"        return (FIELD_TYPE);
  1309. X"field_edits"        return (FIELD_TYPE);
  1310. X"field_adjust"        return (FIELD_ADJUST);
  1311. X"field_mustenter"    return (FIELD_MUSTENTER);
  1312. X"field_prompt"        return (FIELD_PROMPT);
  1313. X"field_terminator"    return (FIELD_TERMINATOR);
  1314. X"field_noinput"        return (FIELD_NOINPUT);
  1315. X"before_field"        return (BEFORE_FIELD);
  1316. X"after_field"        return (AFTER_FIELD);
  1317. X
  1318. X"ENDSCREEN"        return(0);
  1319. X
  1320. X
  1321. X%{ /* Comment line */
  1322. X%}
  1323. X###            { while (input() != '\n'); }
  1324. X
  1325. X[0-9]+            { 
  1326. X                yylval.number = atoi (yytext);
  1327. X                return (NUMBER); 
  1328. X            }
  1329. X
  1330. X%{ /* Alphanumeric string with a leading $ and alphabetic character. */ 
  1331. X%}
  1332. X[$][A-Za-z][A-Za-z0-9_\[\]]* {
  1333. X                            yylval.string = malloc(strlen(yytext)+1);
  1334. X                            strcpy(yylval.string,yytext);
  1335. X                return (EVAR); 
  1336. X            }
  1337. X
  1338. X%{ /* Alphanumeric string with a leading alphabetic character. */ 
  1339. X%}
  1340. X[A-Za-z][A-Za-z0-9_]*    { 
  1341. X                            yylval.string = malloc(strlen(yytext)+1);
  1342. X                            strcpy(yylval.string,yytext);
  1343. X                return (STRING); 
  1344. X            }
  1345. X
  1346. X%{/* Quoted string with a possible " in the string.  ex. "abc\"def" */
  1347. X%}
  1348. X\"[^"]*            {
  1349. X                if (yytext[yyleng-1] == '\\')
  1350. X                {
  1351. X                    yymore ();
  1352. X                }
  1353. X                else
  1354. X                {
  1355. X                    int    i,j;
  1356. X                    /*
  1357. X                    ** need to validate that it is a quote
  1358. X                    ** a core dump will occur if not.
  1359. X                    */
  1360. X                    input ();    /* get last " */
  1361. X                                yylval.string=malloc(strlen(yytext)+1);
  1362. X                    for (j=0,i=1; i < strlen(yytext); i++)
  1363. X                    {
  1364. X                        if (yytext[i] == '\\' && 
  1365. X                            yytext[i+1] == '"')
  1366. X                            continue;
  1367. X                        yylval.string[j++] = yytext[i];
  1368. X                    }
  1369. X                    yylval.string[j] = '\0';
  1370. X                    return (QUOTE_STRING);
  1371. X                }
  1372. X            }
  1373. X
  1374. X","             return (COMMA);
  1375. X"="        return (EQUAL);
  1376. X%{/* Ignore blank, tab, newline */
  1377. X%}
  1378. X[ \t\n]        ;
  1379. X%%
  1380. SHAR_EOF
  1381. chmod 0644 LexDeSrn.l || echo "restore of LexDeSrn.l fails"
  1382. echo "x - extracting menu.hlp (Text)"
  1383. sed 's/^X//' << 'SHAR_EOF' > menu.hlp &&
  1384. XTABLE_OF_CONTENTS
  1385. Xmenu.hlp    menu        Menus      - Help using menus.
  1386. Xmenu.hlp    popmenu        Pop-menus  - Help using popmenus.
  1387. Xmenu.hlp    GETINPUT    Input      - Editing commands.
  1388. Xmenu.hlp    help        Help       - Using help.
  1389. XTABLE_OF_CONTENTS
  1390. X
  1391. X
  1392. Xmenu
  1393. X.TITLE Menu Help
  1394. X
  1395. X  \RMENU COMMANDS:\N
  1396. X          m       \D-  Go directly to main menu.\N
  1397. X          p       \D-  Return to previous menu.\N
  1398. X          g or ^g \D-  Go directly to a specific menu.\N
  1399. X          h or ?  \D-  This help screen.\N
  1400. X          ^r      \D-  Redraw the screen.\N
  1401. X          e       \D-  Exit.\N
  1402. X          !       \D-  Enter a unix command.\N
  1403. X
  1404. X  \RSELECTING OPTIONS:\N
  1405. X          -  Use "up arrow key", "^k", "down arrow key", "^j" or
  1406. X             "tab key" to place bar on option and press "return".    
  1407. X
  1408. X                  or
  1409. X
  1410. X          -  Enter option number and press "return".
  1411. X
  1412. Xmenu
  1413. X
  1414. X
  1415. Xpopmenu
  1416. X.TITLE Pop-Up Menu Help
  1417. XSELECTING OPTIONS:
  1418. X    Use "up arrow key", "^k", "down arrow key", "^j", 
  1419. X    to place bar on option and press "return".
  1420. X
  1421. X    or
  1422. X
  1423. X    Enter the first character of the option you
  1424. X    wish to select and press "return".
  1425. X
  1426. X    KEY_CANCEL (esc)   - Cancel selection.
  1427. Xpopmenu
  1428. X
  1429. X
  1430. XGETINPUT
  1431. X.TITLE GETINPUT Help
  1432. XMover Keys:
  1433. X        KEY_RETURN  (^m)    Traverse forwards through the fields.
  1434. X        KEY_DOWN  (^j)      Traverse forwards through the fields.
  1435. X        KEY_UP  (^k)        Traverse backwards through the fields.
  1436. X        KEY_TAB  (^i)       Fast forward through the fields.
  1437. X        KEY_BTAB            Fast reverse through the fields.
  1438. XField Editing Keys:
  1439. X        KEY_BEG  (^b)       Place cursor at beginning of field.
  1440. X        KEY_END  (^e)       Place cursor at end of input in field.
  1441. X        KEY_RIGHT  (^l)     Forward space within the field.
  1442. X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
  1443. X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
  1444. X        KEY_EOL  (^d)       Delete from cursor to end of field.
  1445. X        KEY_DL  (^c)        Clear field and home cursor.
  1446. X        KEY_DC  (^x)        Delete a character.
  1447. X        KEY_IC  (^t)        Toggle between type-over and insert mode.
  1448. XOther Keys:
  1449. X        KEY_HELP  (?)       Display help screen.
  1450. X        KEY_REFRESH  (^r)   Redraw the screen.
  1451. X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
  1452. X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
  1453. X        KEY_SAVE  (^f)      Save screen to a file.
  1454. X        KEY_PRINT  (^p)     Print screen to lp.
  1455. XGETINPUT
  1456. X
  1457. X
  1458. Xhelp
  1459. X.TITLE Using Help
  1460. XHelp displays consist of a description displayed in a window.
  1461. XIf the description doesn't fit in the window, the Up Arrow and
  1462. XDown Arrow keys can be used to view a few more lines of the 
  1463. Xdisplay.  Exiting the help system will return the display to 
  1464. Xthe state it was in when you asked for help.
  1465. X
  1466. X   The following keys are active in help:
  1467. X        KEY_CANCEL  (esc)   Exit help.
  1468. X        KEY_DOWN  (^j)      View a few more lines.
  1469. X        KEY_UP  (^k)        View the previous lines.
  1470. X        KEY_BEG  (^b)       Display first page.
  1471. X        KEY_END  (^e)       Display last page.
  1472. X        KEY_TOC  (^t)       Display help table of contents.
  1473. Xhelp
  1474. SHAR_EOF
  1475. chmod 0644 menu.hlp || echo "restore of menu.hlp fails"
  1476. echo "x - extracting runrealid.c (Text)"
  1477. sed 's/^X//' << 'SHAR_EOF' > runrealid.c &&
  1478. X#ifndef LINT
  1479. Xstatic char Sccsid[] = "@(#)runrealid.c    1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1480. X#endif
  1481. X
  1482. X#include    <stdio.h>
  1483. X
  1484. Xmain ( argc, argv )
  1485. X    int    argc;
  1486. X    char    *argv[];
  1487. X{
  1488. X    register int    uid, euid, gid, egid ;
  1489. X
  1490. X    /* who am i */
  1491. X    uid = getuid() ;
  1492. X    euid = geteuid() ;
  1493. X    gid = getgid() ;
  1494. X    egid = getegid() ;
  1495. X
  1496. X    /* reset back to the read id */
  1497. X    setuid( uid ) ;
  1498. X    setgid( gid ) ;
  1499. X
  1500. X    system( argv[1] ) ;
  1501. X
  1502. X    /* reset back to the fake id */
  1503. X    setuid( euid ) ;
  1504. X    setgid( egid ) ;
  1505. X}
  1506. X/* Sam S. Lok  11/89 */
  1507. SHAR_EOF
  1508. chmod 0444 runrealid.c || echo "restore of runrealid.c fails"
  1509. echo "x - extracting ParseDeSrn.y (Text)"
  1510. sed 's/^X//' << 'SHAR_EOF' > ParseDeSrn.y &&
  1511. X%{
  1512. X#ifndef LINT
  1513. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1514. X#endif
  1515. X%}
  1516. X
  1517. X%{
  1518. X#include    <curses.h>
  1519. X#include    "GetInput.h"
  1520. X#include    "menu.h"
  1521. X
  1522. X#define    FLD    yyscreen->field[fieldcount-1]
  1523. X
  1524. X#ifdef    _yydebug
  1525. Xextern int        yydebug;
  1526. X#endif
  1527. Xextern int        debug;
  1528. Xstruct ScreenInfo    *yyscreen;
  1529. Xint            fieldcount;
  1530. Xchar            eott[50];        /* error on this token */
  1531. Xchar            *malloc();
  1532. Xint            textcount;        /* # of text(s) */
  1533. X%}
  1534. X%{
  1535. X/*
  1536. X**    The %union declares yylval and the Yacc value stack as a C language
  1537. X**    union of types specified in the body.
  1538. X**
  1539. X**    The %type assigns member declared in the %union to non-terminals.
  1540. X**    The %token <..> assigns member declared in the %union to terminals.
  1541. X*/
  1542. X%}
  1543. X%union{
  1544. X    int    number;
  1545. X    char    *string;
  1546. X}
  1547. X
  1548. X%token    <number> NUMBER
  1549. X%token    <string> STRING
  1550. X%token    <string> QUOTE_STRING
  1551. X%token    <string> EVAR
  1552. X%token     COMMA EQUAL
  1553. X%token     SCREEN_TITLE SCREEN_ROWS SCREEN_COLS SCREEN_BORDER SCREEN_POS
  1554. X%token     SCREEN_HELP EXIT_LAST_FIELD EXIT_ON_CANCEL SCREEN_TEXT AFTER_SCREEN
  1555. X%token     FIELD_NAME FIELD_LABEL FIELD_ROW FIELD_COL FIELD_MASK FIELD_RANGE
  1556. X%token    FIELD_LENGTH FIELD_MIN FIELD_TYPE FIELD_ADJUST FIELD_MUSTENTER 
  1557. X%token    FIELD_TERMINATOR FIELD_PROMPT FIELD_DEFAULTS FIELD_NOINPUT
  1558. X%token    BEFORE_FIELD AFTER_FIELD
  1559. X
  1560. X%%
  1561. X
  1562. X
  1563. Xscreen        : valid_field
  1564. X        | screen valid_field
  1565. X        | screen COMMA valid_field
  1566. X        ;
  1567. X
  1568. Xvalid_field    : screen_pos 
  1569. X        {
  1570. X            strcpy (eott, "window_pos");
  1571. X            if (debug)
  1572. X            {
  1573. X                fprintf (stderr, 
  1574. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> window_pos");
  1575. X                fflush (stderr);
  1576. X            }
  1577. X        }
  1578. X        ;
  1579. X        | screen_rows 
  1580. X        {
  1581. X            strcpy (eott, "window_rows");
  1582. X            if (debug)
  1583. X            {
  1584. X                fprintf (stderr, 
  1585. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> window_rows");
  1586. X                fflush (stderr);
  1587. X            }
  1588. X        }
  1589. X        ;
  1590. X        | screen_cols 
  1591. X        {
  1592. X            strcpy (eott, "window_cols");
  1593. X            if (debug)
  1594. X            {
  1595. X                fprintf (stderr, 
  1596. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> window_cols");
  1597. X                fflush (stderr);
  1598. X            }
  1599. X        }
  1600. X        ;
  1601. X        | screen_border
  1602. X        {
  1603. X            strcpy (eott, "window_border");
  1604. X            if (debug)
  1605. X            {
  1606. X                fprintf (stderr, 
  1607. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> window_border");
  1608. X                fflush (stderr);
  1609. X            }
  1610. X        }
  1611. X        ;
  1612. X        | screen_title
  1613. X        {
  1614. X            strcpy (eott, "window_title");
  1615. X            if (debug)
  1616. X            {
  1617. X                fprintf (stderr, 
  1618. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> window_title");
  1619. X                fflush (stderr);
  1620. X            }
  1621. X        }
  1622. X        ;
  1623. X        | screen_help
  1624. X        {
  1625. X            strcpy (eott, "helpfile");
  1626. X            if (debug)
  1627. X            {
  1628. X                fprintf (stderr, 
  1629. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> helpfile");
  1630. X                fflush (stderr);
  1631. X            }
  1632. X        }
  1633. X        ;
  1634. X        | exit_last_field
  1635. X        {
  1636. X            strcpy (eott, "exit_last_field");
  1637. X            if (debug)
  1638. X            {
  1639. X                fprintf (stderr, 
  1640. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> exit_last_field");
  1641. X                fflush (stderr);
  1642. X            }
  1643. X        }
  1644. X        ;
  1645. X        | exit_on_cancel
  1646. X        {
  1647. X            strcpy (eott, "exit_on_cancel");
  1648. X            if (debug)
  1649. X            {
  1650. X                fprintf (stderr, 
  1651. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> exit_on_cancel");
  1652. X                fflush (stderr);
  1653. X            }
  1654. X        }
  1655. X        ;
  1656. X        | screen_text
  1657. X        {
  1658. X            strcpy (eott, "text");
  1659. X            if (debug)
  1660. X            {
  1661. X                fprintf (stderr, 
  1662. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> text");
  1663. X                fflush (stderr);
  1664. X            }
  1665. X        }
  1666. X        ;
  1667. X        | after_screen
  1668. X        {
  1669. X            strcpy (eott, "after_screen");
  1670. X            if (debug)
  1671. X            {
  1672. X                fprintf (stderr, 
  1673. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> after_screen");
  1674. X                fflush (stderr);
  1675. X            }
  1676. X        }
  1677. X        ;
  1678. X
  1679. X        | field_name 
  1680. X        {
  1681. X            strcpy (eott, "field_name");
  1682. X            if (debug)
  1683. X            {
  1684. X                fprintf (stderr, 
  1685. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_name");
  1686. X                fflush (stderr);
  1687. X            }
  1688. X        }
  1689. X        ;
  1690. X        | field_label 
  1691. X        {
  1692. X            strcpy (eott, "field_label");
  1693. X            if (debug)
  1694. X            {
  1695. X                fprintf (stderr, 
  1696. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_label");
  1697. X                fflush (stderr);
  1698. X            }
  1699. X        }
  1700. X        ;
  1701. X        | field_row 
  1702. X        {
  1703. X            strcpy (eott, "field_row");
  1704. X            if (debug)
  1705. X            {
  1706. X                fprintf (stderr, 
  1707. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_row");
  1708. X                fflush (stderr);
  1709. X            }
  1710. X        }
  1711. X        ;
  1712. X        | field_col 
  1713. X        {
  1714. X            strcpy (eott, "field_col");
  1715. X            if (debug)
  1716. X            {
  1717. X                fprintf (stderr, 
  1718. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_col");
  1719. X                fflush (stderr);
  1720. X            }
  1721. X        }
  1722. X        ;
  1723. X        | field_mask
  1724. X        {
  1725. X            strcpy (eott, "field_mask");
  1726. X            if (debug)
  1727. X            {
  1728. X                fprintf (stderr, 
  1729. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_mask");
  1730. X                fflush (stderr);
  1731. X            }
  1732. X        }
  1733. X        ;
  1734. X        | field_range 
  1735. X        {
  1736. X            strcpy (eott, "field_range");
  1737. X            if (debug)
  1738. X            {
  1739. X                fprintf (stderr, 
  1740. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_range");
  1741. X                fflush (stderr);
  1742. X            }
  1743. X        }
  1744. X        ;
  1745. X        | field_length 
  1746. X        {
  1747. X            strcpy (eott, "field_length");
  1748. X            if (debug)
  1749. X            {
  1750. X                fprintf (stderr, 
  1751. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_length");
  1752. X                fflush (stderr);
  1753. X            }
  1754. X        }
  1755. X        ;
  1756. X        | field_min 
  1757. X        {
  1758. X            strcpy (eott, "field_min");
  1759. X            if (debug)
  1760. X            {
  1761. X                fprintf (stderr, 
  1762. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_min");
  1763. X                fflush (stderr);
  1764. X            }
  1765. X        }
  1766. X        ;
  1767. X        | field_type
  1768. X        {
  1769. X            strcpy (eott, "field_edits");
  1770. X            if (debug)
  1771. X            {
  1772. X                fprintf (stderr, 
  1773. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_edits");
  1774. X                fflush (stderr);
  1775. X            }
  1776. X        }
  1777. X        ;
  1778. X        | field_adjust 
  1779. X        {
  1780. X            strcpy (eott, "field_adjust");
  1781. X            if (debug)
  1782. X            {
  1783. X                fprintf (stderr, 
  1784. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_adjust");
  1785. X                fflush (stderr);
  1786. X            }
  1787. X        }
  1788. X        ;
  1789. X        | field_mustenter 
  1790. X        {
  1791. X            strcpy (eott, "field_mustenter");
  1792. X            if (debug)
  1793. X            {
  1794. X                fprintf (stderr, 
  1795. SHAR_EOF
  1796. echo "End of part 7"
  1797. echo "File ParseDeSrn.y is continued in part 8"
  1798. echo "8" > s2_seq_.tmp
  1799. exit 0
  1800.