allbery@ncoast.UUCP (Brandon S. Allbery) (01/31/88)
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 2117 Jan 30 18:01 inbuf.c # -r--r--r-- 1 allbery users 1919 Jan 30 18:01 inc.c # -r--r--r-- 1 allbery users 2521 Jan 30 18:01 incs.c # -r--r--r-- 1 allbery users 5846 Jan 30 18:01 inl.c # -r--r--r-- 1 allbery users 1155 Jan 30 18:01 input.c # -r--r--r-- 1 allbery users 2604 Jan 30 18:01 inscrf.c # -r--r--r-- 1 allbery users 1735 Jan 30 18:01 ishort.c # -r--r--r-- 1 allbery users 667 Jan 30 18:01 istr.c # -r--r--r-- 1 allbery users 2009 Jan 30 18:01 itime.c # -r--r--r-- 1 allbery users 800 Jan 30 18:01 keybrd.c # -r--r--r-- 1 allbery users 4049 Jan 30 18:01 loadscr.c # -r--r--r-- 1 allbery users 953 Jan 30 18:01 mv_cur.c # -r--r--r-- 1 allbery users 1160 Jan 30 18:01 outbuf.c # -r--r--r-- 1 allbery users 1371 Jan 30 18:01 output.c # -r--r--r-- 1 allbery users 1516 Jan 30 18:01 outscrf.c # -r--r--r-- 1 allbery users 2679 Jan 30 18:01 pageout.c # -r--r--r-- 1 allbery users 659 Jan 30 18:01 pamt.c # -r--r--r-- 1 allbery users 894 Jan 30 18:01 pdata.c # -r--r--r-- 1 allbery users 1018 Jan 30 18:01 pdate.c # -r--r--r-- 1 allbery users 1382 Jan 30 18:01 pflt.c # -r--r--r-- 1 allbery users 608 Jan 30 18:01 pflush.c # -r--r--r-- 1 allbery users 619 Jan 30 18:01 phamt.c # -r--r--r-- 1 allbery users 610 Jan 30 18:01 plong.c # -r--r--r-- 1 allbery users 2557 Jan 30 18:01 priamd.c # -r--r--r-- 1 allbery users 668 Jan 30 18:01 prmp.c # -r--r--r-- 1 allbery users 807 Jan 30 18:01 prmpf.c # -r--r--r-- 1 allbery users 667 Jan 30 18:01 prmprv.c # -r--r--r-- 1 allbery users 976 Jan 30 18:01 prtmsg.c # -r--r--r-- 1 allbery users 612 Jan 30 18:01 pshort.c # -r--r--r-- 1 allbery users 1018 Jan 30 18:01 pstr.c # -r--r--r-- 1 allbery users 735 Jan 30 18:01 ptct_crt.c # echo 'x - inbuf.c' if test -f inbuf.c; then echo 'shar: not overwriting inbuf.c'; else sed 's/^X//' << '________This_Is_The_END________' > inbuf.c X/* X * $Header: inbuf.c,v 1.5 87/04/29 14:19: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: inbuf.c,v $ 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: inbuf() -- Input from a screen field to a buffer X * X * DIFFERENCE FROM UNIFY: See inscrf(). The stuff about NULLDATEs on -3 X * returns from gtube() is done, iff -DCOMPATIBILITY is given. (There's no X * real need for it, and this implementation doesn't *have* that side effect X * unless extra code is added to force the issue.) X */ X Xinbuf(sfld, buf) Xchar *buf; { X int rc, oucf, len; X X setraw(); X if (sfld < 0 || sfld > __nsf) X xerror(-1, "inbuf", "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, "inbuf", "COMB field %d illegal", sfld); X } X if (__scf[sfld].q_fld != 0) X rc = gtube(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_fld, buf); X else X rc = inscrf(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_type & ~_UCF, len, buf); X#ifdef COMPATIBILITY X if (rc == FWD && __scf[sfld].q_type == DATE) X (short *) buf = NULLDATE; X#endif X _sh_up = oucf; X return rc; X} ________This_Is_The_END________ if test `wc -l < inbuf.c` -ne 82; then echo 'shar: inbuf.c was damaged during transit (should have been 82 bytes)' fi fi ; : end of overwriting check echo 'x - inc.c' if test -f inc.c; then echo 'shar: not overwriting inc.c'; else sed 's/^X//' << '________This_Is_The_END________' > inc.c X/* X * $Header: inc.c,v 1.1 87/06/02 11:01:55 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: inc.c,v $ X * Revision 1.1 87/06/02 11:01:55 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Input primitive. Get a single input character. If _sh_up is nonzero, shift X * to uppercase. Underline is used (when available) in place of foreground/ X * background stuff that curses doesn't grok anyway. X * X * The `clrf' flag specifies whether the buffer is cleared or not prior to X * input. This is of doubtful utility, but.... X */ X Xint inc(buf, clrf) Xchar *buf; Xint clrf; { X setraw(); X (void) attron(A_UNDERLINE); X if (clrf) X *buf = ' '; X for (;;) { X (void) printw("%c\b", *buf); X (void) refresh(); X *buf = getchar() & 0x7f; X switch (*buf) { X case '\033': X case '\005': X (void) attroff(A_UNDERLINE); X return GO; X case '\t': X case '\025': X (void) attroff(A_UNDERLINE); X return BACK; X case '\n': X case '\r': X case ' ': X (void) attroff(A_UNDERLINE); X return (!clrf || *buf == ' '? FWD: FWD_OK); X case '\b': X (void) attroff(A_UNDERLINE); X return BKSP; X case '\006': X (void) attroff(A_UNDERLINE); X return CFWD; X case '\002': X (void) attroff(A_UNDERLINE); X return CBACK; X case '\026': X (void) attroff(A_UNDERLINE); X return LOOK; X case '\030': X (void) move(LINES - 1, 0); X (void) clrtoeol(); X (void) refresh(); X (void) endwin(); X exit(0); X case '\020': X _inlsusp(); X break; X case '\f': X case '\022': X (void) clearok(curscr); X (void) wrefresh(curscr); X break; X default: X if (*buf < ' ' || *buf == '\177') { X (void) beep(); X break; X } X if (_sh_up && islower(*buf)) X *buf = toupper(*buf); X return FWD_OK; X } X } X} ________This_Is_The_END________ if test `wc -l < inc.c` -ne 90; then echo 'shar: inc.c was damaged during transit (should have been 90 bytes)' fi fi ; : end of overwriting check echo 'x - incs.c' if test -f incs.c; then echo 'shar: not overwriting incs.c'; else sed 's/^X//' << '________This_Is_The_END________' > incs.c X/* X * $Header: incs.c,v 1.5 87/06/03 11:39:50 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: incs.c,v $ X * Revision 1.5 87/06/03 11:39:50 brandon X * Added XRC_NOFLSH so incs() can be used by functions which build temporary X * windows; otherwise, the main window might be refresh()ed over the temp X * window, destroying it. X * X * Revision 1.4 87/06/02 18:40:09 brandon X * Added XRC_FWDGO: RETURN normally is interpreted as FWD, if XRC_FWDGO then X * RETURN is interpreted as GO. X * X * Revision 1.3 87/06/02 14:22:37 brandon X * Added XRC_CHAR to return normal characters; this contradicts the original X * reason for incs(), but makes it more useful. This effectively renders X * inc() unused; it is retained as a character-input-with-echo primitive. X * X * Revision 1.2 87/06/02 12:16:24 brandon X * Forgot to change shellout() to _inlsusp(). X * X * Revision 1.1 87/06/01 16:48:39 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Input primitive. Get a single input character, accepting status returns X * only. This is used when only the control characters are wanted, not any X * real input. The argument is an XRC flag, valid only for the duration of X * the function. X */ X Xint incs(xrc) Xint xrc; { X int ch; X X setraw(); X if ((xrc & XRC_NOFLSH) == 0) X (void) refresh(); X for (;;) { X ch = getchar() & 0x7f; X switch (ch) { X case '\033': X case '\005': X if (xrc & XRC_GO) X return GO; X (void) beep(); X break; X case '\t': X case '\025': X return BACK; X case '\n': X case '\r': X if (xrc & XRC_FWDGO) X return GO; X /*FALLTHROUGH*/ X case ' ': X return FWD; X case '\b': X if (xrc & XRC_BKSP) X return BKSP; X (void) beep(); X break; X case '\006': X if (xrc & XRC_CFB) X return CFWD; X (void) beep(); X break; X case '\002': X if (xrc & XRC_CFB) X return CBACK; X (void) beep(); X break; X case '\026': X if (xrc & XRC_LOOK) X return LOOK; X (void) beep(); X break; X case '\030': X (void) move(LINES - 1, 0); X (void) clrtoeol(); X (void) refresh(); X (void) endwin(); X exit(0); X case '\020': X _inlsusp(); X break; X case '\f': X case '\022': X (void) clearok(curscr); X (void) wrefresh(curscr); X break; X default: X if ((xrc & XRC_CHAR) && ch > '!' && ch < '\177') X return ch; X (void) beep(); X break; X } X } X} ________This_Is_The_END________ if test `wc -l < incs.c` -ne 111; then echo 'shar: incs.c was damaged during transit (should have been 111 bytes)' fi fi ; : end of overwriting check echo 'x - inl.c' if test -f inl.c; then echo 'shar: not overwriting inl.c'; else sed 's/^X//' << '________This_Is_The_END________' > inl.c X/* X * $Header: inl.c,v 1.15 87/06/09 11:37:10 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: inl.c,v $ X * Revision 1.15 87/06/09 11:37:10 brandon X * New interpretation of clrf flag: val 0 = clear if first char typed is text, X * val 1 == clear on entry, val 2 = clear never. X * X * Revision 1.14 87/06/01 16:29:24 brandon X * Moved shellout() to shellout.c with a new name, so as not to duplicate code X * in inc.c. X * X * Revision 1.13 87/06/01 15:57:34 brandon X * Cleaned up ^X; added underline-disable to ^V. X * X * Revision 1.12 87/06/01 08:30:14 brandon X * Added ^V (view) capability for related records. X * X * Revision 1.11 87/05/28 14:03:17 brandon X * Added ^V (view aka LOOK) for automatic explicit relationship chaining. X * X * Revision 1.10 87/05/28 13:36:13 brandon X * Logic of new-vs.-update and ^M input was wrong. X * X * Revision 1.9 87/05/26 14:28:44 brandon X * Added (void) casts for tty mode changes. X * X * Revision 1.8 87/05/26 13:31:55 brandon X * Added flag so that all updates return action code (*_OK). X * X * Revision 1.7 87/05/26 11:18:59 brandon X * Added clrf flag for update functions. X * X * Revision 1.6 87/05/12 14:27:04 brandon X * fixed final (!) insert bug X * X * Revision 1.5 87/05/12 11:53:23 brandon X * Now keeps original screen contents until the first modifying character is X * typed, so the screen result of an initial BACK makes sense. X * Changed code to determine whether a key is an action or an entry action X * based on whether the buffer is empty or not AND the current cursor position; X * this is now roughly compatible with ENTER. X * X * Revision 1.4 87/05/12 11:38:24 brandon X * Fixed job-control terminal settings. X * Fixed "open" bug. X * X * Revision 1.3 87/05/12 11:27:31 brandon X * The "insert" and "delete" keys were swapped (!) X * The shellout wasn't restoring line mode. (It still doesn't, for job control X * shells.) X * X * Revision 1.2 87/04/29 11:30:42 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X#include <signal.h> X X/* setxrc() changes this, if nonzero then extended returns are enabled */ Xint __ext_rcodes = 0; X X/* X * Move to a specified location. Wrap to the next line if necessary. X */ X Xstatic void moveto(y, x) { X while (x >= COLS) { X x -= COLS; X if (++y == LINES) X y--; X } X (void) move(y, x); X} X X/* X * Check to see if the input buffer is all spaces. If so and the cursor is X * at position zero, the action is a no-check (FWD, BACK, or GO) and the X * returned buffer will not be processed. X */ X Xstatic int allspace(b, l) Xregister char *b; Xregister int l; { X while (l-- > 0) X if (*b++ != ' ') X return 0; X return 1; X} X X/* X * Input primitive. Get a line of input. If _sh_up is nonzero, shift to X * uppercase. Underline is used (when available) in place of foreground/ X * background stuff that curses doesn't grok anyway. X * X * Note that this is FAR smarter than the UNIFY version, including line editing X * commands (insert/delete character, cursor motion, etc.). This falls into X * the category of ``why curses is better''. X * X * The `clrf' flag specifies whether the buffer is cleared or not prior to X * input. This is used by the USC-specific u* functions (update buffer). X * If it is a value of 2, the buffer is never cleared except by ^K; otherwise X * if it is 0, it is cleared if the first character typed is a text character. X * If it is 1, the buffer is always cleared on entry. X */ X Xint inl(buf, len, clrf) Xchar *buf; Xint len, clrf; { X int y, x, cnt, ch, tmp, firsttime; X X setraw(); X (void) attron(A_UNDERLINE); X if (clrf == 1) X cfill(' ', buf, len); X getyx(stdscr, y, x); X cnt = 0; X firsttime = 1; X for (;;) { X (void) move(y, x); X if (!firsttime || clrf != 1) { X (void) printw("%.*s", len, buf); X moveto(y, x + cnt); X } X (void) refresh(); X ch = getchar() & 0x7f; X switch (ch) { X case '\033': X case '\005': X if (!(__ext_rcodes & XRC_GO)) { X (void) beep(); X break; X } X (void) attroff(A_UNDERLINE); X return ((__ext_rcodes & XRC_XOK) && (clrf != 1 || !allspace(buf, len) || cnt != 0)? GO_OK: GO); X case '\t': X case '\025': X (void) attroff(A_UNDERLINE); X return ((__ext_rcodes & XRC_XOK) && (clrf != 1 || !allspace(buf, len) || cnt != 0)? BACK_OK: BACK); X case '\n': X case '\r': X (void) attroff(A_UNDERLINE); X return (clrf == 1 && (allspace(buf, len) && cnt == 0)? FWD: FWD_OK); X case '\b': X if (cnt == 0) X (void) beep(); X else { X for (tmp = --cnt; tmp < len - 1; tmp++) X buf[tmp] = buf[tmp + 1]; X buf[len - 1] = ' '; X } X break; X case '\006': X if (++cnt > len) X cnt = 0; X break; X case '\002': X if (--cnt < 0) X cnt = len; X break; X case '\001': X cnt = 0; X break; X case '\016': X cnt = len; X break; X case '\017': X for (tmp = len - 1; tmp > cnt; tmp--) X buf[tmp] = buf[tmp - 1]; X buf[cnt] = ' '; X break; X case '\004': X for (tmp = cnt; tmp < len - 1; tmp++) X buf[tmp] = buf[tmp + 1]; X buf[len - 1] = ' '; X break; X case '\026': X if (__ext_rcodes & XRC_LOOK) { X (void) attroff(A_UNDERLINE); X return LOOK; X } X (void) beep(); X break; X case '\030': X (void) move(LINES - 1, 0); X (void) clrtoeol(); X (void) refresh(); X (void) endwin(); X exit(0); X case '\013': X cfill(' ', buf + cnt, len - cnt); X break; X case '\020': X _inlsusp(); X break; X case '\f': X case '\022': X (void) clearok(curscr); X (void) wrefresh(curscr); X break; X default: X if (cnt == len || ch < ' ' || ch == '\177') { X (void) beep(); X break; X } X if (firsttime && clrf == 0) X cfill(' ', buf, len); X buf[cnt++] = (_sh_up? toupper(ch): ch); X } X firsttime = 0; X } X} ________This_Is_The_END________ if test `wc -l < inl.c` -ne 221; then echo 'shar: inl.c was damaged during transit (should have been 221 bytes)' fi fi ; : end of overwriting check echo 'x - input.c' if test -f input.c; then echo 'shar: not overwriting input.c'; else sed 's/^X//' << '________This_Is_The_END________' > input.c X/* X * $Header: input.c,v 1.3 87/04/29 11:44:40 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: input.c,v $ 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: input() -- Get data from a screen field and store it in X * the database. X * X * DIFFERENCE FROM UNIFY: See gdata(). X */ X Xinput(sfld) { X int rc, ousf; X X if (sfld < 0 || sfld >= __nsf) X xerror(-1, "input", "Invalid screen field %d", sfld); X if (__scf[sfld].q_fld == 0) X xerror(-2, "input", "Screen field %d has no associated database field", sfld); X ousf = _sh_up; X _sh_up = __scf[sfld].q_type & _UCF; X rc = gdata(__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 < input.c` -ne 44; then echo 'shar: input.c was damaged during transit (should have been 44 bytes)' fi fi ; : end of overwriting check echo 'x - inscrf.c' if test -f inscrf.c; then echo 'shar: not overwriting inscrf.c'; else sed 's/^X//' << '________This_Is_The_END________' > inscrf.c X/* X * $Header: inscrf.c,v 1.7 87/06/01 10:55: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: inscrf.c,v $ X * Revision 1.7 87/06/01 10:55:37 brandon X * _sh_up only forced up; left as is if type doesn't have _UCF. X * X * Revision 1.6 87/06/01 08:30:20 brandon X * Added ^V (view) capability for related records. 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: inscrf() -- Take a type and (character) length, and call the X * correct input routine for the type. 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 * ^V view related records 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 inscrf(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 = ishort(len, (short *) buf); X break; X case LONG: X rc = ilong(len, (long *) buf); X break; X case AMT: X rc = iamt(len, (long *) buf); X break; X case HAMT: X rc = ihamt(len, (double *) buf); X break; X case STRNG: X rc = istr(len, buf); X break; X case DATE: X rc = idate((short *) buf); X break; X case HR: X rc = itime((short *) buf); X break; X case FLT: X rc = iflt(len, (double *) buf); X break; X default: X xerror(-1, "inscrf", "Unknown type %d", type); X /*NOTREACHED*/ X } X _sh_up = oucf; X return rc; X} ________This_Is_The_END________ if test `wc -l < inscrf.c` -ne 107; then echo 'shar: inscrf.c was damaged during transit (should have been 107 bytes)' fi fi ; : end of overwriting check echo 'x - ishort.c' if test -f ishort.c; then echo 'shar: not overwriting ishort.c'; else sed 's/^X//' << '________This_Is_The_END________' > ishort.c X/* X * $Header: ishort.c,v 1.6 87/06/09 11:45: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: ishort.c,v $ X * Revision 1.6 87/06/09 11:45:35 brandon X * Added code to relocate cursor after conversion error message. X * X * Revision 1.5 87/06/01 08:30:29 brandon X * Added ^V (view) capability for related records. X * X * Revision 1.4 87/05/26 13:32:29 brandon X * Changed for new inl() (forces no-update mode). 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 ishort(len, buf) Xshort *buf; { X char ibuf[4]; X int rc, cnt, sign, y, x; X X setraw(); X if (len > 4) X len = 4; /* (short)'s are max len = 4 */ 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 = 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 < ishort.c` -ne 77; then echo 'shar: ishort.c was damaged during transit (should have been 77 bytes)' fi fi ; : end of overwriting check echo 'x - istr.c' if test -f istr.c; then echo 'shar: not overwriting istr.c'; else sed 's/^X//' << '________This_Is_The_END________' > istr.c X/* X * $Header: istr.c,v 1.3 87/05/26 13:32:49 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: istr.c,v $ X * Revision 1.3 87/05/26 13:32:49 brandon X * Changed for new inl() (forces no-update mode). 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. X */ X Xint istr(len, buf) Xchar *buf; { X setraw(); X return inl(buf, len, 1); X} ________This_Is_The_END________ if test `wc -l < istr.c` -ne 31; then echo 'shar: istr.c was damaged during transit (should have been 31 bytes)' fi fi ; : end of overwriting check echo 'x - itime.c' if test -f itime.c; then echo 'shar: not overwriting itime.c'; else sed 's/^X//' << '________This_Is_The_END________' > itime.c X/* X * $Header: itime.c,v 1.7 87/06/09 11:45: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: itime.c,v $ X * Revision 1.7 87/06/09 11:45:37 brandon X * Added code to relocate cursor after conversion error message. X * X * Revision 1.6 87/06/01 08:30:44 brandon X * Added ^V (view) capability for related records. X * X * Revision 1.5 87/05/26 13:32:53 brandon X * Changed for new inl() (forces no-update mode). X * X * Revision 1.4 87/05/12 13:26:31 brandon X * Dumb bug in : parsing. X * X * Revision 1.3 87/05/12 12:04:10 brandon X * Changed to pass FWD, BACK, GO without checking the data buffer X * X * Revision 1.2 87/04/29 11:30:53 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Get a time. H:M only. X */ X Xint itime(buf) Xshort *buf; { X int cnt, rc, hr, min, y, x; X char ibuf[5]; X X setraw(); X getyx(stdscr, y, x); X for (;;) { X (void) move(y, x); X if ((rc = inl(ibuf, 5, 1)) == BACK || rc == FWD || rc == GO || rc == LOOK) X return rc; X for (cnt = 0; cnt < 5 && ibuf[cnt] == ' '; cnt++) X ; X if (cnt == 5) { X prtmsg(1, 23, "Invalid time"); X continue; X } X if (!isdigit(cnt)) { X prtmsg(1, 23, "Invalid time"); X continue; X } X hr = 0; X min = 0; X while (cnt < 5 && isdigit(ibuf[cnt])) { X hr *= 10; X hr += ibuf[cnt++] - '0'; X } X if (cnt > 2 || ibuf[cnt++] != ':') { X prtmsg(1, 23, "Invalid time"); X continue; X } X if (!isdigit(ibuf[cnt])) { X prtmsg(1, 23, "Invalid time"); X continue; X } X min = 10 * (ibuf[cnt++] - '0'); X if (!isdigit(ibuf[cnt])) { X prtmsg(1, 23, "Invalid time"); X continue; X } X min += ibuf[cnt++] - '0'; X while (cnt < 5) X if (ibuf[cnt++] != ' ') { X prtmsg(1, 23, "Invalid time"); X continue; X } X if (hr < 23 && min < 59) X break; X prtmsg(1, 23, "Invalid time"); X } X return rc; X} ________This_Is_The_END________ if test `wc -l < itime.c` -ne 90; then echo 'shar: itime.c was damaged during transit (should have been 90 bytes)' fi fi ; : end of overwriting check echo 'x - keybrd.c' if test -f keybrd.c; then echo 'shar: not overwriting keybrd.c'; else sed 's/^X//' << '________This_Is_The_END________' > keybrd.c X/* X * $Header: keybrd.c,v 1.2 87/04/29 11:30:55 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: keybrd.c,v $ X * Revision 1.2 87/04/29 11:30:55 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: keybrd() -- lock or unlock the terminal keyboard X * X * DIFFERENCE FROM UNIFY: I don't know if UNIFY uses this (it doesn't mention X * termcap support for it), but here it's a no-op except for checking fd = 1 X * as usual. X */ X Xvoid keybrd(fd, flg) { X if (fd != 1) X xerror(-1, "eras_ln", "Multi-terminal operation on fd %d not supported", fd); X} ________This_Is_The_END________ if test `wc -l < keybrd.c` -ne 31; then echo 'shar: keybrd.c was damaged during transit (should have been 31 bytes)' fi fi ; : end of overwriting check echo 'x - loadscr.c' if test -f loadscr.c; then echo 'shar: not overwriting loadscr.c'; else sed 's/^X//' << '________This_Is_The_END________' > loadscr.c X/* X * $Header: loadscr.c,v 1.8 87/06/11 15:21: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: loadscr.c,v $ X * Revision 1.8 87/06/11 15:21:36 brandon X * Wasn't checking the display length against the actual length of fields. X * X * Revision 1.7 87/05/12 11:22:52 brandon X * Forgot to move to the screen field position before underlining! X * X * Revision 1.6 87/05/11 17:01:36 brandon X * dumb bug (sf_type???) X * X * Revision 1.5 87/05/11 16:54:57 brandon X * added code to underline screen fields initially X * X * Revision 1.4 87/05/11 15:30:09 brandon X * chekcs removed, loadscr() works X * X * Revision 1.3 87/05/11 15:26:34 brandon X * added a hook to find a bug in sfield handling X * X * Revision 1.2 87/04/29 11:30:57 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X Xstruct q *__scf = (struct q *) 0; Xint __nsf = 0; Xint _sh_up = 0; X X/* X * Display a string, handling ~-escapes and null-terminating. X */ X Xstatic void mvspit(y, x, s, l) Xchar *s; { X int c; X X#ifdef UNIFY32 X _sdbrt(); /* get bracket & date information */ X#endif X for (c = l - 1; s[c] == ' '; c--) X if (c == 0) X return; X s[++c] = '\0'; X (void) move(y, x); X for (c = 0; s[c] != '\0'; c++) X if (s[c] != '~') { X#ifdef UNIFY32 X if (_ldbrt & UNITED_STATES) X (void) addch(s[c]); X else X switch (s[c]) { X case '[': X (void) addch('('); X break; X case '(': X (void) addch('['); X break; X case ')': X (void) addch(']'); X break; X case ']': X (void) addch(')'); X break; X default: X (void) addch(s[c]); X } X#else X (void) addch(s[c]); X#endif X } else X switch (s[++c]) { X case 'r': X (void) attron(A_REVERSE); X break; X case 's': X (void) attroff(A_REVERSE); X break; X case 'u': X (void) attron(A_UNDERLINE); X break; X case 'v': X (void) attroff(A_UNDERLINE); X break; X case 'w': X (void) attron(A_REVERSE|A_UNDERLINE); X break; X case 'x': X (void) attroff(A_REVERSE|A_UNDERLINE); X break; X case '\0': X c--; X break; X default: X break; X } X} X X/* X * ENTRY POINT: loadscr() -- Load and display a screen .q file. X * X * DIFFERENCE FROM UNIFY: None. X */ X Xvoid loadscr(s) Xchar *s; { X FLDESC fd; X FILE *fp; X char *sf; X int cnt; X X setraw(); X if (__scf != (struct q *) 0) X free((char *) __scf); X __nsf = 0; X if ((sf = dbfile(s, "q")) == (char *) 0) X xerror(-1, "loadscr", "Cannot find screen %s", s); X if ((fp = fopen(sf, "r")) == (FILE *) 0) X xerror(-2, "loadscr", "Cannot open screen %s", s); X (void) fseek(fp, 0L, 2); X if (ftell(fp) == 0L) X return; /* empty??? */ X if ((__scf = (struct q *) malloc((unsigned int) (__nsf = (int) ftell(fp)))) == (struct q *) 0) X xerror(-3, "loadscr", "Out of memory"); X rewind(fp); X __nsf /= sizeof *__scf; X if (fread((char *) __scf, (int) sizeof *__scf, __nsf, fp) != __nsf) X xerror(-4, "loadscr", "Read error on screen %s", s); X for (cnt = 0; cnt < __nsf; cnt++) { X if (__scf[cnt].q_fld == 0) X continue; X if (!fldesc(__scf[cnt].q_fld, &fd)) X xerror(-5, "loadscr", "Invalid database field %.*s", sizeof __scf[cnt].q_dbfld, __scf[cnt].q_dbfld); X if (fd.f_typ != __scf[cnt].q_type) X xerror(-6, "loadscr", "Database field %.*s type has changed -- recompile screen", sizeof __scf[cnt].q_dbfld, __scf[cnt].q_dbfld); X if (fd.f_len != xsize(__scf[cnt].q_type, __scf[cnt].q_len)) X xerror(-7, "loadscr", "Database field %.*s length has changed -- recompile screen", sizeof __scf[cnt].q_dbfld, __scf[cnt].q_dbfld); X } X (void) erase(); X for (cnt = 0; cnt < __nsf; cnt++) { X mvspit(__scf[cnt].q_py, __scf[cnt].q_px, __scf[cnt].q_prmp, sizeof __scf[cnt].q_prmp); X if (__scf[cnt].q_type != 0) { X (void) move(__scf[cnt].q_fy, __scf[cnt].q_fx); X (void) attron(A_UNDERLINE); X (void) printw("%*s", xsize(__scf[cnt].q_type, __scf[cnt].q_len), ""); X (void) attroff(A_UNDERLINE); X } X } X} ________This_Is_The_END________ if test `wc -l < loadscr.c` -ne 161; then echo 'shar: loadscr.c was damaged during transit (should have been 161 bytes)' fi fi ; : end of overwriting check echo 'x - mv_cur.c' if test -f mv_cur.c; then echo 'shar: not overwriting mv_cur.c'; else sed 's/^X//' << '________This_Is_The_END________' > mv_cur.c X/* X * $Header: mv_cur.c,v 1.2 87/04/29 11:31:01 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: mv_cur.c,v $ X * Revision 1.2 87/04/29 11:31:01 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: mv_cur() -- move cursor 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 mv_cur(fd, x, y) { X if (fd != 1) X xerror(-1, "eras_ln", "Multi-terminal operation on fd %d not supported", fd); X if (move(y, x) == ERR) X xerror(-1, "mv_cur", "(%d, %d) cursor position is off the screen", x, y); X} ________This_Is_The_END________ if test `wc -l < mv_cur.c` -ne 33; then echo 'shar: mv_cur.c was damaged during transit (should have been 33 bytes)' fi fi ; : end of overwriting check echo 'x - outbuf.c' if test -f outbuf.c; then echo 'shar: not overwriting outbuf.c'; else sed 's/^X//' << '________This_Is_The_END________' > outbuf.c X/* X * $Header: outbuf.c,v 1.1 87/04/29 14:17:40 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: outbuf.c,v $ X * Revision 1.1 87/04/29 14:17:40 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: outbuf() -- Display data from a buffer to a screen field. X * X * DIFFERENCE FROM UNIFY: None, since screen fields retain decimal info. X */ X Xvoid outbuf(sfld, buf) Xchar *buf; { X int len; X X if (sfld < 0 || sfld >= __nsf) X xerror(-1, "outbuf", "Unknown screen field %d", sfld); 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 (void) move(__scf[sfld].q_fy, __scf[sfld].q_fx); X pflt(__scf[sfld].q_len / 10, (double *) buf, __scf[sfld].q_len % 10); X return; X } X outscrf(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_type & ~_UCF, len, buf); X} ________This_Is_The_END________ if test `wc -l < outbuf.c` -ne 54; then echo 'shar: outbuf.c was damaged during transit (should have been 54 bytes)' fi fi ; : end of overwriting check echo 'x - output.c' if test -f output.c; then echo 'shar: not overwriting output.c'; else sed 's/^X//' << '________This_Is_The_END________' > output.c X/* X * $Header: output.c,v 1.1 87/04/29 14:23: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: output.c,v $ X * Revision 1.1 87/04/29 14:23:38 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: output() -- Output data from the database to a screen field X * X * DIFFERENCE FROM UNIFY: See outbuf() and pflt(). X */ X Xvoid output(sfld) { X int len; X char buf[256]; X X if (sfld < 0 || sfld >= __nsf) X xerror(-1, "output", "Unknown screen field %d", sfld); X if (__scf[sfld].q_fld == 0) X xerror(-2, "output", "Screen field %d has no associated database field", sfld); X if (gfield(__scf[sfld].q_fld, buf) != 0) X xerror(-3, "output", "Read access for field %d denied", __scf[sfld].q_fld); 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 (void) move(__scf[sfld].q_fy, __scf[sfld].q_fx); X pflt(__scf[sfld].q_len / 10, (double *) buf, __scf[sfld].q_len % 10); X return; X } X outscrf(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_type & ~_UCF, len, buf); X} ________This_Is_The_END________ if test `wc -l < output.c` -ne 58; then echo 'shar: output.c was damaged during transit (should have been 58 bytes)' fi fi ; : end of overwriting check echo 'x - outscrf.c' if test -f outscrf.c; then echo 'shar: not overwriting outscrf.c'; else sed 's/^X//' << '________This_Is_The_END________' > outscrf.c X/* X * $Header: outscrf.c,v 1.4 87/05/22 18:01: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: outscrf.c,v $ X * Revision 1.4 87/05/22 18:01:22 brandon X * another dumb bug (`(vid)'?) X * X * Revision 1.3 87/05/22 17:58:48 brandon X * Forgot to move() to the right place before doing output! :-( X * X * Revision 1.2 87/04/29 14:43:24 brandon X * Added cast to (double *) for pflt() call X * X * Revision 1.1 87/04/29 13:18:44 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: outscrf() -- Display a value on the screen X * X * DIFFERENCE FROM UNIFY: Screen fields with type FLT are handled specially. X * See pflt.c for the reason; quick summary is that Unify Corp. blew it. X */ X Xvoid outscrf(x, y, type, len, buf) Xchar *buf; { X (void) setraw(); X (void) move(y, x); X switch (type) { X case INT: X pshort(len, (short *) buf); X break; X case LONG: X plong(len, (long *) buf); X break; X case AMT: X pamt(len, (long *) buf); X break; X case HAMT: X phamt(len, (double *) buf); X break; X case STRNG: X pstr(len, buf); X break; X case DATE: X pdate((short *) buf); X break; X case HR: X ptime((short *) buf); X break; X case FLT: X pflt(len, (double *) buf, -1); /* use %g, we don't know the #dec */ X break; X default: X xerror(-1, "outscrf", "Unknown type %d", type); X } X} ________This_Is_The_END________ if test `wc -l < outscrf.c` -ne 68; then echo 'shar: outscrf.c was damaged during transit (should have been 68 bytes)' fi fi ; : end of overwriting check echo 'x - pageout.c' if test -f pageout.c; then echo 'shar: not overwriting pageout.c'; else sed 's/^X//' << '________This_Is_The_END________' > pageout.c X/* X * $Header: pageout.c,v 1.1 87/04/29 17:04: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: pageout.c,v $ X * Revision 1.1 87/04/29 17:04:47 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * A simple pager, along the lines of that built in to SSQL and the menu X * manager. X */ X Xvoid pageout(fp, title) XFILE *fp; Xchar *title; { X int ch, col, line; X X (void) move(2, 0); X (void) attron(A_REVERSE); X (void) addstr(title); X (void) attroff(A_REVERSE); X (void) addch('\n'); X line = 3; X col = 0; X while ((ch = getc(fp)) != EOF) { X (void) move(line, col); X switch (ch) { X case '\n': X (void) attroff(A_UNDERLINE); X (void) addch('\n'); X if (++line == LINES - 1) { X (void) attron(A_REVERSE); X (void) addstr(" More? Press any key to continue or Q to quit. "); X (void) attroff(A_REVERSE); X (void) refresh(); X switch (getchar() & 0x7f) { X case 'q': X case 'Q': X line = -1; X break; X default: X line = 3; X break; X } X (void) addch('\r'); X (void) clrtoeol(); X } X break; X case '\b': X (void) addch('\b'); X (void) attron(A_UNDERLINE); X if (col > 0) X col--; X continue; X case '\t': X do { X (void) addch(' '); X (void) attroff(A_UNDERLINE); X if (++col == COLS) { X col = 0; X ++line; X break; X } X } while (col % 8 != 0); X if (line == LINES - 1) { X (void) attron(A_REVERSE); X (void) addstr(" More? Press any key to continue or Q to quit. "); X (void) attroff(A_REVERSE); X (void) refresh(); X switch (getchar() & 0x7f) { X case 'q': X case 'Q': X line = -1; X break; X default: X line = 3; X break; X } X (void) addch('\r'); X (void) clrtoeol(); X } X break; X case '\r': X col = 0; X (void) addch('\r'); X (void) attroff(A_UNDERLINE); X break; X default: X if (ch < ' ' || ch > '~') X ch = ' '; X (void) addch(ch); X (void) attroff(A_UNDERLINE); X if (++col < COLS) X break; X col = 0; X if (++line == LINES - 1) { X (void) attron(A_REVERSE); X (void) addstr(" More? Press any key to continue or Q to quit. "); X (void) attroff(A_REVERSE); X (void) refresh(); X switch (getchar() & 0x7f) { X case 'q': X case 'Q': X line = -1; X break; X default: X line = 3; X break; X } X (void) addch('\r'); X (void) clrtoeol(); X } X break; X } X if (line == -1) X break; X } X if (line == -1 || (line == 3 && col == 0)) X return; X prtmsg(1, 23, "Completed. Press RETURN to continue"); X} ________This_Is_The_END________ if test `wc -l < pageout.c` -ne 133; then echo 'shar: pageout.c was damaged during transit (should have been 133 bytes)' fi fi ; : end of overwriting check echo 'x - pamt.c' if test -f pamt.c; then echo 'shar: not overwriting pamt.c'; else sed 's/^X//' << '________This_Is_The_END________' > pamt.c X/* X * $Header: pamt.c,v 1.1 87/04/29 12:18:40 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: pamt.c,v $ X * Revision 1.1 87/04/29 12:18:40 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Display a value of type AMT. X */ X Xvoid pamt(len, buf) Xlong *buf; { X (void) setraw(); X if (len < 4) X return; X (void) attron(A_UNDERLINE); X (void) printw("%*ld.%02d", len - 3, *buf / 100L, *buf % 100L); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < pamt.c` -ne 32; then echo 'shar: pamt.c was damaged during transit (should have been 32 bytes)' fi fi ; : end of overwriting check echo 'x - pdata.c' if test -f pdata.c; then echo 'shar: not overwriting pdata.c'; else sed 's/^X//' << '________This_Is_The_END________' > pdata.c X/* X * $Header: pdata.c,v 1.1 87/04/29 13:51:45 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: pdata.c,v $ X * Revision 1.1 87/04/29 13:51:45 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: pdata() -- Display data from database fields X * X * DIFFERENCE FROM UNIFY: FLT is FUBAR; see pflt.c. X */ X Xvoid pdata(x, y, fld) { X char fbuf[256]; X FLDESC fd; X X if (!fldesc(fld, &fd)) X xerror(-1, "pdata", "Unknown database field %d", fld); X if (fd.f_typ == COMB) X xerror(-2, "pdata", "COMB field %d illegal", fld); X if (gfield(fld, fbuf) != 0) X xerror(-3, "pdata", "Read access for field %d denied", fld); X outscrf(x, y, fd.f_typ, fd.f_len, fbuf); X} ________This_Is_The_END________ if test `wc -l < pdata.c` -ne 37; then echo 'shar: pdata.c was damaged during transit (should have been 37 bytes)' fi fi ; : end of overwriting check echo 'x - pdate.c' if test -f pdate.c; then echo 'shar: not overwriting pdate.c'; else sed 's/^X//' << '________This_Is_The_END________' > pdate.c X/* X * $Header: pdate.c,v 1.1 87/04/29 12:18: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: pdate.c,v $ X * Revision 1.1 87/04/29 12:18:30 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Display a value of type DATE. Under UNIFY 3.2, this is easier... X */ X X#ifdef UNIFY32 X Xvoid pdate(buf) Xshort *buf; { X char dbuf[8]; X X (void) setraw(); X (void) attron(A_UNDERLINE); X (void) dspdt(*buf, dbuf); /* handles DATETP automatically */ X (void) printw("%.8s", dbuf); X (void) attroff(A_UNDERLINE); X} X X#else X Xvoid pdate(buf) Xshort *buf; { X int date[3]; X X (void) setraw(); X (void) attron(A_UNDERLINE); X if (*buf == NULLDATE) X (void) addstr("**/**/**"); X else { X kdate(*buf, date); X (void) printw("%02d/%02d/%02d", date[MONTH], date[DAY], date[YEAR]); X } X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < pdate.c` -ne 52; then echo 'shar: pdate.c was damaged during transit (should have been 52 bytes)' fi fi ; : end of overwriting check echo 'x - pflt.c' if test -f pflt.c; then echo 'shar: not overwriting pflt.c'; else sed 's/^X//' << '________This_Is_The_END________' > pflt.c X/* X * $Header: pflt.c,v 1.2 87/04/29 14:41:32 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: pflt.c,v $ X * Revision 1.2 87/04/29 14:41:32 brandon X * Forgot to declare pflt() as (void)! X * X * Revision 1.1 87/04/29 12:36:23 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Display a value of type FLT. Note that there is a problem here -- screen X * fields come with # of decimals, database fields and outscrf() specs do not. X * This problem persists and I don't know what, really, to do about it in the X * case of database fields. Screen fields get their specified decimals, X * however, and outscrf() uses %g to avoid the issue entirely. So dbfields X * use outscrf() and you have to accept the loss. X * X * This is a botch. UNIFY Corporation, PLEASE FIX THIS!!! I don't like the X * loss of this data and I don't like violating license agreements to dig it X * out of the guts of UNITRIEVE! X */ X Xvoid pflt(len, buf, ndec) Xdouble *buf; { X (void) setraw(); X (void) attron(A_UNDERLINE); X if (ndec == -1) /* unknown decimals */ X (void) printw("%*g", len, *buf); X else X (void) printw("%*.*f", len, ndec, *buf); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < pflt.c` -ne 45; then echo 'shar: pflt.c was damaged during transit (should have been 45 bytes)' fi fi ; : end of overwriting check echo 'x - pflush.c' if test -f pflush.c; then echo 'shar: not overwriting pflush.c'; else sed 's/^X//' << '________This_Is_The_END________' > pflush.c X/* X * $Header: pflush.c,v 1.1 87/06/01 15:32: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: pflush.c,v $ X * Revision 1.1 87/06/01 15:32:07 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * The pflush() function does a refresh() without having to include the X * curses header file in a user program not otherwise using curses. X */ X Xvoid pflush() { X (void) refresh(); X} ________This_Is_The_END________ if test `wc -l < pflush.c` -ne 27; then echo 'shar: pflush.c was damaged during transit (should have been 27 bytes)' fi fi ; : end of overwriting check echo 'x - phamt.c' if test -f phamt.c; then echo 'shar: not overwriting phamt.c'; else sed 's/^X//' << '________This_Is_The_END________' > phamt.c X/* X * $Header: phamt.c,v 1.1 87/04/29 12:35:58 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: phamt.c,v $ X * Revision 1.1 87/04/29 12:35:58 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Print a value of type HAMT. X */ X Xvoid phamt(len, buf) Xdouble *buf; { X (void) setraw(); X (void) attron(A_UNDERLINE); X (void) printw("%*.2f", len, *buf / 100.0); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < phamt.c` -ne 30; then echo 'shar: phamt.c was damaged during transit (should have been 30 bytes)' fi fi ; : end of overwriting check echo 'x - plong.c' if test -f plong.c; then echo 'shar: not overwriting plong.c'; else sed 's/^X//' << '________This_Is_The_END________' > plong.c X/* X * $Header: plong.c,v 1.1 87/04/29 12:47: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: plong.c,v $ X * Revision 1.1 87/04/29 12:47:21 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Display a value of type LONG. X */ X Xvoid plong(len, buf) Xlong *buf; { X (void) setraw(); X (void) attron(A_UNDERLINE); X (void) printw("%*ld", len, *buf); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < plong.c` -ne 30; then echo 'shar: plong.c was damaged during transit (should have been 30 bytes)' fi fi ; : end of overwriting check echo 'x - priamd.c' if test -f priamd.c; then echo 'shar: not overwriting priamd.c'; else sed 's/^X//' << '________This_Is_The_END________' > priamd.c X/* X * $Header: priamd.c,v 1.4 87/04/29 16:02: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: priamd.c,v $ X * Revision 1.4 87/04/29 16:02:38 brandon X * Added a (void) cast to mvaddstr(). X * X * Revision 1.3 87/04/29 15:56:10 brandon X * Added $UUACL handler X * X * Revision 1.2 87/04/29 11:31:08 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X#include <ctype.h> X Xextern int logacl; /* access level, set from sysrecev */ X X/* X * ENTRY POINT: priamd() -- prompt for operational mode X * X * DIFFERENCE FROM UNIFY: We no longer wait for a newline. Also, the blocky X * bleechy "[I]NQUIRE" type stuff is now "Inquire" which looks much nicer. X */ X Xpriamd(line) { X char cmdline[80], cmd[6]; X char ch; X static int uuacl = -1; X X (void) mvaddstr(line, 1, " "); X if (uuacl == -1) { X char *ep; X X if (logacl < 0 || logacl > 15) X logacl = INQUIRE; X if ((ep = getenv("UUACL")) == (char *) 0) X uuacl = logacl; X else if ((uuacl = atoi(ep)) <= 0 || uuacl > 15) X uuacl = logacl; X logacl = uuacl; X } X if (logacl == 0) X return BACK; X cmdline[0] = '\0'; X cmd[0] = '\0'; X if (logacl & INQUIRE) { X (void) strcat(cmdline, "Inquire"); X (void) strcat(cmd, "I"); X } X if (logacl & ADD) { X if (cmdline[0] != '\0') X (void) strcat(cmdline, ", "); X (void) strcat(cmdline, "Add"); X (void) strcat(cmd, "A"); X } X if (logacl & MODIFY) { X if (cmdline[0] != '\0') X (void) strcat(cmdline, ", "); X (void) strcat(cmdline, "Modify"); X (void) strcat(cmd, "M"); X } X if (logacl & DELETE) { X if (cmdline[0] != '\0') X (void) strcat(cmdline, ", "); X (void) strcat(cmdline, "Delete"); X (void) strcat(cmd, "D"); X } X (void) strcat(cmdline, "? "); X (void) mvaddstr(22, 1, cmdline); X for (;; (void) beep()) { X ch = toupper(getchar() & 0x7f); X if (ch == '\0') X continue; X if (ch == '\t' || ch == '\025') { X (void) addch('\r'); X (void) clrtoeol(); X return BACK; X } X if (strchr(cmd, ch) != (char *) 0) X break; X } X (void) addch('\r'); X (void) clrtoeol(); X switch (ch) { X case 'I': X (void) mvaddstr(line, 1, "Inquire mode"); X return 0; X case 'A': X (void) mvaddstr(line, 1, "Add mode"); X return 1; X case 'M': X (void) mvaddstr(line, 1, "Modify mode"); X return 2; X case 'D': X (void) mvaddstr(line, 1, "Delete mode"); X return 3; X } X xerror(-1, "priamd", "Illegal internal state %c", ch); X /*NOTREACHED*/ X} ________This_Is_The_END________ if test `wc -l < priamd.c` -ne 111; then echo 'shar: priamd.c was damaged during transit (should have been 111 bytes)' fi fi ; : end of overwriting check echo 'x - prmp.c' if test -f prmp.c; then echo 'shar: not overwriting prmp.c'; else sed 's/^X//' << '________This_Is_The_END________' > prmp.c X/* X * $Header: prmp.c,v 1.2 87/04/29 11:31:10 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: prmp.c,v $ X * Revision 1.2 87/04/29 11:31:10 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: prmp() -- Display a string X * X * DIFFERENCE FROM UNIFY: Rather than dim/normal, uses regular output vs. X * data fields underlined (if supported). X */ X Xvoid prmp(x, y, str) Xchar *str; { X (void) mvaddstr(y, x, str); X} ________This_Is_The_END________ if test `wc -l < prmp.c` -ne 30; then echo 'shar: prmp.c was damaged during transit (should have been 30 bytes)' fi fi ; : end of overwriting check echo 'x - prmpf.c' if test -f prmpf.c; then echo 'shar: not overwriting prmpf.c'; else sed 's/^X//' << '________This_Is_The_END________' > prmpf.c X/* X * $Header: prmpf.c,v 1.2 87/04/29 11:31: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: prmpf.c,v $ X * Revision 1.2 87/04/29 11:31:12 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: prmpf() -- Display a string in the foreground X * X * DIFFERENCE FROM UNIFY: Rather than dim/normal, uses regular output vs. X * data fields underlined (if supported). Note that cleancrt() won't undo X * these, unfortunately. X */ X Xvoid prmpf(x, y, str) Xchar *str; { X (void) attron(A_UNDERLINE); X (void) mvaddstr(y, x, str); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < prmpf.c` -ne 33; then echo 'shar: prmpf.c was damaged during transit (should have been 33 bytes)' fi fi ; : end of overwriting check echo 'x - prmprv.c' if test -f prmprv.c; then echo 'shar: not overwriting prmprv.c'; else sed 's/^X//' << '________This_Is_The_END________' > prmprv.c X/* X * $Header: prmprv.c,v 1.2 87/04/29 11:31: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: prmprv.c,v $ X * Revision 1.2 87/04/29 11:31:14 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: prmprv() -- Display a string in reverse video X * X * DIFFERENCE FROM UNIFY: None (!) X */ X Xvoid prmprv(x, y, str) Xchar *str; { X (void) attron(A_REVERSE); X (void) mvaddstr(y, x, str); X (void) attroff(A_REVERSE); X} ________This_Is_The_END________ if test `wc -l < prmprv.c` -ne 31; then echo 'shar: prmprv.c was damaged during transit (should have been 31 bytes)' fi fi ; : end of overwriting check echo 'x - prtmsg.c' if test -f prtmsg.c; then echo 'shar: not overwriting prtmsg.c'; else sed 's/^X//' << '________This_Is_The_END________' > prtmsg.c X/* X * $Header: prtmsg.c,v 1.2 87/04/29 11:31:16 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: prtmsg.c,v $ X * Revision 1.2 87/04/29 11:31:16 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: prtmsg() -- Spit out a message in reverse video and wait for X * a keypress. X * X * DIFFERENCE FROM UNIFY: Typeahead is discarded. This prevents the problems X * we have with people typing faster than they are thinking. :-) X */ X Xvoid prtmsg(x, y, str) Xchar *str; { X setraw(); X (void) flushinp(); X (void) attrset(A_REVERSE); X (void) mvprintw(y, x, " %s -> -> ", str); X (void) attrset(0); X (void) refresh(); X (void) getchar(); X (void) move(y, x); X (void) clrtoeol(); X (void) refresh(); /* so it disappears immediately */ X} ________This_Is_The_END________ if test `wc -l < prtmsg.c` -ne 40; then echo 'shar: prtmsg.c was damaged during transit (should have been 40 bytes)' fi fi ; : end of overwriting check echo 'x - pshort.c' if test -f pshort.c; then echo 'shar: not overwriting pshort.c'; else sed 's/^X//' << '________This_Is_The_END________' > pshort.c X/* X * $Header: pshort.c,v 1.1 87/04/29 12:47: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: pshort.c,v $ X * Revision 1.1 87/04/29 12:47:33 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Display a value of type INT. X */ X Xvoid pshort(len, buf) Xshort *buf; { X (void) setraw(); X (void) attron(A_UNDERLINE); X (void) printw("%*d", len, *buf); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < pshort.c` -ne 30; then echo 'shar: pshort.c was damaged during transit (should have been 30 bytes)' fi fi ; : end of overwriting check echo 'x - pstr.c' if test -f pstr.c; then echo 'shar: not overwriting pstr.c'; else sed 's/^X//' << '________This_Is_The_END________' > pstr.c X/* X * $Header: pstr.c,v 1.3 87/06/03 14:05: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: pstr.c,v $ X * Revision 1.3 87/06/03 14:05:11 brandon X * TRY qmove(), DUMMY! :-) X * X * Revision 1.2 87/06/03 13:51:32 brandon X * Added workaround for UNITRIEVE nulls misfeature. X * X * Revision 1.1 87/04/29 12:47:40 brandon X * Initial revision X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * Display a value of type STRNG. This would be simple if not for the penchant X * of UNITRIEVE to initialize STRNG fields to nulls.... X */ X Xvoid pstr(len, buf) Xchar *buf; { X char nulls[256]; X X cfill(0, nulls, len); X if (ivcmp(buf, nulls, len)) X cfill(' ', nulls, len); X else X qmove(buf, nulls, len); X (void) setraw(); X (void) attron(A_UNDERLINE); X (void) printw("%.*s", len, nulls); X (void) attroff(A_UNDERLINE); X} ________This_Is_The_END________ if test `wc -l < pstr.c` -ne 44; then echo 'shar: pstr.c was damaged during transit (should have been 44 bytes)' fi fi ; : end of overwriting check echo 'x - ptct_crt.c' if test -f ptct_crt.c; then echo 'shar: not overwriting ptct_crt.c'; else sed 's/^X//' << '________This_Is_The_END________' > ptct_crt.c X/* X * $Header: ptct_crt.c,v 1.2 87/04/29 11:31: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: ptct_crt.c,v $ X * Revision 1.2 87/04/29 11:31:17 brandon X * Added RCS header information X * X */ X X/*LINTLIBRARY*/ X X#include "usc.h" X X/* X * ENTRY POINT: ptct_crt() -- turn on terminal write protection X * X * DIFFERENCE FROM UNIFY: All we do is check fd == 1, since curses handles the X * screen itself. X */ X Xvoid ptct_crt(fd, flg) { X if (fd != 1) X xerror(-1, "ptct_crt", "Multi-terminal operation on fd %d not supported", fd); X} ________This_Is_The_END________ if test `wc -l < ptct_crt.c` -ne 30; then echo 'shar: ptct_crt.c was damaged during transit (should have been 30 bytes)' fi fi ; : end of overwriting check exit 0