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

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1) part 11 of 14
  4. Message-ID: <445@pcbox.UUCP>
  5. Date: 26 Dec 90 20:14:25 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 11 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file utilities.d/libgeti.d/drawbox.c continued
  12. #
  13. CurArch=11
  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 utilities.d/libgeti.d/drawbox.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/drawbox.c
  25. X        break;
  26. X
  27. X       case StandoutLine:
  28. X        /* draw a standout line */
  29. X        attribute = A_STANDOUT;
  30. X        vchar = ' ';
  31. X        hchar = ' ';
  32. X        tlchar = ' ';
  33. X        trchar = ' ';
  34. X        brchar = ' ';
  35. X        blchar = ' ';
  36. X        break;
  37. X
  38. X       case SingleLine:
  39. X        /* attempt to draw a graphic single line */
  40. X        vchar = 'x';
  41. X        hchar = 'q';
  42. X        tlchar = 'l';
  43. X        trchar = 'k';
  44. X        brchar = 'j';
  45. X        blchar = 'm';
  46. X        break;
  47. X
  48. X       case MosaicLine:
  49. X        vchar = 'a';
  50. X        hchar = 'a';
  51. X        tlchar = 'a';
  52. X        trchar = 'a';
  53. X        brchar = 'a';
  54. X        blchar = 'a';
  55. X        break;
  56. X
  57. X       case DiamondLine:
  58. X        vchar = '`';
  59. X        hchar = '`';
  60. X        tlchar = '`';
  61. X        trchar = '`';
  62. X        brchar = '`';
  63. X        blchar = '`';
  64. X        break;
  65. X
  66. X       case DotLine:
  67. X        vchar = '~';
  68. X        hchar = '~';
  69. X        tlchar = '~';
  70. X        trchar = '~';
  71. X        brchar = '~';
  72. X        blchar = '~';
  73. X        break;
  74. X
  75. X       case PlusLine:
  76. X        vchar = 'n';
  77. X        hchar = 'n';
  78. X        tlchar = 'n';
  79. X        trchar = 'n';
  80. X        brchar = 'n';
  81. X        blchar = 'n';
  82. X        break;
  83. X
  84. X       default:
  85. X        return;
  86. X    }
  87. X
  88. X#ifdef BSD
  89. X    standout ();
  90. X#else
  91. X       wattrset (win, attribute);
  92. X#endif
  93. X       for (row = frow-1; row <= trow-1; row++)
  94. X       {
  95. X              if (row == frow-1  ||  row == trow-1)
  96. X                 for (col = fcol-1; col <= tcol-1; col++)
  97. X                        mvwaddch (win, row, col, hchar);
  98. X              else
  99. X              {
  100. X                 mvwaddch (win, row, fcol-1, vchar);
  101. X                 mvwaddch (win, row, tcol-1, vchar);
  102. X              }
  103. X       }
  104. X    /* draw the corners */
  105. X    mvwaddch (win, frow-1,fcol-1, tlchar);    /* top left */
  106. X    mvwaddch (win, frow-1,tcol-1, trchar);    /* top right */
  107. X    mvwaddch (win, trow-1,fcol-1, blchar);    /* bottom left */
  108. X    mvwaddch (win, trow-1,tcol-1, brchar);    /* bottom right */
  109. X
  110. X    /* draw vertical scroll bars */
  111. X    if (vscroll)
  112. X    {
  113. X        /*
  114. X         *  Make sure we have a good percentage.  We'll bottom
  115. X         *  the elevator if the percentage is out of range.
  116. X         */
  117. X        if ( percent < 0.0 || percent > 1.0 )    /* < 0 = no elevator */
  118. X            percent = 1.0 ;            /* > 1 = undefined */
  119. X        /*
  120. X         *  The weird calculation here is because I want to fit the
  121. X         *  elevator within the window top and bottom boundary.  And
  122. X         *  calculating the relative position for the *bottom* of
  123. X         *  the elevator.  If you still don't get it, don't ask!
  124. X         */
  125. X        mvwaddch (win, frow+(int)((trow-frow-3)*percent)  ,tcol-1, '^');
  126. X        mvwaddch (win, frow+(int)((trow-frow-3)*percent)+1,tcol-1, 'v');
  127. X    }
  128. X    if (help)
  129. X    {
  130. X        wattrset (win, A_STANDOUT);
  131. X        if (isprint(KeyHelp))
  132. X            mvwprintw (win, trow-1,tcol-6, "Help %c", KeyHelp);
  133. X        else
  134. X            mvwprintw (win, trow-1,tcol-7, "Help %c", KeyHelp);
  135. X    }
  136. X
  137. X#ifdef BSD
  138. X       standend ();
  139. X#else
  140. X       wattrset (win, A_NORMAL);
  141. X#endif
  142. X}
  143. X/* Paul J. Condie  10/88 */
  144. SHAR_EOF
  145. echo "File utilities.d/libgeti.d/drawbox.c is complete"
  146. chmod 0644 utilities.d/libgeti.d/drawbox.c || echo "restore of utilities.d/libgeti.d/drawbox.c fails"
  147. echo "x - extracting utilities.d/libgeti.d/findfile.c (Text)"
  148. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/findfile.c &&
  149. X#ifndef LINT
  150. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  151. X#endif
  152. X
  153. X/* Function    findfile()
  154. X**          Search through a number of directories looking for a file
  155. X**  RETURNS    a pointer to the file with the directory if found
  156. X**        otherwise returns a null pointer.
  157. X*/
  158. X
  159. X#include    <stdio.h>
  160. X#include    <varargs.h>
  161. X#include    <sys/types.h>
  162. X#include    <sys/stat.h>
  163. X
  164. X/*VARARGS*/
  165. Xchar *findfile (va_alist)
  166. X    va_dcl
  167. X{
  168. X    va_list        ap;
  169. X    char        *filename;
  170. X    char        *directory;
  171. X    static char    file[200];
  172. X    char        *fileptr;
  173. X    struct stat    buf;
  174. X    int        rc;
  175. X
  176. X    va_start (ap);
  177. X    fileptr = file;
  178. X
  179. X    /* get filename to search for */
  180. X    if ((filename = va_arg (ap, char *)) == (char *)0)
  181. X    {
  182. X        va_end (ap);
  183. X        return ((char *)0);
  184. X    }
  185. X
  186. X    if (strcmp (filename, "") == 0)
  187. X    {
  188. X        va_end (ap);
  189. X        return ("");
  190. X    }
  191. X
  192. X    /* loop through each directory looking for file */
  193. X    while (1)
  194. X    {
  195. X        directory = va_arg (ap, char *);
  196. X        /* getenv() returns a null */
  197. X        if (directory == (char *)0)
  198. X            continue;
  199. X        if (strcmp (directory, "") == 0)
  200. X            break;
  201. X        sprintf (file, "%s/%s", directory, filename);
  202. X        if (stat (file, &buf) == 0)
  203. X        {
  204. X            va_end (ap);
  205. X            return (fileptr);
  206. X        }
  207. X    }
  208. X    va_end (ap);
  209. X    return ("");
  210. X}
  211. X/* Paul J. Condie  10/88 */
  212. SHAR_EOF
  213. chmod 0644 utilities.d/libgeti.d/findfile.c || echo "restore of utilities.d/libgeti.d/findfile.c fails"
  214. echo "x - extracting utilities.d/libgeti.d/getmmddyy.c (Text)"
  215. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/getmmddyy.c &&
  216. X/*
  217. X**  getmmddyy()
  218. X**    Takes a string and a date mask as arguments and returns
  219. X**    the month, day, year using the mask.
  220. X*/
  221. X
  222. X
  223. X#include <stdio.h>
  224. X#include <time.h>
  225. X#include "GetInput.h"
  226. X
  227. Xgetmmddyy (str, mask, month, day, year)
  228. X    char    *str;
  229. X    char    *mask;
  230. X    int    *year, *month, *day;
  231. X{
  232. X    char        cmdstr[5] ;
  233. X    static int    century = 0 ;
  234. X    long        clock;
  235. X
  236. X    struct tm *localtime(), *Tm ;
  237. X
  238. X    if (century == 0) {
  239. X
  240. X        clock = time((long *) 0) ;
  241. X        Tm = localtime (&clock) ;
  242. X        century = 1900 ;
  243. X        if (Tm->tm_year > 100)
  244. X            century += (Tm->tm_year / 100) * 100 ;
  245. X
  246. X    }
  247. X
  248. X    if (mask == NULL) {
  249. X
  250. X        cmdstr[0] = *str++ ;
  251. X        cmdstr[1] = *str++ ;
  252. X        cmdstr[2] = '\0' ;
  253. X        *month = atoi (cmdstr) ;
  254. X
  255. X        cmdstr[0] = *str++ ;
  256. X        cmdstr[1] = *str++ ;
  257. X        cmdstr[2] = '\0' ;
  258. X        *day = atoi (cmdstr) ;
  259. X
  260. X        cmdstr[0] = *str++ ;
  261. X        cmdstr[1] = *str++ ;
  262. X        cmdstr[2] = '\0' ;
  263. X        *year = atoi (cmdstr)  +  century ;
  264. X
  265. X    } else {
  266. X
  267. X        while ( *mask != '\0' ) {
  268. X
  269. X            while ( *mask != 'M' && *mask != 'D' && *mask != 'Y' )
  270. X                mask++ ;
  271. X
  272. X            switch (*mask) {
  273. X                case 'M':
  274. X                    cmdstr[0] = *str++ ;
  275. X                    cmdstr[1] = *str++ ;
  276. X                    cmdstr[2] = '\0' ;
  277. X                    *month = atoi (cmdstr) ;
  278. X                    mask += 2 ;
  279. X                    break ;
  280. X                case 'D':
  281. X                    cmdstr[0] = *str++ ;
  282. X                    cmdstr[1] = *str++ ;
  283. X                    cmdstr[2] = '\0' ;
  284. X                    *day = atoi (cmdstr) ;
  285. X                    mask += 2 ;
  286. X                    break ;
  287. X                case 'Y':
  288. X                    cmdstr[0] = *str++ ;
  289. X                    cmdstr[1] = *str++ ;
  290. X                    mask += 2 ;
  291. X                    if (*mask == 'Y') {
  292. X                        cmdstr[2] = *str++ ;
  293. X                        cmdstr[3] = *str++ ;
  294. X                        cmdstr[4] = '\0' ;
  295. X                        *year = atoi (cmdstr) ;
  296. X                        mask += 2 ;
  297. X                    } else {
  298. X                        cmdstr[2] = '\0' ;
  299. X                        *year = atoi (cmdstr) + century ;
  300. X                    }
  301. X                    break ;
  302. X            }
  303. X        }
  304. X    }
  305. X}
  306. SHAR_EOF
  307. chmod 0644 utilities.d/libgeti.d/getmmddyy.c || echo "restore of utilities.d/libgeti.d/getmmddyy.c fails"
  308. echo "x - extracting utilities.d/libgeti.d/popmenu.c (Text)"
  309. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.c &&
  310. X#ifndef LINT
  311. Xstatic char Sccsid[] = "%W%    DeltaDate %G%    ExtrDate %H%";
  312. X#endif
  313. X
  314. X#include    <curses.h>
  315. X#include    <term.h>
  316. X#include    <varargs.h>
  317. X
  318. X#define    MAXMENUS    10
  319. X#define    MAXITEMS    200
  320. X#define    NEWMENU        0
  321. X#define    DIMWINDOW    -1
  322. X#define    CREATEMENU    -2    /* only if it does not exist */
  323. X#define WRAPAROUND    TRUE
  324. X#define    DumbLine    1    /* A_NORMAL */
  325. X#define    StandoutLine    2    /* A_STANDOUT */
  326. X#define    SingleLine    3    /* A_ALTCHARSET */
  327. X
  328. X#ifndef    KEY_RETURN
  329. X#   define KEY_RETURN    '\r'
  330. X#endif
  331. X#ifndef KEY_HELP
  332. X#   define KEY_HELP    0553
  333. X#endif
  334. X#ifndef KEY_CANCEL
  335. X#   define KEY_CANCEL    0543
  336. X#endif
  337. X#ifndef KEY_DOWN
  338. X#   define KEY_DOWN    0402
  339. X#endif
  340. X#ifndef KEY_UP
  341. X#   define KEY_UP    0403
  342. X#endif
  343. X#ifndef KEY_REFRESH
  344. X#   define KEY_REFRESH    565
  345. X#endif
  346. X
  347. Xextern    int    KeyDown;
  348. Xextern    int    KeyUp;
  349. Xextern    int    KeyHelp;
  350. Xextern    int    KeyCancel;
  351. Xextern    int    KeyRedraw;
  352. Xextern    int    KeyReturn;
  353. Xextern    int    KeyBackspace;
  354. Xextern    int    KeyIC;
  355. X
  356. Xtypedef struct    _menu
  357. X{
  358. X    int    MenuId;            /* numerical menu identifier */
  359. X    int    row;
  360. X    int    col;
  361. X    char    *title ;        /* menu title */
  362. X    char    *helpfile;        /* helpfile */
  363. X    int    winSize ;        /* pop up window length */
  364. X    WINDOW    *win;
  365. X    int    NumItems;        /* number of items in menu */
  366. X    int    width;            /* largest item */
  367. X    char    *items[MAXITEMS+1];
  368. X    int    ActiveItem;        /* last item selected */
  369. X    int    FullMatch;        /* matching stype
  370. X                       TRUE = full string matching
  371. X                       FALSE = single 1st char matching */
  372. X} MENU;
  373. X
  374. X
  375. Xstatic MENU    *THEmenu[MAXMENUS+1];
  376. Xstatic char    promptStr[80] ;
  377. X
  378. X/*VARARGS*/
  379. Xpopmenu (va_alist)
  380. X
  381. X    va_dcl
  382. X{
  383. X    va_list        ap;
  384. X    int        action;
  385. X    int        MenuId;
  386. X    static int    midx = -1;        /* defined menus */
  387. X    char        *ws;            /* base address of table */
  388. X    char        **wws;            /* base address of table */
  389. X    int        wssize;            /* size of one element */
  390. X                        /*  or 0 if **wws is used */
  391. X    register int    i, j;
  392. X    int    rc;                /* return code */
  393. X    int    idx;                /* tmp menu index */
  394. X    int    NewMenu;            /* New Menu Flag */
  395. X    static int    _runMenu();
  396. X    char    *idontknow;            /* was a promptStr supplied */
  397. X
  398. X
  399. X    va_start (ap);
  400. X    action = va_arg (ap, int);
  401. X
  402. X    switch (action)
  403. X    {
  404. X       /*
  405. X       **    Initialize a new popup menu
  406. X       */
  407. X       case NEWMENU:
  408. X       case CREATEMENU:
  409. X        MenuId = va_arg (ap, int);
  410. X
  411. X        /* do we already have this MenuId */
  412. X        NewMenu = TRUE;
  413. X        for (i = 0; i <= midx; i++)
  414. X            if (THEmenu[i]->MenuId == MenuId)
  415. X            {
  416. X                /* Menu already exists */
  417. X                NewMenu = FALSE;
  418. X                if (action == CREATEMENU)
  419. X                    break;    /* don't re-create it */
  420. X
  421. X                /* junk old menu */
  422. X                delwin (THEmenu[i]->win);
  423. X                free (THEmenu[i]);
  424. X                idx = i;
  425. X                break;
  426. X            }
  427. X        if (NewMenu == FALSE  && action == CREATEMENU)
  428. X        {
  429. X            va_end (ap);
  430. X            break;
  431. X        }
  432. X        if (NewMenu == TRUE)
  433. X            idx = ++midx;
  434. X
  435. X
  436. X        /* build the new menu */
  437. X        THEmenu[idx] = (MENU *)malloc (sizeof(MENU));
  438. X        THEmenu[idx]->MenuId = MenuId;
  439. X        THEmenu[idx]->row = va_arg (ap, int);    /* upper left corner */
  440. X        THEmenu[idx]->col = va_arg (ap, int);
  441. X        THEmenu[idx]->title = va_arg (ap, char *);
  442. X        THEmenu[idx]->helpfile = va_arg (ap, char *);
  443. X        if (THEmenu[idx]->helpfile != (char *)NULL  &&
  444. X            strcmp (THEmenu[idx]->helpfile, "") == 0)
  445. X            THEmenu[idx]->helpfile = (char *)NULL;
  446. X        THEmenu[idx]->winSize = va_arg (ap, int);
  447. X        THEmenu[idx]->NumItems = 0;
  448. X        THEmenu[idx]->width = strlen (THEmenu[idx]->title);
  449. X        wssize = va_arg (ap, int);    /* size of one element */
  450. X        /* for char array, ws is used, otherwise, wws is used for
  451. X        ** char *array.
  452. X        */
  453. X        if ( wssize > 0 )
  454. X        {
  455. X            ws = va_arg (ap, char *);    /* base address of table */
  456. X            while (*ws != NULL)
  457. X            {
  458. X                THEmenu[idx]->items[THEmenu[idx]->NumItems] = ws ;
  459. X                THEmenu[idx]->NumItems++;
  460. X                if (strlen(ws) > THEmenu[idx]->width)
  461. X                    THEmenu[idx]->width = strlen(ws);
  462. X                ws += wssize ;
  463. X            }
  464. X        }
  465. X        else        /* this is basically dup code as above */
  466. X        {
  467. X            wws = va_arg (ap, char **);  /* base address of table */
  468. X            while (*wws != NULL)
  469. X            {
  470. X                THEmenu[idx]->items[THEmenu[idx]->NumItems] = *wws ;
  471. X                THEmenu[idx]->NumItems++;
  472. X                if (strlen(*wws) > THEmenu[idx]->width)
  473. X                    THEmenu[idx]->width = strlen(*wws);
  474. X                wws++ ;
  475. X            }
  476. X        }
  477. X        THEmenu[idx]->FullMatch = va_arg (ap, int); /* matching style */
  478. X
  479. X        /*
  480. X         * adjust length of popmenu
  481. X         */
  482. X        if (THEmenu[idx]->winSize <= 0)        /* default length */
  483. X            THEmenu[idx]->winSize = 6;
  484. X        /* not enough items? */
  485. X        if (THEmenu[idx]->winSize > THEmenu[idx]->NumItems ) 
  486. X            THEmenu[idx]->winSize = THEmenu[idx]->NumItems ;
  487. X        /* roll off bottom of screen? */
  488. X        if ( THEmenu[idx]->winSize > LINES-THEmenu[idx]->row-2 ) 
  489. X            THEmenu[idx]->winSize = LINES - THEmenu[idx]->row - 2 ;
  490. X
  491. X        /*
  492. X         * adjust the starting col of popmenu if the menu
  493. X         * will roll off the right edge of screen
  494. X         *      NOTE: col is 0 offset while width is not
  495. X         */
  496. X        if ( THEmenu[idx]->col > COLS-THEmenu[idx]->width-4 )
  497. X            THEmenu[idx]->col = COLS - THEmenu[idx]->width - 4 ;
  498. X
  499. X        va_end (ap);
  500. X        THEmenu[idx]->ActiveItem = 1;
  501. X
  502. X        THEmenu[idx]->win = newwin (THEmenu[idx]->winSize+2, 
  503. X                THEmenu[idx]->width+4,
  504. X                    THEmenu[idx]->row, THEmenu[idx]->col);
  505. X
  506. X        keypad (THEmenu[idx]->win, TRUE);
  507. X        rc = 0;            /* 0 return code */
  508. X        break;
  509. X
  510. X       case DIMWINDOW:
  511. X        MenuId = va_arg (ap, int);
  512. X        va_end (ap);
  513. X
  514. X        for (i = 0; i <= midx; i++)
  515. X            if (THEmenu[i]->MenuId == MenuId)
  516. X            {
  517. X                drawbox( THEmenu[i]->win, 1, 1,
  518. X                     THEmenu[i]->winSize+2,
  519. X                     THEmenu[i]->width+4,
  520. X                     SingleLine, DumbLine,
  521. X                     (THEmenu[i]->winSize >= 4  &&
  522. X                        THEmenu[i]->NumItems >
  523. X                        THEmenu[i]->winSize),
  524. X                     0,
  525. X                     (float)-1 ) ;
  526. X                mvwprintw (THEmenu[i]->win, 0, 
  527. X                    ((THEmenu[i]->width+4-
  528. X                        strlen(THEmenu[i]->title))/2),
  529. X                        "%s", THEmenu[i]->title);
  530. X                wrefresh (THEmenu[i]->win);
  531. X                break;
  532. X            }
  533. X        break;
  534. X
  535. X       default:
  536. X        /*
  537. X        **  Lets try to run a menu
  538. X        */
  539. X        MenuId = action;
  540. X
  541. X        /* Find the menu. */
  542. X        for (i = 0; i <= midx; i++)
  543. X            if (MenuId == THEmenu[i]->MenuId)
  544. X                break;
  545. X        if (i > midx)   return (-1);    /* invalid MenuId */
  546. X
  547. X        /* get default search string? */
  548. X        idontknow = va_arg( ap, char *);
  549. X        if (idontknow && THEmenu[i]->FullMatch ) 
  550. X        {
  551. X            strncpy( promptStr, idontknow, THEmenu[i]->width ) ;
  552. X            promptStr[THEmenu[i]->width] = NULL ;
  553. X        }
  554. X        else
  555. X            promptStr[0] = NULL ;
  556. X        va_end (ap);
  557. X
  558. X        rc = _runMenu (THEmenu[i]);
  559. X
  560. X        break;
  561. X    } /* end switch (action) */
  562. X    return (rc);
  563. X}
  564. X
  565. X
  566. X
  567. X_runMenu (menu)
  568. X
  569. X    MENU    *menu;
  570. X{
  571. X    register int    ch;
  572. X    register int    fptr;            /* field pointer */
  573. X    register int    i;
  574. X    register int    top;
  575. X    register int    inc;
  576. X    char    tmpStr[2] ;
  577. X    register int    firstTime = TRUE ;
  578. X
  579. X    if ( ! menu->FullMatch )        /* turn off cursor? */
  580. X        putp ( cursor_invisible ) ;
  581. X    else
  582. X        putp ( cursor_visible ) ;
  583. X    inc = (int)( menu->winSize / 2 ) ;    /* window increment */
  584. X    fptr = menu->ActiveItem;        /* set current item */
  585. X    top = fptr - menu->winSize + 1 ;    /* set top item of window */
  586. X    if ( top < 1 ) top = 1 ;        /* out of bound? */
  587. X
  588. X    _showWin( menu, top ) ;            /* Display the menu */
  589. X
  590. X    while (1)
  591. X    {
  592. X        wattrset (menu->win, A_REVERSE);
  593. X        mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
  594. X        wattrset (menu->win, A_NORMAL);
  595. X        if ( strlen( promptStr ) )
  596. X            wmove( menu->win, fptr-top+1, strlen( promptStr )+1 ) ;
  597. X        else
  598. X            wmove( menu->win, menu->winSize+1, menu->width+3 ) ;
  599. X        touchwin (menu->win);
  600. X        wrefresh (menu->win);
  601. X
  602. X        /*
  603. X         * The first time in, and if promptStr is filled
  604. X         * we'll extract the last char of promptStr, chop
  605. X         * promptStr by 1 char, so that that 1 char can
  606. X         * be strcat()ed back to promptStr later, and we also
  607. X         * skip the first wgetch().  This is to accomplish
  608. X         * the initial search when entering popmenu().
  609. X         */
  610. X        if ( firstTime && strlen( promptStr ) )
  611. X        {
  612. X            ch = promptStr[ strlen( promptStr ) - 1 ] ;
  613. X            promptStr[ strlen( promptStr ) - 1 ] = NULL ;
  614. X        }
  615. X        else
  616. X            ch = wgetch (menu->win);
  617. X        firstTime = FALSE ;
  618. X
  619. X        mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
  620. X
  621. X        if (ch == KeyReturn)       ch = KEY_RETURN;
  622. X        if (ch == KeyDown)       ch = KEY_DOWN;
  623. X        if (ch == KeyUp)       ch = KEY_UP;
  624. X        if (ch == KeyHelp)       ch = KEY_HELP;
  625. X        if (ch == KeyCancel)    ch = KEY_CANCEL;
  626. X        if (ch == KeyRedraw)    ch = KEY_REFRESH;
  627. X        if (ch == KeyBackspace)    ch = KEY_BACKSPACE;
  628. X        if (ch == KeyIC)    ch = KEY_IC;
  629. X
  630. X        if ( ch >= 'a' && ch <= 'z' )
  631. X            ch = toupper( ch ) ;    /* deals in upper case only */
  632. X        switch ( ch )
  633. X        {
  634. X           case KEY_DOWN:
  635. X           case KEY_RIGHT:
  636. X               promptStr[0] = NULL ;
  637. X            fptr = (fptr >= menu->NumItems) ? 1 : ++fptr;
  638. X
  639. X            /* stroll off window? */
  640. X            if ( fptr-top+1 > menu->winSize || fptr == 1 )
  641. X            {
  642. X                if ( fptr == 1 )
  643. X                    top = 1 ;
  644. X                else
  645. X                    top += inc ;
  646. X                _showWin( menu, top ) ;
  647. X            }
  648. X            break;
  649. X
  650. X           case KEY_UP:
  651. X           case KEY_LEFT:
  652. X               promptStr[0] = NULL ;
  653. X            wrefresh( menu->win ) ;
  654. X            fptr = (fptr <= 1) ? menu->NumItems : --fptr;
  655. X
  656. X            /* stroll off window? */
  657. X            if ( fptr == menu->NumItems || fptr < top )
  658. X            {
  659. X                if ( fptr == menu->NumItems && inc > 0 )
  660. X                    top = menu->NumItems - menu->winSize + 1 ;
  661. X                else
  662. X                    top -= inc ;
  663. X                if ( top < 1 ) top = 1 ;
  664. X                _showWin( menu, top ) ;
  665. X            }
  666. X            break;
  667. X
  668. X           case KEY_BACKSPACE:
  669. X            if ( strlen( promptStr ) )
  670. X                promptStr[ strlen( promptStr ) - 1 ] = NULL ;
  671. X            break ;
  672. X
  673. X           case KEY_IC:        /* toggle between full/1st match */
  674. X            menu->FullMatch = !menu->FullMatch ;    /* XOR it */
  675. X            promptStr[0] = NULL ;
  676. X            wattrset (menu->win, A_STANDOUT);
  677. X            mvwprintw( menu->win, menu->winSize+1, 0,
  678. X                menu->FullMatch?"All":"1st" ) ;
  679. X            wattrset (menu->win, A_NORMAL);
  680. X            break ;
  681. X
  682. X           case KEY_RETURN:
  683. X           case KEY_ENTER:
  684. X            menu->ActiveItem = fptr;
  685. X            wrefresh (menu->win);    /* force flush of attributes */
  686. X            putp ( cursor_visible ) ;
  687. X            return (menu->ActiveItem);
  688. X
  689. X           case KEY_CANCEL:
  690. X            putp ( cursor_visible ) ;
  691. X            return (-1);
  692. X
  693. X           case KEY_HELP:
  694. X            ShowHelp (menu->helpfile, "popmenu", LINES);
  695. X            break;
  696. X
  697. X           case KEY_REFRESH:
  698. X            clearok (menu->win, TRUE);
  699. X            wrefresh (menu->win);
  700. X            break;
  701. X
  702. X           default:
  703. X            /*
  704. X             * build the entered string
  705. X             */
  706. X            if ( menu->FullMatch )
  707. X            {
  708. X                tmpStr[0] = ch ;
  709. X                tmpStr[1] = NULL ;
  710. X                strcat( promptStr, tmpStr ) ;
  711. X            }
  712. X
  713. X            /*
  714. X             * Now do the matching, have fun
  715. X             */
  716. X
  717. X            /* look for first match from here on down */
  718. X            for ( i=fptr+(menu->FullMatch?0:1);
  719. X                  i<=menu->NumItems &&
  720. X                ( menu->FullMatch?
  721. X                    strnicmp( menu->items[i-1], promptStr,
  722. X                            strlen( promptStr ) ) :
  723. X                    toupper(*menu->items[i-1])!=ch ) ;
  724. X                i++ ) ; 
  725. X
  726. X            /* no match?  how about from here on up? */
  727. X            if ( i > menu->NumItems )
  728. X            {
  729. X                for ( i=1; i<fptr &&
  730. X                    ( menu->FullMatch?
  731. X                    strnicmp( menu->items[i-1], promptStr,
  732. X                            strlen( promptStr ) ) :
  733. X                    toupper(*menu->items[i-1])!=ch ) ;
  734. X                    i++ ) ; 
  735. X
  736. X                if ( fptr == i )    /* beep if no match */
  737. X                    beep() ;
  738. X            }
  739. X
  740. X            if ( fptr != i )
  741. X            {
  742. X                wrefresh( menu->win ) ;    /* clear the hilite */
  743. X                fptr = i ;
  744. X            }
  745. X
  746. X            /*
  747. X             * insure we have a match, otherwise, discard last
  748. X             * char entered from promptStr
  749. X             */
  750. X            if ( menu->FullMatch &&
  751. X                 strnicmp( menu->items[fptr-1], promptStr,
  752. X                strlen( promptStr ) ) &&
  753. X                 strlen( promptStr ) > 0 )
  754. X                promptStr[ strlen( promptStr ) - 1 ] = NULL ;
  755. X
  756. X            /* need to display a different window? */
  757. X            if ( fptr >= top+menu->winSize || fptr < top )
  758. X            {
  759. X                top = fptr ;
  760. X                _showWin( menu, top ) ;
  761. X            }
  762. X            break ;
  763. X        }  /* end switch (ch) */
  764. X    }
  765. X}
  766. X
  767. X/* pjc 7/87 */
  768. X
  769. X_showWin( menu, top )
  770. X    MENU    *menu ;
  771. X    int    top ;
  772. X{
  773. X    register int    i ;
  774. X
  775. X    for (i=0; i < menu->winSize && top+i-1 < menu->NumItems; i++)
  776. X        mvwprintw (menu->win, i+1, 2, "%-*s", menu->width, menu->items[top+i-1]);
  777. X    for (; i < menu->winSize ; i++)
  778. X        mvwprintw (menu->win, i+1, 2, "%*s", menu->width, " ");
  779. X
  780. X    drawbox( menu->win, 1, 1, menu->winSize+2, menu->width+4,
  781. X            StandoutLine, StandoutLine,
  782. X            (menu->winSize >= 4 && menu->NumItems > menu->winSize),
  783. X            (menu->helpfile != (char *)NULL),
  784. X            menu->NumItems ?
  785. X                (float)(top+menu->winSize-1) / (float)menu->NumItems
  786. X                    : 0 );
  787. X
  788. X    /* display title */
  789. X    wattrset (menu->win, A_STANDOUT);
  790. X    mvwprintw (menu->win, 0, ((menu->width+4)/2)-(strlen(menu->title)/2), 
  791. X        "%s", menu->title);
  792. X    wattrset (menu->win, A_NORMAL);
  793. X}
  794. SHAR_EOF
  795. chmod 0644 utilities.d/libgeti.d/popmenu.c || echo "restore of utilities.d/libgeti.d/popmenu.c fails"
  796. echo "x - extracting utilities.d/libgeti.d/stricmp.c (Text)"
  797. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/stricmp.c &&
  798. X/* Like strcmp() [string(3C)] but ignore case */
  799. X#define makelower(x)    (((x) >= 'A' && (x) <= 'Z') ? ((x) + ('a' - 'A')) : (x))
  800. Xint
  801. Xstricmp(s1, s2)
  802. Xregister char *s1, *s2;
  803. X{
  804. X    register int difference;
  805. X
  806. X    if(s1 == s2)
  807. X    return(0);
  808. X
  809. X    while((difference = (makelower(*s1) - makelower(*s2))) == 0) {
  810. X    if(*s1 == '\0')
  811. X        return(0);
  812. X    s1++;
  813. X    s2++;
  814. X    }
  815. X
  816. X    return(difference);
  817. X}
  818. X
  819. X/* Like strncmp() [string(3C)] but ignore case */
  820. Xint
  821. Xstrnicmp(s1, s2, n)
  822. Xregister char *s1, *s2;
  823. Xregister unsigned n;
  824. X{
  825. X    register int difference;
  826. X
  827. X    if(s1 == s2 || n == 0)
  828. X    return(0);
  829. X
  830. X    while((difference = (makelower(*s1) - makelower(*s2))) == 0) {
  831. X    if(*s1 == '\0' || --n == 0)
  832. X        return(0);
  833. X    s1++;
  834. X    s2++;
  835. X    }
  836. X
  837. X    return(difference);
  838. X}
  839. X
  840. X
  841. X#ifdef TESTMODE
  842. X#include  <stdio.h>
  843. Xmain()
  844. X{
  845. X    extern void exit();
  846. X    char string[2][BUFSIZ], number[BUFSIZ];
  847. X    int n;
  848. X
  849. X    while(1) {
  850. X    fputs("Enter 1st string: ", stdout);
  851. X    if(fgets(string[0], BUFSIZ, stdin) == NULL) {
  852. X        fputs("\nBye.\n", stdout);
  853. X        exit(0);
  854. X    }
  855. X    string[0][strlen(string[0])-1]='\0';
  856. X    fputs("Enter 2nd string: ", stdout);
  857. X    if(fgets(string[1], BUFSIZ, stdin) == NULL)
  858. X        *string[1]='\0';
  859. X    else
  860. X        string[1][strlen(string[1])-1]='\0';
  861. X    fputs("Enter number: ", stdout);
  862. X    if(fgets(number, BUFSIZ, stdin) == NULL)
  863. X        n = 0;
  864. X    else
  865. X        n = atoi(number);
  866. X    printf("strcmp(%s,%s) = %d\n",
  867. X        string[0], string[1], strcmp(string[0], string[1]));
  868. X    printf("stricmp(%s,%s) = %d\n",
  869. X        string[0], string[1], stricmp(string[0], string[1]));
  870. X    printf("strncmp(%s,%s,%d) = %d\n",
  871. X        string[0], string[1], n, strncmp(string[0], string[1], n));
  872. X    printf("strnicmp(%s,%s,%d) = %d\n",
  873. X        string[0], string[1], n, strnicmp(string[0], string[1], n));
  874. X    }
  875. X}
  876. X#endif
  877. X
  878. X/*
  879. X######################################################################
  880. X# This is the confidential, unpublished property of  Pacific  Bell.  #
  881. X# Receipt  or  possession  of  it  does  not  convey  any rights to  #
  882. X# divulge, reproduce, use, or allow others to use  it  without  the  #
  883. X# specific  written  authorization  of  Pacific  Bell  and use must  #
  884. X# conform strictly  to  the  license  agreement  between  user  and  #
  885. X# Pacific Bell.                                                      #
  886. X#                       Copyright (C) 1988   Pacific Bell            #
  887. X######################################################################
  888. X*/
  889. X#ifndef lint
  890. Xstatic char sccsid[] = "@(#)stricmp.c    UCLID 1.1";
  891. X#endif
  892. SHAR_EOF
  893. chmod 0666 utilities.d/libgeti.d/stricmp.c || echo "restore of utilities.d/libgeti.d/stricmp.c fails"
  894. echo "x - extracting utilities.d/libgeti.d/substr.c (Text)"
  895. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/substr.c &&
  896. X/*  E911 Project
  897. X *  substr()
  898. X *
  899. X *  Purpose:    To find a substring within a given string
  900. X *  Args:    s1: The string being searched
  901. X *        s2: the string being searched for
  902. X *  Return:    pointer to the where the searched for string resides
  903. X *        within the search string; otherwise NULL
  904. X */
  905. X#ifndef lint
  906. Xchar    Sccsid[] = "@(#)substr.c    1.3   6/17/88   10/13/88";
  907. X#endif
  908. X
  909. X
  910. Xchar *substr(s1, s2)
  911. X    char    *s1;
  912. X    char    *s2;
  913. X{
  914. X    char    *p1, *p2;
  915. X
  916. X    for ( ; *s1; s1++) {
  917. X        if (*s1 != *s2)
  918. X            continue;
  919. X        p1 = s1 + 1;
  920. X        p2 = s2 + 1;
  921. X        while (1) {
  922. X            if (*p2 == '\0')
  923. X                return(s1);
  924. X            if (*p1++ != *p2++)
  925. X                break;
  926. X        }
  927. X    }
  928. X    return((char *)0);
  929. X}
  930. X
  931. X
  932. X#ifdef LTEST
  933. Xmain()
  934. X{
  935. X    char    *strtok();
  936. X
  937. X    char    *s1, *s2, *s3;
  938. X    char    buffer[256];
  939. X
  940. X    printf("ok\n");
  941. X    while (gets(buffer)) {
  942. X        s1 = strtok(buffer, " \t:\n");
  943. X        s2 = strtok(0, " \t:\n");
  944. X        printf("%s:%s:", s1, s2);
  945. X        if (s1 && s2)
  946. X            if (s3 = substr(s1, s2))
  947. X                printf("%.*s\n", strlen(s2), s3);
  948. X            else
  949. X                printf("no match\n");
  950. X        else
  951. X            printf("invalid input\n");
  952. X    }
  953. X}
  954. X#endif
  955. X
  956. X
  957. SHAR_EOF
  958. chmod 0666 utilities.d/libgeti.d/substr.c || echo "restore of utilities.d/libgeti.d/substr.c fails"
  959. echo "x - extracting utilities.d/libgeti.d/upper.c (Text)"
  960. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/upper.c &&
  961. Xchar *upper (s)
  962. X
  963. X    char        *s;
  964. X{
  965. X    register int    i;
  966. X    static char    *ws;
  967. X
  968. X   ws = s;
  969. X   while (*s)
  970. X   {
  971. X      if (*s >= 'a'  &&  *s <= 'z')
  972. X         *s = (*s + 'A' - 'a');
  973. X      s++;
  974. X   }
  975. X   return (ws);
  976. X}
  977. SHAR_EOF
  978. chmod 0644 utilities.d/libgeti.d/upper.c || echo "restore of utilities.d/libgeti.d/upper.c fails"
  979. echo "x - extracting utilities.d/libgeti.d/GetInput.h (Text)"
  980. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.h &&
  981. X#ifndef LINT
  982. Xstatic char ID_GetInput[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  983. X#endif
  984. X
  985. X#define    HOLIDAY_FILE    "/usr/lib/acct/holidays"
  986. X
  987. X
  988. X/*
  989. X**    Type of allowable characters
  990. X*/
  991. X
  992. X#define    ALPHANUM    ' '
  993. X#define    ALPHA        'A'
  994. X#define    NUMERIC        '9'
  995. X#define    SET        'E'
  996. X#define    MENU        'M'
  997. X#define    UPPER        'U'
  998. X#define    UPPER_AN    'V'
  999. X#define    HEX        'H'
  1000. X#define    STATE        'S'
  1001. X#define    ZIP        'Z'
  1002. X#define    DATE        'D'
  1003. X#define    TIME        'T'
  1004. X#define    PROTECT        'P'
  1005. X
  1006. X/*
  1007. X**    Adjust/Fill
  1008. X*/
  1009. X
  1010. X#define    NOFILL        ' '
  1011. X#define    RTADJ_ZFILL    'Z'
  1012. X#define    RTADJ_BFILL    'B'
  1013. X#define    LFADJ_ZFILL    'z'
  1014. X#define    LFADJ_BFILL    'b'
  1015. X
  1016. X/*
  1017. X**    'C' field types
  1018. X*/
  1019. X
  1020. X#define CHAR        '0'
  1021. X#define INT        '1'
  1022. X#define SHORT        '2'
  1023. X#define LONG        '3'
  1024. X#define DOUBLE        '4'
  1025. X#define MONEY        'M'
  1026. X#define FLOAT        '5'
  1027. X
  1028. X/*
  1029. X**    Union to take care of a field that could be any valid
  1030. X**        'c' field type.
  1031. X*/
  1032. X
  1033. Xtypedef union FldUnion {
  1034. X    long    *longVal ;
  1035. X    double    *doubleVal ;
  1036. X    float    *floatVal ;
  1037. X    int    *intVal ;
  1038. X    short    *shortVal ;
  1039. X    char    *strVal ;
  1040. X} *FldUnPointer ;
  1041. X
  1042. X
  1043. X#define AUTONEXT    TRUE
  1044. X#define NOAUTO        FALSE
  1045. X
  1046. X#define MUSTENTER    TRUE
  1047. X#define NOMUST        FALSE
  1048. X
  1049. X#define NOHELP        ""
  1050. X#define NORANGE        NULL
  1051. X#define NOMSG        NULL
  1052. X#define NOMASK        NULL
  1053. X#define NOTAG        ""
  1054. X#define    A_SAME        -1        /* same as what's on the screen */
  1055. X
  1056. X
  1057. X#ifndef KEY_RETURN
  1058. X#   define KEY_RETURN    '\r'
  1059. X#endif
  1060. X#ifndef KEY_BEG
  1061. X#   define KEY_BEG    0542
  1062. X#endif
  1063. X#ifndef KEY_END
  1064. X#   define KEY_END    0550
  1065. X#endif
  1066. X#ifndef    KEY_SAVE
  1067. X#   define KEY_SAVE    0571
  1068. X#endif
  1069. X#ifndef    KEY_PRINT
  1070. X#   define KEY_PRINT     0532
  1071. X#endif
  1072. X#ifndef    KEY_HELP
  1073. X#   define KEY_HELP     0553
  1074. X#endif
  1075. X#ifndef    KEY_REFRESH
  1076. X#   define KEY_REFRESH     0565
  1077. X#endif
  1078. X#ifndef    KEY_TAB
  1079. X#   define KEY_TAB     '\t'
  1080. X#endif
  1081. X#ifndef    KEY_BTAB
  1082. X#   define KEY_BTAB     0541
  1083. X#endif
  1084. X#ifndef    KEY_CANCEL
  1085. X#   define KEY_CANCEL     0543
  1086. X#endif
  1087. X#ifndef    KEY_ACCEPT
  1088. X#   define KEY_ACCEPT     1000
  1089. X#endif
  1090. X#ifndef    KEY_TOC
  1091. X#   define KEY_TOC     1001
  1092. X#endif
  1093. X
  1094. X#define NOKEY        '\0'
  1095. X#define KEY_CTLA    '\001'
  1096. X#define KEY_CTLB    '\002'
  1097. X#define KEY_CTLC    '\003'
  1098. X#define KEY_CTLD    '\004'
  1099. X#define KEY_CTLE    '\005'
  1100. X#define KEY_CTLF    '\006'
  1101. X#define KEY_CTLG    '\007'
  1102. X#define KEY_CTLH    '\010'
  1103. X#define KEY_CTLI    '\011'
  1104. X#define KEY_CTLJ    '\012'
  1105. X#define KEY_CTLK    '\013'
  1106. X#define KEY_CTLL    '\014'
  1107. X#define KEY_CTLM    '\015'
  1108. X#define KEY_CTLN    '\016'
  1109. X#define KEY_CTLO    '\017'
  1110. X#define KEY_CTLP    '\020'
  1111. X#define KEY_CTLQ    '\021'
  1112. X#define KEY_CTLR    '\022'
  1113. X#define KEY_CTLS    '\023'
  1114. X#define KEY_CTLT    '\024'
  1115. X#define KEY_CTLU    '\025'
  1116. X#define KEY_CTLV    '\026'
  1117. X#define KEY_CTLW    '\027'
  1118. X#define KEY_CTLX    '\030'
  1119. X#define KEY_CTLY    '\031'
  1120. X#define KEY_CTLZ    '\032'
  1121. X
  1122. X/*
  1123. X**  Macros
  1124. X*/
  1125. X#define wattrOn(a, b)    wattrset(a, b)
  1126. X#define wattrOff(a)    wattrset(a, 0)
  1127. X#ifndef BELL
  1128. X#define    BELL    printf ("%c", 7)
  1129. X#endif
  1130. X
  1131. X#define    CLEARROW(row)    { \
  1132. X                int    col; \
  1133. X                int    tmprow; \
  1134. X                tmprow = ((row%100) == row) ? row : row/100; \
  1135. X                col = ((row%100) == row) ? 0 : row%100; \
  1136. X                for (; col<=COLS-2; col++) \
  1137. X                    mvwaddch (stdscr, tmprow,col, ' '); \
  1138. X            }
  1139. SHAR_EOF
  1140. chmod 0644 utilities.d/libgeti.d/GetInput.h || echo "restore of utilities.d/libgeti.d/GetInput.h fails"
  1141. echo "x - extracting utilities.d/libgeti.d/keys.h (Text)"
  1142. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/keys.h &&
  1143. X#ifndef LINT
  1144. Xstatic char ID_keys[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1145. X#endif
  1146. X
  1147. Xextern int    KeyReturn;
  1148. Xextern int      KeyDown;
  1149. Xextern int      KeyUp;
  1150. Xextern int      KeyTab;
  1151. Xextern int      KeyBTab;
  1152. Xextern int      KeyAccept;
  1153. X
  1154. Xextern int      KeyBeg;
  1155. Xextern int      KeyEnd;
  1156. Xextern int      KeyRight;
  1157. Xextern int      KeyLeft;
  1158. Xextern int      KeyBackspace;
  1159. Xextern int      KeyEOL;
  1160. Xextern int      KeyDL;
  1161. Xextern int      KeyDC;
  1162. Xextern int      KeyIC;
  1163. X
  1164. Xextern int      KeyHelp;
  1165. Xextern int      KeyTOC;
  1166. Xextern int      KeyRedraw;
  1167. Xextern int      KeySave;
  1168. Xextern int      KeyPrint;
  1169. Xextern int      KeyCancel;
  1170. SHAR_EOF
  1171. chmod 0644 utilities.d/libgeti.d/keys.h || echo "restore of utilities.d/libgeti.d/keys.h fails"
  1172. echo "x - extracting utilities.d/libgeti.d/makefile (Text)"
  1173. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/makefile &&
  1174. X# %W%   DeltaDate %G%   ExtrDate %H%
  1175. X
  1176. XTITLE = GETINPUT
  1177. X
  1178. XINSTALLLIB     = 
  1179. XINSTALLHDR    =
  1180. XMANDIR         = .
  1181. X
  1182. X###  CFLAG settings
  1183. X
  1184. X###  Sys5
  1185. XCFLAGS = -O
  1186. X###  Xenix
  1187. X#CFLAGS = -O -DM_TERMINFO -LARGE -Ml -Mlt34 -F 4000
  1188. X
  1189. XARFLAGS = rv
  1190. X
  1191. XLIBS = libgeti.a -lcurses -lc
  1192. X
  1193. X
  1194. XCFILES = AdjField.c DateFun.c DisPrmpt.c FindSet.c GetSetLen.c \
  1195. X    GetInput.c IsDate.c IsFldOk.c IsMask.c IsRange.c IsState.c IsTime.c \
  1196. X    ReDispFld.c ScrnOut.c ShowChar.c ShowSet.c ShowHelp.c \
  1197. X    popmenu.c BuildMenu.c checkmask.c doinsert.c InitGetI.c drawbox.c \
  1198. X    RingMenu.c findfile.c getmmddyy.c substr.c upper.c stricmp.c
  1199. X
  1200. XHFILES = GetInput.h keys.h
  1201. XMANPAGES = GetInput.3X popmenu.3 drawbox.3 ShowHelp.3
  1202. X
  1203. XOBJECTS =${CFILES:.c=.o}
  1204. X
  1205. Xinstall : libgeti.a
  1206. X    -ln libgeti.a ../../libgeti.a
  1207. X    -ln GetInput.h ../../GetInput.h
  1208. X
  1209. Xtest : libgeti.a _Main.o
  1210. X    $(CC) $(CFLAGS) _Main.o $(LIBS) -o test.out
  1211. X
  1212. Xlibgeti.a : $(OBJECTS)
  1213. X    ar $(ARFLAGS) libgeti.a $?
  1214. X
  1215. Xlint:
  1216. X    lint -I$(INCDIR) _Main.c $(CFILES) -lcurses > lint.out
  1217. X
  1218. Xprint :
  1219. X    PrintPrg $(MANPAGES) makefile $(CFILES) $(HFILES) _Main.c | lp -t$(TITLE)
  1220. X
  1221. Xshar:
  1222. X    shar -b GetInput.hlp $(MANPAGES) makefile $(CFILES) $(HFILES) _Main.c > libgeti.shar
  1223. X
  1224. Xclean :
  1225. X    rm -f *.o core libgeti.a test.out lint.out libgeti.shar \
  1226. X    ../../libgeti.a ../../GetInput.h libgeti.shar.Z
  1227. X
  1228. X#####
  1229. X#####
  1230. X
  1231. X_Main.o:    _Main.c GetInput.h keys.h
  1232. XAdjField.o:    AdjField.c GetInput.h
  1233. XDisPrmpt.o:    DisPrmpt.c GetInput.h
  1234. XFindSet.o:    FindSet.c GetInput.h
  1235. XGetSetLen.o:    GetSetLen.c GetInput.h
  1236. XGetInput.o:    GetInput.c GetInput.h keys.h
  1237. XIsDate.o:    IsDate.c GetInput.h
  1238. XIsFldOk.o:    IsFldOk.c GetInput.h
  1239. XIsMask.o:    IsMask.c GetInput.h
  1240. XIsRange.o:    IsRange.c GetInput.h
  1241. XIsTime.o:    IsTime.c GetInput.h
  1242. XReDispFld.o:    ReDispFld.c GetInput.h
  1243. XScrnOut.o:    ScrnOut.c GetInput.h
  1244. XShowChar.o:    ShowChar.c GetInput.h
  1245. XShowSet.o:    ShowSet.c GetInput.h
  1246. SHAR_EOF
  1247. chmod 0644 utilities.d/libgeti.d/makefile || echo "restore of utilities.d/libgeti.d/makefile fails"
  1248. echo "x - extracting utilities.d/libgeti.d/GetInput.3X (Text)"
  1249. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.3X &&
  1250. X. \ %W% DeltaDate %G% ExtrDate %H% 
  1251. X.TH GETINPUT 3X "libgeti"
  1252. X.SH NAME
  1253. XGetInput \- manages terminal input using curses
  1254. X.SH SYNOPSIS
  1255. X.LP
  1256. X.nf
  1257. X#include <curses.h>
  1258. X#include "GetInput.h"
  1259. X
  1260. Xint GetInput (win, row, col, &Fld, FldAttribute, FldMask,
  1261. X              FldRange, FldLength, FldMin, FldCharType, 
  1262. X              FldAdjust, FldType, FldExit, MustEnter, 
  1263. X              ErrRow, MsgRow, PromptMsg, HelpFile, HelpTag)
  1264. X
  1265. XWINDOW        *win;
  1266. Xint           row, col, FldAttrbute, FldLength, FldMin, 
  1267. X              FldExit, MustEnter, ErrRow, MsgRow;
  1268. XFldUnPointer  Fld;
  1269. Xchar          *FldMask, *FldRange, FldCharType, FldAdjust, 
  1270. X              FldType, *PromptMsg, HelpFile[], HelpTag[];
  1271. X.fi
  1272. X.SH DESCRIPTION
  1273. XGets terminal input using curses(3X). 
  1274. XGetInput uses a field by field approach.  All
  1275. Xedits and processing are performed for that field as the user
  1276. Xmoves from field to field.  It is not a fill form methodology where
  1277. Xall edits and processing are performed after the user has inputed
  1278. Xa number of fields in a form.
  1279. X
  1280. X.SH GETTING STARTED
  1281. XYou need to include GetInput.h in your program.
  1282. X
  1283. XCurses tty modes should be - cbreak(), noecho(), nonl() and
  1284. Xkeypad () if you want to use arrow keys and the like.
  1285. X
  1286. XYou should trap and ignore SIGALRM (see BUGS).
  1287. X
  1288. X.SS Defining Keyboard Keys
  1289. XGetInput uses a number of keyboard keys to tell it what to do.
  1290. XA default value to the various keys is automatically assigned when you use
  1291. Xthis library.  Those default values may be changed by declaring the variable
  1292. Xas extern in your program and assigning a new value.
  1293. XIn addition to the default variable values, if the terminal
  1294. Xhas an associated curses key defined (see curses.h) that key may also be used.
  1295. XFor example, ^b (KeyBeg) is the default value to place cursor at beginning 
  1296. Xof a field but if there is a key defined for KEY_BEG, in curses, then that
  1297. Xkey may also be used.  If the value of KeyBeg and KEY_BEG are different, 
  1298. XGetInput will return the value of KEY_BEG not KeyBeg regardless of which 
  1299. Xone is pressed.
  1300. XNot all keys may have an associated curses key.
  1301. XThe "^" indicates press and hold the control key.  A negative one disables
  1302. Xthe key, although the associated curses key is still active.
  1303. X.br
  1304. XBelow is listed the InitGetI() function with the default value and the
  1305. Xassociated curses key.
  1306. X.nf
  1307. X
  1308. X/*
  1309. X**  InitGetI()
  1310. X**    Used in GetInput(3) and assign some default values.
  1311. X*/
  1312. X
  1313. X#include    <curses.h>
  1314. X#include    "GetInput.h"
  1315. X
  1316. X                /* ACCEPT INPUT KEYS */
  1317. X                /* These are the only keys that will return the data inputted into your variable. */
  1318. Xint    KeyReturn = '\\r';        /* ^m  KEY_RETURN */
  1319. Xint    KeyDown = 10;        /* ^j  KEY_DOWN */
  1320. Xint    KeyUp = 11;        /* ^k  KEY_UP */
  1321. Xint    KeyTab = '\\t';        /* ^i  KEY_TAB */
  1322. Xint    KeyBTab = -1;        /*     KEY_BTAB */
  1323. Xint    KeyAccept = 1;        /* ^a  KEY_ACCEPT - Typically this is the key the user presses
  1324. X                             to signify he/she is finished with this screen. */
  1325. X
  1326. X                /* FIELD EDITING KEYS */
  1327. Xint    KeyBeg = 2;        /* ^b  KEY_BEG - Place cursor at beginning of field */
  1328. Xint    KeyEnd = 5;        /* ^e  KEY_END - Place cursor at end of input in field */
  1329. Xint      KeyRight = 12;        /* ^l  KEY_RIGHT - Forward space in field */
  1330. Xint      KeyLeft = 8;        /* ^h  KEY_LEFT - Backspace in field (non-destructive) */
  1331. Xint      KeyBackspace = '\\b';    /* \\b  KEY_BACKSPACE - Same as KEY_LEFT */
  1332. Xint      KeyEOL = 4;        /* ^d  KEY_EOL - Delete from cursor to end of field */
  1333. Xint      KeyDL = 3;        /* ^c  KEY_DL - Clear field and home cursor */
  1334. Xint      KeyDC = 24;        /* ^x  KEY_DC - Delete a character */
  1335. Xint      KeyIC = 20;        /* ^t  KEY_IC - Toggle between type-over and insert mode */
  1336. X
  1337. X                /* OTHER KEYS */
  1338. Xint      KeyRedraw = 18;        /* ^r  KEY_REFRESH - Redraw screen */
  1339. Xint      KeySave = 6;        /* ^f  KEY_SAVE - Save screen to a file */
  1340. Xint      KeyPrint = 16;        /* ^p  KEY_PRINT - Print screen to lp */
  1341. Xint      KeyCancel = 27;        /* esc KEY_CANCEL - Cancel pop-up menu selection */
  1342. Xint      KeyHelp = '?';        /*     KEY_HELP - Display help screen */
  1343. X                /*        If the user needs to input a "?" you will have to change this. */
  1344. Xint      KeyTOC = 20;        /* ^t  KEY_TOC  - When in help display Table of Contents */
  1345. X
  1346. Xvoid
  1347. XInitGetI()
  1348. X{
  1349. X    /*
  1350. X    **  This function sets values for keys used in GetInput.  The default
  1351. X    **  values above may be changed by specifying a new value in a
  1352. X    **  file called ".menuinit".  See menu(1) for more info.
  1353. X    */
  1354. X}
  1355. X.fi
  1356. X
  1357. X.SH ARGUMENT DESCRIPTION
  1358. X.TP 6
  1359. X*win
  1360. XA pointer to a curses window that this routine will operate under.
  1361. X.TP 
  1362. Xrow
  1363. XThe row to position cursor on.
  1364. X.TP 
  1365. Xcol
  1366. XThe starting column for field.
  1367. X.TP
  1368. X&Fld        
  1369. XA pointer to a union variable where you have loaded the
  1370. Xaddress of your memory variable to accept the input data.  Upon
  1371. Xentry to GetInput the value in your memory variable will be
  1372. Xdisplayed as the default value.  The type of union you select must be compatible
  1373. Xwith the \fIFldType\fP you've specified.
  1374. X
  1375. X.nf
  1376. XFor example:
  1377. X    union FldUnion    Fld;
  1378. X    double        myvar;
  1379. X
  1380. X    Fld.doubleVal = &myvar;
  1381. X    GetInput (......);
  1382. X
  1383. X    /*
  1384. X    **  After returning from GetInput() what the user typed in will
  1385. X    **  be in \fImyvar\fP;
  1386. X    */
  1387. X
  1388. X
  1389. X
  1390. X/*
  1391. X**     Structure of Union
  1392. X*/
  1393. Xtypedef union FldUnion
  1394. X{
  1395. X    long    *longVal;
  1396. X    double  *doubleVal;
  1397. X    float   *floatVal;
  1398. X    int     *intVal;
  1399. X    short   *shortVal;
  1400. X    char    *strVal;
  1401. X} *FldUnPointer;
  1402. X.fi
  1403. X.TP
  1404. XFldAttrbute    
  1405. XCurses attribute you want your input field to be.  For
  1406. Xexample A_REVERSE.  Refer to curses(3X) for further
  1407. Xinformation on allowable terminal attributes.
  1408. X.br
  1409. XA_SAME  is a special attribute that tells GetInput to use
  1410. Xthe same attributes that is already on the screen in the
  1411. Xfirst column of the field.
  1412. X
  1413. X. \ **********************************
  1414. X.TP
  1415. XFldMask
  1416. XA char pointer to a mask for the field.  This permits the user to mix 
  1417. Xalpha with numeric while letting GetInput do the edit checking.  You can also
  1418. Xuse this to format a field.
  1419. X
  1420. XThe keyword \fBNOMASK\fP may be placed here if no mask is required.
  1421. X
  1422. XValid masks for a field depend upon the type of field
  1423. Xyou specify, see \fIFldCharType\fP.
  1424. X
  1425. XThe \fIFldLength\fP should not include character positions where no input
  1426. Xis allowed in the mask (format characters), because format characters
  1427. Xare not returned into \fIFld\fP.  For example, \fIFldCharType = DATE,
  1428. XFldMask = "MM/DD/YY"\fP.  The "/" is a format character.  The cursor
  1429. Xwill skip over those positions in the field.  Only the characters typed in
  1430. Xthe MM DD YY positions will be in your memory variable \fIFld\fP.
  1431. XThe FldLength would be six for this case.
  1432. X
  1433. XBecause the mask is so closely tied to the \fIFldCharType\fP, a complete
  1434. Xdescription of what mask characters are valid with what field types is 
  1435. Xdescribed under
  1436. X\fIFldCharType\fP.  Any character in the mask that is not listed as a valid
  1437. Xmask character for that field type becomes a format character.
  1438. X. \ **********************************
  1439. X.TP
  1440. XFldRange
  1441. XA char pointer to a set of valid ranges permitted for this field. 
  1442. XRanges may be specified as comma separated values ("ONE,TWO,THREE") 
  1443. Xor as a inclusive range ("1-5"), or a combination of both ("1-5,M,E").
  1444. XRange values must be compatible with the \fIFldCharType\fP and \fIFldType\fP 
  1445. Xthat you 
  1446. Xhave selected.
  1447. X.br
  1448. XSome examples:
  1449. X.nf
  1450. X    "1-10"
  1451. X    "5,10,15,16"
  1452. X    "1-10,20,M,E,32-40"
  1453. X    "CA,TX,ID"
  1454. X.fi
  1455. X
  1456. XThe keyword \fBNORANGE\fP may be used if no range checking is to be 
  1457. Xperformed for this field.
  1458. X. \ **********************************
  1459. X.TP
  1460. XFldLength
  1461. XMaximum length of this field.  For field types (FldCharTypes) SET and MENU 
  1462. Xthe field length is automatically set to the longest set value in the FldRange.
  1463. X. \ **********************************
  1464. X.TP
  1465. XFldMin
  1466. XIf \fIMUSTENTER\fP is selected in \fIFldExit\fP then this is the minimum
  1467. Xrequired input.  Otherwise, it is the minimum required input only if they try 
  1468. Xto input something.
  1469. X. \ **********************************
  1470. X.TP
  1471. XFldCharType
  1472. XThis argument defines edit checks to be performed on the
  1473. Xinput characters as they are being typed in.  If no mask is provided then
  1474. Xthe field type itself determines the edit checks to be performed on all
  1475. Xcharacters in the field.
  1476. X.RS 6
  1477. X.TP 11
  1478. XALPHANUM
  1479. XAny alpha/numeric character is allowed.
  1480. X.br
  1481. XValid mask characters:
  1482. X.nf
  1483. X    space    alpha/numeric
  1484. X    A    alpha
  1485. X    9    numeric
  1486. X    U    upper alpha
  1487. X    V    upper alpha/numeric
  1488. X    H    ???
  1489. X.fi
  1490. X.TP
  1491. XALPHA
  1492. XAlpha only.
  1493. X.br
  1494. XValid mask characters:
  1495. X.nf
  1496. X    A    alpha
  1497. X.fi
  1498. X.TP
  1499. XNUMERIC
  1500. XNumeric only.
  1501. X.br
  1502. XValid mask characters:
  1503. X.nf
  1504. X    9    numeric
  1505. X.fi
  1506. X.TP
  1507. XUPPER
  1508. XConvert to upper case.  Only alpha permitted.
  1509. X.br
  1510. XValid mask characters:
  1511. X.nf
  1512. X    U    upper alpha
  1513. X.fi
  1514. X.TP
  1515. XUPPER_AN
  1516. XAlpha and numeric permitted.  Convert alpha characters to upper-case.
  1517. X.br
  1518. XValid mask characters:
  1519. X.nf
  1520. X    V    upper alpha/numeric
  1521. X.fi
  1522. X.TP
  1523. XHEX
  1524. XOnly hex characters permitted.
  1525. X.br
  1526. XValid mask characters:
  1527. X.nf
  1528. X    H    ???
  1529. X    space    ???
  1530. X.fi
  1531. X.TP
  1532. XSTATE
  1533. XValid two character Post Office abbreviations for the fifty states.
  1534. XA edit check is done for a valid state.
  1535. X.br
  1536. XValid mask characters:
  1537. X.nf
  1538. X    SS    two character state
  1539. X    S    ???
  1540. X    space    ???
  1541. X.fi
  1542. X.TP
  1543. XZIP
  1544. XPost Office zip code.
  1545. X.br
  1546. XValid mask characters:
  1547. X.nf
  1548. X    99999-9999    ???
  1549. X.fi
  1550. X.TP
  1551. XDATE
  1552. XA valid date.
  1553. X.br
  1554. XValid mask characters:
  1555. X.nf
  1556. X    MM    month  (01-12)
  1557. X    DD    day  (01-31)
  1558. X    YY    year  (00-99)
  1559. X    YYYY    full year with century
  1560. X.fi
  1561. XThe mask must contain at least MM and DD.  If no mask is specified for the
  1562. Xfield a default mask of "MMDDYY" is used.
  1563. X.br
  1564. XSome examples:
  1565. X.nf
  1566. X    MMDDYY
  1567. X    MM/DD/YY
  1568. X    YY-MM-DD
  1569. X    MM  DD  YYYY
  1570. X.fi
  1571. X
  1572. XThe \fIFldRange\fP argument may contain any of the following keywords
  1573. X(case insensitive)
  1574. Xand the appropriate edit will be performed (see \fIfield_range\fP for more
  1575. Xinfo).
  1576. X.nf
  1577. X    sun,mon,tue,wed,thr,fri,sat    - validate date entered against day of week
  1578. X    No_Holidays        - no holidays allowed.  
  1579. SHAR_EOF
  1580. echo "End of part 11"
  1581. echo "File utilities.d/libgeti.d/GetInput.3X is continued in part 12"
  1582. echo "12" > s2_seq_.tmp
  1583. exit 0
  1584.