home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2413 < 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 8 of 14
  4. Message-ID: <442@pcbox.UUCP>
  5. Date: 26 Dec 90 20:10:56 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 8 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file ParseDeSrn.y continued
  12. #
  13. CurArch=8
  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 ParseDeSrn.y"
  24. sed 's/^X//' << 'SHAR_EOF' >> ParseDeSrn.y
  25. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_mustenter");
  26. X                fflush (stderr);
  27. X            }
  28. X        }
  29. X        ;
  30. X        | field_prompt 
  31. X        {
  32. X            strcpy (eott, "field_prompt");
  33. X            if (debug)
  34. X            {
  35. X                fprintf (stderr, 
  36. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_prompt");
  37. X                fflush (stderr);
  38. X            }
  39. X        }
  40. X        ;
  41. X        | field_terminator
  42. X        {
  43. X            strcpy (eott, "field_terminator");
  44. X            if (debug)
  45. X            {
  46. X                fprintf (stderr, 
  47. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_terminator");
  48. X                fflush (stderr);
  49. X            }
  50. X        }
  51. X        ;
  52. X        | field_defaults
  53. X        {
  54. X            strcpy (eott, "field_defaults");
  55. X            if (debug)
  56. X            {
  57. X                fprintf (stderr, 
  58. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_defaults");
  59. X                fflush (stderr);
  60. X            }
  61. X        }
  62. X        ;
  63. X
  64. X        | field_noinput 
  65. X        {
  66. X            strcpy (eott, "field_noinput");
  67. X            if (debug)
  68. X            {
  69. X                fprintf (stderr, 
  70. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> field_noinput");
  71. X                fflush (stderr);
  72. X            }
  73. X        }
  74. X        ;
  75. X
  76. X        | before_field 
  77. X        {
  78. X            strcpy (eott, "before_field");
  79. X            if (debug)
  80. X            {
  81. X                fprintf (stderr, 
  82. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> before_field");
  83. X                fflush (stderr);
  84. X            }
  85. X        }
  86. X        ;
  87. X
  88. X        | after_field 
  89. X        {
  90. X            strcpy (eott, "after_field");
  91. X            if (debug)
  92. X            {
  93. X                fprintf (stderr, 
  94. X                "\n[ParseDeSrn]<.DEFINE_SCREEN> after_field");
  95. X                fflush (stderr);
  96. X            }
  97. X        }
  98. X        ;
  99. X
  100. X
  101. Xscreen_title    : SCREEN_TITLE EQUAL STRING
  102. X        {
  103. X            strcpy (yyscreen->title, $3);
  104. X        }
  105. X        | SCREEN_TITLE EQUAL EVAR
  106. X        {
  107. X            strcpy (yyscreen->title, $3);
  108. X        }
  109. X        | SCREEN_TITLE EQUAL QUOTE_STRING
  110. X        {
  111. X            strcpy (yyscreen->title, $3);
  112. X        }
  113. X        ;
  114. X
  115. Xscreen_help    : SCREEN_HELP EQUAL STRING
  116. X        {
  117. X            strcpy (yyscreen->helpfile, $3);
  118. X        }
  119. X        | SCREEN_HELP EQUAL QUOTE_STRING
  120. X        {
  121. X            strcpy (yyscreen->helpfile, $3);
  122. X        }
  123. X        ;
  124. X
  125. Xscreen_pos    : SCREEN_POS EQUAL NUMBER NUMBER
  126. X        {
  127. X            yyscreen->toprow = $3;
  128. X            yyscreen->leftcol = $4;
  129. X        }
  130. X        | SCREEN_POS EQUAL EVAR EVAR
  131. X        {
  132. X            strcpy (yyscreen->toprowvar, $3);
  133. X            strcpy (yyscreen->leftcolvar, $4);
  134. X            /*
  135. X            yyscreen->toprow = atoi ((char *)getval (&$3, '1'));
  136. X            yyscreen->leftcol = atoi ((char *)getval (&$4, '1'));
  137. X            */
  138. X        }
  139. X        | SCREEN_POS EQUAL NUMBER EVAR
  140. X        {
  141. X            yyscreen->toprow = $3;
  142. X            strcpy (yyscreen->leftcolvar, $4);
  143. X        }
  144. X        | SCREEN_POS EQUAL EVAR NUMBER
  145. X        {
  146. X            /*
  147. X            yyscreen->toprow = atoi ((char *)getval (&$3, '1'));
  148. X            */
  149. X            strcpy (yyscreen->toprowvar, $3);
  150. X            yyscreen->leftcol = $4;
  151. X        }
  152. X        ;
  153. X
  154. Xscreen_rows    : SCREEN_ROWS EQUAL NUMBER
  155. X        {
  156. X            yyscreen->rows = $3;
  157. X        }
  158. X        ;
  159. Xscreen_cols    : SCREEN_COLS EQUAL NUMBER
  160. X        {
  161. X            yyscreen->cols = $3;
  162. X        }
  163. X        ;
  164. Xscreen_border    : SCREEN_BORDER EQUAL STRING
  165. X        {
  166. X            /* get border type for active menu */
  167. X            if (strcmp ($3, "DumbLine") == 0)
  168. X                yyscreen->boxtype = DumbLine;
  169. X            else    if (strcmp ($3, "StandoutLine") == 0)
  170. X                    yyscreen->boxtype = StandoutLine;
  171. X            else    if (strcmp ($3, "SingleLine") == 0 ||
  172. X                    strcmp ($3, "DrawLine") == 0)
  173. X                    yyscreen->boxtype = SingleLine;
  174. X            else    if (strcmp ($3, "MosaicLine") == 0)
  175. X                    yyscreen->boxtype = MosaicLine;
  176. X            else    if (strcmp ($3, "DiamondLine") == 0)
  177. X                    yyscreen->boxtype = DiamondLine;
  178. X            else    if (strcmp ($3, "DotLine") == 0)
  179. X                    yyscreen->boxtype = DotLine;
  180. X            else    if (strcmp ($3, "PlusLine") == 0)
  181. X                    yyscreen->boxtype = PlusLine;
  182. X        }
  183. X        |SCREEN_BORDER EQUAL STRING STRING
  184. X        {
  185. X            /* get border type for active menu */
  186. X            if (strcmp ($3, "DumbLine") == 0)
  187. X                yyscreen->boxtype = DumbLine;
  188. X            else    if (strcmp ($3, "StandoutLine") == 0)
  189. X                    yyscreen->boxtype = StandoutLine;
  190. X            else    if (strcmp ($3, "SingleLine") == 0 ||
  191. X                    strcmp ($3, "DrawLine") == 0)
  192. X                    yyscreen->boxtype = SingleLine;
  193. X            else    if (strcmp ($3, "MosaicLine") == 0)
  194. X                    yyscreen->boxtype = MosaicLine;
  195. X            else    if (strcmp ($3, "DiamondLine") == 0)
  196. X                    yyscreen->boxtype = DiamondLine;
  197. X            else    if (strcmp ($3, "DotLine") == 0)
  198. X                    yyscreen->boxtype = DotLine;
  199. X            else    if (strcmp ($3, "PlusLine") == 0)
  200. X                    yyscreen->boxtype = PlusLine;
  201. X
  202. X            /* border type for inactive menu - dim (high 8 bits) */
  203. X            if (strcmp ($4, "DumbLine") == 0)
  204. X                yyscreen->boxtype = yyscreen->boxtype | 
  205. X                            (DumbLine << 9);
  206. X            else    if (strcmp ($4, "StandoutLine") == 0)
  207. X                    yyscreen->boxtype = yyscreen->boxtype | 
  208. X                            (StandoutLine << 9);
  209. X            else    if (strcmp ($4, "SingleLine") == 0 ||
  210. X                    strcmp ($4, "DrawLine") == 0)
  211. X                    yyscreen->boxtype = yyscreen->boxtype | 
  212. X                            (SingleLine << 9);
  213. X            else    if (strcmp ($4, "MosaicLine") == 0)
  214. X                    yyscreen->boxtype = yyscreen->boxtype | 
  215. X                            (MosaicLine << 9);
  216. X            else    if (strcmp ($4, "DiamondLine") == 0)
  217. X                    yyscreen->boxtype = yyscreen->boxtype | 
  218. X                            (DiamondLine << 9);
  219. X            else    if (strcmp ($4, "DotLine") == 0)
  220. X                    yyscreen->boxtype = yyscreen->boxtype | 
  221. X                            (DotLine << 9);
  222. X            else    if (strcmp ($4, "PlusLine") == 0)
  223. X                    yyscreen->boxtype = yyscreen->boxtype | 
  224. X                            (PlusLine << 9);
  225. X        }
  226. X        ;
  227. Xexit_last_field    : EXIT_LAST_FIELD
  228. X        {
  229. X            yyscreen->exitlastfield = TRUE;
  230. X        }
  231. X        ;
  232. X
  233. Xexit_on_cancel    : EXIT_ON_CANCEL
  234. X        {
  235. X            yyscreen->exitoncancel = TRUE;
  236. X        }
  237. X        ;
  238. X
  239. Xscreen_text    : SCREEN_TEXT EQUAL NUMBER NUMBER STRING
  240. X        {
  241. X            yyscreen->textinfo[textcount] = (struct TextInfo *)
  242. X                    malloc (sizeof (struct TextInfo));
  243. X            yyscreen->textinfo[textcount]->row = $3;
  244. X            yyscreen->textinfo[textcount]->col = $4;
  245. X            yyscreen->textinfo[textcount]->text = 
  246. X                (char *)malloc (strlen($5)+5);
  247. X            strcpy (yyscreen->textinfo[textcount]->text, $5);
  248. X            yyscreen->textinfo[++textcount] = 
  249. X                (struct TextInfo *)NULL;
  250. X        }
  251. X        | SCREEN_TEXT EQUAL NUMBER NUMBER QUOTE_STRING
  252. X        {
  253. X            yyscreen->textinfo[textcount] = (struct TextInfo *)
  254. X                    malloc (sizeof (struct TextInfo));
  255. X            yyscreen->textinfo[textcount]->row = $3;
  256. X            yyscreen->textinfo[textcount]->col = $4;
  257. X            yyscreen->textinfo[textcount]->text = 
  258. X                (char *)malloc (strlen($5)+5);
  259. X            strcpy (yyscreen->textinfo[textcount]->text, $5);
  260. X            yyscreen->textinfo[++textcount] = 
  261. X                (struct TextInfo *)NULL;
  262. X        }
  263. X        ;
  264. X
  265. Xafter_screen    : AFTER_SCREEN EQUAL QUOTE_STRING
  266. X        {
  267. X            yyscreen->after_screen = (char *)malloc (strlen($3)+5);
  268. X            strcpy (yyscreen->after_screen, $3);
  269. X        }
  270. X        ;
  271. X
  272. X
  273. X
  274. X
  275. Xfield_name    : FIELD_NAME EQUAL EVAR
  276. X        {
  277. X            /*
  278. X            **  The field_name token signifes a new field
  279. X            **  we need to malloc the field structure.
  280. X            */
  281. X               if ((++fieldcount) > MAXFIELDS)
  282. X               {
  283. X                      BEEP;
  284. X                      mvprintw (ErrRow-2, 0, 
  285. X                  "Exceeded maximum screen fields of %d.",
  286. X                  MAXFIELDS);
  287. X                      shutdown ();
  288. X               }
  289. X            FLD = (struct FieldInfo *)malloc (sizeof (struct FieldInfo));
  290. X            yyscreen->field[fieldcount] = (struct FieldInfo *)NULL;
  291. X            strcpy (FLD->name, $3+1);
  292. X
  293. X            /* Set default field values */
  294. X            strcpy (FLD->label, "");
  295. X            FLD->min_input = 0;
  296. X            strcpy (FLD->mask, "");
  297. X            strcpy (FLD->range, "");
  298. X            FLD->type = UPPER_AN;
  299. X            FLD->adjust = NOFILL;
  300. X            FLD->mustenter = FALSE;
  301. X            strcpy (FLD->prompt, "");
  302. X            strcpy (FLD->terminator, "[]");
  303. X            FLD->noinput = FALSE;
  304. X            FLD->before_field = (char *)NULL;
  305. X            FLD->after_field = (char *)NULL;
  306. X        }
  307. X        ;
  308. X
  309. Xfield_label    : FIELD_LABEL EQUAL STRING
  310. X        {
  311. X            strcpy (FLD->label, $3);
  312. X        }
  313. X        | FIELD_LABEL EQUAL QUOTE_STRING
  314. X        {
  315. X            strcpy (FLD->label, $3);
  316. X        }
  317. X        ;
  318. X
  319. Xfield_row    : FIELD_ROW EQUAL NUMBER
  320. X        {
  321. X            FLD->row = $3;
  322. X        }
  323. X        ;
  324. Xfield_col    : FIELD_COL EQUAL NUMBER
  325. X        {
  326. X            FLD->col = $3;
  327. X        }
  328. X        ;
  329. X
  330. Xfield_mask    : FIELD_MASK EQUAL STRING
  331. X        {
  332. X            strcpy (FLD->mask, $3);
  333. X        }
  334. X        | FIELD_MASK EQUAL QUOTE_STRING
  335. X        {
  336. X            strcpy (FLD->mask, $3);
  337. X        }
  338. X        ;
  339. X
  340. Xfield_range    : FIELD_RANGE EQUAL STRING
  341. X        {
  342. X            strcpy (FLD->range, $3);
  343. X        }
  344. X        | FIELD_RANGE EQUAL QUOTE_STRING
  345. X        {
  346. X            strcpy (FLD->range, $3);
  347. X        }
  348. X        ;
  349. X
  350. Xfield_length    : FIELD_LENGTH EQUAL NUMBER
  351. X        {
  352. X            FLD->length = $3;
  353. X        }
  354. X        ;
  355. Xfield_min    : FIELD_MIN EQUAL NUMBER
  356. X        {
  357. X            FLD->min_input = $3;
  358. X        }
  359. X        ;
  360. Xfield_type    : FIELD_TYPE EQUAL STRING
  361. X        {
  362. X            if (strcmp ($3, "ALPHANUM") == 0)
  363. X                FLD->type = ALPHANUM;
  364. X            else if (strcmp ($3, "ALPHA") == 0)
  365. X                FLD->type = ALPHA;
  366. X            else if (strcmp ($3, "NUMERIC") == 0)
  367. X                FLD->type = NUMERIC;
  368. X            else if (strcmp ($3, "SET") == 0)
  369. X                FLD->type = SET;
  370. X            else if (strcmp ($3, "UPPER") == 0)
  371. X                FLD->type = UPPER;
  372. X            else if (strcmp ($3, "UPPER_AN") == 0)
  373. X                FLD->type = UPPER_AN;
  374. X            else if (strcmp ($3, "HEX") == 0)
  375. X                FLD->type = HEX;
  376. X            else if (strcmp ($3, "STATE") == 0)
  377. X                FLD->type = STATE;
  378. X            else if (strcmp ($3, "ZIP") == 0)
  379. X                FLD->type = ZIP;
  380. X            else if (strcmp ($3, "DATE") == 0)
  381. X                FLD->type = DATE;
  382. X            else if (strcmp ($3, "TIME") == 0)
  383. X                FLD->type = TIME;
  384. X            else if (strcmp ($3, "MENU") == 0)
  385. X                FLD->type = MENU;
  386. X            else if (strcmp ($3, "PROTECT") == 0)
  387. X                FLD->type = PROTECT;
  388. X            else yyerror ("Invalid field_edits");
  389. X        }
  390. X        ;
  391. Xfield_adjust    : FIELD_ADJUST EQUAL STRING
  392. X        {
  393. X            if (strcmp ($3, "NOFILL") == 0)
  394. X                FLD->adjust = NOFILL;
  395. X            else if (strcmp ($3, "RTADJ_ZFILL") == 0)
  396. X                FLD->adjust = RTADJ_ZFILL;
  397. X            else if (strcmp ($3, "RTADJ_BFILL") == 0)
  398. X                FLD->adjust = RTADJ_BFILL;
  399. X            else if (strcmp ($3, "LFADJ_ZFILL") == 0)
  400. X                FLD->adjust = LFADJ_ZFILL;
  401. X            else if (strcmp ($3, "LFADJ_BFILL") == 0)
  402. X                FLD->adjust = LFADJ_BFILL;
  403. X        }
  404. X        | FIELD_ADJUST EQUAL QUOTE_STRING
  405. X        {
  406. X            if (strcmp ($3, "NOFILL") == 0)
  407. X                FLD->adjust = NOFILL;
  408. X            else if (strcmp ($3, "RTADJ_ZFILL") == 0)
  409. X                FLD->adjust = RTADJ_ZFILL;
  410. X            else if (strcmp ($3, "RTADJ_BFILL") == 0)
  411. X                FLD->adjust = RTADJ_BFILL;
  412. X            else if (strcmp ($3, "LFADJ_ZFILL") == 0)
  413. X                FLD->adjust = LFADJ_ZFILL;
  414. X            else if (strcmp ($3, "LFADJ_BFILL") == 0)
  415. X                FLD->adjust = LFADJ_BFILL;
  416. X        }
  417. X        ;
  418. X
  419. Xfield_mustenter    : FIELD_MUSTENTER
  420. X        {
  421. X            FLD->mustenter = TRUE;
  422. X        }
  423. X        ;
  424. X
  425. Xfield_prompt    : FIELD_PROMPT EQUAL STRING
  426. X        {
  427. X            strcpy (FLD->prompt, $3);
  428. X        }
  429. X        | FIELD_PROMPT EQUAL QUOTE_STRING
  430. X        {
  431. X            strcpy (FLD->prompt, $3);
  432. X        }
  433. X        ;
  434. X
  435. Xfield_terminator : FIELD_TERMINATOR EQUAL QUOTE_STRING
  436. X        {
  437. X            if (strlen ($3) != 2)
  438. X                yyerror ("Bad field_terminator.");
  439. X            strcpy (FLD->terminator, $3);
  440. X        }
  441. X        ;
  442. X
  443. Xfield_defaults    : FIELD_DEFAULTS EQUAL QUOTE_STRING
  444. X        {
  445. X            yyscreen->fielddefaults = (char *)malloc (strlen($3)+5);
  446. X            strcpy (yyscreen->fielddefaults, $3);
  447. X        }
  448. X        ;
  449. X
  450. Xfield_noinput    : FIELD_NOINPUT
  451. X        {
  452. X            FLD->noinput = TRUE;
  453. X        }
  454. X        ;
  455. X
  456. Xbefore_field : BEFORE_FIELD EQUAL QUOTE_STRING
  457. X        {
  458. X            FLD->before_field = (char *)malloc (strlen($3)+5);
  459. X            strcpy (FLD->before_field, $3);
  460. X        }
  461. X        ;
  462. X
  463. Xafter_field : AFTER_FIELD EQUAL QUOTE_STRING
  464. X        {
  465. X            FLD->after_field = (char *)malloc (strlen($3)+5);
  466. X            strcpy (FLD->after_field, $3);
  467. X        }
  468. X        ;
  469. X
  470. X
  471. X
  472. X%%
  473. X
  474. X/*  FUNCTION:    ParseDefineScreen()
  475. X**        This function parses .DEFINE_SCREEN
  476. X**  ARGS:    keyword        the keyword found
  477. X**        menufile    the unix menu file
  478. X**        menu        menu structure
  479. X**        gnames        holder of goto menu names
  480. X**        gfiles        holder of goto menu names (menu file)
  481. X**        gindex        # of gnames
  482. X**  RETURNS:    0
  483. X*/
  484. X
  485. X
  486. X#define    SRN    menu->srn[screencount-1]
  487. X
  488. Xextern FILE    *yyin;
  489. Xextern FILE    *yyout;
  490. Xextern    int    swin, ewin, longest;
  491. X
  492. X    char    ScreenName[50];                /* for yyerror */
  493. X
  494. X
  495. XParseDefineScreen (keyword, menufile, menu, gnames, gfiles, gindex, opnumber)
  496. X
  497. X    char        keyword[];
  498. X    FILE        *menufile;
  499. X    struct MenuInfo    *menu;
  500. X    char        gnames[][15], gfiles[][15];
  501. X    int        *gindex;
  502. X    int        *opnumber;
  503. X{
  504. X    char        *fgets(), line[BUFSIZE];
  505. X    static int    screencount;
  506. X    int        i = 0;
  507. X    int        j;
  508. X    char        *ws;
  509. X
  510. X
  511. X    /* check if this is the first screen for this menu */
  512. X    if (menu->srn[0] == (struct ScreenInfo *)NULL)
  513. X        screencount = 0;
  514. X
  515. X       if ((++screencount) > MAXSCREENS)
  516. X       {
  517. X              BEEP;
  518. X              mvprintw (ErrRow, 0, 
  519. X            "Exceeded maximum allowable .DEFINE_SCREEN.");
  520. X              shutdown ();
  521. X       }
  522. X
  523. X    SRN = (struct ScreenInfo *)malloc (sizeof (struct ScreenInfo));
  524. X       if (SRN == NULL)
  525. X       {
  526. X              BEEP;
  527. X              mvprintw (ErrRow, 0, 
  528. X            "Unable to allocate memory for .DEFINE_SCREEN.");
  529. X              shutdown ();
  530. X       }
  531. X    /* terminate the screens list */
  532. X    menu->srn[screencount] = (struct ScreenInfo *)NULL;
  533. X    SRN->field[0] = (struct FieldInfo *)NULL;    /* no fields yet */
  534. X
  535. X
  536. X    /* get screen name */
  537. X    fgets (line, BUFSIZE, menufile);
  538. X    sscanf (line, "%s", SRN->name);            /* screen name */
  539. X    strcpy (ScreenName, SRN->name);            /* for yyerror */
  540. X
  541. X    yyin = menufile;
  542. X    yyscreen = SRN;
  543. X    fieldcount = 0;
  544. X    textcount = 0;
  545. X
  546. X    /*
  547. X    **  Set default screen values.
  548. X    */
  549. X    sprintf (SRN->title, "%d", AUTO);
  550. X    SRN->rows = AUTO;
  551. X    SRN->cols = AUTO;
  552. X    SRN->toprow = AUTO;
  553. X    SRN->leftcol = AUTO;
  554. X    strcpy (SRN->toprowvar, "");
  555. X    strcpy (SRN->leftcolvar, "");
  556. X    SRN->boxtype = StandoutLine;
  557. X    SRN->fielddefaults = (char *)NULL;
  558. X    strcpy (SRN->helpfile, "menu.hlp");
  559. X    SRN->exitlastfield = FALSE;
  560. X    SRN->exitoncancel = FALSE;
  561. X    SRN->textinfo[textcount] = (struct TextInfo *)NULL;
  562. X    SRN->after_screen = (char *)NULL;
  563. X
  564. X#ifdef    _yydebug
  565. X    if (debug)
  566. X        yydebug = 1;
  567. X#endif
  568. X
  569. X    yyparse ();
  570. X
  571. X       return (0);
  572. X}
  573. X
  574. X
  575. Xyyerror (s)
  576. X    char    *s;
  577. X{
  578. X    mvprintw (ErrRow-5,0, "Unable to process .DEFINE_SCREEN  %s", 
  579. X            ScreenName);
  580. X    mvprintw (ErrRow-4,0, "Field Number %d", fieldcount);
  581. X    mvprintw (ErrRow-3,0, "%s", s);
  582. X    mvprintw (ErrRow-2,0, "The error occured on token = \"%s\"", eott);
  583. X    mvprintw (ErrRow-1,0, "Look ahead token number %d  <tokens.h>", yychar);
  584. X    shutdown ();
  585. X}
  586. SHAR_EOF
  587. echo "File ParseDeSrn.y is complete"
  588. chmod 0644 ParseDeSrn.y || echo "restore of ParseDeSrn.y fails"
  589. echo "x - extracting utilities.d/libgeti.d/AdjField.c (Text)"
  590. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/AdjField.c &&
  591. Xstatic char Sccsid[] = "@(#)AdjField.c    1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
  592. X#include    <curses.h>
  593. X#include    "GetInput.h"
  594. X#include    <ctype.h>
  595. X
  596. XAdjField(win, rowStart, colStart, fldAttrib, fldAdjust, colEnd, charKeyed)
  597. X    WINDOW        *win ;        /* Window                    */
  598. X    int        rowStart ;
  599. X    int        colStart ;
  600. X    int        fldAttrib ;    /* Curses attribute            */
  601. X    char        fldAdjust ;    /* adjust/fill field             */
  602. X    int        colEnd ;    /* column where field ends        */
  603. X    char        charKeyed[] ;    /* characters keyed            */
  604. X{
  605. X    int        col ;        /* working column field */
  606. X    int        row ;        /* working row field */
  607. X    int        colMove ;    /* working column field for adjusting
  608. X                           routines */
  609. X    int        ch ;        /* contains character keyed or being
  610. X                           moved */
  611. X
  612. X    char        *wrkKeyed ;    /* working pointer for charKeyed */
  613. X    char        fillChar ;
  614. X
  615. X
  616. X    getyx (win, row, col) ;
  617. X
  618. X    if (fldAdjust == RTADJ_BFILL || fldAdjust == LFADJ_BFILL)
  619. X        fillChar = ' ' ;
  620. X    else if (fldAdjust == RTADJ_ZFILL  ||  fldAdjust == LFADJ_ZFILL)
  621. X        fillChar = '0' ;
  622. X
  623. X    if (fldAdjust == RTADJ_BFILL || fldAdjust == RTADJ_ZFILL) {
  624. X
  625. X        col-- ;
  626. X
  627. X        wrkKeyed = charKeyed + (col - colStart) ;
  628. X
  629. X        colMove = colEnd - 1 ;
  630. X
  631. X        while (col >= colStart) {
  632. X
  633. X            while ( *wrkKeyed != 'Y') {
  634. X                wrkKeyed-- ;
  635. X                col-- ;
  636. X            }
  637. X
  638. X            if (col < colStart)
  639. X                break ;
  640. X
  641. X            ch = mvwinch(win, rowStart, col--) & A_CHARTEXT ;
  642. X            *wrkKeyed-- = 'N' ;
  643. X
  644. X            while ( colMove > colStart  &&
  645. X                    charKeyed [colMove - colStart] != 'N')
  646. X                colMove-- ;
  647. X
  648. X            charKeyed [colMove - colStart] = 'Y' ;
  649. X
  650. X            wattrset (win, fldAttrib) ;
  651. X            mvwaddch (win, rowStart, colMove--, ch) ;
  652. X            wattrset (win, 0) ;
  653. X        }
  654. X
  655. X        wattrset (win, fldAttrib) ;
  656. X
  657. X        while (colMove >= colStart) {
  658. X
  659. X            if ( charKeyed [colMove - colStart] != 'N')
  660. X                colMove-- ;
  661. X            else {
  662. X                charKeyed [colMove - colStart] = 'Y' ;
  663. X                mvwaddch(win, rowStart, colMove--, fillChar) ;
  664. X            }
  665. X        }
  666. X
  667. X        wattrset (win, 0) ;
  668. X        wmove (win, rowStart, colEnd) ;
  669. X
  670. X    } else if  (fldAdjust == LFADJ_BFILL || fldAdjust == LFADJ_ZFILL) {
  671. X
  672. X        if (col < colStart)
  673. X            col = colStart;
  674. X
  675. X        wattrset (win, fldAttrib) ;
  676. X
  677. X        while (col < colEnd) {
  678. X
  679. X            if ( charKeyed [col - colStart] != 'N')
  680. X                col++ ;
  681. X            else {
  682. X                charKeyed [col - colStart] = 'Y' ;
  683. X                mvwaddch (win, rowStart, col++, fillChar) ;
  684. X            }
  685. X        }
  686. X
  687. X        wattrset (win, 0) ;
  688. X        wmove (win, rowStart, colEnd) ;
  689. X    }
  690. X
  691. X    wrefresh (win) ;
  692. X
  693. X    return(0) ;
  694. X
  695. X}
  696. SHAR_EOF
  697. chmod 0444 utilities.d/libgeti.d/AdjField.c || echo "restore of utilities.d/libgeti.d/AdjField.c fails"
  698. echo "x - extracting utilities.d/libgeti.d/BuildMenu.c (Text)"
  699. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/BuildMenu.c &&
  700. X#ifndef LINT
  701. Xstatic char Sccsid[] = "@(#)BuildMenu.c    1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
  702. X#endif
  703. X
  704. X#include    <curses.h>
  705. X
  706. XBuildMenu (menu, fldRange)
  707. X    char    menu[][80];
  708. X    char    *fldRange;
  709. X{
  710. X    int    eidx = 0;                /* element index */
  711. X    char    *rptr;                    /* range pointer */
  712. X    char    *eptr;                    /* element pointer */
  713. X
  714. X    rptr = fldRange;
  715. X
  716. X    while (*rptr != '\0')
  717. X    {
  718. X        /* get range element eidx */
  719. X        eptr = menu[eidx];
  720. X        while (*rptr != ','  &&  *rptr != '\0')
  721. X            *eptr++ = *rptr++;
  722. X        *eptr = '\0';
  723. X
  724. X        /* skip junk */
  725. X        while (*rptr == ','  || *rptr == ' '  ||  *rptr == '\t')
  726. X            *rptr++;
  727. X        eidx++;
  728. X    }
  729. X    strcpy (menu[eidx], "");
  730. X}
  731. X/* Paul J. Condie  11/88 */
  732. SHAR_EOF
  733. chmod 0444 utilities.d/libgeti.d/BuildMenu.c || echo "restore of utilities.d/libgeti.d/BuildMenu.c fails"
  734. echo "x - extracting utilities.d/libgeti.d/DateFun.c (Text)"
  735. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/DateFun.c &&
  736. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  737. X
  738. X#define    BASEYEAR    1900
  739. X
  740. X/*
  741. X *      is_leap - returns 1 if year is a leap year, 0 if not
  742. X */
  743. Xint is_leap(y)
  744. Xint y;
  745. X{
  746. X    return(y % 4 == 0 && y % 100 != 0 || y % 400 == 0);
  747. X}
  748. X
  749. X/* 
  750. X**
  751. X**    maxdays, returns maximum number of days for 'year' 
  752. X**
  753. X*/
  754. Xint maxdays(y)
  755. Xregister int y;
  756. X{
  757. X    return(is_leap(y) ? 366 : 365);
  758. X}
  759. X
  760. Xstatic  int     day_tab[2][13] = {
  761. X    {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
  762. X    {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
  763. X};                                  
  764. X
  765. X
  766. X/*
  767. X *      julian - converts year month and day to julian date and returns it
  768. X */
  769. Xint julian(year, month, day)
  770. Xint year, month, day;
  771. X{
  772. X    int i, leap;
  773. X
  774. X    leap = is_leap(year);
  775. X    for (i = 1; i < month; i++)
  776. X        day += day_tab[leap][i];
  777. X    return(day);
  778. X}
  779. X
  780. X
  781. X
  782. X/*
  783. X**
  784. X**      week_day - returns the day of the week given the Year, 
  785. X**            Month and Day.  Year must be >= 1973.  
  786. X**            If not, -1 is returned.
  787. X**                      day of the week:  
  788. X**                Sunday = 0,  Monday = 1,  ...,  Saturday = 6.
  789. X*/
  790. Xint week_day( year, month, day )
  791. X    int    year, month, day ;
  792. X{
  793. X    int    century ;
  794. X
  795. X    month -= 2 ;
  796. X    if ( month < 1 )
  797. X    {
  798. X        month += 12 ;
  799. X        year-- ;
  800. X    }
  801. X    century = (int)( year / 100 ) ;
  802. X    year %= 100 ;
  803. X    return(((int)( (13 * month - 1) / 5 ) + day + year + (int)( year / 4 ) +
  804. X        (int)( century / 4 ) - ( 2 * century ) + 77) % 7 ) ;
  805. X}
  806. X
  807. X
  808. X/*
  809. X *      month_day - Converts julian date to month and day. Month and day must be passed as addresses of ints.
  810. X */
  811. Xvoid
  812. Xmonth_day(year, yearday, pmonth, pday)
  813. Xint year, yearday, *pmonth, *pday;
  814. X{
  815. X    int i, leap;
  816. X
  817. X    leap = is_leap(year);
  818. X    for (i = 1; yearday > day_tab[leap][i]; i++)  {
  819. X        yearday -= day_tab[leap][i];
  820. X    }
  821. X    if(i > 12)
  822. X        i = 1;
  823. X
  824. X    if(yearday <= 0)  {     /* special kludge for julian day 0 = Dec. 31st */
  825. X        *pmonth = 12;
  826. X        *pday = 31 + yearday;
  827. X    }  else {
  828. X        *pmonth = i;
  829. X        *pday = yearday;
  830. X    }
  831. X}
  832. X
  833. X
  834. X/* back up (if necessary) month and date to nearest sunday */
  835. X/* return julian date of new date as well */
  836. X
  837. X/*
  838. X *      weekstart - returns julian data of Sunday start date of given YY/MM/DD.
  839. X */
  840. Xint weekstart(year, month, date)
  841. Xregister int year, *month, *date;
  842. X{
  843. X    int mp, dp, i, t;
  844. X
  845. X    if ((i = week_day(year, *month, *date)) != 0)  {
  846. X        t = julian(year, *month, *date);
  847. X        month_day(year, t - i, &mp, &dp);
  848. X        if(mp > *month)
  849. X            year--;
  850. X        *month = mp;
  851. X        *date = dp;
  852. X    }
  853. X    return(julian(year, *month, *date));
  854. X}
  855. X
  856. X
  857. X/* verifies the integrity of a date, returns 1 if good, 0 if bad */
  858. Xint valid_date(yr, mo, day)
  859. Xint yr, mo, day;
  860. X{
  861. X    int days, leap;
  862. X
  863. X    leap = is_leap(yr);
  864. X    if (mo > 0 && mo < 13) {
  865. X        days = day_tab[leap][mo];
  866. X        if (day > 0 && day <= days && yr > 0)
  867. X            return(1);
  868. X    }
  869. X    return(0);
  870. X}
  871. X
  872. X
  873. X/*
  874. X**    datedays - returns the # of days from 1/1/BASEYEAR
  875. X**        01/01/BASEYEAR = 1 days
  876. X**    Year must be >= BASEYEAR.  If not, -1 is returned.
  877. X*/
  878. Xlong datedays(year, month, day)
  879. X    int year, month, day;
  880. X{
  881. X    year -= BASEYEAR ;
  882. X    if(year < 0)
  883. X        return(-1);
  884. X    else
  885. X        return((long) ((year*365)+julian(year, month, day)+
  886. X                   ((year-1)/4)));
  887. X}
  888. SHAR_EOF
  889. chmod 0644 utilities.d/libgeti.d/DateFun.c || echo "restore of utilities.d/libgeti.d/DateFun.c fails"
  890. echo "x - extracting utilities.d/libgeti.d/DisPrmpt.c (Text)"
  891. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/DisPrmpt.c &&
  892. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  893. X#include    <curses.h>
  894. X#include    "GetInput.h"
  895. X
  896. XDisPrmpt(win, Fld, fldAttrib, fldMask, fldLength, fldCharType, fldAdjust, fldType, colStart, colEnd, fldStr, charKeyed)
  897. X    WINDOW        *win ;        /* Window                    */
  898. X    FldUnPointer    Fld ;        /* Pointer to union for field        */
  899. X    int        fldAttrib ;    /* Curses attribute            */
  900. X    char        *fldMask ;    /* mask for character string         */
  901. X    unsigned    fldLength ;    /* Maximum length of output         */
  902. X    char        fldCharType ;    /* type of character             */
  903. X    char        fldAdjust ;    /* Type of adjustment             */
  904. X    char        fldType ;    /* type of field             */
  905. X    int        colStart ;    /* column start of field */
  906. X    int        colEnd ;    /* column end of field */
  907. X    char        *fldStr ;    /* buffer that will contain output  */
  908. X    char        *charKeyed ;    /* characters keyed  */
  909. X{
  910. X    char    *wrk, *fldWrk, *malloc();
  911. X
  912. X    int    ch ;
  913. X    int    col ;
  914. X    int    initFld ;
  915. X    int    i, j ;
  916. X
  917. X    *fldStr = '\0' ;
  918. X
  919. X    /*
  920. X    if (((fldType == HEX  ||  fldType == CHAR)  &&  *Fld->strVal == '\0') ||
  921. X            (fldType == INT     &&  *Fld->intVal    == 0) ||
  922. X            (fldType == SHORT   &&  *Fld->shortVal  == 0) ||
  923. X            (fldType == LONG    &&  *Fld->longVal   == 0L) ||
  924. X            (fldType == FLOAT   &&  *Fld->floatVal  == 0.0) ||
  925. X            (fldType == DOUBLE  &&  *Fld->doubleVal == 0.0) ||
  926. X            (fldType == MONEY   &&  *Fld->doubleVal == 0.0) ) {
  927. X    */
  928. X    if (((fldType == HEX  ||  fldType == CHAR)  &&  *Fld->strVal == '\0')) {
  929. X
  930. X        initFld = FALSE ;
  931. X        fldWrk = fldStr ;
  932. X        while (fldLength--)
  933. X            *fldWrk++ = ' ' ;
  934. X        *fldWrk = '\0' ;
  935. X    } else {
  936. X
  937. X        initFld = TRUE ;
  938. X
  939. X        fldWrk = malloc(fldLength + 10);
  940. X
  941. X        if (fldType == HEX  ||   fldType == CHAR)
  942. X            strcpy (fldWrk, Fld->strVal) ;    
  943. X        else if (fldType == INT)
  944. X            sprintf (fldWrk, "%d", *Fld->intVal) ;
  945. X        else if (fldType == SHORT)
  946. X            sprintf (fldWrk, "%d", *Fld->shortVal) ;
  947. X        else if (fldType == LONG)
  948. X            sprintf (fldWrk, "%ld", *Fld->longVal) ;
  949. X        else if (fldType == FLOAT)
  950. X            sprintf (fldWrk, "%f", *Fld->floatVal) ;
  951. X        else if (fldType == DOUBLE)
  952. X            sprintf (fldWrk, "%g", *Fld->doubleVal) ;
  953. X        else if (fldType == MONEY) {
  954. X            sprintf (fldWrk, "%g", *Fld->doubleVal) ;
  955. X            i = strlen(fldWrk) - 1 ;
  956. X            wrk = fldWrk ;
  957. X            while(*wrk != '.'   &&   *wrk != '\0')
  958. X                wrk++ ;
  959. X            if(*wrk == '\0')
  960. X                strcat(fldWrk, ".00") ;
  961. X            else {
  962. X                wrk++ ;
  963. X                j = 0 ;
  964. X                while(*wrk++ != '\0')
  965. X                    j++ ;
  966. X
  967. X                if(j == 0)
  968. X                    strcat(fldWrk, "00") ;
  969. X                else if(j == 1)
  970. X                    strcat(fldWrk, "0") ;
  971. X            }
  972. X        }
  973. X
  974. X        if (fldAdjust == NOFILL)
  975. X            strcpy (fldStr, fldWrk) ;
  976. X        else if (fldAdjust == LFADJ_BFILL  || fldAdjust == LFADJ_ZFILL){
  977. X            strcpy (fldStr, fldWrk) ;
  978. X
  979. X            for (i = strlen(fldStr) ; i < fldLength ; i++)
  980. X                fldStr[i] = (fldAdjust == LFADJ_ZFILL) ? '0' : ' ' ;
  981. X            fldStr[fldLength] = '\0' ;
  982. X        } else if (fldAdjust == RTADJ_BFILL  || fldAdjust == RTADJ_ZFILL) {
  983. X
  984. X            for (i = 0 ; i < fldLength - strlen(fldWrk) ; i++)
  985. X                fldStr[i] = (fldAdjust == RTADJ_ZFILL) ? '0' : ' ' ;
  986. X            fldStr[fldLength - strlen(fldWrk)] = '\0' ;
  987. X            strcat (fldStr, fldWrk) ;
  988. X        }
  989. X
  990. X        free (fldWrk) ;
  991. X            
  992. X    }
  993. X    wattrset (win, fldAttrib) ;
  994. X
  995. X    col = colStart ;
  996. X
  997. X    do { 
  998. X        if (fldMask == NULL) {
  999. X            *charKeyed++ = (initFld) ? 'Y' : 'N' ;
  1000. X            waddch(win, *fldStr++) ;
  1001. X        } else if (fldCharType != DATE  &&  fldCharType != TIME) {
  1002. X            /*
  1003. X            if(*(fldMask + col - colStart)  ==  ' ')
  1004. X                *(fldMask + col - colStart)  =  fldCharType ;
  1005. X            */
  1006. X            if(IsMask(fldCharType, *(fldMask + col - colStart))) {
  1007. X                *charKeyed++ = 'M' ;
  1008. X                waddch(win, *(fldMask + col - colStart) );
  1009. X            } else {
  1010. X                *charKeyed++ = (initFld) ? 'Y' : 'N' ;
  1011. X                waddch(win, *fldStr++) ;
  1012. X            }
  1013. X        } else {
  1014. X            if( (fldCharType == DATE  &&  
  1015. X                (ch = *(fldMask + col - colStart)) == 'M'  ||
  1016. X                    ch == 'D'  ||  ch == 'Y') ||
  1017. X                (fldCharType == TIME  &&  
  1018. X                (ch = *(fldMask + col - colStart)) == 'I'  ||
  1019. X                    ch == 'H'  ||  ch == 'M'  ||  
  1020. X                    ch == 'S'  ||  ch == 'T')) {
  1021. X                *charKeyed++ = (initFld) ? 'Y' : 'N' ;
  1022. X                waddch(win, *fldStr++) ;
  1023. X            } else {
  1024. X                *charKeyed++ = 'M' ;
  1025. X                waddch(win, *(fldMask + col - colStart) );
  1026. X            }
  1027. X        }
  1028. X        col++ ;
  1029. X    } while (*fldStr != '\0'  &&  col < colEnd) ;
  1030. X
  1031. X    while(col < colEnd) {
  1032. X        if (fldMask == NULL) {
  1033. X            *charKeyed++ = 'N' ;
  1034. X            waddch(win, ' ') ;
  1035. X        } else if (fldCharType != DATE  &&  fldCharType != TIME) {
  1036. X            if(*(fldMask + col - colStart)  ==  ' ')
  1037. X                *(fldMask + col - colStart)  =  fldCharType ;
  1038. X            if(IsMask(fldCharType, *(fldMask + col - colStart))) {
  1039. X                *charKeyed++ = 'M' ;
  1040. X                waddch(win, *(fldMask + col - colStart) );
  1041. X            } else {
  1042. X                *charKeyed++ = 'N' ;
  1043. X                waddch(win, ' ') ;
  1044. X            }
  1045. X        } else {
  1046. X            if( (fldCharType == DATE  &&  
  1047. X                (ch = *(fldMask + col - colStart)) == 'M'  ||
  1048. X                    ch == 'D'  ||  ch == 'Y') ||
  1049. X                (fldCharType == TIME  &&  
  1050. X                (ch = *(fldMask + col - colStart)) == 'I'  ||
  1051. X                    ch == 'H'  ||  ch == 'M'  ||  
  1052. X                    ch == 'S'  ||  ch == 'T')) {
  1053. X                *charKeyed++ = 'N' ;
  1054. X                waddch(win, ' ') ;
  1055. X            } else {
  1056. X                *charKeyed++ = 'M' ;
  1057. X                waddch(win, *(fldMask + col - colStart) );
  1058. X            }
  1059. X        }
  1060. X        col++ ;
  1061. X    }
  1062. X
  1063. X    wattrset (win, 0) ;
  1064. X
  1065. X    return(initFld) ;
  1066. X
  1067. X}
  1068. SHAR_EOF
  1069. chmod 0644 utilities.d/libgeti.d/DisPrmpt.c || echo "restore of utilities.d/libgeti.d/DisPrmpt.c fails"
  1070. echo "x - extracting utilities.d/libgeti.d/FindSet.c (Text)"
  1071. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/FindSet.c &&
  1072. X#ifndef LINT
  1073. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1074. X#endif
  1075. X
  1076. X#include    <stdio.h>
  1077. X
  1078. X/*
  1079. X**  FindSet()
  1080. X**        Determines if the value loaded into Fld is a member of the set.
  1081. X**  RETURNS:
  1082. X**        -1    not a element of the set
  1083. X**        eNum    otherwise returns the element number (base 0)
  1084. X*/
  1085. X
  1086. X#include    "GetInput.h"
  1087. X
  1088. X
  1089. XFindSet(Fld, fldRange, fldLength, fldType)
  1090. X    FldUnPointer    Fld ;
  1091. X    char        *fldRange ;
  1092. X    int        fldLength ;
  1093. X    char        fldType ;
  1094. X{
  1095. X    char        *upper();
  1096. X    char        *a,
  1097. X            *b,
  1098. X            *fldCmp ;
  1099. X
  1100. X    char        *malloc();
  1101. X
  1102. X    int    eNum,                /* element number matched */
  1103. X        gotAmatch ;
  1104. X
  1105. X    gotAmatch = 0 ;
  1106. X
  1107. X    eNum = 0 ;
  1108. X
  1109. X    fldCmp = malloc(fldLength+10);
  1110. X
  1111. X    a = fldRange ;
  1112. X
  1113. X    while(*a != '\0') {
  1114. X
  1115. X        b = fldCmp ;
  1116. X
  1117. X        while(*a != ','  &&  *a != '\0')
  1118. X        /* load the next element into fldCmp */
  1119. X            *b++ = *a++ ;
  1120. X
  1121. X        *b = '\0' ;
  1122. X
  1123. X        switch(fldType) {
  1124. X            case CHAR:
  1125. X            case DATE:
  1126. X            case TIME:
  1127. X                if(strncmp(upper(fldCmp), upper(Fld->strVal), strlen(Fld->strVal)) == 0)
  1128. X                    gotAmatch = 1 ;
  1129. X                break ;
  1130. X            case INT:
  1131. X                if(*Fld->intVal == atoi(fldCmp))
  1132. X                    gotAmatch = 1 ;
  1133. X                break ;
  1134. X            case SHORT:
  1135. X                if(*Fld->shortVal == atoi(fldCmp))
  1136. X                    gotAmatch = 1 ;
  1137. X                break ;
  1138. X            case LONG:
  1139. X                if(*Fld->longVal == atoi(fldCmp))
  1140. X                    gotAmatch = 1 ;
  1141. X                break ;
  1142. X            case FLOAT:
  1143. X                if(*Fld->floatVal == atof(fldCmp))
  1144. X                    gotAmatch = 1 ;
  1145. X                break ;
  1146. X            case DOUBLE:
  1147. X                if(*Fld->doubleVal == atof(fldCmp))
  1148. X                    gotAmatch = 1 ;
  1149. X                break ;
  1150. X        }
  1151. X
  1152. X        if(gotAmatch)
  1153. X            break ;
  1154. X
  1155. X        eNum++ ;
  1156. X
  1157. X        while(*a == ','  ||  *a == ' '  ||  *a == '\t')
  1158. X            a++ ;
  1159. X    }
  1160. X
  1161. X    free(fldCmp) ;
  1162. X
  1163. X    if(gotAmatch)
  1164. X        return(eNum) ;
  1165. X    else
  1166. X        return (-1) ;
  1167. X}
  1168. SHAR_EOF
  1169. chmod 0644 utilities.d/libgeti.d/FindSet.c || echo "restore of utilities.d/libgeti.d/FindSet.c fails"
  1170. echo "x - extracting utilities.d/libgeti.d/GetInput.c (Text)"
  1171. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.c &&
  1172. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1173. X
  1174. X#include     <curses.h>
  1175. X#include     <ctype.h>
  1176. X#include    "keys.h"
  1177. X#include     "GetInput.h"
  1178. X
  1179. X#define    MAXITEMS    200
  1180. X#define    NEWMENU        0
  1181. X
  1182. Xint    insertmode = FALSE;
  1183. X
  1184. X
  1185. XGetInput (win, rowStart, colStart, Fld, fldAttrib, fldMask, fldRange, fldLength,
  1186. X    fldMin, fldCharType, fldAdjust, fldType, keyStream, mustEnter, 
  1187. X    fldErrRow, fldDispRow, helpMsg, helpFile, helpTag)
  1188. X
  1189. X    WINDOW          *win ;          /* Window                */
  1190. X    int           rowStart ;
  1191. X    int           colStart ;
  1192. X    FldUnPointer    Fld ;        /* Pointer to union for field     */
  1193. X    int           fldAttrib ;     /* Curses attribute         */
  1194. X    char          *fldMask ;      /* mask for character string      */
  1195. X    char          *fldRange ;     /* range of valid values for output */
  1196. X    int           fldLength;     /* Maximum length of output       */
  1197. X    int           fldMin;     /* Minimum length of output       */
  1198. X    char          fldCharType;    /* type of character           */
  1199. X    char          fldAdjust ;     /* adjust/fill field           */
  1200. X    char          fldType ;       /* type of field         */
  1201. X    int           keyStream ;     /* if TRUE then the function will
  1202. X                                 exit when the last character is
  1203. X                                 keyed           */
  1204. X    int           mustEnter ;     /* boolean   */
  1205. X    int           fldErrRow ;     /* where to display error message   */
  1206. X    int           fldDispRow ;       /* where to display help message    */
  1207. X    char          *helpMsg ;      /* help message             */
  1208. X    char          helpFile[] ;       /* help file name        */
  1209. X    char          helpTag[] ;     /* tag where help begins       */
  1210. X{
  1211. X       int    colEnd ;        /* column end of field */
  1212. X       int       row ;           /* working row field */
  1213. X       int       col ;           /* working column field */
  1214. X       int       colSave ;          /* working column field */
  1215. X       int       colMove ;          /* working col field for adjusting routines */
  1216. X       int       colBegInput;    /* column where input begins */
  1217. X       int       ch ;            /* contains character keyed or being moved */
  1218. X       int       notFinished ;   /* bool indicator that indicates when the user 
  1219. X                    is finished with keying in data */
  1220. X       int       setNumb ;       /* number to be returned showing which 
  1221. X                    selection the user chose */
  1222. X       int       controlKey ;    /* if not 0 then the user hit a control key */
  1223. X       int       bytesKeyed ;    /* how many bytes were keyed */
  1224. X       int       initFld ;       /* indicate if field was initialized going into 
  1225. X                                      this routine */
  1226. X       char      *fldStr ;       /* buffer that will contain output  */
  1227. X       char      *charKeyed ;    /* characters keyed by the user Y/N */
  1228. X                /*
  1229. X                **  charKeyd indicates how many characters
  1230. X                **  has been keyed in.  A "Y" in the position
  1231. X                **  indicates that the user has keyed a char
  1232. X                **  at that position, otherwise it will be "N"
  1233. X                **  or a "M" for a mask format character.
  1234. X                */
  1235. X       char      *fldWrk ;       /* working field */
  1236. X       int       origAttr[80] ;  /* original field attributes */
  1237. X       char      *malloc();
  1238. X    int    i;
  1239. X    int    junk;        /* use for anything */
  1240. X    char    menu[MAXITEMS+2][80];    /* popmenu items */
  1241. X    int    menuid;
  1242. X
  1243. X
  1244. X
  1245. X
  1246. X
  1247. X    if (fldCharType == PROTECT)
  1248. X    {
  1249. X        /* X out the field */
  1250. X        for (i = 0; i < fldLength; i++)
  1251. X            Fld->strVal[i] = 'X';
  1252. X        Fld->strVal[i] = '\0';
  1253. X    }
  1254. X
  1255. X       /*
  1256. X    ** bug fix  -  pjc  08/26/86
  1257. X    ** bytesKeyed = 0
  1258. X    */
  1259. X       setNumb = controlKey = bytesKeyed = 0;
  1260. X
  1261. X    /* find length of field from the values in fldRange */
  1262. X       if (fldCharType == SET  ||  fldCharType == MENU)
  1263. X              fldLength = GetSetLen(fldRange);
  1264. X
  1265. X       /*
  1266. X       ** pjc - 11/88
  1267. X       ** This allows you to pass "" 
  1268. X       */
  1269. X    if (fldRange != NORANGE  &&  strcmp(fldRange, "") == 0)
  1270. X        fldRange = NORANGE;
  1271. X
  1272. X       if (fldMask != NOMASK  &&  strcmp(fldMask, "") == 0)
  1273. X        fldMask = NOMASK;
  1274. X       if (fldMask == NOMASK) 
  1275. X       {
  1276. X              colEnd    = colStart + fldLength ;
  1277. X              fldStr    = malloc(fldLength + 10);
  1278. X              charKeyed = malloc(fldLength + 10);
  1279. X       } 
  1280. X       else 
  1281. X       {
  1282. X              colEnd    = colStart + strlen(fldMask) ;
  1283. X              fldStr    = malloc(strlen(fldMask) + 10);
  1284. X              charKeyed = malloc(strlen(fldMask) + 10);
  1285. X       }
  1286. X
  1287. X    /*
  1288. X    **    Save original terminal attributes.
  1289. X    */
  1290. X       for (col = colStart; col < colEnd; col++)
  1291. X              origAttr[col - colStart] = mvwinch(win, rowStart, col) & 
  1292. X                        A_ATTRIBUTES ;
  1293. X
  1294. X    /* so a message you put on that line doesn't get erased */
  1295. X    if (helpMsg == NOMSG || strcmp (helpMsg, "DONT_CLEAR") == 0)
  1296. X        helpMsg = NOMSG;
  1297. X    else
  1298. X        CLEARROW (fldDispRow);
  1299. X
  1300. X       /*
  1301. X    ** bug fix     pjc  8/22/86
  1302. X    ** test for NOMSG
  1303. X    ** Display help message.
  1304. X    */
  1305. X       if (helpMsg != NOMSG) 
  1306. X       {
  1307. X              /* pjc 7/87 - clrtoeol for new message 
  1308. X              */
  1309. X              /* pjc 11/88 - 
  1310. X              **    change helpMsg to always display to standard screen.
  1311. X              **    That way popup screens will work right.
  1312. X        **    Display message between col 1 to COLS-1 ... so that
  1313. X        **    it will work with a box border.
  1314. X              */
  1315. X
  1316. X              mvwaddstr (stdscr,
  1317. X        ((fldDispRow%100) == fldDispRow) ? fldDispRow : fldDispRow/100, 
  1318. X        ((fldDispRow%100) == fldDispRow) ? 0 : fldDispRow%100, 
  1319. X            helpMsg) ;
  1320. X              wnoutrefresh (stdscr);
  1321. X       }
  1322. X
  1323. X    /*
  1324. X       **    pjc 9/87
  1325. X       **    Added new attributes
  1326. X       **    If A_SAME then use the attributes that is showing
  1327. X       **    on the screen in that position.
  1328. X    **    As you see it is determined from first column.
  1329. X       */
  1330. X       if (fldAttrib == A_SAME)
  1331. X              fldAttrib = origAttr[0];
  1332. X
  1333. X       wmove(win, rowStart, colStart) ;
  1334. X       if (fldCharType == SET  ||  fldCharType == MENU) 
  1335. X       {
  1336. X              setNumb = FindSet(Fld, fldRange, fldLength, fldType) ;
  1337. X              ShowSet(win, rowStart, colStart, fldAttrib, fldRange, 
  1338. X            fldLength, &setNumb, colEnd, charKeyed, origAttr) ;
  1339. X        if (fldCharType == MENU)
  1340. X        {
  1341. X            char    menustrid[10];
  1342. X            int    mrow;
  1343. X            int    mcol;
  1344. X            int    numitems;
  1345. X
  1346. X            /* make a unique menuid from the row & column */
  1347. X            sprintf (menustrid, "%2d%2d", rowStart, colStart);
  1348. X            menuid = atoi (menustrid);
  1349. X
  1350. X            numitems = BuildMenu (menu, fldRange);
  1351. X            if (numitems == 0)
  1352. X                return (0);
  1353. X
  1354. X            /* try to put menu as close to the field as possible */
  1355. X            if ((rowStart + win->_begy) > 0)
  1356. X                mrow = rowStart + win->_begy - 1;
  1357. X            else
  1358. X                mrow = 0;
  1359. X            /* off the edge of the screen ? */
  1360. X            if ((colEnd + fldLength + 4) + win->_begx > COLS)
  1361. X            {
  1362. X                mcol = COLS - fldLength + 4;
  1363. X                mrow += 2;
  1364. X            }
  1365. X            else
  1366. X                mcol = colEnd + win->_begx;
  1367. X
  1368. X            if (mrow > 0  &&  numitems > (LINES - mrow - 2))
  1369. X            {
  1370. X                mrow = ((mrow-(numitems-(LINES-mrow-2))) > 0) 
  1371. X                    ? (mrow-(numitems-(LINES-mrow-2))) : 0;
  1372. X            }
  1373. X
  1374. X            popmenu (NEWMENU, menuid, mrow, mcol, "", 
  1375. X                helpFile, LINES-mrow-2, sizeof(menu[0]), menu);
  1376. X        }
  1377. X       } 
  1378. X       else
  1379. X        /*
  1380. X        **    FALSE if Fld->strval == '\0'
  1381. X        **    TRUE  if Fld contained a default value.
  1382. X        */
  1383. X              initFld = DisPrmpt(win, Fld, fldAttrib, fldMask, fldLength, 
  1384. X                fldCharType, fldAdjust, fldType, colStart, 
  1385. X                colEnd, fldStr, charKeyed) ;
  1386. X
  1387. X
  1388. X
  1389. X    /* 
  1390. X    ** find the first column where there is not a mask(M) character 
  1391. X    ** This is the column where we begin the input.
  1392. X    */
  1393. X       col = colStart ;
  1394. X       fldWrk = charKeyed ;
  1395. X    /*
  1396. X    **  fldWrk - M = mask character, N = no mask character
  1397. X    */
  1398. X       while (col != colEnd  &&  *fldWrk++ == 'M')
  1399. X              col++;
  1400. X
  1401. X       colBegInput = col ;
  1402. X       wmove(win, rowStart, col) ;
  1403. X       notFinished = TRUE ;
  1404. X
  1405. X
  1406. X    if (fldCharType == PROTECT)
  1407. X    {
  1408. X        /* Password entry field */
  1409. X        wattrset (win, A_REVERSE);
  1410. X        strcpy (Fld->strVal, "");
  1411. X        free (fldStr);
  1412. X        free (charKeyed);
  1413. X        row = rowStart;
  1414. X        col = colStart;
  1415. X        fldStr = Fld->strVal;
  1416. X        *fldStr = '\0';
  1417. X        do
  1418. X        {
  1419. X            wmove (win, row, col);
  1420. X            wnoutrefresh (win);
  1421. X            doupdate ();
  1422. X            ch = wgetch (win);
  1423. X            if (ch == KeyHelp || ch == KEY_HELP)
  1424. X            {
  1425. X                ShowHelp (helpFile, helpTag, fldErrRow);
  1426. X                touchwin (win);
  1427. X                wnoutrefresh (win);
  1428. X            }
  1429. X        } while (ch == KeyHelp || ch == KEY_HELP);
  1430. X        *fldStr = (char)ch;
  1431. X        while (*fldStr != '\r')
  1432. X        {
  1433. X            if (col > colStart + fldLength - 1)
  1434. X                beep ();
  1435. X            else
  1436. X            {
  1437. X                addch ('X');
  1438. X                fldStr++;
  1439. X                col++;
  1440. X            }
  1441. X            wmove (win, row, col);
  1442. X            wnoutrefresh (win);
  1443. X            doupdate ();
  1444. X            ch = wgetch (win);
  1445. X            if (ch == KeyHelp || ch == KEY_HELP)
  1446. X            {
  1447. X                ShowHelp (helpFile, helpTag, fldErrRow);
  1448. X                touchwin (win);
  1449. X                wnoutrefresh (win);
  1450. X            }
  1451. X            else
  1452. X                *fldStr = (char)ch;
  1453. X        }
  1454. X        *fldStr = '\0';
  1455. X        wattrset (win, A_NORMAL);
  1456. X        return ((int)'\r');
  1457. X    }
  1458. X
  1459. X
  1460. X       while (TRUE) 
  1461. X       {
  1462. X              do 
  1463. X              {
  1464. X             /* pjc 11/88 for message and errors to stdscr */
  1465. X             wnoutrefresh (stdscr);
  1466. X                 wnoutrefresh(win) ;
  1467. X             doupdate ();
  1468. X
  1469. X                 getyx(win, row, col) ;
  1470. X
  1471. X               controlKey = 0;
  1472. X                 ch = wgetch(win);
  1473. X
  1474. X            CLEARROW (fldErrRow);
  1475. X               if (helpMsg != NOMSG) 
  1476. X               {
  1477. X                      mvwaddstr (stdscr,
  1478. X        ((fldDispRow%100) == fldDispRow) ? fldDispRow : fldDispRow/100, 
  1479. X        ((fldDispRow%100) == fldDispRow) ? 0 : fldDispRow%100, 
  1480. X                    helpMsg) ;
  1481. X               }
  1482. X
  1483. X               wmove(win, row, col) ;
  1484. X
  1485. X            /* these keys accept the input before returning */
  1486. X            if (ch == KeyReturn)    ch = KEY_RETURN;
  1487. X            if (ch == KeyDown)    ch = KEY_DOWN;
  1488. X            if (ch == KeyUp)    ch = KEY_UP;
  1489. X            if (ch == KeyTab)    ch = KEY_TAB;
  1490. X            if (ch == KeyBTab)    ch = KEY_BTAB;
  1491. X            if (ch == KeyAccept)    ch = KEY_ACCEPT;
  1492. X
  1493. X            /* other keys */
  1494. X            if (ch == KeyHelp)    ch = KEY_HELP;
  1495. X            if (ch == KeyRedraw)    ch = KEY_REFRESH;
  1496. X            if (ch == KeyLeft)    ch = KEY_LEFT;
  1497. X            if (ch == KeyRight)    ch = KEY_RIGHT;
  1498. X            if (ch == KeyEOL)    ch = KEY_EOL;
  1499. X            if (ch == KeyDL)    ch = KEY_DL;
  1500. X            if (ch == KeyDC)    ch = KEY_DC;
  1501. X            if (ch == KeyIC)    ch = KEY_IC;
  1502. X            if (ch == KeySave)    ch = KEY_SAVE;
  1503. X            if (ch == KeyPrint)    ch = KEY_PRINT;
  1504. X            if (ch == KeyBeg)    ch = KEY_BEG;
  1505. X            if (ch == KeyEnd)    ch = KEY_END;
  1506. X            if (ch == KeyCancel)    ch = KEY_CANCEL;
  1507. X
  1508. X            switch (ch)
  1509. X            {
  1510. X               case KEY_BEG:
  1511. X                /* place cursor at beg of field */
  1512. X                col = colStart;
  1513. X                          wmove(win, rowStart, col) ;
  1514. X                break;
  1515. X
  1516. X               case KEY_END:
  1517. X                /* place cursor at end of input */
  1518. X                col = colEnd;
  1519. X                junk = colEnd;
  1520. X                while (col >= colStart)
  1521. X                {
  1522. X                    if (*(charKeyed+col-colStart) == 'N')
  1523. X                        junk = col;
  1524. X                    if (*(charKeyed+col-colStart) == 'Y')
  1525. X                        break;
  1526. X                    col--;
  1527. X                }
  1528. X                col = junk;
  1529. X                          wmove(win, rowStart, col) ;
  1530. X                break;
  1531. X
  1532. X               case KEY_HELP:
  1533. X                ShowHelp (helpFile, helpTag, fldErrRow);
  1534. X                touchwin (win);
  1535. X                wnoutrefresh (win);
  1536. X                continue;
  1537. X
  1538. X               case KEY_REFRESH:
  1539. X                clearok (win, TRUE);
  1540. X                continue;
  1541. X
  1542. X               case KEY_LEFT:
  1543. X                /* fixme
  1544. X                          if (col > colBegInput)
  1545. X                */
  1546. X                          if (col > colStart)
  1547. X                                 col--;
  1548. X                          else
  1549. X                                 BELL;
  1550. X                          while (col > colStart  &&  
  1551. X                       *(charKeyed + col - colStart) == 'M')
  1552. X                                 --col ;
  1553. X                          while (*(charKeyed + col - colStart) == 'M')
  1554. X                                 col++;
  1555. X                          wmove(win, rowStart, col) ;
  1556. X                continue;
  1557. X
  1558. X               case KEY_RIGHT:
  1559. X                             if (col < colEnd - 1  &&
  1560. X                              (*(charKeyed + col - colStart) == 'Y' || 
  1561. X                      *(charKeyed + col - colStart) == 'M' ) )
  1562. X                                col++;
  1563. X                             else
  1564. X                                BELL;
  1565. X                             while (col < colEnd  &&  
  1566. X                       *(charKeyed + col - colStart) == 'M')
  1567. X                                 col++;
  1568. X                             while (*(charKeyed + col - colStart) == 'M')
  1569. X                                col--;
  1570. X                             wmove(win, rowStart, col) ;
  1571. SHAR_EOF
  1572. echo "End of part 8"
  1573. echo "File utilities.d/libgeti.d/GetInput.c is continued in part 9"
  1574. echo "9" > s2_seq_.tmp
  1575. exit 0
  1576.