v02i035: UNIFY(r) Screens with Curses, Part 3 of 4

Brandon S. Allbery allbery at ncoast.UUCP
Sun Jan 31 14:14:08 AEST 1988


Comp.sources.misc: Volume 2, Issue 35
Submitted-By: The Moderator <allbery at ncoast.UUCP>
Archive-Name: usc/Part3

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:
#
# -r--r--r--  1 allbery users       761 Jan 30 18:01 ptct_wrt.c
# -r--r--r--  1 allbery users       710 Jan 30 18:01 ptime.c
# -r--r--r--  1 allbery users       800 Jan 30 18:01 ptube.c
# -r--r--r--  1 allbery users      6626 Jan 30 18:01 ringmenu.c
# -rw-rw-rw-  1 allbery users       152 Jan 30 18:01 ringmenu.h
# -r--r--r--  1 allbery users       769 Jan 30 18:01 setcook.c
# -r--r--r--  1 allbery users       703 Jan 30 18:01 setraw.c
# -r--r--r--  1 allbery users       583 Jan 30 18:01 setxrc.c
# -r--r--r--  1 allbery users       761 Jan 30 18:01 sfldesc.c
# -r--r--r--  1 allbery users      2483 Jan 30 18:01 shellout.c
# -rw-r--r--  1 allbery users       302 Jan 30 18:01 tester.c
# -r--r--r--  1 allbery users      2314 Jan 30 18:01 uamt.c
# -r--r--r--  1 allbery users      5459 Jan 30 18:01 udate.c
# -r--r--r--  1 allbery users       789 Jan 30 18:01 uerror.c
# -r--r--r--  1 allbery users      2267 Jan 30 18:01 uflt.c
# -r--r--r--  1 allbery users      2325 Jan 30 18:01 uhamt.c
# -r--r--r--  1 allbery users      1929 Jan 30 18:01 ulong.c
# -r--r--r--  1 allbery users      1849 Jan 30 18:01 upbuf.c
# -r--r--r--  1 allbery users      2266 Jan 30 18:01 updata.c
# -r--r--r--  1 allbery users      1252 Jan 30 18:01 upfield.c
# -r--r--r--  1 allbery users      2779 Jan 30 18:01 upscrf.c
# -r--r--r--  1 allbery users      2172 Jan 30 18:01 uptube.c
# -rw-r--r--  1 allbery users      4578 Jan 30 18:01 usc.h
# -r--r--r--  1 allbery users      2034 Jan 30 18:01 ushort.c
# -r--r--r--  1 allbery users      1339 Jan 30 18:01 ustr.c
#
echo 'x - ptct_wrt.c'
if test -f ptct_wrt.c; then echo 'shar: not overwriting ptct_wrt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ptct_wrt.c
X/*
X * $Header: ptct_wrt.c,v 1.2 87/04/29 11:31:19 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:	ptct_wrt.c,v $
X * Revision 1.2  87/04/29  11:31:19  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  ptct_wrt() -- Specify whether output is to be in protected
X * mode or not
X *
X * DIFFERENCE FROM UNIFY:  All we do is check fd == 1, since curses handles the
X * screen itself.
X */
X
Xvoid ptct_wrt(fd, flg) {
X	if (fd != 1)
X		xerror(-1, "ptct_wrt", "Multi-terminal operation on fd %d not supported", fd);
X}
________This_Is_The_END________
if test `wc -l < ptct_wrt.c` -ne 31; then
	echo 'shar: ptct_wrt.c was damaged during transit (should have been 31 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ptime.c'
if test -f ptime.c; then echo 'shar: not overwriting ptime.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ptime.c
X/*
X * $Header: ptime.c,v 1.2 87/04/29 12:57:34 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:	ptime.c,v $
X * Revision 1.2  87/04/29  12:57:34  brandon
X * DUMB!!!  Forgot to deref the buffer
X * 
X * Revision 1.1  87/04/29  12:49:31  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Display a value of type HR.
X */
X
Xvoid ptime(buf)
Xshort *buf; {
X	(void) setraw();
X	(void) attron(A_UNDERLINE);
X	(void) printw("%02d:%02d", *buf / 100, *buf % 100);
X	(void) attroff(A_UNDERLINE);
X}
________This_Is_The_END________
if test `wc -l < ptime.c` -ne 33; then
	echo 'shar: ptime.c was damaged during transit (should have been 33 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ptube.c'
if test -f ptube.c; then echo 'shar: not overwriting ptube.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ptube.c
X/*
X * $Header: ptube.c,v 1.1 87/04/29 13:37:02 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:	ptube.c,v $
X * Revision 1.1  87/04/29  13:37:02  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  ptube() -- Display data from a buffer in the format of a
X * database field
X *
X * DIFFERENCE FROM UNIFY:  FLT ends up being printed with %g.  See pflt()
X * for the gory details.
X */
X
Xvoid ptube(x, y, fld, buf)
Xchar *buf; {
X	FLDESC fd;
X
X	if (!fldesc(fld, &fd))
X		xerror(-1, "ptube", "Invalid database field %d", fld);
X	outscrf(x, y, fd.f_typ, fd.f_len, buf);
X}
________This_Is_The_END________
if test `wc -l < ptube.c` -ne 35; then
	echo 'shar: ptube.c was damaged during transit (should have been 35 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ringmenu.c'
