menu(1) part 9 of 14
Paul J. Condie
pjc at pcbox.UUCP
Thu Dec 27 07:12:07 AEST 1990
#!/bin/sh
# this is part 9 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/GetInput.c continued
#
CurArch=9
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
exit 1; fi
( read Scheck
if test "$Scheck" != $CurArch
then echo "Please unpack part $Scheck next!"
exit 1;
else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file utilities.d/libgeti.d/GetInput.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/GetInput.c
X break;
X
X case KEY_EOL:
X /*
X ** Clear from cursor to end of field.
X */
X if (col == colBegInput)
X {
X initFld = FALSE ;
X bytesKeyed = 0;
X }
X colSave = col ;
X fldWrk = fldStr ;
X col = colStart ;
X while (col < colSave)
X {
X if (*(charKeyed + col - colStart)=='Y')
X *fldWrk++ = mvwinch(win, row,
X col) & A_CHARTEXT ;
X col++;
X }
X *fldWrk = '\0' ;
X
X col = colSave ;
X while (col < colEnd)
X {
X if (*(charKeyed + col-colStart) != 'M')
X *(charKeyed + col-colStart)='N';
X col++;
X }
X ReDispFld(win, rowStart, colStart, fldAttrib,
X fldMask, fldRange, fldLength,
X fldCharType, fldType,
X fldStr, colEnd, charKeyed, 0, origAttr);
X
X wmove(win, rowStart, colSave) ;
X break;
X
X case KEY_DL:
X /*
X ** Clear field and home cursor.
X */
X if (col == colBegInput)
X initFld = FALSE ;
X fldWrk = fldStr ;
X *fldWrk = '\0' ;
X
X col = colStart ;
X /* check for a mask character */
X while (col < colEnd)
X {
X if (*(charKeyed + col-colStart) != 'M')
X *(charKeyed + col-colStart)='N';
X col++;
X }
X /* redisplay field */
X ReDispFld(win, rowStart, colStart, fldAttrib,
X fldMask, fldRange, fldLength,
X fldCharType, fldType,
X fldStr, colEnd, charKeyed, 0, origAttr);
X
X col = colBegInput;
X wmove(win, rowStart, col) ;
X bytesKeyed = 0;
X break;
X
X case KEY_DC:
X /*
X ** pjc 11/88
X ** Delete character at cursor.
X */
X
X /*
X ** no can do for SET, MENU or
X ** cursor past end of input or
X ** cursor past end of field
X */
X if (fldCharType == SET || fldCharType == MENU ||
X *(charKeyed+col-colStart) == 'N' ||
X col >= colEnd)
X break;
X colSave = col; /* cursor location */
X
X /* get field content & delete char */
X col = colStart;
X fldWrk = fldStr;
X while (col < colEnd)
X {
X if (col == colSave)
X col++; /* delete char */
X if (*(charKeyed+col-colStart) == 'Y')
X *fldWrk++ = mvwinch(win, row,
X col) & A_CHARTEXT ;
X col++;
X }
X *fldWrk = '\0';
X
X /* validate new field against the mask */
X if (fldMask != NOMASK)
X {
X junk = 0;
X /* fldWrk - fldWrk, col - charKeyed */
X for (fldWrk = fldStr, col = colStart;
X col < colEnd && *fldWrk != '\0';
X col++)
X {
X /* only check shifted chars */
X if (col < colSave ||
X *(charKeyed+col-colStart) == 'M')
X {
X if (*(charKeyed+col-colStart) == 'Y')
X fldWrk++;
X continue;
X }
X
X junk = checkmask (col, colStart,
X fldMask, fldCharType,
X fldType, *fldWrk);
X
X if (junk == -1)
X break;
X *fldWrk++ = junk;
X junk = 0;
X } /* end for */
X if (junk == -1)
X {
X CLEARROW (fldErrRow);
X wattrOn (stdscr,
X A_REVERSE|A_BOLD);
X mvwaddstr(stdscr,
X ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100,
X ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100,
X "Unable to delete character due to edits.");
X wattrOff (stdscr);
X BELL;
X col = colSave;
X wmove (win, rowStart, colSave);
X break;
X }
X }
X
X /* set last Y in charKeyd to N */
X col = colEnd;
X while (col >= colStart)
X {
X if (*(charKeyed+col-colStart) == 'Y')
X {
X *(charKeyed+col-colStart) = 'N';
X break;
X }
X col--;
X }
X
X
X ReDispFld(win, rowStart, colStart, fldAttrib,
X fldMask, fldRange, fldLength,
X fldCharType, fldType,
X fldStr, colEnd, charKeyed, 0, origAttr);
X
X col = colSave;
X wmove (win, rowStart, colSave);
X break;
X
X case KEY_IC:
X /*
X ** Toggle between typeover/insert mode.
X */
X insertmode = (insertmode) ? FALSE : TRUE;
X break;
X
X case KEY_SAVE:
X ScrnFile(win, LINES, COLS) ;
X clearok(win, TRUE) ;
X wmove(win, row, col) ;
X break;
X
X case KEY_PRINT:
X ScrnPrnt(win, LINES, COLS, fldErrRow) ;
X clearok(win, TRUE);
X wmove(win, row, col) ;
X continue ;
X
X case KEY_BACKSPACE:
X if (col > colStart)
X {
X wattrset(win, fldAttrib) ;
X mvwaddch(win, rowStart, --col, ' ') ;
X wattrset(win, 0) ;
X wmove(win, rowStart, col) ;
X }
X else
X BELL;
X break ;
X
X case KEY_RETURN:
X case KEY_ENTER:
X case KEY_DOWN:
X case KEY_UP:
X case KEY_TAB:
X case KEY_BTAB:
X case KEY_ACCEPT:
X /*
X ** bug fix - 9/26/86 pjc
X ** if (col == colend) byteskeyed was not
X ** being counted.
X ** Determine number of bytes keyed by user.
X */
X bytesKeyed = 0;
X for (i = 0; i < strlen (charKeyed); i++)
X if (charKeyed[i] == 'Y')
X bytesKeyed++;
X
X if (fldCharType == SET || fldCharType == MENU)
X {
X col = colEnd ;
X wmove(win, rowStart, col) ;
X notFinished = FALSE ;
X break ;
X }
X
X if (col == colEnd)
X {
X notFinished = FALSE;
X break;
X }
X
X if (initFld)
X {
X col = colEnd - 1 ;
X while (*(charKeyed+col-colStart) != 'Y')
X col--;
X wmove(win, rowStart, col) ;
X }
X
X colMove = colStart ;
X bytesKeyed = 0 ;
X while (colMove < colEnd)
X {
X if (*(charKeyed+colMove-colStart)=='Y')
X {
X col = colMove ;
X bytesKeyed++;
X }
X colMove++;
X }
X while (*(charKeyed + ++col - colStart) == 'M')
X ;
X wmove(win, rowStart, col) ;
X
X if (bytesKeyed == 0 && mustEnter)
X {
X BELL;
X CLEARROW (fldErrRow);
X wattrOn (stdscr, A_REVERSE|A_BOLD);
X mvwaddstr(stdscr,
X ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100,
X ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100,
X "This is a must enter field.") ;
X wattrOff (stdscr);
X wmove(win, rowStart, colStart) ;
X break ;
X }
X
X if (fldMin > 0 && bytesKeyed > 0 &&
X bytesKeyed < fldMin)
X {
X
X BELL;
X CLEARROW (fldErrRow);
X wattrOn (stdscr, A_REVERSE|A_BOLD);
X mvwprintw(stdscr, fldErrRow, 1,
X "The minimum length for this field is: %d keyed %d",
X fldMin, bytesKeyed) ;
X wattrOff (stdscr);
X wmove(win, rowStart, col) ;
X break ;
X }
X
X if (fldAdjust != NOFILL)
X AdjField(win, rowStart, colStart,
X fldAttrib, fldAdjust, colEnd,
X charKeyed) ;
X
X notFinished = FALSE ;
X break ;
X
X default:
X /* check for control character */
X if (ch < 32 || ch > 127)
X {
X int ch1 ;
X
X
X notFinished = FALSE ;
X wmove(win, rowStart, colEnd) ;
X controlKey = ch ;
X break;
X }
X
X if (fldCharType == SET)
X {
X if (fldType == CHAR)
X {
X /* pjc - 7/87
X ** match ch to the first char
X ** in set values
X */
X int rc; /* return code */
X
X Fld->strVal[0] = ch;
X Fld->strVal[1] = '\0';
X rc = FindSet(Fld, fldRange,
X fldLength, fldType);
X setNumb = rc == -1 ? ++setNumb : rc;
X }
X else
X setNumb++;
X
X ShowSet(win, rowStart, colStart,
X fldAttrib, fldRange, fldLength,
X &setNumb, colEnd, charKeyed,
X origAttr) ;
X wmove(win, rowStart, colStart);
X break;
X }
X
X if (fldCharType == MENU)
X {
X char tmpStr[2];
X
X tmpStr[0] = ch;
X tmpStr[1] = (char)NULL;
X junk = popmenu (menuid, tmpStr);
X setNumb = junk >= 1 ? junk-1 : setNumb;
X strcpy (Fld->strVal, menu[setNumb]);
X ShowSet(win, rowStart, colStart,
X fldAttrib, fldRange, fldLength,
X &setNumb, colEnd, charKeyed,
X origAttr) ;
X wmove(win, rowStart, colStart);
X touchwin (stdscr);
X touchwin (win);
X if (junk >= 1)
X notFinished = FALSE ;
X break;
X }
X
X if (col == colEnd)
X BELL;
X else
X notFinished = ShowChar (win, rowStart,
X colStart, fldAttrib, fldMask,
X fldRange, fldLength,
X fldCharType, fldDispRow,
X fldType, keyStream, fldErrRow,
X charKeyed,colEnd, &ch,origAttr);
X break ;
X
X } /* end switch */
X } while (notFinished) ;
X
X if ( controlKey && bytesKeyed == 0)
X {
X ReDispFld(win, rowStart, colStart, -1, fldMask,
X fldRange, fldLength, fldCharType, fldType,
X fldStr, colEnd, charKeyed, setNumb,
X origAttr) ;
X break ;
X }
X else
X {
X if ( IsFldOk(win, rowStart, colStart, Fld, fldMask,
X fldRange, fldLength, fldCharType, fldType,
X mustEnter, fldErrRow, fldDispRow, colEnd,
X fldStr, charKeyed, setNumb, origAttr) )
X {
X break ;
X }
X else
X {
X notFinished = TRUE ;
X continue ;
X }
X }
X
X } /* end while (TRUE) */
X
X free(fldStr) ;
X free(charKeyed) ;
X
X return (ch);
X}
SHAR_EOF
echo "File utilities.d/libgeti.d/GetInput.c is complete"
chmod 0644 utilities.d/libgeti.d/GetInput.c || echo "restore of utilities.d/libgeti.d/GetInput.c fails"
echo "x - extracting utilities.d/libgeti.d/GetSetLen.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetSetLen.c &&
Xstatic char Sccsid[] = "@(#)GetSetLen.c 1.3 DeltaDate 1/22/90 ExtrDate 1/22/90";
X
X/*
X** GetSetLen()
X** Determines the length of the longest element in the set (range).
X** ex. "HI,LOW,MEDIUM" returns (6) as the longest length.
X** This information is used to determine how much memory I need to allocate
X** to hold the element. Does not include a null terminator.
X**
X** RETURNS:
X** length of the longest element in set.
X*/
X
X#include "GetInput.h"
X
XGetSetLen(fldRange)
X char *fldRange ; /* range of valid values for output */
X{
X int len,
X fldLength ;
X char *fldWrk ;
X
X
X fldLength = 0 ;
X
X fldWrk = fldRange ;
X
X while (*fldWrk != '\0') {
X
X len = 0 ;
X
X while (*fldWrk != ',' && *fldWrk != '\0') {
X len++ ; /* length of this element */
X fldWrk++ ; /* fldRange without this element */
X }
X
X if (len > fldLength) /* is this element longer ? */
X fldLength = len ;
X
X /* set pointer to next element in set */
X while (*fldWrk == ',' || *fldWrk == ' ')
X fldWrk++ ;
X }
X
X return (fldLength) ;
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/GetSetLen.c || echo "restore of utilities.d/libgeti.d/GetSetLen.c fails"
echo "x - extracting utilities.d/libgeti.d/InitGetI.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/InitGetI.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
X#endif
X
X/*
X** InitGetI()
X*/
X
X#include <curses.h>
X#include "GetInput.h"
X
X#define MENUINIT ".menuinit" /* menu initialization file */
X#define BUFSIZE 512
X
Xint KeyReturn = '\r';
Xint KeyDown = 10; /* ^j */
Xint KeyUp = 11; /* ^k */
Xint KeyTab = '\t';
Xint KeyBTab = -1;
Xint KeyAccept = 1; /* ^a */
X
Xint KeyBeg = 2;
Xint KeyEnd = 5;
Xint KeyRight = 12; /* ^l */
Xint KeyLeft = 8; /* ^h */
Xint KeyBackspace = '\b'; /* \b */
Xint KeyEOL = 4; /* ^d */
Xint KeyDL = 3; /* ^c */
Xint KeyDC = 24; /* ^x */
Xint KeyIC = 20; /* ^t */
X
Xint KeyHelp = '?';
Xint KeyTOC = 20; /* ^t */
Xint KeyRedraw = 18; /* ^r */
Xint KeySave = 6; /* ^f */
Xint KeyPrint = 16; /* ^p */
Xint KeyCancel = 27; /* esc */
X
X
Xvoid
XInitGetI()
X{
X FILE *fopen(), *menuinit;
X char *getenv();
X char *findfile();
X char *strchr();
X char *ws;
X char filename[100], line[BUFSIZE];
X char *s1;
X
X
X char *terminal;
X
X /*
X ** Parse the .menuinit file
X ** First look in current directory then $HOME then in $MENUDIR
X */
X strcpy (filename, findfile (MENUINIT, ".",
X (char *)getenv("HOME"), (char *)getenv("MENUDIR"), ""));
X if ((menuinit = fopen (filename, "r")) == NULL)
X {
X /* no file found - use the defaults */
X return;
X }
X
X /* set terminal keys */
X while (fgets (line, BUFSIZE, menuinit) != (char *)NULL)
X {
X /*
X if (strncmp ("HOTKEYS", line, 7) == 0)
X HotKeys = 1;
X */
X
X /*
X ** The following keywords require a = sign
X */
X
X if ((s1 = strchr (line, '=')) == (char *)NULL)
X continue;
X
X s1++; /* get past the = */
X
X /* Mover Keys */
X if (strncmp ("KEY_RETURN", line, 10) == 0)
X sscanf (s1, "%d", &KeyReturn);
X else if (strncmp ("KEY_DOWN", line, 8) == 0)
X sscanf (s1, "%d", &KeyDown);
X else if (strncmp ("KEY_UP", line, 6) == 0)
X sscanf (s1, "%d", &KeyUp);
X else if (strncmp ("KEY_TAB", line, 7) == 0)
X sscanf (s1, "%d", &KeyTab);
X else if (strncmp ("KEY_BTAB", line, 8) == 0)
X sscanf (s1, "%d", &KeyBTab);
X
X /* Edit Keys */
X else if (strncmp ("KEY_BEG", line, 7) == 0)
X sscanf (s1, "%d", &KeyBeg);
X else if (strncmp ("KEY_END", line, 7) == 0)
X sscanf (s1, "%d", &KeyEnd);
X else if (strncmp ("KEY_RIGHT", line, 9) == 0)
X sscanf (s1, "%d", &KeyRight);
X else if (strncmp ("KEY_LEFT", line, 8) == 0)
X sscanf (s1, "%d", &KeyLeft);
X else if (strncmp ("KEY_BACKSPACE", line, 13) == 0)
X sscanf (s1, "%d", &KeyBackspace);
X else if (strncmp ("KEY_EOL", line, 13) == 0)
X sscanf (s1, "%d", &KeyEOL);
X else if (strncmp ("KEY_DL", line, 14) == 0)
X sscanf (s1, "%d", &KeyDL);
X else if (strncmp ("KEY_DC", line, 6) == 0)
X sscanf (s1, "%d", &KeyDC);
X else if (strncmp ("KEY_IC", line, 6) == 0)
X sscanf (s1, "%d", &KeyIC);
X
X /* Other Keys */
X else if (strncmp ("KEY_HELP", line, 8) == 0)
X sscanf (s1, "%d", &KeyHelp);
X else if (strncmp ("KEY_REFRESH", line, 10) == 0)
X sscanf (s1, "%d", &KeyRedraw);
X else if (strncmp ("KEY_ACCEPT", line, 10) == 0)
X sscanf (s1, "%d", &KeyAccept);
X else if (strncmp ("KEY_CANCEL", line, 10) == 0)
X sscanf (s1, "%d", &KeyCancel);
X else if (strncmp ("KEY_SAVE", line, 8) == 0)
X sscanf (s1, "%d", &KeySave);
X else if (strncmp ("KEY_PRINT", line, 9) == 0)
X sscanf (s1, "%d", &KeyPrint);
X else if (strncmp ("KEY_TOC", line, 7) == 0)
X sscanf (s1, "%d", &KeyTOC);
X }
X fclose (menuinit);
X return;
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/InitGetI.c || echo "restore of utilities.d/libgeti.d/InitGetI.c fails"
echo "x - extracting utilities.d/libgeti.d/IsDate.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsDate.c &&
Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
X#include <stdio.h>
X#include <time.h>
X#include "GetInput.h"
X
XIsDate (str, mask)
X char *str ;
X char *mask ;
X{
X int year, month, day ;
X
X getmmddyy (str, mask, &month, &day, &year);
X return (valid_date (year, month, day));
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/IsDate.c || echo "restore of utilities.d/libgeti.d/IsDate.c fails"
echo "x - extracting utilities.d/libgeti.d/IsFldOk.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsFldOk.c &&
Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
X
X#include <curses.h>
X#include <ctype.h>
X#include "GetInput.h"
X
X
XIsFldOk (win, row, colStart, Fld, fldMask, fldRange, fldLength, fldCharType,
X fldType, mustEnter, fldErrRow, fldDispRow, colEnd, fldStr, charKeyed,
X setNumb, origAttr)
X
XWINDOW *win ; /* Window */
Xint row ;
Xint colStart ;
XFldUnPointer Fld ; /* Pointer to union for field */
Xchar *fldMask ; /* mask for character string */
Xchar *fldRange ; /* range of valid values for output */
Xunsigned fldLength ; /* Maximum length of output */
Xchar fldCharType ; /* type of character */
Xchar fldType ; /* type of field */
Xint mustEnter ; /* must enter - boolean */
Xint fldErrRow ; /* where to display error message */
Xint fldDispRow ; /* where to display help message */
Xint colEnd ; /* last character to display */
Xchar *fldStr ; /* field string */
Xchar charKeyed[] ; /* characters in the field keyed */
Xint setNumb ; /* for SET & MENU */
Xint origAttr[] ; /* origianl attributes for this fld */
X{
X int colLast, col ;
X double atof() ;
X char *fldWrk ;
X
X
X getyx(win, row, col) ;
X colLast = col - 1 ;
X
X col = colStart ;
X
X fldWrk = fldStr ;
X
X while (col < colEnd)
X {
X
X if (charKeyed [col - colStart] == 'Y')
X *fldWrk++ = mvwinch(win, row, col) & A_CHARTEXT ;
X col++;
X }
X
X *fldWrk = '\0' ;
X
X switch (fldType)
X {
X case CHAR:
X strcpy (Fld->strVal, fldStr) ;
X break ;
X
X case INT:
X *Fld->intVal = atoi(fldStr) ;
X break ;
X
X case SHORT:
X *Fld->shortVal = atoi(fldStr) ;
X break ;
X
X case LONG:
X *Fld->longVal = atoi(fldStr) ;
X break ;
X
X case FLOAT:
X *Fld->floatVal = atof(fldStr) ;
X break ;
X
X case DOUBLE:
X case MONEY:
X *Fld->doubleVal = atof(fldStr) ;
X break ;
X } /* end switch (fldType) */
X
X if ((fldStr == NULL || strcmp (fldStr, "") == 0) && !mustEnter)
X {
X ReDispFld(win, row, colStart, -1, fldMask, fldRange, fldLength,
X fldCharType, fldType, fldStr, colEnd, charKeyed,
X setNumb, origAttr) ;
X return(1) ;
X }
X
X if (fldCharType == DATE &&
X ((mustEnter && !IsDate (fldStr, fldMask)) ||
X (!mustEnter && strcmp(fldStr, "000000") != 0 &&
X strcmp(fldStr, " ") != 0 &&
X fldStr[0] != '\0' &&
X !IsDate (fldStr, fldMask))))
X {
X BELL;
X CLEARROW (fldErrRow);
X wattrOn (stdscr, A_REVERSE|A_BOLD);
X mvwaddstr (stdscr,
X ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100,
X ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100,
X "Invalid Date") ;
X wattrOff (stdscr);
X wmove (win, row, colStart) ;
X return (0) ;
X }
X
X if (fldCharType == TIME &&
X ((mustEnter && !IsTime (fldStr, fldMask)) ||
X (!mustEnter && strcmp(fldStr, "000000") != 0 &&
X strcmp(fldStr, " ") != 0 &&
X fldStr[0] != '\0' &&
X !IsTime (fldStr, fldMask))))
X {
X BELL;
X CLEARROW (fldErrRow);
X wattrOn (stdscr, A_REVERSE|A_BOLD);
X mvwaddstr (stdscr,
X ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100,
X ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100,
X "Invalid Time") ;
X wattrOff (stdscr);
X wmove (win, row, colStart) ;
X return (0) ;
X }
X
X if (fldCharType == STATE && !IsState (fldStr))
X {
X BELL;
X CLEARROW (fldErrRow);
X wattrOn (stdscr, A_REVERSE|A_BOLD);
X mvwaddstr (stdscr,
X ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100,
X ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100,
X "Invalid State") ;
X wattrOff (stdscr);
X wmove (win, row, colStart) ;
X return (0) ;
X }
X
X if (fldCharType == SET || fldCharType == MENU || fldRange == NULL)
X {
X ReDispFld(win, row, colStart, -1, fldMask, fldRange, fldLength,
X fldCharType, fldType, fldStr, colEnd, charKeyed,
X setNumb, origAttr) ;
X return (1) ;
X }
X
X if (IsRange(Fld, fldLength, fldType, fldRange, fldCharType,
X fldStr, fldMask))
X {
X ReDispFld(win, row, colStart, -1, fldMask, fldRange, fldLength,
X fldCharType, fldType, fldStr, colEnd, charKeyed,
X setNumb, origAttr) ;
X return (1) ;
X }
X else
X {
X getyx (win, row, col) ;
X BELL;
X CLEARROW (fldErrRow);
X wattrOn (stdscr, A_REVERSE|A_BOLD);
X mvwprintw (stdscr,
X ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100,
X ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100,
X "Valid Ranges are: %s", fldRange) ;
X wattrOff (stdscr);
X wmove (win, row, colLast) ;
X
X }
X
X return(0) ;
X
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/IsFldOk.c || echo "restore of utilities.d/libgeti.d/IsFldOk.c fails"
echo "x - extracting utilities.d/libgeti.d/IsMask.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsMask.c &&
Xstatic char Sccsid[] = "@(#)IsMask.c 1.2 DeltaDate 1/22/90 ExtrDate 1/22/90";
X
X/*
X** IsMask ()
X** Determines whether a given character is a mask format character based
X** upon the field type.
X** RETURNS:
X** TRUE character is a mask format character
X** FALSE this character allows data input
X*/
X
X#include "GetInput.h"
X
XIsMask (fldCharType, maskChar)
X char fldCharType ;
X char maskChar ;
X{
X
X if ( fldCharType == maskChar)
X return (0) ;
X else if (fldCharType == ALPHANUM &&
X (maskChar == ALPHANUM || maskChar == ALPHA ||
X maskChar == NUMERIC || maskChar == UPPER ||
X maskChar == UPPER_AN || maskChar == HEX) )
X return (0) ;
X else if (fldCharType == DATE &&
X (maskChar == 'D' || maskChar == 'M' || maskChar == 'Y'))
X return (0) ;
X else if (fldCharType == TIME &&
X (maskChar == 'I' || maskChar == 'H' || maskChar == 'M'||
X maskChar == 'S' || maskChar == 'T'))
X return (0) ;
X else
X return (1) ;
X}
X
X
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/IsMask.c || echo "restore of utilities.d/libgeti.d/IsMask.c fails"
echo "x - extracting utilities.d/libgeti.d/IsRange.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsRange.c &&
Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
X
X#include <curses.h>
X#include <ctype.h>
X#include <string.h>
X#include <time.h>
X#include "GetInput.h"
X
X#ifndef TRUE
X# define TRUE 1
X# define FALSE 0
X#endif
X
X#define FROM 0
X#define TO 1
X#define BUFSIZE 512
X
XIsRange (Fld, fldLength, fldType, fldRange, fldCharType, fldStr, fldMask)
X FldUnPointer Fld ;
X unsigned int fldLength ;
X char fldType ;
X char *fldRange ;
X char fldCharType;
X char *fldStr; /* input */
X char *fldMask; /* the mask */
X{
X FILE *fopen(), *fp;
X char *upper();
X char *fgets();
X char *substr();
X char *wrk, *wrkAlloc ;
X char *malloc();
X int testInt, t1, t2, INTFLAG;
X long testLong ;
X float testFloat ;
X double testDouble ;
X int fromTo ; /* indicates FROM-TO part in range */
X int fromOk ; /* passed FROM test */
X int success ;
X int retCode ;
X double atof() ;
X int month, day, year; /* date inputted - broken apart */
X char tmpstr[BUFSIZE];
X struct tm *ltime, *localtime();
X long secs, tdate, idate;
X
X
X
X wrkAlloc = malloc (fldLength + 10);
X
X fromTo = FROM ;
X success = fromOk = FALSE ;
X
X /* loop through each range value */
X while (TRUE)
X {
X wrk = wrkAlloc ;
X
X /*
X ** Get a range value to test on.
X */
X do
X {
X *wrk++ = *fldRange++;
X } while (*fldRange != '\0' && *fldRange != ',' &&
X *fldRange != '-') ;
X
X *wrk = '\0' ;
X wrk = wrkAlloc ;
X
X
X /* some special range checking based on CharType */
X switch (fldCharType)
X {
X case DATE:
X /* get month, day, year from what was inputted */
X getmmddyy (fldStr, fldMask, &month, &day, &year);
X
X /* handle day of week range ? */
X testInt = -1; /* range dayofweek */
X if (strcmp (upper (wrk), "SUN") == 0)
X testInt = 0;
X else if (strcmp (upper (wrk), "MON") == 0)
X testInt = 1;
X else if (strcmp (upper (wrk), "TUE") == 0)
X testInt = 2;
X else if (strcmp (upper (wrk), "WED") == 0)
X testInt = 3;
X else if (strcmp (upper (wrk), "THR") == 0)
X testInt = 4;
X else if (strcmp (upper (wrk), "FRI") == 0)
X testInt = 5;
X else if (strcmp (upper (wrk), "SAT") == 0)
X testInt = 6;
X if (testInt >= 0)
X {
X /* day of week range check */
X
X /* get inputted day of week */
X retCode = week_day (year, month, day);
X
X /*
X ** if dayofweek inputted == range dayofweek ||
X ** if the from part is ok and we are working
X ** on the to part and the dayofweek inputted
X ** is less than the to part
X ** then we're done and it's a good value
X ** else if we are working on the from part
X ** and dayofweek inputted is greater
X ** than range dayofweek
X ** then the from part is ok
X */
X if (retCode == testInt ||
X (fromOk == TRUE && fromTo == TO &&
X retCode < testInt))
X success = TRUE;
X else if (fromTo == FROM &&
X retCode > testInt)
X fromOk = TRUE;
X }
X goto nextvalue;
X
X default:
X /* do nothing. Go on to the fldType edits */
X break;
X } /* end switch (fldCharType) */
X
X
X switch (fldType)
X {
X case CHAR:
X /*
X ** bug fix - 9/24/86 pjc
X ** range = "1-12" double digit could not handle
X */
X INTFLAG = sscanf (wrk, "%d", &t2);
X if (INTFLAG)
X INTFLAG = sscanf (Fld->strVal, "%d", &t1);
X if (INTFLAG)
X retCode = t1 - t2;
X else
X retCode = strcmp (Fld->strVal, wrk);
X if (retCode == 0 || (fromOk == TRUE &&
X fromTo == TO && retCode < 0))
X success = TRUE ;
X else
X if (fromTo == FROM && retCode > 0)
X fromOk = TRUE ;
X break ;
X
X case INT:
X testInt = atoi (wrk) ;
X if (*Fld->intVal == testInt ||
X (fromOk == TRUE && fromTo == TO &&
X *Fld->intVal < testInt) )
X success = TRUE ;
X else if (fromTo == FROM &&
X *Fld->intVal > testInt)
X fromOk = TRUE ;
X break ;
X
X case LONG:
X testLong = atol (wrk) ;
X if (*Fld->longVal == testLong ||
X (fromOk == TRUE && fromTo == TO &&
X *Fld->longVal < testLong) )
X success = TRUE ;
X else if (fromTo == FROM &&
X *Fld->longVal > testLong)
X fromOk = TRUE ;
X break ;
X
X case FLOAT:
X testFloat = atof (wrk) ;
X if (*Fld->floatVal == testFloat ||
X (fromOk == TRUE && fromTo == TO &&
X *Fld->floatVal < testFloat) )
X success = TRUE ;
X else if (fromTo == FROM &&
X *Fld->floatVal > testFloat)
X fromOk = TRUE ;
X break ;
X
X case DOUBLE:
X case MONEY:
X testDouble = atof (wrk) ;
X if (*Fld->doubleVal == testDouble ||
X (fromOk == TRUE && fromTo == TO &&
X *Fld->doubleVal < testDouble))
X success = TRUE ;
X else if (fromTo == FROM &&
X *Fld->doubleVal > testDouble)
X fromOk = TRUE ;
X break ;
X }
X
X
Xnextvalue:
X if (success)
X break ;
X
X /*
X **
X ** Skip to next valid range check
X **
X */
X while (TRUE)
X {
X if (*fldRange == '\0')
X break ;
X else
X if (*fldRange == '-')
X fromTo = TO ;
X else
X if (*fldRange == ',')
X {
X fromOk = FALSE ;
X fromTo = FROM ;
X }
X
X if (isprint (*fldRange) && *fldRange != ' ' &&
X *fldRange != ',' && *fldRange != '-')
X break ;
X
X fldRange++;
X }
X
X if (*fldRange == '\0')
X break ;
X
X }
X
X strcpy (tmpstr, fldRange);
X upper (tmpstr);
X if (fldCharType == DATE && success &&
X substr (tmpstr, "NO_HOLIDAYS") != (char *)NULL)
X {
X /* the date can not be a holiday */
X
X /* convert date inputted to julian */
X getmmddyy (fldStr, fldMask, &month, &day, &year);
X retCode = julian (year, month, day);
X
X /* if holidays file does not exist then ignore edit */
X if ((fp = fopen (HOLIDAY_FILE, "r")) != (FILE *)NULL)
X {
X /* loop through each entry in holidays file */
X while (fgets (tmpstr, BUFSIZE-1, fp) != (char *)NULL)
X {
X sscanf (tmpstr, "%d", &testInt);
X if (testInt > 0 && retCode == testInt)
X {
X success = FALSE;
X break;
X }
X }
X fclose (fp);
X }
X }
X
X /* date must be greater than today */
X strcpy (tmpstr, fldRange);
X upper (tmpstr);
X if (fldCharType == DATE && success &&
X substr (tmpstr, "GT_TODAY") != (char *)NULL)
X {
X secs = time ((long *)0);
X ltime = localtime (&secs);
X tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
X ltime->tm_mday);
X idate = datedays (year, month, day);
X if (idate <= tdate)
X success = FALSE;
X }
X else if (fldCharType == DATE && success &&
X substr (tmpstr, "GE_TODAY") != (char *)NULL)
X {
X secs = time ((long *)0);
X ltime = localtime (&secs);
X tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
X ltime->tm_mday);
X idate = datedays (year, month, day);
X if (idate < tdate)
X success = FALSE;
X }
X else if (fldCharType == DATE && success &&
X substr (tmpstr, "LT_TODAY") != (char *)NULL)
X {
X secs = time ((long *)0);
X ltime = localtime (&secs);
X tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
X ltime->tm_mday);
X idate = datedays (year, month, day);
X if (idate >= tdate)
X success = FALSE;
X }
X else if (fldCharType == DATE && success &&
X substr (tmpstr, "LE_TODAY") != (char *)NULL)
X {
X secs = time ((long *)0);
X ltime = localtime (&secs);
X tdate = datedays (ltime->tm_year+1900, ltime->tm_mon+1,
X ltime->tm_mday);
X idate = datedays (year, month, day);
X if (idate > tdate)
X success = FALSE;
X }
X
X
X free (wrkAlloc) ;
X
X return (success);
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/IsRange.c || echo "restore of utilities.d/libgeti.d/IsRange.c fails"
echo "x - extracting utilities.d/libgeti.d/IsState.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsState.c &&
Xstatic char Sccsid[] = "@(#)IsState.c 1.1 DeltaDate 8/30/87 ExtrDate 1/22/90";
X#include <string.h>
X
X#define MAXSTATES 50
X
XIsState (str)
X char str[] ;
X{
X int retCode, count ;
X
X static char *states[] = {
X "AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA",
X "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD",
X "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH",
X "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC",
X "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI", "WV", "WY"
X } ;
X
X
X count = 0 ;
X
X while (count < MAXSTATES) {
X
X retCode = strcmp (str, states[count++]) ;
X
X if (retCode == 0)
X return (1) ;
X
X if (retCode < 0)
X return (0) ;
X
X }
X
X return (0) ;
X}
X
X
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/IsState.c || echo "restore of utilities.d/libgeti.d/IsState.c fails"
echo "x - extracting utilities.d/libgeti.d/IsTime.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/IsTime.c &&
Xstatic char Sccsid[] = "@(#)IsTime.c 1.1 DeltaDate 8/30/87 ExtrDate 1/22/90";
X#include <stdio.h>
X#include "GetInput.h"
X
XIsTime(str, mask)
X char *str ;
X char *mask ;
X{
X char cmdstr[5] ;
X int i ;
X
X if (mask == NULL) {
X
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 0 || i > 12)
X return(0) ;
X
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 1 || i > 59)
X return(0) ;
X
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 1 || i > 59)
X return(0) ;
X
X } else {
X
X while ( *mask != '\0' ) {
X
X while ( *mask != 'I' && *mask != 'H' && *mask != 'M' &&
X *mask != 'S' && *mask != 'T')
X mask++ ;
X
X switch (*mask) {
X case 'H':
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 1 || i > 12)
X return(0) ;
X mask += 2 ;
X break ;
X case 'M':
X case 'S':
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 0 || i > 59)
X return(0) ;
X mask += 2 ;
X break ;
X case 'T':
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 0 || i > 99)
X return(0) ;
X mask += 2 ;
X break ;
X case 'I':
X cmdstr[0] = *str++ ;
X cmdstr[1] = *str++ ;
X cmdstr[2] = '\0' ;
X i = atoi (cmdstr) ;
X if(i < 0 || i > 23)
X return(0) ;
X mask += 2 ;
X break ;
X }
X }
X }
X return(1) ;
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/IsTime.c || echo "restore of utilities.d/libgeti.d/IsTime.c fails"
echo "x - extracting utilities.d/libgeti.d/ReDispFld.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ReDispFld.c &&
Xstatic char Sccsid[] = "@(#)ReDispFld.c 1.3 DeltaDate 1/22/90 ExtrDate 1/22/90";
X#include <curses.h>
X#include "GetInput.h"
X#include <ctype.h>
X
XReDispFld (win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength,
X fldCharType, fldType, fldStr, colEnd, charKeyed, setNumb,
X origAttr)
X WINDOW *win ; /* Window */
X int rowStart ;
X int colStart ;
X int fldAttrib ; /* field attribute */
X char *fldMask ; /* mask for character string */
X char *fldRange ; /* allowable range for field */
X unsigned fldLength ; /* Maximum length of output */
X char fldCharType ; /* type of character */
X char fldType ; /* type of field */
Xchar *fldStr ; /* the field without the mask chars */
Xint colEnd ; /* last column for display */
Xchar charKeyed[] ; /* characters keyed */
Xint setNumb ; /* for SET & MENU */
Xint origAttr[] ; /* original attributes for field */
X{
X int col ;
X
X char *fldWrk ;
X
X if (fldCharType == SET || fldCharType == MENU )
X ShowSet(win, rowStart, colStart, -1, fldRange, fldLength, &setNumb, colEnd, charKeyed, origAttr) ;
X else {
X if (fldAttrib != -1)
X wattrset(win, fldAttrib) ;
X col = colStart ;
X wmove(win, rowStart, col) ;
X fldWrk = fldStr ;
X
X if (fldAttrib == -1 && fldType == MONEY) {
X int decimalFound, decimalPlaces ;
X
X decimalFound = FALSE ;
X decimalPlaces = 0 ;
X
X while (*fldWrk != '\0') {
X if (*fldWrk == '.')
X decimalFound = TRUE ;
X else if (decimalFound)
X decimalPlaces++;
X fldWrk++;
X }
X if (!decimalFound)
X strcat(fldStr, ".00") ;
X else if (decimalFound && decimalPlaces < 2) {
X if (decimalPlaces == 0)
X strcat(fldStr, "00") ;
X else if (decimalPlaces == 1)
X strcat(fldStr, "0") ;
X }
X
X fldWrk = fldStr ;
X }
X
X while (col < colEnd && *fldWrk != '\0') {
X if (fldAttrib == -1)
X wattrset(win, origAttr[col - colStart] ) ;
X if (charKeyed [col - colStart] == 'M')
X mvwaddch(win, rowStart, col, *(fldMask + col - colStart) ) ;
X else
X mvwaddch(win, rowStart, col, *fldWrk++) ;
X col++;
X };
X
X if (strlen(fldStr) < fldLength) {
X int bytesFill ;
X
X bytesFill = fldLength - strlen(fldStr) ;
X while (bytesFill) {
X if (fldAttrib == -1)
X wattrset(win, origAttr[col - colStart]);
X if (charKeyed [col - colStart] != 'M') {
X bytesFill--;
X mvwaddch(win, rowStart, col++, ' ') ;
X } else {
X mvwaddch(win, rowStart, col, *(fldMask + col - colStart) ) ;
X col++;
X }
X }
X }
X
X while (col < colEnd)
X {
X if (charKeyed [col - colStart] != 'M')
X mvwaddch(win, rowStart, col, ' ') ;
X else
X mvwaddch(win, rowStart, col, *(fldMask + col - colStart) ) ;
X col++;
X }
X
X wattrset(win, 0) ;
X }
X
X return(0) ;
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ReDispFld.c || echo "restore of utilities.d/libgeti.d/ReDispFld.c fails"
echo "x - extracting utilities.d/libgeti.d/RingMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/RingMenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)RingMenu.c 1.3 DeltaDate 2/3/90 ExtrDate 2/3/90";
X#endif
X
X/***********************************************************************
X#############################################################################
X# This software/documentation is the proprietary trade secret and property #
X# of Pacific Bell. Receipt or possession of it does not convey any rights #
X# to divulge, reproduce, use or allow others to use it without the specific #
X# written authorization of Pacific Bell. Use must conform strictly to #
X# the license agreement between user and Pacific Bell. #
X#############################################################################
X
X Program: RingMenu.c
X Purpose: To display a Ring Menu, and prompt for option.
X Options are to be selected with first capital
X letter match, or use the cursor position key
X to move to the right option and depress RETURN.
X Help message for current option is always displayed
X the line below the option line.
X
X Synopsis: RingMenu (win, line, opt, title, opt_table )
X WINDOW *win; /* curses screen
X unsigned short line ; /* line option on
X unsigned short opt ; /* default option pos
X char *title; /* menu title
X char *opt_table[][2]; /* option table
X /* name and description
X Return: 1 - MAXOPTIONS
X
X Author: Sam Lok
X Date Written: March, 1989.
X Installation: Pacific Bell
X Modification History:
X [Plx log name of programmer, date and description]
X
X***********************************************************************/
X
X#include <curses.h>
X#include <term.h>
X#include "GetInput.h"
X#include "keys.h"
X
X#define MSGLINE 23
X#define MAXOPTIONS 20
Xstruct ring /* the ring */
X{
X short column ; /* column position */
X short page ; /* page number */
X} menu[MAXOPTIONS] ;
Xshort Noptions ; /* total number of options */
X
XRingMenu (win, line, opt, title, opt_table )
X WINDOW *win;
X char *opt_table[][2] ;
X char *title ;
X unsigned short line, opt ;
X{
X register short i, ii, ch ;
X
X /*
X * Initializations
X */
X putp( cursor_invisible ) ; /* turn off cursor if possible */
X for ( i=0; /* count # option */
X *opt_table[i]!=NULL && i<MAXOPTIONS;
X i++ )
X ;
X Noptions = i;
X
X /* initialize ring menu */
X /*
X * first option
X */
X if ( title != NULL )
X menu[0].column = strlen( title ) + 2 ;
X else
X menu[0].column = 0 ;
SHAR_EOF
echo "End of part 9"
echo "File utilities.d/libgeti.d/RingMenu.c is continued in part 10"
echo "10" > s2_seq_.tmp
exit 0
More information about the Alt.sources
mailing list