home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume2 / usc / Part3 < prev    next >
Internet Message Format  |  1991-08-07  |  61KB

  1. From: allbery@ncoast.UUCP (Brandon S. Allbery)
  2. Newsgroups: comp.sources.misc
  3. Subject: v02i035: UNIFY(r) Screens with Curses, Part 3 of 4
  4. Message-ID: <7162@ncoast.UUCP>
  5. Date: 31 Jan 88 04:14:08 GMT
  6. Approved: allbery@ncoast.UUCP
  7.  
  8. Comp.sources.misc: Volume 2, Issue 35
  9. Submitted-By: The Moderator <allbery@ncoast.UUCP>
  10. Archive-Name: usc/Part3
  11.  
  12. I've received so many requests for my Unify(r) screen routines that I am
  13. posting them.  The USC library is in four parts; unshar them and type "make".
  14. The curses used is System V; BSDers will want to tweak the usual stuff, such
  15. as beep() and cbreak().
  16.  
  17. I also have a simple screen program using this; if demand warrants, I will
  18. post it -- but in terms of features, you're probably better off with ENTER.
  19.  
  20. #--------------------------------CUT HERE-------------------------------------
  21. #! /bin/sh
  22. #
  23. # This is a shell archive.  Save this into a file, edit it
  24. # and delete all lines above this comment.  Then give this
  25. # file to sh by executing the command "sh file".  The files
  26. # will be extracted into the current directory owned by
  27. # you with default permissions.
  28. #
  29. # The files contained herein are:
  30. #
  31. # -r--r--r--  1 allbery users       761 Jan 30 18:01 ptct_wrt.c
  32. # -r--r--r--  1 allbery users       710 Jan 30 18:01 ptime.c
  33. # -r--r--r--  1 allbery users       800 Jan 30 18:01 ptube.c
  34. # -r--r--r--  1 allbery users      6626 Jan 30 18:01 ringmenu.c
  35. # -rw-rw-rw-  1 allbery users       152 Jan 30 18:01 ringmenu.h
  36. # -r--r--r--  1 allbery users       769 Jan 30 18:01 setcook.c
  37. # -r--r--r--  1 allbery users       703 Jan 30 18:01 setraw.c
  38. # -r--r--r--  1 allbery users       583 Jan 30 18:01 setxrc.c
  39. # -r--r--r--  1 allbery users       761 Jan 30 18:01 sfldesc.c
  40. # -r--r--r--  1 allbery users      2483 Jan 30 18:01 shellout.c
  41. # -rw-r--r--  1 allbery users       302 Jan 30 18:01 tester.c
  42. # -r--r--r--  1 allbery users      2314 Jan 30 18:01 uamt.c
  43. # -r--r--r--  1 allbery users      5459 Jan 30 18:01 udate.c
  44. # -r--r--r--  1 allbery users       789 Jan 30 18:01 uerror.c
  45. # -r--r--r--  1 allbery users      2267 Jan 30 18:01 uflt.c
  46. # -r--r--r--  1 allbery users      2325 Jan 30 18:01 uhamt.c
  47. # -r--r--r--  1 allbery users      1929 Jan 30 18:01 ulong.c
  48. # -r--r--r--  1 allbery users      1849 Jan 30 18:01 upbuf.c
  49. # -r--r--r--  1 allbery users      2266 Jan 30 18:01 updata.c
  50. # -r--r--r--  1 allbery users      1252 Jan 30 18:01 upfield.c
  51. # -r--r--r--  1 allbery users      2779 Jan 30 18:01 upscrf.c
  52. # -r--r--r--  1 allbery users      2172 Jan 30 18:01 uptube.c
  53. # -rw-r--r--  1 allbery users      4578 Jan 30 18:01 usc.h
  54. # -r--r--r--  1 allbery users      2034 Jan 30 18:01 ushort.c
  55. # -r--r--r--  1 allbery users      1339 Jan 30 18:01 ustr.c
  56. #
  57. echo 'x - ptct_wrt.c'
  58. if test -f ptct_wrt.c; then echo 'shar: not overwriting ptct_wrt.c'; else
  59. sed 's/^X//' << '________This_Is_The_END________' > ptct_wrt.c
  60. X/*
  61. X * $Header: ptct_wrt.c,v 1.2 87/04/29 11:31:19 brandon Exp $
  62. X *
  63. X * ``USC'' -- UNIFY(r) Screens using Curses
  64. X * UNIFY(r) is a registered trademark of Unify Corporation.
  65. X *
  66. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  67. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  68. X *
  69. X * $Log:    ptct_wrt.c,v $
  70. X * Revision 1.2  87/04/29  11:31:19  brandon
  71. X * Added RCS header information
  72. X * 
  73. X */
  74. X
  75. X/*LINTLIBRARY*/
  76. X
  77. X#include "usc.h"
  78. X
  79. X/*
  80. X * ENTRY POINT:  ptct_wrt() -- Specify whether output is to be in protected
  81. X * mode or not
  82. X *
  83. X * DIFFERENCE FROM UNIFY:  All we do is check fd == 1, since curses handles the
  84. X * screen itself.
  85. X */
  86. X
  87. Xvoid ptct_wrt(fd, flg) {
  88. X    if (fd != 1)
  89. X        xerror(-1, "ptct_wrt", "Multi-terminal operation on fd %d not supported", fd);
  90. X}
  91. ________This_Is_The_END________
  92. if test `wc -l < ptct_wrt.c` -ne 31; then
  93.     echo 'shar: ptct_wrt.c was damaged during transit (should have been 31 bytes)'
  94. fi
  95. fi        ; : end of overwriting check
  96. echo 'x - ptime.c'
  97. if test -f ptime.c; then echo 'shar: not overwriting ptime.c'; else
  98. sed 's/^X//' << '________This_Is_The_END________' > ptime.c
  99. X/*
  100. X * $Header: ptime.c,v 1.2 87/04/29 12:57:34 brandon Exp $
  101. X *
  102. X * ``USC'' -- UNIFY(r) Screens using Curses
  103. X * UNIFY(r) is a registered trademark of Unify Corporation.
  104. X *
  105. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  106. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  107. X *
  108. X * $Log:    ptime.c,v $
  109. X * Revision 1.2  87/04/29  12:57:34  brandon
  110. X * DUMB!!!  Forgot to deref the buffer
  111. X * 
  112. X * Revision 1.1  87/04/29  12:49:31  brandon
  113. X * Initial revision
  114. X * 
  115. X */
  116. X
  117. X/*LINTLIBRARY*/
  118. X
  119. X#include "usc.h"
  120. X
  121. X/*
  122. X * Display a value of type HR.
  123. X */
  124. X
  125. Xvoid ptime(buf)
  126. Xshort *buf; {
  127. X    (void) setraw();
  128. X    (void) attron(A_UNDERLINE);
  129. X    (void) printw("%02d:%02d", *buf / 100, *buf % 100);
  130. X    (void) attroff(A_UNDERLINE);
  131. X}
  132. ________This_Is_The_END________
  133. if test `wc -l < ptime.c` -ne 33; then
  134.     echo 'shar: ptime.c was damaged during transit (should have been 33 bytes)'
  135. fi
  136. fi        ; : end of overwriting check
  137. echo 'x - ptube.c'
  138. if test -f ptube.c; then echo 'shar: not overwriting ptube.c'; else
  139. sed 's/^X//' << '________This_Is_The_END________' > ptube.c
  140. X/*
  141. X * $Header: ptube.c,v 1.1 87/04/29 13:37:02 brandon Exp $
  142. X *
  143. X * ``USC'' -- UNIFY(r) Screens using Curses
  144. X * UNIFY(r) is a registered trademark of Unify Corporation.
  145. X *
  146. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  147. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  148. X *
  149. X * $Log:    ptube.c,v $
  150. X * Revision 1.1  87/04/29  13:37:02  brandon
  151. X * Initial revision
  152. X * 
  153. X */
  154. X
  155. X/*LINTLIBRARY*/
  156. X
  157. X#include "usc.h"
  158. X
  159. X/*
  160. X * ENTRY POINT:  ptube() -- Display data from a buffer in the format of a
  161. X * database field
  162. X *
  163. X * DIFFERENCE FROM UNIFY:  FLT ends up being printed with %g.  See pflt()
  164. X * for the gory details.
  165. X */
  166. X
  167. Xvoid ptube(x, y, fld, buf)
  168. Xchar *buf; {
  169. X    FLDESC fd;
  170. X
  171. X    if (!fldesc(fld, &fd))
  172. X        xerror(-1, "ptube", "Invalid database field %d", fld);
  173. X    outscrf(x, y, fd.f_typ, fd.f_len, buf);
  174. X}
  175. ________This_Is_The_END________
  176. if test `wc -l < ptube.c` -ne 35; then
  177.     echo 'shar: ptube.c was damaged during transit (should have been 35 bytes)'
  178. fi
  179. fi        ; : end of overwriting check
  180. echo 'x - ringmenu.c'
  181. if test -f ringmenu.c; then echo 'shar: not overwriting ringmenu.c'; else
  182. sed 's/^X//' << '________This_Is_The_END________' > ringmenu.c
  183. X/*
  184. X * $Header: ringmenu.c,v 1.9 87/06/11 15:50:36 brandon Exp $
  185. X *
  186. X * ``USC'' -- UNIFY(r) Screens using Curses
  187. X * UNIFY(r) is a registered trademark of Unify Corporation.
  188. X *
  189. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  190. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  191. X *
  192. X * $Log:    ringmenu.c,v $
  193. X * Revision 1.9  87/06/11  15:50:36  brandon
  194. X * Fixed page backup bug, used XRC_NOFLSH in showmenu(), misc. other fixes.
  195. X * 
  196. X * Revision 1.8  87/06/02  18:47:53  brandon
  197. X * Had forgotten to force input to uppercase.
  198. X * 
  199. X * Revision 1.7  87/06/02  18:41:05  brandon
  200. X * Now uses XRC_FWDGO, so pressing RETURN has a more intuitive result.
  201. X * 
  202. X * Revision 1.6  87/06/02  18:23:10  brandon
  203. X * Fixed another page-number bug.
  204. X * 
  205. X * Revision 1.5  87/06/02  17:35:22  brandon
  206. X * Fixed bug with `page' numbering, and added a setraw() in case it's called
  207. X * before any other USC functions.
  208. X * 
  209. X * Revision 1.4  87/06/02  16:14:38  brandon
  210. X * Fully linted.
  211. X * 
  212. X * Revision 1.3  87/06/02  16:02:33  brandon
  213. X * Partially linted.
  214. X * 
  215. X * Revision 1.2  87/06/02  15:47:15  brandon
  216. X * Partially linted.
  217. X * 
  218. X * Revision 1.1  87/06/02  15:37:27  brandon
  219. X * Initial revision
  220. X * 
  221. X */
  222. X
  223. X/*LINTLIBRARY*/
  224. X
  225. X#include "usc.h"
  226. X
  227. X/*
  228. X * Ring menu manager.  You haven't seen a real ring menu yet; this one uses
  229. X * the full capability of the key primitives (including using "view" to show
  230. X * all the entries on the menu, one per line in a temp window), it scrolls if
  231. X * the menu is wider than the screen, etc.  Rather than using `!' shellout,
  232. X * the ^P convention is used (subshell for Sys5, suspend for BSD) as a part
  233. X * of the input function (the same one used by inl()).  (Late-breaking news:
  234. X * the latest version of I4GL now supports wrapound ring menus.  But the help
  235. X * feature is still unique to USC.)
  236. X *
  237. X * space, CR    next (wraps)
  238. X * tab        exit without selecting
  239. X * esc        execute
  240. X * ^F        next `page'
  241. X * ^B        last `page'
  242. X * ^X        exit program
  243. X * ^P        shellout/suspend
  244. X * ^H        previous (wraps)
  245. X * ^V        display all menu entries in a window
  246. X */
  247. X
  248. Xstatic int paws(w)
  249. XWINDOW *w; {
  250. X    (void) wmove(w, LINES - 1, 0);
  251. X    (void) wattron(w, A_STANDOUT);
  252. X    (void) waddstr(w, " Press ENTER for the next page, or TAB to return: ");
  253. X    (void) wattroff(w, A_STANDOUT);
  254. X    (void) wclrtoeol(w);
  255. X    (void) wrefresh(w);
  256. X    switch (incs(XRC_NOFLSH)) {
  257. X    case -2:
  258. X        return 0;
  259. X    case -3:
  260. X        return 1;
  261. X    }
  262. X    /*NOTREACHED*/
  263. X}
  264. X
  265. Xstatic void showmenu(title, items)
  266. Xchar *title;
  267. Xstruct cmd *items; {
  268. X    int nitem, line;
  269. X    WINDOW *w;
  270. X
  271. X    (void) refresh();    /* otherwise incs() zaps the top two lines */
  272. X    if ((w = newwin(LINES, COLS, 0, 0)) == (WINDOW *) 0)
  273. X        xerror("showmenu", -1, "no space for menu window for `%s'", (title == (char *) 0? "(null)": title));
  274. X    (void) mvwaddstr(w, 0, 0, "Commands on th");
  275. X    if (title == (char *) 0 || title[0] == '\0')
  276. X        (void) waddstr(w, "is");
  277. X    else
  278. X        (void) wprintw(w, "e %s", title);
  279. X    (void) waddstr(w, " menu:\n");
  280. X    (void) waddstr(w, "SPACE or ENTER moves forward, BACKSPACE moves backward, ESC selects, TAB exits;\n");
  281. X    (void) waddstr(w, "      CONTROL-F moves forward one page, CONTROL-B moves backward one page.\n");
  282. X    line = 4;
  283. X    for (nitem = 0; items[nitem].c_key != EOM; nitem++) {
  284. X        if (line == LINES - 1)
  285. X            if (!paws(w))
  286. X                break;
  287. X            else {
  288. X                (void) wmove(w, 4, 0);
  289. X                (void) wclrtobot(w);
  290. X                line = 4;
  291. X            }
  292. X        (void) wmove(w, line, 0);
  293. X        if (items[nitem].c_title != INVISIBLE)
  294. X            (void) waddstr(w, items[nitem].c_title);
  295. X        else
  296. X            (void) waddch(w, items[nitem].c_key);
  297. X        (void) wprintw(w, "\t%s", items[nitem].c_desc);
  298. X        line++;
  299. X    }
  300. X    (void) paws(w);
  301. X    (void) delwin(w);
  302. X    (void) touchwin(stdscr);
  303. X}
  304. X
  305. Xint ringmenu(title, menu/* , initial */)
  306. Xchar *title;
  307. Xstruct cmd *menu; {
  308. X    int *mpage;
  309. X    int nitem, npage, len, page, item, ch, x, y;
  310. X
  311. X    setraw();
  312. X    npage = 1;
  313. X    if (title != (char *) 0 && *title != '\0')
  314. X        len = strlen(title) + 2;
  315. X    else
  316. X        len = 0;
  317. X    for (nitem = 0; menu[nitem].c_key != EOM; nitem++)
  318. X        if (menu[nitem].c_title != INVISIBLE)
  319. X            if ((len += strlen(menu[nitem].c_title) + 2) >= COLS - 1) {
  320. X                npage++;
  321. X                if (title != (char *) 0 && *title != '\0')
  322. X                    len = strlen(title) + 2;
  323. X                else
  324. X                    len = 0;
  325. X            }
  326. X    if ((mpage = (int *) malloc((unsigned) (npage + 1) * sizeof *mpage)) == (int *) 0)
  327. X        xerror("ringmenu", 0, "No memory for menu `%s' page layout", (title == (char *) 0? "(null)": title));
  328. X    npage = 0;
  329. X    if (title != (char *) 0 && *title != '\0')
  330. X        len = strlen(title) + 2;
  331. X    else
  332. X        len = 0;
  333. X    mpage[0] = 0;
  334. X    for (nitem = 0; menu[nitem].c_key != EOM; nitem++)
  335. X        if (menu[nitem].c_title != INVISIBLE)
  336. X            if ((len += strlen(menu[nitem].c_title) + 2) >= COLS - 1) {
  337. X                mpage[++npage] = nitem;
  338. X                if (title != (char *) 0 && *title != '\0')
  339. X                    len = strlen(title) + 2;
  340. X                else
  341. X                    len = 0;
  342. X            }
  343. X    mpage[++npage] = -1;
  344. X    item = 0;
  345. X    page = 0;
  346. X    for (;;) {
  347. X        (void) move(0, 0);
  348. X        if (title != (char *) 0 && title[0] != '\0')
  349. X            (void) printw("%s: ", title);
  350. X        for (len = mpage[page]; menu[len].c_key != EOM && (page == npage - 1 || len < mpage[page + 1]); len++) {
  351. X            if (menu[len].c_title == INVISIBLE)
  352. X                continue;
  353. X            if (len == item)
  354. X                (void) attron(A_STANDOUT);
  355. X            (void) printw(" %s ", menu[len].c_title);
  356. X            if (len == item) {
  357. X                (void) attroff(A_STANDOUT);
  358. X                if (menu[len].c_desc != (char *) 0) {
  359. X                    getyx(stdscr, y, x);
  360. X                    (void) mvaddstr(1, 0, menu[len].c_desc);
  361. X                    (void) clrtoeol();
  362. X                    (void) move(y, x);
  363. X                }
  364. X            }
  365. X        }
  366. X        (void) clrtoeol();
  367. X        if (title != (char *) 0 && *title != '\0')
  368. X            (void) move(0, strlen(title) + 1);
  369. X        else
  370. X            (void) move(0, COLS - 1);
  371. X        (void) refresh();
  372. X        ch = incs(XRC_CFB|XRC_LOOK|XRC_GO|XRC_CHAR|XRC_BKSP|XRC_FWDGO);
  373. X        if (islower(ch))
  374. X            ch = toupper(ch);
  375. X        (void) move(0, 0);
  376. X        (void) clrtoeol();
  377. X        (void) move(1, 0);
  378. X        (void) clrtoeol();
  379. X        switch (ch) {
  380. X        case BKSP:
  381. X            if (--item < mpage[page])
  382. X                if (page-- == 0) {
  383. X                    page = npage - 1;
  384. X                    for (item = mpage[page]; menu[item].c_key != EOM; item++)
  385. X                        ;
  386. X                    item--;
  387. X                }
  388. X            break;
  389. X        case BACK:
  390. X            free((char *) mpage);
  391. X            return BACK;
  392. X        case FWD:
  393. X            if (menu[++item].c_key == EOM) {
  394. X                page = 0;
  395. X                item = 0;
  396. X            }
  397. X            else if (mpage[page + 1] != -1 && item == mpage[page + 1])
  398. X                page++;
  399. X            break;
  400. X        case LOOK:
  401. X            showmenu(title, menu);
  402. X            break;
  403. X        case GO:
  404. X            free((char *) mpage);
  405. X            return menu[item].c_key;
  406. X        case CFWD:
  407. X            if (mpage[++page] == -1)
  408. X                page = 0;
  409. X            item = mpage[page];
  410. X            break;
  411. X        case CBACK:
  412. X            if (page-- == 0)
  413. X                page = npage - 1;
  414. X            item = mpage[page];
  415. X            break;
  416. X        default:
  417. X            for (len = 0; menu[len].c_key != EOM; len++)
  418. X                if ((islower(menu[len].c_key)? toupper(menu[len].c_key): menu[len].c_key) == ch) {
  419. X                    free((char *) mpage);
  420. X                    return menu[len].c_key;
  421. X                }
  422. X            (void) beep();
  423. X        }
  424. X    }
  425. X}
  426. ________This_Is_The_END________
  427. if test `wc -l < ringmenu.c` -ne 243; then
  428.     echo 'shar: ringmenu.c was damaged during transit (should have been 243 bytes)'
  429. fi
  430. fi        ; : end of overwriting check
  431. echo 'x - ringmenu.h'
  432. if test -f ringmenu.h; then echo 'shar: not overwriting ringmenu.h'; else
  433. sed 's/^X//' << '________This_Is_The_END________' > ringmenu.h
  434. Xstruct ringmenu {
  435. X    char c_key;
  436. X    char *c_title;
  437. X    char *c_desc;
  438. X};
  439. X
  440. X#define EOM        '\0'    /* end of ring menu */
  441. X#define INVIS        ""    /* invisible menu entry */
  442. ________This_Is_The_END________
  443. if test `wc -l < ringmenu.h` -ne 8; then
  444.     echo 'shar: ringmenu.h was damaged during transit (should have been 8 bytes)'
  445. fi
  446. fi        ; : end of overwriting check
  447. echo 'x - setcook.c'
  448. if test -f setcook.c; then echo 'shar: not overwriting setcook.c'; else
  449. sed 's/^X//' << '________This_Is_The_END________' > setcook.c
  450. X/*
  451. X * $Header: setcook.c,v 1.2 87/04/29 11:31:20 brandon Exp $
  452. X *
  453. X * ``USC'' -- UNIFY(r) Screens using Curses
  454. X * UNIFY(r) is a registered trademark of Unify Corporation.
  455. X *
  456. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  457. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  458. X *
  459. X * $Log:    setcook.c,v $
  460. X * Revision 1.2  87/04/29  11:31:20  brandon
  461. X * Added RCS header information
  462. X * 
  463. X */
  464. X
  465. X/*LINTLIBRARY*/
  466. X
  467. X#include "usc.h"
  468. X
  469. X/*
  470. X * Leave curses mode.  Again, an assumption is made -- most UNIFY programs
  471. X * under pre-3.2 UNIFY DO NOT FOLLOW THE ASSUMPTION!!! so don't recompile
  472. X * UNIFY stuff unless you don't mind the program not cleaing up after itself.
  473. X */
  474. X
  475. Xvoid setcook() {
  476. X    if (stdscr != (WINDOW *) 0) {
  477. X        (void) endwin();
  478. X        stdscr = (WINDOW *) 0;
  479. X    }
  480. X}
  481. ________This_Is_The_END________
  482. if test `wc -l < setcook.c` -ne 31; then
  483.     echo 'shar: setcook.c was damaged during transit (should have been 31 bytes)'
  484. fi
  485. fi        ; : end of overwriting check
  486. echo 'x - setraw.c'
  487. if test -f setraw.c; then echo 'shar: not overwriting setraw.c'; else
  488. sed 's/^X//' << '________This_Is_The_END________' > setraw.c
  489. X/*
  490. X * $Header: setraw.c,v 1.2 87/04/29 11:31:22 brandon Exp $
  491. X *
  492. X * ``USC'' -- UNIFY(r) Screens using Curses
  493. X * UNIFY(r) is a registered trademark of Unify Corporation.
  494. X *
  495. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  496. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  497. X *
  498. X * $Log:    setraw.c,v $
  499. X * Revision 1.2  87/04/29  11:31:22  brandon
  500. X * Added RCS header information
  501. X * 
  502. X */
  503. X
  504. X/*LINTLIBRARY*/
  505. X
  506. X#include "usc.h"
  507. X
  508. X/*
  509. X * Set up curses, if necessary.  Called by all USC I/O routines.  This routine
  510. X * is based on an assumption of how setraw() is used.
  511. X */
  512. X
  513. Xvoid setraw() {
  514. X    if (stdscr == (WINDOW *) 0) {
  515. X        (void) initscr();
  516. X        (void) noecho();
  517. X        (void) cbreak();
  518. X        (void) nonl();
  519. X    }
  520. X}
  521. ________This_Is_The_END________
  522. if test `wc -l < setraw.c` -ne 32; then
  523.     echo 'shar: setraw.c was damaged during transit (should have been 32 bytes)'
  524. fi
  525. fi        ; : end of overwriting check
  526. echo 'x - setxrc.c'
  527. if test -f setxrc.c; then echo 'shar: not overwriting setxrc.c'; else
  528. sed 's/^X//' << '________This_Is_The_END________' > setxrc.c
  529. X/*
  530. X * $Header: setxrc.c,v 1.2 87/04/29 11:31:23 brandon Exp $
  531. X *
  532. X * ``USC'' -- UNIFY(r) Screens using Curses
  533. X * UNIFY(r) is a registered trademark of Unify Corporation.
  534. X *
  535. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  536. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  537. X *
  538. X * $Log:    setxrc.c,v $
  539. X * Revision 1.2  87/04/29  11:31:23  brandon
  540. X * Added RCS header information
  541. X * 
  542. X */
  543. X
  544. X/*LINTLIBRARY*/
  545. X
  546. X#include "usc.h"
  547. X
  548. X/*
  549. X * Set the extended-return-code flag to the specified value.
  550. X */
  551. X
  552. Xint setxrc(f) {
  553. X    int of;
  554. X
  555. X    of = __ext_rcodes;
  556. X    __ext_rcodes = f;
  557. X    return of;
  558. X}
  559. ________This_Is_The_END________
  560. if test `wc -l < setxrc.c` -ne 30; then
  561.     echo 'shar: setxrc.c was damaged during transit (should have been 30 bytes)'
  562. fi
  563. fi        ; : end of overwriting check
  564. echo 'x - sfldesc.c'
  565. if test -f sfldesc.c; then echo 'shar: not overwriting sfldesc.c'; else
  566. sed 's/^X//' << '________This_Is_The_END________' > sfldesc.c
  567. X/*
  568. X * $Header: sfldesc.c,v 1.2 87/04/29 11:31:25 brandon Exp $
  569. X *
  570. X * ``USC'' -- UNIFY(r) Screens using Curses
  571. X * UNIFY(r) is a registered trademark of Unify Corporation.
  572. X *
  573. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  574. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  575. X *
  576. X * $Log:    sfldesc.c,v $
  577. X * Revision 1.2  87/04/29  11:31:25  brandon
  578. X * Added RCS header information
  579. X * 
  580. X */
  581. X
  582. X/*LINTLIBRARY*/
  583. X
  584. X#include "usc.h"
  585. X
  586. X/*
  587. X * ENTRY POINT:  sfldesc() -- Return screen field description
  588. X *
  589. X * DIFFERENCE FROM UNIFY:  None.  However, see xsfldesc().
  590. X */
  591. X
  592. Xsfldesc(sfld, buf)
  593. XSFLDESC *buf; {
  594. X    if (sfld < 0 || sfld >= __nsf)
  595. X        return 0;
  596. X    buf->sf_fld = __scf[sfld].q_fld;
  597. X    buf->sf_col = __scf[sfld].q_fx;
  598. X    buf->sf_lin = __scf[sfld].q_fy;
  599. X    return 1;
  600. X}
  601. ________This_Is_The_END________
  602. if test `wc -l < sfldesc.c` -ne 34; then
  603.     echo 'shar: sfldesc.c was damaged during transit (should have been 34 bytes)'
  604. fi
  605. fi        ; : end of overwriting check
  606. echo 'x - shellout.c'
  607. if test -f shellout.c; then echo 'shar: not overwriting shellout.c'; else
  608. sed 's/^X//' << '________This_Is_The_END________' > shellout.c
  609. X/*
  610. X * $Header: shellout.c,v 1.4 87/06/17 17:40:53 brandon Exp $
  611. X *
  612. X * ``USC'' -- UNIFY(r) Screens using Curses
  613. X * UNIFY(r) is a registered trademark of Unify Corporation.
  614. X *
  615. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  616. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  617. X *
  618. X * $Log:    shellout.c,v $
  619. X * Revision 1.4  87/06/17  17:40:53  brandon
  620. X * I'm beginning to think that it is impossible to get to the bottom of the
  621. X * screen....
  622. X * 
  623. X * Revision 1.3  87/06/11  16:37:20  brandon
  624. X * Still didn't move to BOS.  Now using term{cap, info} low-level code.
  625. X * 
  626. X * Revision 1.2  87/06/09  11:28:14  brandon
  627. X * Forgot to move to BOS before starting the shell (suspending).  This is done
  628. X * with mvcur(), since otherwise temporary windows (^V) would fail.
  629. X * 
  630. X * Revision 1.1  87/06/01  16:32:06  brandon
  631. X * Initial revision
  632. X * 
  633. X */
  634. X
  635. X/*LINTLIBRARY*/
  636. X
  637. X#include "usc.h"
  638. X#include <signal.h>
  639. X
  640. X/*
  641. X * Internal routine used by inl() and inc() to suspend the program.  Under
  642. X * System V, this does a subshell instead.
  643. X */
  644. X
  645. Xstatic void _putc(ch)
  646. Xchar ch; {
  647. X    (void) write(1, &ch, 1);
  648. X}
  649. X
  650. X#ifndef TERMCAP
  651. X#include <term.h>
  652. X#define CM        cursor_address
  653. X#endif
  654. X
  655. Xstatic void bos() {
  656. X/* this does a move without changing curses... multiple windows would fail. */
  657. X    (void) tputs(tgoto(CM, 1, LINES - 1), 0, _putc);
  658. X}
  659. X
  660. X#ifdef SIGTSTP
  661. X
  662. Xvoid _inlsusp() {
  663. X    (void) nocbreak();
  664. X    (void) nonl();
  665. X    (void) echo();    /* this is a macro in the BSD curses, hurrah! */
  666. X    bos();
  667. X    (void) kill(getpid(), SIGSTOP);
  668. X    (void) cbreak();
  669. X    (void) nl();
  670. X    (void) noecho();
  671. X    (void) move(y, x);
  672. X    (void) clearok(curscr);
  673. X    (void) wrefresh(curscr);
  674. X}
  675. X
  676. X#else
  677. X
  678. Xvoid _inlsusp() {
  679. X    char *sh;
  680. X    int (*oint)(), (*oquit)();
  681. X    int pid, status;
  682. X
  683. X    if ((sh = getenv("SHELL")) == (char *) 0)
  684. X        sh = "/bin/sh";
  685. X    oint = signal(SIGINT, SIG_IGN);
  686. X    oquit = signal(SIGQUIT, SIG_IGN);
  687. X    bos();
  688. X    (void) nocbreak();
  689. X    (void) nl();
  690. X    (void) system("stty echo");    /* ECCH!  echo() conflicts with Unify!!! */
  691. X    /* presumably, I don't need vfork() because of the above */
  692. X    switch (pid = fork()) {
  693. X    case -1:
  694. X        status = -1;
  695. X        break;
  696. X    case 0:
  697. X        (void) signal(SIGINT, SIG_DFL);
  698. X        (void) signal(SIGQUIT, SIG_DFL);
  699. X        (void) execlp(sh, sh, "-i", (char *) 0);
  700. X        _exit(-1);
  701. X    default:
  702. X        while (wait(&status) != pid)
  703. X            ;
  704. X        break;
  705. X    }
  706. X    (void) noecho();
  707. X    (void) nonl();
  708. X    (void) cbreak();
  709. X    (void) signal(SIGINT, oint);
  710. X    (void) signal(SIGQUIT, oquit);
  711. X    (void) clearok(curscr);
  712. X    (void) wrefresh(curscr);
  713. X    if (status == -1)
  714. X        prtmsg(1, 23, "Shell returned -1");
  715. X}
  716. X
  717. X#endif
  718. ________This_Is_The_END________
  719. if test `wc -l < shellout.c` -ne 109; then
  720.     echo 'shar: shellout.c was damaged during transit (should have been 109 bytes)'
  721. fi
  722. fi        ; : end of overwriting check
  723. echo 'x - tester.c'
  724. if test -f tester.c; then echo 'shar: not overwriting tester.c'; else
  725. sed 's/^X//' << '________This_Is_The_END________' > tester.c
  726. X#include <curses.h>
  727. X#include <signal.h>
  728. X
  729. Xbye() {
  730. X    setcook();
  731. X    abort();
  732. X    abort();
  733. X}
  734. X
  735. Xmain() {
  736. X    signal(SIGQUIT, bye);
  737. X    putenv("DBPATH=/proj/e_u");
  738. X    setxrc(4);
  739. X    addrec(4, "TEST#001");
  740. X    gdata(0, 5, 11);
  741. X    delete(4);
  742. X    setcook();
  743. X    exit(0);
  744. X}
  745. X
  746. Xerror(s,ier){setcook();printf("%s(%d)\n",s,ier);abort();abort();}
  747. ________This_Is_The_END________
  748. if test `wc -l < tester.c` -ne 21; then
  749.     echo 'shar: tester.c was damaged during transit (should have been 21 bytes)'
  750. fi
  751. fi        ; : end of overwriting check
  752. echo 'x - uamt.c'
  753. if test -f uamt.c; then echo 'shar: not overwriting uamt.c'; else
  754. sed 's/^X//' << '________This_Is_The_END________' > uamt.c
  755. X/*
  756. X * $Header: uamt.c,v 1.5 87/06/09 11:52:25 brandon Exp $
  757. X *
  758. X * ``USC'' -- UNIFY(r) Screens using Curses
  759. X * UNIFY(r) is a registered trademark of Unify Corporation.
  760. X *
  761. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  762. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  763. X *
  764. X * $Log:    uamt.c,v $
  765. X * Revision 1.5  87/06/09  11:52:25  brandon
  766. X * Right-justified buffer display; repositioned cursor after conversion errors.
  767. X * 
  768. X * Revision 1.4  87/06/01  08:37:14  brandon
  769. X * Added ^V (view) capability for related records.
  770. X * 
  771. X * Revision 1.3  87/05/27  14:42:07  brandon
  772. X * Made sure buffer was padded with spaces.
  773. X * 
  774. X * Revision 1.2  87/05/26  15:43:58  brandon
  775. X * Forgot to cast sprintf().
  776. X * 
  777. X * Revision 1.1  87/05/26  13:32:55  brandon
  778. X * Initial revision
  779. X * 
  780. X * Revision 1.3  87/05/12  12:04:06  brandon
  781. X * Changed to pass FWD, BACK, GO without checking the data buffer
  782. X * 
  783. X * Revision 1.2  87/04/29  11:30:31  brandon
  784. X * Added RCS header information
  785. X * 
  786. X */
  787. X
  788. X/*LINTLIBRARY*/
  789. X
  790. X#include "usc.h"
  791. X
  792. X/*
  793. X * Input a small amount, into a (long).
  794. X */
  795. X
  796. Xint uamt(len, buf)
  797. Xlong *buf; {
  798. X    char ibuf[11];
  799. X    int rc, cnt, sign, dec, y, x;
  800. X
  801. X    setraw();
  802. X    if (len > 10)
  803. X        len = 10;
  804. X    (void) sprintf(ibuf, "%*.2f", len + 3, (double) *buf / 100.0);
  805. X    getyx(stdscr, y, x);
  806. X    for (;;) {
  807. X        (void) move(y, x);
  808. X        if ((rc = inl(ibuf, len, 0)) == BACK || rc == FWD || rc == GO || rc == LOOK)
  809. X            return rc;
  810. X        for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
  811. X            ;
  812. X        if (cnt == len) {
  813. X            prtmsg(1, 23, "Invalid amount");
  814. X            continue;
  815. X        }
  816. X        *buf = 0L;
  817. X        sign = 0;
  818. X        dec = 0;
  819. X        if (ibuf[cnt] == '-') {
  820. X            sign = 1;
  821. X            if (++cnt == len) {
  822. X                prtmsg(1, 23, "Invalid amount");
  823. X                continue;
  824. X            }
  825. X        }
  826. X        for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
  827. X            *buf *= 10;
  828. X            *buf += ibuf[cnt] - '0';
  829. X        }
  830. X        if (ibuf[cnt] == '.') {
  831. X            if (cnt > len - 2) {
  832. X                prtmsg(1, 23, "Invalid amount");
  833. X                continue;
  834. X            }
  835. X            if (!isdigit(ibuf[++cnt])) {
  836. X                prtmsg(1, 23, "Invalid amount");
  837. X                continue;
  838. X            }
  839. X            dec = (ibuf[cnt] - '0') * 10;
  840. X            if (!isdigit(ibuf[++cnt])) {
  841. X                prtmsg(1, 23, "Invalid amount");
  842. X                continue;
  843. X            }
  844. X            dec += ibuf[cnt] - '0';
  845. X        }
  846. X        for (; cnt < len && ibuf[cnt] == ' '; cnt++)
  847. X            ;
  848. X        if (cnt == len)
  849. X             break;
  850. X        prtmsg(1, 23, "Invalid amount");
  851. X    }
  852. X    *buf = *buf * 100 + dec;
  853. X    if (sign)
  854. X        *buf = - *buf;
  855. X    return rc;
  856. X}
  857. ________This_Is_The_END________
  858. if test `wc -l < uamt.c` -ne 102; then
  859.     echo 'shar: uamt.c was damaged during transit (should have been 102 bytes)'
  860. fi
  861. fi        ; : end of overwriting check
  862. echo 'x - udate.c'
  863. if test -f udate.c; then echo 'shar: not overwriting udate.c'; else
  864. sed 's/^X//' << '________This_Is_The_END________' > udate.c
  865. X/*
  866. X * $Header: udate.c,v 1.11 87/06/02 12:51:52 brandon Exp $
  867. X *
  868. X * ``USC'' -- UNIFY(r) Screens using Curses
  869. X * UNIFY(r) is a registered trademark of Unify Corporation.
  870. X *
  871. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  872. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  873. X *
  874. X * $Log:    udate.c,v $
  875. X * Revision 1.11  87/06/02  12:51:52  brandon
  876. X * Linted.
  877. X * 
  878. X * Revision 1.10  87/06/01  16:29:20  brandon
  879. X * Moved today() and thisyear() to datefns.c with new names.
  880. X * 
  881. X * Revision 1.9  87/06/01  09:39:27  brandon
  882. X * Missing move() before pdate() calls.
  883. X * 
  884. X * Revision 1.8  87/06/01  09:25:26  brandon
  885. X * AARGH! ! !  Output func is pdate(), not odate()!
  886. X * 
  887. X * Revision 1.7  87/06/01  09:23:01  brandon
  888. X * Forced redisplay of entered date, so `/' (today) shows up properly.
  889. X * 
  890. X * Revision 1.6  87/06/01  08:37:30  brandon
  891. X * Added ^V (view) capability for related records.
  892. X * 
  893. X * Revision 1.5  87/05/27  15:51:59  brandon
  894. X * Wasn't handling canonical form of NULLDATE.
  895. X * 
  896. X * Revision 1.4  87/05/27  14:42:24  brandon
  897. X * Made sure buffer was padded with spaces.
  898. X * 
  899. X * Revision 1.3  87/05/26  15:44:12  brandon
  900. X * Forgot to cast sprintf().
  901. X * 
  902. X * Revision 1.2  87/05/26  14:08:02  brandon
  903. X * udate() conflicted with UN*X call; changed to upddate().
  904. X * 
  905. X * Revision 1.1  87/05/26  13:33:23  brandon
  906. X * Initial revision
  907. X * 
  908. X * (Log: idate.c,v)
  909. X * Revision 1.8  87/05/12  15:39:26  brandon
  910. X * added call to _sdbrt() to insure correct date types
  911. X * 
  912. X * Revision 1.7  87/05/12  13:24:21  brandon
  913. X * Dumb bugs in parsing /.
  914. X * 
  915. X * Revision 1.6  87/05/11  16:38:35  brandon
  916. X * more checking and another bugfix; it was typechecking on no-data returns
  917. X * 
  918. X * Revision 1.5  87/05/11  16:30:07  brandon
  919. X * more checking added (also friendlier error messages)
  920. X * 
  921. X * Revision 1.4  87/05/11  16:22:40  brandon
  922. X * removed debugging and fixed bug!
  923. X * 
  924. X * Revision 1.3  87/05/11  16:13:54  brandon
  925. X * bugchk
  926. X * 
  927. X * Revision 1.2  87/04/29  11:30:33  brandon
  928. X * Added RCS header information
  929. X * 
  930. X */
  931. X
  932. X/*LINTLIBRARY*/
  933. X
  934. X#include "usc.h"
  935. X#include <ctype.h>
  936. X
  937. X/*
  938. X * Input a date.  This is effectively a (short), but outside may have one of
  939. X * the following values:
  940. X *
  941. X *         n/n[/n]        **.**.**    *    /
  942. X *
  943. X * At any time, . or - may be used in place of /.  * is short for **.**.**;
  944. X * / is short for today's date.  (Note:  I used . in place of / in the null
  945. X * dates, the reason I leave as an exercise for the reader.)
  946. X *
  947. X * This routine is ugly, but it does it all.
  948. X */
  949. X
  950. Xint upddate(buf)
  951. Xshort *buf; {
  952. X    int odate[3], date[3];
  953. X    int cnt, rc, DS1, DS2, DS3, x, y;
  954. X    char ibuf[9];
  955. X
  956. X    setraw();
  957. X    _sdbrt();
  958. X    switch (_ldbrt & MASK_DATES) {
  959. X    case YMD:
  960. X        DS1 = YEAR;
  961. X        DS2 = MONTH;
  962. X        DS3 = DAY;
  963. X        break;
  964. X    case DMY:
  965. X        DS1 = DAY;
  966. X        DS2 = MONTH;
  967. X        DS3 = YEAR;
  968. X        break;
  969. X    case MDY:
  970. X        DS1 = MONTH;
  971. X        DS2 = DAY;
  972. X        DS3 = YEAR;
  973. X        break;
  974. X    default:
  975. X        xerror(-1, "udate", "Unrecognized internal date code %d", _ldbrt & MASK_DATES);
  976. X    }
  977. X    if (*buf == NULLDATE)
  978. X        (void) strcpy(ibuf, "**/**/**");
  979. X    else {
  980. X        kdate(*buf, date);
  981. X        (void) sprintf(ibuf, "%02d/%02d/%02d", date[DS1], date[DS2], date[DS3]);
  982. X    }
  983. X    getyx(stdscr, y, x);
  984. X    for (;;) {
  985. X        (void) move(y, x);
  986. X        if ((rc = inl(ibuf, 8, 0)) == BACK || rc == FWD || rc == GO || rc == LOOK)
  987. X            return rc;
  988. X        for (cnt = 0; cnt < 8; cnt++)
  989. X            if (ibuf[cnt] == '.' || ibuf[cnt] == '-')
  990. X                ibuf[cnt] = '/';
  991. X        for (cnt = 0; cnt < 8 && ibuf[cnt] == ' '; cnt++)
  992. X            ;
  993. X        if (cnt == 8) {
  994. X            prtmsg(1, 23, "Invalid empty date");
  995. X            continue;
  996. X        }
  997. X        if (ibuf[cnt] == '/') {
  998. X            for (cnt++; cnt < 8 && ibuf[cnt] == ' '; cnt++)
  999. X                ;
  1000. X            if (cnt < 8) {
  1001. X                prtmsg(1, 23, "Invalid date format");
  1002. X                continue;
  1003. X            }
  1004. X            *buf = _dt_today();
  1005. X            (void) move(y, x);
  1006. X            pdate(buf);
  1007. X            return rc;
  1008. X        }
  1009. X        if (ibuf[cnt] == '*') {
  1010. X            if (strncmp(ibuf, "**/**/**", 8) == 0) {
  1011. X                *buf = NULLDATE;
  1012. X                (void) move(y, x);
  1013. X                pdate(buf);
  1014. X                return rc;
  1015. X            }
  1016. X            for (cnt++; cnt < 8 && ibuf[cnt] == ' '; cnt++)
  1017. X                ;
  1018. X            if (cnt < 8) {
  1019. X                prtmsg(1, 23, "Invalid null date format");
  1020. X                continue;
  1021. X            }
  1022. X            *buf = NULLDATE;
  1023. X            (void) move(y, x);
  1024. X            pdate(buf);
  1025. X            return rc;
  1026. X        }
  1027. X        if (!isdigit(ibuf[cnt])) {
  1028. X            prtmsg(1, 23, "Invalid date -- bad digit");
  1029. X            continue;
  1030. X        }
  1031. X        date[MONTH] = 0;
  1032. X        date[DAY] = 0;
  1033. X        date[YEAR] = 0;
  1034. X        while (cnt < 8 && isdigit(ibuf[cnt])) {
  1035. X            date[DS1] *= 10;
  1036. X            date[DS1] += ibuf[cnt++] - '0';
  1037. X        }
  1038. X        if (cnt == 8 || ibuf[cnt++] != '/') {
  1039. X            prtmsg(1, 23, "Invalid date -- invalid 1pt");
  1040. X            continue;
  1041. X        }
  1042. X        while (cnt < 8 && isdigit(ibuf[cnt])) {
  1043. X            date[DS2] *= 10;
  1044. X            date[DS2] += ibuf[cnt++] - '0';
  1045. X        }
  1046. X        if (cnt < 8 && ibuf[cnt] == ' ') {
  1047. X            for (; cnt < 8 && ibuf[cnt] == ' '; cnt++)
  1048. X                ;
  1049. X            if (cnt < 8) {
  1050. X                prtmsg(1, 23, "Invalid date -- trailing garbage");
  1051. X                continue;
  1052. X            }
  1053. X            if (_ldbrt & YMD) {
  1054. X                date[DAY] = date[MONTH];
  1055. X                date[MONTH] = date[YEAR];
  1056. X            }
  1057. X            date[YEAR] = _dt_year();
  1058. X        }
  1059. X        else if (cnt == 8)
  1060. X            date[YEAR] = _dt_year();
  1061. X        else if (ibuf[cnt++] != '/') {
  1062. X            prtmsg(1, 23, "Invalid date -- invalid 2pt");
  1063. X            continue;
  1064. X        }
  1065. X        else {
  1066. X            while (cnt < 8 && isdigit(ibuf[cnt])) {
  1067. X                date[DS3] *= 10;
  1068. X                date[DS3] += ibuf[cnt++] - '0';
  1069. X            }
  1070. X            if (cnt < 8) {
  1071. X                for (; cnt < 8 && ibuf[cnt] == ' '; cnt++)
  1072. X                    ;
  1073. X                if (cnt < 8) {
  1074. X                    prtmsg(1, 23, "Invalid date -- trailing garbage in 3pt");
  1075. X                    continue;
  1076. X                }
  1077. X            }
  1078. X        }
  1079. X        *buf = kday(date);
  1080. X        kdate(*buf, odate);
  1081. X        if (ivcmp((char *) date, (char *) odate, sizeof date))
  1082. X            break;
  1083. X        prtmsg(1, 23, "Invalid date -- insane elements");
  1084. X    }
  1085. X    (void) move(y, x);
  1086. X    pdate(buf);
  1087. X    return rc;
  1088. X}
  1089. ________This_Is_The_END________
  1090. if test `wc -l < udate.c` -ne 224; then
  1091.     echo 'shar: udate.c was damaged during transit (should have been 224 bytes)'
  1092. fi
  1093. fi        ; : end of overwriting check
  1094. echo 'x - uerror.c'
  1095. if test -f uerror.c; then echo 'shar: not overwriting uerror.c'; else
  1096. sed 's/^X//' << '________This_Is_The_END________' > uerror.c
  1097. X/*
  1098. X * $Header: uerror.c,v 1.1 87/04/29 14:57:46 brandon Exp $
  1099. X *
  1100. X * ``USC'' -- UNIFY(r) Screens using Curses
  1101. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1102. X *
  1103. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1104. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1105. X *
  1106. X * $Log:    uerror.c,v $
  1107. X * Revision 1.1  87/04/29  14:57:46  brandon
  1108. X * Initial revision
  1109. X * 
  1110. X */
  1111. X
  1112. X/*LINTLIBRARY*/
  1113. X
  1114. X#include "usc.h"
  1115. X
  1116. X/*
  1117. X * ENTRY POINT:  uerror() -- Print a user error message and exit
  1118. X *
  1119. X * DIFFERENCE FROM UNIFY:  *Always* uses the error log, even in pre-3.2
  1120. X * versions.  Also, my idea of what an error should log seems to differ from
  1121. X * that of Unify Corp.
  1122. X */
  1123. X
  1124. Xvoid uerror(s, ier)
  1125. Xchar *s; {
  1126. X    (void) strcpy(errcall, "uerror");
  1127. X    xerror(ier, "User error -- see Notes", "%s", s);
  1128. X}
  1129. ________This_Is_The_END________
  1130. if test `wc -l < uerror.c` -ne 32; then
  1131.     echo 'shar: uerror.c was damaged during transit (should have been 32 bytes)'
  1132. fi
  1133. fi        ; : end of overwriting check
  1134. echo 'x - uflt.c'
  1135. if test -f uflt.c; then echo 'shar: not overwriting uflt.c'; else
  1136. sed 's/^X//' << '________This_Is_The_END________' > uflt.c
  1137. X/*
  1138. X * $Header: uflt.c,v 1.5 87/06/09 11:53:03 brandon Exp $
  1139. X *
  1140. X * ``USC'' -- UNIFY(r) Screens using Curses
  1141. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1142. X *
  1143. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1144. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1145. X *
  1146. X * $Log:    uflt.c,v $
  1147. X * Revision 1.5  87/06/09  11:53:03  brandon
  1148. X * Right-justified buffer display; repositioned cursor after conversion errors.
  1149. X * 
  1150. X * Revision 1.4  87/06/01  08:37:36  brandon
  1151. X * Added ^V (view) capability for related records.
  1152. X * 
  1153. X * Revision 1.3  87/05/27  14:42:30  brandon
  1154. X * Made sure buffer was padded with spaces.
  1155. X * 
  1156. X * Revision 1.2  87/05/26  15:44:16  brandon
  1157. X * Forgot to cast sprintf().
  1158. X * 
  1159. X * Revision 1.1  87/05/26  13:33:48  brandon
  1160. X * Initial revision
  1161. X * 
  1162. X * Revision 1.3  87/05/12  12:04:13  brandon
  1163. X * Changed to pass FWD, BACK, GO without checking the data buffer
  1164. X * 
  1165. X * Revision 1.2  87/04/29  11:30:35  brandon
  1166. X * Added RCS header information
  1167. X * 
  1168. X */
  1169. X
  1170. X/*LINTLIBRARY*/
  1171. X
  1172. X#include "usc.h"
  1173. X
  1174. X/*
  1175. X * Input a float.  This time, they're dumb; take what we're given, no matter
  1176. X * how any decimals -- UNITRIEVE can figure it out for itself, since it won't
  1177. X * let me!  (This is UNIFY's own behavior, in fact.)
  1178. X */
  1179. X
  1180. Xint uflt(len, buf)
  1181. Xregister double *buf; {
  1182. X    char ibuf[18];
  1183. X    int rc, cnt, sign, y, x;
  1184. X    double dec;
  1185. X
  1186. X    setraw();
  1187. X    if (len > 17)
  1188. X        len = 17;
  1189. X    (void) sprintf(ibuf, "%*g", len, *buf);
  1190. X    getyx(stdscr, y, x);
  1191. X    for (;;) {
  1192. X        (void) move(y, x);
  1193. X        if ((rc = inl(ibuf, len, 0)) == BACK || rc == FWD || rc == GO || rc == LOOK)
  1194. X            return rc;
  1195. X        for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
  1196. X            ;
  1197. X        if (cnt == len) {
  1198. X            prtmsg(1, 23, "Invalid float");
  1199. X            continue;
  1200. X        }
  1201. X        *buf = 0.0;
  1202. X        sign = 0;
  1203. X        dec = 0;
  1204. X        if (ibuf[cnt] == '-') {
  1205. X            sign = 1;
  1206. X            if (++cnt == len) {
  1207. X                prtmsg(1, 23, "Invalid float");
  1208. X                continue;
  1209. X            }
  1210. X        }
  1211. X        for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
  1212. X            *buf *= 10.0;
  1213. X            *buf += ibuf[cnt] - '0';
  1214. X        }
  1215. X        if (ibuf[cnt] == '.') {
  1216. X            dec = 10.0;
  1217. X            for (cnt++; cnt < len && isdigit(ibuf[cnt]); cnt++) {
  1218. X                *buf += (ibuf[cnt] - '0') / dec;
  1219. X                dec *= 10.0;
  1220. X            }
  1221. X        }
  1222. X        for (; cnt < len && ibuf[cnt] == ' '; cnt++)
  1223. X            ;
  1224. X        if (cnt == len)
  1225. X             break;
  1226. X        prtmsg(1, 23, "Invalid float");
  1227. X    }
  1228. X    if (sign)
  1229. X        *buf = - *buf;
  1230. X    return rc;
  1231. X}
  1232. ________This_Is_The_END________
  1233. if test `wc -l < uflt.c` -ne 95; then
  1234.     echo 'shar: uflt.c was damaged during transit (should have been 95 bytes)'
  1235. fi
  1236. fi        ; : end of overwriting check
  1237. echo 'x - uhamt.c'
  1238. if test -f uhamt.c; then echo 'shar: not overwriting uhamt.c'; else
  1239. sed 's/^X//' << '________This_Is_The_END________' > uhamt.c
  1240. X/*
  1241. X * $Header: uhamt.c,v 1.5 87/06/09 11:53:05 brandon Exp $
  1242. X *
  1243. X * ``USC'' -- UNIFY(r) Screens using Curses
  1244. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1245. X *
  1246. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1247. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1248. X *
  1249. X * $Log:    uhamt.c,v $
  1250. X * Revision 1.5  87/06/09  11:53:05  brandon
  1251. X * Right-justified buffer display; repositioned cursor after conversion errors.
  1252. X * 
  1253. X * Revision 1.4  87/06/01  08:37:39  brandon
  1254. X * Added ^V (view) capability for related records.
  1255. X * 
  1256. X * Revision 1.3  87/05/27  14:42:45  brandon
  1257. X * Made sure buffer was padded with spaces.
  1258. X * 
  1259. X * Revision 1.2  87/05/26  15:44:18  brandon
  1260. X * Forgot to cast sprintf().
  1261. X * 
  1262. X * Revision 1.1  87/05/26  13:33:59  brandon
  1263. X * Initial revision
  1264. X * 
  1265. X * Revision 1.3  87/05/12  12:04:08  brandon
  1266. X * Changed to pass FWD, BACK, GO without checking the data buffer
  1267. X * 
  1268. X * Revision 1.2  87/04/29  11:30:37  brandon
  1269. X * Added RCS header information
  1270. X * 
  1271. X */
  1272. X
  1273. X/*LINTLIBRARY*/
  1274. X
  1275. X#include "usc.h"
  1276. X
  1277. X/*
  1278. X * Input a huge amount, into a (double).
  1279. X */
  1280. X
  1281. Xint uhamt(len, buf)
  1282. Xregister double *buf; {
  1283. X    char ibuf[15];
  1284. X    int rc, cnt, sign, dec, y, x;
  1285. X
  1286. X    setraw();
  1287. X    if (len > 14)
  1288. X        len = 14;
  1289. X    (void) sprintf(ibuf, "%*.2f", len + 3, *buf / 100.0);
  1290. X    getyx(stdscr, y, x);
  1291. X    for (;;) {
  1292. X        (void) move(y, x);
  1293. X        if ((rc = inl(ibuf, len, 0)) == BACK || rc == FWD || rc == GO || rc == LOOK)
  1294. X            return rc;
  1295. X        for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
  1296. X            ;
  1297. X        if (cnt == len) {
  1298. X            prtmsg(1, 23, "Invalid amount");
  1299. X            continue;
  1300. X        }
  1301. X        *buf = 0.0;
  1302. X        sign = 0;
  1303. X        dec = 0;
  1304. X        if (ibuf[cnt] == '-') {
  1305. X            sign = 1;
  1306. X            if (++cnt == len) {
  1307. X                prtmsg(1, 23, "Invalid amount");
  1308. X                continue;
  1309. X            }
  1310. X        }
  1311. X        for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
  1312. X            *buf *= 10.0;
  1313. X            *buf += ibuf[cnt] - '0';
  1314. X        }
  1315. X        if (ibuf[cnt] == '.') {
  1316. X            if (cnt > len - 2) {
  1317. X                prtmsg(1, 23, "Invalid amount");
  1318. X                continue;
  1319. X            }
  1320. X            if (!isdigit(ibuf[++cnt])) {
  1321. X                prtmsg(1, 23, "Invalid amount");
  1322. X                continue;
  1323. X            }
  1324. X            dec = (ibuf[cnt] - '0') * 10;
  1325. X            if (!isdigit(ibuf[++cnt])) {
  1326. X                prtmsg(1, 23, "Invalid amount");
  1327. X                continue;
  1328. X            }
  1329. X            dec += ibuf[cnt] - '0';
  1330. X        }
  1331. X        for (; cnt < len && ibuf[cnt] == ' '; cnt++)
  1332. X            ;
  1333. X        if (cnt == len)
  1334. X             break;
  1335. X        prtmsg(1, 23, "Invalid amount");
  1336. X    }
  1337. X    *buf = *buf * 100.0 + dec;
  1338. X    if (sign)
  1339. X        *buf = - *buf;
  1340. X    return rc;
  1341. X}
  1342. ________This_Is_The_END________
  1343. if test `wc -l < uhamt.c` -ne 102; then
  1344.     echo 'shar: uhamt.c was damaged during transit (should have been 102 bytes)'
  1345. fi
  1346. fi        ; : end of overwriting check
  1347. echo 'x - ulong.c'
  1348. if test -f ulong.c; then echo 'shar: not overwriting ulong.c'; else
  1349. sed 's/^X//' << '________This_Is_The_END________' > ulong.c
  1350. X/*
  1351. X * $Header: ulong.c,v 1.5 87/06/09 11:53:15 brandon Exp $
  1352. X *
  1353. X * ``USC'' -- UNIFY(r) Screens using Curses
  1354. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1355. X *
  1356. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1357. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1358. X *
  1359. X * $Log:    ulong.c,v $
  1360. X * Revision 1.5  87/06/09  11:53:15  brandon
  1361. X * Right-justified buffer display; repositioned cursor after conversion errors.
  1362. X * 
  1363. X * Revision 1.4  87/06/01  08:37:43  brandon
  1364. X * Added ^V (view) capability for related records.
  1365. X * 
  1366. X * Revision 1.3  87/05/27  14:42:56  brandon
  1367. X * Made sure buffer was padded with spaces.
  1368. X * 
  1369. X * Revision 1.2  87/05/26  15:44:20  brandon
  1370. X * Forgot to cast sprintf().
  1371. X * 
  1372. X * Revision 1.1  87/05/26  13:34:07  brandon
  1373. X * Initial revision
  1374. X * 
  1375. X * Revision 1.3  87/05/12  12:04:03  brandon
  1376. X * Changed to pass FWD, BACK, GO without checking the data buffer
  1377. X * 
  1378. X * Revision 1.2  87/04/29  11:30:39  brandon
  1379. X * Added RCS header information
  1380. X * 
  1381. X */
  1382. X
  1383. X/*LINTLIBRARY*/
  1384. X
  1385. X#include "usc.h"
  1386. X
  1387. X/*
  1388. X * Input an item of type (long).
  1389. X */
  1390. X
  1391. Xint ulong(len, buf)
  1392. Xlong *buf; {
  1393. X    char ibuf[10];
  1394. X    int rc, cnt, sign, y, x;
  1395. X
  1396. X    setraw();
  1397. X    if (len > 9)
  1398. X        len = 9;    /* (long)'s are max len = 9 */
  1399. X    (void) sprintf(ibuf, "%*ld", len, *buf);
  1400. X    getyx(stdscr, y, x);
  1401. X    for (;;) {
  1402. X        (void) move(y, x);
  1403. X        if ((rc = inl(ibuf, len, 0)) == BACK || rc == FWD || rc == GO || rc == LOOK)
  1404. X            return rc;
  1405. X        for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
  1406. X            ;
  1407. X        if (cnt == len) {
  1408. X            prtmsg(1, 23, "Invalid number");
  1409. X            continue;
  1410. X        }
  1411. X        *buf = 0L;
  1412. X        sign = 0;
  1413. X        if (ibuf[cnt] == '-') {
  1414. X            sign = 1;
  1415. X            if (++cnt == len) {
  1416. X                prtmsg(1, 23, "Invalid number");
  1417. X                continue;
  1418. X            }
  1419. X        }
  1420. X        for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
  1421. X            *buf *= 10;
  1422. X            *buf += ibuf[cnt] - '0';
  1423. X        }
  1424. X        for (; cnt < len && ibuf[cnt] == ' '; cnt++)
  1425. X            ;
  1426. X        if (cnt == len)
  1427. X             break;
  1428. X        prtmsg(1, 23, "Invalid number");
  1429. X    }
  1430. X    if (sign)
  1431. X        *buf = - *buf;
  1432. X    return rc;
  1433. X}
  1434. ________This_Is_The_END________
  1435. if test `wc -l < ulong.c` -ne 84; then
  1436.     echo 'shar: ulong.c was damaged during transit (should have been 84 bytes)'
  1437. fi
  1438. fi        ; : end of overwriting check
  1439. echo 'x - upbuf.c'
  1440. if test -f upbuf.c; then echo 'shar: not overwriting upbuf.c'; else
  1441. sed 's/^X//' << '________This_Is_The_END________' > upbuf.c
  1442. X/*
  1443. X * $Header: upbuf.c,v 1.1 87/05/26 13:49:35 brandon Exp $
  1444. X *
  1445. X * ``USC'' -- UNIFY(r) Screens using Curses
  1446. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1447. X *
  1448. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1449. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1450. X *
  1451. X * $Log:    upbuf.c,v $
  1452. X * Revision 1.1  87/05/26  13:49:35  brandon
  1453. X * Initial revision
  1454. X * 
  1455. X * Revision 1.5  87/04/29  14:19:12  brandon
  1456. X * FLT display length is sfield length / 10
  1457. X * 
  1458. X * Revision 1.4  87/04/29  13:17:22  brandon
  1459. X * The code to convert internal to display lengths was in gtube(); it belonged
  1460. X * in here, so here it is.
  1461. X * 
  1462. X * Revision 1.3  87/04/29  11:40:50  brandon
  1463. X * Added ability to OR an upshift flag with a screen field type to get auto
  1464. X * upshifting on certain screen fields.  See also gdata.c.
  1465. X * 
  1466. X * Revision 1.2  87/04/29  11:30:40  brandon
  1467. X * Added RCS header information
  1468. X * 
  1469. X */
  1470. X
  1471. X/*LINTLIBRARY*/
  1472. X
  1473. X#include "usc.h"
  1474. X
  1475. X/*
  1476. X * ENTRY POINT:  upbuf() -- Update from a screen field to a buffer
  1477. X *
  1478. X * DIFFERENCE FROM UNIFY:  See upscrf().
  1479. X */
  1480. X
  1481. Xupbuf(sfld, buf)
  1482. Xchar *buf; {
  1483. X    int rc, oucf, len;
  1484. X
  1485. X    setraw();
  1486. X    if (sfld < 0 || sfld > __nsf)
  1487. X        xerror(-1, "upbuf", "Invalid screen field %d", sfld);
  1488. X    oucf = _sh_up;
  1489. X    _sh_up = __scf[sfld].q_type & _UCF;
  1490. X    /* This code was in gtube(), because I screwed up! */
  1491. X    len = __scf[sfld].q_len;
  1492. X    switch (__scf[sfld].q_type) {
  1493. X    case INT:
  1494. X    case LONG:
  1495. X    case STRNG:
  1496. X        break;
  1497. X    case AMT:
  1498. X    case HAMT:
  1499. X        len += 3;
  1500. X        break;
  1501. X    case DATE:
  1502. X        len = 8;
  1503. X        break;
  1504. X    case HR:
  1505. X        len = 5;
  1506. X        break;
  1507. X    case FLT:
  1508. X        len /= 10;
  1509. X        break;
  1510. X    case COMB:
  1511. X        xerror(-2, "upbuf", "COMB field %d illegal", sfld);
  1512. X    }
  1513. X    if (__scf[sfld].q_fld != 0)
  1514. X        rc = uptube(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_fld, buf);
  1515. X    else
  1516. X        rc = upscrf(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_type & ~_UCF, len, buf);
  1517. X    _sh_up = oucf;
  1518. X    return rc;
  1519. X}
  1520. ________This_Is_The_END________
  1521. if test `wc -l < upbuf.c` -ne 78; then
  1522.     echo 'shar: upbuf.c was damaged during transit (should have been 78 bytes)'
  1523. fi
  1524. fi        ; : end of overwriting check
  1525. echo 'x - updata.c'
  1526. if test -f updata.c; then echo 'shar: not overwriting updata.c'; else
  1527. sed 's/^X//' << '________This_Is_The_END________' > updata.c
  1528. X/*
  1529. X * $Header: updata.c,v 1.3 87/05/27 16:02:26 brandon Exp $
  1530. X *
  1531. X * ``USC'' -- UNIFY(r) Screens using Curses
  1532. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1533. X *
  1534. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1535. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1536. X *
  1537. X * $Log:    updata.c,v $
  1538. X * Revision 1.3  87/05/27  16:02:26  brandon
  1539. X * Had a break; on failed exp. rel. that should have been a continue;.
  1540. X * 
  1541. X * Revision 1.2  87/05/26  14:29:07  brandon
  1542. X * Well, utime() was the culprit (be nice if I could read!)-:
  1543. X * 
  1544. X * Revision 1.1  87/05/26  13:49:49  brandon
  1545. X * Initial revision
  1546. X * 
  1547. X * Revision 1.2  87/04/29  11:30:26  brandon
  1548. X * Added RCS header information
  1549. X * 
  1550. X */
  1551. X
  1552. X/*LINTLIBRARY*/
  1553. X
  1554. X#include "usc.h"
  1555. X
  1556. X/*
  1557. X * ENTRY POINT:  updata() -- get a value at a specified location and store it
  1558. X * in the database.
  1559. X *
  1560. X * DIFFERENCE FROM UNIFY:  Update function are not provided in UNIFY(r).
  1561. X */
  1562. X
  1563. Xupdata(fx, fy, field) {
  1564. X    char buf[256];
  1565. X    int rc, ch;
  1566. X
  1567. X    setraw();
  1568. X    if (gfield(field, buf) != 0)
  1569. X        xerror(-1, "updata", "Read access for field %d denied", field);
  1570. X    for (;;) {
  1571. X        rc = uptube(fx, fy, field, buf);
  1572. X        if (rc == BACK || rc == FWD || rc == GO) {
  1573. X            if (rc == FWD)
  1574. X                rc = FWD_OK;
  1575. X            break;
  1576. X        }
  1577. X
  1578. Xrepass:
  1579. X        switch (ch = pfield(field, buf)) {
  1580. X        case -4:
  1581. X            (void) mvprintw(23, 1, "Enter modify password for field: ");
  1582. X            (void) refresh();
  1583. X            (void) nocbreak();
  1584. X            (void) nl();
  1585. X            if (accsfld(field, getpass(""), 'w') == 0)
  1586. X                goto repass;
  1587. X            (void) noecho();
  1588. X            (void) cbreak();
  1589. X            (void) nonl();
  1590. X            prtmsg(1, 23, "Wrong password");
  1591. X            rc = -3;
  1592. X            break;
  1593. X        case -5:
  1594. X            (void) mvprintw(23, 1, "Record is locked -- Retry or Abort? ");
  1595. X            (void) refresh();
  1596. X            ch = tolower(getchar() & 0x7f);
  1597. X            (void) move(23, 1);
  1598. X            (void) clrtoeol();
  1599. X            switch (ch) {
  1600. X            case 'a':
  1601. X                rc = -3;
  1602. X                break;
  1603. X            default:
  1604. X                goto repass;
  1605. X            }
  1606. X            break;
  1607. X        case 0:
  1608. X            break;
  1609. X        case -1:
  1610. X            prtmsg(1, 23, "Record is referenced, you may not change the key");
  1611. X            continue;
  1612. X        case -2:
  1613. X            prtmsg(1, 23, "This field has a unique index, and the value you entered exists");
  1614. X            continue;
  1615. X        case -3:
  1616. X            prtmsg(1, 23, "There is no related record with this key");
  1617. X            continue;
  1618. X        default:
  1619. X            xerror(-2, "updata", "Unknown error %d from pfield", ch);
  1620. X        }
  1621. X        break;
  1622. X    }
  1623. X    return rc;
  1624. X}
  1625. ________This_Is_The_END________
  1626. if test `wc -l < updata.c` -ne 97; then
  1627.     echo 'shar: updata.c was damaged during transit (should have been 97 bytes)'
  1628. fi
  1629. fi        ; : end of overwriting check
  1630. echo 'x - upfield.c'
  1631. if test -f upfield.c; then echo 'shar: not overwriting upfield.c'; else
  1632. sed 's/^X//' << '________This_Is_The_END________' > upfield.c
  1633. X/*
  1634. X * $Header: upfield.c,v 1.1 87/05/26 13:50:09 brandon Exp $
  1635. X *
  1636. X * ``USC'' -- UNIFY(r) Screens using Curses
  1637. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1638. X *
  1639. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1640. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1641. X *
  1642. X * $Log:    upfield.c,v $
  1643. X * Revision 1.1  87/05/26  13:50:09  brandon
  1644. X * Initial revision
  1645. X * 
  1646. X * Revision 1.3  87/04/29  11:44:40  brandon
  1647. X * Added _UCF upshifting.  See also inbuf.c, xsfldesc.c.  (The comment in
  1648. X * inbuf.c is WRONG!)
  1649. X * Also caused error on screen field w/o database field.
  1650. X * 
  1651. X * Revision 1.2  87/04/29  11:30:44  brandon
  1652. X * Added RCS header information
  1653. X * 
  1654. X */
  1655. X
  1656. X/*LINTLIBRARY*/
  1657. X
  1658. X#include "usc.h"
  1659. X
  1660. X/*
  1661. X * ENTRY POINT:  upfield() -- Updata a database field using a screen field.
  1662. X *
  1663. X * DIFFERENCE FROM UNIFY:  UNIFY(r) does not provide update functions.
  1664. X */
  1665. X
  1666. Xupfield(sfld) {
  1667. X    int rc, ousf;
  1668. X
  1669. X    if (sfld < 0 || sfld >= __nsf)
  1670. X        xerror(-1, "upfield", "Invalid screen field %d", sfld);
  1671. X    if (__scf[sfld].q_fld == 0)
  1672. X        xerror(-2, "upfield", "Screen field %d has no associated database field", sfld);
  1673. X    ousf = _sh_up;
  1674. X    _sh_up = __scf[sfld].q_type & _UCF;
  1675. X    rc = updata(__scf[sfld].q_fx, __scf[sfld].q_fy, __scf[sfld].q_fld);
  1676. X    _sh_up = ousf;
  1677. X    return rc;
  1678. X}
  1679. ________This_Is_The_END________
  1680. if test `wc -l < upfield.c` -ne 46; then
  1681.     echo 'shar: upfield.c was damaged during transit (should have been 46 bytes)'
  1682. fi
  1683. fi        ; : end of overwriting check
  1684. echo 'x - upscrf.c'
  1685. if test -f upscrf.c; then echo 'shar: not overwriting upscrf.c'; else
  1686. sed 's/^X//' << '________This_Is_The_END________' > upscrf.c
  1687. X/*
  1688. X * $Header: upscrf.c,v 1.4 87/06/01 10:56:07 brandon Exp $
  1689. X *
  1690. X * ``USC'' -- UNIFY(r) Screens using Curses
  1691. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1692. X *
  1693. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1694. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1695. X *
  1696. X * $Log:    upscrf.c,v $
  1697. X * Revision 1.4  87/06/01  10:56:07  brandon
  1698. X * _sh_up only forced up; left as is if type doesn't have _UCF.
  1699. X * 
  1700. X * Revision 1.3  87/05/26  14:29:33  brandon
  1701. X * Well, utime() was the culprit (be nice if I could read!)-:
  1702. X * 
  1703. X * Revision 1.2  87/05/26  14:08:27  brandon
  1704. X * udate() conflicted with UN*X call; changed to upddate().
  1705. X * 
  1706. X * Revision 1.1  87/05/26  13:50:24  brandon
  1707. X * Initial revision
  1708. X * 
  1709. X * Revision 1.5  87/05/22  15:39:06  brandon
  1710. X * whoops!  It doesn't help to leave off the "break"'s in a switch().
  1711. X * 
  1712. X * Revision 1.4  87/05/12  17:19:19  brandon
  1713. X * Forgot to get rid of _UCF temporarily during type check
  1714. X * 
  1715. X * Revision 1.3  87/05/12  17:00:28  brandon
  1716. X * Enabled _UCF flag for type.
  1717. X * 
  1718. X * Revision 1.2  87/04/29  11:30:46  brandon
  1719. X * Added RCS header information
  1720. X * 
  1721. X */
  1722. X
  1723. X/*LINTLIBRARY*/
  1724. X
  1725. X#include "usc.h"
  1726. X
  1727. X/*
  1728. X * ENTRY POINT: upscrf() -- Take a type and (character) length, and call the
  1729. X * correct input routine for the type for UPDATE.
  1730. X *
  1731. X * DIFFERENCE FROM UNIFY:  In addition to the standard return codes, there are
  1732. X * a number of new ones.  If you want to use them, call setxrc() with a non-
  1733. X * zero argument.  The new codes are:
  1734. X *
  1735. X *        -5    ESC or ^E
  1736. X *        -6    ESC or ^E, returns buffer
  1737. X *        -7    ^U or TAB, returns buffer
  1738. X *
  1739. X * Also, the following line-editing characters are supported:
  1740. X *
  1741. X *        ^H        delete last charater
  1742. X *        ^F        move forward (wraps to beginning)
  1743. X *        ^B        move backward (wraps to end)
  1744. X *        ^A        move to start of field
  1745. X *        ^N        move to end of field
  1746. X *        ^O        insert a space
  1747. X *        ^D        delete a character
  1748. X *        ^K        clear to end of field
  1749. X *        ^X        exit program
  1750. X *        ^R, ^L        redraw screen
  1751. X *        ^P        shell out
  1752. X *
  1753. X * I would have used ^Z for end-of-field, but I see no reason to get the
  1754. X * people with job control or sxt's upset at me...
  1755. X */
  1756. X
  1757. Xint upscrf(x, y, type, len, buf)
  1758. Xchar *buf; {
  1759. X    int rc, oucf;
  1760. X
  1761. X    setraw();
  1762. X    mv_cur(1, x, y);
  1763. X    oucf = _sh_up;
  1764. X    if (type & _UCF)
  1765. X        _sh_up = type & _UCF;
  1766. X    type &= ~_UCF;
  1767. X    switch (type) {
  1768. X    case INT:
  1769. X        rc = ushort(len, (short *) buf);
  1770. X        break;
  1771. X    case LONG:
  1772. X        rc = ulong(len, (long *) buf);
  1773. X        break;
  1774. X    case AMT:
  1775. X        rc = uamt(len, (long *) buf);
  1776. X        break;
  1777. X    case HAMT:
  1778. X        rc = uhamt(len, (double *) buf);
  1779. X        break;
  1780. X    case STRNG:
  1781. X        rc = ustr(len, buf);
  1782. X        break;
  1783. X    case DATE:
  1784. X        rc = upddate((short *) buf);
  1785. X        break;
  1786. X    case HR:
  1787. X        rc = updtime((short *) buf);
  1788. X        break;
  1789. X    case FLT:
  1790. X        rc = uflt(len, (double *) buf);
  1791. X        break;
  1792. X    default:
  1793. X        xerror(-1, "upscrf", "Unknown type %d", type);
  1794. X        /*NOTREACHED*/
  1795. X    }
  1796. X    _sh_up = oucf;
  1797. X    return rc;
  1798. X}
  1799. ________This_Is_The_END________
  1800. if test `wc -l < upscrf.c` -ne 112; then
  1801.     echo 'shar: upscrf.c was damaged during transit (should have been 112 bytes)'
  1802. fi
  1803. fi        ; : end of overwriting check
  1804. echo 'x - uptube.c'
  1805. if test -f uptube.c; then echo 'shar: not overwriting uptube.c'; else
  1806. sed 's/^X//' << '________This_Is_The_END________' > uptube.c
  1807. X/*
  1808. X * $Header: uptube.c,v 1.3 87/06/09 12:22:37 brandon Exp $
  1809. X *
  1810. X * ``USC'' -- UNIFY(r) Screens using Curses
  1811. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1812. X *
  1813. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1814. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1815. X *
  1816. X * $Log:    uptube.c,v $
  1817. X * Revision 1.3  87/06/09  12:22:37  brandon
  1818. X * Moved FYI message to line 23; cleared it after input.
  1819. X * 
  1820. X * Revision 1.2  87/06/01  08:31:13  brandon
  1821. X * Added ^V (view) capability for related records.
  1822. X * 
  1823. X * Revision 1.1  87/05/26  13:50:36  brandon
  1824. X * Initial revision
  1825. X * 
  1826. X * Revision 1.4  87/04/29  16:09:49  brandon
  1827. X * Added a cast to (void) of mvaddstr()
  1828. X * 
  1829. X * Revision 1.3  87/04/29  13:10:36  brandon
  1830. X * fldesc() returns display length, so mucking around with it isn't needed.
  1831. X * However, probably input() or inbuf() will need help...
  1832. X * 
  1833. X * Revision 1.2  87/04/29  11:30:28  brandon
  1834. X * Added RCS header information
  1835. X * 
  1836. X */
  1837. X
  1838. X/*LINTLIBRARY*/
  1839. X
  1840. X#include "usc.h"
  1841. X
  1842. X/*
  1843. X * ENTRY POINT:  uptube() -- Update a buffer using a database field template.
  1844. X *
  1845. X * DIFFERENCE FROM UNIFY:  UNIFY(r) does not support update functions.
  1846. X */
  1847. X
  1848. Xuptube(fx, fy, field, buf)
  1849. Xchar *buf; {
  1850. X    FLDESC fd;
  1851. X    int rc;
  1852. X#ifdef UNIFY32
  1853. X    char *cmsg, *emsg;
  1854. X#endif
  1855. X
  1856. X    setraw();
  1857. X    if (!fldesc(field, &fd))
  1858. X        xerror(-1, "uptube", "Invalid field %d", field);
  1859. X    if (fd.f_typ == COMB)
  1860. X        xerror(-2, "uptube", "COMB field %d illegal", field);
  1861. X#ifdef UNIFY32
  1862. X    cmsg = getdoms(field, FYISTR);
  1863. X    if ((emsg = getdoms(field, ERRSTR)) == (char *) 0)
  1864. X        emsg = "The value you entered is not legal for this field";
  1865. X    for (;;) {
  1866. X        if (cmsg != (char *) 0)
  1867. X            (void) mvaddstr(23, 1, cmsg);
  1868. X#endif
  1869. X        rc = upscrf(fx, fy, fd.f_typ, fd.f_len, buf);
  1870. X#ifdef UNIFY32
  1871. X        (void) move(23, 1);
  1872. X        (void) clrtoeol();
  1873. X#endif
  1874. X        if (rc == BACK || rc == FWD || rc == GO)
  1875. X            return rc;
  1876. X        if (rc == LOOK) {
  1877. X            if (fd.f_rpfld == 0) {
  1878. X                prtmsg(1, 23, "There is no related record to view");
  1879. X                continue;
  1880. X            }
  1881. X            if ((rc = zoom(fx, fy, field, &fd, buf)) == BACK || rc == FWD)
  1882. X                return rc;
  1883. X            outscrf(fx, fy, fd.f_typ, fd.f_len, buf);
  1884. X        }
  1885. X#ifdef UNIFY32
  1886. X        if (domchk(field, buf))
  1887. X            break;
  1888. X        prtmsg(1, 23, emsg);
  1889. X    }
  1890. X#endif
  1891. X    return rc;
  1892. X}
  1893. ________This_Is_The_END________
  1894. if test `wc -l < uptube.c` -ne 86; then
  1895.     echo 'shar: uptube.c was damaged during transit (should have been 86 bytes)'
  1896. fi
  1897. fi        ; : end of overwriting check
  1898. echo 'x - usc.h'
  1899. if test -f usc.h; then echo 'shar: not overwriting usc.h'; else
  1900. sed 's/^X//' << '________This_Is_The_END________' > usc.h
  1901. X/*
  1902. X * $Header: usc.h,v 1.1 87/05/28 14:04:04 brandon Exp $
  1903. X *
  1904. X * ``USC'' -- UNIFY(r) Screens using Curses
  1905. X * UNIFY(r) is a registered trademark of Unify Corporation.
  1906. X *
  1907. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  1908. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  1909. X *
  1910. X * $Log:    usc.h,v $
  1911. X * Revision 1.1  87/05/28  14:04:04  brandon
  1912. X * Initial revision
  1913. X * 
  1914. X */
  1915. X
  1916. X#ifdef lint
  1917. X# define NOMACROS
  1918. X#endif
  1919. X#include <curses.h>
  1920. X#include <dbtypes.h>
  1921. X#include <fdesc.h>
  1922. X#include <ctype.h>
  1923. X#ifdef UNIFY32
  1924. X#include <domains.h>
  1925. X#endif
  1926. X
  1927. X#ifdef TERMCAP
  1928. X
  1929. X/* Old curses.  We have to emulate some of the new features. */
  1930. X
  1931. X#define beep()        write(1, "\7", 1)
  1932. X#define flash()        beep()
  1933. X#define cbreak()    crmode()
  1934. X#define nocbreak()    nocrmode()
  1935. X
  1936. X#endif
  1937. X#if defined(lint) || defined(TERMCAP)
  1938. X
  1939. X#define A_STANDOUT    0x80
  1940. X#define A_REVERSE    0x80
  1941. X#define A_UNDERLINE    0x00
  1942. X#define A_ALTCHARSET    0x00
  1943. X#define A_BLINK        0x00
  1944. X#define A_DIM        0x00
  1945. X#define A_BOLD        0x00
  1946. X#define A_INVIS        0x00
  1947. X#define A_PROTECT    0x00
  1948. X#define A_ATTRIBUTES    A_STANDOUT
  1949. X#define A_CHARTEXT    0x7f
  1950. X
  1951. X#endif
  1952. X
  1953. Xstruct q {
  1954. X    char q_name[8];
  1955. X    char q_dbfld[44];
  1956. X    short q_fld;
  1957. X    short q_type;
  1958. X    short q_len;
  1959. X    short q_fx;
  1960. X    short q_fy;
  1961. X    char q_prmp[40];
  1962. X    short q_px;
  1963. X    short q_py;
  1964. X};
  1965. X
  1966. Xextern struct q *__scf;
  1967. Xextern int __nsf;
  1968. X
  1969. X/*
  1970. X * If a screen field's type has _UCF OR'ed in with it, it will be upshifted
  1971. X * during calls to input() and inbuf().
  1972. X */
  1973. X
  1974. Xextern int _sh_up;        /* set this flag nonzero for upshifting */
  1975. X#define _UCF        0x80    /* the flag value for upshifted sfields */
  1976. X
  1977. X/*
  1978. X * Date and brackets, since the U.S. (as usual) is different from the rest
  1979. X * of the world...
  1980. X */
  1981. X
  1982. X/* brackets */
  1983. X
  1984. X#define MASK_BRACKETS    0x80
  1985. X#define INTERNATIONAL    0x00
  1986. X#define UNITED_STATES    0x80
  1987. X
  1988. X/* dates */
  1989. X
  1990. X#define MASK_DATES    0x03
  1991. X#define YMD        0x00
  1992. X#define DMY        0x01
  1993. X#define MDY        0x02
  1994. X
  1995. Xextern int _ldbrt;
  1996. X
  1997. X/* used internally for date array addressing */
  1998. X
  1999. X#define MONTH        0
  2000. X#define DAY        1
  2001. X#define YEAR        2    /* ...guess what country Unify Corp. is in! */
  2002. X
  2003. X#if defined(lint) && !defined(TERMCAP)
  2004. X
  2005. X/*
  2006. X * Curses defines <struct screen> under USG, but doesn't declare it.  This
  2007. X * makes lint upset.
  2008. X */
  2009. X
  2010. Xstruct screen {
  2011. X    char dummy;
  2012. X};
  2013. X
  2014. X#endif
  2015. X
  2016. X/* return codes for input routines */
  2017. X
  2018. X#define FWD_OK        0    /* RETURN with data */
  2019. X#define BKSP        -1    /* inc() backspace */
  2020. X#define BACK        -2    /* TAB */
  2021. X#define FWD        -3    /* RETURN */
  2022. X#define LOOK        -4    /* ^V `view mode' (aka ACCELL `zoom') */
  2023. X#define GO        -5    /* ESC */
  2024. X#define GO_OK        -6    /* ESC with data */
  2025. X#define BACK_OK        -7    /* TAB with data */
  2026. X#define CFWD        -8    /* inc() forward */
  2027. X#define CBACK        -9    /* inc() backward */
  2028. X
  2029. X#define XRC_GO        1    /* allow GO, GO_OK return codes */
  2030. X#define XRC_XOK        2    /* allow GO_OK, BACK_OK return codes */
  2031. X#define XRC_LOOK    4    /* allow LOOK return code (no LOOK_OK) */
  2032. X#define XRC_CFB        8    /* for incs(): include CFWD, CBACK */
  2033. X#define XRC_BKSP    16    /* for incs(): include BKSP */
  2034. X#define XRC_CHAR    32    /* for incs(): return non-ctl chars */
  2035. X#define XRC_FWDGO    64    /* for incs(): RETURN == GO instead of FWD */
  2036. X#define XRC_NOFLSH    128    /* for incs(): suppress refresh() call */
  2037. X
  2038. Xextern int __ext_rcodes;
  2039. X
  2040. X/* the eternal happiness of strict(-ish) type checking... */
  2041. X
  2042. Xextern char *getpass();
  2043. Xextern char *malloc();
  2044. Xextern long time();
  2045. Xextern char *ctime();
  2046. Xextern void exit();
  2047. Xextern void _exit();
  2048. Xextern void free();
  2049. Xextern char *getenv();
  2050. Xextern char *strcpy();
  2051. Xextern char *strcat();
  2052. Xextern char *strchr();
  2053. Xextern WINDOW *newwin();
  2054. Xextern int sprintf();
  2055. X
  2056. Xextern short kday();
  2057. Xextern void kdate();
  2058. Xextern void cfill();
  2059. X#ifdef UNIFY32
  2060. Xextern char *getdoms();
  2061. Xextern void dspdt();
  2062. X#endif
  2063. X
  2064. Xextern void setraw();
  2065. Xextern void prtmsg();
  2066. Xextern char *dbfile();
  2067. Xextern FILE *_dbfopen();
  2068. Xextern void erasprmp();
  2069. Xextern void outscrf();
  2070. Xextern void output();
  2071. Xextern void pamt();
  2072. Xextern void pdate();
  2073. Xextern void pflt();
  2074. Xextern void phamt();
  2075. Xextern void plong();
  2076. Xextern void pshort();
  2077. Xextern void pstr();
  2078. Xextern void ptime();
  2079. Xextern void mv_cur();
  2080. Xextern void _inlsusp();
  2081. Xextern int inc();
  2082. Xextern int inl();
  2083. Xextern short _dt_today();
  2084. Xextern int _dt_year();
  2085. X#ifdef UNIFY32
  2086. Xextern void _sdbrt();
  2087. X#endif
  2088. X
  2089. X#if defined(lint) && !defined(TERMCAP)
  2090. Xextern WINDOW *initscr();    /* I had always understood this was (int)?? */
  2091. X#endif
  2092. X
  2093. X#ifdef lint
  2094. X#define getyx(win, y, x)    ((y) = 0, (x) = 0)
  2095. X#endif
  2096. X
  2097. X/* Operational modes in logacl */
  2098. X
  2099. X#define INQUIRE        010
  2100. X#define ADD        004
  2101. X#define MODIFY        002
  2102. X#define DELETE        001
  2103. X
  2104. X/* Used by the error functions */
  2105. X
  2106. Xextern char errcall[];
  2107. X
  2108. X/* Ring menu definitions */
  2109. X
  2110. Xstruct cmd {
  2111. X    char c_key;
  2112. X    char *c_title;
  2113. X    char *c_desc;
  2114. X};
  2115. X
  2116. X#define EOM        '\0'    /* end of menu */
  2117. X#define INVISIBLE    ""    /* invisible entry */
  2118. ________This_Is_The_END________
  2119. if test `wc -l < usc.h` -ne 217; then
  2120.     echo 'shar: usc.h was damaged during transit (should have been 217 bytes)'
  2121. fi
  2122. fi        ; : end of overwriting check
  2123. echo 'x - ushort.c'
  2124. if test -f ushort.c; then echo 'shar: not overwriting ushort.c'; else
  2125. sed 's/^X//' << '________This_Is_The_END________' > ushort.c
  2126. X/*
  2127. X * $Header: ushort.c,v 1.6 87/06/09 12:19:08 brandon Exp $
  2128. X *
  2129. X * ``USC'' -- UNIFY(r) Screens using Curses
  2130. X * UNIFY(r) is a registered trademark of Unify Corporation.
  2131. X *
  2132. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  2133. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  2134. X *
  2135. X * $Log:    ushort.c,v $
  2136. X * Revision 1.6  87/06/09  12:19:08  brandon
  2137. X * Fixed the format for the buffer value generation.
  2138. X * 
  2139. X * Revision 1.5  87/06/09  11:53:17  brandon
  2140. X * Right-justified buffer display; repositioned cursor after conversion errors.
  2141. X * 
  2142. X * Revision 1.4  87/06/01  08:37:46  brandon
  2143. X * Added ^V (view) capability for related records.
  2144. X * 
  2145. X * Revision 1.3  87/05/27  14:43:23  brandon
  2146. X * Made sure buffer was padded with spaces.
  2147. X * 
  2148. X * Revision 1.2  87/05/26  15:44:23  brandon
  2149. X * Forgot to cast sprintf().
  2150. X * 
  2151. X * Revision 1.1  87/05/26  13:34:19  brandon
  2152. X * Initial revision
  2153. X * 
  2154. X * Revision 1.3  87/05/12  12:03:40  brandon
  2155. X * Changed to pass FWD, BACK, GO without checking the data buffer
  2156. X * 
  2157. X * Revision 1.2  87/04/29  11:30:48  brandon
  2158. X * Added RCS header information
  2159. X * 
  2160. X */
  2161. X
  2162. X/*LINTLIBRARY*/
  2163. X
  2164. X#include "usc.h"
  2165. X
  2166. X/*
  2167. X * Input an item of type (short).
  2168. X */
  2169. X
  2170. Xint ushort(len, buf)
  2171. Xshort *buf; {
  2172. X    char ibuf[5];
  2173. X    int rc, cnt, sign, y, x;
  2174. X
  2175. X    setraw();
  2176. X    if (len > 4)
  2177. X        len = 4;    /* (short)'s are max len = 4 */
  2178. X    (void) sprintf(ibuf, "%*d", len, *buf);
  2179. X    getyx(stdscr, y, x);
  2180. X    for (;;) {
  2181. X        (void) move(y, x);
  2182. X        if ((rc = inl(ibuf, len, 0)) == BACK || rc == FWD || rc == GO || rc == LOOK)
  2183. X            return rc;
  2184. X        for (cnt = 0; cnt < len && ibuf[cnt] == ' '; cnt++)
  2185. X            ;
  2186. X        if (cnt == len) {
  2187. X            prtmsg(1, 23, "Invalid number");
  2188. X            continue;
  2189. X        }
  2190. X        *buf = 0;
  2191. X        sign = 0;
  2192. X        if (ibuf[cnt] == '-') {
  2193. X            sign = 1;
  2194. X            if (++cnt == len) {
  2195. X                prtmsg(1, 23, "Invalid number");
  2196. X                continue;
  2197. X            }
  2198. X        }
  2199. X        for (; cnt < len && isdigit(ibuf[cnt]); cnt++) {
  2200. X            *buf *= 10;
  2201. X            *buf += ibuf[cnt] - '0';
  2202. X        }
  2203. X        for (; cnt < len && ibuf[cnt] == ' '; cnt++)
  2204. X            ;
  2205. X        if (cnt == len)
  2206. X             break;
  2207. X        prtmsg(1, 23, "Invalid number");
  2208. X    }
  2209. X    if (sign)
  2210. X        *buf = - *buf;
  2211. X    return rc;
  2212. X}
  2213. ________This_Is_The_END________
  2214. if test `wc -l < ushort.c` -ne 87; then
  2215.     echo 'shar: ushort.c was damaged during transit (should have been 87 bytes)'
  2216. fi
  2217. fi        ; : end of overwriting check
  2218. echo 'x - ustr.c'
  2219. if test -f ustr.c; then echo 'shar: not overwriting ustr.c'; else
  2220. sed 's/^X//' << '________This_Is_The_END________' > ustr.c
  2221. X/*
  2222. X * $Header: ustr.c,v 1.4 87/06/09 11:38:17 brandon Exp $
  2223. X *
  2224. X * ``USC'' -- UNIFY(r) Screens using Curses
  2225. X * UNIFY(r) is a registered trademark of Unify Corporation.
  2226. X *
  2227. X * THIS PROGRAM IS NOT BASED ON COPYRIGHTED CODE OF UNIFY CORPORATION, AND
  2228. X * IS HEREBY PLACED IN THE PUBLIC DOMAIN.
  2229. X *
  2230. X * $Log:    ustr.c,v $
  2231. X * Revision 1.4  87/06/09  11:38:17  brandon
  2232. X * Changed inl() call to use clrf == 2.
  2233. X * 
  2234. X * Revision 1.3  87/06/01  11:36:44  brandon
  2235. X * Was filling nulls[] instead of buf[]... dumb dumb da dumb :-)
  2236. X * 
  2237. X * Revision 1.2  87/06/01  11:23:53  brandon
  2238. X * UNIFY defaults STRNG fields to nulls (!) -- rather antisocial of it.  We
  2239. X * convert to spaces on update of an all-nulls STRNG field.
  2240. X * 
  2241. X * Revision 1.1  87/05/26  13:34:28  brandon
  2242. X * Initial revision
  2243. X * 
  2244. X * Revision 1.2  87/04/29  11:30:50  brandon
  2245. X * Added RCS header information
  2246. X * 
  2247. X */
  2248. X
  2249. X/*LINTLIBRARY*/
  2250. X
  2251. X#include "usc.h"
  2252. X
  2253. X/*
  2254. X * Get a string.  Very easy, since no checking is needed.  Except... UNIFY
  2255. X * defaults string fields to nulls (!) so we should check for all nulls and
  2256. X * convert to all spaces.  (Rather rude, in my opinion.)
  2257. X */
  2258. X
  2259. Xstatic char nulls[256];
  2260. Xstatic int _init = 0;
  2261. X
  2262. Xint ustr(len, buf)
  2263. Xchar *buf; {
  2264. X    setraw();
  2265. X    if (!_init) {
  2266. X        cfill(0, nulls, sizeof nulls);
  2267. X        _init = 1;
  2268. X    }
  2269. X    if (ivcmp(buf, nulls, len))
  2270. X        cfill(' ', buf, len);
  2271. X    return inl(buf, len, 2);
  2272. X}
  2273. ________This_Is_The_END________
  2274. if test `wc -l < ustr.c` -ne 52; then
  2275.     echo 'shar: ustr.c was damaged during transit (should have been 52 bytes)'
  2276. fi
  2277. fi        ; : end of overwriting check
  2278. exit 0
  2279.