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