if test -f ringmenu.c; then echo 'shar: not overwriting ringmenu.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ringmenu.c
X/*
X * $Header: ringmenu.c,v 1.9 87/06/11 15:50:36 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:	ringmenu.c,v $
X * Revision 1.9  87/06/11  15:50:36  brandon
X * Fixed page backup bug, used XRC_NOFLSH in showmenu(), misc. other fixes.
X * 
X * Revision 1.8  87/06/02  18:47:53  brandon
X * Had forgotten to force input to uppercase.
X * 
X * Revision 1.7  87/06/02  18:41:05  brandon
X * Now uses XRC_FWDGO, so pressing RETURN has a more intuitive result.
X * 
X * Revision 1.6  87/06/02  18:23:10  brandon
X * Fixed another page-number bug.
X * 
X * Revision 1.5  87/06/02  17:35:22  brandon
X * Fixed bug with `page' numbering, and added a setraw() in case it's called
X * before any other USC functions.
X * 
X * Revision 1.4  87/06/02  16:14:38  brandon
X * Fully linted.
X * 
X * Revision 1.3  87/06/02  16:02:33  brandon
X * Partially linted.
X * 
X * Revision 1.2  87/06/02  15:47:15  brandon
X * Partially linted.
X * 
X * Revision 1.1  87/06/02  15:37:27  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Ring menu manager.  You haven't seen a real ring menu yet; this one uses
X * the full capability of the key primitives (including using "view" to show
X * all the entries on the menu, one per line in a temp window), it scrolls if
X * the menu is wider than the screen, etc.  Rather than using `!' shellout,
X * the ^P convention is used (subshell for Sys5, suspend for BSD) as a part
X * of the input function (the same one used by inl()).  (Late-breaking news:
X * the latest version of I4GL now supports wrapound ring menus.  But the help
X * feature is still unique to USC.)
X *
X * space, CR	next (wraps)
X * tab		exit without selecting
X * esc		execute
X * ^F		next `page'
X * ^B		last `page'
X * ^X		exit program
X * ^P		shellout/suspend
X * ^H		previous (wraps)
X * ^V		display all menu entries in a window
X */
X
Xstatic int paws(w)
XWINDOW *w; {
X	(void) wmove(w, LINES - 1, 0);
X	(void) wattron(w, A_STANDOUT);
X	(void) waddstr(w, " Press ENTER for the next page, or TAB to return: ");
X	(void) wattroff(w, A_STANDOUT);
X	(void) wclrtoeol(w);
X	(void) wrefresh(w);
X	switch (incs(XRC_NOFLSH)) {
X	case -2:
X		return 0;
X	case -3:
X		return 1;
X	}
X	/*NOTREACHED*/
X}
X
Xstatic void showmenu(title, items)
Xchar *title;
Xstruct cmd *items; {
X	int nitem, line;
X	WINDOW *w;
X
X	(void) refresh();	/* otherwise incs() zaps the top two lines */
X	if ((w = newwin(LINES, COLS, 0, 0)) == (WINDOW *) 0)
X		xerror("showmenu", -1, "no space for menu window for `%s'", (title == (char *) 0? "(null)": title));
X	(void) mvwaddstr(w, 0, 0, "Commands on th");
X	if (title == (char *) 0 || title[0] == '\0')
X		(void) waddstr(w, "is");
X	else
X		(void) wprintw(w, "e %s", title);
X	(void) waddstr(w, " menu:\n");
X	(void) waddstr(w, "SPACE or ENTER moves forward, BACKSPACE moves backward, ESC selects, TAB exits;\n");
X	(void) waddstr(w, "      CONTROL-F moves forward one page, CONTROL-B moves backward one page.\n");
X	line = 4;
X	for (nitem = 0; items[nitem].c_key != EOM; nitem++) {
X		if (line == LINES - 1)
X			if (!paws(w))
X				break;
X			else {
X				(void) wmove(w, 4, 0);
X				(void) wclrtobot(w);
X				line = 4;
X			}
X		(void) wmove(w, line, 0);
X		if (items[nitem].c_title != INVISIBLE)
X			(void) waddstr(w, items[nitem].c_title);
X		else
X			(void) waddch(w, items[nitem].c_key);
X		(void) wprintw(w, "\t%s", items[nitem].c_desc);
X		line++;
X	}
X	(void) paws(w);
X	(void) delwin(w);
X	(void) touchwin(stdscr);
X}
X
Xint ringmenu(title, menu/* , initial */)
Xchar *title;
Xstruct cmd *menu; {
X	int *mpage;
X	int nitem, npage, len, page, item, ch, x, y;
X
X	setraw();
X	npage = 1;
X	if (title != (char *) 0 && *title != '\0')
X		len = strlen(title) + 2;
X	else
X		len = 0;
X	for (nitem = 0; menu[nitem].c_key != EOM; nitem++)
X		if (menu[nitem].c_title != INVISIBLE)
X			if ((len += strlen(menu[nitem].c_title) + 2) >= COLS - 1) {
X				npage++;
X				if (title != (char *) 0 && *title != '\0')
X					len = strlen(title) + 2;
X				else
X					len = 0;
X			}
X	if ((mpage = (int *) malloc((unsigned) (npage + 1) * sizeof *mpage)) == (int *) 0)
X		xerror("ringmenu", 0, "No memory for menu `%s' page layout", (title == (char *) 0? "(null)": title));
X	npage = 0;
X	if (title != (char *) 0 && *title != '\0')
X		len = strlen(title) + 2;
X	else
X		len = 0;
X	mpage[0] = 0;
X	for (nitem = 0; menu[nitem].c_key != EOM; nitem++)
X		if (menu[nitem].c_title != INVISIBLE)
X			if ((len += strlen(menu[nitem].c_title) + 2) >= COLS - 1) {
X				mpage[++npage] = nitem;
X				if (title != (char *) 0 && *title != '\0')
X					len = strlen(title) + 2;
X				else
X					len = 0;
X			}
X	mpage[++npage] = -1;
X	item = 0;
X	page = 0;
X	for (;;) {
X		(void) move(0, 0);
X		if (title != (char *) 0 && title[0] != '\0')
X			(void) printw("%s: ", title);
X		for (len = mpage[page]; menu[len].c_key != EOM && (page == npage - 1 || len < mpage[page + 1]); len++) {
X			if (menu[len].c_title == INVISIBLE)
X				continue;
X			if (len == item)
X				(void) attron(A_STANDOUT);
X			(void) printw(" %s ", menu[len].c_title);
X			if (len == item) {
X				(void) attroff(A_STANDOUT);
X				if (menu[len].c_desc != (char *) 0) {
X					getyx(stdscr, y, x);
X					(void) mvaddstr(1, 0, menu[len].c_desc);
X					(void) clrtoeol();
X					(void) move(y, x);
X				}
X			}
X		}
X		(void) clrtoeol();
X		if (title != (char *) 0 && *title != '\0')
X			(void) move(0, strlen(title) + 1);
X		else
X			(void) move(0, COLS - 1);
X		(void) refresh();
X		ch = incs(XRC_CFB|XRC_LOOK|XRC_GO|XRC_CHAR|XRC_BKSP|XRC_FWDGO);
X		if (islower(ch))
X			ch = toupper(ch);
X		(void) move(0, 0);
X		(void) clrtoeol();
X		(void) move(1, 0);
X		(void) clrtoeol();
X		switch (ch) {
X		case BKSP:
X			if (--item < mpage[page])
X				if (page-- == 0) {
X					page = npage - 1;
X					for (item = mpage[page]; menu[item].c_key != EOM; item++)
X						;
X					item--;
X				}
X			break;
X		case BACK:
X			free((char *) mpage);
X			return BACK;
X		case FWD:
X			if (menu[++item].c_key == EOM) {
X				page = 0;
X				item = 0;
X			}
X			else if (mpage[page + 1] != -1 && item == mpage[page + 1])
X				page++;
X			break;
X		case LOOK:
X			showmenu(title, menu);
X			break;
X		case GO:
X			free((char *) mpage);
X			return menu[item].c_key;
X		case CFWD:
X			if (mpage[++page] == -1)
X				page = 0;
X			item = mpage[page];
X			break;
X		case CBACK:
X			if (page-- == 0)
X				page = npage - 1;
X			item = mpage[page];
X			break;
X		default:
X			for (len = 0; menu[len].c_key != EOM; len++)
X				if ((islower(menu[len].c_key)? toupper(menu[len].c_key): menu[len].c_key) == ch) {
X					free((char *) mpage);
X					return menu[len].c_key;
X				}
X			(void) beep();
X		}
X	}
X}
________This_Is_The_END________
if test `wc -l < ringmenu.c` -ne 243; then
	echo 'shar: ringmenu.c was damaged during transit (should have been 243 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ringmenu.h'
