home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / mytinfo / part01 < prev    next >
Encoding:
Text File  |  1992-12-26  |  105.7 KB  |  4,774 lines

  1. Newsgroups: comp.sources.unix
  2. From: ross@zooid.guild.org (Ross Ridge)
  3. Subject: v26i077: mytinfo - a replacement for terminfo and termcap, Part01/03
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: ross@zooid.guild.org (Ross Ridge)
  8. Posting-Number: Volume 26, Issue 77
  9. Archive-Name: mytinfo/part01
  10.  
  11. Mytinfo is Public Domain and comes with no guarantees.
  12. By Ross Ridge (ross@zooid.guild.org).
  13.  
  14. Mytinfo is a single library that combines the functionality of the
  15. standard Unix termcap and terminfo libraries.  It has the special
  16. ability of being able to fetch terminal descriptions from both
  17. termcap and terminfo databases regardless of which set of functions,
  18. termcap or terminfo, are used.  It can even read terminal descriptions
  19. from terminfo source files. 
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 1 (of 3)."
  28. # Contents:  DECL MANIFEST README README.doc TODO addstr.c bin_order
  29. #   bsearch.c buildpath.c caps.c clear.c compar.c config.h defs.h
  30. #   fake_stdio.c fake_stdio.h fillterm.c findcap.c getother.c
  31. #   gettbin.c mkbinorder.c mkcaplist.c mkcapsort.c mkdir.c
  32. #   mktermhead.c mkversion.c quit.c readcaps.c strtok.c tcapvars.c
  33. #   tconv.1 term.tail termcap.c terminfo.c terminfo.src tgoto.c
  34. #   tiget.c tmatch.c tput.c tputs.c version.h
  35. # Wrapped by vixie@cognition.pa.dec.com on Sun Dec 27 14:45:19 1992
  36. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  37. if test -f 'DECL' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'DECL'\"
  39. else
  40. echo shar: Extracting \"'DECL'\" \(483 characters\)
  41. sed "s/^X//" >'DECL' <<'END_OF_FILE'
  42. int setupterm(char *, int, int *);
  43. int set_curterm(TERMINAL *);
  44. int del_curterm(TERMINAL *);
  45. char *tparm(char *, ...);
  46. int tputs(char *, int, int (*)());
  47. int putp(char *);
  48. int def_prog_mode(void);
  49. int def_shell_mode(void);
  50. int reset_prog_mode(void);
  51. int reset_shell_mode(void);
  52. int tigetnum(char *);
  53. int tigetflag(char *);
  54. char *tigetstr(char *);
  55. int tgetent(char *, char *);
  56. int tgetnum(char *);
  57. int tgetflag(char *);
  58. char *tgetstr(char *, char * *);
  59. char *tgoto(char *, int, int);
  60. END_OF_FILE
  61. if test 483 -ne `wc -c <'DECL'`; then
  62.     echo shar: \"'DECL'\" unpacked with wrong size!
  63. fi
  64. # end of 'DECL'
  65. fi
  66. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  67.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  68. else
  69. echo shar: Extracting \"'MANIFEST'\" \(1832 characters\)
  70. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  71. X   File Name        Archive #    Description
  72. X-----------------------------------------------------------
  73. X DECL                       1    
  74. X DIFFS-moderator            2    
  75. X INSTALL                    2    
  76. X MANIFEST                   1    
  77. X Makefile                   2    
  78. X README                     1    
  79. X README.doc                 1    
  80. X TODO                       1    
  81. X addstr.c                   1    
  82. X bin_order                  1    
  83. X bsearch.c                  1    
  84. X buildpath.c                1    
  85. X cap_list                   2    
  86. X caps.c                     1    
  87. X clear.c                    1    
  88. X compar.c                   1    
  89. X config.h                   1    
  90. X defs.h                     1    
  91. X fake_stdio.c               1    
  92. X fake_stdio.h               1    
  93. X fillterm.c                 1    
  94. X findcap.c                  1    
  95. X findterm.c                 2    
  96. X getother.c                 1    
  97. X gettbin.c                  1    
  98. X gettcap.c                  2    
  99. X gettinfo.c                 2    
  100. X mkbinorder.c               1    
  101. X mkcaplist.c                1    
  102. X mkcapsort.c                1    
  103. X mkdir.c                    1    
  104. X mktermhead.c               1    
  105. X mkversion.c                1    
  106. X qsort.c                    2    
  107. X quit.c                     1    
  108. X readcaps.c                 1    
  109. X sprintf.c                  2    
  110. X strtok.c                   1    
  111. X tcapconv.c                 2    
  112. X tcapvars.c                 1    
  113. X tconv.1                    1    
  114. X tconv.c                    3    
  115. X term.tail                  1    
  116. X termcap.c                  1    
  117. X terminfo.c                 1    
  118. X terminfo.src               1    
  119. X tgoto.c                    1    
  120. X tiget.c                    1    
  121. X tmatch.c                   1    
  122. X tparm.c                    3    
  123. X tput.c                     1    
  124. X tputs.c                    1    
  125. X tset.c                     3    
  126. X ttest.c                    2    
  127. X tty.c                      2    
  128. X version.h                  1    
  129. END_OF_FILE
  130. if test 1832 -ne `wc -c <'MANIFEST'`; then
  131.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  132. fi
  133. # end of 'MANIFEST'
  134. fi
  135. if test -f 'README' -a "${1}" != "-c" ; then 
  136.   echo shar: Will not clobber existing file \"'README'\"
  137. else
  138. echo shar: Extracting \"'README'\" \(4032 characters\)
  139. sed "s/^X//" >'README' <<'END_OF_FILE'
  140. Mytinfo is Public Domain and comes with no guarantees.
  141. By Ross Ridge (ross@zooid.guild.org).
  142. X
  143. Mytinfo is a single library that combines the functionality of the
  144. standard Unix termcap and terminfo libraries.  It has the special
  145. ability of being able to fetch terminal descriptions from both
  146. termcap and terminfo databases regardless of which set of functions,
  147. termcap or terminfo, are used.  It can even read terminal descriptions
  148. from terminfo source files. 
  149. X
  150. You should be able to compile this library on almost all versions of Unix.
  151. Much of it's development was done on '386 Xenix, but I've sucessfuly built
  152. mytinfo under BSD 4.3, HP-UX 2.1 (System III), SunOS 3.5, and Amix
  153. X(System V R4).  There hasn't been a large amount of testing of the support
  154. programmes that come with the library, but the library itself has been in
  155. use on a couple of public access Unix sites for over two years.  It has
  156. successfully linked and run with many programmes such as rn, vi and nethack.
  157. X
  158. Included in the package is tconv, an "all-in-one" programme that will
  159. compile terminfo sources to binary format and also translate termcap to
  160. either terminfo source or binary.  tic and cap2info are just links
  161. to the tconv programme.  I've also written replacement for tset,
  162. that uses the mytinfo library, in case tset doesn't come with your
  163. system or if you aren't too pleased with the one that did.  Since this
  164. is the newest part of the package it probably still has a few bugs.
  165. You'll also find tput, as well two versions of clear, one that uses
  166. termcap and the other that uses terminfo.
  167. X
  168. The environment variables TERMCAP and TERMINFO can have multiple
  169. filenames separated by a space, a feature not in terminfo and not in
  170. most termcaps.  This is very handy for users that maintain their own
  171. private databases, as they don't have to have a copy the entire
  172. database.  Eg:
  173. X    TERMCAP="$HOME/.termcap /etc/termcap"
  174. X    TERMINFO="$HOME/terminfo /usr/lib/terminfo"
  175. X    export TERMCAP TERMINFO
  176. The library will also check compiled-in default locations for terminal
  177. descriptions.  Like most termcaps, the TERMCAP variable can also
  178. contain the complete termcap terminal description, usually supplied
  179. from tset at login.  The TERMINFO variable can also contain a complete
  180. terminfo description, but there is no programme like tset to supply it.
  181. X
  182. Unlike termcap, this library can only use capabilities that it knows about.
  183. However it does knows about all the standard ones, and you can easily
  184. add your own to it's list.  Included in the list are all terminfo
  185. capabilities to Release 4 of System V, obsolete termcap capabilities, a
  186. few caps used from the University of Waterloo (UW), a couple from GNU Emacs,
  187. and a few I made up myself. Two extensions to the standard termcap % codes
  188. are supported, GNU's %a, %m, %b, and %f, and UW's %-, %a, and %s.
  189. X
  190. Termcap and terminfo source descriptions can be mixed in one file, but
  191. because of this termcap databases must be in a certain style.  All
  192. continuation lines of a termcap entry must be indented from the left
  193. margin by white space.  This shouldn't be a problem with most sites
  194. since this is the style that most termcap files are distributed, but local
  195. additions may not adhere to this style.  Another possible problem is
  196. that termcap entries should end with a colon (:), but in most
  197. distributed termcaps there are entries that don't.  If a one line
  198. termcap entry doesn't end with a colon, it will be ignored.  A quick
  199. way to find these is "tconv -c /etc/termcap > /dev/null".
  200. X
  201. See the file INSTALL for instructions on configuring and installing
  202. this library. The file README.doc lists the functions supported by the
  203. library, and gives short description of the tconv programme.  tconv.1 is
  204. a simple man page for tconv.  terminfo.src contains a few sample
  205. terminal descriptions in terminfo source format.  TODO is a list of
  206. possible enhancements too the library, your comments and additions
  207. are welcome.
  208. X
  209. Please let me know of any bugs you find, as well as any ideas you have
  210. for improvement.
  211. X
  212. Ross Ridge
  213. X
  214. ross@zooid.guild.org
  215. END_OF_FILE
  216. if test 4032 -ne `wc -c <'README'`; then
  217.     echo shar: \"'README'\" unpacked with wrong size!
  218. fi
  219. # end of 'README'
  220. fi
  221. if test -f 'README.doc' -a "${1}" != "-c" ; then 
  222.   echo shar: Will not clobber existing file \"'README.doc'\"
  223. else
  224. echo shar: Extracting \"'README.doc'\" \(4738 characters\)
  225. sed "s/^X//" >'README.doc' <<'END_OF_FILE'
  226. X----------------------------------------------------------------------------
  227. tconv [-b] [-c [-OUGd]] [-i] [-B [-D dir]] [-I] [-k] [-t term] [file]
  228. tic [file]
  229. cap2info [-t term] [-OUGdk] [file]
  230. X
  231. X-c        convert from termcap
  232. X-i        convert from terminfo source
  233. X-b        convert from terminfo binary
  234. X-B        convert to terminfo binary
  235. X-I        convert to terminfo source
  236. X
  237. The following switches are available when converting from termcap:
  238. X-d        don't supply any defaults for missing capabilities
  239. X-O        include obsolete termcap capabilities
  240. X-G        include GNU capabilities
  241. X-U        include UW capabilities
  242. X
  243. X-k        keep comments
  244. X-D dir        directory to put terminfo binaries in
  245. X
  246. X-t term        name of terminal to translate
  247. file        filename of termcap/terminfo database to use 
  248. X
  249. If a file is specifed and no terminal is given the entire file we be translated.
  250. If no terminal and no file is specified then the terminal name will be taken
  251. from the environment varible TERM. Unless compiling to a terminfo binary,
  252. output is to stdout.
  253. X----------------------------------------------------------------------------
  254. X
  255. char *tparm(char *str, ...);    /* up to nine parameters */
  256. char *tgoto(char *str, int column, int row);
  257. X
  258. tparm and tgoto support the following termcap and terminfo % codes:
  259. X
  260. Terminfo % Codes
  261. X
  262. X    %%    output a '%'
  263. X    %[[:][-+# ][width][.precision]][doxXs]
  264. X        output pop according to the printf format
  265. X    %c    output pop as a char
  266. X    %'c'    push character constant c.
  267. X    %{n}    push decimal constant n.
  268. X    %p[1-9] push paramter [1-9]
  269. X    %g[a-z] push variable [a-z]
  270. X    %P[a-z] put pop in variable [a-z]
  271. X    %l    push the length of pop (a string)
  272. X    %+    add pop to pop and push the result
  273. X    %-    subtract pop from pop and push the result
  274. X    %*    multiply pop and pop and push the result
  275. X    %&    bitwise and pop and pop and push the result
  276. X    %|    bitwise or pop and pop and push the result
  277. X    %^    bitwise xor pop and pop and push the result
  278. X    %~    push the bitwise not of pop
  279. X    %=    compare if pop and pop are equal and push the result
  280. X    %>    compare if pop is less than pop and push the result
  281. X    %<    compare if pop is greater than pop and push the result
  282. X    %A    logical and pop and pop and push the result
  283. X    %O    logical or pop and pop and push the result
  284. X    %!    push the logical not of pop
  285. X    %? condition %t if_true [%e if_false] %;
  286. X        if condtion evaulates as true then evaluate if_true,
  287. X        else evaluate if_false. elseif's can be done:
  288. X%? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %;
  289. X    %i    add one to parameters 1 and 2. (ANSI)
  290. X
  291. Termcap Codes
  292. X
  293. X    %%    output a %
  294. X    %.    output parameter as a character
  295. X    %d    output parameter as a decimal number
  296. X    %2    output parameter in printf format %02d
  297. X    %3    output parameter in printf format %03d
  298. X    %+x    add the character x to parameter and output it as a character
  299. X(UW)    %-x    subtract parameter FROM the character x and output it as a char
  300. X(UW)    %ax    add the character x to parameter
  301. X(GNU)    %a[+*-/=][cp]x
  302. X        GNU arithmetic. 
  303. X(UW)    %sx    subtract parameter FROM the character x
  304. X    %>xy    if parameter > character x then add character y to parameter
  305. X    %B    convert to BCD (parameter = (parameter/10)*16 + parameter%16)
  306. X    %D    Delta Data encode (parameter = parameter - 2*(paramter%16))
  307. X    %i    increment the first two parameters by one
  308. X    %n    xor the first two parameters by 0140
  309. X(GNU)    %m    xor the first two parameters by 0177
  310. X    %r    swap the first two parameters
  311. X(GNU)    %b    backup to previous parameter
  312. X(GNU)    %f    skip this parameter
  313. X
  314. X(GNU) used by GNU Emacs termcap libraries
  315. X(UW) used by the University of Waterloo (MFCF) termcap libraries
  316. X
  317. Note the two definitions of %a, the GNU defintion is used if the characters
  318. after the 'a' are valid for it, otherwise the UW definition is used.
  319. X----------------------------------------------------------------------------
  320. X
  321. int setupterm(char *term; int fd; int *err);
  322. int set_curterm(TERMINAL *new);
  323. int del_curterm(TERMINAL *old);
  324. char *tparm(char *str, ...);        /* see above */
  325. int tputs(char *str, int count, int (*putc)());
  326. int putp(str);
  327. int tigetflag(char *cap);
  328. int tigetnum(char *cap);
  329. char *tigetstr(char *cap);
  330. int def_prog_mode();
  331. int def_shell_mode();
  332. int reset_prog_mode();
  333. int reset_shell_mode();
  334. char *boolnames[], *boolcodes[], *boolfnames[];
  335. char *numnames[], *numcodes[], *numfnames[];
  336. char *strnames[], *strcodes[], *strfnames[];
  337. X
  338. These functions work just like the terminfo functions. Note restartterm(),
  339. vidputs(), vidattr(), and mvcur() are not available.
  340. X----------------------------------------------------------------------------
  341. X
  342. int tgetent(char *buf, char *term);
  343. int tgetflag(char *cap);
  344. int tgetnum(char *cap);
  345. char *tgetstr(char *cap, char **area);
  346. char *tgoto(char *cap, int column, int row);
  347. int tputs(char *str, int count, int (*putc)());
  348. X
  349. These functions work just like termcap functions.
  350. X----------------------------------------------------------------------------
  351. END_OF_FILE
  352. if test 4738 -ne `wc -c <'README.doc'`; then
  353.     echo shar: \"'README.doc'\" unpacked with wrong size!
  354. fi
  355. # end of 'README.doc'
  356. fi
  357. if test -f 'TODO' -a "${1}" != "-c" ; then 
  358.   echo shar: Will not clobber existing file \"'TODO'\"
  359. else
  360. echo shar: Extracting \"'TODO'\" \(85 characters\)
  361. sed "s/^X//" >'TODO' <<'END_OF_FILE'
  362. X- docs, docs, docs
  363. X- rewrite tparm so it's no so disgusting
  364. X- better string handling
  365. END_OF_FILE
  366. if test 85 -ne `wc -c <'TODO'`; then
  367.     echo shar: \"'TODO'\" unpacked with wrong size!
  368. fi
  369. # end of 'TODO'
  370. fi
  371. if test -f 'addstr.c' -a "${1}" != "-c" ; then 
  372.   echo shar: Will not clobber existing file \"'addstr.c'\"
  373. else
  374. echo shar: Extracting \"'addstr.c'\" \(1523 characters\)
  375. sed "s/^X//" >'addstr.c' <<'END_OF_FILE'
  376. X/*
  377. X * addstr.c
  378. X *
  379. X * By Ross Ridge
  380. X * Public Domain
  381. X * 92/02/01 07:34:01
  382. X *
  383. X */
  384. X
  385. X#include "defs.h"
  386. X#include "term.h"
  387. X
  388. X#include <ctype.h>
  389. X
  390. X#ifdef USE_SCCS_IDS
  391. static char const SCCSid[] = "@(#) mytinfo addstr.c 3.2 92/02/01 public domain, By Ross Ridge";
  392. X#endif
  393. X/*
  394. X * I think this routine could be improved, as it is now it searches a
  395. X * linked list of strbufs for one that has enough room left for the
  396. X * string. The only thing else I can think of doing would be to 
  397. X * expand a buffer by realloc and then fix the string pointers if it
  398. X * moves.
  399. X */
  400. X
  401. static struct strbuf *strbuf = NULL;
  402. X   
  403. struct strbuf *
  404. X_endstr() {
  405. X    register struct strbuf *p;
  406. X
  407. X    p = strbuf;
  408. X    strbuf = NULL;
  409. X    return p;
  410. X}
  411. X
  412. char *
  413. X_addstr(s)
  414. register char *s; {
  415. X    register struct strbuf *p;
  416. X    register int l;
  417. X
  418. X    if (s == NULL) {
  419. X        strbuf = NULL;
  420. X        return NULL;
  421. X    }
  422. X
  423. X    if (strbuf == NULL) {
  424. X        strbuf = (struct strbuf *) malloc(sizeof(struct strbuf));
  425. X        if (strbuf == NULL)
  426. X            return NULL;
  427. X        strbuf->len = 0;
  428. X        strbuf->next = NULL;
  429. X    }
  430. X    l = strlen(s) + 1;
  431. X    if (l > MAX_CHUNK)
  432. X        return NULL;
  433. X    p = strbuf;
  434. X    while (l + p->len > MAX_CHUNK) {
  435. X        if (p->next == NULL) {
  436. X            p->next = (struct strbuf *)
  437. X                    malloc(sizeof(struct strbuf));
  438. X            p = p->next;
  439. X            if (p == NULL)
  440. X                return NULL;
  441. X            p->len = 0;
  442. X            p->next = NULL;
  443. X            break;
  444. X        }
  445. X        p = p->next;
  446. X    }
  447. X    s = strcpy(p->buf + p->len, s);
  448. X    p->len += l;
  449. X    return s;
  450. X}
  451. X
  452. void
  453. X_del_strs(p)
  454. TERMINAL *p; {
  455. X    struct strbuf *q;
  456. X
  457. X    q = p->strbuf;
  458. X    while(q != NULL) {
  459. X        p->strbuf = q->next; 
  460. X        free((anyptr) q);
  461. X        q = p->strbuf;
  462. X    }
  463. X}
  464. END_OF_FILE
  465. if test 1523 -ne `wc -c <'addstr.c'`; then
  466.     echo shar: \"'addstr.c'\" unpacked with wrong size!
  467. fi
  468. # end of 'addstr.c'
  469. fi
  470. if test -f 'bin_order' -a "${1}" != "-c" ; then 
  471.   echo shar: Will not clobber existing file \"'bin_order'\"
  472. else
  473. echo shar: Extracting \"'bin_order'\" \(2353 characters\)
  474. sed "s/^X//" >'bin_order' <<'END_OF_FILE'
  475. X bin_order
  476. X
  477. X By Ross Ridge
  478. X Public Domain
  479. X 92/02/01 07:29:39
  480. X
  481. X Order of entries in a terminfo binary
  482. X
  483. X @(#) mytinfo bin_order 3.2 92/02/01 public domain, By Ross Ridge
  484. X
  485. X
  486. X!
  487. bw am xsb xhp xenl eo gn hc km hs in da db mir msgr os eslok xt hz ul
  488. xon nxon mc5i chts nrrmc npc ndscr ccc bce hls xhpa crxm daisy xvpa sam
  489. cpix lpix
  490. X
  491. X#
  492. cols it lines lm xmc pb vt wsl nlab lh lw ma wnum colors pairs ncv bufsz
  493. spinv spinh maddr mjump mcs mls npins orc orl orhi orvi cps widcs btns
  494. bitwin bitype
  495. X
  496. X$
  497. cbt bel cr csr tbc clear el ed hpa cmdch cup cud1 home civis cub1 mrcup cnorm
  498. cuf1 ll cuu1 cvvis dch1 dl1 dsl hd smacs blink bold smcup smdc dim smir invis
  499. prot rev smso smul ech rmacs sgr0 rmcup rmdc rmir rmso rmul flash ff fsl is1
  500. is2 is3 if ich1 il1 ip kbs ktbc kclr kctab kdch1 kdl1 kcud1 krmir kel ked
  501. kf0 kf1 kf10 kf2 kf3 kf4 kf5 kf6 kf7 kf8 kf9 khome kich1 kil1 kcub1 kll
  502. knp kpp kcuf1 kind kri khts kcuu1 rmkx smkx lf0 lf1 lf10 lf2 lf3 lf4 lf5
  503. lf6 lf7 lf8 lf9 rmm smm nel pad dch dl cud ich indn il cub cuf rin cuu pfkey
  504. pfloc pfx mc0 mc4 mc5 rep rs1 rs2 rs3 rf rc vpa sc ind ri sgr hts wind ht
  505. tsl uc hu iprog ka1 ka3 kb2 kc1 kc3 mc5p rmp acsc pln kcbt smxon rmxon
  506. smam rmam xonc xoffc enacs smln rmln kbeg kcan kclo kcmd kcpy kcrt kend
  507. kent kext kfnd khlp kmrk kmsg kmov knxt kopn kopt kprv kprt krdo kref
  508. krfr krpl krst kres ksav kspd kund kBEG kCAN kCMD kCPY kCRT kDC kDL kslt
  509. kEND kEOL kEXT kFND kHLP kHOM kIC kLFT kMSG kMOV kNXT kOPT kPRV kPRT kRDO
  510. kRPL kRIT kRES kSAV kSPD kUND rfi kf11 kf12 kf13 kf14 kf15 kf16 kf17 kf18
  511. kf19 kf20 kf21 kf22 kf23 kf24 kf25 kf26 kf27 kf28 kf29 kf30 kf31 kf32
  512. kf33 kf34 kf35 kf36 kf37 kf38 kf39 kf40 kf41 kf42 kf43 kf44 kf45 kf46 kf47
  513. kf48 kf49 kf50 kf51 kf52 kf53 kf54 kf55 kf56 kf57 kf58 kf59 kf60 kf61 kf62
  514. kf63 el1 mgc smgl smgr fln sclk dclk rmclk cwin wingo hup dial qdial tone
  515. pulse hook pause wait u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 op oc initc initp scp
  516. setf setb cpi lpi chr cvr defc swidm sdrfq sitm slm smicm snlq snrmq sshm
  517. ssubm ssupm sum rwidm ritm rlm rmicm rshm rsubm rsupm rum mhpa mcud1 mcub1
  518. mcuf1 mvpa mcuu1 porder mcud mcub mcuf mcuu scs smgb smgbp smglp smgrp smgt
  519. smgtp sbim scsd rbim rcsd subcs supcs docr zerom csnm kmous minfo reqmp
  520. getm setaf setab pfxl devt csin s0ds s1ds s2ds s3ds smglr smgtb birep binel
  521. bicr colornm defbi endbi setcolor slines dispc smpch rmpch smsc rmsc pctrm
  522. scesc scesa
  523. END_OF_FILE
  524. if test 2353 -ne `wc -c <'bin_order'`; then
  525.     echo shar: \"'bin_order'\" unpacked with wrong size!
  526. fi
  527. # end of 'bin_order'
  528. fi
  529. if test -f 'bsearch.c' -a "${1}" != "-c" ; then 
  530.   echo shar: Will not clobber existing file \"'bsearch.c'\"
  531. else
  532. echo shar: Extracting \"'bsearch.c'\" \(2102 characters\)
  533. sed "s/^X//" >'bsearch.c' <<'END_OF_FILE'
  534. X/*
  535. X * bsearch.c
  536. X *
  537. X * This is something I found on watmath. I've made some minor changes for use
  538. X * in this package.
  539. X *
  540. X * 92/06/04 11:35:15
  541. X */
  542. X
  543. X#if 0
  544. X#ifndef lint
  545. static char *RCSid = "$OHeader: /usr/mfcf/src/accounts/libuw/RCS/bsearch.c,v 1.1 88/06/11 20:41:48 root Exp $";
  546. X#endif
  547. X#endif
  548. X
  549. X#include "defs.h"
  550. X
  551. X#ifdef USE_MYBSEARCH
  552. X
  553. X#ifdef USE_SCCS_IDS
  554. static char const SCCSid[] = "@(#) mytinfo bsearch.c 3.4 92/06/04 public domain, By Ross Ridge";
  555. X#endif
  556. X
  557. X#ifdef USE_SHORT_BSEARCH
  558. X#define fast_int short
  559. X#else
  560. X#define fast_int mysize_t
  561. X#endif
  562. X
  563. X/*
  564. X * bsearch - find an element of a sorted vector
  565. X *
  566. X *    found = bsearch(key, array, dimension, width, compare)
  567. X *        returns a pointer to the specified element in the array,
  568. X *        or (char*)0 if the element can't be found.
  569. X *    key
  570. X *        pointer to the element to be searched for in the array
  571. X *    array
  572. X *        address of an array of elements
  573. X *    dimension
  574. X *        number of elements in the array
  575. X *    width
  576. X *        sizeof(type) of each element
  577. X *    compare
  578. X *        pointer to a function taking (char *) pointers to two elements
  579. X *        and returning <0, 0, or >0 as the first element comes before,
  580. X *        at, or after the second element.  A compare function is provided
  581. X *        for comparing strings.
  582. X*/
  583. X#if 0
  584. X/*
  585. X * $OLog:    bsearch.c,v $
  586. X * Revision 1.1  88/06/11  20:41:48  root
  587. X * Initial revision
  588. X * 
  589. X*/
  590. X#endif
  591. X
  592. X    static anyptr
  593. bsearch(key, array, dimension, iwidth, compare)
  594. X    anyptr key;
  595. X    anyptr array;
  596. X    int dimension;
  597. X    mysize_t iwidth;
  598. X    compar_fn compare;
  599. X{
  600. X    register fast_int start;   /* offset to start of current interval */
  601. X    register fast_int end;     /* offset to end+1 of current interval */
  602. X    register fast_int middle;  /* offset to middle of current interval */
  603. X    auto int status;
  604. X    register fast_int width;
  605. X
  606. X    width = iwidth / sizeof(char);
  607. X
  608. X    start = 0;
  609. X    middle = 0;
  610. X    end = dimension;
  611. X
  612. X    while (start < end) {
  613. X
  614. X        middle = (start + end) / 2;
  615. X
  616. X        status = (*compare)(key, ((char *)array + middle*width));
  617. X
  618. X        if (status < 0)
  619. X            end = middle;
  620. X
  621. X        else if (status > 0)
  622. X            start = middle + 1;
  623. X
  624. X        else return (anyptr)(((char *)array) + middle*width);
  625. X    }
  626. X
  627. X    return  0;
  628. X}
  629. X
  630. X#endif /* USE_MYBSEARCH */
  631. END_OF_FILE
  632. if test 2102 -ne `wc -c <'bsearch.c'`; then
  633.     echo shar: \"'bsearch.c'\" unpacked with wrong size!
  634. fi
  635. # end of 'bsearch.c'
  636. fi
  637. if test -f 'buildpath.c' -a "${1}" != "-c" ; then 
  638.   echo shar: Will not clobber existing file \"'buildpath.c'\"
  639. else
  640. echo shar: Extracting \"'buildpath.c'\" \(4092 characters\)
  641. sed "s/^X//" >'buildpath.c' <<'END_OF_FILE'
  642. X/*
  643. X * buildpath.c
  644. X * 
  645. X * By Ross Ridge
  646. X * Public Domain
  647. X * 92/02/01 07:29:42
  648. X *
  649. X * _buildpath builds a list of file names and terminal descriprions extracted
  650. X * from its arguments. It returns a pointer to a structure that is used by
  651. X * other routines as the list of file names to search for terminal
  652. X * descriptions.  It is passed a variable number of arguments consisting
  653. X * of file name and type pairs. The file name can actually be a list of 
  654. X * file names seperated by spaces and any environment variables specified
  655. X * by a dollar sign ($) followed by its name are substituted in. A type
  656. X * of 1 indicates that the file name may actually be termcap description
  657. X * and a type of 2 indicates it may be a terminfo description. A type of 0
  658. X * indicates that the file name can only be a file name (or list of them).
  659. X *
  660. X */
  661. X
  662. X#include "defs.h"
  663. X
  664. X#include <ctype.h>
  665. X
  666. X#include "strtok.c"
  667. X
  668. X#ifdef USE_SCCS_IDS
  669. static const char SCCSid[] = "@(#) mytinfo buildpath.c 3.2 92/02/01 public domain, By Ross Ridge";
  670. X#endif
  671. X
  672. X/* more memory is allocated for file names every HUNK file names */
  673. X#define HUNK 32    
  674. X
  675. X/* characters that seperate file names in a list */
  676. X#define SEPERATORS " :"
  677. X
  678. static struct term_path *path = NULL;    /* the list of files */
  679. static int files = 0;            /* # of files in the list */
  680. static int size = 0;            /* # of files there is space for */
  681. X
  682. X/* add a file name, type pair to the list */
  683. static int
  684. addfile(file, type)
  685. char *file;
  686. int type; {
  687. X    int l;
  688. X    char *s;
  689. X
  690. X    if (file == NULL) {
  691. X        if (type != -1)
  692. X            return -1;
  693. X    } else if (file[0] == '\0')
  694. X        return -1;
  695. X
  696. X#ifdef DEBUG
  697. X    if (file != NULL)
  698. X        printf("addfile: %s\n", file);
  699. X#endif
  700. X
  701. X    if (files >= size) {
  702. X        size += HUNK;
  703. X        if (path == NULL)
  704. X            path = (struct term_path *) 
  705. X                malloc(size * sizeof(struct term_path));
  706. X        else
  707. X            path = (struct term_path *)
  708. X                realloc((anyptr) path,
  709. X                    size * sizeof(struct term_path));
  710. X        if (path == NULL)
  711. X            return 0;
  712. X    }
  713. X    if (file == NULL) {
  714. X        path[files].file = file;
  715. X    } else {
  716. X        l = strlen(file) + 1;
  717. X        s = (char *) malloc(l * sizeof(char));
  718. X        if (s == NULL)
  719. X            return 0;
  720. X        path[files].file = strcpy(s, file);
  721. X    }
  722. X    path[files].type = type;
  723. X    
  724. X    return ++files;
  725. X}
  726. X
  727. X/* deallocate space used by the path list */
  728. void
  729. X_delpath(ppath)
  730. struct term_path *ppath; {
  731. X    struct term_path *p;
  732. X
  733. X    p = ppath;
  734. X    while(p->file != NULL) {
  735. X        free((anyptr)p->file);
  736. X        p++;
  737. X    }
  738. X
  739. X    free((anyptr)ppath);
  740. X}
  741. X
  742. X/* build a list of paths. see above */
  743. X#ifdef lint
  744. X/*VARARGS2*/
  745. struct term_path *
  746. X_buildpath(file, type)
  747. char *file;
  748. int type;
  749. X#else
  750. X#ifdef USE_STDARG
  751. X#ifdef USE_PROTOTYPES
  752. struct term_path *_buildpath(char *file, int type, ...)
  753. X#else
  754. struct term_path *_buildpath(file, type)
  755. char *file;
  756. int type;
  757. X#endif /* USE_PROTOTYPES */
  758. X#else /* USE_STDARG */
  759. struct term_path *_buildpath(va_alist)
  760. va_dcl
  761. X#endif /* USE_STDARG */
  762. X#endif /* lint */
  763. X{
  764. X#ifndef lint
  765. X#ifndef USE_STDARG
  766. X    char *file;
  767. X    int type;
  768. X#endif
  769. X#endif
  770. X    va_list ap;
  771. X    register char *s, *d, *e;
  772. X    char line[MAX_BUF+1];
  773. X    char name[MAX_NAME+1];
  774. X    int i,j;
  775. X
  776. X    size = 0;
  777. X    files = 0;
  778. X    path = NULL;
  779. X
  780. X#ifdef lint
  781. X    ap = NULL;
  782. X#else
  783. X#ifdef USE_STDARG
  784. X    va_start(ap, type);
  785. X#else
  786. X    va_start(ap);
  787. X    file = va_arg(ap, char *);
  788. X    type = va_arg(ap, int);
  789. X#endif
  790. X#endif
  791. X
  792. X    while (type >= 0 && type <= 2) {
  793. X        s = file;
  794. X        d = line;
  795. X        i = 0;
  796. X        while(*s != '\0') {
  797. X            if (*s == '$') {
  798. X                s++;
  799. X                j = 0;
  800. X                while(*s != '\0' && (*s == '_' || isalnum(*s))) 
  801. X                    if (j < MAX_NAME) {
  802. X                        name[j] = *s++;
  803. X                        j++;
  804. X                    } else
  805. X                        break;
  806. X                name[j] = '\0';
  807. X                e = getenv(name);
  808. X                if (e != NULL) {
  809. X                    while(*e != '\0') {
  810. X                        if (i < MAX_BUF) {
  811. X                            *d++ = *e++;
  812. X                            i++;
  813. X                        } else
  814. X                            break;
  815. X                    }
  816. X                } else if (*s == '/') 
  817. X                    s++;
  818. X            } else {
  819. X                if (i < MAX_BUF) {
  820. X                    *d++ = *s++;
  821. X                    i++;
  822. X                } else
  823. X                    break;
  824. X            }
  825. X        }
  826. X        *d = '\0';
  827. X        if (type == 0 || line[0] == '/') {
  828. X            s = strtok(line, SEPERATORS);
  829. X            while(s != NULL) {
  830. X                if (addfile(s, 0) == 0)
  831. X                    return NULL;
  832. X                s = strtok(NULL, SEPERATORS);
  833. X            }
  834. X        } else 
  835. X            if (addfile(line, type) == 0)
  836. X                return NULL;
  837. X        file = va_arg(ap, char *);
  838. X        type = va_arg(ap, int);
  839. X    }
  840. X    addfile(NULL, -1);
  841. X    return path;
  842. X}
  843. END_OF_FILE
  844. if test 4092 -ne `wc -c <'buildpath.c'`; then
  845.     echo shar: \"'buildpath.c'\" unpacked with wrong size!
  846. fi
  847. # end of 'buildpath.c'
  848. fi
  849. if test -f 'caps.c' -a "${1}" != "-c" ; then 
  850.   echo shar: Will not clobber existing file \"'caps.c'\"
  851. else
  852. echo shar: Extracting \"'caps.c'\" \(3316 characters\)
  853. sed "s/^X//" >'caps.c' <<'END_OF_FILE'
  854. X/*
  855. X * caps.c
  856. X * 
  857. X * By Ross Ridge
  858. X * Public Domain
  859. X * 92/02/01 07:29:45
  860. X *
  861. X * caps [-c | -t] [term]
  862. X *
  863. X * -c        use termcap names instead of terminfo variable names
  864. X * -t        use terminfo capnames instead of variables names
  865. X * term     name of terminal to use
  866. X *
  867. X * prints out all the capabilities given the specified terminal. If no
  868. X * terminal is given, it is taken from the environment variable TERM.
  869. X *
  870. X */
  871. X
  872. X#define NOTLIB
  873. X#include "defs.h"
  874. X#include "term.h"
  875. X
  876. static const char SCCSid[] = "@(#) mytinfo caps.c 3.2 92/02/01 public domain, By Ross Ridge";
  877. X
  878. X/* output a string in a human readable format */
  879. void
  880. putstr(s)
  881. char *s; {
  882. X    while(*s != '\0') {
  883. X        switch(*s) {
  884. X        case '\n': printf("\\n"); break;
  885. X        case '\b': printf("\\b"); break;
  886. X        case '\t': printf("\\t"); break;
  887. X        case '\r': printf("\\r"); break;
  888. X        case '\f': printf("\\f"); break;
  889. X        case ' ': printf("\\s"); break;
  890. X        case '\177': printf("^?"); break;
  891. X        case '\200': printf("\\0"); break;
  892. X        default:
  893. X            if (*s > 0 && *s < 32)
  894. X                printf("^%c", *s + 64);
  895. X            else if (*s < 0 || *s > 127)
  896. X                printf("\\%03o", *s & 0xff);
  897. X            else
  898. X                putchar(*s);
  899. X            break;
  900. X        }
  901. X        s++;
  902. X    }
  903. X}
  904. X
  905. void
  906. do_cleanup(e)
  907. int e; {
  908. X    fprintf(stderr, "usage: %s [-c | -t ] [terminal]\n", prg_name);
  909. X    return;
  910. X}
  911. X
  912. int
  913. main(argc, argv)
  914. int argc;
  915. char **argv; {
  916. X    int names = 0;
  917. X    register int i;
  918. X    int flag, num;
  919. X    char *str;
  920. X
  921. X    prg_name = argv[0];
  922. X    cleanup = do_cleanup;
  923. X
  924. X    if (argc > 3)
  925. X        quit(-1, "argument count");
  926. X
  927. X    if (argc == 1)
  928. X        setupterm(NULL, 2, (int *) 0);
  929. X    else if (argc == 2)
  930. X        setupterm(argv[1], 2, (int *) 0);
  931. X    else {
  932. X        if (argv[1][0] != '-')
  933. X            quit(-1, "bad switch");
  934. X        if (argv[1][1] == 'c')
  935. X            names = 2;
  936. X        else if (argv[1][1] == 't')
  937. X            names = 1;
  938. X        else
  939. X            quit(-1, "unknown switch '%c'", argv[1][1]);
  940. X        setupterm(argv[2], 2, (int *) 0);
  941. X
  942. X    }
  943. X
  944. X    fflush(stderr);
  945. X    fflush(stdout);
  946. X    printf("\n");
  947. X#ifdef _CUR_TERM
  948. X    printf("%s: %s\n", cur_term->name, cur_term->name_all);
  949. X    printf("pad: %d xon: %d termcap: %d\n",
  950. X            cur_term->pad, cur_term->xon, cur_term->termcap);
  951. X    printf("true_columns: %d true_lines: %d baudrate: %d\n",
  952. X        cur_term->true_columns, cur_term->true_lines,
  953. X        cur_term->baudrate);
  954. X    printf("\n");
  955. X#endif
  956. X
  957. X    printf("Booleans:\n");
  958. X    for(i = 0; boolnames[i] != NULL; i++) {
  959. X#ifdef _CUR_TERM
  960. X        flag = cur_term->bools[i];
  961. X#else
  962. X        flag = tigetflag(boolnames[i]);
  963. X#endif
  964. X        if (flag != -1 && flag != 0) {
  965. X            switch(names) {
  966. X            case 0:
  967. X                printf("  %s\n", boolfnames[i]);
  968. X                break;
  969. X            case 1:
  970. X                printf("  %s\n", boolnames[i]);
  971. X                break;
  972. X            case 2:
  973. X                printf("  %s\n", boolcodes[i]);
  974. X                break;
  975. X            }
  976. X        }
  977. X    }
  978. X
  979. X    printf("\nNumerics:\n");
  980. X    for(i = 0; numnames[i] != NULL; i++) {
  981. X        num = tigetnum(numnames[i]);
  982. X        if (num != -2 && num != -1) {
  983. X            switch(names) {
  984. X            case 0:
  985. X                printf("  %-32s: %d\n", numfnames[i], num);
  986. X                break;
  987. X            case 1:
  988. X                printf("  %-5s: %d\n", numnames[i], num);
  989. X                break;
  990. X            case 2:
  991. X                printf("  %-2s: %d\n", numcodes[i], num);
  992. X                break;
  993. X            }
  994. X        }
  995. X    }
  996. X    printf("\nStrings:\n");
  997. X    for(i = 0; strnames[i] != NULL; i++) {
  998. X        str = tigetstr(strnames[i]);
  999. X        if (str != (char *) -1 && str != (char *) 0) {
  1000. X            switch(names) {
  1001. X            case 0:
  1002. X                printf("  %-32s: ", strfnames[i]);
  1003. X                break;
  1004. X            case 1:
  1005. X                printf("  %-5s: ", strnames[i]);
  1006. X                break;
  1007. X            case 2:
  1008. X                printf("  %-2s: ", strcodes[i]);
  1009. X                break;
  1010. X            }
  1011. X            putstr(str);
  1012. X            putchar('\n');
  1013. X        }
  1014. X    }
  1015. X    return 0;
  1016. X}
  1017. END_OF_FILE
  1018. if test 3316 -ne `wc -c <'caps.c'`; then
  1019.     echo shar: \"'caps.c'\" unpacked with wrong size!
  1020. fi
  1021. # end of 'caps.c'
  1022. fi
  1023. if test -f 'clear.c' -a "${1}" != "-c" ; then 
  1024.   echo shar: Will not clobber existing file \"'clear.c'\"
  1025. else
  1026. echo shar: Extracting \"'clear.c'\" \(1388 characters\)
  1027. sed "s/^X//" >'clear.c' <<'END_OF_FILE'
  1028. X/*
  1029. X * clear.c
  1030. X *
  1031. X * By Ross Ridge
  1032. X * Public Domain
  1033. X * 92/02/01 07:29:47
  1034. X *
  1035. X * clear
  1036. X * 
  1037. X * clears the terminal's screen
  1038. X *
  1039. X */
  1040. X
  1041. X#include "defs.h"
  1042. X
  1043. static const char SCCSid[] = "@(#) mytinfo clear.c 3.2 92/02/01 public domain, By Ross Ridge";
  1044. X
  1045. X#ifndef USE_TERMINFO
  1046. X
  1047. X#ifdef USE_SGTTY
  1048. X#include <sgtty.h>
  1049. X#endif
  1050. X#ifdef USE_TERMIO
  1051. X#include <termio.h>
  1052. X#endif
  1053. X
  1054. char PC;
  1055. short ospeed;
  1056. X
  1057. int
  1058. putch(c)
  1059. int c; {
  1060. X    return putchar(c);
  1061. X}
  1062. X
  1063. int
  1064. main(argc, argv)
  1065. int argc;
  1066. char **argv; {
  1067. X#ifdef USE_PROTYPES
  1068. X    char *tgetstr(char *, char **);
  1069. X#else
  1070. X    char *tgetstr();
  1071. X#endif
  1072. X    char *term;
  1073. X    char buf[MAX_BUF];
  1074. X    char CL[MAX_LINE];
  1075. X    char *s, *pc;
  1076. X
  1077. X#ifdef USE_SGTTY
  1078. X    struct sgttyb tty;
  1079. X
  1080. X    gtty(1, &tty);
  1081. X    ospeed = tty.sg_ospeed;
  1082. X#else
  1083. X#ifdef USE_TERMIO
  1084. X    struct termio tty;
  1085. X
  1086. X    ioctl(1, TCGETA, &tty);
  1087. X    ospeed = tty.c_cflag & CBAUD;
  1088. X#else
  1089. X    ospeed = 0;
  1090. X#endif
  1091. X#endif
  1092. X
  1093. X    term = getenv("TERM");
  1094. X    if (term == NULL)
  1095. X        exit(1);
  1096. X
  1097. X    if (tgetent(buf, term) != 1)
  1098. X        exit(1);
  1099. X
  1100. X    s = CL;
  1101. X    pc = tgetstr("pc", &s);
  1102. X    if (pc != NULL)
  1103. X        PC = *pc;
  1104. X
  1105. X    s = CL;
  1106. X    tgetstr("cl", &s);
  1107. X
  1108. X    if (CL != NULL) {
  1109. X        tputs(CL, tgetnum("li"), putch);
  1110. X        exit(1);
  1111. X    }
  1112. X
  1113. X    return 0;
  1114. X}
  1115. X
  1116. X#else /* USE_TERMINFO */
  1117. X
  1118. X#include "term.h"
  1119. X
  1120. int
  1121. putch(c)
  1122. int c; {
  1123. X    return putchar(c);
  1124. X}
  1125. X
  1126. int
  1127. main() {
  1128. X    setupterm((char *) 0, 1, (int *) 0); 
  1129. X    if (clear_screen == (char *) 0)
  1130. X        exit(1);
  1131. X    tputs(clear_screen, lines > 0 ? lines : 1, putch);
  1132. X    return 0;
  1133. X}
  1134. X
  1135. X#endif /* USE_TERMINFO */
  1136. END_OF_FILE
  1137. if test 1388 -ne `wc -c <'clear.c'`; then
  1138.     echo shar: \"'clear.c'\" unpacked with wrong size!
  1139. fi
  1140. # end of 'clear.c'
  1141. fi
  1142. if test -f 'compar.c' -a "${1}" != "-c" ; then 
  1143.   echo shar: Will not clobber existing file \"'compar.c'\"
  1144. else
  1145. echo shar: Extracting \"'compar.c'\" \(735 characters\)
  1146. sed "s/^X//" >'compar.c' <<'END_OF_FILE'
  1147. X/*
  1148. X * compar.c
  1149. X *
  1150. X * By Ross Ridge
  1151. X * Public Domain
  1152. X * 92/06/04 11:36:24
  1153. X *
  1154. X */
  1155. X
  1156. X#include "defs.h"
  1157. X
  1158. X#ifdef USE_SCCS_IDS
  1159. static const char SCCSid[] = "@(#) mytinfo compar.c 3.3 92/06/04 public domain, By Ross Ridge";
  1160. X#endif
  1161. X
  1162. X/* compare two elements a sorted list of pointers to strings */
  1163. int
  1164. X_compar(a, b)
  1165. X#ifdef USE_ANSIC
  1166. void const *a;
  1167. void const *b; {
  1168. X#else
  1169. anyptr a, b; {
  1170. X#endif
  1171. X    register char *aa = **(char ***)a;
  1172. X    register char *bb = **(char ***)b;
  1173. X
  1174. X    /* An optimization trick from C News, compare the first
  1175. X     * two chars of the string here to avoid a the overhead of a
  1176. X     * call to strcmp.
  1177. X     */
  1178. X
  1179. X#ifdef __GNUC__
  1180. X    return ((*aa - *bb) ? : strcmp(aa, bb));
  1181. X#else
  1182. X    if (*aa != *bb)
  1183. X        return *aa - *bb;
  1184. X    return strcmp(aa, bb);
  1185. X#endif
  1186. X}
  1187. END_OF_FILE
  1188. if test 735 -ne `wc -c <'compar.c'`; then
  1189.     echo shar: \"'compar.c'\" unpacked with wrong size!
  1190. fi
  1191. # end of 'compar.c'
  1192. fi
  1193. if test -f 'config.h' -a "${1}" != "-c" ; then 
  1194.   echo shar: Will not clobber existing file \"'config.h'\"
  1195. else
  1196. echo shar: Extracting \"'config.h'\" \(2141 characters\)
  1197. sed "s/^X//" >'config.h' <<'END_OF_FILE'
  1198. X/*
  1199. X * config.h
  1200. X *
  1201. X * By Ross Ridge
  1202. X * Public Domain
  1203. X * 92/02/19 18:56:28
  1204. X *
  1205. X * @(#) mytinfo config.h 3.3 92/02/19 public domain, By Ross Ridge
  1206. X *
  1207. X * Read the file INSTALL for more information on configuring mytinfo
  1208. X *
  1209. X */
  1210. X
  1211. X#ifndef _CONFIG_H_
  1212. X#define _CONFIG_H_
  1213. X
  1214. X#ifdef __STDC__
  1215. X#define USE_ANSIC        /* undefine this if your compiler lies */
  1216. X#endif
  1217. X
  1218. X#define USE_TERMIO        /* use termio (SysIII, SysV) */
  1219. X#undef USE_SGTTY        /* use sgtty (v7, BSD) */
  1220. X#define USE_WINSZ        /* get window size from the tty driver */
  1221. X#undef USE_STRINGS        /* include <strings.h> instead of <string.h> */
  1222. X#define USE_MYBSEARCH        /* your library doesn't have bsearch */
  1223. X#define USE_MYSTRTOK        /* your library doesn't have strtok */
  1224. X#define USE_MYQSORT        /* your library doesn't have qsort */
  1225. X#define USE_MYMKDIR        /* your library doesn't have mkdir */
  1226. X#define USE_MEMORY        /* you have an <memory.h> header */
  1227. X#define USE_FAKE_STDIO        /* don't use real stdio */
  1228. X#undef USE_DOPRNT        /* no vfprintf, use _doprnt */
  1229. X
  1230. X#define USE_SHORT_BSEARCH    /* speeds up MYBSEARCH on most machines */
  1231. X
  1232. X#define USE_SMALLMEM         /* save some memory */
  1233. X
  1234. X#undef USE_UPBC_KLUDGE        /* do tgoto like real togo */
  1235. X#undef USE_EXTERN_UPBC        /* get cuu1 and cub1 from externs UP and BC */
  1236. X#undef USE_LITOUT_KLUDGE    /* an alternate tgoto kludge, not recommened */
  1237. X
  1238. X
  1239. X#ifndef USE_ANSIC
  1240. X
  1241. X#undef USE_PROTOTYPES        /* use ANSI C prototypes */
  1242. X#undef USE_STDLIB        /* you have a <stdlib.h> */
  1243. X#undef USE_STDARG        /* you have a <stdarg.h> */
  1244. X#undef USE_STDDEF        /* you have a <stddef.h> */
  1245. X
  1246. X#define const 
  1247. X#define volatile
  1248. X#define noreturn        /* a function that doesn't return */
  1249. X
  1250. typedef char *anyptr;        /* a type that any pointer can be assigned to */
  1251. X
  1252. X#define mysize_t unsigned    /* size_t, the size of an object */
  1253. X
  1254. X#else /* USE_ANSIC */
  1255. X
  1256. X#define USE_PROTOTYPES
  1257. X#define USE_STDLIB
  1258. X#define USE_STDARG
  1259. X#define USE_STDDEF
  1260. X
  1261. typedef void *anyptr;
  1262. X
  1263. X#define mysize_t size_t
  1264. X
  1265. X#ifdef __GNUC__
  1266. X#define noreturn volatile
  1267. X#else
  1268. X#define noreturn
  1269. X#endif
  1270. X
  1271. X#endif /* USE_ANSIC */
  1272. X
  1273. X#define TERMCAPFILE "$TERMCAPFILE $HOME/.termcap /etc/termcap"
  1274. X
  1275. X#define TERMINFOSRC "/usr/lib/terminfo/terminfo.src"
  1276. X
  1277. X#define TERMINFODIR "/usr/lib/terminfo"
  1278. X
  1279. X#endif 
  1280. END_OF_FILE
  1281. if test 2141 -ne `wc -c <'config.h'`; then
  1282.     echo shar: \"'config.h'\" unpacked with wrong size!
  1283. fi
  1284. # end of 'config.h'
  1285. fi
  1286. if test -f 'defs.h' -a "${1}" != "-c" ; then 
  1287.   echo shar: Will not clobber existing file \"'defs.h'\"
  1288. else
  1289. echo shar: Extracting \"'defs.h'\" \(3946 characters\)
  1290. sed "s/^X//" >'defs.h' <<'END_OF_FILE'
  1291. X/*
  1292. X * defs.h
  1293. X *
  1294. X * By Ross Ridge
  1295. X * Public Domain
  1296. X * 92/06/04 11:37:02
  1297. X *
  1298. X * @(#) mytinfo defs.h 3.3 92/06/04 public domain, By Ross Ridge
  1299. X */
  1300. X
  1301. X#ifndef _DEFS_H_
  1302. X#define _DEFS_H_
  1303. X
  1304. X#ifdef TEST
  1305. X#undef NOTLIB
  1306. X#define NOTLIB
  1307. X#endif
  1308. X
  1309. X#include "config.h"
  1310. X
  1311. X#ifdef NOTLIB
  1312. X#undef USE_FAKE_STDIO
  1313. X#endif
  1314. X
  1315. X#ifdef USE_STDDEF
  1316. X#include <stddef.h>
  1317. X#else
  1318. X#include <sys/types.h>
  1319. X#endif
  1320. X
  1321. X#ifdef USE_STDLIB
  1322. X#include <stdlib.h>
  1323. X#else
  1324. X#ifdef USE_PROTOTYPES
  1325. anyptr malloc(mysize_t);
  1326. anyptr realloc(anyptr, mysize_t);
  1327. char *getenv(char const *);
  1328. X#else
  1329. anyptr malloc();
  1330. anyptr realloc();
  1331. char *getenv();
  1332. X#endif
  1333. X#endif
  1334. X
  1335. X#ifdef USE_STDARG
  1336. X#include <stdarg.h>
  1337. X#else
  1338. X#include <varargs.h>
  1339. X#endif
  1340. X
  1341. X#ifndef _VA_LIST
  1342. X#define _VA_LIST
  1343. X#endif
  1344. X
  1345. X#ifdef USE_FAKE_STDIO
  1346. X#include "fake_stdio.h"
  1347. X#define sprintf _fake_sprintf
  1348. X#ifdef USE_PROTOTYPES
  1349. int sprintf(char *, char *, ...);
  1350. X#else
  1351. int sprintf();
  1352. X#endif
  1353. X#else /* USE_FAKE_STDIO */
  1354. X#if 0
  1355. X#include <stdio.h>
  1356. X#else
  1357. X#undef NULL
  1358. X#include <stdio.h>
  1359. X#endif
  1360. X#endif /* !USE_FAKE_STDIO */
  1361. X
  1362. X#ifdef USE_STRINGS
  1363. X#include <strings.h>
  1364. X#define strchr(s, c) index(s, c)
  1365. X#define strrchr(s, c) rindex(s, c)
  1366. X#ifndef USE_MYSTRTOK
  1367. X#ifdef USE_PROTOTYPES
  1368. char *strtok(char *, char *);
  1369. X#else
  1370. char *strtok();
  1371. X#endif
  1372. X#endif
  1373. X#else
  1374. X#include <string.h>
  1375. X#endif
  1376. X
  1377. X#ifdef USE_MEMORY
  1378. X#include <memory.h>
  1379. X#else
  1380. X#define memcpy(b, a, n) bcopy(a, b, n)
  1381. X#endif
  1382. X
  1383. X#include <errno.h>
  1384. X
  1385. X#define MAX_BUF    4096
  1386. X#define MAX_LINE 640
  1387. X#define MAX_NAME 128
  1388. X
  1389. X#define MAX_CHUNK MAX_LINE
  1390. X
  1391. X#define MAX_DEPTH 32
  1392. X
  1393. X#define MAX_VARNAME    32
  1394. X#define MAX_TINFONAME    5
  1395. X#define MAX_TCAPNAME    2
  1396. X
  1397. struct caplist {
  1398. X    char    type;
  1399. X    char    flag;
  1400. X    char    var[MAX_VARNAME + 1];
  1401. X    char    tinfo[MAX_TINFONAME + 1];
  1402. X    char    tcap[MAX_TCAPNAME + 1];
  1403. X};
  1404. X
  1405. struct term_path {
  1406. X    char *file;
  1407. X    int type;    /* 0 = file, 1 = TERMCAP env, 2 = TERMINFO env */
  1408. X};
  1409. X
  1410. struct _terminal;
  1411. X
  1412. X#ifdef USE_PROTOTYPES
  1413. X
  1414. int _gettcap(char *, struct _terminal *, struct term_path *);
  1415. int _gettinfo(char *, struct _terminal *, struct term_path *);
  1416. int _fillterm(char *, struct term_path *, char *);
  1417. int _findterm(char *, struct term_path *, char *);
  1418. int _init_tty(void), _lit_output(void), _check_tty(void);
  1419. void _figure_termcap(void);
  1420. int _tmatch(char *, char *);
  1421. void _norm_output(void);
  1422. int readcaps(FILE *, struct caplist *, int);
  1423. noreturn void quit(int, char *, ...);
  1424. X#ifdef lint
  1425. extern void (*cleanup)();
  1426. X#else
  1427. extern void (*cleanup)(int);
  1428. X#endif
  1429. struct term_path *_buildpath(char *, int, ...);
  1430. void _delpath(struct term_path *);
  1431. char *_addstr(char *);
  1432. struct strbuf *_endstr(void);
  1433. void _del_strs(struct _terminal *);
  1434. void _tcapconv(void);
  1435. void _tcapdefault(void);
  1436. int _getother(char *, struct term_path *, struct _terminal *);
  1437. int _gettbin(char *, struct _terminal *);
  1438. int _findboolcode(char *), _findnumcode(char *), _findstrcode(char *);
  1439. int _findboolname(char *), _findnumname(char *), _findstrname(char *);
  1440. int _findboolfname(char *), _findnumfname(char *), _findstrfname(char *);
  1441. X
  1442. X#ifdef USE_ANSIC
  1443. int _compar(void const *, void const *);
  1444. typedef int (*compar_fn)(void const *, void const *);
  1445. X#else
  1446. int _compar(anyptr, anyptr);
  1447. typedef int (*compar_fn)(anyptr, anyptr);
  1448. X#endif
  1449. X
  1450. X#else /* USE_PROTOTYPES */
  1451. X
  1452. int _gettcap(), _gettinfo(), _fillterm(), _findterm(), _init_tty();
  1453. int _lit_output(), _check_tty();
  1454. void _figure_termcap();
  1455. int _tmatch();
  1456. void _norm_output();
  1457. int readcaps();
  1458. noreturn void /* GOTO */ quit(/*FORMAT2*/);
  1459. extern void (*cleanup)();
  1460. struct term_path *_buildpath();
  1461. void _delpath();
  1462. char *_addstr();
  1463. struct strbuf *_endstr();
  1464. void _del_strs();
  1465. void _tcapconv();
  1466. void _tcapdefault();
  1467. int _getother();
  1468. int _gettbin();
  1469. int _findboolcode(), _findnumcode(), _findstrcode();
  1470. int _findboolname(), _findnumname(), _findstrname();
  1471. int _findboolfname(), _findnumfname(), _findstrfname();
  1472. int _compar();
  1473. typedef int (*compar_fn)();
  1474. X
  1475. X#endif /* USE_PROTOTYPES */
  1476. X
  1477. extern char _strflags[];
  1478. X
  1479. extern char _mytinfo_version[];
  1480. X
  1481. X/* for quit.c */
  1482. extern int sys_nerr;
  1483. extern char *sys_errlist[];
  1484. extern char *prg_name;
  1485. X
  1486. X#endif /* _DEFS_H_ */
  1487. END_OF_FILE
  1488. if test 3946 -ne `wc -c <'defs.h'`; then
  1489.     echo shar: \"'defs.h'\" unpacked with wrong size!
  1490. fi
  1491. # end of 'defs.h'
  1492. fi
  1493. if test -f 'fake_stdio.c' -a "${1}" != "-c" ; then 
  1494.   echo shar: Will not clobber existing file \"'fake_stdio.c'\"
  1495. else
  1496. echo shar: Extracting \"'fake_stdio.c'\" \(1803 characters\)
  1497. sed "s/^X//" >'fake_stdio.c' <<'END_OF_FILE'
  1498. X/*
  1499. X * fake_stdio.c
  1500. X *
  1501. X * By Ross Ridge
  1502. X * Public Domain
  1503. X * 92/02/01 07:29:52
  1504. X *
  1505. X * fake some stdio functions
  1506. X *
  1507. X */
  1508. X
  1509. X#include "defs.h"
  1510. X
  1511. X#include <fcntl.h>
  1512. X
  1513. X#ifdef USE_FAKE_STDIO
  1514. X
  1515. X#ifdef USE_SCCS_IDS
  1516. static const char SCCSid[] = "@(#) mytinfo fake_stdio.c 3.2 92/02/01 public domain, By Ross Ridge";
  1517. X#endif
  1518. X#include "fake_stdio.h"
  1519. X
  1520. static FILE _fake_files[] = {
  1521. X    {NULL, NULL, -1, {'\0'}},
  1522. X    {NULL, NULL, -1, {'\0'}},
  1523. X    {NULL, NULL, -1, {'\0'}},
  1524. X    {NULL, NULL, -1, {'\0'}},
  1525. X    {NULL, NULL, -1, {'\0'}}
  1526. X};
  1527. X
  1528. int
  1529. X_fillbuf(f)
  1530. register FILE *f; {
  1531. X    register int r;
  1532. X
  1533. X    r = read(f->fd, f->buf, FAKE_BUF_SIZE);
  1534. X    if (r == -1 || r == 0) {
  1535. X        f->pos = f->end = f->buf;
  1536. X        return EOF;
  1537. X    }
  1538. X    f->pos = f->buf + 1;
  1539. X    f->end = f->buf + r;
  1540. X
  1541. X    return f->buf[0];
  1542. X}
  1543. X
  1544. int
  1545. fgetc(f)
  1546. register FILE *f; {
  1547. X    return getc(f);
  1548. X}
  1549. X
  1550. char *
  1551. fgets(s, n, f)
  1552. char *s;
  1553. int n;
  1554. register FILE *f; {
  1555. X    register char *d;
  1556. X    register int l;
  1557. X    register int c;
  1558. X
  1559. X    d = s;
  1560. X    l = 1;
  1561. X    while(l < n) {
  1562. X        if ((c = getc(f)) == EOF) {
  1563. X            if (l == 0)
  1564. X                return NULL;
  1565. X            break;
  1566. X        }
  1567. X        *d++ = c;
  1568. X        if (c == '\n') 
  1569. X            break;
  1570. X        l++;
  1571. X    }
  1572. X    *d = '\0';
  1573. X    return s;
  1574. X}
  1575. X
  1576. static FILE *
  1577. X_fdopen(fd)
  1578. int fd; {
  1579. X    register FILE *f;
  1580. X    int i, r;
  1581. X
  1582. X    for(f = _fake_files, i = 0; i < FILES; i++, f++) {
  1583. X        if (f->fd == -1) {
  1584. X            f->fd = fd;
  1585. X            r = read(fd, f->buf, FAKE_BUF_SIZE);
  1586. X            if (r == -1) {
  1587. X                f->pos = f->end = f->buf;
  1588. X                return NULL;
  1589. X            }
  1590. X            f->pos = f->buf;
  1591. X            f->end = f->buf + r;
  1592. X            return f;
  1593. X        }
  1594. X    }
  1595. X    return NULL;
  1596. X}
  1597. X
  1598. XFILE *
  1599. fopen(name, type)
  1600. char *name;
  1601. char *type; {
  1602. X    FILE *f;
  1603. X    int fd;
  1604. X
  1605. X    if (strcmp(type, "r") != 0)
  1606. X        return NULL;
  1607. X    fd = open(name, O_RDONLY);
  1608. X    if (fd == -1)
  1609. X        return NULL;
  1610. X    f = _fdopen(fd);
  1611. X    if (f == NULL)
  1612. X        close(fd);
  1613. X    return f;
  1614. X}
  1615. X
  1616. XFILE *
  1617. fdopen(fd, type)
  1618. int fd;
  1619. char *type; {
  1620. X    if (strcmp(type, "r") != 0)
  1621. X        return NULL;
  1622. X    return _fdopen(fd);
  1623. X}
  1624. X
  1625. X#endif /* USE_FAKE_STDIO */
  1626. END_OF_FILE
  1627. if test 1803 -ne `wc -c <'fake_stdio.c'`; then
  1628.     echo shar: \"'fake_stdio.c'\" unpacked with wrong size!
  1629. fi
  1630. # end of 'fake_stdio.c'
  1631. fi
  1632. if test -f 'fake_stdio.h' -a "${1}" != "-c" ; then 
  1633.   echo shar: Will not clobber existing file \"'fake_stdio.h'\"
  1634. else
  1635. echo shar: Extracting \"'fake_stdio.h'\" \(1257 characters\)
  1636. sed "s/^X//" >'fake_stdio.h' <<'END_OF_FILE'
  1637. X/*
  1638. X * fake_stdio.h
  1639. X *
  1640. X * By Ross Ridge
  1641. X * Public Domain
  1642. X * 92/02/01 07:29:53
  1643. X *
  1644. X * A fake stdio.h for a fake stdio (read only)
  1645. X *
  1646. X * @(#) mytinfo fake_stdio.h 3.2 92/02/01 public domain, By Ross Ridge
  1647. X */
  1648. X
  1649. X#ifndef _FAKE_STDIO_H_
  1650. X
  1651. X#define _FAKE_STDIO_H_
  1652. X
  1653. X#if 1
  1654. X#define getc _fake_getc
  1655. X#define fgetc _fake_fgetc
  1656. X#define fgets _fake_fgets
  1657. X#define fclose _fake_fclose
  1658. X#define _fillbuf _fake_fillbuf
  1659. X#define ungetc _fake_ungetc
  1660. X#define fopen _fake_fopen
  1661. X#define fdopen _fake_fdopen
  1662. X#endif
  1663. X
  1664. X#define FILES    5
  1665. X#define FAKE_BUF_SIZE    512
  1666. X
  1667. struct _fake_file {
  1668. X    char *pos;
  1669. X    char *end;
  1670. X    int fd;
  1671. X    char buf[FAKE_BUF_SIZE];
  1672. X};
  1673. X
  1674. X#undef FILE
  1675. X#define FILE struct _fake_file
  1676. X#undef EOF
  1677. X#define EOF (-1)
  1678. X
  1679. X#define _fake_getc(f) ((f)->pos >= (f)->end ? _fillbuf(f) : *((f)->pos)++)
  1680. X#define _fake_fclose(f) (close((f)->fd) == -1 ? EOF : ((f)->fd = -1, 0))
  1681. X#define _fake_ungetc(c, f) ((f)->pos > (f)->buf ? (*--((f)->pos) = c) : EOF)
  1682. X
  1683. X#ifdef USE_PROTOYPES
  1684. int fgetc(FILE *);
  1685. int _fillbuf(FILE *);
  1686. char *fgets(char *, int, FILE *);
  1687. XFILE *fopen(char *, char *);
  1688. XFILE *fdopen(int, char *);
  1689. X#else
  1690. int fgetc();
  1691. int _fillbuf();
  1692. char *fgets();
  1693. XFILE *fopen();
  1694. XFILE *fdopen();
  1695. X#endif
  1696. X
  1697. X#if !defined(NULL) && !defined(USE_STRINGS)
  1698. X#define NULL ((anyptr) 0)
  1699. X#endif
  1700. X
  1701. X#endif /* !_FAKE_STDIO_H_ */
  1702. END_OF_FILE
  1703. if test 1257 -ne `wc -c <'fake_stdio.h'`; then
  1704.     echo shar: \"'fake_stdio.h'\" unpacked with wrong size!
  1705. fi
  1706. # end of 'fake_stdio.h'
  1707. fi
  1708. if test -f 'fillterm.c' -a "${1}" != "-c" ; then 
  1709.   echo shar: Will not clobber existing file \"'fillterm.c'\"
  1710. else
  1711. echo shar: Extracting \"'fillterm.c'\" \(1523 characters\)
  1712. sed "s/^X//" >'fillterm.c' <<'END_OF_FILE'
  1713. X/*
  1714. X * fillterm.c
  1715. X *
  1716. X * By Ross Ridge
  1717. X * Public Domain
  1718. X * 92/02/01 07:29:54
  1719. X *
  1720. X */
  1721. X
  1722. X#include "defs.h"
  1723. X#include "term.h"
  1724. X
  1725. X#ifdef USE_SCCS_IDS
  1726. static const char SCCSid[] = "@(#) mytinfo fillterm.c 3.2 92/02/01 public domain, By Ross Ridge";
  1727. X#endif
  1728. X
  1729. TERMINAL _term_buf;
  1730. TERMINAL *cur_term;
  1731. X
  1732. int
  1733. X_fillterm(name, path, buf)
  1734. char *name, *buf;
  1735. struct term_path *path; {
  1736. X    register int i, r;
  1737. X
  1738. X    r = -1;
  1739. X
  1740. X    for(i = NUM_OF_BOOLS; i;)
  1741. X        _term_buf.bools[--i] = -1;
  1742. X    for(i = NUM_OF_NUMS; i;)
  1743. X        _term_buf.nums[--i] = -2;
  1744. X    for(i = NUM_OF_STRS; i;)
  1745. X        _term_buf.strs[--i] = (char *) -1;
  1746. X
  1747. X    _term_buf.name_all = NULL;
  1748. X    
  1749. X    r = _findterm(name, path, buf);
  1750. X    switch(r) {
  1751. X    case 1:
  1752. X        if (_gettcap(buf, &_term_buf, path) != 0)
  1753. X            return -3;
  1754. X        _tcapconv(); 
  1755. X        _tcapdefault();
  1756. X        break;
  1757. X    case 2:
  1758. X        if (_gettinfo(buf, &_term_buf, path) != 0)
  1759. X            return -3;
  1760. X        break;
  1761. X    case 3:
  1762. X        if (_gettbin(buf, &_term_buf) != 0)
  1763. X            return -3;
  1764. X        break;
  1765. X    default:
  1766. X        return r;
  1767. X    }
  1768. X
  1769. X    if ((_term_buf.name = _addstr(name)) == NULL)
  1770. X        return -3;
  1771. X
  1772. X    for(i = NUM_OF_BOOLS; i;)
  1773. X        if (_term_buf.bools[--i] == -1)
  1774. X            _term_buf.bools[i] = 0;
  1775. X    for(i = NUM_OF_NUMS; i;)
  1776. X        if (_term_buf.nums[--i] == -2)
  1777. X            _term_buf.nums[i] = -1;
  1778. X    for(i = NUM_OF_STRS; i;)
  1779. X        if (_term_buf.strs[--i] == (char *) -1)
  1780. X            _term_buf.strs[i] = NULL;
  1781. X
  1782. X    _term_buf.fd = 1;
  1783. X    _term_buf.pad = 1;
  1784. X    _term_buf.baudrate = 0;
  1785. X    _term_buf.strbuf = _endstr();
  1786. X
  1787. X    cur_term = (TERMINAL *) malloc(sizeof(_term_buf));
  1788. X    if (cur_term == NULL)
  1789. X        return -3;
  1790. X    memcpy((anyptr)cur_term, (anyptr)&_term_buf, sizeof(_term_buf));
  1791. X
  1792. X    return r;
  1793. X}
  1794. END_OF_FILE
  1795. if test 1523 -ne `wc -c <'fillterm.c'`; then
  1796.     echo shar: \"'fillterm.c'\" unpacked with wrong size!
  1797. fi
  1798. # end of 'fillterm.c'
  1799. fi
  1800. if test -f 'findcap.c' -a "${1}" != "-c" ; then 
  1801.   echo shar: Will not clobber existing file \"'findcap.c'\"
  1802. else
  1803. echo shar: Extracting \"'findcap.c'\" \(2619 characters\)
  1804. sed "s/^X//" >'findcap.c' <<'END_OF_FILE'
  1805. X/*
  1806. X * findcap.c
  1807. X *
  1808. X * By Ross Ridge
  1809. X * Public Domain
  1810. X * 92/02/01 07:29:55
  1811. X *
  1812. X */
  1813. X
  1814. X#include "defs.h"
  1815. X#include "term.h"
  1816. X
  1817. X#include "bsearch.c"
  1818. X
  1819. X#ifdef USE_SCCS_IDS
  1820. static const char SCCSid[] = "@(#) mytinfo findcap.c 3.2 92/02/01 public domain, By Ross Ridge";
  1821. X#endif
  1822. X
  1823. extern char **_sboolcodes[], **_snumcodes[], **_sstrcodes[];
  1824. extern char **_sboolnames[], **_snumnames[], **_sstrnames[];
  1825. extern char **_sboolfnames[], **_snumfnames[], **_sstrfnames[];
  1826. X
  1827. static char **p2p2c;
  1828. X
  1829. int
  1830. X_findboolcode(s)
  1831. char *s; {
  1832. X    char ***match;
  1833. X
  1834. X    p2p2c = &s;
  1835. X
  1836. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolcodes,
  1837. X                   NUM_OF_BOOLS, sizeof(p2p2c), _compar);
  1838. X    if (match == NULL)
  1839. X        return -1;
  1840. X    return *match - boolcodes;
  1841. X}
  1842. X
  1843. int
  1844. X_findboolname(s)
  1845. char *s; {
  1846. X    char ***match;
  1847. X
  1848. X    p2p2c = &s;
  1849. X
  1850. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolnames,
  1851. X                   NUM_OF_BOOLS, sizeof(p2p2c), _compar);
  1852. X    if (match == NULL)
  1853. X        return -1;
  1854. X    return *match - boolnames;
  1855. X}
  1856. X
  1857. int
  1858. X_findboolfname(s)
  1859. char *s; {
  1860. X    char ***match;
  1861. X
  1862. X    p2p2c = &s;
  1863. X
  1864. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolfnames,
  1865. X                   NUM_OF_BOOLS, sizeof(p2p2c), _compar);
  1866. X    if (match == NULL)
  1867. X        return -1;
  1868. X    return *match - boolfnames;
  1869. X}
  1870. X
  1871. int
  1872. X_findnumcode(s)
  1873. char *s; {
  1874. X    char ***match;
  1875. X
  1876. X    p2p2c = &s;
  1877. X
  1878. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumcodes,
  1879. X                   NUM_OF_NUMS, sizeof(p2p2c), _compar);
  1880. X    if (match == NULL)
  1881. X        return -1;
  1882. X    return *match - numcodes;
  1883. X}
  1884. X
  1885. int
  1886. X_findnumname(s)
  1887. char *s; {
  1888. X    char ***match;
  1889. X
  1890. X    p2p2c = &s;
  1891. X
  1892. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumnames,
  1893. X                   NUM_OF_NUMS, sizeof(p2p2c), _compar);
  1894. X    if (match == NULL)
  1895. X        return -1;
  1896. X    return *match - numnames;
  1897. X}
  1898. X
  1899. int
  1900. X_findnumfname(s)
  1901. char *s; {
  1902. X    char ***match;
  1903. X
  1904. X    p2p2c = &s;
  1905. X
  1906. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumfnames,
  1907. X                   NUM_OF_NUMS, sizeof(p2p2c), _compar);
  1908. X    if (match == NULL)
  1909. X        return -1;
  1910. X    return *match - numfnames;
  1911. X}
  1912. X
  1913. int
  1914. X_findstrcode(s)
  1915. char *s; {
  1916. X    char ***match;
  1917. X
  1918. X    p2p2c = &s;
  1919. X
  1920. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrcodes,
  1921. X                   NUM_OF_STRS, sizeof(p2p2c), _compar);
  1922. X    if (match == NULL)
  1923. X        return -1;
  1924. X    return *match - strcodes;
  1925. X}
  1926. X
  1927. int
  1928. X_findstrname(s)
  1929. char *s; {
  1930. X    char ***match;
  1931. X
  1932. X    p2p2c = &s;
  1933. X
  1934. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrnames,
  1935. X                   NUM_OF_STRS, sizeof(p2p2c), _compar);
  1936. X    if (match == NULL)
  1937. X        return -1;
  1938. X    return *match - strnames;
  1939. X}
  1940. X
  1941. int
  1942. X_findstrfname(s)
  1943. char *s; {
  1944. X    char ***match;
  1945. X
  1946. X    p2p2c = &s;
  1947. X
  1948. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrfnames,
  1949. X                   NUM_OF_STRS, sizeof(p2p2c), _compar);
  1950. X    if (match == NULL)
  1951. X        return -1;
  1952. X    return *match - strfnames;
  1953. X}
  1954. END_OF_FILE
  1955. if test 2619 -ne `wc -c <'findcap.c'`; then
  1956.     echo shar: \"'findcap.c'\" unpacked with wrong size!
  1957. fi
  1958. # end of 'findcap.c'
  1959. fi
  1960. if test -f 'getother.c' -a "${1}" != "-c" ; then 
  1961.   echo shar: Will not clobber existing file \"'getother.c'\"
  1962. else
  1963. echo shar: Extracting \"'getother.c'\" \(724 characters\)
  1964. sed "s/^X//" >'getother.c' <<'END_OF_FILE'
  1965. X/*
  1966. X * getother.c
  1967. X *
  1968. X * By Ross Ridge
  1969. X * Public Domain
  1970. X * 92/02/01 07:29:58
  1971. X *
  1972. X */
  1973. X
  1974. X#include "defs.h"
  1975. X#include "term.h"
  1976. X
  1977. X#ifdef USE_SCCS_IDS
  1978. static const char SCCSid[] = "@(#) mytinfo getother.c 3.2 92/02/01 public domain, By Ross Ridge";
  1979. X#endif
  1980. X
  1981. int
  1982. X_getother(name, path, ct)
  1983. char *name;
  1984. struct term_path *path;
  1985. TERMINAL *ct; {
  1986. X    static int depth = 0;
  1987. X    int r;
  1988. X    char buf[MAX_BUF];
  1989. X
  1990. X    if (depth >= MAX_DEPTH)
  1991. X        return 1;        /* infinite loop */
  1992. X
  1993. X#ifdef DEBUG
  1994. X    printf("\ngetother: %s\n", name);
  1995. X#endif
  1996. X
  1997. X    switch(_findterm(name, path, buf)) {
  1998. X    case -3:
  1999. X        return 1;
  2000. X    case 1:
  2001. X        depth++;
  2002. X        r = _gettcap(buf, ct, path);
  2003. X        break;
  2004. X    case 2:
  2005. X        depth++;
  2006. X        r = _gettinfo(buf, ct, path);
  2007. X        break;
  2008. X    default:
  2009. X        return 0;
  2010. X    }
  2011. X    depth--;
  2012. X    return r;
  2013. X}
  2014. END_OF_FILE
  2015. if test 724 -ne `wc -c <'getother.c'`; then
  2016.     echo shar: \"'getother.c'\" unpacked with wrong size!
  2017. fi
  2018. # end of 'getother.c'
  2019. fi
  2020. if test -f 'gettbin.c' -a "${1}" != "-c" ; then 
  2021.   echo shar: Will not clobber existing file \"'gettbin.c'\"
  2022. else
  2023. echo shar: Extracting \"'gettbin.c'\" \(2573 characters\)
  2024. sed "s/^X//" >'gettbin.c' <<'END_OF_FILE'
  2025. X/*
  2026. X * gettbin.c
  2027. X *
  2028. X * By Ross Ridge
  2029. X * Public Domain
  2030. X * 92/02/01 07:29:59
  2031. X *
  2032. X * Get a terminfo binary entry
  2033. X *
  2034. X */
  2035. X
  2036. X#include "defs.h"
  2037. X#include "term.h"
  2038. X
  2039. X#ifdef USE_SCCS_IDS
  2040. static const char SCCSid[] = "@(#) mytinfo gettbin.c 3.2 92/02/01 public domain, By Ross Ridge";
  2041. X#endif
  2042. X
  2043. extern int _boolorder[], _numorder[], _strorder[];
  2044. X
  2045. X#ifdef TRUE_BYTE_ORDERING 
  2046. X/* 8 bit char, 16 bit short, lsb first, twos complement */
  2047. X#define convshort(s) (*(short *)(s))
  2048. X
  2049. X#else
  2050. X
  2051. X#ifdef TWOS_COPLEMENT 
  2052. X/* 8 bit char, 16 bit short, lsb last, twos complement */
  2053. X#define convshort(s) ((short)(((s[0] & 0377) << 8) | (s[1] & 0377)))
  2054. X
  2055. X#else
  2056. X
  2057. X/* anything else... */
  2058. X
  2059. static short
  2060. convshort(s)
  2061. char *s; {
  2062. X    register int a,b;
  2063. X
  2064. X    a = (int) s[0] & 0377;
  2065. X    b = (int) s[1] & 0377;
  2066. X
  2067. X    if (a == 0377 && b == 0377)
  2068. X        return -1;
  2069. X    if (a == 0376 && b == 0377)
  2070. X        return -2;
  2071. X
  2072. X    return a + b * 256;
  2073. X}
  2074. X#endif
  2075. X#endif
  2076. X
  2077. int
  2078. X_gettbin(buf, cur)
  2079. char *buf;
  2080. TERMINAL *cur; {
  2081. X    register char *s;
  2082. X    int i;
  2083. X    int sz_names, sz_bools, sz_nums, sz_offs, sz_strs;
  2084. X    int n_bools, n_nums, n_strs;
  2085. X    char *strtbl;
  2086. X
  2087. X    buf[MAX_BUF-1] = '\0';
  2088. X    s = buf;
  2089. X
  2090. X    if (convshort(s) != 0432)
  2091. X        return 1;
  2092. X    sz_names = convshort(s + 2);
  2093. X    sz_bools = convshort(s + 4);
  2094. X    n_nums = convshort(s + 6);
  2095. X    n_strs = convshort(s + 8);
  2096. X    sz_strs = convshort(s + 10);
  2097. X
  2098. X    n_bools = sz_bools;
  2099. X    sz_nums = n_nums * 2;
  2100. X    sz_offs = n_strs * 2;
  2101. X
  2102. X    if ((sz_names + sz_bools) & 1)
  2103. X        sz_bools++;
  2104. X
  2105. X    if (12 + sz_names + sz_bools + sz_nums + sz_offs + sz_strs >= MAX_BUF)
  2106. X        return 1;
  2107. X
  2108. X    s += 12;
  2109. X    if ((cur->name_all = _addstr(s)) == NULL)
  2110. X        return 1;
  2111. X    s += sz_names;
  2112. X    while(--s >= buf + 12) {
  2113. X        if (*s == '|') {
  2114. X            if ((cur->name_long = _addstr(s + 1)) == NULL)
  2115. X                return 1;
  2116. X            break;
  2117. X        }
  2118. X    }
  2119. X
  2120. X    s = buf + 12 + sz_names;
  2121. X    for(i = 0; i < n_bools && _boolorder[i] != -1; i++, s++) {
  2122. X        if (cur->bools[_boolorder[i]] == -1 && *s == 1)
  2123. X            cur->bools[_boolorder[i]] = 1;
  2124. X    }
  2125. X
  2126. X    s = buf + 12 + sz_names + sz_bools;
  2127. X    for(i = 0; i < n_nums && _numorder[i] != -1; i++, s += 2) {
  2128. X        if (convshort(s) == -2) 
  2129. X            cur->nums[_numorder[i]] = -1;
  2130. X        else if (cur->nums[_numorder[i]] == -2 && convshort(s) != -1)
  2131. X            cur->nums[_numorder[i]] = convshort(s);
  2132. X    }
  2133. X
  2134. X    s = buf + 12 + sz_names + sz_bools + sz_nums;
  2135. X    strtbl = s + sz_offs;
  2136. X    for(i = 0; i < n_strs && _strorder[i] != -1; i++, s += 2) {
  2137. X        if (convshort(s) == -2)
  2138. X            cur->strs[_strorder[i]] = NULL;
  2139. X        else if (cur->strs[_strorder[i]] == (char *) -1
  2140. X             && convshort(s) != -1) {
  2141. X#ifdef DEBUG
  2142. X            printf("$%s ", strnames[_strorder[i]]);
  2143. X#endif
  2144. X            if ((cur->strs[_strorder[i]]
  2145. X                 = _addstr(strtbl + convshort(s))) == NULL)
  2146. X                return 1;
  2147. X        } 
  2148. X    }
  2149. X
  2150. X    return 0;
  2151. X}
  2152. END_OF_FILE
  2153. if test 2573 -ne `wc -c <'gettbin.c'`; then
  2154.     echo shar: \"'gettbin.c'\" unpacked with wrong size!
  2155. fi
  2156. # end of 'gettbin.c'
  2157. fi
  2158. if test -f 'mkbinorder.c' -a "${1}" != "-c" ; then 
  2159.   echo shar: Will not clobber existing file \"'mkbinorder.c'\"
  2160. else
  2161. echo shar: Extracting \"'mkbinorder.c'\" \(1960 characters\)
  2162. sed "s/^X//" >'mkbinorder.c' <<'END_OF_FILE'
  2163. X/*
  2164. X * mkbinorder.c
  2165. X *
  2166. X * By Ross Ridge
  2167. X * Public Domain
  2168. X * 92/02/01 07:30:04
  2169. X *
  2170. X */
  2171. X
  2172. X#define NOTLIB
  2173. X#include "defs.h"
  2174. X#include "term.h"
  2175. X
  2176. static const char SCCSid[] = "@(#) mytinfo mkbinorder.c 3.2 92/02/01 public domain, By Ross Ridge";
  2177. X
  2178. char cap[MAX_NAME];
  2179. char *p2c = cap;
  2180. char **p2p2c = &p2c;
  2181. X
  2182. int
  2183. main(argc, argv)
  2184. int argc;
  2185. char **argv; {
  2186. X    int r;
  2187. X    int ind;
  2188. X    FILE *f;
  2189. X
  2190. X    if (argc == 1)
  2191. X        f = stdin;
  2192. X    else if (argc == 2) {
  2193. X        f = fopen(argv[1], "r");
  2194. X        if (f == NULL) {
  2195. X            fprintf(stderr, "can't open %s\n", argv[1]);
  2196. X            exit(1);
  2197. X        }
  2198. X    } else {
  2199. X        fprintf(stderr, "argument count\n");
  2200. X        exit(1);
  2201. X    }
  2202. X
  2203. X    do {
  2204. X        r = fscanf(f, "%s", cap);
  2205. X    } while(r == 1 && strcmp(cap, "!") != 0);
  2206. X    if (r != 1) {
  2207. X        fprintf(stderr, "expected '!'\n");
  2208. X        exit(1);
  2209. X    }
  2210. X
  2211. X    puts("/*");
  2212. X    puts(" * binorder.c");
  2213. X    puts(" *");
  2214. X    puts(" * This file was generated automatically");
  2215. X    puts(" *");
  2216. X    puts(" */\n");
  2217. X
  2218. X    puts("int _boolorder[] = {");
  2219. X
  2220. X    while(1) {
  2221. X        r = fscanf(f, "%s", cap);
  2222. X        cap[MAX_TINFONAME] = '\0';
  2223. X        if (r != 1) {
  2224. X            fprintf(stderr, "unexpected EOF\n");
  2225. X            exit(1);
  2226. X        }
  2227. X        if (strcmp(cap, "#") == 0)
  2228. X            break;
  2229. X        ind = _findboolname(cap);
  2230. X        if (ind == -1) {
  2231. X            fprintf(stderr, "unknown bool name '%s'\n", cap);
  2232. X            continue;
  2233. X        }
  2234. X        printf("\t%d,\n", ind);
  2235. X    }
  2236. X    puts("\t-1");
  2237. X    puts("};\n");
  2238. X
  2239. X    puts("int _numorder[] = {");
  2240. X
  2241. X    while(1) {
  2242. X        r = fscanf(f, "%s", cap);
  2243. X        cap[MAX_TINFONAME] = '\0';
  2244. X        if (r != 1) {
  2245. X            fprintf(stderr, "unexpected EOF\n");
  2246. X            exit(1);
  2247. X        }
  2248. X        if (strcmp(cap, "$") == 0)
  2249. X            break;
  2250. X        ind = _findnumname(cap);
  2251. X        if (ind == -1) {
  2252. X            fprintf(stderr, "unknown num name '%s'\n", cap);
  2253. X            continue;
  2254. X        }
  2255. X        printf("\t%d,\n", ind);
  2256. X    }
  2257. X    puts("\t-1");
  2258. X    puts("};\n");
  2259. X
  2260. X    puts("int _strorder[] = {");
  2261. X
  2262. X    while(1) {
  2263. X        r = fscanf(f, "%s", cap);
  2264. X        cap[MAX_TINFONAME] = '\0';
  2265. X        if (r != 1)
  2266. X            break;
  2267. X        ind = _findstrname(cap);
  2268. X        if (ind == -1) {
  2269. X            fprintf(stderr, "unknown str name '%s'\n", cap);
  2270. X            continue;
  2271. X        }
  2272. X        printf("\t%d,\n", ind);
  2273. X    }
  2274. X    puts("\t-1");
  2275. X    puts("};\n");
  2276. X
  2277. X    return 0;
  2278. X}
  2279. END_OF_FILE
  2280. if test 1960 -ne `wc -c <'mkbinorder.c'`; then
  2281.     echo shar: \"'mkbinorder.c'\" unpacked with wrong size!
  2282. fi
  2283. # end of 'mkbinorder.c'
  2284. fi
  2285. if test -f 'mkcaplist.c' -a "${1}" != "-c" ; then 
  2286.   echo shar: Will not clobber existing file \"'mkcaplist.c'\"
  2287. else
  2288. echo shar: Extracting \"'mkcaplist.c'\" \(3333 characters\)
  2289. sed "s/^X//" >'mkcaplist.c' <<'END_OF_FILE'
  2290. X/*
  2291. X * mkcaplist.c
  2292. X *
  2293. X * By Ross Ridge
  2294. X * Public Domain
  2295. X * 92/02/01 07:30:05
  2296. X *
  2297. X * mkcaplist [-n caps] [file]
  2298. X *
  2299. X * makes caplist.c from the cap_list file
  2300. X *
  2301. X */
  2302. X
  2303. X#define NOTLIB
  2304. X#include "defs.h"
  2305. X
  2306. static const char SCCSid[] = "@(#) mytinfo mkcaplist.c 3.2 92/02/01 public domain, By Ross Ridge";
  2307. X
  2308. X#define DEFAULT_CAPS    1000
  2309. X
  2310. struct caplist *list;
  2311. X
  2312. int
  2313. main(argc, argv)
  2314. int argc;
  2315. char **argv; {
  2316. X    FILE *f;
  2317. X    int caps = DEFAULT_CAPS;
  2318. X    int n;
  2319. X    register int i;
  2320. X
  2321. X    if (argc > 2 && argv[1][0] == '-' && argv[1][1] == 'n') {
  2322. X        caps = atoi(argv[2]);
  2323. X        argv += 2;
  2324. X        argc -= 2;
  2325. X    }
  2326. X
  2327. X    if (argc == 1) {
  2328. X        f = stdin;
  2329. X    } else if (argc == 2) {
  2330. X        f = fopen(argv[1], "r");
  2331. X        if (f == NULL) {
  2332. X            fprintf(stderr, "%s: can't open '%s'\n", argv[0],
  2333. X                argv[1]);
  2334. X            return 1;
  2335. X        }
  2336. X    } else {
  2337. X        fprintf(stderr, "%s: too many arguments\n", argv[0]);
  2338. X        fprintf(stderr, "usage: %s [-n caps] [file]\n", argv[0]);
  2339. X        return 1;
  2340. X    }
  2341. X
  2342. X    list = (struct caplist *) malloc(caps * sizeof(struct caplist));
  2343. X    if (list == NULL) {
  2344. X        fprintf(stderr, "%s: malloc failed.\n", argv[0]);
  2345. X        return 1;
  2346. X    }
  2347. X
  2348. X    n = readcaps(f, list, caps);
  2349. X    if (n > caps) {
  2350. X        fprintf(stderr, "%s: too many caps, use -n.\n", argv[0]);
  2351. X        return 1;
  2352. X    }
  2353. X    if (n == 0) {
  2354. X        fprintf(stderr, "%s: no caps in file.\n", argv[0]);
  2355. X        return 1;
  2356. X    }
  2357. X    if (n == -1) {
  2358. X        fprintf(stderr, "%s: bad caps line.\n", argv[0]);
  2359. X        return 1;
  2360. X    }
  2361. X    if (n == -2) {
  2362. X        fprintf(stderr, "%s: unexpected EOF.\n", argv[0]);
  2363. X        return 1;
  2364. X    }
  2365. X
  2366. X    puts("/*");
  2367. X    puts(" * caplist.c ");
  2368. X    puts(" *");
  2369. X    puts(" * This file was generated automatically.");
  2370. X    puts(" *");
  2371. X    puts(" */");
  2372. X    putchar('\n');
  2373. X
  2374. X    puts("char *boolnames[] = {");
  2375. X    for (i = 0; i < n; i++)
  2376. X        if (list[i].type == '!')
  2377. X            printf("\t\"%s\",\n", list[i].tinfo);
  2378. X    puts("\t(char *)0");
  2379. X    puts("};");
  2380. X    putchar('\n');
  2381. X
  2382. X    puts("char *boolcodes[] = {");
  2383. X    for (i = 0; i < n; i++)
  2384. X        if (list[i].type == '!')
  2385. X            printf("\t\"%s\",\n", list[i].tcap);
  2386. X    puts("\t(char *)0");
  2387. X    puts("};");
  2388. X    putchar('\n');
  2389. X
  2390. X    puts("char *boolfnames[] = {");
  2391. X    for (i = 0; i < n; i++)
  2392. X        if (list[i].type == '!')
  2393. X            printf("\t\"%s\",\n", list[i].var);
  2394. X    puts("\t(char *)0");
  2395. X    puts("};");
  2396. X    putchar('\n');
  2397. X
  2398. X    puts("char *numnames[] = {");
  2399. X    for (i = 0; i < n; i++)
  2400. X        if (list[i].type == '#')
  2401. X            printf("\t\"%s\",\n", list[i].tinfo);
  2402. X    puts("\t(char *)0");
  2403. X    puts("};");
  2404. X    putchar('\n');
  2405. X
  2406. X    puts("char *numcodes[] = {");
  2407. X    for (i = 0; i < n; i++)
  2408. X        if (list[i].type == '#')
  2409. X            printf("\t\"%s\",\n", list[i].tcap);
  2410. X    puts("\t(char *)0");
  2411. X    puts("};");
  2412. X    putchar('\n');
  2413. X
  2414. X    puts("char *numfnames[] = {");
  2415. X    for (i = 0; i < n; i++)
  2416. X        if (list[i].type == '#')
  2417. X            printf("\t\"%s\",\n", list[i].var);
  2418. X    puts("\t(char *)0");
  2419. X    puts("};");
  2420. X    putchar('\n');
  2421. X
  2422. X    puts("char *strnames[] = {");
  2423. X    for (i = 0; i < n; i++)
  2424. X        if (list[i].type == '$')
  2425. X            printf("\t\"%s\",\n", list[i].tinfo);
  2426. X    puts("\t(char *)0");
  2427. X    puts("};");
  2428. X    putchar('\n');
  2429. X
  2430. X    puts("char *strcodes[] = {");
  2431. X    for (i = 0; i < n; i++)
  2432. X        if (list[i].type == '$')
  2433. X            printf("\t\"%s\",\n", list[i].tcap);
  2434. X    puts("\t(char *)0");
  2435. X    puts("};");
  2436. X    putchar('\n');
  2437. X
  2438. X    puts("char *strfnames[] = {");
  2439. X    for (i = 0; i < n; i++)
  2440. X        if (list[i].type == '$')
  2441. X            printf("\t\"%s\",\n", list[i].var);
  2442. X    puts("\t(char *)0");
  2443. X    puts("};");
  2444. X    putchar('\n');
  2445. X
  2446. X    puts("char _strflags[] = {");
  2447. X    for (i = 0; i < n; i++)
  2448. X        if (list[i].type == '$')
  2449. X            printf("\t'%c',\n", list[i].flag);
  2450. X    puts("\t'\\0'");
  2451. X    puts("};");
  2452. X    putchar('\n');
  2453. X
  2454. X    return 0;
  2455. X}
  2456. END_OF_FILE
  2457. if test 3333 -ne `wc -c <'mkcaplist.c'`; then
  2458.     echo shar: \"'mkcaplist.c'\" unpacked with wrong size!
  2459. fi
  2460. # end of 'mkcaplist.c'
  2461. fi
  2462. if test -f 'mkcapsort.c' -a "${1}" != "-c" ; then 
  2463.   echo shar: Will not clobber existing file \"'mkcapsort.c'\"
  2464. else
  2465. echo shar: Extracting \"'mkcapsort.c'\" \(3687 characters\)
  2466. sed "s/^X//" >'mkcapsort.c' <<'END_OF_FILE'
  2467. X/*
  2468. X * mkcapsort.c
  2469. X *
  2470. X * By Ross Ridge
  2471. X * Public Domain
  2472. X * 92/06/04 11:38:02
  2473. X *
  2474. X * mkcapsort
  2475. X *
  2476. X * make the sorted lists of pointers to strins
  2477. X *
  2478. X */
  2479. X
  2480. X#define NOTLIB
  2481. X#include "defs.h"
  2482. X#include "term.h"
  2483. X
  2484. X#ifdef USE_MYQSORT
  2485. X#include "qsort.c"
  2486. X#endif
  2487. X
  2488. static const char SCCSid[] = "@(#) mytinfo mkcapsort.c 3.3 92/06/04 public domain, By Ross Ridge";
  2489. X
  2490. char **sboolnames[NUM_OF_BOOLS], **sboolcodes[NUM_OF_BOOLS], **sboolfnames[NUM_OF_BOOLS];
  2491. char **snumnames[NUM_OF_NUMS], **snumcodes[NUM_OF_NUMS], **snumfnames[NUM_OF_NUMS];
  2492. char **sstrnames[NUM_OF_STRS], **sstrcodes[NUM_OF_STRS], **sstrfnames[NUM_OF_STRS];
  2493. X
  2494. X
  2495. int
  2496. main() {
  2497. X    register int i;
  2498. X    
  2499. X    i = NUM_OF_BOOLS;
  2500. X    while(i) {
  2501. X        i--;
  2502. X        sboolnames[i] = &boolnames[i];
  2503. X        sboolcodes[i] = &boolcodes[i];
  2504. X        sboolfnames[i] = &boolfnames[i];
  2505. X    }
  2506. X    
  2507. X    i = NUM_OF_NUMS;
  2508. X    while(i) {
  2509. X        i--;
  2510. X        snumnames[i] = &numnames[i];
  2511. X        snumcodes[i] = &numcodes[i];
  2512. X        snumfnames[i] = &numfnames[i];
  2513. X    }
  2514. X
  2515. X    i = NUM_OF_STRS;
  2516. X    while(i) {
  2517. X        i--;
  2518. X        sstrnames[i] = &strnames[i];
  2519. X        sstrcodes[i] = &strcodes[i];
  2520. X        sstrfnames[i] = &strfnames[i];
  2521. X    }
  2522. X
  2523. X    qsort((anyptr) sboolnames, NUM_OF_BOOLS, sizeof(*sboolnames), _compar);
  2524. X    qsort((anyptr) sboolcodes, NUM_OF_BOOLS, sizeof(*sboolcodes), _compar);
  2525. X    qsort((anyptr) sboolfnames, NUM_OF_BOOLS, sizeof(*sboolfnames),_compar);
  2526. X    qsort((anyptr) snumnames, NUM_OF_NUMS, sizeof(*snumnames), _compar);
  2527. X    qsort((anyptr) snumcodes, NUM_OF_NUMS, sizeof(*snumcodes), _compar);
  2528. X    qsort((anyptr) snumfnames, NUM_OF_NUMS, sizeof(*snumfnames), _compar);
  2529. X    qsort((anyptr) sstrnames, NUM_OF_STRS, sizeof(*sstrnames), _compar);
  2530. X    qsort((anyptr) sstrcodes, NUM_OF_STRS, sizeof(*sstrcodes), _compar);
  2531. X    qsort((anyptr) sstrfnames, NUM_OF_STRS, sizeof(*sstrfnames), _compar);
  2532. X
  2533. X    printf("/*\n");
  2534. X    printf(" * capsort.c\n");
  2535. X    printf(" *\n");
  2536. X    printf(" * This file was generated automatically.\n");
  2537. X    printf(" *\n");
  2538. X    printf(" */\n\n");
  2539. X
  2540. X    puts("extern char *boolnames[], *boolcodes[], *boolfnames[];");
  2541. X    puts("extern char *numnames[], *numcodes[], *numfnames[];");
  2542. X    puts("extern char *strnames[], *strcodes[], *strfnames[];");
  2543. X    putchar('\n');
  2544. X
  2545. X    printf("char **_sboolnames[] = {\n");
  2546. X    for(i = 0; i < NUM_OF_BOOLS; i++)
  2547. X        printf("\tboolnames + %d,\n", sboolnames[i] - boolnames);
  2548. X    printf("    (char **) 0\n");
  2549. X    printf("};\n\n");
  2550. X
  2551. X    printf("char **_sboolcodes[] = {\n");
  2552. X    for(i = 0; i < NUM_OF_BOOLS; i++)
  2553. X        printf("\tboolcodes + %d,\n", sboolcodes[i] - boolcodes);
  2554. X    printf("    (char **) 0\n");
  2555. X    printf("};\n\n");
  2556. X
  2557. X    printf("char **_sboolfnames[] = {\n");
  2558. X    for(i = 0; i < NUM_OF_BOOLS; i++)
  2559. X        printf("\tboolfnames + %d,\n", sboolfnames[i] - boolfnames);
  2560. X    printf("    (char **) 0\n");
  2561. X    printf("};\n\n");
  2562. X
  2563. X    printf("char **_snumnames[] = {\n");
  2564. X    for(i = 0; i < NUM_OF_NUMS; i++)
  2565. X        printf("\tnumnames + %d,\n", snumnames[i] - numnames);
  2566. X    printf("    (char **) 0\n");
  2567. X    printf("};\n\n");
  2568. X
  2569. X    printf("char **_snumcodes[] = {\n");
  2570. X    for(i = 0; i < NUM_OF_NUMS; i++)
  2571. X        printf("\tnumcodes + %d,\n", snumcodes[i] - numcodes);
  2572. X    printf("    (char **) 0\n");
  2573. X    printf("};\n\n");
  2574. X
  2575. X    printf("char **_snumfnames[] = {\n");
  2576. X    for(i = 0; i < NUM_OF_NUMS; i++)
  2577. X        printf("\tnumfnames + %d,\n", snumfnames[i] - numfnames);
  2578. X    printf("    (char **) 0\n");
  2579. X    printf("};\n\n");
  2580. X
  2581. X    printf("char **_sstrnames[] = {\n");
  2582. X    for(i = 0; i < NUM_OF_STRS; i++)
  2583. X        printf("\tstrnames + %d,\n", sstrnames[i] - strnames);
  2584. X    printf("    (char **) 0\n");
  2585. X    printf("};\n\n");
  2586. X
  2587. X    printf("char **_sstrcodes[] = {\n");
  2588. X    for(i = 0; i < NUM_OF_STRS; i++) 
  2589. X        printf("\tstrcodes + %d,\n", sstrcodes[i] - strcodes);
  2590. X    printf("    (char **) 0\n");
  2591. X    printf("};\n\n");
  2592. X
  2593. X    printf("char **_sstrfnames[] = {\n");
  2594. X    for(i = 0; i < NUM_OF_STRS; i++)
  2595. X        printf("\tstrfnames + %d,\n", sstrfnames[i] - strfnames);
  2596. X    printf("    (char **) 0\n");
  2597. X    printf("};\n\n");
  2598. X
  2599. X    return 0;
  2600. X}
  2601. END_OF_FILE
  2602. if test 3687 -ne `wc -c <'mkcapsort.c'`; then
  2603.     echo shar: \"'mkcapsort.c'\" unpacked with wrong size!
  2604. fi
  2605. # end of 'mkcapsort.c'
  2606. fi
  2607. if test -f 'mkdir.c' -a "${1}" != "-c" ; then 
  2608.   echo shar: Will not clobber existing file \"'mkdir.c'\"
  2609. else
  2610. echo shar: Extracting \"'mkdir.c'\" \(570 characters\)
  2611. sed "s/^X//" >'mkdir.c' <<'END_OF_FILE'
  2612. X/*
  2613. X * mkdir.c
  2614. X *
  2615. X * By Ross Ridge
  2616. X * Public Domain
  2617. X * 92/06/04 11:38:33
  2618. X */
  2619. X
  2620. X#ifdef USE_MYMKDIR
  2621. X
  2622. X#define MKDIR_COMMAND "/bin/mkdir"
  2623. X
  2624. X#ifdef USE_SCCS_IDS
  2625. static char const SCCSid[] = "@(#) mytinfo mkdir.c 3.2 92/06/04 public domain, By Ross Ridge";
  2626. X#endif
  2627. X
  2628. static int
  2629. mkdir(name, perms) 
  2630. char *name;
  2631. int perms; {
  2632. X    static const char cmd[] = MKDIR_COMMAND;
  2633. X    char *s;
  2634. X
  2635. X    s = malloc(strlen(name) + sizeof(cmd) + 1);
  2636. X    if (s == NULL) {
  2637. X        return -1;
  2638. X    }
  2639. X    sprintf(s, "%s %s", cmd, name);
  2640. X    if (system(s)) {
  2641. X        free(s);
  2642. X        return -1;
  2643. X    }
  2644. X    free(s);
  2645. X    return chmod(name, perms);
  2646. X}
  2647. X
  2648. X#endif
  2649. END_OF_FILE
  2650. if test 570 -ne `wc -c <'mkdir.c'`; then
  2651.     echo shar: \"'mkdir.c'\" unpacked with wrong size!
  2652. fi
  2653. # end of 'mkdir.c'
  2654. fi
  2655. if test -f 'mktermhead.c' -a "${1}" != "-c" ; then 
  2656.   echo shar: Will not clobber existing file \"'mktermhead.c'\"
  2657. else
  2658. echo shar: Extracting \"'mktermhead.c'\" \(2916 characters\)
  2659. sed "s/^X//" >'mktermhead.c' <<'END_OF_FILE'
  2660. X/*
  2661. X * mktermhead.c
  2662. X *
  2663. X * By Ross Ridge
  2664. X * Public Domain 
  2665. X * 92/06/04 11:38:57
  2666. X *
  2667. X * mktermhead [-n caps] file
  2668. X *
  2669. X * generates term.head
  2670. X *
  2671. X */
  2672. X
  2673. X#define NOTLIB
  2674. X#include "defs.h"
  2675. X
  2676. static const char SCCSid[] = "@(#) mytinfo mktermhead.c 3.3 92/06/04 public domain, By Ross Ridge";
  2677. X
  2678. X#define DEFAULT_CAPS    1000
  2679. X
  2680. X
  2681. int
  2682. main(argc, argv)
  2683. int argc;
  2684. char **argv; {
  2685. X    FILE *f;
  2686. X    int caps = DEFAULT_CAPS;
  2687. X    int n;
  2688. X    register int i;
  2689. X    int nb, ns, nn;
  2690. X    struct caplist *list;
  2691. X
  2692. X    if (argc > 2 && argv[1][0] == '-' && argv[1][1] == 'n') {
  2693. X        caps = atoi(argv[2]);
  2694. X        argv += 2;
  2695. X        argc -= 2;
  2696. X    }
  2697. X
  2698. X    if (argc == 1) {
  2699. X        f = stdin;
  2700. X    } else if (argc == 2) {
  2701. X        f = fopen(argv[1], "r");
  2702. X        if (f == NULL) {
  2703. X            fprintf(stderr, "%s: can't open '%s'\n", argv[0],
  2704. X                argv[1]);
  2705. X            return 1;
  2706. X        }
  2707. X    } else {
  2708. X        fprintf(stderr, "%s: too many arguments\n", argv[0]);
  2709. X        fprintf(stderr, "usage: %s [-n caps] [file]\n", argv[0]);
  2710. X        return 1;
  2711. X    }
  2712. X
  2713. X    list = (struct caplist *) malloc(caps * sizeof(struct caplist));
  2714. X    if (list == NULL) {
  2715. X        fprintf(stderr, "%s: malloc failed.\n", argv[0]);
  2716. X        return 1;
  2717. X    }
  2718. X
  2719. X    n = readcaps(f, list, caps);
  2720. X    if (n > caps) {
  2721. X        fprintf(stderr, "%s: too many caps, use -n.\n", argv[0]);
  2722. X        return 1;
  2723. X    }
  2724. X    switch(n) {
  2725. X    case 0:
  2726. X        fprintf(stderr, "%s: no caps in file.\n", argv[0]);
  2727. X        return 1;
  2728. X    case -1:
  2729. X        fprintf(stderr, "%s: bad caps line.\n", argv[0]);
  2730. X        return 1;
  2731. X    case -2:
  2732. X        fprintf(stderr, "%s: unexpected EOF.\n", argv[0]);
  2733. X        return 1;
  2734. X    }
  2735. X
  2736. X    puts("/*");
  2737. X    puts(" * term.h ");
  2738. X    puts(" *");
  2739. X    puts(" * This file was generated automatically.");
  2740. X    puts(" *");
  2741. X    puts(" */");
  2742. X    putchar('\n');
  2743. X    puts("#ifndef _TERM_H_");
  2744. X    puts("#define _TERM_H_");
  2745. X    putchar('\n');
  2746. X    nb = 0;
  2747. X    for (i = 0; i < n; i++) {
  2748. X        if (list[i].type == '!') {
  2749. X            printf("#define %-*s (_CUR_TERM.bools[%d])\n",
  2750. X                   MAX_VARNAME, list[i].var, nb);
  2751. X            nb++;
  2752. X        }
  2753. X    }
  2754. X
  2755. X    nn = 0;
  2756. X    for (i = 0; i < n; i++) {
  2757. X        if (list[i].type == '#') {
  2758. X            printf("#define %-*s (_CUR_TERM.nums[%d])\n",
  2759. X                   MAX_VARNAME, list[i].var, nn);
  2760. X            nn++;
  2761. X        }
  2762. X    }
  2763. X
  2764. X    ns = 0;
  2765. X    for (i = 0; i < n; i++) {
  2766. X        if (list[i].type == '$') {
  2767. X            printf("#define %-*s (_CUR_TERM.strs[%d])\n",
  2768. X                   MAX_VARNAME, list[i].var, ns);
  2769. X            ns++;
  2770. X        }
  2771. X    }
  2772. X
  2773. X    putchar('\n');
  2774. X
  2775. X    printf ("#define NUM_OF_BOOLS\t%d\n", nb);
  2776. X    printf ("#define NUM_OF_NUMS\t%d\n", nn);
  2777. X    printf ("#define NUM_OF_STRS\t%d\n", ns);
  2778. X
  2779. X    putchar('\n');
  2780. X    puts("#ifndef OVERRIDE");
  2781. X    puts("#undef _USE_SGTTY");
  2782. X#ifdef USE_SGTTY
  2783. X    puts("#define _USE_SGTTY");
  2784. X#endif
  2785. X    puts("#undef _USE_TERMIO");
  2786. X#ifdef USE_TERMIO
  2787. X    puts("#define _USE_TERMIO");
  2788. X#endif
  2789. X    puts("#undef _USE_SMALLMEM");
  2790. X#ifdef USE_SMALLMEM
  2791. X    puts("#define _USE_SMALLMEM");
  2792. X#endif
  2793. X#if 0
  2794. X    puts("#undef _USE_PROTOTYPES");
  2795. X#ifdef USE_PROTOTYPES
  2796. X    puts("#define _USE_PROTOTYPES");
  2797. X#endif
  2798. X#endif
  2799. X    puts("#undef _USE_WINSZ");
  2800. X#ifdef USE_WINSZ
  2801. X    puts("#define _USE_WINSZ");
  2802. X#endif
  2803. X    puts("#undef _MAX_CHUNK");
  2804. X    printf("#define _MAX_CHUNK %d\n", MAX_CHUNK);
  2805. X    puts("#endif /* OVERRIDE */");
  2806. X    putchar('\n');
  2807. X
  2808. X    return 0;
  2809. X}
  2810. END_OF_FILE
  2811. if test 2916 -ne `wc -c <'mktermhead.c'`; then
  2812.     echo shar: \"'mktermhead.c'\" unpacked with wrong size!
  2813. fi
  2814. # end of 'mktermhead.c'
  2815. fi
  2816. if test -f 'mkversion.c' -a "${1}" != "-c" ; then 
  2817.   echo shar: Will not clobber existing file \"'mkversion.c'\"
  2818. else
  2819. echo shar: Extracting \"'mkversion.c'\" \(588 characters\)
  2820. sed "s/^X//" >'mkversion.c' <<'END_OF_FILE'
  2821. X/*
  2822. X * mkversion.c
  2823. X *
  2824. X * By Ross Ridge
  2825. X * Public Domain 
  2826. X * 92/02/01 07:30:09
  2827. X *
  2828. X * generates version.c
  2829. X *
  2830. X */
  2831. X
  2832. X#define NOTLIB
  2833. X#include "defs.h"
  2834. X
  2835. X#include "version.h"
  2836. X
  2837. static const char SCCSid[] = "@(#) mytinfo mkversion.c 3.2 92/02/01 public domain, By Ross Ridge";
  2838. X
  2839. int
  2840. main(argc, argv)
  2841. int argc;
  2842. char **argv; {
  2843. X    puts("/*");
  2844. X    puts(" * version.c ");
  2845. X    puts(" *");
  2846. X    puts(" * This file was generated automatically.");
  2847. X    puts(" *");
  2848. X    puts(" */");
  2849. X    putchar('\n');
  2850. X
  2851. X    printf("char _mytinfo_version[] = \"@(#) mytinfo: Release %d, Patchlevel %d.\";\n",
  2852. X           RELEASE, PATCHLEVEL);
  2853. X
  2854. X    return 0;
  2855. X}
  2856. END_OF_FILE
  2857. if test 588 -ne `wc -c <'mkversion.c'`; then
  2858.     echo shar: \"'mkversion.c'\" unpacked with wrong size!
  2859. fi
  2860. # end of 'mkversion.c'
  2861. fi
  2862. if test -f 'quit.c' -a "${1}" != "-c" ; then 
  2863.   echo shar: Will not clobber existing file \"'quit.c'\"
  2864. else
  2865. echo shar: Extracting \"'quit.c'\" \(1053 characters\)
  2866. sed "s/^X//" >'quit.c' <<'END_OF_FILE'
  2867. X/*
  2868. X * quit.c
  2869. X *
  2870. X * By Ross Ridge
  2871. X * Public Domain
  2872. X * 92/02/01 07:30:14
  2873. X *
  2874. X * quit with a diagnostic message printed on stderr
  2875. X *
  2876. X */
  2877. X
  2878. X#define NOTLIB
  2879. X#include "defs.h"
  2880. X
  2881. X#ifdef USE_SCCS_IDS
  2882. static const char SCCSid[] = "@(#) mytinfo quit.c 3.2 92/02/01 public domain, By Ross Ridge";
  2883. X#endif
  2884. X
  2885. char *prg_name;
  2886. X
  2887. X#if defined(USE_PROTOTYPES) && !defined(lint)
  2888. void (*cleanup)(int);
  2889. X#else
  2890. void (*cleanup)();
  2891. X#endif
  2892. X
  2893. X/* PRINTFLIKE2 */
  2894. X#ifdef USE_STDARG
  2895. X#ifdef USE_PROTOTYPES
  2896. void
  2897. quit(int e, char *fmt, ...)
  2898. X#else
  2899. void quit(e, fmt)
  2900. int e;
  2901. char *fmt;
  2902. X#endif
  2903. X#else
  2904. void quit(va_alist)
  2905. va_dcl
  2906. X#endif
  2907. X{
  2908. X#ifndef USE_STDARG
  2909. X    int e;
  2910. X    char *fmt;
  2911. X#endif
  2912. X    va_list ap;
  2913. X
  2914. X#ifdef USE_STDARG
  2915. X    va_start(ap, fmt);
  2916. X#else
  2917. X    va_start(ap);
  2918. X    e = va_arg(ap, int);
  2919. X    fmt = va_arg(ap, char *);
  2920. X#endif
  2921. X
  2922. X    (*cleanup)(e);
  2923. X
  2924. X    if (e != 0)
  2925. X        fprintf(stderr, "%s: ", prg_name);
  2926. X#ifdef USE_DOPRNT
  2927. X    _doprnt(fmt, ap, stderr);
  2928. X#else
  2929. X    vfprintf(stderr, fmt, ap);
  2930. X#endif
  2931. X    putc('\n', stderr);
  2932. X    if (e > 0 && e < sys_nerr) {
  2933. X        fprintf(stderr, "%d - %s\n", e, sys_errlist[e]);
  2934. X    }
  2935. X    fflush(stderr);
  2936. X    exit(e);
  2937. X}
  2938. END_OF_FILE
  2939. if test 1053 -ne `wc -c <'quit.c'`; then
  2940.     echo shar: \"'quit.c'\" unpacked with wrong size!
  2941. fi
  2942. # end of 'quit.c'
  2943. fi
  2944. if test -f 'readcaps.c' -a "${1}" != "-c" ; then 
  2945.   echo shar: Will not clobber existing file \"'readcaps.c'\"
  2946. else
  2947. echo shar: Extracting \"'readcaps.c'\" \(2264 characters\)
  2948. sed "s/^X//" >'readcaps.c' <<'END_OF_FILE'
  2949. X/*
  2950. X * readcaps.c
  2951. X *
  2952. X * By Ross Ridge
  2953. X * Public Domain
  2954. X * 92/02/01 07:30:15
  2955. X *
  2956. X * Read in the cap_list file
  2957. X *
  2958. X */
  2959. X
  2960. X#define NOTLIB
  2961. X#include "defs.h"
  2962. X
  2963. X#include <ctype.h>
  2964. X
  2965. X#ifdef USE_SCCS_IDS
  2966. static const char SCCSid[] = "@(#) mytinfo readcaps.c 3.2 92/02/01 public domain, By Ross Ridge";
  2967. X#endif
  2968. X
  2969. X#ifdef __GNUC__
  2970. X__inline__
  2971. X#endif
  2972. static int
  2973. skipline(f)
  2974. register FILE *f; {
  2975. X    register int c;
  2976. X
  2977. X    do {
  2978. X        c = getc(f);
  2979. X        if (c == EOF)
  2980. X            return EOF;
  2981. X#ifdef TEST
  2982. X        putchar(c);
  2983. X#endif
  2984. X    } while (c != '\n');
  2985. X
  2986. X    return 0;
  2987. X}
  2988. X
  2989. X#ifdef __GNUC__
  2990. X__inline__
  2991. X#endif
  2992. static int
  2993. getfield(f, s, len)
  2994. register FILE *f;
  2995. register char *s;
  2996. int len; {
  2997. X    register int c;
  2998. X    int i;
  2999. X#ifdef TEST
  3000. X    char *start = s;
  3001. X#endif
  3002. X
  3003. X    do {
  3004. X        c = getc(f);
  3005. X        if (c == EOF)
  3006. X            return EOF;
  3007. X    } while (c != '\n' && isspace(c));
  3008. X    if (c == '\n')
  3009. X        return 0;
  3010. X
  3011. X    i = 0;
  3012. X    while(!isspace(c)) {
  3013. X        if (i++ < len)
  3014. X            *s++ = c;
  3015. X        c = getc(f);
  3016. X        if (c == EOF)
  3017. X            return EOF;
  3018. X            
  3019. X    }
  3020. X    *s = '\0';
  3021. X#ifdef TEST
  3022. X    printf(" %s", start);
  3023. X#endif
  3024. X    return c;
  3025. X}
  3026. X
  3027. int
  3028. readcaps(f, buf, max)
  3029. XFILE *f;
  3030. register struct caplist *buf;
  3031. int max; {
  3032. X    int type;
  3033. X    register int count;
  3034. X    int c;
  3035. X    static char dummy;
  3036. X
  3037. X    count = 0;
  3038. X    type = getc(f);
  3039. X    while(type != EOF) {
  3040. X        if (type == '$' || type == '!' || type == '#') {
  3041. X            if (count >= max)
  3042. X                return count + 1;
  3043. X#ifdef TEST
  3044. X            putchar(type);
  3045. X#endif
  3046. X            buf[count].type = type;
  3047. X
  3048. X            if (type == '$') {
  3049. X                c = getc(f);
  3050. X                if (c == EOF)
  3051. X                    break;
  3052. X                if (c == 'G')
  3053. X                    buf[count].flag = 'G';
  3054. X                else if (c == 'K')
  3055. X                    buf[count].flag = 'K';
  3056. X                else
  3057. X                    buf[count].flag = ' ';
  3058. X            }
  3059. X    
  3060. X            c = getfield(f, buf[count].var, MAX_VARNAME);
  3061. X            if (c == EOF || c == '\n' || c == 0)
  3062. X                return -1;
  3063. X            c = getfield(f, buf[count].tinfo, MAX_TINFONAME);
  3064. X            if (c == EOF || c == '\n' || c == 0)
  3065. X                return -1;
  3066. X            c = getfield(f, buf[count].tcap, MAX_TCAPNAME);
  3067. X            if (c == EOF || c == 0)
  3068. X                return -1;
  3069. X            if (c != '\n')
  3070. X                if (getfield(f, &dummy, 1) != 0)
  3071. X                    return -1;
  3072. X            count++;
  3073. X#ifdef TEST
  3074. X            putchar('\n');
  3075. X#endif
  3076. X        } else {
  3077. X#ifdef TEST
  3078. X            putchar(type);
  3079. X#endif
  3080. X            if (type != '\n' && skipline(f) == EOF)
  3081. X                return -1;
  3082. X        }
  3083. X        type = getc(f);
  3084. X    }
  3085. X    return count;
  3086. X}
  3087. X
  3088. X#ifdef TEST
  3089. struct caplist list[1000];
  3090. X
  3091. int
  3092. main() {
  3093. X    int ret;
  3094. X
  3095. X    ret = readcaps(stdin, list, 1000);
  3096. X    printf("ret = %d\n", ret);
  3097. X    return 0;
  3098. X}
  3099. X#endif
  3100. END_OF_FILE
  3101. if test 2264 -ne `wc -c <'readcaps.c'`; then
  3102.     echo shar: \"'readcaps.c'\" unpacked with wrong size!
  3103. fi
  3104. # end of 'readcaps.c'
  3105. fi
  3106. if test -f 'strtok.c' -a "${1}" != "-c" ; then 
  3107.   echo shar: Will not clobber existing file \"'strtok.c'\"
  3108. else
  3109. echo shar: Extracting \"'strtok.c'\" \(1366 characters\)
  3110. sed "s/^X//" >'strtok.c' <<'END_OF_FILE'
  3111. X/*
  3112. X * strtok.c
  3113. X *
  3114. X * By Ross Ridge
  3115. X * Public Domain
  3116. X * 92/06/04 11:40:12
  3117. X *
  3118. X */
  3119. X
  3120. X#ifdef TEST
  3121. X
  3122. X#ifndef LIBTEST
  3123. X#define USE_MYSTRTOK
  3124. X#endif
  3125. X#include <stdio.h>
  3126. X
  3127. X#else
  3128. X
  3129. X#include "defs.h"
  3130. X
  3131. X#endif
  3132. X
  3133. X#ifdef USE_MYSTRTOK
  3134. X
  3135. X#ifdef USE_SCCS_IDS
  3136. static const char SCCSid[] = "@(#) mytinfo strtok.c 3.3 92/06/04 public domain, By Ross Ridge";
  3137. X#endif
  3138. X
  3139. static char *
  3140. strtok(s1, s2)
  3141. char *s1, *s2; {
  3142. X    static char *pos = NULL;
  3143. X    register char *s, *d;
  3144. X    char *start;
  3145. X
  3146. X    if (s1 == NULL) {
  3147. X        s = pos;
  3148. X        if (s == NULL)
  3149. X            return NULL;
  3150. X    } else {
  3151. X        s = s1;
  3152. X        while(*s != '\0') {
  3153. X            d = s2;
  3154. X            while(*d != *s) {
  3155. X                if (*d == '\0')
  3156. X                    goto first; /* Oh, no! A goto! */
  3157. X                d++;
  3158. X            }
  3159. X            s++;
  3160. X        }
  3161. X        pos = NULL;
  3162. X        return NULL;
  3163. X    }
  3164. X
  3165. first:
  3166. X    start = s;
  3167. X    while(*s != '\0') {
  3168. X        d = s2;
  3169. X        while(*d != '\0') {
  3170. X            if (*s == *d) {
  3171. X                *s++ = '\0';
  3172. X                while(*s != '\0') {
  3173. X                    d = s2;
  3174. X                    while(*s != *d) {
  3175. X                        if (*d == '\0') {
  3176. X                            pos = s;
  3177. X                            return start;
  3178. X                        }
  3179. X                        d++;
  3180. X                    }
  3181. X                    s++;
  3182. X                }
  3183. X                pos = NULL;
  3184. X                return start;
  3185. X            }
  3186. X            d++;
  3187. X        }
  3188. X        s++;
  3189. X    }
  3190. X    pos = NULL;
  3191. X    return start;
  3192. X}
  3193. X
  3194. X#endif
  3195. X
  3196. X#ifdef TEST
  3197. int main(argc, argv)
  3198. int argc;
  3199. char **argv; {
  3200. X    char *s;
  3201. X    char s1[100];
  3202. X    char *s2;
  3203. X
  3204. X    if (argc > 1)
  3205. X        s2 = argv[1];
  3206. X    else
  3207. X        s2 = " ";
  3208. X
  3209. X    while (gets(s1) != NULL) {
  3210. X        s = strtok(s1, s2);
  3211. X        while(s != NULL) {
  3212. X            printf("'%s'\n", s);
  3213. X            s = strtok(NULL, s2);
  3214. X        }
  3215. X    }
  3216. X
  3217. X    return 0;
  3218. X}
  3219. X#endif
  3220. END_OF_FILE
  3221. if test 1366 -ne `wc -c <'strtok.c'`; then
  3222.     echo shar: \"'strtok.c'\" unpacked with wrong size!
  3223. fi
  3224. # end of 'strtok.c'
  3225. fi
  3226. if test -f 'tcapvars.c' -a "${1}" != "-c" ; then 
  3227.   echo shar: Will not clobber existing file \"'tcapvars.c'\"
  3228. else
  3229. echo shar: Extracting \"'tcapvars.c'\" \(524 characters\)
  3230. sed "s/^X//" >'tcapvars.c' <<'END_OF_FILE'
  3231. X/*
  3232. X * tcapvars.c
  3233. X *
  3234. X * By Ross Ridge
  3235. X * Public Domain
  3236. X * 92/02/01 07:30:21
  3237. X *
  3238. X */
  3239. X
  3240. X#include "defs.h"
  3241. X#include "term.h"
  3242. X
  3243. X#ifdef USE_SCCS_IDS
  3244. static const char SCCSid[] = "@(#) mytinfo tcapvars.c 3.2 92/02/01 public domain, By Ross Ridge";
  3245. X#endif
  3246. X
  3247. char PC;
  3248. short ospeed;
  3249. char *UP, *BC;
  3250. X
  3251. void
  3252. X_figure_termcap() {
  3253. X#if defined(USE_SGTTY) || defined(USE_TERMIO)
  3254. X#ifdef USE_SMALLMEM
  3255. X    extern unsigned short _baud_tbl[];
  3256. X#else
  3257. X    extern long _baud_tbl[];
  3258. X#endif
  3259. X    cur_term->padch = PC;
  3260. X    cur_term->baudrate = _baud_tbl[ospeed];
  3261. X#endif
  3262. X}
  3263. END_OF_FILE
  3264. if test 524 -ne `wc -c <'tcapvars.c'`; then
  3265.     echo shar: \"'tcapvars.c'\" unpacked with wrong size!
  3266. fi
  3267. # end of 'tcapvars.c'
  3268. fi
  3269. if test -f 'tconv.1' -a "${1}" != "-c" ; then 
  3270.   echo shar: Will not clobber existing file \"'tconv.1'\"
  3271. else
  3272. echo shar: Extracting \"'tconv.1'\" \(3823 characters\)
  3273. sed "s/^X//" >'tconv.1' <<'END_OF_FILE'
  3274. X.\" @(#) mytinfo tconv.1 3.2 92/02/01 public domain, By Ross Ridge
  3275. X.TH CONV 1 "92/02/01" "tinfo"
  3276. X.SH NAME
  3277. tconv \- convert between termcap, terminfo source and terminfo binary
  3278. X.SH SYNOPSIS
  3279. X.B tconv
  3280. X[\fB\-b\fR]
  3281. X[\fB\-c\fR\ [\fB\-OUGd\fR]]
  3282. X[\fB\-i\fR]
  3283. X[\fB\-B\fR\ [\fB\-D\fR\ dir]]
  3284. X[\fB\-I\fR]
  3285. X[\fB\-k\fR]
  3286. X[\fB\-V\fR]
  3287. X[\fB\-t\fR\ term]
  3288. X[file]
  3289. X.br
  3290. X.B tic
  3291. X[file]
  3292. X.br
  3293. X.B cap2info
  3294. X[\fB\-t\fR\ term]
  3295. X[\fB\-OUGdk\fR]]
  3296. X[file]
  3297. X.SH DESCRIPTION
  3298. X.I tconv
  3299. converts between the three terminal descriptions,
  3300. termcap, terminfo source, and terminfo binary,
  3301. that the
  3302. X.I tinfo
  3303. library uses.
  3304. It performs the same functions of
  3305. X.IR captoinfo (1M)
  3306. and 
  3307. X.IR tic (1M)
  3308. of System V.
  3309. It also can be used to generate a terminfo source listing from a terminfo
  3310. binary, one of the functions of System V's
  3311. X.IR infocmp (1M).
  3312. X.SS Translation Options
  3313. X.PD 0
  3314. X.TP
  3315. X.B \-c
  3316. convert from termcap
  3317. X.TP
  3318. X.B \-i
  3319. convert from terminfo source
  3320. X.TP
  3321. X.B \-b
  3322. convert from terminfo binary
  3323. X.TP
  3324. X.B \-B
  3325. convert to terminfo binary
  3326. X.TP
  3327. X.B \-I
  3328. convert to terminfo source
  3329. X.PD
  3330. X.PP
  3331. If a file is specified, one of
  3332. X.B \-c
  3333. or
  3334. X.B \-i
  3335. must specified and the whole file while be translated.
  3336. If no file is specified then the input options will only restrict looking
  3337. for the terminal to be translated in places likely have descriptions
  3338. of the desired type
  3339. X(ie. with the
  3340. X.B -c
  3341. option in the
  3342. X.B TERMCAP
  3343. environment variable, and in
  3344. X.IR /etc/termcap ,
  3345. with the
  3346. X.B -i
  3347. option in the
  3348. X.B TERMINFO
  3349. environment variable, and in
  3350. X.IR /usr/lib/terminfo ),
  3351. otherwise
  3352. X.I tconv
  3353. will look in all available databases.
  3354. If neither 
  3355. X.B \-I
  3356. or
  3357. X.B \-B
  3358. are given the
  3359. X.B \-I
  3360. option will be assumed.
  3361. If the 
  3362. X.B \-B
  3363. option is used, the compiled output will be put in the the
  3364. terminfo database, otherwise standard output is used.
  3365. X.PP
  3366. You cannot translate from terminfo binary to terminfo binary.
  3367. Translating from terminfo source to terminfo source is possible, 
  3368. but not of much use in most cases, as 
  3369. X.B use=
  3370. fields will be followed and incorporated into the output terminal
  3371. description. 
  3372. X.PP
  3373. X.I tconv
  3374. should be able translate all standard termcap parameterized strings
  3375. terminfo format, but complex strings using GNU's %a code may be
  3376. too hard to translate.
  3377. If
  3378. X.I tconv
  3379. thinks a termcap string is already in terminfo format (if a %p
  3380. code appears in the string), it won't try to translate it.
  3381. String capabilities that don't take parameters won't be translated.
  3382. X.PP
  3383. X.B 
  3384. X.SS Termcap options
  3385. The following options are available when translating termcap entries 
  3386. X(\fB\-c\fR options is used).
  3387. X.PP
  3388. X.PD 0
  3389. X.TP 
  3390. X.B \-d
  3391. don't supply any defaults for missing capabilities
  3392. X.TP
  3393. X.B \-O
  3394. include obsolete termcap capabilities
  3395. X.TP
  3396. X.B \-G
  3397. include GNU capabilities
  3398. X.TP
  3399. X.B \-U
  3400. include UW capabilities
  3401. X.PD
  3402. X.SS Other Options
  3403. X.PD 0
  3404. X.TP
  3405. X.B \-k
  3406. keep comments when translating a file
  3407. X.TP
  3408. X.B \-V
  3409. print version information and exit
  3410. X.TP
  3411. X.BI \-D " " dir
  3412. directory to put terminfo binaries in
  3413. X.TP
  3414. X.BI \-t " " term
  3415. terminal name to translate
  3416. X.PD
  3417. X.PP
  3418. If no terminal specified with the
  3419. X.B \-t
  3420. option, then the terminal name to to translate will be taken from the
  3421. environment variable
  3422. X.BR TERM .
  3423. X.SH FILES
  3424. X.PD 0
  3425. X.TP 2i
  3426. X.B /usr/lib/terminfo
  3427. The default location to get and put terminfo binaries.
  3428. X.TP
  3429. X.B /usr/lib/terminfo/terminfo.src
  3430. The default filename of the terminfo source file.
  3431. X.TP
  3432. X.B /etc/termcap
  3433. The default filename of the termcap database.
  3434. X.PD
  3435. X.SH "SEE ALSO"
  3436. captoinfo(1M),
  3437. tic(1M),
  3438. infocmp(1M),
  3439. termcap(3),
  3440. curses(3X),
  3441. term(4),
  3442. termcap(4),
  3443. terminfo(4).
  3444. X.SH DIAGNOSTICS
  3445. The line number of a warning message when translating a file
  3446. may refer to the last line of an entry instead of the line in the entry 
  3447. that generated the warning.
  3448. X.SH BUGS
  3449. More warning messages could be generated.
  3450. X.I tconv
  3451. can't translate to termcap.  Binaries generated will have cancelled
  3452. capabilities marked as cancelled, which is incompatible with
  3453. System V Release 2.0 terminfo.
  3454. END_OF_FILE
  3455. if test 3823 -ne `wc -c <'tconv.1'`; then
  3456.     echo shar: \"'tconv.1'\" unpacked with wrong size!
  3457. fi
  3458. # end of 'tconv.1'
  3459. fi
  3460. if test -f 'term.tail' -a "${1}" != "-c" ; then 
  3461.   echo shar: Will not clobber existing file \"'term.tail'\"
  3462. else
  3463. echo shar: Extracting \"'term.tail'\" \(2340 characters\)
  3464. sed "s/^X//" >'term.tail' <<'END_OF_FILE'
  3465. X/* 
  3466. X * 92/02/01 07:30:28
  3467. X * @(#) mytinfo term.tail 3.2 92/02/01 public domain, By Ross Ridge
  3468. X *
  3469. X */
  3470. X
  3471. X#ifdef _USE_TERMIO
  3472. X#ifndef ICANON
  3473. X#include <termio.h>
  3474. X#endif
  3475. X#if defined(_USE_WINSZ) && defined(xenix)
  3476. X#include <sys/stream.h>
  3477. X#include <sys/ptem.h>
  3478. X#endif
  3479. X#endif
  3480. X
  3481. X#ifdef _USE_SGTTY
  3482. X#ifndef CBREAK
  3483. X#include <sgtty.h>
  3484. X#endif
  3485. X#endif
  3486. X
  3487. typedef struct _terminal {
  3488. X    int fd;
  3489. X#ifdef _USE_SMALLMEM
  3490. X    unsigned short baudrate;
  3491. X    unsigned pad:1, xon:1, termcap:1;
  3492. X#else
  3493. X    int pad;
  3494. X    int xon;
  3495. X    int termcap;
  3496. X    long baudrate;
  3497. X#endif
  3498. X    char padch;
  3499. X    short true_lines, true_columns;
  3500. X    struct strbuf {
  3501. X        struct strbuf *next;
  3502. X#ifdef _USE_SMALLMEM
  3503. X        short len;
  3504. X#else
  3505. X        int len;
  3506. X#endif
  3507. X        char buf[_MAX_CHUNK];
  3508. X    } *strbuf;
  3509. X    char *name, *name_long, *name_all;
  3510. X#ifdef _USE_SGTTY
  3511. X    struct sgtty_str {
  3512. X        struct sgttyb v6;
  3513. X#ifdef TIOCGETC
  3514. X        struct tchars v7;
  3515. X#endif
  3516. X#ifdef TIOCLGET
  3517. X        int bsd;
  3518. X#endif
  3519. X#ifdef TIOCGLTC
  3520. X        struct ltchars bsd_new;
  3521. X#endif
  3522. X    } prog_mode, shell_mode;
  3523. X#else    /* _USE_SGTTY */
  3524. X#ifdef _USE_TERMIO
  3525. X    struct termio prog_mode, shell_mode;
  3526. X#endif 
  3527. X#endif    /* else _USE_SGTTY */
  3528. X#ifdef _USE_WINSZ
  3529. X#ifdef TIOCGWINSZ
  3530. X    struct winsize prog_winsz, shell_winsz;
  3531. X#endif
  3532. X#endif
  3533. X    char bools[NUM_OF_BOOLS];
  3534. X    short nums[NUM_OF_NUMS];
  3535. X    char *strs[NUM_OF_STRS];
  3536. X} TERMINAL;
  3537. X
  3538. X#ifndef _CUR_TERM
  3539. X#ifdef SINGLE
  3540. X#define _CUR_TERM _term_buf
  3541. X#else
  3542. X#define _CUR_TERM (*cur_term)
  3543. X#endif
  3544. X#endif
  3545. X
  3546. extern TERMINAL *cur_term;
  3547. extern TERMINAL _term_buf;
  3548. X
  3549. X#ifdef USE_PROTOTYPES
  3550. extern char *tparm(char *, ...);
  3551. extern int setupterm(char *, int, int *), set_curterm(TERMINAL *);
  3552. extern int del_curterm(TERMINAL *), tputs(char *, int, int (*)());
  3553. extern int putp(char *);
  3554. extern int tigetflag(char *), tigetnum(char *);
  3555. extern char *tigetstr(char *);
  3556. extern int def_prog_mode(void), def_shell_mode(void);
  3557. extern int reset_prog_mode(void), reset_shell_mode(void);
  3558. X#else
  3559. extern char *tparm();
  3560. extern int setupterm(), set_curterm();
  3561. extern int del_curterm(), tputs();
  3562. extern int putp();
  3563. extern int tigetflag(), tigetnum();
  3564. extern char *tigetstr();
  3565. extern int def_prog_mode(), def_shell_mode();
  3566. extern int reset_prog_mode(), reset_shell_mode();
  3567. X#endif
  3568. X
  3569. extern char *boolnames[], *boolcodes[], *boolfnames[];
  3570. extern char *numnames[], *numcodes[], *numfnames[];
  3571. extern char *strnames[], *strcodes[], *strfnames[];
  3572. X
  3573. X#ifndef OK
  3574. X#undef ERR
  3575. X#define OK (0)
  3576. X#define ERR (-1)
  3577. X#endif
  3578. X
  3579. X#endif /* _TERM_H_ */
  3580. END_OF_FILE
  3581. if test 2340 -ne `wc -c <'term.tail'`; then
  3582.     echo shar: \"'term.tail'\" unpacked with wrong size!
  3583. fi
  3584. # end of 'term.tail'
  3585. fi
  3586. if test -f 'termcap.c' -a "${1}" != "-c" ; then 
  3587.   echo shar: Will not clobber existing file \"'termcap.c'\"
  3588. else
  3589. echo shar: Extracting \"'termcap.c'\" \(2255 characters\)
  3590. sed "s/^X//" >'termcap.c' <<'END_OF_FILE'
  3591. X/*
  3592. X * termcap.c
  3593. X *
  3594. X * By Ross Ridge
  3595. X * Public Domain
  3596. X * 92/06/01 07:43:08
  3597. X *
  3598. X * termcap compatibility functions
  3599. X *
  3600. X */
  3601. X
  3602. X#include "defs.h"
  3603. X#include "term.h"
  3604. X
  3605. static const char SCCSid[] = "@(#) mytinfo termcap.c 3.3 92/06/01 public domain, By Ross Ridge";
  3606. X
  3607. extern char _mytinfo_version[];
  3608. static char *force = _mytinfo_version;
  3609. X
  3610. int
  3611. tgetent(buf, term)
  3612. char *term, *buf; {
  3613. X    char *s;
  3614. X    struct term_path *path;
  3615. X    int r = -1;
  3616. X    int fd;
  3617. X
  3618. X    if (term == NULL) 
  3619. X        term = getenv("TERM");
  3620. X    if (term == NULL)
  3621. X        return 0;
  3622. X
  3623. X    path = _buildpath("$MYTERMINFO", 2,
  3624. X              "$TERMINFO", 2,
  3625. X              "$TERMCAP", 1,
  3626. X#ifdef TERMINFODIR
  3627. X              TERMINFODIR, 0,
  3628. X#endif
  3629. X#ifdef TERMCAPFILE
  3630. X              TERMCAPFILE, 0,
  3631. X#endif
  3632. X#ifdef TERMINFOSRC
  3633. X              TERMINFOSRC, 0,
  3634. X#endif
  3635. X              NULL, -1);
  3636. X
  3637. X    if (path == NULL)
  3638. X        return -1;
  3639. X
  3640. X#if 1
  3641. X    {
  3642. X        char buf1[MAX_BUF];
  3643. X        r = _fillterm(term, path, buf1);
  3644. X    }
  3645. X#else
  3646. X    r = _fillterm(term, path, buf);
  3647. X#endif
  3648. X
  3649. X    _delpath(path);
  3650. X
  3651. X    switch(r) {
  3652. X    case -3:
  3653. X    case -2:
  3654. X    case -1:
  3655. X        return -1;
  3656. X    case 0:
  3657. X        return 0;
  3658. X    case 1:
  3659. X    case 2:
  3660. X    case 3:
  3661. X        if (isatty(1))
  3662. X            fd = 1;
  3663. X        else if (isatty(2))
  3664. X            fd = 2;
  3665. X        else if (isatty(3))    /* V10 /dev/tty ?? */
  3666. X            fd = 3;
  3667. X        else if (isatty(0))
  3668. X            fd = 0;
  3669. X        else
  3670. X            fd = 1;
  3671. X
  3672. X        cur_term->fd = fd;
  3673. X        _term_buf.fd = fd;
  3674. X
  3675. X        if (_init_tty() == ERR)
  3676. X            return 0;
  3677. X        if ((s = getenv("LINES")) != NULL && atoi(s) > 0) 
  3678. X            lines = atoi(s);
  3679. X        if ((s = getenv("COLUMNS")) != NULL && atoi(s) > 0)
  3680. X            columns = atoi(s);
  3681. X        cur_term->termcap = 1;
  3682. X        return 1;
  3683. X    default:
  3684. X        return -1;
  3685. X    }
  3686. X}
  3687. X
  3688. static char cap2[3];
  3689. X
  3690. int
  3691. tgetnum(cap)
  3692. char *cap; {
  3693. X    int ind;
  3694. X
  3695. X    cap2[0] = cap[0]; 
  3696. X    cap2[1] = cap[1];
  3697. X    cap2[2] = '\0';
  3698. X
  3699. X    ind = _findnumcode(cap2);
  3700. X    if (ind == -1)
  3701. X        return -1;
  3702. X    return cur_term->nums[ind];
  3703. X}
  3704. X
  3705. int
  3706. tgetflag(cap)
  3707. char *cap; {
  3708. X    int ind;
  3709. X
  3710. X    cap2[0] = cap[0]; 
  3711. X    cap2[1] = cap[1];
  3712. X    cap2[2] = '\0';
  3713. X
  3714. X    ind = _findboolcode(cap2);
  3715. X    if (ind == -1)
  3716. X        return 0;
  3717. X    return cur_term->bools[ind];
  3718. X}
  3719. X
  3720. char *
  3721. tgetstr(cap, area)
  3722. char *cap;
  3723. char **area; {
  3724. X    register char *sp, *dp;
  3725. X    int ind;
  3726. X
  3727. X    cap2[0] = cap[0]; 
  3728. X    cap2[1] = cap[1];
  3729. X    cap2[2] = '\0';
  3730. X
  3731. X    ind = _findstrcode(cap2);
  3732. X    if (ind == -1)
  3733. X        return NULL;
  3734. X    sp = cur_term->strs[ind];
  3735. X    if (area == NULL || sp == NULL)
  3736. X        return sp;
  3737. X    dp = *area;
  3738. X    while (*sp != '\0')
  3739. X        *dp++ = *sp++;
  3740. X    *dp++ = '\0';
  3741. X    sp = *area;
  3742. X    *area = dp;
  3743. X    return sp;
  3744. X}
  3745. END_OF_FILE
  3746. if test 2255 -ne `wc -c <'termcap.c'`; then
  3747.     echo shar: \"'termcap.c'\" unpacked with wrong size!
  3748. fi
  3749. # end of 'termcap.c'
  3750. fi
  3751. if test -f 'terminfo.c' -a "${1}" != "-c" ; then 
  3752.   echo shar: Will not clobber existing file \"'terminfo.c'\"
  3753. else
  3754. echo shar: Extracting \"'terminfo.c'\" \(2068 characters\)
  3755. sed "s/^X//" >'terminfo.c' <<'END_OF_FILE'
  3756. X/*
  3757. X * terminfo.c
  3758. X *
  3759. X * By Ross Ridge
  3760. X * Public Domain
  3761. X * 92/02/01 07:30:30
  3762. X *
  3763. X * terminfo compatible libary functions
  3764. X *
  3765. X */
  3766. X
  3767. X#include "defs.h"
  3768. X#include "term.h"
  3769. X
  3770. static const char SCCSid[] = "@(#) mytinfo terminfo.c 3.2 92/02/01 public domain, By Ross Ridge";
  3771. X
  3772. extern char _mytinfo_version[];
  3773. static char *force = _mytinfo_version;
  3774. X
  3775. X#ifdef USE_FAKE_STDIO
  3776. X
  3777. X#ifdef __GNUC__
  3778. X__inline__
  3779. X#endif
  3780. static int
  3781. printerr(msg)
  3782. char *msg; {
  3783. X    return write(2, msg, strlen(msg));
  3784. X}
  3785. X
  3786. X#define RETERR(e, msg)  { (err == NULL ? (printerr(msg), exit(1), 0) \
  3787. X                       : (*err = e)); return ERR; }
  3788. X
  3789. X#else
  3790. X
  3791. X#define RETERR(e, msg)  { (err == NULL ? (fprintf(stderr, msg), exit(1), 0) \
  3792. X                       : (*err = e)); return ERR; }
  3793. X
  3794. X#endif
  3795. X
  3796. int
  3797. setupterm(term, fd, err)
  3798. char *term;
  3799. int fd;
  3800. int *err; {
  3801. X    struct term_path *path;
  3802. X    char *s;
  3803. X    int r = -1;
  3804. X    char buf[MAX_BUF];
  3805. X
  3806. X
  3807. X    if (term == NULL) 
  3808. X        term = getenv("TERM");
  3809. X    if (term == NULL)
  3810. X        RETERR(0, "TERM not set\n")
  3811. X
  3812. X    path = _buildpath("$MYTERMINFO", 2,
  3813. X              "$TERMINFO", 2,
  3814. X              "$TERMCAP", 1,
  3815. X#ifdef TERMINFODIR
  3816. X              TERMINFODIR, 0,
  3817. X#endif
  3818. X#ifdef TERMCAPFILE
  3819. X              TERMCAPFILE, 0,
  3820. X#endif
  3821. X#ifdef TERMINFOSRC
  3822. X              TERMINFOSRC, 0,
  3823. X#endif
  3824. X              NULL, -1);
  3825. X
  3826. X    if (path == NULL)
  3827. X        RETERR(0, "malloc error\n");
  3828. X
  3829. X    r = _fillterm(term, path, buf);
  3830. X
  3831. X    _delpath(path);
  3832. X
  3833. X    switch(r) {
  3834. X    case -3:
  3835. X        RETERR(0, "malloc error\n");
  3836. X    case -2:
  3837. X        RETERR(-1, "bad format\n");
  3838. X    case -1:
  3839. X        RETERR(-1, "database not found\n");
  3840. X    case 0:
  3841. X        RETERR(0, "terminal not found\n");
  3842. X    case 1:
  3843. X    case 2:
  3844. X    case 3:
  3845. X        cur_term->fd = fd;
  3846. X        _term_buf.fd = fd;
  3847. X        if (_init_tty() == ERR)
  3848. X            RETERR(0, "problem initializing tty\n");
  3849. X        if ((s = getenv("LINES")) != NULL && atoi(s) > 0) 
  3850. X            lines = atoi(s);
  3851. X        if ((s = getenv("COLUMNS")) != NULL && atoi(s) > 0)
  3852. X            columns = atoi(s);
  3853. X        if (err != NULL)
  3854. X            *err = 1;
  3855. X        return OK;
  3856. X    default:
  3857. X        RETERR(0, "oops...\n");
  3858. X    }
  3859. X}
  3860. X
  3861. int
  3862. set_curterm(p)
  3863. TERMINAL *p; {
  3864. X    cur_term = p;
  3865. X    if (_init_tty() == ERR)
  3866. X        return ERR;
  3867. X    if (_check_tty() == ERR)
  3868. X        return ERR;
  3869. X    return OK;
  3870. X}
  3871. X
  3872. int
  3873. del_curterm(p)
  3874. TERMINAL *p; {
  3875. X    _del_strs(p);
  3876. X    free((anyptr) p);
  3877. X
  3878. X    return OK;
  3879. X}
  3880. END_OF_FILE
  3881. if test 2068 -ne `wc -c <'terminfo.c'`; then
  3882.     echo shar: \"'terminfo.c'\" unpacked with wrong size!
  3883. fi
  3884. # end of 'terminfo.c'
  3885. fi
  3886. if test -f 'terminfo.src' -a "${1}" != "-c" ; then 
  3887.   echo shar: Will not clobber existing file \"'terminfo.src'\"
  3888. else
  3889. echo shar: Extracting \"'terminfo.src'\" \(4475 characters\)
  3890. sed "s/^X//" >'terminfo.src' <<'END_OF_FILE'
  3891. X# 
  3892. X# terminfo.src
  3893. X#
  3894. X# By Ross Ridge
  3895. X# Public Domain
  3896. X# 92/02/01 07:30:32
  3897. X#
  3898. X# Some sample terminfo definitions
  3899. X#
  3900. X# @(#) mytinfo terminfo.src 3.2 92/02/01 public domain, By Ross Ridge
  3901. X#
  3902. X#
  3903. dumb|dumb terminal, gn, co#80,
  3904. X#
  3905. X# Note not all ANSI terminals will support all of these capabilities.
  3906. X# This doesn't define any real terminal, and probably wouldn't work
  3907. X# with any real terminal either.
  3908. X#
  3909. ansi-all|ANS X3.64-1979 terminal,
  3910. X    cr=^M, cud1=^J, ind=^J, nel=^M^J, bell=^G, cub1=^H, 
  3911. X    cuu1=\EM, ff=^L, ht=^I,
  3912. X    .ind=\ED, .nel=\EE, hts=\EH, hd=\EK, hu=\EL, ri=\EM,
  3913. X    .ich1=\E[@, .ich=\E[%p1%d@, .cuu1=\E[A, cuu=\E[%p1%dA,
  3914. X    cud1=\E[B, .cud=\E[%p1%dB, cuf1=\E[C, cuf=\E[%p1%dC,
  3915. X    .cub1=\E[D, cub=\E[%p1%dD, .cnl=\E[%p1%dE, .cpl=\E[%p1%dF,
  3916. X    .hpa=\E[%i%p1%dG, cup=\E[%i%p1%d;%p2%dH, .cht=\E[%p1%dI,
  3917. X    ed=\E[J, el=\E[K, el1=\E[1K, il1=\E[L, il=\E[%p1%dL,
  3918. X    dl1=\E[M, dl=\E[%p1%dM, .ef=\E[N, .ea=\E[O,
  3919. X    dch1=\E[P, dch=\E[%p1%dP, .sem=\E[%p1%dQ,
  3920. X    .cpr=\E[%i%p1%d;%p2%dR, indn=\E[%p1%dS, .ind=\E[S,
  3921. X    rin=\E[%p1%dT, .ri=\E[T, .np=\E[%p1%dU, .pp=\E[%p1%dU,
  3922. X    .ctc=\E[%p1%dW, ech=\E[%p1%dX, .cvt=\E[%p1%dY,
  3923. X    cbt=\E[Z, hpa=\E[%i%p1%d`, .hpr=\E[%p1%da,
  3924. X    rep=%p1%c%?%p2%{1}%>%t\E[%p2%{1}%-%db%;,
  3925. X    .da=\E[c, vpa=\E[%i%p1%dd, .vpr=\E[%p1%e,
  3926. X    .hvp=\E[%i%p1%d;%p2%df, tbc=\E[3g,
  3927. X    mc=\E[0i, mc4=\E[4i, mc5=\E[5i,
  3928. X    sgr=\E[%?%p6%t;1%;%?%p5%p1%|%t;2%;%?%p2%t;4%;%?%p4%t;6%;%?%p3%p1%|%t;7%;%?%p7%t;8%;m,
  3929. X    smso=\E[1;7m, rmso=\E[m, smul=\E[4m, rmul=\E[m,
  3930. X    blink=\E[6m, bold=\E[1m, invis=\E[8m, rev=\E[7m,
  3931. X    sgr0=\E[m, .dsr=\E[%p1%dn, .daq=\E[%p1%do,
  3932. X    .sl=\E[%p1%d\s@, .sr=\E[%p1%d\sA, clear=\E[H\EJ, home=\E[H,
  3933. X    smir=\E[4h, rmir=\E[4l,
  3934. X    is2=\E[1Q\E[1;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\E[6;12h\E[m,
  3935. X    rs2=\Ec\E[1Q\E[1;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\E[6;12h\E[m\E[H\EJ,
  3936. ansi-all-8|ANS X3.64-1979 terminal (8 bit),
  3937. X    cr=^M, cud1=^J, ind=^J, nel=^M^J, bell=^G, cub1=^H, 
  3938. X    cuu1=\215, ff=^L, ht=^I,
  3939. X    .ind=\204, .nel=\205, hts=\207, hd=\213, hu=\214, ri=\215,
  3940. X    .ich1=\233@, .ich=\E%p1%d@, .cuu1=\233A, cuu=\233%p1%dA,
  3941. X    cud1=\233B, .cud=\233%p1%dB, cuf1=\233C, cuf=\233%p1%dC,
  3942. X    .cub1=\233D, cub=\233%p1%dD, .cnl=\233%p1%dE, .cpl=\233%p1%dF,
  3943. X    .hpa=\233%i%p1%dG, cup=\233%i%p1%d;%p2%dH, .cht=\233%p1%dI,
  3944. X    ed=\233J, el=\233K, el1=\2331K, il1=\233L, il=\233%p1%dL,
  3945. X    dl1=\233M, dl=\233%p1%dM, .ef=\233N, .ea=\233O,
  3946. X    dch1=\233P, dch=\233%p1%dP, .sem=\233%p1%dQ,
  3947. X    .cpr=\233%i%p1%d;%p2%dR, indn=\233%p1%dS, .ind=\233S,
  3948. X    rin=\233%p1%dT, .ri=\233T, .np=\233%p1%dU, .pp=\233%p1%dU,
  3949. X    .ctc=\233%p1%dW, ech=\233%p1%dX, .cvt=\233%p1%dY,
  3950. X    cbt=\233Z, hpa=\233%i%p1%d`, .hpr=\233%p1%da,
  3951. X    rep=%p1%c%?%p2%{1}%>%t\233%p2%{1}%-%db%;,
  3952. X    .da=\233c, vpa=\233%i%p1%dd, .vpr=\233%p1%e,
  3953. X    .hvp=\233%i%p1%d;%p2%df, tbc=\2333g,
  3954. X    mc=\2330i, mc4=\2334i, mc5=\2334i,
  3955. X    sgr=\233%?%p6%t;1%;%?%p5%p1%|%t;2%;%?%p2%t;4%;%?%p4%t;6%;%?%p3%p1%|%t;7%;%?%p7%t;8%;m,
  3956. X    smso=\2331;7m, rmso=\233m, smul=\2334m, rmul=\233m,
  3957. X    blink=\2336m, bold=\2331m, invis=\2338m, rev=\2337m,
  3958. X    sgr0=\233m, .dsr=\233%p1%dn, .daq=\233%p1%do,
  3959. X    .sl=\233%p1%d\s@, .sr=\233%p1%d\sA, clear=\233H\EJ, home=\233H,
  3960. X    smir=\2334h, rmir=\2334l,
  3961. X    is2=\2331Q\2331;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\2336;12h\233m,
  3962. X    rs2=\Ec\2331Q\2331;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\2336;12h\233m\233H\EJ,
  3963. X#
  3964. X# Not tested...
  3965. X#
  3966. vt100|dec vt100,
  3967. X    xon, UWxc, msgr, 
  3968. X    cols#80, lines#24, it#8, vt#3,
  3969. X    cr=\r, csr=^[[%i%p1%d;%p2%dr, tbc=^[[3g, clear=^[[;H^[[2J$<100>,
  3970. X    el=^[[K$<3>, ed=^[[J$<50>, cup=^[[%i%p1%d;%p2%dH$<5>, cud1=^[[B,
  3971. X    home=^[[H, cub1=^[[D, cuf1=^[[C$<2>, cuu1=^[[A$<2>, blink=^[[5m$<2>,
  3972. X    bold=^[[1m$<2>, rev=^[[7m$<2>, smso=^[[7m$<2>, smul=^[[4m$<2>,
  3973. X    sgr0=^[[m^N$<2>, rmso=^[[m$<2>, rmul=^[[m$<2>, hts=^[H, ht=^I,
  3974. X    is2=^[[1;24r^[[?1l^[[?3l^[[30h^[[?7h^[>, bell=^G,
  3975. X    kbs=\b, kcud1=^[[B, kf0=^[OP, kf1=^[OQ, kf2=^[OR, kf3=^[OS,
  3976. X    kcub1=^[[D, kcuf1=^[[C, kcuu1=^[[A, lf0=PF1, lf1=PF2,
  3977. X    lf2=PF3, lf3=PF4, nel=\r^[D, cud=^[[%p1%dB, cub=^[[%p1%dD,
  3978. X    cuf=^[[%p1%dC, cuu=^[[%p1%dA, rc=^[8, sc=^[7, ind=^[D, ri=^[M$<5>,
  3979. X    sgr=^[[0;%?%p4%t;5%;%?%p6%t;1%;%?%p3%p1%|%t;7%;%?%p2%t;4%;m%?%p1%t^N%e^O%;$<2>,
  3980. X    smacs=^O, rmacs=^N,
  3981. vt100-am|vt100 with automatic margins,
  3982. X    am, xenl, @el, @ed,
  3983. X    use=vt100,
  3984. vt102|dec vt102,
  3985. X    is=\E<\E[1;24r\E[?1l\E[?3l\E[?5l\E[?7h\E>,
  3986. X    il=\E[%p1%dL, dch=\E[%p1%dP, dl=\E[%p1%dM,
  3987. X    il1=\E[L, dch1=\E[P, dl1=\E[M,
  3988. X    mir, rmir=\E[4l, smir=\E[4h,
  3989. X    use=vt100,
  3990. vt200|vt220|vt200-js|vt220-js|dec vt200 series with jump scroll,
  3991. X    clear=\E[H\E[J, rmso=\E[27m, rmul=\E[24m,
  3992. X    is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H,
  3993. X    rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
  3994. X    use=vt102, 
  3995. END_OF_FILE
  3996. if test 4475 -ne `wc -c <'terminfo.src'`; then
  3997.     echo shar: \"'terminfo.src'\" unpacked with wrong size!
  3998. fi
  3999. # end of 'terminfo.src'
  4000. fi
  4001. if test -f 'tgoto.c' -a "${1}" != "-c" ; then 
  4002.   echo shar: Will not clobber existing file \"'tgoto.c'\"
  4003. else
  4004. echo shar: Extracting \"'tgoto.c'\" \(2489 characters\)
  4005. sed "s/^X//" >'tgoto.c' <<'END_OF_FILE'
  4006. X/*
  4007. X * tgoto.c
  4008. X *
  4009. X * By Ross Ridge
  4010. X * Public Domain
  4011. X * 92/02/01 07:30:33
  4012. X *
  4013. X * A few kludged attempts to worry outputing ^D's and NL's...
  4014. X * My advice is to get a decent terminal.
  4015. X *
  4016. X */
  4017. X
  4018. X#include "defs.h"
  4019. X#include "term.h"
  4020. X
  4021. X#ifdef USE_SCCS_IDS
  4022. static const char SCCSid[] = "@(#) mytinfo tgoto.c 3.2 92/02/01 public domain, By Ross Ridge";
  4023. X#endif
  4024. X
  4025. X#ifdef USE_LITOUT_KLUDGE
  4026. X
  4027. X/*
  4028. X * This kludge works by telling tputs to switch the tty driver to
  4029. X * "literal output" when printing the string so we don't have worry
  4030. X * about newlines and EOTs. The problem is that ioctls used to
  4031. X * switch modes might flush buffers and cause other problems.
  4032. X */
  4033. X
  4034. X
  4035. char *
  4036. tgoto(str, x, y)
  4037. char *str;
  4038. int x,y; {
  4039. X    register char *sp;
  4040. X    
  4041. X    static char buf[MAX_LINE] = {'\\', '@'};
  4042. X
  4043. X    sp = str = tparm(str, y, x);
  4044. X
  4045. X    while (*sp != '\0') {
  4046. X        if (*sp == '\004' || *sp == '\n') {
  4047. X            strncpy(buf + 2, str, MAX_LINE - 2);
  4048. X            buf[MAX_LINE - 2] = '\0';
  4049. X            return buf;
  4050. X        }
  4051. X        sp++;
  4052. X    }
  4053. X    return sp;
  4054. X}
  4055. X#else
  4056. X
  4057. X#ifdef USE_UPBC_KLUDGE
  4058. X
  4059. X#ifdef USE_EXTERN_UPBC
  4060. extern char *BC, *UP;
  4061. X#else
  4062. X#define BC    cursor_left
  4063. X#define UP    cursor_right
  4064. X#endif
  4065. X
  4066. X#ifdef __GNUC__
  4067. X__inline__
  4068. X#endif
  4069. static int
  4070. checkit(s)
  4071. register char *s; {
  4072. X    while(*s != '\0') {
  4073. X        if (*s == '\004' || *s == '\n')
  4074. X            return 1;
  4075. X        s++;
  4076. X    }
  4077. X    return 0;
  4078. X}
  4079. X
  4080. X/*
  4081. X * Major kludge, basically we just change the parmeters until we get
  4082. X * a string that doesn't contain a newline or EOT.
  4083. X */
  4084. X
  4085. char *
  4086. tgoto(str, x, y)
  4087. char *str;
  4088. int x,y; {
  4089. X    static char buf[MAX_LINE];
  4090. X    register char *orig, *s;
  4091. X    int l;
  4092. X
  4093. X    orig = tparm(str, y, x);
  4094. X
  4095. X    if (!checkit(orig))
  4096. X        return orig;
  4097. X
  4098. X    s = tparm(str, y + 1, x);
  4099. X
  4100. X    if (!checkit(s)) {
  4101. X        if (BC == NULL)
  4102. X            return s;
  4103. X        l = strlen(s);
  4104. X        strncpy(buf, s, MAX_LINE - 1);
  4105. X        if (l < MAX_LINE - 1)
  4106. X            strncpy(buf + l, BC, MAX_LINE - 1 - l);
  4107. X        return s;
  4108. X    }
  4109. X
  4110. X    s = tparm(str, y, x + 1);
  4111. X
  4112. X    if (!checkit(s)) {
  4113. X        if (UP == NULL)
  4114. X            return s;
  4115. X        l = strlen(s);
  4116. X        strncpy(buf, s, MAX_LINE - 1);
  4117. X        if (l < MAX_LINE - 1)
  4118. X            strncpy(buf + l, UP, MAX_LINE - 1 - l);
  4119. X        return s;
  4120. X    }
  4121. X
  4122. X    s = tparm(str, y + 1, x + 1);
  4123. X
  4124. X    if (!checkit(s)) {
  4125. X        if (UP == NULL || BC == NULL)
  4126. X            return s;
  4127. X        l = strlen(s);
  4128. X        strncpy(buf, s, MAX_LINE - 1);
  4129. X        if (l < MAX_LINE - 1)
  4130. X            strncpy(buf + l, UP, MAX_LINE - 1 - l);
  4131. X        l += strlen(UP);
  4132. X        if (l < MAX_LINE - 1)
  4133. X            strncpy(buf + l, BC, MAX_LINE - 1 - l);
  4134. X        return s;
  4135. X    }
  4136. X
  4137. X    return orig;
  4138. X}
  4139. X
  4140. X#else
  4141. X
  4142. X/* the simple tgoto, don't worry about any of this newline/EOT crap */
  4143. X
  4144. char *
  4145. tgoto(str, x, y)
  4146. char *str;
  4147. int x,y; {
  4148. X    return tparm(str, y, x);
  4149. X}
  4150. X
  4151. X#endif
  4152. X
  4153. X#endif
  4154. END_OF_FILE
  4155. if test 2489 -ne `wc -c <'tgoto.c'`; then
  4156.     echo shar: \"'tgoto.c'\" unpacked with wrong size!
  4157. fi
  4158. # end of 'tgoto.c'
  4159. fi
  4160. if test -f 'tiget.c' -a "${1}" != "-c" ; then 
  4161.   echo shar: Will not clobber existing file \"'tiget.c'\"
  4162. else
  4163. echo shar: Extracting \"'tiget.c'\" \(684 characters\)
  4164. sed "s/^X//" >'tiget.c' <<'END_OF_FILE'
  4165. X/*
  4166. X * tiget.c
  4167. X *
  4168. X * By Ross Ridge
  4169. X * Public Domain
  4170. X * 92/02/01 07:30:34
  4171. X *
  4172. X * The various tiget terminfo functions.
  4173. X */
  4174. X
  4175. X#include "defs.h"
  4176. X#include "term.h"
  4177. X
  4178. X#ifdef USE_SCCS_IDS
  4179. static const char SCCSid[] = "@(#) mytinfo tiget.c 3.2 92/02/01 public domain, By Ross Ridge";
  4180. X#endif
  4181. X
  4182. int
  4183. tigetnum(cap)
  4184. char *cap; {
  4185. X    int ind;
  4186. X
  4187. X    ind = _findnumname(cap);
  4188. X    if (ind == -1)
  4189. X        return -2;
  4190. X    return cur_term->nums[ind];
  4191. X}
  4192. X
  4193. int
  4194. tigetflag(cap)
  4195. char *cap; {
  4196. X    int ind;
  4197. X
  4198. X    ind = _findboolname(cap);
  4199. X    if (ind == -1)
  4200. X        return -1;
  4201. X    return cur_term->bools[ind];
  4202. X}
  4203. X
  4204. char *
  4205. tigetstr(cap)
  4206. char *cap; {
  4207. X    int ind;
  4208. X
  4209. X    ind = _findstrname(cap);
  4210. X    if (ind == -1)
  4211. X        return (char *) -1;
  4212. X    return cur_term->strs[ind];
  4213. X}
  4214. X
  4215. X
  4216. END_OF_FILE
  4217. if test 684 -ne `wc -c <'tiget.c'`; then
  4218.     echo shar: \"'tiget.c'\" unpacked with wrong size!
  4219. fi
  4220. # end of 'tiget.c'
  4221. fi
  4222. if test -f 'tmatch.c' -a "${1}" != "-c" ; then 
  4223.   echo shar: Will not clobber existing file \"'tmatch.c'\"
  4224. else
  4225. echo shar: Extracting \"'tmatch.c'\" \(604 characters\)
  4226. sed "s/^X//" >'tmatch.c' <<'END_OF_FILE'
  4227. X/*
  4228. X * tmatch.c
  4229. X *
  4230. X * By Ross Ridge
  4231. X * Public Domain
  4232. X * 92/02/01 07:30:35
  4233. X *
  4234. X * See if a terminal name matches a list of terminal names from a
  4235. X * terminal description
  4236. X *
  4237. X */
  4238. X
  4239. X#include "defs.h"
  4240. X
  4241. X#ifdef USE_SCCS_IDS
  4242. static const char SCCSid[] = "@(#) mytinfo tmatch.c 3.2 92/02/01 public domain, By Ross Ridge";
  4243. X#endif
  4244. X
  4245. int
  4246. X_tmatch(line, name)
  4247. char *line, *name; {
  4248. X    char term[MAX_LINE];
  4249. X    char *sp, *dp;
  4250. X
  4251. X    sp = line;
  4252. X    while (*sp != '\0') {
  4253. X        dp = term;
  4254. X        while (*sp != '\0' && *sp != '|')
  4255. X            *dp++ = *sp++;
  4256. X        *dp = '\0';
  4257. X        if (strcmp(term, name) == 0)
  4258. X            return 1;
  4259. X        if (*sp == '|')
  4260. X            sp++;
  4261. X    }
  4262. X    return 0;
  4263. X}
  4264. END_OF_FILE
  4265. if test 604 -ne `wc -c <'tmatch.c'`; then
  4266.     echo shar: \"'tmatch.c'\" unpacked with wrong size!
  4267. fi
  4268. # end of 'tmatch.c'
  4269. fi
  4270. if test -f 'tput.c' -a "${1}" != "-c" ; then 
  4271.   echo shar: Will not clobber existing file \"'tput.c'\"
  4272. else
  4273. echo shar: Extracting \"'tput.c'\" \(3436 characters\)
  4274. sed "s/^X//" >'tput.c' <<'END_OF_FILE'
  4275. X/*
  4276. X * tput.c
  4277. X * 
  4278. X * By Ross Ridge
  4279. X * Public Domain
  4280. X * 92/02/01 07:30:39
  4281. X *
  4282. X */
  4283. X
  4284. X#define NOTLIB
  4285. X
  4286. X#include "defs.h"
  4287. X
  4288. static const char SCCSid[] = "@(#) mytinfo tput.c 3.2 92/02/01 public domain, By Ross Ridge";
  4289. X
  4290. X#define SINGLE
  4291. X#include "term.h"
  4292. X
  4293. X#include <ctype.h>
  4294. X
  4295. X#define PUTS(s)        putp(s)
  4296. X#define PUTCHAR(c)    putchar(c)
  4297. X#define FLUSH        fflush(stdout)
  4298. X
  4299. extern void (*cleanup)();
  4300. X
  4301. static void
  4302. clean(e)
  4303. int e; {
  4304. X    return;
  4305. X}
  4306. X
  4307. static void
  4308. usage(e)
  4309. int e; {
  4310. X    fprintf(stderr, "usage: %s [-T term] capname\n", prg_name);
  4311. X    return;
  4312. X}
  4313. X
  4314. int
  4315. main(argc, argv)
  4316. int argc;
  4317. char **argv; {
  4318. X    char *s;
  4319. X    int i, j, c;
  4320. X    int reset;
  4321. X    FILE *f;
  4322. X    char *term;
  4323. X
  4324. X    prg_name = argv[0];
  4325. X    s = strrchr(prg_name, '/');
  4326. X    if (s != NULL && *++s != '\0') {
  4327. X        prg_name = s;
  4328. X    }
  4329. X
  4330. X    term = getenv("TERM");
  4331. X
  4332. X    cleanup = usage;
  4333. X
  4334. X    if (argc > 2 && argv[1][0] == '-' && argv[1][1] == 'T') {
  4335. X        if (argv[1][2] == '\0' && argc > 3) {
  4336. X            term = argv[2];
  4337. X            argc--;
  4338. X            argv++;
  4339. X        } else {
  4340. X            term = argv[1] + 2;
  4341. X        }
  4342. X        argc--;
  4343. X        argv++;
  4344. X    }
  4345. X
  4346. X    if (argc != 2) {
  4347. X        quit(-1, "arg count");
  4348. X    }
  4349. X
  4350. X    cleanup = clean;
  4351. X
  4352. X    setupterm(term, 1, (int *)0);
  4353. X
  4354. X    reset = 0;
  4355. X    if (strcmp(argv[1], "reset") == 0) {
  4356. X        reset = 1;
  4357. X    }
  4358. X    if (reset || strcmp(argv[1], "init") == 0) {
  4359. X
  4360. X        if (init_prog != NULL) {
  4361. X            system(init_prog);
  4362. X        }
  4363. X        FLUSH;
  4364. X
  4365. X        if (reset && reset_1string != NULL) {
  4366. X            PUTS(reset_1string);
  4367. X        } else if (init_1string != NULL) {
  4368. X            PUTS(init_1string);
  4369. X        }
  4370. X        FLUSH;
  4371. X
  4372. X        if (reset && reset_2string != NULL) {
  4373. X            PUTS(reset_2string);
  4374. X        } else if (init_2string != NULL) {
  4375. X            PUTS(init_2string);
  4376. X        }
  4377. X        FLUSH;
  4378. X
  4379. X        if (set_lr_margin != NULL) {
  4380. X            PUTS(tparm(set_lr_margin, 0, columns - 1));
  4381. X        } else if (set_left_margin_parm != NULL
  4382. X               && set_right_margin_parm != NULL) {
  4383. X            PUTS(tparm(set_left_margin_parm, 0));
  4384. X            PUTS(tparm(set_right_margin_parm, columns - 1));
  4385. X        } else if (clear_margins != NULL && set_left_margin != NULL
  4386. X               && set_right_margin != NULL) {
  4387. X            PUTS(clear_margins);
  4388. X            if (carriage_return != NULL) {
  4389. X                PUTS(carriage_return);
  4390. X            } else {
  4391. X                PUTCHAR('\r');
  4392. X            }
  4393. X            PUTS(set_left_margin);
  4394. X            if (parm_right_cursor) {
  4395. X                PUTS(tparm(parm_right_cursor, columns - 1));
  4396. X            } else {
  4397. X                for(i = 0; i < columns - 1; i++) {
  4398. X                    PUTCHAR(' ');
  4399. X                }
  4400. X            }
  4401. X            PUTS(set_right_margin);
  4402. X            if (carriage_return != NULL) {
  4403. X                PUTS(carriage_return);
  4404. X            } else {
  4405. X                PUTCHAR('\r');
  4406. X            }
  4407. X        }
  4408. X        FLUSH;
  4409. X
  4410. X        if (init_tabs != 8) {
  4411. X            if (clear_all_tabs != NULL && set_tab != NULL) {
  4412. X                for(i = 0; i < columns - 1; i += 8) {
  4413. X                    if (parm_right_cursor) {
  4414. X                        PUTS(tparm(parm_right_cursor,
  4415. X                             8));
  4416. X                    } else {
  4417. X                        for(j = 0; j < 8; j++) {
  4418. X                            PUTCHAR(' ');
  4419. X                        }
  4420. X                    }
  4421. X                    PUTS(set_tab);
  4422. X                }
  4423. X                FLUSH;
  4424. X            }
  4425. X        }
  4426. X
  4427. X        if (reset && reset_file != NULL) {
  4428. X            f = fopen(reset_file, "r");
  4429. X            if (f == NULL) {
  4430. X                quit(errno, "Can't open reset_file: '%s'",
  4431. X                     reset_file);
  4432. X            }
  4433. X            while((c = fgetc(f)) != EOF) {
  4434. X                PUTCHAR(c);
  4435. X            }
  4436. X            fclose(f);
  4437. X        } else if (init_file != NULL) {
  4438. X            f = fopen(init_file, "r");
  4439. X            if (f == NULL) {
  4440. X                quit(errno, "Can't open init_file: '%s'",
  4441. X                     init_file);
  4442. X            }
  4443. X            while((c = fgetc(f)) != EOF) {
  4444. X                PUTCHAR(c);
  4445. X            }
  4446. X            fclose(f);
  4447. X        }
  4448. X        FLUSH;
  4449. X
  4450. X        if (reset && reset_3string != NULL) {
  4451. X            PUTS(reset_3string);
  4452. X        } else if (init_2string != NULL) {
  4453. X            PUTS(init_3string);
  4454. X        }
  4455. X        FLUSH;
  4456. X        return 0;
  4457. X    }
  4458. X
  4459. X    s = tigetstr(argv[1]);
  4460. X
  4461. X    if (s == (char *) -1) {
  4462. X        quit(-1, "unknown capname '%s'", argv[1]);
  4463. X    } else if (s == NULL) {
  4464. X        return 0;
  4465. X    }
  4466. X
  4467. X    putp(s);
  4468. X
  4469. X    return 0;
  4470. X}
  4471. END_OF_FILE
  4472. if test 3436 -ne `wc -c <'tput.c'`; then
  4473.     echo shar: \"'tput.c'\" unpacked with wrong size!
  4474. fi
  4475. # end of 'tput.c'
  4476. fi
  4477. if test -f 'tputs.c' -a "${1}" != "-c" ; then 
  4478.   echo shar: Will not clobber existing file \"'tputs.c'\"
  4479. else
  4480. echo shar: Extracting \"'tputs.c'\" \(4288 characters\)
  4481. sed "s/^X//" >'tputs.c' <<'END_OF_FILE'
  4482. X/*
  4483. X * tputs.c
  4484. X *
  4485. X * By Ross Ridge
  4486. X * Public Domain
  4487. X * 92/06/04 11:41:15
  4488. X *
  4489. X * Output a terminal capability string with any needed padding
  4490. X *
  4491. X */
  4492. X
  4493. X#include "defs.h"
  4494. X#include "term.h"
  4495. X
  4496. X#include <ctype.h>
  4497. X
  4498. X#ifdef USE_SCCS_IDS
  4499. static const char SCCSid[] = "@(#) mytinfo tputs.c 3.3 92/06/04 public domain, By Ross Ridge";
  4500. X#endif
  4501. X
  4502. X#ifdef TEST
  4503. X#define def_prog_mode()    (OK)
  4504. X#define _norm_output()    ((void)(0))
  4505. X#define _lit_output()    (1)
  4506. X#endif
  4507. X
  4508. X/*
  4509. X * BITSPERCHAR (as actually transmitted over a serial line) is usually 10
  4510. X * (not 8). 1 stop bit, 1 start bit, 7 data bits, and one parity bit.
  4511. X */
  4512. X
  4513. X#define BITSPERCHAR    10
  4514. X
  4515. X#ifdef USE_FAKE_STDIO
  4516. X#undef putchar
  4517. X#endif
  4518. X
  4519. X#define PUTCHAR(c) (outc == (int (*)()) 0 ? (putchar(c)):(*outc)(c))
  4520. X
  4521. int
  4522. tputs(sp, count, outc)
  4523. register char *sp;
  4524. int count;
  4525. register int (*outc)();
  4526. X{
  4527. X    register int l;
  4528. X    register long cnt;
  4529. X    int must_pad, multiply_pad;
  4530. X    int forced_lit = 0;
  4531. X
  4532. X    /* some programmes expect this behaviour from tputs */
  4533. X    if (sp == NULL) {
  4534. X#ifdef DEBUG
  4535. X        fprintf(stderr, "tputs: NULL\n");    
  4536. X#endif
  4537. X        return 0;
  4538. X    }
  4539. X
  4540. X    if (cur_term->termcap) {
  4541. X        _figure_termcap();
  4542. X    }
  4543. X
  4544. X    while(*sp != '\0') {
  4545. X        switch(*sp) {
  4546. X        case '\\':
  4547. X            switch(*++sp) {
  4548. X            case 'n': PUTCHAR('\n'); sp++; break;
  4549. X            case 'b': PUTCHAR('\b'); sp++; break;
  4550. X            case 't': PUTCHAR('\t'); sp++; break;
  4551. X            case 'r': PUTCHAR('\r'); sp++; break;
  4552. X            case 'f': PUTCHAR('\f'); sp++; break;
  4553. X            case 'l': PUTCHAR('\012'); sp++; break;
  4554. X            case 's': PUTCHAR(' '); sp++; break;
  4555. X            case 'e': case 'E': PUTCHAR('\033'); sp++; break;
  4556. X
  4557. X            case '^':
  4558. X            case '\\':
  4559. X            case ',':
  4560. X            case ':':
  4561. X            case '\'':
  4562. X            case '$':
  4563. X                PUTCHAR(*sp++);
  4564. X                break;
  4565. X
  4566. X            case '0':
  4567. X                if (*(sp + 1) < '0' || *(sp + 1) > '7') {
  4568. X                    PUTCHAR('\200'); /* I'd prefer \0 */
  4569. X                    sp++;
  4570. X                    break;
  4571. X                }
  4572. X                ;/* FALLTHROUGH */
  4573. X            case '1': case '2': case '3': case '4':
  4574. X            case '5': case '6': case '7':
  4575. X                l = *sp++ - '0';
  4576. X                if (*sp >= '0' && *sp <= '7') {
  4577. X                    l = l * 8 + (*sp++ - '0');
  4578. X                    if (*sp >= '0' && *sp <= '7')
  4579. X                        l = l * 8 + (*sp++ - '0');
  4580. X                }
  4581. X                PUTCHAR(l);
  4582. X                break;
  4583. X
  4584. X            case '\0':
  4585. X                PUTCHAR('\\');
  4586. X                break;
  4587. X
  4588. X            case '@':
  4589. X                if (!forced_lit)
  4590. X                    forced_lit = _lit_output();
  4591. X                sp++;
  4592. X                break;
  4593. X
  4594. X            default:
  4595. X                PUTCHAR('\\');
  4596. X                PUTCHAR(*sp++);
  4597. X                break;
  4598. X            }
  4599. X            break;
  4600. X        case '^':
  4601. X            if (*++sp == '\0')
  4602. X                break;
  4603. X            l = *sp - '@';
  4604. X            if (l > 31)
  4605. X                l -= 32;
  4606. X            if (l < 0 || l > 31) {
  4607. X                PUTCHAR('^');
  4608. X                PUTCHAR(*sp++);
  4609. X            } else {
  4610. X                PUTCHAR(l);
  4611. X                sp++;
  4612. X            }
  4613. X            break;
  4614. X        case '$':
  4615. X            if (*++sp != '<') {
  4616. X                PUTCHAR('$');
  4617. X                break;
  4618. X            }
  4619. X            must_pad = 0;
  4620. X            multiply_pad = 0;
  4621. X            l = 0;
  4622. X            sp++;
  4623. X            while (isdigit(*sp))
  4624. X                l = l * 10 + (*sp++ - '0');
  4625. X            l *= 10;
  4626. X            if (*sp == '.') {
  4627. X                sp++;
  4628. X                if (isdigit(*sp))
  4629. X                    l += *sp++ - '0';
  4630. X            }
  4631. X            if (*sp == '/') {
  4632. X                must_pad = 1;
  4633. X                if (*++sp == '*') {
  4634. X                    multiply_pad = 1;
  4635. X                    sp++;
  4636. X                }
  4637. X            } else if (*sp == '*') {
  4638. X                multiply_pad = 1;
  4639. X                if (*++sp == '/') {
  4640. X                    must_pad = 1;
  4641. X                    sp++;
  4642. X                }
  4643. X            }
  4644. X            if (*sp != '>') {
  4645. X                PUTCHAR('p');
  4646. X                PUTCHAR('a');
  4647. X                PUTCHAR('d');
  4648. X                PUTCHAR('?');
  4649. X                break;
  4650. X            }
  4651. X            sp++;
  4652. X#ifdef TEST
  4653. X            printf("\nl = %d", l);
  4654. X#endif
  4655. X            if (cur_term->pad || must_pad) {
  4656. X                cnt = ((long) l * cur_term->baudrate
  4657. X                       * (multiply_pad ? count : 1) 
  4658. X                       + (10000L * BITSPERCHAR / 2L))
  4659. X                      / (10000L * BITSPERCHAR);
  4660. X#ifdef TEST
  4661. X                printf("; cnt = %d\n", cnt);
  4662. X#endif
  4663. X                while(cnt--)
  4664. X                    PUTCHAR(cur_term->padch);
  4665. X            }
  4666. X#ifdef TEST
  4667. X            printf("\n");
  4668. X#endif
  4669. X            break;
  4670. X        default:
  4671. X            PUTCHAR(*sp++);
  4672. X        }
  4673. X    }
  4674. X    if (forced_lit)
  4675. X        _norm_output();
  4676. X    return OK;
  4677. X}
  4678. X
  4679. int
  4680. putp(str)
  4681. char *str; {
  4682. X    return(tputs(str, 1,(int (*)()) 0));
  4683. X}
  4684. X
  4685. X#ifdef TEST
  4686. X
  4687. TERMINAL test_term, *cur_term = &test_term;
  4688. X
  4689. void
  4690. putch(c)
  4691. int c; {
  4692. X    c &= 0xff;
  4693. X    if (c > 127 || c < 0) {
  4694. X        printf("\\%03o", c);
  4695. X    } else if (c < 32) {
  4696. X        printf("^%c", c + '@');
  4697. X    } else if (c == 127) {
  4698. X        printf("^?");
  4699. X    } else {
  4700. X        putchar(c);
  4701. X    }
  4702. X}
  4703. X
  4704. char line[MAX_LINE];
  4705. X
  4706. int
  4707. main(argc, argv)
  4708. int argc;
  4709. char **argv; {
  4710. X    test_term.termcap = 0;
  4711. X    test_term.baudrate = 1200;
  4712. X    test_term.pad = 0;
  4713. X    test_term.padch = 0;
  4714. X    if (argc > 1) 
  4715. X        test_term.baudrate = atoi(argv[1]);
  4716. X    if (argc > 2)
  4717. X        test_term.padch = argv[2][0];
  4718. X    if (argc > 3)
  4719. X        test_term.pad = 1;
  4720. X
  4721. X    putchar('\n');
  4722. X
  4723. X    while(gets(line) != NULL) {
  4724. X        tputs(line, 7, putch);
  4725. X        putchar('\n');
  4726. X    }
  4727. X    return 0;
  4728. X}
  4729. X#endif
  4730. END_OF_FILE
  4731. if test 4288 -ne `wc -c <'tputs.c'`; then
  4732.     echo shar: \"'tputs.c'\" unpacked with wrong size!
  4733. fi
  4734. # end of 'tputs.c'
  4735. fi
  4736. if test -f 'version.h' -a "${1}" != "-c" ; then 
  4737.   echo shar: Will not clobber existing file \"'version.h'\"
  4738. else
  4739. echo shar: Extracting \"'version.h'\" \(101 characters\)
  4740. sed "s/^X//" >'version.h' <<'END_OF_FILE'
  4741. X/*
  4742. X * version.h
  4743. X *
  4744. X * By Ross Ridge
  4745. X * Public Domain
  4746. X *
  4747. X */
  4748. X
  4749. X#define RELEASE        3
  4750. X#define PATCHLEVEL    0
  4751. END_OF_FILE
  4752. if test 101 -ne `wc -c <'version.h'`; then
  4753.     echo shar: \"'version.h'\" unpacked with wrong size!
  4754. fi
  4755. # end of 'version.h'
  4756. fi
  4757. echo shar: End of archive 1 \(of 3\).
  4758. cp /dev/null ark1isdone
  4759. MISSING=""
  4760. for I in 1 2 3 ; do
  4761.     if test ! -f ark${I}isdone ; then
  4762.     MISSING="${MISSING} ${I}"
  4763.     fi
  4764. done
  4765. if test "${MISSING}" = "" ; then
  4766.     echo You have unpacked all 3 archives.
  4767.     rm -f ark[1-9]isdone
  4768. else
  4769.     echo You still need to unpack the following archives:
  4770.     echo "        " ${MISSING}
  4771. fi
  4772. ##  End of shell archive.
  4773. exit 0
  4774.