home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2414 < 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 9 of 14
  4. Message-ID: <443@pcbox.UUCP>
  5. Date: 26 Dec 90 20:12:07 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 9 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file utilities.d/libgeti.d/GetInput.c continued
  12. #
  13. CurArch=9
  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/GetInput.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/GetInput.c
  25. X                             break;
  26. X
  27. X               case KEY_EOL:
  28. X                /*
  29. X                **  Clear from cursor to end of field.
  30. X                */
  31. X                            if (col == colBegInput) 
  32. X                {
  33. X                    initFld = FALSE ;
  34. X                            bytesKeyed = 0;
  35. X                }
  36. X                            colSave = col ;
  37. X                            fldWrk = fldStr ;
  38. X                            col = colStart ;
  39. X                            while (col < colSave) 
  40. X                {
  41. X                                  if (*(charKeyed + col - colStart)=='Y')
  42. X                                        *fldWrk++ = mvwinch(win, row, 
  43. X                                 col) & A_CHARTEXT ;
  44. X                                  col++;
  45. X                        }
  46. X                        *fldWrk = '\0' ;
  47. X
  48. X                        col = colSave ;
  49. X                        while (col < colEnd) 
  50. X                        {
  51. X                                  if (*(charKeyed + col-colStart) != 'M')
  52. X                                        *(charKeyed + col-colStart)='N';
  53. X                                  col++;
  54. X                        }
  55. X                        ReDispFld(win, rowStart, colStart, fldAttrib, 
  56. X                    fldMask, fldRange, fldLength, 
  57. X                    fldCharType, fldType,
  58. X                    fldStr, colEnd, charKeyed, 0, origAttr);
  59. X
  60. X                        wmove(win, rowStart, colSave) ;
  61. X                        break;
  62. X
  63. X               case KEY_DL:
  64. X                /*
  65. X                **  Clear field and home cursor.
  66. X                */
  67. X                            if (col == colBegInput) 
  68. X                    initFld = FALSE ;
  69. X                            fldWrk = fldStr ;
  70. X                        *fldWrk = '\0' ;
  71. X
  72. X                            col = colStart ;
  73. X                /* check for a mask character */
  74. X                        while (col < colEnd) 
  75. X                        {
  76. X                                  if (*(charKeyed + col-colStart) != 'M')
  77. X                                        *(charKeyed + col-colStart)='N';
  78. X                                  col++;
  79. X                        }
  80. X                /* redisplay field */
  81. X                        ReDispFld(win, rowStart, colStart, fldAttrib, 
  82. X                    fldMask, fldRange, fldLength, 
  83. X                    fldCharType, fldType,
  84. X                    fldStr, colEnd, charKeyed, 0, origAttr);
  85. X
  86. X                            col = colBegInput;
  87. X                        wmove(win, rowStart, col) ;
  88. X                        bytesKeyed = 0;
  89. X                        break;
  90. X
  91. X               case KEY_DC:
  92. X                /*
  93. X                **  pjc  11/88
  94. X                **  Delete character at cursor.
  95. X                */
  96. X
  97. X                /* 
  98. X                ** no can do for SET, MENU or
  99. X                ** cursor past end of input or
  100. X                ** cursor past end of field 
  101. X                */
  102. X                   if (fldCharType == SET || fldCharType == MENU ||
  103. X                                  *(charKeyed+col-colStart) == 'N'  ||
  104. X                    col >= colEnd)
  105. X                    break;
  106. X                colSave = col;        /* cursor location */
  107. X
  108. X                /* get field content & delete char */
  109. X                col = colStart;
  110. X                fldWrk = fldStr;
  111. X                while (col < colEnd)
  112. X                {
  113. X                    if (col == colSave)
  114. X                        col++;      /* delete char */
  115. X                                  if (*(charKeyed+col-colStart) == 'Y')
  116. X                                        *fldWrk++ = mvwinch(win, row, 
  117. X                                 col) & A_CHARTEXT ;
  118. X                                  col++;
  119. X                }
  120. X                *fldWrk = '\0';
  121. X
  122. X                /* validate new field against the mask */
  123. X                if (fldMask != NOMASK)
  124. X                {
  125. X                    junk = 0;
  126. X                    /* fldWrk - fldWrk, col - charKeyed */
  127. X                    for (fldWrk = fldStr, col = colStart; 
  128. X                         col < colEnd && *fldWrk != '\0';
  129. X                         col++)
  130. X                    {
  131. X                        /* only check shifted chars */
  132. X                        if (col < colSave  ||
  133. X                            *(charKeyed+col-colStart) == 'M')
  134. X                        {
  135. X                            if (*(charKeyed+col-colStart) == 'Y')
  136. X                                fldWrk++;
  137. X                            continue;
  138. X                        }
  139. X
  140. X                               junk = checkmask (col, colStart,
  141. X                               fldMask, fldCharType,
  142. X                               fldType, *fldWrk);
  143. X
  144. X                        if (junk == -1)
  145. X                            break;
  146. X                        *fldWrk++ = junk;
  147. X                        junk = 0;
  148. X                    } /* end for */
  149. X                    if (junk == -1)
  150. X                    {
  151. X                        CLEARROW (fldErrRow);
  152. X                        wattrOn (stdscr, 
  153. X                             A_REVERSE|A_BOLD);
  154. X                                   mvwaddstr(stdscr,
  155. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  156. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  157. X                    "Unable to delete character due to edits.");
  158. X                        wattrOff (stdscr);
  159. X                        BELL;
  160. X                        col = colSave;
  161. X                        wmove (win, rowStart, colSave);
  162. X                        break;
  163. X                    }
  164. X                }
  165. X
  166. X                /* set last Y in charKeyd to N */
  167. X                col = colEnd;
  168. X                while (col >= colStart)
  169. X                {
  170. X                    if (*(charKeyed+col-colStart) == 'Y')
  171. X                    {
  172. X                        *(charKeyed+col-colStart) = 'N';
  173. X                        break;
  174. X                    }
  175. X                    col--;
  176. X                }
  177. X
  178. X
  179. X                        ReDispFld(win, rowStart, colStart, fldAttrib, 
  180. X                    fldMask, fldRange, fldLength, 
  181. X                    fldCharType, fldType,
  182. X                    fldStr, colEnd, charKeyed, 0, origAttr);
  183. X
  184. X                col = colSave;
  185. X                wmove (win, rowStart, colSave);
  186. X                break;
  187. X
  188. X               case KEY_IC:
  189. X                /*
  190. X                **  Toggle between typeover/insert mode.
  191. X                */
  192. X                insertmode = (insertmode) ? FALSE : TRUE;
  193. X                break;
  194. X
  195. X               case KEY_SAVE:
  196. X                           ScrnFile(win, LINES, COLS) ;
  197. X                           clearok(win, TRUE) ;
  198. X                           wmove(win, row, col) ;
  199. X                           break;
  200. X
  201. X               case KEY_PRINT:
  202. X                              ScrnPrnt(win, LINES, COLS, fldErrRow) ;
  203. X                              clearok(win, TRUE);
  204. X                              wmove(win, row, col) ;
  205. X                              continue ;
  206. X
  207. X                    case KEY_BACKSPACE:
  208. X                        if (col > colStart) 
  209. X                    {
  210. X                               wattrset(win, fldAttrib) ;
  211. X                               mvwaddch(win, rowStart, --col, ' ') ;
  212. X                               wattrset(win, 0) ;
  213. X                               wmove(win, rowStart, col) ;
  214. X                        } 
  215. X                    else
  216. X                               BELL;
  217. X                        break ;
  218. X
  219. X                    case KEY_RETURN:
  220. X                    case KEY_ENTER:
  221. X               case KEY_DOWN:
  222. X               case KEY_UP:
  223. X               case KEY_TAB:
  224. X               case KEY_BTAB:
  225. X               case KEY_ACCEPT:
  226. X                /*
  227. X                **    bug fix - 9/26/86 pjc
  228. X                **    if (col == colend) byteskeyed was not 
  229. X                **    being counted.
  230. X                **    Determine number of bytes keyed by user.
  231. X                */
  232. X                    bytesKeyed = 0;
  233. X                    for (i = 0; i < strlen (charKeyed); i++)
  234. X                           if (charKeyed[i] == 'Y')
  235. X                              bytesKeyed++;
  236. X
  237. X                        if (fldCharType == SET  ||  fldCharType == MENU)
  238. X                    {
  239. X                               col = colEnd ;
  240. X                               wmove(win, rowStart, col) ;
  241. X                               notFinished = FALSE ;
  242. X                               break ;
  243. X                        } 
  244. X
  245. X                       if (col == colEnd) 
  246. X                       {
  247. X                              notFinished = FALSE;
  248. X                              break;
  249. X                           } 
  250. X
  251. X                      if (initFld) 
  252. X                  {
  253. X                                 col = colEnd - 1 ;
  254. X                                 while (*(charKeyed+col-colStart) != 'Y')
  255. X                                    col--;
  256. X                                 wmove(win, rowStart, col) ;
  257. X                          }
  258. X
  259. X                        colMove = colStart ;
  260. X                        bytesKeyed = 0 ;
  261. X                        while (colMove < colEnd) 
  262. X                        {
  263. X                               if (*(charKeyed+colMove-colStart)=='Y')
  264. X                           {
  265. X                                  col = colMove ;
  266. X                                  bytesKeyed++;
  267. X                               }
  268. X                               colMove++;
  269. X                        }
  270. X                        while (*(charKeyed + ++col - colStart) == 'M')
  271. X                               ;
  272. X                        wmove(win, rowStart, col) ;
  273. X
  274. X                        if (bytesKeyed == 0 && mustEnter) 
  275. X                        {
  276. X                               BELL;
  277. X                    CLEARROW (fldErrRow);
  278. X                    wattrOn (stdscr, A_REVERSE|A_BOLD);
  279. X                              mvwaddstr(stdscr, 
  280. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  281. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  282. X                        "This is a must enter field.") ;
  283. X                    wattrOff (stdscr);
  284. X                               wmove(win, rowStart, colStart) ;
  285. X                               break ;
  286. X                        } 
  287. X
  288. X                       if (fldMin > 0  && bytesKeyed > 0 && 
  289. X                    bytesKeyed < fldMin)
  290. X                       {
  291. X        
  292. X                               BELL;
  293. X                    CLEARROW (fldErrRow);
  294. X                    wattrOn (stdscr, A_REVERSE|A_BOLD);
  295. X                               mvwprintw(stdscr, fldErrRow, 1,
  296. X                             "The minimum length for this field is: %d keyed %d",
  297. X                                      fldMin, bytesKeyed) ;
  298. X                    wattrOff (stdscr);
  299. X                               wmove(win, rowStart, col) ;
  300. X                               break ;
  301. X                       }
  302. X
  303. X                        if (fldAdjust != NOFILL)
  304. X                               AdjField(win, rowStart, colStart, 
  305. X                        fldAttrib, fldAdjust, colEnd, 
  306. X                        charKeyed) ;
  307. X
  308. X                        notFinished = FALSE ;
  309. X                        break ;
  310. X
  311. X                    default:
  312. X                /* check for control character */
  313. X                        if (ch < 32  ||  ch > 127) 
  314. X                        {
  315. X                               int   ch1 ;
  316. X
  317. X
  318. X                               notFinished = FALSE ;
  319. X                               wmove(win, rowStart, colEnd) ;
  320. X                               controlKey = ch ;
  321. X                    break;
  322. X                        } 
  323. X
  324. X                       if (fldCharType == SET) 
  325. X                       {
  326. X                      if (fldType == CHAR)
  327. X                      {
  328. X                             /*  pjc - 7/87
  329. X                             **  match ch to the first char 
  330. X                        **  in set values
  331. X                             */
  332. X                             int    rc;  /* return code */
  333. X
  334. X                             Fld->strVal[0] = ch;
  335. X                             Fld->strVal[1] = '\0';
  336. X                                   rc = FindSet(Fld, fldRange, 
  337. X                            fldLength, fldType);
  338. X                             setNumb = rc == -1 ? ++setNumb : rc;
  339. X                      }
  340. X                      else
  341. X                             setNumb++;
  342. X
  343. X                              ShowSet(win, rowStart, colStart, 
  344. X                        fldAttrib, fldRange, fldLength, 
  345. X                        &setNumb, colEnd, charKeyed, 
  346. X                        origAttr) ;
  347. X                              wmove(win, rowStart, colStart);
  348. X                    break;
  349. X                       }
  350. X
  351. X                if (fldCharType == MENU)
  352. X                {
  353. X                    char    tmpStr[2];
  354. X
  355. X                    tmpStr[0] = ch;
  356. X                    tmpStr[1] = (char)NULL;
  357. X                    junk = popmenu (menuid, tmpStr);
  358. X                    setNumb = junk >= 1 ? junk-1 : setNumb;
  359. X                    strcpy (Fld->strVal, menu[setNumb]);
  360. X                              ShowSet(win, rowStart, colStart, 
  361. X                        fldAttrib, fldRange, fldLength, 
  362. X                        &setNumb, colEnd, charKeyed, 
  363. X                        origAttr) ;
  364. X                              wmove(win, rowStart, colStart);
  365. X                    touchwin (stdscr);
  366. X                    touchwin (win);
  367. X                    if (junk >= 1)
  368. X                                   notFinished = FALSE ;
  369. X                    break;
  370. X                }
  371. X
  372. X                      if (col == colEnd)
  373. X                           BELL;
  374. X                       else
  375. X                           notFinished = ShowChar (win, rowStart, 
  376. X                        colStart, fldAttrib, fldMask, 
  377. X                        fldRange, fldLength, 
  378. X                        fldCharType, fldDispRow, 
  379. X                        fldType, keyStream, fldErrRow,
  380. X                        charKeyed,colEnd, &ch,origAttr);
  381. X                       break ;
  382. X
  383. X            }  /* end switch */
  384. X        } while (notFinished) ;
  385. X
  386. X              if ( controlKey  &&  bytesKeyed == 0)
  387. X              {
  388. X                 ReDispFld(win, rowStart, colStart, -1, fldMask, 
  389. X                fldRange, fldLength, fldCharType, fldType, 
  390. X                fldStr, colEnd, charKeyed, setNumb, 
  391. X                origAttr) ;
  392. X                 break ;
  393. X              } 
  394. X              else 
  395. X        {
  396. X                 if ( IsFldOk(win, rowStart, colStart, Fld, fldMask, 
  397. X                    fldRange, fldLength, fldCharType, fldType, 
  398. X                    mustEnter, fldErrRow, fldDispRow, colEnd, 
  399. X                    fldStr, charKeyed, setNumb, origAttr) )
  400. X            {
  401. X                        break ;
  402. X            }
  403. X                 else         
  404. X             {
  405. X                        notFinished = TRUE ;
  406. X                        continue ;
  407. X                 }
  408. X        }
  409. X
  410. X    }  /* end  while (TRUE) */
  411. X
  412. X       free(fldStr) ;
  413. X       free(charKeyed) ;
  414. X
  415. X       return (ch);
  416. X}
  417. SHAR_EOF
  418. echo "File utilities.d/libgeti.d/GetInput.c is complete"
  419. chmod 0644 utilities.d/libgeti.d/GetInput.c || echo "restore of utilities.d/libgeti.d/GetInput.c fails"
  420. echo "x - extracting utilities.d/libgeti.d/GetSetLen.c (Text)"
  421. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetSetLen.c &&
  422. Xstatic char Sccsid[] = "@(#)GetSetLen.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  423. X
  424. X/*
  425. X**  GetSetLen()
  426. X**    Determines the length of the longest element in the set (range).
  427. X**    ex. "HI,LOW,MEDIUM" returns (6) as the longest length.
  428. X**    This information is used to determine how much memory I need to allocate
  429. X**    to hold the element.  Does not include a null terminator.
  430. X**
  431. X**  RETURNS:
  432. X**        length of the longest element in set.
  433. X*/
  434. X
  435. X#include    "GetInput.h"
  436. X
  437. XGetSetLen(fldRange)
  438. X    char        *fldRange ;    /* range of valid values for output */
  439. X{
  440. X    int    len,
  441. X        fldLength ;
  442. X    char    *fldWrk ;
  443. X
  444. X
  445. X    fldLength = 0 ;
  446. X
  447. X    fldWrk = fldRange ;
  448. X
  449. X    while (*fldWrk != '\0') {
  450. X
  451. X        len = 0 ;
  452. X
  453. X        while (*fldWrk != ','  &&  *fldWrk != '\0') {
  454. X            len++ ;        /* length of this element */
  455. X            fldWrk++ ;    /* fldRange without this element */
  456. X        }
  457. X
  458. X        if (len > fldLength)    /* is this element longer ? */
  459. X            fldLength = len ;
  460. X
  461. X        /* set pointer to next element in set */
  462. X        while (*fldWrk == ','  ||   *fldWrk == ' ')
  463. X            fldWrk++ ;
  464. X    }
  465. X
  466. X    return (fldLength) ;
  467. X}
  468. SHAR_EOF
  469. chmod 0444 utilities.d/libgeti.d/GetSetLen.c || echo "restore of utilities.d/libgeti.d/GetSetLen.c fails"
  470. echo "x - extracting utilities.d/libgeti.d/InitGetI.c (Text)"
  471. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/InitGetI.c &&
  472. X#ifndef LINT
  473. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  474. X#endif
  475. X
  476. X/*
  477. X**  InitGetI()
  478. X*/
  479. X
  480. X#include    <curses.h>
  481. X#include    "GetInput.h"
  482. X
  483. X#define    MENUINIT    ".menuinit"        /* menu initialization file */
  484. X#define    BUFSIZE        512
  485. X
  486. Xint    KeyReturn = '\r';
  487. Xint    KeyDown = 10;        /* ^j */
  488. Xint    KeyUp = 11;        /* ^k */
  489. Xint    KeyTab = '\t';
  490. Xint    KeyBTab = -1;
  491. Xint    KeyAccept = 1;        /* ^a */
  492. X
  493. Xint    KeyBeg = 2;
  494. Xint    KeyEnd = 5;
  495. Xint      KeyRight = 12;        /* ^l */
  496. Xint      KeyLeft = 8;        /* ^h */
  497. Xint      KeyBackspace = '\b';    /* \b */
  498. Xint      KeyEOL = 4;        /* ^d */
  499. Xint      KeyDL = 3;        /* ^c */
  500. Xint      KeyDC = 24;        /* ^x */
  501. Xint      KeyIC = 20;        /* ^t */
  502. X
  503. Xint      KeyHelp = '?';
  504. Xint    KeyTOC = 20;        /* ^t */
  505. Xint      KeyRedraw = 18;        /* ^r */
  506. Xint      KeySave = 6;        /* ^f */
  507. Xint      KeyPrint = 16;        /* ^p */
  508. Xint      KeyCancel = 27;        /* esc */
  509. X
  510. X
  511. Xvoid
  512. XInitGetI()
  513. X{
  514. X    FILE    *fopen(), *menuinit;
  515. X    char    *getenv();
  516. X    char    *findfile();
  517. X    char    *strchr();
  518. X    char    *ws;
  519. X    char    filename[100], line[BUFSIZE];
  520. X    char    *s1;
  521. X
  522. X
  523. X    char    *terminal;
  524. X
  525. X    /*
  526. X    **  Parse the .menuinit file
  527. X    **  First look in current directory then $HOME then in $MENUDIR
  528. X    */
  529. X    strcpy (filename, findfile (MENUINIT, ".", 
  530. X        (char *)getenv("HOME"), (char *)getenv("MENUDIR"), ""));
  531. X    if ((menuinit = fopen (filename, "r")) == NULL)
  532. X    {
  533. X        /* no file found - use the defaults */
  534. X        return;
  535. X    }
  536. X
  537. X    /* set terminal keys */
  538. X    while (fgets (line, BUFSIZE, menuinit) != (char *)NULL)
  539. X    {
  540. X        /*
  541. X        if (strncmp ("HOTKEYS", line, 7) == 0)
  542. X            HotKeys = 1;
  543. X        */
  544. X            
  545. X        /*
  546. X        **  The following keywords require a = sign
  547. X        */
  548. X
  549. X        if ((s1 = strchr (line, '=')) == (char *)NULL)
  550. X            continue;
  551. X
  552. X        s1++;                    /* get past the = */
  553. X
  554. X        /* Mover Keys */
  555. X        if (strncmp ("KEY_RETURN", line, 10) == 0)
  556. X            sscanf (s1, "%d", &KeyReturn);
  557. X        else if (strncmp ("KEY_DOWN", line, 8) == 0)
  558. X            sscanf (s1, "%d", &KeyDown);
  559. X        else if (strncmp ("KEY_UP", line, 6) == 0)
  560. X            sscanf (s1, "%d", &KeyUp);
  561. X        else if (strncmp ("KEY_TAB", line, 7) == 0)
  562. X            sscanf (s1, "%d", &KeyTab);
  563. X        else if (strncmp ("KEY_BTAB", line, 8) == 0)
  564. X            sscanf (s1, "%d", &KeyBTab);
  565. X
  566. X        /* Edit Keys */
  567. X        else if (strncmp ("KEY_BEG", line, 7) == 0)
  568. X            sscanf (s1, "%d", &KeyBeg);
  569. X        else if (strncmp ("KEY_END", line, 7) == 0)
  570. X            sscanf (s1, "%d", &KeyEnd);
  571. X        else if (strncmp ("KEY_RIGHT", line, 9) == 0)
  572. X            sscanf (s1, "%d", &KeyRight);
  573. X        else if (strncmp ("KEY_LEFT", line, 8) == 0)
  574. X            sscanf (s1, "%d", &KeyLeft);
  575. X        else if (strncmp ("KEY_BACKSPACE", line, 13) == 0)
  576. X            sscanf (s1, "%d", &KeyBackspace);
  577. X        else if (strncmp ("KEY_EOL", line, 13) == 0)
  578. X            sscanf (s1, "%d", &KeyEOL);
  579. X        else if (strncmp ("KEY_DL", line, 14) == 0)
  580. X            sscanf (s1, "%d", &KeyDL);
  581. X        else if (strncmp ("KEY_DC", line, 6) == 0)
  582. X            sscanf (s1, "%d", &KeyDC);
  583. X        else if (strncmp ("KEY_IC", line, 6) == 0)
  584. X            sscanf (s1, "%d", &KeyIC);
  585. X
  586. X        /* Other Keys */
  587. X        else if (strncmp ("KEY_HELP", line, 8) == 0)
  588. X            sscanf (s1, "%d", &KeyHelp);
  589. X        else if (strncmp ("KEY_REFRESH", line, 10) == 0)
  590. X            sscanf (s1, "%d", &KeyRedraw);
  591. X        else if (strncmp ("KEY_ACCEPT", line, 10) == 0)
  592. X            sscanf (s1, "%d", &KeyAccept);
  593. X        else if (strncmp ("KEY_CANCEL", line, 10) == 0)
  594. X            sscanf (s1, "%d", &KeyCancel);
  595. X        else if (strncmp ("KEY_SAVE", line, 8) == 0)
  596. X            sscanf (s1, "%d", &KeySave);
  597. X        else if (strncmp ("KEY_PRINT", line, 9) == 0)
  598. X            sscanf (s1, "%d", &KeyPrint);
  599. X        else if (strncmp ("KEY_TOC", line, 7) == 0)
  600. X            sscanf (s1, "%d", &KeyTOC);
  601. X    }
  602. X    fclose (menuinit);
  603. X    return;
  604. X}
  605. SHAR_EOF
  606. chmod 0644 utilities.d/libgeti.d/InitGetI.c || echo "restore of utilities.d/libgeti.d/InitGetI.c fails"
  607. echo "x - extracting utilities.d/libgeti.d/IsDate.c (Text)"
  608. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsDate.c &&
  609. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  610. X#include <stdio.h>
  611. X#include <time.h>
  612. X#include "GetInput.h"
  613. X
  614. XIsDate (str, mask)
  615. X    char    *str ;
  616. X    char    *mask ;
  617. X{
  618. X    int    year, month, day ;
  619. X
  620. X    getmmddyy (str, mask, &month, &day, &year);
  621. X    return (valid_date (year, month, day));
  622. X}
  623. SHAR_EOF
  624. chmod 0644 utilities.d/libgeti.d/IsDate.c || echo "restore of utilities.d/libgeti.d/IsDate.c fails"
  625. echo "x - extracting utilities.d/libgeti.d/IsFldOk.c (Text)"
  626. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsFldOk.c &&
  627. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  628. X
  629. X#include     <curses.h>
  630. X#include     <ctype.h>
  631. X#include     "GetInput.h"
  632. X
  633. X
  634. XIsFldOk (win, row, colStart, Fld, fldMask, fldRange, fldLength, fldCharType, 
  635. X    fldType, mustEnter, fldErrRow, fldDispRow, colEnd, fldStr, charKeyed, 
  636. X    setNumb, origAttr)
  637. X
  638. XWINDOW          *win ;          /* Window                */
  639. Xint           row ;
  640. Xint           colStart ;
  641. XFldUnPointer    Fld ;        /* Pointer to union for field     */
  642. Xchar          *fldMask ;      /* mask for character string      */
  643. Xchar          *fldRange ;     /* range of valid values for output */
  644. Xunsigned     fldLength ;     /* Maximum length of output       */
  645. Xchar          fldCharType ;  /* type of character           */
  646. Xchar          fldType ;   /* type of field         */
  647. Xint           mustEnter ; /* must enter - boolean   */
  648. Xint           fldErrRow ; /* where to display error message   */
  649. Xint           fldDispRow ;   /* where to display help message    */
  650. Xint           colEnd ; /* last character to display      */
  651. Xchar          *fldStr ;   /* field string             */
  652. Xchar          charKeyed[] ;  /* characters in the field keyed    */
  653. Xint           setNumb ;   /* for SET & MENU      */
  654. Xint           origAttr[] ;   /* origianl attributes for this fld */
  655. X{
  656. X    int       colLast, col ;
  657. X    double  atof() ;
  658. X    char      *fldWrk ;
  659. X
  660. X
  661. X    getyx(win, row, col) ;
  662. X    colLast = col - 1 ;
  663. X
  664. X    col = colStart ;
  665. X
  666. X    fldWrk = fldStr ;
  667. X
  668. X    while (col < colEnd)
  669. X    {
  670. X
  671. X        if (charKeyed [col - colStart] == 'Y')
  672. X            *fldWrk++ = mvwinch(win, row, col) & A_CHARTEXT ;
  673. X        col++;
  674. X    }
  675. X
  676. X    *fldWrk = '\0' ;
  677. X
  678. X    switch (fldType)
  679. X    {
  680. X    case CHAR:
  681. X        strcpy (Fld->strVal, fldStr) ;
  682. X        break ;
  683. X
  684. X    case INT:
  685. X        *Fld->intVal = atoi(fldStr) ;
  686. X        break ;
  687. X
  688. X    case SHORT:
  689. X        *Fld->shortVal = atoi(fldStr) ;
  690. X        break ;
  691. X
  692. X    case LONG:
  693. X        *Fld->longVal = atoi(fldStr) ;
  694. X        break ;
  695. X
  696. X    case FLOAT:
  697. X        *Fld->floatVal = atof(fldStr) ;
  698. X        break ;
  699. X
  700. X    case DOUBLE:
  701. X    case MONEY:
  702. X        *Fld->doubleVal = atof(fldStr) ;
  703. X        break ;
  704. X    } /* end switch (fldType) */
  705. X
  706. X    if ((fldStr == NULL || strcmp (fldStr, "") == 0)  &&  !mustEnter)
  707. X    {
  708. X        ReDispFld(win, row, colStart, -1, fldMask, fldRange, fldLength, 
  709. X            fldCharType, fldType, fldStr, colEnd, charKeyed,
  710. X            setNumb, origAttr) ;
  711. X        return(1) ;
  712. X    }
  713. X
  714. X    if (fldCharType == DATE  &&
  715. X        ((mustEnter && !IsDate (fldStr, fldMask)) ||
  716. X        (!mustEnter && strcmp(fldStr, "000000") != 0  &&
  717. X        strcmp(fldStr, "      ") != 0  &&
  718. X        fldStr[0] != '\0' &&
  719. X        !IsDate (fldStr, fldMask))))
  720. X    {
  721. X        BELL;
  722. X        CLEARROW (fldErrRow);
  723. X        wattrOn (stdscr, A_REVERSE|A_BOLD);
  724. X        mvwaddstr (stdscr,
  725. X            ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  726. X            ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  727. X            "Invalid Date") ;
  728. X        wattrOff (stdscr);
  729. X        wmove (win, row, colStart) ;
  730. X        return (0) ;
  731. X    }
  732. X
  733. X    if (fldCharType == TIME  &&
  734. X        ((mustEnter && !IsTime (fldStr, fldMask)) ||
  735. X        (!mustEnter && strcmp(fldStr, "000000") != 0  &&
  736. X        strcmp(fldStr, "      ") != 0  &&
  737. X        fldStr[0] != '\0' &&
  738. X        !IsTime (fldStr, fldMask))))
  739. X    {
  740. X        BELL;
  741. X        CLEARROW (fldErrRow);
  742. X        wattrOn (stdscr, A_REVERSE|A_BOLD);
  743. X        mvwaddstr (stdscr,
  744. X            ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  745. X            ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  746. X            "Invalid Time") ;
  747. X        wattrOff (stdscr);
  748. X        wmove (win, row, colStart) ;
  749. X        return (0) ;
  750. X    }
  751. X
  752. X    if (fldCharType == STATE  &&  !IsState (fldStr))
  753. X    {
  754. X        BELL;
  755. X        CLEARROW (fldErrRow);
  756. X        wattrOn (stdscr, A_REVERSE|A_BOLD);
  757. X        mvwaddstr (stdscr,
  758. X            ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  759. X            ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  760. X            "Invalid State") ;
  761. X        wattrOff (stdscr);
  762. X        wmove (win, row, colStart) ;
  763. X        return (0) ;
  764. X    }
  765. X
  766. X    if (fldCharType == SET   ||  fldCharType == MENU  ||   fldRange == NULL)
  767. X    {
  768. X        ReDispFld(win, row, colStart, -1, fldMask, fldRange, fldLength, 
  769. X            fldCharType, fldType, fldStr, colEnd, charKeyed,
  770. X            setNumb, origAttr) ;
  771. X        return (1) ;
  772. X    }
  773. X
  774. X    if (IsRange(Fld, fldLength, fldType, fldRange, fldCharType, 
  775. X            fldStr, fldMask))
  776. X    {
  777. X        ReDispFld(win, row, colStart, -1, fldMask, fldRange, fldLength, 
  778. X            fldCharType, fldType, fldStr, colEnd, charKeyed,
  779. X            setNumb, origAttr) ;
  780. X        return (1) ;
  781. X    }
  782. X    else 
  783. X    {
  784. X        getyx (win, row, col) ;
  785. X        BELL;
  786. X        CLEARROW (fldErrRow);
  787. X        wattrOn (stdscr, A_REVERSE|A_BOLD);
  788. X        mvwprintw (stdscr,
  789. X            ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  790. X            ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  791. X            "Valid Ranges are: %s", fldRange) ;
  792. X        wattrOff (stdscr);
  793. X        wmove (win, row, colLast) ;
  794. X
  795. X    }
  796. X
  797. X    return(0) ;
  798. X
  799. X}
  800. SHAR_EOF
  801. chmod 0644 utilities.d/libgeti.d/IsFldOk.c || echo "restore of utilities.d/libgeti.d/IsFldOk.c fails"
  802. echo "x - extracting utilities.d/libgeti.d/IsMask.c (Text)"
  803. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsMask.c &&
  804. Xstatic char Sccsid[] = "@(#)IsMask.c    1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
  805. X
  806. X/*
  807. X**  IsMask ()
  808. X**    Determines whether a given character is a mask format character based
  809. X**    upon the field type.
  810. X**  RETURNS:
  811. X**    TRUE    character is a mask format character
  812. X**    FALSE    this character allows data input
  813. X*/
  814. X
  815. X#include    "GetInput.h"
  816. X
  817. XIsMask (fldCharType, maskChar)
  818. X    char    fldCharType ;
  819. X    char    maskChar ;
  820. X{
  821. X
  822. X    if ( fldCharType  == maskChar)
  823. X        return (0) ;
  824. X    else     if (fldCharType  == ALPHANUM  &&
  825. X           (maskChar == ALPHANUM  || maskChar == ALPHA  ||
  826. X            maskChar == NUMERIC  || maskChar == UPPER  ||
  827. X            maskChar == UPPER_AN  || maskChar == HEX) )
  828. X            return (0) ;
  829. X    else     if (fldCharType  == DATE  &&
  830. X           (maskChar == 'D' || maskChar == 'M' || maskChar == 'Y'))
  831. X            return (0) ;
  832. X    else     if (fldCharType  == TIME  &&
  833. X           (maskChar == 'I' || maskChar == 'H' || maskChar == 'M'||
  834. X            maskChar == 'S' || maskChar == 'T'))
  835. X            return (0) ;
  836. X    else
  837. X        return (1) ;
  838. X}
  839. X
  840. X
  841. SHAR_EOF
  842. chmod 0444 utilities.d/libgeti.d/IsMask.c || echo "restore of utilities.d/libgeti.d/IsMask.c fails"
  843. echo "x - extracting utilities.d/libgeti.d/IsRange.c (Text)"
  844. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsRange.c &&
  845. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  846. X
  847. X#include     <curses.h>
  848. X#include     <ctype.h>
  849. X#include     <string.h>
  850. X#include    <time.h>
  851. X#include     "GetInput.h"
  852. X
  853. X#ifndef TRUE
  854. X# define TRUE    1
  855. X# define FALSE     0
  856. X#endif
  857. X
  858. X#define FROM     0
  859. X#define TO       1
  860. X#define    BUFSIZE    512
  861. X
  862. XIsRange (Fld, fldLength, fldType, fldRange, fldCharType, fldStr, fldMask)
  863. X    FldUnPointer      Fld ;
  864. X    unsigned int    fldLength ;
  865. X    char          fldType ;
  866. X    char          *fldRange ;
  867. X    char        fldCharType;
  868. X    char        *fldStr;        /* input */
  869. X    char        *fldMask;        /* the mask */
  870. X{
  871. X    FILE    *fopen(), *fp;
  872. X    char    *upper();
  873. X    char    *fgets();
  874. X    char    *substr();
  875. X    char    *wrk, *wrkAlloc ;
  876. X    char      *malloc();
  877. X    int       testInt, t1, t2, INTFLAG;
  878. X    long      testLong ;
  879. X    float     testFloat ;
  880. X    double     testDouble ;
  881. X    int       fromTo ;        /* indicates FROM-TO part in range */
  882. X    int       fromOk ;        /* passed FROM test */
  883. X    int       success ;
  884. X    int       retCode ;
  885. X    double     atof() ;
  886. X    int    month, day, year;    /* date inputted - broken apart */
  887. X    char    tmpstr[BUFSIZE];
  888. X    struct tm    *ltime, *localtime();
  889. X    long    secs, tdate, idate;
  890. X
  891. X
  892. X
  893. X    wrkAlloc   = malloc (fldLength + 10);
  894. X
  895. X    fromTo = FROM ;
  896. X    success = fromOk = FALSE ;
  897. X
  898. X    /* loop through each range value */
  899. X    while (TRUE)
  900. X    {
  901. X        wrk = wrkAlloc ;
  902. X
  903. X        /*
  904. X        **     Get a range value to test on.
  905. X        */
  906. X        do
  907. X        {
  908. X            *wrk++ = *fldRange++;
  909. X        } while (*fldRange != '\0' && *fldRange != ',' && 
  910. X             *fldRange != '-') ;
  911. X
  912. X        *wrk = '\0' ;
  913. X        wrk = wrkAlloc ;
  914. X
  915. X
  916. X        /* some special range checking based on CharType */
  917. X        switch (fldCharType)
  918. X        {
  919. X           case DATE:
  920. X            /* get month, day, year from what was inputted */
  921. X            getmmddyy (fldStr, fldMask, &month, &day, &year);
  922. X
  923. X            /* handle day of week range ? */
  924. X            testInt = -1;        /* range dayofweek */
  925. X            if (strcmp (upper (wrk), "SUN") == 0)
  926. X                testInt = 0;
  927. X            else if (strcmp (upper (wrk), "MON") == 0)
  928. X                testInt = 1;
  929. X            else if (strcmp (upper (wrk), "TUE") == 0)
  930. X                testInt = 2;
  931. X            else if (strcmp (upper (wrk), "WED") == 0)
  932. X                testInt = 3;
  933. X            else if (strcmp (upper (wrk), "THR") == 0)
  934. X                testInt = 4;
  935. X            else if (strcmp (upper (wrk), "FRI") == 0)
  936. X                testInt = 5;
  937. X            else if (strcmp (upper (wrk), "SAT") == 0)
  938. X                testInt = 6;
  939. X            if (testInt >= 0)
  940. X            {
  941. X                /* day of week range check */
  942. X
  943. X                /* get inputted day of week */
  944. X                retCode = week_day (year, month, day);
  945. X                
  946. X                /*
  947. X                **  if dayofweek inputted == range dayofweek ||
  948. X                **  if the from part is ok and we are working
  949. X                **  on the to part and the dayofweek inputted
  950. X                **  is less than the to part
  951. X                **     then  we're done and it's a good value
  952. X                **     else  if we are working on the from part
  953. X                **           and dayofweek inputted is greater
  954. X                **           than range dayofweek
  955. X                **              then the from part is ok
  956. X                */
  957. X                if (retCode == testInt  ||
  958. X                    (fromOk == TRUE && fromTo == TO  &&
  959. X                    retCode < testInt))
  960. X                    success = TRUE;
  961. X                else if (fromTo == FROM  &&
  962. X                     retCode > testInt)
  963. X                    fromOk = TRUE;
  964. X            }
  965. X            goto nextvalue;
  966. X        
  967. X           default:
  968. X            /* do nothing. Go on to the fldType edits */
  969. X            break;
  970. X        } /* end switch (fldCharType) */
  971. X
  972. X
  973. X        switch (fldType)
  974. X        {
  975. X        case CHAR:
  976. X            /*
  977. X            **    bug fix - 9/24/86 pjc
  978. X            **    range = "1-12" double digit could not handle
  979. X            */
  980. X            INTFLAG = sscanf (wrk, "%d", &t2);
  981. X            if (INTFLAG)   
  982. X                INTFLAG = sscanf (Fld->strVal, "%d", &t1);
  983. X            if (INTFLAG)
  984. X                retCode = t1 - t2;
  985. X            else
  986. X                retCode = strcmp (Fld->strVal, wrk);
  987. X            if (retCode == 0 || (fromOk == TRUE  &&  
  988. X                fromTo == TO  && retCode < 0))
  989. X                success = TRUE ;
  990. X            else 
  991. X                if (fromTo == FROM  &&  retCode > 0)
  992. X                    fromOk = TRUE ;
  993. X            break ;
  994. X
  995. X        case INT:
  996. X            testInt = atoi (wrk) ;
  997. X            if (*Fld->intVal == testInt  ||
  998. X                (fromOk == TRUE  &&  fromTo == TO &&
  999. X                *Fld->intVal < testInt) )
  1000. X                success = TRUE ;
  1001. X            else if (fromTo == FROM  &&
  1002. X                *Fld->intVal > testInt)
  1003. X                fromOk = TRUE ;
  1004. X            break ;
  1005. X
  1006. X        case LONG:
  1007. X            testLong = atol (wrk) ;
  1008. X            if (*Fld->longVal == testLong  ||
  1009. X                (fromOk == TRUE  &&  fromTo == TO &&
  1010. X                *Fld->longVal < testLong) )
  1011. X                success = TRUE ;
  1012. X            else if (fromTo == FROM  &&
  1013. X                *Fld->longVal > testLong)
  1014. X                fromOk = TRUE ;
  1015. X            break ;
  1016. X
  1017. X        case FLOAT:
  1018. X            testFloat = atof (wrk) ;
  1019. X            if (*Fld->floatVal == testFloat  ||
  1020. X                (fromOk == TRUE  &&  fromTo == TO &&
  1021. X                *Fld->floatVal < testFloat) )
  1022. X                success = TRUE ;
  1023. X            else if (fromTo == FROM  &&
  1024. X                *Fld->floatVal > testFloat)
  1025. X                fromOk = TRUE ;
  1026. X            break ;
  1027. X
  1028. X        case DOUBLE:
  1029. X        case MONEY:
  1030. X            testDouble = atof (wrk) ;
  1031. X            if (*Fld->doubleVal == testDouble  ||
  1032. X                (fromOk == TRUE  &&  fromTo == TO &&
  1033. X                *Fld->doubleVal < testDouble))
  1034. X                success = TRUE ;
  1035. X            else if (fromTo == FROM  &&
  1036. X                *Fld->doubleVal > testDouble)
  1037. X                fromOk = TRUE ;
  1038. X            break ;
  1039. X        }
  1040. X
  1041. X
  1042. Xnextvalue:
  1043. X        if (success)
  1044. X            break ;
  1045. X
  1046. X        /*
  1047. X              **
  1048. X              ** Skip to next valid range check
  1049. X              **
  1050. X              */
  1051. X        while (TRUE)
  1052. X        {
  1053. X            if (*fldRange == '\0')
  1054. X                break ;
  1055. X            else 
  1056. X                if (*fldRange == '-')
  1057. X                    fromTo = TO ;
  1058. X                else 
  1059. X                    if (*fldRange == ',')
  1060. X                    {
  1061. X                        fromOk = FALSE ;
  1062. X                        fromTo = FROM ;
  1063. X                    }
  1064. X
  1065. X            if (isprint (*fldRange)  && *fldRange != ' ' &&
  1066. X                *fldRange != ','  &&  *fldRange != '-')
  1067. X                break ;
  1068. X
  1069. X            fldRange++;
  1070. X        }
  1071. X
  1072. X        if (*fldRange == '\0')
  1073. X            break ;
  1074. X
  1075. X    }
  1076. X
  1077. X    strcpy (tmpstr, fldRange);
  1078. X    upper (tmpstr);
  1079. X    if (fldCharType == DATE  && success && 
  1080. X        substr (tmpstr, "NO_HOLIDAYS") != (char *)NULL)
  1081. X    {
  1082. X        /* the date can not be a holiday */
  1083. X
  1084. X        /* convert date inputted to julian */
  1085. X        getmmddyy (fldStr, fldMask, &month, &day, &year);
  1086. X        retCode = julian (year, month, day);
  1087. X
  1088. X        /* if holidays file does not exist then ignore edit */
  1089. X        if ((fp = fopen (HOLIDAY_FILE, "r")) != (FILE *)NULL)
  1090. X        {
  1091. X            /* loop through each entry in holidays file */
  1092. X            while (fgets (tmpstr, BUFSIZE-1, fp) != (char *)NULL)
  1093. X            {
  1094. X                sscanf (tmpstr, "%d", &testInt);
  1095. X                if (testInt > 0  &&  retCode == testInt)
  1096. X                {
  1097. X                    success = FALSE;
  1098. X                    break;
  1099. X                }
  1100. X            }
  1101. X            fclose (fp);
  1102. X        }
  1103. X    }
  1104. X
  1105. X    /* date must be greater than today */
  1106. X    strcpy (tmpstr, fldRange);
  1107. X    upper (tmpstr);
  1108. X    if (fldCharType == DATE  && success && 
  1109. X        substr (tmpstr, "GT_TODAY") != (char *)NULL)
  1110. X    {
  1111. X        secs = time ((long *)0);
  1112. X        ltime = localtime (&secs);
  1113. X        tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
  1114. X            ltime->tm_mday);
  1115. X        idate = datedays (year, month, day);
  1116. X        if (idate <= tdate)
  1117. X            success = FALSE;
  1118. X    }
  1119. X    else if (fldCharType == DATE  && success && 
  1120. X        substr (tmpstr, "GE_TODAY") != (char *)NULL)
  1121. X    {
  1122. X        secs = time ((long *)0);
  1123. X        ltime = localtime (&secs);
  1124. X        tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
  1125. X            ltime->tm_mday);
  1126. X        idate = datedays (year, month, day);
  1127. X        if (idate < tdate)
  1128. X            success = FALSE;
  1129. X    }
  1130. X    else if (fldCharType == DATE  && success && 
  1131. X        substr (tmpstr, "LT_TODAY") != (char *)NULL)
  1132. X    {
  1133. X        secs = time ((long *)0);
  1134. X        ltime = localtime (&secs);
  1135. X        tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
  1136. X            ltime->tm_mday);
  1137. X        idate = datedays (year, month, day);
  1138. X        if (idate >= tdate)
  1139. X            success = FALSE;
  1140. X    }
  1141. X    else if (fldCharType == DATE  && success && 
  1142. X        substr (tmpstr, "LE_TODAY") != (char *)NULL)
  1143. X    {
  1144. X        secs = time ((long *)0);
  1145. X        ltime = localtime (&secs);
  1146. X        tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
  1147. X            ltime->tm_mday);
  1148. X        idate = datedays (year, month, day);
  1149. X        if (idate > tdate)
  1150. X            success = FALSE;
  1151. X    }
  1152. X
  1153. X
  1154. X    free (wrkAlloc) ;
  1155. X
  1156. X    return (success);
  1157. X}
  1158. SHAR_EOF
  1159. chmod 0644 utilities.d/libgeti.d/IsRange.c || echo "restore of utilities.d/libgeti.d/IsRange.c fails"
  1160. echo "x - extracting utilities.d/libgeti.d/IsState.c (Text)"
  1161. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsState.c &&
  1162. Xstatic char Sccsid[] = "@(#)IsState.c    1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
  1163. X#include <string.h>
  1164. X
  1165. X#define MAXSTATES 50
  1166. X
  1167. XIsState (str)
  1168. X    char str[] ;
  1169. X{
  1170. X    int    retCode, count ;
  1171. X
  1172. X    static char *states[] = {
  1173. X        "AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA",
  1174. X        "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD",
  1175. X        "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH", 
  1176. X        "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC",
  1177. X        "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI", "WV", "WY"
  1178. X    } ;
  1179. X
  1180. X
  1181. X    count = 0 ;
  1182. X
  1183. X    while (count < MAXSTATES) {
  1184. X
  1185. X        retCode = strcmp (str, states[count++]) ;
  1186. X
  1187. X        if (retCode == 0)
  1188. X            return (1) ;
  1189. X
  1190. X        if (retCode < 0)
  1191. X            return (0) ;
  1192. X    
  1193. X    }
  1194. X
  1195. X    return (0) ;
  1196. X}
  1197. X
  1198. X
  1199. SHAR_EOF
  1200. chmod 0444 utilities.d/libgeti.d/IsState.c || echo "restore of utilities.d/libgeti.d/IsState.c fails"
  1201. echo "x - extracting utilities.d/libgeti.d/IsTime.c (Text)"
  1202. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsTime.c &&
  1203. Xstatic char Sccsid[] = "@(#)IsTime.c    1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
  1204. X#include <stdio.h>
  1205. X#include "GetInput.h"
  1206. X
  1207. XIsTime(str, mask)
  1208. X    char    *str ;
  1209. X    char    *mask ;
  1210. X{
  1211. X    char    cmdstr[5] ;
  1212. X    int    i ;
  1213. X
  1214. X    if (mask == NULL) {
  1215. X
  1216. X        cmdstr[0] = *str++ ;
  1217. X        cmdstr[1] = *str++ ;
  1218. X        cmdstr[2] = '\0' ;
  1219. X        i = atoi (cmdstr) ;
  1220. X        if(i < 0  || i > 12)
  1221. X            return(0) ;
  1222. X
  1223. X        cmdstr[0] = *str++ ;
  1224. X        cmdstr[1] = *str++ ;
  1225. X        cmdstr[2] = '\0' ;
  1226. X        i = atoi (cmdstr) ;
  1227. X        if(i < 1  || i > 59)
  1228. X            return(0) ;
  1229. X
  1230. X        cmdstr[0] = *str++ ;
  1231. X        cmdstr[1] = *str++ ;
  1232. X        cmdstr[2] = '\0' ;
  1233. X        i = atoi (cmdstr) ;
  1234. X        if(i < 1  || i > 59)
  1235. X            return(0) ;
  1236. X
  1237. X    } else {
  1238. X
  1239. X        while ( *mask != '\0' ) {
  1240. X
  1241. X            while ( *mask != 'I' && *mask != 'H' && *mask != 'M' &&
  1242. X                    *mask != 'S' && *mask != 'T')
  1243. X                mask++ ;
  1244. X
  1245. X            switch (*mask) {
  1246. X                case 'H':
  1247. X                    cmdstr[0] = *str++ ;
  1248. X                    cmdstr[1] = *str++ ;
  1249. X                    cmdstr[2] = '\0' ;
  1250. X                    i = atoi (cmdstr) ;
  1251. X                    if(i < 1  ||  i > 12)
  1252. X                        return(0) ;
  1253. X                    mask += 2 ;
  1254. X                    break ;
  1255. X                case 'M':
  1256. X                case 'S':
  1257. X                    cmdstr[0] = *str++ ;
  1258. X                    cmdstr[1] = *str++ ;
  1259. X                    cmdstr[2] = '\0' ;
  1260. X                    i = atoi (cmdstr) ;
  1261. X                    if(i < 0  ||  i > 59)
  1262. X                        return(0) ;
  1263. X                    mask += 2 ;
  1264. X                    break ;
  1265. X                case 'T':
  1266. X                    cmdstr[0] = *str++ ;
  1267. X                    cmdstr[1] = *str++ ;
  1268. X                    cmdstr[2] = '\0' ;
  1269. X                    i = atoi (cmdstr) ;
  1270. X                    if(i < 0  ||  i > 99)
  1271. X                        return(0) ;
  1272. X                    mask += 2 ;
  1273. X                    break ;
  1274. X                case 'I':
  1275. X                    cmdstr[0] = *str++ ;
  1276. X                    cmdstr[1] = *str++ ;
  1277. X                    cmdstr[2] = '\0' ;
  1278. X                    i = atoi (cmdstr) ;
  1279. X                    if(i < 0  ||  i > 23)
  1280. X                        return(0) ;
  1281. X                    mask += 2 ;
  1282. X                    break ;
  1283. X            }
  1284. X        }
  1285. X    }
  1286. X    return(1) ;
  1287. X}
  1288. SHAR_EOF
  1289. chmod 0444 utilities.d/libgeti.d/IsTime.c || echo "restore of utilities.d/libgeti.d/IsTime.c fails"
  1290. echo "x - extracting utilities.d/libgeti.d/ReDispFld.c (Text)"
  1291. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ReDispFld.c &&
  1292. Xstatic char Sccsid[] = "@(#)ReDispFld.c    1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1293. X#include <curses.h>
  1294. X#include "GetInput.h"
  1295. X#include <ctype.h>
  1296. X
  1297. XReDispFld (win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, 
  1298. X    fldCharType, fldType, fldStr, colEnd, charKeyed, setNumb, 
  1299. X    origAttr)
  1300. X    WINDOW          *win ;          /* Window                */
  1301. X    int           rowStart ;
  1302. X    int           colStart ;
  1303. X    int           fldAttrib ;     /* field attribute             */
  1304. X    char          *fldMask ;      /* mask for character string      */
  1305. X    char          *fldRange ;     /* allowable range for field      */
  1306. X    unsigned    fldLength ;     /* Maximum length of output       */
  1307. X    char          fldCharType ;      /* type of character           */
  1308. X    char          fldType ;       /* type of field         */
  1309. Xchar  *fldStr ;   /* the field without the mask chars */
  1310. Xint   colEnd ; /* last column for display  */
  1311. Xchar  charKeyed[] ;  /* characters keyed */
  1312. Xint   setNumb ;   /* for SET & MENU */
  1313. Xint   origAttr[] ;   /* original attributes for field */
  1314. X{
  1315. X   int   col ;
  1316. X
  1317. X   char  *fldWrk ;
  1318. X
  1319. X   if (fldCharType == SET  ||  fldCharType == MENU )
  1320. X      ShowSet(win, rowStart, colStart, -1, fldRange, fldLength, &setNumb, colEnd, charKeyed, origAttr) ;
  1321. X   else {
  1322. X      if (fldAttrib != -1)
  1323. X         wattrset(win, fldAttrib) ;
  1324. X      col = colStart ;
  1325. X      wmove(win, rowStart, col) ;
  1326. X      fldWrk = fldStr ;
  1327. X
  1328. X      if (fldAttrib == -1   &&  fldType ==  MONEY) {
  1329. X         int   decimalFound, decimalPlaces ;
  1330. X
  1331. X         decimalFound =  FALSE ;
  1332. X         decimalPlaces = 0 ;
  1333. X
  1334. X         while (*fldWrk != '\0') {
  1335. X            if (*fldWrk == '.')
  1336. X               decimalFound = TRUE ;
  1337. X            else if (decimalFound)
  1338. X               decimalPlaces++;
  1339. X            fldWrk++;
  1340. X         }
  1341. X         if (!decimalFound)
  1342. X            strcat(fldStr, ".00") ;
  1343. X         else if (decimalFound  &&  decimalPlaces < 2) {
  1344. X            if (decimalPlaces == 0)
  1345. X               strcat(fldStr, "00") ;
  1346. X            else if (decimalPlaces == 1)
  1347. X               strcat(fldStr, "0") ;
  1348. X         }
  1349. X
  1350. X         fldWrk = fldStr ;
  1351. X      }
  1352. X
  1353. X      while (col < colEnd  &&  *fldWrk != '\0') {
  1354. X         if (fldAttrib == -1)
  1355. X            wattrset(win, origAttr[col - colStart] ) ;
  1356. X         if (charKeyed [col - colStart] == 'M')
  1357. X            mvwaddch(win, rowStart, col, *(fldMask + col - colStart) ) ;
  1358. X         else
  1359. X            mvwaddch(win, rowStart, col, *fldWrk++) ;
  1360. X         col++;
  1361. X      };
  1362. X
  1363. X      if (strlen(fldStr) < fldLength) {
  1364. X         int   bytesFill ;
  1365. X
  1366. X         bytesFill = fldLength - strlen(fldStr) ;
  1367. X         while (bytesFill) {
  1368. X            if (fldAttrib == -1)
  1369. X               wattrset(win, origAttr[col - colStart]);
  1370. X            if (charKeyed [col - colStart] != 'M') {
  1371. X               bytesFill--;
  1372. X               mvwaddch(win, rowStart, col++, ' ') ;
  1373. X            } else {
  1374. X               mvwaddch(win, rowStart, col, *(fldMask + col - colStart) ) ;
  1375. X               col++;
  1376. X            }
  1377. X         }
  1378. X      }
  1379. X
  1380. X      while (col < colEnd) 
  1381. X      {
  1382. X         if (charKeyed [col - colStart] != 'M')
  1383. X            mvwaddch(win, rowStart, col, ' ') ;
  1384. X         else
  1385. X            mvwaddch(win, rowStart, col, *(fldMask + col - colStart) ) ;
  1386. X         col++;
  1387. X      }
  1388. X
  1389. X      wattrset(win, 0) ;
  1390. X   }
  1391. X
  1392. X    return(0) ;
  1393. X}
  1394. SHAR_EOF
  1395. chmod 0444 utilities.d/libgeti.d/ReDispFld.c || echo "restore of utilities.d/libgeti.d/ReDispFld.c fails"
  1396. echo "x - extracting utilities.d/libgeti.d/RingMenu.c (Text)"
  1397. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/RingMenu.c &&
  1398. X#ifndef LINT
  1399. Xstatic char Sccsid[] = "@(#)RingMenu.c    1.3   DeltaDate 2/3/90   ExtrDate 2/3/90";
  1400. X#endif
  1401. X
  1402. X/***********************************************************************
  1403. X#############################################################################
  1404. X# This software/documentation is the proprietary trade secret and property  #
  1405. X# of Pacific Bell.  Receipt or possession of it does not convey any rights  #
  1406. X# to divulge, reproduce, use or allow others to use it without the specific #
  1407. X# written authorization of Pacific Bell.  Use must conform strictly to        #
  1408. X# the license agreement between user and Pacific Bell.                #
  1409. X#############################################################################
  1410. X
  1411. X    Program: RingMenu.c
  1412. X    Purpose: To display a Ring Menu, and prompt for option.
  1413. X         Options are to be selected with first capital
  1414. X         letter match, or use the cursor position key
  1415. X         to move to the right option and depress RETURN.
  1416. X         Help message for current option is always displayed
  1417. X         the line below the option line.
  1418. X
  1419. X    Synopsis: RingMenu (win, line, opt, title, opt_table )
  1420. X            WINDOW    *win;            /* curses screen
  1421. X            unsigned short    line ;        /* line option on
  1422. X            unsigned short    opt ;        /* default option pos
  1423. X            char    *title;            /* menu title
  1424. X            char    *opt_table[][2];    /* option table
  1425. X                            /*  name and description
  1426. X    Return: 1 - MAXOPTIONS
  1427. X
  1428. X    Author: Sam Lok
  1429. X    Date Written: March, 1989.
  1430. X    Installation: Pacific Bell
  1431. X    Modification History:
  1432. X    [Plx log name of programmer, date and description]
  1433. X
  1434. X***********************************************************************/
  1435. X
  1436. X#include <curses.h>
  1437. X#include <term.h>
  1438. X#include "GetInput.h"
  1439. X#include "keys.h"
  1440. X
  1441. X#define    MSGLINE        23
  1442. X#define    MAXOPTIONS    20
  1443. Xstruct ring                /* the ring */
  1444. X{
  1445. X    short    column ;        /* column position */
  1446. X    short    page ;            /* page number */
  1447. X} menu[MAXOPTIONS] ;
  1448. Xshort    Noptions ;            /* total number of options */
  1449. X
  1450. XRingMenu (win, line, opt, title, opt_table )
  1451. X    WINDOW    *win;
  1452. X    char    *opt_table[][2] ;
  1453. X    char    *title ;
  1454. X    unsigned short    line, opt ;
  1455. X{
  1456. X    register short    i, ii, ch ;
  1457. X
  1458. X    /*
  1459. X     * Initializations
  1460. X     */
  1461. X    putp( cursor_invisible ) ;    /* turn off cursor if possible */
  1462. X    for ( i=0;            /* count # option */
  1463. X          *opt_table[i]!=NULL && i<MAXOPTIONS;
  1464. X          i++ )
  1465. X        ;
  1466. X    Noptions = i;
  1467. X
  1468. X    /* initialize ring menu */
  1469. X    /*
  1470. X     * first option
  1471. X     */
  1472. X    if ( title != NULL )
  1473. X        menu[0].column = strlen( title ) + 2 ;
  1474. X    else
  1475. X        menu[0].column = 0 ;
  1476. SHAR_EOF
  1477. echo "End of part 9"
  1478. echo "File utilities.d/libgeti.d/RingMenu.c is continued in part 10"
  1479. echo "10" > s2_seq_.tmp
  1480. exit 0
  1481.