if test -f ringmenu.h; then echo 'shar: not overwriting ringmenu.h'; else
sed 's/^X//' << '________This_Is_The_END________' > ringmenu.h
Xstruct ringmenu {
X	char c_key;
X	char *c_title;
X	char *c_desc;
X};
X
X#define EOM		'\0'	/* end of ring menu */
X#define INVIS		""	/* invisible menu entry */
________This_Is_The_END________
if test `wc -l < ringmenu.h` -ne 8; then
	echo 'shar: ringmenu.h was damaged during transit (should have been 8 bytes)'
fi
fi		; : end of overwriting check
echo 'x - setcook.c'
if test -f setcook.c; then echo 'shar: not overwriting setcook.c'; else
sed 's/^X//' << '________This_Is_The_END________' > setcook.c
X/*
X * $Header: setcook.c,v 1.2 87/04/29 11:31:20 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:	setcook.c,v $
X * Revision 1.2  87/04/29  11:31:20  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Leave curses mode.  Again, an assumption is made -- most UNIFY programs
X * under pre-3.2 UNIFY DO NOT FOLLOW THE ASSUMPTION!!! so don't recompile
X * UNIFY stuff unless you don't mind the program not cleaing up after itself.
X */
X
Xvoid setcook() {
X	if (stdscr != (WINDOW *) 0) {
X		(void) endwin();
X		stdscr = (WINDOW *) 0;
X	}
X}
________This_Is_The_END________
if test `wc -l < setcook.c` -ne 31; then
	echo 'shar: setcook.c was damaged during transit (should have been 31 bytes)'
fi
fi		; : end of overwriting check
echo 'x - setraw.c'
if test -f setraw.c; then echo 'shar: not overwriting setraw.c'; else
sed 's/^X//' << '________This_Is_The_END________' > setraw.c
X/*
X * $Header: setraw.c,v 1.2 87/04/29 11:31: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:	setraw.c,v $
X * Revision 1.2  87/04/29  11:31:22  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Set up curses, if necessary.  Called by all USC I/O routines.  This routine
X * is based on an assumption of how setraw() is used.
X */
X
Xvoid setraw() {
X	if (stdscr == (WINDOW *) 0) {
X		(void) initscr();
X		(void) noecho();
X		(void) cbreak();
X		(void) nonl();
X	}
X}
________This_Is_The_END________
if test `wc -l < setraw.c` -ne 32; then
	echo 'shar: setraw.c was damaged during transit (should have been 32 bytes)'
fi
fi		; : end of overwriting check
echo 'x - setxrc.c'
if test -f setxrc.c; then echo 'shar: not overwriting setxrc.c'; else
sed 's/^X//' << '________This_Is_The_END________' > setxrc.c
X/*
X * $Header: setxrc.c,v 1.2 87/04/29 11:31:23 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:	setxrc.c,v $
X * Revision 1.2  87/04/29  11:31:23  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Set the extended-return-code flag to the specified value.
X */
X
Xint setxrc(f) {
X	int of;
X
X	of = __ext_rcodes;
X	__ext_rcodes = f;
X	return of;
X}
________This_Is_The_END________
if test `wc -l < setxrc.c` -ne 30; then
	echo 'shar: setxrc.c was damaged during transit (should have been 30 bytes)'
fi
fi		; : end of overwriting check
echo 'x - sfldesc.c'
if test -f sfldesc.c; then echo 'shar: not overwriting sfldesc.c'; else
sed 's/^X//' << '________This_Is_The_END________' > sfldesc.c
X/*
X * $Header: sfldesc.c,v 1.2 87/04/29 11:31:25 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:	sfldesc.c,v $
X * Revision 1.2  87/04/29  11:31:25  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  sfldesc() -- Return screen field description
X *
X * DIFFERENCE FROM UNIFY:  None.  However, see xsfldesc().
X */
X
Xsfldesc(sfld, buf)
XSFLDESC *buf; {
X	if (sfld < 0 || sfld >= __nsf)
X		return 0;
X	buf->sf_fld = __scf[sfld].q_fld;
X	buf->sf_col = __scf[sfld].q_fx;
X	buf->sf_lin = __scf[sfld].q_fy;
X	return 1;
X}
________This_Is_The_END________
if test `wc -l < sfldesc.c` -ne 34; then
	echo 'shar: sfldesc.c was damaged during transit (should have been 34 bytes)'
