[alt.sources] menu

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
#      In appreciation of the many things I've pulled off the net,
#      I give you this.
#
#      A Brief Description:
#           Menu(1) is an easy-to-use menu utility that allows users to
#           operate an application system in a user-friendly, menu-
#           driven environment.  Any application software, regardless of
#           source language or operating system process can be executed
#           from menus designed with Menu(1).
#
#           For systems requiring multi-level menus for a diverse number
#           of users, Menu(1) allows a single menu to call any number of
#           submenus, which may in turn call more menus or execute any
#           number of processes.  Menus can be nested to any level
#           without increasing startup time or memory requirements.
#
#           Menus can also be designed to function as user-friendly data
#           entry screens for capturing data, which can then be used as
#           input for a process.  Text items such as "displays",
#           "choices" and "responses" can be added within any of these
#           defined boundaries, and will automatically adjust if any
#           boundaries are changed.  Special screen attributes, such as
#           highlighting and reverse video, can be defined to add
#           special emphasis.
#
#           The menu script file contains all of the menu instructions,
#           and can be edited using a standard system editor, such as
#           vi.  Menus and utilities can be added or deleted by editing
#           the appropriate script file, even while the menu is in use.
#
#	Run the following text with /bin/sh to create:
#	  README
#	  makefile
#	  menu.1
#	  Main.c
#	  LoadKeys.c
#	  parsedrive.c
#	  showdriver.c
#	  rundriver.c
#	  ParseOpton.c
#	  ParseBaner.c
#	  ParseTitle.c
#	  ParseBox.c
#	  ParseWindo.c
#	  ParseLine.c
#	  ParseComnt.c
#	  ParseUnix.c
#	  ParseGname.c
#	  ParseAuthr.c
#	  ParseText.c
#	  ParseCur.c
#	  ParseSpace.c
#	  ParInclude.c
#	  ParAssign.c
#	  ShowOption.c
#	  RunSystem.c
#	  RunExit.c
#	  RunSetenv.c
#	  RunMenu.c
#	  RunPopMenu.c
#	  RunGetI.c
#	  GetOption.c
#	  EndWindow.c
#	  displaytxt.c
#	  SetTerm.c
#	  systime.c
#	  sysdate.c
#	  TrapSignal.c
#	  checkmail.c
#	  anymail.c
#	  setenv.c
#	  strmatch.c
#	  setvar.c
#	  findfile.c
#	  drawline.c
#	  initmenu.c
#	  keyboard.c
#	  runscreen.c
#	  getval.c
#	  clean_menu.c
#	  System.c
#	  slength.c
#	  upper.c
#	  substr.c
#	  menu.h
#	  terminal.h
#	  LexDeSrn.l
#	  menu.hlp
#	  runrealid.c
#	  ParseDeSrn.y
#	  utilities.d/libgeti.d/AdjField.c
#	  utilities.d/libgeti.d/BuildMenu.c
#	  utilities.d/libgeti.d/DateFun.c
#	  utilities.d/libgeti.d/DisPrmpt.c
#	  utilities.d/libgeti.d/FindSet.c
#	  utilities.d/libgeti.d/GetInput.c
#	  utilities.d/libgeti.d/GetSetLen.c
#	  utilities.d/libgeti.d/InitGetI.c
#	  utilities.d/libgeti.d/IsDate.c
#	  utilities.d/libgeti.d/IsFldOk.c
#	  utilities.d/libgeti.d/IsMask.c
#	  utilities.d/libgeti.d/IsRange.c
#	  utilities.d/libgeti.d/IsState.c
#	  utilities.d/libgeti.d/IsTime.c
#	  utilities.d/libgeti.d/ReDispFld.c
#	  utilities.d/libgeti.d/RingMenu.c
#	  utilities.d/libgeti.d/ScrnOut.c
#	  utilities.d/libgeti.d/ShowChar.c
#	  utilities.d/libgeti.d/ShowHelp.c
#	  utilities.d/libgeti.d/ShowSet.c
#	  utilities.d/libgeti.d/_Main.c
#	  utilities.d/libgeti.d/checkmask.c
#	  utilities.d/libgeti.d/doinsert.c
#	  utilities.d/libgeti.d/drawbox.c
#	  utilities.d/libgeti.d/popmenu.c
#	  utilities.d/libgeti.d/GetInput.h
#	  utilities.d/libgeti.d/keys.h
#	  utilities.d/libgeti.d/makefile
#	  utilities.d/libgeti.d/GetInput.3X
#	  utilities.d/libgeti.d/RingMenu.3
#	  utilities.d/libgeti.d/ShowHelp.3
#	  utilities.d/libgeti.d/drawbox.3
#	  utilities.d/libgeti.d/popmenu.3
#	  utilities.d/libgeti.d/GetInput.hlp
#	  utilities.d/checkpass.d/checkpass.1
#	  utilities.d/checkpass.d/checkpass.c
#	  utilities.d/lock.d/junk
#	  utilities.d/lock.d/lock.1
#	  utilities.d/lock.d/lock.c
#	  utilities.d/lock.d/unlock.1
#	  utilities.d/lock.d/unlock.c
#	  utilities.d/m.d/adduser
#	  utilities.d/m.d/deluser
#	  utilities.d/m.d/junk.m
#	  utilities.d/m.d/passwdsrn.m
#	  utilities.d/m.d/printer2.sh
#	  utilities.d/m.d/printers.m
#	  utilities.d/m.d/printers.sh
#	  utilities.d/m.d/reportsrn.m
#	  utilities.d/m.d/sadmin.m
#	  utilities.d/m.d/sample.m
#	  utilities.d/m.d/suid_exec.c
#
if test -r s2_seq_.tmp
then echo "Must unpack archives in sequence!"
     next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
     exit 1; fi
mkdir utilities.d
mkdir utilities.d/libgeti.d
mkdir utilities.d/m.d
mkdir utilities.d/lock.d
mkdir utilities.d/checkpass.d
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
XThis menu program is being released as public domain software, and as
Xsuch, you have the right to use/abuse it as you see fit so long as no
Xprofit is made from it.
X					Paul J. Condie
X					(Author)
X
Xmenu directory structure:
X
X                             |-MenuAccess.d	MenuAccess(1) program
X  menu(1)                    |-checkpass.d	checkpass(1) program
Xsource code --|-utilities.d--|-libgeti.d	GetInput(3X) library
X                             |-lock.d		lock(1) & unlock(1)
X                             |-m.d		Sample menu script files.
X
XTo install menu(1):
X
X	1.   cd to where you want to keep the source code
X	2.   unpack the package
X	     cpio -iBcdumv < menu.cpio  or  unshar menu.shar.xx
X	3.   vi makefile and set where you want to install menu
X	4.   make
X	5.   make install
X
XTo test menu(1):
X	-   set menu directory to some sample menus
X	    MENUDIR=utilities.d/m.d
X	-   tell menu where you installed the help file
X	    HELPDIR=/usr/local/bin
X	-   run a sample menu
X	    menu sample.m
X
XNotes:
X	- The MenuAccess(1) program is not implemented yet.
SHAR_EOF
chmod 0644 README || echo "restore of README fails"
echo "x - extracting makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > makefile &&
X# %W%   DeltaDate %G%   ExtrDate %H%
XTITLE = "MENU"
X
X# SYS5	- System V
X# BSD	- Berkely
XOSVER = SYS5
X
X# For the $MAIL (mail notification).
X# On some systems the alarm() does not come into effect while in the middle
X# of a getch().  The alarms get buffered up until the user hits a key and
X# then all the bells notifying of mail goes off.  You should take out the
X# -DALARM on the CFLAGS to get around this.
X# Works ok on:		-DALARM
X#	AT&T 3b1
X#	AT&T 3b2
X# Does not work on:
X#	SUN
X#	Arete
X#	AT&T 3b15
X#	AT&T 3b20
X#	CT megaframe
X#
X#  -DSINGLE
X#	Causes static references to terminal capabilities instead of dynamic 
X#	references.  This results in smaller code. See /usr/include/term.h
X#  -DLEXDEBUG
X#	Only if you need more debugging for .DEFINE_SCREEN
X#  -DYYDEBUG
X#	Only if you need more debugging for .DEFINE_SCREEN
X#  -DSUN
X#	Sun compilation with 5bin/cc (SYS5)
X
X
XINSTALLDIR = /usr/lbin
XHELPDIR = /usr/lbin
XMD = /usr/man/man1
XINCDIR = .
XLIBDIR =
X
X###  Various CFLAG settings
X
X###  Sys5
XCFLAGS = -I$(INCDIR) -O -D$(OSVER) -DSINGLE
X###  Xenix
X#CFLAGS = -I$(INCDIR) -O -D$(OSVER) -DSINGLE -DM_TERMINFO -LARGE -Ml -Mlt34 -F 10000 -SEG 500
X
XYFLAGS = -d
X
X###  Libraries
X
X###  Sys5
XLIBS = libgeti.a -lcurses -ltermcap -lc -lm -ll -ly
X#LIBS = libgeti.a -lcurses -ll -ly
X###  Xenix
X#LIBS = libgeti.a -ltinfo -lx -ll -ly
X
XCFILES = Main.c LoadKeys.c parsedrive.c showdriver.c rundriver.c \
X	ParseOpton.c ParseBaner.c ParseTitle.c ParseBox.c ParseWindo.c \
X	ParseLine.c ParseComnt.c ParseUnix.c ParseGname.c ParseAuthr.c \
X	ParseText.c ParseCur.c ParseSpace.c ParInclude.c ParAssign.c \
X	ShowOption.c \
X	RunSystem.c RunExit.c RunSetenv.c RunMenu.c RunPopMenu.c RunGetI.c \
X	GetOption.c \
X	EndWindow.c displaytxt.c SetTerm.c \
X	systime.c sysdate.c TrapSignal.c checkmail.c anymail.c setenv.c \
X	strmatch.c setvar.c findfile.c drawline.c initmenu.c keyboard.c \
X	runscreen.c getval.c clean_menu.c System.c slength.c upper.c substr.c
X
XLFILES = LexDeSrn.l
XYFILES = ParseDeSrn.y
X
XHFILES = menu.h terminal.h
X
XMANPAGES = menu.1
X
XMENUFILES = utilities.d/m.d/*.m
XSHARFILES = README makefile $(MANPAGES) $(CFILES) $(HFILES) $(LFILES) \
X	menu.hlp runrealid.c $(YFILES) utilities.d/libgeti.d/*.c \
X	utilities.d/libgeti.d/*.h utilities.d/libgeti.d/makefile \
X	utilities.d/libgeti.d/*.3* utilities.d/libgeti.d/*.hlp \
X	utilities.d/checkpass.d/* utilities.d/lock.d/* utilities.d/m.d/*
X
XOBJECTS = $(CFILES:.c=.o) $(YFILES:.y=.o) $(LFILES:.l=.o)
X
Xall:	menu runrealid checkpass lock
X
Xmenu:	libgeti $(OBJECTS) 
X	$(CC) $(CFLAGS) $(OBJECTS) $(LIBDIR) $(LIBS) -o $@
X	size menu
X	@echo 
X
Xrunrealid: runrealid.c
X	$(CC) $(CFLAGS) runrealid.c -o $@
X
Xlibgeti:
X	cd utilities.d/libgeti.d; $(MAKE) install
X
Xcheckpass:
X	cd utilities.d/checkpass.d; $(MAKE) checkpass
X
Xlock:
X	cd utilities.d/lock.d; $(MAKE) lock
X	cd utilities.d/lock.d; $(MAKE) unlock
X
Xinstall:
X	strip menu
X	cp menu $(INSTALLDIR)
X	cp menu.hlp $(HELPDIR)
X#	cp sample.m $(INSTALLDIR)
X#	cp printers.m $(INSTALLDIR)
X#	cp reportsrn.m $(INSTALLDIR)
X#	cp menu.1 $(MD)
X	strip runrealid
X	cp runrealid $(INSTALLDIR)
X	cp utilities.d/checkpass.d/checkpass $(INSTALLDIR)
X#	cp utilities.d/checkpass.d/checkpass.1 $(MD)
X	cp utilities.d/lock.d/lock $(INSTALLDIR)
X	cp utilities.d/lock.d/unlock $(INSTALLDIR)
X#	cp utilities.d/lock.d/lock.1 $(MD)
X#	cp utilities.d/lock.d/unlock.1 $(MD)
X
Xlint:
X	lint -D LINT -I $(INCDIR) -I /usr/5include $(CFILES) -l curses -l c > menu.lint 
X
Xxref:
X	cxref -o menu.xref -c -t -I$(INCDIR) $(CFILES) > menu.xref
X
Xflow:
X	cflow -I$(INCDIR) $(CFILES) > menu.flow
X
Xprint:
X	ppgm -t$(TITLE) menu.1 makefile $(CFILES) $(HFILES) $(LFILES) $(YFILES)
X
Xshar:
X#	shar -b -c README makefile $(CFILES) $(HFILES) $(LFILES) $(YFILES) menu.hlp \
X#	$(MANPAGES) > menu.shar
X#	compress menu.shar
X	xshar -vcfx -l40 -omenu.shar. $(SHARFILES)
X
Xcpio:
X	cpio -oBcv > menu.cpio < Files
X	compress menu.cpio
X
Xclean:
X	rm -f *.o core menu menu.lint menu.shar* menu.xref menu.flow \
X	menu.shar.Z y.tab.h menu.cpio.Z runrealid
X	cd utilities.d/libgeti.d; $(MAKE) clean
X	rm -f utilities.d/lock.d/lock utilities.d/lock.d/unlock
X	rm -f utilities.d/lock.d/*.o
X	rm -f utilities.d/checkpass.d/checkpass utilities.d/checkpass.d/*.o
X
Xlinks:
X	ln findfile.c utilities.d/MenuAccess.d/findfile.c
X	ln /usr/src/libgeti.d/GetInput.c utilities.d/libgeti.d/GetInput.c
X
X#####
X#####
X
XMain.o:		Main.c menu.h
XParseOpton.o:	ParseOpton.c menu.h
XParseBaner.o:	ParseBaner.c menu.h
XParseBox.o:	ParseBox.c menu.h
XParseTitle.o:	ParseTitle.c menu.h
XParseLine.o:	ParseLine.c menu.h
XParseWindo.o:	ParseWindo.c menu.h
XParseComnt.o:	ParseComnt.c menu.h
XParseUnix.o:	ParseUnix.c menu.h
XParseGname.o:	ParseGname.c menu.h
XParseAuthr.o:	ParseAuthr.c menu.h
XParseText.o:	ParseText.c menu.h
XParseCur.o:	ParseCur.c menu.h
XParseSpace.o:	menu.h
XParInclude.o:	menu.h
XParAssign.o:	menu.h
XParseDeSrn.o: 	ParseDeSrn.y LexDeSrn.l menu.h
X		yacc $(YFLAGS) ParseDeSrn.y
X		cc $(CFLAGS) -c y.tab.c
X		mv y.tab.o ParseDeSrn.o
X		rm -f y.tab.c
X
XShowOption.o:	ShowOption.c menu.h
X
XRunSystem.o:	RunSystem.c menu.h
XRunMenu.o:	RunMenu.c menu.h
XRunPopMenu.o:	RunPopMenu.c menu.h
XRunExit.o:	menu.h
XRunSetenv.o:	menu.h
XRunPopMenu.o:	menu.h
XRunGetI.o:	menu.h
X
Xparsedrive.o:	parsedrive.c menu.h
Xshowdriver.o:	showdriver.c menu.h 
Xrundriver.o:	rundriver.c menu.h terminal.h
XLoadKeys.o:	LoadKeys.c menu.h
XEndWindow.o:	EndWindow.c menu.h
XGetOption.o:	menu.h terminal.h
XSetTerm.o:	menu.h
Xsetvar.o:	menu.h
Xinitmenu.o:	menu.h
Xrunscreen.o:	menu.h terminal.h
XLexDeSrn.o: 	LexDeSrn.l ParseDeSrn.y menu.h
X		lex LexDeSrn.l
X		cc -c $(CFLAGS) lex.yy.c
X		mv lex.yy.o LexDeSrn.o
X		rm -f lex.yy.c
X		rm -f y.tab.h
X
X#tokens.h: 	y.tab.h
X#		@if /bin/diff tokens.h y.tab.h > /dev/null 2> /dev/null;\
X#         	   then :; \
X#		   else cp y.tab.h tokens.h; \
X#		fi
X#calc.o: 	calc.y calc.l
X#		yacc $(YFLAGS) calc.y
X#		lex calc.l
X#		sed "s/#define YYABORT		return(1)/#define YYABORT return(-999)/" y.tab.c > junkme
X#		mv junkme y.tab.c
X#		rm -f junkme
X#		cc $(CFLAGS) -c y.tab.c
X#		mv y.tab.o calc.o
X#		rm -f y.tab.c
X#		rm -f lex.yy.c
X#		rm -f y.tab.h
X
Xclean_menu.o:	menu.h
X
X
X#####
X#####	Inference Rules
X#####
X
X.SUFFIXES:
X.SUFFIXES: .o .ec .ec~ .c .c~ .h .h~
X
X.c~.c:
X	$(GET) $<
X.h~.h:
X	$(GET) $<
X.c.o:
X	$(CC) -c $(CFLAGS) $*.c
X.c~.o:
X	$(GET) -p $<> $*.c
X	$(CC) -c $(CFLAGS) $*.c
X	rm $*.c
X.ec.o:
X	esql $(CFLAGS) -c $<
X	rm -f $*.c
X.ec~.o:
X	$(GET) -p $<> $*.ec
X	esql $(CFLAGS) -c $<
X	rm $*.ec
X	rm $*.c
SHAR_EOF
chmod 0644 makefile || echo "restore of makefile fails"
echo "x - extracting menu.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > menu.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH MENU 1 "Version 3.41"
X.SH NAME
X.TP 12
Xmenu 
X\- a menu program
X.SH SYNOPSIS
X.B "menu  [ -v ] [ -p row,col ] [ -d ] [ -keys ]  menufile"
X
X.SH DESCRIPTION 
X\fBMenu(1)\fP is an easy-to-use menu utility that allows
Xusers to operate an application system in a user-friendly, menu-driven
Xenvironment.  Any application software, regardless of source language or
Xoperating system process can be executed from menus designed with
X\fIMenu(1)\fP.
X
XFor systems requiring multi-level menus for a diverse number of users,
X\fIMenu(1)\fP allows a single menu to call any number of submenus, which
Xmay in turn call more menus or execute any number of processes.
XMenus can be nested to any level without increasing
Xstartup time or memory requirements.
X
XMenus can also be designed to function as user-friendly data entry 
Xscreens for capturing data, which can then be used as input for a process.
XText items such as "displays", "choices" and "responses" can be added within 
Xany of these defined boundaries, and will automatically adjust if any 
Xboundaries are changed.  Special screen attributes, such as highlighting and
Xreverse video, can be defined to add special emphasis.
X
XThe menu script file contains all of the menu instructions, and can
Xbe edited using a standard system editor, such as vi.  Menus and utilities
Xcan be added or deleted by editing the appropriate script file, even while
Xthe menu is in use.  
X
XMenu provides flexibility in designing how you want your
Xmenus to look, yet, strives to maintain some consistency and functionality from
Xone menu to another.  Menu was designed with "hooks" built in, so that, if 
Xadditional features/functionality for an application is required 
Xthe programmers
Xnew "keyword" modules could be linked in to the driver routines in menu(1)
X(see Programming Notes).
X.br
XThis could be used as a prototyping tool.
X.PP
XMenu is keyword driven.  
XThe menufile (script file) is parsed and when a defined keyword is found the
Xassociated function for that keyword is called.
XThe menufile is first searched for in your current directory and
Xthen in getenv("MENUDIR").  Menufile should be in basename format, use
XMENUDIR to get the full path name.  To be consistent with other file naming
Xconventions, I recommend that all menu script files be suffixed with a ".m"
Xfor menu.
XThe "menu.hlp" file contains the on-line help screen.
XThe help file is
Xfirst searched for in the current directory, then in getenv("HELPDIR"),
Xthen in getenv("MENUDIR").  Look in the directory where menu is installed
Xfor the help file (menu.hlp).  If you want to customize the help file, copy it
Xto another directory and set HELPDIR.  There should be a sample menufile
X(\fIsample.m\fP) in the same directory where menu is installed 
Xtry "\fImenu sample.m\fP".
XMenu uses curses(3X) so you need to have your TERM variable set.
X.PP
XMenu provides a shell escape (!) depending upon whether the SHELL environment
Xvariable is set.  You should \fIunset SHELL\fP if you want to restrict the user
Xfrom the shell.  If the set uid bit is set on menu and a shell escape command
Xis selected by the user.  The uid and gid is set back to the real uid/gid
Xbefore executing the shell command.
X
X.SS Command Line Options
X.TP 6
X-v
XThe [-v] command line option will print the version of the menu program
Xyou are running.  The version number increasing by tenths usually indicate
Xnew capabilities/keywords, 
Xhundredths indicate bug fixes/enchancements to existing keywords/capabilities.
X.TP 6
X-p row,col
XTells menu what row and column (upper left corner) you
Xwant the pop-up menu, for goto menu names, to appear.
XSee .GNAME below.  Default is [6,8].  I would try to keep the pop-up 
Xmenu high and to the left, 
Xthere is no real intelligence built in if the number or length of GNAMES puts
Xit off the screen.
X.TP 6
X-d
XPrints debugging information to stderr.
X.TP 6
X-keys
XDetermine the various key values on your keyboard.  This displays what is
Xreturned from a curses getch() call with the keypad turned on.
XThis information can be used to custom tailor your .menuinit file.
X
X.SS Syntax Used In This Man Page
XThe position of the arguments for the various keywords is important.  All
Xarguments including any
Xoptional arguments that are used must appear in the position shown in
Xthe synopsis for that keyword, unless stated otherwise.
X
X.TP 6
X[ ]
XThroughout this man page the "\fB[ ]\fP" indicate that what is enclosed is 
Xoptional.
X.TP 6
X[ \\\\\\ ]
XA keyword synopsis that has "\fB[ \\ ]\fP" as the last argument 
Xindicates that the continuation 
Xcharacter (\\) may be placed as the last character on the line to continue 
Xto the next line.
X.TP 6
X[!]
XIndicates a conditional enviroment variable setting.  If the variable is not
Xalready set (getenv(variable) == NULL) then the variable is set to the specified
Xvalue, otherwise it is not changed.  Same operation as doing a 
Xshell ${parameter:-word}.
X
X.SH KEYWORD SYNOPSIS
XThe following keywords are placed in a menu script file to tell \fImenu(1)\fP
Xwhat to do.
X
X
X\fB[!]variable=value\fP
X.IP "" 6
XA environment variable assignment statement.  The environment variable defined
Xby \fIvariable\fP is set equal to the \fIvalue\fP specified.  The variable is 
Xset as soon as it is found while parsing the menufile, it becomes
Xpart of the menu environment so that all subsequent programs that are spawned
Xwill inherit these variables.
X
XThe character $ in \fIvalue\fP is used to introduce substitutable 
Xparameters, in the form of ${\fIparameter\fP}.
XThe value, if any, of the \fIparameter\fP is substituted.  The braces are 
Xrequired only when \fIvalue\fP is followed by a letter, digit, or 
Xunderscore that is not to be interpreted as part of its name.
X
XThe character ~ in \fIvalue\fP is used to introduce tilde expansion.  
XMenu checks the value
Xto see if a "~" appears after the "=".  If it does menu checks the word that
Xfollows up to a "/".  A "~" by itself equals $HOME. A "~user" equals home(user).
X
XA pair of grave accents (`command`) introduce command substitution.  The
Xstandard output from the \fIcommand\fP is assigned to the variable.
X
XWarning: If you reset a environment variable in a GETINPUT that you have
Xdefined here.  The variable will get reset back to this value when the menufile
Xis re-parsed, unless you use the "!".
X. \ --------------------------------------------------------------------------
X.PP
X\fB###\fP  Comment text.
X.IP "" 6
XA comment line.  The entire line is ignored.  May be placed anywhere in
Xthe menufile.
X. \ --------------------------------------------------------------------------
X
X.PP
X\fB###NAME\fP  Alias menu name.
X.IP "" 6
XThis optional comment line is used by the MenuAccess(1) program to display
Xa different name on the screen for the menu instead of the unix file name,
Xmore user friendly.  This is recommended if you plan to use MenuAccess.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.AUTHORIZE\fP  logname  [ logname ... ]  [ \\ ]
X.IP "" 6
XAuthorize only certain login's to be able to access a menu.  For example
Xapplication administration functions to be done by application administrators
Xonly.  This can be done by putting those functions in one menu and
Xusing the .AUTHORIZE keyword.  \fILogname\fP is the login name of a user you
Xwant to allow to see this menu.  Only the
Xfirst .AUTHORIZE keyword will be used, so all lognames must be listed on 
Xthat line.
XIf no .AUTHORIZE is given in menufile then that menu is open to every one.
XIf a .AUTHORIZE is given in the main menu (first) then restriction would apply
Xto someone trying to get into the application.
X.br
XThis keyword is used by the \fIMenuAccess(1)\fP program.
X.br
X
X.br
XThis keyword authorizes a login at the menu level.  If you need to authorize
Xat the option level you could try something like this. (see .SYSTEM)
X.nf
X	.SYSTEM  if [ $LOGNAME = "stella" ] \\
X                   	        then  run_program \\
X                   	        else  echo "Sorry honey, Not Authorized." \\
X                	   fi
X	Option Description Text.
X.fi
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.BANNER\fP [ linecount ]
X .section  text
X.fi
X.IP "" 6
XDraws a banner page.  Linecount should be the number of lines
Xfollowing .BANNER, each consisting of ".section text".  Section
Xmay be either .U to display text in upper section or .L to
Xdisplay text in lower section.  Only four lines in each section
Xallowed.
XThe idea behind this was to provide some kind of welcome (to your
Xapplication) screen.
XIf .BANNER is used it should be the first keyword in menufile.
XThis one is really worthless!  It's too slooooow.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.BOX\fP [ StandoutLine ] [ DumbLine ]
X.IP "" 6
XDraws a box around the menu window.
XThe \fIBOX\fP will use the top line of the screen so the first \fI.TITLE\fP
Xline should be null.  The box will also use the first and last column,
Xyour title lines should take that into account.  You get a different effect
Xdepending on whether you place the .BOX before (with a .LINE) or after 
Xthe .TITLE lines.
X
XThe arguments specify what type of line you want to use to draw the box with.
XThe second argument specifies the type of line to use to dim the menu.
X.br
XAny one of the following may be used:
X.nf
X	DumbLine	\fIDefault line used in dimming.\fP
X	StandoutLine	\fIDefault line.\fP
X	SingleLine	\fIAlternate character line.\fP
X	MosaicLine	\fIAlternate character line.\fP
X	DiamondLine	\fIAlternate character line.\fP
X	DotLine		\fIAlternate character line.\fP
X	PlusLine		\fIAlternate character line.\fP
X.fi
XThe alternate character lines are dependant on your terminal (try "menu -key").
XNot all terminals have the capability to draw these lines.
XIf one of the alternate character lines is specified
Xand it is found that the terminal does not support it, the line will be
Xdrawn in StandoutLine.  Check your terminal manual and the terminfo definition
Xfor alternate character set.
X
XNot supported in a \fI.POPMENU\fP menu.  
XAll pop-up menus automatically get boxed.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.CURSOR\fP [-]row [-]column
X.fi
X.IP "" 6
XWhere do you want the cursor to appear on the screen?  If no \fI.CURSOR\fP
Xis specified it defaults to row=lastrow-2, column=lastcol-4.  
XSee explanation under .TEXT for negative row/column.
XThe \fI.CURSOR\fP
Xis only active for the current menu.  If you want the same cursor location
Xin every menu you will need to put a \fI.CURSOR\fP in every menu.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.DEFINE_SCREEN\fP  screen_name
X                      window_rows = number
X                      window_cols = number
X                    [ window_pos = number  number ]
X                    [ window_title = string ]
X                    [ window_border = string [ string ] ]
X                    [ helpfile = string ]
X                    [ field_defaults = "string" ]
X                    [ exit_last_field ]
X
X                      ###  The following repeat for each field.
X
X                      field_name = $string
X                      field_row = number
X                      field_col = number
X                      field_length = number
X                    [ field_label = string ]
X                    [ field_mask = string ]
X                    [ field_edits = string ]
X                    [ field_range = string ]
X                    [ field_min = number ]
X                    [ field_adjust = string ]
X                    [ field_mustenter ]
X                    [ field_prompt = string ]
X                    [ field_terminator = string ]
X                    [ field_noinput ]
X ENDSCREEN
X.fi
X
X.RS 6
XThis keyword defines a input screen that can be used with the .GETINPUT keyword.
XIf you want the same screen definition in all menus you have
Xto place it in all menus (see .INCLUDE).
XThe ordering of the arguments is unimportant except for field_name, see below.
XThe screen arguments may be placed on the same line if separated by a comma.
XThe screen arguments are listed below with the default value
Xspecified for those arguments that are optional.
XSee GetInput(3X) man page for more information.
X
XYou may have a maximum of ten screens (MAXSCREENS) defined in any one menu and
Xa maximum of twenty fields (MAXFIELDS) for any one screen.  This may be
Xincreased via the menu.h file.
X
XScreen Arguments:
X.RS 4
X.TP 15
Xscreen_name
XScreen Name.  Used in .GETINPUT to find screen definition.
X.TP 15
Xwindow_rows
XNumber of rows in window.
X.br
XIf either window_rows or window_cols is zero, they will be set to the value 
Xof (screen_lines-window_pos(row)) and (screen_cols-window_pos(col)).
XIf the window_rows, window_cols and window_pos fields are all set to zero
Xa full-screen will be used.  See newwin(curses 3X) for more info.
X.TP 15
Xwindow_cols
XNumber of columns in window.  See window_rows.
X.TP 15
X[ window_pos ]
XTop left corner to place the window at,  where the first number indicates the
Xrow and the second number indicates the column.  See window_rows.
XIf this argument is omitted then the window will be placed as close to, and to
Xthe right of, the option that selected it.  This argument is not optional if
Xthe screen is to be used with a .UNIX keyword.
XThere is no intellegence built in to check if you put the window outside 
Xthe screen dimensions.
X.br
XA environment variable may be specified for the arguments to window_pos.
X.TP 15
X[ window_title = "" ]
XA title to be centered on line zero of the window.  A environment variable may 
Xbe specified in the title.  The title may not exceed 100 bytes.
X.TP 15
X[ window_border = Standout ]
XThe type of box you want around the window.  A standout box is the default.
XSee \fI.BOX\fP for description of line types.
X.TP 15
X[ helpfile = "menu.hlp" ]
XA help file assiciated with this window.  The helpfile should be in
Xdouble quotes if it has a "." in the name, and shoud be in basename format.
XThe helpfile is first looked for
Xin the current directory and then in \fI$HELPDIR\fP.  The fieldname (excluding
Xthe "$") becomes the tagname in the help file.  See \fIHELP SCREENS\fP in this 
Xdocument for more information.
X.TP 15
X[ field_defaults = "" ]
XThis is used to initialize your fields to a default value at runtime.  
XWhat goes into the quoted
Xstring is a shell command that is passed into a popen(3) call.  What the shell
Xcommand should echo to stdout is the values you want to set your fields to.
XMaximum length of the shell command is 1k.
XField values composed of multiple strings should be quoted.  The quote should
Xalso be escaped. If the number of
Xvalues echoed to stdout is less than the number of screen fields the remainder
Xof the screen fields are set to "".  To force a field value to "" echo NULL to
Xstdout.
X.nf
XFor example:
XAssuming $SNAME is a multiple worded value to be assigned to a field.
X
X	field_defaults = "cat \fIfilename\fP |
X		while [ $? -eq 0 ]
X		do
X			read LINE
X			[ $? -ne 0 ] && break
X			set $LINE
X			SCODE=$1
X			shift
X			SNAME=$*
X			echo $SCODE  \\\\"$SNAME\\\\"
X		done"
X.fi
X.TP 15
X[ exit_last_field ]
XIf exit_last_field is specified, after the user presses return on the last field
Xthe input will be accepted and the user will exit the screen (this is as if the
Xuser had pressed the KEY_ACCEPT).  Don't ask me Lee wanted it.
X.TP 15
Xfield_name
XThe environment variable name that the data will be assigned to.  The field_name
Xmust begin with a "$", just to remind you that it is a environment variable 
Xthat I 
Xam using.  Although, the "$" is not actually used in the environment variable 
Xname.  This screen argument (field_name) tells menu that you are starting 
Xa new field
Xdefinition.  ..soooo...  It has to be the first argument for a field.  
XAll other field
Xarguments for that field_name follows after, but before the next field_name.
X.TP 15
Xfield_row
XThe row this field will appear on (base zero).
XThe window is drawn with a box on the outer edge, row zero and the last 
Xrow (window_rows) is used for the box.
X.TP 15
Xfield_col
XThe starting column for this field (base zero).  
XIf you have a field_label you need to allow enough room to place the label 
Xto the left of the field, also, the field terminators.
XThe window is drawn with
Xa box on the outer edge, so, column zero and the last column (window_cols) 
Xis used for the box.
X.TP 15
Xfield_length
XMaximum length of this field.  For field types SET and MENU this argument
Xbecomes optional, the field length is automatically set to the longest set value
Xin the field_range.
X.TP 15
X[ field_label = "" ]
XA Label to be placed to the left of the field.
X. \ **********************************
X.TP 15
X[ field_mask = "" ]
XValid masks for a field depend upon the type of field
Xyou specified, see (field_edits).  Basically the mask says what character
Xpositions in the field you allow input, what type of character allowed at that
Xposition, and what kind of a format do you want for the field.
X
XThe \fIfield_length\fP should not include character positions where no input
Xis allowed in the mask (format characters), because format characters
Xare not returned into \fIfield_name\fP.  For example, \fIfield_edits = DATE,
Xfield_mask = "MM/DD/YY"\fP.  The "/" is a format character.  The cursor
Xwill skip over those positions in the field.  Only the characters typed in
Xthe MM DD YY positions will be in the environment variable \fIfield_name\fP.
XThe field_length would be six.
X
XBecause the mask is so closely tied to the \fIfield_edits\fP, a complete
Xdescription of what mask characters are valid with what field types is 
Xdescribed under
X\fIfield_edits\fP.  Any character in the mask that is not listed as a valid
Xmask character for that field type becomes a format character.
X. \ ---------------------------------
X.TP 15
X[ field_edits = UPPER_AN ]
XThis argument defines edit checks to be performed on the
Xinput characters as they are being typed in.  If no mask is provided then
Xthe field type itself determines the edit checks to be performed on all
Xcharacters in the field.
X.RS 15
X.TP 11
XALPHANUM
XAny alpha/numeric character is allowed.
X.br
XValid mask characters:
X.nf
X	space	alpha/numeric
X	A	alpha
X	9	numeric
X	U	alpha only - convert to upper case
X	V	alpha/numeric - convert alpha to upper case
X	H	???
X.fi
X.TP
XALPHA
XAlpha only.
X.br
XValid mask characters:
X.nf
X	A	alpha
X.fi
X.TP
XNUMERIC
XNumeric only.
X.br
XValid mask characters:
X.nf
X	9	numeric
X.fi
X.TP
XUPPER
XConvert to upper case.  Only alpha permitted.
X.br
XValid mask characters:
X.nf
X	U	upper alpha
X.fi
X.TP
XUPPER_AN
XAlpha and numeric permitted.  Convert alpha characters to upper-case.
X.br
XValid mask characters:
X.nf
X	V	upper alpha/numeric
X.fi
X.TP
XHEX
XOnly hex characters permitted.
X.br
XValid mask characters:
X.nf
X	H	???
X	space	???
X.fi
X.TP
XSTATE
XValid two character Post Office abbreviations for the fifty states.
XA edit check is done for a valid state.
X.br
XValid mask characters:
X.nf
X	SS	two character state
X	S	???
X	space	???
X.fi
X.TP
XZIP
XPost Office zip code.
X.br
XValid mask characters:
X.nf
X	99999-9999	???
X.fi
X.TP
XDATE
XA valid date.
X.br
XValid mask characters:
X.nf
X	MM	month  (01-12)
X	DD	day  (01-31)
X	YY	year  (00-99)
X	YYYY	full year with century
X.fi
XThe mask must contain at least MM and DD.  If no mask is specified for the
Xfield a default mask of "MMDDYY" is used.
X.br
XSome examples:
X.nf
X	MMDDYY
X	MM/DD/YY
X	YY-MM-DD
X	MM  DD  YYYY
X.fi
X.TP
XTIME
XA time field.
X.br
XValid mask characters:
X.nf
X	HH	hours  (01-12)
X	MM	minutes  (00-59)
X	SS	seconds  (00-59)
X	TT	tenths  (00-99)
X	II	military hours  (00-24)
X.fi
XSome examples:
X.nf
X	HH:MM
X	HH:MM:SS
X	HH:MM:SS:TT
X	II:MM
X	II:MM:SS
X	II:MM:SS:TT
X.fi
X.TP
XSET
XThis field type specifies a set of values that are acceptable in the input 
Xfield.
XThe acceptable values within the set are specified in the \fIfield_range\fP 
Xargument.  
XThe user selects one of the set values specified in the field range by
Xpressing the space bar, which will toggle through the set values,
Xor by pressing the first character in the desired value.
X
XThe format of the field_range can only be comma separated values 
X(ex. "CA,ID,TX").  
XRange values, such as "1-5", don't work.  You would have to say "1,2,3,4,5".
X.br
XThe field length is automatically set to the longest set value in the 
Xfield_range.
X.TP
XMENU
XThis field type is similar to the SET type.  The difference is when the user
Xattempts to type something in the field a pop-up menu of available choices
Xare displayed, as specified in field_range.  
XThe user makes a selection by hi-lighting the choice and pressing return.
X.br
XSee SET type for specifying the field range.
XThe limit is ten items in the field range.
X.TP
XPROTECT
XThis X's out the field so that what is entered on the keyboard can not be seen
Xon the screen.  Useful for password entry.
X.RE
X. \ ---------------------------------
X.TP 15
X[ field_range = "" ]
XA set of valid ranges permitted for this field. 
XRanges may be specified as comma separated values ("ONE,TWO,THREE") 
Xor as a range ("1-5"), or a combination of both ("1-5,M,E").
XRange values must be compatible with the field_edits that you have selected.
XMaximum length of this field is 1k.
X.br
XSome examples:
X.nf
X	"1-10"
X	"5,10,15,16"
X	"1-10,20,M,E,32-40"
X	"CA,TX,ID"
X.fi
X. \ ---------------------------------
X.TP 15
X[ field_min = 0 ]
XIf field_mustenter is selected then this is the minimum
Xrequired input.  Otherwise, it is the minimum required input only if they try 
Xto input something.
X.TP 15
X[ field_adjust = NOFILL ]
XIndicates whether to adjust the text right or left within the field
Xand whether or not to zero or blank fill the field.
X.RS 15
X.TP 15
XNOFILL
Xno action.
X.TP
XRTADJ_ZFILL
Xright adjust, zero fill
X.TP
XRTADJ_BFILL
Xright adjust, blank fill
X.TP
XLFADJ_ZFILL
Xleft adjust, zero fill
X.TP
XLFADJ_BFILL
Xleft adjust, blank fill
X.RE
X. \ ---------------------------------
X.TP 15
X[ field_mustenter ]
XMarks this as a must enter field.  Default is that the field is not
Xa must enter field.
X. \ ---------------------------------
X.TP 15
X[ field_prompt = "" ]
XPrompt message to be displayed.
X. \ ---------------------------------
X.TP 15
X[ field_terminator = "[]" ]
XCharacters to terminate the field with.  The left one goes on the left, 
Xthe right one goes on the right.  Funny how that works.
X. \ ---------------------------------
X.TP 15
X[ field_noinput ]
XIf field_noinput is selected then the cursor will skip over this field.  A
Xdisplay only field.
X.RE
X.RE
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.EXIT\fP [ command ]   [ \\ ]
XExit description text.
X.fi
X.IP "" 6
XExit menu program.  This can be used if you want to exit as a user
Xselectable option.  There should be only one .EXIT per menu.
X.br
XIf command is present a system(3S) will be called, with command as the
Xargument, before exiting.  The command will be executed even if the user uses
Xthe "E" command (see help) to exit, as long as there is a .EXIT 
Xin current menu.  If you
Xwant to make sure a particular command gets executed when the user exits you
Xshould have a ".EXIT command" in every menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.GETINPUT\fP  screen_name
XOption description text.
X.fi
X.IP "" 6
XDisplays a predefined screen and prompts for input
Xas outlined in the screen definition.
XAfter the user has pressed the \fIKEY_ACCEPT\fP
Xthe environment variables, specified by the \fIfield_name\fP argument
Xis set equal to the data the user entered in that field.
XIf no data was entered for a field the environment variable is set equal to
X"NULL".  The logic behind the "NULL" is to maintain the positional parameters
Xwhen the environment variables are passed to a program.
XIf \fIKEY_CANCEL\fP is pressed the environment variables are not set.
X.br
XThe screen_name is what was used in the .DEFINE_SCREEN keyword.
X.br
X
XThe cursor moves from field to field based upon the order of the fields in
Xthe \fI.DEFINE_SCREEN\fP keyword.  
XBelow is listed the various keys used in a GETINPUT, the action they perform 
Xand their default value.  In addition to the default values, if the terminal
Xhas a associated curses key defined (see curses.h) that key may also be used.
XFor example, ^j is the default value to traverse forwards through the fields
Xbut if the down arrow is defined for KEY_DOWN, in curses, then the down arrow 
Xmay also be used.  Not all keys may have an associated curses key.
XThe "^" indicates press and hold the control key.
X.br
XSee \fIMenu Initialization File\fP to customize the values of the keys.
X
XMover Keys:
X.nf
X	KEY_RETURN  (^m)	Traverse forwards through the fields.
X	KEY_DOWN  (^j)	Traverse forwards through the fields.
X	KEY_UP  (^k)		Traverse backwards through the fields.
X	KEY_TAB  (^i)		Fast forward through the fields.
X	KEY_BTAB  		Fast reverse through the fields.
XField Editing Keys:
X	KEY_BEG  (^b)		Place cursor at beginning of field.
X	KEY_END  (^e)		Place cursor at end of input in field.
X	KEY_RIGHT  (^l)	Forward space within the field.
X	KEY_LEFT  (^h)		Backspace within the field (non-destructive).
X	KEY_BACKSPACE  (^h)	Same as KEY_LEFT.
X	KEY_EOL  (^d)		Delete from cursor to end of field.
X	KEY_DL  (^c)		Clear field and home cursor.
X	KEY_DC  (^x)		Delete a character.
X	KEY_IC  (^t)		Toggle between type-over and insert mode.
XOther Keys:
X	KEY_HELP  (?)		Display help screen.
X	KEY_REFRESH  (^r)	Redraw the screen.
X	KEY_ACCEPT  (^a)	Accept all input and exit screen.
X	KEY_CANCEL  (esc)	Cancel all input and exit screen.
X	KEY_SAVE  (^f)		Save screen to a file.
X	KEY_PRINT  (^p)	Print screen to lp.
X.fi
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.GNAME\fP menuname menufile
X.IP "" 6
XDefine a goto name for a menu so that the user may go directly to that
Xmenu by typing in the menu name (G "return" menuname "return").  
XMenuname is the name you want
Xthe user to input.  Menuname has to be one word and is limited to fifteen
Xcharacters.
XMenufile is the unix filename for that menu.  The .GNAME
Xis not accessible to the user until the menufile that you have placed the .GNAME
Xin has been displayed.  If all .GNAME's have been placed in the main menu
Xthen they will all be accessible to the user as soon as the main menu has
Xbeen displayed.
X.br
XInstead of having the user type (G "return" menuname "return") try 
X(control g).
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.INCLUDE\fP menufile
X.IP "" 6
XInclude a menu script file.  This is so you don't have to type the same 
Xscreen definition in all the menu files that you want to use it in.
XAlthough, it could be used for any menufile.
XIt is significant where you place the .INCLUDE in your menufile, depending on
Xwhat is in the .INCLUDE menufile.  Think of it as if you were typing it in
Xat this point in the menu file.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.LINE\fP [ StandoutLine ] [ DumbLine ]
X.IP "" 6
XDraws a standout line underneath your last title line to
Xsplit the options portion of the screen from the title portion.
XPlace after last \fI.TITLE\fP.
X.br
XSee .BOX for description of line types.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.MENU\fP menufile  [ GETINPUT screen_name ]  [ [!]variable=value  ... ]   [ \\ ]
SHAR_EOF
echo "End of part 1"
echo "File menu.1 is continued in part 2"
echo "2" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 2 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file menu.1 continued
#
CurArch=2
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 menu.1"
sed 's/^X//' << 'SHAR_EOF' >> menu.1
X Option description text.
X.fi
X.IP "" 6
XDefines this option as a sub-menu.  When user selects this option
Xthe menu defined in "menufile" will be parsed and displayed.
X
XThe [ GETINPUT ] option allows you to display a screen and prompt a user for
Xinput.  The screen is displayed before parseing of the new menu is begun.
XThis could be used to prompt a user for a password with a .UNIX in the calling
Xmenu using checkpass(1) to check permission to run the menu.
XCompliments of Victoria.
X
XA environment variable may be specified in the Option description text.
X.br
X
XThe optional variables are environment variables that will be set equal to
Xthe value specified when the user selects this option.  This can be used
Xto pass data to a sub menu.  Maximum length of the .MENU line is 700 bytes.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.POPMENU\fP [ NoDim ] menufile [ row column ] [ [!]variable=value  ... ]  [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XDefines this option as a pop-up menu.  When user selects this option
Xthe script file "menufile" will be parsed and displayed.  
XThe optional row and column (upper left corner) is where you want the pop-up 
Xmenu to pop-up.  If row and column is omitted then the menu will be placed
Xas close to the option, that is selecting it, as possible.
XSee \fI.SETENV\fP for \fIvariable=value\fP.
X
XThe [ NoDim ] flag tells menu not to dim the box on a inactive menu.  The
Xdefault is to dim inactive menus.  That way the user can easily see what
Xmenu they are working with.
X
XA environment variable may be specified in the Option description text.
X
XThe options in a pop-up menu can be selected by hi-lighting the option
Xand pressing return, or ESC to cancel.  The pop-up menu goes away after
Xan option has been selected and you are put back in your calling menu 
X(the calling menu is reparsed).
XThis keyword was provided for those options where the user would go over to
Xa menu select an item then return back.  A printer select menu would be ideal
Xfor this keyword.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.SETENV\fP  [ BELL ] [!]variable=value [ [!]variable=value ... ] [ message ]   [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XWhen the user selects this option it will set
Xa variable to a value in the the current environment (i.e. the menu
Xenvironment).  This is useful if you want something like a printer menu
Xlisting available printers and changing the $LPDEST so all print jobs
Xwill go to the new printer.
XThe \fImessage\fP argument is what is printed to the screen so the user
Xcan get feed back that his selection did something.
XThe \fIBELL\fP argument provides an audible beep if the variables were
Xset successfully.
X
Xnote:
X.br
X      If the message has a "=" sign in it menu will think it is a
X      "variable=value" and will try to set a environment variable.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.SPACE\fP
X.fi
X.IP "" 6
XPut a space in between options.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.SYSTEM\fP [ [ variable=value ... ] GETINPUT screen_name ] command   [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XDefines this option as a system call.  When user selects this option
Xa system call will be executed, with command as the argument. Since the command
Xis a argument to system(3S) anything you can type at the $ prompt you can
Xput in the command.
XMaximum length of \fIcommand\fP is 1k.
XA environment variable may be specified in the Option description text.
X
XThe [ GETINPUT ] option allows you to display a screen and prompt a user for
Xinput that could be used as command line arguments to the command.  
XThe screen_name is a defined screen name.
XSee .GETINPUT and .DEFINE_SCREEN for more information.
X.br
XThe optional \fIvariable=value\fP arguments associated with the GETINPUT
Xare set at runtime, when the user selects this option.  This could be
Xused to have a dynamic window_title in your getinput screen.
X
XExample: Say you need to prompt the user for a $DATA field then pass that 
Xfield into
Xyour program, lock the program so that program cannot be run until this one 
Xfinishes
Xand you want to kick the program off in the back ground.  You
Xcould try something like this (see lock(1),unlock(1)):
X.nf
X   .SYSTEM     GETINPUT  screen1 \\
X		lock program_name; \\
X		if [ $? -eq 0 ] \\
X		   then	(nohup program_name $DATA; nohup unlock program_name)& \\
X		   else	echo "Program Already Running."; \\
X			echo "Press [ Return ] to continue ...\\c"; \\
X			read reply \\
X		fi
X   Option Description Text.
X
X
X
XNote: No error checking is done for \fIcommand\fP.  If error checking is
Ximportant for your application you will need to build it into 
Xyour \fIcommand\fP.
X.fi
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.TEXT\fP [-]row [-]column
X Text goes on this line.
X.fi
X.IP "" 6
XAllows you to put any text at a specified row and column on the \fIstdscr\fP 
Xscreen (base 0).
XA negative row and/or column indicates number of rows from the bottom of the
Xscreen or number of columns from the right of the screen (relative addressing).
XFor example, \fI.TEXT -4 -20\fP will display text on the 4th row from the
Xbottom and the 20th column from the right.  This could be useful if your users
Xare using different sized terminals/windows.  If the row and/or column are 
Xgreater than the window size the text will get displayed on the last row or
Xlast column of the screen.
X
XThis keyword could be used to
Xplace a prompt text next to the cursor.  The \fI.TEXT\fP is only active for
Xthe current menu.  If you want the same text to appear in every menu you
Xwill need to put a \fI.TEXT\fP in every menu.
XTerminal attributes may be placed in the text line (see Terminal Attributes).
X
XA environment variable may be specified within the text.
X
XThe last line of the screen is used to report error messages, like 
X\fIInvalid Option\fP.  Your text will probably get erased if put on the last
Xline.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.TITLE\fP
X Title Line text.
X.fi
X.IP "" 6
XDisplay a title line top of menu.
XTitle lines will start at row zero.
XMultiple .TITLE lines may be defined up to MAXTITLE (6) defined in
Xmenu.h file.
X
XThe title line consists of three sections defined as follows:
X.br
Xleft text...center text...right text
X.br
XText you place in the three sections will be either left justified,
Xcentered, or right justified on the screen.  The "\fB...\fP" are used to
Xseparate the sections.
X
X.RS 6
X.PP
XA substitutable variable may be specified within the title line text.
XThe character $ is used to introduce substitutable 
Xparameters, in the form of ${\fIparameter\fP}.
XThe value, if any, of the \fIparameter\fP is substituted.  The braces are 
Xrequired only when \fIparameter\fP is followed by a letter, digit, or 
Xunderscore that is not to be interpreted as part of its name.  See sh(1) 
Xfor more info.
X.TP 6
X$DATE
Xmay be placed anywhere in title text and the system date (mm/dd/yy) will
Xbe displayed.
X.TP 6
X$TIME
Xmay be placed anywhere in title text and the system time (hh:mm zz) will 
Xbe displayed.
X
X.TP 6
X$MAIL
XThe \fI$MAIL\fP is a special environment variable.  This turns on the mail
Xnotification facility.  $MAIL may be placed anywhere in the title text and when
Xthe user has mail to be read the word "\fBMAIL\fP" will be displayed in
Xreverse video at that location in the title line, with an audible beep.
XThe MAIL environment variable needs to be set to the users mail file, ex.
X"MAIL=/usr/mail/pjc".  The environment variable \fIMAILCHECK\fP is used to
Xdetermine how often to check for mail.  See mail(1).
X.br
XIf you have a hierarchy of menus for your application \fI$MAIL\fP only needs
Xto be in the first menu.
X
XWarning: If menu is run with the set uid bit set, menu will be unable to
Xdetermine if your mail is being forwarded, because it won't have read
Xpermission on your mail file, and \fIMAIL\fP will be displayed all the time.
X.TP
XTerminal Attributes
XAttributes may be specified anywhere in the title text as follows:
X.nf
X\\S = Standout
X\\B = Bold
X\\U = Underline
X\\D = Dim
X\\R = Reverse Video
X\\L = Blink
X\\N = Normal
X
Xexample: \\RThis text is reverse video.\\N Now normal.
X
Xnote: Terminal attributes are terminal dependent.
XBerkeleys' version of curses only supports Standout.  Attributes may
Xalso be combined.
X.fi
X
XFor \fI.POPMENU\fP there is no left,center,right sections.  The title is
Xcentered.  You can have only one \fI.TITLE\fP in a pop-up menu.  No attributes
Xand/or environment variables are supported in the title for pop-up menus.
X.RE
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.UNIX\fP  [ REDRAW ]  [ GETINPUT screen_name ]  command  [ \\ ]
X.IP "" 6
XA system(3) call with command as the argument is executed immediately 
Xwhen found while parsing the 
Xmenufile.  Can be used to set function keys on terminal.  Warning: if
Xyou use this to set function keys and the function keys are changed in
Xanother program, they do not get reset back to what they were in the menu.
XMaximum length of command is 700 characters.
X
XThe [ GETINPUT ] option allows you to display a screen and prompt a user for
Xinput, before the command is run.
XThe window_pos argument to DEFINE_SCREEN must be specified in order to use
Xthe screen here, because, menu is unable to automatically figure out where to 
Xput the screen because this is happing during the parsing stage.
X
XThe [ REDRAW ] flag instructs menu to redraw the screen after your command
Xhas been executed.  This is recommended if your command writes anything to
Xthe screen.
X
XDiagnostics
X.RS 10
XThe following actions are taken by menu depending on what exit code your
Xcommand uses.
X.TP 15
X0
XAOK. Continue to parse the next keyword.
X.TP 15
X1
XQuit/Exit the menu program.
X.TP 15
X4
XReturn to previous menu and display the error message 
X"Not Authorized to run menu.".
X.TP 15
Xanything else
XQuit parsing this menu and return to previous menu.  No message.
X.RE
X
X.RS 6
XExample:  Authorize menu access.
X.nf
X         .UNIX grep $LOGNAME access_table >/dev/null 2>/dev/null \\
X		[ $? -ne 0 ] exit 4 \\
X		exit 0
X.fi
X
XExample:  Build a menu script file at run time.
X.nf
X       ###  Printer Selection Menu
X       ###  Build a .POPMENU of available printers connected to a system.
X
X          .UNIX echo ".TITLE" > printers.m; \\
X	         echo "Printer Menu" >> printers.m; \\
X	         echo ".TEXT 23 0" >> printers.m; \\
X	         echo "Select A Printer." >> printers.m; \\
X	         lpstat -p | awk '{ print $2 }' | \\
X	         for i in `cat` \\
X	         do \\
X		     echo ".SETENV LPDEST=$i  Printer ($i) selected." >>printers.m; \\
X		     echo "$i" >> printers.m; \\
X	         done; \\
X	         exit 0
X
X          .POPMENU printers.m  10 50
X          Select Default Printer.
X.fi
X.RE
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.WINDOW\fP  first_row  last_row  first_col  last_col  [ heading ]
X.IP "" 6
XDefines a window area (rectangle) to display the options that follow this 
Xkeyword (up to the next \fI.WINDOW\fP or end of file).
XThe options are centered between first_row / last_row
Xand between first_col / last_col.
XThe \fIrows\fR and \fIcolumns\fR are absolute (base 0) and inclusive.  
XIt is up to you
Xto make sure they don't overlap (unless that's what you want), and
Xthat it is large enough to hold the options that follow.
XThe optional \fIheading\fR is text you wish centered over the window area
X(rectangle).
XIt is
Xdisplayed on \fIfirst_row\fR minus one.
XThe heading may contain terminal attributes as described under \fI.TITLE\fR.
XYour \fI.WINDOW\fP keywords should be placed after all \fI.TITLE\fP(s).
X.br
XFor example suppose you want two columns of options on the screen, one
Xof which will have a heading:
X.nf
X .WINDOW 0 23 0 39
X1. this option in left column
X2. this option in left column
X .WINDOW 10 23 40 79 \\R REPORTS \\N
X3. this option in right column
X
X.fi
XIf no .WINDOW is used a default of .WINDOW 0 screen_rows 0 screen_cols 
Xis used for all options.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.SH HELP SCREENS
XThe default help file for menu(1) is \fImenu.hlp\fP.  Additional help files
Xmay be used in a GETINPUT screen.  The following describes the the syntax of
Xa help file.
X
X\fBtagname\fP
X.br
X[ .TITLE   A Title May Be Placed Here. ]
X.br
XA tagname identifies a help screen and must be on a line by itself.
X.br
XThe text (with optional terminal attributes) to be displayed for this tagname 
Xis placed between the two tags.  Don't use tabs to space the text 
X(it don't work), you have to put in hard spaces.
XMore than one tagname may be placed in a help file.
XAny text outside of a tagname is ignored.
X.br
X\fBtagname\fP
X
X
XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
Xis to be contained in the table of contents for help.  The following is the
Xsyntax for this tagname.
X.nf
X\fBTABLE_OF_CONTENTS\fP
Xhelpfile   tagname   description
Xhelpfile   tagname   description
X	etc...
X\fBTABLE_OF_CONTENTS\fP
X.fi
X
X
XBelow is shown the default help file for menu(1)  (menu.hlp).
XIt has four tagnames in it (TABLE_OF_CONTENTS, menu, popmenu, GETINPUT 
Xand help).  This file may be customized to fit your needs.
X
X.nf
X\fBTABLE_OF_CONTENTS\fP
Xmenu.hlp	menu		Menus      - Help using menus.
Xmenu.hlp	popmenu		Pop-menus  - Help using popmenus.
Xmenu.hlp	GETINPUT	Input      - Editing commands.
Xmenu.hlp	help		Help       - Using help.
X\fBTABLE_OF_CONTENTS\fP
X
X
X\fBmenu\fP
X .TITLE Menu Help
X
X  \\RMENU COMMANDS:\\N
X          M       \\D-  Go directly to main menu.\\N
X          P       \\D-  Return to previous menu.\\N
X          G or ^g \\D-  Go directly to a specific menu.\\N
X          H or ?  \\D-  This help screen.\\N
X          ^r      \\D-  Redraw the screen.\\N
X          E       \\D-  Exit.\N
X          !       \\D-  Enter a unix command.\\N
X
X  \\RSELECTING OPTIONS:\\N
X          -  Use "up arrow key", "^k", "down arrow key", "^j" or
X             "tab key" to place bar on option and press "return".    
X
X                  or
X
X          -  Enter option number and press "return".
X
X\fBmenu\fP
X
X\fBpopmenu\fP
X .TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    To select an option press the "up arrow key",
X    "k", "down arrow key", "j" to place bar on
X    option and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
X\fBpopmenu\fP
X
X\fBGETINPUT\fP
X .TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X	.
X	. (etc.  see GETINPUT)
X	.
X        KEY_PRINT  (^p)     Print screen to lp.
X\fBGETINPUT\fP
X
X\fBhelp\fP
X .TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)	Exit help.
X        KEY_DOWN  (^j)	View a few more lines.
X        KEY_UP  (^k)	View the previous lines.
X        KEY_BEG  (^b)	Display first page.
X        KEY_END  (^e)	Display last page.
X        KEY_TOC  (^t)	Display help table of contents.
X\fBhelp\fP
X.fi
X
X.SH MENU INITIALIZATION FILE - (.menuinit)
XA menu initialization file can be provided that
Xcontains initialization commands
Xto menu.  This file is read when menu is first started.  The \fI.menuinit\fP
Xfile is first looked for in the current directory then in getenv("HOME")
Xthen in getenv("MENUDIR").  This file is not needed if the default settings 
Xsuffice.  
X
XBelow is listed a .menuinit 
Xfile with all the various initialization commands and their associated default 
Xvalue.  The decimal value is what is returned from a curses getch() call.  
X\fITry menu  -keys\fP.  Setting a key value to minus one disables the key, 
Xalthough the associated curses key, if any, is still active.
X
XNote: Menu(1) does character matching (case insensitive) on the option
Xdescription,
Xin addition to entering the number
Xof the option, to select a option.  The character matching is done after it
Xhas checked for any of the following keys.  So, for example, if you use the
Xdefault setting for KEY_EXITMENU (e) and you have a option titled "Enter ...".
XThe user will not be able to press a "e" for character matching on "Enter ...".
XThe exit menu process will be enabled.  This should be considered in
Xselecting your key values if full character matching is important.
X
X
X.nf
X     KEY_EXITMENU = 101	# (e)   Exit Menu Program.
X     KEY_MAINMENU = 109	# (m)   Go to main menu.
X     KEY_PREVMENU = 112	# (p)   Go to previous menu.
X     HOTKEYS			#       This causes the above menu keys to work without a carraige return.
X
X     KEY_GNAME = 103	# (g)   Go to a specific menu prompt.
X     KEY_POPGNAME = 7	# (^g)  Display "\fIGoto Menu\fP", GNAME pop menu.
X     KEY_RETURN = 13	# (^m)  Select hi-lighted menu option or traverse forwards through GETINPUT fields.
X     KEY_DOWN = 10	# (^j)  Traverse forwards through menu options or GETINPUT fields.
X			           Scroll help screen.
X     KEY_UP = 11		# (^k)  Traverse backwards through menu options or GETINPUT fields.
X			           Scroll help screen.
X     KEY_TAB = 9	# (^i)  Fast forward through menu options or GETINPUT fields.
X     KEY_BTAB = -1	#        Fast reverse through menu options or GETINPUT fields.
X     KEY_BEG = 2	# (^b)  Place cursor at beginning of a GETINPUT field.
X			           Display first page of help screen.
X     KEY_END = 5	# (^e)  Place cursor at end of input in a GETINPUT field.
X			           Display last page of help screen.
X     KEY_RIGHT = 12	# (^l)  Forward space within the GETINPUT field.
X     KEY_LEFT = 8	# (^h)  Backspace within the GETINPUT field (non-destructive).
X     KEY_BACKSPACE = 8    # (^h)  Same as KEY_LEFT.
X     KEY_EOL = 4	# (^d)  Delete from cursor to end of GETINPUT field.
X     KEY_DL = 3		# (^c)  Clear GETINPUT field and home cursor.
X     KEY_DC = 24	# (^x)  Delete a character in a GETINPUT field.
X     KEY_IC = 20		# (^t)  Toggle between type-over and insert mode in GETINPUT.
X     KEY_HELP = 63	# (?)  Display help screen.
X     KEY_TOC = 20	# (^t)  When in help display table of contents for help.
X     KEY_REFRESH = 18	# (^r)  Redraw the screen.
X     KEY_ACCEPT = 1	# (^a)  Accept all input from a GETINPUT screen.
X     KEY_CANCEL = 27	# (esc)  Cancel all input from a GETINPUT screen or cancel a pop-up menu selection.
X			           Exit a help screen.
X     KEY_SAVE = 6	# (^f)  Save a GETINPUT screen to a file.
X     KEY_PRINT = 16	# (^p)  Print a GETINPUT screen to lp.
X.fi
X
X.SH EXAMPLE menufile
X.nf
X\fB###\fR     This is a example of a menu script file.
X
X\fB .AUTHORIZE\fR  pjc nortons boink mozart
X
X\fB###\fR	Initialize function keys for TERM=5425
X\fB .UNIX\fR  echo "\\033[1;2;0;0q  HELP          h\\r\\c"
X
X\fB###\fR	Define goto menu names.
X\fB .GNAME\fR  main  main.m
X\fB .GNAME\fR  reports  reports.m
X
X\fB###\fR     Title Lines Section.
X\fB .TITLE\fR
X  Version 3.00...\\RPACIFIC * BELL\\N...$DATE
X\fB .TITLE\fR
X $MAIL...Sample Menu...\\S$TIME\\N
X\fB .TITLE\fR
X ...MAIN MENU...
X\fB .LINE\fR
X
X\fB###\fR     Left column of screen - Options
X\fB .WINDOW\fR 0 23 0 39
X\fB .SYSTEM\fR who
XList who is on the system.
X\fB .SYSTEM\fR ps -ef; \\
X	echo "Press [ Return ] to continue.\\c"; read reply
XPrint process status table.
X
X\fB###\fR     Right column of screen - Options
X\fB .WINDOW\fR 0 23 40 79 \\R SUB MENU \\N
X\fB .MENU\fR reports.m
XGo to report menu.
X
X\fB .TEXT\fP 22 50
XSelection [ ? for help ]
X.fi
X
X.SH GENERALLY ACCEPTED GUIDELINES
X.PD 0.1
X.IP -> 3
XPut a meaningful title on the top of every menu.
X.IP -> 3
XProvide symmetric balance by centering the title and the menu options
Xaround the center axis of the screen.
X.IP -> 3
XChoose an organizing principle for the menu options.
XOrganize menu hierarchies according to the tasks users will perform, rather
Xthan the structure of the software modules.
X.br
XHints in organizing options:
X.RS 6
X.IP * 3
XChronological ordering
X.IP * 3
XAscending or descending numerical ordering
X.IP * 3
XItems grouped by physical properties, (Increasing volume, weight or temperature)
X.IP * 3
XAlphabetic sequence of terms
X.IP * 3
XGrouping of related options with spatial demarcation between groups
X.IP * 3
XMost frequently used options first
X.IP * 3
XMost important options first
X.RE
X.IP -> 3
XTo facilitate scanning, put blank lines between logical groupings of menu
Xoptions and after about every fifth option in a long list.
X.IP -> 3
XLimit the number of menu choices of one screen.
XThe breadth (number of options per menu) should be no more than eight and the
Xdepth (number of levels of menus) should be no more than four.
X.IP -> 3
XUse words for your menu options that clearly and specifically describe 
Xwhat the user is selecting; use simple, active verbs to describe menu options.
XUse common, short English words that clearly describe the action that the 
Xcommand will carry out; choose words that are distinctive from one another.
X.IP -> 3
XDisplay the menu options in mixed, upper and lower case letters.
X.IP -> 3
XBe sure that any function keys that you use will operate correctly on all of
Xthe different types of keyboards the users have.
X.IP -> 3
XBe consistent in the use of menu formats, procedures, and wording; the 
Xmapping of keys to functions; the naming of menu options.
X.IP -> 3
XOptions should suggest or entail closure.  If a menu option calls another
Xmenu (.MENU) the title of the option should be the title of the called menu
Xto provide continuity.  Likewise, if a menu option calls a program (reports,
Xscreens) the title of the option should be the title of the report/screen.
X.IP -> 3
XDisplay only information that the user needs to know.
X.IP -> 3
XEvery menu should indicate how to exit from the screen.
X.IP -> 3
XAvoid hyphenation of words between lines.
X.IP -> 3
XUse abbreviation and acronyms only when they are significantly shorter than
Xthe full text and when they will be understood by the user.
X.IP -> 3
XOptions in a multiple column list should be organized in vertical columns
Xwhich are read from left to right on the screen.
X.IP -> 3
XPut a least two spaces between the longest item in a column and the beginning
Xof the next column.
X.IP -> 3
XUse highlighting to emphasize important information only.  Do not overuse
Xit.
X.IP -> 3
XA \fI.POPMENU\fP, if possible, should appear as close to and to the right 
Xof the option that selected it.  Probably a \fI.GETINPUT\fP screen should also.
X.PD
X
X.SS References
XHuman Factors Engineering, User Interface Guidelines, Pacific Bell, Sept (1987)
X.PP
XShore, John, The Sachertorte Algorithm and Other Antidotes to Computer
XAnxiety, Viking Penguid Inc. (1985)
X.IP * 3
XShore's book for the general public which translates into why designing 
Xgood user interfaces are necessary.
X.PP
XBeer, S. and Schoefer, W., Screen Development Guidelines - Draft,
XVersion 1.0, Pacific Bell, April (1987)
X.PP
XRubinstein R., and Hersch H.M., with Ledgard, H.F., The Human Factor:
XDesigning Computer Systems for People.  Digital Press, Digital Equipment
XCorporation, (1984).
X.IP * 3
XRubinstein's work is very interesting and original.  The text is readable
Xand the ideas presented are clear and attractive.  This is not a text book.
X.PP
XFuture Technology Architecture District, Proposed Pacific*Bell Screen 
XStandards For NonProgrammable Terminals,  Pacific Bell, May (1988)
X.PP
XDumas Joseph S., Designing User Interface for Software, Prentice Hall, 1988
X
X.SH CREDITS
XPaul J. Condie	    8/18/86	original author
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X.br
X
XIrving Griesman			GetInput(3X)
X.br
XSam S. Lok			.POPMENU enhancements
X
X.SH NOTE
XIf memory size is important modify LoadKeys.c and remove all references
Xto keywords your application does not use then relink.  This will reduce
Xthe size of menu.
X
X.SH FILES
Xmenu.hlp    -  menu help file
X.br
X/usr/local/lib/menus	- some menus you might want to use or look at.
X.br
X/usr/local/lib/menus/sample.m    -  a sample menu file
X.br
X/usr/local/lib/menus/printers.m    -  printers pop-up menu
X.br
X/usr/local/lib/menus/reportsrn.m    -  report option input screen
X
XThe library of menus may vary from machine to machine.
X
X.SH SEE ALSO
XMenuAccess(1), curses(3X), system(3), mail(1), getenv(3), 
Xlock(1), unlock(1), GetInput(3X), checkpass(1), runrealid(1).
X
X.SH WARNING
XBecause menu uses the environment to pass and save data you are limited on the
Xvolume of data you can have based upon the size of your environment.  
XThis will vary from machine to machine.  If you see the 
Xmessage "Unable to allocate environment memory..." then you have reached
Xyour limit.  Actually you've surpassed the limit or you wouldn't have
Xgotten the message.  But lets not squabble.
X
XMenu has very little intellegence built in to check if you exceed the bounds
Xof any fields.  If menu core dumps, especially will a bus error, you are
Xprobably trying to load too large a value into a field.
X
X.SH BUGS
XCurses bug - When a attribute is the last character on the line (spaces don't 
Xcount) the attributes do not get turned off until it hits the next character 
Xon the next line.
X
X.PP
XWhen you use the mail notification $MAIL the alarms get buffered up when
Xthe cursor is just sitting there, so, as soon as the user types something
Xat the keyboard all the alarms that were buffered take off, which means, you
Xget a beep...beep...beep...beep.  This doesn't happen on AT&T 3b machines
Xbut I've noticed it on SUNS and ARETE machines.
XYou should take the -DALARM off the CFLAGS in the makefile which tells
Xmenu not to use the alarm(2) to check for mail, but check when a key
Xhas been pressed.
X
X.PP
XMenu has not really been tested on terminals/windows that is not 24x80,
Xok,ok... it hasn't been tested at all.  For the most part it should work
Xfine, EXCEPT (you knew that was coming), when you want to create columns
Xof options using the .WINDOW keyword.  The parameters to .WINDOW are
Xabsolute therefore when you line up your columns for a 24x80 terminal and
Xyour menu is run on say a 34x132 terminal your columns will not be
Xcentered right.  Probably a new keyword should be introduced ".COLUMN"
Xwhich would have some intelligence built in to try to center columns within
Xthe window space.  It might have some problems going from a larger window
Xto a smaller window if the columns won't fit.
X.br
XAnyone volunteer to write this one?
X
X.PP
XTerminal attributes sometimes don't work right.  Especially when putting
Xmultiple attributes on one line.  In all cases I've seen it is a restriction
Xof the terminal (hardware).
X
X.bp
X.SH PROGRAMMING NOTES
XThis section is for those of you who want to or need to add new keywords.
X.PP
XThe keywords that have been provided should accommodate most
Xapplication menus, however, if customization is needed the following
Xmay come in handy.  If you introduce any neat new keywords (say like 
X".IF THEN ELSE") I would
Xappreciate you sending them to me so I can incorporate them.  Send your
XParse, Show, and Run functions along with a copy of \fILoadKeys.c\fP.
X.PP
XMenu is primarily driven from the LoadKeys.c module.  This 
Xmodule describes to menu what keywords it needs to scan for and what
Xaction to take when found.
XThere are four sections in LoadKeys (see LoadKeys example) each of which 
Xneed to be
Xdefined if you are introducing a new keyword.  LoadKkeys provides three areas
Xof control (sections 2,3,4), and it is important that you know what you
Xwant to accomplish at each control point:
X.TP 4
XParse
XWhat do you want menu to do with your keyword once it has found it during
Xthe parsing routine?  Any data you need to store for a later step, etc..
X.TP 4
XShow
XHow do you want your keyword displayed to the screen?  Define as NULL if
Xnot appropriate.
X.TP 4
XRun
XIf the user selects an option that is your keyword, what do you want done?
X
X.PP
XIf you want to put debugging code in your functions then the following
Xformat should be used.
X.nf
Xextern int  debug;
Xif (debug)
X{
X	fprintf (stderr, "\\n[Function] <KeyWord> ...", ...);
X}
X.fi
Xwhere [Function] is the function name and <KeyWord> is the keyword being
Xprocessed.
X
X.SS ADDING A NEW KEYWORD
X.TP 8
XStep 1:
XDecide on the name of the new keyword.  For consistency sake, I suggest, it
Xshould begin with a "." and be all in caps.  Maximum length of keyword is
XMAXKEYLENGTH (15).  Then formulate a syntax for the keyword (what the user
Xneeds to type in the menufile).
X.br
XAlso, get clear in your mind what you want done at each of the three control
Xpoints.
X
X.TP 8
XStep 2:
Xvi LoadKeys.c
X.br
XStrcpy your keyword into the next available slot in KeyWord[], under SECTION 1.
XMake sure MAXKEYS in menu.h is >= the slot you strcpy'ied your keyword into.
XSee KeyWord[] below.
X
X.TP 8
XStep 3:
XIn SECTION 2 of LoadKeys.c assign the Parse function that is going 
Xto parse your keyword.
XIt should be assigned to the same slot as in SECTION 1.  First see if one
Xof the Parse functions already written will do the job.  If so use that one,
Xif not you will have to write one.  For consistency call it Parse????.c or
XPar????.c, and declare it at the beginning of LoadKeys.c.
XAll keywords must have a parse function.
XThis function is called immediately when your keyword is found while parsing
Xthe menufile.
XSee ParseKey[]() below.
X.br
XReturn Values:
X.RS 8
X.TP 9
X0
XContinue to parse next keyword.
X.TP 9
X-1
XQuit/Exit menu program.
X.TP 9
X-2
XReturn to main menu.
X.TP 9
X-4
XNOWAYJOSE - Not authorized to run this menu.
X.TP
Xanything else
XAbort this menu and return to previous menu.
X.RE
X
X.TP 8
XStep 4:
XIn SECTION 3 of LoadKeys.c assign the Show function (if your keyword is a
Xuser selectable option) that will display the
Xoption to the screen.
XIt should be assigned to the same slot as in SECTION 1.  First see if one
Xof the Show functions already written will do the job.  If so use that one,
Xif not you will have to write one.  For consistency call it Show????.c, and
Xdeclare it at the beginning of LoadKeys.c.
XThis function is called when displaying options to the screen.
XIf you don't need a Show function for your keyword assign slot to NULL.
XSee ShowKey[]() below.
X
X.TP 8
XStep 5:
XIn SECTION 4 of LoadKeys.c assign the Run function (if your keyword is a
Xuser selectable option) that will be called when the user selects this option.
XIt should be assigned to the same slot as in SECTION 1.  First see if one
Xof the Run functions already written will do the job.  If so use that one,
Xif not you will have to write one.  For consistency call it Run????.c, and
Xdeclare it at the beginning of LoadKeys.c.
XIf you don't need a Run function for your keyword assign slot to NULL.
X.br
XReturn Values:
X.RS 8
X.TP 9
X0
XAOK, continue with normal menu processing.
X.TP 9
XMAINMENU
XGoto main menu.  This is as if the user had typed an "M".
X.TP
XPREVIOUSMENU
XGoto previous menu.  This is as if the user had typed a "P".
X.TP
XQUIT
XQuit program.  This is as if the user had typed an "E".
X.TP
XSUBMENU
XIf you are introducing
Xa new submenu keyword (like \fI.MENU\fP) the Run??? function must return 
X(SUBMENU), a #define.
XRefer to \fIRunMenu.c\fP for an example.
X.TP
XGNAMEOFFSET + gindex
XGoto a specific (.GNAME) menu.
XWhere gindex = the index into the gnames array (base 0).
XThis is as if the user had typed a goto menu.
X.RE
X
X.TP 6
XStep 6:
XCompile your new functions, LoadKeys.c  and link into menu.  
XYour KeyWord should work.
XThere should be no need to change any of the existing driver routines 
X(other than LoadKeys.c)?
X
X
X.SS char  KeyWord[]
XThis array identifies all the keywords to be scanned for in your
Xmenufile.  Maximum number of keys is "MAXKEYS" defined in menu.h
Xfile.  Increasing MAXKEYS will allow more keys.
X
X.SS "int (*ParseKey[]) (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, gindex, opnumber)"
X.nf
Xchar		keyword[];
XFILE		*menufile;
Xstruct MenuInfo	*menu;
Xchar		KeyWord[][MAXKEYLENGTH];
Xint		(*ParseKey[])();
Xchar		gnames[][15], gfiles[][15];
Xint		*gindex;
Xint		*opnumber;
X.fi
XArray of pointers to functions that will be called to parse the
Xkeyword when found.  Any processing you want done while program
Xis parsing your keyword should be placed in this function.
XIf you have defined a new keyword you must
Xdescribe how that keyword is to be parsed.  Unless you are doing
Xsomething special ParseOption() should do the job.
XYour new function will need to malloc struct OptionInfo if you
Xwant to store some information for the option.  The following describes
Xthe data passed to all parsing functions.
X.RS 6
X.TP 6
Xkeyword
XThe keyword that was found in menufile.
X.TP 6
X*menufile
XA pointer to your menufile.  When function returns you must leave
Xthe pointer set to read in the next keyword.
X.TP 6
X*menu
XA struct holding information about the menufile.  You need to maintain
Xthe information for later processing. The Show and Run functions use the
Xinformation you store here.  See struct MenuInfo and struct OptionInfo.
X.TP 6
Xgnames
XThe goto menu names (.GNAME) presently defined (base 0).
X.TP 6
Xgfiles
XThe menufiles associated with the goto names (base 0) (.GNAME).
X.TP 6
Xgindex
XThe number of goto names (.GNAME) presently defined.
X.TP 6
Xopnumber
XThe last option number.  This is the number that will appear to the left
Xof the option, and the number the user will type in to select the option.
XYou should increment this for the next option if your keyword will
Xcontain a option number.
XThe option number should be set to zero for options you don't want a
Xnumber to appear to the left of the option.
X.nf
X.RE
X
X/*
X**     Menu structure layout
X*/
Xstruct MenuInfo
X{
X	char			name	[15];		/* file name */
X	int			wfrow;			/* window first row */
X	int			wlrow;			/* window last row */
X	int			wfcol;			/* window first col */
X	int			wlcol;			/* window last col */
X	int			row_cursor;		/* row for cursor */
X	int			col_cursor;		/* col for cursor */
X	unsigned		boxtype;		/* 0 = no box */
X	unsigned		linetype;		/* same as box */
X	int			titlecount;
X	int			optioncount;		/* base 0 */
X	struct OptionInfo	*option	[MAXOPTION];
X	struct ScreenInfo	*srn	[MAXSCREENS+1];	/* .DEFINE_SCREEN */
X							/* NULL = EOL */
X};
X
X
Xstruct OptionInfo
X{
X	char	keyword		[MAXKEYLENGTH+1];
X	int	opnumber;				/* option number */
X	char	description	[200];
X	char	command		[MAXLEN];
X	int	row;					/* row to display */
X	int	col;					/* col to display */
X};
X
Xstruct ScreenInfo
X{
X	char			name	[30];		/* screen name */
X	char			title	[100];		/* window title */
X	int			toprow;			/* upper left corner */
X	int			leftcol;
X	int			rows;			/* # rows in win */
X	int			cols;			/* # cols in win */
X	unsigned		boxtype;		/* 0 = no box */
X	int			exitlastfield;		/* after last field */
X	char			helpfile[16];
X	char			*fielddefaults;		/* init field command */
X	struct FieldInfo	*field	[MAXFIELDS+1];
X};
X
X
Xstruct FieldInfo
X{
X	char	name	[30];				/* field name */
X	char	label	[50];				/* field label */
X	int	row;					/* start position */
X	int	col;
X	int	length;
X	int	min_input;
X	char	mask	[100];
X	char	range	[1025];
X	char	type;
X	char	adjust;
X	int	mustenter;
X	char	prompt	[100];
X	char	terminator[3];				/* field terminators */
X	int	noinput;
X};
X.fi
X.RE
X
X.SS "int (*ShowKey[]) (menu, index)"
X.nf
Xstruct MenuInfo   *menu;
Xint               index;
X
X.fi
XThe following describes the data passed to all Show functions.
XArray of pointers to functions that will be called to display
Xthat option to the screen.  Unless you are doing something special
XShowOption() should do the job.
X.RS 6
X.TP 6
X*menu
XSee above for description of menu structure.
X.br
Xmenu.option[index]->description gets displayed to the screen.
X.TP 6
Xindex
XOption number in menu structure that is to be displayed.
X
X.SS "int (*RunKey[]) (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, gnames, gfiles, gindex)"
X.nf
Xstruct MenuInfo	*menu;
Xint		opnumber;
Xint		(*ParseKey[MAXKEYS])();
Xint		(*ShowKey[MAXKEYS])();
Xint		(*RunKey[MAXKEYS])();
Xchar		KeyWord[MAXKEYS][MAXKEYLENGTH];
Xchar		gnames[MAXGNAME][15];
Xchar		gfiles[MAXGNAME][15];
Xint		gindex;
X.fi
XThe following describes the data passed to all Run functions.
XArray of pointers to functions that will be called when the
Xuser selects the option on the screen.
X.RS 6
X.TP 6
X*option
XSee above for description of struct OptionInfo.
X.br
Xoption->command is what is to be executed for this option.
X.RE
X
X.SS LoadKeys Example:
X.nf
XLoadKeys (KeyWord, ParseKey, ShowKey, RunKey)
X
X	char	KeyWord[][10];
X	int	(*ParseKey[])(), (*ShowKey[])(), (*RunKey[])();
X{
X	int	ParseTitle(), ParseOption();
X	int	ShowOption();
X	int	RunSystem();
X
X	/*
X	**   Section 1:
X	**   	Identify the new keyword here.
X	*/
X	strcpy (KeyWord[1], ".TITLE");
X	strcpy (KeyWord[2], ".MENU");
X	strcpy (KeyWord[3], ".SYSTEM");
X
X	/*
X	**  Section 2:
X	**	Identify the parse function for the new keyword.
X	**  	Every keyword needs a parse function.
X	*/
X	ParseKey[1] = ParseTitle;
X	ParseKey[2] = ParseOption;
X	ParseKey[3] = ParseOption;
X
X	/*
X	**  Section 3:
X	**	Identify the show function for keywords that are options.
X	**  	If ShowKey is set to NULL the option will not be displayed.
X	*/
X	ShowKey[1] = NULL;	/* Title gets displayed in the parse function */
X	ShowKey[2] = ShowOption;
X	ShowKey[3] = ShowOption;
X
X	/*
X	**  Section 4:
X	**	Identify the run function for keywords that are options.
X	**  	If RunKey is set to NULL the cursor will not stop at 
X	**  	the option.  The user will not be able to select it.
X	*/
X	RunKey[1] = NULL;	/* You can't select a title */
X	RunKey[2] = RunMenu;
X	RunKey[3] = RunSystem;
X}
X.fi
X
X
X
X
X.PP
XTHE END     (whew)
SHAR_EOF
echo "File menu.1 is complete"
chmod 0644 menu.1 || echo "restore of menu.1 fails"
echo "x - extracting Main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > Main.c &&
Xstatic char Sccsid[] = "@(#)Main.c	1.9   DeltaDate 1/22/90   ExtrDate 1/22/90";
X/*	PROGRAM	   Menu  (generic)
X**	AUTHOR	   Paul J. Condie
X**	DATE	   8/18/86
X*/
X
X#include	<curses.h>
X#include	<signal.h>
X#include	"menu.h"
X
Xint	MAILCALL = FALSE;
Xint	mailrow;
Xint	mailcol;
Xint	debug = FALSE;					/* debug flag */
X
X
Xmain (argc, argv)
X
X	int		argc;
X	char		*argv[];
X{
X	FILE		*fopen(), *menufile;
X	char		*getenv();
X	char		*findfile();
X	int		shutdown();		/* clean up before exit */
X	struct MenuInfo	menu;
X	int		(*ParseKey[MAXKEYS])(), 
X			(*ShowKey[MAXKEYS])(),
X			(*RunKey[MAXKEYS])();
X	char		KeyWord[MAXKEYS][MAXKEYLENGTH];
X/*
X**	menuname keeps track of nested submenus.
X**	mptr is the index into menuname 0 = main menu
SHAR_EOF
echo "End of part 2"
echo "File Main.c is continued in part 3"
echo "3" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file Main.c continued
#
CurArch=3
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 Main.c"
sed 's/^X//' << 'SHAR_EOF' >> Main.c
X**					1 = sub menu 2 = sub sub menu etc.
X**					menuname[mptr--] = previous menu
X*/
X	char		menuname[MAXMENU][15];			/* filenames  */
X	char		filename[80];
X	int		menuoption[MAXMENU];	/* what option to highlight */
X	int		i, exitkey, mptr=0, rc;
X	int		j;			/* loop variable */
X	char		gnames[MAXGNAME][15];	/* goto menu names */
X	char		gfiles[MAXGNAME][15];	/* goto file names */
X	int		gindex = 0;		/* goto index */
X	char		*ws;
X	extern int	optind;
X	extern char	*optarg;
X	int		gotorow = 6;		/* default goto menu row */
X	int		gotocol = 8;		/* default goto menu col */
X	int		keys = 0;		/* show keyboard values */
X	int		parse_rc = 0;		/* parsedriver return code */
X
X
X
X   	TrapSignal (shutdown);
X   	signal (SIGALRM, SIG_IGN);		/* to fix bug in curses */
X   	while ((rc = getopt (argc, argv, "dp:vk:")) != EOF)
X      		switch (rc)
X      		{
X	 	   case 'd':
X			/* Get debug excited */
X			debug++;
X			break;
X
X	 	   case 'p':
X			/* Set row and column for ^g */
X			sscanf (optarg, "%d,%d", &gotorow, &gotocol);
X			break;
X
X         	   case 'v':
X			/* Show Version */
X			fprintf (stderr, "%s   Version %s\n", argv[0], VERSION);
X			exit (0);
X			break;
X		   case 'k':
X			/* Show keyboard key values - for .menuinit */
X			keys++;
X			break;
X      		}
X   	if (argc == optind  &&  (!keys))
X   	{
X      		fprintf (stderr, 
X		       "\nUsage: %s [-v] [-p row,col] [ -keyboard ] menufile\n",
X				argv[0]);
X      		exit (1);
X   	}
X	if (!keys)
X   		sscanf (argv[optind], "%s", menuname[0]);
X   	menuoption[0] = 1;
X
X	/* curses stuff */
X   	initscr ();
X   	cbreak ();
X   	noecho ();
X   	nonl ();
X#ifdef SYS5
X   	keypad (stdscr, TRUE);
X#endif
X
X   	SetTerm ();				/* set terminal keyboard */
X	if (keys)
X	{
X		keyboard ();
X		shutdown ();
X	}
X
X   	LoadKeys (KeyWord, ParseKey, ShowKey, RunKey);
X
X
X	/*
X	**	Parse, Show and Run each menu selected until exit program.
X	*/
X   	do
X   	{
X      		move (0,0);
X      		clrtobot ();				/* clear screen */
X
X		/*
X		**  Check the parse return code from the last parse
X		**  to determine what message to display.
X		*/
X		switch (parse_rc)
X		{
X		   case NOWAYJOSE:
X			BEEP;
X			attrset (A_REVERSE|A_BOLD);
X      			mvprintw (ErrRow, 0, 
X			      "You have not been authorized to run that menu.");
X			attrset (A_NORMAL);
X			break;
X		}
X
X      		initmenu (&menu);			/* init menu defaults */
X
X		/* open menu script file */
X		strcpy (filename, findfile (menuname[mptr], ".",
X			getenv("MENUDIR"), ""));
X      		if ((menufile = fopen (filename, "r")) == NULL)
X		{
X            		BEEP;
X            		mvprintw (20, 0, "Unable to locate (%s) file.", 
X					menuname[mptr]);
X            		shutdown ();
X		}
X
X
X		/*
X		**  Return Codes from parsedriver:
X		**	NOWAYJOSE - not authorized for this menu.
X		*/
X      		parse_rc = parsedriver (menufile, KeyWord, ParseKey, &menu, 
X				gnames, gfiles, &gindex);
X      		fclose (menufile);
X
X		switch (parse_rc)
X		{
X		   case 0:
X			/* success */
X			break;
X
X		   case QUIT:
X			shutdown ();
X			break;
X
X		   case MAINMENU:
X			/* not tested */
X			mptr = 0;
X			break;
X
X		   default:
X	 		if (mptr > 0)
X	 		{
X	    			mptr--;		/* return to previous menu */
X	    			continue;
X	 		}
X	 		else
X			{
X				BEEP;
X				attrset (A_REVERSE|A_BOLD);
X      				mvprintw (ErrRow, 0, 
X			      	"You have not been authorized to run that menu.");
X				attrset (A_NORMAL);
X	    			shutdown ();  /* not authorized for main menu */
X			}
X			break;
X		} /* end switch (parse_rc) */
X
X		/* display menu */
X      		showdriver (KeyWord, ShowKey, &menu);
X
X		/*
X		**  rundriver will return:
X		**	MAINMENU	go directly to main menu
X		**	PREVIOUSMENU	go to previous menu
X		**	REPARSE		reparse & display current menu
X		**	QUIT		quit program.
X		**	0 - 99		option number containing sub menu 
X		**			filename.
X		**	GNAMEOFFSET-199 go directly to menu 
X		**			gnames[exitkey%GNAMEOFFSET]
X		*/
X      		exitkey = rundriver (KeyWord, RunKey, ShowKey, ParseKey, &menu, 
X				&menuoption[mptr], gnames, gfiles, gindex,
X				gotorow, gotocol);
X
X		clean_menu (&menu);		/* free menu space */
X
X
X      		switch (exitkey)
X      		{
X         	   case MAINMENU:
X			mptr = 0;
X			break;
X         	   case PREVIOUSMENU:
X			if (mptr > 0)   mptr--;
X			break;
X	 	   case REPARSE:
X			break;
X	 	   case QUIT:
X			break;
X		/*
X		**	A submenu option has been selected or a goto menu.
X		**	exitkey is the option # selected (which is a submenu)
X		**	The submenu filename is in menu.option[exitkey]->command
X		*/
X         	   default:
X			if (exitkey >= GNAMEOFFSET)	/* goto gname menu */
X		   		strcpy (menuname[++mptr], 
X					gfiles[exitkey % GNAMEOFFSET]);
X			else
X		   		sscanf (menu.option[exitkey]->command, "%s", 
X			   		menuname[++mptr]);
X
X			menuoption[mptr] = 1;
X			break;
X      		}
X   	} while (exitkey != QUIT);
X   	shutdown ();
X}
X
X
X
Xshutdown ()
X{
X   refresh ();
X   endwin ();
X   exit (1);
X}
SHAR_EOF
echo "File Main.c is complete"
chmod 0444 Main.c || echo "restore of Main.c fails"
echo "x - extracting LoadKeys.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > LoadKeys.c &&
Xstatic char Sccsid[] = "@(#)LoadKeys.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	LoadKeys()
X**		Identifies all the recognizable keywords and the
X**		function(s) 2b called to process the keyword.
X**  ARGS:	KeyWord		array to hold keywords
X**		ParseKey	array to hold parse functions
X**		ShowKey		array to hold display functions
X**		RunKey		array to hold run functions
X**  RETURNS:	zilch
X*/
X
X#include		"menu.h"
X
XLoadKeys (KeyWord, ParseKey, ShowKey, RunKey)
X
X	char	KeyWord[][MAXKEYLENGTH];
X	int	(*ParseKey[])(), (*ShowKey[])(), (*RunKey[])();
X{
X	int	ParseTitle(), ParseOption(), ParseBanner(), ParseBox(), 
X		ParseLine(), ParseWindow(), ParseComnt(), ParseUnix(),
X		ParseGname(), ParseAuthr(), ParseText(), ParseCursor(),
X		ParseSpace(), ParseDefineScreen(), ParInclude(), ParAssign();
X	int	ShowOption();
X	int	RunSystem(), RunExit(), RunSetenv(), RunMenu(), RunPopMenu(),
X		RunGetInput();
X
X
X/*
X**	SECTION 1:
X**	Starting with base 1.
X**	Identify keywords to be acted upon when found in your
X**	menu file.
X**	Make sure MAXKEYS is >= the number of entries here.
X*/
X
X   strcpy (KeyWord[1], ".TITLE");	/* title line */
X   strcpy (KeyWord[2], ".MENU");	/* submenu option */
X   strcpy (KeyWord[3], ".SYSTEM");	/* system call option */
X   strcpy (KeyWord[4], ".BOX");  	/* encase menu in a box */
X   strcpy (KeyWord[5], ".BANNER"); 	/* welcome banner screen */
X   strcpy (KeyWord[6], ".LINE"); 	/* line between title & options */
X   strcpy (KeyWord[7], ".WINDOW"); 	/* window area for options */
X   strcpy (KeyWord[8], "###"); 		/* comment line */
X   strcpy (KeyWord[9], ".UNIX"); 	/* unix command line */
X   strcpy (KeyWord[10], ".GNAME"); 	/* menu name (used in goto menu) */
X   strcpy (KeyWord[11], ".AUTHORIZE"); 	/* login's authorized to run menu */
X   strcpy (KeyWord[12], ".TEXT"); 	/* display text at row and column */
X   strcpy (KeyWord[13], ".CURSOR"); 	/* where to put the cursor */
X   strcpy (KeyWord[14], ".EXIT"); 	/* exit menu program */
X   strcpy (KeyWord[15], ".SETENV"); 	/* set enviroment variable */
X   strcpy (KeyWord[16], ".SPACE"); 	/* put a space between options */
X   strcpy (KeyWord[17], ".POPMENU"); 	/* pop menu option */
X   strcpy (KeyWord[18], ".DEFINE_SCREEN");/* define a prompt screen */
X   strcpy (KeyWord[19], ".GETINPUT");	/* prompt screen */
X   strcpy (KeyWord[20], ".INCLUDE");	/* include a menu file */
X   strcpy (KeyWord[21], "*=*");		/* assignment - variable=value */
X
X   strcpy (KeyWord[22], ""); 		/* END OF LIST */
X
X
X/*
X**	SECTION 2:
X**	Starting with base 1.
X**	Identify function names to correspond with above keywords.
X**	These functions describe what is to be done when above keyword
X**	is found while parsing the "menu file".
X**	Every keyword needs a Parse??? function.
X*/
X
X   ParseKey[1] = ParseTitle;
X   ParseKey[2] = ParseOption;
X   ParseKey[3] = ParseOption;
X   ParseKey[4] = ParseBox;
X   ParseKey[5] = ParseBanner;
X   ParseKey[6] = ParseLine;
X   ParseKey[7] = ParseWindow;
X   ParseKey[8] = ParseComnt;
X   ParseKey[9] = ParseUnix;
X   ParseKey[10] = ParseGname;
X   ParseKey[11] = ParseAuthr;
X   ParseKey[12] = ParseText;
X   ParseKey[13] = ParseCursor;
X   ParseKey[14] = ParseOption;
X   ParseKey[15] = ParseOption;
X   ParseKey[16] = ParseSpace;
X   ParseKey[17] = ParseOption;
X   ParseKey[18] = ParseDefineScreen;
X   ParseKey[19] = ParseOption;
X   ParseKey[20] = ParInclude;
X   ParseKey[21] = ParAssign;
X
X
X/*
X**	SECTION 3:
X**	These functions describe what is to be done to display the
X**	option to the screen.  The option you loaded into OptionInfo.
X**	If set to NULL then the option is not displayed.
X*/
X
X   ShowKey[1] = NULL;
X   ShowKey[2] = ShowOption;
X   ShowKey[3] = ShowOption;
X   ShowKey[4] = NULL;
X   ShowKey[5] = NULL;
X   ShowKey[6] = NULL;
X   ShowKey[7] = NULL;
X   ShowKey[8] = NULL;
X   ShowKey[9] = NULL;
X   ShowKey[10] = NULL;
X   ShowKey[11] = NULL;
X   ShowKey[12] = NULL;
X   ShowKey[13] = NULL;
X   ShowKey[14] = ShowOption;
X   ShowKey[15] = ShowOption;
X   ShowKey[16] = NULL;
X   ShowKey[17] = ShowOption;
X   ShowKey[18] = NULL;
X   ShowKey[19] = ShowOption;
X   ShowKey[20] = NULL;
X   ShowKey[21] = NULL;
X
X
X/*
X**	SECTION 4:
X**	These functions explain what you want done when the user
X**	selects the option on the screen with the corresponding 
X**	keyword.
X**	If set to NULL the keyword becomes unselectable.
X*/
X
X   RunKey[1] = NULL;
X   RunKey[2] = RunMenu;
X   RunKey[3] = RunSystem;
X   RunKey[4] = NULL;
X   RunKey[5] = NULL;
X   RunKey[6] = NULL;
X   RunKey[7] = NULL;
X   RunKey[8] = NULL;
X   RunKey[9] = NULL;
X   RunKey[10] = NULL;
X   RunKey[11] = NULL;
X   RunKey[12] = NULL;
X   RunKey[13] = NULL;
X   RunKey[14] = RunExit;
X   RunKey[15] = RunSetenv;
X   RunKey[16] = NULL;
X   RunKey[17] = RunPopMenu;
X   RunKey[18] = NULL;
X   RunKey[19] = RunGetInput;
X   RunKey[20] = NULL;
X   RunKey[21] = NULL;
X}
SHAR_EOF
chmod 0444 LoadKeys.c || echo "restore of LoadKeys.c fails"
echo "x - extracting parsedrive.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > parsedrive.c &&
Xstatic char Sccsid[] = "@(#)parsedrive.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	parsedriver()
X**		This is the driver routine in parseing the menu
X**		file.  This function calls the appropriate parse
X**		function for that keyword.
X**  ARGS:	keyword		the keyword "AUTHORIZE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0	success
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X	int	swin, ewin, longest;
X
Xparsedriver (menufile, KeyWord, ParseKey, menu, gname, gfile, gindex)
X
X	FILE		*menufile;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	struct MenuInfo	*menu;
X	char		gname[][15], gfile[][15];
X	int		*gindex;
X{
X	char	keyword[80];
X	int	rcde, I, KEYFOUND;
X	int	opnumber = 0;				/* last option number */
X
X
X   	/* Set default .WINDOW area */
X   	menu->wfcol = 0;
X   	menu->wlcol = COLS-1;
X	menu->wfrow = 0;
X   	menu->wlrow = LINES-1;
X   	menu->titlecount = 0;
X   	menu->optioncount = 0;
X   	swin = ewin = longest = 0;
X
X   	/* loop through each keyword */
X   	rcde = fscanf (menufile, "%s", keyword);
X   	while (rcde != EOF)
X   	{
X		if (strlen (keyword) >= 80-2)
X		{
X      			BEEP;
X      			mvprintw (ErrRow-2, 0, 
X				"Your keyword <%s> is toooo looong.  Max = %d",
X				keyword, 80-2);
X      			shutdown ();
X		}
X		/*
X		**  Check if we found a defined keyword
X		*/
X      		KEYFOUND = FALSE;
X      		for (I = 1; I <= MAXKEYS; I++)
X      		{
X			/*
X         		if (strcmp (keyword, KeyWord[I]) == 0)
X			*/
X         		if (strmatch (keyword, KeyWord[I]))
X         		{
X            			KEYFOUND = TRUE;
X	    			if (ParseKey[I] != NULL)
X	    			{
X               				rcde = (*ParseKey[I]) (keyword, 
X						menufile, menu, KeyWord, 
X						ParseKey, gname, gfile, gindex, 
X						&opnumber);
X					/*
X					** The return code from each parse
X					** function must be 0 in order to
X					** continue.
X					*/
X	       				if (rcde != 0)   return (rcde);
X	    			}
X            			break;
X         		}
X      		}
X      		if (!KEYFOUND)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, "ERROR: (%s) Key not found.", 
X					keyword);
X         		shutdown ();
X      		}
X      		rcde = fscanf (menufile, "%s", keyword);
X   	} 
X
X   	EndWindow (menu);
X   	return (0);
X}
SHAR_EOF
chmod 0444 parsedrive.c || echo "restore of parsedrive.c fails"
echo "x - extracting showdriver.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > showdriver.c &&
Xstatic char Sccsid[] = "@(#)showdriver.c	1.2   DeltaDate 10/16/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	showdriver()
X**		The driver module to initially display the options
X**		to the screen.
X**  ARGS:	keyword		the keyword found
X**		ShowKey		show functions
X**		menu		menu structure
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
Xshowdriver (KeyWord, ShowKey, menu)
X
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ShowKey[])();
X	struct MenuInfo	*menu;
X{
X	int		i, j;
X
X
X
X	/*
X	**	Loop through options and call apropriate function.
X	*/
X
X   	for (i = 0; i < menu->optioncount; i++)
X      		for (j = 1; j <= MAXKEYS; j++)
X         		if (strcmp (menu->option[i]->keyword, KeyWord[j]) == 0)
X	 		{
X	    			if (ShowKey[j] != NULL)   
X					(*ShowKey[j]) (menu, i);
X	    			break;
X	 		}
X   	refresh ();
X}
SHAR_EOF
chmod 0444 showdriver.c || echo "restore of showdriver.c fails"
echo "x - extracting rundriver.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > rundriver.c &&
Xstatic char Sccsid[] = "@(#)rundriver.c	1.11   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	rundriver()
X**		The driver module to run each selectable option.
X**		Runmenu will call the appropriate run function
X**		for that keyword.
X**  ARGS:	keyword		the keyword "AUTHORIZE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	QUIT		exit pgm
X**		MAIN		go to main menu
X**		PREVIOUS	go to previous menu
X**		index to submenu
X*/
X
X#include	<curses.h>
X#include	<signal.h>
X#include	"menu.h"
X#include	"terminal.h"
X
X#define		INITMENU	0
X#define		GOTOMENU	1
X
Xextern int	MAILCALL;
X
X
Xrundriver (KeyWord, RunKey, ShowKey, ParseKey, menu, option, gnames, 
X		gfiles, gindex, gotorow, gotocol)
X
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*RunKey[])(), *option;
X	int		(*ShowKey[])();
X	int		(*ParseKey[])();
X	struct MenuInfo	*menu;
X	char		gnames[][15], gfiles[][15];
X	int		gindex;
X	int		gotorow;
X	int		gotocol;
X{
X	FILE		*fopen(), *fp;
X	char		*findfile();
X	char		select[78], command[200];
X	char		matchstr[60];
X	int		exitkey, index;
X	int		i, j;
X	int		lastopnumber = 0;		/* last option # */
X	int		MATCHED;			/* char match flag */
X	int		ch;
X
X
X	/*
X   	**  What is the last option number ?
X   	*/
X	for (i = menu->optioncount-1; i >= 0; i--)
X		if (menu->option[i]->opnumber != 0)
X		{
X			lastopnumber = menu->option[i]->opnumber;
X			break;
X		}
X
X	if (lastopnumber <= 0)   return (QUIT);		/* no options */
X	select[0] = '\0';
X	matchstr[0] = '\0';
X
X	/*
X   	**  Loop through options untill user exits menu or selects
X   	**  another menu.
X   	*/
X	for (;;)
X	{
X#ifndef ALARM
X		if (MAILCALL)
X			checkmail ();
X#endif
X
X		/* highlight current option */
X/*
X#ifdef BSD
X		standout ();
X#else
X		attrset (A_REVERSE);
X#endif
X*/
X
X		for (i = 1; i <= MAXKEYS  &&  KeyWord[i] != NULL; i++)
X			if (strcmp (menu->option[*option-1]->keyword, 
X				    KeyWord[i]) == 0)
X			{
X				if (ShowKey[i] != NULL)
X				{
X					/* display option */
X					(*ShowKey[i]) (menu, (*option)-1);
X					mvaddch (menu->option[(*option)-1]->row,
X					       menu->option[(*option)-1]->col-1,
X					       ' ');
X					/*
X					** turn on reverse video 
X					** maintaining current attributes
X					*/
X					exitkey =  slength(menu->option[(*option)-1]->description) + menu->option[(*option)-1]->col + 5;
X					for (j = menu->option[(*option)-1]->col-1; j <= exitkey; j++)
X					{
X						ch = mvinch (menu->option[(*option)-1]->row, j);
X						ch |= A_REVERSE;
X						mvaddch (menu->option[(*option)-1]->row, j, ch);
X					}
X
X				}
X				break;
X			}
X
X#ifdef BSD
X		standend ();
X#else
X		attrset (A_NORMAL);
X#endif
X
X		if (RunKey[i] != NULL)
X			exitkey = GetOption (menu->row_cursor, menu->col_cursor,
X					     select);
X		else
X			/* so we don't go in a loop */
X			exitkey = (exitkey == KEY_UP || 
X			           exitkey == KeyUp) ? KEY_UP : KEY_DOWN;
X
X		if (exitkey == KeyDown)   	exitkey = KEY_DOWN;
X		if (exitkey == KeyUp)		exitkey = KEY_UP;
X		if (exitkey == KeyTab)		exitkey = KEY_TAB;
X		if (exitkey == KeyBTab)		exitkey = KEY_BTAB;
X		if (exitkey == KeyReturn)	exitkey = KEY_RETURN;
X		if (exitkey == KeyMainMenu)	exitkey = KEY_MAINMENU;
X		if (exitkey == KeyPrevMenu)	exitkey = KEY_PREVMENU;
X		if (exitkey == KeyExitMenu)	exitkey = KEY_EXITMENU;
X		if (exitkey == KeyGname)	exitkey = KEY_GNAME;
X
X		/* unhighlight current option */
X		if (ShowKey[i] != NULL)
X		{
X			mvaddch (menu->option[(*option)-1]->row, 
X			    menu->option[(*option)-1]->col-1, ' ');
X			strcat (menu->option[(*option)-1]->description, " ");
X			(*ShowKey[i]) (menu, *option-1);
X			menu->option[(*option)-1]->description[strlen(menu->option[(*option)-1]->description)-1] = '\0';
X
X			/*
X			mvaddch (menu->option[(*option)-1]->row, 
X			    menu->option[(*option)-1]->col + 
X			    strlen (menu->option[(*option)-1]->description)+5, 
X			    ' ');
X			    */
X		}
X
X
X		switch (exitkey)
X		{
X		case KEY_DOWN:
X		case 'j':
X			*option =*option >= menu->optioncount ? 1 : ++(*option);
X			break;
X
X		case KEY_UP:
X		case 'k':
X			*option =*option <= 1 ? menu->optioncount : --(*option);
X			break;
X
X		case KEY_TAB:
X			/* A tab will hop forward four options at a time. */
X			if (menu->optioncount > 4)
X			{
X				*option += 4;
X				if (*option > menu->optioncount)
X					*option = 1 + *option - 
X						  menu->optioncount - 1;
X			}
X			else
X				*option = *option >= menu->optioncount ? 1 : 
X					  ++(*option);
X			break;
X
X		case KEY_BTAB:
X			/* A back tab will hop backward 4 options at a time. */
X			if (menu->optioncount > 4)
X			{
X				*option -= 4;
X				if (*option < 0)
X					*option = menu->optioncount - abs(*option);
X			}
X			else
X				*option = *option <= 1 ? menu->optioncount:--(*option);
X			break;
X
X		/*
X		**	This section is to highlight the selected option 
X		**	before the user presses the return_key to select it.
X		*/
X		case '0':
X		case '1':
X		case '2':
X		case '3':
X		case '4':
X		case '5':
X		case '6':
X		case '7':
X		case '8':
X		case '9':
X			sprintf (select, "%s%c", select, exitkey);
X			if (matoi (select) < 1  ||  
X			    matoi (select) > lastopnumber)
X			{
X				/* Invalid Option */
X				attrset (A_REVERSE);
X				mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
X				attrset (A_NORMAL);
X				select[0] = '\0';
X			}
X			else
X			{
X				/* find the element cooresponding to opnumber */
X				for (i = 0; i < menu->optioncount; i++)
X					if (matoi(select) == menu->option[i]->opnumber)
X					{
X						*option = i+1;
X						break;
X					}
X			}
X			break;
X
X	        case 'A':
X	        case 'B':
X	        case 'C':
X	        case 'D':
X	        case 'E':
X	        case 'F':
X	        case 'G':
X	        case 'H':
X	        case 'I':
X	        case 'J':
X	        case 'K':
X	        case 'L':
X	        case 'M':
X	        case 'N':
X	        case 'O':
X	        case 'P':
X	        case 'Q':
X	        case 'R':
X	        case 'S':
X	        case 'T':
X	        case 'U':
X	        case 'V':
X	        case 'W':
X	        case 'X':
X	        case 'Y':
X	        case 'Z':
X	        case ' ':
X			/* character matching */
X			sprintf (matchstr, "%s%c", matchstr, exitkey);
X			MATCHED = FALSE;
X			for (i = 0; i < menu->optioncount; i++)
X			{
X				strcpy (command, menu->option[i]->description);
X				upper (command);
X				if (strncmp (command, matchstr, 
X				    strlen(matchstr)) == 0)
X				{
X					MATCHED = TRUE;
X					sprintf (select, "%d", 
X						menu->option[i]->opnumber);
X					*option = i + 1;
X					break;
X				}
X			}
X			if (!MATCHED)
X				strcpy (matchstr, "");
X			break;
X
X		case KEY_EXITMENU:
X			/* check if we have a .EXIT option */
X			for (i = 0; i < menu->optioncount; i++)
X				if (strcmp (menu->option[i]->keyword, ".EXIT") == 0)
X					RunExit (menu, i, KeyWord, ParseKey, ShowKey, 
X					    RunKey, gnames, gfiles, gindex);
X			return (QUIT);
X
X		case KEY_MAINMENU:
X			return (MAINMENU);
X
X		case KEY_PREVMENU:
X			return (PREVIOUSMENU);
X
X		case '!':
X			/*
X		**	Shell Option.
X		**	Prompt user for a command to be executed within a 
X		**      shell (system(1)).
X		*/
X			select[0] = '\0';
X			mvaddch (ErrRow, 0, '!');
X			move (ErrRow, 1);
X			echo ();
X			refresh ();
X#ifdef ALARM
X			alarm (0);		/* turn off mail check */
X			signal (SIGALRM, SIG_IGN);
X#endif
X			getstr (select);
X#ifdef ALARM
X			if (MAILCALL)
X				checkmail ();
X#endif
X			noecho ();
X			sprintf (command, "%s;runrealid \"%s\";%s;%s",
X#if BSD || SUN
X			    "clear",
X#else
X			    "tput clear",
X#endif
X			    select,
X			    "echo \"\\n[Press return to continue]\\c\"",
X			    "read reply");
X			reset_shell_mode ();
X			system (command);
X			reset_prog_mode ();
X			move (ErrRow,0);
X			clrtoeol ();
X			select[0] = '\0';
X			matchstr[0] = '\0';
X			clearok (stdscr, TRUE);
X			break;
X
X		case KEY_HELP:
X		/*
X		**	Show Help Screen Option.
X		**	Search directories for a menu.hlp file.
X		**	If found display to screen.
X		*/
X			strcpy (command, findfile ("menu.hlp", ".",
X			    getenv("HELPDIR"), getenv("MENUDIR"),
X			    ""));
X#ifdef ALARM
X			alarm (0);		/* turn off mail check */
X			signal (SIGALRM, SIG_IGN);
X#endif
X			ShowHelp (command, "menu", ErrRow);
X#ifdef ALARM
X			if (MAILCALL)
X				checkmail ();
X#endif
X			clearok (stdscr, TRUE);
X			select[0] ='\0';
X			matchstr[0] ='\0';
X			break;
X
X		case KEY_GNAME:
X			/*
X			**	Goto Menu option
X			**	Prompt user for the Gname (goto menu name) 
X			**	that the user wants to go to.
X			**	And then return GNAMEOFFSET + gindex to main.  
X			**	The > GNAMEOFFSET indicates a goto menu option.
X			*/
X			select[0] = '\0';
X			echo ();
X			mvprintw (ErrRow, 0, "Goto ");
X#ifdef ALARM
X			alarm (0);		/* turn off mail check */
X			signal (SIGALRM, SIG_IGN);
X#endif
X			getstr (select);
X#ifdef ALARM
X			if (MAILCALL)
X				checkmail ();
X#endif
X			noecho ();
X			for (i = 0; i < gindex; i++)
X			{
X				if (strcmp (select, gnames[i]) == 0)
X					return (GNAMEOFFSET + i);
X			}
X			BEEP;
X			attrset (A_REVERSE);
X			mvprintw (ErrRow, 0, "[%s] not found.", select);
X			attrset (A_NORMAL);
X			select[0] = '\0';
X			matchstr[0] ='\0';
X			break;
X
X		case KEY_RETURN:
X		case KEY_LINEFEED:
X			/*
X			**	We now take an action based upon what is in 
X			**	select - that which the user typed in.
X			*/
X			if (select[0] == KeyExitMenu)
X			{
X				/* check if we have a .EXIT option */
X				for (i = 0; i < menu->optioncount; i++)
X					if (strcmp (menu->option[i]->keyword, 
X					    ".EXIT") == 0)
X					{
X						RunExit (menu, i, KeyWord,
X						    ParseKey, ShowKey, RunKey,
X						    gnames, gfiles, gindex);
X						break;
X					}
X				return (QUIT);
X			}
X			if (select[0] == KeyMainMenu)	return (MAINMENU);
X			if (select[0] == KeyPrevMenu)	return (PREVIOUSMENU);
X
X			/*
X			**	Goto Menu option
X			**	Prompt user for the Gname (goto menu name) 
X			**	that the user wants to go to.
X			**	And then return GNAMEOFFSET + gindex to main.  
X			**	The > GNAMEOFFSET indicates a goto menu option.
X			*/
X			if (select[0] == KeyGname)
X			{
X				select[0] = '\0';
X				echo ();
X				mvprintw (ErrRow, 0, "Goto ");
X#ifdef ALARM
X				alarm (0);	/* turn off mail check */
X				signal (SIGALRM, SIG_IGN);
X#endif
X				getstr (select);
X#ifdef ALARM
X				if (MAILCALL)
X					checkmail ();
X#endif
X				noecho ();
X				for (i = 0; i < gindex; i++)
X				{
X					if (strcmp (select, gnames[i]) == 0)
X						return (GNAMEOFFSET + i);
X				}
X				BEEP;
X				attrset (A_REVERSE);
X				mvprintw (ErrRow, 0, "[%s] not found.", select);
X				attrset (A_NORMAL);
X				select[0] = '\0';
X				matchstr[0] ='\0';
X				break;
X			}
X
X			/*
X			**	Show Help Screen Option.
X			**	Search directories for a menu.hlp file.
X			**	If found display to screen.
X			*/
X			if (select[0] == KeyHelp)
X			{
X				strcpy (command, findfile ("menu.hlp", 
X					".", getenv("HELPDIR"), 
X					getenv("MENUDIR"), ""));
X#ifdef ALARM
X				alarm (0);		/* turn off mail check */
X				signal (SIGALRM, SIG_IGN);
X#endif
X				ShowHelp (command, "menu", ErrRow);
X#ifdef ALARM
X				if (MAILCALL)
X					checkmail ();
X#endif
X				clearok (stdscr, TRUE);
X				select[0] ='\0';
X				matchstr[0] ='\0';
X				break;
X			}
X
X
X			/*
X			**	The user has manually typed in a option to be 
X			**	executed.  Execute the appropriate option.
X			*/
X			if (strlen (select) > 0)
X			{
X				index = matoi (select);
X				if (index < 1  ||  index > lastopnumber)
X				{
X					/* Invalid Option */
X					attrset (A_REVERSE);
X					mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
X					attrset (A_NORMAL);
X					select[0] = '\0';
X					break;
X				}
X				/* find the element cooresponding to opnumber */
X				for (i = 0; i < menu->optioncount; i++)
X					if (index == menu->option[i]->opnumber)
X					{
X						*option = i+1;
X						break;
X					}
X			}
X
X			/*
X			**  Run the option the user selected.
X			*/
X			for (i = 1; i <= MAXKEYS; i++)
X				if (strcmp (menu->option[*option-1]->keyword, 
X				    KeyWord[i]) == 0)
X				{
X					if (RunKey[i] != NULL)
X					{
X#ifdef ALARM
X						alarm (0); /* turn off mail */
X						signal (SIGALRM, SIG_IGN);
X#endif
X						exitkey = (*RunKey[i]) (menu, *option-1, KeyWord,
X						    ParseKey, ShowKey, RunKey,
X						    gnames, gfiles, gindex);
X						/* .MENU is a special case */
X						if (exitkey == SUBMENU)
X							return (*option-1);
X						if (exitkey == MAINMENU)
X							return (MAINMENU);
X						if (exitkey == PREVIOUSMENU)
X							return (PREVIOUSMENU);
X						if (exitkey == QUIT)
X							return (QUIT);
X						if (exitkey == REPARSE)
X							return (REPARSE);
X						if (exitkey >= GNAMEOFFSET  &&  
X						    exitkey <= GNAMEOFFSET + gindex)
X							return (exitkey);
X#ifdef ALARM
X						if (MAILCALL)
X							checkmail ();
X#endif
X					}
X					break;
X				}
X			select[0] = '\0';
X			matchstr[0] = '\0';
X			break;
X
X		default:
X			if (exitkey == KeyPopGname  &&  gindex > 0)
X			{
X				/*
X				**   Popup menu for goto names.
X				*/
X#ifdef ALARM
X				alarm (0);	/* turn off mail check */
X				signal (SIGALRM, SIG_IGN);
X#endif
X				popmenu (INITMENU, GOTOMENU, gotorow, gotocol, 
X				    "GOTO MENU", HELPFILE, LINES-2, 
X				    sizeof(gnames[0]), gnames);
X
X				move (ErrRow,0);
X				clrtoeol ();
X				BEEP;
X				mvprintw (ErrRow, 0, "Goto what menu ?");
X				refresh ();
X				exitkey = popmenu (GOTOMENU);
X				touchwin (stdscr);
X				refresh ();
X#ifdef ALARM
X				if (MAILCALL)
X					checkmail ();
X#endif
X				if (exitkey >= 1  &&  exitkey <= gindex)
X					return (GNAMEOFFSET + exitkey-1);
X			}
X
X			move (ErrRow,0);
X			clrtoeol ();
X			mvprintw (ErrRow, 0, "Say What.");
X			select[0] = '\0';
X			matchstr[0] = '\0';
X			break;
X		}
X	}
X}
X
X
X
X/*
X**  My ascii to integer
X**  Return -1 if string contains more than digits.
X*/
Xmatoi (s)
X	char	*s;
X{
X	int	value;
X
X	value = atoi (s);
X	while (*s)
X	{
X		if (*s < '0' || *s > '9')
X			return (-1);
X		s++;
X	}
X	return (value);
X}
SHAR_EOF
chmod 0444 rundriver.c || echo "restore of rundriver.c fails"
echo "x - extracting ParseOpton.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseOpton.c &&
Xstatic char Sccsid[] = "@(#)ParseOpton.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseOption()
X**		This function parses user selectable options.
X**  ARGS:	keyword		the keyword found
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
Xextern	int	debug;
X
X
XParseOption (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
Xgindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	struct OptionInfo	*malloc();
X	char			*getval();
X	char		*fgets(), line[MAXLEN+100];
X	int		i = 0;
X	int		j;
X	char		*ws;
X
X
X	if (menu->optioncount >= MAXOPTION)
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, "Exceeded maximum allowable options.");
X		shutdown ();
X	}
X	menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
X	if (menu->option[menu->optioncount] == NULL)
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, "Unable to allocate memory for option.");
X		shutdown ();
X	}
X
X	strcpy (menu->option[menu->optioncount]->keyword, keyword);
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X	fgets (line, BUFSIZE, menufile);
X	line[strlen(line)-1] = '\0';			/* get rid of \n */
X	while (line[strlen(line)-1] == '\\')
X	{
X		if (strlen(line) >= MAXLEN)
X		{
X			BEEP;
X			mvprintw (ErrRow-2, 0, 
X			    "Option command is too long.  Max = %d",MAXLEN);
X			shutdown ();
X		}
X		line[strlen(line)-1] = '\n';		/* replace \ with \n */
X		fgets (line+strlen(line), BUFSIZE, menufile);
X		line[strlen(line)-1] = '\0';		/* get rid of \n */
X	}
X	strcpy (menu->option[menu->optioncount]->command, line);
X	if (debug)
X	{
X		fprintf (stderr, "\n[ParseOpton] <%s> command=:%s:",
X		    keyword, menu->option[menu->optioncount]->command);
X		fflush (stderr);
X	}
X
X	/*
X	**	Read in option description
X	*/
X	fgets (line, BUFSIZE+1, menufile);
X	line[strlen(line)-1] = '\0';
X	for (j = 0, i = 0; i < strlen (line); j++, i++)
X		if (line[i] == '$')
X		{
X			char    *sptr, *b4ptr;
X
X			sptr = b4ptr = line+i;
X			strcpy (menu->option[menu->optioncount]->description+j, 
X				getval (&sptr, '$'));
X			i += (int)(sptr - b4ptr);
X			j += strlen (menu->option[menu->optioncount]->description+j) - 1;
X			i--;
X		}
X		else
X		{
X			menu->option[menu->optioncount]->description[j] = line[i];
X		}
X	menu->option[menu->optioncount]->description[j] = '\0';
X
X
X	/*
X	**	Determine length of longest option
X	*/
X	if (slength (menu->option[menu->optioncount]->description) > longest)
X		longest = slength(menu->option[menu->optioncount]->description);
X
X	/* set option number 2b displayed */
X	(*opnumber)++;
X	menu->option[menu->optioncount]->opnumber = *opnumber;
X
X	menu->optioncount++;
X	ewin++;
X	return (0);
X}
SHAR_EOF
chmod 0444 ParseOpton.c || echo "restore of ParseOpton.c fails"
echo "x - extracting ParseBaner.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseBaner.c &&
Xstatic char Sccsid[] = "@(#)ParseBaner.c	1.4   DeltaDate 11/13/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseBanner()
X**		Parses the "BANNER" keyword.
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
XParseBanner (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	static int	onetime = FALSE;		/* show only 1 time */
X	int	row, col, rstart, rstop, cstart, cstop;
X	int	ulc=0, llc=0, linecount, increment;
X	char	flag[5], upper[4][30], lower[4][30];
X
X
X   fscanf (menufile, "%d", &linecount);
X
X/*
X**	Load the input banner text into upper and lower arrays.
X*/
X
X   for (row = 1; row <= linecount; row++)
X   {
X      fscanf (menufile, "%s", flag);
X      if (strncmp (flag, ".U", 2) == 0)
X      {
X         fgets (upper[ulc], 80, menufile);
X         upper[ulc][strlen(upper[ulc])-1] = '\0';
X         ulc++;
X      }
X      else
X      {
X         fgets (lower[llc], 80, menufile);
X         lower[llc][strlen(lower[llc])-1] = '\0';
X         llc++;
X      }
X   }
X
X   if (onetime)
X	return (0);
X   onetime++;
X
X#ifdef BSD
X   standout ();
X#else
X   attrset (A_STANDOUT);
X#endif
X   for (rstart = 24/2-1, rstop = 24/2+1, 
X        cstart = COLS/2-2, cstop = COLS/2+1;
X        rstart >= 0 && rstop <= 23 && cstart >= 0 && cstop <= COLS-1;
X        rstart--, rstop++, cstart-=3, cstop+=3)
X   {
X      for (row = rstart; row <= rstop; row++)
X      {
X         if (row == rstart  ||  row == rstop)
X         {
X            for (col = cstart; col <= cstop; col++)
X               mvaddch (row, col, BORDERCHAR);
X         }
X         else
X         {
X            mvaddch (row, cstart, BORDERCHAR);
X            mvaddch (row, cstop, BORDERCHAR);
X         }
X      }
X      refresh ();
X   }
X
X   increment = 2;
X   for (rstart = rstart+3, rstop=rstop-2, cstart = cstart+1, cstop = cstop-1;
X        cstart >= 0  &&  cstop <= COLS-1;
X        rstart++, rstop--, cstart-=increment, cstop+=increment)
X   {
X      for (row = 1; row <= 23; row++)
X      {
X         if (row < rstart  ||  row > rstop)
X         {
X            for (col = cstart; col <= cstart+increment; col++)
X               mvaddch (row, col, BORDERCHAR);
X            for (col = cstop-increment; col <= cstop; col++)
X               mvaddch (row, col, BORDERCHAR);
X         }
X         else
X         {
X            mvaddch (row, cstart, BORDERCHAR);
X            mvaddch (row, cstop, BORDERCHAR);
X         }
X      }
X      refresh ();
X   }
X
X#ifdef BSD
X   standout ();
X#else
X   attrset (A_REVERSE);
X#endif
X   for (row = 0; ulc > 0; row++, ulc--)
X      mvprintw (row+4, COLS/2-strlen(upper[row])/2-1, "%s", upper[row]);
X   for (row = 0; llc > 0; row++, llc--)
X      mvprintw (row+17, COLS/2-strlen(lower[row])/2-1, "%s", lower[row]);
X
X   mvprintw (23, 27, "Press return to continue");
X   move (23,0);
X   getch ();
X   refresh ();
X#ifdef BSD
X   standend ();
X#else
X   attrset (A_NORMAL);
X#endif
X   move (0,0); clrtobot ();
X   return (0);
X}
SHAR_EOF
chmod 0444 ParseBaner.c || echo "restore of ParseBaner.c fails"
echo "x - extracting ParseTitle.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseTitle.c &&
Xstatic char Sccsid[] = "@(#)ParseTitle.c	1.8   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseTitle()
X**		Parses keyword "TITLE".
X**  ARGS:	keyword		the keyword "TITLE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
Xextern int	MAILCALL;
Xextern int	mailrow;
Xextern int	mailcol;
X
X
XParseTitle (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets(), line[201];
X	char	*getenv();
X	char	*getval();
X	char	section[3][201];	      /* section[0] = left justified */
X					      /* section[1] = centered */
X					      /* section[2] = right justified */
X	int	i = 0;			      /* index into line */
X	int	j;			      /* index into section */
X	int	k, row, col;
X	char	*ws;
X	int	mailsection=999;	      /* section $MAIL was found */
X					      /* we set to 999 so sub menus */
X					      /* that don't have a $MAIL wont */
X					      /* recalculate mailcol */
X
X
X
X   fgets (line, 200, menufile);
X
X/*
X**	Get title line
X*/
X   fgets (line, 200, menufile);
X   line[strlen(line)-1] = '\0';
X   
X   section[0][0] = section[1][0] = section[2][0] = '\0';
X
X/*
X**	Now we break input line into left, center, and right sections
X**	Loop through each section.
X*/
X
X   for (k = 0; k <= 2; k++)
X   {
X      /* Loop through each character of line until we find next section */
X      for (j = 0; i < strlen (line)  &&  strncmp (line+i, "...", 3) != 0;
X          i++, j++)
X      {
X         if (strncmp (line+i, "$DATE", 5) == 0)
X         {
X            sysdate (section[k]+j, "mm/dd/yy");
X            j += 7;
X            i += 4;
X         }
X         else
X            if (strncmp (line+i, "$TIME", 5) == 0)
X            {
X               systime (section[k]+j, "HH:MM zz");
X               j += 7;
X               i += 4;
X            }
X            else
X               if (strncmp (line+i, "$MAIL", 5) == 0)
X	       {
X		  /*
X		  **  User wants 2b notified when mail arrives.
X		  **  The mailfile is located in enviroment $MAIL
X		  **  if the mailfile exists and size is greater than zero
X		  **  mailfile = getenv("$MAIL")
X		  **  We need to process entire line b4 we find mailcol
X		  */
X		  MAILCALL = TRUE;
X		  strcpy (section[k]+j, "mAiL");	/* unique ? */
X		  mailrow = menu->titlecount;
X		  mailsection = k;
X                  i += 4;				/* get past $MAIL */
X                  j += 3;				/* for "MAIL" */
X	       }
X	       else
X		  /*
X		  **  A environment variable
X		  */
X                  if (line[i] == '$')
X   	          {
X			char	*sptr, *b4ptr;
X
X		     sptr = b4ptr = line+i;
X		     strcpy (section[k]+j, getval (&sptr, '$'));
X		     i += (int)(sptr - b4ptr);
X		     j += strlen (section[k]+j) - 1;
X		     i--;
X	          }
X	          else
X                     section[k][j] = line[i];
X      }
X      section[k][j] = '\0';
X      i += 3;
X   }
X
X   if (menu->titlecount >= MAXTITLE)
X   {
X      BEEP;
X      mvprintw (ErrRow, 0, "Number of Title lines exceed the maximim.");
X      shutdown ();
X   }
X   (menu->titlecount)++;
X   (menu->wfrow)++;			/* reduce window size to center in */
X
X
X/*
X**	Now we display the three sections to the screen
X*/
X
X   for (k = 0; k <= 2; k++)
X   {
X/*
X**	First we must find out what column to start displaying on.
X**	Taking into account the terminal attribute characters.
X*/
X      switch (k)
X      {
X         case 0:
X			/* left justified */
X			row = menu->titlecount - 1;
X			col = 0;
X			break;
X	 case 1:
X			/* center */
X			for (i = 0, j = 0; section[k][i] != '\0'; i++)
X			   if (section[k][i] == '\\') j++;
X			col = COLS/2-(strlen(section[k])-j*2)/2;
X			col -= (((strlen(section[k])-j*2) % 2) == 0) ? 0 : 1;
X			row = menu->titlecount - 1;
X			move (menu->titlecount-1, i); 
X			break;
X	 case 2:
X			/* right justify */
X			for (i = 0, j = 0; section[k][i] != '\0'; i++)
X			   if (section[k][i] == '\\') j++;
X			row = menu->titlecount - 1;
X			col = COLS-strlen(section[k])+j*2;
X			break;
X      }  /* end switch */
X
X      if (MAILCALL  &&  mailsection == k)
X      {
X         /* find mailcol - remember the attributes */
X         for (i = 0, j = 0; section[k][i] != '\0' &&
X              strncmp (section[k]+i, "mAiL", 4) != 0; i++)
X            if (section[k][i] == '\\') j++;
X         mailcol = i - j*2 + col;		/* for \R */
X	 memcpy (section[k]+i, "    ", 4);		/* get rid of mAiL */
X      }
X
X      displaytext (row, col, section[k]);
X   }  /* end for loop */
SHAR_EOF
echo "End of part 3"
echo "File ParseTitle.c is continued in part 4"
echo "4" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 4 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ParseTitle.c continued
#
CurArch=4
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 ParseTitle.c"
sed 's/^X//' << 'SHAR_EOF' >> ParseTitle.c
X#ifdef ALARM
X   if (MAILCALL)
X      checkmail ();
X#endif
X   return (0);
X}
SHAR_EOF
echo "File ParseTitle.c is complete"
chmod 0444 ParseTitle.c || echo "restore of ParseTitle.c fails"
echo "x - extracting ParseBox.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseBox.c &&
Xstatic char Sccsid[] = "@(#)ParseBox.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseBox()
X**		Parses keyword ".BOX".
X**  ARGS:	keyword		the keyword "BOX"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XParseBox (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*fgets(), line[BUFSIZE+1];
X	char		boxtype[30];
X	char		*sptr;
X
X	/* Default Values */
X	menu->boxtype = StandoutLine;
X	menu->boxtype = menu->boxtype | (DumbLine << 9);
X
X	fgets (line, BUFSIZE, menufile);
X	sptr = line;
X	SKIPJUNK(sptr);
X
X	/* get border type for active menu */
X	sscanf (sptr, "%s", boxtype);
X	sptr += strlen(boxtype);
X	if (strcmp (boxtype, "DumbLine") == 0)
X		menu->boxtype = DumbLine;
X	else	if (strcmp (boxtype, "StandoutLine") == 0)
X			menu->boxtype = StandoutLine;
X	else	if (strcmp (boxtype, "SingleLine") == 0 ||
X		    strcmp (boxtype, "DrawLine") == 0)
X			menu->boxtype = SingleLine;
X	else	if (strcmp (boxtype, "MosaicLine") == 0)
X			menu->boxtype = MosaicLine;
X	else	if (strcmp (boxtype, "DiamondLine") == 0)
X			menu->boxtype = DiamondLine;
X	else	if (strcmp (boxtype, "DotLine") == 0)
X			menu->boxtype = DotLine;
X	else	if (strcmp (boxtype, "PlusLine") == 0)
X			menu->boxtype = PlusLine;
X
X	/* get border type for inactive menu - dim (high 8 bits) */
X	sscanf (sptr, "%s", boxtype);
X	sptr += strlen(boxtype);
X	if (strcmp (boxtype, "DumbLine") == 0)
X		menu->boxtype = menu->boxtype | (DumbLine << 9);
X	else	if (strcmp (boxtype, "StandoutLine") == 0)
X			menu->boxtype = menu->boxtype | (DumbLine << 9);
X	else	if (strcmp (boxtype, "SingleLine") == 0 ||
X		    strcmp (boxtype, "DrawLine") == 0)
X			menu->boxtype = menu->boxtype | (SingleLine << 9);
X	else	if (strcmp (boxtype, "MosaicLine") == 0)
X			menu->boxtype = menu->boxtype | (MosaicLine << 9);
X	else	if (strcmp (boxtype, "DiamondLine") == 0)
X			menu->boxtype = menu->boxtype | (DiamondLine << 9);
X	else	if (strcmp (boxtype, "DotLine") == 0)
X			menu->boxtype = menu->boxtype | (DotLine << 9);
X	else	if (strcmp (boxtype, "PlusLine") == 0)
X			menu->boxtype = menu->boxtype | (PlusLine << 9);
X
X	drawbox (stdscr, 1,1, LINES-1,COLS, menu->boxtype & 0777, StandoutLine,
X		FALSE, FALSE);
X   	return (0);
X}
SHAR_EOF
chmod 0444 ParseBox.c || echo "restore of ParseBox.c fails"
echo "x - extracting ParseWindo.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseWindo.c &&
Xstatic char Sccsid[] = "@(#)ParseWindo.c	1.4   DeltaDate 11/13/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseWindow()
X**		Parses keyword ".WINDOW".
X**  ARGS:	keyword		the keyword "WINDOW"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
X
XParseWindow (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	int		i, j, row, col;
X	char		line[BUFSIZE];
X
X
X   EndWindow (menu);
X
X   fscanf (menufile, "%d", &menu->wfrow);
X   if (menu->wfrow < 0)   menu->wfrow = 0;
X   if (menu->wfrow < menu->titlecount) menu->wfrow = menu->titlecount;
X   if (menu->wfrow > LINES-1)   menu->wfrow = LINES-1;
X   fscanf (menufile, "%d", &menu->wlrow);
X   if (menu->wlrow < 0)   menu->wlrow = 0;
X   if (menu->wlrow > LINES-1)   menu->wlrow = LINES-1;
X   fscanf (menufile, "%d", &menu->wfcol);
X   if (menu->wfcol < 0)   menu->wfcol = 0;
X   if (menu->wfcol > COLS-1)   menu->wfcol = COLS-1;
X   fscanf (menufile, "%d", &menu->wlcol);
X   if (menu->wlcol < 0)   menu->wlcol = 0;
X   if (menu->wlcol > COLS-1)   menu->wlcol = COLS-1;
X
X/*
X**	Now lets read in the window heading.
X*/
X   fgets (line, BUFSIZE+1, menufile);
X   line[strlen(line)-1] = '\0';
X
X/*
X**	Determine where to display heading.
X*/
X   for (i = 0, j = 0; line[i] != '\0'; i++)
X      if (line[i] == '\\') j++;
X   row = menu->wfrow - 1;
X   col = (menu->wlcol - menu->wfcol)/2-(strlen(line)-1-j*2)/2 + menu->wfcol;
X   col -= (((strlen(line)-1-j*2) % 2) == 0) ? 0 : 1;
X   if (strlen(line) > 0)   displaytext (row, col, line+1);
X   
X   longest = 0;
X   swin = ewin;
X   return (0);
X}
SHAR_EOF
chmod 0444 ParseWindo.c || echo "restore of ParseWindo.c fails"
echo "x - extracting ParseLine.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseLine.c &&
Xstatic char Sccsid[] = "@(#)ParseLine.c	1.6   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseLine()
X**		Parses keyword "LINE".
X**  ARGS:	keyword		the keyword "LINE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
X
XParseLine (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	int	col;
X	char		*fgets(), line[BUFSIZE+1];
X	char		linetype[30];
X	char		*sptr;
X
X
X	/* default values */
X	menu->linetype = StandoutLine;
X	menu->linetype = menu->linetype | (DumbLine << 9);
X
X	fgets (line, BUFSIZE, menufile);
X	sptr = line;
X	SKIPJUNK(sptr);
X
X	/* get border type for active menu */
X	sscanf (sptr, "%s", linetype);
X	sptr += strlen(linetype);
X	if (strcmp (linetype, "DumbLine") == 0)
X		menu->linetype = DumbLine;
X	else	if (strcmp (linetype, "StandoutLine") == 0)
X			menu->linetype = StandoutLine;
X	else	if (strcmp (linetype, "SingleLine") == 0 ||
X		    strcmp (linetype, "DrawLine") == 0)
X			menu->linetype = SingleLine;
X	else	if (strcmp (linetype, "MosaicLine") == 0)
X			menu->linetype = MosaicLine;
X	else	if (strcmp (linetype, "DiamondLine") == 0)
X			menu->linetype = DiamondLine;
X	else	if (strcmp (linetype, "DotLine") == 0)
X			menu->linetype = DotLine;
X	else	if (strcmp (linetype, "PlusLine") == 0)
X			menu->linetype = PlusLine;
X
X	/* get border type for inactive menu - dim (high 8 bits) */
X	sscanf (sptr, "%s", linetype);
X	sptr += strlen(linetype);
X	if (strcmp (linetype, "DumbLine") == 0)
X		menu->linetype = menu->linetype | (DumbLine << 9);
X	else	if (strcmp (linetype, "StandoutLine") == 0)
X			menu->linetype = menu->linetype | (DumbLine << 9);
X	else	if (strcmp (linetype, "SingleLine") == 0 ||
X		    strcmp (linetype, "DrawLine") == 0)
X			menu->linetype = menu->linetype | (SingleLine << 9);
X	else	if (strcmp (linetype, "MosaicLine") == 0)
X			menu->linetype = menu->linetype | (MosaicLine << 9);
X	else	if (strcmp (linetype, "DiamondLine") == 0)
X			menu->linetype = menu->linetype | (DiamondLine << 9);
X	else	if (strcmp (linetype, "DotLine") == 0)
X			menu->linetype = menu->linetype | (DotLine << 9);
X	else	if (strcmp (linetype, "PlusLine") == 0)
X			menu->linetype = menu->linetype | (PlusLine << 9);
X
X	drawline (stdscr, menu->titlecount, menu->linetype&0777, StandoutLine,
X			menu->boxtype);
X
X   	menu->titlecount++;
X   	return (0);
X}
SHAR_EOF
chmod 0444 ParseLine.c || echo "restore of ParseLine.c fails"
echo "x - extracting ParseComnt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseComnt.c &&
Xstatic char Sccsid[] = "@(#)ParseComnt.c	1.5   DeltaDate 11/13/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseComnt()
X**		Parses keyword "###".
X##		A comment line.
X**  ARGS:	keyword		the keyword "###"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
XParseComnt (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets(), line[BUFSIZE+1];
X
X
X   	fgets (line, BUFSIZE, menufile);
X	return (0);
X}
SHAR_EOF
chmod 0444 ParseComnt.c || echo "restore of ParseComnt.c fails"
echo "x - extracting ParseUnix.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseUnix.c &&
Xstatic char Sccsid[] = "@(#)ParseUnix.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseUnix()
X**		Parses keyword ".unix".
X**  ARGS:	keyword		the keyword "unix"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
Xextern	int	debug;
X
X
X
XParseUnix (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X		gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		command[MAXLEN+1];
X	int		rc;
X	char		*comptr;
X	char		tmpstr[80];
X	int		redrawflag = FALSE;
X
X
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X   	fgets (command, MAXLEN, menufile);
X   	command[strlen(command)-1] = '\0';		/* get rid of \n */
X   	while (command[strlen(command)-1] == '\\')
X   	{
X      		if (strlen(command) > MAXLEN)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, 
X				".UNIX command is too long.  Max = %d",MAXLEN);
X         		shutdown ();
X      		}
X      		command[strlen(command)-1] = '\n';	/* replace \ with \n */
X      		fgets (command+strlen(command), MAXLEN, menufile);
X      		command[strlen(command)-1] = '\0';	/* get rid of \n */
X   	}
X
X	comptr = command;
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", tmpstr);		/* do we have a REDRAW */
X	if (strcmp (tmpstr, "REDRAW") == 0)
X	{
X		redrawflag = TRUE;
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);
X   		sscanf (comptr, "%s", tmpstr);	/* do we have a GETINPUT */
X	}
X
X	if (strcmp (tmpstr, "GETINPUT") == 0)
X	{
X		/* get screen name */
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);
X   		sscanf (comptr, "%s", tmpstr);		/* screen name */
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);		/* sitting at system(3) */
X		rc = runscreen (tmpstr, menu, *opnumber);
X		if (rc == KEY_CANCEL)
X			return (0);
X	}
X
X	reset_shell_mode ();
X   	rc = system (comptr);
X	reset_prog_mode ();
X
X	/*
X	**  Going from a shell return code (char) to a c return code (int)
X	**  the shell return code gets put in the high byte.  So we will
X	**  shift the int right 8 bytes.
X	*/
X	rc = rc >> 8;					/* to get shell rc */
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] <%s> rc=%d  command=%s", 
X			__FILE__, keyword, rc, comptr);
X		fflush (stderr);
X	}
X
X	/*
X	**  Shell can't handle negative return codes so we will convert 
X	**  the return code to negative so menu can use it.
X	**	-1 = QUIT
X	**	-2 = MAINMENU
X	**	-3 = PREVMENU
X	**	-4 = NOWAYJOSE
X	**	100+offset = GNAME
X	*/
X	if (rc < GNAMEOFFSET)
X		rc -= rc * 2;				/* make negative */
X
X	if (redrawflag)
X		clearok (stdscr, TRUE);
X
X	return (rc);
X}
X/* Paul J. Condie  12/88 */
SHAR_EOF
chmod 0444 ParseUnix.c || echo "restore of ParseUnix.c fails"
echo "x - extracting ParseGname.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseGname.c &&
Xstatic char Sccsid[] = "@(#)ParseGname.c	1.5   DeltaDate 11/13/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseGname()
X**		Parses keyword ".GNAME".
X**  ARGS:	keyword		the keyword "GNAME"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
X
XParseGname (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		name[BUFSIZE+1];
X	char		file[BUFSIZE+1];
X	int		i;
X	int		NameFound;
X
X
X	if (*gindex >= MAXGNAME)
X	{
X		BEEP;
X		mvprintw (20, 0, 
X		   "Exceeded maximum (%d) number of goto menu names", 
X		   MAXGNAME-1);
X		shutdown ();
X	}
X   	fscanf (menufile, "%s %s", name, file);
X	if (strlen(name) >= 15  ||  strlen(file) >= 15)
X	{
X		BEEP;
X		mvprintw (20, 0, 
X       "The goto menu name and the goto menu file is limited to 14 characters");
X		shutdown ();
X	}
X
X	/* Check if we already have this menu name */
X	NameFound = FALSE;
X	for (i = 0; i < *gindex; i++)
X	{
X		if (strcmp (name, gnames[i]) == 0)
X		{
X			NameFound = TRUE;
X			strcpy (gfiles[i], file);	/* new menu file */
X		}
X	}
X	if (!NameFound)
X	{
X		/* a new name */
X		strcpy (gnames[*gindex], name);
X		strcpy (gfiles[*gindex], file);
X		(*gindex)++;
X		strcpy (gnames[*gindex], "");		/* null last one */
X	}
X   	fgets (name, BUFSIZE, menufile);	/* junk rest of line */
X	return (0);
X}
SHAR_EOF
chmod 0444 ParseGname.c || echo "restore of ParseGname.c fails"
echo "x - extracting ParseAuthr.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseAuthr.c &&
Xstatic char Sccsid[] = "@(#)ParseAuthr.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseAuthr()
X**		Parses keyword "AUTHORIZE".
X**		This function determines whether you are authorized
X**		to run this menu or not.
X**  ARGS:	keyword		the keyword "AUTHORIZE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0		you are authorized
X**		NOWAYJOSE	nowayjose
X*/
X
X#include	<curses.h>
X#include	<pwd.h>
X#include	"menu.h"
X
X
X
XParseAuthr (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*strchr();
X	char		line[MAXLEN+100], *lptr, word[15];
X	char		user[15];
X	int		OKflag;
X	struct passwd	*getpwuid();
X	struct passwd	*pw;				/* password entry */
X
X
X	pw = getpwuid (getuid());			/* get real uid */
X	strcpy (user, pw->pw_name);
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X   	fgets (line, BUFSIZE, menufile);
X   	line[strlen(line)-1] = '\0';			/* get rid of \n */
X   	while (line[strlen(line)-1] == '\\')
X   	{
X      		if (strlen(line) >= MAXLEN)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, 
X				"Option command is too long.  Max = %d",MAXLEN);
X         		shutdown ();
X      		}
X      		line[strlen(line)-1] = '\0';		/* junk \ */
X      		fgets (line+strlen(line), BUFSIZE, menufile);
X      		line[strlen(line)-1] = '\0';		/* get rid of \n */
X   	}
X
X   	lptr = line;
X   	OKflag = FALSE;
X   	while (lptr  &&  (sscanf (lptr, "%s", word) == 1))
X   	{
X      		if (strcmp (user, word) == 0)
X      		{
X			OKflag = TRUE;
X			break;
X      		}
X      		lptr = strchr (++lptr, ' ');
X   	}
X
X   	if (!OKflag)
X      		return (NOWAYJOSE);
X   	return (0);
X}
SHAR_EOF
chmod 0444 ParseAuthr.c || echo "restore of ParseAuthr.c fails"
echo "x - extracting ParseText.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseText.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ParseText.c	1.6   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*  FUNCTION:	ParseText()
X**		Parses keyword "TEXT".
X**  ARGS:	keyword		the keyword "TEXT"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XParseText (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*fgets(), line[BUFSIZE+1];
X	char		*getval();
X	int		row;
X	int		col;
X	char		fline[BUFSIZE+1];		/* formated line */
X	int		j;
X	int		i;
X	char		*ws;
X
X   	fgets (line, BUFSIZE, menufile);		/* read row, col */
X	ws = line;
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", fline);			/* get row */
X	row = strcmp (fline, "-0") == 0 ? LINES : atoi(fline);
X	ws += strlen(fline);
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", fline);			/* get col */
X	col = strcmp (fline, "-0") == 0 ? COLS : atoi(fline);
X	
X   	fgets (line, BUFSIZE, menufile);		/* read text */
X   	line[strlen(line)-1] = '\0';
X   	for (j = 0, i = 0; i < strlen (line); j++, i++)
X      		if (line[i] == '$')
X      		{
X			char	*sptr, *b4ptr;
X
X		     	sptr = b4ptr = line+i;
X		     	strcpy (fline+j, getval (&sptr, '$'));
X		     	i += (int)(sptr - b4ptr);
X		     	j += strlen (fline+j) - 1;
X		     	i--;
X      		}
X      		else
X      		{
X			fline[j] = line[i];
X      		}
X	fline[j] = '\0';
X
X	/*
X	**   If the row or column is negative
X	**     then  we use relative addressing
X	**     	     the row or col is subtracted from # of rows on screen.
X	*/
X	if (row < 0)
X		row = abs(row) > LINES ? LINES-1 : LINES+row-1;
X	else
X		row = row > LINES-1 ? LINES-1 : row;
X	if (col < 0)
X		col = abs(col) > COLS ? COLS-1 : COLS+col-1;
X	else
X		col = col > COLS-1 ? COLS-1 : col;
X   	displaytext (row, col, fline);
X	return (0);
X}
X/* Paul J. Condie  4/88 */
SHAR_EOF
chmod 0444 ParseText.c || echo "restore of ParseText.c fails"
echo "x - extracting ParseCur.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseCur.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ParseCur.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X
X/*  FUNCTION:	ParseCursor()
X**		Parses keyword "CURSOR".
X**  ARGS:	keyword		the keyword "CURSOR"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XParseCursor (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets(), line[BUFSIZE+1];
X	char	*ws;
X	char	tmpstr[20];
X
X   	fgets (line, BUFSIZE, menufile);
X	ws = line;
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", tmpstr);			/* get row */
X	menu->row_cursor = strcmp (tmpstr, "-0") == 0 ? LINES : atoi(tmpstr);
X	ws += strlen(tmpstr);
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", tmpstr);			/* get col */
X	menu->col_cursor = strcmp (tmpstr, "-0") == 0 ? COLS : atoi(tmpstr);
X
X	/*
X	**   If the row or column is negative
X	**     then  we use relative addressing
X	**     	     the row or col is subtracted from # of rows on screen.
X	*/
X	if (menu->row_cursor < 0)
X		menu->row_cursor = abs(menu->row_cursor) > LINES ? 
X			LINES-1 : LINES+menu->row_cursor-1;
X	else
X		menu->row_cursor = menu->row_cursor > LINES-1 ? 
X			LINES-1 : menu->row_cursor;
X	if (menu->col_cursor < 0)
X		menu->col_cursor = abs(menu->col_cursor) > COLS ? 
X			COLS-1 : COLS+menu->col_cursor-1;
X	else
X		menu->col_cursor = menu->col_cursor > COLS-1 ? 
X			COLS-1 : menu->col_cursor;
X	return (0);
X}
X/* Paul J. Condie  4/88 */
SHAR_EOF
chmod 0444 ParseCur.c || echo "restore of ParseCur.c fails"
echo "x - extracting ParseSpace.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseSpace.c &&
Xstatic char Sccsid[] = "@(#)ParseSpace.c	1.4   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseSpace()
X**  ARGS:	keyword		the keyword found
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
X
X
XParseSpace (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	struct OptionInfo	*malloc();
X	char	*fgets(), line[BUFSIZE];
X
X
X   if (menu->optioncount >= MAXOPTION)
X   {
X      BEEP;
X      mvprintw (ErrRow, 0, "Exceeded maximum allowable options.");
X      shutdown ();
X   }
X   menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
X   if (menu->option[menu->optioncount] == NULL)
X   {
X      BEEP;
X      mvprintw (ErrRow, 0, "Unable to allocate memory for option.");
X      shutdown ();
X   }
X
X   strcpy (menu->option[menu->optioncount]->keyword, keyword);
X   menu->option[menu->optioncount]->opnumber = 0;		/* no number */
X   strcpy (menu->option[menu->optioncount]->description, "");
X   strcpy (menu->option[menu->optioncount]->command, "");
X
X   fgets (line, BUFSIZE, menufile);			/* junk rest of line */
X   menu->optioncount++;
X   ewin++;
X   return (0);
X}
SHAR_EOF
chmod 0444 ParseSpace.c || echo "restore of ParseSpace.c fails"
echo "x - extracting ParInclude.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParInclude.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ParInclude.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*  FUNCTION:	ParInclude()
X**		Parses keyword ".INCLUDE".
X**  ARGS:	keyword		the keyword "INCLUDE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
XParInclude (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	FILE		*fopen(), *newfile;
X	char		*fgets(), line[BUFSIZE+1];
X	char		*findfile();
X	char		*getenv();
X	char		unixfile[100];
X	char		filename[30];
X	int		rc;
X	int		KEYFOUND;
X	int		idx;
X	char		newkey[MAXKEYLENGTH];
X
X	fgets (line, BUFSIZE, menufile);
X	sscanf (line, "%s", filename);
X
X	/*
X	**  Open and Parse the new menu file
X	*/
X	strcpy (unixfile, findfile (filename, ".", getenv("MENUDIR"), ""));
X      	if ((newfile = fopen (unixfile, "r")) == NULL)
X      	{
X        	BEEP;
X            	mvprintw (ErrRow-2, 0, "Unable to locate .INCLUDE (%s) file.", 
X				filename);
X            	shutdown ();
X      	}
X
X
X   	/* loop through each keyword */
X   	rc = fscanf (newfile, "%s", newkey);
X   	while (rc != EOF)
X   	{
X		/*
X		**  Check if we found a defined keyword
X		*/
X      		KEYFOUND = FALSE;
X      		for (idx = 1; idx <= MAXKEYS; idx++)
X      		{
X			/*
X         		if (strcmp (newkey, KeyWord[idx]) == 0)
X			*/
X         		if (strmatch (newkey, KeyWord[idx]))
X         		{
X            			KEYFOUND = TRUE;
X	    			if (ParseKey[idx] != NULL)
X	    			{
X               				rc = (*ParseKey[idx]) (newkey, 
X						newfile, menu, KeyWord,
X						ParseKey, gnames, gfiles, 
X						gindex, opnumber);
X	       				if (rc != 0)   return (rc);
X  				}
X            			break;
X         		}
X      		}
X      		if (!KEYFOUND)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, "ERROR: (%s) Key not found.", 
X					newkey);
X         		shutdown ();
X      		}
X      		rc = fscanf (newfile, "%s", newkey);
X	} /* end while */
X
X	/*
X      	rc = parsedriver (newfile, KeyWord, ParseKey, menu, gnames, gfiles, 
X			&gindex);
X	*/
X      	fclose (newfile);
X
X   	return (0);
X}
SHAR_EOF
chmod 0444 ParInclude.c || echo "restore of ParInclude.c fails"
echo "x - extracting ParAssign.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParAssign.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	ParAssign()
X**		Parses keyword "*=*"
X**		A variable=value assignment.
X**  ARGS:	keyword		the keyword "*=*"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern int	debug;
X
X
XParAssign (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets();
X	char	line[BUFSIZE+1];
X	char	assignment[2*BUFSIZE];
X	char	*aptr;
X
X
X   	fgets (line, BUFSIZE, menufile);
X	line[strlen(line)-1] = '\0';
X	strcpy (assignment, keyword);
X	strcat (assignment, line);
X	aptr = assignment;
X	if (debug)
X	{
X		fprintf (stderr, "\n[ParAssign]  command=:%s:", aptr);
X		fflush (stderr);
X	}
X	setvariable (&aptr);
X	return (0);
X}
SHAR_EOF
chmod 0644 ParAssign.c || echo "restore of ParAssign.c fails"
echo "x - extracting ShowOption.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ShowOption.c &&
Xstatic char Sccsid[] = "@(#)ShowOption.c	1.3   DeltaDate 10/16/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ShowOption()
X**		Displays a option to the screen.
X**  ARGS:	menu		menu structure
X**		index		option # to display
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern int	debug;
X
X
XShowOption (menu, index)
X
X	struct MenuInfo	*menu;
X	int		index;
X{
X
X
X	/*
X	**	Now display option.
X	*/
X   	mvprintw (menu->option[index]->row, menu->option[index]->col, "%2d.  ",
X		menu->option[index]->opnumber);
X   
X   	displaytext (menu->option[index]->row, menu->option[index]->col+5,
X		menu->option[index]->description);
X
X	if (debug)
X	{
X		fprintf (stderr, "\n[ShowOption] <%s> row=%d col=%d", 
X			menu->option[index]->keyword,
X			menu->option[index]->row, 
X			menu->option[index]->col);
X	}
X}
SHAR_EOF
chmod 0444 ShowOption.c || echo "restore of ShowOption.c fails"
echo "x - extracting RunSystem.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunSystem.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	RunSystem()
X**		Runs keyword ".SYSTEM".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
Xextern	int	errno;
Xextern	int	debug;
X
XRunSystem (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			command[BUFSIZ];
X	int			rc;		/* return code */
X	char			*comptr;
X	int			screenflag = FALSE;
X
X
X
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X
X	if (substr (comptr, "GETINPUT") != NULL)
X	{
X		sscanf (comptr, "%s", command);
X		/*
X		**  Loop through each variable=value until GETINPUT is found
X		*/
X		do
X		{
X			if (strcmp (command, "GETINPUT") == 0)
X			{
X				screenflag = TRUE;
X				/* get screen name */
X				comptr += strlen(command);
X				SKIPJUNK(comptr);
X   				sscanf (comptr, "%s", command);/* screen name */
X				comptr += strlen(command);
X				SKIPJUNK(comptr);     /* sitting at system(3) */
X				rc = runscreen (command, menu, opnumber);
X				if (rc == KEY_CANCEL)
X					return (0);
X				break;
X			}
X			else
X			{
X				rc = setvariable (&comptr);
X				if (rc != 0) break;
X			}
X
X			SKIPJUNK(comptr);
X   			rc = sscanf (comptr, "%s", command);/* next var=value */
X		} while (rc != EOF);
X	} /* end if GETINPUT */
X
X
X	/* run system command */
X	refresh();			/* force curses to flush attributes */
X	sprintf (command, "%s;echo \"One moment, loading %s%s%s ....\"; %s",
X#if BSD || SUN
X			"clear",
X#else
X			"tput clear",
X#endif
X#if BSD || SUN
X			NULL,
X#else
X			"`tput smul`",
X#endif
X			menu->option[opnumber]->description,
X#if BSD || SUN
X			NULL,
X#else
X			"`tput rmul`",
X#endif
X			comptr);
X   	reset_shell_mode ();
X	if (debug)
X	{
X		fprintf (stderr, "\n[RunSystem] <%s> command=:%s:", 
X			menu->option[opnumber]->keyword, command);
X	}
X   	rc = system (command);
X	if (debug)
X	{
X		fprintf (stderr, 
X			"\n[RunSystem] <%s> return code = %d, errno = %d", 
X			rc, errno);
X	}
X
X/*  Pending survey on whether majority of users want this or not
X	if ( rc )
X	{
X		printf( "\n\nPress RETURN when ready ==> " ) ;
X		fflush( stdout ) ;
X		beep() ;
X		getchar() ;
X	}
X*/
X   	reset_prog_mode ();
X	clearok (stdscr, TRUE);
X
X
X	if (rc == 0  &&  screenflag)
X		return (REPARSE);
X   	return (rc);
X}
SHAR_EOF
chmod 0644 RunSystem.c || echo "restore of RunSystem.c fails"
echo "x - extracting RunExit.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunExit.c &&
Xstatic char Sccsid[] = "@(#)RunExit.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	RunExit()
X**		Runs keyword ".EXIT".
X**		Exit menu program.
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
XRunExit (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			command[BUFSIZ];
X	int			rc;		/* return code */
X
X	refresh ();
X	if (strcmp (menu->option[opnumber]->command, "") != 0)
X	{
X   		sprintf (command, "%s", menu->option[opnumber]->command);
X   		reset_shell_mode ();
X   		rc = system (command);
X   		reset_prog_mode ();
X	}
X	return (QUIT);
X}
SHAR_EOF
chmod 0444 RunExit.c || echo "restore of RunExit.c fails"
echo "x - extracting RunSetenv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunSetenv.c &&
Xstatic char Sccsid[] = "@(#)RunSetenv.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	RunSetenv()
X**		Runs keyword ".SETENV".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<string.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XRunSetenv (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			*strchr();
X	int			rc;
X	char			command[BUFSIZ];
X	char			*comptr;
X	int			BELLFLAG=FALSE;
X
X
X	/*
X	**  The first argument [ BELL ]
X	*/
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", command);		/* do we have a BELL */
X	if (strcmp (command, "BELL") == 0)
X	{
X		BELLFLAG = TRUE;
X		comptr += strlen(command);
X	}
X
X	do
X	{
X		rc = setvariable (&comptr);
X		if (rc != 0) break;
X   		rc = sscanf (comptr, "%s", command);	/* get next var=value */
X		if (rc == EOF)   break;
X		/* if the command has an = sign in it, it is another one */
X		if (!strmatch(command, "*=*"))
X			break;
X	} while (rc != EOF);
X
X	SKIPJUNK(comptr);
X	mvprintw (ErrRow, 0, "%s", comptr);		/* dispaly message */
X	if (BELLFLAG)
X		BEEP;
X
X	return (REPARSE);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 RunSetenv.c || echo "restore of RunSetenv.c fails"
echo "x - extracting RunMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunMenu.c &&
Xstatic char Sccsid[] = "@(#)RunMenu.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	RunMenu()
X**		Runs keyword ".MENU".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
XRunMenu (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			command[BUFSIZ];
X	int			rc;		/* return code */
X	char			*comptr;
X
X	/*
X	**  The first argument is the menu script filename
X	*/
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK (comptr);
X   	sscanf (comptr, "%s", command);			/* filename */
X	comptr += strlen(command);
X	SKIPJUNK (comptr);
X   	sscanf (comptr, "%s", command);		/* next argument */
X
X	/*
X	**  Loop through each variable=value || GETINPUT
X	*/
X	do
X	{
X		if (strcmp (command, "GETINPUT") == 0)
X		{
X			/* get screen name */
X			comptr += strlen(command);
X			SKIPJUNK(comptr);
X   			sscanf (comptr, "%s", command);	/* screen name */
X			comptr += strlen(command);
X			SKIPJUNK(comptr);	/* sitting at next argument */
X			rc = runscreen (command, menu, opnumber);
X			if (rc == KEY_CANCEL)
X				return (0);
X		}
X		else
X		{
X			rc = setvariable (&comptr);
X			if (rc != 0) break;
X		}
X
X   		rc = sscanf (comptr, "%s", command);/* next var=value */
X	} while (rc != EOF);
X
X	return (SUBMENU);
X}
X/* Paul J. Condie  5/88 */
SHAR_EOF
chmod 0444 RunMenu.c || echo "restore of RunMenu.c fails"
echo "x - extracting RunPopMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunPopMenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)RunPopMenu.c	1.8   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*  FUNCTION:	RunPopMenu()
X**		Runs keyword ".POPMENU".
X**		RunPopMenu will use recursion if there is another .POPMENU
X**		within .POPMENU.
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<string.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X#define	INITMENU	0
X#define	CREATEMENU	-2
X#define	UNHILIGHTBOX	-1
X
X
XRunPopMenu (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	FILE			*fopen(), *menufile;
X	char			*strchr();
X	char			*findfile();
X	char			*getenv();
X	char			command[BUFSIZ];
X	int			rc;			/* return code */
X	char			*comptr;
X	int			row, col;		/* top left corner */
X	char			*filename;
X	int			i;
X	static int		popmid = 9;		/* popup menu id */
X	int			titleline[200];		/* title 1 on stdscr */
X	char			poptitle[200];		/* title for popmenu */
X	int			DIMFLAG = TRUE;
X	struct MenuInfo		pmenu;
X	char			PopMenu[100][80];	/* the pop menu */
X	int			AUTOFIG = FALSE;	/* figure row/col */
X
X
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", command);		/* do we have NoDim */
X	if (strcmp (command, "NoDim") == 0)
X	{
X		DIMFLAG = FALSE;
X		comptr += strlen(command);
X	}
X
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", command);		/* menufile name */
X	comptr += strlen(command);
X	SKIPJUNK(comptr);
X
X	/* do we have a row/column parameter 
X	** we'll use titleline for working storage
X	*/
X   	sscanf (comptr, "%s", titleline);	/* get next argument */
X	if (*comptr != '\0' && strchr (titleline, '=') == (char *)NULL)
X	{
X		/* we have a row/column parameter */
X		/* get row and column */
X		sscanf (comptr, "%d", &row);
X		comptr = strchr (comptr, ' ');		/* past row */
X		SKIPJUNK(comptr);			/* at begining of col */
X		sscanf (comptr, "%d", &col);
X		comptr = strchr (comptr, ' ');		/* past column */
X	}
X	else
X		AUTOFIG = TRUE;
X
X
X	/*
X	**  Loop through each variable=value
X	*/
X	do
X	{
X		rc = setvariable (&comptr);
X		if (rc != 0) break;
X	} while (rc != EOF);
X
X	/*
X	**  Open and Parse the popmenu
X	*/
X	filename = findfile (command, ".", getenv("MENUDIR"), "");
X      	if ((menufile = fopen (filename, "r")) == NULL)
X      	{
X        	BEEP;
X            	mvprintw (ErrRow-2, 0, "Unable to locate (%s) file.", command);
X            	shutdown ();
X      	}
X
X	/*
X	**  The ParseTitle will put the .POPMENU title on line 0 of stdscr
X	**  so we need to save original title
X	**  then read and compare title 1 to see what the title for popmenu
X	**  should be.
X	**  Then write the original title back out. (whew)
X	*/
X	/* save title line 0 with attributes */
X	for (i = 0; i <= COLS; i++)
X		titleline[i] = mvwinch (stdscr, 0, i);
X
X	initmenu (&pmenu);
X
X      	rc = parsedriver (menufile, KeyWord, ParseKey, &pmenu, gnames, gfiles, 
X			&gindex);
X      	fclose (menufile);
X
X	if (AUTOFIG)
X	{
X		int	longest;
X
X		/*
X		** try to put menu as close to the option as possible
X		**  menu->option[opnumber]->row holds the
X		**  location on stdscr of the option that selected this.
X		*/
X		row = menu->option[opnumber]->row - 1;
X		col = menu->option[opnumber]->col + 
X		      	      strlen (menu->option[opnumber]->description);
X		if (popmid == 9)
X			col += 4;
X
X		/* make sure it fits on the screen */
X		if ((row + pmenu.optioncount + 2) > LINES)
X			row = LINES - pmenu.optioncount - 2;
X
X		for (i = 0, longest = 0; i < pmenu.optioncount; i++)
X			if (strlen (pmenu.option[i]->description) > longest)
X				longest = strlen (pmenu.option[i]->description);
X		if ((col + longest + 4) > COLS)
X			col = COLS - longest - 4;
X
X		/*
X		**  Recalculate the options row and col for recursion
X		*/
X		for (i = 0; i < pmenu.optioncount; i++)
X		{
X			pmenu.option[i]->row = row + 1 + i;
X			pmenu.option[i]->col = col;
X		}
X	}
X
X	/* find popmenu title in line 0 */
X	for (i = 0; i <= COLS; i++)
X	{
X		poptitle[i] = ' ';
X		if (mvwinch (stdscr, 0,i) != titleline[i])
X		{
X			poptitle[i] = mvwinch(stdscr, 0,i);
X		}
X		else
X			poptitle[i] = ' ';
X		/* write original title back out */
X		mvwaddch (stdscr, 0,i, titleline[i]);
X	}
X	poptitle[i] = '\0';
X	/* junk trailing spaces */
X	for (i = strlen(poptitle)-1; i >= 0; i--)
X		if (poptitle[i] == ' ')
X			poptitle[i] = '\0';
X		else
X			break;
X
X	if (rc != 0) return (rc);			/* from parsemenu */
X
X
X
X	/* if .BOX||.LINE && DIM then unhilight */
X	if (DIMFLAG)
X	{
X		/* Dim the .BOX */
X		if (menu->boxtype)
X			drawbox (stdscr, 1,1, LINES-1,COLS, 
X				(menu->boxtype&0777000)>>9, DumbLine,
X				FALSE, FALSE);
X
X		/* Dim the .LINE */
X		if (menu->linetype)
X			drawline (stdscr, menu->titlecount-1, 
X				(menu->linetype&0777000)>>9, DumbLine, 
X				menu->boxtype);
X
X		wnoutrefresh (stdscr);
X	}
X
X	/* popmid = 10+ */
X	popmid++;
SHAR_EOF
echo "End of part 4"
echo "File RunPopMenu.c is continued in part 5"
echo "5" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 5 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file RunPopMenu.c continued
#
CurArch=5
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 RunPopMenu.c"
sed 's/^X//' << 'SHAR_EOF' >> RunPopMenu.c
X	for (i = 0; i < pmenu.optioncount; i++)
X		strcpy (PopMenu[i], pmenu.option[i]->description);
X	strcpy (PopMenu[i], "");
X	popmenu (INITMENU, popmid, row, col, poptitle, HELPFILE,
X			LINES-2, sizeof(PopMenu[0]), PopMenu);
X
X	rc = popmenu (popmid);
X
X	/* run option selected */
X	if (rc > 0)
X	{
X		for (i = 1; i <= MAXKEYS && strcmp (KeyWord[i], "") != 0; i++)
X			if (strcmp (pmenu.option[rc-1]->keyword, 
X				    KeyWord[i]) == 0)
X			{
X				if (RunKey[i] != NULL)
X				{
X					/*
X					**  Dim box is option is a .POPMENU or
X					**  a .GETINPUT or a .SYSTEM GETINPUT
X					*/
X					comptr = pmenu.option[rc-1]->command;
X					SKIPJUNK(comptr);
X   					sscanf (comptr, "%s", command);
X					if (strcmp (pmenu.option[rc-1]->keyword, ".POPMENU") == 0  ||
X					    strcmp (pmenu.option[rc-1]->keyword, ".GETINPUT") == 0 ||
X					    (strcmp (pmenu.option[rc-1]->keyword, ".SYSTEM") == 0 && 
X					     strcmp (command, "GETINPUT") == 0))
X						popmenu (UNHILIGHTBOX, popmid);
X
X		         		rc = (*RunKey[i]) (&pmenu, rc-1,
X						KeyWord, ParseKey, ShowKey, 
X						RunKey, gnames, gfiles, gindex);
X				}
X				break;
X			}
X	}
X	else
X		rc = 0;			/* popmenu was cancelled, continue */
X
X	popmid--;
X
X	clean_menu (&pmenu);
X
X	if (DIMFLAG)
X	{
X		/* hilight .BOX */
X		if (menu->boxtype)
X			drawbox (stdscr, 1,1, LINES-1,COLS, 
X				menu->boxtype & 0777, StandoutLine,
X				FALSE, FALSE);
X
X		/* hilight .LINE */
X		if (menu->linetype)
X			drawline (stdscr, menu->titlecount-1,
X				menu->linetype & 0777, StandoutLine,
X				menu->boxtype);
X	}
X
X	touchwin (stdscr);
X
X    	if (rc != 0)  
X		return (rc);
X	else
X		return (REPARSE);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
echo "File RunPopMenu.c is complete"
chmod 0444 RunPopMenu.c || echo "restore of RunPopMenu.c fails"
echo "x - extracting RunGetI.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunGetI.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)RunGetI.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*  FUNCTION:	RunGetInpt()
X**		Runs keyword ".GETINPUT".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<term.h>
X#include	"menu.h"
X
X
X
XRunGetInput (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			screen_name[50];
X	int			rc;		/* return code */
X
X	/*
X	**  The first argument is the screen name
X	*/
X   	sscanf (menu->option[opnumber]->command, "%s", screen_name);
X	rc = runscreen (screen_name, menu, opnumber);
X	if (rc == KEY_CANCEL)
X		return (0);
X	else
X		return (REPARSE);
X}
SHAR_EOF
chmod 0444 RunGetI.c || echo "restore of RunGetI.c fails"
echo "x - extracting GetOption.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > GetOption.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X#include	"terminal.h"
X
Xextern int	HotKeys;
X	int	ch;			/* input character */
X
X
XGetOption (row, col, s)
X
X	int	row;			/* row to get user input */
X	int	col;			/* col to get user input */
X	char	*s;			/* memory string to store input */
X{
X	char	*findfile();
X	char	*getenv();
X	char	*ws;			/* working string */
X	int	cc;			/* column count */
X	int	i;			/* work variable */
X	char	hlpfile[100];
X
X
X	ws = s;				/* set to memory string */
X	cc = col;
X
X	for (i = col; i <= col+3; i++)	/* blank out prompt field */
X	   mvaddch (row, i, ' ');
X					/* display default text */
X	while (*ws)
X	{
X		move (row, cc++);
X		addch (*ws);
X		ws++;
X	}
X					/* loop until done */
X	for (;;)
X	{
X		move (row, cc);
X		refresh ();
X		ch = getch ();
X		move (ErrRow, 0);  clrtoeol ();
X
X      		if (ch == KeyDown)   	ch = KEY_DOWN;
X      		if (ch == KeyUp)	ch = KEY_UP;
X      		if (ch == KeyTab)	ch = KEY_TAB;
X      		if (ch == KeyBTab)	ch = KEY_BTAB;
X      		if (ch == KeyReturn)	ch = KEY_RETURN;
X		if (ch == KeyBackspace)	ch = KEY_BACKSPACE;
X		if (ch == KeyRedraw)	ch = KEY_REFRESH;
X		if (ch == KeyHelp)	ch = KEY_HELP;
X		if (ch == KeyMainMenu)	ch = KEY_MAINMENU;
X		if (ch == KeyPrevMenu)	ch = KEY_PREVMENU;
X		if (ch == KeyExitMenu)	ch = KEY_EXITMENU;
X		if (ch == KeyGname)	ch = KEY_GNAME;
X		if (ch == KeyPopGname)	ch = KEY_POPGNAME;
X
X		if (ch >= 'a' && ch <= 'z')
X			ch = toupper (ch);
X
X		switch (ch)
X		{
X		   case KEY_DOWN:
X		   case KEY_UP:
X		   case KEY_TAB:
X		   case KEY_BTAB:
X			*s = '\0';	/* reset select to null */
X		   case KEY_RETURN:
X		   case KEY_LINEFEED:
X		   case '0':
X		   case '1':
X		   case '2':
X		   case '3':
X		   case '4':
X		   case '5':
X		   case '6':
X		   case '7':
X		   case '8':
X		   case '9':
X			return (ch);
X
X		   case '!':
X			if (getenv ("SHELL") != (char *)NULL)
X				return (ch);
X			break;
X
X		   case KEY_HELP:
X		   case KEY_EXITMENU:
X		   case KEY_MAINMENU:
X		   case KEY_PREVMENU:
X		   case KEY_GNAME:
X			if (HotKeys)
X			{
X				return (ch);
X			}
X			else
X			{
X				if (ch == KEY_HELP)
X					*ws = KeyHelp;
X				else if (ch == KEY_EXITMENU)
X					*ws = KeyExitMenu;
X				else if (ch == KEY_MAINMENU)
X					*ws = KeyMainMenu;
X				else if (ch == KEY_PREVMENU)
X					*ws = KeyPrevMenu;
X				else if (ch == KEY_GNAME)
X					*ws = KeyGname;
X				move (row, cc);
X				addch (*ws);
X				ws++;
X				*ws = '\0';
X				cc++;		/*move over one column*/
X			}
X			break;
X			
X		   case KEY_BACKSPACE:
X			if (cc == col) 
X				continue;
X			else
X			{
X				move (row, --cc);	/* back up one column */
X				addch (' ');
X				ws--;
X				*ws = '\0';
X			}
X			break;
X
X		   case KEY_REFRESH:
X			/* redraw screen */
X			clearok (stdscr, TRUE);
X			refresh ();
X			break;
X
X		   case KEY_POPGNAME:
X			return (KeyPopGname);
X
X		   case ' ':
X		   case 'A':
X		   case 'B':
X		   case 'C':
X		   case 'D':
X		   case 'E':
X		   case 'F':
X		   case 'G':
X		   case 'H':
X		   case 'I':
X		   case 'J':
X		   case 'K':
X		   case 'L':
X		   case 'M':
X		   case 'N':
X		   case 'O':
X		   case 'P':
X		   case 'Q':
X		   case 'R':
X		   case 'S':
X		   case 'T':
X		   case 'U':
X		   case 'V':
X		   case 'W':
X		   case 'X':
X		   case 'Y':
X		   case 'Z':
X			return (ch);
X
X		   default:
X			if (isprint (ch))
X			{
X				*ws = ch;
X				move (row, cc);
X				addch (*ws);
X				ws++;
X				*ws = '\0';
X				cc++;		/*move over one column*/
X			}
X			break;
X		} /* end switch */
X	} /* end for */
X}
SHAR_EOF
chmod 0644 GetOption.c || echo "restore of GetOption.c fails"
echo "x - extracting EndWindow.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > EndWindow.c &&
Xstatic char Sccsid[] = "@(#)EndWindow.c	1.1   DeltaDate 9/6/87   ExtrDate 1/22/90";
X/*  FUNCTION:	EndWindow()
X**		When a "WINDOW" keyword is found this function
X**		recalculates the row and column to begin 
X**		displaying the next subwindow.
X**  ARGS:	menu	current menu structure
X*/
X
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
X
X
XEndWindow (menu)
X
X	struct MenuInfo	*menu;
X{
X	int		i;
X
X
X   if (swin == ewin)  return;
X
X   longest += 5;
X
X/*
X**	Calculate what row and column to display option on.
X*/
X
X   for (i = swin; i < ewin; i++)
X   {
X      menu->option[i]->row = ((menu->wlrow - menu->wfrow) / 2 + menu->wfrow) -
X			      ((ewin - swin) / 2) + i - swin;
X      menu->option[i]->col = (menu->wlcol - menu->wfcol) / 2 - 
X			      longest / 2 + menu->wfcol;
X   }
X}
SHAR_EOF
chmod 0444 EndWindow.c || echo "restore of EndWindow.c fails"
echo "x - extracting displaytxt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > displaytxt.c &&
Xstatic char Sccsid[] = "@(#)displaytxt.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	displaytext()
X**		Displays a string to the screen with atributes.
X**  ARGS:	row	screen row
X**		col	screen col
X**		s	the string
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X
Xdisplaytext (row, col, s)
X
X	int	row, col;
X	char	s[];
X{
X	int	i;
X
X   move (row, col);
X
X/*
X**	Now display looking for terminal attributes.
X*/
X      for (i = 0; s[i] != '\0'; i++)
X      {
X         if (s[i] == '\\')
X	 {
X#ifdef BSD
X	    if (s[i+1] != 'N') s[i+1] = 'S';   /* Berk only supports standout */
X#endif
X            switch (s[++i])
X            {
X	       case 'S':
X#ifdef BSD
X			standout ();
X#else
X	   		attrset (stdscr->_attrs|A_STANDOUT);
X#endif
X			break;
X	       case 'B':
X#ifdef SYS5
X			attrset (stdscr->_attrs|A_BOLD);
X#endif
X			break;
X	       case 'U':
X#ifdef SYS5
X			attrset (stdscr->_attrs|A_UNDERLINE);
X#endif
X			break;
X	       case 'D':
X#ifdef SYS5
X			attrset (stdscr->_attrs|A_DIM);
X#endif
X			break;
X	       case 'R':
X#ifdef SYS5
X			attrset (stdscr->_attrs|A_REVERSE);
X#endif
X			break;
X	       case 'L':
X#ifdef SYS5
X			attrset (stdscr->_attrs|A_BLINK);
X#endif
X			break;
X	       case 'N': 
X#ifdef BSD
X			standend ();
X#else
X			attrset (A_NORMAL);
X#endif
X			break;
X	    }
X	 }
X         else
X            addch (s[i]);
X      }
X}
SHAR_EOF
chmod 0444 displaytxt.c || echo "restore of displaytxt.c fails"
echo "x - extracting SetTerm.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > SetTerm.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	"menu.h"
X
X				/* default values for dumb terminals */
X				/* a -1 indicates nokey */
X/* Mover Keys */
Xint	KeyReturn	= '\r';	/* \r - menu & GetInput */
Xint	KeyDown		= 10;	/* \n - menu & GetInput */
Xint	KeyUp		= 11;	/* ^k - menu & GetInput */
Xint	KeyTab		= '\t';	/* \t - menu & GetInput */
Xint	KeyBTab		= -1;	/*    - menu & GetInput */
X
X/* Edit Keys */
Xint	KeyBeg		= 2;	/* ^b - GetInput */
Xint	KeyEnd		= 5;	/* ^e - GetInput */
Xint	KeyRight	= 12;	/* ^l - GetInput */
Xint	KeyLeft		= 8;	/* \b - GetInput */
Xint	KeyBackspace	= '\b';	/* \b - GetInput */
Xint	KeyEOL		= 4;	/* ^d - GetInput clear to end of field */
Xint	KeyDL		= 3;	/* ^c - GetInput clear field and home cursor */
Xint	KeyDC		= 24;	/* ^x - GetInput delete character */
Xint	KeyIC		= 20;	/* ^t - GetInput typeover/insert mode */
X
X/* Other Keys */
Xint	KeyHelp		= '?';	/* ?  - menu & GetInput */
Xint	KeyTOC		= 20;	/* ^t - ShowHelp */
Xint	KeyRedraw	= 18;	/* ^r - menu & GetInput */
Xint	KeyCancel	= 27;	/* ESC - menu & GetInput pop-up menus */
Xint	KeySave		= 6;	/* ^f - GetInput save screen to a file */
Xint	KeyPrint	= 16;	/* ^p - GetInput prints screen to lp */
Xint	KeyAccept	= 1;	/* ^a - GetInput accepts input */
X
X
X/* Menu Specific */
Xint	HotKeys		= 0;	/* for hot keyboard */
Xint	KeyMainMenu	= 'm';	/* goto main menu */
Xint	KeyPrevMenu	= 'p';	/* goto previous menu */
Xint	KeyExitMenu	= 'e';	/* exit menu */
Xint	KeyGname	= 'g';	/* goto a specific menu (dumb) */
Xint	KeyPopGname	= 7;	/* ^g  - goto a specific menu (popmenu) */
X
X
X
XSetTerm ()
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 (0);
X	}
X
X	/* set terminal keys */
X	while (fgets (line, BUFSIZE, menuinit) != (char *)NULL)
X	{
X		if (strncmp ("HOTKEYS", line, 7) == 0)
X			HotKeys = 1;
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_EXITMENU", line, 12) == 0)
X			sscanf (s1, "%d", &KeyExitMenu);
X		else if (strncmp ("KEY_MAINMENU", line, 12) == 0)
X			sscanf (s1, "%d", &KeyMainMenu);
X		else if (strncmp ("KEY_PREVMENU", line, 12) == 0)
X			sscanf (s1, "%d", &KeyPrevMenu);
X		else if (strncmp ("KEY_GNAME", line, 9) == 0)
X			sscanf (s1, "%d", &KeyGname);
X		else if (strncmp ("KEY_POPGNAME", line, 12) == 0)
X			sscanf (s1, "%d", &KeyPopGname);
X		else if (strncmp ("KEY_TOC", line, 7) == 0)
X			sscanf (s1, "%d", &KeyTOC);
X	}
X	fclose (menuinit);
X	return (0);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0644 SetTerm.c || echo "restore of SetTerm.c fails"
echo "x - extracting systime.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > systime.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)systime.c	1.2   DeltaDate 5/6/88   ExtrDate 1/22/90";
X#endif
X
X#include <stdio.h>
X#include <time.h>
X
Xsystime (timeStr, mask)
X
X	char *timeStr, *mask;
X{
X	long		tloc ;
X	struct tm  	*ltime, *localtime() ;
X	char 		tmpstr[4] ;
X	int		tmpval;
X
X   tloc = time((long *) 0) ;
X   ltime = localtime(&tloc) ;
X
X   ltime->tm_mon++;
X
X   if (mask == NULL)
X   {
X      sprintf (timeStr, "%2d:%02d:%02d", ltime->tm_hour, ltime->tm_min, 
X	       ltime->tm_sec) ;
X   }
X   else
X      while (*mask != '\0')
X      {
X         switch (*mask)
X         {
X            case 'H':
X			if (ltime->tm_hour > 12)
X			{
X			   tmpval = ltime->tm_hour - 12;
X			   sprintf (tmpstr, "%2d", tmpval);
X			}
X			else
X			   sprintf (tmpstr, "%2d", ltime->tm_hour);
X	    		break;
X	    case 'M':
X			sprintf (tmpstr, "%02d", ltime->tm_min);
X			break;
X	    case 'S':
X			sprintf (tmpstr, "%02d", ltime->tm_sec);
X			break;
X	    case 'I':
X			sprintf (tmpstr, "%2d", ltime->tm_hour);
X			break;
X	    case 'Z':
X			if (ltime->tm_hour >= 12)
X			   strcpy (tmpstr, "PM");
X			else
X			   strcpy (tmpstr, "AM");
X			break;
X	    case 'z':
X			if (ltime->tm_hour >= 12)
X			   strcpy (tmpstr, "pm");
X			else
X			   strcpy (tmpstr, "am");
X			break;
X	    default:
X			*timeStr = *mask;
X			timeStr++;
X			mask++;
X			continue;
X         }   /* end switch */
X         *timeStr = tmpstr[0];
X	 timeStr++;
X         *timeStr = tmpstr[1];
X	 timeStr++;
X         mask += 2;
X      }  /* end while */
X
X   *timeStr = '\0';
X   return (0);
X}
SHAR_EOF
chmod 0444 systime.c || echo "restore of systime.c fails"
echo "x - extracting sysdate.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > sysdate.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)sysdate.c	1.1   DeltaDate 9/6/87   ExtrDate 1/22/90";
X#endif
X
X#include	<time.h>
X
Xsysdate (dateStr, mask)
X
X	char *dateStr, *mask;
X{
X	long		tloc ;
X	struct tm  	*ltime, *localtime() ;
X
Xstatic	char		*shortmon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
X			              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
X
Xstatic	char		*longmon[]= 
X		  {"January","February","March","April","May","June",
X		   "July","August","September","October","November","December"};
X
Xstatic	char		*shortday[]= {"sun","mon","tue","wed","thr","fri","sat"};
X
Xstatic	char		*longday[]= {"Sunday","Monday","Tuesday","Wednessday",
X			            "Thursday", "Friday", "Saturday"};
X
X
X   tloc = time ((long *) 0) ;
X   ltime = localtime (&tloc) ;
X
X   while (*mask != '\0')
X   {
X
X/*
X**	Process month
X*/
X      if (strncmp (mask, "mmmmm", 5) == 0)
X      {
X	 sprintf (dateStr, "%s", longmon[ltime->tm_mon]);
X	 mask += 5;
X	 dateStr += strlen (longmon[ltime->tm_mon]);
X	 continue;
X      }
X      else
X         if (strncmp (mask, "mmm", 3) == 0)
X         {
X            sprintf (dateStr, "%s", shortmon [ltime->tm_mon]);
X	    mask += 3;
X	    dateStr += 3;
X	    continue;
X         }
X	 else
X	    if (strncmp (mask, "mm", 2) == 0)
X	    {
X	       sprintf (dateStr, "%.2d", ltime->tm_mon + 1);
X	       mask += 2;
X	       dateStr += 2;
X 	       continue;
X	    }
X
X/*
X**	Process day
X*/
X      if (strncmp (mask, "ddddd", 5) == 0)
X      {
X         sprintf (dateStr, "%s", longday [ ltime->tm_wday ]);
X	 mask += 5;
X	 dateStr += strlen (longday[ltime->tm_wday]);
X	 continue;
X      }
X      else
X         if (strncmp (mask, "ddd", 3) == 0)
X         {
X            sprintf (dateStr, "%s", shortday [ltime->tm_wday]);
X	    mask += 3;
X	    dateStr += 3;
X	    continue;
X         }
X         else
X            if (strncmp (mask, "dd", 2) == 0)
X	    {
X	       sprintf (dateStr, "%.2d", ltime->tm_mday);
X	       mask += 2;
X	       dateStr += 2;
X	       continue;
X	    }
X      if (strncmp (mask, "jjj", 3) == 0)
X      {
X         sprintf (dateStr, "%3d", ltime->tm_yday + 1);
X	 mask += 3;
X	 dateStr += 3;
X	 continue;
X      }
X
X/*
X**	Process year
X*/
X      if (strncmp (mask, "yyyy", 4) == 0)
X      {
X         sprintf (dateStr, "19%.2d", ltime->tm_year);
X	 mask += 4;
X	 dateStr += 4;
X	 continue;
X      }
X      else
X         if (strncmp (mask, "yy", 2) == 0)
X	 {
X	    sprintf (dateStr, "%.2d", ltime->tm_year);
X	    mask += 2;
X	    dateStr += 2;
X	    continue;
X 	 }
X
X/*
X**	Process mask
X*/
X      *dateStr = *mask;
X      dateStr++;
X      mask++;
X   }
X
X   *dateStr = '\0';
X   return (0);
X}
SHAR_EOF
chmod 0444 sysdate.c || echo "restore of sysdate.c fails"
echo "x - extracting TrapSignal.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > TrapSignal.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)TrapSignal.c	1.2   DeltaDate 5/6/88   ExtrDate 1/22/90";
X#endif
X
X#include	<signal.h>
X
XTrapSignal (action)
X
X	int	(*action)();
X{
X   if (signal (SIGINT, SIG_IGN) != SIG_IGN)   signal (SIGINT, action);
X   if (signal (SIGQUIT, SIG_IGN) != SIG_IGN)   signal (SIGQUIT, action);
X}
SHAR_EOF
chmod 0444 TrapSignal.c || echo "restore of TrapSignal.c fails"
echo "x - extracting checkmail.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > checkmail.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)checkmail.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	<signal.h>
X
X#ifndef BELL
X#define	BELL		printf ("%c", 7);
X#endif
X
Xextern	int		mailrow;
Xextern	int		mailcol;
X
Xcheckmail ()
X{
X	int		rc;
X	static int	mailcheck = 30;			/* default */
X
X#ifdef ALARM
X	alarm (0);					/* turn off alarm */
X#endif
X	if ((rc = anymail()) != FALSE)
X	{
X		/* we got mail */
X		attrset (A_REVERSE);
X		if (rc == 1  ||  rc == 3)
X			mvprintw (mailrow,mailcol, "MAIL");
X		else
X			mvprintw (mailrow,mailcol, "EMAIL");
X		attrset (A_NORMAL);
X#ifdef ALARM
X		BELL;
X#endif
X	}
X	else
X		mvprintw (mailrow,mailcol, "    ");
X
X#ifdef ALARM
X	signal (SIGALRM, checkmail);
X	if ((char *)getenv("MAILCHECK") != (char *)0)
X		sscanf ((char *)getenv("MAILCHECK"), "%d", &mailcheck);
X	if (mailcheck < 10)
X		mailcheck = 10;
X	alarm (mailcheck);				/* set alarm again */
X#endif
X}
X/* Paul J. Condie  4/88 */
SHAR_EOF
chmod 0444 checkmail.c || echo "restore of checkmail.c fails"
echo "x - extracting anymail.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > anymail.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)anymail.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*	FUNCTION:	anymail()
X**			If the first word in the mail file is Forward it returns
X**			no mail.
X**	RETURNS:	FALSE	- no unix or email.
X**			1	- unix mail.
X**			2	- email
X**			3	- both unix and email
X*/
X#include	<stdio.h>
X#include	<sys/types.h>
X#include	<sys/stat.h>
X
Xanymail ()
X{
X	FILE		*fopen(), *fp;
X	char		*getenv();
X	struct stat	Statbuf;
X	int		rc = 0;				/* return code */
X	char		*mailfile;
X	static int	FIRST_TIME = 1;
X	static int	FORWARDFLAG = 0;
X	char		tmpstr[80];
X
X
X   if ((mailfile = getenv("MAIL")) != (char *)0)
X   	if (stat (mailfile, &Statbuf) == 0)  
X   	{
X		/* there is a mail file */
X		if (Statbuf.st_size > 0)
X		{
X			/* there is something in the mail file */
X			if (FIRST_TIME)
X			{
X				/* check to see if mail is being Forwarded */
X				FIRST_TIME = 0;
X				if ((fp=fopen (mailfile, "r")) != (FILE *)NULL)
X				{
X					fscanf (fp, "%s", tmpstr);
X					if (strcmp (tmpstr, "Forward") == 0)
X						FORWARDFLAG = 1;
X					fclose (fp);
X				}
X			}
X			if (!FORWARDFLAG)
X				rc = 1;
X		}
X   	}
X   if ((mailfile = getenv("EMAIL")) != (char *)0)
X   	if (stat (mailfile, &Statbuf) == 0) 
X   	{
X		if (Statbuf.st_size > 0)
X			rc = rc == 1 ? 3 : 2;
X   	}
X   return (rc);
X}
SHAR_EOF
chmod 0444 anymail.c || echo "restore of anymail.c fails"
echo "x - extracting setenv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > setenv.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)setenv.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/* PROGRAM NAME:  @(#)setenv.c	1.2  
X*  REVISION DATE: 
X*  REVISION LEVEL:
X*  CONTACT PERSON: Library Staff
X*  AUTHOR: Stephen J. Muir 
X*  ABSTRACT: setenv/delenv - add, change or delete environment variables
X*  KEYWORDS: environment, shell, getenv
X*  DESCRIPTION: Setenv allows a program to set environment variables.
X*  		delenv allows a program to delete environment variables.
X*  PROJECTS: 
X*  SOFTWARE CATEGORY: application development tools
X*  COPYRIGHT:              Notice
X   This is the confidential, unpublished property of Pacific Bell.
X   Receipt or possession of it does not convey any rights to divulge,
X   reproduce, use, or allow others to use it without the specific written
X   authorization of Pacific Bell and use must conform strictly to
X   the license agreement between user and Pacific Bell.
X
X      COPYRIGHT (c) 1986 Pacific Bell. All Rights Reserved. 
X
X*  OPERATING ENVIRONMENT: all standard AT&T UNIX machines.
X*  SOFTWARE DEPENDENCIES: none.
X*  HARDWARE DEPENDENCIES: 
X*  LIMITATIONS: 
X*  DOCUMENTATION: setenv.3 manual page
X*  COMPILE COMMAND: cc setenv.c 
X*  SIZE: 
X*  SUPPORT LEVEL:
X*  MODULE LIST:
X*/
X# include <string.h>
X
X/* This is the number of extra array elements to allocate each time it becomes
X * necessary.
X */
X# define INC	10
X
Xextern char	**environ, *malloc ();
Xextern int	free ();
X
Xstatic char	**original, **current, **limit;
X
X/* This routine should be called only once (when either "setenv" or "delenv" is
X * called for the first time).  It would only be called again if it fails due
X * to lack of memory.  It makes a copy of the original environment because the
X * original environment array and its elements were not obtained from "malloc"
X * and the "free" routine cannot, therefore, be called with any of its
X * elements.
X *
X * return values:
X *	 0: success
X *	-1: out of memory - nothing has changed
X */
Xstatic	/* this is a private routine */
Xinitialise ()
X	{ register char	**old, **new_ptr, *tmp, **new_env;
X
X	  /* count number of existing strings */
X	  for (old = environ; *old; ++old)
X		;
X
X	  /* make space for extra strings */
X	  if ((new_ptr =
X	       new_env =
X	       (char **)malloc (sizeof (char **) * ((old - environ) + INC + 1))
X	      )
X	      == 0
X	     )
X		return (-1);
X
X	  /* "limit" points to the last element of the array -- it is used to
X	   * decide when to recreate it
X	   */
X	  limit = new_env + (old - environ) + INC;
X
X	  /* copy across old strings */
X	  for (old = environ; *old; ++old)
X	  { if ((tmp = malloc (strlen (*old) + 1)) == 0)
X	    { /* out of memory -- undo everything */
X	      while (new_ptr != new_env)
X		free (*--new_ptr);
X	      free ((char *)new_ptr);
X	      return (-1);
X	    }
X	    strcpy (tmp, *old);
X	    *new_ptr++ = tmp;
X	  }
X	  /* "current" points to the null pointer at the end of the array */
X	  *(current = new_ptr) = 0;
X
X	  /* this is really just a flag to say it's initialised */
X	  original = environ;
X	  /* overwrite old environment with new */
X	  environ = new_env;
X	  return (0);
X	}
X
X/* This is a special routine to compare a string "name" of the form "NAME" with
X * a string "name_value" of the form "NAME=VALUE".  It returns zero if the
X * comparison is successful
X */
Xstatic	/* this is a private routine */
Xdiffer (name, name_value)
X	char	*name, *name_value;
X	{ while (*name && *name_value)
X		if (*name++ != *name_value++)
X			return (1);
X	  return (*name_value != '=');
X	}
X
X/* This routine deletes an environment variable, e.g. delenv ("SHELL");
X *
X * return values:
X *	 0: success
X *	 1: environment variable not found
X *	-1: out of memory - nothing has changed
X */
Xdelenv (name)
X	char	*name;
X	{ register char	**ptr;
X
X	  /* initialise if necessary */
X	  if (original == 0 && initialise ())
X		return (-1);
X
X	  /* attempt to find it */
X	  for (ptr = environ; *ptr && differ (name, *ptr); ++ptr)
X		;
X	  if (*ptr == 0)
X		return (1);	/* not found */
X
X	  /* delete it */
X	  free (*ptr);
X	  *ptr = *--current;
X	  *current = 0;
X	  return (0);
X	}
X
X/* This routine sets a new environment variable, replacing an existing one
X * where appropriate, e.g. setenv ("SHELL", "/bin/csh");
X *
X * return values:
X *	 0: success
X *	-1: out of memory - nothing has changed
X */
Xsetenv (name, value)
X	char	*name, *value;
X	{ register char	**old, **new_ptr, *cp, *tmp, **new_env;
X
X	  /* initialise if necessary */
X	  if (original == 0 && initialise ())
X		return (-1);
X
X	  /* allocate space for the new string */
X	  if ((cp = tmp = malloc (strlen (name) + strlen (value) + 2)) == 0)
X		return (-1);
X
X	  /* find an existing one if we can - we do this now as we will lose
X	   * the original "name" pointer in the while loop following
X	   */
X	  for (old = environ; *old && differ (name, *old); ++old)
X		;
X
X	  /* make the new entry */
X	  while (*name)
X		*cp++ = *name++;
X	  *cp++ = '=';
X	  while (*value)
X		*cp++ = *value++;
X	  *cp = '\0';
X
X	  /* case 1: overwrite previous value */
X	  if (*old)
X	  { free (*old);
X	    *old = tmp;
X	  }
X
X	  /* case 2: no previous value and no space left - allocate more */
X	  else if (current == limit)
X	  { if ((new_ptr =
X		 new_env =
X		 (char **)malloc (sizeof (char **) *
X				  ((old - environ) + INC + 1)
X				 )
X		) == 0
X	       )
X	    { free (tmp);
X	      return (-1);
X	    }
X	    limit = new_env + (old - environ) + INC;
X	    for (old = environ; *old; )
X		*new_ptr++ = *old++;
X	    *new_ptr++ = tmp;
X	    *(current = new_ptr) = 0;
X	    free ((char *)environ);
X	    environ = new_env;
X	  }
X
X	  /* case 3: no previous value and there is enough space */
X	  else
X	  { *current++ = tmp;
X	    *current = 0;
X	  }
X	  return (0);
X	}
SHAR_EOF
chmod 0444 setenv.c || echo "restore of setenv.c fails"
echo "x - extracting strmatch.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > strmatch.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)strmatch.c	1.1   DeltaDate 10/20/88   ExtrDate 1/22/90";
X#endif
X
X#ifndef	TRUE
X#define	TRUE	1
X#endif
X#ifndef	FALSE
X#define	FALSE	0
X#endif
X#ifndef	BOOL
X#define	BOOL	int
X#endif
X
X#define	M_ALL	'*'
X#define	M_ONE	'?'
X#define	M_SET	'['
X#define	M_RNG	'-'
X#define	M_END	']'
X
X
XBOOL strmatch (name, pat)
X
X	char		*name, *pat;
X{
X   	char		c, k;
X	BOOL		ok;
X
X
X   while ((c = *pat++) != '\0')
X   {
X      switch (c)
X      {
X	 case M_ONE:
X		if (*name++ == '\0')   return (FALSE);
X		break;
X	
X	case M_ALL:
X		if (*pat == '\0')   return (TRUE);
X		for (; *name != '\0'; ++name)
X		   if (strmatch (name, pat))   return (TRUE);
X		return (FALSE);
X
X	case M_SET:
X		ok = FALSE;
X		k = *name++;
X		while ((c = *pat++) != M_END)
X		   if (*pat == M_RNG)
X		   {
X		      if (c <= k  &&  k <= pat[1])
X			 ok = TRUE;
X		      pat += 2;
X		   }
X		   else
X		      if (c == k)   ok = TRUE;
X		if (!ok)   return (FALSE);
X		break;
X
X	default:
X		if (*name++ != c)   return (FALSE);
X		break;
X      }
X   }
X   return (*name == '\0');
X}
SHAR_EOF
chmod 0444 strmatch.c || echo "restore of strmatch.c fails"
echo "x - extracting setvar.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > setvar.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)setvar.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	<string.h>
X#include	"menu.h"
X
X
X
Xsetvariable (cptr)
X	char	**cptr;				/* command pointer var=value */
X{
X	char	*getenv();
X	char	*getval();
X	char	command[BUFSIZ];
X	char	variable[100];
X	char	value[100];
X	int	rc;				/* return code */
X	int	i, j;
X
X	if (*cptr == (char *)NULL)   return (EOF);
X
X	/* skip junk characters */
X	for (;**cptr != '\0' &&  (!isalpha(**cptr)) && (!isdigit(**cptr)); 
X	      (*cptr)++) 
X		if (**cptr == '!')
X			break;
X		;
X	if (**cptr == '\0') return (EOF);	/* end of line */
X
X	/* get the enviroment variable */
X	for (i = 0; **cptr != '=' && **cptr != '\0'; i++, (*cptr)++)
X		variable[i] = **cptr;
X	variable[i] = '\0';
X	if (strcmp (variable, "") == 0  ||  **cptr != '=')
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, 
X		   "Error occured while setting enviroment variable %s",
X		   command);
X		shutdown ();
X	}
X	(*cptr)++;					/* get past the = */
X
X	strcpy (value, getval (cptr, '0'));
X
X	/* set the enviroment variable */
X	if (variable[0] == '!')
X	{
X		/*
X		**  if !
X		**     then only set if not already set
X		*/
X		/* junk ! - shift left one */
X		for (i = 0; variable[i] != '\0'; i++)
X			variable[i] = variable[i+1];
X		rc = 0;
X		if (getenv(variable) == (char *)NULL)
X			rc = setenv (variable, value);
X	}
X	else
X		rc = setenv (variable, value);
X	if (rc != 0)
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, 
X		   "Error occured while setting enviroment variable %s",
X		   command);
X		shutdown ();
X	}
X	return (0);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 setvar.c || echo "restore of setvar.c fails"
echo "x - extracting findfile.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > findfile.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)findfile.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/* Function	findfile()
X**  		Search through a number of directories looking for a file
X**  RETURNS	a pointer to the file with the directory if found
X**		otherwise returns a null pointer.
X*/
X
X#include	<stdio.h>
X#include	<varargs.h>
X#include	<sys/types.h>
X#include	<sys/stat.h>
X
X/*VARARGS*/
Xchar *findfile (va_alist)
X	va_dcl
X{
X	va_list		ap;
X	char		*filename;
X	char		*directory;
X	static char	file[200];
X	char		*fileptr;
X	struct stat	buf;
X	int		rc;
X
X	va_start (ap);
X	fileptr = file;
X
X	/* get filename to search for */
X	if ((filename = va_arg (ap, char *)) == (char *)0)
X	{
X		va_end (ap);
X		return ((char *)0);
X	}
X
X	/* loop through each directory looking for file */
X	while (1)
X	{
X		directory = va_arg (ap, char *);
X		/* getenv() returns a null */
X		if (directory == (char *)0)
X			continue;
X		if (strcmp (directory, "") == 0)
X			break;
X		sprintf (file, "%s/%s", directory, filename);
X		if (stat (file, &buf) == 0)
X		{
X			va_end (ap);
X			return (fileptr);
X		}
X	}
X	va_end (ap);
X	return ("");
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 findfile.c || echo "restore of findfile.c fails"
echo "x - extracting drawline.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > drawline.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)drawline.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X#define	MosaicLine	4	/* A_ALTCHARSET */
X#define	DiamondLine	5	/* A_ALTCHARSET */
X#define	DotLine		6	/* A_ALTCHARSET */
X#define	PlusLine	7	/* A_ALTCHARSET */
X
X#define	CANDRAWGRAPHICS	(enter_alt_charset_mode != NULL  && \
X			 strcmp(enter_alt_charset_mode, "") != 0)
X
X
Xdrawline (win, row, trythis, trythat, box)
X	WINDOW	*win;
X	int	row;
X	int	trythis;
X	int	trythat;
X	int	box;
X{
X	int	col;
X	int	hchar;					/* horizonal char */
X	int	lchar;					/* left char */
X	int	rchar;					/* right char */
X	int	attribute;
X	int	boxtype;
X
X
X	boxtype = trythis;
X	attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
X	if (attribute == A_ALTCHARSET)
X		/* can this terminal do graphics ? */
X		boxtype = CANDRAWGRAPHICS ? trythis : trythat;
X
X	switch (boxtype)
X	{
X	   case DumbLine:
X		/* draw a dumb line */
X		hchar = '-';
X		lchar = '+';
X		rchar = '+';
X		break;
X
X	   case StandoutLine:
X		/* draw a standout line */
X		attribute = A_STANDOUT;
X		hchar = ' ';
X		lchar = ' ';
X		rchar = ' ';
X		break;
X
X	   case SingleLine:
X		/* attempt to draw a graphic single line */
X		hchar = 'q';
X		lchar = 't';
X		rchar = 'u';
X		break;
X
X	   case MosaicLine:
X		hchar = 'a';
X		lchar = 'a';
X		rchar = 'a';
X		break;
X
X	   case DiamondLine:
X		hchar = '`';
X		lchar = '`';
X		rchar = '`';
X		break;
X
X	   case DotLine:
X		hchar = '~';
X		lchar = '~';
X		rchar = '~';
X		break;
X
X	   case PlusLine:
X		hchar = 'n';
X		lchar = 'n';
X		rchar = 'n';
X		break;
X		break;
X
X	   default:
X		return (-1);
X	}
X
X#ifdef BSD
X   	standout ();
X#else
X   	wattrset (win, attribute);
X#endif
X   	for (col = 0; col <= COLS-1; col++)
X      		mvwaddch (win, row, col, hchar);
X
X	if (box)
X	{
X		mvwaddch (win, row, 0, lchar);
X		mvwaddch (win, row, COLS-1, rchar);
X	}
X
X#ifdef BSD
X   	standend ();
X#else
X   	wattrset (win, A_NORMAL);
X#endif
X	return (0);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 drawline.c || echo "restore of drawline.c fails"
echo "x - extracting initmenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > initmenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)initmenu.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	"menu.h"
X
Xinitmenu (menu)
X	struct MenuInfo	*menu;
X{
X      /* set default menu settings */
X      menu->row_cursor = LINES - 2;
X      menu->col_cursor = COLS - 4;
X      menu->boxtype = 0;
X      menu->linetype = 0;
X      menu->srn[0] = (struct ScreenInfo *)NULL;
X}
SHAR_EOF
chmod 0444 initmenu.c || echo "restore of initmenu.c fails"
echo "x - extracting keyboard.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > keyboard.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)keyboard.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	"menu.h"
X
Xkeyboard ()
X{
X	char	*getenv();
X	int	ch;
X	int	wrow = 0;				/* from row */
X	int	wcol = 10;				/* from col */
X	int	sstart;					/* scrool start row */
X	int	send;					/* scrool end row */
X	int	prow;					/* print row */
X	int	dflag=0;
X	WINDOW	*bwin;
X
X
X	sstart = wrow + 10;
X	send = wrow + 20;
X	prow = sstart;
X
X	mvprintw (1,0, "Keyboard");
X	mvprintw (2,4, "Fun");
X
X	drawbox (stdscr, wrow+1,wcol, wrow+23,wcol+40, StandoutLine, 
X		StandoutLine, FALSE, FALSE);
X	mvprintw (2,wcol+40, "StandoutLine");
X	drawbox (stdscr, wrow+2,wcol+1, wrow+22,wcol+39, DumbLine, DumbLine,
X		FALSE, FALSE);
X	mvprintw (3,wcol+39, "DumbLine");
X
X	/* to get around bug in curses of not turning attributes off */
X	for (ch = 0; ch <= LINES; ch++)
X	{
X		mvprintw (ch,70, "hi");
X		refresh ();
X		mvprintw (ch,70, "  ");
X	}
X
X	/* terminal type */
X	mvprintw (wrow+3, wcol+4, "Terminal = %s", getenv("TERM"));
X
X	/* DrawLine ? */
X	if (enter_alt_charset_mode == NULL  ||
X	    strcmp (enter_alt_charset_mode, "") == 0)
X		mvprintw (wrow+4, wcol+4, "Alternate Characters = No");
X	else
X	{
X		dflag++;
X		mvprintw (wrow+4, wcol+4, "Alternate Characters = Yes");
X
X		mvprintw (5,wcol+44, "Check termcap/terminfo");
X		mvprintw (6,wcol+44, "setting if the alternate");
X		mvprintw (7,wcol+44, "character lines below");
X		mvprintw (8,wcol+44, "don't look right.");
X
X		bwin = newwin (13, 27, 10, wcol+43);
X		drawbox (bwin, 1,1, 13,27, SingleLine, SingleLine, FALSE,FALSE);
X		drawbox (bwin, 2,2, 12,26, MosaicLine, MosaicLine, FALSE,FALSE);
X		drawbox (bwin, 3,3, 11,25, DiamondLine, DiamondLine, FALSE,FALSE);
X		drawbox (bwin, 4,4, 10,24, DotLine, DotLine, FALSE,FALSE);
X		drawbox (bwin, 5,5, 9,23, PlusLine, PlusLine, FALSE,FALSE);
X
X		mvwprintw (bwin, 0,7, " SingleLine ");
X		mvwprintw (bwin, 1,7, " MosaicLine ");
X		mvwprintw (bwin, 2,7, " DiamondLine ");
X		mvwprintw (bwin, 3,7, " DotLine ");
X		mvwprintw (bwin, 4,7, " PlusLine ");
X	}
X
X	/* Show all attributes */
X	mvprintw (11,0, "Curses");
X	mvprintw (12,0, "Attributes");
X
X	attrset (A_NORMAL);
X	mvprintw (14,0, "NORMAL");
X	attrset (A_STANDOUT);
X	mvprintw (15,0, "STANDOUT");
X	attrset (A_REVERSE);
X	mvprintw (16,0, "REVERSE");
X	attrset (A_UNDERLINE);
X	mvprintw (17,0, "UNDERLINE");
X	attrset (A_BLINK);
X	mvprintw (18,0, "BLINK");
X	attrset (A_DIM);
X	mvprintw (19,0, "DIM");
X	attrset (A_BOLD);
X	mvprintw (20,0, "BOLD");
X
X	attrset (A_NORMAL);
X
X	/* key codes */
X	mvprintw (wrow+6,wcol+8, "Press a Key");
X	mvprintw (wrow+7,wcol+8, "Press zero to exit.");
X
X	/* set up scroll */
X	scrollok (stdscr, TRUE);
X	wsetscrreg (stdscr, sstart, send);
X
X	mvprintw (sstart-2, wcol+4, "      (.menuinit)");
X	attrset (A_BOLD);
X	mvprintw (sstart-1, wcol+4, "char      dec     hex    octal");
X	attrset (A_NORMAL);
X	do
X	{
X		refresh ();
X		if (dflag)
X		{
X			touchwin (bwin);
X			wrefresh (bwin);
X		}
X		move (wrow+6, wcol+8+strlen("Press a Key")+1);
X		refresh ();
X		ch = getch ();
X
X		/*
X		nodelay (stdscr, TRUE);
X		while ((ch = getch()) != -1)
X			print ch
X		nodelay (stdscr, FALSE);
X		*/
X
X		if (prow > send-2)
X		{
X			scroll (stdscr);
X			attrset (A_STANDOUT);
X			mvprintw (prow+1,wcol-1, " ");
X			mvprintw (prow+1,wcol+39, " ");
X			attrset (A_NORMAL);
X
X			mvprintw (prow+1,wcol, "|");
X			mvprintw (prow+1,wcol+38, "|");
X		}
X		else
X			prow++;
X		if (ch == '\t')
X			mvprintw (prow,wcol+4, "\t\\t\t%d\t%x\t%o", ch,ch,ch);
X		else	if (ch == '\n')
X				mvprintw (prow,wcol+4, "\t\\n\t%d\t%x\t%o", 
X						ch,ch,ch);
X		else	if (ch == '\r')
X				mvprintw (prow,wcol+4, "\t\\r\t%d\t%x\t%o", 
X						ch,ch,ch);
X		else	if (ch == '\b')
X				mvprintw (prow,wcol+4, "\t\\b\t%d\t%x\t%o", 
X						ch,ch,ch);
X		else
X			mvprintw (prow,wcol+4, "\t%c\t%d\t%x\t%o", ch,ch,ch,ch);
X
X	} while (ch != '0');
X	if (dflag)
X	{
X		touchwin (bwin);
X		wrefresh (bwin);
X	}
X}
X/* Paul J. Condie */
SHAR_EOF
chmod 0444 keyboard.c || echo "restore of keyboard.c fails"
echo "x - extracting runscreen.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > runscreen.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	runscreen()
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X#include	"menu.h"
X#include	"terminal.h"
X
X#define	SRN	menu->srn[sidx]
X#define	FLD	menu->srn[sidx]->field[fidx]
X
Xextern int debug;
X
X
Xrunscreen (screen_name, menu, opnumber)
SHAR_EOF
echo "End of part 5"
echo "File runscreen.c is continued in part 6"
echo "6" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 6 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file runscreen.c continued
#
CurArch=6
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 runscreen.c"
sed 's/^X//' << 'SHAR_EOF' >> runscreen.c
X	char			screen_name[];
X	struct MenuInfo		*menu;
X	int			opnumber;
X{
X	FILE			*popen(), *pp;
X	char			*getenv();
X	char			*getval();
X	char			*findfile();
X	WINDOW			*swin;
X	union FldUnion		Fld;
X	int			rc;		/* return code */
X	int			exitkey;
X	int			sidx;
X	int			fidx = 0;
X	char			fieldinput[MAXFIELDS+1][100];
X	int			fieldcount;
X	char			*promptptr;
X	char			*mask;		/* mask pointer */
X	char			fmtdefault[100];/* formated default value */
X	char			*wsptr;		/* working storage pointer */
X	char			*source;	/* default data pointer */
X	int			helpflag = TRUE;
X	char			helpfile[80];
X	char			tmptitle[100];
X	int			toprow;
X	int			leftcol;
X
X
X
X	/* Find the screen definition */
X	for (sidx = 0; menu->srn[sidx] != (struct ScreenInfo *)NULL && 
X		sidx <= MAXSCREENS; sidx++)
X	{
X		if (strcmp (screen_name, menu->srn[sidx]->name) == 0)
X			break;
X	}
X	if (sidx > MAXSCREENS  ||  menu->srn[sidx] == (struct ScreenInfo *)NULL)
X	{
X		BEEP;
X		mvprintw (ErrRow-2,0, "Could not find your screen definition.");
X		shutdown ();
X	}
X
X	wsptr = SRN->toprowvar;
X	if (strcmp (SRN->toprowvar, "") != 0)
X		toprow = atoi (getval (&wsptr, '1'));
X	else
X		toprow = SRN->toprow;
X	wsptr = SRN->leftcolvar;
X	if (strcmp (SRN->leftcolvar, "") != 0)
X		leftcol = atoi (getval (&wsptr, '1'));
X	else
X		leftcol = SRN->leftcol;
X
X	if (toprow == AUTO)
X	{
X		/*
X		** Figure out where to put the screen 
X		** try to put screen as close to the option as possible 
X		*/
X		toprow = menu->option[opnumber]->row - 2;
X		/*
X		for (rc = 0, leftcol = 0; rc < menu->optioncount ; rc ++)
X			if (strlen (menu->option[rc]->description) > leftcol)
X				leftcol = strlen (menu->option[rc]->description);
X		leftcol = menu->option[opnumber]->col + 
X			      ((leftcol + 4) / 2);
X		*/
X		leftcol = menu->option[opnumber]->col +
X			       strlen(menu->option[opnumber]->description) + 4;
X
X		/* make sure it fits on the screen */
X		if ((toprow + SRN->rows) > LINES-1)
X			toprow = LINES - SRN->rows - 1;
X
X		if ((leftcol + SRN->cols + 2) > COLS)
X			leftcol = COLS - SRN->cols - 1;
X	}
X
X
X	/* create the window */
X	swin = newwin (SRN->rows, SRN->cols, toprow, leftcol);
X	keypad (swin, TRUE);
X
X	/* 
X	**	check if recalculation of rows & cols is necessary
X	**	see newwin() for info on why
X	*/
X	if (SRN->rows == 0  &&  SRN->cols == 0  &&  
X	    toprow == 0  && leftcol == 0)
X	{
X		/* a full-screen was created */
X		SRN->rows = LINES-1;
X		SRN->cols = COLS;
X	}
X	else  	if (SRN->rows == 0  ||  SRN->cols == 0)
X		{
X			SRN->rows = LINES - toprow;
X			SRN->cols = COLS - leftcol;
X			if (SRN->rows == LINES)
X				SRN->rows--;
X		}
X
X
X	if (strcmp (SRN->helpfile, "") == 0)
X		helpflag = FALSE;
X	else
X		strcpy (helpfile, findfile (SRN->helpfile, ".",
X			getenv("HELPDIR"), getenv("MENUDIR"), ""));
X	drawbox (swin, 1,1, SRN->rows,SRN->cols, SRN->boxtype & 0777, 
X		StandoutLine, FALSE, helpflag);
X
X	/* display title */
X	wsptr = SRN->title;
X	strcpy (tmptitle, getval (&wsptr, '1'));
X	wattrset (swin, A_STANDOUT);
X	mvwprintw (swin, 0, ((SRN->cols)/2)-(strlen(tmptitle)/2), 
X		"%s", tmptitle);
X	/*
X	if (strcmp (menu->helpfile, "") != 0)
X		mvwprintw (menu->win, menu->NumItems+2,menu->width+3, "?");
X	*/
X	wattrset (swin, A_NORMAL);
X
X	/*
X	**  Run fielddefaults if there is one and load results into fieldinput
X	*/
X	if (SRN->fielddefaults != (char *)NULL)
X	{
X		if (debug)
X		{
X			fprintf (stderr, "\n[runscreen] <%s> popen=:%s:", 
X				SRN->name, SRN->fielddefaults);
X			fflush (stderr);
X		}
X		move (ErrRow,0);  clrtoeol();
X		mvprintw (ErrRow,1, "Initializing screen fields...");
X		refresh ();
X		if ((pp = popen (SRN->fielddefaults, "r")) == (FILE *)NULL)
X		{
X			BEEP;
X			mvprintw (ErrRow-2,0, "Could not open pipe = %s",
X				SRN->fielddefaults);
X			shutdown ();
X		}
X
X		/* read and set each field until no more input */
X		rc = 99;
X		for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X			fidx <= MAXFIELDS; fidx++)
X		{
X			strcpy (fieldinput[fidx], "");
X			if (rc == EOF) 
X			{
X				if (debug)
X				{
X					fprintf (stderr, 
X			 	     		"\n[runscreen] <%s> read nothing from popen",
X						SRN->name);
X					fprintf (stderr, 
X	 	     		          "\n[runscreen] <%s> field %d =:%s:",
X				          SRN->name,fidx, fieldinput[fidx]);
X					fflush (stderr);
X				}
X				continue;
X			}
X
X			/* get a word from the pipe */
X   			rc = fscanf (pp, "%s", fmtdefault);
X			if (rc == EOF) continue;
X			if (debug)
X			{
X				fprintf (stderr, 
X			 	     "\n[runscreen] <%s> read from popen=:%s:",
X					SRN->name, fmtdefault);
X				fflush (stderr);
X			}
X
X			/* check for NULL value */
X			if (strcmp (fmtdefault, "NULL") == 0)
X			{
X				strcpy (fieldinput[fidx], "");
X				if (debug)
X				{
X					fprintf (stderr, 
X	 	     		          "\n[runscreen] <%s> field %d =:%s:",
X				          SRN->name,fidx, fieldinput[fidx]);
X					fflush (stderr);
X				}
X				continue;
X			}
X				
X			/* check for a quoted value */
X			if (fmtdefault[0] == '"')
X			{
X				/*
X				** found a quoted value 
X				** read until another quote or end of line
X				*/
X				strcpy (fieldinput[fidx], fmtdefault+1);
X				if (fmtdefault[strlen(fmtdefault)-1] == '"')
X				{
X					/* end of quote is on first word */
X					fieldinput[fidx][strlen(fieldinput[fidx])-1] = '\0';
X					if (debug)
X					{
X						fprintf (stderr, 
X	 	     		          	    "\n[runscreen] <%s> field %d =:%s:",
X				          	    SRN->name, fidx, 
X						    fieldinput[fidx]);
X						fflush (stderr);
X					}
X					continue;
X				}
X   				while ((rc = fscanf (pp, "%s", fmtdefault)) != EOF)
X				{
X					if (debug)
X					{
X						fprintf (stderr, 
X			 	     		"\n[runscreen] <%s> read from popen=:%s:",
X						    SRN->name, fmtdefault);
X						fflush (stderr);
X					}
X					strcat (fieldinput[fidx], " ");
X					strcat (fieldinput[fidx], fmtdefault);
X					if (fmtdefault[strlen(fmtdefault)-1] == '"')
X					{
X						/* end of quote */
X						fieldinput[fidx][strlen(fieldinput[fidx])-1] = '\0';
X						break;
X					}
X				}
X			}
X			else
X				strcpy (fieldinput[fidx], fmtdefault);
X			if (debug)
X			{
X				fprintf (stderr, 
X	 	     		        "\n[runscreen] <%s> field %d =:%s:",
X				        SRN->name, fidx, fieldinput[fidx]);
X				fflush (stderr);
X			}
X		} /* end for each field */
X		pclose(pp);
X	}
X
X	/*
X	**  Initialize the screen
X	**  Loop through each field
X	**	print the label
X	**	for SET and MENU types determine field_length
X	**	put in the field terminators
X	**	get, format and print default value in getenv () or fielddefaults
X	*/
X	for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X		fidx <= MAXFIELDS;
X		fidx++)
X	{
X		/* print label */
X		if (strlen(FLD->label) > 0)
X			mvwprintw (swin, FLD->row, 
X				FLD->col - strlen(FLD->label) - 2,
X				"%s", FLD->label);
X
X		/* for SET and MENU types get field_length */
X		if (FLD->type == SET  ||  FLD->type == MENU)
X			FLD->length = GetSetLen (FLD->range);
X
X		/* print field terminators */
X		if (strlen(FLD->terminator) > 0)
X		{
X			/* left */
X			mvwprintw (swin, FLD->row, FLD->col - 1,
X				"%c", FLD->terminator[0]);
X			/* right */
X			if (strlen(FLD->mask) > 0)
X				mvwprintw (swin, FLD->row, 
X					FLD->col + strlen(FLD->mask),
X					"%c", FLD->terminator[1]);
X			else
X				mvwprintw (swin, FLD->row, 
X					FLD->col + FLD->length,
X					"%c", FLD->terminator[1]);
X		}
X
X		/*
X		**  If a fielddefaults command was given
X		**    then the default values are already in fieldinput
X		**    else load from getenv()
X		*/
X		if (SRN->fielddefaults == (char *)NULL)
X		{
X			/* get default value from getenv() */
X			if (getenv(FLD->name) != (char *)NULL)
X				strcpy (fieldinput[fidx], getenv (FLD->name));
X			else
X				strcpy (fieldinput[fidx], "");
X			if (strcmp (fieldinput[fidx], "NULL") == 0)
X				strcpy (fieldinput[fidx], "");
X		}
X
X		/* format default value to the mask */
X		strcpy (fmtdefault, fieldinput[fidx]);
X		if (strlen(FLD->mask) > 0)
X		{
X			wsptr = fmtdefault;
X			mask = FLD->mask;
X			source = fieldinput[fidx];
X			for (; *mask != '\0'; mask++, wsptr++)
X			{
X				if (IsMask (FLD->type, *mask))
X					*wsptr = *mask;	/* format char */
X				else
X				{
X					if (*source != '\0')
X					{
X						*wsptr = *source;
X						source++;
X					} 
X					else
X						*wsptr = ' ';	/* no data */
X				}
X			}
X			*wsptr = '\0';
X		}
X		/* print default data */
X		if (strlen(fmtdefault) > 0)
X			mvwprintw (swin, FLD->row, FLD->col, "%s", fmtdefault);
X	}
X	fieldcount = fidx-1;				/* save field count */
X
X
X	/*
X	**  GetInput from fields untill KEY_CANCEL || KEY_ACCEPT
X	*/
X	move (ErrRow,0);  clrtoeol();
X	fidx = 0;				/* start with first field */
X
X	do
X	{
X   		Fld.strVal = fieldinput[fidx];
X
X
X		if (exitkey == 999)
X			/*
X			** This is so GetInput doesn't overwrite the
X			** must enter message.
X			*/
X			promptptr = NOMSG;
X		else
X			promptptr = FLD->prompt;
X
X		/* if noinput == FALSE prompt for input */
X		if (!FLD->noinput)
X		{
X   			exitkey = GetInput (swin, FLD->row, FLD->col, &Fld, 
X				A_REVERSE, FLD->mask, FLD->range, FLD->length, 
X				FLD->min_input, FLD->type, FLD->adjust, CHAR, 
X				NOAUTO, FLD->mustenter, ErrRow, ErrRow, 
X				promptptr, helpfile, FLD->name);
X		}
X		else
X		{
X			/* use the exitkey from the last field */
X			if (exitkey != KEY_UP)
X				exitkey = KEY_DOWN;
X		}
X
X
X		if (exitkey == KeyReturn)	exitkey = KEY_RETURN;
X		if (exitkey == KeyUp)  		exitkey = KEY_UP;
X		if (exitkey == KeyDown)  	exitkey = KEY_DOWN;
X		if (exitkey == KeyTab)  	exitkey = KEY_TAB;
X		if (exitkey == KeyBTab)  	exitkey = KEY_BTAB;
X		if (exitkey == KeyCancel) 	exitkey = KEY_CANCEL;
X		if (exitkey == KeyAccept)	exitkey = KEY_ACCEPT;
X
X		/* if exitlastfield accept input and exit on last field */
X		if (SRN->exitlastfield && fidx == fieldcount && 
X		    exitkey == KEY_RETURN)
X			exitkey = KEY_ACCEPT;
X
X		switch (exitkey)
X		{
X		   case KEY_CANCEL:
X			break;
X
X		   case KEY_ACCEPT:
X			/* make sure mustenter fields have been entered */
X			for (fidx = 0; fidx <= fieldcount; fidx++)
X				if (FLD->mustenter  &&  
X				    strcmp (fieldinput[fidx], "") == 0)
X				{
X					mvwprintw (stdscr, ErrRow,1, 
X					   "This is a must enter field.");
X					BEEP;
X					wnoutrefresh (stdscr);
X					exitkey = 999;
X					break;
X				}
X			/* if mustenter then more input */
X			if (fidx <= fieldcount)
X				break;
X
X			/* set the environment variables */
X			for (fidx = 0; fidx <= fieldcount; fidx++)
X			{
X				if (strcmp (fieldinput[fidx], "") == 0)
X					strcpy (fieldinput[fidx], "NULL");
X
X				rc = setenv (FLD->name, fieldinput[fidx]);
X				if (rc < 0)
X				{
X					mvwprintw (stdscr, ErrRow,0, "Unable to allocate environment memory to set variable %s.", fieldinput[fidx]);
X					BEEP;
X				}
X			}
X			break;
X
X		   case KEY_TAB:
X			fidx += 4;
X			fidx = fidx >= fieldcount ? 0 : ++fidx;
X			break;
X
X		   case KEY_BTAB:
X			fidx -= 4;
X			fidx = fidx < 0 ? fieldcount : --fidx;
X			break;
X
X		   case KEY_UP:
X			fidx = fidx <= 0 ? fieldcount : --fidx;
X			break;
X
X		   case KEY_RETURN:
X		   case KEY_DOWN:
X		   default:
X			fidx = fidx >= fieldcount ? 0 : ++fidx;
X			break;
X		}
X	} while (exitkey != KEY_CANCEL  &&  exitkey != KEY_ACCEPT);
X
X	delwin (swin);					/* junk screen window */
X	wmove (stdscr,LINES-1,0);
X	clrtoeol ();					/* clear field prompt */
X	touchwin (stdscr);
X
X	if (exitkey == KEY_CANCEL)
X		return (exitkey);
X	else
X		return (0);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
echo "File runscreen.c is complete"
chmod 0644 runscreen.c || echo "restore of runscreen.c fails"
echo "x - extracting getval.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > getval.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*
X**  getval()
X**  ARGS:
X**	sptr	- pointer to beginning of value 2b parsed
X**	endch	- $ process only the dollar part of value
X**		- ` process only the single quote part of value
X**		- " process only the double quote part of value
X**		- 0 process until a space or invalid is found
X**		- 1 process entire string until '\0' is found
X**  RETURNS:
X**	sptr	- pointer to end of value 2b parsed
X**	rval	- the resulting value.
X**
X**	var=one
X**	var="one"
X**	var=$var
X**	var="one $var"
X**	var=${var}
X**	var=`ls`
X**	var=one"two three"
X**	var=~/
X**	var=~usr/
X*/
X
X#include	<stdio.h>
X#include	<ctype.h>
X#include	<pwd.h>
X
X#define DQUOTE	'"'
X#define SQUOTE	'`'
X#define LITERAL	'\''
X#define DOLLAR	'$'
X#define ESCAPE	'\\'
X#define BRACE	'{'
X#define COMCHAR '#'
X#define	TILDE	'~'
X#ifndef	TRUE
X#define	TRUE	1
X#define	FALSE	0
X#endif
X
X#ifndef	TEST
Xextern int	debug;
X#endif
X
X
Xchar *getval (sptr, endch)
X	char	**sptr;					/* pointer to $+1 */
X	char	endch;
X{
X	char		*getenv();
X	struct passwd	*getpwnam();
X	FILE		*popen(), *pp;
X	static char	value[400];
X	char		tmpval[400];
X	static char	*rval;				/* pointer for return */
X	int		i;
X	int		EOV = FALSE;			/* End Of Value */
X	int		dqflag = FALSE;			/* double quote flag */
X	struct passwd	*pw;
X
X
X	strcpy (value, "");
X	rval = value;
X	while (!EOV && **sptr)
X	{
X		switch (**sptr)
X		{
X	   	   case SQUOTE:
X			(*sptr)++;				/* get past ' */
X			for (i = 0; **sptr != '`' && **sptr; i++, (*sptr)++)
X				tmpval[i] = **sptr;
X			if (**sptr)
X				(*sptr)++;		/* get past ' */
X			tmpval[i] = '\0';
X			/* open pipe and read results */
X			if ((pp = popen (tmpval, "r")) != NULL)
X			{
X				for (; ((i = fgetc(pp)) != EOF); rval++)
X				{
X					*rval = i ;
X					if (!isprint(*rval))
X						rval--;
X				}
X				pclose (pp);
X			}
X			if (endch == SQUOTE)
X			{
X				*rval = '\0';
X				rval = value;
X				return (rval);
X			}
X			break;
X
X	   	   case DQUOTE:
X			(*sptr)++;
X			dqflag = dqflag == FALSE ? TRUE : FALSE;
X			if (endch == DQUOTE && dqflag == FALSE)
X			{
X				*rval = '\0';
X				rval = value;
X				return (rval);
X			}
X			break;
X
X	   	   case DOLLAR:
X			/* Substitutable parameter */
X
X			(*sptr)++;				/* get past $ */
X
X			/*
X			**  The braces are required only when parameter is
X			**  followed by a letter, digit, or underscore.
X			*/
X			if (**sptr == BRACE)
X			{
X				(*sptr)++;			/* get past { */
X				for (i = 0; **sptr != '}' && **sptr; 
X				     i++, (*sptr)++)
X					tmpval[i] = **sptr;
X				if (**sptr)
X					(*sptr)++;		/* get past } */
X			}
X			else
X			{
X				for (i = 0; isalnum(**sptr) || **sptr == '_'; 
X					i++, (*sptr)++)
X					tmpval[i] = **sptr;
X			}
X			tmpval[i] = '\0';
X			if (getenv(tmpval) != (char *)NULL)
X				strcpy (rval, getenv(tmpval));
X			rval += strlen (rval);
X			if (endch == DOLLAR)
X			{
X				*rval = '\0';
X				rval = value;
X				return (rval);
X			}
X			break;
X
X		   case TILDE:
X			(*sptr)++;				/* get past ~ */
X			/*
X			**  ~/ = $HOME
X			**  ~user/ = home(user)
X			*/
X			for (i = 0; **sptr != '/' && **sptr; i++, (*sptr)++)
X				tmpval[i] = **sptr;
X			tmpval[i] = '\0';
X			if (strcmp (tmpval, "") == 0)
X				if (getenv("LOGNAME") != (char *)NULL)
X					strcpy (tmpval, getenv ("LOGNAME"));
X			/*
X			**  tmpval holds the user name
X			**  now we get the password entry
X			*/
X			pw = getpwnam (tmpval);
X			strcpy (rval, pw->pw_dir);
X			rval += strlen (pw->pw_dir);
X			break;
X
X	   	   default:
X			if (dqflag || **sptr != ' ' || endch == '1')
X			{
X				*rval++ = **sptr;
X				(*sptr)++;
X			}
X			else
X				EOV = TRUE;
X			break;
X		} /* end switch */
X	} /* end while */
X
X	*rval = '\0';
X	rval = value;
X#ifndef	TEST
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] value=:%s:, :%s:",
X			__FILE__, value, *sptr);
X		fflush (stderr);
X	}
X#endif
X	return (rval);
X}
X
X
X
X#ifdef	TEST
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	char		*getval();
X	char		*sptr;
X	char		*rval;
X
X	sptr = argv[1];
X	if (argc == 3)
X		rval = getval (&sptr, argv[2][0]);
X	else
X		rval = getval (&sptr, '1');
X	printf ("\nparameter value :%s:", rval);
X	printf ("\narg pointer :%s:", sptr);
X}
X#endif
X/* Paul J. Condie  5/89 */
SHAR_EOF
chmod 0644 getval.c || echo "restore of getval.c fails"
echo "x - extracting clean_menu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > clean_menu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)clean_menu.c	1.1   DeltaDate 6/14/89   ExtrDate 1/22/90";
X#endif
X
X#include	"menu.h"
X
Xclean_menu (menu)
X	struct MenuInfo	*menu;
X{
X	int		i,j;
X
X
X	/*
X	** Just to keep things simple, lets start from scratch on the
X	** next menu selected.
X	*/
X
X	/* free options */
X      	for (i = 0; i < menu->optioncount; i++)
X       		free (menu->option[i]);
X
X      	/* free screens */
X	for (i = 0; menu->srn[i] != (struct ScreenInfo *)NULL  &&  
X	     i <= MAXSCREENS; i++)
X	{
X		if (menu->srn[i]->fielddefaults != (char *)NULL)
X			free (menu->srn[i]->fielddefaults);
X		/* free screen fields */
X		for (j = 0; 
X		     menu->srn[i]->field[j] != (struct FieldInfo *)NULL &&
X		     j <= MAXFIELDS; j++)
X			free (menu->srn[i]->field[j]);
X		free (menu->srn[i]);
X		menu->srn[i] = (struct ScreenInfo *)NULL;
X	}
X}
X/* Paul J. Condie  6/89 */
SHAR_EOF
chmod 0444 clean_menu.c || echo "restore of clean_menu.c fails"
echo "x - extracting System.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > System.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)System.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  System()
X**	Reset the effective uid/gid in case menu has the set uid bit set.
X*/
X
XSystem( cmdStr )
X	char	*cmdStr ;
X{
X	register int	uid, euid, gid, egid ;
X
X	/* who am i */
X	uid = getuid() ;
X	euid = geteuid() ;
X	gid = getgid() ;
X	egid = getegid() ;
X
X	/* reset back to the read id */
X	setuid( uid ) ;
X	setgid( gid ) ;
X
X	system( cmdStr ) ;
X
X	/* reset back to the fake id */
X	setuid( euid ) ;
X	setgid( egid ) ;
X}
X/* Sam S. Lok  11/89 */
SHAR_EOF
chmod 0444 System.c || echo "restore of System.c fails"
echo "x - extracting slength.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > slength.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)slength.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**	How long is a string not counting attributes.
X*/
X
Xslength (s)
X	char		*s;
X{
X	register int	i = 0;
X
X	while (*s)
X	{
X		if (*s == '\\')
X		{
X			s++;
X			s++;
X			continue;
X		}
X		s++;
X		i++;
X	}
X	return (i);
X}
X/* Paul J. Condie  11-89 */
SHAR_EOF
chmod 0444 slength.c || echo "restore of slength.c fails"
echo "x - extracting upper.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > upper.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)upper.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
Xupper (s)
X
X	char		*s;
X{
X	register int	i;
X
X   while (*s)
X   {
X      if (*s >= 'a'  &&  *s <= 'z')
X         *s = (*s + 'A' - 'a');
X      s++;
X   }
X}
SHAR_EOF
chmod 0444 upper.c || echo "restore of upper.c fails"
echo "x - extracting substr.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > substr.c &&
X/*  E911 Project
X *  substr()
X *
X *  Purpose:	To find a substring within a given string
X *  Args:	s1: The string being searched
X *		s2: the string being searched for
X *  Return:	pointer to the where the searched for string resides
X *		within the search string; otherwise NULL
X */
X
X
Xchar	*
Xsubstr(s1, s2)
Xchar	*s1;
Xchar	*s2;
X{
X	char	*p1, *p2;
X
X	for ( ; *s1; s1++) {
X		if (*s1 != *s2)
X			continue;
X		p1 = s1 + 1;
X		p2 = s2 + 1;
X		while (1) {
X			if (*p2 == '\0')
X				return(s1);
X			if (*p1++ != *p2++)
X				break;
X		}
X	}
X	return(0);
X}
X
X
X#ifdef LTEST
Xmain()
X{
X	char	*strtok();
X
X	char	*s1, *s2, *s3;
X	char	buffer[256];
X
X	printf("ok\n");
X	while (gets(buffer)) {
X		s1 = strtok(buffer, " \t:\n");
X		s2 = strtok(0, " \t:\n");
X		printf("%s:%s:", s1, s2);
X		if (s1 && s2)
X			if (s3 = substr(s1, s2))
X				printf("%.*s\n", strlen(s2), s3);
X			else
X				printf("no match\n");
X		else
X			printf("invalid input\n");
X	}
X}
X#endif
X
X
SHAR_EOF
chmod 0666 substr.c || echo "restore of substr.c fails"
echo "x - extracting menu.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > menu.h &&
X#ifndef LINT
Xstatic char ID_menu[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#define	VERSION	"3.41"			/* current version */
X
X#ifndef BELL
X#define	BELL	printf ("%c", 7)
X#endif
X#ifndef BEEP
X#define	BEEP	printf ("%c", 7)
X#endif
X#ifndef NULL
X#define	NULL	0
X#endif
X#define	null			0
X#define	MENUINIT	".menuinit"	/* initialize filename */
X#define	HELPFILE	"menu.hlp"
X#define	BORDERCHAR	' '
X#define	MAXTITLE	6		/* maximum # of title lines */
X#define	MAXKEYS		25		/* maximum # of keys */
X#define	MAXKEYLENGTH	15		/* maximum length of keyword */
X#define	MAXOPTION	60		/* max # of option 2b displayed */
X#define	MAXMENU		20		/* max nested menus */
X#define	MAXGNAME	20		/* max goto menu names */
X#define	MAXLEN		1024		/* max length of option command */
X#define	MAXSCREENS	10		/* max .DEFINE_SCREEN per menu */
X#define	MAXFIELDS	20		/* max fields per .DEFINE_SCREEN */
X#define	ErrRow		(LINES-1)	/* last line to print error message */
X#define	GNAMEOFFSET	100		/* Offset return code for gnames */
X
X#define	QUIT		-1
X#define	MAINMENU	-2
X#define	PREVIOUSMENU	-3
X#define	NOWAYJOSE	-4		/* not authorized for menu */
X#define	REPARSE		-5		/* reparse & display the current menu */
X#define	SUBMENU		-99		/* a submenu was selected */
X
X#define	BUFSIZE		512
X
X/* Line drawing types */
X#define	DumbLine	1
X#define	StandoutLine	2
X#define	SingleLine	3
X#define	MosaicLine	4
X#define	DiamondLine	5
X#define	DotLine		6
X#define	PlusLine	7
X
X#define	AUTO		999
X
X
X/*
X**  Keys not defined in some curses.h
X*/
X
X#ifndef KEY_HELP
X#   define KEY_HELP	0553
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	0565
X#endif
X#ifndef KEY_CANCEL
X#   define KEY_CANCEL	0543
X#endif
X#ifndef KEY_TAB
X#   define KEY_TAB	'\t'
X#endif
X#ifndef KEY_BTAB
X#   define KEY_BTAB	0541
X#endif
X#ifndef KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_LINEFEED
X#   define KEY_LINEFEED	'\n'
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	0565
X#endif
X#ifndef KEY_BEG
X#   define KEY_BEG	0542
X#endif
X#ifndef KEY_END
X#   define KEY_END	0550
X#endif
X#define KEY_ACCEPT	1000
X#define	KEY_MAINMENU	1001
X#define	KEY_PREVMENU	1002
X#define	KEY_EXITMENU	1003
X#define	KEY_POPGNAME	1004
X#define	KEY_GNAME	1005
X
X/*
X**  MACROS
X*/
X
X#define	SKIPJUNK(s) 	/* \
X			**  This macro skips over spaces, tabs, etc. \
X			**  ARGS:  char  *s \
X			*/ \
X			for (;*s != '\0' && (isspace(*s)); s++) \
X				;
X
X
X/*
X**  STRUCTURES
X*/
X
Xstruct MenuInfo
X{
X	char			name	[15];		/* file name */
X	int			wfrow;			/* window first row */
X	int			wlrow;			/* window last row */
X	int			wfcol;			/* window first col */
X	int			wlcol;			/* window last col */
X	int			row_cursor;		/* row for cursor */
X	int			col_cursor;		/* col for cursor */
X	unsigned		boxtype;		/* 0 = no box */
X	unsigned		linetype;		/* same as box */
X	int			titlecount;
X	int			optioncount;		/* base 0 */
X	struct OptionInfo	*option	[MAXOPTION];
X	struct ScreenInfo	*srn	[MAXSCREENS+1];	/* .DEFINE_SCREEN */
X							/* NULL = EOL */
X};
X
X
Xstruct OptionInfo
X{
X	char	keyword		[MAXKEYLENGTH+1];
X	int	opnumber;				/* option number */
X	char	description	[200];
X	char	command		[MAXLEN];
X	int	row;					/* row to display */
X	int	col;					/* col to display */
X};
X
Xstruct ScreenInfo
X{
X	char			name	[30];		/* screen name */
X	char			title	[100];		/* window title */
X	int			toprow;			/* upper left corner */
X	char			toprowvar[40];
X	int			leftcol;
X	char			leftcolvar[40];
X	int			rows;			/* # rows in win */
X	int			cols;			/* # cols in win */
X	unsigned		boxtype;		/* 0 = no box */
X	int			exitlastfield;		/* after last field */
X	char			helpfile[16];
X	char			*fielddefaults;		/* init field command */
X	struct FieldInfo	*field	[MAXFIELDS+1];
X};
X
X
Xstruct FieldInfo
X{
X	char	name	[30];				/* field name */
X	char	label	[50];				/* field label */
X	int	row;					/* start position */
X	int	col;
X	int	length;
X	int	min_input;
X	char	mask	[100];
X	char	range	[1025];
X	char	type;
X	char	adjust;
X	int	mustenter;
X	char	prompt	[100];
X	char	terminator[3];				/* field terminators */
X	int	noinput;
X};
SHAR_EOF
chmod 0644 menu.h || echo "restore of menu.h fails"
echo "x - extracting terminal.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > terminal.h &&
X#ifndef LINT
Xstatic char ID_terminal[] = "@(#)terminal.h	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/* Mover Keys */
Xextern int	KeyReturn;
Xextern int	KeyDown;
Xextern int	KeyUp;
Xextern int	KeyTab;
Xextern int	KeyBTab;
X
X/* Edit Keys */
Xextern int	KeyBeg;
Xextern int	KeyEnd;
Xextern int	KeyRight;
Xextern int	KeyLeft;
Xextern int	KeyBackspace;
Xextern int	KeyEOL;
Xextern int	KeyDL;
Xextern int	KeyDC;
Xextern int	KeyIC;
X
X/* Other Keys */
Xextern int	KeyHelp;
Xextern int	KeyRedraw;
Xextern int	KeyCancel;
Xextern int	KeySave;
Xextern int	KeyPrint;
Xextern int	KeyAccept;
X
X
X/* Menu Specific Keys */
Xextern int	KeyMainMenu;
Xextern int	KeyPrevMenu;
Xextern int	KeyExitMenu;
Xextern int	KeyGname;
Xextern int	KeyPopGname;
SHAR_EOF
chmod 0444 terminal.h || echo "restore of terminal.h fails"
echo "x - extracting LexDeSrn.l (Text)"
sed 's/^X//' << 'SHAR_EOF' > LexDeSrn.l &&
X%{
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X%}
X
X%{
X#include 	"y.tab.h"
X#include	"menu.h"
X
X#undef	YYLMAX
X#define	YYLMAX	MAXLEN
X
Xchar	*malloc();
X%}
X%%
X%{
X/*
X**	Operators:
X**	" \ [ ] ^ - ? . * + | ( ) $ / { } % < >
X**	-	match a range
X**	^	match all except or match begining of line if outside []
X**	.	match any character except \n
X**	?	optional  ab?c matches ac or abc
X**	|	alternation  ab|cd matches either ab or cd
X**	$	match end of line
X**	/	trailing context  ab/cd matches ab only if followed by cd
X**	<>	start conditions
X**	{}	repetitions a{1,5}  or definition expansion {abc}
X**	%	separator for source segments
X**
X**	object		match one occurence of object
X**	object*		matches zero or more occurrences of object
X**	object+		matches one or more occurrences of object
X**	object{m,n}	match m through n occurrences of object
X*/
X%}
X
X%{ /* Screen Stuff
X%}
X"window_rows"		return (SCREEN_ROWS);
X"window_title"		return (SCREEN_TITLE);
X"window_cols"		return (SCREEN_COLS);
X"window_border"		return (SCREEN_BORDER);
X"window_pos"		return (SCREEN_POS);
X"helpfile"		return (SCREEN_HELP);
X"exit_last_field"	return (EXIT_LAST_FIELD);
X
X%{ /* Field Stuff
X%}
X"field_name"		return(FIELD_NAME); 
X"field_label" 		return(FIELD_LABEL); 
X"field_row"		return (FIELD_ROW);
X"field_col"		return (FIELD_COL);
X"field_mask"		return (FIELD_MASK);
X"field_range"		return (FIELD_RANGE);
X"field_length"		return (FIELD_LENGTH);
X"field_min"		return (FIELD_MIN);
X"field_type"		return (FIELD_TYPE);
X"field_edits"		return (FIELD_TYPE);
X"field_adjust"		return (FIELD_ADJUST);
X"field_mustenter"	return (FIELD_MUSTENTER);
X"field_prompt"		return (FIELD_PROMPT);
X"field_terminator"	return (FIELD_TERMINATOR);
X"field_defaults"	return (FIELD_DEFAULTS);
X"field_noinput"		return (FIELD_NOINPUT);
X
X"ENDSCREEN"		return(0);
X
X
X%{ /* Comment line */
X%}
X###			{ while (input() != '\n'); }
X
X[0-9]+			{ 
X				yylval.number = atoi (yytext);
X				return (NUMBER); 
X			}
X
X%{ /* Alphanumeric string with a leading $ and alphabetic character. */ 
X%}
X[$][A-Za-z][A-Za-z0-9_]* {
X                        	yylval.string = malloc(strlen(yytext)+1);
X                        	strcpy(yylval.string,yytext);
X				return (EVAR); 
X			}
X
X%{ /* Alphanumeric string with a leading alphabetic character. */ 
X%}
X[A-Za-z][A-Za-z0-9_]*	{ 
X                        	yylval.string = malloc(strlen(yytext)+1);
X                        	strcpy(yylval.string,yytext);
X				return (STRING); 
X			}
X
X%{/* Quoted string with a possible " in the string.  ex. "abc\"def" */
X%}
X\"[^"]*			{
X				if (yytext[yyleng-1] == '\\')
X				{
X					yymore ();
X				}
X				else
X				{
X					int	i,j;
X					/*
X					** need to validate that it is a quote
X					** a core dump will occur if not.
X					*/
X					input ();	/* get last " */
X                        		yylval.string=malloc(strlen(yytext)+1);
X					for (j=0,i=1; i < strlen(yytext); i++)
X					{
X						if (yytext[i] == '\\' && 
X						    yytext[i+1] == '"')
X							continue;
X						yylval.string[j++] = yytext[i];
X					}
X					yylval.string[j] = '\0';
X					return (QUOTE_STRING);
X				}
X			}
X
X","             return (COMMA);
X"="		return (EQUAL);
X%{/* Ignore blank, tab, newline */
X%}
X[ \t\n]		;
X%%
SHAR_EOF
chmod 0644 LexDeSrn.l || echo "restore of LexDeSrn.l fails"
echo "x - extracting menu.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > menu.hlp &&
XTABLE_OF_CONTENTS
Xmenu.hlp	menu		Menus      - Help using menus.
Xmenu.hlp	popmenu		Pop-menus  - Help using popmenus.
Xmenu.hlp	GETINPUT	Input      - Editing commands.
Xmenu.hlp	help		Help       - Using help.
XTABLE_OF_CONTENTS
X
X
Xmenu
X.TITLE Menu Help
X
X  \RMENU COMMANDS:\N
X          M       \D-  Go directly to main menu.\N
X          P       \D-  Return to previous menu.\N
X          G or ^g \D-  Go directly to a specific menu.\N
X          H or ?  \D-  This help screen.\N
X          ^r      \D-  Redraw the screen.\N
X          E       \D-  Exit.\N
X          !       \D-  Enter a unix command.\N
X
X  \RSELECTING OPTIONS:\N
X          -  Use "up arrow key", "^k", "down arrow key", "^j" or
X             "tab key" to place bar on option and press "return".    
X
X                  or
X
X          -  Enter option number and press "return".
X
Xmenu
X
X
Xpopmenu
X.TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    Use "up arrow key", "^k", "down arrow key", "^j", 
X    to place bar on option and press "return".
X
X    or
X
X    Enter the first character of the option you
X    wish to select and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
Xpopmenu
X
X
XGETINPUT
X.TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X        KEY_DOWN  (^j)      Traverse forwards through the fields.
X        KEY_UP  (^k)        Traverse backwards through the fields.
X        KEY_TAB  (^i)       Fast forward through the fields.
X        KEY_BTAB            Fast reverse through the fields.
XField Editing Keys:
X        KEY_BEG  (^b)       Place cursor at beginning of field.
X        KEY_END  (^e)       Place cursor at end of input in field.
X        KEY_RIGHT  (^l)     Forward space within the field.
X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
X        KEY_EOL  (^d)       Delete from cursor to end of field.
X        KEY_DL  (^c)        Clear field and home cursor.
X        KEY_DC  (^x)        Delete a character.
X        KEY_IC  (^t)        Toggle between type-over and insert mode.
XOther Keys:
X        KEY_HELP  (?)       Display help screen.
X        KEY_REFRESH  (^r)   Redraw the screen.
X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
X        KEY_SAVE  (^f)      Save screen to a file.
X        KEY_PRINT  (^p)     Print screen to lp.
XGETINPUT
X
X
Xhelp
X.TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
X        KEY_TOC  (^t)       Display help table of contents.
Xhelp
SHAR_EOF
chmod 0644 menu.hlp || echo "restore of menu.hlp fails"
echo "x - extracting runrealid.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > runrealid.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)runrealid.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<stdio.h>
X
Xmain ( argc, argv )
X	int	argc;
X	char	*argv[];
X{
X	register int	uid, euid, gid, egid ;
X
X	/* who am i */
X	uid = getuid() ;
X	euid = geteuid() ;
X	gid = getgid() ;
X	egid = getegid() ;
X
X	/* reset back to the read id */
X	setuid( uid ) ;
X	setgid( gid ) ;
X
X	system( argv[1] ) ;
X
X	/* reset back to the fake id */
X	setuid( euid ) ;
X	setgid( egid ) ;
X}
X/* Sam S. Lok  11/89 */
SHAR_EOF
chmod 0444 runrealid.c || echo "restore of runrealid.c fails"
echo "x - extracting ParseDeSrn.y (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseDeSrn.y &&
X%{
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X%}
X
X%{
X#include	<curses.h>
X#include	"GetInput.h"
X#include	"menu.h"
X
X#define	FLD	yyscreen->field[fieldcount-1]
X
X#ifdef	_yydebug
Xextern int		yydebug;
X#endif
Xextern int		debug;
Xstruct ScreenInfo	*yyscreen;
Xint			fieldcount;
Xchar			eott[50];		/* error on this token */
Xchar			*malloc();
X%}
X%{
X/*
X**	The %union declares yylval and the Yacc value stack as a C language
X**	union of types specified in the body.
X**
X**	The %type assigns member declared in the %union to non-terminals.
X**	The %token <..> assigns member declared in the %union to terminals.
X*/
X%}
X%union{
X	int	number;
X	char	*string;
X}
X
X%token	<number> NUMBER
X%token	<string> STRING
X%token	<string> QUOTE_STRING
X%token	<string> EVAR
X%token 	COMMA EQUAL
X%token 	SCREEN_TITLE SCREEN_ROWS SCREEN_COLS SCREEN_BORDER SCREEN_POS
X%token 	SCREEN_HELP EXIT_LAST_FIELD
X%token 	FIELD_NAME FIELD_LABEL FIELD_ROW FIELD_COL FIELD_MASK FIELD_RANGE
X%token	FIELD_LENGTH FIELD_MIN FIELD_TYPE FIELD_ADJUST FIELD_MUSTENTER 
X%token	FIELD_TERMINATOR FIELD_PROMPT FIELD_DEFAULTS FIELD_NOINPUT
X
X%%
X
X
Xscreen		: valid_field
X		| screen valid_field
X		| screen COMMA valid_field
X		;
X
Xvalid_field	: screen_pos 
X		{
X			strcpy (eott, "window_pos");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_pos");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_rows 
X		{
X			strcpy (eott, "window_rows");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_rows");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_cols 
X		{
X			strcpy (eott, "window_cols");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_cols");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_border
X		{
X			strcpy (eott, "window_border");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_border");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_title
X		{
X			strcpy (eott, "window_title");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_title");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_help
X		{
X			strcpy (eott, "helpfile");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> helpfile");
X				fflush (stderr);
X			}
X		}
X		;
X		| exit_last_field
X		{
X			strcpy (eott, "exit_last_field");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> exit_last_field");
X				fflush (stderr);
X			}
X		}
X		;
X
X		| field_name 
X		{
X			strcpy (eott, "field_name");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_name");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_label 
X		{
X			strcpy (eott, "field_label");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_label");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_row 
X		{
X			strcpy (eott, "field_row");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_row");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_col 
X		{
X			strcpy (eott, "field_col");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_col");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_mask
X		{
X			strcpy (eott, "field_mask");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_mask");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_range 
X		{
X			strcpy (eott, "field_range");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_range");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_length 
X		{
X			strcpy (eott, "field_length");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_length");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_min 
X		{
X			strcpy (eott, "field_min");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_min");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_type
X		{
X			strcpy (eott, "field_edits");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_edits");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_adjust 
X		{
X			strcpy (eott, "field_adjust");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_adjust");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_mustenter 
X		{
X			strcpy (eott, "field_mustenter");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_mustenter");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_prompt 
X		{
X			strcpy (eott, "field_prompt");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_prompt");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_terminator
X		{
X			strcpy (eott, "field_terminator");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_terminator");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_defaults
X		{
X			strcpy (eott, "field_defaults");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_defaults");
X				fflush (stderr);
X			}
X		}
X		;
X
X		| field_noinput 
X		{
X			strcpy (eott, "field_noinput");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_noinput");
X				fflush (stderr);
X			}
X		}
X		;
X
X
Xscreen_title	: SCREEN_TITLE EQUAL STRING
X		{
X			strcpy (yyscreen->title, $3);
X		}
X		| SCREEN_TITLE EQUAL EVAR
X		{
X			strcpy (yyscreen->title, $3);
X			/*
X			strcpy (yyscreen->title, (char *)getval (&$3,'1'));
X			*/
X		}
X		| SCREEN_TITLE EQUAL QUOTE_STRING
X		{
X			strcpy (yyscreen->title, $3);
X			/*
X			strcpy (yyscreen->title, (char *)getval (&$3, '1'));
X			*/
X		}
X		;
X
Xscreen_help	: SCREEN_HELP EQUAL STRING
X		{
X			strcpy (yyscreen->helpfile, $3);
X		}
X		| SCREEN_HELP EQUAL QUOTE_STRING
X		{
X			strcpy (yyscreen->helpfile, $3);
X		}
X		;
X
Xscreen_pos	: SCREEN_POS EQUAL NUMBER NUMBER
X		{
X			yyscreen->toprow = $3;
X			yyscreen->leftcol = $4;
X		}
X		| SCREEN_POS EQUAL EVAR EVAR
X		{
X			strcpy (yyscreen->toprowvar, $3);
X			strcpy (yyscreen->leftcolvar, $4);
X			/*
X			yyscreen->toprow = atoi ((char *)getval (&$3, '1'));
X			yyscreen->leftcol = atoi ((char *)getval (&$4, '1'));
X			*/
X		}
X		| SCREEN_POS EQUAL NUMBER EVAR
X		{
X			yyscreen->toprow = $3;
X			strcpy (yyscreen->leftcolvar, $4);
X		}
X		| SCREEN_POS EQUAL EVAR NUMBER
X		{
X			/*
X			yyscreen->toprow = atoi ((char *)getval (&$3, '1'));
X			*/
X			strcpy (yyscreen->toprowvar, $3);
X			yyscreen->leftcol = $4;
X		}
X		;
X
Xscreen_rows	: SCREEN_ROWS EQUAL NUMBER
SHAR_EOF
echo "End of part 6"
echo "File ParseDeSrn.y is continued in part 7"
echo "7" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 7 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ParseDeSrn.y continued
#
CurArch=7
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 ParseDeSrn.y"
sed 's/^X//' << 'SHAR_EOF' >> ParseDeSrn.y
X		{
X			yyscreen->rows = $3;
X		}
X		;
Xscreen_cols	: SCREEN_COLS EQUAL NUMBER
X		{
X			yyscreen->cols = $3;
X		}
X		;
Xscreen_border	: SCREEN_BORDER EQUAL STRING
X		{
X			/* get border type for active menu */
X			if (strcmp ($3, "DumbLine") == 0)
X				yyscreen->boxtype = DumbLine;
X			else	if (strcmp ($3, "StandoutLine") == 0)
X					yyscreen->boxtype = StandoutLine;
X			else	if (strcmp ($3, "SingleLine") == 0 ||
X		    		strcmp ($3, "DrawLine") == 0)
X					yyscreen->boxtype = SingleLine;
X			else	if (strcmp ($3, "MosaicLine") == 0)
X					yyscreen->boxtype = MosaicLine;
X			else	if (strcmp ($3, "DiamondLine") == 0)
X					yyscreen->boxtype = DiamondLine;
X			else	if (strcmp ($3, "DotLine") == 0)
X					yyscreen->boxtype = DotLine;
X			else	if (strcmp ($3, "PlusLine") == 0)
X					yyscreen->boxtype = PlusLine;
X		}
X		|SCREEN_BORDER EQUAL STRING STRING
X		{
X			/* get border type for active menu */
X			if (strcmp ($3, "DumbLine") == 0)
X				yyscreen->boxtype = DumbLine;
X			else	if (strcmp ($3, "StandoutLine") == 0)
X					yyscreen->boxtype = StandoutLine;
X			else	if (strcmp ($3, "SingleLine") == 0 ||
X		    		strcmp ($3, "DrawLine") == 0)
X					yyscreen->boxtype = SingleLine;
X			else	if (strcmp ($3, "MosaicLine") == 0)
X					yyscreen->boxtype = MosaicLine;
X			else	if (strcmp ($3, "DiamondLine") == 0)
X					yyscreen->boxtype = DiamondLine;
X			else	if (strcmp ($3, "DotLine") == 0)
X					yyscreen->boxtype = DotLine;
X			else	if (strcmp ($3, "PlusLine") == 0)
X					yyscreen->boxtype = PlusLine;
X
X			/* border type for inactive menu - dim (high 8 bits) */
X			if (strcmp ($4, "DumbLine") == 0)
X				yyscreen->boxtype = yyscreen->boxtype | 
X						    (DumbLine << 9);
X			else	if (strcmp ($4, "StandoutLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (StandoutLine << 9);
X			else	if (strcmp ($4, "SingleLine") == 0 ||
X		    		strcmp ($4, "DrawLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (SingleLine << 9);
X			else	if (strcmp ($4, "MosaicLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (MosaicLine << 9);
X			else	if (strcmp ($4, "DiamondLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (DiamondLine << 9);
X			else	if (strcmp ($4, "DotLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (DotLine << 9);
X			else	if (strcmp ($4, "PlusLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (PlusLine << 9);
X		}
X		;
Xexit_last_field	: EXIT_LAST_FIELD
X		{
X			yyscreen->exitlastfield = TRUE;
X		}
X		;
X
X
Xfield_name	: FIELD_NAME EQUAL EVAR
X		{
X			/*
X			**  The field_name token signifes a new field
X			**  we need to malloc the field structure.
X			*/
X   			if ((++fieldcount) > MAXFIELDS)
X   			{
X      				BEEP;
X      				mvprintw (ErrRow-2, 0, 
X				  "Exceeded maximum screen fields of %d.",
X				  MAXFIELDS);
X      				shutdown ();
X   			}
X			FLD = (struct FieldInfo *)malloc (sizeof (struct FieldInfo));
X			yyscreen->field[fieldcount] = (struct FieldInfo *)NULL;
X			strcpy (FLD->name, $3+1);
X
X			/* Set default field values */
X			strcpy (FLD->label, "");
X			FLD->min_input = 0;
X			strcpy (FLD->mask, "");
X			strcpy (FLD->range, "");
X			FLD->type = UPPER_AN;
X			FLD->adjust = NOFILL;
X			FLD->mustenter = FALSE;
X			strcpy (FLD->prompt, "");
X			strcpy (FLD->terminator, "[]");
X			FLD->noinput = FALSE;
X		}
X		;
X
Xfield_label	: FIELD_LABEL EQUAL STRING
X		{
X			strcpy (FLD->label, $3);
X		}
X		| FIELD_LABEL EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->label, $3);
X		}
X		;
X
Xfield_row	: FIELD_ROW EQUAL NUMBER
X		{
X			FLD->row = $3;
X		}
X		;
Xfield_col	: FIELD_COL EQUAL NUMBER
X		{
X			FLD->col = $3;
X		}
X		;
X
Xfield_mask	: FIELD_MASK EQUAL STRING
X		{
X			strcpy (FLD->mask, $3);
X		}
X		| FIELD_MASK EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->mask, $3);
X		}
X		;
X
Xfield_range	: FIELD_RANGE EQUAL STRING
X		{
X			strcpy (FLD->range, $3);
X		}
X		| FIELD_RANGE EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->range, $3);
X		}
X		;
X
Xfield_length	: FIELD_LENGTH EQUAL NUMBER
X		{
X			FLD->length = $3;
X		}
X		;
Xfield_min	: FIELD_MIN EQUAL NUMBER
X		{
X			FLD->min_input = $3;
X		}
X		;
Xfield_type	: FIELD_TYPE EQUAL STRING
X		{
X			if (strcmp ($3, "ALPHANUM") == 0)
X				FLD->type = ALPHANUM;
X			else if (strcmp ($3, "ALPHA") == 0)
X				FLD->type = ALPHA;
X			else if (strcmp ($3, "NUMERIC") == 0)
X				FLD->type = NUMERIC;
X			else if (strcmp ($3, "SET") == 0)
X				FLD->type = SET;
X			else if (strcmp ($3, "UPPER") == 0)
X				FLD->type = UPPER;
X			else if (strcmp ($3, "UPPER_AN") == 0)
X				FLD->type = UPPER_AN;
X			else if (strcmp ($3, "HEX") == 0)
X				FLD->type = HEX;
X			else if (strcmp ($3, "STATE") == 0)
X				FLD->type = STATE;
X			else if (strcmp ($3, "ZIP") == 0)
X				FLD->type = ZIP;
X			else if (strcmp ($3, "DATE") == 0)
X				FLD->type = DATE;
X			else if (strcmp ($3, "TIME") == 0)
X				FLD->type = TIME;
X			else if (strcmp ($3, "MENU") == 0)
X				FLD->type = MENU;
X			else if (strcmp ($3, "PROTECT") == 0)
X				FLD->type = PROTECT;
X			else yyerror ("Invalid field_edits");
X		}
X		;
Xfield_adjust	: FIELD_ADJUST EQUAL STRING
X		{
X			if (strcmp ($3, "NOFILL") == 0)
X				FLD->adjust = NOFILL;
X			else if (strcmp ($3, "RTADJ_ZFILL") == 0)
X				FLD->adjust = RTADJ_ZFILL;
X			else if (strcmp ($3, "RTADJ_BFILL") == 0)
X				FLD->adjust = RTADJ_BFILL;
X			else if (strcmp ($3, "LFADJ_ZFILL") == 0)
X				FLD->adjust = LFADJ_ZFILL;
X			else if (strcmp ($3, "LFADJ_BFILL") == 0)
X				FLD->adjust = LFADJ_BFILL;
X		}
X		| FIELD_ADJUST EQUAL QUOTE_STRING
X		{
X			if (strcmp ($3, "NOFILL") == 0)
X				FLD->adjust = NOFILL;
X			else if (strcmp ($3, "RTADJ_ZFILL") == 0)
X				FLD->adjust = RTADJ_ZFILL;
X			else if (strcmp ($3, "RTADJ_BFILL") == 0)
X				FLD->adjust = RTADJ_BFILL;
X			else if (strcmp ($3, "LFADJ_ZFILL") == 0)
X				FLD->adjust = LFADJ_ZFILL;
X			else if (strcmp ($3, "LFADJ_BFILL") == 0)
X				FLD->adjust = LFADJ_BFILL;
X		}
X		;
X
Xfield_mustenter	: FIELD_MUSTENTER
X		{
X			FLD->mustenter = TRUE;
X		}
X		;
X
Xfield_prompt	: FIELD_PROMPT EQUAL STRING
X		{
X			strcpy (FLD->prompt, $3);
X		}
X		| FIELD_PROMPT EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->prompt, $3);
X		}
X		;
X
Xfield_terminator : FIELD_TERMINATOR EQUAL QUOTE_STRING
X		{
X			if (strlen ($3) != 2)
X				yyerror ("Bad field_terminator.");
X			strcpy (FLD->terminator, $3);
X		}
X		;
X
Xfield_defaults	: FIELD_DEFAULTS EQUAL QUOTE_STRING
X		{
X			yyscreen->fielddefaults = (char *)malloc (strlen($3)+5);
X			strcpy (yyscreen->fielddefaults, $3);
X		}
X		;
X
Xfield_noinput	: FIELD_NOINPUT
X		{
X			FLD->noinput = TRUE;
X		}
X		;
X
X
X
X%%
X
X/*  FUNCTION:	ParseDefineScreen()
X**		This function parses .DEFINE_SCREEN
X**  ARGS:	keyword		the keyword found
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X
X#define	SRN	menu->srn[screencount-1]
X
Xextern FILE	*yyin;
Xextern FILE	*yyout;
Xextern	int	swin, ewin, longest;
X
X	char	ScreenName[50];				/* for yyerror */
X
X
XParseDefineScreen (keyword, menufile, menu, gnames, gfiles, gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*fgets(), line[BUFSIZE];
X	static int	screencount;
X	int		i = 0;
X	int		j;
X	char		*ws;
X
X
X	/* check if this is the first screen for this menu */
X	if (menu->srn[0] == (struct ScreenInfo *)NULL)
X		screencount = 0;
X
X   	if ((++screencount) > MAXSCREENS)
X   	{
X      		BEEP;
X      		mvprintw (ErrRow, 0, 
X			"Exceeded maximum allowable .DEFINE_SCREEN.");
X      		shutdown ();
X   	}
X
X	SRN = (struct ScreenInfo *)malloc (sizeof (struct ScreenInfo));
X   	if (SRN == NULL)
X   	{
X      		BEEP;
X      		mvprintw (ErrRow, 0, 
X			"Unable to allocate memory for .DEFINE_SCREEN.");
X      		shutdown ();
X   	}
X	/* terminate the screens list */
X	menu->srn[screencount] = (struct ScreenInfo *)NULL;
X	SRN->field[0] = (struct FieldInfo *)NULL;	/* no fields yet */
X
X
X	/* get screen name */
X	fgets (line, BUFSIZE, menufile);
X	sscanf (line, "%s", SRN->name);			/* screen name */
X	strcpy (ScreenName, SRN->name);			/* for yyerror */
X
X	yyin = menufile;
X	yyscreen = SRN;
X	fieldcount = 0;
X
X	/*
X	**  Set default screen values.
X	*/
X	strcpy (SRN->title, "");
X	SRN->toprow = AUTO;
X	SRN->leftcol = AUTO;
X	strcpy (SRN->toprowvar, "");
X	strcpy (SRN->leftcolvar, "");
X	SRN->boxtype = StandoutLine;
X	SRN->fielddefaults = (char *)NULL;
X	strcpy (SRN->helpfile, "menu.hlp");
X	SRN->exitlastfield = FALSE;
X
X#ifdef	_yydebug
X	if (debug)
X		yydebug = 1;
X#endif
X
X	yyparse ();
X
X   	return (0);
X}
X
X
Xyyerror (s)
X	char	*s;
X{
X	mvprintw (ErrRow-5,0, "Unable to process .DEFINE_SCREEN  %s", 
X			ScreenName);
X	mvprintw (ErrRow-4,0, "Field Number %d", fieldcount);
X	mvprintw (ErrRow-3,0, "%s", s);
X	mvprintw (ErrRow-2,0, "The error occured on token = \"%s\"", eott);
X	mvprintw (ErrRow-1,0, "Look ahead token number %d  <tokens.h>", yychar);
X	shutdown ();
X}
SHAR_EOF
echo "File ParseDeSrn.y is complete"
chmod 0644 ParseDeSrn.y || echo "restore of ParseDeSrn.y fails"
echo "x - extracting utilities.d/libgeti.d/AdjField.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/AdjField.c &&
Xstatic char Sccsid[] = "@(#)AdjField.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include	<curses.h>
X#include	"GetInput.h"
X#include	<ctype.h>
X
XAdjField(win, rowStart, colStart, fldAttrib, fldAdjust, colEnd, charKeyed)
X	WINDOW		*win ;		/* Window	    		    */
X	int		rowStart ;
X	int		colStart ;
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		fldAdjust ;	/* adjust/fill field 		    */
X	int		colEnd ;	/* column where field ends	    */
X	char		charKeyed[] ;	/* characters keyed		    */
X{
X	int		col ;		/* working column field */
X	int		row ;		/* working row field */
X	int		colMove ;	/* working column field for adjusting
X				   		routines */
X	int		ch ;		/* contains character keyed or being
X				   		moved */
X
X	char		*wrkKeyed ;	/* working pointer for charKeyed */
X	char		fillChar ;
X
X
X	getyx (win, row, col) ;
X
X	if (fldAdjust == RTADJ_BFILL || fldAdjust == LFADJ_BFILL)
X		fillChar = ' ' ;
X	else if (fldAdjust == RTADJ_ZFILL  ||  fldAdjust == LFADJ_ZFILL)
X		fillChar = '0' ;
X
X	if (fldAdjust == RTADJ_BFILL || fldAdjust == RTADJ_ZFILL) {
X
X		col-- ;
X
X		wrkKeyed = charKeyed + (col - colStart) ;
X
X		colMove = colEnd - 1 ;
X
X		while (col >= colStart) {
X
X			while ( *wrkKeyed != 'Y') {
X				wrkKeyed-- ;
X				col-- ;
X			}
X
X			if (col < colStart)
X				break ;
X
X			ch = mvwinch(win, rowStart, col--) & A_CHARTEXT ;
X			*wrkKeyed-- = 'N' ;
X
X			while ( colMove > colStart  &&
X					charKeyed [colMove - colStart] != 'N')
X				colMove-- ;
X
X			charKeyed [colMove - colStart] = 'Y' ;
X
X			wattrset (win, fldAttrib) ;
X			mvwaddch (win, rowStart, colMove--, ch) ;
X			wattrset (win, 0) ;
X		}
X
X		wattrset (win, fldAttrib) ;
X
X		while (colMove >= colStart) {
X
X			if ( charKeyed [colMove - colStart] != 'N')
X				colMove-- ;
X			else {
X				charKeyed [colMove - colStart] = 'Y' ;
X				mvwaddch(win, rowStart, colMove--, fillChar) ;
X			}
X		}
X
X		wattrset (win, 0) ;
X		wmove (win, rowStart, colEnd) ;
X
X	} else if  (fldAdjust == LFADJ_BFILL || fldAdjust == LFADJ_ZFILL) {
X
X		if (col < colStart)
X			col = colStart;
X
X		wattrset (win, fldAttrib) ;
X
X		while (col < colEnd) {
X
X			if ( charKeyed [col - colStart] != 'N')
X				col++ ;
X			else {
X				charKeyed [col - colStart] = 'Y' ;
X				mvwaddch (win, rowStart, col++, fillChar) ;
X			}
X		}
X
X		wattrset (win, 0) ;
X		wmove (win, rowStart, colEnd) ;
X	}
X
X	wrefresh (win) ;
X
X	return(0) ;
X
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/AdjField.c || echo "restore of utilities.d/libgeti.d/AdjField.c fails"
echo "x - extracting utilities.d/libgeti.d/BuildMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/BuildMenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)BuildMenu.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X
XBuildMenu (menu, fldRange)
X	char	menu[][80];
X	char	*fldRange;
X{
X	int	eidx = 0;				/* element index */
X	char	*rptr;					/* range pointer */
X	char	*eptr;					/* element pointer */
X
X	rptr = fldRange;
X
X	while (*rptr != '\0')
X	{
X		/* get range element eidx */
X		eptr = menu[eidx];
X		while (*rptr != ','  &&  *rptr != '\0')
X			*eptr++ = *rptr++;
X		*eptr = '\0';
X
X		/* skip junk */
X		while (*rptr == ','  || *rptr == ' '  ||  *rptr == '\t')
X			*rptr++;
X		eidx++;
X	}
X	strcpy (menu[eidx], "");
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/BuildMenu.c || echo "restore of utilities.d/libgeti.d/BuildMenu.c fails"
echo "x - extracting utilities.d/libgeti.d/DateFun.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/DateFun.c &&
Xstatic char Sccsid[] = "@(#)DateFun.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X/*
X *      is_leap - returns 1 if year is a leap year, 0 if not
X */
Xint is_leap(y)
Xint y;
X{
X	return(y % 4 == 0 && y % 100 != 0 || y % 400 == 0);
X}
X
X/* 
X**
X**	maxdays, returns maximum number of days for 'year' 
X**
X*/
Xint maxdays(y)
Xregister int y;
X{
X	return(is_leap(y) ? 366 : 365);
X}
X
Xstatic  int     day_tab[2][13] = {
X	{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
X	{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
X};                                  
X
X
X/*
X *      julian - converts year month and day to julian date and returns it
X */
Xint julian(year, month, day)
Xint year, month, day;
X{
X	int i, leap;
X
X	leap = is_leap(year);
X	for (i = 1; i < month; i++)
X		day += day_tab[leap][i];
X	return(day);
X}
X
X
X
X/*
X**
X**      week_day - returns the day of the week given the Year, 
X**			Month and Day.  Year must be >= 1973.  
X**			If not, -1 is returned.
X**                      day of the week:  
X**				Sunday = 0,  Monday = 1,  ...,  Saturday = 6.
X*/
Xint week_day(year,month,date) int year,month,date;
X{
X	if(year<73)
X		return(-1); 
X	else 
X		return((((year-73)*365)+julian(year,month,date)+((year-73)/4))%7);
X}
X
X
X/*
X *      month_day - Converts julian date to month and day. Month and day must be passed as addresses of ints.
X */
Xvoid
Xmonth_day(year, yearday, pmonth, pday)
Xint year, yearday, *pmonth, *pday;
X{
X	int i, leap;
X
X	leap = is_leap(year);
X	for (i = 1; yearday > day_tab[leap][i]; i++)  {
X		yearday -= day_tab[leap][i];
X	}
X	if(i > 12)
X		i = 1;
X
X	if(yearday <= 0)  {     /* special kludge for julian day 0 = Dec. 31st */
X		*pmonth = 12;
X		*pday = 31 + yearday;
X	}  else {
X		*pmonth = i;
X		*pday = yearday;
X	}
X}
X
X
X/* back up (if necessary) month and date to nearest sunday */
X/* return julian date of new date as well */
X
X/*
X *      weekstart - returns julian data of Sunday start date of given YY/MM/DD.
X */
Xint weekstart(year, month, date)
Xregister int year, *month, *date;
X{
X	int mp, dp, i, t;
X
X	if ((i = week_day(year, *month, *date)) != 0)  {
X		t = julian(year, *month, *date);
X		month_day(year, t - i, &mp, &dp);
X		if(mp > *month)
X			year--;
X		*month = mp;
X		*date = dp;
X	}
X	return(julian(year, *month, *date));
X}
X
X
X/* verifies the integrity of a date, returns 1 if good, 0 if bad */
Xint valid_date(yr, mo, day)
Xint yr, mo, day;
X{
X	int days, leap;
X
X	leap = is_leap(yr);
X	if (mo > 0 && mo < 13) {
X		days = day_tab[leap][mo];
X		if (day > 0 && day <= days && yr > 0)
X			return(1);
X	}
X	return(0);
X}
X
X
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/DateFun.c || echo "restore of utilities.d/libgeti.d/DateFun.c fails"
echo "x - extracting utilities.d/libgeti.d/DisPrmpt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/DisPrmpt.c &&
Xstatic char Sccsid[] = "@(#)DisPrmpt.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include	<curses.h>
X#include	"GetInput.h"
X
XDisPrmpt(win, Fld, fldAttrib, fldMask, fldLength, fldCharType, fldAdjust, fldType, colStart, colEnd, fldStr, charKeyed)
X	WINDOW		*win ;		/* Window	    		    */
X	FldUnPointer	Fld ;		/* Pointer to union for field	    */
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		*fldMask ;	/* mask for character string 	    */
X	unsigned	fldLength ;	/* Maximum length of output 	    */
X	char		fldCharType ;	/* type of character 		    */
X	char		fldAdjust ;	/* Type of adjustment 		    */
X	char		fldType ;	/* type of field 		    */
X	int		colStart ;	/* column start of field */
X	int		colEnd ;	/* column end of field */
X	char		*fldStr ;	/* buffer that will contain output  */
X	char		*charKeyed ;	/* characters keyed  */
X{
X	char	*wrk, *fldWrk, *malloc() ;
X
X	int	ch ;
X	int	col ;
X	int	initFld ;
X	int	i, j ;
X
X	*fldStr = '\0' ;
X
X	/*
X	if (((fldType == HEX  ||  fldType == CHAR)  &&  *Fld->strVal == '\0') ||
X			(fldType == INT     &&  *Fld->intVal    == 0) ||
X			(fldType == SHORT   &&  *Fld->shortVal  == 0) ||
X			(fldType == LONG    &&  *Fld->longVal   == 0L) ||
X			(fldType == FLOAT   &&  *Fld->floatVal  == 0.0) ||
X			(fldType == DOUBLE  &&  *Fld->doubleVal == 0.0) ||
X			(fldType == MONEY   &&  *Fld->doubleVal == 0.0) ) {
X	*/
X	if (((fldType == HEX  ||  fldType == CHAR)  &&  *Fld->strVal == '\0')) {
X
X		initFld = FALSE ;
X		fldWrk = fldStr ;
X		while (fldLength--)
X			*fldWrk++ = ' ' ;
X		*fldWrk = '\0' ;
X	} else {
X
X		initFld = TRUE ;
X
X		fldWrk = malloc(fldLength + 1) ;
X
X		if (fldType == HEX  ||   fldType == CHAR)
X			strcpy (fldWrk, Fld->strVal) ;	
X		else if (fldType == INT)
X			sprintf (fldWrk, "%d", *Fld->intVal) ;
X		else if (fldType == SHORT)
X			sprintf (fldWrk, "%d", *Fld->shortVal) ;
X		else if (fldType == LONG)
X			sprintf (fldWrk, "%ld", *Fld->longVal) ;
X		else if (fldType == FLOAT)
X			sprintf (fldWrk, "%f", *Fld->floatVal) ;
X		else if (fldType == DOUBLE)
X			sprintf (fldWrk, "%g", *Fld->doubleVal) ;
X		else if (fldType == MONEY) {
X			sprintf (fldWrk, "%g", *Fld->doubleVal) ;
X			i = strlen(fldWrk) - 1 ;
X			wrk = fldWrk ;
X			while(*wrk != '.'   &&   *wrk != '\0')
X				wrk++ ;
X			if(*wrk == '\0')
X				strcat(fldWrk, ".00") ;
X			else {
X				wrk++ ;
X				j = 0 ;
X				while(*wrk++ != '\0')
X					j++ ;
X
X				if(j == 0)
X					strcat(fldWrk, "00") ;
X				else if(j == 1)
X					strcat(fldWrk, "0") ;
X			}
X		}
X
X		if (fldAdjust == NOFILL)
X			strcpy (fldStr, fldWrk) ;
X		else if (fldAdjust == LFADJ_BFILL  || fldAdjust == LFADJ_ZFILL){
X			strcpy (fldStr, fldWrk) ;
X
X			for (i = strlen(fldStr) ; i < fldLength ; i++)
X				fldStr[i] = (fldAdjust == LFADJ_ZFILL) ? '0' : ' ' ;
X			fldStr[fldLength] = '\0' ;
X		} else if (fldAdjust == RTADJ_BFILL  || fldAdjust == RTADJ_ZFILL) {
X
X			for (i = 0 ; i < fldLength - strlen(fldWrk) ; i++)
X				fldStr[i] = (fldAdjust == RTADJ_ZFILL) ? '0' : ' ' ;
X			fldStr[fldLength - strlen(fldWrk)] = '\0' ;
X			strcat (fldStr, fldWrk) ;
X		}
X
X		free (fldWrk) ;
X			
X	}
X	wattrset (win, fldAttrib) ;
X
X	col = colStart ;
X
X	do { 
X		if (fldMask == NULL) {
X			*charKeyed++ = (initFld) ? 'Y' : 'N' ;
X			waddch(win, *fldStr++) ;
X		} else if (fldCharType != DATE  &&  fldCharType != TIME) {
X			/*
X			if(*(fldMask + col - colStart)  ==  ' ')
X				*(fldMask + col - colStart)  =  fldCharType ;
X			*/
X			if(IsMask(fldCharType, *(fldMask + col - colStart))) {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			} else {
X				*charKeyed++ = (initFld) ? 'Y' : 'N' ;
X				waddch(win, *fldStr++) ;
X			}
X		} else {
X			if( (fldCharType == DATE  &&  
X				(ch = *(fldMask + col - colStart)) == 'M'  ||
X					ch == 'D'  ||  ch == 'Y') ||
X			    (fldCharType == TIME  &&  
X				(ch = *(fldMask + col - colStart)) == 'I'  ||
X					ch == 'H'  ||  ch == 'M'  ||  
X					ch == 'S'  ||  ch == 'T')) {
X				*charKeyed++ = (initFld) ? 'Y' : 'N' ;
X				waddch(win, *fldStr++) ;
X			} else {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			}
X		}
X		col++ ;
X	} while (*fldStr != '\0'  &&  col < colEnd) ;
X
X	while(col < colEnd) {
X		if (fldMask == NULL) {
X			*charKeyed++ = 'N' ;
X			waddch(win, ' ') ;
X		} else if (fldCharType != DATE  &&  fldCharType != TIME) {
X			if(*(fldMask + col - colStart)  ==  ' ')
X				*(fldMask + col - colStart)  =  fldCharType ;
X			if(IsMask(fldCharType, *(fldMask + col - colStart))) {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			} else {
X				*charKeyed++ = 'N' ;
X				waddch(win, ' ') ;
X			}
X		} else {
X			if( (fldCharType == DATE  &&  
X				(ch = *(fldMask + col - colStart)) == 'M'  ||
X					ch == 'D'  ||  ch == 'Y') ||
X			    (fldCharType == TIME  &&  
X				(ch = *(fldMask + col - colStart)) == 'I'  ||
X					ch == 'H'  ||  ch == 'M'  ||  
X					ch == 'S'  ||  ch == 'T')) {
X				*charKeyed++ = 'N' ;
X				waddch(win, ' ') ;
X			} else {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			}
X		}
X		col++ ;
X	}
X
X	wattrset (win, 0) ;
X
X	return(initFld) ;
X
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/DisPrmpt.c || echo "restore of utilities.d/libgeti.d/DisPrmpt.c fails"
echo "x - extracting utilities.d/libgeti.d/FindSet.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/FindSet.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)FindSet.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  FindSet()
X**		Determines if the value loaded into Fld is a member of the set.
X**  RETURNS:
X**		-1	not a element of the set
X**		eNum	otherwise returns the element number (base 0)
X*/
X
X#include	"GetInput.h"
X
X
XFindSet(Fld, fldRange, fldLength, fldType)
X	FldUnPointer	Fld ;
X	char		*fldRange ;
X	int		fldLength ;
X	char		fldType ;
X{
X	static char	*upper();
X	char		*a,
X			*b,
X			*fldCmp ;
X
X	char		*malloc() ;
X
X	int	eNum,				/* element number matched */
X		gotAmatch ;
X
X	gotAmatch = 0 ;
X
X	eNum = 0 ;
X
X	fldCmp = malloc(fldLength+1);
X
X	a = fldRange ;
X
X	while(*a != '\0') {
X
X		b = fldCmp ;
X
X		while(*a != ','  &&  *a != '\0')
X		/* load the next element into fldCmp */
X			*b++ = *a++ ;
X
X		*b = '\0' ;
X
X		switch(fldType) {
X			case CHAR:
X			case DATE:
X			case TIME:
X				if(strncmp(upper(fldCmp), upper(Fld->strVal), strlen(Fld->strVal)) == 0)
X					gotAmatch = 1 ;
X				break ;
X			case INT:
X				if(*Fld->intVal == atoi(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case SHORT:
X				if(*Fld->shortVal == atoi(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case LONG:
X				if(*Fld->longVal == atoi(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case FLOAT:
X				if(*Fld->floatVal == atof(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case DOUBLE:
X				if(*Fld->doubleVal == atof(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X		}
X
X		if(gotAmatch)
X			break ;
X
X		eNum++ ;
X
X		while(*a == ','  ||  *a == ' '  ||  *a == '\t')
X			a++ ;
X	}
X
X	free(fldCmp) ;
X
X	if(gotAmatch)
X		return(eNum) ;
X	else
X		return (-1) ;
X}
X
X
Xstatic char *upper (s)
X
X	char		*s;
X{
X	register int	i;
X	char		*ws;
X
X   ws = s;
X   while (*s)
X   {
X      if (*s >= 'a'  &&  *s <= 'z')
X         *s = (*s + 'A' - 'a');
X      s++;
X   }
X   return (ws);
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/FindSet.c || echo "restore of utilities.d/libgeti.d/FindSet.c fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.c &&
Xstatic char Sccsid[] = "@(#)GetInput.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include	"keys.h"
X#include 	"GetInput.h"
X
X#define	MAXITEMS	100
X#define	CREATEMENU	-2
X
Xint	insertmode = FALSE;
X
X
XGetInput (win, rowStart, colStart, Fld, fldAttrib, fldMask, fldRange, fldLength,
X	fldMin, fldCharType, fldAdjust, fldType, keyStream, mustEnter, 
X	fldErrRow, fldDispRow, helpMsg, helpFile, helpTag)
X
X	WINDOW      	*win ;      	/* Window                */
X	int   		rowStart ;
X	int   		colStart ;
X	FldUnPointer	Fld ;    	/* Pointer to union for field     */
X	int   		fldAttrib ; 	/* Curses attribute         */
X	char  		*fldMask ;  	/* mask for character string      */
X	char  		*fldRange ; 	/* range of valid values for output */
X	int   		fldLength; 	/* Maximum length of output       */
X	int   		fldMin; 	/* Minimum length of output       */
X	char  		fldCharType;	/* type of character           */
X	char  		fldAdjust ; 	/* adjust/fill field           */
X	char  		fldType ;   	/* type of field         */
X	int   		keyStream ; 	/* if TRUE then the function will
X                  			   exit when the last character is
X                  			   keyed           */
X	int   		mustEnter ; 	/* boolean   */
X	int   		fldErrRow ; 	/* where to display error message   */
X	int   		fldDispRow ;   	/* where to display help message    */
X	char  		*helpMsg ;  	/* help message             */
X	char  		helpFile[] ;   	/* help file name        */
X	char  		helpTag[] ; 	/* tag where help begins       */
X{
X   	int	colEnd ;    	/* column end of field */
X   	int   	row ;       	/* working row field */
X   	int   	col ;       	/* working column field */
X   	int   	colSave ;      	/* working column field */
X   	int   	colMove ;      	/* working col field for adjusting routines */
X   	int   	colBegInput;	/* column where input begins */
X   	int   	ch ;            /* contains character keyed or being moved */
X   	int   	notFinished ;   /* bool indicator that indicates when the user 
X					is finished with keying in data */
X   	int   	setNumb ;       /* number to be returned showing which 
X					selection the user chose */
X   	int   	controlKey ;    /* if not 0 then the user hit a control key */
X   	int   	bytesKeyed ;    /* how many bytes were keyed */
X   	int   	initFld ;       /* indicate if field was initialized going into 
X                              		this routine */
X   	char  	*fldStr ;       /* buffer that will contain output  */
X   	char  	*charKeyed ;    /* characters keyed by the user Y/N */
X				/*
X				**  charKeyd indicates how many characters
X				**  has been keyed in.  A "Y" in the position
X				**  indicates that the user has keyed a char
X				**  at that position, otherwise it will be "N"
X				**  or a "M" for a mask format character.
X				*/
X   	char  	*fldWrk ;       /* working field */
X   	int   	origAttr[80] ;  /* original field attributes */
X   	char  	*malloc() ;
X	int	i;
X	int	junk;		/* use for anything */
X	char	menu[MAXITEMS+2][80];	/* popmenu items */
X	int	menuid;
X
X
X
X
X
X	if (fldCharType == PROTECT)
X	{
X		/* X out the field */
X		for (i = 0; i < fldLength; i++)
X			Fld->strVal[i] = 'X';
X		Fld->strVal[i] = '\0';
X	}
X
X   	/*
X	** bug fix  -  pjc  08/26/86
X	** bytesKeyed = 0
X	*/
X   	setNumb = controlKey = bytesKeyed = 0;
X
X	/* find length of field from the values in fldRange */
X   	if (fldCharType == SET  ||  fldCharType == MENU)
X      		fldLength = GetSetLen(fldRange);
X
X   	/*
X   	** pjc - 11/88
X   	** This allows you to pass "" 
X   	*/
X	if (fldRange != NORANGE  &&  strcmp(fldRange, "") == 0)
X		fldRange = NORANGE;
X
X   	if (fldMask != NOMASK  &&  strcmp(fldMask, "") == 0)
X		fldMask = NOMASK;
X   	if (fldMask == NOMASK) 
X   	{
X      		colEnd    = colStart + fldLength ;
X      		fldStr    = malloc(fldLength + 1) ;
X      		charKeyed = malloc(fldLength + 1) ;
X   	} 
X   	else 
X   	{
X      		colEnd    = colStart + strlen(fldMask) ;
X      		fldStr    = malloc(strlen(fldMask) + 1) ;
X      		charKeyed = malloc(strlen(fldMask) + 1) ;
X   	}
X
X	/*
X	**	Save original terminal attributes.
X	*/
X   	for (col = colStart; col < colEnd; col++)
X      		origAttr[col - colStart] = mvwinch(win, rowStart, col) & 
X						A_ATTRIBUTES ;
X
X	CLEARROW (fldDispRow);
X   	/*
X	** bug fix     pjc  8/22/86
X	** test for NOMSG
X	** Display help message.
X	*/
X   	if (helpMsg != NOMSG) 
X   	{
X      		/* pjc 7/87 - clrtoeol for new message 
X      		*/
X      		/* pjc 11/88 - 
X      		**	change helpMsg to always display to standard screen.
X      		**	That way popup screens will work right.
X		**	Display message between col 1 to COLS-1 ... so that
X		**	it will work with a box border.
X      		*/
X
X      		mvwaddstr (stdscr,
X		((fldDispRow%100) == fldDispRow) ? fldDispRow : fldDispRow/100, 
X		((fldDispRow%100) == fldDispRow) ? 0 : fldDispRow%100, 
X			helpMsg) ;
X      		wnoutrefresh (stdscr);
X   	}
X
X	/*
X   	**	pjc 9/87
X   	**	Added new attributes
X   	**	If A_SAME then use the attributes that is showing
X   	**	on the screen in that position.
X	**	As you see it is determined from first column.
X   	*/
X   	if (fldAttrib == A_SAME)
X      		fldAttrib = origAttr[0];
X
X   	wmove(win, rowStart, colStart) ;
X   	if (fldCharType == SET  ||  fldCharType == MENU) 
X   	{
X      		setNumb = FindSet(Fld, fldRange, fldLength, fldType) ;
X      		ShowSet(win, rowStart, colStart, fldAttrib, fldRange, 
X			fldLength, &setNumb, colEnd, charKeyed, origAttr) ;
X		if (fldCharType == MENU)
X		{
X			char	menustrid[10];
X			int	mrow;
X			int	mcol;
X
X			/* make a unique menuid from the row & column */
X			sprintf (menustrid, "%2d%2d", rowStart, colStart);
X			menuid = atoi (menustrid);
X
X			/* try to put menu as close to the field as possible */
X			if ((rowStart + win->_begy) > 0)
X				mrow = rowStart + win->_begy - 1;
X			else
X				mrow = 0;
X			/* off the edge of the screen ? */
X			if ((colEnd + fldLength + 4) + win->_begx > COLS)
X			{
X				mcol = COLS - fldLength + 4;
X				mrow += 2;
X			}
X			else
X				mcol = colEnd + win->_begx;
X
X			BuildMenu (menu, fldRange);
X			popmenu (CREATEMENU, menuid, mrow, mcol, "", 
X				helpFile, LINES-mrow-2, sizeof(menu[0]), menu);
X
X			/* replace with new popmenu(3)
X			popmenu (CREATEMENU, menuid, mrow, mcol, "","",
X				menu[0], menu[1], menu[2], menu[3], menu[4],
X				menu[5], menu[6], menu[7], menu[8], menu[9],
X				menu[10], menu[11]);
X			*/
X		}
X   	} 
X   	else
X		/*
X		**	FALSE if Fld->strval == '\0'
X		**	TRUE  if Fld contained a default value.
X		*/
X      		initFld = DisPrmpt(win, Fld, fldAttrib, fldMask, fldLength, 
X				fldCharType, fldAdjust, fldType, colStart, 
X				colEnd, fldStr, charKeyed) ;
X
X
X
X	/* 
X	** find the first column where there is not a mask(M) character 
X	** This is the column where we begin the input.
X	*/
X   	col = colStart ;
X   	fldWrk = charKeyed ;
X	/*
X	**  fldWrk - M = mask character, N = no mask character
X	*/
X   	while (col != colEnd  &&  *fldWrk++ == 'M')
X      		col++;
X
X   	colBegInput = col ;
X   	wmove(win, rowStart, col) ;
X   	notFinished = TRUE ;
X
X
X	if (fldCharType == PROTECT)
X	{
X		/* Password entry field */
X		wattrset (win, A_REVERSE);
X		strcpy (Fld->strVal, "");
X		free (fldStr);
X		free (charKeyed);
X		row = rowStart;
X		col = colStart;
X		fldStr = Fld->strVal;
X		*fldStr = '\0';
X		do
X		{
X			wmove (win, row, col);
X			wnoutrefresh (win);
X			doupdate ();
X			ch = wgetch (win);
X			if (ch == KeyHelp || ch == KEY_HELP)
X			{
X				ShowHelp (helpFile, helpTag, fldErrRow);
X				touchwin (win);
X				wnoutrefresh (win);
X			}
X		} while (ch == KeyHelp || ch == KEY_HELP);
X		*fldStr = (char)ch;
X		while (*fldStr != '\r')
X		{
X			if (col > colStart + fldLength - 1)
X				beep ();
X			else
X			{
X				addch ('X');
X				fldStr++;
X				col++;
X			}
X			wmove (win, row, col);
X			wnoutrefresh (win);
X			doupdate ();
X			ch = wgetch (win);
X			if (ch == KeyHelp || ch == KEY_HELP)
X			{
X				ShowHelp (helpFile, helpTag, fldErrRow);
X				touchwin (win);
X				wnoutrefresh (win);
X			}
X			else
X				*fldStr = (char)ch;
X		}
X		*fldStr = '\0';
X		wattrset (win, A_NORMAL);
X		return ((int)'\r');
X	}
X
X
X   	while (TRUE) 
X   	{
X      		do 
X      		{
X	 		/* pjc 11/88 for message and errors to stdscr */
X	 		wnoutrefresh (stdscr);
X         		wnoutrefresh(win) ;
X	 		doupdate ();
X
X         		getyx(win, row, col) ;
X
X         		ch = wgetch(win);
X
X			CLEARROW (fldErrRow);
X   			if (helpMsg != NOMSG) 
X   			{
X      				mvwaddstr (stdscr,
X		((fldDispRow%100) == fldDispRow) ? fldDispRow : fldDispRow/100, 
X		((fldDispRow%100) == fldDispRow) ? 0 : fldDispRow%100, 
X					helpMsg) ;
X   			}
X
X   			wmove(win, row, col) ;
X
X			/* these keys accept the input before returning */
X			if (ch == KeyReturn)	ch = KEY_RETURN;
X			if (ch == KeyDown)	ch = KEY_DOWN;
X			if (ch == KeyUp)	ch = KEY_UP;
X			if (ch == KeyTab)	ch = KEY_TAB;
X			if (ch == KeyBTab)	ch = KEY_BTAB;
X			if (ch == KeyAccept)	ch = KEY_ACCEPT;
X
X			/* other keys */
X			if (ch == KeyHelp)	ch = KEY_HELP;
X			if (ch == KeyRedraw)	ch = KEY_REFRESH;
X			if (ch == KeyLeft)	ch = KEY_LEFT;
X			if (ch == KeyRight)	ch = KEY_RIGHT;
X			if (ch == KeyEOL)	ch = KEY_EOL;
X			if (ch == KeyDL)	ch = KEY_DL;
X			if (ch == KeyDC)	ch = KEY_DC;
X			if (ch == KeyIC)	ch = KEY_IC;
X			if (ch == KeySave)	ch = KEY_SAVE;
X			if (ch == KeyPrint)	ch = KEY_PRINT;
X			if (ch == KeyBeg)	ch = KEY_BEG;
X			if (ch == KeyEnd)	ch = KEY_END;
X			if (ch == KeyCancel)	ch = KEY_CANCEL;
X
X			switch (ch)
X			{
X			   case KEY_BEG:
X				/* place cursor at beg of field */
X				col = colStart;
X                  		wmove(win, rowStart, col) ;
X				break;
X
X			   case KEY_END:
X				/* place cursor at end of input */
X				col = colEnd;
X				junk = colEnd;
X				while (col >= colStart)
X				{
X					if (*(charKeyed+col-colStart) == 'N')
X						junk = col;
X					if (*(charKeyed+col-colStart) == 'Y')
X						break;
X					col--;
X				}
X				col = junk;
X                  		wmove(win, rowStart, col) ;
X				break;
X
X			   case KEY_HELP:
X				ShowHelp (helpFile, helpTag, fldErrRow);
X				touchwin (win);
X				wnoutrefresh (win);
X				continue;
X
X			   case KEY_REFRESH:
X				clearok (win, TRUE);
X				continue;
X
X			   case KEY_LEFT:
X				/* fixme
X                  		if (col > colBegInput)
X				*/
X                  		if (col > colStart)
X                     			col--;
X                  		else
X                     			BELL;
X                  		while (col > colStart  &&  
X				       *(charKeyed + col - colStart) == 'M')
X                     			--col ;
X                  		while (*(charKeyed + col - colStart) == 'M')
X                     			col++;
X                  		wmove(win, rowStart, col) ;
X				continue;
X
X			   case KEY_RIGHT:
X                     		if (col < colEnd - 1  &&
X                	  	    (*(charKeyed + col - colStart) == 'Y' || 
X			  	    *(charKeyed + col - colStart) == 'M' ) )
X                        		col++;
X            	     		else
X                        		BELL;
X                     		while (col < colEnd  &&  
X				       *(charKeyed + col - colStart) == 'M')
X                     			col++;
X                     		while (*(charKeyed + col - colStart) == 'M')
X                        		col--;
X                     		wmove(win, rowStart, col) ;
X            	     		break;
X
X			   case KEY_EOL:
X				/*
X				**  Clear from cursor to end of field.
X				*/
X            	        	if (col == colBegInput) initFld = FALSE ;
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            			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:
SHAR_EOF
echo "End of part 7"
echo "File utilities.d/libgeti.d/GetInput.c is continued in part 8"
echo "8" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 8 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=8
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				/*
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					junk = popmenu (menuid);
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					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         		if ( IsFldOk(win, rowStart, colStart, Fld, fldMask, 
X				    fldRange, fldLength, fldCharType, fldType, 
X				    mustEnter, fldErrRow, fldDispRow, colEnd, 
X				    fldStr, charKeyed, setNumb, origAttr) )
X            			break ;
X         		else         
X	 		{
X            			notFinished = TRUE ;
X            			continue ;
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 0444 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**		All this does is define some global variables for the keys
X**		used in GetInput(3) and assign some default values.
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
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/*
X	char  *tName, *lName, *getenv() ;
X
X   	lName = longname() ;
X   	tName = getenv("TERM") ;
X
X   	if (strcmp(tName, "5425")  ==  0)
X      		Load5425 () ;
X   	else
X		if (strcmp (tName, "sun") == 0)
X			LoadSun ();
X		else
X      			LoadAnsi() ;
X*/
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[] = "@(#)IsDate.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include <stdio.h>
X#include <time.h>
X#include "GetInput.h"
X
XIsDate (str, mask)
X	char	*str ;
X	char	*mask ;
X{
X	char	cmdstr[5] ;
X	int	year, month, day ;
X	static int	century = 0 ;
X	long	clock ;
X
X	struct tm *localtime(), *Tm ;
X
X	if (century == 0) {
X
X		clock = time((long *) 0) ;
X		Tm = localtime (&clock) ;
X		century = 1900 ;
X		if (Tm->tm_year > 100)
X			century += (Tm->tm_year / 100) * 100 ;
X
X	}
X
X	if (mask == NULL) {
X
X		cmdstr[0] = *str++ ;
X		cmdstr[1] = *str++ ;
X		cmdstr[2] = '\0' ;
X		month = atoi (cmdstr) ;
X
X		cmdstr[0] = *str++ ;
X		cmdstr[1] = *str++ ;
X		cmdstr[2] = '\0' ;
X		day = atoi (cmdstr) ;
X
X		cmdstr[0] = *str++ ;
X		cmdstr[1] = *str++ ;
X		cmdstr[2] = '\0' ;
X		year = atoi (cmdstr)  +  century ;
X
X	} else {
X
X		while ( *mask != '\0' ) {
X
X			while ( *mask != 'M' && *mask != 'D' && *mask != 'Y' )
X				mask++ ;
X
X			switch (*mask) {
X				case 'M':
X					cmdstr[0] = *str++ ;
X					cmdstr[1] = *str++ ;
X					cmdstr[2] = '\0' ;
X					month = atoi (cmdstr) ;
X					mask += 2 ;
X					break ;
X				case 'D':
X					cmdstr[0] = *str++ ;
X					cmdstr[1] = *str++ ;
X					cmdstr[2] = '\0' ;
X					day = atoi (cmdstr) ;
X					mask += 2 ;
X					break ;
X				case 'Y':
X					cmdstr[0] = *str++ ;
X					cmdstr[1] = *str++ ;
X					mask += 2 ;
X					if (*mask == 'Y') {
X						cmdstr[2] = *str++ ;
X						cmdstr[3] = *str++ ;
X						cmdstr[4] = '\0' ;
X						year = atoi (cmdstr) ;
X						mask += 2 ;
X					} else {
X						cmdstr[2] = '\0' ;
X						year = atoi (cmdstr) + century ;
X					}
X					break ;
X			}
X		}
X	}
X	return (valid_date (year, month, day)) ;
X}
X
X
SHAR_EOF
chmod 0444 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[] = "@(#)IsFldOk.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
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
X	WINDOW      	*win ;      	/* Window                */
X	int   		row ;
X	int   		colStart ;
X	FldUnPointer	Fld ;    	/* Pointer to union for field     */
X	char  		*fldMask ;  	/* mask for character string      */
X	char  		*fldRange ; 	/* range of valid values for output */
X	unsigned 	fldLength ; 	/* Maximum length of output       */
X	char  		fldCharType ;  /* type of character           */
X	char  		fldType ;   /* type of field         */
X	int   		mustEnter ; /* must enter - boolean   */
X	int   		fldErrRow ; /* where to display error message   */
X	int   		fldDispRow ;   /* where to display help message    */
X	int   		colEnd ; /* last character to display      */
X	char  		*fldStr ;   /* field string             */
X	char  		charKeyed[] ;  /* characters in the field keyed    */
X	int   		setNumb ;   /* for SET & MENU      */
X	int   		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{
X   case CHAR:
X   case DATE:
X   case TIME:
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   }
X
X   if (fldStr == NULL  &&  !mustEnter)
X      return(1) ;
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) ) 
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			"[%s] Valid Ranges are: %s", fldStr, fldRange) ;
X		wattrOff (stdscr);
X      		wmove (win, row, colLast) ;
X
X   	}
X
X   	return(0) ;
X
X}
SHAR_EOF
chmod 0444 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[] = "@(#)IsRange.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include <curses.h>
X#include <ctype.h>
X#include <string.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
XIsRange (Fld, fldLength, fldType, fldRange)
X
XFldUnPointer   Fld ;
Xunsigned int   fldLength ;
Xchar  fldType ;
Xchar  *fldRange ;
X{
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 ;
X   int   	fromOk ;
X   int   	success ;
X   int   	retCode ;
X   double   	atof() ;
X
X
X   wrkAlloc   = malloc (fldLength + 1) ;
X
X   fromTo = FROM ;
X   success = fromOk = FALSE ;
X
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 != ',' && *fldRange != '-') ;
X
X      *wrk = '\0' ;
X      wrk = wrkAlloc ;
X
X      switch (fldType) 
X      {
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)   INTFLAG = sscanf (Fld->strVal, "%d", &t1);
X	 if (INTFLAG)
X	 {
X	    retCode = t1 - t2;
X	 }
X	 else
X	    retCode = strcmp (Fld->strVal, wrk);
X         if (retCode == 0 || (fromOk == TRUE  &&  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      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   free (wrkAlloc) ;
X
X   if (success)
X      return (TRUE) ;
X   else
X      return (FALSE) ;
X}
X
X
SHAR_EOF
chmod 0444 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 ;
X	menu[0].page = 1 ;
X	/*
X	 * beyond the 1st option
X	 */
X	for ( i=1; i<Noptions ; i++ )
X	{
X		menu[i].page = menu[i-1].page ;
X		menu[i].column = menu[i-1].column
X				+ strlen( opt_table[i-1][0] ) + 2 ;
X		/*
X		 * about to roll off the right edge?
X		 */
X		if ( menu[i].column+strlen( opt_table[i][0] ) > COLS ||
X		     ( i < Noptions-1 &&
X		       menu[i].column+strlen( opt_table[i][0] )+5 > COLS ) )
X		{
X			menu[i].page++ ;	/* bump a page */
X			if ( title != NULL )	/* and wrap around */
X				menu[i].column = strlen( title ) + 7 ;
X			else
X				menu[i].column = 5 ;
X		}
X	}
X
X	i = ( opt<=Noptions && opt>0 ) ? opt-1 : 0 ;	/* set highlight */
X
X	/*
X	 * The LOOP
X	 */
X	while ( TRUE )
X	{
X		_showring( win, line, title, i, opt_table ) ;
X		ch = wgetch( win ) ;		/* get input */
X
X		if ( ch == KeyBackspace )	ch = KEY_BACKSPACE ;
X		if ( ch == KeyHelp )		ch = KEY_HELP ;
X		if ( ch == KeyRedraw )		ch = KEY_REFRESH ;
X		if ( ch == KeyPrint )		ch = KEY_PRINT ;
X
X		switch (ch)
X		{
X	 	case KEY_UP:
X		case KEY_LEFT:
X		case KEY_CTLK:
X		case KEY_CTLH:
X	 	case KEY_BACKSPACE:
X	 	case KEY_BTAB:
X			if ( --i < 0 )
X				i = Noptions - 1 ;
X			break ;
X
X	 	case KEY_DOWN:
X		case KEY_RIGHT:
X		case KEY_CTLJ:
X		case KEY_CTLL:
X	 	case ' ':
X	 	case KEY_TAB:
X			if ( ++i >= Noptions )
X				i = 0 ;
X		        break ;
X
X		case KEY_RETURN:
X		case KEY_ENTER:
X			_wclrring( win, line ) ;
X			putp( cursor_visible ) ;
X			return( i+1 ) ;
X			break ;
X
X		case KEY_HELP:
X			/*
X			ShowHelp( GENERAL, SPECIALKEYS, MSGLINE ) ;
X			*/
X			break ;
X
X		case KEY_REFRESH:
X			clearok( win, TRUE ) ;
X			break ;
X			
X		case KEY_PRINT:
X            		ScrnPrnt(win, LINES, COLS, MSGLINE) ;
X            		clearok(win, TRUE ) ;
X			break ;
X			
X		default:
X			for ( ii=0; ii<=Noptions-1; ii++ )
X			{
X				/* upper char match */
X				if ( strchr( opt_table[ii][0], toupper(ch) ) != NULL )
X				{
X					_wclrring( win, line ) ;
X					putp( cursor_visible ) ;
X		        		return ( ii+1 );
X				}
X			}
X			flash() ;
X		        break;
X		}
X	}
X}
X
X/*
X * _wclrring:  Erase the ring menu from screen
X */
X_wclrring( win, line )
X	WINDOW	*win ;
X	short	line ;
X{
X	wmove( win, line, 0 ) ; wclrtoeol( win ) ;
X	wmove( win, line+1, 0 ) ; wclrtoeol( win ) ;
X}
X
X/*
X * _showring: Display one lineful of RingMenu depending on the page
X *	      current option is on.
X */
X_showring( win, line, title, opt, opt_table )
X	WINDOW	*win ;
X	short 	line, opt ;
X	char	*title, *opt_table[][2] ;
X{
X	register short	i ;
X
X	wmove( win, line, 0 ) ;			/* go there */
X	if ( title != NULL )			/* title? */
X		wprintw( win, "%s  ", title ) ;
X	if ( menu[opt].page != 1 )		/* not 1st page? */
X		waddstr( win, "...  " ) ;
X		
X	/*
X	 * show options
X	 */
X	for ( i=0; i<Noptions && menu[i].page<=menu[opt].page; i++ )
X		if ( menu[i].page == menu[opt].page )	/* same page? */
X		{
X			if ( i == opt )		/* need highlight? */
X				wattrset( win, A_REVERSE );
X			waddstr( win, opt_table[i][0] );
X			wattrset( win, A_NORMAL ) ;
X			waddstr( win, "  " ) ;
X		}
X
X	if ( menu[opt].page < menu[Noptions-1].page )	/* not last page? */
X		waddstr( win, "..." ) ;
X	wclrtoeol( win ) ;
X
X	/*
X	 * show description
X	 */
X	wmove( win, line+1, 0 ) ;
X	wclrtoeol( win ) ;
X	mvwprintw( win, line+1,menu[0].column, "%s", opt_table[opt][1] ) ;
X
X	/*
X	 * fix cursor
X	 */
X	if ( menu[0].column >= 2 )
X		wmove(win, line, menu[0].column-2 );	/* before 1st option */
X	else
X		/* behind the last option */
X		wmove(win, line, menu[i-1].column+strlen(opt_table[i-1][0])+2 ) ;
X
X	wrefresh( win );
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/RingMenu.c || echo "restore of utilities.d/libgeti.d/RingMenu.c fails"
echo "x - extracting utilities.d/libgeti.d/ScrnOut.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ScrnOut.c &&
Xstatic char Sccsid[] = "@(#)ScrnOut.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X#include	<curses.h>
X#include	"GetInput.h"
X
XScrnOut(win, y, x, fpout)
X	WINDOW	*win ;
X	int	y, x ;
X	FILE	*fpout ;
X{
X	int	xx, yy ;
X
X	for(yy = 0 ; yy < y ; yy++) {
X		for(xx = 0 ; xx < x ; xx++)
X			fputc( mvwinch( win, yy, xx ) & A_CHARTEXT, fpout) ;
X		fputc( '\n', fpout ) ;
X	}
X
X	return( 0 ) ;
X}
X
X
X
XScrnPrnt(win, y, x, msgLine)
X	WINDOW	*win ;
X	int	y, x ;
X	int	msgLine ;
X{
X	FILE	*fp ;
X
X	BELL;
X	mvaddstr(msgLine, 0, "Printing Screen ") ;
X	wattrOn(stdscr, A_BLINK) ;
X	addstr("...") ;
X	wattrOff(stdscr) ;
X	refresh() ;
X	BELL;
X
X	if( (fp = popen("lp -s", "w")) == NULL )
X		return(1) ;
X
X	ScrnOut(win, y, x, fp) ;
X
X	pclose(fp) ;
X
X	move(msgLine, 0) ;
X	clrtoeol() ;
X	refresh() ;
X
X	return(0) ;
X}
X
X
X
XScrnFile(win, y, x)
X	WINDOW	*win ;
X	int	y, x ;
X{
X	WINDOW	*twin ;
X	FILE	*fp ;
X	char	cmdstr[17] ;
X	union 	FldUnion Fld ;
X
X	twin = newwin(LINES, COLS, 0, 0) ;
X	mvwaddstr(twin, 10, 0, "File Name: ") ;
X	BELL;
X	cmdstr[0] = '\0' ;
X	Fld.strVal = cmdstr ;
X	GetInput (twin, 10, 11, &Fld, A_REVERSE, NOMASK, NORANGE, 16, 0, 
X		ALPHANUM, NOFILL, CHAR, AUTONEXT, NOMUST, LINES-1, LINES-1, 
X		"Enter the name of the file that will contain the image of the screen.", 
X		NULL, NULL) ;
X
X	if(cmdstr[0] == '\0')
X		return(1) ;
X
X	if( (fp = fopen(cmdstr, "w")) == NULL )
X		return(1) ;
X
X	ScrnOut(win, y, x, fp) ;
X
X	fclose(fp) ;
X
X	delwin(twin) ;
X
X	return(0) ;
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ScrnOut.c || echo "restore of utilities.d/libgeti.d/ScrnOut.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowChar.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowChar.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ShowChar.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  ShowChar()
X**	Validate character against the mask and convert to upper is neccessary.
X**	Display char to screen.
X*/
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include 	"GetInput.h"
X
Xextern int	insertmode;
X
XShowChar (win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, 
X	fldCharType, fldDispRow, fldType, keyStream, fldErrRow, charKeyed, 
X	colEnd, ch, origAttr)
X
X	WINDOW      	*win ;      	/* Window                */
X	int   		rowStart ;
X	int   		colStart ;
X	int   		fldAttrib ; 	/* Curses 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	int   		fldDispRow ;   	/* where to display help message    */
X	char  		fldType ;   	/* type of field         */
X	int   		keyStream ; 	/* if TRUE then the function will
X                  			exit when the last character is
X                  			keyed           */
X	int   		fldErrRow ; 	/* where to display error message   */
X	char  		*charKeyed ;   	/* characters keyed array      */
X	int   		colEnd ; 	/* column start of field */
X	int   		*ch ;     	/* contains character keyed or being
X                  			moved */
X	int   		origAttr[] ;   	/* original attributes for field */
X{
X	int		row ;       /* working row field */
X   	int   		col ;       /* working column field */
X   	char  		charType ;
X   	char  		cmdstr[16] ;
X	int		junk;
X
X
X   	getyx(win, row, col) ;
X
X   	if (fldCharType == STATE  || fldMask == NULL)
X      		charType = fldCharType ;
X   	else 
X      		if (fldCharType == DATE  ||  fldCharType == TIME)
X         		charType = NUMERIC ;
X      		else
X         		charType = *(fldMask + col - colStart) ;
X
X   	switch (charType) 
X   	{
X   	   case HEX:
X      		break ;
X
X   	   case ALPHA:
X      		if (isalpha(*ch)) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X		else 
X		{
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				"Only alpha characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   case ALPHANUM:
X   	   case UPPER_AN:
X   	   case STATE:
X      		if (isprint(*ch)) 
X      		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		if (charType == UPPER_AN  ||  charType == STATE)
X            			*ch = toupper(*ch);
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X      		else 
X      		{
X			CLEARROW (fldErrRow);
X			wattrOn (stdscr, A_REVERSE|A_BOLD);
X         		mvwaddstr(stdscr,
SHAR_EOF
echo "End of part 8"
echo "File utilities.d/libgeti.d/ShowChar.c is continued in part 9"
echo "9" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/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/ShowChar.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/ShowChar.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/ShowChar.c
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X				"Only alpha/numberic characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   case UPPER:
X      		if (isalpha(*ch)) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		*ch = toupper(*ch);
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X		else 
X		{
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				"Only alpha characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break;
X
X   	   case NUMERIC:
X      		if (isdigit(*ch)  ||
X          	   ((fldType == FLOAT ||
X          	     fldType == DOUBLE ||
X          	     fldType == MONEY) && *ch == '.') ) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X         		if (fldType == FLOAT || fldType == DOUBLE ||
X             			fldType == MONEY) 
X			{
X            			int   firstCol ;
X
X            			firstCol = colStart ;
X            			while (*(charKeyed + firstCol - colStart) == 'M')
X               				firstCol++;
X            			if (col == firstCol) 
X				{
X               				cmdstr[0] = *ch ;
X               				cmdstr[1] = '\0' ;
X               				while (++col < colEnd)
X                  				*(charKeyed + col - colStart) = 'N' ;
X               				ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, fldCharType,
X                    				fldType, cmdstr, colEnd, charKeyed, 0, origAttr) ;
X               					wattrOn(win, fldAttrib) ;
X               				mvwaddstr(win, rowStart, colStart + 1, "   ") ;
X               				wattrOff(win) ;
X               				wmove(win, rowStart, colStart + 1) ;
X            			}
X         		}
X
X    		} 
X		else 
X		{
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					"Only numbers allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   default:
X      		BELL;
X      		break ;
X
X   	} /* end switch */
X
X   	getyx(win, row, col) ;
X   	if (col == colEnd && keyStream == TRUE)
X	{
X		*ch = KEY_RETURN;
X      		return(FALSE) ;
X	}
X   	else 
X      		if (col != colEnd && fldMask != NULL) 
X      		{
X	 		/* skip cursor over format characters in the mask */
X         		while (col != colEnd && 
X			       *(charKeyed+col-colStart) == 'M')
X            			col++;
X         		wmove(win, rowStart, col) ;
X         		return(TRUE) ;
X      		}
X
X   	return (TRUE);
X}
SHAR_EOF
echo "File utilities.d/libgeti.d/ShowChar.c is complete"
chmod 0444 utilities.d/libgeti.d/ShowChar.c || echo "restore of utilities.d/libgeti.d/ShowChar.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowHelp.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include	<ctype.h>
X#include	"keys.h"
X#include	"GetInput.h"
X
X
X#ifndef	KEY_BEG
X#define	KEY_BEG		0542
X#endif
X#ifndef	KEY_END
X#define	KEY_END		0550
X#endif
X#ifndef	KEY_HELP
X#define	KEY_HELP	0553
X#endif
X#ifndef	KEY_CANCEL
X#define	KEY_CANCEL	0543
X#endif
X
X#ifndef BELL
X#define BELL	printf ("%c", 7);
X#endif
X#define	NEXTPAGE	1
X#define	PREVPAGE	2
X#define	SCROLLDOWN	3
X#define	SCROLLUP	4
X#define	FIRSTPAGE	5
X#define	LASTPAGE	6
X
X#define	SCROLLRATE	(wrows/2)			/* # lines to scroll */
X#define	MAXTOC		24				/* max TOC entries */
X#define	TOCTAG		"TABLE_OF_CONTENTS"		/* helptag for TOC */
X
X#define	SKIPJUNK(s) 	/* \
X			**  This macro skips over spaces, tabs, etc. \
X			**  ARGS:  char  *s \
X			*/ \
X			for (;*s != '\0' && (isspace(*s)); s++) \
X				;
X
Xstruct TableOfContents
X{
X	char	helpfile[16];
X	char	helptag[30];
X	char	text[100];
X};
X
X
XShowHelp (HelpFile, Tag, fldErrRow)
X	char	HelpFile[];
X	char	Tag[];
X	int	fldErrRow;
X{
X	WINDOW	*helpWin;
X   	FILE	*fopen(), *fp;
X	char	*fgets();
X	char	*getenv();
X	long	ftell();
X	char	line[100];
X	char	*sptr;
X	int	row;
X	int	col;
X	int	wrows;
X	int	wcols;
X	char	helpfile[80];
X	int	longline; /*0*/
X	int	ch;
X	char	title[100];
X	int	scrollflag;
X	int	linecount;
X	long	lineoffset[200];		/* start of line in file */
X	static int	helpHelp = FALSE;
X	struct TableOfContents	TOC[MAXTOC];
X	int	rc;
X	int	TOCflag = FALSE;
X	char	fileName[100];
X	char	tag[80];
X
X
X	strcpy (fileName, HelpFile);
X	strcpy (tag, Tag);
Xrestart:
X	strcat (tag, "\n");
X	linecount = 0;
X	/* do we have a help tag ? */
X	if (strcmp (tag, "") == 0)
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				"No help available.");
X		wattrOff (stdscr);
X		return (1);
X	}
X
X	/*
X	**  open help file
X	*/
X   	if ((fp = fopen (fileName, "r")) == NULL)
X   	{
X		if (getenv("HELPDIR") != (char *)NULL)
X      			sprintf (helpfile, "%s/%s", getenv ("HELPDIR"), 
X				 fileName);
X      		fp = fopen (helpfile, "r");
X      		if (fp == NULL) 
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				"No help available.");
X			wattrOff (stdscr);
X         		return(1) ;
X      		}
X   	}
X
X	if (!TOCflag) 
X		TOCflag = loadTOC (fp, TOC) == 0 ? TRUE : FALSE;
X
X	/*
X	**  Locate starting tag.
X	*/
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X		if (strncmp (line, tag, strlen(tag)) == 0)
X			break;
X
X	if (sptr == (char *)NULL)
X	{
X		/* Did not find starting tag */
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			"No help available.");
X		wattrOff (stdscr);
X      		fclose(fp) ;
X      		return(1) ;
X	}
X
X	/*
X	**	Found starting tag.
X	**	determine how big of a window to make by searching for 
X	**  	ending tag
X	**	check for a .TITLE line
X	*/
X	lineoffset[linecount+1] = ftell (fp);
X	fscanf (fp, "%s", title);
X	if (strcmp (title, ".TITLE") == 0)
X	{
X		fseek (fp, 1, 1);			/* skip 1 byte */
X		sptr = fgets (title, sizeof(title)-1, fp);
X		title[strlen(title)-1] = '\0';		/* junk \n */
X		lineoffset[linecount+1] = ftell (fp); 	/* reset beg of help */
X	}
X	else
X		strcpy (title, "");
X	longline = strlen(title)+2;
X
X	fseek (fp, lineoffset[1], 0);		/* back to row 1 */
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X	{
X		/* check for ending tag */
X		if (strncmp (line, tag, strlen(tag)) == 0)
X			break;
X		
X		/* calculate longest line */
X		if (strlen(line) > longline)
X			longline = strlen(line);
X		linecount++;
X		lineoffset[linecount+1] = ftell (fp);
X	}
X
X	wrows = (linecount+2 < (LINES-2)) ? linecount+2 : (LINES-2);
X	wcols = (longline+1 < COLS) ? longline+1 : COLS;	/* 1 for \n */
X	/* center window on the screen */
X   	helpWin = newwin(wrows, wcols, LINES/2-wrows/2,COLS/2-wcols/2) ;
X	keypad (helpWin, TRUE);
X	scrollflag = (linecount+2 <= LINES) ? FALSE : TRUE;
X	drawbox (helpWin, 1,1, wrows,wcols, 2,2, scrollflag,
X			(helpHelp == FALSE ? TRUE : FALSE));
X	if (strcmp (title, "") != 0)
X	{
X		wattrset (helpWin, A_STANDOUT);
X		mvwprintw (helpWin, 0,2, "%s", title);
X		wattrset (helpWin, A_NORMAL);
X	}
X
X	row = 1;
X	fseek (fp, lineoffset[row], 0);		/* back to row 1 */
X	ch = KEY_BEG;
X	do
X	{
X		switch (ch)
X		{
X		   case KEY_TOC:
X			if (!TOCflag)
X				break;
X			rc = showTOC (TOC);
X			if (rc > 0)
X			{
X				fclose (fp);
X				delwin (helpWin);
X				strcpy (fileName,TOC[rc-1].helpfile);
X				strcpy (tag,TOC[rc-1].helptag);
X				goto restart;
X			}
X			touchwin (helpWin);
X			break;
X		   case KEY_BEG:
X			showpage (FIRSTPAGE,fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_DOWN:
X			showpage (SCROLLDOWN,fp,wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_UP:
X			showpage (SCROLLUP, fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_END:
X			showpage (LASTPAGE, fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_HELP:
X			if (!helpHelp)
X			{
X				helpHelp = TRUE;
X				ShowHelp (fileName, "help", fldErrRow);
X				helpHelp = FALSE;
X			}
X			touchwin (helpWin);
X			break;
X		} /* end switch */
X		wattrset (helpWin, A_STANDOUT);
X		if (ftell(fp) != lineoffset[linecount+1])
X		{
X			/* we are not at end of file yet */
X			mvwprintw (helpWin, wrows-1, 2, "--More--(%d%c)",
X		     	   (int)((double)((double)(ftell(fp)-lineoffset[1]) / 
X		     	   (lineoffset[linecount+1]-lineoffset[1])) * 100), 
X			   '%');
X		}
X		else
X		{
X			if (linecount+2 >= LINES)
X				mvwprintw (helpWin, wrows-1, 2, 
X						"--End--       ");
X			else
X				mvwprintw (helpWin, wrows-1, 2, 
X						"              ");
X		}
X
X		wattrset (helpWin, A_NORMAL);
X		wmove (helpWin, wrows-2,wcols-2);
X		wrefresh (helpWin);
X		ch = wgetch (helpWin);
X
X		if (ch == KeyBeg || ch == KEY_BEG)
X			ch = KEY_BEG;
X		else if (ch == KeyDown || ch == KEY_DOWN)
X			ch = KEY_DOWN;
X		else if (ch == KeyUp || ch == KEY_UP)
X			ch = KEY_UP;
X		else if (ch == KeyCancel || ch == KEY_CANCEL)
X			ch = KEY_CANCEL;
X		else if (ch == KeyEnd || ch == KEY_END)
X			ch = KEY_END;
X		else if (ch == KeyHelp || ch == KEY_HELP)
X			ch = KEY_HELP;
X		else if (ch == KeyTOC || ch == KEY_TOC)
X			ch = KEY_TOC;
X		else
X		{
X			if (ftell(fp) != lineoffset[linecount+1])
X				ch = KEY_DOWN;
X			else
X				ch = KEY_CANCEL;
X		}
X	} while (ch != KEY_CANCEL);
X
X   	fclose(fp) ;
X	delwin (helpWin);
X	touchwin (stdscr);
X	wnoutrefresh (stdscr);
X   	return(0) ;
X}
X
X/*
X**  RETURNS:
X**		0	more info
X**		-1	end of file or tag
X*/
Xshowpage (action, fp, wrows, wcols, helpWin, linecount, lineoffset)
X	int	action;
X	FILE	*fp;
X	int	wrows;
X	int	wcols;
X	WINDOW	*helpWin;
X	int	linecount;
X	long	lineoffset[];		/* start of line in file */
X{
X	char		line[100];
X	static int	here;				/* line top of screen */
X	int		rowcount;
X	int		i,j;
X
X
X	switch (action)
X	{
X	   case FIRSTPAGE:
X		here = 1;
X		break;
X
X	   case LASTPAGE:
X		if (here == linecount - wrows + 1) return (-1);
X		here = linecount - wrows + 1;
X		break;
X
X	   case SCROLLDOWN:
X		if (here + wrows > linecount)
X			return(-1);				/* at EOF */
X		if (here + wrows + SCROLLRATE <= linecount+1)
X			here += SCROLLRATE;
X		else
X			here = linecount - wrows + 1;
X		break;
X
X	   case SCROLLUP:
X		if (here == 1)
X			return (-1);				/* at BOF */
X		if (here - SCROLLRATE >= 1)
X			here -= SCROLLRATE;
X		else
X			here = 1;
X		break;
X
X	   case NEXTPAGE:
X		break;
X
X	   case PREVPAGE:
X		break;
X	}
X
X	/* clear screen */
X	for (i=1; i<=wrows; i++)
X		for (j=1; j<=wcols; j++)
X			mvwprintw (helpWin, i,j, " ");
X	fseek (fp, lineoffset[here], 0);		/* first of screen */
X	for (rowcount=1; rowcount<=wrows && rowcount<=linecount; rowcount++)
X	{
X		fgets (line, sizeof(line)-1, fp);
X		line[strlen(line)-1] = '\0';		/* junk \n */
X		showline (helpWin, rowcount, 1, line);
X	}
X	return (0);
X}
X
X
X
X/*  FUNCTION:	displaytext()
X**		Displays a string to the screen with atributes.
X**  ARGS:	row	screen row
X**		col	screen col
X**		s	the string
X**  RETURNS:	none
X*/
X#ifndef SYSV
X#define	SYSV	1
X#endif
Xshowline (helpWin, row, col, s)
X	WINDOW	*helpWin;
X	int	row, col;
X	char	s[];
X{
X	int	i;
X
X   	wmove (helpWin, row, col);
X
X	/*
X	**	Now display looking for terminal attributes.
X	*/
X      	for (i = 0; s[i] != '\0'; i++)
X      	{
X         	if (s[i] == '\\')
X	 	{
X#ifdef BSD
X	    		/* Berkeley curses only supports standout */
X	    		if (s[i+1] != 'N') s[i+1] = 'S';
X#endif
X            		switch (s[++i])
X            		{
X	       		   case 'S':
X#ifdef BSD
X				standout ();
X#else
X	   			wattrset (helpWin, A_STANDOUT);
X#endif
X				break;
X	       		   case 'B':
X#ifdef SYSV
X				wattrset (helpWin, A_BOLD);
X#endif
X				break;
X	       		   case 'U':
X#ifdef SYSV
X				wattrset (helpWin, A_UNDERLINE);
X#endif
X				break;
X	       		   case 'D':
X#ifdef SYSV
X				wattrset (helpWin, A_DIM);
X#endif
X				break;
X	       		   case 'R':
X#ifdef SYSV
X				wattrset (helpWin, A_REVERSE);
X#endif
X				break;
X	       		   case 'L':
X#ifdef SYSV
X				wattrset (helpWin, A_BLINK);
X#endif
X				break;
X	       		   case 'N': 
X#ifdef BSD
X				standend ();
X#else
X				wattrset (helpWin, A_NORMAL);
X#endif
X				break;
X			}
X		}
X         	else
X            		waddch (helpWin, s[i]);
X	}
X}
X
X
X
XloadTOC (fp, TOC)
X	FILE			*fp;
X	struct TableOfContents	TOC[];
X{
X	char	line[100];
X	char	*sptr;
X	int	count = 0;
X
X
X	strcpy (TOC[0].text, "");
X	/*
X	**  Locate TABLE_OF_CONTENT tag.
X	*/
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X		if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
X			break;
X
X	if (sptr == (char *)NULL) 
X	{
X		rewind (fp);
X		return (-1);				/* no TOC */
X	}
X
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X	{
X		/* check for ending tag */
X		if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
X			break;
X		
X   		sscanf (sptr, "%s", TOC[count].helpfile);
X		sptr += strlen(TOC[count].helpfile);
X		SKIPJUNK(sptr);
X   		sscanf (sptr, "%s", TOC[count].helptag);
X		sptr += strlen(TOC[count].helptag);
X		SKIPJUNK(sptr);
X		strcpy (TOC[count].text, sptr);
X		TOC[count].text[strlen(TOC[count].text)-1] = '\0'; /* junk \n */
X		count++;
X	}
X	strcpy (TOC[count].text, "");
X	rewind (fp);
X	return (0);
X}
X
X
X
XshowTOC (TOC)
X	struct TableOfContents	TOC[];
X{
X	int	count;
X	int	length = 0;
X	char	menu[MAXTOC+2][80];		/* popmenu items */
X	int	menuid = 99;
X	int	rc;
X
X
X	for (count = 0; strcmp (TOC[count].text, "") != 0; count++)
X	{
X		strcpy (menu[count], TOC[count].text);
X		if (strlen(menu[count]) > length)
X			length = strlen(menu[count]);
X	}
X	strcpy (menu[count], "");
X
X	/* center on screen */
X	popmenu (-2, menuid, (LINES/2)-(count/2)-3, (COLS/2)-(length/2)-2, 
X			"Help - Table Of Contents", "", count, sizeof(menu[0]), 
X			menu);
X	rc = popmenu (menuid);
X	return (rc);
X}
X/* Paul J. Condie  12/88 */
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/ShowHelp.c || echo "restore of utilities.d/libgeti.d/ShowHelp.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowSet.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowSet.c &&
Xstatic char Sccsid[] = "@(#)ShowSet.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include	<curses.h>
X#include	"GetInput.h"
X
XShowSet(win, rowStart, colStart, fldAttrib, fldRange, fldLength, pNum, colEnd, charKeyed, origAttr)
X	WINDOW		*win ;		/* Window	    		    */
X	int		rowStart ;
X	int		colStart ;
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		*fldRange ;	/* enumeration list for SET 	    */
X	unsigned	fldLength ;	/* Maximum length of output 	    */
X	int		*pNum ;		/* enum to display */
X	int		colEnd ;
X	char		*charKeyed ;	/* characters keyed */
X	int		origAttr[] ;	/* original attributes for field */
X{
X	char	*fldWrk ;
X	int	count ;
X	int	col ;
X
X	wmove (win, rowStart, colStart) ;
X
X	fldWrk = fldRange ;
X
X	count = 0 ;
X
X	while (*fldWrk != '\0') {
X
X		if (count == *pNum)
X			break ;
X
X		while (*fldWrk != ','  &&  *fldWrk != '\0')
X			fldWrk++ ;
X
X		if (*fldWrk == '\0') {
X			fldWrk = fldRange ;
X			*pNum = 0 ;
X			break ;
X		}
X
X		while (*fldWrk == ','  ||  *fldWrk == ' ')
X			fldWrk++ ;
X
X		count++ ;
X	}
X
X	if(fldAttrib != -1)
X		wattrset (win, fldAttrib) ;
X
X	col = colStart ;
X	while (*fldWrk != ','  &&  *fldWrk != '\0') {
X		if(fldAttrib == -1)
X			wattrset(win, origAttr[col++ - colStart]) ;
X		waddch (win, *fldWrk++) ;
X		*charKeyed++ = 'Y' ;
X		fldLength-- ;
X	}
X
X	if(fldAttrib != -1)
X		wattrset (win, 0) ;
X
X	while (fldLength--) {
X		*charKeyed++ = 'N' ;
X		if(fldAttrib == -1)
X			wattrset(win, origAttr[col++ - colStart]) ;
X		waddch (win, ' ') ;
X	}
X
X	wmove (win, rowStart, colStart) ;
X	wattrset(win, 0) ;
X
X	return(0) ;
X
X}
X
X
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ShowSet.c || echo "restore of utilities.d/libgeti.d/ShowSet.c fails"
echo "x - extracting utilities.d/libgeti.d/_Main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/_Main.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include 	"GetInput.h"
X#include 	"keys.h"
X
X
Xmain (argc, argv)
X
X	int   argc;
X	char  *argv[];
X{
X   int   	intV ;
X   long  	longV ;
X   double   	doubleV ;
X   int   	retCode ;
X   char  	cmdstr[128] ;
X   union FldUnion Fld ;
X
X
X   Initialize() ;
X
X   cmdstr[0]='\0';
X   strcpy (cmdstr, "hi");
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 1, 1, &Fld, A_REVERSE, NOMASK, NORANGE,
X       5, 0, ALPHANUM, RTADJ_BFILL, CHAR, NOAUTO, NOMUST, 20, 22,
X       "Prompt", "GetInput.hlp", "GETINPUT");
X
X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X   /* Double */
X   doubleV = 123.45 ;
X   Fld.doubleVal = &doubleV ;
X   retCode = GetInput (stdscr, 18, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 
X	10, 0, NUMERIC, RTADJ_ZFILL, DOUBLE, NOAUTO,
X        NOMUST, 20, 21, "Double: ") ;
X   mvprintw (18, 40, "return code = :%d: value = :%f:", retCode, doubleV);
X   refresh ();
X
X   /*
X   cmdstr[0]='\0';
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 1, 1, &Fld, A_PROTECT, NOMASK, NORANGE,
X       5, 2, ALPHANUM, NOFILL, CHAR, NOAUTO, MUSTENTER, 2010, 22,
X       "Prompt                   %", "junk.hlp", "GETINPUT");
X
X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X
X   strcpy(cmdstr, "AA") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 2, 1, &Fld, A_STANDOUT, 
X	"[VV][VV][  ][  ][  ][  ][  ][  ]", NORANGE, 16, 2, UPPER_AN, NOFILL, 
X	CHAR, NOAUTO, MUSTENTER, 23, 22, "Character field:", "testfile", 
X	"FIELD 1") ;
X
X   mvprintw (2, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X   */
X
X
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 3, 1, &Fld, A_REVERSE, "HH:MM:SS:TT", NULL, 6, 6, 
X	TIME, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, 
X	"Time Field HH:MM:SS:TT: ", "testfile", "FIELD 2") ;
X
X   mvprintw (3, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X
X/* DATE */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "MM/DD/YY", NULL, 6, 6, DATE,
X	NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Date Field MM/DD/YY: ", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/* ZIP */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 9, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 9, 0, 
X	ZIP, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Zip Field XXXXX-XXXX",
X	NOHELP, NOTAG) ;
X
X   mvprintw (9, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/*
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 8, 0, &Fld, A_REVERSE, "(999) 999-9999", NULL, 10, 5, NUMERIC, RTADJ_ZFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Phone Number:", NULL, NULL) ;
X
X   flash () ;
X   strcpy(cmdstr, "ABC") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 10, 0, &Fld, A_REVERSE, NULL, NULL, 9, 0, UPPER_AN, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Job Number:", NULL, NULL) ;
X   mvprintw(12, 0, "strlen %d", strlen(cmdstr) ) ;
X   refresh() ;
X*/
X
X
X/*
X   strcpy(cmdstr, ";lkj") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 12, 0, &Fld, A_REVERSE, NOMASK, 
X		", INTeger, CHARacter, HEXdecimal, DATE", 12, 0, SET, NOFILL, 
X		CHAR, NOAUTO, NOMUST, 20, 21, "enumeration field: ", 
X		NOMSG, NOTAG) ;
X   mvprintw (12, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh () ;
X*/
X
X/*
X   flash () ;
X   intV = 200 ;
X   Fld.intVal = &intV ;
X   retCode = GetInput (stdscr, 13, 0, &Fld, A_REVERSE, NOMASK, "100, 200, 300", 
X		12, 0, SET, NOFILL, INT, NOAUTO, MUSTENTER, 23, 22, 
X		"enumeration field - int: ", NULL, NULL) ;
X   mvprintw (13, 20, "return code = :%d: value = :%d:", retCode, intV);
X   refresh () ;
X
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 14, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 2, 2, STATE, NOFILL, CHAR, AUTONEXT, MUSTENTER, 20, 21, "State Field: ", NULL, NULL) ;
X   refresh () ;
X
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 16, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 6, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, NOMUST,
X        20, 21, "Six char field") ;
X
X   refresh () ;
X
X   */
X
X   refresh () ;
X   sleep (4) ;
X   Windup () ;
X   exit (0) ;
X}
X
X
XInitialize ()
X{
X   initscr() ;
X   cbreak() ;
X   noecho() ;
X   nonl() ;
X   keypad(stdscr, TRUE) ;
X   InitGetI() ;
X   return(0) ;
X}
X
X
XWindup()
X{
X	/*
X	**
X	**	Take care of curses.
X	**
X	*/
X	endwin() ;
X
X	return(0) ;
X}
X
X
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/_Main.c || echo "restore of utilities.d/libgeti.d/_Main.c fails"
echo "x - extracting utilities.d/libgeti.d/checkmask.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/checkmask.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)checkmask.c	1.1   DeltaDate 11/21/88   ExtrDate 1/22/90";
X#endif
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include 	"GetInput.h"
X
Xcheckmask (col, colStart, fldMask, fldCharType, fldType, ch)
X
X	int	col ;
X	int   colStart ;
X	char  *fldMask ;  	/* mask for character string      */
X	char  fldCharType ;  	/* type of character           */
X	char  fldType ;   	/* type of field         */
X	int   ch ;     		/* contains character keyed or being
X                  			moved */
X{
X   	char  charType ;
X   	char  cmdstr[16] ;
X
X
X
X   	if (fldCharType == STATE  || fldMask == NULL)
X      		charType = fldCharType ;
X   	else 
X      		if (fldCharType == DATE  ||  fldCharType == TIME)
X         		charType = NUMERIC ;
X      		else
X         		charType = *(fldMask + col - colStart) ;
X
X   	switch (charType) 
X   	{
X   	   case HEX:
X      		break ;
X
X   	   case ALPHA:
X      		if (isalpha(ch)) 
X			return (ch);
X		else 
X			return (-1);
X      		break ;
X
X   	   case ALPHANUM:
X   	   case UPPER_AN:
X   	   case STATE:
X      		if (isprint(ch)) 
X      		{
X         		if (charType == UPPER_AN  ||  charType == STATE)
X            			ch = toupper(ch);
X			return (ch);
X      		} 
X      		else 
X			return (-1);
X      		break ;
X
X   	   case UPPER:
X      		if (isalpha(ch)) 
X		{
X         		ch = toupper(ch);
X			return (ch);
X      		}
X		else
X			return (-1);
X      		break ;
X
X   	   case NUMERIC:
X      		if (isdigit(ch)  ||
X          	   ( (fldType == FLOAT ||
X          	      fldType == DOUBLE ||
X          	      fldType == MONEY) && ch == '.') ) 
X		{
X			return (ch);
X      		} 
X		else 
X			return (-1);
X      		break ;
X
X   	   default:
X		return (-1);
X   	} /* end switch */
X	return (-1);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/checkmask.c || echo "restore of utilities.d/libgeti.d/checkmask.c fails"
echo "x - extracting utilities.d/libgeti.d/doinsert.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/doinsert.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)doinsert.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  doinsert()
X**	Shifts characters to the right of cursor location over one and
X**	places a space where the new character will go.
X**  RETURNS:
X**		-1	field is full
X**		-2	didn't pass mask edits
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X
X
Xdoinsert (win, row, col, colStart, colEnd, charKeyed, fldMask, fldCharType,
X	fldType, rowStart, fldAttrib, fldRange, fldLength, fldErrRow, origAttr)
X	WINDOW	*win;
X	int	row;
X	int	col;
X	int	colStart;
X	int	colEnd;
X	char	*charKeyed;
X	char	*fldMask;
X	char	fldCharType;
X	char	fldType;
X	int	rowStart;
X	int	fldAttrib;
X	char	*fldRange;
X	int	fldLength;
X	int	fldErrRow;
X	int	origAttr[];
X{
X	int	colSave;
X	char	fldStr[100];
X	char	*fldWrk;
X	int	junk;
X
X
X	colSave = col;		/* cursor location */
X
X	/* if we're sitting at end of field then no need to insert */
X	if (*(charKeyed+col-colStart) == 'N')
X		return (0);
X
X	/* do we have room to shift right on position ? */
X	col = colEnd;
X	while (col >= colStart)
X	{
X		if (*(charKeyed+col-colStart) == 'N')
X			break;				/* looks like we do */
X		if (*(charKeyed+col-colStart) == 'Y')
X		{
X			BELL;
X			return (-1);			/* no room */
X		}
X		col--;
X	}
X	if (col < colStart)
X	{
X		BELL;
X		return (-1);				/* all 'M' characters */
X	}
X
X	/* get field content & insert a space */
X	col = colStart;
X	fldWrk = fldStr;
X	while (col < colEnd)
X	{
X		if (col == colSave)
X			*fldWrk++ = ' ';	/* insert space */
X       		if (*(charKeyed+col-colStart) == 'Y')
X       			*fldWrk++ = mvwinch(win, row, 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'; col++)
X		{
X			/* only check shifted chars */
X			if (col <= colSave  || *(charKeyed+col-colStart) == 'M')
X			{
X				if (*(charKeyed+col-colStart) == 'Y')
X					fldWrk++;
X				continue;
X			}
X
X       			junk = checkmask (col, colStart, 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, A_REVERSE|A_BOLD);
X       			mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X	    			"Unable to insert character due to edits.");
X			wattrOff (stdscr);
X			BELL;
X			col = colSave;
X			wmove (win, rowStart, colSave);
X			return (-2);
X		}
X	}
X
X	/* set last N in charKeyd to Y */
X	col = colEnd;
X	while (col >= colStart)
X	{
X		if (*(charKeyed+col-colStart) == 'N')
X			junk = col;
X		if (*(charKeyed+col-colStart) == 'Y')
X		{
X			*(charKeyed+junk-colStart) = 'Y';
X			break;
X		}
X		col--;
X	}
X
X
X       	ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, 
X			fldLength, fldCharType, fldType,
X			fldStr, colEnd, charKeyed, 0, origAttr);
X
X	col = colSave;
X	wmove (win, rowStart, colSave);
X	return (0);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/doinsert.c || echo "restore of utilities.d/libgeti.d/doinsert.c fails"
echo "x - extracting utilities.d/libgeti.d/drawbox.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)drawbox.c	1.2   DeltaDate 2/1/90   ExtrDate 2/1/90";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	<ctype.h>
X
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X#define	MosaicLine	4	/* A_ALTCHARSET */
X#define	DiamondLine	5	/* A_ALTCHARSET */
X#define	DotLine		6	/* A_ALTCHARSET */
X#define	PlusLine	7	/* A_ALTCHARSET */
X
X#define	CANDRAWGRAPHICS	(enter_alt_charset_mode != NULL  && \
X			 strcmp(enter_alt_charset_mode, "") != 0)
X
Xextern	int	KeyHelp;
X
X
Xvoid drawbox (win, frow, fcol, trow, tcol, trythis, trythat, vscroll, help)
X	WINDOW	*win;
X	int	frow;			/* from row base 1 */
X	int	fcol;
X	int	trow;
X	int	tcol;
X	int	trythis;
X	int	trythat;
X	int	vscroll;
X	int	help;
X{
X	int	row;
X	int	col;
X	int	vchar;
X	int	hchar;
X	int	tlchar;				/* top left corner */
X	int	trchar;				/* top right corner */
X	int	brchar;				/* bottom right corner */
X	int	blchar;				/* bottom left corner */
X	int	attribute;
X	int	boxtype;
X
X
X
X	boxtype = trythis;
X	attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
X	if (attribute == A_ALTCHARSET)
X		/* can this terminal do graphics ? */
X		boxtype = CANDRAWGRAPHICS ? trythis : trythat;
X
X	switch (boxtype)
X	{
X	   case DumbLine:
X		/* draw a dumb line */
X		vchar = '|';
X		hchar = '-';
X		tlchar = '+';
X		trchar = '+';
X		brchar = '+';
X		blchar = '+';
X		break;
X
X	   case StandoutLine:
X		/* draw a standout line */
X		attribute = A_STANDOUT;
X		vchar = ' ';
X		hchar = ' ';
X		tlchar = ' ';
X		trchar = ' ';
X		brchar = ' ';
X		blchar = ' ';
X		break;
X
X	   case SingleLine:
X		/* attempt to draw a graphic single line */
X		vchar = 'x';
X		hchar = 'q';
X		tlchar = 'l';
X		trchar = 'k';
X		brchar = 'j';
X		blchar = 'm';
X		break;
X
X	   case MosaicLine:
X		vchar = 'a';
X		hchar = 'a';
X		tlchar = 'a';
X		trchar = 'a';
X		brchar = 'a';
X		blchar = 'a';
X		break;
X
X	   case DiamondLine:
X		vchar = '`';
X		hchar = '`';
X		tlchar = '`';
X		trchar = '`';
X		brchar = '`';
X		blchar = '`';
X		break;
X
X	   case DotLine:
X		vchar = '~';
X		hchar = '~';
X		tlchar = '~';
X		trchar = '~';
X		brchar = '~';
X		blchar = '~';
X		break;
X
X	   case PlusLine:
X		vchar = 'n';
X		hchar = 'n';
X		tlchar = 'n';
X		trchar = 'n';
X		brchar = 'n';
X		blchar = 'n';
X		break;
X
X	   default:
X		return;
X	}
X
X#ifdef BSD
X	standout ();
X#else
X   	wattrset (win, attribute);
X#endif
X   	for (row = frow-1; row <= trow-1; row++)
X   	{
X      		if (row == frow-1  ||  row == trow-1)
X         		for (col = fcol-1; col <= tcol-1; col++)
X            			mvwaddch (win, row, col, hchar);
X      		else
X      		{
X         		mvwaddch (win, row, fcol-1, vchar);
X         		mvwaddch (win, row, tcol-1, vchar);
X      		}
X   	}
X	/* draw the corners */
X	mvwaddch (win, frow-1,fcol-1, tlchar);	/* top left */
X	mvwaddch (win, frow-1,tcol-1, trchar);	/* top right */
X	mvwaddch (win, trow-1,fcol-1, blchar);	/* bottom left */
X	mvwaddch (win, trow-1,tcol-1, brchar);	/* bottom right */
X
X	/* draw vertical scroll bars */
X	if (vscroll)
X	{
X		wattrset (win, A_REVERSE|A_BOLD);
X		mvwaddch (win, trow-7,tcol-1, '^');
X		mvwaddch (win, trow-6,tcol-1, 'v');
X	}
X	if (help)
X	{
X		wattrset (win, A_STANDOUT);
X		if (isprint(KeyHelp))
X			mvwprintw (win, trow-1,tcol-6, "Help %c", KeyHelp);
X		else
X			mvwprintw (win, trow-1,tcol-7, "Help %c", KeyHelp);
X	}
X
X#ifdef BSD
X   	standend ();
X#else
X   	wattrset (win, A_NORMAL);
X#endif
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/drawbox.c || echo "restore of utilities.d/libgeti.d/drawbox.c fails"
echo "x - extracting utilities.d/libgeti.d/popmenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	<varargs.h>
X
X#define	MAXMENUS	10
X#define	MAXITEMS	100
X#define	NEWMENU		0
X#define	DIMWINDOW	-1
X#define	CREATEMENU	-2	/* only if it does not exist */
X#define WRAPAROUND	TRUE
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X
X#ifndef	KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_HELP
X#   define KEY_HELP	0553
X#endif
X#ifndef KEY_CANCEL
X#   define KEY_CANCEL	0543
X#endif
X#ifndef KEY_DOWN
X#   define KEY_DOWN	0402
X#endif
X#ifndef KEY_UP
X#   define KEY_UP	0403
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	565
X#endif
X
Xextern	int	KeyDown;
Xextern	int	KeyUp;
Xextern	int	KeyHelp;
Xextern	int	KeyCancel;
Xextern	int	KeyRedraw;
Xextern	int	KeyReturn;
X
Xtypedef struct	_menu
X{
X	int	MenuId;			/* numerical menu identifier */
X	int	row;
X	int	col;
X	char	*title ;		/* menu title */
X	char	*helpfile;		/* helpfile */
X	int	winSize ;		/* pop up window length */
X	WINDOW	*win;
X	int	NumItems;		/* number of items in menu */
X	int	width;			/* largest item */
X	char	*items[MAXITEMS+1];
X	int	ActiveItem;		/* last item selected */
X} MENU;
X
X
Xstatic MENU	*THEmenu[MAXMENUS+1];
X
X
X/*VARARGS*/
Xpopmenu (va_alist)
X
X	va_dcl
X{
X	va_list		ap;
X	int		action;
X	int		MenuId;
X	static int	midx = -1;		/* defined menus */
X	char		*ws;			/* base address of table */
X	char		**wws;			/* base address of table */
X	int		wssize;			/* size of one element */
X						/*  or 0 if **wws is used */
X	register int	i, j;
X	int	rc;				/* return code */
X	int	idx;				/* tmp menu index */
X	int	NewMenu;			/* New Menu Flag */
X	static int	_runMenu();
X
X
X	va_start (ap);
X	action = va_arg (ap, int);
X
X	switch (action)
X	{
X	   /*
X	   **	Initialize a new popup menu
X	   */
X	   case NEWMENU:
X	   case CREATEMENU:
X		MenuId = va_arg (ap, int);
X
X		/* do we already have this MenuId */
X		NewMenu = TRUE;
X		for (i = 0; i <= midx; i++)
X			if (THEmenu[i]->MenuId == MenuId)
X			{
X				/* Menu already exists */
X				NewMenu = FALSE;
X				if (action == CREATEMENU)
X					break;	/* don't re-create it */
X
X				/* junk old menu */
X				delwin (THEmenu[i]->win);
X				free (THEmenu[i]);
X				idx = i;
X				break;
X			}
X		if (NewMenu == FALSE  && action == CREATEMENU)
X		{
X			va_end (ap);
X			break;
X		}
X		if (NewMenu == TRUE)
X			idx = ++midx;
X
X
X		/* build the new menu */
X		THEmenu[idx] = (MENU *)malloc (sizeof(MENU));
X		THEmenu[idx]->MenuId = MenuId;
X		THEmenu[idx]->row = va_arg (ap, int);	/* upper left corner */
X		THEmenu[idx]->col = va_arg (ap, int);
X		THEmenu[idx]->title = va_arg (ap, char *);
X		THEmenu[idx]->helpfile = va_arg (ap, char *);
X		if (THEmenu[idx]->helpfile != (char *)NULL  &&
X		    strcmp (THEmenu[idx]->helpfile, "") == 0)
X			THEmenu[idx]->helpfile = (char *)NULL;
X		THEmenu[idx]->winSize = va_arg (ap, int);
X		THEmenu[idx]->NumItems = -1;
X		THEmenu[idx]->width = strlen (THEmenu[idx]->title);
X		wssize = va_arg (ap, int);	/* size of one element */
X		/* for char array, ws is used, otherwise, wws is used for
X		** char *array.
X		*/
X		if ( wssize > 0 )
X		{
X			ws = va_arg (ap, char *);    /* base address of table */
X			while (*ws != NULL)
X			{
X				THEmenu[idx]->NumItems++;
X				THEmenu[idx]->items[THEmenu[idx]->NumItems] = ws ;
X				if (strlen(ws) > THEmenu[idx]->width)
X					THEmenu[idx]->width = strlen(ws);
X				ws += wssize ;
X			}
X		}
X		else		/* this is basically dup code as above */
X		{
X			wws = va_arg (ap, char **);  /* base address of table */
X			while (*wws != NULL)
X			{
X				THEmenu[idx]->NumItems++;
X				THEmenu[idx]->items[THEmenu[idx]->NumItems] = *wws ;
X				if (strlen(*wws) > THEmenu[idx]->width)
X					THEmenu[idx]->width = strlen(*wws);
X				wws++ ;
X			}
X		}
X		/*
X		 * adjust length of popmenu
X		 */
X		if (THEmenu[idx]->winSize <= 0)		/* default length */
X			THEmenu[idx]->winSize = 6;
X		/* not enough items? */
X		if (THEmenu[idx]->winSize > THEmenu[idx]->NumItems+1 ) 
X			THEmenu[idx]->winSize = THEmenu[idx]->NumItems + 1 ;
X		/* roll off bottom of screen? */
X		if ( THEmenu[idx]->winSize > LINES-THEmenu[idx]->row-2 ) 
X			THEmenu[idx]->winSize = LINES - THEmenu[idx]->row - 2 ;
X
X		/*
X		 * adjust the starting col of popmenu if the menu
X		 * will roll off the right edge of screen
X		 *      NOTE: col is 0 offset while width is not
X		 */
X		if ( THEmenu[idx]->col > COLS-THEmenu[idx]->width-4 )
X			THEmenu[idx]->col = COLS - THEmenu[idx]->width - 4 ;
X
X		va_end (ap);
X		THEmenu[idx]->ActiveItem = 1;
X
X		THEmenu[idx]->win = newwin (THEmenu[idx]->winSize+2, 
X				THEmenu[idx]->width+4,
X			        THEmenu[idx]->row, THEmenu[idx]->col);
X
X		keypad (THEmenu[idx]->win, TRUE);
X		rc = 0;			/* 0 return code */
X		break;
X
X	   case DIMWINDOW:
X		MenuId = va_arg (ap, int);
X		va_end (ap);
X
X		for (i = 0; i <= midx; i++)
X			if (THEmenu[i]->MenuId == MenuId)
X			{
X				drawbox( THEmenu[i]->win, 1, 1,
X					 THEmenu[i]->winSize+2,
X					 THEmenu[i]->width+4,
X					SingleLine, DumbLine,
X					(THEmenu[i]->winSize >= 4  &&
X					    THEmenu[i]->NumItems+1 >
X						THEmenu[i]->winSize),
X					(THEmenu[i]->helpfile !=
X						(char *)NULL) ) ;
X				mvwprintw (THEmenu[i]->win, 0, 
X					((THEmenu[i]->width+4-
X						strlen(THEmenu[i]->title))/2),
X				    	"%s", THEmenu[i]->title);
X				wrefresh (THEmenu[i]->win);
X				break;
X			}
X		break;
X
X	   default:
X		/*
X		**  Lets try to run a menu
X		*/
X		va_end (ap);
X		MenuId = action;
X
X		/* Find the menu. */
X		for (i = 0; i <= midx; i++)
X			if (MenuId == THEmenu[i]->MenuId)
X				break;
X		if (i > midx)   return (-1);		/* invalid MenuId */
X		rc = _runMenu (THEmenu[i]);
X		break;
X	} /* end switch (action) */
X	return (rc);
X}
X
X
X
X_runMenu (menu)
X
X	MENU	*menu;
X{
X	register int	ch;
X	register int	fptr;			/* field pointer */
X	register int	i;
X	register int	top;
X	register int	inc;
X
X	putp ( cursor_invisible ) ;
X	inc = (int)( menu->winSize / 2 ) ;	/* window increment */
X	fptr = menu->ActiveItem;		/* set current item */
X	top = fptr - menu->winSize + 1 ;	/* set top item of window */
X	if ( top < 1 ) top = 1 ;		/* out of bound? */
X
X	/*
X	**	Display the menu.
X	*/
X	for (i=0; i < menu->winSize && top+i-1 < menu->NumItems+1; i++)
X		mvwprintw (menu->win, i+1, 2, "%s", menu->items[top+i-1]);
X	drawbox( menu->win, 1, 1, menu->winSize+2, menu->width+4,
X			StandoutLine, StandoutLine,
X			(menu->winSize >= 4  &&
X				menu->NumItems+1 > menu->winSize),
X			(menu->helpfile != (char *)NULL) ) ;
X
X	/* display title */
X	wattrset (menu->win, A_STANDOUT);
X	mvwprintw (menu->win, 0, ((menu->width+4)/2)-(strlen(menu->title)/2), 
X		"%s", menu->title);
X	wattrset (menu->win, A_NORMAL);
X
X	while (1)
X	{
X		wattrset (menu->win, A_REVERSE);
X		mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
X		wattrset (menu->win, A_NORMAL);
X		wmove( menu->win, menu->winSize+1, menu->width+3 ) ;
X		touchwin (menu->win);
X		wrefresh (menu->win);
X
X		ch = wgetch (menu->win);
X		mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
X
X		if (ch == KeyReturn)   	ch = KEY_RETURN;
X		if (ch == KeyDown)   	ch = KEY_DOWN;
X		if (ch == KeyUp)   	ch = KEY_UP;
X		if (ch == KeyHelp)   	ch = KEY_HELP;
X		if (ch == KeyCancel)	ch = KEY_CANCEL;
X		if (ch == KeyRedraw)	ch = KEY_REFRESH;
X
X		if ( ch >= 'a' && ch <= 'z' )
X			ch = toupper( ch ) ;	/* deals in upper case only */
SHAR_EOF
echo "End of part 9"
echo "File utilities.d/libgeti.d/popmenu.c is continued in part 10"
echo "10" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 10 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/popmenu.c continued
#
CurArch=10
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/popmenu.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/popmenu.c
X		switch ( ch )
X		{
X		   case KEY_DOWN:
X		   case KEY_RIGHT:
X			fptr = (fptr >= menu->NumItems+1) ? 1 : ++fptr;
X
X			/* stroll off window? */
X			if ( fptr-top+1 > menu->winSize || fptr == 1 )
X			{
X				if ( fptr == 1 )
X					top = 1 ;
X				else
X					top += inc ;
X				_showWin( menu, top ) ;
X			}
X			break;
X
X		   case KEY_UP:
X		   case KEY_LEFT:
X			wrefresh( menu->win ) ;
X			fptr = (fptr <= 1) ? menu->NumItems+1 : --fptr;
X
X			/* stroll off window? */
X			if ( fptr == menu->NumItems+1 || fptr < top )
X			{
X				if ( fptr == menu->NumItems+1 && inc > 0 )
X					top = menu->NumItems - menu->winSize + 2 ;
X				else
X					top -= inc ;
X				if ( top < 1 ) top = 1 ;
X				_showWin( menu, top ) ;
X			}
X			break;
X
X		   case '0':
X		   case '1':
X		   case '2':
X		   case '3':
X		   case '4':
X		   case '5':
X		   case '6':
X		   case '7':
X		   case '8':
X		   case '9':
X		   case 'A':
X		   case 'B':
X		   case 'C':
X		   case 'D':
X		   case 'E':
X		   case 'F':
X		   case 'G':
X		   case 'H':
X		   case 'I':
X		   case 'J':
X		   case 'K':
X		   case 'L':
X		   case 'M':
X		   case 'N':
X		   case 'O':
X		   case 'P':
X		   case 'Q':
X		   case 'R':
X		   case 'S':
X		   case 'T':
X		   case 'U':
X		   case 'V':
X		   case 'W':
X		   case 'X':
X		   case 'Y':
X		   case 'Z':
X			wrefresh( menu->win ) ;
X			/* look for first char match from here on down */
X			for ( i=fptr+1; i<=menu->NumItems+1 &&
X				toupper(*menu->items[i-1])!=ch; i++ ) ; 
X
X			/* no match?  how about from here on up? */
X			if ( i > menu->NumItems+1 )
X				for ( i=1; i<fptr &&
X					toupper(*menu->items[i-1])!=ch; i++ ) ;
X
X			fptr = i ;	/* i would still be fptr if both failed */
X
X			/* need to display a different window? */
X			if ( fptr >= top+menu->winSize || fptr < top )
X			{
X				top = fptr ;
X				_showWin( menu, top ) ;
X			}
X			break ;
X
X		   case KEY_RETURN:
X		   case KEY_ENTER:
X			menu->ActiveItem = fptr;
X			wrefresh (menu->win);	/* force flush of attributes */
X			putp ( cursor_visible ) ;
X			return (menu->ActiveItem);
X
X		   case KEY_CANCEL:
X			putp ( cursor_visible ) ;
X			return (-1);
X
X		   case KEY_HELP:
X			ShowHelp (menu->helpfile, "popmenu", LINES);
X			break;
X
X		   case KEY_REFRESH:
X			clearok (menu->win, TRUE);
X			wrefresh (menu->win);
X			break;
X
X		   default:
X			break;
X		}  /* end switch (ch) */
X	}
X}
X
X/* pjc 7/87 */
X
X_showWin( menu, top )
X	MENU	*menu ;
X	int	top ;
X{
X	register int	i ;
X
X	for (i=0; i < menu->winSize && top+i-1 < menu->NumItems+1; i++)
X		mvwprintw (menu->win, i+1, 2, "%-*s", menu->width, menu->items[top+i-1]);
X	for (; i < menu->winSize ; i++)
X		mvwprintw (menu->win, i+1, 2, "%*s", menu->width, " ");
X}
SHAR_EOF
echo "File utilities.d/libgeti.d/popmenu.c is complete"
chmod 0644 utilities.d/libgeti.d/popmenu.c || echo "restore of utilities.d/libgeti.d/popmenu.c fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.h &&
X#ifndef LINT
Xstatic char ID_GetInput[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*
X**	Type of allowable characters
X*/
X
X#define	ALPHANUM	' '
X#define	ALPHA		'A'
X#define	NUMERIC		'9'
X#define	SET		'E'
X#define	MENU		'M'
X#define	UPPER		'U'
X#define	UPPER_AN	'V'
X#define	HEX		'H'
X#define	STATE		'S'
X#define	ZIP		'Z'
X#define	DATE		'D'
X#define	TIME		'T'
X#define	PROTECT		'P'
X
X/*
X**	Adjust/Fill
X*/
X
X#define	NOFILL		' '
X#define	RTADJ_ZFILL	'Z'
X#define	RTADJ_BFILL	'B'
X#define	LFADJ_ZFILL	'z'
X#define	LFADJ_BFILL	'b'
X
X/*
X**	'C' field types
X*/
X
X#define CHAR		'0'
X#define INT		'1'
X#define SHORT		'2'
X#define LONG		'3'
X#define DOUBLE		'4'
X#define MONEY		'M'
X#define FLOAT		'5'
X
X/*
X**	Union to take care of a field that could be any valid
X**		'c' field type.
X*/
X
Xtypedef union FldUnion {
X	long	*longVal ;
X	double	*doubleVal ;
X	float	*floatVal ;
X	int	*intVal ;
X	short	*shortVal ;
X	char	*strVal ;
X} *FldUnPointer ;
X
X
X#define AUTONEXT	TRUE
X#define NOAUTO		FALSE
X
X#define MUSTENTER	TRUE
X#define NOMUST		FALSE
X
X#define NOHELP		""
X#define NORANGE		NULL
X#define NOMSG		NULL
X#define NOMASK		NULL
X#define NOTAG		""
X#define	A_SAME		-1		/* same as what's on the screen */
X
X
X#ifndef KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_BEG
X#   define KEY_BEG	0542
X#endif
X#ifndef KEY_END
X#   define KEY_END	0550
X#endif
X#ifndef	KEY_SAVE
X#   define KEY_SAVE	0571
X#endif
X#ifndef	KEY_PRINT
X#   define KEY_PRINT 	0532
X#endif
X#ifndef	KEY_HELP
X#   define KEY_HELP 	0553
X#endif
X#ifndef	KEY_REFRESH
X#   define KEY_REFRESH 	0565
X#endif
X#ifndef	KEY_TAB
X#   define KEY_TAB 	'\t'
X#endif
X#ifndef	KEY_BTAB
X#   define KEY_BTAB 	0541
X#endif
X#ifndef	KEY_CANCEL
X#   define KEY_CANCEL 	0543
X#endif
X#ifndef	KEY_ACCEPT
X#   define KEY_ACCEPT 	1000
X#endif
X#ifndef	KEY_TOC
X#   define KEY_TOC 	1001
X#endif
X
X#define NOKEY		'\0'
X#define KEY_CTLA	'\001'
X#define KEY_CTLB	'\002'
X#define KEY_CTLC	'\003'
X#define KEY_CTLD	'\004'
X#define KEY_CTLE	'\005'
X#define KEY_CTLF	'\006'
X#define KEY_CTLG	'\007'
X#define KEY_CTLH	'\010'
X#define KEY_CTLI	'\011'
X#define KEY_CTLJ	'\012'
X#define KEY_CTLK	'\013'
X#define KEY_CTLL	'\014'
X#define KEY_CTLM	'\015'
X#define KEY_CTLN	'\016'
X#define KEY_CTLO	'\017'
X#define KEY_CTLP	'\020'
X#define KEY_CTLQ	'\021'
X#define KEY_CTLR	'\022'
X#define KEY_CTLS	'\023'
X#define KEY_CTLT	'\024'
X#define KEY_CTLU	'\025'
X#define KEY_CTLV	'\026'
X#define KEY_CTLW	'\027'
X#define KEY_CTLX	'\030'
X#define KEY_CTLY	'\031'
X#define KEY_CTLZ	'\032'
X
X/*
X**  Macros
X*/
X#define wattrOn(a, b)	wattrset(a, b)
X#define wattrOff(a)	wattrset(a, 0)
X#ifndef BELL
X#define	BELL	printf ("%c", 7)
X#endif
X
X#define	CLEARROW(row)	{ \
X				int	col; \
X				int	tmprow; \
X				tmprow = ((row%100) == row) ? row : row/100; \
X				col = ((row%100) == row) ? 0 : row%100; \
X				for (; col<=COLS-2; col++) \
X					mvwaddch (stdscr, tmprow,col, ' '); \
X			}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/GetInput.h || echo "restore of utilities.d/libgeti.d/GetInput.h fails"
echo "x - extracting utilities.d/libgeti.d/keys.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/keys.h &&
X#ifndef LINT
Xstatic char ID_keys[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
Xextern int	KeyReturn;
Xextern int  	KeyDown;
Xextern int  	KeyUp;
Xextern int  	KeyTab;
Xextern int  	KeyBTab;
Xextern int  	KeyAccept;
X
Xextern int  	KeyBeg;
Xextern int  	KeyEnd;
Xextern int  	KeyRight;
Xextern int  	KeyLeft;
Xextern int  	KeyBackspace;
Xextern int  	KeyEOL;
Xextern int  	KeyDL;
Xextern int  	KeyDC;
Xextern int  	KeyIC;
X
Xextern int  	KeyHelp;
Xextern int  	KeyTOC;
Xextern int  	KeyRedraw;
Xextern int  	KeySave;
Xextern int  	KeyPrint;
Xextern int  	KeyCancel;
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/keys.h || echo "restore of utilities.d/libgeti.d/keys.h fails"
echo "x - extracting utilities.d/libgeti.d/makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/makefile &&
X# %W%   DeltaDate %G%   ExtrDate %H%
X
XTITLE = GETINPUT
X
XINSTALLLIB 	= 
XINSTALLHDR	=
XMANDIR 		= .
X
X#CC = cc
X
X###  CFLAG settings
X
X###  Sys5
XCFLAGS = -O
X###  Xenix
X#CFLAGS = -O -DM_TERMINFO -LARGE -Ml -Mlt34 -F 4000
X
XARFLAGS = rv
X
XLIBS = libgeti.a -lcurses -lc
X
X
XCFILES = AdjField.c DateFun.c DisPrmpt.c FindSet.c GetSetLen.c \
X	GetInput.c IsDate.c IsFldOk.c IsMask.c IsRange.c IsState.c IsTime.c \
X	ReDispFld.c ScrnOut.c ShowChar.c ShowSet.c ShowHelp.c \
X	popmenu.c BuildMenu.c checkmask.c doinsert.c InitGetI.c drawbox.c \
X	RingMenu.c
X
XHFILES = GetInput.h keys.h
XMANPAGES = GetInput.3X popmenu.3 drawbox.3 ShowHelp.3
X
XOBJECTS =${CFILES:.c=.o}
X
Xinstall : libgeti.a
X	-ln libgeti.a ../../libgeti.a
X	-ln GetInput.h ../../GetInput.h
X
Xtest : libgeti.a _Main.o
X	$(CC) $(CFLAGS) _Main.o $(LIBS) -o test.out
X
Xlibgeti.a : $(OBJECTS)
X	ar $(ARFLAGS) libgeti.a $?
X
Xlint:
X	lint -I$(INCDIR) _Main.c $(CFILES) -lcurses > lint.out
X
Xprint :
X	PrintPrg $(MANPAGES) makefile $(CFILES) $(HFILES) _Main.c | lp -t$(TITLE)
X
Xshar:
X	shar -b GetInput.hlp $(MANPAGES) makefile $(CFILES) $(HFILES) _Main.c > libgeti.shar
X
Xclean :
X	rm -f *.o core libgeti.a test.out lint.out libgeti.shar \
X	../../libgeti.a ../../GetInput.h libgeti.shar.Z
X
X#####
X#####
X
X_Main.o:	_Main.c GetInput.h keys.h
XAdjField.o:	AdjField.c GetInput.h
XDisPrmpt.o:	DisPrmpt.c GetInput.h
XFindSet.o:	FindSet.c GetInput.h
XGetSetLen.o:	GetSetLen.c GetInput.h
XGetInput.o:	GetInput.c GetInput.h keys.h
XIsDate.o:	IsDate.c GetInput.h
XIsFldOk.o:	IsFldOk.c GetInput.h
XIsMask.o:	IsMask.c GetInput.h
XIsRange.o:	IsRange.c GetInput.h
XIsTime.o:	IsTime.c GetInput.h
XReDispFld.o:	ReDispFld.c GetInput.h
XScrnOut.o:	ScrnOut.c GetInput.h
XShowChar.o:	ShowChar.c GetInput.h
XShowSet.o:	ShowSet.c GetInput.h
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/makefile || echo "restore of utilities.d/libgeti.d/makefile fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.3X (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.3X &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.TH GETINPUT 3X "libgeti"
X.SH NAME
XGetInput \- manages terminal input using curses
X.SH SYNOPSIS
X.LP
X.nf
X#include <curses.h>
X#include "GetInput.h"
X
Xint GetInput (win, row, col, &Fld, FldAttribute, FldMask,
X              FldRange, FldLength, FldMin, FldCharType, 
X              FldAdjust, FldType, FldExit, MustEnter, 
X              ErrRow, MsgRow, PromptMsg, HelpFile, HelpTag)
X
XWINDOW        *win;
Xint           row, col, FldAttrbute, FldLength, FldMin, 
X              FldExit, MustEnter, ErrRow, MsgRow;
XFldUnPointer  Fld;
Xchar          *FldMask, *FldRange, FldCharType, FldAdjust, 
X              FldType, *PromptMsg, HelpFile[], HelpTag[];
X.fi
X.SH DESCRIPTION
XGets terminal input using curses(3X). 
XGetInput uses a field by field approach.  All
Xedits and processing are performed for that field as the user
Xmoves from field to field.  It is not a fill form methodology where
Xall edits and processing are performed after the user has inputed
Xa number of fields in a form.
X
X.SH GETTING STARTED
XYou need to include GetInput.h in your program.
X
XCurses tty modes should be - cbreak(), noecho(), nonl() and
Xkeypad () if you want to use arrow keys and the like.
X
XYou should trap and ignore SIGALRM (see BUGS).
X
X.SS Defining Keyboard Keys
XGetInput uses a number of keyboard keys to tell it what to do.
XA default value to the various keys is automatically assigned when you use
Xthis library.  Those default values may be changed by declaring the variable
Xas extern in your program and assigning a new value.
XIn addition to the default variable values, if the terminal
Xhas an associated curses key defined (see curses.h) that key may also be used.
XFor example, ^b (KeyBeg) is the default value to place cursor at beginning 
Xof a field but if there is a key defined for KEY_BEG, in curses, then that
Xkey may also be used.  If the value of KeyBeg and KEY_BEG are different, 
XGetInput will return the value of KEY_BEG not KeyBeg regardless of which 
Xone is pressed.
XNot all keys may have an associated curses key.
XThe "^" indicates press and hold the control key.  A negative one disables
Xthe key, although the associated curses key is still active.
X.br
XBelow is listed the InitGetI() function with the default value and the
Xassociated curses key.
X.nf
X
X/*
X**  InitGetI()
X**	All this does is define some global variables for the keys
X**	used in GetInput(3) and assign some default values.
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X
X				/* ACCEPT INPUT KEYS */
X				/* These are the only keys that will return the data inputted into your variable. */
Xint	KeyReturn = '\\r';		/* ^m  KEY_RETURN */
Xint	KeyDown = 10;		/* ^j  KEY_DOWN */
Xint	KeyUp = 11;		/* ^k  KEY_UP */
Xint	KeyTab = '\\t';		/* ^i  KEY_TAB */
Xint	KeyBTab = -1;		/*     KEY_BTAB */
Xint	KeyAccept = 1;		/* ^a  KEY_ACCEPT - Typically this is the key the user presses
X				             to signify he/she is finished with this screen. */
X
X				/* FIELD EDITING KEYS */
Xint	KeyBeg = 2;		/* ^b  KEY_BEG - Place cursor at beginning of field */
Xint	KeyEnd = 5;		/* ^e  KEY_END - Place cursor at end of input in field */
Xint  	KeyRight = 12;		/* ^l  KEY_RIGHT - Forward space in field */
Xint  	KeyLeft = 8;		/* ^h  KEY_LEFT - Backspace in field (non-destructive) */
Xint  	KeyBackspace = '\\b';	/* \\b  KEY_BACKSPACE - Same as KEY_LEFT */
Xint  	KeyEOL = 4;		/* ^d  KEY_EOL - Delete from cursor to end of field */
Xint  	KeyDL = 3;		/* ^c  KEY_DL - Clear field and home cursor */
Xint  	KeyDC = 24;		/* ^x  KEY_DC - Delete a character */
Xint  	KeyIC = 20;		/* ^t  KEY_IC - Toggle between type-over and insert mode */
X
X				/* OTHER KEYS */
Xint  	KeyRedraw = 18;		/* ^r  KEY_REFRESH - Redraw screen */
Xint  	KeySave = 6;		/* ^f  KEY_SAVE - Save screen to a file */
Xint  	KeyPrint = 16;		/* ^p  KEY_PRINT - Print screen to lp */
Xint  	KeyCancel = 27;		/* esc KEY_CANCEL - Cancel pop-up menu selection */
Xint  	KeyHelp = '?';		/*     KEY_HELP - Display help screen */
X				/*        If the user needs to input a "?" you will have to change this. */
Xint  	KeyTOC = 20;		/* ^t  KEY_TOC  - When in help display Table of Contents */
X
Xvoid
XInitGetI()
X{
X	/* i don't do nuthin */
X}
X.fi
X
X.SH ARGUMENT DESCRIPTION
X.TP 6
X*win
XA pointer to a curses window that this routine will operate under.
X.TP 
Xrow
XThe row to position cursor on.
X.TP 
Xcol
XThe starting column for field.
X.TP
X&Fld		
XA pointer to a union variable where you have loaded the
Xaddress of your memory variable to accept the input data.  Upon
Xentry to GetInput the value in your memory variable will be
Xdisplayed as the default value.  The type of union you select must be compatible
Xwith the \fIFldType\fP you've specified.
X
X.nf
XFor example:
X	union FldUnion	Fld;
X	double		myvar;
X
X	Fld.doubleVal = &myvar;
X	GetInput (......);
X
X	/*
X	**  After returning from GetInput() what the user typed in will
X	**  be in \fImyvar\fP;
X	*/
X
X
X
X/*
X**     Structure of Union
X*/
Xtypedef union FldUnion
X{
X	long    *longVal;
X	double  *doubleVal;
X	float   *floatVal;
X	int     *intVal;
X	short   *shortVal;
X	char    *strVal;
X} *FldUnPointer;
X.fi
X.TP
XFldAttrbute	
XCurses attribute you want your input field to be.  For
Xexample A_REVERSE.  Refer to curses(3X) for further
Xinformation on allowable terminal attributes.
X.br
XA_SAME  is a special attribute that tells GetInput to use
Xthe same attributes that is already on the screen in the
Xfirst column of the field.
X
X. \ **********************************
X.TP
XFldMask
XA char pointer to a mask for the field.  This permits the user to mix 
Xalpha with numeric while letting GetInput do the edit checking.  You can also
Xuse this to format a field.
X
XThe keyword \fBNOMASK\fP may be placed here if no mask is required.
X
XValid masks for a field depend upon the type of field
Xyou specify, see \fIFldCharType\fP.
X
XThe \fIFldLength\fP should not include character positions where no input
Xis allowed in the mask (format characters), because format characters
Xare not returned into \fIFld\fP.  For example, \fIFldCharType = DATE,
XFldMask = "MM/DD/YY"\fP.  The "/" is a format character.  The cursor
Xwill skip over those positions in the field.  Only the characters typed in
Xthe MM DD YY positions will be in your memory variable \fIFld\fP.
XThe FldLength would be six for this case.
X
XBecause the mask is so closely tied to the \fIFldCharType\fP, a complete
Xdescription of what mask characters are valid with what field types is 
Xdescribed under
X\fIFldCharType\fP.  Any character in the mask that is not listed as a valid
Xmask character for that field type becomes a format character.
X. \ **********************************
X.TP
XFldRange
XA char pointer to a set of valid ranges permitted for this field. 
XRanges may be specified as comma separated values ("ONE,TWO,THREE") 
Xor as a range ("1-5"), or a combination of both ("1-5,M,E").
XRange values must be compatible with the \fIFldCharType\fP and \fIFldType\fP 
Xthat you 
Xhave selected.
X.br
XSome examples:
X.nf
X	"1-10"
X	"5,10,15,16"
X	"1-10,20,M,E,32-40"
X	"CA,TX,ID"
X.fi
X
XThe keyword \fBNORANGE\fP may be used if no range checking is to be 
Xperformed for this field.
X. \ **********************************
X.TP
XFldLength
XMaximum length of this field.  For field types (FldCharTypes) SET and MENU 
Xthe field length is automatically set to the longest set value in the FldRange.
X. \ **********************************
X.TP
XFldMin
XIf \fIMUSTENTER\fP is selected in \fIFldExit\fP then this is the minimum
Xrequired input.  Otherwise, it is the minimum required input only if they try 
Xto input something.
X. \ **********************************
X.TP
XFldCharType
XThis argument defines edit checks to be performed on the
Xinput characters as they are being typed in.  If no mask is provided then
Xthe field type itself determines the edit checks to be performed on all
Xcharacters in the field.
X.RS 6
X.TP 11
XALPHANUM
XAny alpha/numeric character is allowed.
X.br
XValid mask characters:
X.nf
X	space	alpha/numeric
X	A	alpha
X	9	numeric
X	U	upper alpha
X	V	upper alpha/numeric
X	H	???
X.fi
X.TP
XALPHA
XAlpha only.
X.br
XValid mask characters:
X.nf
X	A	alpha
X.fi
X.TP
XNUMERIC
XNumeric only.
X.br
XValid mask characters:
X.nf
X	9	numeric
X.fi
X.TP
XUPPER
XConvert to upper case.  Only alpha permitted.
X.br
XValid mask characters:
X.nf
X	U	upper alpha
X.fi
X.TP
XUPPER_AN
XAlpha and numeric permitted.  Convert alpha characters to upper-case.
X.br
XValid mask characters:
X.nf
X	V	upper alpha/numeric
X.fi
X.TP
XHEX
XOnly hex characters permitted.
X.br
XValid mask characters:
X.nf
X	H	???
X	space	???
X.fi
X.TP
XSTATE
XValid two character Post Office abbreviations for the fifty states.
XA edit check is done for a valid state.
X.br
XValid mask characters:
X.nf
X	SS	two character state
X	S	???
X	space	???
X.fi
X.TP
XZIP
XPost Office zip code.
X.br
XValid mask characters:
X.nf
X	99999-9999	???
X.fi
X.TP
XDATE
XA valid date.
X.br
XValid mask characters:
X.nf
X	MM	month  (01-12)
X	DD	day  (01-31)
X	YY	year  (00-99)
X	YYYY	full year with century
X.fi
XThe mask must contain at least MM and DD.  If no mask is specified for the
Xfield a default mask of "MMDDYY" is used.
X.br
XSome examples:
X.nf
X	MMDDYY
X	MM/DD/YY
X	YY-MM-DD
X	MM  DD  YYYY
X.fi
X.TP
XTIME
XA time field.
X.br
XValid mask characters:
X.nf
X	HH	hours  (01-12)
X	MM	minutes  (00-59)
X	SS	seconds  (00-59)
X	TT	tenths  (00-99)
X	II	military hours  (00-24)
X.fi
XSome examples:
X.nf
X	HH:MM
X	HH:MM:SS
X	HH:MM:SS:TT
X	II:MM
X	II:MM:SS
X	II:MM:SS:TT
X.fi
X.TP
XSET
XThis field type specifies a set of values that are acceptable in the input 
Xfield.
XThe acceptable values within the set are specified in the \fIFldRange\fP 
Xargument.  
XThe user selects one of the set values specified in the field range by
Xpressing the space bar, which will toggle through the set values,
Xor by pressing the first character in the desired value.
X
XThe format of the FldRange can only be comma separated values 
X(ex. "CA,ID,TX").  
XRange values, such as "1-5", don't work.  You would have to say "1,2,3,4,5".
X.br
XThe FldLength is automatically set to the longest set value in the FldRange.
X.TP
XMENU
XThis field type is similar to the SET type.  The difference is when the user
Xattempts to type something in the field a pop-up menu of available choices
Xare displyed, as specified in field_range.  
XThe user makes a selection by hi-lighting the choice and pressing return.
X.br
XSee SET type for specifying the FldRange.
XThe limit is ten items in the FldRange.
X.TP
XPROTECT
XThis X's out the field so what is typed on the keyboard can not be seen on
Xthe screen.  Useful for password entry.
X.RE
X. \ ---------------------------------
X.TP
XFldAdjust
XIndicates whether to adjust the text right or left within the field
Xand whether or not to zero or blank fill the field.
X.RS 6
X.TP 15
XNOFILL
Xno action.
X.TP
XRTADJ_ZFILL
Xright adjust, zero fill
X.TP
XRTADJ_BFILL
Xright adjust, blank fill
X.TP
XLFADJ_ZFILL
Xleft adjust, zero fill
X.TP
XLFADJ_BFILL
Xleft adjust, blank fill
X.RE
X. \ ---------------------------------
X.TP 6
XFldType
XThis argument describes the memory variable that is to hold
Xthe input data.  The address that you loaded into "&Fld".
X.RS 6
X.TP 10
XCHAR
Xcharacter field
X.TP
XINT
Xinteger
X.TP
XSHORT
Xshort integer
X.TP
XLONG
Xlong integer
X.TP
XDOUBLE
Xdouble
X.TP
XFLOAT
Xfloating point
X.TP
XMONEY
Xdouble which accepts only two decimal positions.
X.RE
X. \ ---------------------------------
X.TP 11
XFldExit
X.RS 6
X.TP 10
XAUTONEXT
XGetInput() will exit, with the value of KEY_RETURN, when the last character 
Xin the field is keyed in.
X.TP
XNOAUTO
XWill not exit field until a accept key (see defining keyboard keys) is pressed.
X.RE
X. \ ---------------------------------
X.TP
XMustEnter
X.RS 6
X.TP 12
XMUSTENTER
XThis is a must enter field and the value of FldMin must be
Xentered before exiting field.
X.TP
XNOMUST
XNot a must enter field.
X.RE
X. \ ---------------------------------
X.RE
X.TP 6
XErrRow
XIndicates what row/column to display an error message if one occurs.
XThe row specified is for stdscr.
XIf a optional column is to be specified on where to start the message, the
Xformat would be for example 2302 where 23 is the row and 02 is the column.
XOtherwise, a default of column zero is used.
XGetInput will do a clrtoeol() before displaying the error message, therefore,
Xthe entire row must be given over to GetInput.
XIf this row is outside the boundary of the window unpredictable results will
Xoccur, for example, winch() will return garbage.
X.TP
XMsgRow
XIndicates what row to display help messages.
XThe row specified is for stdscr.
XIf a optional column is to be specified on where to start the message, the
Xformat would be for example 2202 where 22 is the row and 02 is the column.
XOtherwise, a default of column zero is used.
XGetInput will do a clrtoeol() before displaying the message, therefore,
Xthe entire row must be given over to GetInput.
XIf this row is outside the boundary of the window unpredictable results will
Xoccur, for example, winch() will return garbage.
X.RS 6
X.TP 10
XNULL
XNo active message line.  Only if PromptMsg == NOMSG.
X.RE
X.TP
X*PromptMsg
XPrompt message to be displayed.  The prompt message is always displayed
Xto stdscr, regardless of the win specified.
X.RS 6
X.TP 10
XNOMSG
XNo message to be displayed.
X.RE
X.TP
XHelpFile
XFile name containing on-line help messages.  Current directory
Xis searched first for helpfile and then getenv("HELPDIR") directory is
Xsearched.
X.RS 6
X.TP 10
XNOHELP
XNo help file is available for this field.
X
X.PP
XThe default helpfile (GetInput.hlp) is shown below.  Where this file is
Xinstalled will vary from machine to machine.
X
X.nf
X\fBGETINPUT\fP
X .TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X        KEY_DOWN  (^j)      Traverse forwards through the fields.
X        KEY_UP  (^k)        Traverse backwards through the fields.
X        KEY_TAB  (^i)       Fast forward through the fields.
X        KEY_BTAB            Fast reverse through the fields.
XField Editing Keys:
X        KEY_BEG  (^b)       Place cursor at beginning of field.
X        KEY_END  (^e)       Place cursor at end of input in field.
X        KEY_RIGHT  (^l)     Forward space within the field.
X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
X        KEY_EOL  (^d)       Delete from cursor to end of field.
X        KEY_DL  (^c)        Clear field and home cursor.
X        KEY_DC  (^x)        Delete a character.
X        KEY_IC  (^t)        Toggle between type-over and insert mode.
XOther Keys:
X        KEY_HELP  (?)       Display help screen.
X        KEY_REFRESH  (^r)   Redraw the screen.
X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
X        KEY_SAVE  (^f)      Save screen to a file.
X        KEY_PRINT  (^p)     Print screen to lp.
X\fBGETINPUT\fP
X
X
X
X\fBpopmenu\fP
X.TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    To select an option press the "up arrow key",
X    "k", "down arrow key", "j" to place bar on
X    option and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
X\fBpopmenu\fP
X
X
X
X\fBhelp\fP
X.TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
X        KEY_TOC  (^t)       Display table of contents.
X\fBhelp\fP
X.fi
X.RE
X.TP
XHelpTag
XTag in help file where messages are to be found.  The tag 
Xsurrounds the help message.  For example:
X.nf
X
Xhelptag
X[ .TITLE  Title line goes here. ]
XI put any help message for the user between the tags.  
XIt can be any length as it will be displayed one screen 
Xat a time.
XThe following screen attributes may be used:
X\\S  =  Standout
X\\B  =  Bold
X\\U  =  Underline
X\\D  =  Dim
X\\R  =  Reverse video
X\\L  =  Blink
X\\N  =  Normal (reset)
X
X\\BThis text is in bold face.  \\NBack in normal mode.
Xhelptag
X
XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
Xis to be contained in the table of contents menu.  The following is the
Xsyntax for this tagname.
XTABLE_OF_CONTENTS
Xhelpfile   tagname   description
XTABLE_OF_CONTENTS
X.fi
X.RS 6
X.TP 10
XNOTAG
XNo tag.  Should only be used if (HelpFile == NOHELP).
X.RE
X.SH EXAMPLE
X.nf
X#include <curses.h>
X#include "GetInput.h"
X
Xmain ()
X{
X	union FldUnion Fld;
X	char	name[20], tempstring[50];
X	int	exitcode;
X
X   initscr ();
X   cbreak ();
X   noecho ();
X   nonl ();
X   keypad (stdscr, TRUE);
X
X   name[0] = '\\0';
X   Fld.strVal = name;
X   exitcode = GetInput (stdscr, 2, 0, &Fld, A_REVERSE, NOMASK, 
X                  NORANGE, 20, 0, UPPER_AN, NOFILL, CHAR, 
X                  NOAUTO, MUSTENTER, 21, 20, 
X                  "Please enter your name.", NOHELP, NOTAG);
X
X   Fld.strVal = tempstring;
X   exitcode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "HH:MM:SS:TT",
X                  NORANGE, 6, 6, TIME, NOFILL, CHAR, AUTONEXT, 
X                  NOMUST, 20, 21, "Time Field HH:MM:SS:TT", 
X                  "myhelpfile", "field2");
X
X   Fld.strVal = tempstring;
X   exitcode = GetInput (stdscr, 8, 0, &Fld, A_NORMAL, 
X                  "(999) 999-9999", NORANGE, 10, 5, NUMERIC, 
X                  RTADJ_ZFILL, CHAR, NOAUTO, MUSTENTER, 20, NULL, 
X                  NOMSG, NOHELP, NOTAG);
X
X   Fld.strVal = tempstring;
X   exitcode = GetInput (stdscr, 9, 1, &Fld, A_REVERSE, NOMASK,
X                  "CA, NV, ID", 2, 2, SET, NOFILL, CHAR, NOAUTO,
X                  NOMUST, 20, 20, "Select your state.", NOHELP, 
X                  NOTAG);
X   endwin ();
X}
X.fi
X.SH AUTHOR
XIrving Griesman  (original author)
X.br
XEnhanced & Maintained by Paul J. Condie
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
X.SH FILES
XGetInput.hlp	- default GetInput help file.
X
X.SH DIAGNOSTICS
XGetInput returns the the decimal value of the key pressed from the getch()
Xfunction.  If the key pressed has an associated curses key GetInput returns
Xthe value of the curses key.  See Defining keyboard keys.
X
X.SH SEE ALSO
Xcurses(3X), popmenu(3).
X
X.SH WARNING
XPutting a field on the same row as your message row or error row may cause
Xunpredictable results.  This is not recommended.
X
X.SH BUGS
XThere is a bug in curses when you call getch() which this routine does.
XWhen in keypad() mode and an ESC character is read, curses 
Xdoes a timed read (1 second) waiting for other characters to appear.  if
Xsome other characters are received within the one second time interval,
Xcurses attempts to match the received string with a caps string defined for the terminal (i.e. ESC[A, ESC[B are arrow keys for a vt100 type terminal)
Xand then returns a #defined int value which can be tested for easily.
XIn some cases untrapped alarm calls occur.  The solution is to trap (ignore)
Xalarm calls.
X.PP
XOn a mustenter field with a fldmin specified a control key (i.e. KEY_DOWN, etc.)
Xwill exit the
Xfield if that is the first key the user presses.  Once the user has tried
Xto input a value in the field even if he clears the field the control key
Xwill not exit until fldmin is inputed.
X
X.nf
XThe following example does not turn the reverse video off when you leave the field on the sun.
Xrc = GetInput (stdscr, 0, 1, &Fld, A_REVERSE, "VVVVVV.VVVVV.VV.VV.V", 
X	NORANGE, 16, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, MUSTENTER, 
X	ERRROW, MSGROW, "Please enter niu location.", "cfgsrn.hlp", NOTAG);
X.fi
X
X.PP
XA core dump of (DisPrmpt at line 37) indicates the string was not null terminated.
X
X..PP
XIf a range is given on a field and a invalid range is inputed and then you
Xclear the field you are unable to exit field.
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/GetInput.3X || echo "restore of utilities.d/libgeti.d/GetInput.3X fails"
echo "x - extracting utilities.d/libgeti.d/RingMenu.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/RingMenu.3 &&
X. \ @(#)RingMenu.3	1.1 DeltaDate 1/22/90 ExtrDate 1/22/90 
X.po 6
X.TH RINGMENU 3L
X.SH NAME
XRingMenu \- Produce a Ring Menu.
X
X.SH SYNOPSIS
X.B "int RingMenu ( win, line, optNum, title, optTable )"
X.B "WINDOW *win ;"
X.B "unsigned short line, optNum ;"
X.B "char *title, *optTable[][2] ;"
X
X.SH DESCRIPTION
XRingMenu accepts a two dimensional pointers arrary, optTable, as specification to display a ring 
Xmenu.  OptTable[][0] is the option name, while optTable[][1] is the description for the option.  The 
Xlast pair of entry in OpTable must be NULL to signify the end of the menu.  The optNumth option is 
Xhighlighted, or the first item will be highlighted if optNum is 0.  The ring menu will be displayed on 
Xwindow win on line number line.  Description for option is displayed on the line+1 line.  An option-
Xal title may be displayed to the left of the ring menu or NULL may be passed if no title is desired..
X
XUser may use the arrow keys, or the equivalent control keys to move the highlighted option, and then 
Xhit the RETURN key to select the desired option.  Or a capital letter match may also select a particu-
Xlar option, there is no need to hit RETURN in this case.
X
XRingMenu accepts at most 20 options.
X
X.SH AUTHOR
XSam S. Lok
X
X.SH RETURN VALUES
XThe position number of the selected option.  The first option being 1.
X
X.SH DIAGNOSTICS
XNone.
X
X.SH EXAMPLES
X	short	option = 1 ;
X
X	static	char	*emp_menu[][2] = {	/* The menu */
X		{ "Query",	"Query existing employee" },
X		{ "Add",	"Add new employee" },
X		{ "Change",	"Update existing employee" },
X		{ "Delete",	"Delete existing employee" },
X		{ "Print",	"Screen dump to printer" },
X		{ "Exit",	"Return to menu" },
X		{ NULL,	NULL } 
X	} ;
X
X	option = RingMenu( stdscr, ERRLINE, option, "Employee:", emp_menu ) ;
X
X.SH FILES
XNone.
X
X.SH SEE ALSO
Xmenu(1L), popmenu(3L), GetInput(3L).
X
X.SH WARNINGS
XRingMenu ignores options more than 20.
XRingMenu.c makes uses of GetInput(3L)'s GetInput.h, keys.h, ShowHelp() and ScrnPrnt(), other-
Xwise, it is very much self contained.
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/RingMenu.3 || echo "restore of utilities.d/libgeti.d/RingMenu.3 fails"
echo "x - extracting utilities.d/libgeti.d/ShowHelp.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.3 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH SHOWHELP 3 "libgeti"
X
X.SH NAME
XShowHelp \- creates and displays a help window using curses
X
X.SH SYNOPSIS
X.B "void  ShowHelp (help_file_name, tag, error_row)
X.br
X.B "char	help_file_name[];"
X.br
X.B "char	tag[];"
X.br
X.B "int	error_row;"
X
X.SH \s9DESCRIPTION\s0
X.B ShowHelp
Xsearches the \fIhelp_file_name\fP for the specified \fItag\fP, creates and
Xcenters a curses window on the screen.  Then displays the content of the tag
Xin the window.  The size of the help window is automatically adjusted to the 
Xsize of message to be displayed.
X
X.SS ARGUMENTS
X.TP 6
Xhelp_file_name
XThe unix file name containing the help message to be displayed.
X.TP 6
Xtag
XThe tag in the help file that contains the help message to be displayed.
X.TP 6
Xerror_row
XThe row on the screen (stdscr) to display any error messages.
X
X.SH HELP FILE SYNTAX
XA help file may consist of multiple help tags.  Any text found outside a helptag
Xis ignored.  See the following example.
X
X.nf
X\fBhelptag\fP
X[ .TITLE  A optional Title line goes here. ]
XI put any help message for the user between the tags.  
XIt can be any length as it will be displayed one screen 
Xat a time.
XThe following screen attributes may be used:
X\\S  =  Standout
X\\B  =  Bold
X\\U  =  Underline
X\\D  =  Dim
X\\R  =  Reverse video
X\\L  =  Blink
X\\N  =  Normal (reset)
X
X\\BThis text is in bold face.  \\NBack in normal mode.
X\fBhelptag\fP
X
X
XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
Xis to be contained in the table of contents menu.  The following is the
Xsyntax for this tagname.
XTABLE_OF_CONTENTS
Xhelpfile   tagname   description
XTABLE_OF_CONTENTS
X
X
X\fBhelp\fP
X .TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
X        KEY_TOC  (^t)       Display table of contents.
X\fBhelp\fP
X.fi
X
X.SH AUTHOR
XPaul J. Condie         2/89
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
X.SH SEE ALSO
Xcurses(3X).
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/ShowHelp.3 || echo "restore of utilities.d/libgeti.d/ShowHelp.3 fails"
echo "x - extracting utilities.d/libgeti.d/drawbox.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.3 &&
X. \ @(#)drawbox.3	1.2 DeltaDate 1/22/90 ExtrDate 1/22/90 
X.po 6
X.TH DRAWBOX 3 "libgeti"
X
X.SH NAME
Xdrawbox \- draws a box in a curses window
X
X.SH SYNOPSIS
X.B #define	DumbLine	1
X.br
X.B #define	StandoutLine	2
X.br
X.B #define	SingleLine	3	/* alternate character line */
X.br
X.B #define	MosaicLine	4	/* alternate character line */
X.br
X.B #define	DiamondLine	5	/* alternate character line */
X.br
X.B #define	DotLine		6	/* alternate character line */
X.br
X.B #define	PlusLine	7	/* alternate character line */
X
Xextern int	KeyHelp;
X
X.B "void  drawbox (win, from_row, from_col, to_row, to_col, trythis, trythat, vscroll, help)"
X.br
X.B "WINDOW	*win;"
X.br
X.B "int	from_row;"
X.br
X.B "int	from_col;"
X.br
X.B "int	to_row;"
X.br
X.B "int	to_col;"
X.br
X.B "int	trythis;"
X.br
X.B "int	trythat;"
X.br
X.B "int	vscroll;"
X.br
X.B "int	help;"
X
X.SH DESCRIPTION
X.B Drawbox
Xdraws a box within a curses window.  This is similar to the box(3X) function
Xin curses, but provides more flexibility in where to draw the box and what
Xthe box should look like.
X
X.SS ARGUMENTS
X.TP 6
Xwin
XThe curses window to draw the box in.
X.TP 6
Xfrom_row, from_col, to_row, to_col
XDimensions of the box.  Upper left corner and lower right corner of the box.
XTo draw a box around the whole window (like box(3) does) 
Xtry: \fI1,1, LINES,COLS\fP as the box dimensions.
X.TP 6
Xtrythis
XWhat line type to try first.  Any one of the #defines shown above.  
XIf the terminal
Xdoes not support alternate character lines then drawbox will \fItrythat\fP line.
X.TP 6
Xtrythat
XWhat line to use if trythis doesn't work.  This should not be a
Xalternate character line.
X.TP 6
Xvscroll
XIf TRUE vertical scroll bars will be drawn in the right side of the box.
X.TP 6
Xhelp
XIf TRUE the help key (KeyHelp) will be displayed in the lower right corner 
Xof the box to indicate help is available.
X
X.SH AUTHOR
XPaul J. Condie         7/87
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
X.SH EXAMPLE
X.nf
X#include	<curses.h>
X
X
Xmain ()
X{
X	drawbox (stdscr, 1,1, LINES,COLS, SingleLine, StandoutLine, TRUE, TRUE);
X}
X.fi
X
X.SH SEE ALSO
Xcurses(3X).
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/drawbox.3 || echo "restore of utilities.d/libgeti.d/drawbox.3 fails"
echo "x - extracting utilities.d/libgeti.d/popmenu.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.3 &&
X.po 6
X.TH POPMENU 3 "libgeti"
X
X.SH NAME
Xpopmenu \- runs a popup type menu
X
X.SH SYNOPSIS
X.B #define	NEWMENU		0
X.br
X.B #define	CREATEMENU	-2
X.br
X.B #define	DIMWINDOW	-1
X.br
X.br
X.B extern int	KeyHelp;
X.br
X.B extern int	KeyCancel;
X.br
X.B extern int	KeyUp;
X.br
X.B extern int	KeyDown;
X.br
X
X.B "int  popmenu (menu_id)"
X.br
X.B "int		menu_id;"
X
X.SH \s9DESCRIPTION\s0
X.B Popmenu
Xis a generic curses popup menu program.  The synopsis of popmenu will vary
Xdepending on whether you are initializing a new menu or running
Xa previously defined menu.  The above synopsis will run menu (menu_id)
Xthat you have previously defined.
X.PP
XPopmenu will return the number (counting from the top of the menu)
Xof the item selected.  If the user selected the second item in the menu
Xthen \fIpopmenu\fP will return (2).
X.br
XA negative return value indicates the user canceled the selection.
X.PP
XAfter you run a menu you will need to touchwin(stdscr); wrefresh(stdscr);
Xin order to remove the popmenu from the screen.
X.PP
XThe KeyCancel defines the key where the user does not want to make any
Xchoice.  The KeyHelp defines what key is to display the help.  The KeyUp and
XKeyDown inaddition to the curses arrow key move the select bar up and down.
X
X.SH DEFINE NEW MENU
X.B "popmenu (action, menu_id, row, column, title, helpfile, win_size, sizeof( option_base ), option_base )"
X.br
X.B "int	action;"
X.br
X.B "int	menu_id;"
X.br
X.B "int	row;"
X.br
X.B "int	column;"
X.br
X.B "char	*title;"
X.br
X.B "char	*helpfile;"
X.br
X.B "int	win_size;"
X.br
X.B "char	*option_base;"
X.br
X     or
X.br
X.B "char	**option_base;"
X
X.SS ARGUMENTS
X.TP 6
Xaction
XNEWMENU - tells popmenu that you want to initialize a new menu.
XIf one already exists for this menu_id it will be deleted and then recreated
Xfrom the new list.
X.br
X
XCREATEMENU - If a menu already exists for this menu_id then this flag has
Xno effect.  Otherwise, it initializes a new menu from the list provided.
X
XDIMWINDOW - Dims the reverse video box around the menu.
X.br
Xpopmenu (DIMWINDOW, menu_id);
X.TP 6
Xmenu_id
XA unique identifier that you chose to be assiciated with a menu.
XYou use this identifier to run the menu.
X.TP 6
Xrow, column
XThe upper left corner of where you want the menu box to popup at.
X.TP 6
Xtitle
XTitle to be centered on the first row of the menu.  If title is null no title
SHAR_EOF
echo "End of part 10"
echo "File utilities.d/libgeti.d/popmenu.3 is continued in part 11"
echo "11" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/07/90)

#!/bin/sh
# this is part 11 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/popmenu.3 continued
#
CurArch=11
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/popmenu.3"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/popmenu.3
Xwill be displayed.
X.TP 6
Xhelpfile
XThe helpfile name that contains help text to be displayed when the uses presses
Xthe help key.  If a helpfile is supplied a "?" is displayed in the lower
Xright hand corner of the menu.  Set to null if no help file is provided.
X.br
XThe help file should be in a format corresponding to GetInput(3),  see
XGetInput(3X) for more information.  Popmenu is hard-coded to look for
X\fIhelptag\fP "popmenu" in the helpfile.
X.TP 6
Xwin_size
XThe length of the pop-up window.  This may be less than the number of
Xoptions, so that popmenu() will only display
X.I win_size
Xnumber of options on the screen.  A window size of 6 or the number of options,
Xwhichever is less, is used if this field is set to 0.  Note that this field
Xshould not be set to be more than 22, which is the normal screen size (24)
Xminus 2 for the borders.
X.TP 6
Xsizeof( option[0] ) or 0
XIs an integer telling popmenu() the size of one option array element.  It can
Xalso be set to
X.I zero(0)
Xif (char **) array is passed as the next argument,
X.I popmenu
Xwill figure out the increment as the size of a char pointer.
X.TP 6
Xoption    
XThis is a (char *) to an array which store
Xthe options you want to appear in the menu.  This array can be either a
Xtwo dimensional char array, or a structure array, or even an array of pointers.
XThe first char string in each array element up to the first NULL character is
Xused to be displayed as options.  The rest of the field may just be table
Xlook-up items.  Also, The last element must be NULL to signify the end of the
Xtable.
X.PP
XFor menus that has to be built dynamically during run time,
Xthere are benefit of preparing your option table either way.  With a pre-set
Xchar array storing the menu entries, cpu usage is optimized in the expense of
Xmemory; while using char *array will optimize memory usage but has to allocate
Xmemory on the fly.  Menus built at compiled time are about equal with either
Xmethod.
X
X.SH CREDITS
XPaul J. Condie      7/87	(original author)
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
XSam S. Lok		enhancements
X
X.SH EXAMPLE
X.nf
X#include	<curses.h>
X
X#define	NEWMENU	0
X
Xint	KeyHelp = 23;		/* control w */
Xint	KeyCancel = 27;		/* ESC */
Xint	KeyDown;
Xint	KeyUp;
X
Xmain ()
X{
X	int	option;		/* the option the user selected */
X	static char	mymenu[][7] = {
X		"QUERY", "ADD", "DELETE", (char *)NULL };
X	static char	*yourmenu[] = {
X		"QUERY", "ADD", "DELETE", (char *)NULL };
X
X
X	/* define a new menu */
X	popmenu(NEWMENU, 1, 5,10, "Title", "", 3, sizeof( mymenu[0] ), mymenu );
X	popmenu(NEWMENU, 2, 7,15, "Title", "", 0, 0, yourmenu );
X
X	/* run the menu */
X	option = popmenu (1);
X	option = popmenu (2);
X
X	/* remove the menu from the screen */
X	touchwin (stdscr);
X	wrefresh (stdscr);
X}
X.fi
X
X.SH SEE ALSO
Xcurses(3X), GetInput(3X).
SHAR_EOF
echo "File utilities.d/libgeti.d/popmenu.3 is complete"
chmod 0444 utilities.d/libgeti.d/popmenu.3 || echo "restore of utilities.d/libgeti.d/popmenu.3 fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.hlp &&
XGETINPUT
X.TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X        KEY_DOWN  (^j)      Traverse forwards through the fields.
X        KEY_UP  (^k)        Traverse backwards through the fields.
X        KEY_TAB  (^i)       Fast forward through the fields.
X        KEY_BTAB            Fast reverse through the fields.
XField Editing Keys:
X        KEY_BEG  (^b)       Place cursor at beginning of field.
X        KEY_END  (^e)       Place cursor at end of input in field.
X        KEY_RIGHT  (^l)     Forward space within the field.
X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
X        KEY_EOL  (^d)       Delete from cursor to end of field.
X        KEY_DL  (^c)        Clear field and home cursor.
X        KEY_DC  (^x)        Delete a character.
X        KEY_IC  (^t)        Toggle between type-over and insert mode.
XOther Keys:
X        KEY_HELP  (?)       Display help screen.
X        KEY_REFRESH  (^r)   Redraw the screen.
X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
X        KEY_SAVE  (^f)      Save screen to a file.
X        KEY_PRINT  (^p)     Print screen to lp.
XGETINPUT
X
X
X
Xpopmenu
X.TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    Press the "up arrow key", "^k", "down arrow key", "^j" 
X    to place bar on option and press "return".
X
X    or
X
X    Enter the first character of the option you
X    wish to select and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
Xpopmenu
X
X
X
Xhelp
X.TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
Xhelp
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/GetInput.hlp || echo "restore of utilities.d/libgeti.d/GetInput.hlp fails"
echo "x - extracting utilities.d/checkpass.d/checkpass.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH CHECKPASS 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xcheckpass \- find matching passwd in /etc/passwd file for a specified login.
X
X.SH SYNOPSIS
Xcheckpass login passwd 
X
X.SH DESCRIPTION
X.I Checkpass 
Xfinds the \fIlogin\fP password in the /etc/passwd file, encrypts the
X\fIpasswd\fP and does a comparison. 
X.SH FILES
X/etc/passwd
X
X.SH AUTHOR
XVickie C. Chui
X
X.SH DIAGNOSTICS
XCheckpass returns exit code zero if it was successful, otherwise, it
Xreturns a 4.
SHAR_EOF
chmod 0644 utilities.d/checkpass.d/checkpass.1 || echo "restore of utilities.d/checkpass.d/checkpass.1 fails"
echo "x - extracting utilities.d/checkpass.d/checkpass.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.c &&
X/*
X *	checkpass.c:  encrypt entered passwd and comparing it against 
X *		 the /etc/passwd.
X *	
X *	Inputs:	 argv[1] - login
X *		 argv[2] - passwd
X *	
X *	Return Values: 4 failure
X *		0 - matched passwd found
X */
X
X#include <pwd.h>
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	struct 	passwd *getpwnam(), *pwentry;
X	char 	salt[2], 
X		*crypt(),
X		*encryptedpw;
X
X
X	/* check number of arguments */
X	if(argc != 3) {
X		printf("Usage:  checkpass login passwd\n");
X		exit(4);
X	}
X	
X	/* get passwd for login from /etc/passwd file */
X	if((pwentry=getpwnam(argv[1])) == (struct passwd *) 0) 
X		exit(4);
X
X	salt[0] = *(pwentry->pw_passwd);
X	salt[1] = *(pwentry->pw_passwd +1);
X
X	/* encrypt entered passwd */
X	encryptedpw = crypt(argv[2], salt);
X
X	/* compare passwd in /etc/passwd with the encrypted passwd */
X	if(strcmp(encryptedpw, pwentry->pw_passwd) )
X		exit(4);
X	exit(0);
X}
SHAR_EOF
chmod 0644 utilities.d/checkpass.d/checkpass.c || echo "restore of utilities.d/checkpass.d/checkpass.c fails"
echo "x - extracting utilities.d/lock.d/junk (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/junk &&
X				lockfd = open(diallock, O_WRONLY|O_CREAT|O_EXCL,
X						0444) ;
X				if (lockfd < 0) 
X				{
X					if (debug & D_DEVICE) 
X					{
X						dialmsg("%s: %s\n", errstring(),
X							diallock) ;
X					}
X					continue ;
X				}
X				else
X				{
X					/* pjc */
X					/* write process id to lock file */
X					sprintf (tmpstr, "%d", getpid());
X					sprintf (spid, "%10.10s", tmpstr);
X					write (lockfd, spid, strlen(spid));
X				}
X
X				(void) close(lockfd) ;
SHAR_EOF
chmod 0644 utilities.d/lock.d/junk || echo "restore of utilities.d/lock.d/junk fails"
echo "x - extracting utilities.d/lock.d/lock.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH LOCK 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xlock \- does a lock on a file
X
X.SH SYNOPSIS
X.B lock  filename
X
X.SH DESCRIPTION
X.B LOCK
Xis designed to be a utility program to be used in conjunction with the menu(1)
Xprogram.  Lock does a lock on a file.  When used with the menu(1)
Xprogram the filename should probably be the program name.  A "LCK.." is 
Xprepended
Xto the filename to indicate that this is a lock file.  This is in keeping
Xwith uucp lock file syntax.  If the \fILCK..filename\fP
Xdoes not exist it will be created.  The lock file is created/looked for in
Xgetenv("LOCKDIR").
X
X
X.SH EXAMPLE
X.nf
Xlock program_name
Xif [ $? -eq 0 ]
X   then	program_name
X		unlock program_name
Xfi
X.fi
X
X.SH FILES
X\fI$LOCKDIR/LCK..filename\fP	the lock file
X
X.SH AUTHOR
XPaul J. Condie       10/88
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X
X.SH SEE ALSO
Xmenu(1), unlock(1).
X
X.SH DIAGNOSTICS
XLock returns a zero if the lock was successfully created,
X99 no file specified on command line,
Xotherwise, it returns \fIerrno\fP.  See errno description in manual.
SHAR_EOF
chmod 0644 utilities.d/lock.d/lock.1 || echo "restore of utilities.d/lock.d/lock.1 fails"
echo "x - extracting utilities.d/lock.d/lock.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.c &&
X/*
X** Returns:
X**	0	lock successful
X**	99	no file on command line
X**	otherwise	errno
X*/
X
X#include	<stdio.h>
X#include	<fcntl.h>
X#include	<errno.h>
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	char		*getenv();
X	int		fd;			/* file descriptor */
X	char		file[40];
X
X	if (argc != 2)
X		exit (1);
X
X	if (getenv("LOCKDIR") != (char *)NULL)
X		sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
X	else
X		sprintf (file, "LCK..%s", argv[1]);
X
X	if ((fd = open (file, O_WRONLY|O_CREAT|O_EXCL, 0444)) < 0)
X	{
X		/* check to see if process is still running */
X		exit (errno);
X	}
X
X	/* write process id to lock file */
X	/*
X	sprintf (tmpstr, "%d", getpid());
X	sprintf (spid, "%10.10s", tmpstr);
X	write (lockfd, spid, strlen(spid));
X	*/
X
X	close (fd);
X	exit (0);
X}
X/* Paul J. Condie  8-89 */
SHAR_EOF
chmod 0644 utilities.d/lock.d/lock.c || echo "restore of utilities.d/lock.d/lock.c fails"
echo "x - extracting utilities.d/lock.d/unlock.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH UNLOCK 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xunlock \- unlocks a semaphore lock on a file
X
X.SH SYNOPSIS
Xlock  filename
X
X.SH DESCRIPTION
X.B UNLOCK
Xis designed to be a utility program to be used in conjunction with the menu(1)
Xprogram.  Unlock does a semaphore unlock on a file then unlinks the filename.  
XThe filename should have been previously locked using lock(1).
XA "LCK.." is prepended
Xto the filename to indicate that this is a lock file.
XThe lock file is looked for in getenv("LOCKDIR").
X
X.PP
XThe important thing for unlock is to make sure it runs regardless of how
Xthe program exits.  Examples of how insure that this happens is illustrated
Xbelow:
X.br
Xtrap 'unlock pgm; trap 2' 2; (pgm; unlock pgm); trap 2
X.br
X(nohup pgm; nohup unlock)&
X
X.SH FILES
X\fI$LOCKDIR/LCK..filename\fP	the lock file
X
X.SH AUTHOR
XPaul J. Condie          10/88
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X
X.SH SEE ALSO
Xmenu(1), lock(1).
X
X.SH DIAGNOSTICS
XUnlock returns exit code zero if the unlock was successful, otherwise, it
Xreturns a non-zero.
SHAR_EOF
chmod 0644 utilities.d/lock.d/unlock.1 || echo "restore of utilities.d/lock.d/unlock.1 fails"
echo "x - extracting utilities.d/lock.d/unlock.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.c &&
X/*
X** Name:	unlock(1)
X** Returns:
X**	0	unlock successful
X**	99	no file on command line
X**	otherwise	errno
X*/
X
X#include	<stdio.h>
X#include	<errno.h>
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	char		*getenv();
X	char		file[40];
X
X	if (argc != 2)
X		exit (99);
X
X	if (getenv("LOCKDIR") != (char *)NULL)
X		sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
X	else
X		sprintf (file, "LCK..%s", argv[1]);
X
X	if (unlink (file) < 0)
X		exit (errno);
X
X	exit (0);
X}
X/* Paul J. Condie  8-89 */
SHAR_EOF
chmod 0644 utilities.d/lock.d/unlock.c || echo "restore of utilities.d/lock.d/unlock.c fails"
echo "x - extracting utilities.d/m.d/adduser (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/adduser &&
X#! /bin/ksh
X# %W%   DeltaDate %G%   ExtrDate %H%
X
X###  adduser
X###	Add a new user login to the system.
X###	This script is designed to be run from the menu(1) program.
X###	Menu script file is sadmin.m
X###	This script needs to be run with a set uid to root program.  You
X###	pick the one you want to use.
X###
X###  Arguments:
X###	$1 = login ID
X###	$2 = encrypted password
X###	$3 = numerical user ID
X###	$4 = numerical group ID
X###	$5 = Text (Users Read Name)
X###	$6 = directory to create users home directory in
X###	$7 = program to use as Shell
X###	$8 = default .profile for user
X###	$9 = default printer
X###
X###  Note:
X###  	In order to get chgrp to work you need to chown to $LOGNAME first.
X###  	The setuid does not work for chgrp ????
X###
X
X###	Validate argument count
Xif [ $# -ne 9 ]
X   then	exit 1
Xfi
X
XLOGNAME=$1
XPASSWD=$2
XUID=$3
XGID=$4
XNAME=$5
XHOMEDIR=$6/$LOGNAME
XLOGSHELL=$7
XDPROFILE=$8
XPRINTER=$9
X
XPWDFILE=/etc/passwd
XGROUPFILE=/etc/group
XECHO=/bin/echo
X
X#stty sane erase '^h' echoe isig
X
Xtrap "$ECHO 'Adduser aborted.\nPress [ Return ] to continue...\c'; read reply; exit" 2 3 15
X
X$ECHO "\n"
X
Xif grep '^'$LOGNAME: $PWDFILE > /dev/null 2>&1
X   then $ECHO "Logname $LOGNAME is already in use."
X	$ECHO "Please try another."
X	$ECHO "Press [ Return ] to continue...\c"
X	read reply
X	exit 0
Xfi
X
XGROUP=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$GID $GROUPFILE`
X
X
X
X$ECHO "Logname:         $LOGNAME"
X$ECHO "Default Passwd:  $PASSWD"
X$ECHO "Real name:       $NAME"
X$ECHO "User id:         $UID"
X$ECHO "Group:           $GROUP"
X$ECHO "Group number:    $GID"
X$ECHO "Home directory:  $HOMEDIR"
X$ECHO "Default Printer: $PRINTER"
X	
X#$ECHO "\nDatabase Permissions:"
X#$ECHO "\tService Rep: $rep"
X	
X$ECHO "\nOkay to add (y/n)? \c"
Xread reply
X
X$ECHO "\n"
Xif [ "$reply" = "y" ]
X   then trap "$ECHO 'Too late to abort adduser!'" 2 3 15
X	$ECHO "Adding entry to $PWDFILE"
X	###  Next line is for standard SYSV
X	$ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> $PWDFILE
X	if [ $? -ne 0 ]
X	   then	$ECHO "Unable to add entry to $PWDFILE"
X		$ECHO "Aborting add new user."
X		$ECHO "Press [ Return ] to continue...\c"
X		read reply
X		exit 0
X	fi
X	###  Next Line is for the SUN
X#	$ECHO "/^+/i\\" > /tmp/adduser.script
X#	$ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> /tmp/adduser.script
X#	sed -f /tmp/adduser.script $PWDFILE > /tmp/newpasswd
X#	cp /tmp/newpasswd $PWDFILE
X#	rm -f /tmp/adduser.script
X#	rm -f /tmp/newpasswd
X   else
X	$ECHO "$LOGNAME not added."
X	exit
Xfi
X
X
X###	Make home directory
XMAKEDIR=yes
Xif [ -s $HOMEDIR ]
X   then $ECHO "Warning: $HOMEDIR exists. Okay to use it (y/n)? \c"
X	read reply
X	if [ "$reply" = "y" ]
X	   then MAKEDIR=no
X	fi
Xfi
Xif [ "$MAKEDIR" = "yes" ]
X   then	mkdir $HOMEDIR
X	if [ $? -ne 0 ]
X	   then $ECHO "Could not create $HOMEDIR."
X		$ECHO "Aborting adduser."
X		$ECHO "Removing entry in $PWDFILE"
X		sed -e "/^$LOGNAME:/D" $PWDFILE > /tmp/passwd
X	  	if [ $? -ne 0 ]
X 	       	   then	$ECHO "Unable to delete entry from password file."
X	  		exit
X		   else chmod 744 $PWDFILE
X	  		cp /tmp/passwd $PWDFILE
X			rm -f /tmp/passwd
X		fi
X		$ECHO "Press [ Return ] to continue...\c"
X		read reply
X		exit
X	fi
Xfi
X# Correct mode of HOMEDIR
Xchown $LOGNAME $HOMEDIR
X/bin/chgrp $GROUP $HOMEDIR
X/bin/chmod 754 $HOMEDIR
Xchown $LOGNAME $HOMEDIR
X
X
X
X###
X###  If there is no .profile in HOMEDIR
X###     then  Copy default .profile to HOMEDIR
X###
X
Xif [ -f $HOMEDIR/.profile ]
X   then	$ECHO "A .profile already exists in $HOMEDIR."
X   else
X	if [ -f $DPROFILE ]
X	   then	$ECHO "Placing a .profile in $HOMEDIR"
X		###  Next line is used to set default printer LPDEST
X		if [ "$PRINTER" != "NULL" ]
X			# fix this
X		   then	sed "s/^LPDEST=local/LPDEST=$PRINTER/" $DPROFILE > $HOMEDIR/.profile
X		   else	cp $DPROFILE $HOMEDIR/.profile
X		fi
X		chown $LOGNAME $HOMEDIR/.profile
X		/bin/chgrp $GROUP $HOMEDIR/.profile
X		/bin/chmod 754 $HOMEDIR/.profile
X		chown $LOGNAME $HOMEDIR/.profile
X		$ECHO "Default .profile added for $LOGNAME."
X	   else	$ECHO "The default .profile ($DPROFILE) was not found."
X	fi
Xfi
X
X
X
X###
X### Create bin in HOMEDIR
X###
X
Xif [ -d $HOMEDIR/bin ]
X   then	$ECHO "A bin directory already exists."
X   else 
X	$ECHO "Making directory $HOMEDIR/bin"
X	mkdir $HOMEDIR/bin
X	chown $LOGNAME $HOMEDIR/bin
X	/bin/chgrp $GROUP $HOMEDIR/bin
X	/bin/chmod 755 $HOMEDIR/bin
X	chown $LOGNAME $HOMEDIR/bin
X	$ECHO "Bin directory added for $LOGNAME."
Xfi
X
X
X
X###
X###  Grant Database Permissions
X###
X
X#DBPATH=/prod/date.d; export DBPATH
X#/usr/informix/bin/isql - - <<END
X#database dateme;
X#grant select on techs to $LOGNAME;
X#grant insert on techs to $LOGNAME;
X#grant update on techs to $LOGNAME;
X#grant delete on techs to $LOGNAME;
X#grant connect to $LOGNAME;
X#END
X
X$ECHO "$LOGNAME added."
X$ECHO "Press [ Return ] to continue...\c"
Xread reply
SHAR_EOF
chmod 6755 utilities.d/m.d/adduser || echo "restore of utilities.d/m.d/adduser fails"
echo "x - extracting utilities.d/m.d/deluser (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/deluser &&
X#! /usr/lbin/ksh
X# @(#)deluser.sh	1.1   DeltaDate 12/31/87   ExtrDate 12/31/87
X###
X###  You need to chown all files in the home directory you want to delete
X###  to $LOGNAME before you can remove the home directory.
X###
X
XLOGNAME=$1
XECHO=echo
XUIDBASE=2000
X
Xtrap "$ECHO 'Deluser aborted.'; exit 1" 2 3 15
X
Xtput clear
X#stty sane erase '^h' echoe isig
X
X
X
Xcase $LOGNAME in
X   dateme|pjc|root|nobody|daemon|sys|bin|uucp|nuucp|news|informix|telic|cadsys)
X	$ECHO "Sorry, You don't have permission to delete that one."
X	continue
X	;;
Xesac
X
X###
X### Check for validity - listed in password file.
X###
Xif grep '^'$LOGNAME: /etc/passwd > /dev/null 2>&1
X   then
X	### Extract data for this user and display.
X       	setthem=`sed -n "s/^$LOGNAME:\(.*\):\(.*\):\(.*\):\(.*\):\(.*\):\(.*\)/passwd=\1;uid=\2;gid=\3;realname='\4';homedir=\5;shell=\6/p" /etc/passwd`
X       	eval $setthem
X       	group=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$gid /etc/group`
X
X	###
X	###  uid must be >= UIDBASE
X	###
X	if [ "$uid" -lt $UIDBASE ]
X   	   then	$ECHO "Sorry, You don't have permission to delete that one."
X   		continue
X	fi
X
X	$ECHO "\nLogname:           $LOGNAME"
X	$ECHO "Real name:         $realname"
X       	$ECHO "User id:           $uid"
X       	$ECHO "Group:             $group"
X       	$ECHO "Group number:      $gid"
X       	$ECHO "Home directory:    $homedir"
X	$ECHO "\n\n"
X       	break
X   else
X	$ECHO "$LOGNAME is not listed in the password file. Try again."
X	read reply
Xfi
X
X
X
Xwhile true
Xdo
X	$ECHO "Do you wish to delete this user from the system  (y/n):  \c"
X   	read reply
X
X   	case $reply in
X	   n|N)	break ;;
X     	   y|Y)
X		if [ "$homedir" != "/prod/date.d/cadsys.d" ]
X	   	   then
X			###  Not a Service Rep
X			###  Service Reps never had permission here
X			DBPATH=/prod/date.d
X			export DBPATH
X/usr/informix/bin/isql - - <<END
Xdatabase dateme;
Xrevoke all on techs from $LOGNAME;
Xrevoke all on turfs from $LOGNAME;
Xrevoke all on techtime from $LOGNAME;
Xrevoke all on factors from $LOGNAME;
Xrevoke all on turfs from $LOGNAME;
XEND
X		fi
X		DBPATH=/prod/date.d/cadsys.d
X		export DBPATH
X/usr/informix/bin/isql - - <<END
Xdatabase cadsys;
Xrevoke all on appt from $LOGNAME;
Xrevoke all on grid from $LOGNAME;
Xrevoke all on syserror from $LOGNAME;
Xrevoke all on appt_time from $LOGNAME;
Xrevoke all on sorder from $LOGNAME;
Xrevoke all on sysdeflt from $LOGNAME;
Xrevoke connect from $LOGNAME;
XEND
X			sed -e "/^$LOGNAME:/D" /etc/passwd > /tmp/passwd
X	  		if [ $? -ne 0 ]
X 	    	   	   then	$ECHO "Unable to delete from password file."
X		  		exit
X	  		fi
X	  		chmod 744 /etc/passwd
X	  		cp /tmp/passwd /etc/passwd
X
X			###
X			###  CUSTOMIZE
X			###  if this is a service rep we don't want to remove homedir
X			###
X			if [ "$homedir" != "/prod/date.d/cadsys.d" ]
X		   	   then
X	  			find $homedir -exec /etc/chown $LOGNAME {} \;
X	  			rm -r $homedir
X			fi
X	  		$ECHO "\nUser removed from system."
X	  		break;
X	  		;;
X     	   	   *)	$ECHO "Invalid reply."
X          		continue ;;
X   		esac
SHAR_EOF
chmod 0777 utilities.d/m.d/deluser || echo "restore of utilities.d/m.d/deluser fails"
echo "x - extracting utilities.d/m.d/junk.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/junk.m &&
X###
X###   	.POPMENU
X###	Printer Selection Menu
X###
X
X.TITLE
XPrinter Menu
X
X.TEXT 23 0
XSelect A Printer.
X
X.SETENV BELL LPDEST=srv4e_700ps  Printer (srv4e_700ps) selected.
Xsrv4e_700ps
X
X.SETENV BELL LPDEST=srv4e_700dm  Printer (srv4e_700dm) selected.
Xsrv4e_700dm
X
X.SETENV BELL LPDEST=srv4e_811a  Printer (srv4e_811a) selected.
Xsrv4e_811a
X
X.SETENV BELL LPDEST=srv4e_760c  Printer (srv4e_760c) selected.
Xsrv4e_760c
SHAR_EOF
chmod 0644 utilities.d/m.d/junk.m || echo "restore of utilities.d/m.d/junk.m fails"
echo "x - extracting utilities.d/m.d/passwdsrn.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/passwdsrn.m &&
X.DEFINE_SCREEN passwdsrn
X	window_title = "Password Screen"
X	window_rows = 5
X	window_cols = 26
X	exit_last_field
X
X	field_name = $PASSWD
X	field_label = Password
X	field_row = 2
X	field_col = 12
X	field_length = 8
X	field_edits = PROTECT
X	field_prompt = "Enter password."
XENDSCREEN
SHAR_EOF
chmod 0644 utilities.d/m.d/passwdsrn.m || echo "restore of utilities.d/m.d/passwdsrn.m fails"
echo "x - extracting utilities.d/m.d/printer2.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printer2.sh &&
XFrom uucp Tue Nov 28 16:07 PST 1989
X>From uucp Tue Nov 28 15:56 PST 1989 remote from pacbell
X>From srv.PacBell.COM!pjcondie  Tue Nov 28 14:35:31 1989 remote from mother
XReceived: from pbuddy.srv.PacBell.COM (pbuddy-gw) by srv.PacBell.COM (4.0/SMI-4.0)
X	id AA17298; Tue, 28 Nov 89 14:35:31 PST
XReceived: from lacm2.srv.PacBell.COM by pbuddy.srv.PacBell.COM (4.0/SMI-4.0)
X	id AA02251; Tue, 28 Nov 89 14:37:38 PST
XDate: Tue, 28 Nov 89 14:37:38 PST
XFrom: pjcondie@srv.PacBell.COM (Paul J. Condie)
XMessage-Id: <8911282237.AA02251@pbuddy.srv.PacBell.COM>
XTo: pcbox!pjc
XSubject: Re:  printers.sh
XStatus: R
X
X
X----- Begin Included Message -----
X
X>From pbear2!ssl Tue Nov 28 14:31:29 1989
XSubject: printers.sh
XTo: pjc (Paul J. Condie(baer))
XX-Mailer: ELM [version 2.2 PL0]
X
X###
X###   	Build lpoptions.m from lpoptions.menu
X###	Printer Selection Menu
X###
X
XDUMMY="zzzzzzzz"			# end-of-list marker
X
Xsetprinters() {				# make a function
Xlpstat -a | grep accept | cut -d' ' -f1 | ( sort ; echo $DUMMY ) |
Xfor i in `cat`
Xdo
X	if [ $i = $DUMMY ]		# hit last one?
X	then
X		echo $PRINTERS
X	fi
X	PRINTERS=$PRINTERS","$i		# concat
Xdone ; }
X
XPRINTERS=$LPDEST`setprinters`		# now build it
Xsed -e s/\$PRINTERS/$PRINTERS/ $BVPS/misc/lpoptions.menu > lpoptions.m
X
X
X----- End Included Message -----
X
X
X
SHAR_EOF
chmod 0644 utilities.d/m.d/printer2.sh || echo "restore of utilities.d/m.d/printer2.sh fails"
echo "x - extracting utilities.d/m.d/printers.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.m &&
X###
X###   	.POPMENU
X###	Printer Selection Menu
X###
X
X.TITLE
XPrinter Menu
X
X.TEXT 23 0
XSelect A Printer.
X
X.SETENV BELL LPDEST=srv4e_700ps  Printer (srv4e_700ps) selected.
Xsrv4e_700ps
X
X.SETENV BELL LPDEST=srv4e_700dm  Printer (srv4e_700dm) selected.
Xsrv4e_700dm
X
X.SETENV BELL LPDEST=srv4e_811a  Printer (srv4e_811a) selected.
Xsrv4e_811a
X
X.SETENV BELL LPDEST=srv4e_760c  Printer (srv4e_760c) selected.
Xsrv4e_760c
X
X.POPMENU printers.m
XPOP
SHAR_EOF
chmod 0644 utilities.d/m.d/printers.m || echo "restore of utilities.d/m.d/printers.m fails"
echo "x - extracting utilities.d/m.d/printers.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.sh &&
X###
X###   	Build a .POPMENU
X###	Printer Selection Menu
X###
X
Xecho ".TITLE" > printers.m
Xecho "Printer Menu" >> printers.m
X
Xecho ".TEXT 23 0" >> printers.m
Xecho "Select A Printer." >> printers.m
X
Xlpstat -p | awk '{ print $2 }' |
Xfor i in `cat`
Xdo
X	echo ".SETENV BELL LPDEST=$i  Printer ($i) selected." >> printers.m
X	echo "$i" >> printers.m
Xdone
SHAR_EOF
chmod 0755 utilities.d/m.d/printers.sh || echo "restore of utilities.d/m.d/printers.sh fails"
echo "x - extracting utilities.d/m.d/reportsrn.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/reportsrn.m &&
X###	Screen to prompt user for report options.
X###	Fields:
X###		$FDATE    - From date.
X###		$TDATE    - To date.
X###		$PRIORITY - Priority
X###		$LPDEST   - Printer Destination
X###		$TARGET   - Print to terminal or printer.
X
X.DEFINE_SCREEN reportsrn
X	window_title = "REPORT OPTIONS"
X	window_rows = 10
X	window_cols = 28
X
X	###	$FDATE - From date.
X
X	field_name = $FDATE
X	field_label = From
X	field_row = 2
X	field_col = 13
X	field_length = 6
X	field_type = DATE
X	field_mask = "MM/DD/YY"
X	field_mustenter
X	field_prompt = "Enter starting date."
X
X	###	$TDATE - To date.
X
X	field_name = $TDATE
X	field_label = To
X	field_row = 3
X	field_col = 13
X	field_length = 6
X	field_type = DATE
X	field_mask = "MM/DD/YY"
X	field_mustenter
X	field_prompt = "Enter starting date."
X
X	field_name = $PRIORITY
X	field_label = Priority
X	field_row = 5
X	field_col = 13
X	field_length = 6
X	field_type = MENU
X	field_range = "LOW,MEDIUM,HIGH"
X	field_prompt = "Select priority level."
X
X	field_name = $LPDEST
X	field_label = Printer
X	field_row = 6
X	field_col = 13
X	field_length = 11
X	field_type = SET
X	field_range = "srv4e_700ps,srv4e_811a"
X	field_prompt = "Select printer."
X
X	field_name = $TARGET
X	field_label = "Print To"
X	field_row = 7
X	field_col = 13
X	field_length = 8
X	field_type = SET
X	field_range = "TERMINAL,PRINTER,BOTH"
X	field_prompt = "Print to terminal or printer."
XENDSCREEN
SHAR_EOF
chmod 0644 utilities.d/m.d/reportsrn.m || echo "restore of utilities.d/m.d/reportsrn.m fails"
echo "x - extracting utilities.d/m.d/sadmin.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sadmin.m &&
X###	Add new user stuff
X###	GROUP - default group for new users
X###	HOMEDIRS - where to make home directories for new users
X
XGROUP=users
XHOMEDIRS=/tmp
XPRINTER=NULL
XDPROFILE=/tmp/profile.lacm
XLOGSHELL=/bin/sh
XUIDBASE=2000
XPASSWDAGE=",O/"
X
XPWDFILE=/etc/passwd
XGROUPFILE=/etc/group
X
X.TITLE
X$LOGNAME ...System Administration...$DATE
X.TITLE
X...Menu...$TIME
X.LINE
X
X.SYSTEM GETINPUT adduser \
X	suid_exec adduser $logname $PASSWDAGE $UID $GID "$realname" $HOMEDIRS $LOGSHELL $DPROFILE $PRINTER
XAdd New User To System.
X
X.SYSTEM GETINPUT deluser \
X	suid_exec deluser $logname
XRemove User From System.
X
X
X
X.DEFINE_SCREEN adduser
X	window_rows = 11
X	window_cols = 47
X	window_title = "Add New User Screen"
X
X	field_name = $logname
X	field_label = "Login Name"
X	field_row = 2, field_col = 19
X	field_length = 8
X	field_type = ALPHANUM, field_mask = "A       "
X	field_mustenter
X
X	field_name = $realname
X	field_label = "Real Name"
X	field_row = 3, field_col = 19
X	field_length = 25
X	field_type = ALPHANUM
X	field_mustenter
X
X	field_name = $UID
X	field_label = "User ID"
X	field_row = 4, field_col = 19
X	field_length = 5
X	field_noinput
X
X	field_name = $GROUP
X	field_label = "Group"
X	field_row = 5, field_col = 19
X	field_length = 10
X	field_noinput
X
X	field_name = $GID
X	field_label = "Group ID"
X	field_row = 6, field_col = 19
X	field_length = 5
X	field_noinput
X
X	field_name = $HOMEDIRS
X	field_label = "Home Directory"
X	field_row = 7, field_col = 19
X	field_length = 25
X	field_noinput
X
X	field_name = $PRINTER
X	field_label = "Default Printer"
X	field_row = 8, field_col = 19
X	field_length = 20
X	field_type = ALPHANUM
X
X	field_defaults = "UID=`awk 'BEGIN{ FS=\":\" } { x[$3] = 1 } END { i = 2000; while (x[i] == 1) { ++i }; print i }' $PWDFILE`
X		GID=`awk 'BEGIN{FS=\":\"} {if($1 == g) print $3}' g=$GROUP $GROUPFILE`
X		echo NULL NULL $UID $GROUP $GID $HOMEDIRS $PRINTER"
XENDSCREEN
X
X
X.DEFINE_SCREEN deluser
X	window_rows = 5
X	window_cols = 25
X	window_title = "Delete User Screen"
X
X	field_name = $logname
X	field_label = "Login Name"
X	field_row = 2, field_col = 14
X	field_length = 8
X	field_type = ALPHANUM, field_mask = "A       "
X	field_mustenter
XENDSCREEN
SHAR_EOF
chmod 0644 utilities.d/m.d/sadmin.m || echo "restore of utilities.d/m.d/sadmin.m fails"
echo "x - extracting utilities.d/m.d/sample.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sample.m &&
X### 	Sample.Menu
X###	A sample menu script file.
X
X.TITLE
X$LOGNAME ...SAMPLE...$DATE
X.TITLE
X$MAIL...MENU...$TIME
X.LINE
X
X.GNAME sample sample.m
X
X.INCLUDE reportsrn.m
X.INCLUDE passwdsrn.m
X
X.TEXT 22 61
X"?" for help :
X
X.SYSTEM echo "Press [ ^d ] to return to menu ..."; ksh
XUnix System.
X
X.SYSTEM who; \
X	echo "Press [ Return ] to continue ..."; \
X	read reply
XShow Who Is On The System.
X
X.SYSTEM more sample.m; echo "Press [ Return ] to continue ...\c"; read reply
XDisplay sample.m script file.
X
X.POPMENU printers.m
XSelect Printer Menu ($LPDEST).
X
X.GETINPUT reportsrn
XA Sample GETINPUT Screen.
X
X.GETINPUT passwdsrn
XA Sample Password Screen.
X
X.SPACE
X
X.EXIT
XExit Menu Program.
SHAR_EOF
chmod 0644 utilities.d/m.d/sample.m || echo "restore of utilities.d/m.d/sample.m fails"
echo "x - extracting utilities.d/m.d/suid_exec.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/suid_exec.c &&
X#include	<stdio.h>
X#include	<fcntl.h>
X#include	<sys/stat.h>
X
X#define	ROOT	0
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	int		fd;
X	struct stat	sbuf;
X	char		command[200];
X	int		i;
X
X
X	if (argc < 2)
X		exit (1);
X
X	if ((fd = open (argv[1], O_RDONLY)) <= 0)
X		exit (1);				/* can't open */
X
X	/* Get file status information */
X   	if (fstat (fd, &sbuf) < 0)
X		exit (1);
X
X	/* Is this a regular file */
X	if ((sbuf.st_mode & S_IFREG) != S_IFREG)
X		exit (1);
X
X	/* does root own this file */
X	if (sbuf.st_uid != ROOT)
X		exit (1);
X
X	/* Is file executable by owner(root) */
X	if ((sbuf.st_mode & S_IEXEC) != S_IEXEC)
X		exit (1);
X
X	/* Is set uid bit on */
X	if ((sbuf.st_mode & S_ISUID) != S_ISUID)
X		exit (1);
X
X	setuid (ROOT);
X
X	strcpy (command, argv[1]);			/* program name */
X	for (i = 2; i < argc; i++)
X	{
X		strcat (command, " ");
X		strcat (command, "\"");
X		strcat (command, argv[i]);		/* program arguments */
X		strcat (command, "\"");
X	}
X
X	system (command);
X}
X/* Paul J. Condie  2-89 */
SHAR_EOF
chmod 0644 utilities.d/m.d/suid_exec.c || echo "restore of utilities.d/m.d/suid_exec.c fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (04/12/90)

It has been pointed out to me that on some machines while compiling
menu you will get a warning message about "ambiguous assignment..." on
rundriver.c line 161 and line 166.

if you change line 161 from this:
		*option =*option >= menu->optioncount ? 1 : ++(*option);
to this:
		*option =(*option) >= menu->optioncount ? 1 : ++(*option);
putting paranthesis around *option will get rid of the warning.  The
same for line 166, put parenthesis around *option.

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
#      A Brief Description:
#           Menu(1) is an easy-to-use menu utility that allows users to
#           operate an application system in a user-friendly, menu-
#           driven environment.  Any application software, regardless of
#           source language or operating system process can be executed
#           from menus designed with Menu(1).
#
#           For systems requiring multi-level menus for a diverse number
#           of users, Menu(1) allows a single menu to call any number of
#           submenus, which may in turn call more menus or execute any
#           number of processes.  Menus can be nested to any level
#           without increasing startup time or memory requirements.
#
#           Menus can also be designed to function as user-friendly data
#           entry screens for capturing data, which can then be used as
#           input for a process.  Text items such as "displays",
#           "choices" and "responses" can be added within any of these
#           defined boundaries, and will automatically adjust if any
#           boundaries are changed.  Special screen attributes, such as
#           highlighting and reverse video, can be defined to add
#           special emphasis.
#
#           The menu script file contains all of the menu instructions,
#           and can be edited using a standard system editor, such as
#           vi.  Menus and utilities can be added or deleted by editing
#           the appropriate script file, even while the menu is in use.
#########
#
#
#	Run the following text with /bin/sh to create:
#	  README
#	  VERSIONHISTORY
#	  SHAREWARE
#	  makefile
#	  menu.1
#	  Main.c
#	  LoadKeys.c
#	  parsedrive.c
#	  showdriver.c
#	  rundriver.c
#	  ParseOpton.c
#	  ParseBaner.c
#	  ParseTitle.c
#	  ParseBox.c
#	  ParseWindo.c
#	  ParseLine.c
#	  ParseComnt.c
#	  ParseUnix.c
#	  ParseGname.c
#	  ParseAuthr.c
#	  ParseText.c
#	  ParseCur.c
#	  ParseSpace.c
#	  ParInclude.c
#	  ParAssign.c
#	  ParAftMenu.c
#	  ShowOption.c
#	  RunSystem.c
#	  RunExit.c
#	  RunSetenv.c
#	  RunMenu.c
#	  RunPopMenu.c
#	  RunGetI.c
#	  RunAftMenu.c
#	  GetOption.c
#	  EndWindow.c
#	  displaytxt.c
#	  SetTerm.c
#	  systime.c
#	  sysdate.c
#	  checkmail.c
#	  anymail.c
#	  setenv.c
#	  strmatch.c
#	  setvar.c
#	  drawline.c
#	  initmenu.c
#	  keyboard.c
#	  runscreen.c
#	  getval.c
#	  clean_menu.c
#	  slength.c
#	  runpopen.c
#	  mygetch.c
#	  menu.h
#	  terminal.h
#	  LexDeSrn.l
#	  menu.hlp
#	  runrealid.c
#	  ParseDeSrn.y
#	  utilities.d/libgeti.d/AdjField.c
#	  utilities.d/libgeti.d/BuildMenu.c
#	  utilities.d/libgeti.d/DateFun.c
#	  utilities.d/libgeti.d/DisPrmpt.c
#	  utilities.d/libgeti.d/FindSet.c
#	  utilities.d/libgeti.d/GetInput.c
#	  utilities.d/libgeti.d/GetSetLen.c
#	  utilities.d/libgeti.d/InitGetI.c
#	  utilities.d/libgeti.d/IsDate.c
#	  utilities.d/libgeti.d/IsFldOk.c
#	  utilities.d/libgeti.d/IsMask.c
#	  utilities.d/libgeti.d/IsRange.c
#	  utilities.d/libgeti.d/IsState.c
#	  utilities.d/libgeti.d/IsTime.c
#	  utilities.d/libgeti.d/ReDispFld.c
#	  utilities.d/libgeti.d/RingMenu.c
#	  utilities.d/libgeti.d/ScrnOut.c
#	  utilities.d/libgeti.d/ShowChar.c
#	  utilities.d/libgeti.d/ShowHelp.c
#	  utilities.d/libgeti.d/ShowSet.c
#	  utilities.d/libgeti.d/_Main.c
#	  utilities.d/libgeti.d/checkmask.c
#	  utilities.d/libgeti.d/doinsert.c
#	  utilities.d/libgeti.d/drawbox.c
#	  utilities.d/libgeti.d/findfile.c
#	  utilities.d/libgeti.d/getmmddyy.c
#	  utilities.d/libgeti.d/popmenu.c
#	  utilities.d/libgeti.d/stricmp.c
#	  utilities.d/libgeti.d/substr.c
#	  utilities.d/libgeti.d/upper.c
#	  utilities.d/libgeti.d/GetInput.h
#	  utilities.d/libgeti.d/keys.h
#	  utilities.d/libgeti.d/makefile
#	  utilities.d/libgeti.d/GetInput.3X
#	  utilities.d/libgeti.d/RingMenu.3
#	  utilities.d/libgeti.d/ShowHelp.3
#	  utilities.d/libgeti.d/drawbox.3
#	  utilities.d/libgeti.d/popmenu.3
#	  utilities.d/libgeti.d/GetInput.hlp
#	  utilities.d/checkpass.d/checkpass.1
#	  utilities.d/checkpass.d/checkpass.c
#	  utilities.d/lock.d/junk
#	  utilities.d/lock.d/lock.1
#	  utilities.d/lock.d/lock.c
#	  utilities.d/lock.d/unlock.1
#	  utilities.d/lock.d/unlock.c
#	  utilities.d/lock.d/uulock.c
#	  utilities.d/m.d/adduser
#	  utilities.d/m.d/adduser.old
#	  utilities.d/m.d/deluser
#	  utilities.d/m.d/junk
#	  utilities.d/m.d/junk.m
#	  utilities.d/m.d/passwdsrn.m
#	  utilities.d/m.d/printer2.sh
#	  utilities.d/m.d/printers.m
#	  utilities.d/m.d/printers.sh
#	  utilities.d/m.d/reportsrn.m
#	  utilities.d/m.d/sadmin.m
#	  utilities.d/m.d/sample.m
#	  utilities.d/m.d/setdbaperm
#	  utilities.d/m.d/suid_exec.c
#	  utilities.d/msgbox.d/displaytxt.c
#	  utilities.d/msgbox.d/makefile
#	  utilities.d/msgbox.d/msgbox.1
#	  utilities.d/msgbox.d/msgbox.c
#	  utilities.d/MenuMsg.d/MenuMsg.1
#	  utilities.d/MenuMsg.d/MenuMsg.c
#	  utilities.d/MenuMsg.d/MenuPrompt.1
#	  utilities.d/MenuMsg.d/MenuPrompt.c
#	  utilities.d/MenuMsg.d/makefile
#
mkdir utilities.d
mkdir utilities.d/checkpass.d
mkdir utilities.d/libgeti.d
mkdir utilities.d/lock.d
mkdir utilities.d/m.d
mkdir utilities.d/msgbox.d
mkdir utilities.d/MenuMsg.d
if test -r s2_seq_.tmp
then echo "Must unpack archives in sequence!"
     next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
     exit 1; fi
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
Xmenu directory structure:
X
X                             |-MenuAccess.d	MenuAccess(1) program
X  menu(1)                    |-checkpass.d	checkpass(1) program
Xsource code --|-utilities.d--|-libgeti.d	GetInput(3X) library
X                             |-lock.d		lock(1) & unlock(1)
X                             |-m.d		Sample menu script files.
X                             |-msgbox.d		msgbox(1) program
X
XTo install menu(1):
X
X	1.   cd to where you want to keep the source code
X	2.   unpack the package
X	     cpio -iBcdumv < menu.cpio  or  unshar menu.shar.xx
X	3.   vi makefile and set where you want to install menu
X	4.   make
X	5.   make install
X
XTo test menu(1):
X	-   set menu directory to some sample menus
X	    MENUDIR=utilities.d/m.d; export MENUDIR
X	-   tell menu where you installed the help file
X	    HELPDIR=/usr/local/bin; export HELPDIR
X	-   run a sample menu
X	    menu sample.m
X
XNotes:
X	- The MenuAccess(1) program is not implemented yet.
X	- Refer to VERSIONHISTORY file for changes since previous versions.
SHAR_EOF
chmod 0644 README || echo "restore of README fails"
echo "x - extracting VERSIONHISTORY (Text)"
sed 's/^X//' << 'SHAR_EOF' > VERSIONHISTORY &&
X*** VERSION HISTORY ***
XVersion Number: A new keyword or major enhancements gets version bumped by a .10
X		Bug fixes small enhancements bumped .01
X
XVERSION 3.63 - Submitted to NetNews
X.  modified makefiles so CC would get carried to other makefiles	12/90
X.  fixed major bug if command line was greater than BUFSIZ but less than
X	MAXLEN - menu would core dump	10/90
X
XVERSION 3.62
X.  port to the sun	9/90
X.  clean_menu(3) - fixed bug in freeing memory	9/90
X.  popmenu(3) - KeyIC toggles between full and single char matching  sslok 9/90
X
XVVERSION 3.61
X.  GetInput() - popmenu tries to fit all options on the screen	9/90
X.  .POPMENU - fixed bug if # of items go off the screen	9/90
X.  do keypad (stdscr, TRUE) after each system() call	9/90
X.  GetInput() fixed REVERSE video on fields with no input	8/90
X.  popmenu() - added character matching		sslok 8/90
X	probably not downward compatible
X.  popmenu() - would core dump if only one item also increased max items
X	in a pop menu to 200	sslok	7/90
X.  GETINPUT added variable=value	8/90
X.  GETINPUT now adjusts (LFADJ_BFIL) the values set in popen calls	8/90
X.  popmenu() fixed bug where title would disappear when scrolling
X	off the last item	8/90
X.  popmenu() took off hi-lighted help on dimmed windows	8/90
X.  AFTER_MENU may now be used in a POPMENU	8/90
X.  after_field now get executed before a exit_last_field	8/90
X.  increased MAXFIELDS to 40	8/90
X
XVERSION 3.60
X.  added MenuMsg(1) utility	7/90
X.  added MenuPrompt(1) utility	7/90
X.  allow comment (#) on variable=value line	7/90
X.  popmenu(), drawbox() - added elevator	sslok 7/90
X.  ParAssign() - malloc assignment	7/90
X.  added exitoncancel in DEFINE_SCREEN	7/90
X.  field_range - added "`command`" 	7/90
X.  after_field/before_field - allow "$field_name=value ..."	7/90
X.  after_field - changed runscreen() to setenv after GetInput() instead of
X	after KEY_ACCEPT	7/90
X.  added -notrap to command line	7/90
X.  DEFINE_SCREEN title default is now the option description text	7/90
X.  DEFINE_SCREEN window_rows & window_cols may automatically be calculated 7/90
X.  GetInput() a MENU type field will now exit the field upon selecting a option
X	in the popmenu	6/90
X.  GetInput() now reads .menuinit file to set key values in InitGetI()	6/90
X.  GetInput() now does range checking on sun-sat,no_holidays,gt_today,
X	ge_today,lt_today,le_today for date fields	7/90
X.  GetInput() fixed bug where if value was entered then cleared the
X	function reported invalid range	7/90
X.  did away with the NULL on GETINPUT fields	7/90
X
XVERSION 3.50
X.  menu now ignores SIGINT, SIGQUIT	4/90
X.  added text option to DEFINE_SCREEN	4/90
X.  added field_before_input option to DEFINE_SCREEN	4/90
X.  added field_after_input option to DEFINE_SCREEN	4/90
X.  added .AFTER_MENU	4/90
X.  added after_menu to DEFINE_SCREEN	4/90
X.  added utility msgbox.1	rsprice 4/90
X
XVERSION 3.42
X.  .INCLUDE - the menufile argument can now be an environment variable or
X	absolute pathname	4/90
X.  fixed warning message in rundriver.c during compile	4/90
X
XVERSION 3.41 - released to alt.sources	4/90
X.  ParAssign.c - increased var=value to allow value to be BUFSIZE*2   sslok 4/90
X.  RunSystem.c - changed message "One moment loading program to say the
X		actual option you picked	sslok 4/90
X.  getval.c - fixed problem on 3b2/700 -- int/char casting	sslok 4/90
X.  popmenu.c - 3b2/700 -- int/char casting problem with toupper	sslok 4/90
X
XVERSION 3.40
X.  DEFINE_SCREEN - window_title, window_pos accepts a $var	2/90
X.  moved the GETINPUT screen on AUTO to end of description	2/90
X.  GETINPUT helpfile accepts double quotes and the fieldname becomes
X   the tagname in the helpfile	2/90
X.  ShowHelp - added table of contents	2/90
X.  fldadjust does not work in getinput screen	2/90
X.  help in getinput screen does not work if there is no toc	2/90
X
XVERSION 3.32 - released to comp.sources.unix and unix/c library
X.  changed (case ?) casting declarations for Xneix	11/89
X.  ssl added number matching on popmenu so "1.  xxx" may be placed in a
X   popmenu text
X.  .AUTHORIZE now checks the real uid instead of LOGNAME	11/89
X.  add character matching	11/89
X.  ssl added System() reset shell mode to the real uid	11/89
X.  combining attributes now work \R\D	11/89
X.  attributes work better on option description line	11/89
X.  increased field_range maximum to 1k	11/89
X
XVERSION 3.31
X.  added KEY_EXITMENU,KEY_MAINMENU,KEY_PREVMENU,KEY_POPGNAME, KEY_GNAME
X   to .menuinit	8/89
X.  fixed anymail() when set uid is set on menu	9/89
X.  fixed non numeric entry in selecting option	9/89
X
XVERSION 3.30 - Released to Unix/C library
X.  added field_protect	6/89
X.  added GETINPUT to .UNIX	6/89
X.  added GETINPUT to .MENU	6/89
X.  added REDRAW to .UNIX	6/89
X.  .UNIX command exit 4 = NOWAYJOSE, etc.	6/89
X.  added curses attributes to -keys	6/89
X
XVERSION 3.26
X.  mainly port to the sun
X.  GetInput allow for row and col for fldErrRow/fldMsgRow	6/89
X.  fixed ShowHelp to be more more like	6/89
X.  popmenu/GETINPUT automatically figure out where to put the window	6/89
X.  tilde expansion
X.  fixed clean_menu for RunPopMenu	6/89
X.  .TEXT a -0 should work	6/89
X.  changed selectable option to REVERSE as in popmenu	6/89
X.  put clearok in ParseUnix in case .UNIX messes up the screen	6/89
X
XVERSION 3.25 - pbcast
X.  install getval()  ${parameter}	5/89
X.  *=*  add PATH=$PATH:/usr/me
X
XVERSION 3.24
X.  added \ to .AUTHORIZE
X.  .INCLUDE - now menu will display the filename if it can't find it	4/89
X.  fixed .WINDOW bug	5/89
X.  refresh before a .EXIT
X.  added HOTKEYS to .menuinit
X.  fixed ShowHelp() bug when help file > 2 pages	5/89
X.  var=value can now be put in a .INCLUDE file	5/89
X.  findfile()  replaced access(3) with stat(3) for suid on menu	5/89
X.  for G and ! do away with the carraige after the G or !	4/89
X.  ability to turn off shell escape
X
XVERSION 3.23 - Released to Unix/C Library
X.  installed sam's new version on popmenu(3)	3/89
X
XVERSION 3.22
X.  GETINPUT error message did not clear err row.	1/89
X.  exit_last_field on last field in GETINPUT	1/89
X.  fixed SKIPJUNK	1/89
X.  POPMENU multiple popmenus in the same menu did not work	1/89
X.  ShowHelp - put More on bar line	1/89
X.  bumped YYLMAX to MAXLEN	2/89
X.  allowed _ in field_name	2/89
X
XVERSION 3.21 -  Released
X.  fixed popen for field_defaults	12/88
X.  added field_noinput	12/88
X.  a new ShowHelp(3)	12/88
X
XVERSION 3.20 - Released
X.  added continuation \ to .UNIX	12/88
X.  *=* keyword - variable=value	12/88
X.  increase length of command	12/88
X.  cleared prompt line when exiting GETINPUT	12/88
X.  add field_init to DEFINE_SCREEN	12/88
X.  fix getenv on returning NULL
X
XVERSION 3.10 - Released
X.  .DEFINE_SCREEN	11/88
X.  .GETINPUT - user input into fields/environment var	11/88
X.  menu -keys	11/88
X.  .INCLUDE	11/88
X.  renamed Menu.hlp to menu.hlp	11/88
X.  menufile nameing format = menufile.m	11/88
X.  GetInput()  added MENU	11/88
X.  GetInput()  clear field and home cursor	11/88
X.  GetInput()  delete a character	11/88
X.  GetInput()  type-over/insert	11/88
X.  GetInput()  KEY_BEG, KEY_END 11/88
X.  comments in a .DEFINE_SCREEN	11/88
X.  .GETINPUT  format the default value to the mask	11/88
X.  GetInput()  have down and up arrow accept field input
X
XVERSION 2.81 - Released
X.  check for mail being forwarded	10/88
X.  fixed .POPMENU with no var=value	10/88
X.  Dim does not work	10/88
X.  The space terminater for enviroment var should not be counted in text 10/88
X.  .menuinit - popup menu key GNAME	10/88
X.  take out LoadKeys in RunPopMenu	10/88
X.  reparsed menu on return from RunPopMenu & RunSetenv	10/88
X.  check if terminal has DrawLine capability	11/88
X.  popmenu - last item selected is displayed	11/88
X
XVERSION 2.8 - Released
X.  on goto popup menu put heading of GOTO MENU	10/88
X.  .POPMENU	10/88
X.  .menuinit with ^h etc. configurable	10/88
X.  .unix changed to .UNIX	10/88
X
XVERSION 2.72 - Released
X.  lock option so only one can run at a time - lock(1) utilities.d 10/88
X.  speeded up the box redraw - clrtobot(). 10/88
X.  added multiple variable setting on .SETENV 10/88
X.  fixed .MENU and .SETENV to allow quoted values for variables 10/88
X.  took out restriction of clear(1) - now tput clear 		10/88
X.  BELL on .SETENV ??	10/88
X
XVERSION 2.71 - Released
X.  fix mAiL display
X.  ^r redraw screen
X.  fixed the if [ $? -eq 0 ] \  etc... on the command line
X      be able to authorize down to the option level
X
XVERSION 2.7 - Released
X.  EXIT command
X.  ? for help
X
XVERSION 2.6 - Released  pbody pbhyf
X.  relative addresses for .TEXT .CURSOR - = calc from LINES,COLS	5/88
X.  got screen size from LINES,COLS
X
XVERSION 2.5 - Released  lacm pbuddy
X.  a debuging feature
X
XVERSION 2.4 - Released  3b2a
X.  modify rundriver that anytime a run function returns		5/88
X   SUBMENU	- display a new menu
X   MAINMENU	- goto main menu
X   PREVMENU	- previous menu
X		- goto a menu name
X   QUIT		- exit menu
X.  updated menu.1 for adding new keywords	5/88
X
XVERSION 2.3 - Released  pbody
X.  fixed ^g  5/88
X.  changed .SETENV var=value
X
XVERSION 2.2 - Released  pbody
X.  some way to pass data to another submenu 5/88
X.  reworked .MENU to RunMenu  5/88
X
XVERSION 2.1 - Released  pbody
X.  enviroment vars in .TEXT  5/88
X
XVERSION 2.0 - Released  pbody
X.  build mail notifier into menu	4/88
X.  increase length of command line	4/88
X.  .TEXT row col text  - display text at specified location	4/88
X.  .CURSOR row col  - allow user to specify where to put cursor	4/88
X.  display "enter h for help screen"	4/88  use .TEXT
X.  .SPACE keyword	4/88
X.  menu -v  print version 4/88
SHAR_EOF
chmod 0644 VERSIONHISTORY || echo "restore of VERSIONHISTORY fails"
echo "x - extracting SHAREWARE (Text)"
sed 's/^X//' << 'SHAR_EOF' > SHAREWARE &&
XMenu is released as ShareWare, which means it can be freely copied and
Xshared.  Due to the increased demand on my time, if you use menu(1) and
Xlike it, I'm asking for a voluntary contribution of $35 to help differ
Xthe costs of on-going support and future enhancements.
X
X	Paul J. Condie
X	2133 Fieldcrest Ave
X	Fairfield, Ca.  94546
X
X
SHAR_EOF
chmod 0644 SHAREWARE || echo "restore of SHAREWARE fails"
echo "x - extracting makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > makefile &&
X# %W%   DeltaDate %G%   ExtrDate %H%
XTITLE = "MENU"
X
X# SYS5	- System V
X# BSD	- Berkely
XOSVER = SYS5
X
X# For the $MAIL (mail notification).
X# On some systems the alarm() does not come into effect while in the middle
X# of a getch().  The alarms get buffered up until the user hits a key and
X# then all the bells notifying of mail goes off.  You should take out the
X# -DALARM on the CFLAGS to get around this.
X# Works ok on:		-DALARM
X#	AT&T 3b1
X#	AT&T 3b2
X# Does not work on:
X#	SUN
X#	Arete
X#	AT&T 3b15
X#	AT&T 3b20
X#	CT megaframe
X#
X#  -DSINGLE
X#	Causes static references to terminal capabilities instead of dynamic 
X#	references.  This results in smaller code. See /usr/include/term.h
X#  -DLEXDEBUG
X#	Only if you need more debugging for .DEFINE_SCREEN
X#  -DYYDEBUG
X#	Only if you need more debugging for .DEFINE_SCREEN
X#  -DSUN
X#	Sun compilation with 5bin/cc (SYS5)
X
X
XINSTALLDIR = /usr/lbin
XHELPDIR = /usr/lbin
XMD = /usr/man/man1
XINCDIR = .
XLIBDIR =
X### Sun
X#CC	= /usr/5bin/cc
X### Sys V
XCC	= cc
X
X###  Various CFLAG settings
X
X###  Sys5
XCFLAGS = -I$(INCDIR) -O -D$(OSVER) -DSINGLE
X###  Xenix
X#CFLAGS = -I$(INCDIR) -O -D$(OSVER) -DSINGLE -DM_TERMINFO -LARGE -Ml -Mlt34 -F 10000 -SEG 500
X###  Sun (5bin)
X#CFLAGS = -I$(INCDIR) -O -D$(OSVER) -DSINGLE -DSUN
X
XYFLAGS = -d
X
X###  Libraries
X
X###  Sys5
XLIBS = libgeti.a -lcurses -ltermcap -lc -lm -ll -ly
X#LIBS = libgeti.a -lcurses -ll -ly
X###  Xenix
X#LIBS = libgeti.a -ltinfo -lx -ll -ly
X
XCFILES = Main.c LoadKeys.c parsedrive.c showdriver.c rundriver.c \
X	ParseOpton.c ParseBaner.c ParseTitle.c ParseBox.c ParseWindo.c \
X	ParseLine.c ParseComnt.c ParseUnix.c ParseGname.c ParseAuthr.c \
X	ParseText.c ParseCur.c ParseSpace.c ParInclude.c ParAssign.c \
X	ParAftMenu.c \
X	ShowOption.c \
X	RunSystem.c RunExit.c RunSetenv.c RunMenu.c RunPopMenu.c RunGetI.c \
X	RunAftMenu.c \
X	GetOption.c \
X	EndWindow.c displaytxt.c SetTerm.c \
X	systime.c sysdate.c checkmail.c anymail.c setenv.c \
X	strmatch.c setvar.c drawline.c initmenu.c keyboard.c \
X	runscreen.c getval.c clean_menu.c slength.c \
X	runpopen.c mygetch.c
X
XLFILES = LexDeSrn.l
XYFILES = ParseDeSrn.y
X
XHFILES = menu.h terminal.h
X
XMANPAGES = menu.1
X
XMENUFILES = utilities.d/m.d/*.m
XSHARFILES = README VERSIONHISTORY SHAREWARE makefile $(MANPAGES) $(CFILES) \
X	$(HFILES) $(LFILES) \
X	menu.hlp runrealid.c $(YFILES) \
X	utilities.d/libgeti.d/*.c utilities.d/libgeti.d/*.h \
X	utilities.d/libgeti.d/makefile utilities.d/libgeti.d/*.3* \
X	utilities.d/libgeti.d/*.hlp \
X	utilities.d/checkpass.d/* utilities.d/lock.d/* utilities.d/m.d/* \
X	utilities.d/msgbox.d/* utilities.d/MenuMsg.d/*
X
XOBJECTS = $(CFILES:.c=.o) $(YFILES:.y=.o) $(LFILES:.l=.o)
X
Xall:	menu runrealid checkpass lock msgbox MenuMsg MenuPrompt
X
Xmenu:	libgeti $(OBJECTS) 
X	$(CC) $(CFLAGS) $(OBJECTS) $(LIBDIR) $(LIBS) -o $@
X	size menu
X	@echo 
X
Xrunrealid: runrealid.c
X	$(CC) $(CFLAGS) runrealid.c -o $@
X
Xlibgeti:
X	cd utilities.d/libgeti.d; $(MAKE) CC=$(CC) install
X#	For SUN
X#	ranlib libgeti.a
X
Xcheckpass:
X	cd utilities.d/checkpass.d; $(MAKE) CC=$(CC) checkpass
X
Xlock:
X	cd utilities.d/lock.d; $(MAKE) CC=$(CC) lock
X	cd utilities.d/lock.d; $(MAKE) CC=$(CC) unlock
Xmsgbox:
X	cd utilities.d/msgbox.d; $(MAKE) CC=$(CC)
XMenuMsg:
X	cd utilities.d/MenuMsg.d; $(MAKE) CC=$(CC) MenuMsg
XMenuPrompt:
X	cd utilities.d/MenuMsg.d; $(MAKE) CC=$(CC) MenuPrompt
X
Xinstall:
X	strip menu
X	cp menu $(INSTALLDIR)
X	cp menu.hlp $(HELPDIR)
X#	cp sample.m $(INSTALLDIR)
X#	cp printers.m $(INSTALLDIR)
X#	cp reportsrn.m $(INSTALLDIR)
X	strip runrealid
X	cp runrealid $(INSTALLDIR)
X	cp utilities.d/checkpass.d/checkpass $(INSTALLDIR)
X	cp utilities.d/lock.d/lock $(INSTALLDIR)
X	cp utilities.d/lock.d/unlock $(INSTALLDIR)
X	cp utilities.d/msgbox.d/msgbox $(INSTALLDIR)
X	cp utilities.d/MenuMsg.d/MenuMsg $(INSTALLDIR)
X	cp utilities.d/MenuMsg.d/MenuPrompt $(INSTALLDIR)
X#	cp menu.1 $(MD)
X#	cp utilities.d/checkpass.d/checkpass.1 $(MD)
X#	cp utilities.d/lock.d/lock.1 $(MD)
X#	cp utilities.d/lock.d/unlock.1 $(MD)
X#	cp utilities.d/msgbox.d/msgbox.1 $(MD)
X#	cp utilities.d/MenuMsg.d/MenuMsg.1 $(MD)
X#	cp utilities.d/MenuMsg.d/MenuPrompt.1 $(MD)
X
Xlint:
X	lint -D LINT -I $(INCDIR) -I /usr/5include $(CFILES) -l curses -l c > menu.lint 
X
Xxref:
X	cxref -o menu.xref -c -t -I$(INCDIR) $(CFILES) > menu.xref
X
Xflow:
X	cflow -I$(INCDIR) $(CFILES) > menu.flow
X
Xprint:
X	ppgm -t$(TITLE) menu.1 makefile $(CFILES) $(HFILES) $(LFILES) $(YFILES)
X
Xshar:
X#	shar -b -c README makefile $(CFILES) $(HFILES) $(LFILES) $(YFILES) menu.hlp \
X#	$(MANPAGES) > menu.shar
X#	compress menu.shar
X#
X#	include HEADER file begining of file
X#	mkdir utilities.d directories
X	xshar -vcfx -l40 -omenu.shar. $(SHARFILES)
X
Xcpio:
X	cpio -oBcv > menu.cpio < Files
X	compress menu.cpio
X
Xclean:
X	rm -f *.o core menu menu.lint menu.shar* menu.xref menu.flow \
X	menu.shar.Z y.tab.h menu.cpio.Z runrealid
X	cd utilities.d/libgeti.d; $(MAKE) clean
X	rm -f utilities.d/lock.d/lock utilities.d/lock.d/unlock
X	rm -f utilities.d/lock.d/*.o
X	rm -f utilities.d/checkpass.d/checkpass utilities.d/checkpass.d/*.o
X	rm -f utilities.d/msgbox.d/msgbox utilities.d/msgbox.d/*.o
X	rm -f utilities.d/MenuMsg.d/MenuMsg utilities.d/MenuMsg.d/*.o
X	rm -f utilities.d/MenuMsg.d/MenuPrompt
X
Xlinks:
X	ln /usr/src/libgeti.d/findfile.c utilities.d/MenuAccess.d/findfile.c
X	ln /usr/src/libgeti.d/GetInput.c utilities.d/libgeti.d/GetInput.c
X
X#####
X#####
X
XMain.o:		Main.c menu.h
XParseOpton.o:	ParseOpton.c menu.h
XParseBaner.o:	ParseBaner.c menu.h
XParseBox.o:	ParseBox.c menu.h
XParseTitle.o:	ParseTitle.c menu.h
XParseLine.o:	ParseLine.c menu.h
XParseWindo.o:	ParseWindo.c menu.h
XParseComnt.o:	ParseComnt.c menu.h
XParseUnix.o:	ParseUnix.c menu.h
XParseGname.o:	ParseGname.c menu.h
XParseAuthr.o:	ParseAuthr.c menu.h
XParseText.o:	ParseText.c menu.h
XParseCur.o:	ParseCur.c menu.h
XParseSpace.o:	menu.h
XParInclude.o:	menu.h
XParAssign.o:	menu.h
XParAftMenu.o:	menu.h
XParseDeSrn.o: 	ParseDeSrn.y LexDeSrn.l menu.h
X		yacc $(YFLAGS) ParseDeSrn.y
X		$(CC) $(CFLAGS) -c y.tab.c
X		mv y.tab.o ParseDeSrn.o
X		rm -f y.tab.c
X
XShowOption.o:	ShowOption.c menu.h
X
XRunSystem.o:	RunSystem.c menu.h
XRunMenu.o:	RunMenu.c menu.h
XRunPopMenu.o:	RunPopMenu.c menu.h
XRunExit.o:	menu.h
XRunSetenv.o:	menu.h
XRunPopMenu.o:	menu.h
XRunGetI.o:	menu.h
X
Xparsedrive.o:	parsedrive.c menu.h
Xshowdriver.o:	showdriver.c menu.h 
Xrundriver.o:	rundriver.c menu.h terminal.h
XLoadKeys.o:	LoadKeys.c menu.h
XEndWindow.o:	EndWindow.c menu.h
XGetOption.o:	menu.h terminal.h
XSetTerm.o:	menu.h
Xsetvar.o:	menu.h
Xinitmenu.o:	menu.h
Xrunscreen.o:	menu.h terminal.h
XLexDeSrn.o: 	LexDeSrn.l ParseDeSrn.y menu.h
X		lex LexDeSrn.l
X		$(CC) -c $(CFLAGS) lex.yy.c
X		mv lex.yy.o LexDeSrn.o
X		rm -f lex.yy.c
X		rm -f y.tab.h
X
X#tokens.h: 	y.tab.h
X#		@if /bin/diff tokens.h y.tab.h > /dev/null 2> /dev/null;\
X#         	   then :; \
X#		   else cp y.tab.h tokens.h; \
X#		fi
X#calc.o: 	calc.y calc.l
X#		yacc $(YFLAGS) calc.y
X#		lex calc.l
X#		sed "s/#define YYABORT		return(1)/#define YYABORT return(-999)/" y.tab.c > junkme
X#		mv junkme y.tab.c
X#		rm -f junkme
X#		$(CC) $(CFLAGS) -c y.tab.c
X#		mv y.tab.o calc.o
X#		rm -f y.tab.c
X#		rm -f lex.yy.c
X#		rm -f y.tab.h
X
Xclean_menu.o:	menu.h
X
X
X#####
X#####	Inference Rules
X#####
X
X.SUFFIXES:
X.SUFFIXES: .o .ec .ec~ .c .c~ .h .h~
X
X.c~.c:
X	$(GET) $<
X.h~.h:
X	$(GET) $<
X.c.o:
X	$(CC) -c $(CFLAGS) $*.c
X.c~.o:
X	$(GET) -p $<> $*.c
X	$(CC) -c $(CFLAGS) $*.c
X	rm $*.c
X.ec.o:
X	esql $(CFLAGS) -c $<
X	rm -f $*.c
X.ec~.o:
X	$(GET) -p $<> $*.ec
X	esql $(CFLAGS) -c $<
X	rm $*.ec
X	rm $*.c
SHAR_EOF
chmod 0644 makefile || echo "restore of makefile fails"
echo "x - extracting menu.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > menu.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH MENU 1 "Version 3.63"
X.SH NAME
X.TP 12
Xmenu 
X\- a menu program
X.SH SYNOPSIS
X.B "menu  [ -v ] [ -p row,col ] [ -d ] [ -keys ] [ -notrap ]  menufile"
X
X.SH DESCRIPTION 
X\fBMenu(1)\fP is an easy-to-use menu utility that allows
Xusers to operate an application system in a user-friendly, menu-driven
Xenvironment.  Any application software, regardless of source language or
Xoperating system process can be executed from menus designed with
X\fIMenu(1)\fP.
X
XFor systems requiring multi-level menus for a diverse number of users,
X\fIMenu(1)\fP allows a single menu to call any number of submenus, which
Xmay in turn call more menus or execute any number of processes.
XMenus can be nested to any level without increasing
Xstartup time or memory requirements.
X
XMenus can also be designed to function as user-friendly data entry 
Xscreens for capturing data, which can then be used as input for a process.
XText items such as "displays", "choices" and "responses" can be added within 
Xany of these defined boundaries, and will automatically adjust if any 
Xboundaries are changed.  Special screen attributes, such as highlighting and
Xreverse video, can be defined to add special emphasis.
X
XThe menu script file contains all of the menu instructions, and can
Xbe edited using a standard system editor, such as vi.  Menus and utilities
Xcan be added or deleted by editing the appropriate script file, even while
Xthe menu is in use.  
X
XMenu provides flexibility in designing how you want your
Xmenus to look, yet, strives to maintain some consistency and functionality from
Xone menu to another.  Menu was designed with "hooks" built in, so that, if 
Xadditional features/functionality for an application is required 
Xthe programmers
Xnew "keyword" modules could be linked in to the driver routines in menu(1)
X(see Programming Notes).  Menu(1) could be used as a prototyping tool.
X.PP
XMenu is keyword driven.  
XThe menufile (script file) is parsed and when a defined keyword is found the
Xassociated function for that keyword is called.
XThe menufile is first searched for in your current directory and
Xthen in getenv("MENUDIR").  Menufile should be in basename format, use
XMENUDIR to get the full path name.  To be consistent with other file naming
Xconventions, I recommend that all menu script files be suffixed with a ".m"
Xfor menu.
XThe "menu.hlp" file contains the on-line help screen.
XThe help file is
Xfirst searched for in the current directory, then in getenv("HELPDIR"),
Xthen in getenv("MENUDIR").  Look in the directory where menu is installed
Xfor the help file (menu.hlp).  If you want to customize the help file, copy it
Xto another directory and set HELPDIR.
XMenu uses curses(3X) so you need to have your TERM variable set.
X.PP
XMenu provides a shell escape (!) depending upon whether the SHELL environment
Xvariable is set.  You should \fIunset SHELL\fP if you want to restrict the user
Xfrom the shell.  If the set uid bit is set on menu and a shell escape command
Xis selected by the user.  The uid and gid is set back to the real uid/gid
Xbefore executing the shell command.
X
X.SS Command Line Options
X.TP 6
X-v
XThe [-v] command line option will print the version of the menu program
Xyou are running.  The version number increasing by tenths usually indicate
Xnew capabilities/keywords, 
Xhundredths indicate bug fixes/enchancements to existing keywords/capabilities.
X.TP 6
X-p row,col
XTells menu what row and column (upper left corner) you
Xwant the pop-up menu, for goto menu names, to appear.
XSee .GNAME below.  Default is [6,8].  I would try to keep the pop-up 
Xmenu high and to the left, 
Xthere is no real intelligence built in if the number or length of GNAMES puts
Xit off the screen.
X.TP 6
X-d
XPrints debugging information to stderr.
X.TP 6
X-keys
XDetermine the various key values on your keyboard.  This displays what is
Xreturned from a curses getch() call with the keypad turned on.
XThis information can be used to custom tailor your .menuinit file.
X.TP 6
X-notrap
XDon't trap and ignore SIGINT,SIGQUIT signals.  This is good for testing so you
Xdon't lock up your terminal.  The default is to ignore those signals.
X
X.SS Syntax Used In This Man Page
XThe position of the arguments for the various keywords is important.  All
Xarguments including any
Xoptional arguments that are used must appear in the position shown in
Xthe synopsis for that keyword, unless stated otherwise.
X
X.TP 6
X[ ]
XThroughout this man page the "\fB[ ]\fP" indicate that what is enclosed is 
Xoptional.
X.TP 6
X[ \\\\\\ ]
XA keyword synopsis that has "\fB[ \\ ]\fP" as the last argument 
Xindicates that the continuation 
Xcharacter (\\) may be placed as the last character on the line to continue 
Xto the next line.
X.TP 6
X[!]
XIndicates a conditional environment variable setting.  If the variable is not
Xalready set (getenv(variable) == NULL) then the variable is set to the specified
Xvalue, otherwise it is not changed.  Same operation as doing a 
Xshell ${parameter:-word}.
X
X.SH KEYWORD SYNOPSIS
XThe following keywords are placed in a menu script file to tell \fImenu(1)\fP
Xwhat to do.  They are listed in alphabetical order, with special character
Xkeywords listed first.
X
X
X\fB[!]variable=value\fP
X.IP "" 6
XA environment variable assignment statement.  The environment variable defined
Xby \fIvariable\fP is set equal to the \fIvalue\fP specified.  The variable is 
Xset as soon as it is found while parsing the menufile, it becomes
Xpart of the menu environment so that all subsequent programs that are spawned
Xwill inherit these variables.
X
XThe character "$" in \fIvalue\fP is used to introduce substitutable 
Xparameters, in the form of ${\fIparameter\fP}.
XThe value, if any, of the \fIparameter\fP is substituted.  The braces are 
Xrequired only when \fIvalue\fP is followed by a letter, digit, or 
Xunderscore that is not to be interpreted as part of its name.
X
XThe character "~" in \fIvalue\fP is used to introduce tilde expansion.  
XMenu checks the value
Xto see if a "~" appears after the "=".  If it does menu checks the word that
Xfollows up to a "/".  A "~" by itself equals $HOME. A "~user" equals home(user).
X
XA pair of grave accents (`command`) introduce command substitution.  The
Xstandard output from the \fIcommand\fP is assigned to the variable.
X
XWarning: If you reset a environment variable in a GETINPUT that you have
Xdefined here.  The variable will get reset back to this value when the menufile
Xis re-parsed, unless you use the "!".
X. \ --------------------------------------------------------------------------
X.PP
X\fB###\fP  Comment text.
X.IP "" 6
XA comment line.  The entire line is ignored.  May be placed anywhere in
Xthe menufile.
X. \ --------------------------------------------------------------------------
X
X.PP
X\fB###NAME\fP  Alias menu name.
X.IP "" 6
XThis optional comment line is used by the MenuAccess(1) program to display
Xa different name on the screen for the menu instead of the unix file name,
Xmore user friendly.  This is recommended if you plan to use MenuAccess.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.AFTER_MENU\fP  [ REDRAW ]  [ GETINPUT screen_name ]  command  [ \\ ]
X.IP "" 6
XA command that is run after the user exits/gets out of/returns from a menu
XSee \fI.UNIX\fP for more info.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.AUTHORIZE\fP  logname  [ logname ... ]  [ \\ ]
X.IP "" 6
XAuthorize only certain login's to be able to access a menu.  For example
Xapplication administration functions to be done by application administrators
Xonly.  This can be done by putting those functions in one menu and
Xusing the .AUTHORIZE keyword.  \fILogname\fP is the login name of a user you
Xwant to allow to see this menu.  Only the
Xfirst .AUTHORIZE keyword will be used, so all lognames must be listed on 
Xthat line.
XIf no .AUTHORIZE is given in menufile then that menu is open to every one.
XIf a .AUTHORIZE is given in the main menu (first) then restriction would apply
Xto someone trying to get into the application.
X.br
XThis keyword is used by the \fIMenuAccess(1)\fP program.
X.br
X
X.br
XThis keyword authorizes a login at the menu level.  If you need to authorize
Xat the option level you could try something like this. (see .SYSTEM)
X.nf
X	.SYSTEM  if [ $LOGNAME = "stella" ] \\
X                   	        then  run_program \\
X                   	        else  echo "Sorry honey, Not Authorized." \\
X                	   fi
X	Option Description Text.
X.fi
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.BANNER\fP [ linecount ]
X .section  text
X.fi
X.IP "" 6
XDraws a banner page.  Linecount should be the number of lines
Xfollowing .BANNER, each consisting of ".section text".  Section
Xmay be either .U to display text in upper section or .L to
Xdisplay text in lower section.  Only four lines in each section
Xallowed.
XThe idea behind this was to provide some kind of welcome (to your
Xapplication) screen.
XIf .BANNER is used it should be the first keyword in menufile.
XThis one is really worthless!  It's too slooooow.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.BOX\fP [ StandoutLine ] [ DumbLine ]
X.IP "" 6
XDraws a box around the menu window.
XThe \fIBOX\fP will use the top line of the screen so the first \fI.TITLE\fP
Xline should be null.  The box will also use the first and last column,
Xyour title lines should take that into account.  You get a different effect
Xdepending on whether you place the .BOX before (with a .LINE) or after 
Xthe .TITLE lines.
X
XThe arguments specify what type of line you want to use to draw the box with.
XThe second argument specifies the type of line to use to dim the menu.
X.br
XAny one of the following may be used:
X.nf
X	DumbLine	\fIDefault line used in dimming.\fP
X	StandoutLine	\fIDefault line.\fP
X	SingleLine	\fIAlternate character line.\fP
X	MosaicLine	\fIAlternate character line.\fP
X	DiamondLine	\fIAlternate character line.\fP
X	DotLine		\fIAlternate character line.\fP
X	PlusLine		\fIAlternate character line.\fP
X.fi
XThe alternate character lines are dependent on your terminal (try "menu -key").
XNot all terminals have the capability to draw these lines.
XIf one of the alternate character lines is specified
Xand it is found that the terminal does not support it, the line will be
Xdrawn in StandoutLine.  Check your terminal manual and the terminfo definition
Xfor alternate character set.
X
XNot supported in a \fI.POPMENU\fP menu.  
XAll pop-up menus automatically get boxed.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.CURSOR\fP [-]row [-]column
X.fi
X.IP "" 6
XWhere do you want the cursor to appear on the screen?  If no \fI.CURSOR\fP
Xis specified it defaults to row=lastrow-2, column=lastcol-4.  
XSee explanation under .TEXT for negative row/column.
XThe \fI.CURSOR\fP
Xis only active for the current menu.  If you want the same cursor location
Xin every menu you will need to put a \fI.CURSOR\fP in every menu.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.DEFINE_SCREEN\fP  screen_name
X                    [ window_rows = number ]
X                    [ window_cols = number ]
X                    [ window_pos = number  number ]
X                    [ window_title = string ]
X                    [ window_border = string [ string ] ]
X                    [ helpfile = string ]
X                    [ field_defaults = "string" ]
X                    [ after_screen = "string" ]
X                    [ exit_last_field ]
X                    [ exit_on_cancel ]
X                    [ text = number number string ]
X
X                      ###  The following repeat for each field.
X
X                      field_name = $string
X                      field_row = number
X                      field_col = number
X                      field_length = number
X                    [ field_label = string ]
X                    [ field_mask = string ]
X                    [ field_edits = string ]
X                    [ field_range = string ]
X                    [ field_min = number ]
X                    [ field_adjust = string ]
X                    [ field_mustenter ]
X                    [ field_prompt = string ]
X                    [ field_terminator = string ]
X                    [ field_noinput ]
X                    [ before_field = "string" ]
X                    [ after_field = "string" ]
X ENDSCREEN
X.fi
X
X.RS 6
XThis keyword defines a input screen that can be used with the .GETINPUT keyword.
XIf you want the same screen definition in all menus you have
Xto place it in all menus (see .INCLUDE).
XThe ordering of the arguments is unimportant except for field_name, see below.
XThe screen arguments may be placed on the same line if separated by a comma.
XThe screen arguments are listed below with the default value
Xspecified for those arguments that are optional.
XSee GetInput(3X) man page for more information.
X
XYou may have a maximum of ten screens (MAXSCREENS) defined in any one menu and
Xa maximum of forty fields (MAXFIELDS) for any one screen.  This may be
Xincreased via the menu.h file.
X
XThe following arguments are listed in the order they are shown above.
X
XScreen Arguments:
X.RS 4
X.TP 15
Xscreen_name
XScreen Name.  Used with .GETINPUT to find screen definition.
XMaximum length of name is 30 characters.
X.TP 15
X[ window_rows ]
XNumber of rows in window.
X.br
XIf either window_rows or window_cols is zero, they will be set to the value 
Xof (screen_lines-window_pos(row)) and (screen_cols-window_pos(col)).
XIf the window_rows, window_cols and window_pos fields are all set to zero
Xa full-screen will be used.  See newwin(curses 3X) for more info.
XIf this argument is omitted then it will be automatically calculated.
X.TP 15
X[ window_cols ]
XNumber of columns in window.  See window_rows.
XIf this argument is omitted then it will be automatically calculated.
X.TP 15
X[ window_pos ]
XTop left corner to place the window at,  where the first number indicates the
Xrow and the second number indicates the column.  See window_rows.
XIf this argument is omitted then the window will be placed as close to, and to
Xthe right of, the option that selected it.  This argument is not optional if
Xthe screen is to be used with a .UNIX keyword.
XThere is no intelligence built in to check if you put the window outside 
Xthe screen dimensions.
X.br
XA environment variable may be specified for the arguments to window_pos.
X.TP 15
X[ window_title ]
XA title to be centered on line zero of the window.  A environment variable may 
Xbe specified in the title.  The title may not exceed 100 bytes.
XIf no window_title is specified a default of the option description text 
Xthat selected the \fIGETINPUT\fP screen is used.
X.TP 15
X[ window_border = Standout ]
XThe type of box you want around the window.  A standout box is the default.
XSee \fI.BOX\fP for description of line types.
X.TP 15
X[ helpfile = "menu.hlp" ]
XA help file associated with this window.  The helpfile should be in
Xdouble quotes if it has a "." in the name, and should be in basename format.
XThe helpfile is first looked for
Xin the current directory and then in \fI$HELPDIR\fP.  The fieldname (excluding
Xthe "$") becomes the tagname in the help file.  See \fIHELP SCREENS\fP in this 
Xdocument for more information.
XSet helpfile = "" if you don't want the Help message to appear in lower
Xright corner of window.
X.TP 15
X[ field_defaults = "" ]
XThis is used to initialize your fields to a default value at runtime.  
XWhat goes into the quoted
Xstring is a shell command that is passed into a popen(3) call.  What the shell
Xcommand should echo to stdout is the values you want to set your fields to.
XNo edit checks against the range values, if any, are performed on the default 
Xvalues.
XMaximum length of the shell command is 1k.
XField values composed of multiple strings should be quoted.  The quote should
Xalso be double escaped (\\\\"). If the number of
Xvalues echoed to stdout is less than the number of screen fields the remainder
Xof the screen fields are set to "".  To force a field value to "" echo \\"\\" to
Xstdout.
X.nf
SHAR_EOF
echo "End of part 1"
echo "File menu.1 is continued in part 2"
echo "2" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 2 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file menu.1 continued
#
CurArch=2
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 menu.1"
sed 's/^X//' << 'SHAR_EOF' >> menu.1
XFor example:
XAssuming $SNAME is a multiple worded value to be assigned to a field.
X
X	field_defaults = "cat \fIfilename\fP |
X		while [ $? -eq 0 ]
X		do
X			read LINE
X			[ $? -ne 0 ] && break
X			set $LINE
X			SCODE=$1
X			shift
X			SNAME=$*
X			echo $SCODE  \\\\"$SNAME\\\\"
X		done"
X.fi
X.TP 15
X[ after_screen = "" ]
XA command to be run after the user exits the screen.
XThis command does not get run if the user presses the \fIKEY_CANCEL\fP
Xkey to exit the screen.
X
XDiagnostics
X.RS 15
XThe following actions are taken by menu depending on what exit code your
Xcommand uses.
X.TP 8
X0
XAOK.
XIf your command prints something to stdout,
Xthat output (up to a newline) will be displayed to the screen as a message
Xto the message line before prompting for input again.
X.TP 8
X1
XIssue a audible bell.
XIf your command prints something to stdout,
Xthat output (up to a newline) will be displayed to the screen as a message
Xto the message line before prompting for input again.
X.TP 8
Xanything else
XNo action.
X.RE
X
X.RS 15
Xnote:  Other return codes will be added depending on demand.
X.RE
X
X.TP 15
X[ exit_last_field ]
XIf exit_last_field is specified, after the user presses return on the last field
Xthe input will be accepted and the user will exit the screen (this is as if the
Xuser had pressed the KEY_ACCEPT).  Don't ask me Lee wanted it.
X.TP 15
X[ exit_on_cancel ]
XOnly exit from the screen when the user presses the \fIKEY_CANCEL\fP key.
XThis is useful in combination with the \fIafter_screen\fP keyword if you
Xwant the capability, for example, to add a bunch of records without exiting
Xthe screen.  In this case, the \fIKEY_ACCEPT\fP key would add the record(s) 
Xby running the \fIafter_screen\fP command and 
Xthe user would signify he is done by pressing the \fIKEY_CANCEL\fP key.
X.br
XFor a good example of this see the sadmin.m menu script with the adduser
Xshell script in the utilities.d/m.d directory.
X.TP 15
X[ text = row col text ]
XAllows you to put any text at a specified row and column within the input
Xwindow.  Where the first number is the row (base 0) and the second number
Xis the column (base 0).  Remember the border of the window will take up
Xtwo rows and two columns.  The text will be written to the window before
Xany of the field stuff is placed on the window.  Any number of text lines
Xmay be specified up to \fIMAXTEXT\fP (20) defined in menu.h.
XIt's up to you to make sure your text stays in the window.
XThe text may contain terminal attributes.
X.RE
X
XField Arguments:
X.RS 4
X.TP 15
Xfield_name
XThe environment variable name that the data will be assigned to.  The field_name
Xmust begin with a "$", just to remind you that it is a environment variable 
Xthat I 
Xam using.  Although, the "$" is not actually used in the environment variable 
Xname.  This screen argument (field_name) tells menu that you are starting 
Xa new field
Xdefinition.  ..soooo...  It has to be the first argument for a field.  
XAll other field
Xarguments for that field_name follows after, but before the next field_name.
X
XThe user's input is immediatly accessable, via the environment variable,
Xas soon as the user exits the field.  If the \fIKEY_CANCEL\fP is pressed
Xto exit the screen.  All environment variables are set back to their original
Xvalues, before the screen was entered.
X.TP 15
Xfield_row
XThe row this field will appear on (base zero).
XThe window is drawn with a box on the outer edge, row zero and the last 
Xrow (window_rows) is used for the box.
X.TP 15
Xfield_col
XThe starting column for this field (base zero).  
XIf you have a field_label you need to allow enough room to place the label 
Xto the left of the field, also, the field terminators.
XThe window is drawn with
Xa box on the outer edge, so, column zero and the last column (window_cols) 
Xis used for the box.
X.TP 15
Xfield_length
XMaximum length of this field.  For field types SET and MENU this argument
Xbecomes optional, the field length is automatically set to the longest set value
Xin the field_range.
X.TP 15
X[ field_label = "" ]
XA Label to be placed to the left of the field.
X. \ **********************************
X.TP 15
X[ field_mask = "" ]
XValid masks for a field depend upon the type of field
Xyou specified, see (field_edits).  Basically the mask says what character
Xpositions in the field you allow input, what type of character allowed at that
Xposition, and what kind of a format do you want for the field.
X
XThe \fIfield_length\fP should not include character positions where no input
Xis allowed in the mask (format characters), because format characters
Xare not returned into \fIfield_name\fP.  For example, \fIfield_edits = DATE,
Xfield_mask = "MM/DD/YY"\fP.  The "/" is a format character.  The cursor
Xwill skip over those positions in the field.  Only the characters typed in
Xthe MM DD YY positions will be in the environment variable \fIfield_name\fP.
XThe field_length would be six.
X
XBecause the mask is so closely tied to the \fIfield_edits\fP, a complete
Xdescription of what mask characters are valid with what field types is 
Xdescribed under
X\fIfield_edits\fP.  Any character in the mask that is not listed as a valid
Xmask character for that field type becomes a format character.
X. \ ---------------------------------
X.TP 15
X[ field_edits = UPPER_AN ]
XThis argument defines edit checks to be performed on the
Xinput characters as they are being typed in.  If no mask is provided then
Xthe field type itself determines the edit checks to be performed on all
Xcharacters in the field.
X.RS 15
X.TP 11
XALPHANUM
XAny alpha/numeric character is allowed.
X.br
XValid mask characters:
X.nf
X	space	alpha/numeric
X	A	alpha
X	9	numeric
X	U	alpha only - convert to upper case
X	V	alpha/numeric - convert alpha to upper case
X	H	???
X.fi
X.TP
XALPHA
XAlpha only.
X.br
XValid mask characters:
X.nf
X	A	alpha
X.fi
X.TP
XNUMERIC
XNumeric only.
X.br
XValid mask characters:
X.nf
X	9	numeric
X.fi
X.TP
XUPPER
XConvert to upper case.  Only alpha permitted.
X.br
XValid mask characters:
X.nf
X	U	upper alpha
X.fi
X.TP
XUPPER_AN
XAlpha and numeric permitted.  Convert alpha characters to upper-case.
X.br
XValid mask characters:
X.nf
X	V	upper alpha/numeric
X.fi
X.TP
XHEX
XOnly hex characters permitted.
X.br
XValid mask characters:
X.nf
X	H	???
X	space	???
X.fi
X.TP
XSTATE
XValid two character Post Office abbreviations for the fifty states.
XA edit check is done for a valid state.
X.br
XValid mask characters:
X.nf
X	SS	two character state
X	S	???
X	space	???
X.fi
X.TP
XZIP
XPost Office zip code.
X.br
XValid mask characters:
X.nf
X	99999-9999	???
X.fi
X.TP
XDATE
XA valid date.
X.br
XValid mask characters:
X.nf
X	MM	month  (01-12)
X	DD	day  (01-31)
X	YY	year  (00-99)
X	YYYY	full year with century
X.fi
XThe mask must contain at least MM and DD.  If no mask is specified for the
Xfield a default mask of "MMDDYY" is used.
X.br
XSome examples:
X.nf
X	MMDDYY
X	MM/DD/YY
X	YY-MM-DD
X	MM  DD  YYYY
X.fi
X
XThe \fIfield_range\fP argument may contain any of the following keywords
X(case insensitive)
Xand the appropriate edit will be performed (see \fIfield_range\fP for more
Xinfo).
X.nf
X	sun,mon,tue,
X	wed,thr,fri,sat	- validate date entered against day of week.
X	No_Holidays	- no holidays allowed.  
X			  This is validated against the file 
X			  /usr/lib/acct/holidays by default.  
X			  Modify GetInput.h to change default.
X	GT_Today	- date must be greater than todays date.
X	GE_Today	- greater than or equal to todays date.
X	LT_Today	- less than todays date.
X	LE_Today	- less than or equal to todays date.
X.fi
X.TP
XTIME
XA time field.
X.br
XValid mask characters:
X.nf
X	HH	hours  (01-12)
X	MM	minutes  (00-59)
X	SS	seconds  (00-59)
X	TT	tenths  (00-99)
X	II	military hours  (00-24)
X.fi
XSome examples:
X.nf
X	HH:MM
X	HH:MM:SS
X	HH:MM:SS:TT
X	II:MM
X	II:MM:SS
X	II:MM:SS:TT
X.fi
X.TP
XSET
XThis field type specifies a set of values that are acceptable in the input 
Xfield.
XThe acceptable values within the set are specified in the \fIfield_range\fP 
Xargument.  
XThe user selects one of the set values specified in the field range by
Xpressing the space bar, which will toggle through the set values,
Xor by pressing the first character in the desired value.
X
XThe format of the field_range can only be comma separated values 
X(ex. "CA,ID,TX").  
XRange values, such as "1-5", don't work.  You would have to say "1,2,3,4,5".
X.br
XThe field length is automatically set to the longest set value in the 
Xfield_range.
X.TP
XMENU
XThis field type is similar to the SET type.  The difference is when the user
Xattempts to type something in the field a pop-up menu of available choices
Xare displayed, as specified in field_range.  
XThe user makes a selection by hi-lighting the choice and pressing return.
X.br
XSee SET type for specifying the field range.
XThe limit is ten items in the field range.
X.TP
XPROTECT
XThis X's out the field so that what is entered on the keyboard can not be seen
Xon the screen.  Useful for password entry.
X.RE
X. \ ---------------------------------
X.TP 15
X[ field_range = "" ]
XA set of valid ranges permitted for this field. 
XRanges may be specified as comma separated values ("ONE,TWO,THREE") 
Xor as a inclusive range ("1-5"), or a combination of both ("1-5,M,E").
XThe comma separated range values are "or" conditions not "and" conditions,
Xexcept for
XDATE ranges.  Date range "mon-fri,No_Holidays" means date must be mon-fri
Xand not a holiday.
XRange values must be compatible with the field_edits that you have selected.
XMaximum length of this field is 1k.
X
XInstead of hard coding the range values a command may be specified,
Xenclosed in grave accents, that will echo to stdout the range values to
Xbe used.  The command will be run once upon entering the screen.
X.br
XSome examples:
X.nf
X	"1-10"
X	"5,10,15,16"
X	"1-10,20,M,E,32-40"
X	",CA,TX,ID"
X	"mon-fri"
X
X	### this command builds a field_range of valid printers
X	"`lpstat -p | awk '{ print $2 }' |
X		for printer in `cat`
X		do
X			if [ \\"$printer\\" = \\"unknown\\" ]
X			   then continue
X			fi
X			if [ -z \\"$RANGEVALUES\\" ]
X	      		   then RANGEVALUES=$printer
X	      		   else RANGEVALUES=\\"$RANGEVALUES,$printer\\"
X			fi
X			echo $RANGEVALUES > /tmp/menu.tmpfile
X		done
X		cat /tmp/menu.tmpfile`"
X.fi
X. \ ---------------------------------
X.TP 15
X[ field_min = 0 ]
XIf field_mustenter is selected then this is the minimum
Xrequired input.  Otherwise, it is the minimum required input only if they try 
Xto input something.
X.br
XWarning: If you select a \fIfield_adjust\fP that blank fills then this 
Xoption will have no meaning because there will be spaces in the field.
X.TP 15
X[ field_adjust = NOFILL ]
XIndicates whether to adjust the text right or left within the field
Xand whether or not to zero or blank fill the field.
X.RS 15
X.TP 15
XNOFILL
Xno action.
X.TP
XRTADJ_ZFILL
Xright adjust, zero fill
X.TP
XRTADJ_BFILL
Xright adjust, blank fill
X.TP
XLFADJ_ZFILL
Xleft adjust, zero fill
X.TP
XLFADJ_BFILL
Xleft adjust, blank fill
X.RE
X. \ ---------------------------------
X.TP 15
X[ field_mustenter ]
XMarks this as a must enter field.  Default is that the field is not
Xa must enter field.
X. \ ---------------------------------
X.TP 15
X[ field_prompt = "" ]
XPrompt message to be displayed.
X. \ ---------------------------------
X.TP 15
X[ field_terminator = "[]" ]
XCharacters to terminate the field with.  The left one goes on the left, 
Xthe right one goes on the right.  Funny how that works.  I recommend
Xto use terminators on input fields and no terminators (spaces) for
X\fIfield_noinput\fP fields.
X. \ ---------------------------------
X.TP 15
X[ field_noinput ]
XIf field_noinput is selected then the cursor will skip over this field.  A
Xdisplay only field.
X.TP 15
X[ before_field = "" ]
XWhat goes into the quoted string is a shell command that is passed into a 
Xpopen(3) call before any input is done or default values displayed.
X
XDiagnostics
X.RS 15
XThe following actions are taken by menu depending on what exit code your
Xcommand uses.
X.TP 8
X0
XAOK. Continue to prompt for input.
XYour command may print to stdout, up to a newline, enviroment variable 
Xsettings to change the values of your \fIfield_names\fP.  For example
X"$FIELD_1=value1 $FIELD_2=value2 ...".  The new values are displayed 
Ximmediately to the fields.
X.TP 8
X1
XAOK.  Continue to prompt for input.  If your command prints something to stdout,
Xthat output (up to a newline) will be displayed to the screen as a message
Xto the message line.
X.TP 8
X2
XSkip this field.  Same effect as specifying \fIfield_noinput\fP, only this 
Xhappens at runtime.
X.TP 8
Xanything else
XDo nothing.
X.RE
X
X.RS 15
Xnote:  Other return codes will be added depending on demand.
X.RE
X
X.TP 15
X[ after_field = "" ]
XWhat goes into the quoted string is a shell command that is passed into a 
Xpopen(3) call after the user exits the field.
XThis command does not get run if the user presses the KEY_CANCEL key 
Xwhile in this field.
X
XDiagnostics
X.RS 15
XThe following actions are taken by menu depending on what exit code your
Xcommand uses.
X.TP 8
X0
XAOK. Continue to next field.
XYour command may print to stdout, up to a newline, enviroment variable 
Xsettings to change the values of your \fIfield_names\fP.  For example
X"$FIELD_1=value1 $FIELD_2=value2 ...".  The new values are displayed 
Ximmediately to the fields.
X.TP 8
X1
XStay on this field (re-input).  Issue a audible bell.
XIf your command prints something to stdout,
Xthat output (up to a newline) will be displayed to the screen as a message
Xto the message line before prompting for input again.
X.TP 8
Xanything else
XDo nothing.
X.RE
X
X.RS 15
Xnote:  Other return codes will be added depending on demand.
X.RE
X
X.RE
X.RE
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.EXIT\fP [ command ]   [ \\ ]
XExit description text.
X.fi
X.IP "" 6
XExit menu program.  This can be used if you want to exit as a user
Xselectable option.  There should be only one .EXIT per menu.
X.br
XIf command is present a system(3S) will be called, with command as the
Xargument, before exiting.  The command will be executed even if the user uses
Xthe "E" command (see help) to exit, as long as there is a .EXIT 
Xin current menu.  If you
Xwant to make sure a particular command gets executed when the user exits you
Xshould have a ".EXIT command" in every menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.GETINPUT\fP  screen_name [ [!]variable=value ... ] [ \\ ]
XOption description text.
X.fi
X.IP "" 6
XDisplays a predefined screen and prompts for input
Xas outlined in the screen definition.
XAfter the user has pressed the \fIKEY_ACCEPT\fP
Xthe environment variables, specified by the \fIfield_name\fP argument
Xis set equal to the data the user entered in that field.
XIf no data was entered for a field the environment variable is set equal to
X"".
XThe after_screen command is executed after every \fIKEY_ACCEPT\fP.
XIf \fIKEY_CANCEL\fP is pressed the environment variables are not set.
X.br
XThe screen_name is what was used in the .DEFINE_SCREEN keyword.
XThe \fIvariable=value\fP are set at runtime (when the user selects the
Xoption).
X
X
XThe cursor moves from field to field based upon the order of the fields in
Xthe \fI.DEFINE_SCREEN\fP keyword.  
XBelow is listed the various keys used in a GETINPUT, the action they perform 
Xand their default value.  In addition to the default values, if the terminal
Xhas a associated curses key defined (see curses.h) that key may also be used.
XFor example, ^j is the default value to traverse forwards through the fields
Xbut if the down arrow is defined for KEY_DOWN, in curses, then the down arrow 
Xmay also be used.  Not all keys may have an associated curses key.
XThe "^" indicates press and hold the control key.
X.br
XSee \fIMenu Initialization File\fP to customize the values of the keys.
X
XMover Keys:
X.nf
X	KEY_RETURN  (^m)	Traverse forwards through the fields.
X	KEY_DOWN  (^j)	Traverse forwards through the fields.
X	KEY_UP  (^k)		Traverse backwards through the fields.
X	KEY_TAB  (^i)		Fast forward through the fields.
X	KEY_BTAB  		Fast reverse through the fields.
XField Editing Keys:
X	KEY_BEG  (^b)		Place cursor at beginning of field.
X	KEY_END  (^e)		Place cursor at end of input in field.
X	KEY_RIGHT  (^l)	Forward space within the field.
X	KEY_LEFT  (^h)		Backspace within the field (non-destructive).
X	KEY_BACKSPACE  (^h)	Same as KEY_LEFT.
X	KEY_EOL  (^d)		Delete from cursor to end of field.
X	KEY_DL  (^c)		Clear field and home cursor.
X	KEY_DC  (^x)		Delete a character.
X	KEY_IC  (^t)		Toggle between type-over and insert mode.
XOther Keys:
X	KEY_HELP  (?)		Display help screen.
X	KEY_REFRESH  (^r)	Redraw the screen.
X	KEY_ACCEPT  (^a)	Accept all input and exit screen.
X	KEY_CANCEL  (esc)	Cancel all input and exit screen.
X	KEY_SAVE  (^f)		Save screen to a file.
X	KEY_PRINT  (^p)	Print screen to lp.
X.fi
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.GNAME\fP menuname menufile
X.IP "" 6
XDefine a goto name for a menu so that the user may go directly to that
Xmenu by typing in the menu name (G "return" menuname "return").  
XMenuname is the name you want
Xthe user to input.  Menuname has to be one word and is limited to fifteen
Xcharacters.
XMenufile is the unix filename for that menu.  The .GNAME
Xis not accessible to the user until the menufile that you have placed the .GNAME
Xin has been displayed.  If all .GNAME's have been placed in the main menu
Xthen they will all be accessible to the user as soon as the main menu has
Xbeen displayed.
X.br
XInstead of having the user type (G "return" menuname "return") try 
X(control g).
X
XWarning:
X.br
XThis should not be used to goto a pop-up (.POPMENU) type menu.  It doesn't
Xwork too well.  If your .MENU calls a .GETINPUT screen or sets environment
Xvariables before it calls the menu those will not be called if you use a
Xgoto for that menu.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.INCLUDE\fP menufile
X.IP "" 6
XInclude a menu script file.  This is so you don't have to type the same 
Xscreen definition in all the menu files that you want to use it in.
XAlthough, it could be used for any menufile.
XIt is significant where you place the .INCLUDE in your menufile, depending on
Xwhat is in the .INCLUDE menufile.  Think of it as if you were typing it in
Xat this point in the menu file.
X
XThe file is looked for first in the current directory and
Xthen in \fI$MENUDIR\fP.  The \fImenufile\fP may be a environment variable or 
Xabsolute pathname of the file.
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.LINE\fP [ StandoutLine ] [ DumbLine ]
X.IP "" 6
XDraws a standout line underneath your last title line to
Xsplit the options portion of the screen from the title portion.
XPlace after last \fI.TITLE\fP.
X.br
XSee .BOX for description of line types.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.MENU\fP menufile  [ [!]variable=value ... ]  [ GETINPUT screen_name ]  [ [!]variable=value  ... ]   [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XDefines this option as a sub-menu.  When user selects this option
Xthe menu defined in "menufile" will be parsed and displayed.
X
XThe [ GETINPUT ] option allows you to display a screen and prompt a user for
Xinput.  The screen is displayed before parsing of the new menu is begun.
XThis could be used to prompt a user for a password with a .UNIX in the calling
Xmenu using checkpass(1) to check permission to run the menu.
XCompliments of Victoria.
X
XA environment variable may be specified in the Option description text.
X.br
X
XThe optional variables are environment variables that will be set equal to
Xthe value specified when the user selects this option.  
XPlacing them before or after a GETINPUT call causes them to be set either
Xbefore or after the GETINPUT screen is called.
XThis can be used
Xto pass data to a sub menu.  Maximum length of the .MENU line is 700 bytes.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.POPMENU\fP [ NoDim ] menufile [ row column ] [ [!]variable=value  ... ]  [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XDefines this option as a pop-up menu.  When user selects this option
Xthe script file "menufile" will be parsed and displayed.  
XThe optional row and column (upper left corner) is where you want the pop-up 
Xmenu to pop-up.  If row and column is omitted then the menu will be placed
Xas close to the option, that is selecting it, as possible.
XSee \fI.SETENV\fP for \fIvariable=value\fP.
X
XThe [ NoDim ] flag tells menu not to dim the box on a inactive menu.  The
Xdefault is to dim inactive menus.  That way the user can easily see what
Xmenu they are working with.
X
XA environment variable may be specified in the Option description text.
X
XThe options in a pop-up menu can be selected by hi-lighting the option
Xand pressing return, or ESC to cancel.  The pop-up menu goes away after
Xan option has been selected and you are put back in your calling menu 
X(the calling menu is reparsed).
XThis keyword was provided for those options where the user would go over to
Xa menu select an item then return back.  A printer select menu would be ideal
Xfor this keyword.
X
XYou can toggle between full character matching and single (first) character
Xmatching by pressing KEY_IC/KeyIC key.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.SETENV\fP  [ BELL ] [!]variable=value [ [!]variable=value ... ] [ message ]   [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XWhen the user selects this option it will set
Xa variable to a value in the the current environment (i.e. the menu
Xenvironment).  This is useful if you want something like a printer menu
Xlisting available printers and changing the $LPDEST so all print jobs
Xwill go to the new printer.
XThe \fImessage\fP argument is what is printed to the screen so the user
Xcan get feed back that his selection did something.
XThe \fIBELL\fP argument provides an audible beep if the variables were
Xset successfully.
X
Xnote:
X.br
X      If the message has a "=" sign in it menu will think it is a
X      "variable=value" and will try to set a environment variable.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.SPACE\fP
X.fi
X.IP "" 6
XPut a space in between options.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.SYSTEM\fP [ [ variable=value ... ] GETINPUT screen_name ] command   [ \\ ]
X Option description text.
X.fi
X.IP "" 6
XDefines this option as a system call.  When user selects this option
Xa system call will be executed, with command as the argument. Since the command
Xis a argument to system(3S) anything you can type at the $ prompt you can
Xput in the command.
XMaximum length of \fIcommand\fP is 1k.
XA environment variable may be specified in the Option description text.
X
XThe [ GETINPUT ] option allows you to display a screen and prompt a user for
Xinput that could be used as command line arguments to the command.  
XThe screen_name is a defined screen name.
XSee .GETINPUT and .DEFINE_SCREEN for more information.
X.br
XThe optional \fIvariable=value\fP arguments associated with the GETINPUT
Xare set at runtime, when the user selects this option.  This could be
Xused to have a dynamic window_title in your GETINPUT screen.
X
XExample: Say you need to prompt the user for a $DATA field then pass that 
Xfield into
Xyour program, lock the program so that program cannot be run until this one 
Xfinishes
Xand you want to kick the program off in the back ground.  You
Xcould try something like this (see lock(1),unlock(1)):
X.nf
X   .SYSTEM     GETINPUT  screen1 \\
X		lock program_name; \\
X		if [ $? -eq 0 ] \\
X		   then	(nohup program_name $DATA; nohup unlock program_name)& \\
X		   else	echo "Program Already Running."; \\
X			echo "Press [ Return ] to continue ...\\c"; \\
X			read reply \\
X		fi
X   Option Description Text.
X
X
X
XNote: No error checking is done for \fIcommand\fP.  If error checking is
Ximportant for your application you will need to build it into 
Xyour \fIcommand\fP.
X.fi
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.TEXT\fP [-]row [-]column
X Text goes on this line.
X.fi
X.IP "" 6
XAllows you to put any text at a specified row and column on the \fIstdscr\fP 
Xscreen (base 0).
XA negative row and/or column indicates number of rows from the bottom of the
Xscreen or number of columns from the right of the screen (relative addressing).
XFor example, \fI.TEXT -4 -20\fP will display text on the 4th row from the
Xbottom and the 20th column from the right.  This could be useful if your users
Xare using different sized terminals/windows.  If the row and/or column are 
Xgreater than the window size the text will get displayed on the last row or
Xlast column of the screen.
X
XThis keyword could be used to
Xplace a prompt text next to the cursor.  The \fI.TEXT\fP is only active for
Xthe current menu.  If you want the same text to appear in every menu you
Xwill need to put a \fI.TEXT\fP in every menu.
XTerminal attributes may be placed in the text line (see Terminal Attributes).
X
XA environment variable may be specified within the text.
X
XThe last line of the screen is used to report error messages, like 
X\fIInvalid Option\fP.  Your text will probably get erased if put on the last
Xline.
X. \ --------------------------------------------------------------------------
X
X.PP
X.nf
X \fB.TITLE\fP
X Title Line text.
X.fi
X.IP "" 6
XDisplay a title line top of menu.
XTitle lines will start at row zero.
XMultiple .TITLE lines may be defined up to MAXTITLE (6) defined in
Xmenu.h file.
X
XThe title line consists of three sections defined as follows:
X.br
Xleft text...center text...right text
X.br
XText you place in the three sections will be either left justified,
Xcentered, or right justified on the screen.  The "\fB...\fP" are used to
Xseparate the sections.
X
X.RS 6
X.PP
XA substitutable variable may be specified within the title line text.
XThe character $ is used to introduce substitutable 
Xparameters, in the form of ${\fIparameter\fP}.
XThe value, if any, of the \fIparameter\fP is substituted.  The braces are 
Xrequired only when \fIparameter\fP is followed by a letter, digit, or 
Xunderscore that is not to be interpreted as part of its name.  See sh(1) 
Xfor more info.
X.TP 6
X$DATE
Xmay be placed anywhere in title text and the system date (mm/dd/yy) will
Xbe displayed.
X.TP 6
X$TIME
Xmay be placed anywhere in title text and the system time (hh:mm zz) will 
Xbe displayed.
X
X.TP 6
X$MAIL
XThe \fI$MAIL\fP is a special environment variable.  This turns on the mail
Xnotification facility.  $MAIL may be placed anywhere in the title text and when
Xthe user has mail to be read the word "\fBMAIL\fP" will be displayed in
Xreverse video at that location in the title line, with an audible beep.
XThe MAIL environment variable needs to be set to the users mail file, ex.
X"MAIL=/usr/mail/pjc".  The environment variable \fIMAILCHECK\fP is used to
Xdetermine how often to check for mail.  See mail(1).
X.br
XIf you have a hierarchy of menus for your application \fI$MAIL\fP only needs
Xto be in the first menu.
X
XWarning: If menu is run with the set uid bit set, menu will be unable to
Xdetermine if your mail is being forwarded, because it won't have read
Xpermission on your mail file, and \fIMAIL\fP will be displayed all the time
Xon machines where you forward your mail.
X.TP
XTerminal Attributes
XAttributes may be specified anywhere in the title text as follows:
X.nf
X\\S = Standout
X\\B = Bold
X\\U = Underline
X\\D = Dim
X\\R = Reverse Video
X\\L = Blink
X\\N = Normal
X
Xexample: \\RThis text is reverse video.\\N Now normal.
X
Xnote: Terminal attributes are terminal dependent.
XBerkeleys' version of curses only supports Standout.  Attributes may
Xalso be combined.
X.fi
X
XFor \fI.POPMENU\fP there is no left,center,right sections.  The title is
Xcentered.  You can have only one \fI.TITLE\fP in a pop-up menu.  No attributes
Xand/or environment variables are supported in the title for pop-up menus.
X.RE
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.UNIX\fP  [ REDRAW ]  [ GETINPUT screen_name ]  command  [ \\ ]
X.IP "" 6
XA system(3) call with command as the argument is executed immediately 
Xwhen found while parsing the 
Xmenufile.  Can be used to set function keys on terminal.  Warning: if
Xyou use this to set function keys and the function keys are changed in
Xanother program, they do not get reset back to what they were in the menu.
XMaximum length of command is 700 characters.
X
XThe [ GETINPUT ] option allows you to display a screen and prompt a user for
Xinput, before the command is run.
XThe window_pos argument to DEFINE_SCREEN must be specified in order to use
Xthe screen here, because, menu is unable to automatically figure out where to 
Xput the screen because this is happing during the parsing stage.
XAdditionally, the \fIDEFINE_SCREEN\fP must be declared before the \fI.UNIX\fP.
X
XThe [ REDRAW ] flag instructs menu to redraw the menu screen after your command
Xhas been executed.  This is recommended if your command writes anything to
Xthe screen.
X
XDiagnostics
X.RS 10
XThe following actions are taken by menu depending on what exit code your
Xcommand uses.
X.TP 8
X0
XAOK. Continue to parse the next keyword.
X.TP 8
X1
XQuit/Exit the menu program.
X.TP 8
X4
XReturn to previous menu and display the error message 
X"Not Authorized to run menu.".
X.TP 8
X> 4
XQuit parsing this menu and return to previous menu.  No message.
X.RE
X
X.RS 6
XExample:  Authorize menu access.
X.nf
X         .UNIX grep $LOGNAME access_table >/dev/null 2>/dev/null \\
X		[ $? -ne 0 ] && exit 4 \\
X		exit 0
X.fi
X
XExample:  Build a menu script file at run time.
X.nf
X       ###  Printer Selection Menu
X       ###  Build a .POPMENU of available printers connected to a system.
X
X          .UNIX echo ".TITLE" > printers.m; \\
X	         echo "Printer Menu" >> printers.m; \\
X	         echo ".TEXT 23 0" >> printers.m; \\
X	         echo "Select A Printer." >> printers.m; \\
X	         lpstat -p | awk '{ print $2 }' | \\
X	         for i in `cat` \\
X	         do \\
X		     echo ".SETENV LPDEST=$i  Printer ($i) selected." >>printers.m; \\
X		     echo "$i" >> printers.m; \\
X	         done; \\
X	         exit 0
X
X          .POPMENU printers.m
X          Select Default Printer.
X.fi
X.RE
X. \ --------------------------------------------------------------------------
X
X.PP
X \fB.WINDOW\fP  first_row  last_row  first_col  last_col  [ heading ]
X.IP "" 6
XDefines a window area (rectangle) to display the options that follow this 
Xkeyword (up to the next \fI.WINDOW\fP or end of file).
XThe options are centered between first_row / last_row
Xand between first_col / last_col.
XThe \fIrows\fR and \fIcolumns\fR are absolute (base 0) and inclusive.  
XIt is up to you
Xto make sure they don't overlap (unless that's what you want), and
Xthat it is large enough to hold the options that follow.
XThe optional \fIheading\fR is text you wish centered over the window area
X(rectangle).
XIt is
Xdisplayed on \fIfirst_row\fR minus one.
XThe heading may contain terminal attributes as described under \fI.TITLE\fR.
XYour \fI.WINDOW\fP keywords should be placed after all \fI.TITLE\fP(s).
X.br
XFor example suppose you want two columns of options on the screen, one
Xof which will have a heading:
X.nf
X .WINDOW 0 23 0 39
X1. this option in left column
X2. this option in left column
X .WINDOW 10 23 40 79 \\R REPORTS \\N
X3. this option in right column
X
X.fi
XIf no .WINDOW is used a default of .WINDOW 0 screen_rows 0 screen_cols 
Xis used for all options.
X
XNot supported in a \fI.POPMENU\fP menu.
X. \ --------------------------------------------------------------------------
X
X.SH HELP SCREENS
XThe default help file for menu(1) is \fImenu.hlp\fP.  Additional help files
Xmay be used in a GETINPUT screen.  The following describes the the syntax of
Xa help file.
X
X\fBtagname\fP
X.br
X[ .TITLE   A Title May Be Placed Here. ]
X.br
XA tagname identifies a help screen and must be on a line by itself.
X.br
XThe text (with optional terminal attributes) to be displayed for this tagname 
Xis placed between the two tags.  Don't use tabs to space the text 
X(it don't work), you have to put in hard spaces.
XMore than one tagname may be placed in a help file.
XAny text outside of a tagname is ignored.
X.br
X\fBtagname\fP
X
X
XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
Xis to be contained in the table of contents for help.  The following is the
Xsyntax for this tagname.
X.nf
X\fBTABLE_OF_CONTENTS\fP
Xhelpfile   tagname   description
Xhelpfile   tagname   description
X	etc...
X\fBTABLE_OF_CONTENTS\fP
X.fi
X
X
XBelow is shown the default help file for menu(1)  (menu.hlp).
XIt has four tagnames in it (TABLE_OF_CONTENTS, menu, popmenu, GETINPUT 
Xand help).  This file may be customized to fit your needs.
X
X.nf
X\fBTABLE_OF_CONTENTS\fP
Xmenu.hlp	menu		Menus      - Help using menus.
Xmenu.hlp	popmenu	Pop-menus  - Help using popmenus.
Xmenu.hlp	GETINPUT	Input      - Editing commands.
Xmenu.hlp	help		Help       - Using help.
X\fBTABLE_OF_CONTENTS\fP
X
X
X\fBmenu\fP
X .TITLE Menu Help
X
X  \\RMENU COMMANDS:\\N
X          m       \\D-  Go directly to main menu.\\N
X          p       \\D-  Return to previous menu.\\N
X          g or ^g \\D-  Go directly to a specific menu.\\N
X          h or ?  \\D-  This help screen.\\N
X          ^r      \\D-  Redraw the screen.\\N
X          e       \\D-  Exit.\N
X          !       \\D-  Enter a unix command.\\N
X
X  \\RSELECTING OPTIONS:\\N
X          -  Use "up arrow key", "^k", "down arrow key", "^j" or
X             "tab key" to place bar on option and press "return".    
X
X                  or
X
X          -  Enter option number and press "return".
X
X\fBmenu\fP
X
X\fBpopmenu\fP
X .TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    To select an option press the "up arrow key",
X    "k", "down arrow key", "j" to place bar on
X    option and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
X\fBpopmenu\fP
X
X\fBGETINPUT\fP
X .TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X	.
X	. (etc.  see GETINPUT)
X	.
X        KEY_PRINT  (^p)     Print screen to lp.
X\fBGETINPUT\fP
X
X\fBhelp\fP
X .TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)	Exit help.
X        KEY_DOWN  (^j)	View a few more lines.
X        KEY_UP  (^k)	View the previous lines.
X        KEY_BEG  (^b)	Display first page.
X        KEY_END  (^e)	Display last page.
X        KEY_TOC  (^t)	Display help table of contents.
X\fBhelp\fP
X.fi
X
X.SH MENU INITIALIZATION FILE - (.menuinit)
XA menu initialization file can be provided that
Xcontains initialization commands
Xto menu.  This file is read when menu is first started.  The \fI.menuinit\fP
Xfile is first looked for in the current directory then in getenv("HOME")
Xthen in getenv("MENUDIR").  This file is not needed if the default settings 
Xsuffice.  
X
XBelow is listed a .menuinit 
Xfile with all the various initialization commands and their associated default 
Xvalue.  The decimal value is what is returned from a curses getch() call.  
X\fITry menu  -keys\fP.  Setting a key value to minus one disables the key, 
Xalthough the associated curses key, if any, is still active.
X
XNote: Menu(1) does character matching (case insensitive) on the option
Xdescription,
Xin addition to entering the number
Xof the option, to select a option.  The character matching is done after it
Xhas checked for any of the following keys.  So, for example, if you use the
Xdefault setting for KEY_EXITMENU (e) and you have a option titled "Enter ...".
XThe user will not be able to press a "e" for character matching on "Enter ...".
XThe exit menu process will be enabled.  This should be considered in
Xselecting your key values if full character matching is important.
X
X
X.nf
X     KEY_EXITMENU = 101	# (e)   Exit Menu Program.
X     KEY_MAINMENU = 109	# (m)   Go to main menu.
X     KEY_PREVMENU = 112	# (p)   Go to previous menu.
X     HOTKEYS			#       This causes the above menu keys to work without a carriage return.
X
X     KEY_GNAME = 103	# (g)   Go to a specific menu prompt.
X     KEY_POPGNAME = 7	# (^g)  Display "\fIGoto Menu\fP", GNAME pop menu.
X     KEY_RETURN = 13	# (^m)  Select hi-lighted menu option or traverse forwards through GETINPUT fields.
X     KEY_DOWN = 10	# (^j)  Traverse forwards through menu options or GETINPUT fields.
X			           Scroll help screen.
X     KEY_UP = 11		# (^k)  Traverse backwards through menu options or GETINPUT fields.
X			           Scroll help screen.
X     KEY_TAB = 9	# (^i)  Fast forward through menu options or GETINPUT fields.
X     KEY_BTAB = -1	#        Fast reverse through menu options or GETINPUT fields.
X     KEY_BEG = 2	# (^b)  Place cursor at beginning of a GETINPUT field.
X			           Display first page of help screen.
X     KEY_END = 5	# (^e)  Place cursor at end of input in a GETINPUT field.
X			           Display last page of help screen.
X     KEY_RIGHT = 12	# (^l)  Forward space within the GETINPUT field.
X     KEY_LEFT = 8	# (^h)  Backspace within the GETINPUT field (non-destructive).
X     KEY_BACKSPACE = 8    # (^h)  Same as KEY_LEFT.
X     KEY_EOL = 4	# (^d)  Delete from cursor to end of GETINPUT field.
X     KEY_DL = 3		# (^c)  Clear GETINPUT field and home cursor.
X     KEY_DC = 24	# (^x)  Delete a character in a GETINPUT field.
X     KEY_IC = 20		# (^t)  Toggle between type-over and insert mode in GETINPUT.
X     KEY_HELP = 63	# (?)  Display help screen.
X     KEY_TOC = 20	# (^t)  When in help display table of contents for help.
X     KEY_REFRESH = 18	# (^r)  Redraw the screen.
X     KEY_ACCEPT = 1	# (^a)  Accept all input from a GETINPUT screen.
SHAR_EOF
echo "End of part 2"
echo "File menu.1 is continued in part 3"
echo "3" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file menu.1 continued
#
CurArch=3
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 menu.1"
sed 's/^X//' << 'SHAR_EOF' >> menu.1
X     KEY_CANCEL = 27	# (esc)  Cancel all input from a GETINPUT screen or cancel a pop-up menu selection.
X			           Exit a help screen.
X     KEY_SAVE = 6	# (^f)  Save a GETINPUT screen to a file.
X     KEY_PRINT = 16	# (^p)  Print a GETINPUT screen to lp.
X.fi
X
X.SH EXAMPLE menufile
X.nf
X\fB###\fR     This is a example of a menu script file.
X
X\fB .AUTHORIZE\fR  pjc nortons boink mozart
X
X\fB###\fR	Initialize function keys for TERM=5425
X\fB .UNIX\fR  echo "\\033[1;2;0;0q  HELP          h\\r\\c"
X
X\fB###\fR	Define goto menu names.
X\fB .GNAME\fR  main  main.m
X\fB .GNAME\fR  reports  reports.m
X
X\fB###\fR     Title Lines Section.
X\fB .TITLE\fR
X  Version 3.00...\\RPACIFIC * BELL\\N...$DATE
X\fB .TITLE\fR
X $MAIL...Sample Menu...\\S$TIME\\N
X\fB .TITLE\fR
X ...MAIN MENU...
X\fB .LINE\fR
X
X\fB###\fR     Left column of screen - Options
X\fB .WINDOW\fR 0 23 0 39
X\fB .SYSTEM\fR who
XList who is on the system.
X\fB .SYSTEM\fR ps -ef; \\
X	echo "Press [ Return ] to continue.\\c"; read reply
XPrint process status table.
X
X\fB###\fR     Right column of screen - Options
X\fB .WINDOW\fR 0 23 40 79 \\R SUB MENU \\N
X\fB .MENU\fR reports.m
XGo to report menu.
X
X\fB .TEXT\fP 22 50
XSelection [ ? for help ]
X.fi
X
X.SH GENERALLY ACCEPTED GUIDELINES
X.PD 0.1
X.IP -> 3
XPut a meaningful title on the top of every menu.
X.IP -> 3
XProvide symmetric balance by centering the title and the menu options
Xaround the center axis of the screen.
X.IP -> 3
XChoose an organizing principle for the menu options.
XOrganize menu hierarchies according to the tasks users will perform, rather
Xthan the structure of the software modules.
X.br
XHints in organizing options:
X.RS 6
X.IP * 3
XChronological ordering
X.IP * 3
XAscending or descending numerical ordering
X.IP * 3
XItems grouped by physical properties, (Increasing volume, weight or temperature)
X.IP * 3
XAlphabetic sequence of terms
X.IP * 3
XGrouping of related options with spatial demarcation between groups
X.IP * 3
XMost frequently used options first
X.IP * 3
XMost important options first
X.RE
X.IP -> 3
XTo facilitate scanning, put blank lines between logical groupings of menu
Xoptions and after about every fifth option in a long list.
X.IP -> 3
XLimit the number of menu choices of one screen.
XThe breadth (number of options per menu) should be no more than eight and the
Xdepth (number of levels of menus) should be no more than four.
X.IP -> 3
XUse words for your menu options that clearly and specifically describe 
Xwhat the user is selecting; use simple, active verbs to describe menu options.
XUse common, short English words that clearly describe the action that the 
Xcommand will carry out; choose words that are distinctive from one another.
X.IP -> 3
XDisplay the menu options in mixed, upper and lower case letters.
X.IP -> 3
XBe sure that any function keys that you use will operate correctly on all of
Xthe different types of keyboards the users have.
X.IP -> 3
XBe consistent in the use of menu formats, procedures, and wording; the 
Xmapping of keys to functions; the naming of menu options.
X.IP -> 3
XOptions should suggest or entail closure.  If a menu option calls another
Xmenu (.MENU) the option description should be the title of the called menu
Xto provide continuity.  Likewise, if a menu option calls a program (reports,
Xscreens) the option description should be the title of the report/screen.
X.IP -> 3
XDisplay only information that the user needs to know.
X.IP -> 3
XEvery menu should indicate how to exit from the screen.
X.IP -> 3
XAvoid hyphenation of words between lines.
X.IP -> 3
XUse abbreviation and acronyms only when they are significantly shorter than
Xthe full text and when they will be understood by the user.
X.IP -> 3
XOptions in a multiple column list should be organized in vertical columns
Xwhich are read from left to right on the screen.
X.IP -> 3
XPut a least two spaces between the longest item in a column and the beginning
Xof the next column.
X.IP -> 3
XUse highlighting to emphasize important information only.  Do not overuse
Xit.
X.IP -> 3
XA \fI.POPMENU\fP, if possible, should appear as close to and to the right 
Xof the option that selected it.  Probably a \fI.GETINPUT\fP screen should also.
X.PD
X
X.SS References
XHuman Factors Engineering, User Interface Guidelines, Pacific Bell, Sept (1987)
X.PP
XShore, John, The Sachertorte Algorithm and Other Antidotes to Computer
XAnxiety, Viking Penguid Inc. (1985)
X.IP * 3
XShore's book for the general public which translates into why designing 
Xgood user interfaces are necessary.
X.PP
XBeer, S. and Schoefer, W., Screen Development Guidelines - Draft,
XVersion 1.0, Pacific Bell, April (1987)
X.PP
XRubinstein R., and Hersch H.M., with Ledgard, H.F., The Human Factor:
XDesigning Computer Systems for People.  Digital Press, Digital Equipment
XCorporation, (1984).
X.IP * 3
XRubinstein's work is very interesting and original.  The text is readable
Xand the ideas presented are clear and attractive.  This is not a text book.
X.PP
XFuture Technology Architecture District, Proposed Pacific*Bell Screen 
XStandards For NonProgrammable Terminals,  Pacific Bell, May (1988)
X.PP
XDumas Joseph S., Designing User Interface for Software, Prentice Hall, 1988
X
X.SH CREDITS
XPaul J. Condie	    8/18/86	original author
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X.br
X
XIrving Griesman			GetInput(3X).
X.br
XSam S. Lok			popmenu(3) enhancements, runrealid(3).
X
X.SH NOTE
XIf memory size is important modify LoadKeys.c and remove all references
Xto keywords your application does not use then relink.  This will reduce
Xthe size of menu.
X
X.SH FILES
Xmenu.hlp    -  menu help file
X.br
X/usr/local/lib/menus	- some menus you might want to use or look at.
X.br
X/usr/local/lib/menus/sample.m    -  a sample menu file
X.br
X/usr/local/lib/menus/printers.m    -  printers pop-up menu
X.br
X/usr/local/lib/menus/reportsrn.m    -  report option input screen
X.br
X/usr/lib/acct/holidays		- holidays file.
X
XThe library of menus may vary from machine to machine.
X
X.SH SEE ALSO
XMenuAccess(1), curses(3X), system(3), mail(1), getenv(3), 
Xlock(1), unlock(1), GetInput(3X), checkpass(1), runrealid(1), MenuMsg(1),
XMenuPrompt(1).
X
X.SH WARNING
XBecause menu uses the environment to pass and save data you are limited on the
Xvolume of data you can have based upon the size of your environment.  
XThis will vary from machine to machine.  If you see the 
Xmessage "Unable to allocate environment memory..." then you have reached
Xyour limit.  Actually you've surpassed the limit or you wouldn't have
Xgotten the message.  But lets not squabble.
X
XMenu has very little intelligence built in to check if you exceed the bounds
Xof any fields.  If menu core dumps, especially with a bus error, you are
Xprobably trying to load too large a value into a field.
X
X.SH BUGS
XCurses bug - When a attribute is the last character on the line (spaces don't 
Xcount) the attributes do not get turned off until it hits the next character 
Xon the next line.
X
X.PP
XWhen you use the mail notification $MAIL the alarms get buffered up when
Xthe cursor is just sitting there, so, as soon as the user types something
Xat the keyboard all the alarms that were buffered take off, which means, you
Xget a beep...beep...beep...beep.  This doesn't happen on AT&T 3b machines
Xbut I've noticed it on SUNS and ARETE machines.
XYou should take the -DALARM off the CFLAGS in the makefile which tells
Xmenu not to use the alarm(2) to check for mail, but check when a key
Xhas been pressed.
X
X.PP
XMenu has not really been tested on terminals/windows that is not 24x80,
Xok,ok... it hasn't been tested at all.  For the most part it should work
Xfine, EXCEPT (you knew that was coming), when you want to create columns
Xof options using the .WINDOW keyword.  The parameters to .WINDOW are
Xabsolute therefore when you line up your columns for a 24x80 terminal and
Xyour menu is run on say a 34x132 terminal your columns will not be
Xcentered right.  Probably a new keyword should be introduced ".COLUMN"
Xwhich would have some intelligence built in to try to center columns within
Xthe window space.  It might have some problems going from a larger window
Xto a smaller window if the columns won't fit.
X.br
XAnyone volunteer to write this one?
X
X.PP
XTerminal attributes sometimes don't work right.  Especially when putting
Xmultiple attributes on one line.  In all cases I've seen it is a restriction
Xof the terminal (hardware).
X
X.bp
X.SH PROGRAMMING NOTES
XThis section is for those of you who want to or need to add new keywords.
X.PP
XThe keywords that have been provided should accommodate most
Xapplication menus, however, if customization is needed the following
Xmay come in handy.  If you introduce any neat new keywords (say like 
X".IF THEN ELSE") I would
Xappreciate you sending them to me so I can incorporate them.  Send your
XParse, Show, and Run functions along with a copy of \fILoadKeys.c\fP.
X.PP
XMenu is primarily driven from the LoadKeys.c module.  This 
Xmodule describes to menu what keywords it needs to scan for and what
Xaction to take when found.
XThere are four sections in LoadKeys (see LoadKeys example) each of which 
Xneed to be
Xdefined if you are introducing a new keyword.  LoadKkeys provides three areas
Xof control (sections 2,3,4), and it is important that you know what you
Xwant to accomplish at each control point:
X.TP 4
XParse
XWhat do you want menu to do with your keyword once it has found it during
Xthe parsing routine?  Any data you need to store for a later step, etc..
X.TP 4
XShow
XHow do you want your keyword displayed to the screen?  Define as NULL if
Xnot appropriate.
X.TP 4
XRun
XIf the user selects an option that is your keyword, what do you want done?
X
X.PP
XIf you want to put debugging code in your functions then the following
Xformat should be used.
X.nf
Xextern int  debug;
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] <%s> ...", __FILE__,
X			menu->option[opnumber]->keyword, ...);
X		fflush (stderr);
X	}
X.fi
Xwhere [Function] is the function name and <KeyWord> is the keyword being
Xprocessed.
X
X.SS ADDING A NEW KEYWORD
X.TP 8
XStep 1:
XDecide on the name of the new keyword.  For consistency sake, I suggest, it
Xshould begin with a "." and be all in caps.  Maximum length of keyword is
XMAXKEYLENGTH (15).  Then formulate a syntax for the keyword (what the user
Xneeds to type in the menufile).
X.br
XAlso, get clear in your mind what you want done at each of the three control
Xpoints.
X
X.TP 8
XStep 2:
Xvi LoadKeys.c
X.br
XStrcpy your keyword into the next available slot in KeyWord[], under SECTION 1.
XMake sure MAXKEYS in menu.h is >= the slot you strcpy'ied your keyword into.
XSee KeyWord[] below.
X
X.TP 8
XStep 3:
XIn SECTION 2 of LoadKeys.c assign the Parse function that is going 
Xto parse your keyword.
XIt should be assigned to the same slot as in SECTION 1.  First see if one
Xof the Parse functions already written will do the job.  If so use that one,
Xif not you will have to write one.  For consistency call it Parse????.c or
XPar????.c, and declare it at the beginning of LoadKeys.c.
XAll keywords must have a parse function.
XThis function is called immediately when your keyword is found while parsing
Xthe menufile.
XSee ParseKey[]() below.
X.br
XReturn Values:
X.RS 8
X.TP 9
X0
XContinue to parse next keyword.
X.TP 9
X-1
XQuit/Exit menu program.
X.TP 9
X-2
XReturn to main menu.
X.TP 9
X-4
XNOWAYJOSE - Not authorized to run this menu.
X.TP
Xanything else
XAbort this menu and return to previous menu.
X.RE
X
X.TP 8
XStep 4:
XIn SECTION 3 of LoadKeys.c assign the Show function (if your keyword is a
Xuser selectable option) that will display the
Xoption to the screen.
XIt should be assigned to the same slot as in SECTION 1.  First see if one
Xof the Show functions already written will do the job.  If so use that one,
Xif not you will have to write one.  For consistency call it Show????.c, and
Xdeclare it at the beginning of LoadKeys.c.
XThis function is called when displaying options to the screen.
XIf you don't need a Show function for your keyword assign slot to NULL.
XSee ShowKey[]() below.
X
X.TP 8
XStep 5:
XIn SECTION 4 of LoadKeys.c assign the Run function (if your keyword is a
Xuser selectable option) that will be called when the user selects this option.
XIt should be assigned to the same slot as in SECTION 1.  First see if one
Xof the Run functions already written will do the job.  If so use that one,
Xif not you will have to write one.  For consistency call it Run????.c, and
Xdeclare it at the beginning of LoadKeys.c.
XIf you don't need a Run function for your keyword assign slot to NULL.
X.br
XReturn Values:
X.RS 8
X.TP 9
X0
XAOK, continue with normal menu processing.
X.TP 9
XMAINMENU
XGoto main menu.  This is as if the user had typed an "M".
X.TP
XPREVIOUSMENU
XGoto previous menu.  This is as if the user had typed a "P".
X.TP
XQUIT
XQuit program.  This is as if the user had typed an "E".
X.TP
XSUBMENU
XIf you are introducing
Xa new submenu keyword (like \fI.MENU\fP) the Run??? function must return 
X(SUBMENU), a #define.
XRefer to \fIRunMenu.c\fP for an example.
X.TP
XGNAMEOFFSET + gindex
XGoto a specific (.GNAME) menu.
XWhere gindex = the index into the gnames array (base 0).
XThis is as if the user had typed a goto menu.
X.RE
X
X.TP 6
XStep 6:
XCompile your new functions, LoadKeys.c  and link into menu.  
XYour KeyWord should work.
XThere should be no need to change any of the existing driver routines 
X(other than LoadKeys.c)?
X
X
X.SS char  KeyWord[]
XThis array identifies all the keywords to be scanned for in your
Xmenufile.  Maximum number of keys is "MAXKEYS" defined in menu.h
Xfile.  Increasing MAXKEYS will allow more keys.
X
X.SS "int (*ParseKey[]) (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, gindex, opnumber)"
X.nf
Xchar		keyword[];
XFILE		*menufile;
Xstruct MenuInfo	*menu;
Xchar		KeyWord[][MAXKEYLENGTH];
Xint		(*ParseKey[])();
Xchar		gnames[][15], gfiles[][15];
Xint		*gindex;
Xint		*opnumber;
X.fi
XArray of pointers to functions that will be called to parse the
Xkeyword when found.  Any processing you want done while program
Xis parsing your keyword should be placed in this function.
XIf you have defined a new keyword you must
Xdescribe how that keyword is to be parsed.  Unless you are doing
Xsomething special ParseOption() should do the job.
XYour new function will need to malloc struct OptionInfo if you
Xwant to store some information for the option.  The following describes
Xthe data passed to all parsing functions.
X.RS 6
X.TP 6
Xkeyword
XThe keyword that was found in menufile.
X.TP 6
X*menufile
XA pointer to your menufile.  When function returns you must leave
Xthe pointer set to read in the next keyword.
X.TP 6
X*menu
XA struct holding information about the menufile.  You need to maintain
Xthe information for later processing. The Show and Run functions use the
Xinformation you store here.  See struct MenuInfo and struct OptionInfo.
X.TP 6
Xgnames
XThe goto menu names (.GNAME) presently defined (base 0).
X.TP 6
Xgfiles
XThe menufiles associated with the goto names (base 0) (.GNAME).
X.TP 6
Xgindex
XThe number of goto names (.GNAME) presently defined.
X.TP 6
Xopnumber
XThe last option number.  This is the number that will appear to the left
Xof the option, and the number the user will type in to select the option.
XYou should increment this for the next option if your keyword will
Xcontain a option number.
XThe option number should be set to zero for options you don't want a
Xnumber to appear to the left of the option.
X.nf
X.RE
X
X/*
X**     Menu structure layout
X*/
Xstruct MenuInfo
X{
X	char			name	[15];		/* file name */
X	int			wfrow;			/* window first row */
X	int			wlrow;			/* window last row */
X	int			wfcol;			/* window first col */
X	int			wlcol;			/* window last col */
X	int			row_cursor;		/* row for cursor */
X	int			col_cursor;		/* col for cursor */
X	unsigned		boxtype;		/* 0 = no box */
X	unsigned		linetype;		/* same as box */
X	int			titlecount;
X	int			optioncount;		/* base 0 */
X	struct OptionInfo	*option	[MAXOPTION];
X	struct ScreenInfo	*srn	[MAXSCREENS+1];	/* .DEFINE_SCREEN */
X							/* NULL = EOL */
X};
X
X
Xstruct OptionInfo
X{
X	char	keyword		[MAXKEYLENGTH+1];
X	int	opnumber;				/* option number */
X	char	description	[200];
X	char	command		[MAXLEN];
X	int	row;					/* row to display */
X	int	col;					/* col to display */
X};
X
Xstruct ScreenInfo
X{
X	char			name	[30];		/* screen name */
X	char			title	[100];		/* window title */
X	int			toprow;			/* upper left corner */
X	int			leftcol;
X	int			rows;			/* # rows in win */
X	int			cols;			/* # cols in win */
X	unsigned		boxtype;		/* 0 = no box */
X	int			exitlastfield;		/* after last field */
X	char			helpfile[16];
X	char			*fielddefaults;		/* init field command */
X	struct FieldInfo	*field	[MAXFIELDS+1];
X};
X
X
Xstruct FieldInfo
X{
X	char	name	[30];				/* field name */
X	char	label	[50];				/* field label */
X	int	row;					/* start position */
X	int	col;
X	int	length;
X	int	min_input;
X	char	mask	[100];
X	char	range	[1025];
X	char	type;
X	char	adjust;
X	int	mustenter;
X	char	prompt	[100];
X	char	terminator[3];				/* field terminators */
X	int	noinput;
X};
X.fi
X.RE
X
X.SS "int (*ShowKey[]) (menu, index)"
X.nf
Xstruct MenuInfo   *menu;
Xint               index;
X
X.fi
XThe following describes the data passed to all Show functions.
XArray of pointers to functions that will be called to display
Xthat option to the screen.  Unless you are doing something special
XShowOption() should do the job.
X.RS 6
X.TP 6
X*menu
XSee above for description of menu structure.
X.br
Xmenu.option[index]->description gets displayed to the screen.
X.TP 6
Xindex
XOption number in menu structure that is to be displayed.
X
X.SS "int (*RunKey[]) (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, gnames, gfiles, gindex)"
X.nf
Xstruct MenuInfo	*menu;
Xint		opnumber;
Xint		(*ParseKey[MAXKEYS])();
Xint		(*ShowKey[MAXKEYS])();
Xint		(*RunKey[MAXKEYS])();
Xchar		KeyWord[MAXKEYS][MAXKEYLENGTH];
Xchar		gnames[MAXGNAME][15];
Xchar		gfiles[MAXGNAME][15];
Xint		gindex;
X.fi
XThe following describes the data passed to all Run functions.
XArray of pointers to functions that will be called when the
Xuser selects the option on the screen.
X.RS 6
X.TP 6
X*option
XSee above for description of struct OptionInfo.
X.br
Xoption->command is what is to be executed for this option.
X.RE
X
X.SS LoadKeys Example:
X.nf
XLoadKeys (KeyWord, ParseKey, ShowKey, RunKey)
X
X	char	KeyWord[][10];
X	int	(*ParseKey[])(), (*ShowKey[])(), (*RunKey[])();
X{
X	int	ParseTitle(), ParseOption();
X	int	ShowOption();
X	int	RunSystem();
X
X	/*
X	**   Section 1:
X	**   	Identify the new keyword here.
X	*/
X	strcpy (KeyWord[1], ".TITLE");
X	strcpy (KeyWord[2], ".MENU");
X	strcpy (KeyWord[3], ".SYSTEM");
X
X	/*
X	**  Section 2:
X	**	Identify the parse function for the new keyword.
X	**  	Every keyword needs a parse function.
X	*/
X	ParseKey[1] = ParseTitle;
X	ParseKey[2] = ParseOption;
X	ParseKey[3] = ParseOption;
X
X	/*
X	**  Section 3:
X	**	Identify the show function for keywords that are options.
X	**  	If ShowKey is set to NULL the option will not be displayed.
X	*/
X	ShowKey[1] = NULL;	/* Title gets displayed in the parse function */
X	ShowKey[2] = ShowOption;
X	ShowKey[3] = ShowOption;
X
X	/*
X	**  Section 4:
X	**	Identify the run function for keywords that are options.
X	**  	If RunKey is set to NULL the cursor will not stop at 
X	**  	the option.  The user will not be able to select it.
X	*/
X	RunKey[1] = NULL;	/* You can't select a title */
X	RunKey[2] = RunMenu;
X	RunKey[3] = RunSystem;
X}
X.fi
X
X
X
X
X.PP
XTHE END     (whew)
SHAR_EOF
echo "File menu.1 is complete"
chmod 0644 menu.1 || echo "restore of menu.1 fails"
echo "x - extracting Main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > Main.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X/*	PROGRAM	   Menu  (generic)
X**	AUTHOR	   Paul J. Condie
X**	DATE	   8/18/86
X*/
X
X#include	<curses.h>
X#include	<signal.h>
X#include	"menu.h"
X
Xint	MAILCALL = FALSE;
Xint	mailrow;
Xint	mailcol;
Xint	debug = FALSE;				/* debug flag */
Xint	trapsigs = 1;				/* flag - trap ignore signals */
X
Xchar		KeyWord[MAXKEYS][MAXKEYLENGTH];	/* the keywords */
Xint		(*ShowKey[MAXKEYS])();
Xstruct MenuInfo	menu;
X
X
Xmain (argc, argv)
X
X	int		argc;
X	char		*argv[];
X{
X	FILE		*fopen(), *menufile;
X	char		*getenv();
X	char		*findfile();
X	int		shutdown();		/* clean up before exit */
X	int		(*ParseKey[MAXKEYS])(), 
X			(*RunKey[MAXKEYS])();
X/*
X**	menuname keeps track of nested submenus.
X**	mptr is the index into menuname 0 = main menu
X**					1 = sub menu 2 = sub sub menu etc.
X**					menuname[mptr--] = previous menu
X*/
X	char		menuname[MAXMENU][15];			/* filenames  */
X	char		filename[80];
X	int		menuoption[MAXMENU];	/* what option to highlight */
X	int		i, exitkey, mptr=0, rc;
X	int		j;			/* loop variable */
X	char		gnames[MAXGNAME][15];	/* goto menu names */
X	char		gfiles[MAXGNAME][15];	/* goto file names */
X	int		gindex = 0;		/* goto index */
X	char		*ws;
X	extern int	optind;
X	extern char	*optarg;
X	int		gotorow = 6;		/* default goto menu row */
X	int		gotocol = 8;		/* default goto menu col */
X	int		keys = 0;		/* show keyboard values */
X	int		parse_rc = 0;		/* parsedriver return code */
X
X
X
X   	while ((rc = getopt (argc, argv, "dp:vk:n:")) != EOF)
X      		switch (rc)
X      		{
X	 	   case 'd':
X			/* Get debug excited */
X			debug++;
X			break;
X
X	 	   case 'p':
X			/* Set row and column for ^g */
X			sscanf (optarg, "%d,%d", &gotorow, &gotocol);
X			break;
X
X         	   case 'v':
X			/* Show Version */
X			fprintf (stderr, "%s   Version %s\n", argv[0], VERSION);
X			exit (0);
X			break;
X		   case 'k':
X			/* Show keyboard key values - for .menuinit */
X			keys++;
X			break;
X		   case 'n':
X			/* don't trap signals */
X			trapsigs = 0;
X			break;
X      		}
X   	if (argc == optind  &&  (!keys))
X   	{
X      		fprintf (stderr, 
X		       "\nUsage: %s [-v] [-p row,col] [ -keyboard ] menufile\n",
X				argv[0]);
X      		exit (1);
X   	}
X	if (!keys)
X   		sscanf (argv[optind], "%s", menuname[0]);
X   	menuoption[0] = 1;
X
X	if (trapsigs)
X	{
X		signal (SIGINT, SIG_IGN);
X		signal (SIGQUIT, SIG_IGN);
X	}
X	else
X	{
X		signal (SIGINT, shutdown);
X		signal (SIGQUIT, shutdown);
X	}
X	signal (SIGHUP, shutdown);
X   	signal (SIGALRM, SIG_IGN);		/* to fix bug in curses */
X
X	/* curses stuff */
X   	initscr ();
X   	cbreak ();
X   	noecho ();
X   	nonl ();
X#ifdef SYS5
X   	keypad (stdscr, TRUE);
X#endif
X
X   	SetTerm ();				/* set terminal keyboard */
X	if (keys)
X	{
X		keyboard ();
X		shutdown ();
X	}
X
X   	LoadKeys (KeyWord, ParseKey, ShowKey, RunKey);
X
X
X	/*
X	**	Parse, Show and Run each menu selected until exit program.
X	*/
X   	do
X   	{
X      		move (0,0);
X      		clrtobot ();				/* clear screen */
X
X		/*
X		**  Check the parse return code from the last parse
X		**  to determine what message to display.
X		*/
X		switch (parse_rc)
X		{
X		   case NOWAYJOSE:
X			BEEP;
X			attrset (A_REVERSE|A_BOLD);
X      			mvprintw (ErrRow, 0, 
X			      "You have not been authorized to run that menu.");
X			attrset (A_NORMAL);
X			break;
X		}
X
X      		initmenu (&menu);			/* init menu defaults */
X
X		/* open menu script file */
X		strcpy (filename, findfile (menuname[mptr], ".",
X			getenv("MENUDIR"), ""));
X      		if ((menufile = fopen (filename, "r")) == NULL)
X		{
X            		BEEP;
X            		mvprintw (20, 0, "Unable to locate (%s) file.", 
X					menuname[mptr]);
X            		shutdown ();
X		}
X
X
X		/*
X		**  Return Codes from parsedriver:
X		**	NOWAYJOSE - not authorized for this menu.
X		*/
X      		parse_rc = parsedriver (menufile, KeyWord, ParseKey, &menu, 
X				gnames, gfiles, &gindex);
X      		fclose (menufile);
X
X		switch (parse_rc)
X		{
X		   case 0:
X			/* success */
X			break;
X
X		   case QUIT:
X			shutdown ();
X			break;
X
X		   case MAINMENU:
X			/* not tested */
X			mptr = 0;
X			break;
X
X		   default:
X	 		if (mptr > 0)
X	 		{
X	    			mptr--;		/* return to previous menu */
X	    			continue;
X	 		}
X	 		else
X			{
X				BEEP;
X				attrset (A_REVERSE|A_BOLD);
X      				mvprintw (ErrRow, 0, 
X			      	"You have not been authorized to run that menu.");
X				attrset (A_NORMAL);
X	    			shutdown ();  /* not authorized for main menu */
X			}
X			break;
X		} /* end switch (parse_rc) */
X
X		/* display menu */
X      		showdriver (KeyWord, ShowKey, &menu);
X
X		/*
X		**  rundriver will return:
X		**	MAINMENU	go directly to main menu
X		**	PREVIOUSMENU	go to previous menu
X		**	REPARSE		reparse & display current menu
X		**	QUIT		quit program.
X		**	0 - 99		option number containing sub menu 
X		**			filename.
X		**	GNAMEOFFSET-199 go directly to menu 
X		**			gnames[exitkey%GNAMEOFFSET]
X		*/
X      		exitkey = rundriver (RunKey, ParseKey,
X				&menuoption[mptr], gnames, gfiles, gindex,
X				gotorow, gotocol);
X		if (menu.after_menu != (char *)NULL)
X			RunAftMenu (&menu);
X
X
X
X      		switch (exitkey)
X      		{
X         	   case MAINMENU:
X			mptr = 0;
X			break;
X         	   case PREVIOUSMENU:
X			if (mptr > 0)   mptr--;
X			break;
X	 	   case REPARSE:
X			break;
X	 	   case QUIT:
X			break;
X
X			/*
X			** A submenu option has been selected or a goto menu.
X			** exitkey is the option # selected (which is a submenu)
X			** The submenu filename is in 
X			** menu.option[exitkey]->command
X			*/
X         	   default:
X			if (exitkey >= GNAMEOFFSET)	/* goto gname menu */
X		   		strcpy (menuname[++mptr], 
X					gfiles[exitkey % GNAMEOFFSET]);
X			else
X		   		sscanf (menu.option[exitkey]->command, "%s", 
X			   		menuname[++mptr]);
X
X			menuoption[mptr] = 1;
X			break;
X      		} /* end switch */
X
X		clean_menu (&menu);		/* free menu space */
X
X   	} while (exitkey != QUIT);
X   	shutdown ();
X}
X
X
X
Xshutdown ()
X{
X   move (LINES-1, 0);
X   refresh ();
X   endwin ();
X   exit (1);
X}
SHAR_EOF
chmod 0644 Main.c || echo "restore of Main.c fails"
echo "x - extracting LoadKeys.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > LoadKeys.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	LoadKeys()
X**		Identifies all the recognizable keywords and the
X**		function(s) 2b called to process the keyword.
X**  ARGS:	KeyWord		array to hold keywords
X**		ParseKey	array to hold parse functions
X**		ShowKey		array to hold display functions
X**		RunKey		array to hold run functions
X**  RETURNS:	zilch
X*/
X
X#include		"menu.h"
X
XLoadKeys (KeyWord, ParseKey, ShowKey, RunKey)
X
X	char	KeyWord[][MAXKEYLENGTH];
X	int	(*ParseKey[])(), (*ShowKey[])(), (*RunKey[])();
X{
X	int	ParseTitle(), ParseOption(), ParseBanner(), ParseBox(), 
X		ParseLine(), ParseWindow(), ParseComnt(), ParseUnix(),
X		ParseGname(), ParseAuthr(), ParseText(), ParseCursor(),
X		ParseSpace(), ParseDefineScreen(), ParInclude(), ParAssign(),
X		ParAftMenu();
X	int	ShowOption();
X	int	RunSystem(), RunExit(), RunSetenv(), RunMenu(), RunPopMenu(),
X		RunGetInput();
X
X
X/*
X**	SECTION 1:
X**	Starting with base 1.
X**	Identify keywords to be acted upon when found in your
X**	menu file.
X**	Make sure MAXKEYS is >= the number of entries here.
X*/
X
X   strcpy (KeyWord[1], ".TITLE");	/* title line */
X   strcpy (KeyWord[2], ".MENU");	/* submenu option */
X   strcpy (KeyWord[3], ".SYSTEM");	/* system call option */
X   strcpy (KeyWord[4], ".BOX");  	/* encase menu in a box */
X   strcpy (KeyWord[5], ".BANNER"); 	/* welcome banner screen */
X   strcpy (KeyWord[6], ".LINE"); 	/* line between title & options */
X   strcpy (KeyWord[7], ".WINDOW"); 	/* window area for options */
X   strcpy (KeyWord[8], "###"); 		/* comment line */
X   strcpy (KeyWord[9], ".UNIX"); 	/* unix command line */
X   strcpy (KeyWord[10], ".GNAME"); 	/* menu name (used in goto menu) */
X   strcpy (KeyWord[11], ".AUTHORIZE"); 	/* login's authorized to run menu */
X   strcpy (KeyWord[12], ".TEXT"); 	/* display text at row and column */
X   strcpy (KeyWord[13], ".CURSOR"); 	/* where to put the cursor */
X   strcpy (KeyWord[14], ".EXIT"); 	/* exit menu program */
X   strcpy (KeyWord[15], ".SETENV"); 	/* set enviroment variable */
X   strcpy (KeyWord[16], ".SPACE"); 	/* put a space between options */
X   strcpy (KeyWord[17], ".POPMENU"); 	/* pop menu option */
X   strcpy (KeyWord[18], ".DEFINE_SCREEN");/* define a prompt screen */
X   strcpy (KeyWord[19], ".GETINPUT");	/* prompt screen */
X   strcpy (KeyWord[20], ".INCLUDE");	/* include a menu file */
X   strcpy (KeyWord[21], "*=*");		/* assignment - variable=value */
X   strcpy (KeyWord[22], ".AFTER_MENU");	/* command to run after menu */
X
X   strcpy (KeyWord[23], ""); 		/* END OF LIST */
X
X
X/*
X**	SECTION 2:
X**	Starting with base 1.
X**	Identify function names to correspond with above keywords.
X**	These functions describe what is to be done when above keyword
X**	is found while parsing the "menu file".
X**	Every keyword needs a Parse??? function.
X*/
X
X   ParseKey[1] = ParseTitle;
X   ParseKey[2] = ParseOption;
X   ParseKey[3] = ParseOption;
X   ParseKey[4] = ParseBox;
X   ParseKey[5] = ParseBanner;
X   ParseKey[6] = ParseLine;
X   ParseKey[7] = ParseWindow;
X   ParseKey[8] = ParseComnt;
X   ParseKey[9] = ParseUnix;
X   ParseKey[10] = ParseGname;
X   ParseKey[11] = ParseAuthr;
X   ParseKey[12] = ParseText;
X   ParseKey[13] = ParseCursor;
X   ParseKey[14] = ParseOption;
X   ParseKey[15] = ParseOption;
X   ParseKey[16] = ParseSpace;
X   ParseKey[17] = ParseOption;
X   ParseKey[18] = ParseDefineScreen;
X   ParseKey[19] = ParseOption;
X   ParseKey[20] = ParInclude;
X   ParseKey[21] = ParAssign;
X   ParseKey[22] = ParAftMenu;
X
X
X/*
X**	SECTION 3:
X**	These functions describe what is to be done to display the
X**	option to the screen.  The option you loaded into OptionInfo.
X**	If set to NULL then the option is not displayed.
X*/
X
X   ShowKey[1] = NULL;
X   ShowKey[2] = ShowOption;
X   ShowKey[3] = ShowOption;
X   ShowKey[4] = NULL;
X   ShowKey[5] = NULL;
X   ShowKey[6] = NULL;
X   ShowKey[7] = NULL;
X   ShowKey[8] = NULL;
X   ShowKey[9] = NULL;
X   ShowKey[10] = NULL;
X   ShowKey[11] = NULL;
X   ShowKey[12] = NULL;
X   ShowKey[13] = NULL;
X   ShowKey[14] = ShowOption;
X   ShowKey[15] = ShowOption;
X   ShowKey[16] = NULL;
X   ShowKey[17] = ShowOption;
X   ShowKey[18] = NULL;
X   ShowKey[19] = ShowOption;
X   ShowKey[20] = NULL;
X   ShowKey[21] = NULL;
X   ShowKey[22] = NULL;
X
X
X/*
X**	SECTION 4:
X**	These functions explain what you want done when the user
X**	selects the option on the screen with the corresponding 
X**	keyword.
X**	If set to NULL the keyword becomes unselectable.
X*/
X
X   RunKey[1] = NULL;
X   RunKey[2] = RunMenu;
X   RunKey[3] = RunSystem;
X   RunKey[4] = NULL;
X   RunKey[5] = NULL;
X   RunKey[6] = NULL;
X   RunKey[7] = NULL;
X   RunKey[8] = NULL;
X   RunKey[9] = NULL;
X   RunKey[10] = NULL;
X   RunKey[11] = NULL;
X   RunKey[12] = NULL;
X   RunKey[13] = NULL;
X   RunKey[14] = RunExit;
X   RunKey[15] = RunSetenv;
X   RunKey[16] = NULL;
X   RunKey[17] = RunPopMenu;
X   RunKey[18] = NULL;
X   RunKey[19] = RunGetInput;
X   RunKey[20] = NULL;
X   RunKey[21] = NULL;
X   RunKey[22] = NULL;
X}
SHAR_EOF
chmod 0644 LoadKeys.c || echo "restore of LoadKeys.c fails"
echo "x - extracting parsedrive.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > parsedrive.c &&
Xstatic char Sccsid[] = "@(#)parsedrive.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	parsedriver()
X**		This is the driver routine in parseing the menu
X**		file.  This function calls the appropriate parse
X**		function for that keyword.
X**  ARGS:	keyword		the keyword "AUTHORIZE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0	success
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X	int	swin, ewin, longest;
X
Xparsedriver (menufile, KeyWord, ParseKey, menu, gname, gfile, gindex)
X
X	FILE		*menufile;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	struct MenuInfo	*menu;
X	char		gname[][15], gfile[][15];
X	int		*gindex;
X{
X	char	keyword[80];
X	int	rcde, I, KEYFOUND;
X	int	opnumber = 0;				/* last option number */
X
X
X   	/* Set default .WINDOW area */
X   	menu->wfcol = 0;
X   	menu->wlcol = COLS-1;
X	menu->wfrow = 0;
X   	menu->wlrow = LINES-1;
X   	menu->titlecount = 0;
X   	menu->optioncount = 0;
X   	swin = ewin = longest = 0;
X
X   	/* loop through each keyword */
X   	rcde = fscanf (menufile, "%s", keyword);
X   	while (rcde != EOF)
X   	{
X		if (strlen (keyword) >= 80-2)
X		{
X      			BEEP;
X      			mvprintw (ErrRow-2, 0, 
X				"Your keyword <%s> is toooo looong.  Max = %d",
X				keyword, 80-2);
X      			shutdown ();
X		}
X		/*
X		**  Check if we found a defined keyword
X		*/
X      		KEYFOUND = FALSE;
X      		for (I = 1; I <= MAXKEYS; I++)
X      		{
X			/*
X         		if (strcmp (keyword, KeyWord[I]) == 0)
X			*/
X         		if (strmatch (keyword, KeyWord[I]))
X         		{
X            			KEYFOUND = TRUE;
X	    			if (ParseKey[I] != NULL)
X	    			{
X               				rcde = (*ParseKey[I]) (keyword, 
X						menufile, menu, KeyWord, 
X						ParseKey, gname, gfile, gindex, 
X						&opnumber);
X					/*
X					** The return code from each parse
X					** function must be 0 in order to
X					** continue.
X					*/
X	       				if (rcde != 0)   return (rcde);
X	    			}
X            			break;
X         		}
X      		}
X      		if (!KEYFOUND)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, "ERROR: (%s) Key not found.", 
X					keyword);
X         		shutdown ();
X      		}
X      		rcde = fscanf (menufile, "%s", keyword);
X   	} 
X
X   	EndWindow (menu);
X   	return (0);
X}
SHAR_EOF
chmod 0444 parsedrive.c || echo "restore of parsedrive.c fails"
echo "x - extracting showdriver.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > showdriver.c &&
Xstatic char Sccsid[] = "@(#)showdriver.c	1.2   DeltaDate 10/16/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	showdriver()
X**		The driver module to initially display the options
X**		to the screen.
X**  ARGS:	keyword		the keyword found
X**		ShowKey		show functions
X**		menu		menu structure
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
Xshowdriver (KeyWord, ShowKey, menu)
X
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ShowKey[])();
X	struct MenuInfo	*menu;
X{
X	int		i, j;
X
X
X
X	/*
X	**	Loop through options and call apropriate function.
X	*/
X
X   	for (i = 0; i < menu->optioncount; i++)
X      		for (j = 1; j <= MAXKEYS; j++)
X         		if (strcmp (menu->option[i]->keyword, KeyWord[j]) == 0)
X	 		{
X	    			if (ShowKey[j] != NULL)   
X					(*ShowKey[j]) (menu, i);
X	    			break;
X	 		}
X   	refresh ();
X}
SHAR_EOF
chmod 0444 showdriver.c || echo "restore of showdriver.c fails"
echo "x - extracting rundriver.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > rundriver.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	rundriver()
X**		The driver module to run each selectable option.
X**		Runmenu will call the appropriate run function
X**		for that keyword.
X**  ARGS:	keyword		the keyword "AUTHORIZE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	QUIT		exit pgm
X**		MAIN		go to main menu
X**		PREVIOUS	go to previous menu
X**		index to submenu
X*/
X
X#include	<curses.h>
X#include	<signal.h>
X#include	"menu.h"
X#include	"terminal.h"
X
X#define		INITMENU	0
X#define		GOTOMENU	1
X
Xextern int	MAILCALL;
Xextern int	trapsigs;
Xextern int	debug;
X
Xextern	struct MenuInfo	menu;
Xint		tmpoption;
Xint		ckik;				/* current keyword in KeyWord */
Xextern	int	(*ShowKey[])();
Xextern	char	KeyWord[][MAXKEYLENGTH];
X
X
Xrundriver (RunKey, ParseKey, option, gnames, 
X		gfiles, gindex, gotorow, gotocol)
X
X	int		(*RunKey[])(), *option;
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		gindex;
X	int		gotorow;
X	int		gotocol;
X{
X	FILE		*fopen(), *fp;
X	char		*findfile();
X	char		*upper();
X	int		shutdown();
X	char		select[78], command[MAXLEN];
X	char		matchstr[60];
X	int		exitkey, index;
X	int		i, j;
X	int		lastopnumber = 0;		/* last option # */
X	int		MATCHED;			/* char match flag */
X	int		ch;
X
X
X
X	/*
X   	**  What is the last option number ?
X   	*/
X	for (i = menu.optioncount-1; i >= 0; i--)
X		if (menu.option[i]->opnumber != 0)
X		{
X			lastopnumber = menu.option[i]->opnumber;
X			break;
X		}
X
X	if (lastopnumber <= 0)   return (QUIT);		/* no options */
X	select[0] = '\0';
X	matchstr[0] = '\0';
X
X	/*
X   	**  Loop through options untill user exits menu or selects
X   	**  another menu.
X   	*/
X	for (;;)
X	{
X#ifndef ALARM
X		if (MAILCALL)
X			checkmail ();
X#endif
X
X		/* highlight current option */
X		for (ckik = 1; ckik <= MAXKEYS  &&  KeyWord[ckik] != NULL;
X		     ckik++)
X			if (strcmp (menu.option[*option-1]->keyword, 
X				    KeyWord[ckik]) == 0)
X			{
X				if (ShowKey[ckik] != NULL)
X				{
X					/* display option */
X					(*ShowKey[ckik]) (&menu, (*option)-1);
X					mvaddch (menu.option[(*option)-1]->row,
X					       menu.option[(*option)-1]->col-1,
X					       ' ');
X					/*
X					** turn on reverse video 
X					** maintaining current attributes
X					*/
X					exitkey =  slength(menu.option[(*option)-1]->description) + menu.option[(*option)-1]->col + 5;
X					for (j = menu.option[(*option)-1]->col-1; j <= exitkey; j++)
X					{
X						ch = mvinch (menu.option[(*option)-1]->row, j);
X						ch |= A_REVERSE;
X						mvaddch (menu.option[(*option)-1]->row, j, ch);
X					}
X
X				}
X				break;
X			}
X
X#ifdef BSD
X		standend ();
X#else
X		attrset (A_NORMAL);
X#endif
X
X		tmpoption = *option;
X		if (RunKey[ckik] != NULL)
X			exitkey = GetOption (menu.row_cursor, menu.col_cursor,
X					     select);
X		else
X			/* so we don't go in a loop */
X			exitkey = (exitkey == KEY_UP || 
X			           exitkey == KeyUp) ? KEY_UP : KEY_DOWN;
X		*option = tmpoption;
X
X		if (exitkey == KeyDown)   	exitkey = KEY_DOWN;
X		if (exitkey == KeyUp)		exitkey = KEY_UP;
X		if (exitkey == KeyTab)		exitkey = KEY_TAB;
X		if (exitkey == KeyBTab)		exitkey = KEY_BTAB;
X		if (exitkey == KeyReturn)	exitkey = KEY_RETURN;
X		if (exitkey == KeyMainMenu)	exitkey = KEY_MAINMENU;
X		if (exitkey == KeyPrevMenu)	exitkey = KEY_PREVMENU;
X		if (exitkey == KeyExitMenu)	exitkey = KEY_EXITMENU;
X		if (exitkey == KeyGname)	exitkey = KEY_GNAME;
X
X		/* unhighlight current option */
X		if (ShowKey[ckik] != NULL)
X		{
X			mvaddch (menu.option[(*option)-1]->row, 
X			    menu.option[(*option)-1]->col-1, ' ');
X			strcat (menu.option[(*option)-1]->description, " ");
X			(*ShowKey[ckik]) (&menu, *option-1);
X			menu.option[(*option)-1]->description[strlen(menu.option[(*option)-1]->description)-1] = '\0';
X		}
X
X
X		switch (exitkey)
X		{
X		case KEY_DOWN:
X		case 'j':
X			*option = (*option) >= menu.optioncount 
X					? 1 : ++(*option);
X			break;
X
X		case KEY_UP:
X		case 'k':
X			*option = (*option) <= 1 
X					? menu.optioncount : --(*option);
X			break;
X
X		case KEY_TAB:
X			/* A tab will hop forward four options at a time. */
X			if (menu.optioncount > 4)
X			{
X				*option += 4;
X				if (*option > menu.optioncount)
X					*option = 1 + *option - 
X						  menu.optioncount - 1;
X			}
X			else
X				*option = *option >= menu.optioncount ? 1 : 
SHAR_EOF
echo "End of part 3"
echo "File rundriver.c is continued in part 4"
echo "4" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 4 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file rundriver.c continued
#
CurArch=4
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 rundriver.c"
sed 's/^X//' << 'SHAR_EOF' >> rundriver.c
X					  ++(*option);
X			break;
X
X		case KEY_BTAB:
X			/* A back tab will hop backward 4 options at a time. */
X			if (menu.optioncount > 4)
X			{
X				*option -= 4;
X				if (*option < 0)
X					*option = menu.optioncount - abs(*option);
X			}
X			else
X				*option = *option <= 1 ? menu.optioncount:--(*option);
X			break;
X
X		/*
X		**	This section is to highlight the selected option 
X		**	before the user presses the return_key to select it.
X		*/
X		case '0':
X		case '1':
X		case '2':
X		case '3':
X		case '4':
X		case '5':
X		case '6':
X		case '7':
X		case '8':
X		case '9':
X			sprintf (select, "%s%c", select, exitkey);
X			if (matoi (select) < 1  ||  
X			    matoi (select) > lastopnumber)
X			{
X				/* Invalid Option */
X				attrset (A_REVERSE);
X				mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
X				attrset (A_NORMAL);
X				select[0] = '\0';
X			}
X			else
X			{
X				/* find the element cooresponding to opnumber */
X				for (i = 0; i < menu.optioncount; i++)
X					if (matoi(select) == menu.option[i]->opnumber)
X					{
X						*option = i+1;
X						break;
X					}
X			}
X			break;
X
X	        case 'A':
X	        case 'B':
X	        case 'C':
X	        case 'D':
X	        case 'E':
X	        case 'F':
X	        case 'G':
X	        case 'H':
X	        case 'I':
X	        case 'J':
X	        case 'K':
X	        case 'L':
X	        case 'M':
X	        case 'N':
X	        case 'O':
X	        case 'P':
X	        case 'Q':
X	        case 'R':
X	        case 'S':
X	        case 'T':
X	        case 'U':
X	        case 'V':
X	        case 'W':
X	        case 'X':
X	        case 'Y':
X	        case 'Z':
X	        case ' ':
X			/* character matching */
X			sprintf (matchstr, "%s%c", matchstr, exitkey);
X			MATCHED = FALSE;
X			for (i = 0; i < menu.optioncount; i++)
X			{
X				strcpy (command, menu.option[i]->description);
X				upper (command);
X				if (strncmp (command, matchstr, 
X				    strlen(matchstr)) == 0)
X				{
X					MATCHED = TRUE;
X					sprintf (select, "%d", 
X						menu.option[i]->opnumber);
X					*option = i + 1;
X					break;
X				}
X			}
X			if (!MATCHED)
X				strcpy (matchstr, "");
X			break;
X
X		case KEY_EXITMENU:
X			/* check if we have a .EXIT option */
X			for (i = 0; i < menu.optioncount; i++)
X				if (strcmp (menu.option[i]->keyword, ".EXIT") == 0)
X					RunExit (&menu, i, KeyWord, ParseKey, ShowKey, 
X					    RunKey, gnames, gfiles, gindex);
X			return (QUIT);
X
X		case KEY_MAINMENU:
X			return (MAINMENU);
X
X		case KEY_PREVMENU:
X			return (PREVIOUSMENU);
X
X		case '!':
X			/*
X		**	Shell Option.
X		**	Prompt user for a command to be executed within a 
X		**      shell (system(1)).
X		*/
X			select[0] = '\0';
X			mvaddch (ErrRow, 0, '!');
X			move (ErrRow, 1);
X			echo ();
X			refresh ();
X#ifdef ALARM
X			alarm (0);		/* turn off mail check */
X			signal (SIGALRM, SIG_IGN);
X#endif
X			getstr (select);
X#ifdef ALARM
X			if (MAILCALL)
X				checkmail ();
X#endif
X			noecho ();
X			sprintf (command, "%s;runrealid \"%s\";%s;%s",
X#if BSD || SUN
X			    "clear",
X#else
X			    "tput clear",
X#endif
X			    select,
X			    "echo \"\\n[Press return to continue]\\c\"",
X			    "read reply");
X			reset_shell_mode ();
X			signal (SIGINT, shutdown);
X			signal (SIGQUIT, shutdown);
X			system (command);
X			if (trapsigs)
X			{
X				signal (SIGINT, SIG_IGN);
X				signal (SIGQUIT, SIG_IGN);
X			}
X			reset_prog_mode ();
X			keypad (stdscr, TRUE);
X			move (ErrRow,0);
X			clrtoeol ();
X			select[0] = '\0';
X			matchstr[0] = '\0';
X			clearok (stdscr, TRUE);
X			break;
X
X		case KEY_HELP:
X		/*
X		**	Show Help Screen Option.
X		**	Search directories for a menu.hlp file.
X		**	If found display to screen.
X		*/
X			strcpy (command, findfile ("menu.hlp", ".",
X			    getenv("HELPDIR"), getenv("MENUDIR"),
X			    ""));
X#ifdef ALARM
X			alarm (0);		/* turn off mail check */
X			signal (SIGALRM, SIG_IGN);
X#endif
X			ShowHelp (command, "menu", ErrRow);
X#ifdef ALARM
X			if (MAILCALL)
X				checkmail ();
X#endif
X			clearok (stdscr, TRUE);
X			select[0] ='\0';
X			matchstr[0] ='\0';
X			break;
X
X		case KEY_GNAME:
X			/*
X			**	Goto Menu option
X			**	Prompt user for the Gname (goto menu name) 
X			**	that the user wants to go to.
X			**	And then return GNAMEOFFSET + gindex to main.  
X			**	The > GNAMEOFFSET indicates a goto menu option.
X			*/
X			select[0] = '\0';
X			echo ();
X			mvprintw (ErrRow, 0, "Goto ");
X#ifdef ALARM
X			alarm (0);		/* turn off mail check */
X			signal (SIGALRM, SIG_IGN);
X#endif
X			getstr (select);
X#ifdef ALARM
X			if (MAILCALL)
X				checkmail ();
X#endif
X			noecho ();
X			for (i = 0; i < gindex; i++)
X			{
X				if (strcmp (select, gnames[i]) == 0)
X					return (GNAMEOFFSET + i);
X			}
X			BEEP;
X			attrset (A_REVERSE);
X			mvprintw (ErrRow, 0, "[%s] not found.", select);
X			attrset (A_NORMAL);
X			select[0] = '\0';
X			matchstr[0] ='\0';
X			break;
X
X		case KEY_RETURN:
X		case KEY_LINEFEED:
X			/*
X			**	We now take an action based upon what is in 
X			**	select - that which the user typed in.
X			*/
X			if (select[0] == KeyExitMenu)
X			{
X				/* check if we have a .EXIT option */
X				for (i = 0; i < menu.optioncount; i++)
X					if (strcmp (menu.option[i]->keyword, 
X					    ".EXIT") == 0)
X					{
X						RunExit (&menu, i, KeyWord,
X						    ParseKey, ShowKey, RunKey,
X						    gnames, gfiles, gindex);
X						break;
X					}
X				return (QUIT);
X			}
X			if (select[0] == KeyMainMenu)	return (MAINMENU);
X			if (select[0] == KeyPrevMenu)	return (PREVIOUSMENU);
X
X			/*
X			**	Goto Menu option
X			**	Prompt user for the Gname (goto menu name) 
X			**	that the user wants to go to.
X			**	And then return GNAMEOFFSET + gindex to main.  
X			**	The > GNAMEOFFSET indicates a goto menu option.
X			*/
X			if (select[0] == KeyGname)
X			{
X				select[0] = '\0';
X				echo ();
X				mvprintw (ErrRow, 0, "Goto ");
X#ifdef ALARM
X				alarm (0);	/* turn off mail check */
X				signal (SIGALRM, SIG_IGN);
X#endif
X				getstr (select);
X#ifdef ALARM
X				if (MAILCALL)
X					checkmail ();
X#endif
X				noecho ();
X				for (i = 0; i < gindex; i++)
X				{
X					if (strcmp (select, gnames[i]) == 0)
X						return (GNAMEOFFSET + i);
X				}
X				BEEP;
X				attrset (A_REVERSE);
X				mvprintw (ErrRow, 0, "[%s] not found.", select);
X				attrset (A_NORMAL);
X				select[0] = '\0';
X				matchstr[0] ='\0';
X				break;
X			}
X
X			/*
X			**	Show Help Screen Option.
X			**	Search directories for a menu.hlp file.
X			**	If found display to screen.
X			*/
X			if (select[0] == KeyHelp)
X			{
X				strcpy (command, findfile ("menu.hlp", 
X					".", getenv("HELPDIR"), 
X					getenv("MENUDIR"), ""));
X#ifdef ALARM
X				alarm (0);		/* turn off mail check */
X				signal (SIGALRM, SIG_IGN);
X#endif
X				ShowHelp (command, "menu", ErrRow);
X#ifdef ALARM
X				if (MAILCALL)
X					checkmail ();
X#endif
X				clearok (stdscr, TRUE);
X				select[0] ='\0';
X				matchstr[0] ='\0';
X				break;
X			}
X
X
X			/*
X			**	The user has manually typed in a option to be 
X			**	executed.  Execute the appropriate option.
X			*/
X			if (strlen (select) > 0)
X			{
X				index = matoi (select);
X				if (index < 1  ||  index > lastopnumber)
X				{
X					/* Invalid Option */
X					attrset (A_REVERSE);
X					mvprintw (ErrRow, 0, "To select an option enter the option number and press return.");
X					attrset (A_NORMAL);
X					select[0] = '\0';
X					break;
X				}
X				/* find the element cooresponding to opnumber */
X				for (i = 0; i < menu.optioncount; i++)
X					if (index == menu.option[i]->opnumber)
X					{
X						*option = i+1;
X						break;
X					}
X			}
X
X			/*
X			**  Run the option the user selected.
X			*/
X			for (i = 1; i <= MAXKEYS; i++)
X				if (strcmp (menu.option[*option-1]->keyword, 
X				    KeyWord[i]) == 0)
X				{
X					if (RunKey[i] != NULL)
X					{
X#ifdef ALARM
X						alarm (0); /* turn off mail */
X						signal (SIGALRM, SIG_IGN);
X#endif
X						exitkey = (*RunKey[i]) (&menu, *option-1, KeyWord,
X						    ParseKey, ShowKey, RunKey,
X						    gnames, gfiles, gindex);
X						/* .MENU is a special case */
X						if (exitkey == SUBMENU)
X							return (*option-1);
X						if (exitkey == MAINMENU)
X							return (MAINMENU);
X						if (exitkey == PREVIOUSMENU)
X							return (PREVIOUSMENU);
X						if (exitkey == QUIT)
X							return (QUIT);
X						if (exitkey == REPARSE)
X							return (REPARSE);
X						if (exitkey >= GNAMEOFFSET  &&  
X						    exitkey <= GNAMEOFFSET + gindex)
X							return (exitkey);
X#ifdef ALARM
X						if (MAILCALL)
X							checkmail ();
X#endif
X					}
X					break;
X				}
X			select[0] = '\0';
X			matchstr[0] = '\0';
X			break;
X
X		default:
X			if (exitkey == KeyPopGname  &&  gindex > 0)
X			{
X				/*
X				**   Popup menu for goto names.
X				*/
X#ifdef ALARM
X				alarm (0);	/* turn off mail check */
X				signal (SIGALRM, SIG_IGN);
X#endif
X				popmenu (INITMENU, GOTOMENU, gotorow, gotocol, 
X				    "GOTO MENU", HELPFILE, LINES-2, 
X				    sizeof(gnames[0]), gnames);
X
X				move (ErrRow,0);
X				clrtoeol ();
X				BEEP;
X				mvprintw (ErrRow, 0, "Goto what menu ?");
X				refresh ();
X				exitkey = popmenu (GOTOMENU, (char *)NULL);
X				touchwin (stdscr);
X				refresh ();
X#ifdef ALARM
X				if (MAILCALL)
X					checkmail ();
X#endif
X				if (exitkey >= 1  &&  exitkey <= gindex)
X					return (GNAMEOFFSET + exitkey-1);
X			}
X
X			move (ErrRow,0);
X			clrtoeol ();
X			mvprintw (ErrRow, 0, "Say What.");
X			select[0] = '\0';
X			matchstr[0] = '\0';
X			break;
X		}
X	}
X}
X
X
X
X/*
X**  My ascii to integer
X**  Return -1 if string contains more than digits.
X*/
Xmatoi (s)
X	char	*s;
X{
X	int	value;
X
X	value = atoi (s);
X	while (*s)
X	{
X		if (*s < '0' || *s > '9')
X			return (-1);
X		s++;
X	}
X	return (value);
X}
X
X
X
Xsetoption (row, col)
X	int	row;
X	int	col;
X{
X	static int	*saveoption;
X	int		newoption;
X	int		rc;
X	int		j;
X	int		ch;
X	int		found;
X
X	/* find the option associated with this row/col */
X	found = FALSE;
X	for (newoption = 0; newoption < menu.optioncount; newoption++)
X	{
X		if (row == menu.option[newoption]->row &&
X		    (col >= menu.option[newoption]->col && 
X		     col <= (menu.option[newoption]->col + 
X			     strlen(menu.option[newoption]->description))))
X		{
X			found = TRUE;
X			break;
X		}
X	}
X	newoption++;					/* base 1 */
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] newoption %d, %s, row %d, col %d",
X			__FILE__,
X			newoption, menu.option[newoption]->description,
X			row, col);
X		fflush (stderr);
X	}
X	if (!found  ||  newoption == tmpoption)
X		return;
X
X
X
X	/* unhighlight current option */
X#ifdef BSD
X	standend ();
X#else
X	attrset (A_NORMAL);
X#endif
X	if (ShowKey[ckik] != NULL)
X	{
X		mvaddch (menu.option[(tmpoption)-1]->row, 
X			    menu.option[(tmpoption)-1]->col-1, ' ');
X		strcat (menu.option[(tmpoption)-1]->description, " ");
X		(*ShowKey[ckik]) (&menu, tmpoption-1);
X		menu.option[(tmpoption)-1]->description[strlen(menu.option[(tmpoption)-1]->description)-1] = '\0';
X	}
X
X
X	tmpoption = newoption;
X	/* highlight new option */
X	for (ckik = 1; ckik <= MAXKEYS  &&  KeyWord[ckik] != NULL; 
X	     ckik++)
X	{
X		if (strcmp (menu.option[(tmpoption)-1]->keyword, 
X		    KeyWord[ckik]) == 0)
X		{
X			if (ShowKey[ckik] != NULL)
X			{
X				/* display option */
X				(*ShowKey[ckik]) (&menu, (tmpoption)-1);
X				mvaddch (menu.option[(tmpoption)-1]->row,
X				       menu.option[(tmpoption)-1]->col-1, ' ');
X				/*
X				** turn on reverse video 
X				** maintaining current attributes
X				*/
X				rc =  slength(menu.option[(tmpoption)-1]->description) + menu.option[(tmpoption)-1]->col + 5;
X				for (j = menu.option[(tmpoption)-1]->col-1; j <= rc; j++)
X				{
X					ch = mvinch (menu.option[(tmpoption)-1]->row, j);
X					ch |= A_REVERSE;
X					mvaddch (menu.option[(tmpoption)-1]->row, j, ch);
X				}
X
X			}
X			break;
X		} /* end if */
X	}
X
X#ifdef BSD
X	standend ();
X#else
X	attrset (A_NORMAL);
X#endif
X	refresh ();
X}
SHAR_EOF
echo "File rundriver.c is complete"
chmod 0644 rundriver.c || echo "restore of rundriver.c fails"
echo "x - extracting ParseOpton.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseOpton.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseOption()
X**		This function parses user selectable options.
X**  ARGS:	keyword		the keyword found
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
Xextern	int	debug;
X
X
XParseOption (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
Xgindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	struct OptionInfo	*malloc();
X	char			*getval();
X	char		*fgets(), line[MAXLEN+100];
X	int		i = 0;
X	int		j;
X	char		*ws;
X
X
X	if (menu->optioncount >= MAXOPTION)
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, "Exceeded maximum allowable options.");
X		shutdown ();
X	}
X	menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
X	if (menu->option[menu->optioncount] == NULL)
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, "Unable to allocate memory for option.");
X		shutdown ();
X	}
X
X	strcpy (menu->option[menu->optioncount]->keyword, keyword);
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X	fgets (line, sizeof(line)-1, menufile);
X	line[strlen(line)-1] = '\0';			/* get rid of \n */
X	while (line[strlen(line)-1] == '\\')
X	{
X		if (strlen(line) >= MAXLEN)
X		{
X			BEEP;
X			mvprintw (ErrRow-2, 0, 
X			    "Option command is too long.  Max = %d",MAXLEN);
X			shutdown ();
X		}
X		line[strlen(line)-1] = '\n';		/* replace \ with \n */
X		fgets (line+strlen(line), sizeof(line)-1, menufile);
X		line[strlen(line)-1] = '\0';		/* get rid of \n */
X	}
X	menu->option[menu->optioncount]->command = 
X				(char *) malloc (strlen(line)+5);
X	strcpy (menu->option[menu->optioncount]->command, line);
X	if (debug)
X	{
X		fprintf (stderr, "\n[ParseOpton] <%s> command=:%s:",
X		    keyword, menu->option[menu->optioncount]->command);
X		fflush (stderr);
X	}
X
X	/*
X	**	Read in option description
X	*/
X	fgets (line, BUFSIZE+1, menufile);
X	line[strlen(line)-1] = '\0';
X	for (j = 0, i = 0; i < strlen (line); j++, i++)
X		if (line[i] == '$')
X		{
X			char    *sptr, *b4ptr;
X
X			sptr = b4ptr = line+i;
X			strcpy (menu->option[menu->optioncount]->description+j, 
X				getval (&sptr, '$'));
X			i += (int)(sptr - b4ptr);
X			j += strlen (menu->option[menu->optioncount]->description+j) - 1;
X			i--;
X		}
X		else
X		{
X			menu->option[menu->optioncount]->description[j] = line[i];
X		}
X	menu->option[menu->optioncount]->description[j] = '\0';
X
X
X	/*
X	**	Determine length of longest option
X	*/
X	if (slength (menu->option[menu->optioncount]->description) > longest)
X		longest = slength(menu->option[menu->optioncount]->description);
X
X	/* set option number 2b displayed */
X	(*opnumber)++;
X	menu->option[menu->optioncount]->opnumber = *opnumber;
X
X	menu->optioncount++;
X	ewin++;
X	return (0);
X}
SHAR_EOF
chmod 0644 ParseOpton.c || echo "restore of ParseOpton.c fails"
echo "x - extracting ParseBaner.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseBaner.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseBanner()
X**		Parses the "BANNER" keyword.
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
XParseBanner (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	static int	onetime = FALSE;		/* show only 1 time */
X	int	row, col, rstart, rstop, cstart, cstop;
X	int	ulc=0, llc=0, linecount, increment;
X	char	flag[5], tophalf[4][30], lower[4][30];
X
X
X   fscanf (menufile, "%d", &linecount);
X
X/*
X**	Load the input banner text into tophalf and lower arrays.
X*/
X
X   for (row = 1; row <= linecount; row++)
X   {
X      fscanf (menufile, "%s", flag);
X      if (strncmp (flag, ".U", 2) == 0)
X      {
X         fgets (tophalf[ulc], 80, menufile);
X         tophalf[ulc][strlen(tophalf[ulc])-1] = '\0';
X         ulc++;
X      }
X      else
X      {
X         fgets (lower[llc], 80, menufile);
X         lower[llc][strlen(lower[llc])-1] = '\0';
X         llc++;
X      }
X   }
X
X   if (onetime)
X	return (0);
X   onetime++;
X
X#ifdef BSD
X   standout ();
X#else
X   attrset (A_STANDOUT);
X#endif
X   for (rstart = 24/2-1, rstop = 24/2+1, 
X        cstart = COLS/2-2, cstop = COLS/2+1;
X        rstart >= 0 && rstop <= 23 && cstart >= 0 && cstop <= COLS-1;
X        rstart--, rstop++, cstart-=3, cstop+=3)
X   {
X      for (row = rstart; row <= rstop; row++)
X      {
X         if (row == rstart  ||  row == rstop)
X         {
X            for (col = cstart; col <= cstop; col++)
X               mvaddch (row, col, BORDERCHAR);
X         }
X         else
X         {
X            mvaddch (row, cstart, BORDERCHAR);
X            mvaddch (row, cstop, BORDERCHAR);
X         }
X      }
X      refresh ();
X   }
X
X   increment = 2;
X   for (rstart = rstart+3, rstop=rstop-2, cstart = cstart+1, cstop = cstop-1;
X        cstart >= 0  &&  cstop <= COLS-1;
X        rstart++, rstop--, cstart-=increment, cstop+=increment)
X   {
X      for (row = 1; row <= 23; row++)
X      {
X         if (row < rstart  ||  row > rstop)
X         {
X            for (col = cstart; col <= cstart+increment; col++)
X               mvaddch (row, col, BORDERCHAR);
X            for (col = cstop-increment; col <= cstop; col++)
X               mvaddch (row, col, BORDERCHAR);
X         }
X         else
X         {
X            mvaddch (row, cstart, BORDERCHAR);
X            mvaddch (row, cstop, BORDERCHAR);
X         }
X      }
X      refresh ();
X   }
X
X#ifdef BSD
X   standout ();
X#else
X   attrset (A_REVERSE);
X#endif
X   for (row = 0; ulc > 0; row++, ulc--)
X      mvprintw (row+4, COLS/2-strlen(tophalf[row])/2-1, "%s", tophalf[row]);
X   for (row = 0; llc > 0; row++, llc--)
X      mvprintw (row+17, COLS/2-strlen(lower[row])/2-1, "%s", lower[row]);
X
X   mvprintw (23, 27, "Press return to continue");
X   move (23,0);
X   getch ();
X   refresh ();
X#ifdef BSD
X   standend ();
X#else
X   attrset (A_NORMAL);
X#endif
X   move (0,0); clrtobot ();
X   return (0);
X}
SHAR_EOF
chmod 0644 ParseBaner.c || echo "restore of ParseBaner.c fails"
echo "x - extracting ParseTitle.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseTitle.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseTitle()
X**		Parses keyword "TITLE".
X**  ARGS:	keyword		the keyword "TITLE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
Xextern int	MAILCALL;
Xextern int	mailrow;
Xextern int	mailcol;
X
X
XParseTitle (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets(), line[201];
X	char	*getenv();
X	char	*getval();
X	char	section[3][201];	      /* section[0] = left justified */
X					      /* section[1] = centered */
X					      /* section[2] = right justified */
X	int	i = 0;			      /* index into line */
X	int	j;			      /* index into section */
X	int	k, row, col;
X	char	*ws;
X	int	mailsection=999;	      /* section $MAIL was found */
X					      /* we set to 999 so sub menus */
X					      /* that don't have a $MAIL wont */
X					      /* recalculate mailcol */
X
X
X
X   fgets (line, 200, menufile);
X
X/*
X**	Get title line
X*/
X   fgets (line, 200, menufile);
X   line[strlen(line)-1] = '\0';
X   
X   section[0][0] = section[1][0] = section[2][0] = '\0';
X
X/*
X**	Now we break input line into left, center, and right sections
X**	Loop through each section.
X*/
X
X   for (k = 0; k <= 2; k++)
X   {
X      /* Loop through each character of line until we find next section */
X      for (j = 0; i < strlen (line)  &&  strncmp (line+i, "...", 3) != 0;
X          i++, j++)
X      {
X         if (strncmp (line+i, "$DATE", 5) == 0)
X         {
X            sysdate (section[k]+j, "mm/dd/yy");
X            j += 7;
X            i += 4;
X         }
X         else
X            if (strncmp (line+i, "$TIME", 5) == 0)
X            {
X               systime (section[k]+j, "HH:MM zz");
X               j += 7;
X               i += 4;
X            }
X            else
X               if (strncmp (line+i, "$MAIL", 5) == 0)
X	       {
X		  /*
X		  **  User wants 2b notified when mail arrives.
X		  **  The mailfile is located in enviroment $MAIL
X		  **  if the mailfile exists and size is greater than zero
X		  **  mailfile = getenv("$MAIL")
X		  **  We need to process entire line b4 we find mailcol
X		  */
X		  MAILCALL = TRUE;
X		  strcpy (section[k]+j, "mAiL");	/* unique ? */
X		  mailrow = menu->titlecount;
X		  mailsection = k;
X                  i += 4;				/* get past $MAIL */
X                  j += 3;				/* for "MAIL" */
X	       }
X	       else
X		  /*
X		  **  A environment variable
X		  */
X                  if (line[i] == '$')
X   	          {
X			char	*sptr, *b4ptr;
X
X		     sptr = b4ptr = line+i;
X		     strcpy (section[k]+j, getval (&sptr, '$'));
X		     i += (int)(sptr - b4ptr);
X		     j += strlen (section[k]+j) - 1;
X		     i--;
X	          }
X	          else
X                     section[k][j] = line[i];
X      }
X      section[k][j] = '\0';
X      i += 3;
X   }
X
X   if (menu->titlecount >= MAXTITLE)
X   {
X      BEEP;
X      mvprintw (ErrRow, 0, "Number of Title lines exceed the maximim.");
X      shutdown ();
X   }
X   (menu->titlecount)++;
X   (menu->wfrow)++;			/* reduce window size to center in */
X
X
X/*
X**	Now we display the three sections to the screen
X*/
X
X   for (k = 0; k <= 2; k++)
X   {
X/*
X**	First we must find out what column to start displaying on.
X**	Taking into account the terminal attribute characters.
X*/
X      switch (k)
X      {
X         case 0:
X			/* left justified */
X			row = menu->titlecount - 1;
X			col = 0;
X			break;
X	 case 1:
X			/* center */
X			for (i = 0, j = 0; section[k][i] != '\0'; i++)
X			   if (section[k][i] == '\\') j++;
X			col = COLS/2-(strlen(section[k])-j*2)/2;
X			col -= (((strlen(section[k])-j*2) % 2) == 0) ? 0 : 1;
X			row = menu->titlecount - 1;
X			move (menu->titlecount-1, i); 
X			break;
X	 case 2:
X			/* right justify */
X			for (i = 0, j = 0; section[k][i] != '\0'; i++)
X			   if (section[k][i] == '\\') j++;
X			row = menu->titlecount - 1;
X			col = COLS-strlen(section[k])+j*2;
X			break;
X      }  /* end switch */
X
X      if (MAILCALL  &&  mailsection == k)
X      {
X         /* find mailcol - remember the attributes */
X         for (i = 0, j = 0; section[k][i] != '\0' &&
X              strncmp (section[k]+i, "mAiL", 4) != 0; i++)
X            if (section[k][i] == '\\') j++;
X         mailcol = i - j*2 + col;		/* for \R */
X	 memcpy (section[k]+i, "    ", 4);		/* get rid of mAiL */
X      }
X
X      displaytext (stdscr, row, col, section[k]);
X   }  /* end for loop */
X#ifdef ALARM
X   if (MAILCALL)
X      checkmail ();
X#endif
X   return (0);
X}
SHAR_EOF
chmod 0644 ParseTitle.c || echo "restore of ParseTitle.c fails"
echo "x - extracting ParseBox.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseBox.c &&
Xstatic char Sccsid[] = "@(#)ParseBox.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseBox()
X**		Parses keyword ".BOX".
X**  ARGS:	keyword		the keyword "BOX"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XParseBox (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*fgets(), line[BUFSIZE+1];
X	char		boxtype[30];
X	char		*sptr;
X
X	/* Default Values */
X	menu->boxtype = StandoutLine;
X	menu->boxtype = menu->boxtype | (DumbLine << 9);
X
X	fgets (line, BUFSIZE, menufile);
X	sptr = line;
X	SKIPJUNK(sptr);
X
X	/* get border type for active menu */
X	sscanf (sptr, "%s", boxtype);
X	sptr += strlen(boxtype);
X	if (strcmp (boxtype, "DumbLine") == 0)
X		menu->boxtype = DumbLine;
X	else	if (strcmp (boxtype, "StandoutLine") == 0)
X			menu->boxtype = StandoutLine;
X	else	if (strcmp (boxtype, "SingleLine") == 0 ||
X		    strcmp (boxtype, "DrawLine") == 0)
X			menu->boxtype = SingleLine;
X	else	if (strcmp (boxtype, "MosaicLine") == 0)
X			menu->boxtype = MosaicLine;
X	else	if (strcmp (boxtype, "DiamondLine") == 0)
X			menu->boxtype = DiamondLine;
X	else	if (strcmp (boxtype, "DotLine") == 0)
X			menu->boxtype = DotLine;
X	else	if (strcmp (boxtype, "PlusLine") == 0)
X			menu->boxtype = PlusLine;
X
X	/* get border type for inactive menu - dim (high 8 bits) */
X	sscanf (sptr, "%s", boxtype);
X	sptr += strlen(boxtype);
X	if (strcmp (boxtype, "DumbLine") == 0)
X		menu->boxtype = menu->boxtype | (DumbLine << 9);
X	else	if (strcmp (boxtype, "StandoutLine") == 0)
X			menu->boxtype = menu->boxtype | (DumbLine << 9);
X	else	if (strcmp (boxtype, "SingleLine") == 0 ||
X		    strcmp (boxtype, "DrawLine") == 0)
X			menu->boxtype = menu->boxtype | (SingleLine << 9);
X	else	if (strcmp (boxtype, "MosaicLine") == 0)
X			menu->boxtype = menu->boxtype | (MosaicLine << 9);
X	else	if (strcmp (boxtype, "DiamondLine") == 0)
X			menu->boxtype = menu->boxtype | (DiamondLine << 9);
X	else	if (strcmp (boxtype, "DotLine") == 0)
X			menu->boxtype = menu->boxtype | (DotLine << 9);
X	else	if (strcmp (boxtype, "PlusLine") == 0)
X			menu->boxtype = menu->boxtype | (PlusLine << 9);
X
X	drawbox (stdscr, 1,1, LINES-1,COLS, menu->boxtype & 0777, StandoutLine,
X		FALSE, FALSE);
X   	return (0);
X}
SHAR_EOF
chmod 0444 ParseBox.c || echo "restore of ParseBox.c fails"
echo "x - extracting ParseWindo.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseWindo.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseWindow()
X**		Parses keyword ".WINDOW".
X**  ARGS:	keyword		the keyword "WINDOW"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
X
XParseWindow (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	int		i, j, row, col;
X	char		line[BUFSIZE];
X
X
X   EndWindow (menu);
X
X   fscanf (menufile, "%d", &menu->wfrow);
X   if (menu->wfrow < 0)   menu->wfrow = 0;
X   if (menu->wfrow < menu->titlecount) menu->wfrow = menu->titlecount;
X   if (menu->wfrow > LINES-1)   menu->wfrow = LINES-1;
X   fscanf (menufile, "%d", &menu->wlrow);
X   if (menu->wlrow < 0)   menu->wlrow = 0;
X   if (menu->wlrow > LINES-1)   menu->wlrow = LINES-1;
X   fscanf (menufile, "%d", &menu->wfcol);
X   if (menu->wfcol < 0)   menu->wfcol = 0;
X   if (menu->wfcol > COLS-1)   menu->wfcol = COLS-1;
X   fscanf (menufile, "%d", &menu->wlcol);
X   if (menu->wlcol < 0)   menu->wlcol = 0;
X   if (menu->wlcol > COLS-1)   menu->wlcol = COLS-1;
X
X/*
X**	Now lets read in the window heading.
X*/
X   fgets (line, BUFSIZE+1, menufile);
X   line[strlen(line)-1] = '\0';
X
X/*
X**	Determine where to display heading.
X*/
X   for (i = 0, j = 0; line[i] != '\0'; i++)
X      if (line[i] == '\\') j++;
X   row = menu->wfrow - 1;
X   col = (menu->wlcol - menu->wfcol)/2-(strlen(line)-1-j*2)/2 + menu->wfcol;
X   col -= (((strlen(line)-1-j*2) % 2) == 0) ? 0 : 1;
X   if (strlen(line) > 0)   displaytext (stdscr, row, col, line+1);
X   
X   longest = 0;
X   swin = ewin;
X   return (0);
X}
SHAR_EOF
chmod 0644 ParseWindo.c || echo "restore of ParseWindo.c fails"
echo "x - extracting ParseLine.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseLine.c &&
Xstatic char Sccsid[] = "@(#)ParseLine.c	1.6   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseLine()
X**		Parses keyword "LINE".
X**  ARGS:	keyword		the keyword "LINE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
X
XParseLine (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	int	col;
X	char		*fgets(), line[BUFSIZE+1];
X	char		linetype[30];
X	char		*sptr;
X
X
X	/* default values */
X	menu->linetype = StandoutLine;
X	menu->linetype = menu->linetype | (DumbLine << 9);
X
X	fgets (line, BUFSIZE, menufile);
X	sptr = line;
X	SKIPJUNK(sptr);
X
X	/* get border type for active menu */
X	sscanf (sptr, "%s", linetype);
X	sptr += strlen(linetype);
X	if (strcmp (linetype, "DumbLine") == 0)
X		menu->linetype = DumbLine;
X	else	if (strcmp (linetype, "StandoutLine") == 0)
X			menu->linetype = StandoutLine;
X	else	if (strcmp (linetype, "SingleLine") == 0 ||
X		    strcmp (linetype, "DrawLine") == 0)
X			menu->linetype = SingleLine;
X	else	if (strcmp (linetype, "MosaicLine") == 0)
X			menu->linetype = MosaicLine;
X	else	if (strcmp (linetype, "DiamondLine") == 0)
X			menu->linetype = DiamondLine;
X	else	if (strcmp (linetype, "DotLine") == 0)
X			menu->linetype = DotLine;
X	else	if (strcmp (linetype, "PlusLine") == 0)
X			menu->linetype = PlusLine;
X
X	/* get border type for inactive menu - dim (high 8 bits) */
X	sscanf (sptr, "%s", linetype);
X	sptr += strlen(linetype);
X	if (strcmp (linetype, "DumbLine") == 0)
X		menu->linetype = menu->linetype | (DumbLine << 9);
X	else	if (strcmp (linetype, "StandoutLine") == 0)
X			menu->linetype = menu->linetype | (DumbLine << 9);
X	else	if (strcmp (linetype, "SingleLine") == 0 ||
X		    strcmp (linetype, "DrawLine") == 0)
X			menu->linetype = menu->linetype | (SingleLine << 9);
X	else	if (strcmp (linetype, "MosaicLine") == 0)
X			menu->linetype = menu->linetype | (MosaicLine << 9);
X	else	if (strcmp (linetype, "DiamondLine") == 0)
X			menu->linetype = menu->linetype | (DiamondLine << 9);
X	else	if (strcmp (linetype, "DotLine") == 0)
X			menu->linetype = menu->linetype | (DotLine << 9);
X	else	if (strcmp (linetype, "PlusLine") == 0)
X			menu->linetype = menu->linetype | (PlusLine << 9);
X
X	drawline (stdscr, menu->titlecount, menu->linetype&0777, StandoutLine,
X			menu->boxtype);
X
X   	menu->titlecount++;
X   	return (0);
X}
SHAR_EOF
chmod 0444 ParseLine.c || echo "restore of ParseLine.c fails"
echo "x - extracting ParseComnt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseComnt.c &&
Xstatic char Sccsid[] = "@(#)ParseComnt.c	1.5   DeltaDate 11/13/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseComnt()
X**		Parses keyword "###".
X##		A comment line.
X**  ARGS:	keyword		the keyword "###"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
XParseComnt (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets(), line[BUFSIZE+1];
X
X
X   	fgets (line, BUFSIZE, menufile);
X	return (0);
X}
SHAR_EOF
chmod 0444 ParseComnt.c || echo "restore of ParseComnt.c fails"
echo "x - extracting ParseUnix.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseUnix.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseUnix()
X**		Parses keyword ".unix".
X**  ARGS:	keyword		the keyword "unix"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	<signal.h>
X#include	"menu.h"
X
Xextern	int	debug;
Xextern	int	trapsigs;
X
X
X
XParseUnix (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X		gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	int		shutdown();
X	char		command[MAXLEN+1];
X	int		rc;
X	char		*comptr;
X	char		tmpstr[80];
X	int		redrawflag = FALSE;
X
X
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X   	fgets (command, sizeof(command)-1, menufile);
X   	command[strlen(command)-1] = '\0';		/* get rid of \n */
X   	while (command[strlen(command)-1] == '\\')
X   	{
X      		if (strlen(command) > MAXLEN)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, 
X				".UNIX command is too long.  Max = %d",MAXLEN);
X         		shutdown ();
X      		}
X      		command[strlen(command)-1] = '\n';	/* replace \ with \n */
X      		fgets (command+strlen(command), sizeof(command)-1, menufile);
X      		command[strlen(command)-1] = '\0';	/* get rid of \n */
X   	}
X
X	comptr = command;
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", tmpstr);		/* do we have a REDRAW */
X	if (strcmp (tmpstr, "REDRAW") == 0)
X	{
X		redrawflag = TRUE;
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);
X   		sscanf (comptr, "%s", tmpstr);	/* do we have a GETINPUT */
X	}
X
X	if (strcmp (tmpstr, "GETINPUT") == 0)
X	{
X		/* get screen name */
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);
X   		sscanf (comptr, "%s", tmpstr);		/* screen name */
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);		/* sitting at system(3) */
X		rc = runscreen (tmpstr, menu, *opnumber);
X		if (rc == KEY_CANCEL)
X			return (0);
X	}
X
X	reset_shell_mode ();
X	signal (SIGINT, shutdown);
X	signal (SIGQUIT, shutdown);
X   	rc = system (comptr);
X	if (trapsigs)
X	{
X		signal (SIGINT, SIG_IGN);
X		signal (SIGQUIT, SIG_IGN);
X	}
X	reset_prog_mode ();
X	keypad (stdscr, TRUE);
X
X	/*
X	**  Going from a shell return code (char) to a c return code (int)
X	**  the shell return code gets put in the high byte.  So we will
X	**  shift the int right 8 bytes.
X	*/
X	rc = rc >> 8;					/* to get shell rc */
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] <%s> rc=%d  command=%s", 
X			__FILE__, keyword, rc, comptr);
X		fflush (stderr);
X	}
X
X	/*
X	**  Shell can't handle negative return codes so we will convert 
X	**  the return code to negative so menu can use it.
X	**	-1 = QUIT
X	**	-2 = MAINMENU
X	**	-3 = PREVMENU
X	**	-4 = NOWAYJOSE
X	**	100+offset = GNAME
X	*/
X	if (rc < GNAMEOFFSET)
X		rc -= rc * 2;				/* make negative */
X
X	if (redrawflag)
X		clearok (stdscr, TRUE);
X
X	return (rc);
X}
X/* Paul J. Condie  12/88 */
SHAR_EOF
chmod 0644 ParseUnix.c || echo "restore of ParseUnix.c fails"
echo "x - extracting ParseGname.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseGname.c &&
Xstatic char Sccsid[] = "@(#)ParseGname.c	1.5   DeltaDate 11/13/88   ExtrDate 1/22/90";
X
X/*  FUNCTION:	ParseGname()
X**		Parses keyword ".GNAME".
X**  ARGS:	keyword		the keyword "GNAME"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
X
XParseGname (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		name[BUFSIZE+1];
X	char		file[BUFSIZE+1];
X	int		i;
X	int		NameFound;
X
X
X	if (*gindex >= MAXGNAME)
X	{
X		BEEP;
X		mvprintw (20, 0, 
X		   "Exceeded maximum (%d) number of goto menu names", 
X		   MAXGNAME-1);
X		shutdown ();
X	}
X   	fscanf (menufile, "%s %s", name, file);
X	if (strlen(name) >= 15  ||  strlen(file) >= 15)
X	{
X		BEEP;
X		mvprintw (20, 0, 
X       "The goto menu name and the goto menu file is limited to 14 characters");
X		shutdown ();
X	}
X
X	/* Check if we already have this menu name */
X	NameFound = FALSE;
X	for (i = 0; i < *gindex; i++)
X	{
X		if (strcmp (name, gnames[i]) == 0)
X		{
X			NameFound = TRUE;
X			strcpy (gfiles[i], file);	/* new menu file */
X		}
X	}
X	if (!NameFound)
X	{
X		/* a new name */
X		strcpy (gnames[*gindex], name);
X		strcpy (gfiles[*gindex], file);
X		(*gindex)++;
X		strcpy (gnames[*gindex], "");		/* null last one */
X	}
X   	fgets (name, BUFSIZE, menufile);	/* junk rest of line */
X	return (0);
X}
SHAR_EOF
chmod 0444 ParseGname.c || echo "restore of ParseGname.c fails"
echo "x - extracting ParseAuthr.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseAuthr.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseAuthr()
X**		Parses keyword "AUTHORIZE".
X**		This function determines whether you are authorized
X**		to run this menu or not.
X**  ARGS:	keyword		the keyword "AUTHORIZE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0		you are authorized
X**		NOWAYJOSE	nowayjose
X*/
X
X#include	<curses.h>
X#include	<pwd.h>
X#include	"menu.h"
X
X
X
XParseAuthr (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*strchr();
X	char		line[MAXLEN+100], *lptr, word[15];
X	char		user[15];
X	int		OKflag;
X	struct passwd	*getpwuid();
X	struct passwd	*pw;				/* password entry */
X
X
X	pw = getpwuid (getuid());			/* get real uid */
X	strcpy (user, pw->pw_name);
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X   	fgets (line, sizeof(line)-1, menufile);
X   	line[strlen(line)-1] = '\0';			/* get rid of \n */
X   	while (line[strlen(line)-1] == '\\')
X   	{
X      		if (strlen(line) >= MAXLEN)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, 
X				"Option command is too long.  Max = %d",MAXLEN);
X         		shutdown ();
X      		}
X      		line[strlen(line)-1] = '\0';		/* junk \ */
X      		fgets (line+strlen(line), sizeof(line)-1, menufile);
X      		line[strlen(line)-1] = '\0';		/* get rid of \n */
X   	}
X
X   	lptr = line;
X   	OKflag = FALSE;
X   	while (lptr  &&  (sscanf (lptr, "%s", word) == 1))
X   	{
SHAR_EOF
echo "End of part 4"
echo "File ParseAuthr.c is continued in part 5"
echo "5" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 5 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ParseAuthr.c continued
#
CurArch=5
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 ParseAuthr.c"
sed 's/^X//' << 'SHAR_EOF' >> ParseAuthr.c
X      		if (strcmp (user, word) == 0)
X      		{
X			OKflag = TRUE;
X			break;
X      		}
X      		lptr = strchr (++lptr, ' ');
X   	}
X
X   	if (!OKflag)
X      		return (NOWAYJOSE);
X   	return (0);
X}
SHAR_EOF
echo "File ParseAuthr.c is complete"
chmod 0644 ParseAuthr.c || echo "restore of ParseAuthr.c fails"
echo "x - extracting ParseText.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseText.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	ParseText()
X**		Parses keyword "TEXT".
X**  ARGS:	keyword		the keyword "TEXT"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XParseText (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*fgets(), line[BUFSIZE+1];
X	char		*getval();
X	int		row;
X	int		col;
X	char		fline[BUFSIZE+1];		/* formated line */
X	int		j;
X	int		i;
X	char		*ws;
X
X   	fgets (line, BUFSIZE, menufile);		/* read row, col */
X	ws = line;
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", fline);			/* get row */
X	row = strcmp (fline, "-0") == 0 ? LINES : atoi(fline);
X	ws += strlen(fline);
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", fline);			/* get col */
X	col = strcmp (fline, "-0") == 0 ? COLS : atoi(fline);
X	
X   	fgets (line, BUFSIZE, menufile);		/* read text */
X   	line[strlen(line)-1] = '\0';
X   	for (j = 0, i = 0; i < strlen (line); j++, i++)
X      		if (line[i] == '$')
X      		{
X			char	*sptr, *b4ptr;
X
X		     	sptr = b4ptr = line+i;
X		     	strcpy (fline+j, getval (&sptr, '$'));
X		     	i += (int)(sptr - b4ptr);
X		     	j += strlen (fline+j) - 1;
X		     	i--;
X      		}
X      		else
X      		{
X			fline[j] = line[i];
X      		}
X	fline[j] = '\0';
X
X	/*
X	**   If the row or column is negative
X	**     then  we use relative addressing
X	**     	     the row or col is subtracted from # of rows on screen.
X	*/
X	if (row < 0)
X		row = abs(row) > LINES ? LINES-1 : LINES+row-1;
X	else
X		row = row > LINES-1 ? LINES-1 : row;
X	if (col < 0)
X		col = abs(col) > COLS ? COLS-1 : COLS+col-1;
X	else
X		col = col > COLS-1 ? COLS-1 : col;
X   	displaytext (stdscr, row, col, fline);
X	return (0);
X}
X/* Paul J. Condie  4/88 */
SHAR_EOF
chmod 0644 ParseText.c || echo "restore of ParseText.c fails"
echo "x - extracting ParseCur.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseCur.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ParseCur.c	1.5   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X
X/*  FUNCTION:	ParseCursor()
X**		Parses keyword "CURSOR".
X**  ARGS:	keyword		the keyword "CURSOR"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XParseCursor (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets(), line[BUFSIZE+1];
X	char	*ws;
X	char	tmpstr[20];
X
X   	fgets (line, BUFSIZE, menufile);
X	ws = line;
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", tmpstr);			/* get row */
X	menu->row_cursor = strcmp (tmpstr, "-0") == 0 ? LINES : atoi(tmpstr);
X	ws += strlen(tmpstr);
X	SKIPJUNK (ws);
X	sscanf (ws, "%s", tmpstr);			/* get col */
X	menu->col_cursor = strcmp (tmpstr, "-0") == 0 ? COLS : atoi(tmpstr);
X
X	/*
X	**   If the row or column is negative
X	**     then  we use relative addressing
X	**     	     the row or col is subtracted from # of rows on screen.
X	*/
X	if (menu->row_cursor < 0)
X		menu->row_cursor = abs(menu->row_cursor) > LINES ? 
X			LINES-1 : LINES+menu->row_cursor-1;
X	else
X		menu->row_cursor = menu->row_cursor > LINES-1 ? 
X			LINES-1 : menu->row_cursor;
X	if (menu->col_cursor < 0)
X		menu->col_cursor = abs(menu->col_cursor) > COLS ? 
X			COLS-1 : COLS+menu->col_cursor-1;
X	else
X		menu->col_cursor = menu->col_cursor > COLS-1 ? 
X			COLS-1 : menu->col_cursor;
X	return (0);
X}
X/* Paul J. Condie  4/88 */
SHAR_EOF
chmod 0444 ParseCur.c || echo "restore of ParseCur.c fails"
echo "x - extracting ParseSpace.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseSpace.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ParseSpace()
X**  ARGS:	keyword		the keyword found
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
X
X
XParseSpace (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	struct OptionInfo	*malloc();
X	char	*fgets(), line[BUFSIZE];
X
X
X   if (menu->optioncount >= MAXOPTION)
X   {
X      BEEP;
X      mvprintw (ErrRow, 0, "Exceeded maximum allowable options.");
X      shutdown ();
X   }
X   menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
X   if (menu->option[menu->optioncount] == NULL)
X   {
X      BEEP;
X      mvprintw (ErrRow, 0, "Unable to allocate memory for option.");
X      shutdown ();
X   }
X
X   strcpy (menu->option[menu->optioncount]->keyword, keyword);
X   menu->option[menu->optioncount]->opnumber = 0;		/* no number */
X   strcpy (menu->option[menu->optioncount]->description, "");
X   menu->option[menu->optioncount]->command = (char *) malloc (5);
X   strcpy (menu->option[menu->optioncount]->command, "");
X
X   fgets (line, sizeof(line)-1, menufile);		/* junk rest of line */
X   menu->optioncount++;
X   ewin++;
X   return (0);
X}
SHAR_EOF
chmod 0644 ParseSpace.c || echo "restore of ParseSpace.c fails"
echo "x - extracting ParInclude.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParInclude.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	ParInclude()
X**		Parses keyword ".INCLUDE".
X**  ARGS:	keyword		the keyword "INCLUDE"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
X
XParInclude (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	FILE		*fopen(), *newfile;
X	char		*fgets(), line[BUFSIZE+1];
X	char		*findfile();
X	char		*getenv();
X	char		*getval();
X	char		unixfile[100];
X	char		filename[100];
X	int		rc;
X	int		KEYFOUND;
X	int		idx;
X	char		newkey[MAXKEYLENGTH];
X	char		*sptr;
X
X	fgets (line, BUFSIZE, menufile);
X	sscanf (line, "%s", filename);
X
X	/*
X	**  Open and Parse the new menu file
X	*/
X	sptr = filename;
X	strcpy (unixfile, getval (&sptr, 1));
X	strcpy (filename, unixfile);
X	if (filename[0] != '/')
X		strcpy (unixfile, findfile (filename, ".", getenv("MENUDIR"), 
X		""));
X      	if ((newfile = fopen (unixfile, "r")) == NULL)
X      	{
X        	BEEP;
X            	mvprintw (ErrRow-2, 0, "Unable to locate .INCLUDE (%s) file.", 
X				filename);
X            	shutdown ();
X      	}
X
X
X   	/* loop through each keyword */
X   	rc = fscanf (newfile, "%s", newkey);
X   	while (rc != EOF)
X   	{
X		/*
X		**  Check if we found a defined keyword
X		*/
X      		KEYFOUND = FALSE;
X      		for (idx = 1; idx <= MAXKEYS; idx++)
X      		{
X			/*
X         		if (strcmp (newkey, KeyWord[idx]) == 0)
X			*/
X         		if (strmatch (newkey, KeyWord[idx]))
X         		{
X            			KEYFOUND = TRUE;
X	    			if (ParseKey[idx] != NULL)
X	    			{
X               				rc = (*ParseKey[idx]) (newkey, 
X						newfile, menu, KeyWord,
X						ParseKey, gnames, gfiles, 
X						gindex, opnumber);
X	       				if (rc != 0)   return (rc);
X  				}
X            			break;
X         		}
X      		}
X      		if (!KEYFOUND)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, "ERROR: (%s) Key not found.", 
X					newkey);
X         		shutdown ();
X      		}
X      		rc = fscanf (newfile, "%s", newkey);
X	} /* end while */
X
X	/*
X      	rc = parsedriver (newfile, KeyWord, ParseKey, menu, gnames, gfiles, 
X			&gindex);
X	*/
X      	fclose (newfile);
X
X   	return (0);
X}
SHAR_EOF
chmod 0644 ParInclude.c || echo "restore of ParInclude.c fails"
echo "x - extracting ParAssign.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParAssign.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	ParAssign()
X**		Parses keyword "*=*"
X**		A variable=value assignment.
X**  ARGS:	keyword		the keyword "*=*"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern int	debug;
X
X
XParAssign (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X	gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char	*fgets();
X	char	line[BUFSIZE+1];
X	char	*assignment;
X	char	*aptr;
X	char	*sptr;
X
X
X   	fgets (line, BUFSIZE, menufile);
X	line[strlen(line)-1] = '\0';			/* junk \n */
X	/* if comment (#,###) junk rest of line */
X	for (aptr = line; *aptr; aptr++)
X		if (*aptr == '#'  ||  strncmp (aptr, "###", 3) == 0)
X		{
X			*aptr = '\0';			/* junk comment */
X			for (sptr = aptr-1, aptr = line; 
X			     sptr >= aptr && (*sptr == ' ' || *sptr == '\t'); 
X			     sptr--)
X				*sptr = '\0';	/* junk trailing white space */
X			break;
X		}
X	assignment = (char *)malloc (strlen(keyword) + strlen(line) + 20);
X	strcpy (assignment, keyword);
X	strcat (assignment, line);	/* the rest of the quoted value */
X	aptr = assignment;
X	if (debug)
X	{
X		fprintf (stderr, "\n[ParAssign]  command=:%s:", aptr);
X		fflush (stderr);
X	}
X	setvariable (&aptr);
X	free (assignment);
X	return (0);
X}
SHAR_EOF
chmod 0644 ParAssign.c || echo "restore of ParAssign.c fails"
echo "x - extracting ParAftMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParAftMenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	ParAftMenu()
X**		Parses keyword ".AFTER_MENU".
X**  ARGS:	keyword		the keyword "unix"
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
Xextern	int	debug;
X
X
X
XParAftMenu (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, 
X		gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		KeyWord[][MAXKEYLENGTH];
X	int		(*ParseKey[])();
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		command[MAXLEN+1];
X	int		rc;
X	char		*comptr;
X	char		tmpstr[80];
X	int		redrawflag = FALSE;
X
X
X
X	/*
X	**	Read in option command
X	**	strcat continuation lines
X	*/
X   	fgets (command, sizeof(command)-1, menufile);
X   	command[strlen(command)-1] = '\0';		/* get rid of \n */
X   	while (command[strlen(command)-1] == '\\')
X   	{
X      		if (strlen(command) > MAXLEN)
X      		{
X         		BEEP;
X         		mvprintw (ErrRow-2, 0, 
X			      ".AFTER_MENU command is too long.  Max = %d",
X			      MAXLEN);
X         		shutdown ();
X      		}
X      		command[strlen(command)-1] = '\n';	/* replace \ with \n */
X      		fgets (command+strlen(command), sizeof(command)-1, menufile);
X      		command[strlen(command)-1] = '\0';	/* get rid of \n */
X   	}
X
X	comptr = command;
X	SKIPJUNK(comptr);
X
X	/* save command for later */
X	menu->after_menu = (char *)malloc (strlen(comptr)+5);
X	strcpy (menu->after_menu, comptr);
X	return (0);
X}
X/* Paul J. Condie  4-90 */
SHAR_EOF
chmod 0644 ParAftMenu.c || echo "restore of ParAftMenu.c fails"
echo "x - extracting ShowOption.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ShowOption.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	ShowOption()
X**		Displays a option to the screen.
X**  ARGS:	menu		menu structure
X**		index		option # to display
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	"menu.h"
X
Xextern int	debug;
X
X
XShowOption (menu, index)
X
X	struct MenuInfo	*menu;
X	int		index;
X{
X
X
X	/*
X	**	Now display option.
X	*/
X   	mvprintw (menu->option[index]->row, menu->option[index]->col, "%2d.  ",
X		menu->option[index]->opnumber);
X   
X   	displaytext (stdscr, menu->option[index]->row, 
X		     menu->option[index]->col+5,
X		menu->option[index]->description);
X
X	if (debug)
X	{
X		fprintf (stderr, "\n[ShowOption] <%s> row=%d col=%d", 
X			menu->option[index]->keyword,
X			menu->option[index]->row, 
X			menu->option[index]->col);
X	}
X}
SHAR_EOF
chmod 0644 ShowOption.c || echo "restore of ShowOption.c fails"
echo "x - extracting RunSystem.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunSystem.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	RunSystem()
X**		Runs keyword ".SYSTEM".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	<signal.h>
X#include	"menu.h"
X
Xextern	int	errno;
Xextern	int	debug;
X
XRunSystem (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	int			shutdown();
X	char			*command = (char *)NULL;
X	int			rc;		/* return code */
X	char			*comptr;
X	int			screenflag = FALSE;
X
X
X
X	/*
X	** we need to allocate enough space to hold the command
X	** the description and the tput clear stuff
X	*/
X	command = (char *)malloc (strlen (menu->option[opnumber]->command) +
X			strlen (menu->option[opnumber]->description) + 100);
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X
X	if (substr (comptr, "GETINPUT") != NULL)
X	{
X		sscanf (comptr, "%s", command);
X		/*
X		**  Loop through each variable=value until GETINPUT is found
X		*/
X		do
X		{
X			if (strcmp (command, "GETINPUT") == 0)
X			{
X				screenflag = TRUE;
X				/* get screen name */
X				comptr += strlen(command);
X				SKIPJUNK(comptr);
X   				sscanf (comptr, "%s", command);/* screen name */
X				comptr += strlen(command);
X				SKIPJUNK(comptr);     /* sitting at system(3) */
X				rc = runscreen (command, menu, opnumber);
X				if (rc == KEY_CANCEL)
X				{
X					free (command);
X					return (0);
X				}
X				break;
X			}
X			else
X			{
X				rc = setvariable (&comptr);
X				if (rc != 0) break;
X			}
X
X			SKIPJUNK(comptr);
X   			rc = sscanf (comptr, "%s", command);/* next var=value */
X		} while (rc != EOF);
X	} /* end if GETINPUT */
X
X
X	/* run system command */
X	refresh();			/* force curses to flush attributes */
X	sprintf (command, "%s;echo \"One moment, loading %s%s%s ....\"; %s",
X#if BSD || SUN
X			"clear",
X#else
X			"tput clear",
X#endif
X#if BSD || SUN
X			"",
X#else
X			"`tput smul`",
X#endif
X			menu->option[opnumber]->description,
X#if BSD || SUN
X			"",
X#else
X			"`tput rmul`",
X#endif
X			comptr);
X   	reset_shell_mode ();
X	if (debug)
X	{
X		fprintf (stderr, "\n[RunSystem] <%s> command=:%s:", 
X			menu->option[opnumber]->keyword, command);
X	}
X	signal (SIGINT, shutdown);
X	signal (SIGQUIT, shutdown);
X   	rc = system (command);
X	signal (SIGINT, SIG_IGN);
X	signal (SIGQUIT, SIG_IGN);
X	if (debug)
X	{
X		fprintf (stderr, 
X			"\n[RunSystem] <%s> return code = %d, errno = %d", 
X			rc, errno);
X	}
X
X   	reset_prog_mode ();
X	clearok (stdscr, TRUE);
X
X
X	free (command);
X
X	if (rc == 0  &&  screenflag)
X		return (REPARSE);
X   	return (rc);
X}
SHAR_EOF
chmod 0644 RunSystem.c || echo "restore of RunSystem.c fails"
echo "x - extracting RunExit.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunExit.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	RunExit()
X**		Runs keyword ".EXIT".
X**		Exit menu program.
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<signal.h>
X#include	"menu.h"
X
Xextern int	trapsigs;
X
XRunExit (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	int			shutdown();
X	int			rc;		/* return code */
X
X	refresh ();
X	if (strcmp (menu->option[opnumber]->command, "") != 0)
X	{
X   		reset_shell_mode ();
X		signal (SIGINT, shutdown);
X		signal (SIGQUIT, shutdown);
X   		rc = system (menu->option[opnumber]->command);
X		if (trapsigs)
X		{
X			signal (SIGINT, SIG_IGN);
X			signal (SIGQUIT, SIG_IGN);
X		}
X   		reset_prog_mode ();
X	}
X	return (QUIT);
X}
SHAR_EOF
chmod 0644 RunExit.c || echo "restore of RunExit.c fails"
echo "x - extracting RunSetenv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunSetenv.c &&
Xstatic char Sccsid[] = "@(#)RunSetenv.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	RunSetenv()
X**		Runs keyword ".SETENV".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<string.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
XRunSetenv (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			*strchr();
X	int			rc;
X	char			command[BUFSIZ];
X	char			*comptr;
X	int			BELLFLAG=FALSE;
X
X
X	/*
X	**  The first argument [ BELL ]
X	*/
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", command);		/* do we have a BELL */
X	if (strcmp (command, "BELL") == 0)
X	{
X		BELLFLAG = TRUE;
X		comptr += strlen(command);
X	}
X
X	do
X	{
X		rc = setvariable (&comptr);
X		if (rc != 0) break;
X   		rc = sscanf (comptr, "%s", command);	/* get next var=value */
X		if (rc == EOF)   break;
X		/* if the command has an = sign in it, it is another one */
X		if (!strmatch(command, "*=*"))
X			break;
X	} while (rc != EOF);
X
X	SKIPJUNK(comptr);
X	mvprintw (ErrRow, 0, "%s", comptr);		/* dispaly message */
X	if (BELLFLAG)
X		BEEP;
X
X	return (REPARSE);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 RunSetenv.c || echo "restore of RunSetenv.c fails"
echo "x - extracting RunMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunMenu.c &&
Xstatic char Sccsid[] = "@(#)RunMenu.c	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X/*  FUNCTION:	RunMenu()
X**		Runs keyword ".MENU".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X
XRunMenu (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			command[BUFSIZ];
X	int			rc;		/* return code */
X	char			*comptr;
X
X	/*
X	**  The first argument is the menu script filename
X	*/
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK (comptr);
X   	sscanf (comptr, "%s", command);			/* filename */
X	comptr += strlen(command);
X	SKIPJUNK (comptr);
X   	sscanf (comptr, "%s", command);		/* next argument */
X
X	/*
X	**  Loop through each variable=value || GETINPUT
X	*/
X	do
X	{
X		if (strcmp (command, "GETINPUT") == 0)
X		{
X			/* get screen name */
X			comptr += strlen(command);
X			SKIPJUNK(comptr);
X   			sscanf (comptr, "%s", command);	/* screen name */
X			comptr += strlen(command);
X			SKIPJUNK(comptr);	/* sitting at next argument */
X			rc = runscreen (command, menu, opnumber);
X			if (rc == KEY_CANCEL)
X				return (0);
X		}
X		else
X		{
X			rc = setvariable (&comptr);
X			if (rc != 0) break;
X		}
X
X   		rc = sscanf (comptr, "%s", command);/* next var=value */
X	} while (rc != EOF);
X
X	return (SUBMENU);
X}
X/* Paul J. Condie  5/88 */
SHAR_EOF
chmod 0444 RunMenu.c || echo "restore of RunMenu.c fails"
echo "x - extracting RunPopMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunPopMenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	RunPopMenu()
X**		Runs keyword ".POPMENU".
X**		RunPopMenu will use recursion if there is another .POPMENU
X**		within .POPMENU.
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<string.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X#define	INITMENU	0
X#define	CREATEMENU	-2
X#define	UNHILIGHTBOX	-1
X
X
XRunPopMenu (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	FILE			*fopen(), *menufile;
X	char			*strchr();
X	char			*findfile();
X	char			*getenv();
X	char			command[BUFSIZ];
X	int			rc;			/* return code */
X	char			*comptr;
X	int			row, col;		/* top left corner */
X	char			*filename;
X	int			i;
X	static int		popmid = 9;		/* popup menu id */
X	int			titleline[200];		/* title 1 on stdscr */
X	char			poptitle[200];		/* title for popmenu */
X	int			DIMFLAG = TRUE;
X	struct MenuInfo		pmenu;
X	char			PopMenu[100][80];	/* the pop menu */
X	int			AUTOFIG = FALSE;	/* figure row/col */
X
X
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", command);		/* do we have NoDim */
X	if (strcmp (command, "NoDim") == 0)
X	{
X		DIMFLAG = FALSE;
X		comptr += strlen(command);
X	}
X
X	SKIPJUNK(comptr);
X   	sscanf (comptr, "%s", command);		/* menufile name */
X	comptr += strlen(command);
X	SKIPJUNK(comptr);
X
X	/* do we have a row/column parameter 
X	** we'll use titleline for working storage
X	*/
X   	sscanf (comptr, "%s", titleline);	/* get next argument */
X	if (*comptr != '\0' && strchr (titleline, '=') == (char *)NULL)
X	{
X		/* we have a row/column parameter */
X		/* get row and column */
X		sscanf (comptr, "%d", &row);
X		comptr = strchr (comptr, ' ');		/* past row */
X		SKIPJUNK(comptr);			/* at begining of col */
X		sscanf (comptr, "%d", &col);
X		comptr = strchr (comptr, ' ');		/* past column */
X	}
X	else
X		AUTOFIG = TRUE;
X
X
X	/*
X	**  Loop through each variable=value
X	*/
X	do
X	{
X		rc = setvariable (&comptr);
X		if (rc != 0) break;
X	} while (rc != EOF);
X
X	/*
X	**  Open and Parse the popmenu
X	*/
X	filename = findfile (command, ".", getenv("MENUDIR"), "");
X      	if ((menufile = fopen (filename, "r")) == NULL)
X      	{
X        	BEEP;
X            	mvprintw (ErrRow-2, 0, "Unable to locate (%s) file.", command);
X            	shutdown ();
X      	}
X
X	/*
X	**  The ParseTitle will put the .POPMENU title on line 0 of stdscr
X	**  so we need to save original title
X	**  then read and compare title 1 to see what the title for popmenu
X	**  should be.
X	**  Then write the original title back out. (whew)
X	*/
X	/* save title line 0 with attributes */
X	for (i = 0; i <= COLS; i++)
X		titleline[i] = mvwinch (stdscr, 0, i);
X
X	initmenu (&pmenu);
X
X      	rc = parsedriver (menufile, KeyWord, ParseKey, &pmenu, gnames, gfiles, 
X			&gindex);
X      	fclose (menufile);
X
X	if (AUTOFIG)
X	{
X		int	longest;
X
X		/*
X		** try to put menu as close to the option as possible
X		**  menu->option[opnumber]->row holds the
X		**  location on stdscr of the option that selected this.
X		*/
X		row = menu->option[opnumber]->row - 1;
X		col = menu->option[opnumber]->col + 
X		      	      strlen (menu->option[opnumber]->description);
X		if (popmid == 9)
X			col += 4;
X
X		/* make sure it fits on the screen */
X		if ((row + pmenu.optioncount + 2) > LINES)
X			row = LINES - pmenu.optioncount - 2;
X
X		for (i = 0, longest = 0; i < pmenu.optioncount; i++)
X			if (strlen (pmenu.option[i]->description) > longest)
X				longest = strlen (pmenu.option[i]->description);
X		if ((col + longest + 4) > COLS)
X			col = COLS - longest - 4;
X
X		if (row < 0)
X			row = 0;
X
X		/*
X		**  Recalculate the options row and col for recursion
X		*/
X		for (i = 0; i < pmenu.optioncount; i++)
X		{
X			pmenu.option[i]->row = row + 1 + i;
X			pmenu.option[i]->col = col;
X		}
X	}
X
X	/* find popmenu title in line 0 */
X	for (i = 0; i <= COLS; i++)
X	{
X		poptitle[i] = ' ';
X		if (mvwinch (stdscr, 0,i) != titleline[i])
X		{
X			poptitle[i] = mvwinch(stdscr, 0,i);
X		}
X		else
X			poptitle[i] = ' ';
X		/* write original title back out */
X		mvwaddch (stdscr, 0,i, titleline[i]);
X	}
X	poptitle[i] = '\0';
X	/* junk trailing spaces */
X	for (i = strlen(poptitle)-1; i >= 0; i--)
X		if (poptitle[i] == ' ')
X			poptitle[i] = '\0';
X		else
X			break;
X
X	if (rc != 0) return (rc);			/* from parsemenu */
X
X
X
X	/* if .BOX||.LINE && DIM then unhilight */
X	if (DIMFLAG)
X	{
X		/* Dim the .BOX */
X		if (menu->boxtype)
X			drawbox (stdscr, 1,1, LINES-1,COLS, 
X				(menu->boxtype&0777000)>>9, DumbLine,
X				FALSE, FALSE);
X
X		/* Dim the .LINE */
X		if (menu->linetype)
X			drawline (stdscr, menu->titlecount-1, 
X				(menu->linetype&0777000)>>9, DumbLine, 
X				menu->boxtype);
X
X		wnoutrefresh (stdscr);
X	}
X
X	/* popmid = 10+ */
X	popmid++;
X	for (i = 0; i < pmenu.optioncount; i++)
X		strcpy (PopMenu[i], pmenu.option[i]->description);
X	strcpy (PopMenu[i], "");
X	popmenu (INITMENU, popmid, row, col, poptitle, HELPFILE,
X			LINES-2, sizeof(PopMenu[0]), PopMenu);
X
X	rc = popmenu (popmid, (char *)NULL);
X
X	/* run option selected */
X	if (rc > 0)
X	{
X		for (i = 1; i <= MAXKEYS && strcmp (KeyWord[i], "") != 0; i++)
X			if (strcmp (pmenu.option[rc-1]->keyword, 
X				    KeyWord[i]) == 0)
X			{
X				if (RunKey[i] != NULL)
X				{
X					/*
X					**  Dim box is option is a .POPMENU or
X					**  a .GETINPUT or a .SYSTEM GETINPUT
X					*/
X					comptr = pmenu.option[rc-1]->command;
X					SKIPJUNK(comptr);
X   					sscanf (comptr, "%s", command);
X					if (strcmp (pmenu.option[rc-1]->keyword, ".POPMENU") == 0  ||
X					    strcmp (pmenu.option[rc-1]->keyword, ".GETINPUT") == 0 ||
X					    (strcmp (pmenu.option[rc-1]->keyword, ".SYSTEM") == 0 && 
X					     strcmp (command, "GETINPUT") == 0))
X						popmenu (UNHILIGHTBOX, popmid);
X
X		         		rc = (*RunKey[i]) (&pmenu, rc-1,
X						KeyWord, ParseKey, ShowKey, 
X						RunKey, gnames, gfiles, gindex);
X				}
X				break;
X			}
X	}
X	else
X		rc = 0;			/* popmenu was cancelled, continue */
X
X	popmid--;
X
X	/* run after_menu if there is one */
X	if (pmenu.after_menu != (char *)NULL)
X		RunAftMenu (&pmenu);
X
X	clean_menu (&pmenu);
X
X	if (DIMFLAG)
X	{
X		/* hilight .BOX */
X		if (menu->boxtype)
X			drawbox (stdscr, 1,1, LINES-1,COLS, 
X				menu->boxtype & 0777, StandoutLine,
X				FALSE, FALSE);
X
X		/* hilight .LINE */
X		if (menu->linetype)
X			drawline (stdscr, menu->titlecount-1,
X				menu->linetype & 0777, StandoutLine,
X				menu->boxtype);
X	}
X
X	touchwin (stdscr);
X
X    	if (rc != 0)  
X		return (rc);
X	else
X		return (REPARSE);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0644 RunPopMenu.c || echo "restore of RunPopMenu.c fails"
echo "x - extracting RunGetI.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunGetI.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	RunGetInpt()
X**		Runs keyword ".GETINPUT".
X**  ARGS:	option		option info sturcture
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<term.h>
X#include	<ctype.h>
X#include	"menu.h"
X
X
X
XRunGetInput (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey, 
X		gnames, gfiles, gindex)
X	struct MenuInfo		*menu;
X	int			opnumber;
X	int			(*ParseKey[MAXKEYS])(),
X				(*ShowKey[MAXKEYS])(),
X				(*RunKey[MAXKEYS])();
X	char			KeyWord[MAXKEYS][MAXKEYLENGTH];
X	char			gnames[MAXGNAME][15];
X	char			gfiles[MAXGNAME][15];
X	int			gindex;
X{
X	char			screen_name[50];
X	int			rc;		/* return code */
X	char			*comptr;
X
X	/*
X	**  The first argument is the screen name
X	*/
X	comptr = menu->option[opnumber]->command;
X	SKIPJUNK(comptr);
X   	sscanf (menu->option[opnumber]->command, "%s", screen_name);
X	comptr += strlen (screen_name);
X	SKIPJUNK(comptr);
X
X	/*
X	**  Loop through each variable=value
X	*/
X	do
X	{
X		rc = setvariable (&comptr);
X		if (rc != 0) break;
X	} while (rc != EOF);
X
X	rc = runscreen (screen_name, menu, opnumber);
X	if (rc == KEY_CANCEL)
X		return (0);
X	else
X		return (REPARSE);
X}
SHAR_EOF
chmod 0644 RunGetI.c || echo "restore of RunGetI.c fails"
echo "x - extracting RunAftMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > RunAftMenu.c &&
X/*  FUNCTION:	RunAftMenu()
X**		Runs keyword ".AFTER_MENU".
X**  ARGS:
X**		menu		menu structure
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	<signal.h>
X#include	"menu.h"
X
X
Xextern	int	debug;
Xextern	int	trapsigs;
X
X
X
XRunAftMenu (menu)
X	struct MenuInfo	*menu;
X{
X	int		shutdown();
X	int		rc;
X	char		*comptr;
X	char		tmpstr[80];
X	int		redrawflag = FALSE;
X
X
X
X	comptr = menu->after_menu;
X	SKIPJUNK(comptr);
X
X
X   	sscanf (comptr, "%s", tmpstr);		/* do we have a REDRAW */
X	if (strcmp (tmpstr, "REDRAW") == 0)
X	{
X		redrawflag = TRUE;
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);
X   		sscanf (comptr, "%s", tmpstr);	/* do we have a GETINPUT */
X	}
X
X	if (strcmp (tmpstr, "GETINPUT") == 0)
X	{
X		/* get screen name */
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);
X   		sscanf (comptr, "%s", tmpstr);		/* screen name */
X		comptr += strlen(tmpstr);
X		SKIPJUNK(comptr);		/* sitting at system(3) */
X		rc = runscreen (tmpstr, menu, 1);
X		if (rc == KEY_CANCEL)
X			return (0);
X	}
X
X	reset_shell_mode ();
X	signal (SIGINT, shutdown);
X	signal (SIGQUIT, shutdown);
X   	rc = system (comptr);
X	if (trapsigs)
X	{
X		signal (SIGINT, SIG_IGN);
X		signal (SIGQUIT, SIG_IGN);
X	}
X	reset_prog_mode ();
X	keypad (stdscr, TRUE);
X
X	/*
X	**  Going from a shell return code (char) to a c return code (int)
X	**  the shell return code gets put in the high byte.  So we will
X	**  shift the int right 8 bytes.
X	*/
X	rc = rc >> 8;					/* to get shell rc */
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] <%s> rc=%d  command=%s", 
X			__FILE__, ".AFTER_MENU", rc, comptr);
X		fflush (stderr);
X	}
X
X	/*
X	**  Shell can't handle negative return codes so we will convert 
X	**  the return code to negative so menu can use it.
X	**	-1 = QUIT
X	**	-2 = MAINMENU
X	**	-3 = PREVMENU
X	**	-4 = NOWAYJOSE
X	**	100+offset = GNAME
X	*/
X	if (rc < GNAMEOFFSET)
X		rc -= rc * 2;				/* make negative */
X
X	if (redrawflag)
X		clearok (stdscr, TRUE);
X
X	return (rc);
X}
X/* Paul J. Condie  4-90 */
SHAR_EOF
chmod 0644 RunAftMenu.c || echo "restore of RunAftMenu.c fails"
echo "x - extracting GetOption.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > GetOption.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#include	<curses.h>
X#include	<ctype.h>
X#include	"menu.h"
X#include	"terminal.h"
X
Xextern int	HotKeys;
X	int	ch;			/* input character */
X
X
XGetOption (row, col, s)
X
X	int	row;			/* row to get user input */
X	int	col;			/* col to get user input */
X	char	*s;			/* memory string to store input */
X{
X	char	*findfile();
X	char	*getenv();
X	char	*ws;			/* working string */
X	int	cc;			/* column count */
X	int	i;			/* work variable */
X	char	hlpfile[100];
X
X
X	ws = s;				/* set to memory string */
X	cc = col;
X
X	for (i = col; i <= col+3; i++)	/* blank out prompt field */
X	   mvaddch (row, i, ' ');
X					/* display default text */
X	while (*ws)
X	{
X		move (row, cc++);
X		addch (*ws);
X		ws++;
X	}
X					/* loop until done */
X	for (;;)
X	{
X		move (row, cc);
X		refresh ();
X		ch = mygetch ();
X		move (ErrRow, 0);  clrtoeol ();
X
X      		if (ch == KeyDown)   	ch = KEY_DOWN;
X      		if (ch == KeyUp)	ch = KEY_UP;
X      		if (ch == KeyTab)	ch = KEY_TAB;
X      		if (ch == KeyBTab)	ch = KEY_BTAB;
X      		if (ch == KeyReturn)	ch = KEY_RETURN;
X		if (ch == KeyBackspace)	ch = KEY_BACKSPACE;
X		if (ch == KeyRedraw)	ch = KEY_REFRESH;
X		if (ch == KeyHelp)	ch = KEY_HELP;
X		if (ch == KeyMainMenu)	ch = KEY_MAINMENU;
X		if (ch == KeyPrevMenu)	ch = KEY_PREVMENU;
X		if (ch == KeyExitMenu)	ch = KEY_EXITMENU;
X		if (ch == KeyGname)	ch = KEY_GNAME;
X		if (ch == KeyPopGname)	ch = KEY_POPGNAME;
X
X		if (ch >= 'a' && ch <= 'z')
X			ch = toupper (ch);
X
X		switch (ch)
X		{
X		   case KEY_DOWN:
X		   case KEY_UP:
X		   case KEY_TAB:
X		   case KEY_BTAB:
X			*s = '\0';	/* reset select to null */
X		   case KEY_RETURN:
X		   case KEY_LINEFEED:
X		   case '0':
X		   case '1':
X		   case '2':
X		   case '3':
X		   case '4':
X		   case '5':
X		   case '6':
X		   case '7':
X		   case '8':
X		   case '9':
X			return (ch);
X
X		   case '!':
X			if (getenv ("SHELL") != (char *)NULL)
X				return (ch);
X			break;
X
X		   case KEY_HELP:
X		   case KEY_EXITMENU:
X		   case KEY_MAINMENU:
X		   case KEY_PREVMENU:
X		   case KEY_GNAME:
X			if (HotKeys)
X			{
X				return (ch);
X			}
X			else
X			{
X				if (ch == KEY_HELP)
X					*ws = KeyHelp;
X				else if (ch == KEY_EXITMENU)
X					*ws = KeyExitMenu;
X				else if (ch == KEY_MAINMENU)
X					*ws = KeyMainMenu;
X				else if (ch == KEY_PREVMENU)
X					*ws = KeyPrevMenu;
X				else if (ch == KEY_GNAME)
X					*ws = KeyGname;
X				move (row, cc);
X				addch (*ws);
X				ws++;
X				*ws = '\0';
X				cc++;		/*move over one column*/
X			}
X			break;
X			
X		   case KEY_BACKSPACE:
X			if (cc == col) 
X				continue;
X			else
X			{
X				move (row, --cc);	/* back up one column */
X				addch (' ');
X				ws--;
X				*ws = '\0';
X			}
X			break;
X
X		   case KEY_REFRESH:
X			/* redraw screen */
X			clearok (stdscr, TRUE);
X			refresh ();
X			break;
X
X		   case KEY_POPGNAME:
X			return (KeyPopGname);
X
X		   case ' ':
X		   case 'A':
X		   case 'B':
X		   case 'C':
X		   case 'D':
X		   case 'E':
X		   case 'F':
X		   case 'G':
X		   case 'H':
X		   case 'I':
X		   case 'J':
X		   case 'K':
X		   case 'L':
X		   case 'M':
X		   case 'N':
X		   case 'O':
X		   case 'P':
X		   case 'Q':
X		   case 'R':
X		   case 'S':
X		   case 'T':
X		   case 'U':
X		   case 'V':
X		   case 'W':
X		   case 'X':
X		   case 'Y':
X		   case 'Z':
X			return (ch);
X
X		   default:
X			if (isprint (ch))
X			{
X				*ws = ch;
X				move (row, cc);
X				addch (*ws);
X				ws++;
X				*ws = '\0';
X				cc++;		/*move over one column*/
X			}
X			break;
X		} /* end switch */
X	} /* end for */
X}
SHAR_EOF
chmod 0644 GetOption.c || echo "restore of GetOption.c fails"
echo "x - extracting EndWindow.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > EndWindow.c &&
Xstatic char Sccsid[] = "@(#)EndWindow.c	1.1   DeltaDate 9/6/87   ExtrDate 1/22/90";
X/*  FUNCTION:	EndWindow()
X**		When a "WINDOW" keyword is found this function
X**		recalculates the row and column to begin 
X**		displaying the next subwindow.
X**  ARGS:	menu	current menu structure
X*/
X
X#include	"menu.h"
X
Xextern	int	swin, ewin, longest;
X
X
XEndWindow (menu)
X
X	struct MenuInfo	*menu;
X{
X	int		i;
X
X
X   if (swin == ewin)  return;
X
X   longest += 5;
X
X/*
X**	Calculate what row and column to display option on.
X*/
X
X   for (i = swin; i < ewin; i++)
X   {
X      menu->option[i]->row = ((menu->wlrow - menu->wfrow) / 2 + menu->wfrow) -
X			      ((ewin - swin) / 2) + i - swin;
X      menu->option[i]->col = (menu->wlcol - menu->wfcol) / 2 - 
X			      longest / 2 + menu->wfcol;
X   }
X}
SHAR_EOF
chmod 0444 EndWindow.c || echo "restore of EndWindow.c fails"
echo "x - extracting displaytxt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > displaytxt.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	displaytext()
X**		Displays a string to the screen with atributes.
X**  ARGS:	
X**		win	curses window to display to
X**		row	screen row
X**		col	screen col
X**		s	the string
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X
Xdisplaytext (win, row, col, s)
X	WINDOW	*win;
X	int	row, col;
X	char	s[];
X{
X	int	i;
X
X	wmove (win, row, col);
X
X/*
X**	Now display looking for terminal attributes.
X*/
X      for (i = 0; s[i] != '\0'; i++)
X      {
X         if (s[i] == '\\')
X	 {
X#ifdef BSD
X	    if (s[i+1] != 'N') s[i+1] = 'S';   /* Berk only supports standout */
X#endif
X            switch (s[++i])
X            {
X	       case 'S':
X#ifdef BSD
X			wstandout (win);
X#else
X	   		wattrset (win, win->_attrs|A_STANDOUT);
X#endif
X			break;
X	       case 'B':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_BOLD);
X#endif
X			break;
X	       case 'U':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_UNDERLINE);
X#endif
X			break;
X	       case 'D':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_DIM);
X#endif
X			break;
X	       case 'R':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_REVERSE);
X#endif
X			break;
X	       case 'L':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_BLINK);
X#endif
X			break;
X	       case 'N': 
X#ifdef BSD
X			wstandend (win);
X#else
X			wattrset (win, A_NORMAL);
X#endif
X			break;
X	    }
X	 }
X         else
X            waddch (win, s[i]);
X      }
X}
SHAR_EOF
chmod 0644 displaytxt.c || echo "restore of displaytxt.c fails"
echo "x - extracting SetTerm.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > SetTerm.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	"menu.h"
X
X				/* default values for dumb terminals */
X				/* a -1 indicates nokey */
X/* Mover Keys */
Xint	KeyReturn	= '\r';	/* \r - menu & GetInput */
Xint	KeyDown		= 10;	/* \n - menu & GetInput */
Xint	KeyUp		= 11;	/* ^k - menu & GetInput */
Xint	KeyTab		= '\t';	/* \t - menu & GetInput */
Xint	KeyBTab		= -1;	/*    - menu & GetInput */
X
X/* Edit Keys */
Xint	KeyBeg		= 2;	/* ^b - GetInput */
Xint	KeyEnd		= 5;	/* ^e - GetInput */
Xint	KeyRight	= 12;	/* ^l - GetInput */
Xint	KeyLeft		= 8;	/* \b - GetInput */
Xint	KeyBackspace	= '\b';	/* \b - GetInput */
Xint	KeyEOL		= 4;	/* ^d - GetInput clear to end of field */
Xint	KeyDL		= 3;	/* ^c - GetInput clear field and home cursor */
Xint	KeyDC		= 24;	/* ^x - GetInput delete character */
Xint	KeyIC		= 20;	/* ^t - GetInput typeover/insert mode */
X
X/* Other Keys */
Xint	KeyHelp		= '?';	/* ?  - menu & GetInput */
Xint	KeyTOC		= 20;	/* ^t - ShowHelp */
Xint	KeyRedraw	= 18;	/* ^r - menu & GetInput */
Xint	KeyCancel	= 27;	/* ESC - menu & GetInput pop-up menus */
SHAR_EOF
echo "End of part 5"
echo "File SetTerm.c is continued in part 6"
echo "6" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 6 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file SetTerm.c continued
#
CurArch=6
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 SetTerm.c"
sed 's/^X//' << 'SHAR_EOF' >> SetTerm.c
Xint	KeySave		= 6;	/* ^f - GetInput save screen to a file */
Xint	KeyPrint	= 16;	/* ^p - GetInput prints screen to lp */
Xint	KeyAccept	= 1;	/* ^a - GetInput accepts input */
X
X
X/* Menu Specific */
Xint	HotKeys		= 0;	/* for hot keyboard */
Xint	KeyMainMenu	= 'm';	/* goto main menu */
Xint	KeyPrevMenu	= 'p';	/* goto previous menu */
Xint	KeyExitMenu	= 'e';	/* exit menu */
Xint	KeyGname	= 'g';	/* goto a specific menu (dumb) */
Xint	KeyPopGname	= 7;	/* ^g  - goto a specific menu (popmenu) */
X
X
X
XSetTerm ()
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 (0);
X	}
X
X	/* set terminal keys */
X	while (fgets (line, BUFSIZE, menuinit) != (char *)NULL)
X	{
X		if (strncmp ("HOTKEYS", line, 7) == 0)
X			HotKeys = 1;
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_EXITMENU", line, 12) == 0)
X			sscanf (s1, "%d", &KeyExitMenu);
X		else if (strncmp ("KEY_MAINMENU", line, 12) == 0)
X			sscanf (s1, "%d", &KeyMainMenu);
X		else if (strncmp ("KEY_PREVMENU", line, 12) == 0)
X			sscanf (s1, "%d", &KeyPrevMenu);
X		else if (strncmp ("KEY_GNAME", line, 9) == 0)
X			sscanf (s1, "%d", &KeyGname);
X		else if (strncmp ("KEY_POPGNAME", line, 12) == 0)
X			sscanf (s1, "%d", &KeyPopGname);
X		else if (strncmp ("KEY_TOC", line, 7) == 0)
X			sscanf (s1, "%d", &KeyTOC);
X	}
X	fclose (menuinit);
X	return (0);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
echo "File SetTerm.c is complete"
chmod 0644 SetTerm.c || echo "restore of SetTerm.c fails"
echo "x - extracting systime.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > systime.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)systime.c	1.2   DeltaDate 5/6/88   ExtrDate 1/22/90";
X#endif
X
X#include <stdio.h>
X#include <time.h>
X
Xsystime (timeStr, mask)
X
X	char *timeStr, *mask;
X{
X	long		tloc ;
X	struct tm  	*ltime, *localtime() ;
X	char 		tmpstr[4] ;
X	int		tmpval;
X
X   tloc = time((long *) 0) ;
X   ltime = localtime(&tloc) ;
X
X   ltime->tm_mon++;
X
X   if (mask == NULL)
X   {
X      sprintf (timeStr, "%2d:%02d:%02d", ltime->tm_hour, ltime->tm_min, 
X	       ltime->tm_sec) ;
X   }
X   else
X      while (*mask != '\0')
X      {
X         switch (*mask)
X         {
X            case 'H':
X			if (ltime->tm_hour > 12)
X			{
X			   tmpval = ltime->tm_hour - 12;
X			   sprintf (tmpstr, "%2d", tmpval);
X			}
X			else
X			   sprintf (tmpstr, "%2d", ltime->tm_hour);
X	    		break;
X	    case 'M':
X			sprintf (tmpstr, "%02d", ltime->tm_min);
X			break;
X	    case 'S':
X			sprintf (tmpstr, "%02d", ltime->tm_sec);
X			break;
X	    case 'I':
X			sprintf (tmpstr, "%2d", ltime->tm_hour);
X			break;
X	    case 'Z':
X			if (ltime->tm_hour >= 12)
X			   strcpy (tmpstr, "PM");
X			else
X			   strcpy (tmpstr, "AM");
X			break;
X	    case 'z':
X			if (ltime->tm_hour >= 12)
X			   strcpy (tmpstr, "pm");
X			else
X			   strcpy (tmpstr, "am");
X			break;
X	    default:
X			*timeStr = *mask;
X			timeStr++;
X			mask++;
X			continue;
X         }   /* end switch */
X         *timeStr = tmpstr[0];
X	 timeStr++;
X         *timeStr = tmpstr[1];
X	 timeStr++;
X         mask += 2;
X      }  /* end while */
X
X   *timeStr = '\0';
X   return (0);
X}
SHAR_EOF
chmod 0444 systime.c || echo "restore of systime.c fails"
echo "x - extracting sysdate.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > sysdate.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)sysdate.c	1.1   DeltaDate 9/6/87   ExtrDate 1/22/90";
X#endif
X
X#include	<time.h>
X
Xsysdate (dateStr, mask)
X
X	char *dateStr, *mask;
X{
X	long		tloc ;
X	struct tm  	*ltime, *localtime() ;
X
Xstatic	char		*shortmon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
X			              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
X
Xstatic	char		*longmon[]= 
X		  {"January","February","March","April","May","June",
X		   "July","August","September","October","November","December"};
X
Xstatic	char		*shortday[]= {"sun","mon","tue","wed","thr","fri","sat"};
X
Xstatic	char		*longday[]= {"Sunday","Monday","Tuesday","Wednessday",
X			            "Thursday", "Friday", "Saturday"};
X
X
X   tloc = time ((long *) 0) ;
X   ltime = localtime (&tloc) ;
X
X   while (*mask != '\0')
X   {
X
X/*
X**	Process month
X*/
X      if (strncmp (mask, "mmmmm", 5) == 0)
X      {
X	 sprintf (dateStr, "%s", longmon[ltime->tm_mon]);
X	 mask += 5;
X	 dateStr += strlen (longmon[ltime->tm_mon]);
X	 continue;
X      }
X      else
X         if (strncmp (mask, "mmm", 3) == 0)
X         {
X            sprintf (dateStr, "%s", shortmon [ltime->tm_mon]);
X	    mask += 3;
X	    dateStr += 3;
X	    continue;
X         }
X	 else
X	    if (strncmp (mask, "mm", 2) == 0)
X	    {
X	       sprintf (dateStr, "%.2d", ltime->tm_mon + 1);
X	       mask += 2;
X	       dateStr += 2;
X 	       continue;
X	    }
X
X/*
X**	Process day
X*/
X      if (strncmp (mask, "ddddd", 5) == 0)
X      {
X         sprintf (dateStr, "%s", longday [ ltime->tm_wday ]);
X	 mask += 5;
X	 dateStr += strlen (longday[ltime->tm_wday]);
X	 continue;
X      }
X      else
X         if (strncmp (mask, "ddd", 3) == 0)
X         {
X            sprintf (dateStr, "%s", shortday [ltime->tm_wday]);
X	    mask += 3;
X	    dateStr += 3;
X	    continue;
X         }
X         else
X            if (strncmp (mask, "dd", 2) == 0)
X	    {
X	       sprintf (dateStr, "%.2d", ltime->tm_mday);
X	       mask += 2;
X	       dateStr += 2;
X	       continue;
X	    }
X      if (strncmp (mask, "jjj", 3) == 0)
X      {
X         sprintf (dateStr, "%3d", ltime->tm_yday + 1);
X	 mask += 3;
X	 dateStr += 3;
X	 continue;
X      }
X
X/*
X**	Process year
X*/
X      if (strncmp (mask, "yyyy", 4) == 0)
X      {
X         sprintf (dateStr, "19%.2d", ltime->tm_year);
X	 mask += 4;
X	 dateStr += 4;
X	 continue;
X      }
X      else
X         if (strncmp (mask, "yy", 2) == 0)
X	 {
X	    sprintf (dateStr, "%.2d", ltime->tm_year);
X	    mask += 2;
X	    dateStr += 2;
X	    continue;
X 	 }
X
X/*
X**	Process mask
X*/
X      *dateStr = *mask;
X      dateStr++;
X      mask++;
X   }
X
X   *dateStr = '\0';
X   return (0);
X}
SHAR_EOF
chmod 0444 sysdate.c || echo "restore of sysdate.c fails"
echo "x - extracting checkmail.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > checkmail.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)checkmail.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	<signal.h>
X
X#ifndef BELL
X#define	BELL		printf ("%c", 7);
X#endif
X
Xextern	int		mailrow;
Xextern	int		mailcol;
X
Xcheckmail ()
X{
X	int		rc;
X	static int	mailcheck = 30;			/* default */
X
X#ifdef ALARM
X	alarm (0);					/* turn off alarm */
X#endif
X	if ((rc = anymail()) != FALSE)
X	{
X		/* we got mail */
X		attrset (A_REVERSE);
X		if (rc == 1  ||  rc == 3)
X			mvprintw (mailrow,mailcol, "MAIL");
X		else
X			mvprintw (mailrow,mailcol, "EMAIL");
X		attrset (A_NORMAL);
X#ifdef ALARM
X		BELL;
X#endif
X	}
X	else
X		mvprintw (mailrow,mailcol, "    ");
X
X#ifdef ALARM
X	signal (SIGALRM, checkmail);
X	if ((char *)getenv("MAILCHECK") != (char *)0)
X		sscanf ((char *)getenv("MAILCHECK"), "%d", &mailcheck);
X	if (mailcheck < 10)
X		mailcheck = 10;
X	alarm (mailcheck);				/* set alarm again */
X#endif
X}
X/* Paul J. Condie  4/88 */
SHAR_EOF
chmod 0444 checkmail.c || echo "restore of checkmail.c fails"
echo "x - extracting anymail.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > anymail.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)anymail.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*	FUNCTION:	anymail()
X**			If the first word in the mail file is Forward it returns
X**			no mail.
X**	RETURNS:	FALSE	- no unix or email.
X**			1	- unix mail.
X**			2	- email
X**			3	- both unix and email
X*/
X#include	<stdio.h>
X#include	<sys/types.h>
X#include	<sys/stat.h>
X
Xanymail ()
X{
X	FILE		*fopen(), *fp;
X	char		*getenv();
X	struct stat	Statbuf;
X	int		rc = 0;				/* return code */
X	char		*mailfile;
X	static int	FIRST_TIME = 1;
X	static int	FORWARDFLAG = 0;
X	char		tmpstr[80];
X
X
X   if ((mailfile = getenv("MAIL")) != (char *)0)
X   	if (stat (mailfile, &Statbuf) == 0)  
X   	{
X		/* there is a mail file */
X		if (Statbuf.st_size > 0)
X		{
X			/* there is something in the mail file */
X			if (FIRST_TIME)
X			{
X				/* check to see if mail is being Forwarded */
X				FIRST_TIME = 0;
X				if ((fp=fopen (mailfile, "r")) != (FILE *)NULL)
X				{
X					fscanf (fp, "%s", tmpstr);
X					if (strcmp (tmpstr, "Forward") == 0)
X						FORWARDFLAG = 1;
X					fclose (fp);
X				}
X			}
X			if (!FORWARDFLAG)
X				rc = 1;
X		}
X   	}
X   if ((mailfile = getenv("EMAIL")) != (char *)0)
X   	if (stat (mailfile, &Statbuf) == 0) 
X   	{
X		if (Statbuf.st_size > 0)
X			rc = rc == 1 ? 3 : 2;
X   	}
X   return (rc);
X}
SHAR_EOF
chmod 0444 anymail.c || echo "restore of anymail.c fails"
echo "x - extracting setenv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > setenv.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)setenv.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/* PROGRAM NAME:  @(#)setenv.c	1.2  
X*  REVISION DATE: 
X*  REVISION LEVEL:
X*  CONTACT PERSON: Library Staff
X*  AUTHOR: Stephen J. Muir 
X*  ABSTRACT: setenv/delenv - add, change or delete environment variables
X*  KEYWORDS: environment, shell, getenv
X*  DESCRIPTION: Setenv allows a program to set environment variables.
X*  		delenv allows a program to delete environment variables.
X*  PROJECTS: 
X*  SOFTWARE CATEGORY: application development tools
X*  COPYRIGHT:              Notice
X   This is the confidential, unpublished property of Pacific Bell.
X   Receipt or possession of it does not convey any rights to divulge,
X   reproduce, use, or allow others to use it without the specific written
X   authorization of Pacific Bell and use must conform strictly to
X   the license agreement between user and Pacific Bell.
X
X      COPYRIGHT (c) 1986 Pacific Bell. All Rights Reserved. 
X
X*  OPERATING ENVIRONMENT: all standard AT&T UNIX machines.
X*  SOFTWARE DEPENDENCIES: none.
X*  HARDWARE DEPENDENCIES: 
X*  LIMITATIONS: 
X*  DOCUMENTATION: setenv.3 manual page
X*  COMPILE COMMAND: cc setenv.c 
X*  SIZE: 
X*  SUPPORT LEVEL:
X*  MODULE LIST:
X*/
X# include <string.h>
X
X/* This is the number of extra array elements to allocate each time it becomes
X * necessary.
X */
X# define INC	10
X
Xextern char	**environ, *malloc ();
Xextern int	free ();
X
Xstatic char	**original, **current, **limit;
X
X/* This routine should be called only once (when either "setenv" or "delenv" is
X * called for the first time).  It would only be called again if it fails due
X * to lack of memory.  It makes a copy of the original environment because the
X * original environment array and its elements were not obtained from "malloc"
X * and the "free" routine cannot, therefore, be called with any of its
X * elements.
X *
X * return values:
X *	 0: success
X *	-1: out of memory - nothing has changed
X */
Xstatic	/* this is a private routine */
Xinitialise ()
X	{ register char	**old, **new_ptr, *tmp, **new_env;
X
X	  /* count number of existing strings */
X	  for (old = environ; *old; ++old)
X		;
X
X	  /* make space for extra strings */
X	  if ((new_ptr =
X	       new_env =
X	       (char **)malloc (sizeof (char **) * ((old - environ) + INC + 1))
X	      )
X	      == 0
X	     )
X		return (-1);
X
X	  /* "limit" points to the last element of the array -- it is used to
X	   * decide when to recreate it
X	   */
X	  limit = new_env + (old - environ) + INC;
X
X	  /* copy across old strings */
X	  for (old = environ; *old; ++old)
X	  { if ((tmp = malloc (strlen (*old) + 1)) == 0)
X	    { /* out of memory -- undo everything */
X	      while (new_ptr != new_env)
X		free (*--new_ptr);
X	      free ((char *)new_ptr);
X	      return (-1);
X	    }
X	    strcpy (tmp, *old);
X	    *new_ptr++ = tmp;
X	  }
X	  /* "current" points to the null pointer at the end of the array */
X	  *(current = new_ptr) = 0;
X
X	  /* this is really just a flag to say it's initialised */
X	  original = environ;
X	  /* overwrite old environment with new */
X	  environ = new_env;
X	  return (0);
X	}
X
X/* This is a special routine to compare a string "name" of the form "NAME" with
X * a string "name_value" of the form "NAME=VALUE".  It returns zero if the
X * comparison is successful
X */
Xstatic	/* this is a private routine */
Xdiffer (name, name_value)
X	char	*name, *name_value;
X	{ while (*name && *name_value)
X		if (*name++ != *name_value++)
X			return (1);
X	  return (*name_value != '=');
X	}
X
X/* This routine deletes an environment variable, e.g. delenv ("SHELL");
X *
X * return values:
X *	 0: success
X *	 1: environment variable not found
X *	-1: out of memory - nothing has changed
X */
Xdelenv (name)
X	char	*name;
X	{ register char	**ptr;
X
X	  /* initialise if necessary */
X	  if (original == 0 && initialise ())
X		return (-1);
X
X	  /* attempt to find it */
X	  for (ptr = environ; *ptr && differ (name, *ptr); ++ptr)
X		;
X	  if (*ptr == 0)
X		return (1);	/* not found */
X
X	  /* delete it */
X	  free (*ptr);
X	  *ptr = *--current;
X	  *current = 0;
X	  return (0);
X	}
X
X/* This routine sets a new environment variable, replacing an existing one
X * where appropriate, e.g. setenv ("SHELL", "/bin/csh");
X *
X * return values:
X *	 0: success
X *	-1: out of memory - nothing has changed
X */
Xsetenv (name, value)
X	char	*name, *value;
X	{ register char	**old, **new_ptr, *cp, *tmp, **new_env;
X
X	  /* initialise if necessary */
X	  if (original == 0 && initialise ())
X		return (-1);
X
X	  /* allocate space for the new string */
X	  if ((cp = tmp = malloc (strlen (name) + strlen (value) + 2)) == 0)
X		return (-1);
X
X	  /* find an existing one if we can - we do this now as we will lose
X	   * the original "name" pointer in the while loop following
X	   */
X	  for (old = environ; *old && differ (name, *old); ++old)
X		;
X
X	  /* make the new entry */
X	  while (*name)
X		*cp++ = *name++;
X	  *cp++ = '=';
X	  while (*value)
X		*cp++ = *value++;
X	  *cp = '\0';
X
X	  /* case 1: overwrite previous value */
X	  if (*old)
X	  { free (*old);
X	    *old = tmp;
X	  }
X
X	  /* case 2: no previous value and no space left - allocate more */
X	  else if (current == limit)
X	  { if ((new_ptr =
X		 new_env =
X		 (char **)malloc (sizeof (char **) *
X				  ((old - environ) + INC + 1)
X				 )
X		) == 0
X	       )
X	    { free (tmp);
X	      return (-1);
X	    }
X	    limit = new_env + (old - environ) + INC;
X	    for (old = environ; *old; )
X		*new_ptr++ = *old++;
X	    *new_ptr++ = tmp;
X	    *(current = new_ptr) = 0;
X	    free ((char *)environ);
X	    environ = new_env;
X	  }
X
X	  /* case 3: no previous value and there is enough space */
X	  else
X	  { *current++ = tmp;
X	    *current = 0;
X	  }
X	  return (0);
X	}
SHAR_EOF
chmod 0444 setenv.c || echo "restore of setenv.c fails"
echo "x - extracting strmatch.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > strmatch.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)strmatch.c	1.1   DeltaDate 10/20/88   ExtrDate 1/22/90";
X#endif
X
X#ifndef	TRUE
X#define	TRUE	1
X#endif
X#ifndef	FALSE
X#define	FALSE	0
X#endif
X#ifndef	BOOL
X#define	BOOL	int
X#endif
X
X#define	M_ALL	'*'
X#define	M_ONE	'?'
X#define	M_SET	'['
X#define	M_RNG	'-'
X#define	M_END	']'
X
X
XBOOL strmatch (name, pat)
X
X	char		*name, *pat;
X{
X   	char		c, k;
X	BOOL		ok;
X
X
X   while ((c = *pat++) != '\0')
X   {
X      switch (c)
X      {
X	 case M_ONE:
X		if (*name++ == '\0')   return (FALSE);
X		break;
X	
X	case M_ALL:
X		if (*pat == '\0')   return (TRUE);
X		for (; *name != '\0'; ++name)
X		   if (strmatch (name, pat))   return (TRUE);
X		return (FALSE);
X
X	case M_SET:
X		ok = FALSE;
X		k = *name++;
X		while ((c = *pat++) != M_END)
X		   if (*pat == M_RNG)
X		   {
X		      if (c <= k  &&  k <= pat[1])
X			 ok = TRUE;
X		      pat += 2;
X		   }
X		   else
X		      if (c == k)   ok = TRUE;
X		if (!ok)   return (FALSE);
X		break;
X
X	default:
X		if (*name++ != c)   return (FALSE);
X		break;
X      }
X   }
X   return (*name == '\0');
X}
SHAR_EOF
chmod 0444 strmatch.c || echo "restore of strmatch.c fails"
echo "x - extracting setvar.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > setvar.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	<ctype.h>
X#include	<string.h>
X#include	"menu.h"
X
X
X
Xsetvariable (cptr)
X	char	**cptr;				/* command pointer var=value */
X{
X	char	*getenv();
X	char	*getval();
X	char	variable[100];
X	char	value[100];
X	int	rc;				/* return code */
X	int	i, j;
X
X	if (*cptr == (char *)NULL)   return (EOF);
X
X	/* skip junk characters */
X	for (;**cptr != '\0' &&  (!isalpha(**cptr)) && (!isdigit(**cptr)); 
X	      (*cptr)++) 
X		if (**cptr == '!')
X			break;
X		;
X	if (**cptr == '\0') return (EOF);	/* end of line */
X
X	/* get the enviroment variable */
X	for (i = 0; **cptr != '=' && **cptr != '\0'; i++, (*cptr)++)
X		variable[i] = **cptr;
X	variable[i] = '\0';
X	if (strcmp (variable, "") == 0  ||  **cptr != '=')
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, 
X		   "Error occured while setting enviroment variable %s",
X		   variable);
X		shutdown ();
X	}
X	(*cptr)++;					/* get past the = */
X
X	strcpy (value, getval (cptr, '0'));
X
X	/* set the enviroment variable */
X	if (variable[0] == '!')
X	{
X		/*
X		**  if !
X		**     then only set if not already set
X		*/
X		/* junk ! - shift left one */
X		for (i = 0; variable[i] != '\0'; i++)
X			variable[i] = variable[i+1];
X		rc = 0;
X		if (getenv(variable) == (char *)NULL)
X			rc = setenv (variable, value);
X	}
X	else
X		rc = setenv (variable, value);
X	if (rc != 0)
X	{
X		BEEP;
X		mvprintw (ErrRow-2, 0, 
X		   "Error occured while setting enviroment variable %s",
X		   variable);
X		shutdown ();
X	}
X	return (0);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0644 setvar.c || echo "restore of setvar.c fails"
echo "x - extracting drawline.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > drawline.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)drawline.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X#define	MosaicLine	4	/* A_ALTCHARSET */
X#define	DiamondLine	5	/* A_ALTCHARSET */
X#define	DotLine		6	/* A_ALTCHARSET */
X#define	PlusLine	7	/* A_ALTCHARSET */
X
X#define	CANDRAWGRAPHICS	(enter_alt_charset_mode != NULL  && \
X			 strcmp(enter_alt_charset_mode, "") != 0)
X
X
Xdrawline (win, row, trythis, trythat, box)
X	WINDOW	*win;
X	int	row;
X	int	trythis;
X	int	trythat;
X	int	box;
X{
X	int	col;
X	int	hchar;					/* horizonal char */
X	int	lchar;					/* left char */
X	int	rchar;					/* right char */
X	int	attribute;
X	int	boxtype;
X
X
X	boxtype = trythis;
X	attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
X	if (attribute == A_ALTCHARSET)
X		/* can this terminal do graphics ? */
X		boxtype = CANDRAWGRAPHICS ? trythis : trythat;
X
X	switch (boxtype)
X	{
X	   case DumbLine:
X		/* draw a dumb line */
X		hchar = '-';
X		lchar = '+';
X		rchar = '+';
X		break;
X
X	   case StandoutLine:
X		/* draw a standout line */
X		attribute = A_STANDOUT;
X		hchar = ' ';
X		lchar = ' ';
X		rchar = ' ';
X		break;
X
X	   case SingleLine:
X		/* attempt to draw a graphic single line */
X		hchar = 'q';
X		lchar = 't';
X		rchar = 'u';
X		break;
X
X	   case MosaicLine:
X		hchar = 'a';
X		lchar = 'a';
X		rchar = 'a';
X		break;
X
X	   case DiamondLine:
X		hchar = '`';
X		lchar = '`';
X		rchar = '`';
X		break;
X
X	   case DotLine:
X		hchar = '~';
X		lchar = '~';
X		rchar = '~';
X		break;
X
X	   case PlusLine:
X		hchar = 'n';
X		lchar = 'n';
X		rchar = 'n';
X		break;
X		break;
X
X	   default:
X		return (-1);
X	}
X
X#ifdef BSD
X   	standout ();
X#else
X   	wattrset (win, attribute);
X#endif
X   	for (col = 0; col <= COLS-1; col++)
X      		mvwaddch (win, row, col, hchar);
X
X	if (box)
X	{
X		mvwaddch (win, row, 0, lchar);
X		mvwaddch (win, row, COLS-1, rchar);
X	}
X
X#ifdef BSD
X   	standend ();
X#else
X   	wattrset (win, A_NORMAL);
X#endif
X	return (0);
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 drawline.c || echo "restore of drawline.c fails"
echo "x - extracting initmenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > initmenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	"menu.h"
X
Xinitmenu (menu)
X	struct MenuInfo	*menu;
X{
X      /* set default menu settings */
X      menu->row_cursor = LINES - 2;
X      menu->col_cursor = COLS - 4;
X      menu->boxtype = 0;
X      menu->linetype = 0;
X      menu->srn[0] = (struct ScreenInfo *)NULL;
X      menu->after_menu = (char *)NULL;
X}
SHAR_EOF
chmod 0644 initmenu.c || echo "restore of initmenu.c fails"
echo "x - extracting keyboard.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > keyboard.c &&
X#include	<curses.h>
X#include	<term.h>
X#include	"menu.h"
X
Xkeyboard ()
X{
X	char	*getenv();
X	int	ch;
X	int	wrow = 0;				/* from row */
X	int	wcol = 10;				/* from col */
X	int	sstart;					/* scrool start row */
X	int	send;					/* scrool end row */
X	int	prow;					/* print row */
X	int	dflag=0;
X	WINDOW	*bwin;
X
X
X	sstart = wrow + 10;
X	send = wrow + 20;
X	prow = sstart;
X
X	mvprintw (1,0, "Keyboard");
X	mvprintw (2,4, "Fun");
X
X	drawbox (stdscr, wrow+1,wcol, wrow+23,wcol+40, StandoutLine, 
X		StandoutLine, FALSE, FALSE);
X	mvprintw (2,wcol+40, "StandoutLine");
X	drawbox (stdscr, wrow+2,wcol+1, wrow+22,wcol+39, DumbLine, DumbLine,
X		FALSE, FALSE);
X	mvprintw (3,wcol+39, "DumbLine");
X
X	/* to get around bug in curses of not turning attributes off */
X	/*
X	for (ch = 0; ch <= LINES; ch++)
X	{
X		mvprintw (ch,70, "hi");
X		refresh ();
X		mvprintw (ch,70, "  ");
X	}
X	*/
X
X	/* terminal type */
X	mvprintw (wrow+3, wcol+4, "Terminal = %s", getenv("TERM"));
X
X	/* DrawLine ? */
X	if (enter_alt_charset_mode == NULL  ||
X	    strcmp (enter_alt_charset_mode, "") == 0)
X		mvprintw (wrow+4, wcol+4, "Alternate Characters = No");
X	else
X	{
X		dflag++;
X		mvprintw (wrow+4, wcol+4, "Alternate Characters = Yes");
X
X		mvprintw (5,wcol+44, "Check termcap/terminfo");
X		mvprintw (6,wcol+44, "setting if the alternate");
X		mvprintw (7,wcol+44, "character lines below");
X		mvprintw (8,wcol+44, "don't look right.");
X
X		bwin = newwin (13, 27, 10, wcol+43);
X		drawbox (bwin, 1,1, 13,27, SingleLine, SingleLine, FALSE,FALSE);
X		drawbox (bwin, 2,2, 12,26, MosaicLine, MosaicLine, FALSE,FALSE);
X		drawbox (bwin, 3,3, 11,25, DiamondLine, DiamondLine, FALSE,FALSE);
X		drawbox (bwin, 4,4, 10,24, DotLine, DotLine, FALSE,FALSE);
X		drawbox (bwin, 5,5, 9,23, PlusLine, PlusLine, FALSE,FALSE);
X
X		mvwprintw (bwin, 0,7, " SingleLine ");
X		mvwprintw (bwin, 1,7, " MosaicLine ");
X		mvwprintw (bwin, 2,7, " DiamondLine ");
X		mvwprintw (bwin, 3,7, " DotLine ");
X		mvwprintw (bwin, 4,7, " PlusLine ");
X	}
X
X	/* Show all attributes */
X	mvprintw (11,0, "Curses");
X	mvprintw (12,0, "Attributes");
X
X	attrset (A_NORMAL);
X	mvprintw (14,0, "NORMAL");
X	attrset (A_STANDOUT);
X	mvprintw (15,0, "STANDOUT");
X	attrset (A_REVERSE);
X	mvprintw (16,0, "REVERSE");
X	attrset (A_UNDERLINE);
X	mvprintw (17,0, "UNDERLINE");
X	attrset (A_BLINK);
X	mvprintw (18,0, "BLINK");
X	attrset (A_DIM);
X	mvprintw (19,0, "DIM");
X	attrset (A_BOLD);
X	mvprintw (20,0, "BOLD");
X
X	attrset (A_NORMAL);
X
X	/* key codes */
X	mvprintw (wrow+6,wcol+8, "Press a Key");
X	mvprintw (wrow+7,wcol+8, "Press zero to exit.");
X
X	/* set up scroll */
X	scrollok (stdscr, TRUE);
X	wsetscrreg (stdscr, sstart, send);
X
X	mvprintw (sstart-2, wcol+4, "      (.menuinit)");
X	attrset (A_BOLD);
X	mvprintw (sstart-1, wcol+4, "char      dec     hex    octal");
X	attrset (A_NORMAL);
X	do
X	{
X		refresh ();
X		if (dflag)
X		{
X			touchwin (bwin);
X			wrefresh (bwin);
X		}
X		move (wrow+6, wcol+8+strlen("Press a Key")+1);
X		refresh ();
X		ch = getch ();
X
X		/*
X		nodelay (stdscr, TRUE);
X		while ((ch = getch()) != -1)
X			print ch
X		nodelay (stdscr, FALSE);
X		*/
X
X		if (prow > send-2)
X		{
X			scroll (stdscr);
X			attrset (A_STANDOUT);
X			mvprintw (prow+1,wcol-1, " ");
X			mvprintw (prow+1,wcol+39, " ");
X			attrset (A_NORMAL);
X
X			mvprintw (prow+1,wcol, "|");
X			mvprintw (prow+1,wcol+38, "|");
X		}
X		else
X			prow++;
X		if (ch == '\t')
X			mvprintw (prow,wcol+4, "\t\\t\t%d\t%x\t%o", ch,ch,ch);
X		else	if (ch == '\n')
X				mvprintw (prow,wcol+4, "\t\\n\t%d\t%x\t%o", 
X						ch,ch,ch);
X		else	if (ch == '\r')
X				mvprintw (prow,wcol+4, "\t\\r\t%d\t%x\t%o", 
X						ch,ch,ch);
X		else	if (ch == '\b')
X				mvprintw (prow,wcol+4, "\t\\b\t%d\t%x\t%o", 
X						ch,ch,ch);
X		else
X			mvprintw (prow,wcol+4, "\t%c\t%d\t%x\t%o", ch,ch,ch,ch);
X
X	} while (ch != '0');
X	if (dflag)
X	{
X		touchwin (bwin);
X		wrefresh (bwin);
X	}
X}
X/* Paul J. Condie */
SHAR_EOF
chmod 0644 keyboard.c || echo "restore of keyboard.c fails"
echo "x - extracting runscreen.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > runscreen.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*  FUNCTION:	runscreen()
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X#include	"menu.h"
X#include	"terminal.h"
X
X#define	SRN	menu->srn[sidx]
X#define	FLD	menu->srn[sidx]->field[fidx]
X
Xextern int debug;
X
X
Xrunscreen (screen_name, menu, opnumber)
X	char			screen_name[];
X	struct MenuInfo		*menu;
X	int			opnumber;
X{
X	FILE			*popen(), *pp;
X	char			*getenv();
X	char			*getval();
X	char			*findfile();
X	char			*format();
X	char			*malloc();
X	WINDOW			*swin;
X	union FldUnion		Fld;
X	int			rc;		/* return code */
X	int			exitkey;
X	int			sidx;
X	int			fidx = 0;
X	char			fielddata[MAXFIELDS+1][100];
X	int			fieldcount;
X	char			*promptptr = (char *)NULL;
X	char			fmtdefault[100];/* formated default value */
X	char			*wsptr;		/* working storage pointer */
X	int			helpflag;
X	char			helpfile[80];
X	char			tmptitle[100];
X	char			Title[100];	/* tmp for AUTO */
X	int			Rows;		/* tmp for AUTO */
X	int			Cols;		/* tmp for AUTO */
X	int			toprow;
X	int			leftcol;
X	int			i;		/* tmp loop var */
X	char			value[200];
X	char			input[100];	/* what user inputted */
X	char			*tmprange[MAXFIELDS+1];
X	int			NoInput;
X
X
X
Xherewegoagain:
X
X	helpflag = TRUE;
X
X	/* Find the screen definition */
X	for (sidx = 0; menu->srn[sidx] != (struct ScreenInfo *)NULL && 
X		sidx <= MAXSCREENS; sidx++)
X	{
X		if (strcmp (screen_name, menu->srn[sidx]->name) == 0)
X			break;
X	}
X	if (sidx > MAXSCREENS  ||  menu->srn[sidx] == (struct ScreenInfo *)NULL)
X	{
X		BEEP;
X		mvprintw (ErrRow-2,0, "Could not find your screen definition.");
X		shutdown ();
X	}
X
X	/* loop through each field */
X	/* save current field data - if KEY_CANCEL reset to this */
X	for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X	     fidx <= MAXFIELDS; fidx++)
X	{
X		if (getenv(FLD->name) != (char *)NULL)
X			strcpy (fielddata[fidx], getenv (FLD->name));
X		else
X			strcpy (fielddata[fidx], "");
X
X
X		/*  range values */
X		if (strcmp (FLD->range, "") == 0)
X			tmprange[fidx] = (char *)NULL;
X		else if (FLD->range[0] != '`'  && 
X			 FLD->range[strlen(FLD->range)-1] != '`')
X		{
X			/* not a command */
X			tmprange[fidx] = (char *)malloc (strlen (FLD->range)+4);
X			strcpy (tmprange[fidx], FLD->range);
X		}
X		else if (FLD->range[0] == '`'  && 
X			 FLD->range[strlen(FLD->range)-1] == '`'  &&
X		    tmprange[fidx] == (char *)NULL)
X		{
X			/* we have a command to run - get new range values */
X			/* junk the grave accents and ! if there is one */
X			tmprange[fidx] = (char *) malloc (MAXLEN+4);
X			strcpy (tmprange[fidx], FLD->range+1);
X			if (tmprange[fidx][0] == '!')
X				strcpy (tmprange[fidx], FLD->range+2);
X			tmprange[fidx][strlen(tmprange[fidx])-1] = '\0';
X
X			if (promptptr == (char *)NULL || 
X			    strcmp (promptptr, "DONT_CLEAR") != 0)
X			{
X				move (ErrRow,0);  clrtoeol();
X				mvprintw (ErrRow,1, "Working ...");
X				refresh ();
X			}
X			if (debug)
X			{
X				fprintf (stderr, 
X					"\n[runscreen] <%s> popen=:%s:", 
X					SRN->name, tmprange[fidx]);
X				fflush (stderr);
X			}
X			if ((pp = popen (tmprange[fidx], "r")) == (FILE *)NULL)
X			{
X				BEEP;
X				mvprintw (ErrRow-2,0, 
X					"Could not open pipe = %s", tmprange[fidx]);
X				shutdown ();
X			}
X			fgets (tmprange[fidx], MAXLEN-1, pp);
X			tmprange[fidx][strlen(tmprange[fidx])-1] = '\0';   /* junk \n */
X			pclose (pp);
X		}
X	}
X
X
X	/* set tmp variables used for AUTO */
X	strcpy (Title, SRN->title);
X	Rows = SRN->rows;
X	Cols = SRN->cols;
X
X	/* if title is set to AUTO then use the description text */
X	if (atoi(Title) == AUTO)
X	{
X		strcpy (Title, menu->option[opnumber]->description);
X		/* junk ending period if there is one */
X		if (Title[strlen(Title)-1] == '.')  
X			Title[strlen(Title)-1] = '\0';
X	}
X
X	/* for SET and MENU type determine field_length */
X	for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X	     fidx <= MAXFIELDS; fidx++)
X	{
X		/* for SET and MENU types get field_length */
X		if (FLD->type == SET  ||  FLD->type == MENU)
X			FLD->length = GetSetLen (tmprange[fidx]);
X	}
X
X	/* calculate window_rows & window_cols if AUTO */
X	if (Rows == AUTO)
X	{
X		/* field with largest row + 4 */
X		Rows = 0;
X		for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X		     fidx <= MAXFIELDS; fidx++)
X		{
X			if (FLD->row > Rows)
X				Rows = FLD->row;
X		}
X		
X		/* make sure window is big enough to hold text stuff */
X		for (i = 0; SRN->textinfo[i] != (struct TextInfo *)NULL; i++)
X			if (SRN->textinfo[i]->row + 1 > Rows)
X				Rows = SRN->textinfo[i]->row + 1;
X		Rows += 3;
X	}
X	if (Cols == AUTO)
X	{
X		/* field with largest col + length + 4   or  title */
X		/* make sure screen is big enough to hold the title */
X		wsptr = Title;
X		strcpy (tmptitle, getval (&wsptr, '1'));
X		Cols = strlen (tmptitle);
X		for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X		     fidx <= MAXFIELDS; fidx++)
X		{
X			if (strlen(FLD->mask) > 0)
X			{
X				if ((FLD->col + strlen(FLD->mask) + 1) > Cols)
X					Cols = FLD->col + strlen(FLD->mask) + 1;
X			}
X			else
X				if ((FLD->col + FLD->length + 1) > Cols)
X					Cols = FLD->col + FLD->length + 1;
X		}
X
X		/* make sure window is big enough to hold text stuff */
X		for (i = 0; SRN->textinfo[i] != (struct TextInfo *)NULL; i++)
X	    		if (SRN->textinfo[i]->col +
X			    strlen(SRN->textinfo[i]->text) + 1 > Cols)
X	    			Cols = SRN->textinfo[i]->col + 
X					strlen(SRN->textinfo[i]->text) + 1;
X		Cols += 2;
X	}
X
X	/* use environment variable if there is one */
X	wsptr = SRN->toprowvar;
X	if (strcmp (SRN->toprowvar, "") != 0)
X		toprow = atoi (getval (&wsptr, '1'));
X	else
X		toprow = SRN->toprow;
X	wsptr = SRN->leftcolvar;
X	if (strcmp (SRN->leftcolvar, "") != 0)
X		leftcol = atoi (getval (&wsptr, '1'));
X	else
X		leftcol = SRN->leftcol;
X
X	if (toprow == AUTO)
X	{
X		/*
X		** Figure out where to put the screen 
X		** try to put screen as close to the option as possible 
X		*/
X		toprow = menu->option[opnumber]->row - 2;
X		/*
X		for (rc = 0, leftcol = 0; rc < menu->optioncount ; rc++)
X			if (strlen (menu->option[rc]->description) > leftcol)
X				leftcol = strlen (menu->option[rc]->description);
X		leftcol = menu->option[opnumber]->col + 
X			      ((leftcol + 4) / 2);
X		*/
X		leftcol = menu->option[opnumber]->col +
X			       strlen(menu->option[opnumber]->description) + 4;
X
X		/* make sure it fits on the screen */
X		if ((toprow + Rows) > LINES-1)
X			toprow = LINES - Rows - 1;
X		toprow = toprow < 0 ? 0 : toprow;
X
X		if ((leftcol + Cols + 2) > COLS)
X			leftcol = COLS - Cols - 1;
X		leftcol = leftcol < 0 ? 0 : leftcol;
X	}
X
X
X	/* create the window */
X	swin = newwin (Rows, Cols, toprow, leftcol);
X	keypad (swin, TRUE);
X
X	/* 
X	**	check if recalculation of rows & cols is necessary
X	**	see newwin() for info on why
X	*/
X	if (Rows == 0  &&  Cols == 0  &&  
X	    toprow == 0  && leftcol == 0)
X	{
X		/* a full-screen was created */
X		Rows = LINES-1;
X		Cols = COLS;
X	}
X	else  	if (Rows == 0  ||  Cols == 0)
X		{
X			Rows = LINES - toprow;
X			Cols = COLS - leftcol;
X			if (Rows == LINES)
X				Rows--;
X		}
X
X
X	if (strcmp (SRN->helpfile, "") == 0)
X		helpflag = FALSE;
X	else
X		strcpy (helpfile, findfile (SRN->helpfile, ".",
X			getenv("HELPDIR"), getenv("MENUDIR"), ""));
X	drawbox (swin, 1,1, Rows,Cols, SRN->boxtype & 0777, 
X		StandoutLine, FALSE, helpflag);
X
X	/* display title */
X	wsptr = Title;
X	strcpy (tmptitle, getval (&wsptr, '1'));
X	wattrset (swin, A_STANDOUT);
X	mvwprintw (swin, 0, ((Cols)/2)-(strlen(tmptitle)/2), "%s", tmptitle);
X	wattrset (swin, A_NORMAL);
X
X	/* display text stuff */
X	for (i = 0; SRN->textinfo[i] != (struct TextInfo *)NULL; i++)
X		displaytext (swin, SRN->textinfo[i]->row, SRN->textinfo[i]->col,
X			SRN->textinfo[i]->text);
X
X	/*
X	**  Run fielddefaults if there is one and load results into $field_name
X	*/
X	if (SRN->fielddefaults != (char *)NULL)
X	{
X		if (debug)
X		{
X			fprintf (stderr, "\n[runscreen] <%s> popen=:%s:", 
X				SRN->name, SRN->fielddefaults);
X			fflush (stderr);
X		}
X		if (promptptr == (char *)NULL ||
X		    strcmp (promptptr, "DONT_CLEAR") != 0)
X		{
X			move (ErrRow,0);  clrtoeol();
X			mvprintw (ErrRow,1, "Working ...");
X			refresh ();
X		}
X		if ((pp = popen (SRN->fielddefaults, "r")) == (FILE *)NULL)
X		{
X			BEEP;
X			mvprintw (ErrRow-2,0, "Could not open pipe = %s",
X				SRN->fielddefaults);
X			shutdown ();
X		}
X
X		/* read and set each $field_name until no more input */
X		rc = 99;
X		for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X			fidx <= MAXFIELDS; fidx++)
X		{
X			strcpy (value, "");
X			if (rc == EOF) 
X			{
X				if (debug)
X				{
X					fprintf (stderr, 
X			 	     		"\n[runscreen] <%s> read nothing from popen",
X						SRN->name);
X					fprintf (stderr, 
X	 	     		          "\n[runscreen] <%s> field %s =:%s:",
X				          SRN->name, FLD->name, value);
X					fflush (stderr);
X				}
X				continue;
X			}
X
X			/* get a word from the pipe */
X   			rc = fscanf (pp, "%s", fmtdefault);
X			if (rc == EOF) continue;
X			if (debug)
X			{
X				fprintf (stderr, 
X			 	     "\n[runscreen] <%s> read from popen=:%s:",
X					SRN->name, fmtdefault);
X				fflush (stderr);
X			}
X
X				
X			/* check for a quoted value */
X			if (fmtdefault[0] == '"')
X			{
X				/*
X				** found a quoted value 
X				** read until another quote or end of line
X				*/
X				strcpy (value, fmtdefault+1);	/* junk 1st " */
X				wsptr = value + strlen(value);
X				if (*(wsptr-1) == '"')
X				{
X					/* quote is on first word */
X					*(wsptr-1) = '\0';
X				}
X				else
X				{
X					while ((rc = fgetc (pp)) != EOF)
X					{
X						if ((*wsptr = (char)rc) == '"')
X						{
X							*wsptr = '\0';
X							break;
X						}
X						wsptr++;
X					} /* end while */
X				}
X			}
X			else
X				strcpy (value, fmtdefault);
X			if (debug)
X			{
X				fprintf (stderr, 
X	 	     		        "\n[runscreen] <%s> field %s =:%s:",
X				        SRN->name, FLD->name, value);
X				fflush (stderr);
X			}
X
X			/* set $field_name with new value */
X			adjustfield (value, FLD->adjust, FLD->length);
X			rc = setenv (FLD->name, value);
X		} /* end for each field */
X		pclose(pp);
X	}
X
X
X
X	/*
X	**  display field stuff
X	**  Loop through each field
X	**	print the label
X	**	put in the field terminators
X	**	get, format and print default value in getenv () or fielddefault
X	*/
X	for (fidx = 0; SRN->field[fidx] != (struct FieldInfo *)NULL && 
X		fidx <= MAXFIELDS;
X		fidx++)
X	{
X		/* print label */
X		if (strlen(FLD->label) > 0)
X			mvwprintw (swin, FLD->row, 
X				FLD->col - strlen(FLD->label) - 2,
X				"%s", FLD->label);
X
X		/* print field terminators */
X		if (strlen(FLD->terminator) > 0)
X		{
X			/* left */
X			mvwprintw (swin, FLD->row, FLD->col - 1,
X				"%c", FLD->terminator[0]);
X			/* right */
X			if (strlen(FLD->mask) > 0)
X				mvwprintw (swin, FLD->row, 
X					FLD->col + strlen(FLD->mask),
X					"%c", FLD->terminator[1]);
X			else
X				mvwprintw (swin, FLD->row, 
X					FLD->col + FLD->length,
X					"%c", FLD->terminator[1]);
X		}
X
X		/* get default value from getenv() */
X		if (getenv(FLD->name) != (char *)NULL)
X			strcpy (value, getenv (FLD->name));
X		else
X			strcpy (value, "");
X
X		/* format default value to the mask */
X		strcpy (fmtdefault, format (value, FLD->mask, FLD->type));
X		/* print default data */
X		if (strlen(fmtdefault) > 0)
X			mvwprintw (swin, FLD->row, FLD->col, "%s", fmtdefault);
X	}
X	fieldcount = fidx-1;				/* save field count */
X
X
X	/*
X	**  GetInput() from fields untill KEY_CANCEL || KEY_ACCEPT ||
X	**	exit_last_field || exit_on_cancel
X	*/
X	if (promptptr == (char *)NULL ||
X	    strcmp (promptptr, "DONT_CLEAR") != 0)
X	{
X		move (ErrRow,0);  clrtoeol();
X	}
X	fidx = 0;				/* start with first field */
X
X	do
X	{
X		NoInput = FLD->noinput;
X		/* run before_inpput command */
X		if (FLD->before_field != (char *)NULL)
X		{
X			char	buf[BUFSIZ+1];
X
X			if (promptptr == (char *)NULL || 
X			    strcmp (promptptr, "DONT_CLEAR") != 0)
X			{
X				move (ErrRow,0);  clrtoeol();
X				mvprintw (ErrRow,1, "Working ...");
X				refresh ();
SHAR_EOF
echo "End of part 6"
echo "File runscreen.c is continued in part 7"
echo "7" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 7 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file runscreen.c continued
#
CurArch=7
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 runscreen.c"
sed 's/^X//' << 'SHAR_EOF' >> runscreen.c
X			}
X			rc = runpopen (FLD->before_field, buf);
X			switch (rc)
X			{
X			   case 0:
X				/*
X				** aok accept input
X				** if buf is not null replace $var
X				*/
X				ifvarset (buf, swin, menu->srn[sidx]->field);
X				break;
X			   case 1:
X				/*
X				** aok prompt for input
X				** if buf display on message line.
X				*/
X				move (ErrRow, 0); clrtoeol ();
X				attrset (A_REVERSE);
X				mvprintw (ErrRow, 0, "%s", buf);
X				attrset (A_NORMAL);
X				refresh ();
X				sleep (3);
X				break;
X			   case 2:
X				/* skip this field */
X				ifvarset (buf, swin, menu->srn[sidx]->field);
X				NoInput = TRUE;
X				break;
X
X			   default:
X				/* do nothing */
X				break;
X			}
X		}
X
X
X		if (getenv(FLD->name) != (char *)NULL)
X			strcpy (input, getenv (FLD->name));
X		else
X			strcpy (input, "");
X   		Fld.strVal = input;
X
X
X		/*
X		** This is so GetInput doesn't overwrite the
X		** must enter message.
X		*/
X		if (promptptr == (char *)NULL)
X			promptptr = FLD->prompt;
X		else if (strcmp (promptptr, "NOMSG") == 0)
X			promptptr = NOMSG;
X
X
X		/* if noinput == FALSE prompt for input */
X		if (!NoInput)
X		{
X   			exitkey = GetInput (swin, FLD->row, FLD->col, &Fld, 
X				A_REVERSE, FLD->mask, tmprange[fidx], FLD->length, 
X				FLD->min_input, FLD->type, FLD->adjust, CHAR, 
X				NOAUTO, FLD->mustenter, ErrRow, ErrRow, 
X				promptptr, helpfile, FLD->name);
X			/* set the environment variable */
X			rc = setenv (FLD->name, Fld.strVal);
X			if (rc < 0)
X			{
X				mvwprintw (stdscr, ErrRow,0, 
X					"Unable to allocate environment memory to set variable %s.",
X					FLD->name);
X				BEEP;
X			}
X		}
X		else
X		{
X			/* use the exitkey from the last field */
X			if (exitkey != KEY_UP)
X				exitkey = KEY_DOWN;
X		}
X		promptptr = (char *)NULL;
X
X
X
X
X		if (exitkey == KeyReturn)	exitkey = KEY_RETURN;
X		if (exitkey == KeyUp)  		exitkey = KEY_UP;
X		if (exitkey == KeyDown)  	exitkey = KEY_DOWN;
X		if (exitkey == KeyTab)  	exitkey = KEY_TAB;
X		if (exitkey == KeyBTab)  	exitkey = KEY_BTAB;
X		if (exitkey == KeyCancel) 	exitkey = KEY_CANCEL;
X		if (exitkey == KeyAccept)	exitkey = KEY_ACCEPT;
X
X
X		/* run after_field command */
X		if (exitkey != KEY_CANCEL && FLD->after_field != (char *)NULL)
X		{
X			char	buf[BUFSIZ+1];
X
X			if (promptptr == (char *)NULL  ||
X			    strcmp (promptptr, "DONT_CLEAR") != 0)
X			{
X				move (ErrRow,0);  clrtoeol();
X				mvprintw (ErrRow,1, "Working ...");
X				refresh ();
X			}
X			rc = runpopen (FLD->after_field, buf);
X			switch (rc)
X			{
X			   case 0:
X				/*
X				** aok continue to next field
X				** If buf has var=value set and redisplay
X				*/
X				ifvarset (buf, swin, menu->srn[sidx]->field);
X				break;
X			   case 1:
X				/*
X				** aok prompt for input
X				** if buf display on message line.
X				*/
X				move (ErrRow, 0); clrtoeol ();
X				attrset (A_REVERSE);
X				mvprintw (ErrRow, 0, "%s", buf);
X				attrset (A_NORMAL);
X				wnoutrefresh (stdscr);
X				promptptr = "DONT_CLEAR";
X				BELL;
X				continue;
X
X			   default:
X				/* do nothing */
X				break;
X			}
X		} /* end after_field */
X
X		/* if exitlastfield accept input and exit on last field */
X		if (SRN->exitlastfield && fidx == fieldcount && 
X		    exitkey == KEY_RETURN)
X			exitkey = KEY_ACCEPT;
X
X		switch (exitkey)
X		{
X		   case KEY_CANCEL:
X			/* reset $field_name to orginal data */
X			for (fidx = 0; SRN->field[fidx] != 
X			     (struct FieldInfo *)NULL && fidx <= MAXFIELDS; 
X			     fidx++)
X				setenv (FLD->name, fielddata[fidx]);
X			break;
X
X		   case KEY_ACCEPT:
X			/* make sure mustenter fields have been entered */
X			for (fidx = 0; fidx <= fieldcount; fidx++)
X			{
X				if (FLD->mustenter  &&  
X				    strlen (getenv(FLD->name)) <= 0)
X				{
X					mvwprintw (stdscr, ErrRow,1, 
X					   "This is a must enter field.");
X					BEEP;
X					wnoutrefresh (stdscr);
X					promptptr = "DONT_CLEAR";
X					exitkey = KEY_DOWN;	/* not done */
X					break;
X				}
X			}
X			/* if mustenter then more input */
X			if (fidx <= fieldcount)
X				break;
X			break;
X
X		   case KEY_TAB:
X			fidx += 4;
X			fidx = fidx >= fieldcount ? 0 : ++fidx;
X			break;
X
X		   case KEY_BTAB:
X			fidx -= 4;
X			fidx = fidx < 0 ? fieldcount : --fidx;
X			break;
X
X		   case KEY_UP:
X			fidx = fidx <= 0 ? fieldcount : --fidx;
X			break;
X
X		   case KEY_RETURN:
X		   case KEY_DOWN:
X		   default:
X			fidx = fidx >= fieldcount ? 0 : ++fidx;
X			break;
X		}
X	} while (exitkey != KEY_CANCEL  &&  exitkey != KEY_ACCEPT);
X
X	if (exitkey != KEY_CANCEL && SRN->after_screen != (char *)NULL)
X	{
X		char	buf[BUFSIZ+1];
X
X		move (ErrRow,0);  clrtoeol();
X		mvprintw (ErrRow,1, "Working ...");
X		refresh ();
X		rc = runpopen (SRN->after_screen, buf);
X		switch (rc)
X		{
X		   case 0:
X			/*
X			** aok 
X			** if buf display on message line with no bell.
X			*/
X			move (ErrRow, 0); clrtoeol ();
X			attrset (A_REVERSE);
X			mvprintw (ErrRow, 0, "%s", buf);
X			attrset (A_NORMAL);
X			wnoutrefresh (stdscr);
X			promptptr = "DONT_CLEAR";
X			break;
X
X		   case 1:
X			/*
X			** aok prompt for input
X			** if buf display on message line with bell.
X			*/
X			move (ErrRow, 0); clrtoeol ();
X			attrset (A_REVERSE);
X			mvprintw (ErrRow, 0, "%s", buf);
X			attrset (A_NORMAL);
X			wnoutrefresh (stdscr);
X			promptptr = "DONT_CLEAR";
X			BELL;
X			break;
X
X		   default:
X			/* do nothing */
X			break;
X		}
X	} /* end after_screen */
X		
X	delwin (swin);					/* junk screen window */
X	if (!SRN->exitoncancel || exitkey == KEY_CANCEL)
X	{
X		wmove (stdscr,LINES-1,0);
X		clrtoeol ();				/* clear field prompt */
X		touchwin (stdscr);
X	}
X
X	/* junk tmp range values */
X	for (i = 0; i < MAXFIELDS; i++)
X	{
X		if (tmprange[i] != (char *)NULL)
X			free (tmprange[i]);
X		tmprange[i] = (char *)NULL;
X	}
X
X	if (SRN->exitoncancel && exitkey != KEY_CANCEL)
X		goto herewegoagain;
X
X	if (exitkey == KEY_CANCEL)
X		return (exitkey);
X	else
X		return (0);
X}
X
X
X
Xchar *format (data, mask, fldtype)
X	char	*data;			/* data 2b formated */
X	char	*mask;				/* mask to format to */
X	char	fldtype;			/* GetInput field type */
X{
X	static char	fmtdefault[100];
X	char		*wsptr;
X	char		*source;
X	int		i;
X
X
X	strcpy (fmtdefault, data);
X	wsptr = fmtdefault;
X	source = data;
X
X	if (strlen(mask) > 0)
X	{
X		for (; *mask != '\0'; mask++, wsptr++)
X		{
X			if (IsMask (fldtype, *mask))
X				*wsptr = *mask;	/* format char */
X			else
X			{
X				if (*source != '\0')
X				{
X					*wsptr = *source;
X					source++;
X				} 
X				else
X					*wsptr = ' ';	/* no data */
X			}
X		}
X			*wsptr = '\0';
X	}
X	wsptr = fmtdefault;
X	return (wsptr);
X}
X
X
X
X/*
X**  if buf contains space separated $var=value
X**     then setenv $var to value
X*/
Xifvarset (buf, swin, field)
X	char	*buf;				/* var=value ... */
X	WINDOW	*swin;				/* window to write to */
X	struct FieldInfo	*field[];
X{
X	char	*substr();
X	char	*wsptr;
X	char	variable[100];			/* name */
X	char	value[200];			/* value to set name to */
X	int	i;
X	int	rc;
X
X
X	wsptr = buf;
X	while ((wsptr = substr (wsptr, "$")) != (char *)NULL)
X	{
X		wsptr++;		/* get past $ */
X		/* get the enviroment variable */
X		for (i = 0; *wsptr != '=' && *wsptr != '\0'; i++, wsptr++)
X			variable[i] = *wsptr;
X		variable[i] = '\0';
X		if (strcmp (variable, "") == 0  ||  *wsptr != '=')
X		{
X			BEEP;
X			mvprintw (ErrRow-2, 0, 
X			   "Error occured while setting enviroment variable %s",
X			   buf);
X			shutdown ();
X		}
X		wsptr++;	/* get past the = */
X
X		if (*wsptr == '"')
X			strcpy (value, getval (&wsptr, '"'));
X		else
X			strcpy (value, getval (&wsptr, '0'));
X
X		/* find the appropriate field */
X		for (i = 0; field[i] != (struct FieldInfo *)NULL && 
X	     		i <= MAXFIELDS; i++)
X		{
X			if (strcmp (field[i]->name, variable) == 0)
X			{
X				/* found field */
X				adjustfield (value, field[i]->adjust, 
X					field[i]->length);
X
X				/* format value to the mask and display */
X				mvwprintw (swin, field[i]->row, field[i]->col, 
X					"%s", format (value, field[i]->mask, 
X					field[i]->type));
X				break;
X			}
X		} /* end for */
X		/* set the enviroment variable */
X		rc = setenv (variable, value);
X		if (rc != 0)
X		{
X			BEEP;
X			mvprintw (ErrRow-2, 0, 
X			   "Error occured while setting enviroment variable %s",
X				variable);
X			shutdown ();
X		}
X
X	} /* end while */
X	wnoutrefresh (swin);
X}
X
X
X
X
Xadjustfield (data, fldadjust, fldlength)
X	char	*data;			/* data 2b formated */
X	char	fldadjust;
X	int	fldlength;
X{
X	char		*source;
X	int		i;
X
X
X	switch (fldadjust)
X	{
X	   case LFADJ_BFILL:
X		/* get to end of data */
X		for (i = 0, source = data; *source != '\0'; i++, source++)
X			;
X		/* blank fill rest of field */
X		for (; i < fldlength; i++, source++)
X			*source = ' ';
X		*source = '\0';
X		break;
X	}
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
echo "File runscreen.c is complete"
chmod 0644 runscreen.c || echo "restore of runscreen.c fails"
echo "x - extracting getval.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > getval.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/*
X**  getval()
X**  ARGS:
X**	sptr	- pointer to beginning of value 2b parsed
X**	endch	- $ process only the dollar part of value
X**		- ` process only the single quote part of value
X**		- " process only the double quote part of value
X**		- 0 process until a space or invalid is found
X**		- 1 process entire string until '\0' is found
X**  RETURNS:
X**	sptr	- pointer to end of value 2b parsed
X**	rval	- the resulting value.
X**
X**	var=one
X**	var="one"
X**	var=$var
X**	var="one $var"
X**	var=${var}
X**	var=`ls`
X**	var=one"two three"
X**	var=~/
X**	var=~usr/
X*/
X
X#include	<stdio.h>
X#include	<ctype.h>
X#include	<pwd.h>
X
X#define DQUOTE	'"'
X#define SQUOTE	'`'
X#define LITERAL	'\''
X#define DOLLAR	'$'
X#define ESCAPE	'\\'
X#define BRACE	'{'
X#define COMCHAR '#'
X#define	TILDE	'~'
X#ifndef	TRUE
X#define	TRUE	1
X#define	FALSE	0
X#endif
X
X#ifndef	TEST
Xextern int	debug;
X#endif
X
X
Xchar *getval (sptr, endch)
X	char	**sptr;					/* pointer to $+1 */
X	char	endch;
X{
X	char		*getenv();
X	struct passwd	*getpwnam();
X	FILE		*popen(), *pp;
X	static char	value[400];
X	char		tmpval[400];
X	static char	*rval;				/* pointer for return */
X	int		i;
X	int		EOV = FALSE;			/* End Of Value */
X	int		dqflag = FALSE;			/* double quote flag */
X	struct passwd	*pw;
X
X
X	strcpy (value, "");
X	rval = value;
X	while (!EOV && **sptr)
X	{
X		switch (**sptr)
X		{
X	   	   case SQUOTE:
X			(*sptr)++;				/* get past ' */
X			for (i = 0; **sptr != '`' && **sptr; i++, (*sptr)++)
X				tmpval[i] = **sptr;
X			if (**sptr)
X				(*sptr)++;		/* get past ' */
X			tmpval[i] = '\0';
X			/* open pipe and read results */
X			if ((pp = popen (tmpval, "r")) != NULL)
X			{
X				for (; ((i = fgetc(pp)) != EOF); rval++)
X				{
X					*rval = i ;
X					if (!isprint(*rval))
X						rval--;
X				}
X				pclose (pp);
X			}
X			if (endch == SQUOTE)
X			{
X				*rval = '\0';
X				rval = value;
X				return (rval);
X			}
X			break;
X
X	   	   case DQUOTE:
X			(*sptr)++;
X			dqflag = dqflag == FALSE ? TRUE : FALSE;
X			if (endch == DQUOTE && dqflag == FALSE)
X			{
X				*rval = '\0';
X				rval = value;
X				return (rval);
X			}
X			break;
X
X	   	   case DOLLAR:
X			/* Substitutable parameter */
X
X			(*sptr)++;				/* get past $ */
X
X			/*
X			**  The braces are required only when parameter is
X			**  followed by a letter, digit, or underscore.
X			*/
X			if (**sptr == BRACE)
X			{
X				(*sptr)++;			/* get past { */
X				for (i = 0; **sptr != '}' && **sptr; 
X				     i++, (*sptr)++)
X					tmpval[i] = **sptr;
X				if (**sptr)
X					(*sptr)++;		/* get past } */
X			}
X			else
X			{
X				for (i = 0; isalnum(**sptr) || **sptr == '_'; 
X					i++, (*sptr)++)
X					tmpval[i] = **sptr;
X			}
X			tmpval[i] = '\0';
X			if (getenv(tmpval) != (char *)NULL)
X				strcpy (rval, getenv(tmpval));
X			rval += strlen (rval);
X			if (endch == DOLLAR)
X			{
X				*rval = '\0';
X				rval = value;
X				return (rval);
X			}
X			break;
X
X		   case TILDE:
X			(*sptr)++;				/* get past ~ */
X			/*
X			**  ~/ = $HOME
X			**  ~user/ = home(user)
X			*/
X			for (i = 0; **sptr != '/' && **sptr; i++, (*sptr)++)
X				tmpval[i] = **sptr;
X			tmpval[i] = '\0';
X			if (strcmp (tmpval, "") == 0)
X				if (getenv("LOGNAME") != (char *)NULL)
X					strcpy (tmpval, getenv ("LOGNAME"));
X			/*
X			**  tmpval holds the user name
X			**  now we get the password entry
X			*/
X			pw = getpwnam (tmpval);
X			strcpy (rval, pw->pw_dir);
X			rval += strlen (pw->pw_dir);
X			break;
X
X	   	   default:
X			if (dqflag || **sptr != ' ' || endch == '1')
X			{
X				*rval++ = **sptr;
X				(*sptr)++;
X			}
X			else
X				EOV = TRUE;
X			break;
X		} /* end switch */
X	} /* end while */
X
X	*rval = '\0';
X	rval = value;
X#ifndef	TEST
X	if (debug)
X	{
X		fprintf (stderr, "\n[%s] value=:%s:, :%s:",
X			__FILE__, value, *sptr);
X		fflush (stderr);
X	}
X#endif
X	return (rval);
X}
X
X
X
X#ifdef	TEST
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	char		*getval();
X	char		*sptr;
X	char		*rval;
X
X	sptr = argv[1];
X	if (argc == 3)
X		rval = getval (&sptr, argv[2][0]);
X	else
X		rval = getval (&sptr, '1');
X	printf ("\nparameter value :%s:", rval);
X	printf ("\narg pointer :%s:", sptr);
X}
X#endif
X/* Paul J. Condie  5/89 */
SHAR_EOF
chmod 0644 getval.c || echo "restore of getval.c fails"
echo "x - extracting clean_menu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > clean_menu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	"menu.h"
X
Xclean_menu (menu)
X	struct MenuInfo	*menu;
X{
X	int		i,j;
X	int		textcnt;
X
X
X	/*
X	** Just to keep things simple, lets start from scratch on the
X	** next menu selected.
X	*/
X
X	/* free options */
X      	for (i = 0; i < menu->optioncount; i++)
X	{
X		if (menu->option[i]->command)
X			free (menu->option[i]->command);
X       		free (menu->option[i]);
X	}
X
X      	/* free screens */
X	for (i = 0; menu->srn[i] != (struct ScreenInfo *)NULL  &&  
X	     i <= MAXSCREENS; i++)
X	{
X		/* screen information */
X		if (menu->srn[i]->fielddefaults != (char *)NULL)
X			free (menu->srn[i]->fielddefaults);
X
X		/* text stuff */
X		for (textcnt = 0; 
X		     menu->srn[i]->textinfo[textcnt] != (struct TextInfo *)NULL;
X		     textcnt++)
X		{
X			free (menu->srn[i]->textinfo[textcnt]->text);
X			free (menu->srn[i]->textinfo[textcnt]);
X		}
X
X		if (menu->srn[i]->after_screen != (char *)NULL)
X			free (menu->srn[i]->after_screen);
X
X
X		/* free field information */
X		for (j = 0; 
X		     menu->srn[i]->field[j] != (struct FieldInfo *)NULL &&
X		     j <= MAXFIELDS; j++)
X		{
X			if (menu->srn[i]->field[j]->before_field != (char *)NULL)
X				free (menu->srn[i]->field[j]->before_field);
X			if (menu->srn[i]->field[j]->after_field != (char *)NULL)
X				free (menu->srn[i]->field[j]->after_field);
X			free (menu->srn[i]->field[j]);
X		}
X
X
X		free (menu->srn[i]);
X		menu->srn[i] = (struct ScreenInfo *)NULL;
X	} /* end screens */
X
X	if (menu->after_menu != (char *)NULL)
X		free (menu->after_menu);
X}
X/* Paul J. Condie  6/89 */
SHAR_EOF
chmod 0644 clean_menu.c || echo "restore of clean_menu.c fails"
echo "x - extracting slength.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > slength.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)slength.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**	How long is a string not counting attributes.
X*/
X
Xslength (s)
X	char		*s;
X{
X	register int	i = 0;
X
X	while (*s)
X	{
X		if (*s == '\\')
X		{
X			s++;
X			s++;
X			continue;
X		}
X		s++;
X		i++;
X	}
X	return (i);
X}
X/* Paul J. Condie  11-89 */
SHAR_EOF
chmod 0444 slength.c || echo "restore of slength.c fails"
echo "x - extracting runpopen.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > runpopen.c &&
X/*
X**  ARGS:
X**	command	- the command to run
X**  RETURNS:
X**	-1	unable to open pope
X**	x	return code from command
X*/
X
X#include	<stdio.h>
X
X#ifndef DEBUG
Xextern 	int	debug;
X#else
Xint	debug;
X#endif
Xextern	int	errno;
X
Xrunpopen (command, result)
X	char	*command;				/* command to run */
X	char	*result;				/* from pipe */
X{
X	FILE	*popen(), *pp;
X	char	*fgets();
X	int	rc;
X
X	strcpy (result, "");
X	if ((pp = popen (command, "r")) == (FILE *)NULL)
X	{
X		if (debug)
X		{
X			fprintf (stderr, 
X				"\n[%s] %d Unable to popen command=:%s:",
X				__FILE__, errno, command);
X			fflush (stderr);
X		}
X		return (-1);
X	}
X
X	if (fgets (result, BUFSIZ, pp) == (char *)NULL)
X		strcpy (result, "");
X	else
X		if (result[strlen(result)-1] == '\n')
X			result[strlen(result)-1] = '\0';	/* junk \n */
X
X	rc = pclose (pp);
X	return (rc >> 8);			/* shell rc is in high 8 bits */
X}
X/* Paul J. Condie  4-90 */
X
X
X#ifdef DEBUG
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	int	rc;
X	char	buf[BUFSIZ+1];
X
X	rc = runpopen (argv[1], buf);
X	printf ("\n%d :%s:", rc, buf);
X	exit (rc);
X}
X#endif
SHAR_EOF
chmod 0644 runpopen.c || echo "restore of runpopen.c fails"
echo "x - extracting mygetch.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > mygetch.c &&
X#include	<curses.h>
X
X#ifndef ESC
X#define	ESC	27
X#endif
X
Xextern int	debug;
X
X
Xmygetch ()
X{
X	int	row;				/* row where mouse is at */
X	int	col;				/* col where mouse is at */
X	int	rc;
X
X#ifdef UNIXPC
X	rc = mouse3b1 (&row, &col);
X#else
X	rc = getch();
X#endif
X	return (rc);				/* character inputted */
X}
X
X
X#ifdef UNIXPC
X
X#include	<stdio.h>
X#include	<sys/types.h>
X#include	<sys/stat.h>
X#include	<sys/window.h>
X
Xmouse3b1 (row, col)
X	int	*row;
X	int	*col;
X{
X	char		*readkey();
X	char		*strchr();
X	struct stat	sbuf;
X	struct umdata	umdata;
X	int		wd;			/* window descriptor */
X	int		rc;
X	char		kbuf[80];		/* key buffer */
X	char		*sptr;
X	int		prow;
X	int		pcol;
X
X
X	/* find window (wd) */
X	rc = fstat (0, &sbuf);
X	if (rc != 0)
X		return (getch());
X	wd = sbuf.st_dev;			/* window descriptor */
X
X	umdata.um_flags = MSDOWN|MSIN|MSOUT;
X	/* rectangle in pixels */
X	umdata.um_x = 0;
X	umdata.um_y = 0;
X	umdata.um_w = 100;
X	umdata.um_h = 100;
X	umdata.um_icon = 0;			/* use system cursor icon */
X
X	while (1)
X	{
X		rc = ioctl (0, WIOCSETMOUSE, &umdata);
X		if (rc != 0)
X		{
X			if (debug)
X			{
X				fprintf (stderr, 
X				     "\n[%s] %d=ioctl(%d,WIOCSETMOUSE) failed",
X					__FILE__, rc, wd);
X				fflush (stderr);
X			}
X			return (getch());
X		}
X		strcpy (kbuf, readkey ());
X		if (kbuf[0] != (char)ESC)
X			return ((int)kbuf[0]);
X		if (debug)
X		{
X			fprintf (stderr, "\n[%s] mouse report = :%s:", __FILE__,
X				kbuf+1);
X			fflush (stderr);
X		}
X
X		/*
X		** screen size in pixels 720,288 
X		** one char = 9x12  pixels
X		** Mouse reports take the form:
X		**	ESC [ ? {x-pos} ; {y-pos} ; {buttons} ; {reason} M
X		*/
X		sptr = strchr (kbuf, '?');
X		sptr++;
X		sscanf (sptr, "%d", &pcol);
X		sptr = strchr (sptr, ';');
X		sptr++;
X		sscanf (sptr, "%d", &prow);
X		/* convert from pixel to character row/col the mouse is on */
X		*col = pcol / 9;
X		*row = prow / 12;
X		if (debug)
X		{
X			fprintf (stderr, "\n[%s] mouse row %d, col %d", 
X				__FILE__, *row, *col);
X			fflush (stderr);
X		}
X		setoption (*row, *col);		/* hi-light menu option */
X	}
X}
X
X
X/*
X** readkey()
X** Returns:
X**	the string of characters generated by a key
X*/
X#include	<stdio.h>
X#include	<signal.h>
X#include	<ctype.h>
X
X
Xstatic int	sig_caught;
X
Xchar *readkey ()
X{
X	int	(*oldsig)();
X	int	_Catch_Alarm();
X	int	oldalarm;
X	char	ch;
X	int	rc;
X	static char	keybuf[80];
X	char		*sptr;
X
X	strcpy (keybuf, "");
X	sptr = keybuf;
X	*sptr = getch (); rc = 1;
X	if (*sptr != 27)		/* check for escape */
X	{
X		sptr++;
X		*sptr = '\0';
X		sptr = keybuf;
X		return (sptr);
X	}
X	sptr++;
X
X	/*
X	** check to see if this is a multi-char key
X	** loop until read returns -1 (no input) or
X	** a time out signal occurs indicating no more input
X	**
X	** The best resolution we have is 1 second, so we set a 1 second alarm
X	** and try to read.  If we fail for 1 second, we assume there is no
X	** key waiting.  Problem here is that 1 second is too long, people
X	** can type faster than this.
X	*/
X	while (rc == 1)
X	{
X		oldsig = signal (SIGALRM, _Catch_Alarm);
X		oldalarm = alarm (1);
X		sig_caught = 0;
X		*sptr = getch (); rc = 1;
X		if (sig_caught)
X		{
X			sig_caught = 0;
X			alarm (oldalarm);
X			rc = -2;
X		}
X		signal (SIGALRM, oldsig);
X		alarm (oldalarm);
X		sptr++;
X	}
X	sptr--;
X	*sptr = '\0';
X	sptr = keybuf;
X	return (sptr);
X}
X
X_Catch_Alarm ()
X{
X	sig_caught = 1;
X}
X#endif
X/* Paul J. Condie  5-90 */
SHAR_EOF
chmod 0644 mygetch.c || echo "restore of mygetch.c fails"
echo "x - extracting menu.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > menu.h &&
X#ifndef LINT
Xstatic char ID_menu[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#define	VERSION	"3.63"			/* current version */
X
X#ifndef BELL
X#define	BELL	printf ("%c", 7)
X#endif
X#ifndef BEEP
X#define	BEEP	printf ("%c", 7)
X#endif
X#ifndef NULL
X#define	NULL	0
X#endif
X#define	null			0
X#define	MENUINIT	".menuinit"	/* initialize filename */
X#define	HELPFILE	"menu.hlp"
X#define	BORDERCHAR	' '
X#define	MAXTITLE	6		/* maximum # of title lines */
X#define	MAXKEYS		25		/* maximum # of keys */
X#define	MAXKEYLENGTH	15		/* maximum length of keyword */
X#define	MAXOPTION	60		/* max # of option 2b displayed */
X#define	MAXMENU		20		/* max nested menus */
X#define	MAXGNAME	20		/* max goto menu names */
X#define	MAXLEN		2048		/* max length of option command */
X#define	MAXSCREENS	10		/* max .DEFINE_SCREEN per menu */
X#define	MAXFIELDS	40		/* max fields per .DEFINE_SCREEN */
X#define	MAXTEXT		20		/* max # of text per .DEFINE_SCREEN */
X#define	ErrRow		(LINES-1)	/* last line to print error message */
X#define	GNAMEOFFSET	100		/* Offset return code for gnames */
X
X#define	QUIT		-1
X#define	MAINMENU	-2
X#define	PREVIOUSMENU	-3
X#define	NOWAYJOSE	-4		/* not authorized for menu */
X#define	REPARSE		-5		/* reparse & display the current menu */
X#define	SUBMENU		-99		/* a submenu was selected */
X
X#define	BUFSIZE		512
X
X/* Line drawing types */
X#define	DumbLine	1
X#define	StandoutLine	2
X#define	SingleLine	3
X#define	MosaicLine	4
X#define	DiamondLine	5
X#define	DotLine		6
X#define	PlusLine	7
X
X#define	AUTO		999
X
X
X/*
X**  Keys not defined in some curses.h
X*/
X
X#ifndef KEY_HELP
X#   define KEY_HELP	0553
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	0565
X#endif
X#ifndef KEY_CANCEL
X#   define KEY_CANCEL	0543
X#endif
X#ifndef KEY_TAB
X#   define KEY_TAB	'\t'
X#endif
X#ifndef KEY_BTAB
X#   define KEY_BTAB	0541
X#endif
X#ifndef KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_LINEFEED
X#   define KEY_LINEFEED	'\n'
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	0565
X#endif
X#ifndef KEY_BEG
X#   define KEY_BEG	0542
X#endif
X#ifndef KEY_END
X#   define KEY_END	0550
X#endif
X#ifndef KEY_ACCEPT
X#define KEY_ACCEPT	1000
X#endif
X#ifndef KEY_MAINMENU
X#define	KEY_MAINMENU	1001
X#endif
X#ifndef KEY_PREVMENU
X#define	KEY_PREVMENU	1002
X#endif
X#ifndef KEY_EXITMENU
X#define	KEY_EXITMENU	1003
X#endif
X#ifndef KEY_POPGNAME
X#define	KEY_POPGNAME	1004
X#endif
X#ifndef KEY_GNAME
X#define	KEY_GNAME	1005
X#endif
X
X/*
X**  MACROS
X*/
X
X#define	SKIPJUNK(s) 	/* \
X			**  This macro skips over spaces, tabs, etc. \
X			**  ARGS:  char  *s \
X			*/ \
X			for (;*s != '\0' && (isspace(*s)); s++) \
X				;
X
X
X/*
X**  STRUCTURES
X*/
X
Xstruct MenuInfo
X{
X	char			name	[15];		/* file name */
X	int			wfrow;			/* window first row */
X	int			wlrow;			/* window last row */
X	int			wfcol;			/* window first col */
X	int			wlcol;			/* window last col */
X	int			row_cursor;		/* row for cursor */
X	int			col_cursor;		/* col for cursor */
X	unsigned		boxtype;		/* 0 = no box */
X	unsigned		linetype;		/* same as box */
X	int			titlecount;
X	int			optioncount;		/* base 0 */
X	struct OptionInfo	*option	[MAXOPTION];
X	struct ScreenInfo	*srn	[MAXSCREENS+1];	/* .DEFINE_SCREEN */
X							/* NULL = EOL */
X	char			*after_menu;		/* command to run */
X};
X
X
Xstruct OptionInfo
X{
X	char	keyword		[MAXKEYLENGTH+1];
X	int	opnumber;				/* option number */
X	char	description	[200];
X	char	*command;
X	int	row;					/* row to display */
X	int	col;					/* col to display */
X};
X
Xstruct ScreenInfo
X{
X	char			name	[31];		/* screen name */
X	char			title	[100];		/* window title */
X	int			toprow;			/* upper left corner */
X	char			toprowvar[40];
X	int			leftcol;
X	char			leftcolvar[40];
X	int			rows;			/* # rows in win */
X	int			cols;			/* # cols in win */
X	unsigned		boxtype;		/* 0 = no box */
X	int			exitlastfield;		/* after last field */
X	int			exitoncancel;		/* only on KEY_CANCEL */
X	char			helpfile[16];
X	struct TextInfo		*textinfo[MAXTEXT+1];	/* text information */
X	char			*fielddefaults;		/* init field command */
X	char			*after_screen;		/* command to run */
X	struct FieldInfo	*field	[MAXFIELDS+1];
X};
X
X
Xstruct FieldInfo
X{
X	char	name	[30];				/* field name */
X	char	label	[50];				/* field label */
X	int	row;					/* start position */
X	int	col;
X	int	length;
X	int	min_input;
X	char	mask	[100];
X	char	range	[MAXLEN];
X	char	type;
X	char	adjust;
X	int	mustenter;
X	char	prompt	[100];
X	char	terminator[3];				/* field terminators */
X	int	noinput;
X	char	*before_field;				/* before command */
X	char	*after_field;				/* after command */
X};
X
Xstruct TextInfo
X{
X	int	row;					/* row to display txt */
X	int	col;					/* col to diplay txt */
X	char	*text;					/* the text */
X};
SHAR_EOF
chmod 0644 menu.h || echo "restore of menu.h fails"
echo "x - extracting terminal.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > terminal.h &&
X#ifndef LINT
Xstatic char ID_terminal[] = "@(#)terminal.h	1.7   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/* Mover Keys */
Xextern int	KeyReturn;
Xextern int	KeyDown;
Xextern int	KeyUp;
Xextern int	KeyTab;
Xextern int	KeyBTab;
X
X/* Edit Keys */
Xextern int	KeyBeg;
Xextern int	KeyEnd;
Xextern int	KeyRight;
Xextern int	KeyLeft;
Xextern int	KeyBackspace;
Xextern int	KeyEOL;
Xextern int	KeyDL;
Xextern int	KeyDC;
Xextern int	KeyIC;
X
X/* Other Keys */
Xextern int	KeyHelp;
Xextern int	KeyRedraw;
Xextern int	KeyCancel;
Xextern int	KeySave;
Xextern int	KeyPrint;
Xextern int	KeyAccept;
X
X
X/* Menu Specific Keys */
Xextern int	KeyMainMenu;
Xextern int	KeyPrevMenu;
Xextern int	KeyExitMenu;
Xextern int	KeyGname;
Xextern int	KeyPopGname;
SHAR_EOF
chmod 0444 terminal.h || echo "restore of terminal.h fails"
echo "x - extracting LexDeSrn.l (Text)"
sed 's/^X//' << 'SHAR_EOF' > LexDeSrn.l &&
X%{
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X%}
X
X%{
X#include 	"y.tab.h"
X#include	"menu.h"
X
X#undef	YYLMAX
X#define	YYLMAX	MAXLEN
X
Xchar	*malloc();
X%}
X%%
X%{
X/*
X**	Operators:
X**	" \ [ ] ^ - ? . * + | ( ) $ / { } % < >
X**	-	match a range
X**	^	match all except or match begining of line if outside []
X**	.	match any character except \n
X**	?	optional  ab?c matches ac or abc
X**	|	alternation  ab|cd matches either ab or cd
X**	$	match end of line
X**	/	trailing context  ab/cd matches ab only if followed by cd
X**	<>	start conditions
X**	{}	repetitions a{1,5}  or definition expansion {abc}
X**	%	separator for source segments
X**
X**	object		match one occurence of object
X**	object*		matches zero or more occurrences of object
X**	object+		matches one or more occurrences of object
X**	object{m,n}	match m through n occurrences of object
X*/
X%}
X
X%{ /* Screen Stuff
X%}
X"window_rows"		return (SCREEN_ROWS);
X"window_title"		return (SCREEN_TITLE);
X"window_cols"		return (SCREEN_COLS);
X"window_border"		return (SCREEN_BORDER);
X"window_pos"		return (SCREEN_POS);
X"helpfile"		return (SCREEN_HELP);
X"exit_last_field"	return (EXIT_LAST_FIELD);
X"exit_on_cancel"	return (EXIT_ON_CANCEL);
X"text"			return (SCREEN_TEXT);
X"field_defaults"	return (FIELD_DEFAULTS);
X"after_screen"		return (AFTER_SCREEN);
X
X%{ /* Field Stuff
X%}
X"field_name"		return(FIELD_NAME); 
X"field_label" 		return(FIELD_LABEL); 
X"field_row"		return (FIELD_ROW);
X"field_col"		return (FIELD_COL);
X"field_mask"		return (FIELD_MASK);
X"field_range"		return (FIELD_RANGE);
X"field_length"		return (FIELD_LENGTH);
X"field_min"		return (FIELD_MIN);
X"field_type"		return (FIELD_TYPE);
X"field_edits"		return (FIELD_TYPE);
X"field_adjust"		return (FIELD_ADJUST);
X"field_mustenter"	return (FIELD_MUSTENTER);
X"field_prompt"		return (FIELD_PROMPT);
X"field_terminator"	return (FIELD_TERMINATOR);
X"field_noinput"		return (FIELD_NOINPUT);
X"before_field"		return (BEFORE_FIELD);
X"after_field"		return (AFTER_FIELD);
X
X"ENDSCREEN"		return(0);
X
X
X%{ /* Comment line */
X%}
X###			{ while (input() != '\n'); }
X
X[0-9]+			{ 
X				yylval.number = atoi (yytext);
X				return (NUMBER); 
X			}
X
X%{ /* Alphanumeric string with a leading $ and alphabetic character. */ 
X%}
X[$][A-Za-z][A-Za-z0-9_\[\]]* {
X                        	yylval.string = malloc(strlen(yytext)+1);
X                        	strcpy(yylval.string,yytext);
X				return (EVAR); 
X			}
X
X%{ /* Alphanumeric string with a leading alphabetic character. */ 
X%}
X[A-Za-z][A-Za-z0-9_]*	{ 
X                        	yylval.string = malloc(strlen(yytext)+1);
X                        	strcpy(yylval.string,yytext);
X				return (STRING); 
X			}
X
X%{/* Quoted string with a possible " in the string.  ex. "abc\"def" */
X%}
X\"[^"]*			{
X				if (yytext[yyleng-1] == '\\')
X				{
X					yymore ();
X				}
X				else
X				{
X					int	i,j;
X					/*
X					** need to validate that it is a quote
X					** a core dump will occur if not.
X					*/
X					input ();	/* get last " */
X                        		yylval.string=malloc(strlen(yytext)+1);
X					for (j=0,i=1; i < strlen(yytext); i++)
X					{
X						if (yytext[i] == '\\' && 
X						    yytext[i+1] == '"')
X							continue;
X						yylval.string[j++] = yytext[i];
X					}
X					yylval.string[j] = '\0';
X					return (QUOTE_STRING);
X				}
X			}
X
X","             return (COMMA);
X"="		return (EQUAL);
X%{/* Ignore blank, tab, newline */
X%}
X[ \t\n]		;
X%%
SHAR_EOF
chmod 0644 LexDeSrn.l || echo "restore of LexDeSrn.l fails"
echo "x - extracting menu.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > menu.hlp &&
XTABLE_OF_CONTENTS
Xmenu.hlp	menu		Menus      - Help using menus.
Xmenu.hlp	popmenu		Pop-menus  - Help using popmenus.
Xmenu.hlp	GETINPUT	Input      - Editing commands.
Xmenu.hlp	help		Help       - Using help.
XTABLE_OF_CONTENTS
X
X
Xmenu
X.TITLE Menu Help
X
X  \RMENU COMMANDS:\N
X          m       \D-  Go directly to main menu.\N
X          p       \D-  Return to previous menu.\N
X          g or ^g \D-  Go directly to a specific menu.\N
X          h or ?  \D-  This help screen.\N
X          ^r      \D-  Redraw the screen.\N
X          e       \D-  Exit.\N
X          !       \D-  Enter a unix command.\N
X
X  \RSELECTING OPTIONS:\N
X          -  Use "up arrow key", "^k", "down arrow key", "^j" or
X             "tab key" to place bar on option and press "return".    
X
X                  or
X
X          -  Enter option number and press "return".
X
Xmenu
X
X
Xpopmenu
X.TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    Use "up arrow key", "^k", "down arrow key", "^j", 
X    to place bar on option and press "return".
X
X    or
X
X    Enter the first character of the option you
X    wish to select and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
Xpopmenu
X
X
XGETINPUT
X.TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X        KEY_DOWN  (^j)      Traverse forwards through the fields.
X        KEY_UP  (^k)        Traverse backwards through the fields.
X        KEY_TAB  (^i)       Fast forward through the fields.
X        KEY_BTAB            Fast reverse through the fields.
XField Editing Keys:
X        KEY_BEG  (^b)       Place cursor at beginning of field.
X        KEY_END  (^e)       Place cursor at end of input in field.
X        KEY_RIGHT  (^l)     Forward space within the field.
X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
X        KEY_EOL  (^d)       Delete from cursor to end of field.
X        KEY_DL  (^c)        Clear field and home cursor.
X        KEY_DC  (^x)        Delete a character.
X        KEY_IC  (^t)        Toggle between type-over and insert mode.
XOther Keys:
X        KEY_HELP  (?)       Display help screen.
X        KEY_REFRESH  (^r)   Redraw the screen.
X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
X        KEY_SAVE  (^f)      Save screen to a file.
X        KEY_PRINT  (^p)     Print screen to lp.
XGETINPUT
X
X
Xhelp
X.TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
X        KEY_TOC  (^t)       Display help table of contents.
Xhelp
SHAR_EOF
chmod 0644 menu.hlp || echo "restore of menu.hlp fails"
echo "x - extracting runrealid.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > runrealid.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)runrealid.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<stdio.h>
X
Xmain ( argc, argv )
X	int	argc;
X	char	*argv[];
X{
X	register int	uid, euid, gid, egid ;
X
X	/* who am i */
X	uid = getuid() ;
X	euid = geteuid() ;
X	gid = getgid() ;
X	egid = getegid() ;
X
X	/* reset back to the read id */
X	setuid( uid ) ;
X	setgid( gid ) ;
X
X	system( argv[1] ) ;
X
X	/* reset back to the fake id */
X	setuid( euid ) ;
X	setgid( egid ) ;
X}
X/* Sam S. Lok  11/89 */
SHAR_EOF
chmod 0444 runrealid.c || echo "restore of runrealid.c fails"
echo "x - extracting ParseDeSrn.y (Text)"
sed 's/^X//' << 'SHAR_EOF' > ParseDeSrn.y &&
X%{
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X%}
X
X%{
X#include	<curses.h>
X#include	"GetInput.h"
X#include	"menu.h"
X
X#define	FLD	yyscreen->field[fieldcount-1]
X
X#ifdef	_yydebug
Xextern int		yydebug;
X#endif
Xextern int		debug;
Xstruct ScreenInfo	*yyscreen;
Xint			fieldcount;
Xchar			eott[50];		/* error on this token */
Xchar			*malloc();
Xint			textcount;		/* # of text(s) */
X%}
X%{
X/*
X**	The %union declares yylval and the Yacc value stack as a C language
X**	union of types specified in the body.
X**
X**	The %type assigns member declared in the %union to non-terminals.
X**	The %token <..> assigns member declared in the %union to terminals.
X*/
X%}
X%union{
X	int	number;
X	char	*string;
X}
X
X%token	<number> NUMBER
X%token	<string> STRING
X%token	<string> QUOTE_STRING
X%token	<string> EVAR
X%token 	COMMA EQUAL
X%token 	SCREEN_TITLE SCREEN_ROWS SCREEN_COLS SCREEN_BORDER SCREEN_POS
X%token 	SCREEN_HELP EXIT_LAST_FIELD EXIT_ON_CANCEL SCREEN_TEXT AFTER_SCREEN
X%token 	FIELD_NAME FIELD_LABEL FIELD_ROW FIELD_COL FIELD_MASK FIELD_RANGE
X%token	FIELD_LENGTH FIELD_MIN FIELD_TYPE FIELD_ADJUST FIELD_MUSTENTER 
X%token	FIELD_TERMINATOR FIELD_PROMPT FIELD_DEFAULTS FIELD_NOINPUT
X%token	BEFORE_FIELD AFTER_FIELD
X
X%%
X
X
Xscreen		: valid_field
X		| screen valid_field
X		| screen COMMA valid_field
X		;
X
Xvalid_field	: screen_pos 
X		{
X			strcpy (eott, "window_pos");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_pos");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_rows 
X		{
X			strcpy (eott, "window_rows");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_rows");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_cols 
X		{
X			strcpy (eott, "window_cols");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_cols");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_border
X		{
X			strcpy (eott, "window_border");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_border");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_title
X		{
X			strcpy (eott, "window_title");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> window_title");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_help
X		{
X			strcpy (eott, "helpfile");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> helpfile");
X				fflush (stderr);
X			}
X		}
X		;
X		| exit_last_field
X		{
X			strcpy (eott, "exit_last_field");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> exit_last_field");
X				fflush (stderr);
X			}
X		}
X		;
X		| exit_on_cancel
X		{
X			strcpy (eott, "exit_on_cancel");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> exit_on_cancel");
X				fflush (stderr);
X			}
X		}
X		;
X		| screen_text
X		{
X			strcpy (eott, "text");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> text");
X				fflush (stderr);
X			}
X		}
X		;
X		| after_screen
X		{
X			strcpy (eott, "after_screen");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> after_screen");
X				fflush (stderr);
X			}
X		}
X		;
X
X		| field_name 
X		{
X			strcpy (eott, "field_name");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_name");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_label 
X		{
X			strcpy (eott, "field_label");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_label");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_row 
X		{
X			strcpy (eott, "field_row");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_row");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_col 
X		{
X			strcpy (eott, "field_col");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_col");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_mask
X		{
X			strcpy (eott, "field_mask");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_mask");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_range 
X		{
X			strcpy (eott, "field_range");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_range");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_length 
X		{
X			strcpy (eott, "field_length");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_length");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_min 
X		{
X			strcpy (eott, "field_min");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_min");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_type
X		{
X			strcpy (eott, "field_edits");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_edits");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_adjust 
X		{
X			strcpy (eott, "field_adjust");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_adjust");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_mustenter 
X		{
X			strcpy (eott, "field_mustenter");
X			if (debug)
X			{
X				fprintf (stderr, 
SHAR_EOF
echo "End of part 7"
echo "File ParseDeSrn.y is continued in part 8"
echo "8" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 8 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ParseDeSrn.y continued
#
CurArch=8
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 ParseDeSrn.y"
sed 's/^X//' << 'SHAR_EOF' >> ParseDeSrn.y
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_mustenter");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_prompt 
X		{
X			strcpy (eott, "field_prompt");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_prompt");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_terminator
X		{
X			strcpy (eott, "field_terminator");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_terminator");
X				fflush (stderr);
X			}
X		}
X		;
X		| field_defaults
X		{
X			strcpy (eott, "field_defaults");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_defaults");
X				fflush (stderr);
X			}
X		}
X		;
X
X		| field_noinput 
X		{
X			strcpy (eott, "field_noinput");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> field_noinput");
X				fflush (stderr);
X			}
X		}
X		;
X
X		| before_field 
X		{
X			strcpy (eott, "before_field");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> before_field");
X				fflush (stderr);
X			}
X		}
X		;
X
X		| after_field 
X		{
X			strcpy (eott, "after_field");
X			if (debug)
X			{
X				fprintf (stderr, 
X				"\n[ParseDeSrn]<.DEFINE_SCREEN> after_field");
X				fflush (stderr);
X			}
X		}
X		;
X
X
Xscreen_title	: SCREEN_TITLE EQUAL STRING
X		{
X			strcpy (yyscreen->title, $3);
X		}
X		| SCREEN_TITLE EQUAL EVAR
X		{
X			strcpy (yyscreen->title, $3);
X		}
X		| SCREEN_TITLE EQUAL QUOTE_STRING
X		{
X			strcpy (yyscreen->title, $3);
X		}
X		;
X
Xscreen_help	: SCREEN_HELP EQUAL STRING
X		{
X			strcpy (yyscreen->helpfile, $3);
X		}
X		| SCREEN_HELP EQUAL QUOTE_STRING
X		{
X			strcpy (yyscreen->helpfile, $3);
X		}
X		;
X
Xscreen_pos	: SCREEN_POS EQUAL NUMBER NUMBER
X		{
X			yyscreen->toprow = $3;
X			yyscreen->leftcol = $4;
X		}
X		| SCREEN_POS EQUAL EVAR EVAR
X		{
X			strcpy (yyscreen->toprowvar, $3);
X			strcpy (yyscreen->leftcolvar, $4);
X			/*
X			yyscreen->toprow = atoi ((char *)getval (&$3, '1'));
X			yyscreen->leftcol = atoi ((char *)getval (&$4, '1'));
X			*/
X		}
X		| SCREEN_POS EQUAL NUMBER EVAR
X		{
X			yyscreen->toprow = $3;
X			strcpy (yyscreen->leftcolvar, $4);
X		}
X		| SCREEN_POS EQUAL EVAR NUMBER
X		{
X			/*
X			yyscreen->toprow = atoi ((char *)getval (&$3, '1'));
X			*/
X			strcpy (yyscreen->toprowvar, $3);
X			yyscreen->leftcol = $4;
X		}
X		;
X
Xscreen_rows	: SCREEN_ROWS EQUAL NUMBER
X		{
X			yyscreen->rows = $3;
X		}
X		;
Xscreen_cols	: SCREEN_COLS EQUAL NUMBER
X		{
X			yyscreen->cols = $3;
X		}
X		;
Xscreen_border	: SCREEN_BORDER EQUAL STRING
X		{
X			/* get border type for active menu */
X			if (strcmp ($3, "DumbLine") == 0)
X				yyscreen->boxtype = DumbLine;
X			else	if (strcmp ($3, "StandoutLine") == 0)
X					yyscreen->boxtype = StandoutLine;
X			else	if (strcmp ($3, "SingleLine") == 0 ||
X		    		strcmp ($3, "DrawLine") == 0)
X					yyscreen->boxtype = SingleLine;
X			else	if (strcmp ($3, "MosaicLine") == 0)
X					yyscreen->boxtype = MosaicLine;
X			else	if (strcmp ($3, "DiamondLine") == 0)
X					yyscreen->boxtype = DiamondLine;
X			else	if (strcmp ($3, "DotLine") == 0)
X					yyscreen->boxtype = DotLine;
X			else	if (strcmp ($3, "PlusLine") == 0)
X					yyscreen->boxtype = PlusLine;
X		}
X		|SCREEN_BORDER EQUAL STRING STRING
X		{
X			/* get border type for active menu */
X			if (strcmp ($3, "DumbLine") == 0)
X				yyscreen->boxtype = DumbLine;
X			else	if (strcmp ($3, "StandoutLine") == 0)
X					yyscreen->boxtype = StandoutLine;
X			else	if (strcmp ($3, "SingleLine") == 0 ||
X		    		strcmp ($3, "DrawLine") == 0)
X					yyscreen->boxtype = SingleLine;
X			else	if (strcmp ($3, "MosaicLine") == 0)
X					yyscreen->boxtype = MosaicLine;
X			else	if (strcmp ($3, "DiamondLine") == 0)
X					yyscreen->boxtype = DiamondLine;
X			else	if (strcmp ($3, "DotLine") == 0)
X					yyscreen->boxtype = DotLine;
X			else	if (strcmp ($3, "PlusLine") == 0)
X					yyscreen->boxtype = PlusLine;
X
X			/* border type for inactive menu - dim (high 8 bits) */
X			if (strcmp ($4, "DumbLine") == 0)
X				yyscreen->boxtype = yyscreen->boxtype | 
X						    (DumbLine << 9);
X			else	if (strcmp ($4, "StandoutLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (StandoutLine << 9);
X			else	if (strcmp ($4, "SingleLine") == 0 ||
X		    		strcmp ($4, "DrawLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (SingleLine << 9);
X			else	if (strcmp ($4, "MosaicLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (MosaicLine << 9);
X			else	if (strcmp ($4, "DiamondLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (DiamondLine << 9);
X			else	if (strcmp ($4, "DotLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (DotLine << 9);
X			else	if (strcmp ($4, "PlusLine") == 0)
X					yyscreen->boxtype = yyscreen->boxtype | 
X						    (PlusLine << 9);
X		}
X		;
Xexit_last_field	: EXIT_LAST_FIELD
X		{
X			yyscreen->exitlastfield = TRUE;
X		}
X		;
X
Xexit_on_cancel	: EXIT_ON_CANCEL
X		{
X			yyscreen->exitoncancel = TRUE;
X		}
X		;
X
Xscreen_text	: SCREEN_TEXT EQUAL NUMBER NUMBER STRING
X		{
X			yyscreen->textinfo[textcount] = (struct TextInfo *)
X					malloc (sizeof (struct TextInfo));
X			yyscreen->textinfo[textcount]->row = $3;
X			yyscreen->textinfo[textcount]->col = $4;
X			yyscreen->textinfo[textcount]->text = 
X				(char *)malloc (strlen($5)+5);
X			strcpy (yyscreen->textinfo[textcount]->text, $5);
X			yyscreen->textinfo[++textcount] = 
X				(struct TextInfo *)NULL;
X		}
X		| SCREEN_TEXT EQUAL NUMBER NUMBER QUOTE_STRING
X		{
X			yyscreen->textinfo[textcount] = (struct TextInfo *)
X					malloc (sizeof (struct TextInfo));
X			yyscreen->textinfo[textcount]->row = $3;
X			yyscreen->textinfo[textcount]->col = $4;
X			yyscreen->textinfo[textcount]->text = 
X				(char *)malloc (strlen($5)+5);
X			strcpy (yyscreen->textinfo[textcount]->text, $5);
X			yyscreen->textinfo[++textcount] = 
X				(struct TextInfo *)NULL;
X		}
X		;
X
Xafter_screen	: AFTER_SCREEN EQUAL QUOTE_STRING
X		{
X			yyscreen->after_screen = (char *)malloc (strlen($3)+5);
X			strcpy (yyscreen->after_screen, $3);
X		}
X		;
X
X
X
X
Xfield_name	: FIELD_NAME EQUAL EVAR
X		{
X			/*
X			**  The field_name token signifes a new field
X			**  we need to malloc the field structure.
X			*/
X   			if ((++fieldcount) > MAXFIELDS)
X   			{
X      				BEEP;
X      				mvprintw (ErrRow-2, 0, 
X				  "Exceeded maximum screen fields of %d.",
X				  MAXFIELDS);
X      				shutdown ();
X   			}
X			FLD = (struct FieldInfo *)malloc (sizeof (struct FieldInfo));
X			yyscreen->field[fieldcount] = (struct FieldInfo *)NULL;
X			strcpy (FLD->name, $3+1);
X
X			/* Set default field values */
X			strcpy (FLD->label, "");
X			FLD->min_input = 0;
X			strcpy (FLD->mask, "");
X			strcpy (FLD->range, "");
X			FLD->type = UPPER_AN;
X			FLD->adjust = NOFILL;
X			FLD->mustenter = FALSE;
X			strcpy (FLD->prompt, "");
X			strcpy (FLD->terminator, "[]");
X			FLD->noinput = FALSE;
X			FLD->before_field = (char *)NULL;
X			FLD->after_field = (char *)NULL;
X		}
X		;
X
Xfield_label	: FIELD_LABEL EQUAL STRING
X		{
X			strcpy (FLD->label, $3);
X		}
X		| FIELD_LABEL EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->label, $3);
X		}
X		;
X
Xfield_row	: FIELD_ROW EQUAL NUMBER
X		{
X			FLD->row = $3;
X		}
X		;
Xfield_col	: FIELD_COL EQUAL NUMBER
X		{
X			FLD->col = $3;
X		}
X		;
X
Xfield_mask	: FIELD_MASK EQUAL STRING
X		{
X			strcpy (FLD->mask, $3);
X		}
X		| FIELD_MASK EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->mask, $3);
X		}
X		;
X
Xfield_range	: FIELD_RANGE EQUAL STRING
X		{
X			strcpy (FLD->range, $3);
X		}
X		| FIELD_RANGE EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->range, $3);
X		}
X		;
X
Xfield_length	: FIELD_LENGTH EQUAL NUMBER
X		{
X			FLD->length = $3;
X		}
X		;
Xfield_min	: FIELD_MIN EQUAL NUMBER
X		{
X			FLD->min_input = $3;
X		}
X		;
Xfield_type	: FIELD_TYPE EQUAL STRING
X		{
X			if (strcmp ($3, "ALPHANUM") == 0)
X				FLD->type = ALPHANUM;
X			else if (strcmp ($3, "ALPHA") == 0)
X				FLD->type = ALPHA;
X			else if (strcmp ($3, "NUMERIC") == 0)
X				FLD->type = NUMERIC;
X			else if (strcmp ($3, "SET") == 0)
X				FLD->type = SET;
X			else if (strcmp ($3, "UPPER") == 0)
X				FLD->type = UPPER;
X			else if (strcmp ($3, "UPPER_AN") == 0)
X				FLD->type = UPPER_AN;
X			else if (strcmp ($3, "HEX") == 0)
X				FLD->type = HEX;
X			else if (strcmp ($3, "STATE") == 0)
X				FLD->type = STATE;
X			else if (strcmp ($3, "ZIP") == 0)
X				FLD->type = ZIP;
X			else if (strcmp ($3, "DATE") == 0)
X				FLD->type = DATE;
X			else if (strcmp ($3, "TIME") == 0)
X				FLD->type = TIME;
X			else if (strcmp ($3, "MENU") == 0)
X				FLD->type = MENU;
X			else if (strcmp ($3, "PROTECT") == 0)
X				FLD->type = PROTECT;
X			else yyerror ("Invalid field_edits");
X		}
X		;
Xfield_adjust	: FIELD_ADJUST EQUAL STRING
X		{
X			if (strcmp ($3, "NOFILL") == 0)
X				FLD->adjust = NOFILL;
X			else if (strcmp ($3, "RTADJ_ZFILL") == 0)
X				FLD->adjust = RTADJ_ZFILL;
X			else if (strcmp ($3, "RTADJ_BFILL") == 0)
X				FLD->adjust = RTADJ_BFILL;
X			else if (strcmp ($3, "LFADJ_ZFILL") == 0)
X				FLD->adjust = LFADJ_ZFILL;
X			else if (strcmp ($3, "LFADJ_BFILL") == 0)
X				FLD->adjust = LFADJ_BFILL;
X		}
X		| FIELD_ADJUST EQUAL QUOTE_STRING
X		{
X			if (strcmp ($3, "NOFILL") == 0)
X				FLD->adjust = NOFILL;
X			else if (strcmp ($3, "RTADJ_ZFILL") == 0)
X				FLD->adjust = RTADJ_ZFILL;
X			else if (strcmp ($3, "RTADJ_BFILL") == 0)
X				FLD->adjust = RTADJ_BFILL;
X			else if (strcmp ($3, "LFADJ_ZFILL") == 0)
X				FLD->adjust = LFADJ_ZFILL;
X			else if (strcmp ($3, "LFADJ_BFILL") == 0)
X				FLD->adjust = LFADJ_BFILL;
X		}
X		;
X
Xfield_mustenter	: FIELD_MUSTENTER
X		{
X			FLD->mustenter = TRUE;
X		}
X		;
X
Xfield_prompt	: FIELD_PROMPT EQUAL STRING
X		{
X			strcpy (FLD->prompt, $3);
X		}
X		| FIELD_PROMPT EQUAL QUOTE_STRING
X		{
X			strcpy (FLD->prompt, $3);
X		}
X		;
X
Xfield_terminator : FIELD_TERMINATOR EQUAL QUOTE_STRING
X		{
X			if (strlen ($3) != 2)
X				yyerror ("Bad field_terminator.");
X			strcpy (FLD->terminator, $3);
X		}
X		;
X
Xfield_defaults	: FIELD_DEFAULTS EQUAL QUOTE_STRING
X		{
X			yyscreen->fielddefaults = (char *)malloc (strlen($3)+5);
X			strcpy (yyscreen->fielddefaults, $3);
X		}
X		;
X
Xfield_noinput	: FIELD_NOINPUT
X		{
X			FLD->noinput = TRUE;
X		}
X		;
X
Xbefore_field : BEFORE_FIELD EQUAL QUOTE_STRING
X		{
X			FLD->before_field = (char *)malloc (strlen($3)+5);
X			strcpy (FLD->before_field, $3);
X		}
X		;
X
Xafter_field : AFTER_FIELD EQUAL QUOTE_STRING
X		{
X			FLD->after_field = (char *)malloc (strlen($3)+5);
X			strcpy (FLD->after_field, $3);
X		}
X		;
X
X
X
X%%
X
X/*  FUNCTION:	ParseDefineScreen()
X**		This function parses .DEFINE_SCREEN
X**  ARGS:	keyword		the keyword found
X**		menufile	the unix menu file
X**		menu		menu structure
X**		gnames		holder of goto menu names
X**		gfiles		holder of goto menu names (menu file)
X**		gindex		# of gnames
X**  RETURNS:	0
X*/
X
X
X#define	SRN	menu->srn[screencount-1]
X
Xextern FILE	*yyin;
Xextern FILE	*yyout;
Xextern	int	swin, ewin, longest;
X
X	char	ScreenName[50];				/* for yyerror */
X
X
XParseDefineScreen (keyword, menufile, menu, gnames, gfiles, gindex, opnumber)
X
X	char		keyword[];
X	FILE		*menufile;
X	struct MenuInfo	*menu;
X	char		gnames[][15], gfiles[][15];
X	int		*gindex;
X	int		*opnumber;
X{
X	char		*fgets(), line[BUFSIZE];
X	static int	screencount;
X	int		i = 0;
X	int		j;
X	char		*ws;
X
X
X	/* check if this is the first screen for this menu */
X	if (menu->srn[0] == (struct ScreenInfo *)NULL)
X		screencount = 0;
X
X   	if ((++screencount) > MAXSCREENS)
X   	{
X      		BEEP;
X      		mvprintw (ErrRow, 0, 
X			"Exceeded maximum allowable .DEFINE_SCREEN.");
X      		shutdown ();
X   	}
X
X	SRN = (struct ScreenInfo *)malloc (sizeof (struct ScreenInfo));
X   	if (SRN == NULL)
X   	{
X      		BEEP;
X      		mvprintw (ErrRow, 0, 
X			"Unable to allocate memory for .DEFINE_SCREEN.");
X      		shutdown ();
X   	}
X	/* terminate the screens list */
X	menu->srn[screencount] = (struct ScreenInfo *)NULL;
X	SRN->field[0] = (struct FieldInfo *)NULL;	/* no fields yet */
X
X
X	/* get screen name */
X	fgets (line, BUFSIZE, menufile);
X	sscanf (line, "%s", SRN->name);			/* screen name */
X	strcpy (ScreenName, SRN->name);			/* for yyerror */
X
X	yyin = menufile;
X	yyscreen = SRN;
X	fieldcount = 0;
X	textcount = 0;
X
X	/*
X	**  Set default screen values.
X	*/
X	sprintf (SRN->title, "%d", AUTO);
X	SRN->rows = AUTO;
X	SRN->cols = AUTO;
X	SRN->toprow = AUTO;
X	SRN->leftcol = AUTO;
X	strcpy (SRN->toprowvar, "");
X	strcpy (SRN->leftcolvar, "");
X	SRN->boxtype = StandoutLine;
X	SRN->fielddefaults = (char *)NULL;
X	strcpy (SRN->helpfile, "menu.hlp");
X	SRN->exitlastfield = FALSE;
X	SRN->exitoncancel = FALSE;
X	SRN->textinfo[textcount] = (struct TextInfo *)NULL;
X	SRN->after_screen = (char *)NULL;
X
X#ifdef	_yydebug
X	if (debug)
X		yydebug = 1;
X#endif
X
X	yyparse ();
X
X   	return (0);
X}
X
X
Xyyerror (s)
X	char	*s;
X{
X	mvprintw (ErrRow-5,0, "Unable to process .DEFINE_SCREEN  %s", 
X			ScreenName);
X	mvprintw (ErrRow-4,0, "Field Number %d", fieldcount);
X	mvprintw (ErrRow-3,0, "%s", s);
X	mvprintw (ErrRow-2,0, "The error occured on token = \"%s\"", eott);
X	mvprintw (ErrRow-1,0, "Look ahead token number %d  <tokens.h>", yychar);
X	shutdown ();
X}
SHAR_EOF
echo "File ParseDeSrn.y is complete"
chmod 0644 ParseDeSrn.y || echo "restore of ParseDeSrn.y fails"
echo "x - extracting utilities.d/libgeti.d/AdjField.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/AdjField.c &&
Xstatic char Sccsid[] = "@(#)AdjField.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include	<curses.h>
X#include	"GetInput.h"
X#include	<ctype.h>
X
XAdjField(win, rowStart, colStart, fldAttrib, fldAdjust, colEnd, charKeyed)
X	WINDOW		*win ;		/* Window	    		    */
X	int		rowStart ;
X	int		colStart ;
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		fldAdjust ;	/* adjust/fill field 		    */
X	int		colEnd ;	/* column where field ends	    */
X	char		charKeyed[] ;	/* characters keyed		    */
X{
X	int		col ;		/* working column field */
X	int		row ;		/* working row field */
X	int		colMove ;	/* working column field for adjusting
X				   		routines */
X	int		ch ;		/* contains character keyed or being
X				   		moved */
X
X	char		*wrkKeyed ;	/* working pointer for charKeyed */
X	char		fillChar ;
X
X
X	getyx (win, row, col) ;
X
X	if (fldAdjust == RTADJ_BFILL || fldAdjust == LFADJ_BFILL)
X		fillChar = ' ' ;
X	else if (fldAdjust == RTADJ_ZFILL  ||  fldAdjust == LFADJ_ZFILL)
X		fillChar = '0' ;
X
X	if (fldAdjust == RTADJ_BFILL || fldAdjust == RTADJ_ZFILL) {
X
X		col-- ;
X
X		wrkKeyed = charKeyed + (col - colStart) ;
X
X		colMove = colEnd - 1 ;
X
X		while (col >= colStart) {
X
X			while ( *wrkKeyed != 'Y') {
X				wrkKeyed-- ;
X				col-- ;
X			}
X
X			if (col < colStart)
X				break ;
X
X			ch = mvwinch(win, rowStart, col--) & A_CHARTEXT ;
X			*wrkKeyed-- = 'N' ;
X
X			while ( colMove > colStart  &&
X					charKeyed [colMove - colStart] != 'N')
X				colMove-- ;
X
X			charKeyed [colMove - colStart] = 'Y' ;
X
X			wattrset (win, fldAttrib) ;
X			mvwaddch (win, rowStart, colMove--, ch) ;
X			wattrset (win, 0) ;
X		}
X
X		wattrset (win, fldAttrib) ;
X
X		while (colMove >= colStart) {
X
X			if ( charKeyed [colMove - colStart] != 'N')
X				colMove-- ;
X			else {
X				charKeyed [colMove - colStart] = 'Y' ;
X				mvwaddch(win, rowStart, colMove--, fillChar) ;
X			}
X		}
X
X		wattrset (win, 0) ;
X		wmove (win, rowStart, colEnd) ;
X
X	} else if  (fldAdjust == LFADJ_BFILL || fldAdjust == LFADJ_ZFILL) {
X
X		if (col < colStart)
X			col = colStart;
X
X		wattrset (win, fldAttrib) ;
X
X		while (col < colEnd) {
X
X			if ( charKeyed [col - colStart] != 'N')
X				col++ ;
X			else {
X				charKeyed [col - colStart] = 'Y' ;
X				mvwaddch (win, rowStart, col++, fillChar) ;
X			}
X		}
X
X		wattrset (win, 0) ;
X		wmove (win, rowStart, colEnd) ;
X	}
X
X	wrefresh (win) ;
X
X	return(0) ;
X
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/AdjField.c || echo "restore of utilities.d/libgeti.d/AdjField.c fails"
echo "x - extracting utilities.d/libgeti.d/BuildMenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/BuildMenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)BuildMenu.c	1.1   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X#include	<curses.h>
X
XBuildMenu (menu, fldRange)
X	char	menu[][80];
X	char	*fldRange;
X{
X	int	eidx = 0;				/* element index */
X	char	*rptr;					/* range pointer */
X	char	*eptr;					/* element pointer */
X
X	rptr = fldRange;
X
X	while (*rptr != '\0')
X	{
X		/* get range element eidx */
X		eptr = menu[eidx];
X		while (*rptr != ','  &&  *rptr != '\0')
X			*eptr++ = *rptr++;
X		*eptr = '\0';
X
X		/* skip junk */
X		while (*rptr == ','  || *rptr == ' '  ||  *rptr == '\t')
X			*rptr++;
X		eidx++;
X	}
X	strcpy (menu[eidx], "");
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/BuildMenu.c || echo "restore of utilities.d/libgeti.d/BuildMenu.c fails"
echo "x - extracting utilities.d/libgeti.d/DateFun.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/DateFun.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#define	BASEYEAR	1900
X
X/*
X *      is_leap - returns 1 if year is a leap year, 0 if not
X */
Xint is_leap(y)
Xint y;
X{
X	return(y % 4 == 0 && y % 100 != 0 || y % 400 == 0);
X}
X
X/* 
X**
X**	maxdays, returns maximum number of days for 'year' 
X**
X*/
Xint maxdays(y)
Xregister int y;
X{
X	return(is_leap(y) ? 366 : 365);
X}
X
Xstatic  int     day_tab[2][13] = {
X	{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
X	{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
X};                                  
X
X
X/*
X *      julian - converts year month and day to julian date and returns it
X */
Xint julian(year, month, day)
Xint year, month, day;
X{
X	int i, leap;
X
X	leap = is_leap(year);
X	for (i = 1; i < month; i++)
X		day += day_tab[leap][i];
X	return(day);
X}
X
X
X
X/*
X**
X**      week_day - returns the day of the week given the Year, 
X**			Month and Day.  Year must be >= 1973.  
X**			If not, -1 is returned.
X**                      day of the week:  
X**				Sunday = 0,  Monday = 1,  ...,  Saturday = 6.
X*/
Xint week_day( year, month, day )
X	int	year, month, day ;
X{
X	int	century ;
X
X	month -= 2 ;
X	if ( month < 1 )
X	{
X		month += 12 ;
X		year-- ;
X	}
X	century = (int)( year / 100 ) ;
X	year %= 100 ;
X	return(((int)( (13 * month - 1) / 5 ) + day + year + (int)( year / 4 ) +
X		(int)( century / 4 ) - ( 2 * century ) + 77) % 7 ) ;
X}
X
X
X/*
X *      month_day - Converts julian date to month and day. Month and day must be passed as addresses of ints.
X */
Xvoid
Xmonth_day(year, yearday, pmonth, pday)
Xint year, yearday, *pmonth, *pday;
X{
X	int i, leap;
X
X	leap = is_leap(year);
X	for (i = 1; yearday > day_tab[leap][i]; i++)  {
X		yearday -= day_tab[leap][i];
X	}
X	if(i > 12)
X		i = 1;
X
X	if(yearday <= 0)  {     /* special kludge for julian day 0 = Dec. 31st */
X		*pmonth = 12;
X		*pday = 31 + yearday;
X	}  else {
X		*pmonth = i;
X		*pday = yearday;
X	}
X}
X
X
X/* back up (if necessary) month and date to nearest sunday */
X/* return julian date of new date as well */
X
X/*
X *      weekstart - returns julian data of Sunday start date of given YY/MM/DD.
X */
Xint weekstart(year, month, date)
Xregister int year, *month, *date;
X{
X	int mp, dp, i, t;
X
X	if ((i = week_day(year, *month, *date)) != 0)  {
X		t = julian(year, *month, *date);
X		month_day(year, t - i, &mp, &dp);
X		if(mp > *month)
X			year--;
X		*month = mp;
X		*date = dp;
X	}
X	return(julian(year, *month, *date));
X}
X
X
X/* verifies the integrity of a date, returns 1 if good, 0 if bad */
Xint valid_date(yr, mo, day)
Xint yr, mo, day;
X{
X	int days, leap;
X
X	leap = is_leap(yr);
X	if (mo > 0 && mo < 13) {
X		days = day_tab[leap][mo];
X		if (day > 0 && day <= days && yr > 0)
X			return(1);
X	}
X	return(0);
X}
X
X
X/*
X**	datedays - returns the # of days from 1/1/BASEYEAR
X**		01/01/BASEYEAR = 1 days
X**	Year must be >= BASEYEAR.  If not, -1 is returned.
X*/
Xlong datedays(year, month, day)
X	int year, month, day;
X{
X	year -= BASEYEAR ;
X	if(year < 0)
X		return(-1);
X	else
X		return((long) ((year*365)+julian(year, month, day)+
X			       ((year-1)/4)));
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/DateFun.c || echo "restore of utilities.d/libgeti.d/DateFun.c fails"
echo "x - extracting utilities.d/libgeti.d/DisPrmpt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/DisPrmpt.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#include	<curses.h>
X#include	"GetInput.h"
X
XDisPrmpt(win, Fld, fldAttrib, fldMask, fldLength, fldCharType, fldAdjust, fldType, colStart, colEnd, fldStr, charKeyed)
X	WINDOW		*win ;		/* Window	    		    */
X	FldUnPointer	Fld ;		/* Pointer to union for field	    */
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		*fldMask ;	/* mask for character string 	    */
X	unsigned	fldLength ;	/* Maximum length of output 	    */
X	char		fldCharType ;	/* type of character 		    */
X	char		fldAdjust ;	/* Type of adjustment 		    */
X	char		fldType ;	/* type of field 		    */
X	int		colStart ;	/* column start of field */
X	int		colEnd ;	/* column end of field */
X	char		*fldStr ;	/* buffer that will contain output  */
X	char		*charKeyed ;	/* characters keyed  */
X{
X	char	*wrk, *fldWrk, *malloc();
X
X	int	ch ;
X	int	col ;
X	int	initFld ;
X	int	i, j ;
X
X	*fldStr = '\0' ;
X
X	/*
X	if (((fldType == HEX  ||  fldType == CHAR)  &&  *Fld->strVal == '\0') ||
X			(fldType == INT     &&  *Fld->intVal    == 0) ||
X			(fldType == SHORT   &&  *Fld->shortVal  == 0) ||
X			(fldType == LONG    &&  *Fld->longVal   == 0L) ||
X			(fldType == FLOAT   &&  *Fld->floatVal  == 0.0) ||
X			(fldType == DOUBLE  &&  *Fld->doubleVal == 0.0) ||
X			(fldType == MONEY   &&  *Fld->doubleVal == 0.0) ) {
X	*/
X	if (((fldType == HEX  ||  fldType == CHAR)  &&  *Fld->strVal == '\0')) {
X
X		initFld = FALSE ;
X		fldWrk = fldStr ;
X		while (fldLength--)
X			*fldWrk++ = ' ' ;
X		*fldWrk = '\0' ;
X	} else {
X
X		initFld = TRUE ;
X
X		fldWrk = malloc(fldLength + 10);
X
X		if (fldType == HEX  ||   fldType == CHAR)
X			strcpy (fldWrk, Fld->strVal) ;	
X		else if (fldType == INT)
X			sprintf (fldWrk, "%d", *Fld->intVal) ;
X		else if (fldType == SHORT)
X			sprintf (fldWrk, "%d", *Fld->shortVal) ;
X		else if (fldType == LONG)
X			sprintf (fldWrk, "%ld", *Fld->longVal) ;
X		else if (fldType == FLOAT)
X			sprintf (fldWrk, "%f", *Fld->floatVal) ;
X		else if (fldType == DOUBLE)
X			sprintf (fldWrk, "%g", *Fld->doubleVal) ;
X		else if (fldType == MONEY) {
X			sprintf (fldWrk, "%g", *Fld->doubleVal) ;
X			i = strlen(fldWrk) - 1 ;
X			wrk = fldWrk ;
X			while(*wrk != '.'   &&   *wrk != '\0')
X				wrk++ ;
X			if(*wrk == '\0')
X				strcat(fldWrk, ".00") ;
X			else {
X				wrk++ ;
X				j = 0 ;
X				while(*wrk++ != '\0')
X					j++ ;
X
X				if(j == 0)
X					strcat(fldWrk, "00") ;
X				else if(j == 1)
X					strcat(fldWrk, "0") ;
X			}
X		}
X
X		if (fldAdjust == NOFILL)
X			strcpy (fldStr, fldWrk) ;
X		else if (fldAdjust == LFADJ_BFILL  || fldAdjust == LFADJ_ZFILL){
X			strcpy (fldStr, fldWrk) ;
X
X			for (i = strlen(fldStr) ; i < fldLength ; i++)
X				fldStr[i] = (fldAdjust == LFADJ_ZFILL) ? '0' : ' ' ;
X			fldStr[fldLength] = '\0' ;
X		} else if (fldAdjust == RTADJ_BFILL  || fldAdjust == RTADJ_ZFILL) {
X
X			for (i = 0 ; i < fldLength - strlen(fldWrk) ; i++)
X				fldStr[i] = (fldAdjust == RTADJ_ZFILL) ? '0' : ' ' ;
X			fldStr[fldLength - strlen(fldWrk)] = '\0' ;
X			strcat (fldStr, fldWrk) ;
X		}
X
X		free (fldWrk) ;
X			
X	}
X	wattrset (win, fldAttrib) ;
X
X	col = colStart ;
X
X	do { 
X		if (fldMask == NULL) {
X			*charKeyed++ = (initFld) ? 'Y' : 'N' ;
X			waddch(win, *fldStr++) ;
X		} else if (fldCharType != DATE  &&  fldCharType != TIME) {
X			/*
X			if(*(fldMask + col - colStart)  ==  ' ')
X				*(fldMask + col - colStart)  =  fldCharType ;
X			*/
X			if(IsMask(fldCharType, *(fldMask + col - colStart))) {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			} else {
X				*charKeyed++ = (initFld) ? 'Y' : 'N' ;
X				waddch(win, *fldStr++) ;
X			}
X		} else {
X			if( (fldCharType == DATE  &&  
X				(ch = *(fldMask + col - colStart)) == 'M'  ||
X					ch == 'D'  ||  ch == 'Y') ||
X			    (fldCharType == TIME  &&  
X				(ch = *(fldMask + col - colStart)) == 'I'  ||
X					ch == 'H'  ||  ch == 'M'  ||  
X					ch == 'S'  ||  ch == 'T')) {
X				*charKeyed++ = (initFld) ? 'Y' : 'N' ;
X				waddch(win, *fldStr++) ;
X			} else {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			}
X		}
X		col++ ;
X	} while (*fldStr != '\0'  &&  col < colEnd) ;
X
X	while(col < colEnd) {
X		if (fldMask == NULL) {
X			*charKeyed++ = 'N' ;
X			waddch(win, ' ') ;
X		} else if (fldCharType != DATE  &&  fldCharType != TIME) {
X			if(*(fldMask + col - colStart)  ==  ' ')
X				*(fldMask + col - colStart)  =  fldCharType ;
X			if(IsMask(fldCharType, *(fldMask + col - colStart))) {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			} else {
X				*charKeyed++ = 'N' ;
X				waddch(win, ' ') ;
X			}
X		} else {
X			if( (fldCharType == DATE  &&  
X				(ch = *(fldMask + col - colStart)) == 'M'  ||
X					ch == 'D'  ||  ch == 'Y') ||
X			    (fldCharType == TIME  &&  
X				(ch = *(fldMask + col - colStart)) == 'I'  ||
X					ch == 'H'  ||  ch == 'M'  ||  
X					ch == 'S'  ||  ch == 'T')) {
X				*charKeyed++ = 'N' ;
X				waddch(win, ' ') ;
X			} else {
X				*charKeyed++ = 'M' ;
X				waddch(win, *(fldMask + col - colStart) );
X			}
X		}
X		col++ ;
X	}
X
X	wattrset (win, 0) ;
X
X	return(initFld) ;
X
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/DisPrmpt.c || echo "restore of utilities.d/libgeti.d/DisPrmpt.c fails"
echo "x - extracting utilities.d/libgeti.d/FindSet.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/FindSet.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<stdio.h>
X
X/*
X**  FindSet()
X**		Determines if the value loaded into Fld is a member of the set.
X**  RETURNS:
X**		-1	not a element of the set
X**		eNum	otherwise returns the element number (base 0)
X*/
X
X#include	"GetInput.h"
X
X
XFindSet(Fld, fldRange, fldLength, fldType)
X	FldUnPointer	Fld ;
X	char		*fldRange ;
X	int		fldLength ;
X	char		fldType ;
X{
X	char		*upper();
X	char		*a,
X			*b,
X			*fldCmp ;
X
X	char		*malloc();
X
X	int	eNum,				/* element number matched */
X		gotAmatch ;
X
X	gotAmatch = 0 ;
X
X	eNum = 0 ;
X
X	fldCmp = malloc(fldLength+10);
X
X	a = fldRange ;
X
X	while(*a != '\0') {
X
X		b = fldCmp ;
X
X		while(*a != ','  &&  *a != '\0')
X		/* load the next element into fldCmp */
X			*b++ = *a++ ;
X
X		*b = '\0' ;
X
X		switch(fldType) {
X			case CHAR:
X			case DATE:
X			case TIME:
X				if(strncmp(upper(fldCmp), upper(Fld->strVal), strlen(Fld->strVal)) == 0)
X					gotAmatch = 1 ;
X				break ;
X			case INT:
X				if(*Fld->intVal == atoi(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case SHORT:
X				if(*Fld->shortVal == atoi(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case LONG:
X				if(*Fld->longVal == atoi(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case FLOAT:
X				if(*Fld->floatVal == atof(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X			case DOUBLE:
X				if(*Fld->doubleVal == atof(fldCmp))
X					gotAmatch = 1 ;
X				break ;
X		}
X
X		if(gotAmatch)
X			break ;
X
X		eNum++ ;
X
X		while(*a == ','  ||  *a == ' '  ||  *a == '\t')
X			a++ ;
X	}
X
X	free(fldCmp) ;
X
X	if(gotAmatch)
X		return(eNum) ;
X	else
X		return (-1) ;
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/FindSet.c || echo "restore of utilities.d/libgeti.d/FindSet.c fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include	"keys.h"
X#include 	"GetInput.h"
X
X#define	MAXITEMS	200
X#define	NEWMENU		0
X
Xint	insertmode = FALSE;
X
X
XGetInput (win, rowStart, colStart, Fld, fldAttrib, fldMask, fldRange, fldLength,
X	fldMin, fldCharType, fldAdjust, fldType, keyStream, mustEnter, 
X	fldErrRow, fldDispRow, helpMsg, helpFile, helpTag)
X
X	WINDOW      	*win ;      	/* Window                */
X	int   		rowStart ;
X	int   		colStart ;
X	FldUnPointer	Fld ;    	/* Pointer to union for field     */
X	int   		fldAttrib ; 	/* Curses attribute         */
X	char  		*fldMask ;  	/* mask for character string      */
X	char  		*fldRange ; 	/* range of valid values for output */
X	int   		fldLength; 	/* Maximum length of output       */
X	int   		fldMin; 	/* Minimum length of output       */
X	char  		fldCharType;	/* type of character           */
X	char  		fldAdjust ; 	/* adjust/fill field           */
X	char  		fldType ;   	/* type of field         */
X	int   		keyStream ; 	/* if TRUE then the function will
X                  			   exit when the last character is
X                  			   keyed           */
X	int   		mustEnter ; 	/* boolean   */
X	int   		fldErrRow ; 	/* where to display error message   */
X	int   		fldDispRow ;   	/* where to display help message    */
X	char  		*helpMsg ;  	/* help message             */
X	char  		helpFile[] ;   	/* help file name        */
X	char  		helpTag[] ; 	/* tag where help begins       */
X{
X   	int	colEnd ;    	/* column end of field */
X   	int   	row ;       	/* working row field */
X   	int   	col ;       	/* working column field */
X   	int   	colSave ;      	/* working column field */
X   	int   	colMove ;      	/* working col field for adjusting routines */
X   	int   	colBegInput;	/* column where input begins */
X   	int   	ch ;            /* contains character keyed or being moved */
X   	int   	notFinished ;   /* bool indicator that indicates when the user 
X					is finished with keying in data */
X   	int   	setNumb ;       /* number to be returned showing which 
X					selection the user chose */
X   	int   	controlKey ;    /* if not 0 then the user hit a control key */
X   	int   	bytesKeyed ;    /* how many bytes were keyed */
X   	int   	initFld ;       /* indicate if field was initialized going into 
X                              		this routine */
X   	char  	*fldStr ;       /* buffer that will contain output  */
X   	char  	*charKeyed ;    /* characters keyed by the user Y/N */
X				/*
X				**  charKeyd indicates how many characters
X				**  has been keyed in.  A "Y" in the position
X				**  indicates that the user has keyed a char
X				**  at that position, otherwise it will be "N"
X				**  or a "M" for a mask format character.
X				*/
X   	char  	*fldWrk ;       /* working field */
X   	int   	origAttr[80] ;  /* original field attributes */
X   	char  	*malloc();
X	int	i;
X	int	junk;		/* use for anything */
X	char	menu[MAXITEMS+2][80];	/* popmenu items */
X	int	menuid;
X
X
X
X
X
X	if (fldCharType == PROTECT)
X	{
X		/* X out the field */
X		for (i = 0; i < fldLength; i++)
X			Fld->strVal[i] = 'X';
X		Fld->strVal[i] = '\0';
X	}
X
X   	/*
X	** bug fix  -  pjc  08/26/86
X	** bytesKeyed = 0
X	*/
X   	setNumb = controlKey = bytesKeyed = 0;
X
X	/* find length of field from the values in fldRange */
X   	if (fldCharType == SET  ||  fldCharType == MENU)
X      		fldLength = GetSetLen(fldRange);
X
X   	/*
X   	** pjc - 11/88
X   	** This allows you to pass "" 
X   	*/
X	if (fldRange != NORANGE  &&  strcmp(fldRange, "") == 0)
X		fldRange = NORANGE;
X
X   	if (fldMask != NOMASK  &&  strcmp(fldMask, "") == 0)
X		fldMask = NOMASK;
X   	if (fldMask == NOMASK) 
X   	{
X      		colEnd    = colStart + fldLength ;
X      		fldStr    = malloc(fldLength + 10);
X      		charKeyed = malloc(fldLength + 10);
X   	} 
X   	else 
X   	{
X      		colEnd    = colStart + strlen(fldMask) ;
X      		fldStr    = malloc(strlen(fldMask) + 10);
X      		charKeyed = malloc(strlen(fldMask) + 10);
X   	}
X
X	/*
X	**	Save original terminal attributes.
X	*/
X   	for (col = colStart; col < colEnd; col++)
X      		origAttr[col - colStart] = mvwinch(win, rowStart, col) & 
X						A_ATTRIBUTES ;
X
X	/* so a message you put on that line doesn't get erased */
X	if (helpMsg == NOMSG || strcmp (helpMsg, "DONT_CLEAR") == 0)
X		helpMsg = NOMSG;
X	else
X		CLEARROW (fldDispRow);
X
X   	/*
X	** bug fix     pjc  8/22/86
X	** test for NOMSG
X	** Display help message.
X	*/
X   	if (helpMsg != NOMSG) 
X   	{
X      		/* pjc 7/87 - clrtoeol for new message 
X      		*/
X      		/* pjc 11/88 - 
X      		**	change helpMsg to always display to standard screen.
X      		**	That way popup screens will work right.
X		**	Display message between col 1 to COLS-1 ... so that
X		**	it will work with a box border.
X      		*/
X
X      		mvwaddstr (stdscr,
X		((fldDispRow%100) == fldDispRow) ? fldDispRow : fldDispRow/100, 
X		((fldDispRow%100) == fldDispRow) ? 0 : fldDispRow%100, 
X			helpMsg) ;
X      		wnoutrefresh (stdscr);
X   	}
X
X	/*
X   	**	pjc 9/87
X   	**	Added new attributes
X   	**	If A_SAME then use the attributes that is showing
X   	**	on the screen in that position.
X	**	As you see it is determined from first column.
X   	*/
X   	if (fldAttrib == A_SAME)
X      		fldAttrib = origAttr[0];
X
X   	wmove(win, rowStart, colStart) ;
X   	if (fldCharType == SET  ||  fldCharType == MENU) 
X   	{
X      		setNumb = FindSet(Fld, fldRange, fldLength, fldType) ;
X      		ShowSet(win, rowStart, colStart, fldAttrib, fldRange, 
X			fldLength, &setNumb, colEnd, charKeyed, origAttr) ;
X		if (fldCharType == MENU)
X		{
X			char	menustrid[10];
X			int	mrow;
X			int	mcol;
X			int	numitems;
X
X			/* make a unique menuid from the row & column */
X			sprintf (menustrid, "%2d%2d", rowStart, colStart);
X			menuid = atoi (menustrid);
X
X			numitems = BuildMenu (menu, fldRange);
X			if (numitems == 0)
X				return (0);
X
X			/* try to put menu as close to the field as possible */
X			if ((rowStart + win->_begy) > 0)
X				mrow = rowStart + win->_begy - 1;
X			else
X				mrow = 0;
X			/* off the edge of the screen ? */
X			if ((colEnd + fldLength + 4) + win->_begx > COLS)
X			{
X				mcol = COLS - fldLength + 4;
X				mrow += 2;
X			}
X			else
X				mcol = colEnd + win->_begx;
X
X			if (mrow > 0  &&  numitems > (LINES - mrow - 2))
X			{
X				mrow = ((mrow-(numitems-(LINES-mrow-2))) > 0) 
X					? (mrow-(numitems-(LINES-mrow-2))) : 0;
X			}
X
X			popmenu (NEWMENU, menuid, mrow, mcol, "", 
X				helpFile, LINES-mrow-2, sizeof(menu[0]), menu);
X		}
X   	} 
X   	else
X		/*
X		**	FALSE if Fld->strval == '\0'
X		**	TRUE  if Fld contained a default value.
X		*/
X      		initFld = DisPrmpt(win, Fld, fldAttrib, fldMask, fldLength, 
X				fldCharType, fldAdjust, fldType, colStart, 
X				colEnd, fldStr, charKeyed) ;
X
X
X
X	/* 
X	** find the first column where there is not a mask(M) character 
X	** This is the column where we begin the input.
X	*/
X   	col = colStart ;
X   	fldWrk = charKeyed ;
X	/*
X	**  fldWrk - M = mask character, N = no mask character
X	*/
X   	while (col != colEnd  &&  *fldWrk++ == 'M')
X      		col++;
X
X   	colBegInput = col ;
X   	wmove(win, rowStart, col) ;
X   	notFinished = TRUE ;
X
X
X	if (fldCharType == PROTECT)
X	{
X		/* Password entry field */
X		wattrset (win, A_REVERSE);
X		strcpy (Fld->strVal, "");
X		free (fldStr);
X		free (charKeyed);
X		row = rowStart;
X		col = colStart;
X		fldStr = Fld->strVal;
X		*fldStr = '\0';
X		do
X		{
X			wmove (win, row, col);
X			wnoutrefresh (win);
X			doupdate ();
X			ch = wgetch (win);
X			if (ch == KeyHelp || ch == KEY_HELP)
X			{
X				ShowHelp (helpFile, helpTag, fldErrRow);
X				touchwin (win);
X				wnoutrefresh (win);
X			}
X		} while (ch == KeyHelp || ch == KEY_HELP);
X		*fldStr = (char)ch;
X		while (*fldStr != '\r')
X		{
X			if (col > colStart + fldLength - 1)
X				beep ();
X			else
X			{
X				addch ('X');
X				fldStr++;
X				col++;
X			}
X			wmove (win, row, col);
X			wnoutrefresh (win);
X			doupdate ();
X			ch = wgetch (win);
X			if (ch == KeyHelp || ch == KEY_HELP)
X			{
X				ShowHelp (helpFile, helpTag, fldErrRow);
X				touchwin (win);
X				wnoutrefresh (win);
X			}
X			else
X				*fldStr = (char)ch;
X		}
X		*fldStr = '\0';
X		wattrset (win, A_NORMAL);
X		return ((int)'\r');
X	}
X
X
X   	while (TRUE) 
X   	{
X      		do 
X      		{
X	 		/* pjc 11/88 for message and errors to stdscr */
X	 		wnoutrefresh (stdscr);
X         		wnoutrefresh(win) ;
X	 		doupdate ();
X
X         		getyx(win, row, col) ;
X
X   			controlKey = 0;
X         		ch = wgetch(win);
X
X			CLEARROW (fldErrRow);
X   			if (helpMsg != NOMSG) 
X   			{
X      				mvwaddstr (stdscr,
X		((fldDispRow%100) == fldDispRow) ? fldDispRow : fldDispRow/100, 
X		((fldDispRow%100) == fldDispRow) ? 0 : fldDispRow%100, 
X					helpMsg) ;
X   			}
X
X   			wmove(win, row, col) ;
X
X			/* these keys accept the input before returning */
X			if (ch == KeyReturn)	ch = KEY_RETURN;
X			if (ch == KeyDown)	ch = KEY_DOWN;
X			if (ch == KeyUp)	ch = KEY_UP;
X			if (ch == KeyTab)	ch = KEY_TAB;
X			if (ch == KeyBTab)	ch = KEY_BTAB;
X			if (ch == KeyAccept)	ch = KEY_ACCEPT;
X
X			/* other keys */
X			if (ch == KeyHelp)	ch = KEY_HELP;
X			if (ch == KeyRedraw)	ch = KEY_REFRESH;
X			if (ch == KeyLeft)	ch = KEY_LEFT;
X			if (ch == KeyRight)	ch = KEY_RIGHT;
X			if (ch == KeyEOL)	ch = KEY_EOL;
X			if (ch == KeyDL)	ch = KEY_DL;
X			if (ch == KeyDC)	ch = KEY_DC;
X			if (ch == KeyIC)	ch = KEY_IC;
X			if (ch == KeySave)	ch = KEY_SAVE;
X			if (ch == KeyPrint)	ch = KEY_PRINT;
X			if (ch == KeyBeg)	ch = KEY_BEG;
X			if (ch == KeyEnd)	ch = KEY_END;
X			if (ch == KeyCancel)	ch = KEY_CANCEL;
X
X			switch (ch)
X			{
X			   case KEY_BEG:
X				/* place cursor at beg of field */
X				col = colStart;
X                  		wmove(win, rowStart, col) ;
X				break;
X
X			   case KEY_END:
X				/* place cursor at end of input */
X				col = colEnd;
X				junk = colEnd;
X				while (col >= colStart)
X				{
X					if (*(charKeyed+col-colStart) == 'N')
X						junk = col;
X					if (*(charKeyed+col-colStart) == 'Y')
X						break;
X					col--;
X				}
X				col = junk;
X                  		wmove(win, rowStart, col) ;
X				break;
X
X			   case KEY_HELP:
X				ShowHelp (helpFile, helpTag, fldErrRow);
X				touchwin (win);
X				wnoutrefresh (win);
X				continue;
X
X			   case KEY_REFRESH:
X				clearok (win, TRUE);
X				continue;
X
X			   case KEY_LEFT:
X				/* fixme
X                  		if (col > colBegInput)
X				*/
X                  		if (col > colStart)
X                     			col--;
X                  		else
X                     			BELL;
X                  		while (col > colStart  &&  
X				       *(charKeyed + col - colStart) == 'M')
X                     			--col ;
X                  		while (*(charKeyed + col - colStart) == 'M')
X                     			col++;
X                  		wmove(win, rowStart, col) ;
X				continue;
X
X			   case KEY_RIGHT:
X                     		if (col < colEnd - 1  &&
X                	  	    (*(charKeyed + col - colStart) == 'Y' || 
X			  	    *(charKeyed + col - colStart) == 'M' ) )
X                        		col++;
X            	     		else
X                        		BELL;
X                     		while (col < colEnd  &&  
X				       *(charKeyed + col - colStart) == 'M')
X                     			col++;
X                     		while (*(charKeyed + col - colStart) == 'M')
X                        		col--;
X                     		wmove(win, rowStart, col) ;
SHAR_EOF
echo "End of part 8"
echo "File utilities.d/libgeti.d/GetInput.c is continued in part 9"
echo "9" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/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

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 10 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/RingMenu.c continued
#
CurArch=10
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/RingMenu.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/RingMenu.c
X	menu[0].page = 1 ;
X	/*
X	 * beyond the 1st option
X	 */
X	for ( i=1; i<Noptions ; i++ )
X	{
X		menu[i].page = menu[i-1].page ;
X		menu[i].column = menu[i-1].column
X				+ strlen( opt_table[i-1][0] ) + 2 ;
X		/*
X		 * about to roll off the right edge?
X		 */
X		if ( menu[i].column+strlen( opt_table[i][0] ) > COLS ||
X		     ( i < Noptions-1 &&
X		       menu[i].column+strlen( opt_table[i][0] )+5 > COLS ) )
X		{
X			menu[i].page++ ;	/* bump a page */
X			if ( title != NULL )	/* and wrap around */
X				menu[i].column = strlen( title ) + 7 ;
X			else
X				menu[i].column = 5 ;
X		}
X	}
X
X	i = ( opt<=Noptions && opt>0 ) ? opt-1 : 0 ;	/* set highlight */
X
X	/*
X	 * The LOOP
X	 */
X	while ( TRUE )
X	{
X		_showring( win, line, title, i, opt_table ) ;
X		ch = wgetch( win ) ;		/* get input */
X
X		if ( ch == KeyBackspace )	ch = KEY_BACKSPACE ;
X		if ( ch == KeyHelp )		ch = KEY_HELP ;
X		if ( ch == KeyRedraw )		ch = KEY_REFRESH ;
X		if ( ch == KeyPrint )		ch = KEY_PRINT ;
X
X		switch (ch)
X		{
X	 	case KEY_UP:
X		case KEY_LEFT:
X		case KEY_CTLK:
X		case KEY_CTLH:
X	 	case KEY_BACKSPACE:
X	 	case KEY_BTAB:
X			if ( --i < 0 )
X				i = Noptions - 1 ;
X			break ;
X
X	 	case KEY_DOWN:
X		case KEY_RIGHT:
X		case KEY_CTLJ:
X		case KEY_CTLL:
X	 	case ' ':
X	 	case KEY_TAB:
X			if ( ++i >= Noptions )
X				i = 0 ;
X		        break ;
X
X		case KEY_RETURN:
X		case KEY_ENTER:
X			_wclrring( win, line ) ;
X			putp( cursor_visible ) ;
X			return( i+1 ) ;
X			break ;
X
X		case KEY_HELP:
X			/*
X			ShowHelp( GENERAL, SPECIALKEYS, MSGLINE ) ;
X			*/
X			break ;
X
X		case KEY_REFRESH:
X			clearok( win, TRUE ) ;
X			break ;
X			
X		case KEY_PRINT:
X            		ScrnPrnt(win, LINES, COLS, MSGLINE) ;
X            		clearok(win, TRUE ) ;
X			break ;
X			
X		default:
X			for ( ii=0; ii<=Noptions-1; ii++ )
X			{
X				/* upper char match */
X				if ( strchr( opt_table[ii][0], toupper(ch) ) != NULL )
X				{
X					_wclrring( win, line ) ;
X					putp( cursor_visible ) ;
X		        		return ( ii+1 );
X				}
X			}
X			flash() ;
X		        break;
X		}
X	}
X}
X
X/*
X * _wclrring:  Erase the ring menu from screen
X */
X_wclrring( win, line )
X	WINDOW	*win ;
X	short	line ;
X{
X	wmove( win, line, 0 ) ; wclrtoeol( win ) ;
X	wmove( win, line+1, 0 ) ; wclrtoeol( win ) ;
X}
X
X/*
X * _showring: Display one lineful of RingMenu depending on the page
X *	      current option is on.
X */
X_showring( win, line, title, opt, opt_table )
X	WINDOW	*win ;
X	short 	line, opt ;
X	char	*title, *opt_table[][2] ;
X{
X	register short	i ;
X
X	wmove( win, line, 0 ) ;			/* go there */
X	if ( title != NULL )			/* title? */
X		wprintw( win, "%s  ", title ) ;
X	if ( menu[opt].page != 1 )		/* not 1st page? */
X		waddstr( win, "...  " ) ;
X		
X	/*
X	 * show options
X	 */
X	for ( i=0; i<Noptions && menu[i].page<=menu[opt].page; i++ )
X		if ( menu[i].page == menu[opt].page )	/* same page? */
X		{
X			if ( i == opt )		/* need highlight? */
X				wattrset( win, A_REVERSE );
X			waddstr( win, opt_table[i][0] );
X			wattrset( win, A_NORMAL ) ;
X			waddstr( win, "  " ) ;
X		}
X
X	if ( menu[opt].page < menu[Noptions-1].page )	/* not last page? */
X		waddstr( win, "..." ) ;
X	wclrtoeol( win ) ;
X
X	/*
X	 * show description
X	 */
X	wmove( win, line+1, 0 ) ;
X	wclrtoeol( win ) ;
X	mvwprintw( win, line+1,menu[0].column, "%s", opt_table[opt][1] ) ;
X
X	/*
X	 * fix cursor
X	 */
X	if ( menu[0].column >= 2 )
X		wmove(win, line, menu[0].column-2 );	/* before 1st option */
X	else
X		/* behind the last option */
X		wmove(win, line, menu[i-1].column+strlen(opt_table[i-1][0])+2 ) ;
X
X	wrefresh( win );
X}
SHAR_EOF
echo "File utilities.d/libgeti.d/RingMenu.c is complete"
chmod 0444 utilities.d/libgeti.d/RingMenu.c || echo "restore of utilities.d/libgeti.d/RingMenu.c fails"
echo "x - extracting utilities.d/libgeti.d/ScrnOut.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ScrnOut.c &&
Xstatic char Sccsid[] = "@(#)ScrnOut.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X#include	<curses.h>
X#include	"GetInput.h"
X
XScrnOut(win, y, x, fpout)
X	WINDOW	*win ;
X	int	y, x ;
X	FILE	*fpout ;
X{
X	int	xx, yy ;
X
X	for(yy = 0 ; yy < y ; yy++) {
X		for(xx = 0 ; xx < x ; xx++)
X			fputc( mvwinch( win, yy, xx ) & A_CHARTEXT, fpout) ;
X		fputc( '\n', fpout ) ;
X	}
X
X	return( 0 ) ;
X}
X
X
X
XScrnPrnt(win, y, x, msgLine)
X	WINDOW	*win ;
X	int	y, x ;
X	int	msgLine ;
X{
X	FILE	*fp ;
X
X	BELL;
X	mvaddstr(msgLine, 0, "Printing Screen ") ;
X	wattrOn(stdscr, A_BLINK) ;
X	addstr("...") ;
X	wattrOff(stdscr) ;
X	refresh() ;
X	BELL;
X
X	if( (fp = popen("lp -s", "w")) == NULL )
X		return(1) ;
X
X	ScrnOut(win, y, x, fp) ;
X
X	pclose(fp) ;
X
X	move(msgLine, 0) ;
X	clrtoeol() ;
X	refresh() ;
X
X	return(0) ;
X}
X
X
X
XScrnFile(win, y, x)
X	WINDOW	*win ;
X	int	y, x ;
X{
X	WINDOW	*twin ;
X	FILE	*fp ;
X	char	cmdstr[17] ;
X	union 	FldUnion Fld ;
X
X	twin = newwin(LINES, COLS, 0, 0) ;
X	mvwaddstr(twin, 10, 0, "File Name: ") ;
X	BELL;
X	cmdstr[0] = '\0' ;
X	Fld.strVal = cmdstr ;
X	GetInput (twin, 10, 11, &Fld, A_REVERSE, NOMASK, NORANGE, 16, 0, 
X		ALPHANUM, NOFILL, CHAR, AUTONEXT, NOMUST, LINES-1, LINES-1, 
X		"Enter the name of the file that will contain the image of the screen.", 
X		NULL, NULL) ;
X
X	if(cmdstr[0] == '\0')
X		return(1) ;
X
X	if( (fp = fopen(cmdstr, "w")) == NULL )
X		return(1) ;
X
X	ScrnOut(win, y, x, fp) ;
X
X	fclose(fp) ;
X
X	delwin(twin) ;
X
X	return(0) ;
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ScrnOut.c || echo "restore of utilities.d/libgeti.d/ScrnOut.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowChar.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowChar.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ShowChar.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  ShowChar()
X**	Validate character against the mask and convert to upper is neccessary.
X**	Display char to screen.
X*/
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include 	"GetInput.h"
X
Xextern int	insertmode;
X
XShowChar (win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, 
X	fldCharType, fldDispRow, fldType, keyStream, fldErrRow, charKeyed, 
X	colEnd, ch, origAttr)
X
X	WINDOW      	*win ;      	/* Window                */
X	int   		rowStart ;
X	int   		colStart ;
X	int   		fldAttrib ; 	/* Curses 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	int   		fldDispRow ;   	/* where to display help message    */
X	char  		fldType ;   	/* type of field         */
X	int   		keyStream ; 	/* if TRUE then the function will
X                  			exit when the last character is
X                  			keyed           */
X	int   		fldErrRow ; 	/* where to display error message   */
X	char  		*charKeyed ;   	/* characters keyed array      */
X	int   		colEnd ; 	/* column start of field */
X	int   		*ch ;     	/* contains character keyed or being
X                  			moved */
X	int   		origAttr[] ;   	/* original attributes for field */
X{
X	int		row ;       /* working row field */
X   	int   		col ;       /* working column field */
X   	char  		charType ;
X   	char  		cmdstr[16] ;
X	int		junk;
X
X
X   	getyx(win, row, col) ;
X
X   	if (fldCharType == STATE  || fldMask == NULL)
X      		charType = fldCharType ;
X   	else 
X      		if (fldCharType == DATE  ||  fldCharType == TIME)
X         		charType = NUMERIC ;
X      		else
X         		charType = *(fldMask + col - colStart) ;
X
X   	switch (charType) 
X   	{
X   	   case HEX:
X      		break ;
X
X   	   case ALPHA:
X      		if (isalpha(*ch)) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X		else 
X		{
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				"Only alpha characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   case ALPHANUM:
X   	   case UPPER_AN:
X   	   case STATE:
X      		if (isprint(*ch)) 
X      		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		if (charType == UPPER_AN  ||  charType == STATE)
X            			*ch = toupper(*ch);
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X      		else 
X      		{
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				"Only alpha/numberic characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   case UPPER:
X      		if (isalpha(*ch)) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		*ch = toupper(*ch);
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X		else 
X		{
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				"Only alpha characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break;
X
X   	   case NUMERIC:
X      		if (isdigit(*ch)  ||
X          	   ((fldType == FLOAT ||
X          	     fldType == DOUBLE ||
X          	     fldType == MONEY) && *ch == '.') ) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X         		if (fldType == FLOAT || fldType == DOUBLE ||
X             			fldType == MONEY) 
X			{
X            			int   firstCol ;
X
X            			firstCol = colStart ;
X            			while (*(charKeyed + firstCol - colStart) == 'M')
X               				firstCol++;
X            			if (col == firstCol) 
X				{
X               				cmdstr[0] = *ch ;
X               				cmdstr[1] = '\0' ;
X               				while (++col < colEnd)
X                  				*(charKeyed + col - colStart) = 'N' ;
X               				ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, fldCharType,
X                    				fldType, cmdstr, colEnd, charKeyed, 0, origAttr) ;
X               					wattrOn(win, fldAttrib) ;
X               				mvwaddstr(win, rowStart, colStart + 1, "   ") ;
X               				wattrOff(win) ;
X               				wmove(win, rowStart, colStart + 1) ;
X            			}
X         		}
X
X    		} 
X		else 
X		{
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					"Only numbers allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   default:
X      		BELL;
X      		break ;
X
X   	} /* end switch */
X
X   	getyx(win, row, col) ;
X   	if (col == colEnd && keyStream == TRUE)
X	{
X		*ch = KEY_RETURN;
X      		return(FALSE) ;
X	}
X   	else 
X      		if (col != colEnd && fldMask != NULL) 
X      		{
X	 		/* skip cursor over format characters in the mask */
X         		while (col != colEnd && 
X			       *(charKeyed+col-colStart) == 'M')
X            			col++;
X         		wmove(win, rowStart, col) ;
X         		return(TRUE) ;
X      		}
X
X   	return (TRUE);
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ShowChar.c || echo "restore of utilities.d/libgeti.d/ShowChar.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowHelp.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include	<ctype.h>
X#include	"keys.h"
X#include	"GetInput.h"
X
X
X#ifndef	KEY_BEG
X#define	KEY_BEG		0542
X#endif
X#ifndef	KEY_END
X#define	KEY_END		0550
X#endif
X#ifndef	KEY_HELP
X#define	KEY_HELP	0553
X#endif
X#ifndef	KEY_CANCEL
X#define	KEY_CANCEL	0543
X#endif
X
X#ifndef BELL
X#define BELL	printf ("%c", 7);
X#endif
X#define	NEXTPAGE	1
X#define	PREVPAGE	2
X#define	SCROLLDOWN	3
X#define	SCROLLUP	4
X#define	FIRSTPAGE	5
X#define	LASTPAGE	6
X
X#define	SCROLLRATE	(wrows/2)			/* # lines to scroll */
X#define	MAXTOC		24				/* max TOC entries */
X#define	TOCTAG		"TABLE_OF_CONTENTS"		/* helptag for TOC */
X
X#define	SKIPJUNK(s) 	/* \
X			**  This macro skips over spaces, tabs, etc. \
X			**  ARGS:  char  *s \
X			*/ \
X			for (;*s != '\0' && (isspace(*s)); s++) \
X				;
X
Xstruct TableOfContents
X{
X	char	helpfile[16];
X	char	helptag[30];
X	char	text[100];
X};
X
X
XShowHelp (HelpFile, Tag, fldErrRow)
X	char	HelpFile[];
X	char	Tag[];
X	int	fldErrRow;
X{
X	WINDOW	*helpWin;
X   	FILE	*fopen(), *fp;
X	char	*fgets();
X	char	*getenv();
X	long	ftell();
X	char	line[100];
X	char	*sptr;
X	int	row;
X	int	col;
X	int	wrows;
X	int	wcols;
X	char	helpfile[80];
X	int	longline; /*0*/
X	int	ch;
X	char	title[100];
X	int	scrollflag;
X	int	linecount;
X	long	lineoffset[200];		/* start of line in file */
X	static int	helpHelp = FALSE;
X	struct TableOfContents	TOC[MAXTOC];
X	int	rc;
X	int	TOCflag = FALSE;
X	char	fileName[100];
X	char	tag[80];
X
X
X	strcpy (fileName, HelpFile);
X	strcpy (tag, Tag);
Xrestart:
X	strcat (tag, "\n");
X	linecount = 0;
X	/* do we have a help tag ? */
X	if (strcmp (tag, "") == 0)
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				"No help available.");
X		wattrOff (stdscr);
X		return (1);
X	}
X
X	/*
X	**  open help file
X	*/
X   	if ((fp = fopen (fileName, "r")) == (FILE *)NULL)
X   	{
X		if (getenv("HELPDIR") != (char *)NULL)
X      			sprintf (helpfile, "%s/%s", getenv ("HELPDIR"), 
X				 fileName);
X      		fp = fopen (helpfile, "r");
X      		if (fp == (FILE *)NULL) 
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				"No help available.");
X			wattrOff (stdscr);
X         		return(1) ;
X      		}
X   	}
X
X	if (!TOCflag) 
X		TOCflag = loadTOC (fp, TOC) == 0 ? TRUE : FALSE;
X
X	/*
X	**  Locate starting tag.
X	*/
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X		if (strncmp (line, tag, strlen(tag)) == 0)
X			break;
X
X	if (sptr == (char *)NULL)
X	{
X		/* Did not find starting tag */
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			"No help available.");
X		wattrOff (stdscr);
X      		fclose(fp) ;
X      		return(1) ;
X	}
X
X	/*
X	**	Found starting tag.
X	**	determine how big of a window to make by searching for 
X	**  	ending tag
X	**	check for a .TITLE line
X	*/
X	lineoffset[linecount+1] = ftell (fp);
X	fscanf (fp, "%s", title);
X	if (strcmp (title, ".TITLE") == 0)
X	{
X		fseek (fp, 1, 1);			/* skip 1 byte */
X		sptr = fgets (title, sizeof(title)-1, fp);
X		title[strlen(title)-1] = '\0';		/* junk \n */
X		lineoffset[linecount+1] = ftell (fp); 	/* reset beg of help */
X	}
X	else
X		strcpy (title, "");
X	longline = strlen(title)+2;
X
X	fseek (fp, lineoffset[1], 0);		/* back to row 1 */
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X	{
X		/* check for ending tag */
X		if (strncmp (line, tag, strlen(tag)) == 0)
X			break;
X		
X		/* calculate longest line */
X		if (strlen(line) > longline)
X			longline = strlen(line);
X		linecount++;
X		lineoffset[linecount+1] = ftell (fp);
X	}
X
X	wrows = (linecount+2 < (LINES-2)) ? linecount+2 : (LINES-2);
X	wcols = (longline+1 < COLS) ? longline+1 : COLS;	/* 1 for \n */
X	/* center window on the screen */
X   	helpWin = newwin(wrows, wcols, LINES/2-wrows/2,COLS/2-wcols/2) ;
X	keypad (helpWin, TRUE);
X	scrollflag = (linecount+2 <= LINES) ? FALSE : TRUE;
X	drawbox (helpWin, 1,1, wrows,wcols, 2,2, scrollflag,
X			(helpHelp == FALSE ? TRUE : FALSE), FALSE);
X	if (strcmp (title, "") != 0)
X	{
X		wattrset (helpWin, A_STANDOUT);
X		mvwprintw (helpWin, 0,2, "%s", title);
X		wattrset (helpWin, A_NORMAL);
X	}
X
X	row = 1;
X	fseek (fp, lineoffset[row], 0);		/* back to row 1 */
X	ch = KEY_BEG;
X	do
X	{
X		switch (ch)
X		{
X		   case KEY_TOC:
X			if (!TOCflag)
X				break;
X			rc = showTOC (TOC);
X			if (rc > 0)
X			{
X				fclose (fp);
X				delwin (helpWin);
X				strcpy (fileName,TOC[rc-1].helpfile);
X				strcpy (tag,TOC[rc-1].helptag);
X				goto restart;
X			}
X			touchwin (helpWin);
X			break;
X		   case KEY_BEG:
X			showpage (FIRSTPAGE,fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_DOWN:
X			showpage (SCROLLDOWN,fp,wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_UP:
X			showpage (SCROLLUP, fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_END:
X			showpage (LASTPAGE, fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_HELP:
X			if (!helpHelp)
X			{
X				helpHelp = TRUE;
X				ShowHelp (fileName, "help", fldErrRow);
X				helpHelp = FALSE;
X			}
X			touchwin (helpWin);
X			break;
X		} /* end switch */
X		wattrset (helpWin, A_STANDOUT);
X		if (ftell(fp) != lineoffset[linecount+1])
X		{
X			/* we are not at end of file yet */
X			mvwprintw (helpWin, wrows-1, 2, "--More--(%d%c)",
X		     	   (int)((double)((double)(ftell(fp)-lineoffset[1]) / 
X		     	   (lineoffset[linecount+1]-lineoffset[1])) * 100), 
X			   '%');
X		}
X		else
X		{
X			if (linecount+2 >= LINES)
X				mvwprintw (helpWin, wrows-1, 2, 
X						"--End--       ");
X			else
X				mvwprintw (helpWin, wrows-1, 2, 
X						"              ");
X		}
X
X		wattrset (helpWin, A_NORMAL);
X		wmove (helpWin, wrows-1,wcols-1);
X		wrefresh (helpWin);
X		ch = wgetch (helpWin);
X
X		if (ch == KeyBeg || ch == KEY_BEG)
X			ch = KEY_BEG;
X		else if (ch == KeyDown || ch == KEY_DOWN)
X			ch = KEY_DOWN;
X		else if (ch == KeyUp || ch == KEY_UP)
X			ch = KEY_UP;
X		else if (ch == KeyCancel || ch == KEY_CANCEL)
X			ch = KEY_CANCEL;
X		else if (ch == KeyEnd || ch == KEY_END)
X			ch = KEY_END;
X		else if (ch == KeyHelp || ch == KEY_HELP)
X			ch = KEY_HELP;
X		else if (ch == KeyTOC || ch == KEY_TOC)
X			ch = KEY_TOC;
X		else
X		{
X			if (ftell(fp) != lineoffset[linecount+1])
X				ch = KEY_DOWN;
X			else
X				ch = KEY_CANCEL;
X		}
X	} while (ch != KEY_CANCEL);
X
X   	fclose(fp) ;
X	delwin (helpWin);
X	touchwin (stdscr);
X	wnoutrefresh (stdscr);
X   	return(0) ;
X}
X
X/*
X**  RETURNS:
X**		0	more info
X**		-1	end of file or tag
X*/
Xshowpage (action, fp, wrows, wcols, helpWin, linecount, lineoffset)
X	int	action;
X	FILE	*fp;
X	int	wrows;
X	int	wcols;
X	WINDOW	*helpWin;
X	int	linecount;
X	long	lineoffset[];		/* start of line in file */
X{
X	char		line[100];
X	static int	here;				/* line top of screen */
X	int		rowcount;
X	int		i,j;
X
X
X	switch (action)
X	{
X	   case FIRSTPAGE:
X		here = 1;
X		break;
X
X	   case LASTPAGE:
X		if (here == linecount - wrows + 1) return (-1);
X		here = linecount - wrows + 1;
X		break;
X
X	   case SCROLLDOWN:
X		if (here + wrows > linecount)
X			return(-1);				/* at EOF */
X		if (here + wrows + SCROLLRATE <= linecount+1)
X			here += SCROLLRATE;
X		else
X			here = linecount - wrows + 1;
X		break;
X
X	   case SCROLLUP:
X		if (here == 1)
X			return (-1);				/* at BOF */
X		if (here - SCROLLRATE >= 1)
X			here -= SCROLLRATE;
X		else
X			here = 1;
X		break;
X
X	   case NEXTPAGE:
X		break;
X
X	   case PREVPAGE:
X		break;
X	}
X
X	/* clear screen */
X	for (i=1; i<=wrows; i++)
X		for (j=1; j<=wcols; j++)
X			mvwprintw (helpWin, i,j, " ");
X	fseek (fp, lineoffset[here], 0);		/* first of screen */
X	for (rowcount=1; rowcount<=wrows && rowcount<=linecount; rowcount++)
X	{
X		fgets (line, sizeof(line)-1, fp);
X		line[strlen(line)-1] = '\0';		/* junk \n */
X		showline (helpWin, rowcount, 1, line);
X	}
X	return (0);
X}
X
X
X
X/*  FUNCTION:	displaytext()
X**		Displays a string to the screen with atributes.
X**  ARGS:	row	screen row
X**		col	screen col
X**		s	the string
X**  RETURNS:	none
X*/
X#ifndef SYSV
X#define	SYSV	1
X#endif
Xshowline (helpWin, row, col, s)
X	WINDOW	*helpWin;
X	int	row, col;
X	char	s[];
X{
X	int	i;
X
X   	wmove (helpWin, row, col);
X
X	/*
X	**	Now display looking for terminal attributes.
X	*/
X      	for (i = 0; s[i] != '\0'; i++)
X      	{
X         	if (s[i] == '\\')
X	 	{
X#ifdef BSD
X	    		/* Berkeley curses only supports standout */
X	    		if (s[i+1] != 'N') s[i+1] = 'S';
X#endif
X            		switch (s[++i])
X            		{
X	       		   case 'S':
X#ifdef BSD
X				standout ();
X#else
X	   			wattrset (helpWin, A_STANDOUT);
X#endif
X				break;
X	       		   case 'B':
X#ifdef SYSV
X				wattrset (helpWin, A_BOLD);
X#endif
X				break;
X	       		   case 'U':
X#ifdef SYSV
X				wattrset (helpWin, A_UNDERLINE);
X#endif
X				break;
X	       		   case 'D':
X#ifdef SYSV
X				wattrset (helpWin, A_DIM);
X#endif
X				break;
X	       		   case 'R':
X#ifdef SYSV
X				wattrset (helpWin, A_REVERSE);
X#endif
X				break;
X	       		   case 'L':
X#ifdef SYSV
X				wattrset (helpWin, A_BLINK);
X#endif
X				break;
X	       		   case 'N': 
X#ifdef BSD
X				standend ();
X#else
X				wattrset (helpWin, A_NORMAL);
X#endif
X				break;
X			}
X		}
X         	else
X            		waddch (helpWin, s[i]);
X	}
X}
X
X
X
XloadTOC (fp, TOC)
X	FILE			*fp;
X	struct TableOfContents	TOC[];
X{
X	char	line[100];
X	char	*sptr;
X	int	count = 0;
X
X
X	strcpy (TOC[0].text, "");
X	/*
X	**  Locate TABLE_OF_CONTENT tag.
X	*/
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X		if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
X			break;
X
X	if (sptr == (char *)NULL) 
X	{
X		rewind (fp);
X		return (-1);				/* no TOC */
X	}
X
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X	{
X		/* check for ending tag */
X		if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
X			break;
X		
X   		sscanf (sptr, "%s", TOC[count].helpfile);
X		sptr += strlen(TOC[count].helpfile);
X		SKIPJUNK(sptr);
X   		sscanf (sptr, "%s", TOC[count].helptag);
X		sptr += strlen(TOC[count].helptag);
X		SKIPJUNK(sptr);
X		strcpy (TOC[count].text, sptr);
X		TOC[count].text[strlen(TOC[count].text)-1] = '\0'; /* junk \n */
X		count++;
X	}
X	strcpy (TOC[count].text, "");
X	rewind (fp);
X	return (0);
X}
X
X
X
XshowTOC (TOC)
X	struct TableOfContents	TOC[];
X{
X	int	count;
X	int	length = 0;
X	char	menu[MAXTOC+2][80];		/* popmenu items */
X	int	menuid = 99;
X	int	rc;
X
X
X	for (count = 0; strcmp (TOC[count].text, "") != 0; count++)
X	{
X		strcpy (menu[count], TOC[count].text);
X		if (strlen(menu[count]) > length)
X			length = strlen(menu[count]);
X	}
X	strcpy (menu[count], "");
X
X	/* center on screen */
X	popmenu (-2, menuid, (LINES/2)-(count/2)-3, (COLS/2)-(length/2)-2, 
X			"Help - Table Of Contents", "", count, sizeof(menu[0]), 
X			menu);
X	rc = popmenu (menuid, (char *)NULL);
X	return (rc);
X}
X/* Paul J. Condie  12/88 */
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/ShowHelp.c || echo "restore of utilities.d/libgeti.d/ShowHelp.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowSet.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowSet.c &&
Xstatic char Sccsid[] = "@(#)ShowSet.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include	<curses.h>
X#include	"GetInput.h"
X
XShowSet(win, rowStart, colStart, fldAttrib, fldRange, fldLength, pNum, colEnd, charKeyed, origAttr)
X	WINDOW		*win ;		/* Window	    		    */
X	int		rowStart ;
X	int		colStart ;
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		*fldRange ;	/* enumeration list for SET 	    */
X	unsigned	fldLength ;	/* Maximum length of output 	    */
X	int		*pNum ;		/* enum to display */
X	int		colEnd ;
X	char		*charKeyed ;	/* characters keyed */
X	int		origAttr[] ;	/* original attributes for field */
X{
X	char	*fldWrk ;
X	int	count ;
X	int	col ;
X
X	wmove (win, rowStart, colStart) ;
X
X	fldWrk = fldRange ;
X
X	count = 0 ;
X
X	while (*fldWrk != '\0') {
X
X		if (count == *pNum)
X			break ;
X
X		while (*fldWrk != ','  &&  *fldWrk != '\0')
X			fldWrk++ ;
X
X		if (*fldWrk == '\0') {
X			fldWrk = fldRange ;
X			*pNum = 0 ;
X			break ;
X		}
X
X		while (*fldWrk == ','  ||  *fldWrk == ' ')
X			fldWrk++ ;
X
X		count++ ;
X	}
X
X	if(fldAttrib != -1)
X		wattrset (win, fldAttrib) ;
X
X	col = colStart ;
X	while (*fldWrk != ','  &&  *fldWrk != '\0') {
X		if(fldAttrib == -1)
X			wattrset(win, origAttr[col++ - colStart]) ;
X		waddch (win, *fldWrk++) ;
X		*charKeyed++ = 'Y' ;
X		fldLength-- ;
X	}
X
X	if(fldAttrib != -1)
X		wattrset (win, 0) ;
X
X	while (fldLength--) {
X		*charKeyed++ = 'N' ;
X		if(fldAttrib == -1)
X			wattrset(win, origAttr[col++ - colStart]) ;
X		waddch (win, ' ') ;
X	}
X
X	wmove (win, rowStart, colStart) ;
X	wattrset(win, 0) ;
X
X	return(0) ;
X
X}
X
X
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ShowSet.c || echo "restore of utilities.d/libgeti.d/ShowSet.c fails"
echo "x - extracting utilities.d/libgeti.d/_Main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/_Main.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include 	"GetInput.h"
X#include 	"keys.h"
X
X
Xmain (argc, argv)
X
X	int   argc;
X	char  *argv[];
X{
X   int   	intV ;
X   long  	longV ;
X   double   	doubleV ;
X   int   	retCode ;
X   char  	cmdstr[128] ;
X   union FldUnion Fld ;
X
X
X   Initialize() ;
X
X/* MENU */
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 13, 0, &Fld, A_REVERSE, NOMASK, 
X	"one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,13,14,15,16,17,18,19,20,21,22,23", 6, 0, MENU,
X	NOFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Menu Field", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X/* SET */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 4, 0, &Fld, A_REVERSE, NOMASK, 
X	"one,two,three,four,five,six,seven,sevab", 6, 0, SET,
X	NOFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Set Field", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/* DATE */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "MM/DD/YY", 
X	"sun,wed,no_holidays,gt_today", 6, 6, DATE,
X	NOFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Date Field MM/DD/YY: ", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/* CHAR */
X   cmdstr[0]='\0';
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 2, 1, &Fld, A_REVERSE, NOMASK, NORANGE,
X       5, 0, ALPHANUM, NOFILL, CHAR, NOAUTO, NOMUST, 20, 22,
X       "Prompt", "GetInput.hlp", "GETINPUT");
X
X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X   /* Double */
X   doubleV = 123.45 ;
X   Fld.doubleVal = &doubleV ;
X   retCode = GetInput (stdscr, 18, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 
X	10, 0, NUMERIC, RTADJ_ZFILL, DOUBLE, NOAUTO,
X        NOMUST, 20, 21, "Double: ") ;
X   mvprintw (18, 40, "return code = :%d: value = :%f:", retCode, doubleV);
X   refresh ();
X
X   /*
X   cmdstr[0]='\0';
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 1, 1, &Fld, A_PROTECT, NOMASK, NORANGE,
X       5, 2, ALPHANUM, NOFILL, CHAR, NOAUTO, MUSTENTER, 2010, 22,
X       "Prompt                   %", "junk.hlp", "GETINPUT");
X
X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X
X   strcpy(cmdstr, "AA") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 2, 1, &Fld, A_STANDOUT, 
X	"[VV][VV][  ][  ][  ][  ][  ][  ]", NORANGE, 16, 2, UPPER_AN, NOFILL, 
X	CHAR, NOAUTO, MUSTENTER, 23, 22, "Character field:", "testfile", 
X	"FIELD 1") ;
X
X   mvprintw (2, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X   */
X
X
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 3, 1, &Fld, A_REVERSE, "HH:MM:SS:TT", NULL, 6, 6, 
X	TIME, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, 
X	"Time Field HH:MM:SS:TT: ", "testfile", "FIELD 2") ;
X
X   mvprintw (3, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X
X/* ZIP */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 9, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 9, 0, 
X	ZIP, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Zip Field XXXXX-XXXX",
X	NOHELP, NOTAG) ;
X
X   mvprintw (9, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/*
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 8, 0, &Fld, A_REVERSE, "(999) 999-9999", NULL, 10, 5, NUMERIC, RTADJ_ZFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Phone Number:", NULL, NULL) ;
X
X   flash () ;
X   strcpy(cmdstr, "ABC") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 10, 0, &Fld, A_REVERSE, NULL, NULL, 9, 0, UPPER_AN, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Job Number:", NULL, NULL) ;
X   mvprintw(12, 0, "strlen %d", strlen(cmdstr) ) ;
X   refresh() ;
X*/
X
X
X/*
X   strcpy(cmdstr, ";lkj") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 12, 0, &Fld, A_REVERSE, NOMASK, 
X		", INTeger, CHARacter, HEXdecimal, DATE", 12, 0, SET, NOFILL, 
X		CHAR, NOAUTO, NOMUST, 20, 21, "enumeration field: ", 
X		NOMSG, NOTAG) ;
X   mvprintw (12, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh () ;
X*/
X
X/*
X   flash () ;
X   intV = 200 ;
X   Fld.intVal = &intV ;
X   retCode = GetInput (stdscr, 13, 0, &Fld, A_REVERSE, NOMASK, "100, 200, 300", 
X		12, 0, SET, NOFILL, INT, NOAUTO, MUSTENTER, 23, 22, 
X		"enumeration field - int: ", NULL, NULL) ;
X   mvprintw (13, 20, "return code = :%d: value = :%d:", retCode, intV);
X   refresh () ;
X
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 14, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 2, 2, STATE, NOFILL, CHAR, AUTONEXT, MUSTENTER, 20, 21, "State Field: ", NULL, NULL) ;
X   refresh () ;
X
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 16, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 6, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, NOMUST,
X        20, 21, "Six char field") ;
X
X   refresh () ;
X
X   */
X
X   refresh () ;
X   sleep (4) ;
X   Windup () ;
X   exit (0) ;
X}
X
X
XInitialize ()
X{
X   initscr() ;
X   cbreak() ;
X   noecho() ;
X   nonl() ;
X   keypad(stdscr, TRUE) ;
X   InitGetI() ;
X   return(0) ;
X}
X
X
XWindup()
X{
X	/*
X	**
X	**	Take care of curses.
X	**
X	*/
X	endwin() ;
X
X	return(0) ;
X}
X
X
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/_Main.c || echo "restore of utilities.d/libgeti.d/_Main.c fails"
echo "x - extracting utilities.d/libgeti.d/checkmask.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/checkmask.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)checkmask.c	1.1   DeltaDate 11/21/88   ExtrDate 1/22/90";
X#endif
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include 	"GetInput.h"
X
Xcheckmask (col, colStart, fldMask, fldCharType, fldType, ch)
X
X	int	col ;
X	int   colStart ;
X	char  *fldMask ;  	/* mask for character string      */
X	char  fldCharType ;  	/* type of character           */
X	char  fldType ;   	/* type of field         */
X	int   ch ;     		/* contains character keyed or being
X                  			moved */
X{
X   	char  charType ;
X   	char  cmdstr[16] ;
X
X
X
X   	if (fldCharType == STATE  || fldMask == NULL)
X      		charType = fldCharType ;
X   	else 
X      		if (fldCharType == DATE  ||  fldCharType == TIME)
X         		charType = NUMERIC ;
X      		else
X         		charType = *(fldMask + col - colStart) ;
X
X   	switch (charType) 
X   	{
X   	   case HEX:
X      		break ;
X
X   	   case ALPHA:
X      		if (isalpha(ch)) 
X			return (ch);
X		else 
X			return (-1);
X      		break ;
X
X   	   case ALPHANUM:
X   	   case UPPER_AN:
X   	   case STATE:
X      		if (isprint(ch)) 
X      		{
X         		if (charType == UPPER_AN  ||  charType == STATE)
X            			ch = toupper(ch);
X			return (ch);
X      		} 
X      		else 
X			return (-1);
X      		break ;
X
X   	   case UPPER:
X      		if (isalpha(ch)) 
X		{
X         		ch = toupper(ch);
X			return (ch);
X      		}
X		else
X			return (-1);
X      		break ;
X
X   	   case NUMERIC:
X      		if (isdigit(ch)  ||
X          	   ( (fldType == FLOAT ||
X          	      fldType == DOUBLE ||
X          	      fldType == MONEY) && ch == '.') ) 
X		{
X			return (ch);
X      		} 
X		else 
X			return (-1);
X      		break ;
X
X   	   default:
X		return (-1);
X   	} /* end switch */
X	return (-1);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/checkmask.c || echo "restore of utilities.d/libgeti.d/checkmask.c fails"
echo "x - extracting utilities.d/libgeti.d/doinsert.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/doinsert.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)doinsert.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  doinsert()
X**	Shifts characters to the right of cursor location over one and
X**	places a space where the new character will go.
X**  RETURNS:
X**		-1	field is full
X**		-2	didn't pass mask edits
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X
X
Xdoinsert (win, row, col, colStart, colEnd, charKeyed, fldMask, fldCharType,
X	fldType, rowStart, fldAttrib, fldRange, fldLength, fldErrRow, origAttr)
X	WINDOW	*win;
X	int	row;
X	int	col;
X	int	colStart;
X	int	colEnd;
X	char	*charKeyed;
X	char	*fldMask;
X	char	fldCharType;
X	char	fldType;
X	int	rowStart;
X	int	fldAttrib;
X	char	*fldRange;
X	int	fldLength;
X	int	fldErrRow;
X	int	origAttr[];
X{
X	int	colSave;
X	char	fldStr[100];
X	char	*fldWrk;
X	int	junk;
X
X
X	colSave = col;		/* cursor location */
X
X	/* if we're sitting at end of field then no need to insert */
X	if (*(charKeyed+col-colStart) == 'N')
X		return (0);
X
X	/* do we have room to shift right on position ? */
X	col = colEnd;
X	while (col >= colStart)
X	{
X		if (*(charKeyed+col-colStart) == 'N')
X			break;				/* looks like we do */
X		if (*(charKeyed+col-colStart) == 'Y')
X		{
X			BELL;
X			return (-1);			/* no room */
X		}
X		col--;
X	}
X	if (col < colStart)
X	{
X		BELL;
X		return (-1);				/* all 'M' characters */
X	}
X
X	/* get field content & insert a space */
X	col = colStart;
X	fldWrk = fldStr;
X	while (col < colEnd)
X	{
X		if (col == colSave)
X			*fldWrk++ = ' ';	/* insert space */
X       		if (*(charKeyed+col-colStart) == 'Y')
X       			*fldWrk++ = mvwinch(win, row, 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'; col++)
X		{
X			/* only check shifted chars */
X			if (col <= colSave  || *(charKeyed+col-colStart) == 'M')
X			{
X				if (*(charKeyed+col-colStart) == 'Y')
X					fldWrk++;
X				continue;
X			}
X
X       			junk = checkmask (col, colStart, 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, A_REVERSE|A_BOLD);
X       			mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X	    			"Unable to insert character due to edits.");
X			wattrOff (stdscr);
X			BELL;
X			col = colSave;
X			wmove (win, rowStart, colSave);
X			return (-2);
X		}
X	}
X
X	/* set last N in charKeyd to Y */
X	col = colEnd;
X	while (col >= colStart)
X	{
X		if (*(charKeyed+col-colStart) == 'N')
X			junk = col;
X		if (*(charKeyed+col-colStart) == 'Y')
X		{
X			*(charKeyed+junk-colStart) = 'Y';
X			break;
X		}
X		col--;
X	}
X
X
X       	ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, 
X			fldLength, fldCharType, fldType,
X			fldStr, colEnd, charKeyed, 0, origAttr);
X
X	col = colSave;
X	wmove (win, rowStart, colSave);
X	return (0);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/doinsert.c || echo "restore of utilities.d/libgeti.d/doinsert.c fails"
echo "x - extracting utilities.d/libgeti.d/drawbox.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.c &&
X
X#ifndef LINT
Xstatic char Sccsid[] = "%W%    DeltaDate %G%    ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	<ctype.h>
X
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X#define	MosaicLine	4	/* A_ALTCHARSET */
X#define	DiamondLine	5	/* A_ALTCHARSET */
X#define	DotLine		6	/* A_ALTCHARSET */
X#define	PlusLine	7	/* A_ALTCHARSET */
X
X#define	CANDRAWGRAPHICS	(enter_alt_charset_mode != NULL  && \
X			 strcmp(enter_alt_charset_mode, "") != 0)
X
Xextern	int	KeyHelp;
X
X
Xvoid drawbox (win, frow, fcol, trow, tcol, trythis, trythat, vscroll, help, percent)
X	WINDOW	*win;
X	int	frow;			/* from row base 1 */
X	int	fcol;
X	int	trow;
X	int	tcol;
X	int	trythis;
X	int	trythat;
X	int	vscroll;
X	int	help;
X	float	percent;		/* percent into list for vscroll
X					   indicator */
X{
X	int	row;
X	int	col;
X	int	vchar;
X	int	hchar;
X	int	tlchar;				/* top left corner */
X	int	trchar;				/* top right corner */
X	int	brchar;				/* bottom right corner */
X	int	blchar;				/* bottom left corner */
X	int	attribute;
X	int	boxtype;
X
X
X	boxtype = trythis;
X	attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
X	if (attribute == A_ALTCHARSET)
X		/* can this terminal do graphics ? */
X		boxtype = CANDRAWGRAPHICS ? trythis : trythat;
X
X	switch (boxtype)
X	{
X	   case DumbLine:
X		/* draw a dumb line */
X		vchar = '|';
X		hchar = '-';
X		tlchar = '+';
X		trchar = '+';
X		brchar = '+';
X		blchar = '+';
SHAR_EOF
echo "End of part 10"
echo "File utilities.d/libgeti.d/drawbox.c is continued in part 11"
echo "11" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 11 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/drawbox.c continued
#
CurArch=11
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/drawbox.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/drawbox.c
X		break;
X
X	   case StandoutLine:
X		/* draw a standout line */
X		attribute = A_STANDOUT;
X		vchar = ' ';
X		hchar = ' ';
X		tlchar = ' ';
X		trchar = ' ';
X		brchar = ' ';
X		blchar = ' ';
X		break;
X
X	   case SingleLine:
X		/* attempt to draw a graphic single line */
X		vchar = 'x';
X		hchar = 'q';
X		tlchar = 'l';
X		trchar = 'k';
X		brchar = 'j';
X		blchar = 'm';
X		break;
X
X	   case MosaicLine:
X		vchar = 'a';
X		hchar = 'a';
X		tlchar = 'a';
X		trchar = 'a';
X		brchar = 'a';
X		blchar = 'a';
X		break;
X
X	   case DiamondLine:
X		vchar = '`';
X		hchar = '`';
X		tlchar = '`';
X		trchar = '`';
X		brchar = '`';
X		blchar = '`';
X		break;
X
X	   case DotLine:
X		vchar = '~';
X		hchar = '~';
X		tlchar = '~';
X		trchar = '~';
X		brchar = '~';
X		blchar = '~';
X		break;
X
X	   case PlusLine:
X		vchar = 'n';
X		hchar = 'n';
X		tlchar = 'n';
X		trchar = 'n';
X		brchar = 'n';
X		blchar = 'n';
X		break;
X
X	   default:
X		return;
X	}
X
X#ifdef BSD
X	standout ();
X#else
X   	wattrset (win, attribute);
X#endif
X   	for (row = frow-1; row <= trow-1; row++)
X   	{
X      		if (row == frow-1  ||  row == trow-1)
X         		for (col = fcol-1; col <= tcol-1; col++)
X            			mvwaddch (win, row, col, hchar);
X      		else
X      		{
X         		mvwaddch (win, row, fcol-1, vchar);
X         		mvwaddch (win, row, tcol-1, vchar);
X      		}
X   	}
X	/* draw the corners */
X	mvwaddch (win, frow-1,fcol-1, tlchar);	/* top left */
X	mvwaddch (win, frow-1,tcol-1, trchar);	/* top right */
X	mvwaddch (win, trow-1,fcol-1, blchar);	/* bottom left */
X	mvwaddch (win, trow-1,tcol-1, brchar);	/* bottom right */
X
X	/* draw vertical scroll bars */
X	if (vscroll)
X	{
X		/*
X		 *  Make sure we have a good percentage.  We'll bottom
X		 *  the elevator if the percentage is out of range.
X		 */
X		if ( percent < 0.0 || percent > 1.0 )	/* < 0 = no elevator */
X			percent = 1.0 ;			/* > 1 = undefined */
X		/*
X		 *  The weird calculation here is because I want to fit the
X		 *  elevator within the window top and bottom boundary.  And
X		 *  calculating the relative position for the *bottom* of
X		 *  the elevator.  If you still don't get it, don't ask!
X		 */
X		mvwaddch (win, frow+(int)((trow-frow-3)*percent)  ,tcol-1, '^');
X		mvwaddch (win, frow+(int)((trow-frow-3)*percent)+1,tcol-1, 'v');
X	}
X	if (help)
X	{
X		wattrset (win, A_STANDOUT);
X		if (isprint(KeyHelp))
X			mvwprintw (win, trow-1,tcol-6, "Help %c", KeyHelp);
X		else
X			mvwprintw (win, trow-1,tcol-7, "Help %c", KeyHelp);
X	}
X
X#ifdef BSD
X   	standend ();
X#else
X   	wattrset (win, A_NORMAL);
X#endif
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
echo "File utilities.d/libgeti.d/drawbox.c is complete"
chmod 0644 utilities.d/libgeti.d/drawbox.c || echo "restore of utilities.d/libgeti.d/drawbox.c fails"
echo "x - extracting utilities.d/libgeti.d/findfile.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/findfile.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X/* Function	findfile()
X**  		Search through a number of directories looking for a file
X**  RETURNS	a pointer to the file with the directory if found
X**		otherwise returns a null pointer.
X*/
X
X#include	<stdio.h>
X#include	<varargs.h>
X#include	<sys/types.h>
X#include	<sys/stat.h>
X
X/*VARARGS*/
Xchar *findfile (va_alist)
X	va_dcl
X{
X	va_list		ap;
X	char		*filename;
X	char		*directory;
X	static char	file[200];
X	char		*fileptr;
X	struct stat	buf;
X	int		rc;
X
X	va_start (ap);
X	fileptr = file;
X
X	/* get filename to search for */
X	if ((filename = va_arg (ap, char *)) == (char *)0)
X	{
X		va_end (ap);
X		return ((char *)0);
X	}
X
X	if (strcmp (filename, "") == 0)
X	{
X		va_end (ap);
X		return ("");
X	}
X
X	/* loop through each directory looking for file */
X	while (1)
X	{
X		directory = va_arg (ap, char *);
X		/* getenv() returns a null */
X		if (directory == (char *)0)
X			continue;
X		if (strcmp (directory, "") == 0)
X			break;
X		sprintf (file, "%s/%s", directory, filename);
X		if (stat (file, &buf) == 0)
X		{
X			va_end (ap);
X			return (fileptr);
X		}
X	}
X	va_end (ap);
X	return ("");
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/findfile.c || echo "restore of utilities.d/libgeti.d/findfile.c fails"
echo "x - extracting utilities.d/libgeti.d/getmmddyy.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/getmmddyy.c &&
X/*
X**  getmmddyy()
X**	Takes a string and a date mask as arguments and returns
X**	the month, day, year using the mask.
X*/
X
X
X#include <stdio.h>
X#include <time.h>
X#include "GetInput.h"
X
Xgetmmddyy (str, mask, month, day, year)
X	char	*str;
X	char	*mask;
X	int	*year, *month, *day;
X{
X	char		cmdstr[5] ;
X	static int	century = 0 ;
X	long		clock;
X
X	struct tm *localtime(), *Tm ;
X
X	if (century == 0) {
X
X		clock = time((long *) 0) ;
X		Tm = localtime (&clock) ;
X		century = 1900 ;
X		if (Tm->tm_year > 100)
X			century += (Tm->tm_year / 100) * 100 ;
X
X	}
X
X	if (mask == NULL) {
X
X		cmdstr[0] = *str++ ;
X		cmdstr[1] = *str++ ;
X		cmdstr[2] = '\0' ;
X		*month = atoi (cmdstr) ;
X
X		cmdstr[0] = *str++ ;
X		cmdstr[1] = *str++ ;
X		cmdstr[2] = '\0' ;
X		*day = atoi (cmdstr) ;
X
X		cmdstr[0] = *str++ ;
X		cmdstr[1] = *str++ ;
X		cmdstr[2] = '\0' ;
X		*year = atoi (cmdstr)  +  century ;
X
X	} else {
X
X		while ( *mask != '\0' ) {
X
X			while ( *mask != 'M' && *mask != 'D' && *mask != 'Y' )
X				mask++ ;
X
X			switch (*mask) {
X				case 'M':
X					cmdstr[0] = *str++ ;
X					cmdstr[1] = *str++ ;
X					cmdstr[2] = '\0' ;
X					*month = atoi (cmdstr) ;
X					mask += 2 ;
X					break ;
X				case 'D':
X					cmdstr[0] = *str++ ;
X					cmdstr[1] = *str++ ;
X					cmdstr[2] = '\0' ;
X					*day = atoi (cmdstr) ;
X					mask += 2 ;
X					break ;
X				case 'Y':
X					cmdstr[0] = *str++ ;
X					cmdstr[1] = *str++ ;
X					mask += 2 ;
X					if (*mask == 'Y') {
X						cmdstr[2] = *str++ ;
X						cmdstr[3] = *str++ ;
X						cmdstr[4] = '\0' ;
X						*year = atoi (cmdstr) ;
X						mask += 2 ;
X					} else {
X						cmdstr[2] = '\0' ;
X						*year = atoi (cmdstr) + century ;
X					}
X					break ;
X			}
X		}
X	}
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/getmmddyy.c || echo "restore of utilities.d/libgeti.d/getmmddyy.c fails"
echo "x - extracting utilities.d/libgeti.d/popmenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%    DeltaDate %G%    ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	<varargs.h>
X
X#define	MAXMENUS	10
X#define	MAXITEMS	200
X#define	NEWMENU		0
X#define	DIMWINDOW	-1
X#define	CREATEMENU	-2	/* only if it does not exist */
X#define WRAPAROUND	TRUE
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X
X#ifndef	KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_HELP
X#   define KEY_HELP	0553
X#endif
X#ifndef KEY_CANCEL
X#   define KEY_CANCEL	0543
X#endif
X#ifndef KEY_DOWN
X#   define KEY_DOWN	0402
X#endif
X#ifndef KEY_UP
X#   define KEY_UP	0403
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	565
X#endif
X
Xextern	int	KeyDown;
Xextern	int	KeyUp;
Xextern	int	KeyHelp;
Xextern	int	KeyCancel;
Xextern	int	KeyRedraw;
Xextern	int	KeyReturn;
Xextern	int	KeyBackspace;
Xextern	int	KeyIC;
X
Xtypedef struct	_menu
X{
X	int	MenuId;			/* numerical menu identifier */
X	int	row;
X	int	col;
X	char	*title ;		/* menu title */
X	char	*helpfile;		/* helpfile */
X	int	winSize ;		/* pop up window length */
X	WINDOW	*win;
X	int	NumItems;		/* number of items in menu */
X	int	width;			/* largest item */
X	char	*items[MAXITEMS+1];
X	int	ActiveItem;		/* last item selected */
X	int	FullMatch;		/* matching stype
X					   TRUE = full string matching
X					   FALSE = single 1st char matching */
X} MENU;
X
X
Xstatic MENU	*THEmenu[MAXMENUS+1];
Xstatic char	promptStr[80] ;
X
X/*VARARGS*/
Xpopmenu (va_alist)
X
X	va_dcl
X{
X	va_list		ap;
X	int		action;
X	int		MenuId;
X	static int	midx = -1;		/* defined menus */
X	char		*ws;			/* base address of table */
X	char		**wws;			/* base address of table */
X	int		wssize;			/* size of one element */
X						/*  or 0 if **wws is used */
X	register int	i, j;
X	int	rc;				/* return code */
X	int	idx;				/* tmp menu index */
X	int	NewMenu;			/* New Menu Flag */
X	static int	_runMenu();
X	char	*idontknow;			/* was a promptStr supplied */
X
X
X	va_start (ap);
X	action = va_arg (ap, int);
X
X	switch (action)
X	{
X	   /*
X	   **	Initialize a new popup menu
X	   */
X	   case NEWMENU:
X	   case CREATEMENU:
X		MenuId = va_arg (ap, int);
X
X		/* do we already have this MenuId */
X		NewMenu = TRUE;
X		for (i = 0; i <= midx; i++)
X			if (THEmenu[i]->MenuId == MenuId)
X			{
X				/* Menu already exists */
X				NewMenu = FALSE;
X				if (action == CREATEMENU)
X					break;	/* don't re-create it */
X
X				/* junk old menu */
X				delwin (THEmenu[i]->win);
X				free (THEmenu[i]);
X				idx = i;
X				break;
X			}
X		if (NewMenu == FALSE  && action == CREATEMENU)
X		{
X			va_end (ap);
X			break;
X		}
X		if (NewMenu == TRUE)
X			idx = ++midx;
X
X
X		/* build the new menu */
X		THEmenu[idx] = (MENU *)malloc (sizeof(MENU));
X		THEmenu[idx]->MenuId = MenuId;
X		THEmenu[idx]->row = va_arg (ap, int);	/* upper left corner */
X		THEmenu[idx]->col = va_arg (ap, int);
X		THEmenu[idx]->title = va_arg (ap, char *);
X		THEmenu[idx]->helpfile = va_arg (ap, char *);
X		if (THEmenu[idx]->helpfile != (char *)NULL  &&
X		    strcmp (THEmenu[idx]->helpfile, "") == 0)
X			THEmenu[idx]->helpfile = (char *)NULL;
X		THEmenu[idx]->winSize = va_arg (ap, int);
X		THEmenu[idx]->NumItems = 0;
X		THEmenu[idx]->width = strlen (THEmenu[idx]->title);
X		wssize = va_arg (ap, int);	/* size of one element */
X		/* for char array, ws is used, otherwise, wws is used for
X		** char *array.
X		*/
X		if ( wssize > 0 )
X		{
X			ws = va_arg (ap, char *);    /* base address of table */
X			while (*ws != NULL)
X			{
X				THEmenu[idx]->items[THEmenu[idx]->NumItems] = ws ;
X				THEmenu[idx]->NumItems++;
X				if (strlen(ws) > THEmenu[idx]->width)
X					THEmenu[idx]->width = strlen(ws);
X				ws += wssize ;
X			}
X		}
X		else		/* this is basically dup code as above */
X		{
X			wws = va_arg (ap, char **);  /* base address of table */
X			while (*wws != NULL)
X			{
X				THEmenu[idx]->items[THEmenu[idx]->NumItems] = *wws ;
X				THEmenu[idx]->NumItems++;
X				if (strlen(*wws) > THEmenu[idx]->width)
X					THEmenu[idx]->width = strlen(*wws);
X				wws++ ;
X			}
X		}
X		THEmenu[idx]->FullMatch = va_arg (ap, int); /* matching style */
X
X		/*
X		 * adjust length of popmenu
X		 */
X		if (THEmenu[idx]->winSize <= 0)		/* default length */
X			THEmenu[idx]->winSize = 6;
X		/* not enough items? */
X		if (THEmenu[idx]->winSize > THEmenu[idx]->NumItems ) 
X			THEmenu[idx]->winSize = THEmenu[idx]->NumItems ;
X		/* roll off bottom of screen? */
X		if ( THEmenu[idx]->winSize > LINES-THEmenu[idx]->row-2 ) 
X			THEmenu[idx]->winSize = LINES - THEmenu[idx]->row - 2 ;
X
X		/*
X		 * adjust the starting col of popmenu if the menu
X		 * will roll off the right edge of screen
X		 *      NOTE: col is 0 offset while width is not
X		 */
X		if ( THEmenu[idx]->col > COLS-THEmenu[idx]->width-4 )
X			THEmenu[idx]->col = COLS - THEmenu[idx]->width - 4 ;
X
X		va_end (ap);
X		THEmenu[idx]->ActiveItem = 1;
X
X		THEmenu[idx]->win = newwin (THEmenu[idx]->winSize+2, 
X				THEmenu[idx]->width+4,
X			        THEmenu[idx]->row, THEmenu[idx]->col);
X
X		keypad (THEmenu[idx]->win, TRUE);
X		rc = 0;			/* 0 return code */
X		break;
X
X	   case DIMWINDOW:
X		MenuId = va_arg (ap, int);
X		va_end (ap);
X
X		for (i = 0; i <= midx; i++)
X			if (THEmenu[i]->MenuId == MenuId)
X			{
X				drawbox( THEmenu[i]->win, 1, 1,
X					 THEmenu[i]->winSize+2,
X					 THEmenu[i]->width+4,
X					 SingleLine, DumbLine,
X					 (THEmenu[i]->winSize >= 4  &&
X					    THEmenu[i]->NumItems >
X					    THEmenu[i]->winSize),
X					 0,
X					 (float)-1 ) ;
X				mvwprintw (THEmenu[i]->win, 0, 
X					((THEmenu[i]->width+4-
X						strlen(THEmenu[i]->title))/2),
X				    	"%s", THEmenu[i]->title);
X				wrefresh (THEmenu[i]->win);
X				break;
X			}
X		break;
X
X	   default:
X		/*
X		**  Lets try to run a menu
X		*/
X		MenuId = action;
X
X		/* Find the menu. */
X		for (i = 0; i <= midx; i++)
X			if (MenuId == THEmenu[i]->MenuId)
X				break;
X		if (i > midx)   return (-1);	/* invalid MenuId */
X
X		/* get default search string? */
X		idontknow = va_arg( ap, char *);
X		if (idontknow && THEmenu[i]->FullMatch ) 
X		{
X			strncpy( promptStr, idontknow, THEmenu[i]->width ) ;
X			promptStr[THEmenu[i]->width] = NULL ;
X		}
X		else
X			promptStr[0] = NULL ;
X		va_end (ap);
X
X		rc = _runMenu (THEmenu[i]);
X
X		break;
X	} /* end switch (action) */
X	return (rc);
X}
X
X
X
X_runMenu (menu)
X
X	MENU	*menu;
X{
X	register int	ch;
X	register int	fptr;			/* field pointer */
X	register int	i;
X	register int	top;
X	register int	inc;
X	char	tmpStr[2] ;
X	register int	firstTime = TRUE ;
X
X	if ( ! menu->FullMatch )		/* turn off cursor? */
X		putp ( cursor_invisible ) ;
X	else
X		putp ( cursor_visible ) ;
X	inc = (int)( menu->winSize / 2 ) ;	/* window increment */
X	fptr = menu->ActiveItem;		/* set current item */
X	top = fptr - menu->winSize + 1 ;	/* set top item of window */
X	if ( top < 1 ) top = 1 ;		/* out of bound? */
X
X	_showWin( menu, top ) ;			/* Display the menu */
X
X	while (1)
X	{
X		wattrset (menu->win, A_REVERSE);
X		mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
X		wattrset (menu->win, A_NORMAL);
X		if ( strlen( promptStr ) )
X			wmove( menu->win, fptr-top+1, strlen( promptStr )+1 ) ;
X		else
X			wmove( menu->win, menu->winSize+1, menu->width+3 ) ;
X		touchwin (menu->win);
X		wrefresh (menu->win);
X
X		/*
X		 * The first time in, and if promptStr is filled
X		 * we'll extract the last char of promptStr, chop
X		 * promptStr by 1 char, so that that 1 char can
X		 * be strcat()ed back to promptStr later, and we also
X		 * skip the first wgetch().  This is to accomplish
X		 * the initial search when entering popmenu().
X		 */
X		if ( firstTime && strlen( promptStr ) )
X		{
X			ch = promptStr[ strlen( promptStr ) - 1 ] ;
X			promptStr[ strlen( promptStr ) - 1 ] = NULL ;
X		}
X		else
X			ch = wgetch (menu->win);
X		firstTime = FALSE ;
X
X		mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
X
X		if (ch == KeyReturn)   	ch = KEY_RETURN;
X		if (ch == KeyDown)   	ch = KEY_DOWN;
X		if (ch == KeyUp)   	ch = KEY_UP;
X		if (ch == KeyHelp)   	ch = KEY_HELP;
X		if (ch == KeyCancel)	ch = KEY_CANCEL;
X		if (ch == KeyRedraw)	ch = KEY_REFRESH;
X		if (ch == KeyBackspace)	ch = KEY_BACKSPACE;
X		if (ch == KeyIC)	ch = KEY_IC;
X
X		if ( ch >= 'a' && ch <= 'z' )
X			ch = toupper( ch ) ;	/* deals in upper case only */
X		switch ( ch )
X		{
X		   case KEY_DOWN:
X		   case KEY_RIGHT:
X		   	promptStr[0] = NULL ;
X			fptr = (fptr >= menu->NumItems) ? 1 : ++fptr;
X
X			/* stroll off window? */
X			if ( fptr-top+1 > menu->winSize || fptr == 1 )
X			{
X				if ( fptr == 1 )
X					top = 1 ;
X				else
X					top += inc ;
X				_showWin( menu, top ) ;
X			}
X			break;
X
X		   case KEY_UP:
X		   case KEY_LEFT:
X		   	promptStr[0] = NULL ;
X			wrefresh( menu->win ) ;
X			fptr = (fptr <= 1) ? menu->NumItems : --fptr;
X
X			/* stroll off window? */
X			if ( fptr == menu->NumItems || fptr < top )
X			{
X				if ( fptr == menu->NumItems && inc > 0 )
X					top = menu->NumItems - menu->winSize + 1 ;
X				else
X					top -= inc ;
X				if ( top < 1 ) top = 1 ;
X				_showWin( menu, top ) ;
X			}
X			break;
X
X		   case KEY_BACKSPACE:
X			if ( strlen( promptStr ) )
X				promptStr[ strlen( promptStr ) - 1 ] = NULL ;
X			break ;
X
X		   case KEY_IC:		/* toggle between full/1st match */
X			menu->FullMatch = !menu->FullMatch ;	/* XOR it */
X			promptStr[0] = NULL ;
X			wattrset (menu->win, A_STANDOUT);
X			mvwprintw( menu->win, menu->winSize+1, 0,
X				menu->FullMatch?"All":"1st" ) ;
X			wattrset (menu->win, A_NORMAL);
X			break ;
X
X		   case KEY_RETURN:
X		   case KEY_ENTER:
X			menu->ActiveItem = fptr;
X			wrefresh (menu->win);	/* force flush of attributes */
X			putp ( cursor_visible ) ;
X			return (menu->ActiveItem);
X
X		   case KEY_CANCEL:
X			putp ( cursor_visible ) ;
X			return (-1);
X
X		   case KEY_HELP:
X			ShowHelp (menu->helpfile, "popmenu", LINES);
X			break;
X
X		   case KEY_REFRESH:
X			clearok (menu->win, TRUE);
X			wrefresh (menu->win);
X			break;
X
X		   default:
X			/*
X			 * build the entered string
X			 */
X			if ( menu->FullMatch )
X			{
X				tmpStr[0] = ch ;
X				tmpStr[1] = NULL ;
X				strcat( promptStr, tmpStr ) ;
X			}
X
X			/*
X			 * Now do the matching, have fun
X			 */
X
X			/* look for first match from here on down */
X			for ( i=fptr+(menu->FullMatch?0:1);
X			      i<=menu->NumItems &&
X				( menu->FullMatch?
X					strnicmp( menu->items[i-1], promptStr,
X							strlen( promptStr ) ) :
X					toupper(*menu->items[i-1])!=ch ) ;
X				i++ ) ; 
X
X			/* no match?  how about from here on up? */
X			if ( i > menu->NumItems )
X			{
X				for ( i=1; i<fptr &&
X				    ( menu->FullMatch?
X					strnicmp( menu->items[i-1], promptStr,
X							strlen( promptStr ) ) :
X					toupper(*menu->items[i-1])!=ch ) ;
X				    i++ ) ; 
X
X				if ( fptr == i )	/* beep if no match */
X					beep() ;
X			}
X
X			if ( fptr != i )
X			{
X				wrefresh( menu->win ) ;	/* clear the hilite */
X				fptr = i ;
X			}
X
X			/*
X			 * insure we have a match, otherwise, discard last
X			 * char entered from promptStr
X			 */
X			if ( menu->FullMatch &&
X			     strnicmp( menu->items[fptr-1], promptStr,
X				strlen( promptStr ) ) &&
X			     strlen( promptStr ) > 0 )
X				promptStr[ strlen( promptStr ) - 1 ] = NULL ;
X
X			/* need to display a different window? */
X			if ( fptr >= top+menu->winSize || fptr < top )
X			{
X				top = fptr ;
X				_showWin( menu, top ) ;
X			}
X			break ;
X		}  /* end switch (ch) */
X	}
X}
X
X/* pjc 7/87 */
X
X_showWin( menu, top )
X	MENU	*menu ;
X	int	top ;
X{
X	register int	i ;
X
X	for (i=0; i < menu->winSize && top+i-1 < menu->NumItems; i++)
X		mvwprintw (menu->win, i+1, 2, "%-*s", menu->width, menu->items[top+i-1]);
X	for (; i < menu->winSize ; i++)
X		mvwprintw (menu->win, i+1, 2, "%*s", menu->width, " ");
X
X	drawbox( menu->win, 1, 1, menu->winSize+2, menu->width+4,
X			StandoutLine, StandoutLine,
X			(menu->winSize >= 4 && menu->NumItems > menu->winSize),
X			(menu->helpfile != (char *)NULL),
X			menu->NumItems ?
X			    (float)(top+menu->winSize-1) / (float)menu->NumItems
X					: 0 );
X
X	/* display title */
X	wattrset (menu->win, A_STANDOUT);
X	mvwprintw (menu->win, 0, ((menu->width+4)/2)-(strlen(menu->title)/2), 
X		"%s", menu->title);
X	wattrset (menu->win, A_NORMAL);
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/popmenu.c || echo "restore of utilities.d/libgeti.d/popmenu.c fails"
echo "x - extracting utilities.d/libgeti.d/stricmp.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/stricmp.c &&
X/* Like strcmp() [string(3C)] but ignore case */
X#define makelower(x)	(((x) >= 'A' && (x) <= 'Z') ? ((x) + ('a' - 'A')) : (x))
Xint
Xstricmp(s1, s2)
Xregister char *s1, *s2;
X{
X    register int difference;
X
X    if(s1 == s2)
X	return(0);
X
X    while((difference = (makelower(*s1) - makelower(*s2))) == 0) {
X	if(*s1 == '\0')
X	    return(0);
X	s1++;
X	s2++;
X    }
X
X    return(difference);
X}
X
X/* Like strncmp() [string(3C)] but ignore case */
Xint
Xstrnicmp(s1, s2, n)
Xregister char *s1, *s2;
Xregister unsigned n;
X{
X    register int difference;
X
X    if(s1 == s2 || n == 0)
X	return(0);
X
X    while((difference = (makelower(*s1) - makelower(*s2))) == 0) {
X	if(*s1 == '\0' || --n == 0)
X	    return(0);
X	s1++;
X	s2++;
X    }
X
X    return(difference);
X}
X
X
X#ifdef TESTMODE
X#include  <stdio.h>
Xmain()
X{
X    extern void exit();
X    char string[2][BUFSIZ], number[BUFSIZ];
X    int n;
X
X    while(1) {
X	fputs("Enter 1st string: ", stdout);
X	if(fgets(string[0], BUFSIZ, stdin) == NULL) {
X	    fputs("\nBye.\n", stdout);
X	    exit(0);
X	}
X	string[0][strlen(string[0])-1]='\0';
X	fputs("Enter 2nd string: ", stdout);
X	if(fgets(string[1], BUFSIZ, stdin) == NULL)
X	    *string[1]='\0';
X	else
X	    string[1][strlen(string[1])-1]='\0';
X	fputs("Enter number: ", stdout);
X	if(fgets(number, BUFSIZ, stdin) == NULL)
X	    n = 0;
X	else
X	    n = atoi(number);
X	printf("strcmp(%s,%s) = %d\n",
X	    string[0], string[1], strcmp(string[0], string[1]));
X	printf("stricmp(%s,%s) = %d\n",
X	    string[0], string[1], stricmp(string[0], string[1]));
X	printf("strncmp(%s,%s,%d) = %d\n",
X	    string[0], string[1], n, strncmp(string[0], string[1], n));
X	printf("strnicmp(%s,%s,%d) = %d\n",
X	    string[0], string[1], n, strnicmp(string[0], string[1], n));
X    }
X}
X#endif
X
X/*
X######################################################################
X# This is the confidential, unpublished property of  Pacific  Bell.  #
X# Receipt  or  possession  of  it  does  not  convey  any rights to  #
X# divulge, reproduce, use, or allow others to use  it  without  the  #
X# specific  written  authorization  of  Pacific  Bell  and use must  #
X# conform strictly  to  the  license  agreement  between  user  and  #
X# Pacific Bell.                                                      #
X#                       Copyright (C) 1988   Pacific Bell            #
X######################################################################
X*/
X#ifndef lint
Xstatic char sccsid[] = "@(#)stricmp.c	UCLID 1.1";
X#endif
SHAR_EOF
chmod 0666 utilities.d/libgeti.d/stricmp.c || echo "restore of utilities.d/libgeti.d/stricmp.c fails"
echo "x - extracting utilities.d/libgeti.d/substr.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/substr.c &&
X/*  E911 Project
X *  substr()
X *
X *  Purpose:	To find a substring within a given string
X *  Args:	s1: The string being searched
X *		s2: the string being searched for
X *  Return:	pointer to the where the searched for string resides
X *		within the search string; otherwise NULL
X */
X#ifndef lint
Xchar	Sccsid[] = "@(#)substr.c	1.3   6/17/88   10/13/88";
X#endif
X
X
Xchar *substr(s1, s2)
X	char	*s1;
X	char	*s2;
X{
X	char	*p1, *p2;
X
X	for ( ; *s1; s1++) {
X		if (*s1 != *s2)
X			continue;
X		p1 = s1 + 1;
X		p2 = s2 + 1;
X		while (1) {
X			if (*p2 == '\0')
X				return(s1);
X			if (*p1++ != *p2++)
X				break;
X		}
X	}
X	return((char *)0);
X}
X
X
X#ifdef LTEST
Xmain()
X{
X	char	*strtok();
X
X	char	*s1, *s2, *s3;
X	char	buffer[256];
X
X	printf("ok\n");
X	while (gets(buffer)) {
X		s1 = strtok(buffer, " \t:\n");
X		s2 = strtok(0, " \t:\n");
X		printf("%s:%s:", s1, s2);
X		if (s1 && s2)
X			if (s3 = substr(s1, s2))
X				printf("%.*s\n", strlen(s2), s3);
X			else
X				printf("no match\n");
X		else
X			printf("invalid input\n");
X	}
X}
X#endif
X
X
SHAR_EOF
chmod 0666 utilities.d/libgeti.d/substr.c || echo "restore of utilities.d/libgeti.d/substr.c fails"
echo "x - extracting utilities.d/libgeti.d/upper.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/upper.c &&
Xchar *upper (s)
X
X	char		*s;
X{
X	register int	i;
X	static char	*ws;
X
X   ws = s;
X   while (*s)
X   {
X      if (*s >= 'a'  &&  *s <= 'z')
X         *s = (*s + 'A' - 'a');
X      s++;
X   }
X   return (ws);
X}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/upper.c || echo "restore of utilities.d/libgeti.d/upper.c fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.h &&
X#ifndef LINT
Xstatic char ID_GetInput[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#define	HOLIDAY_FILE	"/usr/lib/acct/holidays"
X
X
X/*
X**	Type of allowable characters
X*/
X
X#define	ALPHANUM	' '
X#define	ALPHA		'A'
X#define	NUMERIC		'9'
X#define	SET		'E'
X#define	MENU		'M'
X#define	UPPER		'U'
X#define	UPPER_AN	'V'
X#define	HEX		'H'
X#define	STATE		'S'
X#define	ZIP		'Z'
X#define	DATE		'D'
X#define	TIME		'T'
X#define	PROTECT		'P'
X
X/*
X**	Adjust/Fill
X*/
X
X#define	NOFILL		' '
X#define	RTADJ_ZFILL	'Z'
X#define	RTADJ_BFILL	'B'
X#define	LFADJ_ZFILL	'z'
X#define	LFADJ_BFILL	'b'
X
X/*
X**	'C' field types
X*/
X
X#define CHAR		'0'
X#define INT		'1'
X#define SHORT		'2'
X#define LONG		'3'
X#define DOUBLE		'4'
X#define MONEY		'M'
X#define FLOAT		'5'
X
X/*
X**	Union to take care of a field that could be any valid
X**		'c' field type.
X*/
X
Xtypedef union FldUnion {
X	long	*longVal ;
X	double	*doubleVal ;
X	float	*floatVal ;
X	int	*intVal ;
X	short	*shortVal ;
X	char	*strVal ;
X} *FldUnPointer ;
X
X
X#define AUTONEXT	TRUE
X#define NOAUTO		FALSE
X
X#define MUSTENTER	TRUE
X#define NOMUST		FALSE
X
X#define NOHELP		""
X#define NORANGE		NULL
X#define NOMSG		NULL
X#define NOMASK		NULL
X#define NOTAG		""
X#define	A_SAME		-1		/* same as what's on the screen */
X
X
X#ifndef KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_BEG
X#   define KEY_BEG	0542
X#endif
X#ifndef KEY_END
X#   define KEY_END	0550
X#endif
X#ifndef	KEY_SAVE
X#   define KEY_SAVE	0571
X#endif
X#ifndef	KEY_PRINT
X#   define KEY_PRINT 	0532
X#endif
X#ifndef	KEY_HELP
X#   define KEY_HELP 	0553
X#endif
X#ifndef	KEY_REFRESH
X#   define KEY_REFRESH 	0565
X#endif
X#ifndef	KEY_TAB
X#   define KEY_TAB 	'\t'
X#endif
X#ifndef	KEY_BTAB
X#   define KEY_BTAB 	0541
X#endif
X#ifndef	KEY_CANCEL
X#   define KEY_CANCEL 	0543
X#endif
X#ifndef	KEY_ACCEPT
X#   define KEY_ACCEPT 	1000
X#endif
X#ifndef	KEY_TOC
X#   define KEY_TOC 	1001
X#endif
X
X#define NOKEY		'\0'
X#define KEY_CTLA	'\001'
X#define KEY_CTLB	'\002'
X#define KEY_CTLC	'\003'
X#define KEY_CTLD	'\004'
X#define KEY_CTLE	'\005'
X#define KEY_CTLF	'\006'
X#define KEY_CTLG	'\007'
X#define KEY_CTLH	'\010'
X#define KEY_CTLI	'\011'
X#define KEY_CTLJ	'\012'
X#define KEY_CTLK	'\013'
X#define KEY_CTLL	'\014'
X#define KEY_CTLM	'\015'
X#define KEY_CTLN	'\016'
X#define KEY_CTLO	'\017'
X#define KEY_CTLP	'\020'
X#define KEY_CTLQ	'\021'
X#define KEY_CTLR	'\022'
X#define KEY_CTLS	'\023'
X#define KEY_CTLT	'\024'
X#define KEY_CTLU	'\025'
X#define KEY_CTLV	'\026'
X#define KEY_CTLW	'\027'
X#define KEY_CTLX	'\030'
X#define KEY_CTLY	'\031'
X#define KEY_CTLZ	'\032'
X
X/*
X**  Macros
X*/
X#define wattrOn(a, b)	wattrset(a, b)
X#define wattrOff(a)	wattrset(a, 0)
X#ifndef BELL
X#define	BELL	printf ("%c", 7)
X#endif
X
X#define	CLEARROW(row)	{ \
X				int	col; \
X				int	tmprow; \
X				tmprow = ((row%100) == row) ? row : row/100; \
X				col = ((row%100) == row) ? 0 : row%100; \
X				for (; col<=COLS-2; col++) \
X					mvwaddch (stdscr, tmprow,col, ' '); \
X			}
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/GetInput.h || echo "restore of utilities.d/libgeti.d/GetInput.h fails"
echo "x - extracting utilities.d/libgeti.d/keys.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/keys.h &&
X#ifndef LINT
Xstatic char ID_keys[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
Xextern int	KeyReturn;
Xextern int  	KeyDown;
Xextern int  	KeyUp;
Xextern int  	KeyTab;
Xextern int  	KeyBTab;
Xextern int  	KeyAccept;
X
Xextern int  	KeyBeg;
Xextern int  	KeyEnd;
Xextern int  	KeyRight;
Xextern int  	KeyLeft;
Xextern int  	KeyBackspace;
Xextern int  	KeyEOL;
Xextern int  	KeyDL;
Xextern int  	KeyDC;
Xextern int  	KeyIC;
X
Xextern int  	KeyHelp;
Xextern int  	KeyTOC;
Xextern int  	KeyRedraw;
Xextern int  	KeySave;
Xextern int  	KeyPrint;
Xextern int  	KeyCancel;
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/keys.h || echo "restore of utilities.d/libgeti.d/keys.h fails"
echo "x - extracting utilities.d/libgeti.d/makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/makefile &&
X# %W%   DeltaDate %G%   ExtrDate %H%
X
XTITLE = GETINPUT
X
XINSTALLLIB 	= 
XINSTALLHDR	=
XMANDIR 		= .
X
X###  CFLAG settings
X
X###  Sys5
XCFLAGS = -O
X###  Xenix
X#CFLAGS = -O -DM_TERMINFO -LARGE -Ml -Mlt34 -F 4000
X
XARFLAGS = rv
X
XLIBS = libgeti.a -lcurses -lc
X
X
XCFILES = AdjField.c DateFun.c DisPrmpt.c FindSet.c GetSetLen.c \
X	GetInput.c IsDate.c IsFldOk.c IsMask.c IsRange.c IsState.c IsTime.c \
X	ReDispFld.c ScrnOut.c ShowChar.c ShowSet.c ShowHelp.c \
X	popmenu.c BuildMenu.c checkmask.c doinsert.c InitGetI.c drawbox.c \
X	RingMenu.c findfile.c getmmddyy.c substr.c upper.c stricmp.c
X
XHFILES = GetInput.h keys.h
XMANPAGES = GetInput.3X popmenu.3 drawbox.3 ShowHelp.3
X
XOBJECTS =${CFILES:.c=.o}
X
Xinstall : libgeti.a
X	-ln libgeti.a ../../libgeti.a
X	-ln GetInput.h ../../GetInput.h
X
Xtest : libgeti.a _Main.o
X	$(CC) $(CFLAGS) _Main.o $(LIBS) -o test.out
X
Xlibgeti.a : $(OBJECTS)
X	ar $(ARFLAGS) libgeti.a $?
X
Xlint:
X	lint -I$(INCDIR) _Main.c $(CFILES) -lcurses > lint.out
X
Xprint :
X	PrintPrg $(MANPAGES) makefile $(CFILES) $(HFILES) _Main.c | lp -t$(TITLE)
X
Xshar:
X	shar -b GetInput.hlp $(MANPAGES) makefile $(CFILES) $(HFILES) _Main.c > libgeti.shar
X
Xclean :
X	rm -f *.o core libgeti.a test.out lint.out libgeti.shar \
X	../../libgeti.a ../../GetInput.h libgeti.shar.Z
X
X#####
X#####
X
X_Main.o:	_Main.c GetInput.h keys.h
XAdjField.o:	AdjField.c GetInput.h
XDisPrmpt.o:	DisPrmpt.c GetInput.h
XFindSet.o:	FindSet.c GetInput.h
XGetSetLen.o:	GetSetLen.c GetInput.h
XGetInput.o:	GetInput.c GetInput.h keys.h
XIsDate.o:	IsDate.c GetInput.h
XIsFldOk.o:	IsFldOk.c GetInput.h
XIsMask.o:	IsMask.c GetInput.h
XIsRange.o:	IsRange.c GetInput.h
XIsTime.o:	IsTime.c GetInput.h
XReDispFld.o:	ReDispFld.c GetInput.h
XScrnOut.o:	ScrnOut.c GetInput.h
XShowChar.o:	ShowChar.c GetInput.h
XShowSet.o:	ShowSet.c GetInput.h
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/makefile || echo "restore of utilities.d/libgeti.d/makefile fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.3X (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.3X &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.TH GETINPUT 3X "libgeti"
X.SH NAME
XGetInput \- manages terminal input using curses
X.SH SYNOPSIS
X.LP
X.nf
X#include <curses.h>
X#include "GetInput.h"
X
Xint GetInput (win, row, col, &Fld, FldAttribute, FldMask,
X              FldRange, FldLength, FldMin, FldCharType, 
X              FldAdjust, FldType, FldExit, MustEnter, 
X              ErrRow, MsgRow, PromptMsg, HelpFile, HelpTag)
X
XWINDOW        *win;
Xint           row, col, FldAttrbute, FldLength, FldMin, 
X              FldExit, MustEnter, ErrRow, MsgRow;
XFldUnPointer  Fld;
Xchar          *FldMask, *FldRange, FldCharType, FldAdjust, 
X              FldType, *PromptMsg, HelpFile[], HelpTag[];
X.fi
X.SH DESCRIPTION
XGets terminal input using curses(3X). 
XGetInput uses a field by field approach.  All
Xedits and processing are performed for that field as the user
Xmoves from field to field.  It is not a fill form methodology where
Xall edits and processing are performed after the user has inputed
Xa number of fields in a form.
X
X.SH GETTING STARTED
XYou need to include GetInput.h in your program.
X
XCurses tty modes should be - cbreak(), noecho(), nonl() and
Xkeypad () if you want to use arrow keys and the like.
X
XYou should trap and ignore SIGALRM (see BUGS).
X
X.SS Defining Keyboard Keys
XGetInput uses a number of keyboard keys to tell it what to do.
XA default value to the various keys is automatically assigned when you use
Xthis library.  Those default values may be changed by declaring the variable
Xas extern in your program and assigning a new value.
XIn addition to the default variable values, if the terminal
Xhas an associated curses key defined (see curses.h) that key may also be used.
XFor example, ^b (KeyBeg) is the default value to place cursor at beginning 
Xof a field but if there is a key defined for KEY_BEG, in curses, then that
Xkey may also be used.  If the value of KeyBeg and KEY_BEG are different, 
XGetInput will return the value of KEY_BEG not KeyBeg regardless of which 
Xone is pressed.
XNot all keys may have an associated curses key.
XThe "^" indicates press and hold the control key.  A negative one disables
Xthe key, although the associated curses key is still active.
X.br
XBelow is listed the InitGetI() function with the default value and the
Xassociated curses key.
X.nf
X
X/*
X**  InitGetI()
X**	Used in GetInput(3) and assign some default values.
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X
X				/* ACCEPT INPUT KEYS */
X				/* These are the only keys that will return the data inputted into your variable. */
Xint	KeyReturn = '\\r';		/* ^m  KEY_RETURN */
Xint	KeyDown = 10;		/* ^j  KEY_DOWN */
Xint	KeyUp = 11;		/* ^k  KEY_UP */
Xint	KeyTab = '\\t';		/* ^i  KEY_TAB */
Xint	KeyBTab = -1;		/*     KEY_BTAB */
Xint	KeyAccept = 1;		/* ^a  KEY_ACCEPT - Typically this is the key the user presses
X				             to signify he/she is finished with this screen. */
X
X				/* FIELD EDITING KEYS */
Xint	KeyBeg = 2;		/* ^b  KEY_BEG - Place cursor at beginning of field */
Xint	KeyEnd = 5;		/* ^e  KEY_END - Place cursor at end of input in field */
Xint  	KeyRight = 12;		/* ^l  KEY_RIGHT - Forward space in field */
Xint  	KeyLeft = 8;		/* ^h  KEY_LEFT - Backspace in field (non-destructive) */
Xint  	KeyBackspace = '\\b';	/* \\b  KEY_BACKSPACE - Same as KEY_LEFT */
Xint  	KeyEOL = 4;		/* ^d  KEY_EOL - Delete from cursor to end of field */
Xint  	KeyDL = 3;		/* ^c  KEY_DL - Clear field and home cursor */
Xint  	KeyDC = 24;		/* ^x  KEY_DC - Delete a character */
Xint  	KeyIC = 20;		/* ^t  KEY_IC - Toggle between type-over and insert mode */
X
X				/* OTHER KEYS */
Xint  	KeyRedraw = 18;		/* ^r  KEY_REFRESH - Redraw screen */
Xint  	KeySave = 6;		/* ^f  KEY_SAVE - Save screen to a file */
Xint  	KeyPrint = 16;		/* ^p  KEY_PRINT - Print screen to lp */
Xint  	KeyCancel = 27;		/* esc KEY_CANCEL - Cancel pop-up menu selection */
Xint  	KeyHelp = '?';		/*     KEY_HELP - Display help screen */
X				/*        If the user needs to input a "?" you will have to change this. */
Xint  	KeyTOC = 20;		/* ^t  KEY_TOC  - When in help display Table of Contents */
X
Xvoid
XInitGetI()
X{
X	/*
X	**  This function sets values for keys used in GetInput.  The default
X	**  values above may be changed by specifying a new value in a
X	**  file called ".menuinit".  See menu(1) for more info.
X	*/
X}
X.fi
X
X.SH ARGUMENT DESCRIPTION
X.TP 6
X*win
XA pointer to a curses window that this routine will operate under.
X.TP 
Xrow
XThe row to position cursor on.
X.TP 
Xcol
XThe starting column for field.
X.TP
X&Fld		
XA pointer to a union variable where you have loaded the
Xaddress of your memory variable to accept the input data.  Upon
Xentry to GetInput the value in your memory variable will be
Xdisplayed as the default value.  The type of union you select must be compatible
Xwith the \fIFldType\fP you've specified.
X
X.nf
XFor example:
X	union FldUnion	Fld;
X	double		myvar;
X
X	Fld.doubleVal = &myvar;
X	GetInput (......);
X
X	/*
X	**  After returning from GetInput() what the user typed in will
X	**  be in \fImyvar\fP;
X	*/
X
X
X
X/*
X**     Structure of Union
X*/
Xtypedef union FldUnion
X{
X	long    *longVal;
X	double  *doubleVal;
X	float   *floatVal;
X	int     *intVal;
X	short   *shortVal;
X	char    *strVal;
X} *FldUnPointer;
X.fi
X.TP
XFldAttrbute	
XCurses attribute you want your input field to be.  For
Xexample A_REVERSE.  Refer to curses(3X) for further
Xinformation on allowable terminal attributes.
X.br
XA_SAME  is a special attribute that tells GetInput to use
Xthe same attributes that is already on the screen in the
Xfirst column of the field.
X
X. \ **********************************
X.TP
XFldMask
XA char pointer to a mask for the field.  This permits the user to mix 
Xalpha with numeric while letting GetInput do the edit checking.  You can also
Xuse this to format a field.
X
XThe keyword \fBNOMASK\fP may be placed here if no mask is required.
X
XValid masks for a field depend upon the type of field
Xyou specify, see \fIFldCharType\fP.
X
XThe \fIFldLength\fP should not include character positions where no input
Xis allowed in the mask (format characters), because format characters
Xare not returned into \fIFld\fP.  For example, \fIFldCharType = DATE,
XFldMask = "MM/DD/YY"\fP.  The "/" is a format character.  The cursor
Xwill skip over those positions in the field.  Only the characters typed in
Xthe MM DD YY positions will be in your memory variable \fIFld\fP.
XThe FldLength would be six for this case.
X
XBecause the mask is so closely tied to the \fIFldCharType\fP, a complete
Xdescription of what mask characters are valid with what field types is 
Xdescribed under
X\fIFldCharType\fP.  Any character in the mask that is not listed as a valid
Xmask character for that field type becomes a format character.
X. \ **********************************
X.TP
XFldRange
XA char pointer to a set of valid ranges permitted for this field. 
XRanges may be specified as comma separated values ("ONE,TWO,THREE") 
Xor as a inclusive range ("1-5"), or a combination of both ("1-5,M,E").
XRange values must be compatible with the \fIFldCharType\fP and \fIFldType\fP 
Xthat you 
Xhave selected.
X.br
XSome examples:
X.nf
X	"1-10"
X	"5,10,15,16"
X	"1-10,20,M,E,32-40"
X	"CA,TX,ID"
X.fi
X
XThe keyword \fBNORANGE\fP may be used if no range checking is to be 
Xperformed for this field.
X. \ **********************************
X.TP
XFldLength
XMaximum length of this field.  For field types (FldCharTypes) SET and MENU 
Xthe field length is automatically set to the longest set value in the FldRange.
X. \ **********************************
X.TP
XFldMin
XIf \fIMUSTENTER\fP is selected in \fIFldExit\fP then this is the minimum
Xrequired input.  Otherwise, it is the minimum required input only if they try 
Xto input something.
X. \ **********************************
X.TP
XFldCharType
XThis argument defines edit checks to be performed on the
Xinput characters as they are being typed in.  If no mask is provided then
Xthe field type itself determines the edit checks to be performed on all
Xcharacters in the field.
X.RS 6
X.TP 11
XALPHANUM
XAny alpha/numeric character is allowed.
X.br
XValid mask characters:
X.nf
X	space	alpha/numeric
X	A	alpha
X	9	numeric
X	U	upper alpha
X	V	upper alpha/numeric
X	H	???
X.fi
X.TP
XALPHA
XAlpha only.
X.br
XValid mask characters:
X.nf
X	A	alpha
X.fi
X.TP
XNUMERIC
XNumeric only.
X.br
XValid mask characters:
X.nf
X	9	numeric
X.fi
X.TP
XUPPER
XConvert to upper case.  Only alpha permitted.
X.br
XValid mask characters:
X.nf
X	U	upper alpha
X.fi
X.TP
XUPPER_AN
XAlpha and numeric permitted.  Convert alpha characters to upper-case.
X.br
XValid mask characters:
X.nf
X	V	upper alpha/numeric
X.fi
X.TP
XHEX
XOnly hex characters permitted.
X.br
XValid mask characters:
X.nf
X	H	???
X	space	???
X.fi
X.TP
XSTATE
XValid two character Post Office abbreviations for the fifty states.
XA edit check is done for a valid state.
X.br
XValid mask characters:
X.nf
X	SS	two character state
X	S	???
X	space	???
X.fi
X.TP
XZIP
XPost Office zip code.
X.br
XValid mask characters:
X.nf
X	99999-9999	???
X.fi
X.TP
XDATE
XA valid date.
X.br
XValid mask characters:
X.nf
X	MM	month  (01-12)
X	DD	day  (01-31)
X	YY	year  (00-99)
X	YYYY	full year with century
X.fi
XThe mask must contain at least MM and DD.  If no mask is specified for the
Xfield a default mask of "MMDDYY" is used.
X.br
XSome examples:
X.nf
X	MMDDYY
X	MM/DD/YY
X	YY-MM-DD
X	MM  DD  YYYY
X.fi
X
XThe \fIFldRange\fP argument may contain any of the following keywords
X(case insensitive)
Xand the appropriate edit will be performed (see \fIfield_range\fP for more
Xinfo).
X.nf
X	sun,mon,tue,wed,thr,fri,sat	- validate date entered against day of week
X	No_Holidays		- no holidays allowed.  
SHAR_EOF
echo "End of part 11"
echo "File utilities.d/libgeti.d/GetInput.3X is continued in part 12"
echo "12" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 12 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/GetInput.3X continued
#
CurArch=12
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.3X"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/GetInput.3X
X				This is validated against the file /usr/lib/acct/holidays by default.  Modify GetInput.h to change default.
X	GT_Today		- date must be greater than todays date.
X	GE_Today		- greater than or equal to todays date.
X	LT_Today		- less than todays date.
X	LE_Today		- less than or equal to todays date.
X.fi
X.TP
XTIME
XA time field.
X.br
XValid mask characters:
X.nf
X	HH	hours  (01-12)
X	MM	minutes  (00-59)
X	SS	seconds  (00-59)
X	TT	tenths  (00-99)
X	II	military hours  (00-24)
X.fi
XSome examples:
X.nf
X	HH:MM
X	HH:MM:SS
X	HH:MM:SS:TT
X	II:MM
X	II:MM:SS
X	II:MM:SS:TT
X.fi
X.TP
XSET
XThis field type specifies a set of values that are acceptable in the input 
Xfield.
XThe acceptable values within the set are specified in the \fIFldRange\fP 
Xargument.  
XThe user selects one of the set values specified in the field range by
Xpressing the space bar, which will toggle through the set values,
Xor by pressing the first character in the desired value.
X
XThe format of the FldRange can only be comma separated values 
X(ex. "CA,ID,TX").  
XRange values, such as "1-5", don't work.  You would have to say "1,2,3,4,5".
X.br
XThe FldLength is automatically set to the longest set value in the FldRange.
X.TP
XMENU
XThis field type is similar to the SET type.  The difference is when the user
Xattempts to type something in the field a pop-up menu of available choices
Xare displyed, as specified in field_range.  
XThe user makes a selection by hi-lighting the choice and pressing return.
X.br
XSee SET type for specifying the FldRange.
XThe limit is ten items in the FldRange.
X.TP
XPROTECT
XThis X's out the field so what is typed on the keyboard can not be seen on
Xthe screen.  Useful for password entry.
X.RE
X. \ ---------------------------------
X.TP
XFldAdjust
XIndicates whether to adjust the text right or left within the field
Xand whether or not to zero or blank fill the field.
X.RS 6
X.TP 15
XNOFILL
Xno action.
X.TP
XRTADJ_ZFILL
Xright adjust, zero fill
X.TP
XRTADJ_BFILL
Xright adjust, blank fill
X.TP
XLFADJ_ZFILL
Xleft adjust, zero fill
X.TP
XLFADJ_BFILL
Xleft adjust, blank fill
X.RE
X. \ ---------------------------------
X.TP 6
XFldType
XThis argument describes the memory variable that is to hold
Xthe input data.  The address that you loaded into "&Fld".
X.RS 6
X.TP 10
XCHAR
Xcharacter field
X.TP
XINT
Xinteger
X.TP
XSHORT
Xshort integer
X.TP
XLONG
Xlong integer
X.TP
XDOUBLE
Xdouble
X.TP
XFLOAT
Xfloating point
X.TP
XMONEY
Xdouble which accepts only two decimal positions.
X.RE
X. \ ---------------------------------
X.TP 11
XFldExit
X.RS 6
X.TP 10
XAUTONEXT
XGetInput() will exit, with the value of KEY_RETURN, when the last character 
Xin the field is keyed in.
X.TP
XNOAUTO
XWill not exit field until a accept key (see defining keyboard keys) is pressed.
X.RE
X. \ ---------------------------------
X.TP
XMustEnter
X.RS 6
X.TP 12
XMUSTENTER
XThis is a must enter field and the value of FldMin must be
Xentered before exiting field.
X.TP
XNOMUST
XNot a must enter field.
X.RE
X. \ ---------------------------------
X.RE
X.TP 6
XErrRow
XIndicates what row/column to display an error message if one occurs.
XThe row specified is for stdscr.
XIf a optional column is to be specified on where to start the message, the
Xformat would be for example 2302 where 23 is the row and 02 is the column.
XOtherwise, a default of column zero is used.
XGetInput will do a clrtoeol() before displaying the error message, therefore,
Xthe entire row must be given over to GetInput.
XIf this row is outside the boundary of the window unpredictable results will
Xoccur, for example, winch() will return garbage.
X.TP
XMsgRow
XIndicates what row to display help messages.
XThe row specified is for stdscr.
XIf a optional column is to be specified on where to start the message, the
Xformat would be for example 2202 where 22 is the row and 02 is the column.
XOtherwise, a default of column zero is used.
XGetInput will do a clrtoeol() before displaying the message, therefore,
Xthe entire row must be given over to GetInput.
XIf this row is outside the boundary of the window unpredictable results will
Xoccur, for example, winch() will return garbage.
X.RS 6
X.TP 10
XNULL
XNo active message line.  Only if PromptMsg == NOMSG.
X.RE
X.TP
X*PromptMsg
XPrompt message to be displayed.  The prompt message is always displayed
Xto stdscr, regardless of the win specified.
X.RS 6
X.TP 10
XNOMSG
XNo message to be displayed.
X.RE
X.TP
XHelpFile
XFile name containing on-line help messages.  Current directory
Xis searched first for helpfile and then getenv("HELPDIR") directory is
Xsearched.
X.RS 6
X.TP 10
XNOHELP
XNo help file is available for this field.
X
X.PP
XThe default helpfile (GetInput.hlp) is shown below.  Where this file is
Xinstalled will vary from machine to machine.
X
X.nf
X\fBGETINPUT\fP
X .TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X        KEY_DOWN  (^j)      Traverse forwards through the fields.
X        KEY_UP  (^k)        Traverse backwards through the fields.
X        KEY_TAB  (^i)       Fast forward through the fields.
X        KEY_BTAB            Fast reverse through the fields.
XField Editing Keys:
X        KEY_BEG  (^b)       Place cursor at beginning of field.
X        KEY_END  (^e)       Place cursor at end of input in field.
X        KEY_RIGHT  (^l)     Forward space within the field.
X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
X        KEY_EOL  (^d)       Delete from cursor to end of field.
X        KEY_DL  (^c)        Clear field and home cursor.
X        KEY_DC  (^x)        Delete a character.
X        KEY_IC  (^t)        Toggle between type-over and insert mode.
XOther Keys:
X        KEY_HELP  (?)       Display help screen.
X        KEY_REFRESH  (^r)   Redraw the screen.
X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
X        KEY_SAVE  (^f)      Save screen to a file.
X        KEY_PRINT  (^p)     Print screen to lp.
X\fBGETINPUT\fP
X
X
X
X\fBpopmenu\fP
X.TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    To select an option press the "up arrow key",
X    "k", "down arrow key", "j" to place bar on
X    option and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
X\fBpopmenu\fP
X
X
X
X\fBhelp\fP
X.TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
X        KEY_TOC  (^t)       Display table of contents.
X\fBhelp\fP
X.fi
X.RE
X.TP
XHelpTag
XTag in help file where messages are to be found.  The tag 
Xsurrounds the help message.  For example:
X.nf
X
Xhelptag
X[ .TITLE  Title line goes here. ]
XI put any help message for the user between the tags.  
XIt can be any length as it will be displayed one screen 
Xat a time.
XThe following screen attributes may be used:
X\\S  =  Standout
X\\B  =  Bold
X\\U  =  Underline
X\\D  =  Dim
X\\R  =  Reverse video
X\\L  =  Blink
X\\N  =  Normal (reset)
X
X\\BThis text is in bold face.  \\NBack in normal mode.
Xhelptag
X
XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
Xis to be contained in the table of contents menu.  The following is the
Xsyntax for this tagname.
XTABLE_OF_CONTENTS
Xhelpfile   tagname   description
XTABLE_OF_CONTENTS
X.fi
X.RS 6
X.TP 10
XNOTAG
XNo tag.  Should only be used if (HelpFile == NOHELP).
X.RE
X.SH EXAMPLE
X.nf
X#include <curses.h>
X#include "GetInput.h"
X
Xmain ()
X{
X	union FldUnion Fld;
X	char	name[20], tempstring[50];
X	int	exitcode;
X
X   initscr ();
X   cbreak ();
X   noecho ();
X   nonl ();
X   keypad (stdscr, TRUE);
X
X   name[0] = '\\0';
X   Fld.strVal = name;
X   exitcode = GetInput (stdscr, 2, 0, &Fld, A_REVERSE, NOMASK, 
X                  NORANGE, 20, 0, UPPER_AN, NOFILL, CHAR, 
X                  NOAUTO, MUSTENTER, 21, 20, 
X                  "Please enter your name.", NOHELP, NOTAG);
X
X   Fld.strVal = tempstring;
X   exitcode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "HH:MM:SS:TT",
X                  NORANGE, 6, 6, TIME, NOFILL, CHAR, AUTONEXT, 
X                  NOMUST, 20, 21, "Time Field HH:MM:SS:TT", 
X                  "myhelpfile", "field2");
X
X   Fld.strVal = tempstring;
X   exitcode = GetInput (stdscr, 8, 0, &Fld, A_NORMAL, 
X                  "(999) 999-9999", NORANGE, 10, 5, NUMERIC, 
X                  RTADJ_ZFILL, CHAR, NOAUTO, MUSTENTER, 20, NULL, 
X                  NOMSG, NOHELP, NOTAG);
X
X   Fld.strVal = tempstring;
X   exitcode = GetInput (stdscr, 9, 1, &Fld, A_REVERSE, NOMASK,
X                  "CA, NV, ID", 2, 2, SET, NOFILL, CHAR, NOAUTO,
X                  NOMUST, 20, 20, "Select your state.", NOHELP, 
X                  NOTAG);
X   endwin ();
X}
X.fi
X.SH AUTHOR
XIrving Griesman  (original author)
X.br
XEnhanced & Maintained by Paul J. Condie
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
X.SH FILES
XGetInput.hlp	- default GetInput help file.
X
X.SH DIAGNOSTICS
XGetInput returns the the decimal value of the key pressed from the getch()
Xfunction.  If the key pressed has an associated curses key GetInput returns
Xthe value of the curses key.  See Defining keyboard keys.
X
X.SH SEE ALSO
Xmenu(1), curses(3X), popmenu(3).
X
X.SH WARNING
XPutting a field on the same row as your message row or error row may cause
Xunpredictable results.  This is not recommended.
X
X.SH BUGS
XThere is a bug in curses when you call getch() which this routine does.
XWhen in keypad() mode and an ESC character is read, curses 
Xdoes a timed read (1 second) waiting for other characters to appear.  if
Xsome other characters are received within the one second time interval,
Xcurses attempts to match the received string with a caps string defined for the terminal (i.e. ESC[A, ESC[B are arrow keys for a vt100 type terminal)
Xand then returns a #defined int value which can be tested for easily.
XIn some cases untrapped alarm calls occur.  The solution is to trap (ignore)
Xalarm calls.
X.PP
XOn a mustenter field with a fldmin specified a control key (i.e. KEY_DOWN, etc.)
Xwill exit the
Xfield if that is the first key the user presses.  Once the user has tried
Xto input a value in the field even if he clears the field the control key
Xwill not exit until fldmin is inputed.
X
X.nf
XThe following example does not turn the reverse video off when you leave the field on the sun.
Xrc = GetInput (stdscr, 0, 1, &Fld, A_REVERSE, "VVVVVV.VVVVV.VV.VV.V", 
X	NORANGE, 16, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, MUSTENTER, 
X	ERRROW, MSGROW, "Please enter niu location.", "cfgsrn.hlp", NOTAG);
X.fi
X
X.PP
XA core dump of (DisPrmpt at line 37) indicates the string was not null terminated.
SHAR_EOF
echo "File utilities.d/libgeti.d/GetInput.3X is complete"
chmod 0644 utilities.d/libgeti.d/GetInput.3X || echo "restore of utilities.d/libgeti.d/GetInput.3X fails"
echo "x - extracting utilities.d/libgeti.d/RingMenu.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/RingMenu.3 &&
X. \ @(#)RingMenu.3	1.1 DeltaDate 1/22/90 ExtrDate 1/22/90 
X.po 6
X.TH RINGMENU 3L
X.SH NAME
XRingMenu \- Produce a Ring Menu.
X
X.SH SYNOPSIS
X.B "int RingMenu ( win, line, optNum, title, optTable )"
X.B "WINDOW *win ;"
X.B "unsigned short line, optNum ;"
X.B "char *title, *optTable[][2] ;"
X
X.SH DESCRIPTION
XRingMenu accepts a two dimensional pointers arrary, optTable, as specification to display a ring 
Xmenu.  OptTable[][0] is the option name, while optTable[][1] is the description for the option.  The 
Xlast pair of entry in OpTable must be NULL to signify the end of the menu.  The optNumth option is 
Xhighlighted, or the first item will be highlighted if optNum is 0.  The ring menu will be displayed on 
Xwindow win on line number line.  Description for option is displayed on the line+1 line.  An option-
Xal title may be displayed to the left of the ring menu or NULL may be passed if no title is desired..
X
XUser may use the arrow keys, or the equivalent control keys to move the highlighted option, and then 
Xhit the RETURN key to select the desired option.  Or a capital letter match may also select a particu-
Xlar option, there is no need to hit RETURN in this case.
X
XRingMenu accepts at most 20 options.
X
X.SH AUTHOR
XSam S. Lok
X
X.SH RETURN VALUES
XThe position number of the selected option.  The first option being 1.
X
X.SH DIAGNOSTICS
XNone.
X
X.SH EXAMPLES
X	short	option = 1 ;
X
X	static	char	*emp_menu[][2] = {	/* The menu */
X		{ "Query",	"Query existing employee" },
X		{ "Add",	"Add new employee" },
X		{ "Change",	"Update existing employee" },
X		{ "Delete",	"Delete existing employee" },
X		{ "Print",	"Screen dump to printer" },
X		{ "Exit",	"Return to menu" },
X		{ NULL,	NULL } 
X	} ;
X
X	option = RingMenu( stdscr, ERRLINE, option, "Employee:", emp_menu ) ;
X
X.SH FILES
XNone.
X
X.SH SEE ALSO
Xmenu(1L), popmenu(3L), GetInput(3L).
X
X.SH WARNINGS
XRingMenu ignores options more than 20.
XRingMenu.c makes uses of GetInput(3L)'s GetInput.h, keys.h, ShowHelp() and ScrnPrnt(), other-
Xwise, it is very much self contained.
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/RingMenu.3 || echo "restore of utilities.d/libgeti.d/RingMenu.3 fails"
echo "x - extracting utilities.d/libgeti.d/ShowHelp.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.3 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH SHOWHELP 3 "libgeti"
X
X.SH NAME
XShowHelp \- creates and displays a help window using curses
X
X.SH SYNOPSIS
X.B "void  ShowHelp (help_file_name, tag, error_row)
X.br
X.B "char	help_file_name[];"
X.br
X.B "char	tag[];"
X.br
X.B "int	error_row;"
X
X.SH \s9DESCRIPTION\s0
X.B ShowHelp
Xsearches the \fIhelp_file_name\fP for the specified \fItag\fP, creates and
Xcenters a curses window on the screen.  Then displays the content of the tag
Xin the window.  The size of the help window is automatically adjusted to the 
Xsize of message to be displayed.
X
X.SS ARGUMENTS
X.TP 6
Xhelp_file_name
XThe unix file name containing the help message to be displayed.
X.TP 6
Xtag
XThe tag in the help file that contains the help message to be displayed.
X.TP 6
Xerror_row
XThe row on the screen (stdscr) to display any error messages.
X
X.SH HELP FILE SYNTAX
XA help file may consist of multiple help tags.  Any text found outside a helptag
Xis ignored.  See the following example.
X
X.nf
X\fBhelptag\fP
X[ .TITLE  A optional Title line goes here. ]
XI put any help message for the user between the tags.  
XIt can be any length as it will be displayed one screen 
Xat a time.
XThe following screen attributes may be used:
X\\S  =  Standout
X\\B  =  Bold
X\\U  =  Underline
X\\D  =  Dim
X\\R  =  Reverse video
X\\L  =  Blink
X\\N  =  Normal (reset)
X
X\\BThis text is in bold face.  \\NBack in normal mode.
X\fBhelptag\fP
X
X
XThe \fITABLE_OF_CONTENTS\fP tagname is a special tag describing what
Xis to be contained in the table of contents menu.  The following is the
Xsyntax for this tagname.
XTABLE_OF_CONTENTS
Xhelpfile   tagname   description
XTABLE_OF_CONTENTS
X
X
X\fBhelp\fP
X .TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
X        KEY_TOC  (^t)       Display table of contents.
X\fBhelp\fP
X.fi
X
X.SH AUTHOR
XPaul J. Condie         2/89
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
X.SH SEE ALSO
Xcurses(3X).
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/ShowHelp.3 || echo "restore of utilities.d/libgeti.d/ShowHelp.3 fails"
echo "x - extracting utilities.d/libgeti.d/drawbox.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.3 &&
X. \ @(#)drawbox.3	1.2 DeltaDate 1/22/90 ExtrDate 1/22/90 
X.po 6
X.TH DRAWBOX 3 "libgeti"
X
X.SH NAME
Xdrawbox \- draws a box in a curses window
X
X.SH SYNOPSIS
X.B #define	DumbLine	1
X.br
X.B #define	StandoutLine	2
X.br
X.B #define	SingleLine	3	/* alternate character line */
X.br
X.B #define	MosaicLine	4	/* alternate character line */
X.br
X.B #define	DiamondLine	5	/* alternate character line */
X.br
X.B #define	DotLine		6	/* alternate character line */
X.br
X.B #define	PlusLine	7	/* alternate character line */
X
Xextern int	KeyHelp;
X
X.B "void  drawbox (win, from_row, from_col, to_row, to_col, trythis, trythat, vscroll, help\fI, percent\fP)"
X.br
X.B "WINDOW	*win;"
X.br
X.B "int	from_row;"
X.br
X.B "int	from_col;"
X.br
X.B "int	to_row;"
X.br
X.B "int	to_col;"
X.br
X.B "int	trythis;"
X.br
X.B "int	trythat;"
X.br
X.B "int	vscroll;"
X.br
X.B "int	help;"
X.br
X.B "\fIfloat	percent;\fP"
X
X.SH DESCRIPTION
X.B Drawbox
Xdraws a box within a curses window.  This is similar to the box(3X) function
Xin curses, but provides more flexibility in where to draw the box and what
Xthe box should look like.
X
X.SS ARGUMENTS
X.TP 6
Xwin
XThe curses window to draw the box in.
X.TP 6
Xfrom_row, from_col, to_row, to_col
XDimensions of the box.  Upper left corner and lower right corner of the box.
XTo draw a box around the whole window (like box(3) does) 
Xtry: \fI1,1, LINES,COLS\fP as the box dimensions.
X.TP 6
Xtrythis
XWhat line type to try first.  Any one of the #defines shown above.  
XIf the terminal
Xdoes not support alternate character lines then drawbox will \fItrythat\fP line.
X.TP 6
Xtrythat
XWhat line to use if trythis doesn't work.  This should not be a
Xalternate character line.
X.TP 6
Xvscroll
XIf TRUE vertical scroll bars will be drawn in the right side of the box.
X.TP 6
Xhelp
XIf TRUE the help key (KeyHelp) will be displayed in the lower right corner 
Xof the box to indicate help is available.
X.TP 6
Xpercent
XAn optional decimal value between 0.0 and 1.0 to indicate the position of the
Xvertical scroll bars in the right side of the box.  Any other value or an
Xundefined value will put the scoll bar at the bottom.
X
X.SH AUTHOR
XPaul J. Condie         7/87
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
X.SH EXAMPLE
X.nf
X#include	<curses.h>
X
X
Xmain ()
X{
X	drawbox (stdscr, 1,1, LINES,COLS, SingleLine, StandoutLine, TRUE, TRUE, 0.5);
X}
X.fi
X
X.SH SEE ALSO
Xcurses(3X).
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/drawbox.3 || echo "restore of utilities.d/libgeti.d/drawbox.3 fails"
echo "x - extracting utilities.d/libgeti.d/popmenu.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.3 &&
X.po 6
X.TH POPMENU 3 "libgeti"
X
X.SH NAME
Xpopmenu \- runs a popup type menu
X
X.SH SYNOPSIS
X.B #define	NEWMENU		0
X.br
X.B #define	CREATEMENU	-2
X.br
X.B #define	DIMWINDOW	-1
X.br
X.br
X.B extern int	KeyHelp;
X.br
X.B extern int	KeyCancel;
X.br
X.B extern int	KeyUp;
X.br
X.B extern int	KeyDown;
X.br
X
X.B "int  popmenu (menu_id, searchStr)"
X.br
X.B "int		menu_id;"
X.br
X.B "char	*searchStr;"
X
X.SH \s9DESCRIPTION\s0
X.B Popmenu
Xis a generic curses popup menu program.  The synopsis of popmenu will vary
Xdepending on whether you are initializing a new menu or running
Xa previously defined menu.  The above synopsis will run menu (menu_id)
Xthat you have previously defined.
X.PP
XAn optional search string,\fI*searchStr\fP, is needed as the 
Xsecond parameter in order for \fIpopmenu\fP to perform initial start-up
Xsearch.  If (char *)NULL is passed, no start-up search will be done
Xand the first or last selected option will be the default option.
X.PP
XPopmenu will return the number (counting from the top of the menu)
Xof the item selected.  If the user selected the second item in the menu
Xthen \fIpopmenu\fP will return (2).
X.br
XA negative return value indicates the user canceled the selection.
X.PP
XAfter you run a menu you will need to touchwin(stdscr); wrefresh(stdscr);
Xin order to remove the popmenu from the screen.
X.PP
XThe KeyCancel defines the key where the user does not want to make any
Xchoice.  The KeyHelp defines what key is to display the help.  The KeyUp and
XKeyDown inaddition to the curses arrow key move the select bar up and down.
XKeyIC is used to toggle between \fIfull\fP and \fIfirst\fP character matching
Xschemes.
X
X.SH DEFINE NEW MENU
X.B "popmenu (action, menu_id, row, column, title, helpfile, win_size, sizeof( option_base ), option_base, mtype )"
X.br
X.B "int	action;"
X.br
X.B "int	menu_id;"
X.br
X.B "int	row;"
X.br
X.B "int	column;"
X.br
X.B "char	*title;"
X.br
X.B "char	*helpfile;"
X.br
X.B "int	win_size;"
X.br
X.B "char	*option_base;"
X.br
X     or
X.br
X.B "char	**option_base;"
X.br
X.B "int		mtype;"
X
X.SS ARGUMENTS
X.TP 6
Xaction
XNEWMENU - tells popmenu that you want to initialize a new menu.
XIf one already exists for this menu_id it will be deleted and then recreated
Xfrom the new list.
X.br
X
XCREATEMENU - If a menu already exists for this menu_id then this flag has
Xno effect.  Otherwise, it initializes a new menu from the list provided.
X
XDIMWINDOW - Dims the reverse video box around the menu.
X.br
Xpopmenu (DIMWINDOW, menu_id);
X.TP 6
Xmenu_id
XA unique identifier that you chose to be assiciated with a menu.
XYou use this identifier to run the menu.
X.TP 6
Xrow, column
XThe upper left corner of where you want the menu box to popup at.
X.TP 6
Xtitle
XTitle to be centered on the first row of the menu.  If title is null no title
Xwill be displayed.
X.TP 6
Xhelpfile
XThe helpfile name that contains help text to be displayed when the uses presses
Xthe help key.  If a helpfile is supplied a "?" is displayed in the lower
Xright hand corner of the menu.  Set to null if no help file is provided.
X.br
XThe help file should be in a format corresponding to GetInput(3),  see
XGetInput(3X) for more information.  Popmenu is hard-coded to look for
X\fIhelptag\fP "popmenu" in the helpfile.
X.TP 6
Xwin_size
XThe length of the pop-up window.  This may be less than the number of
Xoptions, so that popmenu() will only display
X.I win_size
Xnumber of options on the screen.  A window size of 6 or the number of options,
Xwhichever is less, is used if this field is set to 0.  Note that this field
Xshould not be set to be more than 22, which is the normal screen size (24)
Xminus 2 for the borders.
X.TP 6
Xsizeof( option_base[0] ) or 0
XIs an integer telling popmenu() the size of one option array element.  It can
Xalso be set to
X.I zero(0)
Xif (char **) array is passed as the next argument,
X.I popmenu
Xwill figure out the increment as the size of a char pointer.
X.TP 6
Xoption_base    
XThis is a (char *) to an array which store
Xthe options you want to appear in the menu.  This array can be either a
Xtwo dimensional char array, or a structure array, or even an array of pointers.
XThe first char string in each array element up to the first NULL character is
Xused to be displayed as options.  The rest of the field may just be table
Xlook-up items.  Also, The last element must be NULL to signify the end of the
Xtable.
X.TP 6
Xmtype
X.I mtype
Xis either TRUE or FALSE.  When TRUE, \fIpopmenu\fP performs full length,
Xnon-case-sensitive option matching, otherwise, a first character only
Xmatching scheme will be used.
X.PP
XFor menus that has to be built dynamically during run time,
Xthere are benefit of preparing your option table either way.  With a pre-set
Xchar array storing the menu entries, cpu usage is optimized in the expense of
Xmemory; while using char *array will optimize memory usage but has to allocate
Xmemory on the fly.  Menus built at compiled time are about equal with either
Xmethod.
X
X.SH CREDITS
XPaul J. Condie      7/87	(original author)
X.br
X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
X
XSam S. Lok		enhancements
X
X.SH EXAMPLE
X.nf
X#include	<curses.h>
X
X#define	NEWMENU	0
X
Xint	KeyHelp = 23;		/* control w */
Xint	KeyCancel = 27;		/* ESC */
Xint	KeyDown;
Xint	KeyUp;
X
Xmain ()
X{
X	int	option;		/* the option the user selected */
X	static char	mymenu[][7] = {
X		"QUERY", "ADD", "DELETE", (char *)NULL };
X	static char	*yourmenu[] = {
X		"QUERY", "ADD", "DELETE", (char *)NULL };
X
X
X	/* define a new menu */
X	popmenu(NEWMENU, 1, 5,10, "Title", "", 3, sizeof( mymenu[0] ), mymenu, TRUE );
X	popmenu(NEWMENU, 2, 7,15, "Title", "", 0, 0, yourmenu, TRUE );
X
X	/* run the menu */
X	option = popmenu (1, "c");
X	option = popmenu (2, (char *)NULL);
X
X	/* remove the menu from the screen */
X	touchwin (stdscr);
X	wrefresh (stdscr);
X}
X.fi
X
X.SH SEE ALSO
Xcurses(3X), GetInput(3X).
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/popmenu.3 || echo "restore of utilities.d/libgeti.d/popmenu.3 fails"
echo "x - extracting utilities.d/libgeti.d/GetInput.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.hlp &&
XGETINPUT
X.TITLE GETINPUT Help
XMover Keys:
X        KEY_RETURN  (^m)    Traverse forwards through the fields.
X        KEY_DOWN  (^j)      Traverse forwards through the fields.
X        KEY_UP  (^k)        Traverse backwards through the fields.
X        KEY_TAB  (^i)       Fast forward through the fields.
X        KEY_BTAB            Fast reverse through the fields.
XField Editing Keys:
X        KEY_BEG  (^b)       Place cursor at beginning of field.
X        KEY_END  (^e)       Place cursor at end of input in field.
X        KEY_RIGHT  (^l)     Forward space within the field.
X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
X        KEY_EOL  (^d)       Delete from cursor to end of field.
X        KEY_DL  (^c)        Clear field and home cursor.
X        KEY_DC  (^x)        Delete a character.
X        KEY_IC  (^t)        Toggle between type-over and insert mode.
XOther Keys:
X        KEY_HELP  (?)       Display help screen.
X        KEY_REFRESH  (^r)   Redraw the screen.
X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
X        KEY_SAVE  (^f)      Save screen to a file.
X        KEY_PRINT  (^p)     Print screen to lp.
XGETINPUT
X
X
X
Xpopmenu
X.TITLE Pop-Up Menu Help
XSELECTING OPTIONS:
X    Press the "up arrow key", "^k", "down arrow key", "^j" 
X    to place bar on option and press "return".
X
X    or
X
X    Enter the first character of the option you
X    wish to select and press "return".
X
X    KEY_CANCEL (esc)   - Cancel selection.
Xpopmenu
X
X
X
Xhelp
X.TITLE Using Help
XHelp displays consist of a description displayed in a window.
XIf the description doesn't fit in the window, the Up Arrow and
XDown Arrow keys can be used to view a few more lines of the 
Xdisplay.  Exiting the help system will return the display to 
Xthe state it was in when you asked for help.
X
X   The following keys are active in help:
X        KEY_CANCEL  (esc)   Exit help.
X        KEY_DOWN  (^j)      View a few more lines.
X        KEY_UP  (^k)        View the previous lines.
X        KEY_BEG  (^b)       Display first page.
X        KEY_END  (^e)       Display last page.
Xhelp
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/GetInput.hlp || echo "restore of utilities.d/libgeti.d/GetInput.hlp fails"
echo "x - extracting utilities.d/checkpass.d/checkpass.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH CHECKPASS 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xcheckpass \- find matching passwd in /etc/passwd file for a specified login.
X
X.SH SYNOPSIS
Xcheckpass login passwd 
X
X.SH DESCRIPTION
X.I Checkpass 
Xfinds the \fIlogin\fP password in the /etc/passwd file, encrypts the
X\fIpasswd\fP and does a comparison. 
X.SH FILES
X/etc/passwd
X
X.SH AUTHOR
XVickie C. Chui
X
X.SH DIAGNOSTICS
XCheckpass returns exit code zero if it was successful, otherwise, it
Xreturns a 4.
SHAR_EOF
chmod 0644 utilities.d/checkpass.d/checkpass.1 || echo "restore of utilities.d/checkpass.d/checkpass.1 fails"
echo "x - extracting utilities.d/checkpass.d/checkpass.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.c &&
X/*
X *	checkpass.c:  encrypt entered passwd and comparing it against 
X *		 the /etc/passwd.
X *	
X *	Inputs:	 argv[1] - login
X *		 argv[2] - passwd
X *	
X *	Return Values: 4 failure
X *		0 - matched passwd found
X */
X
X#include <pwd.h>
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	struct 	passwd *getpwnam(), *pwentry;
X	char 	salt[2], 
X		*crypt(),
X		*encryptedpw;
X
X
X	/* check number of arguments */
X	if(argc != 3) {
X		printf("Usage:  checkpass login passwd\n");
X		exit(4);
X	}
X	
X	/* get passwd for login from /etc/passwd file */
X	if((pwentry=getpwnam(argv[1])) == (struct passwd *) 0) 
X		exit(4);
X
X	salt[0] = *(pwentry->pw_passwd);
X	salt[1] = *(pwentry->pw_passwd +1);
X
X	/* encrypt entered passwd */
X	encryptedpw = crypt(argv[2], salt);
X
X	/* compare passwd in /etc/passwd with the encrypted passwd */
X	if(strcmp(encryptedpw, pwentry->pw_passwd) )
X		exit(4);
X	exit(0);
X}
SHAR_EOF
chmod 0644 utilities.d/checkpass.d/checkpass.c || echo "restore of utilities.d/checkpass.d/checkpass.c fails"
echo "x - extracting utilities.d/lock.d/junk (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/junk &&
X				lockfd = open(diallock, O_WRONLY|O_CREAT|O_EXCL,
X						0444) ;
X				if (lockfd < 0) 
X				{
X					if (debug & D_DEVICE) 
X					{
X						dialmsg("%s: %s\n", errstring(),
X							diallock) ;
X					}
X					continue ;
X				}
X				else
X				{
X					/* pjc */
X					/* write process id to lock file */
X					sprintf (tmpstr, "%d", getpid());
X					sprintf (spid, "%10.10s", tmpstr);
X					write (lockfd, spid, strlen(spid));
X				}
X
X				(void) close(lockfd) ;
SHAR_EOF
chmod 0644 utilities.d/lock.d/junk || echo "restore of utilities.d/lock.d/junk fails"
echo "x - extracting utilities.d/lock.d/lock.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH LOCK 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xlock \- does a lock on a file
X
X.SH SYNOPSIS
X.B lock  filename
X
X.SH DESCRIPTION
X.B LOCK
Xis designed to be a utility program to be used in conjunction with the menu(1)
Xprogram.  Lock does a lock on a file.  When used with the menu(1)
Xprogram the filename should probably be the program name.  A "LCK.." is 
Xprepended
Xto the filename to indicate that this is a lock file.  This is in keeping
Xwith uucp lock file syntax.  If the \fILCK..filename\fP
Xdoes not exist it will be created.  The lock file is created/looked for in
Xgetenv("LOCKDIR").
X
X
X.SH EXAMPLE
X.nf
Xlock program_name
Xif [ $? -eq 0 ]
X   then	program_name
X		unlock program_name
Xfi
X.fi
X
X.SH FILES
X\fI$LOCKDIR/LCK..filename\fP	the lock file
X
X.SH AUTHOR
XPaul J. Condie       10/88
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X
X.SH SEE ALSO
Xmenu(1), unlock(1).
X
X.SH DIAGNOSTICS
XLock returns a zero if the lock was successfully created,
X99 no file specified on command line,
Xotherwise, it returns \fIerrno\fP.  See errno description in manual.
SHAR_EOF
chmod 0644 utilities.d/lock.d/lock.1 || echo "restore of utilities.d/lock.d/lock.1 fails"
echo "x - extracting utilities.d/lock.d/lock.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.c &&
X/*
X** Returns:
X**	0	lock successful
X**	99	no file on command line
X**	otherwise	errno
X*/
X
X#include	<stdio.h>
X#include	<fcntl.h>
X#include	<errno.h>
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	char		*getenv();
X	int		fd;			/* file descriptor */
X	char		file[40];
X
X	if (argc != 2)
X		exit (1);
X
X	if (getenv("LOCKDIR") != (char *)NULL)
X		sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
X	else
X		sprintf (file, "LCK..%s", argv[1]);
X
X	if ((fd = open (file, O_WRONLY|O_CREAT|O_EXCL, 0444)) < 0)
X	{
X		/* check to see if process is still running */
X		exit (errno);
X	}
X
X	/* write process id to lock file */
X	/*
X	sprintf (tmpstr, "%d", getpid());
X	sprintf (spid, "%10.10s", tmpstr);
X	write (lockfd, spid, strlen(spid));
X	*/
X
X	close (fd);
X	exit (0);
X}
X/* Paul J. Condie  8-89 */
SHAR_EOF
chmod 0644 utilities.d/lock.d/lock.c || echo "restore of utilities.d/lock.d/lock.c fails"
echo "x - extracting utilities.d/lock.d/unlock.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH UNLOCK 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xunlock \- unlocks a semaphore lock on a file
X
X.SH SYNOPSIS
Xlock  filename
X
X.SH DESCRIPTION
X.B UNLOCK
Xis designed to be a utility program to be used in conjunction with the menu(1)
Xprogram.  Unlock does a semaphore unlock on a file then unlinks the filename.  
XThe filename should have been previously locked using lock(1).
XA "LCK.." is prepended
Xto the filename to indicate that this is a lock file.
XThe lock file is looked for in getenv("LOCKDIR").
X
X.PP
XThe important thing for unlock is to make sure it runs regardless of how
Xthe program exits.  Examples of how insure that this happens is illustrated
Xbelow:
X.br
Xtrap 'unlock pgm; trap 2' 2; (pgm; unlock pgm); trap 2
X.br
X(nohup pgm; nohup unlock)&
X
X.SH FILES
X\fI$LOCKDIR/LCK..filename\fP	the lock file
X
X.SH AUTHOR
XPaul J. Condie          10/88
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X
X.SH SEE ALSO
Xmenu(1), lock(1).
X
X.SH DIAGNOSTICS
XUnlock returns exit code zero if the unlock was successful, otherwise, it
Xreturns a non-zero.
SHAR_EOF
chmod 0644 utilities.d/lock.d/unlock.1 || echo "restore of utilities.d/lock.d/unlock.1 fails"
echo "x - extracting utilities.d/lock.d/unlock.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.c &&
X/*
X** Name:	unlock(1)
X** Returns:
X**	0	unlock successful
X**	99	no file on command line
X**	otherwise	errno
X*/
X
X#include	<stdio.h>
X#include	<errno.h>
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	char		*getenv();
X	char		file[40];
X
X	if (argc != 2)
X		exit (99);
X
X	if (getenv("LOCKDIR") != (char *)NULL)
X		sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
X	else
X		sprintf (file, "LCK..%s", argv[1]);
X
X	if (unlink (file) < 0)
X		exit (errno);
X
X	exit (0);
X}
X/* Paul J. Condie  8-89 */
SHAR_EOF
chmod 0644 utilities.d/lock.d/unlock.c || echo "restore of utilities.d/lock.d/unlock.c fails"
echo "x - extracting utilities.d/lock.d/uulock.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/uulock.c &&
X/*
X
X  Lock a tty and then run a program.  Blow away old locks.
X
X  Written for Sys V with HDB style locks.
X  Written by Jon Zeeff (zeeff@b-tech.ann-arbor.mi.us)
X  This program placed in the public domain.
X
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <signal.h>
X#include <fcntl.h>
X#include <termio.h>
X#include <sys/errno.h>
X
Xchar *strcpy();
Xchar *strcat();
Xunsigned sleep();
Xunsigned alarm();
Xvoid exit();
Xint pid;
X
XFILE *lock;
Xchar tty_lock[100];
X
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X
X        if (argc < 3) {
X           fprintf(stderr,"Usage: uulock tty command args\n");
X           exit(1);
X        }
X 
X	/* create a hdb style lock file */
X
X        strcpy(tty_lock,"/usr/spool/locks/LCK..");
X        strcat(tty_lock,argv[1]);
X
X        check_lock(tty_lock);
X        umask(022);
X
X	lock = fopen(tty_lock,"w");
X	if (lock) {
X		fprintf(lock,"%10.10d\n",(int)getpid());
X		fclose(lock);
X
X                if (pid = fork()) {
X		  int w;
X                  while ((w = wait((int *)0)) != pid && w != -1);
X                  unlink(tty_lock);
X                } else {
X                   execvp(argv[2],&argv[2]);
X		   printf("Can't exec that program\n");
X		   exit(2);
X                } 
X	} else {
X          fprintf(stderr,"tty port in use\n");
X          return 2;
X        }
X
X   return 0;
X}
X
X/* remove a lock file if the process is no longer there */
X
Xcheck_lock(file_name)
Xchar *file_name;
X{
X
X	int fd;
X        char lock_pid[11];
X	extern int errno;
X
X	if ((fd = open(file_name, O_RDONLY)) == -1) {
X           unlink(file_name);
X           return 0;
X        }
X
X	read(fd,lock_pid, 10);
X	close(fd);
X
X	if ((kill(atoi(lock_pid), 0)) == 0 || errno == EPERM) 
X           return 1;    /* process is active */
X
X        unlink(file_name);
X        return 0;
X}
SHAR_EOF
chmod 0644 utilities.d/lock.d/uulock.c || echo "restore of utilities.d/lock.d/uulock.c fails"
echo "x - extracting utilities.d/m.d/adduser (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/adduser &&
X#! /bin/ksh
X# %W%   DeltaDate %G%   ExtrDate %H%
X
X###  adduser
X###	Add a new user login to the system.
X###	This script is designed to be run from the menu(1) program.
X###	Menu script file is sadmin.m
X###	This script needs to be run with a set uid to root.
X###
X###  Arguments:
X###	$1 = login ID
X###	$2 = encrypted password
X###	$3 = numerical user ID
X###	$4 = numerical group ID
X###	$5 = Text (Users Read Name)
X###	$6 = directory to create users home directory in
X###	$7 = program to use as Shell
X###	$8 = default .profile for user
X###	$9 = default printer
X###	$10 =	password file
X###	$11 =	group file
X###
X###  Note:
X###  	In order to get chgrp to work you need to chown to $LOGNAME first.
X###  	The setuid does not work for chgrp ????
X###
X
X###	Validate argument count
Xif [ $# -ne 11 ]
X   then	echo "[$0] Incorrect argument count."
X	exit 1
Xfi
X
XLOGNAME=$1
XPASSWD=$2
XUID=$3
XGID=$4
XNAME=$5
XHOMEDIR=$6
XLOGSHELL=$7
XDPROFILE=$8
XPRINTER=$9
Xshift; shift
XPWDFILE=$8
XGROUPFILE=$9
X
X###	Validate must enter arguments.
Xif [ -z "$LOGNAME" ]
X   then	echo "No Login specified.  Aborting adduser."
X	exit 1
Xfi
Xif [ -z "$UID" ]
X   then	echo "No User ID specified.  Aborting adduser."
X	exit 1
Xfi
Xif [ -z "$GID" ]
X   then	echo "No Group ID specified.  Aborting adduser."
X	exit 1
Xfi
Xif [ -z "$HOMEDIR" ]
X   then	echo "No Home Directory specified.  Aborting adduser."
X	exit 1
Xfi
Xif [ -z "$LOGSHELL" ]
X   then	echo "No Login Shell specified.  Aborting adduser."
X	exit 1
Xfi
Xif [ -z "$PWDFILE" ]
X   then	echo "No Password File specified.  Aborting adduser."
X	exit 1
Xfi
Xif [ -z "$GROUPFILE" ]
X   then	echo "No Group File specified.  Aborting adduser."
X	exit 1
Xfi
X
X
X
X# Prompt for conformation
Xreply=`MenuPrompt \`tput lines\` 0 "Are You Sure (y/n) ? "`
Xif [ "$reply" != "y" ]
X   then	echo "$LOGNAME not added."
X	exit 1
Xfi
X
Xtrap "MenuMsg `tput lines` 0 'Too late to abort adduser!'" 2 3 15
X
X
X
X
X###	Make home directory
XMenuMsg `tput lines` 0 "Making a home directory."
XMAKEDIR=yes
Xif [ -s "$HOMEDIR" ]
X   then	reply=`MenuPrompt \`tput lines\` 0 "Warning: $HOMEDIR already exists.  Okay to use it. (y/n) ?  "`
X	if [ "$reply" = "y" ]
X	   then MAKEDIR=no
X	fi
Xfi
Xif [ "$MAKEDIR" = "yes" ]
X   then	mkdir $HOMEDIR
X	rcde=$?
X	if [ $rcde -ne 0 ]
X	   then echo "[$rcde]  Could not create $HOMEDIR."
X		exit 1
X	fi
Xfi
X###	The home directory will be chown'd after we add entry to password file.
SHAR_EOF
echo "End of part 12"
echo "File utilities.d/m.d/adduser is continued in part 13"
echo "13" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 13 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/m.d/adduser continued
#
CurArch=13
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/m.d/adduser"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/m.d/adduser
X
X
X
X###	Add entry to password file
X### 	$PWDFILE must be writable.
XMenuMsg `tput lines` 0 "Adding entry to $PWDFILE"
Xif [ ! -w "$PWDFILE" ]
X   then echo "$PWDFILE is not writable."
X	exit 1
Xfi
X
X###  Next line is for standard SYSV
Xecho "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> $PWDFILE
Xrcde=$?
X
X###  Next Line is for the SUN
X#$ECHO "/^+/i\\" > /tmp/adduser.script
X#$ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> /tmp/adduser.script
X#sed -f /tmp/adduser.script $PWDFILE > /tmp/newpasswd
X#cp /tmp/newpasswd $PWDFILE
X#rm -f /tmp/adduser.script
X#rm -f /tmp/newpasswd
X
Xif [ $rcde -ne 0 ]
X   then echo "[$rcde]  Unable to add entry to $PWDFILE"
X	exit 1
Xfi
X###	Now that the entry has been added to the password file
X###	we can chown the home directory
Xchown $LOGNAME $HOMEDIR		
Xchgrp $GROUP $HOMEDIR
Xchmod 755 $HOMEDIR
X
X
X
X###
X### Create .profile
X###
X
Xif [ -n "$DPROFILE" ]
X   then	MenuMsg `tput lines` 0 "Setting up the .profile."
Xfi
XNEWPROFILE=yes
Xif [ -f $HOMEDIR/.profile ]
X   then	reply=`MenuPrompt \`tput lines\` 0 "A .profile already exists in $HOMEDIR.  Okay to use it. (y/n) ?  "`
X	if [ "$reply" = "y" ]
X   	   then NEWPROFILE=no
X		MenuMsg `tput lines` 0 "Using existing .profile."
X	   else rm -f "$HOMEDIR/.profile"
X	fi
Xfi
X
Xif [ "$NEWPROFILE" = "yes" -a -n "$DPROFILE" ]
X   then	MenuMsg `tput lines` 0 "Creating new .profile."
X	###  set default printer LPDEST
X	if [ -n "$PRINTER" ]
X	   then	sed "s/^LPDEST=local/LPDEST=$PRINTER/" $DPROFILE > $HOMEDIR/.profile
X	   else	cp $DPROFILE $HOMEDIR/.profile
X	fi
X	chown $LOGNAME $HOMEDIR/.profile
X	chgrp $GROUP $HOMEDIR/.profile
X	chmod 755 $HOMEDIR/.profile
X	chown $LOGNAME $HOMEDIR/.profile
X   	MenuMsg `tput lines` 0 ".profile added for $LOGNAME."
Xfi
X
X
X
X
X###
X### Create bin in HOMEDIR
X###
X
XMenuMsg `tput lines` 0 "Setting up the bin directory."
Xif [ -d $HOMEDIR/bin ]
X   then MenuMsg `tput lines` 0 "A bin directory already exists."
X   else MenuMsg `tput lines` 0 "Making direcotry $HOMEDIR/bin."
X	mkdir $HOMEDIR/bin
X	chown $LOGNAME $HOMEDIR/bin
X	chgrp $GROUP $HOMEDIR/bin
X	chmod 755 $HOMEDIR/bin
X	chown $LOGNAME $HOMEDIR/bin
X   	MenuMsg `tput lines` 0 "Bin directory added for $LOGNAME."
Xfi
X
X
X
X###
X###  Grant Database Permissions
X###
X
X#DBPATH=/prod/date.d; export DBPATH
X#/usr/informix/bin/isql - - <<END
X#database dateme;
X#grant select on techs to $LOGNAME;
X#grant insert on techs to $LOGNAME;
X#grant update on techs to $LOGNAME;
X#grant delete on techs to $LOGNAME;
X#grant connect to $LOGNAME;
X#END
X
Xecho "$LOGNAME added."
Xexit 1
SHAR_EOF
echo "File utilities.d/m.d/adduser is complete"
chmod 6755 utilities.d/m.d/adduser || echo "restore of utilities.d/m.d/adduser fails"
echo "x - extracting utilities.d/m.d/adduser.old (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/adduser.old &&
X#! /bin/ksh
X# %W%   DeltaDate %G%   ExtrDate %H%
X
X###  adduser
X###	Add a new user login to the system.
X###	This script is designed to be run from the menu(1) program.
X###	Menu script file is sadmin.m
X###	This script needs to be run with a set uid to root program.  You
X###	pick the one you want to use.
X###
X###  Arguments:
X###	$1 = login ID
X###	$2 = encrypted password
X###	$3 = numerical user ID
X###	$4 = numerical group ID
X###	$5 = Text (Users Read Name)
X###	$6 = directory to create users home directory in
X###	$7 = program to use as Shell
X###	$8 = default .profile for user
X###	$9 = default printer
X###
X###  Note:
X###  	In order to get chgrp to work you need to chown to $LOGNAME first.
X###  	The setuid does not work for chgrp ????
X###
X
X###	Validate argument count
Xif [ $# -ne 9 ]
X   then	exit 1
Xfi
X
XLOGNAME=$1
XPASSWD=$2
XUID=$3
XGID=$4
XNAME=$5
XHOMEDIR=$6/$LOGNAME
XLOGSHELL=$7
XDPROFILE=$8
XPRINTER=$9
X
XPWDFILE=/etc/passwd
XGROUPFILE=/etc/group
XECHO=/bin/echo
X
X#stty sane erase '^h' echoe isig
X
Xtrap "$ECHO 'Adduser aborted.\nPress [ Return ] to continue...\c'; read reply; exit" 2 3 15
X
X$ECHO "\n"
X
Xif grep '^'$LOGNAME: $PWDFILE > /dev/null 2>&1
X   then $ECHO "Logname $LOGNAME is already in use."
X	$ECHO "Please try another."
X	$ECHO "Press [ Return ] to continue...\c"
X	read reply
X	exit 0
Xfi
X
XGROUP=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$GID $GROUPFILE`
X
X
X
X$ECHO "Logname:         $LOGNAME"
X$ECHO "Default Passwd:  $PASSWD"
X$ECHO "Real name:       $NAME"
X$ECHO "User id:         $UID"
X$ECHO "Group:           $GROUP"
X$ECHO "Group number:    $GID"
X$ECHO "Home directory:  $HOMEDIR"
X$ECHO "Default Printer: $PRINTER"
X	
X#$ECHO "\nDatabase Permissions:"
X#$ECHO "\tService Rep: $rep"
X	
X$ECHO "\nOkay to add (y/n)? \c"
Xread reply
X
X$ECHO "\n"
Xif [ "$reply" = "y" ]
X   then trap "$ECHO 'Too late to abort adduser!'" 2 3 15
X	$ECHO "Adding entry to $PWDFILE"
X	###  Next line is for standard SYSV
X	$ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> $PWDFILE
X	if [ $? -ne 0 ]
X	   then	$ECHO "Unable to add entry to $PWDFILE"
X		$ECHO "Aborting add new user."
X		$ECHO "Press [ Return ] to continue...\c"
X		read reply
X		exit 0
X	fi
X	###  Next Line is for the SUN
X#	$ECHO "/^+/i\\" > /tmp/adduser.script
X#	$ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> /tmp/adduser.script
X#	sed -f /tmp/adduser.script $PWDFILE > /tmp/newpasswd
X#	cp /tmp/newpasswd $PWDFILE
X#	rm -f /tmp/adduser.script
X#	rm -f /tmp/newpasswd
X   else
X	$ECHO "$LOGNAME not added."
X	exit
Xfi
X
X
X###	Make home directory
XMAKEDIR=yes
Xif [ -s $HOMEDIR ]
X   then $ECHO "Warning: $HOMEDIR exists. Okay to use it (y/n)? \c"
X	read reply
X	if [ "$reply" = "y" ]
X	   then MAKEDIR=no
X	fi
Xfi
Xif [ "$MAKEDIR" = "yes" ]
X   then	mkdir $HOMEDIR
X	if [ $? -ne 0 ]
X	   then $ECHO "Could not create $HOMEDIR."
X		$ECHO "Aborting adduser."
X		$ECHO "Removing entry in $PWDFILE"
X		sed -e "/^$LOGNAME:/D" $PWDFILE > /tmp/passwd
X	  	if [ $? -ne 0 ]
X 	       	   then	$ECHO "Unable to delete entry from password file."
X	  		exit
X		   else chmod 744 $PWDFILE
X	  		cp /tmp/passwd $PWDFILE
X			rm -f /tmp/passwd
X		fi
X		$ECHO "Press [ Return ] to continue...\c"
X		read reply
X		exit
X	fi
Xfi
X# Correct mode of HOMEDIR
Xchown $LOGNAME $HOMEDIR
X/bin/chgrp $GROUP $HOMEDIR
X/bin/chmod 754 $HOMEDIR
Xchown $LOGNAME $HOMEDIR
X
X
X
X###
X###  If there is no .profile in HOMEDIR
X###     then  Copy default .profile to HOMEDIR
X###
X
Xif [ -f $HOMEDIR/.profile ]
X   then	$ECHO "A .profile already exists in $HOMEDIR."
X   else
X	if [ -f $DPROFILE ]
X	   then	$ECHO "Placing a .profile in $HOMEDIR"
X		###  Next line is used to set default printer LPDEST
X		if [ "$PRINTER" != "NULL" ]
X			# fix this
X		   then	sed "s/^LPDEST=local/LPDEST=$PRINTER/" $DPROFILE > $HOMEDIR/.profile
X		   else	cp $DPROFILE $HOMEDIR/.profile
X		fi
X		chown $LOGNAME $HOMEDIR/.profile
X		/bin/chgrp $GROUP $HOMEDIR/.profile
X		/bin/chmod 754 $HOMEDIR/.profile
X		chown $LOGNAME $HOMEDIR/.profile
X		$ECHO "Default .profile added for $LOGNAME."
X	   else	$ECHO "The default .profile ($DPROFILE) was not found."
X	fi
Xfi
X
X
X
X###
X### Create bin in HOMEDIR
X###
X
Xif [ -d $HOMEDIR/bin ]
X   then	$ECHO "A bin directory already exists."
X   else 
X	$ECHO "Making directory $HOMEDIR/bin"
X	mkdir $HOMEDIR/bin
X	chown $LOGNAME $HOMEDIR/bin
X	/bin/chgrp $GROUP $HOMEDIR/bin
X	/bin/chmod 755 $HOMEDIR/bin
X	chown $LOGNAME $HOMEDIR/bin
X	$ECHO "Bin directory added for $LOGNAME."
Xfi
X
X
X
X###
X###  Grant Database Permissions
X###
X
X#DBPATH=/prod/date.d; export DBPATH
X#/usr/informix/bin/isql - - <<END
X#database dateme;
X#grant select on techs to $LOGNAME;
X#grant insert on techs to $LOGNAME;
X#grant update on techs to $LOGNAME;
X#grant delete on techs to $LOGNAME;
X#grant connect to $LOGNAME;
X#END
X
X$ECHO "$LOGNAME added."
X$ECHO "Press [ Return ] to continue...\c"
Xread reply
SHAR_EOF
chmod 6755 utilities.d/m.d/adduser.old || echo "restore of utilities.d/m.d/adduser.old fails"
echo "x - extracting utilities.d/m.d/deluser (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/deluser &&
X#! /usr/lbin/ksh
X# @(#)deluser.sh	1.1   DeltaDate 12/31/87   ExtrDate 12/31/87
X###
X###  You need to chown all files in the home directory you want to delete
X###  to $LOGNAME before you can remove the home directory.
X###
X
XLOGNAME=$1
XECHO=echo
XUIDBASE=2000
X
Xtrap "$ECHO 'Deluser aborted.'; exit 1" 2 3 15
X
Xtput clear
X#stty sane erase '^h' echoe isig
X
X
X
Xcase $LOGNAME in
X   dateme|pjc|root|nobody|daemon|sys|bin|uucp|nuucp|news|informix|telic|cadsys)
X	$ECHO "Sorry, You don't have permission to delete that one."
X	continue
X	;;
Xesac
X
X###
X### Check for validity - listed in password file.
X###
Xif grep '^'$LOGNAME: /etc/passwd > /dev/null 2>&1
X   then
X	### Extract data for this user and display.
X       	setthem=`sed -n "s/^$LOGNAME:\(.*\):\(.*\):\(.*\):\(.*\):\(.*\):\(.*\)/passwd=\1;uid=\2;gid=\3;realname='\4';homedir=\5;shell=\6/p" /etc/passwd`
X       	eval $setthem
X       	group=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$gid /etc/group`
X
X	###
X	###  uid must be >= UIDBASE
X	###
X	if [ "$uid" -lt $UIDBASE ]
X   	   then	$ECHO "Sorry, You don't have permission to delete that one."
X   		continue
X	fi
X
X	$ECHO "\nLogname:           $LOGNAME"
X	$ECHO "Real name:         $realname"
X       	$ECHO "User id:           $uid"
X       	$ECHO "Group:             $group"
X       	$ECHO "Group number:      $gid"
X       	$ECHO "Home directory:    $homedir"
X	$ECHO "\n\n"
X       	break
X   else
X	$ECHO "$LOGNAME is not listed in the password file. Try again."
X	read reply
Xfi
X
X
X
Xwhile true
Xdo
X	$ECHO "Do you wish to delete this user from the system  (y/n):  \c"
X   	read reply
X
X   	case $reply in
X	   n|N)	break ;;
X     	   y|Y)
X		if [ "$homedir" != "/prod/date.d/cadsys.d" ]
X	   	   then
X			###  Not a Service Rep
X			###  Service Reps never had permission here
X			DBPATH=/prod/date.d
X			export DBPATH
X/usr/informix/bin/isql - - <<END
Xdatabase dateme;
Xrevoke all on techs from $LOGNAME;
Xrevoke all on turfs from $LOGNAME;
Xrevoke all on techtime from $LOGNAME;
Xrevoke all on factors from $LOGNAME;
Xrevoke all on turfs from $LOGNAME;
XEND
X		fi
X		DBPATH=/prod/date.d/cadsys.d
X		export DBPATH
X/usr/informix/bin/isql - - <<END
Xdatabase cadsys;
Xrevoke all on appt from $LOGNAME;
Xrevoke all on grid from $LOGNAME;
Xrevoke all on syserror from $LOGNAME;
Xrevoke all on appt_time from $LOGNAME;
Xrevoke all on sorder from $LOGNAME;
Xrevoke all on sysdeflt from $LOGNAME;
Xrevoke connect from $LOGNAME;
XEND
X			sed -e "/^$LOGNAME:/D" /etc/passwd > /tmp/passwd
X	  		if [ $? -ne 0 ]
X 	    	   	   then	$ECHO "Unable to delete from password file."
X		  		exit
X	  		fi
X	  		chmod 744 /etc/passwd
X	  		cp /tmp/passwd /etc/passwd
X
X			###
X			###  CUSTOMIZE
X			###  if this is a service rep we don't want to remove homedir
X			###
X			if [ "$homedir" != "/prod/date.d/cadsys.d" ]
X		   	   then
X	  			find $homedir -exec /etc/chown $LOGNAME {} \;
X	  			rm -r $homedir
X			fi
X	  		$ECHO "\nUser removed from system."
X	  		break;
X	  		;;
X     	   	   *)	$ECHO "Invalid reply."
X          		continue ;;
X   		esac
SHAR_EOF
chmod 0777 utilities.d/m.d/deluser || echo "restore of utilities.d/m.d/deluser fails"
echo "x - extracting utilities.d/m.d/junk (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/junk &&
X			sed -e "/^$LOGNAME:/D" /etc/passwd > /tmp/passwd
SHAR_EOF
chmod 0644 utilities.d/m.d/junk || echo "restore of utilities.d/m.d/junk fails"
echo "x - extracting utilities.d/m.d/junk.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/junk.m &&
X###
X###   	.POPMENU
X###	Printer Selection Menu
X###
X
X.TITLE
XPrinter Menu
X
X.TEXT 23 0
XSelect A Printer.
X
X.SETENV BELL LPDEST=srv4e_700ps  Printer (srv4e_700ps) selected.
Xsrv4e_700ps
X
X.SETENV BELL LPDEST=srv4e_700dm  Printer (srv4e_700dm) selected.
Xsrv4e_700dm
X
X.SETENV BELL LPDEST=srv4e_811a  Printer (srv4e_811a) selected.
Xsrv4e_811a
X
X.SETENV BELL LPDEST=srv4e_760c  Printer (srv4e_760c) selected.
Xsrv4e_760c
SHAR_EOF
chmod 0644 utilities.d/m.d/junk.m || echo "restore of utilities.d/m.d/junk.m fails"
echo "x - extracting utilities.d/m.d/passwdsrn.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/passwdsrn.m &&
X.DEFINE_SCREEN passwdsrn
X	window_title = "Password Screen"
X	window_rows = 5
X	window_cols = 26
X	exit_last_field
X
X	field_name = $PASSWD
X	field_label = Password
X	field_row = 2
X	field_col = 12
X	field_length = 8
X	field_edits = PROTECT
X	field_prompt = "Enter password."
XENDSCREEN
SHAR_EOF
chmod 0644 utilities.d/m.d/passwdsrn.m || echo "restore of utilities.d/m.d/passwdsrn.m fails"
echo "x - extracting utilities.d/m.d/printer2.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printer2.sh &&
XFrom uucp Tue Nov 28 16:07 PST 1989
X>From uucp Tue Nov 28 15:56 PST 1989 remote from pacbell
X>From srv.PacBell.COM!pjcondie  Tue Nov 28 14:35:31 1989 remote from mother
XReceived: from pbuddy.srv.PacBell.COM (pbuddy-gw) by srv.PacBell.COM (4.0/SMI-4.0)
X	id AA17298; Tue, 28 Nov 89 14:35:31 PST
XReceived: from lacm2.srv.PacBell.COM by pbuddy.srv.PacBell.COM (4.0/SMI-4.0)
X	id AA02251; Tue, 28 Nov 89 14:37:38 PST
XDate: Tue, 28 Nov 89 14:37:38 PST
XFrom: pjcondie@srv.PacBell.COM (Paul J. Condie)
XMessage-Id: <8911282237.AA02251@pbuddy.srv.PacBell.COM>
XTo: pcbox!pjc
XSubject: Re:  printers.sh
XStatus: R
X
X
X----- Begin Included Message -----
X
X>From pbear2!ssl Tue Nov 28 14:31:29 1989
XSubject: printers.sh
XTo: pjc (Paul J. Condie(baer))
XX-Mailer: ELM [version 2.2 PL0]
X
X###
X###   	Build lpoptions.m from lpoptions.menu
X###	Printer Selection Menu
X###
X
XDUMMY="zzzzzzzz"			# end-of-list marker
X
Xsetprinters() {				# make a function
Xlpstat -a | grep accept | cut -d' ' -f1 | ( sort ; echo $DUMMY ) |
Xfor i in `cat`
Xdo
X	if [ $i = $DUMMY ]		# hit last one?
X	then
X		echo $PRINTERS
X	fi
X	PRINTERS=$PRINTERS","$i		# concat
Xdone ; }
X
XPRINTERS=$LPDEST`setprinters`		# now build it
Xsed -e s/\$PRINTERS/$PRINTERS/ $BVPS/misc/lpoptions.menu > lpoptions.m
X
X
X----- End Included Message -----
X
X
X
SHAR_EOF
chmod 0644 utilities.d/m.d/printer2.sh || echo "restore of utilities.d/m.d/printer2.sh fails"
echo "x - extracting utilities.d/m.d/printers.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.m &&
X###
X###   	.POPMENU
X###	Printer Selection Menu
X###
X
X.TITLE
XPrinter Menu
X
X.TEXT 23 0
XSelect A Printer.
X
X.SETENV BELL LPDEST=srv4e_700ps  Printer (srv4e_700ps) selected.
Xsrv4e_700ps
X
X.SETENV BELL LPDEST=srv4e_700dm  Printer (srv4e_700dm) selected.
Xsrv4e_700dm
X
X.SETENV BELL LPDEST=srv4e_811a  Printer (srv4e_811a) selected.
Xsrv4e_811a
X
X.SETENV BELL LPDEST=srv4e_760c  Printer (srv4e_760c) selected.
Xsrv4e_760c
X
X.POPMENU printers.m
XPOP
SHAR_EOF
chmod 0644 utilities.d/m.d/printers.m || echo "restore of utilities.d/m.d/printers.m fails"
echo "x - extracting utilities.d/m.d/printers.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.sh &&
X###
X###   	Build a .POPMENU
X###	Printer Selection Menu
X###
X
Xecho ".TITLE" > printers.m
Xecho "Printer Menu" >> printers.m
X
Xecho ".TEXT 23 0" >> printers.m
Xecho "Select A Printer." >> printers.m
X
Xlpstat -p | awk '{ print $2 }' |
Xfor i in `cat`
Xdo
X	echo ".SETENV BELL LPDEST=$i  Printer ($i) selected." >> printers.m
X	echo "$i" >> printers.m
Xdone
SHAR_EOF
chmod 0755 utilities.d/m.d/printers.sh || echo "restore of utilities.d/m.d/printers.sh fails"
echo "x - extracting utilities.d/m.d/reportsrn.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/reportsrn.m &&
X###	Screen to prompt user for report options.
X###	Fields:
X###		$FDATE    - From date.
X###		$TDATE    - To date.
X###		$PRIORITY - Priority
X###		$LPDEST   - Printer Destination
X###		$TARGET   - Print to terminal or printer.
X
X.DEFINE_SCREEN reportsrn
X	window_title = "REPORT OPTIONS"
X	window_rows = 10
X	window_cols = 28
X
X	###	$FDATE - From date.
X
X	field_name = $FDATE
X	field_label = From
X	field_row = 2
X	field_col = 13
X	field_length = 6
X	field_type = DATE
X	field_mask = "MM/DD/YY"
X	field_mustenter
X	field_prompt = "Enter starting date."
X
X	###	$TDATE - To date.
X
X	field_name = $TDATE
X	field_label = To
X	field_row = 3
X	field_col = 13
X	field_length = 6
X	field_type = DATE
X	field_mask = "MM/DD/YY"
X	field_mustenter
X	field_prompt = "Enter starting date."
X
X	field_name = $PRIORITY
X	field_label = Priority
X	field_row = 5
X	field_col = 13
X	field_length = 6
X	field_type = MENU
X	field_range = "LOW,MEDIUM,HIGH"
X	field_prompt = "Select priority level."
X
X	field_name = $LPDEST
X	field_label = Printer
X	field_row = 6
X	field_col = 13
X	field_length = 11
X	field_type = SET
X	field_range = "srv4e_700ps,srv4e_811a"
X	field_prompt = "Select printer."
X
X	field_name = $TARGET
X	field_label = "Print To"
X	field_row = 7
X	field_col = 13
X	field_length = 8
X	field_type = SET
X	field_range = "TERMINAL,PRINTER,BOTH"
X	field_prompt = "Print to terminal or printer."
XENDSCREEN
SHAR_EOF
chmod 0644 utilities.d/m.d/reportsrn.m || echo "restore of utilities.d/m.d/reportsrn.m fails"
echo "x - extracting utilities.d/m.d/sadmin.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sadmin.m &&
X###	sadmin.m
X###	System administration menu(1) script file.
X###
X###  Contains:
X###	Add New User To System.
X###	Remove User From System.
X
XGROUP=users				# default group for new users
XHOMEDIRS=/tmp				# where to make home dir for new users
XPRINTER=""				# default printer destination
XDPROFILE=				# skeleton .profile for new users
XLOGSHELL=/bin/ksh			# default login shell for new users
XPASSWDAGE=",O/"				# password entry for new users
XUIDBASE=1000				# new users uid start from here
X
XPWDFILE=/etc/passwd			# password file
XGROUPFILE=/etc/group
X
X.TITLE
X$LOGNAME ...System Administration...$DATE
X.TITLE
X...Menu...$TIME
X.LINE
X
X.GETINPUT adduser
XAdd New User To System.
X
X.GETINPUT deluser
XRemove User From System.
X
X.GETINPUT dbapermissions
XSet Database Permissions.
X
X
X
X###	Screen Definitions
X
X.DEFINE_SCREEN adduser
X	exit_on_cancel
X	after_screen = "adduser \"$logname\" \"$PASSWDAGE\" \"$UID\" \"$GID\" \
X				\"$realname\" \"$HOMEDIR\" \"$LOGSHELL\" \
X				\"$DPROFILE\" \"$PRINTER\" \"$PWDFILE\" \
X				\"$GROUPFILE\"
X			exit $?"
X
X	field_name = $logname
X	field_label = "Login Name"
X	field_row = 2, field_col = 19
X	field_length = 8
X	field_type = ALPHANUM, field_mask = "A       "
X	field_min = 3
X	field_mustenter
X	### make sure logname is unique and tag on logname to homedirs
X	after_field = "grep $logname $PWDFILE >/dev/null 2>/dev/null
X			if [ $? -eq 0 ]
X			   then echo \"Login already exists.\"
X				exit 1
X			   else echo \"\$HOMEDIR=$HOMEDIRS/$logname\"
X				exit 0
X			fi"
X
X	field_name = $realname
X	field_label = "Real Name"
X	field_row = 3, field_col = 19
X	field_length = 25
X	field_type = ALPHANUM
X	field_mustenter
X
X	field_name = $UID
X	field_label = "User ID"
X	field_row = 4, field_col = 19
X	field_length = 5
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $GROUP
X	field_label = "Group"
X	field_row = 5, field_col = 19
X	field_length = 10
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $GID
X	field_label = "Group ID"
X	field_row = 6, field_col = 19
X	field_length = 5
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $HOMEDIR
X	field_label = "Home Directory"
X	field_row = 7, field_col = 19
X	field_length = 25
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $PRINTER
X	field_label = "Default Printer"
X	field_row = 8, field_col = 19
X	field_type = MENU
X	### build field_range based on available printers
X	field_range = "`lpstat -p | awk '{ print $2 }' |
X			for printer in `cat`
X			do
X				if [ \"$printer\" = \"unknown\" ]
X				   then continue
X				fi
X				if [ -z \"$RANGEVALUES\" ]
X	   	   		   then RANGEVALUES=$printer
X	   	   		   else RANGEVALUES=\"$RANGEVALUES,$printer\"
X				fi
X				echo $RANGEVALUES > /tmp/menu.tmpfile
X			done
X			cat /tmp/menu.tmpfile`"
X
X	### get next unused uid greater than UIDBASE from password file
X	### get gid from group file using GROUP
X	field_defaults = "UID=`awk 'BEGIN{ FS=\":\" } { x[$3] = 1 } END \
X		{ i = UIDBASE; while (x[i] == 1) { ++i }; print i }' \
X			UIDBASE=$UIDBASE $PWDFILE`
X		GID=`awk 'BEGIN{FS=\":\"} {if($1 == g) print $3}' g=$GROUP \
X			$GROUPFILE`
X		echo \\"\\" \\"\\" $UID $GROUP $GID $HOMEDIRS \\"$PRINTER\\""
XENDSCREEN
X
X
X
X.DEFINE_SCREEN deluser
X	exit_on_cancel
X	after_screen = "deluser \"$logname\" \"$PWDFILE\"
X			exit $?"
X
X	field_name = $logname
X	field_label = "Login Name"
X	field_row = 2, field_col = 19
X	field_length = 8
X	field_type = ALPHANUM, field_mask = "A       "
X	field_min = 3
X	field_mustenter
X	### make sure logname exists and set other fields
X	after_field = "grep $logname $PWDFILE >/dev/null 2>/dev/null
X		if [ $? -ne 0 ]
X	   	   then	echo \"Login not found.\"
X			exit 1
X		fi
X       		setthem=`sed -n \"s/^$logname:\(.*\):\(.*\):\(.*\):\(.*\):\(.*\):\(.*\)/passwd=\1;uid=\2;gid=\3;realname='\4';homedir=\5;shell=\6/p\" /etc/passwd`
X       	eval $setthem
X       	group=`awk 'BEGIN{FS=\":\"} {if($3 == g) print $1}' g=$gid /etc/group`
X	if [ \"$uid\" -lt $UIDBASE ]
X   	   then	echo \"Sorry, You don't have permission to delete that one.\"
X   		exit 1
X	fi
X	echo \"$logname\" \"$realname\" \"$uid\" \"$group\" \"$gid\" \"$homedir\"
X	exit 0"
X
X	field_name = $realname
X	field_label = "Real Name"
X	field_row = 3, field_col = 19
X	field_length = 25
X	field_type = ALPHANUM
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $UID
X	field_label = "User ID"
X	field_row = 4, field_col = 19
X	field_length = 5
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $GROUP
X	field_label = "Group"
X	field_row = 5, field_col = 19
X	field_length = 10
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $GID
X	field_label = "Group ID"
X	field_row = 6, field_col = 19
X	field_length = 5
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $HOMEDIR
X	field_label = "Home Directory"
X	field_row = 7, field_col = 19
X	field_length = 25
X	field_noinput
X	field_terminator = "  "
X
X	field_name = $DELETE
X	field_label = "Delete"
X	field_row = 9, field_col = 19
X	field_range = "YES,NO"
X	field_edits = SET
X
X
X	field_defaults = "echo \\"\\" \\"\\" \\"\\" \\"\\" \\"\\""
XENDSCREEN
X
X
X.DEFINE_SCREEN dbapermissions
X	after_screen = "setdbaperm hits he"
X
X	### Column Headings
X	text = 2 3 "\UUsers\N"
X	text = 2 16 "\USelect\N"
X	text = 2 23 "\UUpdate\N"
X	text = 2 30 "\UInsert\N"
X	text = 2 37 "\UDelete\N"
X	text = 2 44 "\UIndex\N"
X	text = 2 51 "\UAlter\N"
X
X	### Retrieve current database permissions
X	### Save for latter comparison on what logins got changed.
X	### Set variables with current permissions
X	field_defaults = "LINECNT=0
X			DATA=\"\"
X			isql hits - <<-END 2> /dev/null | tee -a /tmp/tmpfile2 |
X				info tables access for he;
XEND
X			for i in `cat`
X			do
X				LINECNT=`expr $LINECNT + 1`
X				[ $LINECNT -le 7 ] && continue
X				DATA=\"$DATA $i\"
X				echo $DATA > /tmp/menu.tmpfile
X			done
X			cat /tmp/menu.tmpfile"
X
X	field_name = $USER[0]
X	field_row = 3, field_col = 3
X	field_length = 10
X	field_edits = ALPHANUM
X	after_field = "[ \"${USER[0]}\" = \"public\" ] && exit 0
X		[ \"${USER[0]}\" = \"\" ] && exit 0
X		grep \"${USER[0]}\" $PWDFILE >/dev/null 2>/dev/null
X		if [ $? -ne 0 ]
X	   	   then	echo \"Login not found.\"
X			exit 1
X		   else exit 0
X		fi"
X
X	field_name = $SELECT[0]
X	field_row = 3, field_col = 17
X	field_edits = SET
X	field_range = ",All,No"
X
X	field_name = $UPDATE[0]
X	field_row = 3, field_col = 24
X	field_edits = SET
X	field_range = ",All,No"
X
X	field_name = $INSERT[0]
X	field_row = 3, field_col = 31
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $DELETE[0]
X	field_row = 3, field_col = 38
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $INDEX[0]
X	field_row = 3, field_col = 45
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $ALTER[0]
X	field_row = 3, field_col = 52
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $USER[1]
X	field_row = 4, field_col = 3
X	field_length = 10
X	field_edits = ALPHANUM
X	### accept public login
X	after_field = "[ \"${USER[1]}\" = \"public\" ] && exit 0
X		[ \"${USER[1]}\" = \"\" ] && exit 0
X		grep \"${USER[1]}\" $PWDFILE >/dev/null 2>/dev/null
X		if [ $? -ne 0 ]
X	   	   then	echo \"Login not found.\"
X			exit 1
X		   else [ \"${SELECT[1]}\" = \"\" ] && echo \"\$SELECT[1]=All \$UPDATE[1]=No \$INSERT[1]=No \$DELETE[1]=No \$INDEX[1]=No \$ALTER[1]=No\"
X			exit 0
X		fi"
X
X	field_name = $SELECT[1]
X	field_row = 4, field_col = 17
X	field_edits = SET
X	field_range = ",All,No"
X
X	field_name = $UPDATE[1]
X	field_row = 4, field_col = 24
X	field_edits = SET
X	field_range = ",All,No"
X
X	field_name = $INSERT[1]
X	field_row = 4, field_col = 31
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $DELETE[1]
X	field_row = 4, field_col = 38
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $INDEX[1]
X	field_row = 4, field_col = 45
X	field_edits = SET
X	field_range = ",Yes,No"
X
X	field_name = $ALTER[1]
X	field_row = 4, field_col = 52
X	field_edits = SET
X	field_range = ",Yes,No"
XENDSCREEN
SHAR_EOF
chmod 0644 utilities.d/m.d/sadmin.m || echo "restore of utilities.d/m.d/sadmin.m fails"
echo "x - extracting utilities.d/m.d/sample.m (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sample.m &&
X### 	Sample.Menu
X###	A sample menu script file.
X
X.TITLE
X$LOGNAME ...SAMPLE...$DATE
X.TITLE
X$MAIL...MENU...$TIME
X.LINE
X
X.GNAME sample sample.m
X
X.INCLUDE reportsrn.m
X.INCLUDE passwdsrn.m
X
X.TEXT 22 61
X"?" for help :
X
X.SYSTEM echo "Press [ ^d ] to return to menu ..."; ksh
XUnix System.
X
X.SYSTEM who; \
X	echo "Press [ Return ] to continue ..."; \
X	read reply
XShow Who Is On The System.
X
X.SYSTEM more sample.m; echo "Press [ Return ] to continue ...\c"; read reply
XDisplay sample.m script file.
X
X.POPMENU printers.m
XSelect Printer Menu ($LPDEST).
X
X.GETINPUT reportsrn
XA Sample GETINPUT Screen.
X
X.GETINPUT passwdsrn
XA Sample Password Screen.
X
X.SPACE
X
X.EXIT
XExit Menu Program.
SHAR_EOF
chmod 0644 utilities.d/m.d/sample.m || echo "restore of utilities.d/m.d/sample.m fails"
echo "x - extracting utilities.d/m.d/setdbaperm (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/setdbaperm &&
X#!/bin/ksh
X
X###	$1	- database
X###	$2	- table name
X
X[ $# -ne 2 ] && exit 1			# validate argument count
X
XDATABASE=$1
XTABLE=$2
XTMPFILE=/tmp/menutmp
X
X
X#  Get current settings
Xisql "$DATABASE" - <<-END 2> /dev/null > $TMPFILE
X	info tables access for $TABLE;
XEND
X
X
X#  Loop through each user
Xlet i=0
Xfor dummy in "${USER[@]}"
Xdo
X	GC=""						# Grant Commands
X	grep "^${USER[i]}" $TMPFILE | read line
X	if [ $? -ne 0 ]
X	   then	# "No match "${USER[i]}" - add new login's permissions."
X		GC="${GC}grant connect to ${USER[i]};\n"
X		[ "${SELECT[i]}" = "All" ] && 
X			GC="${GC}grant select on $TABLE to ${USER[i]};\n"
X		[ "${UPDATE[i]}" = "All" ] && 
X			GC="${GC}grant update on $TABLE to ${USER[i]};\n"
X		[ "${INSERT[i]}" = "Yes" ] && 
X			GC="${GC}grant insert on $TABLE to ${USER[i]};\n"
X		[ "${DELETE[i]}" = "Yes" ] && 
X			GC="${GC}grant delete on $TABLE to ${USER[i]};\n"
X		[ "${INDEX[i]}" = "Yes" ] && 
X			GC="${GC}grant index on $TABLE to ${USER[i]};\n"
X		[ "${ALTER[i]}" = "Yes" ] && 
X			GC="${GC}grant alter on $TABLE to ${USER[i]};\n"
X	   else	# "Match "${USER[i]}" - check if permissions have changed."
X		set $line
X		PUSER=$1; PSELECT=$2; PUPDATE=$3; PINSERT=$4; 
X		PDELETE=$5; PINDEX=$6; PALTER=$7
X		if [ "${SELECT[i]}" != "$PSELECT" ]
X		   then # "Select changed. $PSELECT-${SELECT[i]}"
X			[ "${SELECT[i]}" = "All" ] && 
X			    GC="${GC}grant select on $TABLE from ${USER[i]};\n"
X			[ "${SELECT[i]}" = "No" ] && 
X			    GC="${GC}revoke select on $TABLE from ${USER[i]};\n"
X		fi
X		if [ "${UPDATE[i]}" != "$PUPDATE" ]
X		   then # "Select changed. $PUPDATE-${UPDATE[i]}"
X			[ "${UPDATE[i]}" = "All" ] && 
X			    GC="${GC}grant update on $TABLE from ${USER[i]};\n"
X			[ "${UPDATE[i]}" = "No" ] && 
X			    GC="${GC}revoke update on $TABLE from ${USER[i]};\n"
X		fi
X		if [ "${INSERT[i]}" != "$PINSERT" ]
X		   then # "Select changed. $PINSERT-${INSERT[i]}"
X			[ "${INSERT[i]}" = "Yes" ] && 
X			    GC="${GC}grant insert on $TABLE from ${USER[i]};\n"
X			[ "${INSERT[i]}" = "No" ] && 
X			    GC="${GC}revoke insert on $TABLE from ${USER[i]};\n"
X		fi
X		if [ "${DELETE[i]}" != "$PDELETE" ]
X		   then # "Select changed. $PDELETE-${DELETE[i]}"
X			[ "${DELETE[i]}" = "Yes" ] && 
X			    GC="${GC}grant delete on $TABLE from ${USER[i]};\n"
X			[ "${DELETE[i]}" = "No" ] && 
X			    GC="${GC}revoke delete on $TABLE from ${USER[i]};\n"
X		fi
X		if [ "${INDEX[i]}" != "$PINDEX" ]
X		   then # "Select changed. $PINDEX-${INDEX[i]}"
X			[ "${INDEX[i]}" = "Yes" ] && 
X			    GC="${GC}grant index on $TABLE from ${USER[i]};\n"
X			[ "${INDEX[i]}" = "No" ] && 
X			    GC="${GC}revoke index on $TABLE from ${USER[i]};\n"
X		fi
X		if [ "${ALTER[i]}" != "$PALTER" ]
X		   then # "Select changed. $PALTER-${ALTER[i]}"
X			[ "${ALTER[i]}" = "Yes" ] && 
X			    GC="${GC}grant alter on $TABLE from ${USER[i]};\n"
X			[ "${ALTER[i]}" = "No" ] && 
X			    GC="${GC}revoke alter on $TABLE from ${USER[i]};\n"
X		fi
X	fi
X	echo "$GC\n" >> /tmp/grantstuff
X	let i=i+1				# increment index
Xdone
SHAR_EOF
chmod 0755 utilities.d/m.d/setdbaperm || echo "restore of utilities.d/m.d/setdbaperm fails"
echo "x - extracting utilities.d/m.d/suid_exec.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/suid_exec.c &&
X#include	<stdio.h>
X#include	<fcntl.h>
X#include	<sys/stat.h>
X
X#define	ROOT	0
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	int		fd;
X	struct stat	sbuf;
X	char		command[200];
X	int		i;
X
X
X	if (argc < 2)
X		exit (1);
X
X	if ((fd = open (argv[1], O_RDONLY)) <= 0)
X		exit (1);				/* can't open */
X
X	/* Get file status information */
X   	if (fstat (fd, &sbuf) < 0)
X		exit (1);
X
X	/* Is this a regular file */
X	if ((sbuf.st_mode & S_IFREG) != S_IFREG)
X		exit (1);
X
X	/* does root own this file */
X	if (sbuf.st_uid != ROOT)
X		exit (1);
X
X	/* Is file executable by owner(root) */
X	if ((sbuf.st_mode & S_IEXEC) != S_IEXEC)
X		exit (1);
X
X	/* Is set uid bit on */
X	if ((sbuf.st_mode & S_ISUID) != S_ISUID)
X		exit (1);
X
X	setuid (ROOT);
X
X	strcpy (command, argv[1]);			/* program name */
X	for (i = 2; i < argc; i++)
X	{
X		strcat (command, " ");
X		strcat (command, "\"");
X		strcat (command, argv[i]);		/* program arguments */
X		strcat (command, "\"");
X	}
X
X	system (command);
X}
X/* Paul J. Condie  2-89 */
SHAR_EOF
chmod 0644 utilities.d/m.d/suid_exec.c || echo "restore of utilities.d/m.d/suid_exec.c fails"
echo "x - extracting utilities.d/msgbox.d/displaytxt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/msgbox.d/displaytxt.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X/*  FUNCTION:	displaytext()
X**		Displays a string to the screen with atributes.
X**  ARGS:	
X**		win	curses window to display to
X**		row	screen row
X**		col	screen col
X**		s	the string
X**  RETURNS:	none
X*/
X
X#include	<curses.h>
X
Xdisplaytext (win, row, col, s)
X	WINDOW	*win;
X	int	row, col;
X	char	s[];
X{
X	int	i;
X
X	wmove (win, row, col);
X
X/*
X**	Now display looking for terminal attributes.
X*/
X      for (i = 0; s[i] != '\0'; i++)
X      {
X         if (s[i] == '\\')
X	 {
X#ifdef BSD
X	    if (s[i+1] != 'N') s[i+1] = 'S';   /* Berk only supports standout */
X#endif
X            switch (s[++i])
X            {
X	       case 'n':	/* newline */
X			wmove (win, ++row, col);
X			break;
X
X	       case 'S':
X#ifdef BSD
X			wstandout (win);
X#else
X	   		wattrset (win, win->_attrs|A_STANDOUT);
X#endif
X			break;
X	       case 'B':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_BOLD);
X#endif
X			break;
X	       case 'U':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_UNDERLINE);
X#endif
X			break;
X	       case 'D':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_DIM);
X#endif
X			break;
X	       case 'R':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_REVERSE);
X#endif
X			break;
X	       case 'L':
X#ifdef SYS5
X			wattrset (win, win->_attrs|A_BLINK);
X#endif
X			break;
X	       case 'N': 
X#ifdef BSD
X			wstandend (win);
X#else
X			wattrset (win, A_NORMAL);
X#endif
X			break;
X	    }
X	 }
X         else
X            waddch (win, s[i]);
X      }
X}
SHAR_EOF
chmod 0644 utilities.d/msgbox.d/displaytxt.c || echo "restore of utilities.d/msgbox.d/displaytxt.c fails"
echo "x - extracting utilities.d/msgbox.d/makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/msgbox.d/makefile &&
X###	Special function targets begin with a dot.
X###	Target name that begin with a dot are never used as the starting 
X###	target, unless specifically requested as an argument on the command
X###	line.
X
X#.SILENT:	# inhibit the display of command lines (@)
X#.IGNORE:	# ignore exit codes from command lines (-)
X
XPGM		= msgbox
XINSTALLDIR 	= 
XTARGET_ARCH	= sys5
X
XLIBS	= ../../libgeti.a -lcurses
X
X###	Flags
XINCDIR		= ../libgeti.d
XCPPFLAGS	=
XCFLAGS		= -O -I$(INCDIR)
XLDFLAGS		=
XLINTFLAGS	=
X
X###	Source Files
XPERFILES 	= 
XACEFILES	=
XCFILES		= msgbox.c
XC+FILES		=
XECFILES		=
XHFILES		=
X
XOBJECTS = $(CFILES:.c=.o)
XLINTFILES = $(SOURCES:.c=.ln)
X
X#all:	$(PGM) install
X
X###	Conditional Macro Definitions
X#debug := CFLAGS= -g
X#profile := CFLAGS= -pg -O
X
X###	Targets and Dependencies
X###	target [target ...]: [dependency ...]
X###		[command]			# target rule
X###		...
X###	* If there is no rule for a target entry, make looks for an implicit 
X###	  rule to use.
X###	* Line breaks within a rule are significant in that each command line
X###	  is performed by a separate process or shell.
X###	* Make invokes a shell to process a command line if that line contains
X###	  any shell metacharacters, (;,<,>,>>,|,...).
X###  The $@ = target name
X###	@command - inhibit the display of a given command line
X###	-command - continue processing regardless of command's exit code.
X###	-@command - works
X
X$(PGM):	$(OBJECTS)
X	$(CC) $(CFLAGS) $(OBJECTS) $(LIBS) -o $@
X	@echo 
X	size $@
X
Xclean:
Xcpio:
X
Xinstall:
X	mv *.frm $(INSTALLDIR)
X
Xlint:	$(LINTFILES)
X	$(LINT.c) $(LINTFILES)
X
Xprint:
Xshar:
X
X
X###	Implicit Rules
X###	Suffixes should be ordered from target to dependency
X###	Make scans the SUFFIXES from left to right until it finds a match.
X###	The .SUFFIXES: on a line by itself puts yours at the head of the list.
X###	ex: .o .c .c~
X###	Dynamic Macros:
X###		$@  Current target
X###		$?  List of dependencies newer than the target.
X###		$<  Name of the dependency file.
X###		$*  Basename of the current target(stripped of suffix).
X###		$%  For libraries, member being processed.
X###	Dynamic Macro Modifiers:
X###		F   Filename part  ex. $(@F)
X###		D   Directory part
X.SUFFIXES:
X.SUFFIXES: .o .ec .ec~ .c .c~ .h .h~
X
X.c~.c:
X	$(GET) $<
X.h~.h:
X	$(GET) $<
X.c.o:
X	$(CC) -c $(CFLAGS) $*.c
X.c~.o:
X	$(GET) -p $<> $*.c
X	$(CC) -c $(CFLAGS) $*.c
X	rm $*.c
X.ec.o:
X	esql $(CFLAGS) -c $<
X	rm -f $*.c
X.ec~.o:
X	$(GET) -p $<> $*.ec
X	esql $(CFLAGS) -c $<
X	rm $*.ec
X	rm $*.c
SHAR_EOF
chmod 0666 utilities.d/msgbox.d/makefile || echo "restore of utilities.d/msgbox.d/makefile fails"
echo "x - extracting utilities.d/msgbox.d/msgbox.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/msgbox.d/msgbox.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH MSGBOX 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
Xmsgbox \- place a message in a STANDOUT bordered box; center box horizontally
X
X.SH SYNOPSIS
Xmsgbox msg [TopRow]
X
X.SH DESCRIPTION
X.I Msgbox 
Xplaces \fBmsg\fP, a message of 1 - 78 characters in a curses window bordered
Xby STANDOUT attributes.  The window, called "box" from here on, is 5 rows
Xhigh:  Row 1 - STANDOUT border; Row 2 - blank; Row 3 - \fBmsg\fP; Row 4 - blank;
XRow 5 - STANDOUT border.
X.P
XThe optional argument, \fBTopRow\fP, determines which screen row on which to
Xstart the box.  (0, 0 are assumed to be the home coordinates of the screen.)
XIf \fBTopRow\fP is omitted, non-numeric, or out of the range 0 - 19, the box
Xwill be started on row 0.
X
X.SH FILES
X/eng/lib/libgeti.a, the \fBGetInput(3X)\fP library containing drawbox()
X
X.SH AUTHOR
XR. Stephen Price
X
X.SH DIAGNOSTICS
X\fImsgbox\fP returns exit code zero if it was successful, 1 if the arg count is 
Xbad, and 2 if \fBmsg\fP length is less than 1 or greater than 78.
X
X.SH BUGS
XSTANDOUT attribute is not produced using the curses provided on Convergent
XTechnologies Mighty Frame.  The curses taken from a Convergent Technologies 
XMega Frame must be used on a Convergent Technologies Mighty Frame or S320.
SHAR_EOF
chmod 0644 utilities.d/msgbox.d/msgbox.1 || echo "restore of utilities.d/msgbox.d/msgbox.1 fails"
echo "x - extracting utilities.d/msgbox.d/msgbox.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/msgbox.d/msgbox.c &&
X
Xstatic char Sccsid[] = "%W%    DeltaDate %G%    ExtrDate %H%";
X
X/* msgbox.c -- Displaying a user message in a STANDOUT box (window).
X *
X *             Draw and center a curses window and place a message in the box.
X *             Center the box horizontally, making the box 2 characters
X *             wider than the message contained in argv[1].
X *             Place the top row of the box on the line indicated by argv[2]. 
X *
X *	       The box will be 5 rows in height: 
X *			border (STANDOUT)
X *			blank row
X *			message
X *			blank row
X *			border (STANDOUT)
X *
X *
X * files:      /eng/lib/libgeti.a, the GetInput library containing drawbox()
X *
X * input:      msg: argv[1] holds a message -- a string of 1 - 78 chars.
X *                 (quotation mark delimited, if there is embedded whitespace)
X *             BoxTop: argv[2] holds the screen line on which to 
X *	           start the message box.  
X *                 [This is optional.  If not given or if atoi(argv[2]) is
X *                  out of range (0-19), 0 is used.]
X *
X * output:     The MsgWind will appear with the msg on the terminal.
X *	       There will ALWAYS be a MsgWind, even if there are parameter
X *	       errors. See "exit value" below.
X *
X * exit value: Exit codes indicate execution status:
X *	       NO_ERR -- Gut, alles in ordnung!
X *             ARG_COUNT_ERR -- Failure: improper arg count (should be 2 or 3)
X *	       MSG_LEN_ERROR -- strlen(argv[2]) < 1 or > 78
X *		
X *	       The legal range of rows is 0 - 19 to fit box on screen;
X *	       If the legal range of rows is violated, 0 will be
X *	       used for BoxTop. NO_ERR exit code will be used.
X *
X *             If error, a USAGE message is displayed in the msgbox and the
X *	       appropriate non zero exit code is used.  Also a 5 second 
X *             sleep is used to preserve the USAGE msg on the terminal before
X *	       program termination.
X *
X *	       If no errors are found the user's message will appear as 
X *	       requesed and NO_ERR will be the exit value.
X *
X * note:       Will clear stdscr, since initscr() is used.
X *
X * author:     Steve Price (pacbell!pbhyf!rsp)
X *
X * bugs:       The curses on Convergent Technologies Mighty Frame does not
X *	       handle the STANDOUT attribute properly.  Use the curses from
X *             a Convergent Technologies Mega Frame, in that case.
X */
X
X
X
X
X#include <signal.h>
X#include <curses.h>
X#include "GetInput.h"
X
X
X#define MAX_ROW 19	/* last row at which a box can be started & still fit */
X#define BOX_ROWS 5	/* total height of message box */
X#define NO_ERR 0	/* it's cool, dude! */
SHAR_EOF
echo "End of part 13"
echo "File utilities.d/msgbox.d/msgbox.c is continued in part 14"
echo "14" > s2_seq_.tmp
exit 0

pjc@pcbox.UUCP (Paul J. Condie) (12/27/90)

#!/bin/sh
# this is part 14 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/msgbox.d/msgbox.c continued
#
CurArch=14
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/msgbox.d/msgbox.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/msgbox.d/msgbox.c
X#define ARG_COUNT_ERR 1	/* improper argc value in main */
X#define MSG_LEN_ERR 2	/* argv[2] message is out of range (1 - 78 chars) */
X#define STANDOUT 2	/* drawbox() needs this for border attribute. */
X
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X    char msg[78];	/* a message gotten from argv[2] or error msg */
X
X    int	BoxColumns,	/* total columns in box, calculated */
X    	BoxStartCol,	/* starting left most column of box, calculated */
X        BoxTop,		/* starting top most row of box, from argv[1] */
X    	ErrStatus;	/* values: NO_ERR, ARG_COUNT_ERR, MSG_LEN_ERR */
X
X    WINDOW *MsgWind;	/* The mesage box itself */
X
X    /* derive the box's top row value from argv[1] via atoi() */
X    BoxTop = atoi(argv[2]);
X
X    /* if error in argv[2], use 0 as BoxTop value */
X    if (BoxTop > MAX_ROW || BoxTop < 1) {
X	BoxTop=0;
X    }
X
X    /* check for proper arg count and proper msg length; If in error, form msg
X     * as an error message; if no error, use argv[2] as msg.
X     */
X    if (argc < 2 || argc > 3) {
X	ErrStatus=ARG_COUNT_ERR;
X    } else {
X	/* check the string length of the message */
X	if (strlen(argv[1]) && strlen(argv[1]) < 79 ) {
X	    ErrStatus=NO_ERR;
X	} else {
X	    ErrStatus=MSG_LEN_ERR;
X	}
X    }
X
X
X    /* if no errors were found, use argv[2] as msg, else use a USEAGE message */
X    if (ErrStatus == NO_ERR) {
X	strcpy(msg, argv[1]);
X    } else {
X	sprintf(msg, 
X	 " USAGE: %s \"Quote mark delimited message (1-78 chars)\" [TopRow] ",
X	 argv[0]); 
X    }
X
X    BoxColumns=strlen(msg) + 2;		/* size box on msg */
X    BoxStartCol=(80 - BoxColumns)/2;		/* center window horizontally */
X
X
X    initscr();
X
X
X    /* Create a new window to display a message to the user */
X    MsgWind=newwin(BOX_ROWS, BoxColumns, BoxTop, BoxStartCol);
X    drawbox(MsgWind, 1, 1, BOX_ROWS, BoxColumns, STANDOUT, STANDOUT, 0, 0);
X    mvwaddstr(MsgWind, 2, 1, msg);
X    wrefresh(MsgWind);
X
X    endwin();
X
X    /* give humans time to view usage error message */
X    if (ErrStatus != NO_ERR) 
X	sleep(5);
X
X    exit(ErrStatus);
X
X}   /* end main */
SHAR_EOF
echo "File utilities.d/msgbox.d/msgbox.c is complete"
chmod 0644 utilities.d/msgbox.d/msgbox.c || echo "restore of utilities.d/msgbox.d/msgbox.c fails"
echo "x - extracting utilities.d/MenuMsg.d/MenuMsg.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/MenuMsg.d/MenuMsg.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH MENUMSG 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
XMenuMsg -\ writes a message to a menu screen
X
X.SH SYNOPSIS
X.B MenuMsg [ DONT_CLEAR ] row col message
X
X.SH DESCRIPTION
X.B MenuMsg
Xis designed to be a utility program to be used in conjunction with the menu(1)
Xprogram.  This can be used to display a message to a menu screen without
Xmessing up the screen.  The [ DONT_CLEAR ] option causes MenuMsg not to
Xclear the line before displaying the message.
X
X
X.SH EXAMPLE
XTo print a message to the message row:
X.nf
X
X	MenuMsg `tput lines` 0 "This is a message."
X.fi
X
X.SH AUTHOR
XPaul J. Condie       7/90
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X
X.SH SEE ALSO
Xmenu(1).
SHAR_EOF
chmod 0644 utilities.d/MenuMsg.d/MenuMsg.1 || echo "restore of utilities.d/MenuMsg.d/MenuMsg.1 fails"
echo "x - extracting utilities.d/MenuMsg.d/MenuMsg.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/MenuMsg.d/MenuMsg.c &&
X/*
X**  MenuMsg(1)
X**	Display text to a menu(1) screen without trashing the screen.
X**  ARGS
X**	row and col to dispaly text to
X*/
X
X#include	<curses.h>
X#include	<term.h>
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	FILE	*fopen(), *fp;
X	char	*tparm();
X	char	*getenv();
X	char	*tparm();
X	int	_outch();
X	char	*term;
X	int	status;
X	char	*str;
X	int	row;
X	int	col;
X
X	if ((fp = fopen ("/dev/tty", "w")) == (FILE *)NULL)/* reopen terminal */
X		exit (1);
X	if ((term = getenv ("TERM")) == (char *)NULL)
X		exit (1);
X	setupterm (term, 1, &status);		/* set-up terminal */
X	if (status != 1)
X		exit (1);
X	if (cursor_address == NULL)		/* we need cursor movement */
X		exit (1);
X	if (strcmp (argv[1], "DONT_CLEAR") == 0)
X	{
X		sscanf (argv[2], "%d", &row);
X		sscanf (argv[3], "%d", &col);
X		fprintf (fp, "%s%s", tparm (cursor_address, row, col), argv[4]);
X	}
X	else
X	{
X		sscanf (argv[1], "%d", &row);
X		sscanf (argv[2], "%d", &col);
X		fprintf (fp, "%s", tparm (cursor_address, row, col));
X		fprintf (fp, "%s", tparm (clr_eol));
X		fprintf (fp, "%s%s", tparm (cursor_address, row, col), argv[3]);
X	}
X	/*
X	tputs (tparm (cursor_address, row, col), 1, _outch);
X	fprintf (fp, "%s", argv[3]);
X	*/
X	fclose (fp);
X}
X/* Paul J. Condie  7-90 */
SHAR_EOF
chmod 0644 utilities.d/MenuMsg.d/MenuMsg.c || echo "restore of utilities.d/MenuMsg.d/MenuMsg.c fails"
echo "x - extracting utilities.d/MenuMsg.d/MenuPrompt.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/MenuMsg.d/MenuPrompt.1 &&
X. \ %W% DeltaDate %G% ExtrDate %H% 
X.po 6
X.TH MENUPROMPT 1 "" "Menu Utility"
X
X.SH \s9NAME\s0
XMenuPrompt -\ writes a prompt message to a menu screen then prompts for a reply
X
X.SH SYNOPSIS
X.B MenuPrompt [ DONT_CLEAR ] row col message
X
X.SH DESCRIPTION
X.B MenuPrompt
Xis designed to be a utility program to be used in conjunction with the menu(1)
Xprogram.  This can be used to prompt for a reply from the user within a
Xmenu screen.
X
X
X.SH EXAMPLE
XTo prompt the user:
X.nf
X
X	reply=`MenuPrompt \\`tput lines\\` 0 "Do you want to continue  (y/n) ? "`
X.fi
X
X.SH AUTHOR
XPaul J. Condie       7/90
X.br
X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
X
X.SH SEE ALSO
Xmenu(1).
SHAR_EOF
chmod 0644 utilities.d/MenuMsg.d/MenuPrompt.1 || echo "restore of utilities.d/MenuMsg.d/MenuPrompt.1 fails"
echo "x - extracting utilities.d/MenuMsg.d/MenuPrompt.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/MenuMsg.d/MenuPrompt.c &&
X/*
X**  MenuPrompt(1)
X**  ARGS
X**	row and col to dispaly text to
X*/
X
X#include	<curses.h>
X#include	<term.h>
X
Xmain (argc, argv)
X	int	argc;
X	char	*argv[];
X{
X	FILE	*fopen(), *fpout, *fpin;
X	char	*tparm();
X	char	*getenv();
X	char	*tparm();
X	int	_outch();
X	char	*term;
X	int	status;
X	char	*strp;
X	int	row;
X	int	col;
X	char	buf[BUFSIZ];
X	int	ch;
X
X	if ((fpout = fopen ("/dev/tty", "w")) == (FILE *)NULL)
X		exit (1);
X	if ((fpin = fopen ("/dev/tty", "r")) == (FILE *)NULL)
X		exit (1);
X	if ((term = getenv ("TERM")) == (char *)NULL)
X		exit (1);
X	setupterm (term, 1, &status);		/* set-up terminal */
X	if (status != 1)
X		exit (1);
X	if (cursor_address == NULL)		/* we need cursor movement */
X		exit (1);
X	if (strcmp (argv[1], "DONT_CLEAR") == 0)
X	{
X		sscanf (argv[2], "%d", &row);
X		sscanf (argv[3], "%d", &col);
X		fprintf (fpout, "%s%s", tparm (cursor_address, row, col), 
X			argv[4]);
X	}
X	else
X	{
X		sscanf (argv[1], "%d", &row);
X		sscanf (argv[2], "%d", &col);
X		fprintf (fpout, "%s", tparm (cursor_address, row, col));
X		fprintf (fpout, "%s", tparm (clr_eol));
X		fprintf (fpout, "%s%s", tparm (cursor_address, row, col), 
X			argv[3]);
X	}
X
X	strp = buf;
X	while (1)
X	{
X		ch = fgetc (fpin);
X		if ((char)ch == '\n'  ||  (char)ch == '\r')
X			break;
X		*strp = (char)ch;
X		fprintf (fpout, "%c", *strp); fflush (stdout);
X		strp++;
X	}
X	*strp = '\0';
X	printf ("%s", buf);
X
X	fclose (fpin);
X	fclose (fpout);
X}
X/* Paul J. Condie  7-90 */
SHAR_EOF
chmod 0644 utilities.d/MenuMsg.d/MenuPrompt.c || echo "restore of utilities.d/MenuMsg.d/MenuPrompt.c fails"
echo "x - extracting utilities.d/MenuMsg.d/makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/MenuMsg.d/makefile &&
Xall: MenuMsg MenuPrompt
X
XMenuMsg: MenuMsg.o
X	$(CC) -O MenuMsg.c -lcurses -o MenuMsg
X
XMenuPrompt: MenuPrompt.o
X	$(CC) -O MenuPrompt.c -lcurses -o MenuPrompt
SHAR_EOF
chmod 0644 utilities.d/MenuMsg.d/makefile || echo "restore of utilities.d/MenuMsg.d/makefile fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0

rwright@novavax.UUCP (Ronald K. Wright) (01/03/91)

pjc@pcbox.UUCP (Paul J. Condie) writes:


>
> This is part 1 of a multipart archive                                    
> do not concatenate these parts, unpack them in order with /bin/sh        
>
>      A Brief Description:
>           Menu(1) is an easy-to-use menu utility that allows users to
>           operate an application system in a user-friendly, menu-
>           driven environment.  Any application software, regardless of
>           source language or operating system process can be executed
>           from menus designed with Menu(1).

I have been unable to compile menu on the AT&T 3B1..although it works
on the 3B2 except for the popup menu which dies with a core dump.
It lacks some definitions such as A_CHARTEXT in the 3B1.

Does anyone know the secret to the above problems...?
I cannot reach pjc@pcbox.uucp.
-- 
R. K. Wright MD JD                     | office: rkw@medexam.ftl.fl.us
Chief Medical Examiner, Broward County | nova:   rwright@nova.edu
Associate Professor Pathology          | home:   rkw@love1.ftl.fl.us
University of Miami School of Medicine | fax:    305 765 5193