home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume2
/
usc
/
Part1
next >
Wrap
Internet Message Format
|
1991-08-07
|
61KB
From: allbery@ncoast.UUCP (Brandon S. Allbery)
Newsgroups: comp.sources.misc
Subject: v02i033: UNIFY(r) Screens with Curses, Part 1 of 4
Message-ID: <7160@ncoast.UUCP>
Date: 31 Jan 88 04:08:06 GMT
Approved: allbery@ncoast.UUCP
Comp.sources.misc: Volume 2, Issue 33
Submitted-By: The Moderator <allbery@ncoast.UUCP>
Archive-Name: usc/Part1
I've received so many requests for my Unify(r) screen routines that I am
posting them. The USC library is in four parts; unshar them and type "make".
The curses used is System V; BSDers will want to tweak the usual stuff, such
as beep() and cbreak().
I also have a simple screen program using this; if demand warrants, I will
post it -- but in terms of features, you're probably better off with ENTER.
#--------------------------------CUT HERE-------------------------------------
#! /bin/sh
#
# This is a shell archive. Save this into a file, edit it
# and delete all lines above this comment. Then give this
# file to sh by executing the command "sh file". The files
# will be extracted into the current directory owned by
# you with default permissions.
#
# The files contained herein are:
#
# -rw-r--r-- 1 allbery users 6259 Jan 30 20:39 README
# -rw-r--r-- 1 allbery users 2745 Jan 30 20:44 Makefile
# -rw-r--r-- 1 allbery users 3344 Jan 30 18:01 Lcurses.c
# -rw-r--r-- 1 allbery users 909 Jan 30 18:01 Lunitrieve.c
# -r--r--r-- 1 allbery users 761 Jan 30 18:01 cleancrt.c
# -r--r--r-- 1 allbery users 886 Jan 30 18:01 clearscr.c
# -r--r--r-- 1 allbery users 938 Jan 30 18:01 clr_crt.c
# -r--r--r-- 1 allbery users 1406 Jan 30 18:01 curses.c
# -r--r--r-- 1 allbery users 1267 Jan 30 18:01 datefns.c
# -r--r--r-- 1 allbery users 1959 Jan 30 18:01 datetp.c
# -r--r--r-- 1 allbery users 1198 Jan 30 18:01 dbfile.c
# -r--r--r-- 1 allbery users 785 Jan 30 18:01 dbfopen.c
# -r--r--r-- 1 allbery users 804 Jan 30 18:01 dbherr.c
# -r--r--r-- 1 allbery users 628 Jan 30 18:01 dsply.c
# -r--r--r-- 1 allbery users 884 Jan 30 18:01 eras_ln.c
# -r--r--r-- 1 allbery users 717 Jan 30 18:01 eras_pg.c
# -r--r--r-- 1 allbery users 1226 Jan 30 18:01 erasprmp.c
# -r--r--r-- 1 allbery users 785 Jan 30 18:01 error.c
# -r--r--r-- 1 allbery users 2152 Jan 30 18:01 gdata.c
# -r--r--r-- 1 allbery users 1818 Jan 30 18:01 gprint.c
# -r--r--r-- 1 allbery users 2688 Jan 30 18:01 gtube.c
# -r--r--r-- 1 allbery users 2094 Jan 30 18:01 iamt.c
# -r--r--r-- 1 allbery users 5178 Jan 30 18:01 idate.c
# -r--r--r-- 1 allbery users 2070 Jan 30 18:01 iflt.c
# -r--r--r-- 1 allbery users 2114 Jan 30 18:01 ihamt.c
# -r--r--r-- 1 allbery users 1730 Jan 30 18:01 ilong.c
#
echo 'x - README'
if test -f README; then echo 'shar: not overwriting README'; else
sed 's/^X//' << '________This_Is_The_END________' > README
X``USC'' -- UNIFY(r) Screens using Curses
XUNIFY(r) is a registered trademark of Unify Corporation.
X
XTHIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
XIS HEREBY PLACED IN THE PUBLIC DOMAIN.
X
XThis is a short description of the extended functionality of USC. The
Xfunctions are source-level compatible with the standard UNIFY calls, but NOT
Xcompatible with the special internal calls used in ENTER. This code is known
Xto work with UNIFY 3.2, it will probably work with UNIFY 3.1, I have no idea
Xhow compatible it is with UNIFY 4.0. INCLUDE THE COMPILER DIRECTIVE -DUNIFY32
XTO ENABLE USE OF ADVANCED FIELD ATTRIBUTES IN UNIFY 3.2.
X
XAll the I/O functions use curses. Provision is made only for stdscr; use of
Xother windows must be made at the curses level. For the low-level UNIFY
Xfunctions which expect an fd argument, the provided fd MUST BE 1 or the USC
Xroutines will print an error message and dump core.
X
XInput functions support the following special keys:
X
X^H delete character before cursor
X^F move cursor forward; wraps to beginning of field
X^B move cursor backward; wraps to end of field
X^A move cursor to beginning of field
X^N move cursor to end of field
X^O insert a space
X^D delete character after cursor
X^K clear to end of field
X^X immediate program exit
X^L, ^R redisplay screen
X^P push a shell
X^U, TAB return -2
X^M, ^J return -3 or 0 depending on input state
X
XIf the "look" capability is enabled, the following character may be used:
X
X^V view parent record
X
XIf extended return codes are enabled (see below), the following may be used:
X
X^E, ESC return -5 or -6 depending on input state
X^U, TAB return -2 or -7 depending on input state
X
XThe input routines check to see if the buffer has been filled; if extended
Xreturn codes are enabled, special codes are returned when ^E or ^U are done
Xon fields after data is entered in them. This allows the user to type
Xsomething before a ^U or ^E and have it accepted.
X
XExtended return codes are processed via the setxrc() function. To use this
Xfunction, #include the file "xrc.h" in your program and invoke setxrc() with
Xan integer containing a combination of zero or more of the following flags:
X
X XRC_GO allow the ^E key to cause end of input
X XRC_XOK return special values if data entered in field
X XRC_LOOK on screen fields in explicit relationships,
X allow ^V to display parent record
X
XTHE USE OF XRC_XOK WILL BREAK PROGRAMS NOT EXPECTING IT!!! Use of XRC_GO may
Xalso break programs; but XRC_LOOK alone will NEVER return an unexpected return
Xcode.
X
XFor each input function in the UNIFY manual, there is an update function; the
Xname of the update function is the name with the leading `g' replaced with a
X`up'. Thus, the update version of gtube() is uptube(). The update functions
Xare called in the same way as the input functions, but they start with the
Xexisting data values, and if XRC_XOK is enabled the -2, -3, and -5 return
Xcodes will NEVER be returned.
X
XInput which can be related to a database field (primarily gdata()) will do
Xsome extra work for you. If write passwords are enabled and gdata() is
Xinvoked on a write-protected field, USC will ask for the modify password and
Xretry the pfield(); if the password is incorrect, the operation fails. If the
Xrecord is locked, the program will ask you if you wish to retry the pfield()
Xor abort the operation. Both of these make life easier on a programmer. Note
Xthat gdata() is called internally by input() and upfield() [the update form of
Xinput(); update() is used].
X
XScreen fields may be enhanced by a program by setting special flags; in
Xparticular, the UPCASE flag may be set to force USC to force all input to
Xuppercase for the field. NO PROVISION IS MADE TO STORE THIS IN UNIFY SCREEN
XFILES, AS THIS WOULD BREAK EXISTING UNIFY PROGRAMS. To use this feature,
X#include the file "xsfldesc.h" and call the function xsfldesc(sfield). This
Xfunctioon returns a pointer to the internal screen field structure, which
Xcontains *all* of the information for the screen field (not just the x, y,
Xfield information in Unify's sfdesc structure). THIS IS NOT A COPY OF THE
XDATA; CORRUPTING THIS INFORMATION MAY CAUSE A CORE DUMP. The UPCASE flag may
Xthen be ORed in with the structure member xsf_typ to force uppercase input.
X
XSome new functions are provided as well; in particular, ringmenu() will
Xexecute a ring menu at the top of the screen. (For the more eclectic members
Xof the audience, think of Informix-4GL's menus.) The menu is defined as an
Xarray of structures; the structure is defined in "ringmenu.h". An example of
Xa ring menu might be:
X
X#include "ringmenu.h"
X
Xstruct ringmenu mymenu[] = {
X 'A', "Add", "Add a new order.",
X 'D', "Delete", "Delete an order.",
X 'M', "Modify", "Modify an existing order.",
X 'E', "Exit", "Exit the order maintenance.",
X EOM,
X};
X
X...
Xringmenu("ORDERS", mymenu);
X
XMany of the function keys used in field I/O have similar meanings in a ring
Xmenu. In particular, since a ring menu may be larger than the screen width
Xthe ^F and ^B keys move by "pages"; and ^V pops up a full-screen listing of
Xall selections on the menu.
X
XSince the *error() routines had to be replaced anyway to insure that curses
XI/O is reset, I provide 3.2-compatible error routines... which use an error
Xlog even under UNIFY 3.1, so you get a bonus. There are some added features:
X
Xextern void (*errexit)();
X
XSet this function to some function to execute after displaying the error
Xmessage but before final program exit. Curses mode is turned off before the
Xfunction is called. I most commonly point this to abort() so I have more
Xinformation to work with when a program bombs.
X
Xint xerror(ier, id, format[, args ...])
Xint ier;
Xchar *id, *format;
X
XThis function is the lowest-level interface to the error mechanism; it
X*should* be the highest, but.... The argument "ier" becomes the "Status" in
Xthe error log; "id" is the offending function (the calling function is
X"xerror"); the notes are built from the printf-style format and its arguments.
X
Xextern char errcall[30];
X
XThis string contains "xerror" initially; it is the value printed for "calling
Xfunction" in the error log. It is changed by the standard error routines to
Xname themselves; you can change it in a custom error function if you wish.
X
________This_Is_The_END________
if test `wc -l < README` -ne 138; then
echo 'shar: README was damaged during transit (should have been 138 bytes)'
fi
fi ; : end of overwriting check
echo 'x - Makefile'
if test -f Makefile; then echo 'shar: not overwriting Makefile'; else
sed 's/^X//' << '________This_Is_The_END________' > Makefile
XSHELL = /bin/sh
X
X.SUFFIXES: .c,v .h,v
X
X.c,v.o:
X @co -q $*.c
X cc $(CFLAGS) -c $*.c
X @rm -f $*.c
X
X.h,v.h:
X @co -q $*.h
X
XUNIFY = /appl/u32
XUINCL = $(UNIFY)/include
XOBJ = curses.o datetp.o gdata.o gtube.o iamt.o idate.o iflt.o ihamt.o ilong.o \
X inbuf.o inl.o inscrf.o ishort.o istr.o itime.o loadscr.o prtmsg.o \
X xerror.o dbfopen.o dbfile.o setxrc.o input.o setraw.o setcook.o \
X cleancrt.o clearscr.o clr_crt.o eras_ln.o dsply.o erasprmp.o keybrd.o \
X mv_cur.o priamd.o ptct_crt.o ptct_wrt.o prmp.o prmpf.o prmprv.o \
X yorn.o sfldesc.o xsfldesc.o pamt.o pdate.o pflt.o phamt.o plong.o \
X pshort.o pstr.o ptime.o outscrf.o ptube.o pdata.o outbuf.o output.o \
X error.o uerror.o dbherr.o pageout.o eras_pg.o xsize.o uamt.o udate.o \
X uflt.o uhamt.o ulong.o ushort.o ustr.o utime.o updata.o uptube.o \
X upbuf.o upscrf.o upfield.o zoom.o gprint.o pflush.o inc.o datefns.o \
X shellout.o incs.o ringmenu.o
XSRC = curses.c datetp.c gdata.c gtube.c iamt.c idate.c iflt.c ihamt.c ilong.c \
X inbuf.c inl.c inscrf.c ishort.c istr.c itime.c loadscr.c prtmsg.c \
X xerror.c dbfopen.c dbfile.c setxrc.c input.c setraw.c setcook.c \
X cleancrt.c clearscr.c clr_crt.c eras_ln.c dsply.c erasprmp.c keybrd.c \
X mv_cur.c priamd.c ptct_crt.c ptct_wrt.c prmp.c prmpf.c prmprv.c \
X yorn.c sfldesc.c xsfldesc.c pamt.c pdate.c pflt.c phamt.c plong.c \
X pshort.c pstr.c ptime.c outscrf.c ptube.c pdata.c outbuf.c output.c \
X error.c uerror.c dbherr.c pageout.c eras_pg.c xsize.c uamt.c udate.c \
X uflt.c uhamt.c ulong.c ushort.c ustr.c utime.c updata.c uptube.c \
X upbuf.c upscrf.c upfield.c zoom.c gprint.c pflush.c inc.c datefns.c \
X shellout.c incs.c ringmenu.c
XTG = tgraph.a
XCFLAGS = -O -I$(UINCL) -DUNIFY32 -DTG
X#CFLAGS = -O -DTERMCAP -I$(UINCL)
XLINT =
X
Xlibusc.a: $(OBJ)
X @rm -f libusc.a
X ar rc libusc.a $(OBJ)
X
Xlint:
X @co -q $(SRC)
X lint $(CFLAGS) $(LINT) $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
Xlint31c:
X @co -q $(SRC)
X lint -UUNIFY32 -DTERMCAP -UTG $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
Xlint32c:
X @co -q $(SRC)
X lint -DUNIFY32 -DTERMCAP -UTG $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
Xlint31i:
X @co -q $(SRC)
X lint -UUNIFY32 -UTERMCAP -UTG $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
Xlint32i:
X @co -q $(SRC)
X lint -DUNIFY32 -UTERMCAP -UTG $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
Xlint31g:
X @co -q $(SRC)
X lint -UUNIFY32 -UTERMCAP -DTG $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
Xlint32g:
X @co -q $(SRC)
X lint -DUNIFY32 -UTERMCAP -DTG $(SRC) Lcurses.c Lunitrieve.c > lint.out
X @rm -f $(SRC)
X
X$(OBJ): usc.h
X
Xtester: tester.o libusc.a
X ld -x -o tester /lib/crt0.o \
X tester.o \
X libusc.a \
X $(UNIFY)/lib/libd[12].a \
X libusc.a \
X $(UNIFY)/lib/libx.a $(TG) -lcurses -lm -lc
________This_Is_The_END________
if test `wc -l < Makefile` -ne 89; then
echo 'shar: Makefile was damaged during transit (should have been 89 bytes)'
fi
fi ; : end of overwriting check
echo 'x - Lcurses.c'
if test -f Lcurses.c; then echo 'shar: not overwriting Lcurses.c'; else
sed 's/^X//' << '________This_Is_The_END________' > Lcurses.c
X/*LINTLIBRARY*/
X
X/*
X * Curses(3x) routines (llib-lcurses is empty!!!?)
X */
X
X#define NOMACROS
X#include <curses.h>
X
X#ifndef TERMCAP
X
X/* curses.h defines struct screen, never declares structure */
X
Xstruct screen { char dummy; };
X
X#endif
X
XWINDOW *stdscr = (WINDOW *) 0;
XWINDOW *curscr = (WINDOW *) 0;
Xint LINES = 0, COLS = 0;
Xchar *Def_term = "unknown";
Xchar ttytype[128] = "unknown";
X
Xint echo() {return 0;}
Xint noecho() {return 0;}
Xint cbreak() {return 0;}
Xint nocbreak() {return 0;}
Xint nl() {return 0;}
Xint nonl() {return 0;}
Xint waddch(win, ch) WINDOW *win; {return 0;}
Xint wgetch(win) WINDOW *win; {return 0;}
Xint waddstr(win, s) WINDOW *win; char *s; {return 0;}
Xint wgetstr(win, s) WINDOW *win; char *s; {return 0;}
Xint wmove(win, y, x) WINDOW *win; {return 0;}
Xint wclear(win) WINDOW *win; {return 0;}
Xint werase(win) WINDOW *win; {return 0;}
Xint wclrtobot(win) WINDOW *win; {return 0;}
Xint wclrtoeol(win) WINDOW *win; {return 0;}
Xint winsertln(win) WINDOW *win; {return 0;}
Xint wdeleteln(win) WINDOW *win; {return 0;}
Xint wrefresh(win) WINDOW *win; {return 0;}
Xint winsch(win, ch) WINDOW *win; {return 0;}
Xint wdelch(win) WINDOW *win; {return 0;}
Xint wstandout(win) WINDOW *win; {return 0;}
Xint wstandend(win) WINDOW *win; {return 0;}
X#ifndef TERMCAP
Xint flushinp() {return 0;}
Xint wattron(win, at) WINDOW *win; {return 0;}
Xint wattroff(win, at) WINDOW *win; {return 0;}
Xint wattrset(win, at) WINDOW *win; {return 0;}
Xint beep() { return 0; }
X#endif TERMCAP
X/* AARGH! ! ! ! ! Why is initscr() defined as (WINDOW *) ????? */
XWINDOW *initscr() { return (WINDOW *) 0; }
Xint endwin() { return 0; }
X/*VARARGS1 PRINTFLIKE1*/
Xint printw(s) char *s; { return 0; }
X/*VARARGS2 PRINTFLIKE2*/
Xint wprintw(win, s) WINDOW *win; char *s; { return 0; }
X/*VARARGS3 PRINTFLIKE3*/
Xint mvprintw(y, x, s) char *s; { return 0; }
X/*VARARGS4 PRINTFLIKE4*/
Xint mvwprintw(win, y, x, s) WINDOW *win; char *s; { return 0; }
Xint winch(win) WINDOW *win; { return 0; }
Xint wsetscrreg(win, t, b) WINDOW *win; { return 0; }
Xint mvwaddch(win, y, x, ch) WINDOW *win; { return 0; }
Xint mvwgetch(win, y, x) WINDOW *win; { return 0; }
Xint mvwaddstr(win, y, x, s) char *s; WINDOW *win; { return 0; }
Xint mvwgetstr(win, y, x, s) char *s; WINDOW *win; { return 0; }
Xint mvwinch(win, y, x) WINDOW *win; { return 0; }
Xint mvwdelch(win, y, x) WINDOW *win; { return 0; }
Xint mvwinsch(win, y, x, c) WINDOW *win; { return 0; }
Xint mvaddch(y, x, c) { return 0; }
Xint mvgetch(y, x) { return 0; }
Xint mvaddstr(y, x, s) char *s; { return 0; }
Xint mvgetstr(y, x, s) char *s; { return 0; }
Xint mvinch(y, x) { return 0; }
Xint mvdelch(y, x) { return 0; }
Xint mvinsch(y, x, c) { return 0; }
Xint refresh() { return 0; }
Xint move(y, x) { return 0; }
Xint clrtoeol() { return 0; }
Xint addch(c) { return 0; }
Xint addstr(s) char *s; { return 0; }
Xint attron(a) { return 0; }
Xint attroff(a) { return 0; }
Xint erase() { return 0; }
Xint attrset(a) { return 0; }
Xint clearok(win) WINDOW *win; { return 0; }
Xint clear() { return 0; }
Xint standout() { return 0; }
Xint standend() { return 0; }
Xint clrtobot() { return 0; }
XWINDOW *newwin(x, y, x1, y1) { return (WINDOW *) 0; }
Xint delwin(w) WINDOW *w; { return 0; }
Xint touchwin(w) WINDOW *w; { return 0; }
Xint box(w, v, h) WINDOW *w; { return 0; }
X#ifdef TG
Xvoid wgraph(w, s) WINDOW *w; char *s; {}
X#include "tgraph.h"
Xstruct __g__ch_ __graph[25];
X#endif
________This_Is_The_END________
if test `wc -l < Lcurses.c` -ne 102; then
echo 'shar: Lcurses.c was damaged during transit (should have been 102 bytes)'
fi
fi ; : end of overwriting check
echo 'x - Lunitrieve.c'
if test -f Lunitrieve.c; then echo 'shar: not overwriting Lunitrieve.c'; else
sed 's/^X//' << '________This_Is_The_END________' > Lunitrieve.c
X/*LINTLIBRARY*/
X
X/*
X * UNITRIEVE(r) lint library
X */
X
X#include <fdesc.h>
X
Xchar langtp[2] = {'A', 'M'};
Xint logacl = 0;
Xstatic char __v_p_buf[128] = "unknown";
Xchar *V_prgnm = __v_p_buf;
X
Xint pfield(fld, buf) char *buf; { return 0; }
Xint accsfld(fld, pass, rwf) char *pass; { return 0; }
Xint fldesc(fld, buf) FLDESC *buf; { return 0; }
Xshort kday(date) int date[3]; { return 0; }
Xvoid kdate(day, date) short day; int date[3]; {}
Xint ivcmp(v1, v2, l) char *v1, *v2; { return 0; }
Xvoid cfill(c, v, l) char *v; {}
Xint gfield(fld, buf) char *buf; { return 0; }
X#ifdef UNIFY32
Xvoid dspdt(d, buf) short d; char *buf; {}
Xchar *getdoms(fld, typ) { return (char *) 0; }
Xint domchk(fld, buf) char *buf; { return 0; }
Xint numflds() { return 0; }
Xchar *fldsyn(f) { return ""; }
Xint reckey(r) { return 0; }
Xint seqacc(r, t) { return 0; }
Xint loc(r, tp) long *tp; { return 0; }
Xint setloc(r, t) long t; { return 0; }
X#endif
________This_Is_The_END________
if test `wc -l < Lunitrieve.c` -ne 32; then
echo 'shar: Lunitrieve.c was damaged during transit (should have been 32 bytes)'
fi
fi ; : end of overwriting check
echo 'x - cleancrt.c'
if test -f cleancrt.c; then echo 'shar: not overwriting cleancrt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > cleancrt.c
X/*
X * $Header: cleancrt.c,v 1.2 87/04/29 11:29:57 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: cleancrt.c,v $
X * Revision 1.2 87/04/29 11:29:57 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: cleancrt() -- Clear the foreground (data prompts) on the
X * screen.
X *
X * DIFFERENCE FROM UNIFY: Curses doesn't know about clear foreground, and
X * if it did it'd do it iteself anyway. We always call erasprmp() and let
X * curses optimize the result.
X */
X
Xvoid cleancrt() {
X erasprmp(0, __nsf - 1);
X}
________This_Is_The_END________
if test `wc -l < cleancrt.c` -ne 31; then
echo 'shar: cleancrt.c was damaged during transit (should have been 31 bytes)'
fi
fi ; : end of overwriting check
echo 'x - clearscr.c'
if test -f clearscr.c; then echo 'shar: not overwriting clearscr.c'; else
sed 's/^X//' << '________This_Is_The_END________' > clearscr.c
X/*
X * $Header: clearscr.c,v 1.3 87/04/29 17:06:53 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: clearscr.c,v $
X * Revision 1.3 87/04/29 17:06:53 brandon
X * Now retains top 2 lines AFTER curses. You can roll your own screen, but
X * you still can't use the menu handler's heading.
X *
X * Revision 1.2 87/04/29 11:30:09 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: clearscr() -- Clear the screen preparatory to loading a new
X * screen form.
X *
X * DIFFERENCE FROM UNIFY: Curses can't save the first three lines of the
X * screen. (Two for UNIFY 3.2.)
X */
X
Xvoid clearscr() {
X (void) move(2, 0);
X (void) clrtobot();
X}
________This_Is_The_END________
if test `wc -l < clearscr.c` -ne 35; then
echo 'shar: clearscr.c was damaged during transit (should have been 35 bytes)'
fi
fi ; : end of overwriting check
echo 'x - clr_crt.c'
if test -f clr_crt.c; then echo 'shar: not overwriting clr_crt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > clr_crt.c
X/*
X * $Header: clr_crt.c,v 1.2 87/04/29 11:30:12 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: clr_crt.c,v $
X * Revision 1.2 87/04/29 11:30:12 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: clr_crt() -- clear, forcibly, a screen on a given fd.
X *
X * DIFFERENCE FROM UNIFY: If fd isn't 1, you get a run-time error; use the
X * old library if you want funny terminal stuff, or else hook into terminfo-
X * based curses and call newterm(). I daresay nobody uses the fd hook anyway.
X */
X
Xvoid clr_crt(fd, flg) {
X if (fd != 1)
X xerror(-1, "clr_crt", "Multi-terminal operation on fd %d not supported", fd);
X if (flg == 'a')
X (void) clear();
X else
X erasprmp(0, __nsf - 1);
X}
________This_Is_The_END________
if test `wc -l < clr_crt.c` -ne 35; then
echo 'shar: clr_crt.c was damaged during transit (should have been 35 bytes)'
fi
fi ; : end of overwriting check
echo 'x - curses.c'
if test -f curses.c; then echo 'shar: not overwriting curses.c'; else
sed 's/^X//' << '________This_Is_The_END________' > curses.c
X/*
X * $Header: curses.c,v 1.2 87/04/29 11:30:14 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: curses.c,v $
X * Revision 1.2 87/04/29 11:30:14 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X#ifdef TERMCAP
X
X/*
X * The old style curses doesn't know about attributes, except for standout.
X * We have to emulate them... which basically means ignoring them, except
X * for A_STANDOUT == A_REVERSE.
X */
X
Xint setattr(win, att)
XWINDOW *win; {
X if (att == A_STANDOUT)
X return wstandout(win);
X else
X return wstandend(win);
X}
X
Xint attron(win, att)
XWINDOW *win; {
X if (att == A_STANDOUT)
X return wstandout(win);
X return OK;
X}
X
Xint attroff(win, att)
XWINDOW *win; {
X if (att == A_STANDOUT)
X return wstandend(win);
X return OK;
X}
X
Xint flushinp() {
X#ifdef TIOCGETP
X struct sgttyb t;
X
X if (ioctl(0, TIOCGETP, &t) == -1)
X return ERR;
X if (ioctl(0, TIOCSETP, &t) == -1)
X return ERR;
X#else
X# ifdef TCFLSH
X if (ioctl(0, TCFLSH, 0) == -1)
X return ERR;
X# else
X struct sgttyb t;
X
X if (gtty(0, &t) == -1)
X return ERR;
X if (stty(0, &t) == -1)
X return ERR;
X# endif
X#endif
X return OK;
X}
X
X#else
X# ifndef lint
Xstatic char dummy[] = ""; /* gratuitous dumb-loader food */
X# endif
X#endif
________This_Is_The_END________
if test `wc -l < curses.c` -ne 78; then
echo 'shar: curses.c was damaged during transit (should have been 78 bytes)'
fi
fi ; : end of overwriting check
echo 'x - datefns.c'
if test -f datefns.c; then echo 'shar: not overwriting datefns.c'; else
sed 's/^X//' << '________This_Is_The_END________' > datefns.c
X/*
X * $Header: datefns.c,v 1.1 87/06/01 16:24:26 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: datefns.c,v $
X * Revision 1.1 87/06/01 16:24:26 brandon
X * Initial revision
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X#ifdef BSD
X/*
X * What is this, anyway? Did UCB make localtime() a system call???
X * (If this is because of setitimer(), then WHY ARE setitimer() AND localtime()
X * IN THE SAME INCLUDE FILE?????)
X */
X# include <sys/time.h>
X#else
X# include <time.h>
X#endif
X
Xextern struct tm *localtime();
X
X/*
X * Internal date manipulating functions. They may be called by external
X * functions safely.
X */
X
X/*
X * Return today's date in UNIFY(r) internal format.
X */
X
Xshort _dt_today() {
X long now;
X struct tm *tmbuf;
X int date[3];
X
X now = time((long *) 0);
X tmbuf = localtime(&now);
X date[MONTH] = tmbuf->tm_mon + 1;
X date[DAY] = tmbuf->tm_mday;
X date[YEAR] = tmbuf->tm_year;
X return kday(date);
X}
X
X/*
X * Return the current year.
X */
X
Xint _dt_year() {
X long now;
X struct tm *tmbuf;
X
X now = time((long *) 0);
X tmbuf = localtime(&now);
X return tmbuf->tm_year;
X}
________This_Is_The_END________
if test `wc -l < datefns.c` -ne 65; then
echo 'shar: datefns.c was damaged during transit (should have been 65 bytes)'
fi
fi ; : end of overwriting check
echo 'x - datetp.c'
if test -f datetp.c; then echo 'shar: not overwriting datetp.c'; else
sed 's/^X//' << '________This_Is_The_END________' > datetp.c
X/*
X * $Header: datetp.c,v 1.5 87/05/12 15:35:12 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: datetp.c,v $
X * Revision 1.5 87/05/12 15:35:12 brandon
X * langtp[] wasn't being set properly.
X *
X * Revision 1.4 87/04/29 16:01:06 brandon
X * The #ifdef for UNIFY32 should have been an #ifndef.
X *
X * Revision 1.3 87/04/29 12:20:40 brandon
X * Not only is DATETP not supported under pre-3.2 UNIFY, but parmnt tends to
X * dump core if you attempt to change it.
X *
X * Revision 1.2 87/04/29 11:30:15 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X#ifndef UNIFY32
X
X/* No real choice, unfortunately -- and parmnt dumps core if you try! :-( */
Xint _ldbrt = UNITED_STATES | MDY;
X
X#else
X
X/*
X * Under UNIFY 3.2, the "langtp" variable becomes a means of changing the
X * parsing of dates, and also determines whether a bracket conforms to the
X * standards of the United States -- `[]' -- or to the rest of the world
X * -- `()'. (As usual, the U.S. is oddball. Kind of makes you wonder...)
X */
X
Xextern char langtp[2];
Xint _ldbrt = -1;
X
X#define CH(x,y) (((x) << 8) | (y))
X
Xvoid _sdbrt() {
X if (_ldbrt != -1)
X return;
X if (langtp[0] == '\0') {
X char *cp;
X
X if ((cp = getenv("DATETP")) == (char *) 0)
X cp = "EN"; /* UNIFY still has old default?! */
X langtp[0] = cp[0];
X langtp[1] = cp[1];
X }
X switch (CH(langtp[0], langtp[1])) {
X case CH('A', 'M'):
X case CH('E', 'N'):
X _ldbrt = UNITED_STATES | MDY;
X break;
X case CH('E', 'U'):
X _ldbrt = INTERNATIONAL | DMY;
X break;
X case CH('U', 'S'):
X _ldbrt = INTERNATIONAL | MDY;
X break;
X default:
X {
X char buf[3];
X buf[0] = langtp[0];
X buf[1] = langtp[1];
X buf[2] = '\0';
X prtmsg(1, 22, buf);
X }
X _ldbrt = INTERNATIONAL | YMD;
X }
X}
X
X#endif /* UNIFY32 */
________This_Is_The_END________
if test `wc -l < datetp.c` -ne 83; then
echo 'shar: datetp.c was damaged during transit (should have been 83 bytes)'
fi
fi ; : end of overwriting check
echo 'x - dbfile.c'
if test -f dbfile.c; then echo 'shar: not overwriting dbfile.c'; else
sed 's/^X//' << '________This_Is_The_END________' > dbfile.c
X/*
X * $Header: dbfile.c,v 1.3 87/05/12 10:58:24 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: dbfile.c,v $
X * Revision 1.3 87/05/12 10:58:24 brandon
X * OOPS: null filename if no extension!
X *
X * Revision 1.2 87/04/29 11:30:17 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X#include <sys/types.h>
X#include <sys/stat.h>
X
X/*
X * Generate a file name. Append the given extension (if any), and try to
X * find it in the DBPATH or the current directory.
X */
X
Xchar *dbfile(fn, ext)
Xchar *fn, *ext; {
X char fnb[1024];
X static char path[1024];
X static char *dbpath = (char *) 0;
X struct stat exist;
X
X if (ext != (char *) 0)
X (void) sprintf(fnb, "%s.%s", fn, ext);
X else
X (void) strcpy(fnb, fn);
X if (dbpath == (char *) 0 && (dbpath = getenv("DBPATH")) == (char *) 0)
X dbpath = ".";
X (void) sprintf(path, "%s/%s", dbpath, fnb);
X if (stat(path, &exist) == 0)
X return path;
X (void) strcpy(path, fnb);
X return (stat(path, &exist) == 0? path: (char *) 0);
X}
________This_Is_The_END________
if test `wc -l < dbfile.c` -ne 48; then
echo 'shar: dbfile.c was damaged during transit (should have been 48 bytes)'
fi
fi ; : end of overwriting check
echo 'x - dbfopen.c'
if test -f dbfopen.c; then echo 'shar: not overwriting dbfopen.c'; else
sed 's/^X//' << '________This_Is_The_END________' > dbfopen.c
X/*
X * $Header: dbfopen.c,v 1.3 87/04/29 15:00:47 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: dbfopen.c,v $
X * Revision 1.3 87/04/29 15:00:47 brandon
X * Since xerror() calls dbfopen(), dbfopen() cannot call xerror().
X *
X * Revision 1.2 87/04/29 11:30:19 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Open a file associated with a database.
X */
X
XFILE *_dbfopen(fn, mode)
Xchar *fn, *mode; {
X char *dbf;
X
X if ((dbf = dbfile(fn, (char *) 0)) == (char *) 0)
X return (FILE *) 0; /* xerror() calls us */
X return fopen(dbf, mode);
X}
________This_Is_The_END________
if test `wc -l < dbfopen.c` -ne 34; then
echo 'shar: dbfopen.c was damaged during transit (should have been 34 bytes)'
fi
fi ; : end of overwriting check
echo 'x - dbherr.c'
if test -f dbherr.c; then echo 'shar: not overwriting dbherr.c'; else
sed 's/^X//' << '________This_Is_The_END________' > dbherr.c
X/*
X * $Header: dbherr.c,v 1.1 87/04/29 14:57:38 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: dbherr.c,v $
X * Revision 1.1 87/04/29 14:57:38 brandon
X * Initial revision
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: dbherr() -- Print a data dictionary error message and exit
X *
X * DIFFERENCE FROM UNIFY: *Always* uses the error log, even in pre-3.2
X * versions. Also, my idea of what an error should log seems to differ from
X * that of Unify Corp.
X */
X
Xvoid dbherr(s)
Xchar *s; {
X (void) strcpy(errcall, "dbherr");
X xerror(0, "Data Dictionary error -- see Notes", "%s", s);
X}
________This_Is_The_END________
if test `wc -l < dbherr.c` -ne 32; then
echo 'shar: dbherr.c was damaged during transit (should have been 32 bytes)'
fi
fi ; : end of overwriting check
echo 'x - dsply.c'
if test -f dsply.c; then echo 'shar: not overwriting dsply.c'; else
sed 's/^X//' << '________This_Is_The_END________' > dsply.c
X/*
X * $Header: dsply.c,v 1.2 87/04/29 11:30:21 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: dsply.c,v $
X * Revision 1.2 87/04/29 11:30:21 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: dsply() -- Display a set of screen fields
X *
X * DIFFERENCE FROM UNIFY: None (!) at this level.
X */
X
Xdsply(ssfld, esfld) {
X for (; ssfld <= esfld; ssfld++)
X output(ssfld);
X}
________This_Is_The_END________
if test `wc -l < dsply.c` -ne 29; then
echo 'shar: dsply.c was damaged during transit (should have been 29 bytes)'
fi
fi ; : end of overwriting check
echo 'x - eras_ln.c'
if test -f eras_ln.c; then echo 'shar: not overwriting eras_ln.c'; else
sed 's/^X//' << '________This_Is_The_END________' > eras_ln.c
X/*
X * $Header: eras_ln.c,v 1.2 87/04/29 11:30:22 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: eras_ln.c,v $
X * Revision 1.2 87/04/29 11:30:22 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: eras_ln() -- clear, forcibly, a line on a given fd.
X *
X * DIFFERENCE FROM UNIFY: If fd isn't 1, you get a run-time error; use the
X * old library if you want funny terminal stuff, or else hook into terminfo-
X * based curses and call newterm(). I daresay nobody uses the fd hook anyway.
X */
X
Xvoid eras_ln(fd) {
X if (fd != 1)
X xerror(-1, "eras_ln", "Multi-terminal operation on fd %d not supported", fd);
X (void) clrtoeol();
X}
________This_Is_The_END________
if test `wc -l < eras_ln.c` -ne 32; then
echo 'shar: eras_ln.c was damaged during transit (should have been 32 bytes)'
fi
fi ; : end of overwriting check
echo 'x - eras_pg.c'
if test -f eras_pg.c; then echo 'shar: not overwriting eras_pg.c'; else
sed 's/^X//' << '________This_Is_The_END________' > eras_pg.c
X/*
X * $Header: eras_pg.c,v 1.1 87/05/11 12:26:53 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: eras_pg.c,v $
X * Revision 1.1 87/05/11 12:26:53 brandon
X * Initial revision
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Groping in the dark, trying to prevent the loading of the original Unify
X * code, which conflicts with the curses echo() function (terminfo only)
X */
X
Xvoid eras_pg(fd) {
X if (fd != 1)
X xerror(-1, "eras_pg", "Multi-terminal operation on fd %d not supported", fd);
X (void) clrtobot();
X}
________This_Is_The_END________
if test `wc -l < eras_pg.c` -ne 29; then
echo 'shar: eras_pg.c was damaged during transit (should have been 29 bytes)'
fi
fi ; : end of overwriting check
echo 'x - erasprmp.c'
if test -f erasprmp.c; then echo 'shar: not overwriting erasprmp.c'; else
sed 's/^X//' << '________This_Is_The_END________' > erasprmp.c
X/*
X * $Header: erasprmp.c,v 1.2 87/04/29 11:30:24 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: erasprmp.c,v $
X * Revision 1.2 87/04/29 11:30:24 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: erasprmp() -- Clear the data portions of screen fields
X *
X * DIFFERENCES FROM UNIFY: Since data fields are foreground, we enter
X * underline mode (if supported).
X */
X
Xvoid erasprmp(ssfld, esfld) {
X int len;
X
X (void) attron(A_UNDERLINE);
X for (; ssfld <= esfld; ssfld++) {
X if (ssfld < 0 || ssfld >= __nsf)
X xerror(-1, "erasprmp", "Invalid screen field %d", ssfld);
X if (__scf[ssfld].q_len == 0)
X continue; /* no data field involved */
X len = __scf[ssfld].q_len;
X switch (__scf[ssfld].q_type) {
X case DATE:
X len = 8;
X break;
X case HR:
X len = 5;
X break;
X case FLT:
X len /= 10;
X break;
X case HAMT:
X case AMT:
X len += 3;
X break;
X }
X (void) mvprintw(__scf[ssfld].q_fy, __scf[ssfld].q_fx, "%*s", len, "");
X }
X (void) attroff(A_UNDERLINE);
X}
________This_Is_The_END________
if test `wc -l < erasprmp.c` -ne 55; then
echo 'shar: erasprmp.c was damaged during transit (should have been 55 bytes)'
fi
fi ; : end of overwriting check
echo 'x - error.c'
if test -f error.c; then echo 'shar: not overwriting error.c'; else
sed 's/^X//' << '________This_Is_The_END________' > error.c
X/*
X * $Header: error.c,v 1.1 87/04/29 14:57:30 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: error.c,v $
X * Revision 1.1 87/04/29 14:57:30 brandon
X * Initial revision
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: error() -- Print an error message and exit
X *
X * DIFFERENCE FROM UNIFY: *Always* uses the error log, even in pre-3.2
X * versions. Also, my idea of what an error should log seems to differ from
X * that of Unify Corp.
X */
X
Xvoid error(s, ier)
Xchar *s; {
X (void) strcpy(errcall, "error");
X xerror(ier, "UNITRIEVE error -- see Notes", "%s", s);
X}
________This_Is_The_END________
if test `wc -l < error.c` -ne 32; then
echo 'shar: error.c was damaged during transit (should have been 32 bytes)'
fi
fi ; : end of overwriting check
echo 'x - gdata.c'
if test -f gdata.c; then echo 'shar: not overwriting gdata.c'; else
sed 's/^X//' << '________This_Is_The_END________' > gdata.c
X/*
X * $Header: gdata.c,v 1.3 87/05/27 16:01:59 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: gdata.c,v $
X * Revision 1.3 87/05/27 16:01:59 brandon
X * Had a break; on failed exp. rel. that should have been a continue;.
X *
X * Revision 1.2 87/04/29 11:30:26 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: gdata() -- get a value at a specified location and store it
X * in the database.
X *
X * DIFFERENCE FROM UNIFY: See inscrf(). Also, if a pfield() fails, the
X * operation will be retried as follows:
X *
X * record locked: asks retry or abort -- the latter acts as a -3
X * no access: asks for a password, wrong acts as -3 return
X */
X
Xgdata(fx, fy, field) {
X char buf[256];
X int rc, ch;
X
X setraw();
X for (;;) {
X rc = gtube(fx, fy, field, buf);
X if (rc == BACK || rc == FWD || rc == GO) {
X if (rc == FWD)
X rc = FWD_OK;
X break;
X }
X
Xrepass:
X switch (ch = pfield(field, buf)) {
X case -4:
X (void) mvprintw(23, 1, "Enter modify password for field: ");
X (void) refresh();
X (void) nocbreak();
X (void) nl();
X if (accsfld(field, getpass(""), 'w') == 0)
X goto repass;
X (void) noecho();
X (void) cbreak();
X (void) nonl();
X prtmsg(1, 23, "Wrong password");
X rc = -3;
X break;
X case -5:
X (void) mvprintw(23, 1, "Record is locked -- Retry or Abort? ");
X (void) refresh();
X ch = tolower(getchar() & 0x7f);
X (void) move(23, 1);
X (void) clrtoeol();
X switch (ch) {
X case 'a':
X rc = -3;
X break;
X default:
X goto repass;
X }
X break;
X case 0:
X break;
X case -1:
X prtmsg(1, 23, "Record is referenced, you may not change the key");
X continue;
X case -2:
X prtmsg(1, 23, "This field has a unique index, and the value you entered exists");
X continue;
X case -3:
X prtmsg(1, 23, "There is no related record with this key");
X continue;
X default:
X xerror(-1, "gtube", "Unknown error %d from pfield", ch);
X }
X break;
X }
X return rc;
X}
________This_Is_The_END________
if test `wc -l < gdata.c` -ne 93; then
echo 'shar: gdata.c was damaged during transit (should have been 93 bytes)'
fi
fi ; : end of overwriting check
echo 'x - gprint.c'
if test -f gprint.c; then echo 'shar: not overwriting gprint.c'; else
sed 's/^X//' << '________This_Is_The_END________' > gprint.c
X/*
X * $Header: gprint.c,v 1.2 87/06/02 12:51:46 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: gprint.c,v $
X * Revision 1.2 87/06/02 12:51:46 brandon
X * Linted.
X *
X * Revision 1.1 87/06/01 08:28:48 brandon
X * Initial revision
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Generate a printable version of a database field. This is similar to dspdt
X * but works for any data type.
X */
X
Xvoid uttoa(buf, typ, len, xbuf)
Xchar *buf, *xbuf; {
X#ifndef UNIFY32
X int date[3];
X#endif UNIFY32
X
X switch (typ) {
X case INT:
X (void) sprintf(buf, "%*d", len, *((short *) xbuf));
X break;
X case LONG:
X (void) sprintf(buf, "%*ld", len, *((long *) xbuf));
X break;
X case AMT:
X (void) sprintf(buf, "%*.2f", len, (double) *((long *) xbuf) / 100.0);
X break;
X case HAMT:
X (void) sprintf(buf, "%*.2f", len, *((double *) xbuf) / 100.0);
X break;
X case STRNG:
X (void) sprintf(buf, "%-*.*s", len, len, xbuf);
X break;
X case FLT:
X (void) sprintf(buf, "%*g", len, *((double *) xbuf));
X break;
X case DATE:
X#ifdef UNIFY32
X dspdt(*((short *) xbuf), buf);
X buf[8] = '\0';
X#else
X kdate(*((short *) buf), date);
X (void) sprintf(buf, "%02d/%02d/%02d", date[MONTH], date[DAY], date[YEAR]);
X#endif UNIFY32
X break;
X case HR:
X (void) sprintf(buf, "%02d:%02d", *((short *) xbuf) / 100, *((short *) xbuf) % 100);
X break;
X default:
X xerror(-1, "uttoa", "Unknown or illegal type %d", typ);
X }
X}
X
Xgprint(fld, fbuf)
Xchar *fbuf; {
X char buf[256];
X FLDESC fd;
X
X if (!fldesc(fld, &fd))
X xerror(-1, "gprint", "Unrecognized field %d", fld);
X if (gfield(fld, buf) == -1)
X return -1;
X uttoa(fbuf, fd.f_typ, fd.f_len, buf);
X return 0;
X}
________This_Is_The_END________
if test `wc -l < gprint.c` -ne 81; then
echo 'shar: gprint.c was damaged during transit (should have been 81 bytes)'
fi
fi ; : end of overwriting check
echo 'x - gtube.c'
if test -f gtube.c; then echo 'shar: not overwriting gtube.c'; else
sed 's/^X//' << '________This_Is_The_END________' > gtube.c
X/*
X * $Header: gtube.c,v 1.6 87/06/09 12:22:11 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: gtube.c,v $
X * Revision 1.6 87/06/09 12:22:11 brandon
X * Moved FYI message to line 23; cleared it after input.
X *
X * Revision 1.5 87/06/01 08:29:28 brandon
X * Added ^V (view) capability for related records.
X *
X * Revision 1.4 87/04/29 16:09:49 brandon
X * Added a cast to (void) of mvaddstr()
X *
X * Revision 1.3 87/04/29 13:10:36 brandon
X * fldesc() returns display length, so mucking around with it isn't needed.
X * However, probably input() or inbuf() will need help...
X *
X * Revision 1.2 87/04/29 11:30:28 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: gtube() -- Get input using a database field template.
X *
X * DIFFERENCE FROM UNIFY: See inscrf(). Also, the UNIFY 3.2 manual says that
X * COMB fields are allowed in gtube(); they never were before. I am assuming
X * that the manual is in error, since inputting a COMB field may be nice but
X * is extremely difficult and requires a search throuh every field in the
X * database, without the secret information internal to UNITRIEVE. That, of
X * course, assumes that we're not treating it as type == STRNG, which would
X * be a *real* botch.
X *
X * Another major difference is that with XRC_LOOK enabled, ^V will cause a
X * browse screen for related records to pop up; select a record and press
X * GO (ESC) to enter that value.
X */
X
Xgtube(fx, fy, field, buf)
Xchar *buf; {
X FLDESC fd;
X int rc;
X#ifdef UNIFY32
X char *cmsg, *emsg;
X#endif
X
X setraw();
X if (!fldesc(field, &fd))
X xerror(-1, "gtube", "Invalid field %d", field);
X if (fd.f_typ == COMB)
X xerror(-2, "gtube", "COMB field %d illegal", field);
X#ifdef UNIFY32
X cmsg = getdoms(field, FYISTR);
X if ((emsg = getdoms(field, ERRSTR)) == (char *) 0)
X emsg = "The value you entered is not legal for this field";
X for (;;) {
X if (cmsg != (char *) 0)
X (void) mvaddstr(23, 1, cmsg);
X#endif
X rc = inscrf(fx, fy, fd.f_typ, fd.f_len, buf);
X#ifdef UNIFY32
X (void) move(23, 1);
X (void) clrtoeol();
X#endif
X if (rc == BACK || rc == FWD || rc == GO)
X return rc;
X if (rc == LOOK) {
X if (fd.f_rpfld == 0) {
X prtmsg(1, 23, "There is no related record to view");
X continue;
X }
X if ((rc = zoom(fx, fy, field, &fd, buf)) == BACK || rc == FWD)
X return rc;
X outscrf(fx, fy, fd.f_typ, fd.f_len, buf);
X }
X#ifdef UNIFY32
X if (domchk(field, buf))
X break;
X prtmsg(1, 23, emsg);
X }
X#endif
X return rc;
X}
________This_Is_The_END________
if test `wc -l < gtube.c` -ne 93; then
echo 'shar: gtube.c was damaged during transit (should have been 93 bytes)'
fi
fi ; : end of overwriting check
echo 'x - iamt.c'
if test -f iamt.c; then echo 'shar: not overwriting iamt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > iamt.c
X/*
X * $Header: iamt.c,v 1.6 87/06/09 11:45:05 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: iamt.c,v $
X * Revision 1.6 87/06/09 11:45:05 brandon
X * Added code to relocate cursor after conversion error message.
X *
X * Revision 1.5 87/06/01 08:29:50 brandon
X * Added ^V (view) capability for related records.
X *
X * Revision 1.4 87/05/26 13:31:23 brandon
X * Changed for new inl() (forces no-update mode).
X *
X * Revision 1.3 87/05/12 12:04:06 brandon
X * Changed to pass FWD, BACK, GO without checking the data buffer
X *
X * Revision 1.2 87/04/29 11:30:31 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Input a small amount, into a (long).
X */
X
Xint iamt(len, buf)
Xlong *buf; {
X char ibuf[10];
X int rc, cnt, sign, dec, y, x;
X
X setraw();
X if (len > 10)
X len = 10;
X getyx(stdscr, y, x);
X for (;;) {
X (void) move(y, x);
X if ((rc = inl(ibuf, len, 1)) == BACK || rc == FWD || rc == GO || rc == LOOK)
X return rc;
X for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X *buf = 0L;
X sign = 0;
X dec = 0;
X if (ibuf[cnt] == '-') {
X sign = 1;
X if (++cnt == len) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X }
X for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
X *buf *= 10;
X *buf += ibuf[cnt] - '0';
X }
X if (ibuf[cnt] == '.') {
X if (cnt > len - 2) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X if (!isdigit(ibuf[++cnt])) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X dec = (ibuf[cnt] - '0') * 10;
X if (!isdigit(ibuf[++cnt])) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X dec += ibuf[cnt] - '0';
X }
X for (; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len)
X break;
X prtmsg(1, 23, "Invalid amount");
X }
X *buf = *buf * 100 + dec;
X if (sign)
X *buf = - *buf;
X return rc;
X}
________This_Is_The_END________
if test `wc -l < iamt.c` -ne 95; then
echo 'shar: iamt.c was damaged during transit (should have been 95 bytes)'
fi
fi ; : end of overwriting check
echo 'x - idate.c'
if test -f idate.c; then echo 'shar: not overwriting idate.c'; else
sed 's/^X//' << '________This_Is_The_END________' > idate.c
X/*
X * $Header: idate.c,v 1.16 87/06/01 16:28:46 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: idate.c,v $
X * Revision 1.16 87/06/01 16:28:46 brandon
X * Moved today() and thisyear() to datefns.c with new names.
X *
X * Revision 1.15 87/06/01 09:39:07 brandon
X * Missing move() before pdate() calls.
X *
X * Revision 1.14 87/06/01 09:25:08 brandon
X * AARGH! ! ! Output func is pdate(), not odate()!
X *
X * Revision 1.13 87/06/01 09:22:39 brandon
X * Forced redisplay of entered date, so `/' (today) shows up properly.
X *
X * Revision 1.12 87/06/01 08:29:58 brandon
X * Added ^V (view) capability for related records.
X *
X * Revision 1.11 87/05/27 15:53:15 brandon
X * Wasn't handling canonical NULLDATE correctly.
X *
X * Revision 1.10 87/05/26 15:43:49 brandon
X * Forgot to cast move() call.
X *
X * Revision 1.9 87/05/26 13:31:40 brandon
X * Changed for new inl() (forces no-update mode).
X *
X * Revision 1.8 87/05/12 15:39:26 brandon
X * added call to _sdbrt() to insure correct date types
X *
X * Revision 1.7 87/05/12 13:24:21 brandon
X * Dumb bugs in parsing /.
X *
X * Revision 1.6 87/05/11 16:38:35 brandon
X * more checking and another bugfix; it was typechecking on no-data returns
X *
X * Revision 1.5 87/05/11 16:30:07 brandon
X * more checking added (also friendlier error messages)
X *
X * Revision 1.4 87/05/11 16:22:40 brandon
X * removed debugging and fixed bug!
X *
X * Revision 1.3 87/05/11 16:13:54 brandon
X * bugchk
X *
X * Revision 1.2 87/04/29 11:30:33 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X#include <ctype.h>
X
X/*
X * Input a date. This is effectively a (short), but outside may have one of
X * the following values:
X *
X * n/n[/n] **.**.** * /
X *
X * At any time, . or - may be used in place of /. * is short for **.**.**;
X * / is short for today's date. (Note: I used . in place of / in the null
X * dates, the reason I leave as an exercise for the reader.)
X *
X * This routine is ugly, but it does it all.
X */
X
Xint idate(buf)
Xshort *buf; {
X int odate[3], date[3];
X int cnt, rc, DS1, DS2, DS3, x, y;
X char ibuf[9];
X
X setraw();
X _sdbrt();
X switch (_ldbrt & MASK_DATES) {
X case YMD:
X DS1 = YEAR;
X DS2 = MONTH;
X DS3 = DAY;
X break;
X case DMY:
X DS1 = DAY;
X DS2 = MONTH;
X DS3 = YEAR;
X break;
X case MDY:
X DS1 = MONTH;
X DS2 = DAY;
X DS3 = YEAR;
X break;
X default:
X xerror(-1, "idate", "Unrecognized internal date code %d", _ldbrt & MASK_DATES);
X }
X getyx(stdscr, y, x);
X for (;;) {
X (void) move(y, x);
X if ((rc = inl(ibuf, 8, 1)) == BACK || rc == FWD || rc == GO || rc == LOOK)
X return rc;
X for (cnt = 0; cnt < 8; cnt++)
X if (ibuf[cnt] == '.' || ibuf[cnt] == '-')
X ibuf[cnt] = '/';
X for (cnt = 0; cnt < 8 && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == 8) {
X prtmsg(1, 23, "Invalid empty date");
X continue;
X }
X if (ibuf[cnt] == '/') {
X for (cnt++; cnt < 8 && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt < 8) {
X prtmsg(1, 23, "Invalid date format");
X continue;
X }
X *buf = _dt_today();
X (void) move(y, x);
X pdate(buf);
X return rc;
X }
X if (ibuf[cnt] == '*') {
X if (strncmp(ibuf, "**/**/**", 8) == 0) {
X *buf = NULLDATE;
X (void) attron(A_UNDERLINE);
X (void) mvaddstr(y, x, "**/**/**");
X (void) attroff(A_UNDERLINE);
X return rc;
X }
X for (cnt++; cnt < 8 && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt < 8) {
X prtmsg(1, 23, "Invalid null date format");
X continue;
X }
X *buf = NULLDATE;
X (void) attron(A_UNDERLINE);
X (void) mvaddstr(y, x, "**/**/**");
X (void) attroff(A_UNDERLINE);
X return rc;
X }
X if (!isdigit(ibuf[cnt])) {
X prtmsg(1, 23, "Invalid date -- bad digit");
X continue;
X }
X date[MONTH] = 0;
X date[DAY] = 0;
X date[YEAR] = 0;
X while (cnt < 8 && isdigit(ibuf[cnt])) {
X date[DS1] *= 10;
X date[DS1] += ibuf[cnt++] - '0';
X }
X if (cnt == 8 || ibuf[cnt++] != '/') {
X prtmsg(1, 23, "Invalid date -- invalid 1pt");
X continue;
X }
X while (cnt < 8 && isdigit(ibuf[cnt])) {
X date[DS2] *= 10;
X date[DS2] += ibuf[cnt++] - '0';
X }
X if (cnt < 8 && ibuf[cnt] == ' ') {
X for (; cnt < 8 && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt < 8) {
X prtmsg(1, 23, "Invalid date -- trailing garbage");
X continue;
X }
X if (_ldbrt & YMD) {
X date[DAY] = date[MONTH];
X date[MONTH] = date[YEAR];
X }
X date[YEAR] = _dt_year();
X }
X else if (cnt == 8)
X date[YEAR] = _dt_year();
X else if (ibuf[cnt++] != '/') {
X prtmsg(1, 23, "Invalid date -- invalid 2pt");
X continue;
X }
X else {
X while (cnt < 8 && isdigit(ibuf[cnt])) {
X date[DS3] *= 10;
X date[DS3] += ibuf[cnt++] - '0';
X }
X if (cnt < 8) {
X for (; cnt < 8 && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt < 8) {
X prtmsg(1, 23, "Invalid date -- trailing garbage in 3pt");
X continue;
X }
X }
X }
X *buf = kday(date);
X kdate(*buf, odate);
X if (ivcmp((char *) date, (char *) odate, sizeof date))
X break;
X prtmsg(1, 23, "Invalid date -- insane elements");
X }
X (void) move(y, x);
X pdate(buf);
X return rc;
X}
________This_Is_The_END________
if test `wc -l < idate.c` -ne 210; then
echo 'shar: idate.c was damaged during transit (should have been 210 bytes)'
fi
fi ; : end of overwriting check
echo 'x - iflt.c'
if test -f iflt.c; then echo 'shar: not overwriting iflt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > iflt.c
X/*
X * $Header: iflt.c,v 1.6 87/06/09 11:45:29 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: iflt.c,v $
X * Revision 1.6 87/06/09 11:45:29 brandon
X * Added code to relocate cursor after conversion error message.
X *
X * Revision 1.5 87/06/01 08:30:02 brandon
X * Added ^V (view) capability for related records.
X *
X * Revision 1.4 87/05/26 13:31:47 brandon
X * Changed for new inl() (forces no-update mode).
X *
X * Revision 1.3 87/05/12 12:04:13 brandon
X * Changed to pass FWD, BACK, GO without checking the data buffer
X *
X * Revision 1.2 87/04/29 11:30:35 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Input a float. This time, they're dumb; take what we're given, no matter
X * how any decimals -- UNITRIEVE can figure it out for itself, since it won't
X * let me! (This is UNIFY's own behavior, in fact.)
X */
X
Xint iflt(len, buf)
Xregister double *buf; {
X char ibuf[17];
X int rc, cnt, sign, y, x;
X double dec;
X
X setraw();
X if (len > 17)
X len = 17;
X getyx(stdscr, y, x);
X for (;;) {
X (void) move(y, x);
X if ((rc = inl(ibuf, len, 1)) == BACK || rc == FWD || rc == GO || rc == LOOK)
X return rc;
X for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len) {
X prtmsg(1, 23, "Invalid float");
X continue;
X }
X *buf = 0.0;
X sign = 0;
X dec = 0;
X if (ibuf[cnt] == '-') {
X sign = 1;
X if (++cnt == len) {
X prtmsg(1, 23, "Invalid float");
X continue;
X }
X }
X for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
X *buf *= 10.0;
X *buf += ibuf[cnt] - '0';
X }
X if (ibuf[cnt] == '.') {
X dec = 10.0;
X for (cnt++; cnt < len && isdigit(ibuf[cnt]); cnt++) {
X *buf += (ibuf[cnt] - '0') / dec;
X dec *= 10.0;
X }
X }
X for (; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len)
X break;
X prtmsg(1, 23, "Invalid float");
X }
X if (sign)
X *buf = - *buf;
X return rc;
X}
________This_Is_The_END________
if test `wc -l < iflt.c` -ne 88; then
echo 'shar: iflt.c was damaged during transit (should have been 88 bytes)'
fi
fi ; : end of overwriting check
echo 'x - ihamt.c'
if test -f ihamt.c; then echo 'shar: not overwriting ihamt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ihamt.c
X/*
X * $Header: ihamt.c,v 1.6 87/06/09 11:45:31 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: ihamt.c,v $
X * Revision 1.6 87/06/09 11:45:31 brandon
X * Added code to relocate cursor after conversion error message.
X *
X * Revision 1.5 87/06/01 08:30:09 brandon
X * Added ^V (view) capability for related records.
X *
X * Revision 1.4 87/05/26 13:31:50 brandon
X * Changed for new inl() (forces no-update mode).
X *
X * Revision 1.3 87/05/12 12:04:08 brandon
X * Changed to pass FWD, BACK, GO without checking the data buffer
X *
X * Revision 1.2 87/04/29 11:30:37 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Input a huge amount, into a (double).
X */
X
Xint ihamt(len, buf)
Xregister double *buf; {
X char ibuf[14];
X int rc, cnt, sign, dec, y, x;
X
X setraw();
X if (len > 14)
X len = 14;
X getyx(stdscr, y, x);
X for (;;) {
X (void) move(y, x);
X if ((rc = inl(ibuf, len, 1)) == BACK || rc == FWD || rc == GO || rc == LOOK)
X return rc;
X for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X *buf = 0.0;
X sign = 0;
X dec = 0;
X if (ibuf[cnt] == '-') {
X sign = 1;
X if (++cnt == len) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X }
X for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
X *buf *= 10.0;
X *buf += ibuf[cnt] - '0';
X }
X if (ibuf[cnt] == '.') {
X if (cnt > len - 2) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X if (!isdigit(ibuf[++cnt])) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X dec = (ibuf[cnt] - '0') * 10;
X if (!isdigit(ibuf[++cnt])) {
X prtmsg(1, 23, "Invalid amount");
X continue;
X }
X dec += ibuf[cnt] - '0';
X }
X for (; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len)
X break;
X prtmsg(1, 23, "Invalid amount");
X }
X *buf = *buf * 100.0 + dec;
X if (sign)
X *buf = - *buf;
X return rc;
X}
________This_Is_The_END________
if test `wc -l < ihamt.c` -ne 95; then
echo 'shar: ihamt.c was damaged during transit (should have been 95 bytes)'
fi
fi ; : end of overwriting check
echo 'x - ilong.c'
if test -f ilong.c; then echo 'shar: not overwriting ilong.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ilong.c
X/*
X * $Header: ilong.c,v 1.6 87/06/09 11:45:33 brandon Exp $
X *
X * ``USC'' -- UNIFY(r) Screens using Curses
X * UNIFY(r) is a registered trademark of Unify Corporation.
X *
X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
X *
X * $Log: ilong.c,v $
X * Revision 1.6 87/06/09 11:45:33 brandon
X * Added code to relocate cursor after conversion error message.
X *
X * Revision 1.5 87/06/01 08:30:12 brandon
X * Added ^V (view) capability for related records.
X *
X * Revision 1.4 87/05/26 13:31:52 brandon
X * Changed for new inl() (forces no-update mode).
X *
X * Revision 1.3 87/05/12 12:04:03 brandon
X * Changed to pass FWD, BACK, GO without checking the data buffer
X *
X * Revision 1.2 87/04/29 11:30:39 brandon
X * Added RCS header information
X *
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Input an item of type (long).
X */
X
Xint ilong(len, buf)
Xlong *buf; {
X char ibuf[9];
X int rc, cnt, sign, y, x;
X
X setraw();
X if (len > 9)
X len = 9; /* (long)'s are max len = 9 */
X getyx(stdscr, y, x);
X for (;;) {
X (void) move(y, x);
X if ((rc = inl(ibuf, len, 1)) == BACK || rc == FWD || rc == GO || rc == LOOK)
X return rc;
X for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len) {
X prtmsg(1, 23, "Invalid number");
X continue;
X }
X *buf = 0L;
X sign = 0;
X if (ibuf[cnt] == '-') {
X sign = 1;
X if (++cnt == len) {
X prtmsg(1, 23, "Invalid number");
X continue;
X }
X }
X for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
X *buf *= 10;
X *buf += ibuf[cnt] - '0';
X }
X for (; cnt < len && ibuf[cnt] == ' '; cnt++)
X ;
X if (cnt == len)
X break;
X prtmsg(1, 23, "Invalid number");
X }
X if (sign)
X *buf = - *buf;
X return rc;
X}
________This_Is_The_END________
if test `wc -l < ilong.c` -ne 77; then
echo 'shar: ilong.c was damaged during transit (should have been 77 bytes)'
fi
fi ; : end of overwriting check
exit 0
--
Brandon S. Allbery, moderator of comp.sources.misc
{well!hoptoad,uunet!hnsurg3,cbosgd,sun!mandrill}!ncoast!allbery
KABOOM!!! Worf: "I think I'm sick." LaForge: "I'm sure half the ship knows it."