fi
fi		; : end of overwriting check
echo 'x - shellout.c'
if test -f shellout.c; then echo 'shar: not overwriting shellout.c'; else
sed 's/^X//' << '________This_Is_The_END________' > shellout.c
X/*
X * $Header: shellout.c,v 1.4 87/06/17 17:40: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:	shellout.c,v $
X * Revision 1.4  87/06/17  17:40:53  brandon
X * I'm beginning to think that it is impossible to get to the bottom of the
X * screen....
X * 
X * Revision 1.3  87/06/11  16:37:20  brandon
X * Still didn't move to BOS.  Now using term{cap, info} low-level code.
X * 
X * Revision 1.2  87/06/09  11:28:14  brandon
X * Forgot to move to BOS before starting the shell (suspending).  This is done
X * with mvcur(), since otherwise temporary windows (^V) would fail.
X * 
X * Revision 1.1  87/06/01  16:32:06  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X#include <signal.h>
X
X/*
X * Internal routine used by inl() and inc() to suspend the program.  Under
X * System V, this does a subshell instead.
X */
X
Xstatic void _putc(ch)
Xchar ch; {
X	(void) write(1, &ch, 1);
X}
X
X#ifndef TERMCAP
X#include <term.h>
X#define CM		cursor_address
X#endif
X
Xstatic void bos() {
X/* this does a move without changing curses... multiple windows would fail. */
X	(void) tputs(tgoto(CM, 1, LINES - 1), 0, _putc);
X}
X
X#ifdef SIGTSTP
X
Xvoid _inlsusp() {
X	(void) nocbreak();
X	(void) nonl();
X	(void) echo();	/* this is a macro in the BSD curses, hurrah! */
X	bos();
X	(void) kill(getpid(), SIGSTOP);
X	(void) cbreak();
X	(void) nl();
X	(void) noecho();
X	(void) move(y, x);
X	(void) clearok(curscr);
X	(void) wrefresh(curscr);
X}
X
X#else
X
Xvoid _inlsusp() {
X	char *sh;
X	int (*oint)(), (*oquit)();
X	int pid, status;
X
X	if ((sh = getenv("SHELL")) == (char *) 0)
X		sh = "/bin/sh";
X	oint = signal(SIGINT, SIG_IGN);
X	oquit = signal(SIGQUIT, SIG_IGN);
X	bos();
X	(void) nocbreak();
X	(void) nl();
X	(void) system("stty echo");	/* ECCH!  echo() conflicts with Unify!!! */
X	/* presumably, I don't need vfork() because of the above */
X	switch (pid = fork()) {
X	case -1:
X		status = -1;
X		break;
X	case 0:
X		(void) signal(SIGINT, SIG_DFL);
X		(void) signal(SIGQUIT, SIG_DFL);
X		(void) execlp(sh, sh, "-i", (char *) 0);
X		_exit(-1);
X	default:
X		while (wait(&status) != pid)
X			;
X		break;
X	}
X	(void) noecho();
X	(void) nonl();
X	(void) cbreak();
X	(void) signal(SIGINT, oint);
X	(void) signal(SIGQUIT, oquit);
X	(void) clearok(curscr);
X	(void) wrefresh(curscr);
X	if (status == -1)
X		prtmsg(1, 23, "Shell returned -1");
X}
X
X#endif
________This_Is_The_END________
if test `wc -l < shellout.c` -ne 109; then
	echo 'shar: shellout.c was damaged during transit (should have been 109 bytes)'
fi
fi		; : end of overwriting check
echo 'x - tester.c'
if test -f tester.c; then echo 'shar: not overwriting tester.c'; else
sed 's/^X//' << '________This_Is_The_END________' > tester.c
X#include <curses.h>
X#include <signal.h>
X
Xbye() {
X	setcook();
X	abort();
X	abort();
X}
X
Xmain() {
X	signal(SIGQUIT, bye);
X	putenv("DBPATH=/proj/e_u");
X	setxrc(4);
X	addrec(4, "TEST#001");
X	gdata(0, 5, 11);
X	delete(4);
X	setcook();
X	exit(0);
X}
X
Xerror(s,ier){setcook();printf("%s(%d)\n",s,ier);abort();abort();}
________This_Is_The_END________
if test `wc -l < tester.c` -ne 21; then
	echo 'shar: tester.c was damaged during transit (should have been 21 bytes)'
fi
fi		; : end of overwriting check
echo 'x - uamt.c'
if test -f uamt.c; then echo 'shar: not overwriting uamt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > uamt.c
X/*
X * $Header: uamt.c,v 1.5 87/06/09 11:52:25 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:	uamt.c,v $
X * Revision 1.5  87/06/09  11:52:25  brandon
X * Right-justified buffer display; repositioned cursor after conversion errors.
X * 
X * Revision 1.4  87/06/01  08:37:14  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.3  87/05/27  14:42:07  brandon
X * Made sure buffer was padded with spaces.
X * 
X * Revision 1.2  87/05/26  15:43:58  brandon
X * Forgot to cast sprintf().
X * 
X * Revision 1.1  87/05/26  13:32:55  brandon
X * Initial revision
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 uamt(len, buf)
Xlong *buf; {
X	char ibuf[11];
X	int rc, cnt, sign, dec, y, x;
X
X	setraw();
X	if (len > 10)
X		len = 10;
X	(void) sprintf(ibuf, "%*.2f", len + 3, (double) *buf / 100.0);
X	getyx(stdscr, y, x);
X	for (;;) {
X		(void) move(y, x);
X		if ((rc = inl(ibuf, len, 0)) == 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 < uamt.c` -ne 102; then
	echo 'shar: uamt.c was damaged during transit (should have been 102 bytes)'
fi
fi		; : end of overwriting check
echo 'x - udate.c'
if test -f udate.c; then echo 'shar: not overwriting udate.c'; else
sed 's/^X//' << '________This_Is_The_END________' > udate.c
X/*
X * $Header: udate.c,v 1.11 87/06/02 12:51:52 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:	udate.c,v $
X * Revision 1.11  87/06/02  12:51:52  brandon
X * Linted.
X * 
X * Revision 1.10  87/06/01  16:29:20  brandon
X * Moved today() and thisyear() to datefns.c with new names.
X * 
X * Revision 1.9  87/06/01  09:39:27  brandon
X * Missing move() before pdate() calls.
X * 
X * Revision 1.8  87/06/01  09:25:26  brandon
X * AARGH! ! !  Output func is pdate(), not odate()!
X * 
X * Revision 1.7  87/06/01  09:23:01  brandon
X * Forced redisplay of entered date, so `/' (today) shows up properly.
X * 
X * Revision 1.6  87/06/01  08:37:30  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.5  87/05/27  15:51:59  brandon
X * Wasn't handling canonical form of NULLDATE.
X * 
X * Revision 1.4  87/05/27  14:42:24  brandon
X * Made sure buffer was padded with spaces.
X * 
X * Revision 1.3  87/05/26  15:44:12  brandon
X * Forgot to cast sprintf().
X * 
X * Revision 1.2  87/05/26  14:08:02  brandon
X * udate() conflicted with UN*X call; changed to upddate().
X * 
X * Revision 1.1  87/05/26  13:33:23  brandon
X * Initial revision
X * 
X * (Log: idate.c,v)
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 upddate(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, "udate", "Unrecognized internal date code %d", _ldbrt & MASK_DATES);
X	}
X	if (*buf == NULLDATE)
X		(void) strcpy(ibuf, "**/**/**");
X	else {
X		kdate(*buf, date);
X		(void) sprintf(ibuf, "%02d/%02d/%02d", date[DS1], date[DS2], date[DS3]);
X	}
X	getyx(stdscr, y, x);
X	for (;;) {
X		(void) move(y, x);
X		if ((rc = inl(ibuf, 8, 0)) == 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) move(y, x);
X				pdate(buf);
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) move(y, x);
X			pdate(buf);
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 < udate.c` -ne 224; then
	echo 'shar: udate.c was damaged during transit (should have been 224 bytes)'
fi
fi		; : end of overwriting check
echo 'x - uerror.c'
if test -f uerror.c; then echo 'shar: not overwriting uerror.c'; else
sed 's/^X//' << '________This_Is_The_END________' > uerror.c
X/*
X * $Header: uerror.c,v 1.1 87/04/29 14:57: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:	uerror.c,v $
X * Revision 1.1  87/04/29  14:57:46  brandon
X * Initial revision
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  uerror() -- Print a user 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 uerror(s, ier)
Xchar *s; {
X	(void) strcpy(errcall, "uerror");
X	xerror(ier, "User error -- see Notes", "%s", s);
X}
________This_Is_The_END________
if test `wc -l < uerror.c` -ne 32; then
	echo 'shar: uerror.c was damaged during transit (should have been 32 bytes)'
fi
fi		; : end of overwriting check
echo 'x - uflt.c'
if test -f uflt.c; then echo 'shar: not overwriting uflt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > uflt.c
X/*
X * $Header: uflt.c,v 1.5 87/06/09 11:53:03 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:	uflt.c,v $
X * Revision 1.5  87/06/09  11:53:03  brandon
X * Right-justified buffer display; repositioned cursor after conversion errors.
X * 
X * Revision 1.4  87/06/01  08:37:36  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.3  87/05/27  14:42:30  brandon
X * Made sure buffer was padded with spaces.
X * 
X * Revision 1.2  87/05/26  15:44:16  brandon
X * Forgot to cast sprintf().
X * 
X * Revision 1.1  87/05/26  13:33:48  brandon
X * Initial revision
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 uflt(len, buf)
Xregister double *buf; {
X	char ibuf[18];
X	int rc, cnt, sign, y, x;
X	double dec;
X
X	setraw();
X	if (len > 17)
X		len = 17;
X	(void) sprintf(ibuf, "%*g", len, *buf);
X	getyx(stdscr, y, x);
X	for (;;) {
X		(void) move(y, x);
X		if ((rc = inl(ibuf, len, 0)) == 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 < uflt.c` -ne 95; then
	echo 'shar: uflt.c was damaged during transit (should have been 95 bytes)'
fi
fi		; : end of overwriting check
echo 'x - uhamt.c'
if test -f uhamt.c; then echo 'shar: not overwriting uhamt.c'; else
sed 's/^X//' << '________This_Is_The_END________' > uhamt.c
X/*
X * $Header: uhamt.c,v 1.5 87/06/09 11:53: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:	uhamt.c,v $
X * Revision 1.5  87/06/09  11:53:05  brandon
X * Right-justified buffer display; repositioned cursor after conversion errors.
X * 
X * Revision 1.4  87/06/01  08:37:39  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.3  87/05/27  14:42:45  brandon
X * Made sure buffer was padded with spaces.
X * 
X * Revision 1.2  87/05/26  15:44:18  brandon
X * Forgot to cast sprintf().
X * 
X * Revision 1.1  87/05/26  13:33:59  brandon
X * Initial revision
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 uhamt(len, buf)
Xregister double *buf; {
X	char ibuf[15];
X	int rc, cnt, sign, dec, y, x;
X
X	setraw();
X	if (len > 14)
X		len = 14;
X	(void) sprintf(ibuf, "%*.2f", len + 3, *buf / 100.0);
X	getyx(stdscr, y, x);
X	for (;;) {
X		(void) move(y, x);
X		if ((rc = inl(ibuf, len, 0)) == 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 < uhamt.c` -ne 102; then
	echo 'shar: uhamt.c was damaged during transit (should have been 102 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ulong.c'
if test -f ulong.c; then echo 'shar: not overwriting ulong.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ulong.c
X/*
X * $Header: ulong.c,v 1.5 87/06/09 11:53:15 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:	ulong.c,v $
X * Revision 1.5  87/06/09  11:53:15  brandon
X * Right-justified buffer display; repositioned cursor after conversion errors.
X * 
X * Revision 1.4  87/06/01  08:37:43  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.3  87/05/27  14:42:56  brandon
X * Made sure buffer was padded with spaces.
X * 
X * Revision 1.2  87/05/26  15:44:20  brandon
X * Forgot to cast sprintf().
X * 
X * Revision 1.1  87/05/26  13:34:07  brandon
X * Initial revision
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 ulong(len, buf)
Xlong *buf; {
X	char ibuf[10];
X	int rc, cnt, sign, y, x;
X
X	setraw();
X	if (len > 9)
X		len = 9;	/* (long)'s are max len = 9 */
X	(void) sprintf(ibuf, "%*ld", len, *buf);
X	getyx(stdscr, y, x);
X	for (;;) {
X		(void) move(y, x);
X		if ((rc = inl(ibuf, len, 0)) == 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 < ulong.c` -ne 84; then
	echo 'shar: ulong.c was damaged during transit (should have been 84 bytes)'
fi
fi		; : end of overwriting check
echo 'x - upbuf.c'
if test -f upbuf.c; then echo 'shar: not overwriting upbuf.c'; else
sed 's/^X//' << '________This_Is_The_END________' > upbuf.c
X/*
X * $Header: upbuf.c,v 1.1 87/05/26 13:49:35 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:	upbuf.c,v $
X * Revision 1.1  87/05/26  13:49:35  brandon
X * Initial revision
X * 
X * Revision 1.5  87/04/29  14:19:12  brandon
X * FLT display length is sfield length / 10
X * 
X * Revision 1.4  87/04/29  13:17:22  brandon
X * The code to convert internal to display lengths was in gtube(); it belonged
X * in here, so here it is.
X * 
X * Revision 1.3  87/04/29  11:40:50  brandon
X * Added ability to OR an upshift flag with a screen field type to get auto
X * upshifting on certain screen fields.  See also gdata.c.
X * 
X * Revision 1.2  87/04/29  11:30:40  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  upbuf() -- Update from a screen field to a buffer
X *
X * DIFFERENCE FROM UNIFY:  See upscrf().
X */
X
Xupbuf(sfld, buf)
Xchar *buf; {
X	int rc, oucf, len;
X
X	setraw();
X	if (sfld < 0 || sfld > __nsf)
X		xerror(-1, "upbuf", "Invalid screen field %d", sfld);
X	oucf = _sh_up;
X	_sh_up = __scf[sfld].q_type & _UCF;
X	/* This code was in gtube(), because I screwed up! */
X	len = __scf[sfld].q_len;
X	switch (__scf[sfld].q_type) {
X	case INT:
X	case LONG:
X	case STRNG:
X		break;
X	case AMT:
X	case HAMT:
X		len += 3;
X		break;
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 COMB:
X		xerror(-2, "upbuf", "COMB field %d illegal", sfld);
X	}
X	if (__scf[sfld].q_fld != 0)
X		rc = uptube(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_fld, buf);
X	else
X		rc = upscrf(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_type & ~_UCF, len, buf);
X	_sh_up = oucf;
X	return rc;
X}
________This_Is_The_END________
if test `wc -l < upbuf.c` -ne 78; then
	echo 'shar: upbuf.c was damaged during transit (should have been 78 bytes)'
fi
fi		; : end of overwriting check
echo 'x - updata.c'
if test -f updata.c; then echo 'shar: not overwriting updata.c'; else
sed 's/^X//' << '________This_Is_The_END________' > updata.c
X/*
X * $Header: updata.c,v 1.3 87/05/27 16:02: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:	updata.c,v $
X * Revision 1.3  87/05/27  16:02:26  brandon
X * Had a break; on failed exp. rel. that should have been a continue;.
X * 
X * Revision 1.2  87/05/26  14:29:07  brandon
X * Well, utime() was the culprit (be nice if I could read!)-:
X * 
X * Revision 1.1  87/05/26  13:49:49  brandon
X * Initial revision
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:  updata() -- get a value at a specified location and store it
X * in the database.
X *
X * DIFFERENCE FROM UNIFY:  Update function are not provided in UNIFY(r).
X */
X
Xupdata(fx, fy, field) {
X	char buf[256];
X	int rc, ch;
X
X	setraw();
X	if (gfield(field, buf) != 0)
X		xerror(-1, "updata", "Read access for field %d denied", field);
X	for (;;) {
X		rc = uptube(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(-2, "updata", "Unknown error %d from pfield", ch);
X		}
X		break;
X	}
X	return rc;
X}
________This_Is_The_END________
if test `wc -l < updata.c` -ne 97; then
	echo 'shar: updata.c was damaged during transit (should have been 97 bytes)'
fi
fi		; : end of overwriting check
echo 'x - upfield.c'
if test -f upfield.c; then echo 'shar: not overwriting upfield.c'; else
sed 's/^X//' << '________This_Is_The_END________' > upfield.c
X/*
X * $Header: upfield.c,v 1.1 87/05/26 13:50:09 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:	upfield.c,v $
X * Revision 1.1  87/05/26  13:50:09  brandon
X * Initial revision
X * 
X * Revision 1.3  87/04/29  11:44:40  brandon
X * Added _UCF upshifting.  See also inbuf.c, xsfldesc.c.  (The comment in
X * inbuf.c is WRONG!)
X * Also caused error on screen field w/o database field.
X * 
X * Revision 1.2  87/04/29  11:30:44  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT:  upfield() -- Updata a database field using a screen field.
X *
X * DIFFERENCE FROM UNIFY:  UNIFY(r) does not provide update functions.
X */
X
Xupfield(sfld) {
X	int rc, ousf;
X
X	if (sfld < 0 || sfld >= __nsf)
X		xerror(-1, "upfield", "Invalid screen field %d", sfld);
X	if (__scf[sfld].q_fld == 0)
X		xerror(-2, "upfield", "Screen field %d has no associated database field", sfld);
X	ousf = _sh_up;
X	_sh_up = __scf[sfld].q_type & _UCF;
X	rc = updata(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_fld);
X	_sh_up = ousf;
X	return rc;
X}
________This_Is_The_END________
if test `wc -l < upfield.c` -ne 46; then
	echo 'shar: upfield.c was damaged during transit (should have been 46 bytes)'
fi
fi		; : end of overwriting check
echo 'x - upscrf.c'
if test -f upscrf.c; then echo 'shar: not overwriting upscrf.c'; else
sed 's/^X//' << '________This_Is_The_END________' > upscrf.c
X/*
X * $Header: upscrf.c,v 1.4 87/06/01 10:56:07 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:	upscrf.c,v $
X * Revision 1.4  87/06/01  10:56:07  brandon
X * _sh_up only forced up; left as is if type doesn't have _UCF.
X * 
X * Revision 1.3  87/05/26  14:29:33  brandon
X * Well, utime() was the culprit (be nice if I could read!)-:
X * 
X * Revision 1.2  87/05/26  14:08:27  brandon
X * udate() conflicted with UN*X call; changed to upddate().
X * 
X * Revision 1.1  87/05/26  13:50:24  brandon
X * Initial revision
X * 
X * Revision 1.5  87/05/22  15:39:06  brandon
X * whoops!  It doesn't help to leave off the "break"'s in a switch().
X * 
X * Revision 1.4  87/05/12  17:19:19  brandon
X * Forgot to get rid of _UCF temporarily during type check
X * 
X * Revision 1.3  87/05/12  17:00:28  brandon
X * Enabled _UCF flag for type.
X * 
X * Revision 1.2  87/04/29  11:30:46  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * ENTRY POINT: upscrf() -- Take a type and (character) length, and call the
X * correct input routine for the type for UPDATE.
X *
X * DIFFERENCE FROM UNIFY:  In addition to the standard return codes, there are
X * a number of new ones.  If you want to use them, call setxrc() with a non-
X * zero argument.  The new codes are:
X *
X *		-5	ESC or ^E
X *		-6	ESC or ^E, returns buffer
X *		-7	^U or TAB, returns buffer
X *
X * Also, the following line-editing characters are supported:
X *
X *		^H		delete last charater
X *		^F		move forward (wraps to beginning)
X *		^B		move backward (wraps to end)
X *		^A		move to start of field
X *		^N		move to end of field
X *		^O		insert a space
X *		^D		delete a character
X *		^K		clear to end of field
X *		^X		exit program
X *		^R, ^L		redraw screen
X *		^P		shell out
X *
X * I would have used ^Z for end-of-field, but I see no reason to get the
X * people with job control or sxt's upset at me...
X */
X
Xint upscrf(x, y, type, len, buf)
Xchar *buf; {
X	int rc, oucf;
X
X	setraw();
X	mv_cur(1, x, y);
X	oucf = _sh_up;
X	if (type & _UCF)
X		_sh_up = type & _UCF;
X	type &= ~_UCF;
X	switch (type) {
X	case INT:
X		rc = ushort(len, (short *) buf);
X		break;
X	case LONG:
X		rc = ulong(len, (long *) buf);
X		break;
X	case AMT:
X		rc = uamt(len, (long *) buf);
X		break;
X	case HAMT:
X		rc = uhamt(len, (double *) buf);
X		break;
X	case STRNG:
X		rc = ustr(len, buf);
X		break;
X	case DATE:
X		rc = upddate((short *) buf);
X		break;
X	case HR:
X		rc = updtime((short *) buf);
X		break;
X	case FLT:
X		rc = uflt(len, (double *) buf);
X		break;
X	default:
X		xerror(-1, "upscrf", "Unknown type %d", type);
X		/*NOTREACHED*/
X	}
X	_sh_up = oucf;
X	return rc;
X}
________This_Is_The_END________
if test `wc -l < upscrf.c` -ne 112; then
	echo 'shar: upscrf.c was damaged during transit (should have been 112 bytes)'
fi
fi		; : end of overwriting check
echo 'x - uptube.c'
if test -f uptube.c; then echo 'shar: not overwriting uptube.c'; else
sed 's/^X//' << '________This_Is_The_END________' > uptube.c
X/*
X * $Header: uptube.c,v 1.3 87/06/09 12:22:37 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:	uptube.c,v $
X * Revision 1.3  87/06/09  12:22:37  brandon
X * Moved FYI message to line 23; cleared it after input.
X * 
X * Revision 1.2  87/06/01  08:31:13  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.1  87/05/26  13:50:36  brandon
X * Initial revision
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:  uptube() -- Update a buffer using a database field template.
X *
X * DIFFERENCE FROM UNIFY:  UNIFY(r) does not support update functions.
X */
X
Xuptube(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, "uptube", "Invalid field %d", field);
X	if (fd.f_typ == COMB)
X		xerror(-2, "uptube", "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 = upscrf(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 < uptube.c` -ne 86; then
	echo 'shar: uptube.c was damaged during transit (should have been 86 bytes)'
fi
fi		; : end of overwriting check
echo 'x - usc.h'
if test -f usc.h; then echo 'shar: not overwriting usc.h'; else
sed 's/^X//' << '________This_Is_The_END________' > usc.h
X/*
X * $Header: usc.h,v 1.1 87/05/28 14:04:04 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:	usc.h,v $
X * Revision 1.1  87/05/28  14:04:04  brandon
X * Initial revision
X * 
X */
X
X#ifdef lint
X# define NOMACROS
X#endif
X#include <curses.h>
X#include <dbtypes.h>
X#include <fdesc.h>
X#include <ctype.h>
X#ifdef UNIFY32
X#include <domains.h>
X#endif
X
X#ifdef TERMCAP
X
X/* Old curses.  We have to emulate some of the new features. */
X
X#define beep()		write(1, "\7", 1)
X#define flash()		beep()
X#define cbreak()	crmode()
X#define nocbreak()	nocrmode()
X
X#endif
X#if defined(lint) || defined(TERMCAP)
X
X#define A_STANDOUT	0x80
X#define A_REVERSE	0x80
X#define A_UNDERLINE	0x00
X#define A_ALTCHARSET	0x00
X#define A_BLINK		0x00
X#define A_DIM		0x00
X#define A_BOLD		0x00
X#define A_INVIS		0x00
X#define A_PROTECT	0x00
X#define A_ATTRIBUTES	A_STANDOUT
X#define A_CHARTEXT	0x7f
X
X#endif
X
Xstruct q {
X	char q_name[8];
X	char q_dbfld[44];
X	short q_fld;
X	short q_type;
X	short q_len;
X	short q_fx;
X	short q_fy;
X	char q_prmp[40];
X	short q_px;
X	short q_py;
X};
X
Xextern struct q *__scf;
Xextern int __nsf;
X
X/*
X * If a screen field's type has _UCF OR'ed in with it, it will be upshifted
X * during calls to input() and inbuf().
X */
X
Xextern int _sh_up;		/* set this flag nonzero for upshifting */
X#define _UCF		0x80	/* the flag value for upshifted sfields */
X
X/*
X * Date and brackets, since the U.S. (as usual) is different from the rest
X * of the world...
X */
X
X/* brackets */
X
X#define MASK_BRACKETS	0x80
X#define INTERNATIONAL	0x00
X#define UNITED_STATES	0x80
X
X/* dates */
X
X#define MASK_DATES	0x03
X#define YMD		0x00
X#define DMY		0x01
X#define MDY		0x02
X
Xextern int _ldbrt;
X
X/* used internally for date array addressing */
X
X#define MONTH		0
X#define DAY		1
X#define YEAR		2	/* ...guess what country Unify Corp. is in! */
X
X#if defined(lint) && !defined(TERMCAP)
X
X/*
X * Curses defines <struct screen> under USG, but doesn't declare it.  This
X * makes lint upset.
X */
X
Xstruct screen {
X	char dummy;
X};
X
X#endif
X
X/* return codes for input routines */
X
X#define FWD_OK		0	/* RETURN with data */
X#define BKSP		-1	/* inc() backspace */
X#define BACK		-2	/* TAB */
X#define FWD		-3	/* RETURN */
X#define LOOK		-4	/* ^V `view mode' (aka ACCELL `zoom') */
X#define GO		-5	/* ESC */
X#define GO_OK		-6	/* ESC with data */
X#define BACK_OK		-7	/* TAB with data */
X#define CFWD		-8	/* inc() forward */
X#define CBACK		-9	/* inc() backward */
X
X#define XRC_GO		1	/* allow GO, GO_OK return codes */
X#define XRC_XOK		2	/* allow GO_OK, BACK_OK return codes */
X#define XRC_LOOK	4	/* allow LOOK return code (no LOOK_OK) */
X#define XRC_CFB		8	/* for incs(): include CFWD, CBACK */
X#define XRC_BKSP	16	/* for incs(): include BKSP */
X#define XRC_CHAR	32	/* for incs(): return non-ctl chars */
X#define XRC_FWDGO	64	/* for incs(): RETURN == GO instead of FWD */
X#define XRC_NOFLSH	128	/* for incs(): suppress refresh() call */
X
Xextern int __ext_rcodes;
X
X/* the eternal happiness of strict(-ish) type checking... */
X
Xextern char *getpass();
Xextern char *malloc();
Xextern long time();
Xextern char *ctime();
Xextern void exit();
Xextern void _exit();
Xextern void free();
Xextern char *getenv();
Xextern char *strcpy();
Xextern char *strcat();
Xextern char *strchr();
Xextern WINDOW *newwin();
Xextern int sprintf();
X
Xextern short kday();
Xextern void kdate();
Xextern void cfill();
X#ifdef UNIFY32
Xextern char *getdoms();
Xextern void dspdt();
X#endif
X
Xextern void setraw();
Xextern void prtmsg();
Xextern char *dbfile();
Xextern FILE *_dbfopen();
Xextern void erasprmp();
Xextern void outscrf();
Xextern void output();
Xextern void pamt();
Xextern void pdate();
Xextern void pflt();
Xextern void phamt();
Xextern void plong();
Xextern void pshort();
Xextern void pstr();
Xextern void ptime();
Xextern void mv_cur();
Xextern void _inlsusp();
Xextern int inc();
Xextern int inl();
Xextern short _dt_today();
Xextern int _dt_year();
X#ifdef UNIFY32
Xextern void _sdbrt();
X#endif
X
X#if defined(lint) && !defined(TERMCAP)
Xextern WINDOW *initscr();	/* I had always understood this was (int)?? */
X#endif
X
X#ifdef lint
X#define getyx(win, y, x)	((y) = 0, (x) = 0)
X#endif
X
X/* Operational modes in logacl */
X
X#define INQUIRE		010
X#define ADD		004
X#define MODIFY		002
X#define DELETE		001
X
X/* Used by the error functions */
X
Xextern char errcall[];
X
X/* Ring menu definitions */
X
Xstruct cmd {
X	char c_key;
X	char *c_title;
X	char *c_desc;
X};
X
X#define EOM		'\0'	/* end of menu */
X#define INVISIBLE	""	/* invisible entry */
________This_Is_The_END________
if test `wc -l < usc.h` -ne 217; then
	echo 'shar: usc.h was damaged during transit (should have been 217 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ushort.c'
if test -f ushort.c; then echo 'shar: not overwriting ushort.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ushort.c
X/*
X * $Header: ushort.c,v 1.6 87/06/09 12:19:08 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:	ushort.c,v $
X * Revision 1.6  87/06/09  12:19:08  brandon
X * Fixed the format for the buffer value generation.
X * 
X * Revision 1.5  87/06/09  11:53:17  brandon
X * Right-justified buffer display; repositioned cursor after conversion errors.
X * 
X * Revision 1.4  87/06/01  08:37:46  brandon
X * Added ^V (view) capability for related records.
X * 
X * Revision 1.3  87/05/27  14:43:23  brandon
X * Made sure buffer was padded with spaces.
X * 
X * Revision 1.2  87/05/26  15:44:23  brandon
X * Forgot to cast sprintf().
X * 
X * Revision 1.1  87/05/26  13:34:19  brandon
X * Initial revision
X * 
X * Revision 1.3  87/05/12  12:03:40  brandon
X * Changed to pass FWD, BACK, GO without checking the data buffer
X * 
X * Revision 1.2  87/04/29  11:30:48  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Input an item of type (short).
X */
X
Xint ushort(len, buf)
Xshort *buf; {
X	char ibuf[5];
X	int rc, cnt, sign, y, x;
X
X	setraw();
X	if (len > 4)
X		len = 4;	/* (short)'s are max len = 4 */
X	(void) sprintf(ibuf, "%*d", len, *buf);
X	getyx(stdscr, y, x);
X	for (;;) {
X		(void) move(y, x);
X		if ((rc = inl(ibuf, len, 0)) == 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 = 0;
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 < ushort.c` -ne 87; then
	echo 'shar: ushort.c was damaged during transit (should have been 87 bytes)'
fi
fi		; : end of overwriting check
echo 'x - ustr.c'
if test -f ustr.c; then echo 'shar: not overwriting ustr.c'; else
sed 's/^X//' << '________This_Is_The_END________' > ustr.c
X/*
X * $Header: ustr.c,v 1.4 87/06/09 11:38:17 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:	ustr.c,v $
X * Revision 1.4  87/06/09  11:38:17  brandon
X * Changed inl() call to use clrf == 2.
X * 
X * Revision 1.3  87/06/01  11:36:44  brandon
X * Was filling nulls[] instead of buf[]... dumb dumb da dumb :-)
X * 
X * Revision 1.2  87/06/01  11:23:53  brandon
X * UNIFY defaults STRNG fields to nulls (!) -- rather antisocial of it.  We
X * convert to spaces on update of an all-nulls STRNG field.
X * 
X * Revision 1.1  87/05/26  13:34:28  brandon
X * Initial revision
X * 
X * Revision 1.2  87/04/29  11:30:50  brandon
X * Added RCS header information
X * 
X */
X
X/*LINTLIBRARY*/
X
X#include "usc.h"
X
X/*
X * Get a string.  Very easy, since no checking is needed.  Except... UNIFY
X * defaults string fields to nulls (!) so we should check for all nulls and
X * convert to all spaces.  (Rather rude, in my opinion.)
X */
X
Xstatic char nulls[256];
Xstatic int _init = 0;
X
Xint ustr(len, buf)
Xchar *buf; {
X	setraw();
X	if (!_init) {
X		cfill(0, nulls, sizeof nulls);
X		_init = 1;
X	}
X	if (ivcmp(buf, nulls, len))
X		cfill(' ', buf, len);
X	return inl(buf, len, 2);
X}
________This_Is_The_END________
if test `wc -l < ustr.c` -ne 52; then
	echo 'shar: ustr.c was damaged during transit (should have been 52 bytes)'
fi
fi		; : end of overwriting check
exit 0



More information about the Comp.sources.misc mailing list