home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sources / unix / 277 < prev    next >
Encoding:
Internet Message Format  |  1992-12-27  |  89.0 KB

  1. Path: sparky!uunet!paladin.american.edu!gatech!concert!decwrl!pa.dec.com!vixie
  2. From: ross@zooid.guild.org (Ross Ridge)
  3. Newsgroups: comp.sources.unix
  4. Subject: v26i078: mytinfo - a replacement for terminfo and termcap, Part02/03
  5. Date: 27 Dec 1992 22:50:33 GMT
  6. Organization: Digital Equipment Corporation Palo Alto, CA
  7. Lines: 3828
  8. Sender: unix-sources-moderator@pa.dec.com
  9. Approved: vixie@pa.dec.com
  10. Message-ID: <1hlbvpINN74s@usenet.pa.dec.com>
  11. NNTP-Posting-Host: cognition.pa.dec.com
  12. Originator: vixie@cognition.pa.dec.com
  13.  
  14. Submitted-By: ross@zooid.guild.org (Ross Ridge)
  15. Posting-Number: Volume 26, Issue 78
  16. Archive-Name: mytinfo/part02
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 2 (of 3)."
  25. # Contents:  DIFFS-moderator INSTALL Makefile cap_list findterm.c
  26. #   gettcap.c gettinfo.c qsort.c sprintf.c tcapconv.c ttest.c tty.c
  27. # Wrapped by vixie@cognition.pa.dec.com on Sun Dec 27 14:45:19 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'DIFFS-moderator' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'DIFFS-moderator'\"
  31. else
  32. echo shar: Extracting \"'DIFFS-moderator'\" \(5496 characters\)
  33. sed "s/^X//" >'DIFFS-moderator' <<'END_OF_FILE'
  34. These were the changes I made to this package to make it easier to build
  35. and install.  The files I edited are present as *.orig.  --vix, 27dec92
  36. X
  37. Only in ../../../New/mytinfo: MANIFEST.BAK
  38. diff -r -c ./Makefile ../../../New/mytinfo/Makefile
  39. X*** ./Makefile    Sun Dec 27 14:14:24 1992
  40. X--- ../../../New/mytinfo/Makefile    Fri Jul 10 03:42:25 1992
  41. X***************
  42. X*** 12,22 ****
  43. X  
  44. X  SHELL = /bin/sh
  45. X  
  46. X- DESTROOT =
  47. X- DESTPATH = $(DESTROOT)/usr/local
  48. X- DESTLIB = $(DESTPATH)/lib
  49. X- DESTINC = $(DESTPATH)/include
  50. X- 
  51. X  #
  52. X  # Your generic Unix C compiler.
  53. X  #
  54. X--- 12,17 ----
  55. X***************
  56. X*** 45,51 ****
  57. X  #
  58. X  #RANLIB = :
  59. X  
  60. X! LINKLIB = libmytinfo.a
  61. X  OTHERLIB =
  62. X  #
  63. X  # Set LINKLIB and OTHERLIB to libmytinfo.so for ELF dynamic libs.
  64. X--- 40,46 ----
  65. X  #
  66. X  #RANLIB = :
  67. X  
  68. X! LINKLIB = mytinfo.a
  69. X  OTHERLIB =
  70. X  #
  71. X  # Set LINKLIB and OTHERLIB to libmytinfo.so for ELF dynamic libs.
  72. X***************
  73. X*** 86,116 ****
  74. X  
  75. X  DEFS_H = defs.h config.h fake_stdio.h
  76. X  
  77. X! all: $(LINKLIB) $(OTHERLIB) term.h tconv cap2info tic clear tset tput
  78. X  
  79. X! install: $(LINKLIB) term.h
  80. X!     cp $(LINKLIB) $(DESTLIB); $(RANLIB) $(DESTLIB)/$(LINKLIB)
  81. X!     cp term.h $(DESTINC)
  82. X! 
  83. X! it: $(LINKLIB) $(OTHERLIB)
  84. X      
  85. X! libmytinfo.a: $(OBJS)
  86. X!     rm -f libmytinfo.a
  87. X!     $(AR) $(ARFLAGS) libmytinfo.a $(OBJS)
  88. X!     $(RANLIB) libmytinfo.a
  89. X  
  90. X  libmytinfo.so: $(OBJS)
  91. X      ld -G -o libmytinfo.so $(OBJS)
  92. X  
  93. X! libmytinfo_g.a: $(OBJS)
  94. X!     rm -f libmytinfo_g.a
  95. X!     $(AR) $(ARFLAGS) libmytinfo_g.a $(OBJS)
  96. X!     $(RANLIB) libmytinfo_g.a
  97. X  
  98. X! libmytinfo_p.a: $(OBJS)
  99. X!     rm -f libmytinfo_p.a
  100. X!     $(AR) $(ARFLAGS) ligmytinfo_p.a $(OBJS)
  101. X!     $(RANLIB) libmytinfo_p.a
  102. X  
  103. X  debug: 
  104. X      $(MAKE) DFLAGS=$(DEBUG) mytinfo_g.a
  105. X--- 81,107 ----
  106. X  
  107. X  DEFS_H = defs.h config.h fake_stdio.h
  108. X  
  109. X! it: mytinfo.a $(OTHERLIB)
  110. X  
  111. X! all: mytinfo.a $(OTHERLIB) term.h tconv cap2info tic clear tset tput
  112. X      
  113. X! mytinfo.a: $(OBJS)
  114. X!     rm -f mytinfo.a
  115. X!     $(AR) $(ARFLAGS) mytinfo.a $(OBJS)
  116. X!     $(RANLIB) mytinfo.a
  117. X  
  118. X  libmytinfo.so: $(OBJS)
  119. X      ld -G -o libmytinfo.so $(OBJS)
  120. X  
  121. X! mytinfo_g.a: $(OBJS)
  122. X!     rm -f mytinfo_g.a
  123. X!     $(AR) $(ARFLAGS) mytinfo_g.a $(OBJS)
  124. X!     $(RANLIB) mytinfo_g.a
  125. X  
  126. X! mytinfo_p.a: $(OBJS)
  127. X!     rm -f mytinfo_p.a
  128. X!     $(AR) $(ARFLAGS) mytinfo_p.a $(OBJS)
  129. X!     $(RANLIB) mytinfo_p.a
  130. X  
  131. X  debug: 
  132. X      $(MAKE) DFLAGS=$(DEBUG) mytinfo_g.a
  133. Only in .: cap2info
  134. Only in .: clear.tcap
  135. Only in .: clear.tinfo
  136. diff -r -c ./config.h ../../../New/mytinfo/config.h
  137. X*** ./config.h    Sun Dec 27 13:58:50 1992
  138. X--- ../../../New/mytinfo/config.h    Fri Jul 10 03:42:19 1992
  139. X***************
  140. X*** 20,40 ****
  141. X  
  142. X  #define USE_TERMIO        /* use termio (SysIII, SysV) */
  143. X  #undef USE_SGTTY        /* use sgtty (v7, BSD) */
  144. X! #define USE_WINSZ        /* get window size from the tty driver */
  145. X  #undef USE_STRINGS        /* include <strings.h> instead of <string.h> */
  146. X  #define USE_MYBSEARCH        /* your library doesn't have bsearch */
  147. X! #define USE_MYSTRTOK        /* your library doesn't have strtok */
  148. X! #define USE_MYQSORT        /* your library doesn't have qsort */
  149. X! #define USE_MYMKDIR        /* your library doesn't have mkdir */
  150. X  #define USE_MEMORY        /* you have an <memory.h> header */
  151. X  #define USE_FAKE_STDIO        /* don't use real stdio */
  152. X  #undef USE_DOPRNT        /* no vfprintf, use _doprnt */
  153. X  
  154. X! #define USE_SHORT_BSEARCH    /* speeds up MYBSEARCH on most machines */
  155. X  
  156. X! #define USE_SMALLMEM         /* save some memory */
  157. X  
  158. X! #undef USE_UPBC_KLUDGE        /* do tgoto like real togo */
  159. X  #undef USE_EXTERN_UPBC        /* get cuu1 and cub1 from externs UP and BC */
  160. X  #undef USE_LITOUT_KLUDGE    /* an alternate tgoto kludge, not recommened */
  161. X  
  162. X--- 20,40 ----
  163. X  
  164. X  #define USE_TERMIO        /* use termio (SysIII, SysV) */
  165. X  #undef USE_SGTTY        /* use sgtty (v7, BSD) */
  166. X! #undef USE_WINSZ        /* get window size from the tty driver */
  167. X  #undef USE_STRINGS        /* include <strings.h> instead of <string.h> */
  168. X  #define USE_MYBSEARCH        /* your library doesn't have bsearch */
  169. X! #undef USE_MYSTRTOK        /* your library doesn't have strtok */
  170. X! #undef USE_MYQSORT        /* your library doesn't have qsort */
  171. X! #undef USE_MYMKDIR        /* your library doesn't have mkdir */
  172. X  #define USE_MEMORY        /* you have an <memory.h> header */
  173. X  #define USE_FAKE_STDIO        /* don't use real stdio */
  174. X  #undef USE_DOPRNT        /* no vfprintf, use _doprnt */
  175. X  
  176. X! #undef USE_SHORT_BSEARCH    /* speeds up MYBSEARCH on most machines */
  177. X  
  178. X! #undef USE_SMALLMEM         /* save some memory */
  179. X  
  180. X! #define USE_UPBC_KLUDGE        /* do tgoto like real togo */
  181. X  #undef USE_EXTERN_UPBC        /* get cuu1 and cub1 from externs UP and BC */
  182. X  #undef USE_LITOUT_KLUDGE    /* an alternate tgoto kludge, not recommened */
  183. X  
  184. diff -r -c ./fake_stdio.h ../../../New/mytinfo/fake_stdio.h
  185. X*** ./fake_stdio.h    Sun Dec 27 14:10:12 1992
  186. X--- ../../../New/mytinfo/fake_stdio.h    Fri Jul 10 03:42:22 1992
  187. X***************
  188. X*** 58,64 ****
  189. X  FILE *fdopen();
  190. X  #endif
  191. X  
  192. X! #if !defined(NULL) && !defined(USE_STRINGS)
  193. X  #define NULL ((anyptr) 0)
  194. X  #endif
  195. X  
  196. X--- 58,64 ----
  197. X  FILE *fdopen();
  198. X  #endif
  199. X  
  200. X! #ifndef NULL
  201. X  #define NULL ((anyptr) 0)
  202. X  #endif
  203. X  
  204. Only in .: libmytinfo.a
  205. Only in .: mytinfo.a
  206. Only in .: tconv
  207. Only in .: term.h
  208. diff -r -c ./term.tail ../../../New/mytinfo/term.tail
  209. X*** ./term.tail    Sun Dec 27 14:11:31 1992
  210. X--- ../../../New/mytinfo/term.tail    Fri Jul 10 03:42:17 1992
  211. X***************
  212. X*** 8,14 ****
  213. X  #ifndef ICANON
  214. X  #include <termio.h>
  215. X  #endif
  216. X! #if defined(_USE_WINSZ) && defined(xenix)
  217. X  #include <sys/stream.h>
  218. X  #include <sys/ptem.h>
  219. X  #endif
  220. X--- 8,14 ----
  221. X  #ifndef ICANON
  222. X  #include <termio.h>
  223. X  #endif
  224. X! #ifdef _USE_WINSZ
  225. X  #include <sys/stream.h>
  226. X  #include <sys/ptem.h>
  227. X  #endif
  228. Only in .: tic
  229. Only in .: tput
  230. Only in .: tset
  231. END_OF_FILE
  232. if test 5496 -ne `wc -c <'DIFFS-moderator'`; then
  233.     echo shar: \"'DIFFS-moderator'\" unpacked with wrong size!
  234. fi
  235. # end of 'DIFFS-moderator'
  236. fi
  237. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  238.   echo shar: Will not clobber existing file \"'INSTALL'\"
  239. else
  240. echo shar: Extracting \"'INSTALL'\" \(7255 characters\)
  241. sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  242. Compiling this package requires a fair bit of knowledge about your system.
  243. There are no automatic configuration programmes or prepared configuration
  244. files for different type of systems.  You will need to edit the Makefile
  245. to specify things like which compiler to use and any options it needs.
  246. The file config.h needs to be edited to reflect the system you are
  247. using and to enable and/or disable certain features.
  248. X
  249. Defines in config.h
  250. X===================
  251. X
  252. USE_ANSIC 
  253. X
  254. Normally this will be defined automaticly if __STDC__ is defined, but
  255. if your compile isn't truly ANSI C compliant you may need to undefine this.
  256. X
  257. USE_TERMIO
  258. X
  259. Define this if your system uses the termio tty driver.  System III and
  260. System V use termio. 
  261. X
  262. USE_SGTTY
  263. X
  264. Define this if your system uses the "sgtty" tty driver.  V7 Unix and BSD
  265. use sgtty.
  266. X
  267. USE_WINSZ
  268. X
  269. If you defined USE_SGTTY you can define this if your system supports
  270. SIGWINSZ and the accompaning ioctls.  If this is defined the library
  271. will get number of columns and lines from the tty driver not the
  272. terminal description.  BSD 4.3 supports SIGWINSZ.  This will also work
  273. if USE_TERMIO is defined on some hybrid System V machines such as Release 4.
  274. X
  275. Do not define both USE_TERMIO and USE_SGTTY.  If your system supports both
  276. you'd probably be better of defining USE_TERMIO.  If your system supports
  277. neither termio or sgtty you can leave USE_TERMIO and USE_SGTTY undefined,
  278. but this is only recommended for use with micomputers.
  279. X
  280. USE_STRINGS
  281. X
  282. If you define this then the header file <strings.h> will be included
  283. and BSD type string library assumed (index instead of strchr), otherwise
  284. X<string.h> will included.  If you have a BSD type system define this.
  285. If you have an ANSI C, System III, or System V type of system leave it
  286. undefined.
  287. X
  288. USE_MYBSEARCH
  289. X
  290. If your system's C library doesn't include bsearch, define this.
  291. Most System V systems have bsearch.  However even your C library has this
  292. function you still may want to define USE_MYBSEARCH, see USE_SHORT_BSEARCH
  293. below.  ("MYBSEARCH" is misnomer, I didn't write this routine.)
  294. X
  295. USE_SHORT_BSEARCH
  296. X
  297. If you define USE_MYBSEARCH you can define this so that the bsearch
  298. routine that library uses the type short instead of size_t (usually long)
  299. for it's arguments.  This results a large speedup on 68000 based machines
  300. and possibly a significant speedup on others as well.  However on some CPU's
  301. defining this will only make things slower.
  302. X
  303. USE_MYSTRTOK 
  304. X
  305. If your system's C library doesn't include strtok, define this.
  306. Most ANSI C, System III, and System V systems have this.
  307. X
  308. USE_MYQSORT
  309. X
  310. If your system's C library doesn't include qsort, define this.
  311. All most all systems should have this function, if it doesn't complain
  312. to your vendor.  The qsort routine comes from the GNU Emacs distribution.
  313. X
  314. USE_MYMKDIR
  315. X
  316. Define this if your system doesn't have the mkdir library function call.  
  317. My routine simply calls the system command mkdir, you may have to
  318. edit mkdir.c if the pathname of that command isn't "/bin/mkdir". 
  319. X
  320. USE_MEMORY
  321. X
  322. If your system has a <memory.h> header define this.  If USE_MEMORY
  323. is not defined bcopy will used instead of memcpy.
  324. X
  325. USE_SMALLMEM 
  326. X
  327. Use you can define use this to save some memory, but it doesn't
  328. save much at moment, and will only slow the library down.
  329. X
  330. USE_FAKE_STDIO
  331. X
  332. If you define this then the library won't use the real stdio but a
  333. fake one instead.  This is for compatiblity with termcap and vi which
  334. don't use stdio.
  335. X
  336. USE_DOPRNT
  337. X
  338. If you don't have a vfprintf function, but you have a _doprnt function
  339. define this.  If you don't have either than you can compile the library
  340. but not the support programmes.  System V has vfprintf and most Unixes
  341. have a _doprnt (but probably not documented).  BSD has released a freely
  342. distributable vfprintf for BSD Unixes.
  343. X
  344. USE_UPBC_KLUDGE
  345. X
  346. Define this if you want the library's tgoto to work like termcap's tgoto
  347. and avoid putting ^D, and \n into an output string by using the cursor up
  348. and backspace strings.
  349. X
  350. USE_EXTERN_UPBC
  351. X
  352. If you defined USE_UPBC_KLUDGE you can define this so tgoto will,
  353. like termcap's tgoto, get the cursor up and backspace strings from the
  354. externs UP and BC instead from the library's internal record.
  355. X
  356. USE_LITOUT_KLUDGE
  357. X
  358. Don't define this.  It's another kludge for tgoto.
  359. X
  360. If neither USE_UPBC_KLUDGE or USE_LITOUT_KLUDGE is defined then tgoto
  361. won't worry about putting ^D, and \n in a string.
  362. X
  363. USE_PROTOTYPES
  364. X
  365. Define this if your compiler supports ANSI C style prototypes.
  366. X
  367. USE_STDLIB
  368. X
  369. Define this if your system has an <stdlib.h> header.
  370. X
  371. USE_STDARG
  372. X
  373. Define this if your system has an <stdarg.h> header.  If this isn't
  374. defined <varargs.h> will be included instead.
  375. X
  376. USE_STDDEF
  377. X
  378. Define this if your system has an <stddef.h> header.  If this isn't
  379. defined <sys/types.h> will be included instead.
  380. X
  381. typedef char *anyptr;
  382. X
  383. You should change the typedef to a type that any pointer can be assigned
  384. to or from.  ANSI C compilers can use "typedef void *anyptr", most
  385. other compilers should use "typedef char *anyptr".
  386. X
  387. X#define mysize_t unsigned
  388. X
  389. X"mysize_t" needs to defined as the type of the size of an object, or
  390. the type of the sizeof operator.  Traditional usage is "unsigned", for
  391. ANSI C you should define mysize_t as "size_t".
  392. X
  393. TERMCAPFILE
  394. X
  395. Define this to a string containing the default termcap file(s) to look
  396. for terminal descriptions in.  Multiple filenames should be seperated
  397. by spaces and environment variables can be specfied by prefixing them
  398. with dolar signs ($).  eg:
  399. X    #define TERMCAPFILE "$TERMCAPFILE $HOME/.termcap /etc/termcap"
  400. X
  401. TERMINFOSRC
  402. X
  403. Define this to a string containing the default terminfo source file to
  404. look for terminal descriptions in.
  405. X
  406. TERMINFODIR
  407. X
  408. Define this as the directory containing the default terminfo database,
  409. usually "/usr/lib/terminfo".
  410. X
  411. Any of TERMCAPFILE, TERMINFOSRC or TERMINFODIR can be left undefined.
  412. X
  413. X
  414. defs.h
  415. X======
  416. X
  417. You may also need to edit defs.h and change the definitions of MAX_BUF,
  418. MAX_LINE, and MAX_NAME.  Unless you are seriously starved for memory I
  419. don't recomend making them smaller.
  420. X
  421. X
  422. cap_list
  423. X========
  424. X
  425. You can add new capabilities to the file cap_list.  You must provide
  426. a type, terminfo variable name, terminfo capname, and termcap name for
  427. all capabilities and you must make sure they are all unique.
  428. X
  429. X
  430. Making in the library
  431. X=====================
  432. X
  433. Once you've configured the package you can just type "make" and it
  434. will build the library and the "term.h" header.  You can enter
  435. X"make all" to make the library and the support programmes, tconv,
  436. cap2info, tic, clear, tput and tset.  If you want a profiled library
  437. you can enter "make profiled".  You can remove all the intermediate
  438. files with "make clean".  "make spotless" will remove the target
  439. files as well.
  440. X
  441. X
  442. Installing the library
  443. X======================
  444. X
  445. As for installing it, that's up to you.  Depending on how much you
  446. plan to use the libraries and whether or not you have termcap and/or
  447. terminfo already you can install them "standard" places (ie. /usr/lib,
  448. X/usr/include, /usr/bin), in local directories, or just leave them in
  449. the source directory.  However if you are compiling programmes that
  450. use terminfo and linking it with this library you must make sure that
  451. this library's term.h file is included in your programme and not the
  452. system supplied one.
  453. END_OF_FILE
  454. if test 7255 -ne `wc -c <'INSTALL'`; then
  455.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  456. fi
  457. # end of 'INSTALL'
  458. fi
  459. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  460.   echo shar: Will not clobber existing file \"'Makefile'\"
  461. else
  462. echo shar: Extracting \"'Makefile'\" \(8696 characters\)
  463. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  464. X#
  465. X# Makefile
  466. X#
  467. X# By Ross Ridge
  468. X# Public Domain
  469. X# 92/06/04 11:43:09
  470. X#
  471. X# make the terminfo/termcap library
  472. X#
  473. X# @(#) mytinfo Makefile 3.7 92/06/04 public domain, By Ross Ridge
  474. X#
  475. X
  476. SHELL = /bin/sh
  477. X
  478. DESTROOT =
  479. DESTPATH = $(DESTROOT)/usr/local
  480. DESTLIB = $(DESTPATH)/lib
  481. DESTINC = $(DESTPATH)/include
  482. X
  483. X#
  484. X# Your generic Unix C compiler.
  485. X#
  486. CC = cc
  487. CFLAGS = $(DFLAGS)
  488. X#
  489. X# For the GNU C compiler.
  490. X#
  491. X#CC = gcc
  492. X#CFLAGS = $(DFLAGS) -O -Wall -fstrength-reduce -I.
  493. X#
  494. X# For the Xenix compiler
  495. X#
  496. X#CC = cc
  497. X#CFLAGS = $(DFLAGS) -W1 -Ox
  498. X
  499. LDFLAGS = $(DFLAGS)
  500. DEBUG = -g
  501. X
  502. X#
  503. X# For systems that need their libraries ranlib'ed
  504. X#
  505. RANLIB = ranlib
  506. X#
  507. X# For systems that don't (most System V's)
  508. X#
  509. X#RANLIB = :
  510. X
  511. LINKLIB = libmytinfo.a
  512. OTHERLIB =
  513. X#
  514. X# Set LINKLIB and OTHERLIB to libmytinfo.so for ELF dynamic libs.
  515. X#
  516. X#LINKLIB = libmytinfo.so
  517. X#OTHERLIB = libmytinfo.so
  518. X
  519. AR = ar
  520. ARFLAGS = qcv
  521. X
  522. CAPS = 1000
  523. X
  524. ALLCSRCS = addstr.c buildpath.c caps.c clear.c compar.c fake_stdio.c\
  525. fillterm.c findcap.c findterm.c getother.c gettbin.c gettcap.c gettinfo.c\
  526. mkbinorder.c mkcaplist.c mkcapsort.c mktermhead.c mkversion.c\
  527. quit.c readcaps.c sprintf.c tcapconv.c tcapvars.c tconv.c\
  528. termcap.c terminfo.c tgoto.c tiget.c tmatch.c tparm.c tput.c tputs.c\
  529. tset.c ttest.c tty.c
  530. X
  531. ALLSRCS = $(ALLCSRCS) qsort.c bsearch.c strtok.c mkdir.c \
  532. term.tail defs.h config.h cap_list terminfo.src bin_order fake_stdio.h tconv.1
  533. X
  534. ALLOTHERS = Makefile TODO README README.doc INSTALL DECL version.h
  535. X
  536. ALL = $(ALLSRCS) $(ALLOTHERS)
  537. X
  538. SRCS = addstr.c binorder.c buildpath.c caplist.c capsort.c compar.c\
  539. fake_stdio.c fillterm.c findcap.c findterm.c getother.c gettbin.c\
  540. gettcap.c gettinfo.c sprintf.c tcapconv.c tcapvars.c termcap.c\
  541. terminfo.c tgoto.c tiget.c tmatch.c tparm.c tputs.c tty.c version.c
  542. X
  543. OBJS = addstr.o binorder.o buildpath.o caplist.o capsort.o compar.o\
  544. fake_stdio.o fillterm.o findcap.o findterm.o getother.o gettbin.o\
  545. gettcap.o gettinfo.o sprintf.o tcapconv.o tcapvars.o termcap.o\
  546. terminfo.o tgoto.o tiget.o tmatch.o tparm.o tputs.o tty.o version.o
  547. X
  548. LINTFLAGS = 
  549. X
  550. DEFS_H = defs.h config.h fake_stdio.h
  551. X
  552. all: $(LINKLIB) $(OTHERLIB) term.h tconv cap2info tic clear tset tput
  553. X
  554. install: $(LINKLIB) term.h
  555. X    cp $(LINKLIB) $(DESTLIB); $(RANLIB) $(DESTLIB)/$(LINKLIB)
  556. X    cp term.h $(DESTINC)
  557. X
  558. it: $(LINKLIB) $(OTHERLIB)
  559. X    
  560. libmytinfo.a: $(OBJS)
  561. X    rm -f libmytinfo.a
  562. X    $(AR) $(ARFLAGS) libmytinfo.a $(OBJS)
  563. X    $(RANLIB) libmytinfo.a
  564. X
  565. libmytinfo.so: $(OBJS)
  566. X    ld -G -o libmytinfo.so $(OBJS)
  567. X
  568. libmytinfo_g.a: $(OBJS)
  569. X    rm -f libmytinfo_g.a
  570. X    $(AR) $(ARFLAGS) libmytinfo_g.a $(OBJS)
  571. X    $(RANLIB) libmytinfo_g.a
  572. X
  573. libmytinfo_p.a: $(OBJS)
  574. X    rm -f libmytinfo_p.a
  575. X    $(AR) $(ARFLAGS) ligmytinfo_p.a $(OBJS)
  576. X    $(RANLIB) libmytinfo_p.a
  577. X
  578. debug: 
  579. X    $(MAKE) DFLAGS=$(DEBUG) mytinfo_g.a
  580. X
  581. profiled:
  582. X    rm -f $(OBJS)
  583. X    $(MAKE) mktermhead mkcaplist mkcapsort mkbinorder mkversion
  584. X    $(MAKE) DFLAGS="-p" mytinfo_p.a
  585. X    rm -f $(OBJS)
  586. X
  587. rm:
  588. X    rm -f $(OBJS)
  589. X
  590. mv:
  591. X    -mv -f $(OBJS) Objs 2> /dev/null
  592. X
  593. test: ttest tputs.test tparm.test readcaps.test caps sprintf.test
  594. X
  595. ttest: ttest.o quit.o debug
  596. X    $(CC) -o ttest $(DEBUG) $(LDFLAGS) ttest.o quit.o mytinfo_g.a 
  597. X
  598. ttest.o: ttest.c # $(DEFS_H) term.h
  599. X    $(CC) -c $(DEBUG) $(CFLAGS) ttest.c
  600. X
  601. caps: caps.o quit.o debug
  602. X    $(CC) -o caps $(DEBUG) $(LDFLAGS) caps.o quit.o mytinfo_g.a
  603. X
  604. caps.o: ttest.c # $(DEFS_H) term.h
  605. X    $(CC) -c $(DEBUG) $(CFLAGS) caps.c
  606. X
  607. X.SUFFIXES: .test
  608. X
  609. X.c.test:
  610. X    $(CC) -DTEST $(DEBUG) $(LDFLAGS) $(CFLAGS) $< -o $@
  611. X
  612. tputs.test: tputs.c term.h $(DEFS_H)
  613. X
  614. tparm.test: tparm.c term.h $(DEFS_H)
  615. X
  616. readcaps.test: readcaps.c $(DEFS_H)
  617. X
  618. sprintf.test: sprintf.c $(DEFS_H)
  619. X
  620. capsort.c: mkcapsort
  621. X    ./mkcapsort > capsort.c
  622. X
  623. mkcapsort: mkcapsort.o caplist.o compar.o
  624. X    $(CC) $(LDFLAGS) -o mkcapsort mkcapsort.o caplist.o compar.o 
  625. X
  626. binorder.c: mkbinorder bin_order
  627. X    ./mkbinorder bin_order > binorder.c
  628. X
  629. mkbinorder: mkbinorder.o capsort.o caplist.o compar.o findcap.o
  630. X    $(CC) $(LDFLAGS) -o mkbinorder mkbinorder.o capsort.o \
  631. caplist.o compar.o findcap.o
  632. X
  633. version.c: mkversion
  634. X    ./mkversion > version.c
  635. X
  636. mkversion: mkversion.o
  637. X    $(CC) $(LDFLAGS) -o mkversion mkversion.o
  638. X
  639. term.h: term.head term.tail
  640. X    cat term.head term.tail > term.h
  641. X
  642. term.head: mktermhead cap_list
  643. X    ./mktermhead -n $(CAPS) cap_list > term.head
  644. X
  645. caplist.c: mkcaplist cap_list
  646. X    ./mkcaplist -n $(CAPS) cap_list > caplist.c
  647. X
  648. mktermhead: mktermhead.o readcaps.o
  649. X    $(CC) $(LDFLAGS) -o mktermhead mktermhead.o readcaps.o
  650. X
  651. mkcaplist: mkcaplist.o readcaps.o
  652. X    $(CC) $(LDFLAGS) -o mkcaplist mkcaplist.o readcaps.o
  653. X
  654. cap2info: tconv
  655. X    rm -f cap2info
  656. X    ln tconv cap2info
  657. X
  658. tic: tconv
  659. X    rm -f tic
  660. X    ln tconv tic
  661. X
  662. tconv: tconv.o quit.o version.o $(LINKLIB)
  663. X    $(CC) $(LDFLAGS) -o tconv tconv.o quit.o version.o $(LINKLIB)
  664. X
  665. clear: clear.tcap clear.tinfo
  666. X
  667. clear.tcap: clear.c $(LINKLIB) $(DEFS_H)
  668. X    $(CC) $(LDFLAGS) $(CFLAGS) -o clear.tcap clear.c $(LINKLIB)
  669. X
  670. clear.tinfo: clear.c $(LINKLIB) $(DEFS_H) term.h
  671. X    $(CC) $(LDFLAGS) $(CFLAGS) -DUSE_TERMINFO -o clear.tinfo clear.c $(LINKLIB)
  672. X
  673. tset: tset.o quit.o version.o $(LINKLIB)
  674. X    $(CC) $(LDFLAGS) -o tset tset.o quit.o version.o $(LINKLIB)
  675. X
  676. tput: tput.o quit.o $(LINKLIB)
  677. X    $(CC) $(LDFLAGS) -o tput tput.o quit.o version.o $(LINKLIB)
  678. X
  679. printf.o: sprintf.c $(DEFS_H)
  680. X    -mv -f sprintf.o sprintf..o 
  681. X    $(CC) $(CFLAGS) -c -DUSE_FAKE_STDIO -DPRINTF sprintf.c
  682. X    -mv -f sprintf.o printf.o
  683. X    -mv -f sprintf..o sprintf.o
  684. X
  685. print: $(ALL)
  686. X    pr $(ALL) | lpr
  687. X
  688. X#lint: $(SRCS) term.h $(DEFS_H)
  689. X#    lint $(LINTFLAGS) $(SRCS)
  690. X
  691. llib-ltinfo.ln: $(SRCS) $(DEFS_H) term.h
  692. X    lint -x $(LINTFLAGS) -otinfo $(SRCS)
  693. X
  694. lint: llib-ltinfo.ln quit.c tconv.c tset.c tput.c $(DEFS_H) term.h
  695. X    lint -L. -ltinfo $(LINTFLAGS) tconv.c quit.c
  696. X    lint -L. -ltinfo $(LINTFLAGS) tset.c quit.c
  697. X    lint -L. -ltinfo $(LINTFLAGS) tput.c quit.c
  698. X
  699. clean:
  700. X    rm -f *.o mkcapsort capsort.c term.head caplist.c version.c
  701. X    rm -f mkbinorder binorder.c mkcaplist mktermhead mkversion
  702. X    rm -f Debug/*.o Profile/*.o Objs/*.o
  703. X
  704. spotless: clean
  705. X    rm -f libmytinfo.so mytinfo.a term.h tparm.test tputs.test mytinfo_g.a
  706. X    rm -f mytinfo_p.a ttest sprintf.test clear.tcap clear.tinfo
  707. X    rm -f readcaps.test caps cap2info tconv tic tset tput
  708. X    rm -f core a.out 
  709. X    rm -rf Dist
  710. X
  711. lorder: $(OBJS)
  712. X    rm -f mytinfo.a
  713. X    $(AR) $(ARFLAGS) `lorder $(OBJS) | tsort`
  714. X    $(RANLIB) mytinfo.a
  715. X
  716. X#.DEFAULT: $(ALLSRCS)
  717. X#    test -f SCCS/s.$< && get SCCS/s.$<
  718. X#
  719. X#get:
  720. X#    get SCCS
  721. X#
  722. X#edit:
  723. X#    get -e SCCS
  724. X#
  725. X#nuke: spotless
  726. X#    -mv -f $(ALLSRCS) Backup 2> /dev/null
  727. X#    rm -f makerrs
  728. X#
  729. X#dist: $(ALLOTHERS)
  730. X#    test -d Dist || mkdir Dist
  731. X#    cp $(ALLOTHERS) Dist
  732. X#    cd Dist && rm -f $(ALLSRCS)
  733. X#    (cd Dist; for i in $(ALLSRCS); do echo "$$i:"; test -f $$i || get -r3 ../SCCS/s.$$i;done)
  734. X##    rm -f Dist/config.h
  735. X##    get -r2.2 -p SCCS/s.config.h > Dist/config.h
  736. X#    rm -f Dist/Makefile
  737. X#    get -r3 -p s.Makefile | sed '/^.DEFAULT/,/^# YOW.$$/s/^/#/' > Dist/Makefile
  738. X#    chmod u+w Dist/*
  739. X#
  740. X#shar: dist
  741. X#    (cd Dist; shar -l50 -o"part" -c -v -w -n"mytinfo" $(ALL))
  742. X#
  743. X#dist-tar: dist
  744. X#    cd Dist && tar cvf mytinfo.tar $(ALL) && compress mytinfo.tar
  745. X#
  746. X#dist-zip: dist
  747. X#    cd Dist && rm -f mytinfo.zip && zip -9 mytinfo.zip $(ALL)
  748. X#
  749. X#zip: $(ALL)
  750. X#    zip -9 mytinfo.zip $(ALL)
  751. X#
  752. X#diff: $(ALL)
  753. X#    -for i in $(ALL); do echo Index: $$i; diff Old/$$i $$i; done
  754. X#
  755. X#depend: $(ALLCSRCS) term.h $(DEFS_H) qsort.c strtok.c bsearch.c mkdir.c version.h
  756. X#    (sed '/^# YOW.$$/,$$d' Makefile; echo "# YOW."; gcc -MM $(ALLCSRCS) | sed -e 's/defs.h/$$(DEFS_H)/' -e 's/[ ]*config.h//' -e 's/[ ]*fake_stdio.h//' -e 's/ : /: /') > Makefile.new
  757. X#
  758. X## The usual stuff about not deleting this line or anything after it...
  759. X## YOW.
  760. addstr.o: addstr.c $(DEFS_H) term.h 
  761. buildpath.o: buildpath.c $(DEFS_H) strtok.c 
  762. caps.o: caps.c $(DEFS_H) term.h 
  763. clear.o: clear.c $(DEFS_H) 
  764. compar.o: compar.c $(DEFS_H) 
  765. fake_stdio.o: fake_stdio.c $(DEFS_H) 
  766. fillterm.o: fillterm.c $(DEFS_H) term.h 
  767. findcap.o: findcap.c $(DEFS_H) term.h bsearch.c 
  768. findterm.o: findterm.c $(DEFS_H) 
  769. getother.o: getother.c $(DEFS_H) term.h 
  770. gettbin.o: gettbin.c $(DEFS_H) term.h 
  771. gettcap.o: gettcap.c $(DEFS_H) term.h 
  772. gettinfo.o: gettinfo.c $(DEFS_H) term.h 
  773. mkbinorder.o: mkbinorder.c $(DEFS_H) term.h 
  774. mkcaplist.o: mkcaplist.c $(DEFS_H) 
  775. mkcapsort.o: mkcapsort.c $(DEFS_H) term.h qsort.c 
  776. mktermhead.o: mktermhead.c $(DEFS_H) 
  777. mkversion.o: mkversion.c $(DEFS_H) version.h 
  778. quit.o: quit.c $(DEFS_H) 
  779. readcaps.o: readcaps.c $(DEFS_H) 
  780. sprintf.o: sprintf.c $(DEFS_H) 
  781. tcapconv.o: tcapconv.c $(DEFS_H) term.h 
  782. tcapvars.o: tcapvars.c $(DEFS_H) term.h 
  783. tconv.o: tconv.c $(DEFS_H) term.h strtok.c mkdir.c 
  784. termcap.o: termcap.c $(DEFS_H) term.h 
  785. terminfo.o: terminfo.c $(DEFS_H) term.h 
  786. tgoto.o: tgoto.c $(DEFS_H) term.h 
  787. tiget.o: tiget.c $(DEFS_H) term.h 
  788. tmatch.o: tmatch.c $(DEFS_H) 
  789. tparm.o: tparm.c $(DEFS_H) term.h 
  790. tput.o: tput.c $(DEFS_H) term.h 
  791. tputs.o: tputs.c $(DEFS_H) term.h 
  792. tset.o: tset.c $(DEFS_H) term.h 
  793. ttest.o: ttest.c $(DEFS_H) term.h 
  794. tty.o: tty.c $(DEFS_H) term.h 
  795. END_OF_FILE
  796. if test 8696 -ne `wc -c <'Makefile'`; then
  797.     echo shar: \"'Makefile'\" unpacked with wrong size!
  798. fi
  799. # end of 'Makefile'
  800. fi
  801. if test -f 'cap_list' -a "${1}" != "-c" ; then 
  802.   echo shar: Will not clobber existing file \"'cap_list'\"
  803. else
  804. echo shar: Extracting \"'cap_list'\" \(12854 characters\)
  805. sed "s/^X//" >'cap_list' <<'END_OF_FILE'
  806. X cap_list
  807. X
  808. X By Ross Ridge
  809. X Public Domain
  810. X 92/02/01 07:29:44
  811. X
  812. X @(#) mytinfo cap_list 3.2 92/02/01 public domain, By Ross Ridge
  813. X
  814. types: ! = boolean, # = number, $ = string, $G = string with parameters,
  815. X       $K = string that never is outputed (with tputs).
  816. X
  817. type    variable        capname termcap 
  818. X
  819. Standard terminfo capabilities:
  820. X
  821. X!    auto_left_margin    bw    bw
  822. X!    auto_right_margin    am    am
  823. X!    ceol_standout_glitch    xhp    xs
  824. X!    dest_tabs_magic_smso    xt    xt
  825. X!    eat_newline_glitch    xenl    xn
  826. X!    erase_overstrike    eo    eo
  827. X!    generic_type        gn    gn
  828. X!    hard_copy        hc    hc
  829. X!    hard_cursor        chts    HC
  830. X!    has_meta_key        km    km
  831. X!    has_status_line        hs    hs
  832. X!    insert_null_glitch    in    in
  833. X!    memory_above        da    da
  834. X!    memory_below        db    db
  835. X!    move_insert_mode    mir    mi
  836. X!    move_standout_mode    msgr    ms
  837. X!    needs_xon_xoff        nxon    nx
  838. X!    no_esc_ctlc        xsb    xb
  839. X!    no_pad_char        npc    NP
  840. X!    non_rev_rmcup        nrrmc    NR
  841. X!    over_strike        os    os
  842. X!    prtr_silent        mc5i    5i
  843. X!    status_line_esc_ok    eslok    es
  844. X!    tilde_glitch        hz    hz
  845. X!    transparent_underline    ul    ul
  846. X!    xon_xoff        xon    xo
  847. X#    columns            cols    co
  848. X#    init_tabs        it    it
  849. X#    label_height        lh    lh
  850. X#    label_width        lw    lw
  851. X#    lines            lines    li
  852. X#    lines_of_memory        lm    lm
  853. X#    magic_cookie_glitch    xmc    sg
  854. X#    num_labels        nlab    Nl
  855. X#    padding_baud_rate    pb    pb
  856. X#    virtual_terminal    vt    vt
  857. X#    width_status_line    wsl    ws
  858. X$K    acs_chars        acsc    ac
  859. X$    back_tab        cbt    bt
  860. X$    bell            bel    bl
  861. X$    carriage_return        cr    cr
  862. X$G    change_scroll_region    csr    cs
  863. X$    char_padding        rmp    rP
  864. X$    clear_all_tabs        tbc    ct
  865. X$    clear_margins        mgc    MC
  866. X$    clear_screen        clear    cl
  867. X$    clr_bol            el1    cb
  868. X$    clr_eol            el    ce
  869. X$    clr_eos            ed    cd
  870. X$G    column_address        hpa    ch
  871. X$K    command_character    cmdch    CC
  872. X$G    cursor_address        cup    cm
  873. X$    cursor_down        cud1    do
  874. X$    cursor_home        home    ho
  875. X$    cursor_invisible    civis    vi
  876. X$    cursor_left        cub1    le
  877. X$G    cursor_mem_address    mrcup    CM
  878. X$    cursor_normal        cnorm    ve
  879. X$    cursor_right        cuf1    nd
  880. X$    cursor_to_ll        ll    ll
  881. X$    cursor_up        cuu1    up
  882. X$    cursor_visible        cvvis    vs
  883. X$    delete_character    dch1    dc
  884. X$    delete_line        dl1    dl
  885. X$    dis_status_line        dsl    ds
  886. X$    down_half_line        hd    hd
  887. X$    ena_acs            enacs    eA
  888. X$    enter_alt_charset_mode    smacs    as
  889. X$    enter_am_mode        smam    SA
  890. X$    enter_blink_mode    blink    mb
  891. X$    enter_bold_mode        bold    md
  892. X$    enter_ca_mode        smcup    ti
  893. X$    enter_delete_mode    smdc    dm
  894. X$    enter_dim_mode        dim    mh
  895. X$    enter_insert_mode    smir    im
  896. X$    enter_protected_mode    prot    mp
  897. X$    enter_reverse_mode    rev    mr
  898. X$    enter_secure_mode    invis    mk
  899. X$    enter_standout_mode    smso    so
  900. X$    enter_underline_mode    smul    us
  901. X$    enter_xon_mode        smxon    SX
  902. X$G    erase_chars        ech    ec
  903. X$    exit_alt_charset_mode    rmacs    ae
  904. X$    exit_am_mode        rmam    RA
  905. X$    exit_attribute_mode    sgr0    me
  906. X$    exit_ca_mode        rmcup    te
  907. X$    exit_delete_mode    rmdc    ed
  908. X$    exit_insert_mode    rmir    ei
  909. X$    exit_standout_mode    rmso    se
  910. X$    exit_underline_mode    rmul    ue
  911. X$    exit_xon_mode        rmxon    RX
  912. X$    flash_screen        flash    vb
  913. X$    form_feed        ff    ff
  914. X$    from_status_line    fsl    fs
  915. X$     init_1string        is1    i1
  916. X$     init_2string        is2    is
  917. X$     init_3string        is3    i3
  918. X$K    init_file        if    if
  919. X$K    init_prog        iprog    iP
  920. X$    insert_character    ich1    ic
  921. X$    insert_line        il1    al
  922. X$    insert_padding        ip    ip
  923. X$K    key_a1            ka1    K1
  924. X$K    key_a3            ka3    K3
  925. X$K    key_b2            kb2    K2
  926. X$K    key_backspace        kbs    kb
  927. X$K    key_beg            kbeg    @1
  928. X$K    key_btab        kcbt    kB
  929. X$K    key_c1            kc1    K4
  930. X$K    key_c3            kc3    K5
  931. X$K    key_cancel        kcan    @2
  932. X$K    key_catab        ktbc    ka
  933. X$K    key_clear        kclr    kC
  934. X$K    key_close        kclo    @3
  935. X$K    key_command        kcmd    @4
  936. X$K    key_copy        kcpy    @5
  937. X$K    key_create        kcrt    @6
  938. X$K    key_ctab        kctab    kt
  939. X$K    key_dc            kdch1    kD
  940. X$K    key_dl            kdl1    kL
  941. X$K    key_down        kcud1    kd
  942. X$K    key_eic            krmir    kM
  943. X$K    key_end            kend    @7
  944. X$K    key_enter        kent    @8
  945. X$K    key_eol            kel    kE
  946. X$K    key_eos            ked    kS
  947. X$K    key_exit        kext    @9
  948. X$K    key_f0            kf0    k0
  949. X$K    key_f1            kf1    k1
  950. X$K    key_f10            kf10    k;
  951. X$K    key_f11            kf11    F1
  952. X$K    key_f12            kf12    F2
  953. X$K    key_f13            kf13    F3
  954. X$K    key_f14            kf14    F4
  955. X$K    key_f15            kf15    F5
  956. X$K    key_f16            kf16    F6
  957. X$K    key_f17            kf17    F7
  958. X$K    key_f18            kf18    F8
  959. X$K    key_f19            kf19    F9
  960. X$K    key_f2            kf2    k2
  961. X$K    key_f20            kf20    FA
  962. X$K    key_f21            kf21    FB
  963. X$K    key_f22            kf22    FC
  964. X$K    key_f23            kf23    FD
  965. X$K    key_f24            kf24    FE
  966. X$K    key_f25            kf25    FF
  967. X$K    key_f26            kf26    FG
  968. X$K    key_f27            kf27    FH
  969. X$K    key_f28            kf28    FI
  970. X$K    key_f29            kf29    FJ
  971. X$K    key_f3            kf3    k3
  972. X$K    key_f30            kf30    FK
  973. X$K    key_f31            kf31    FL
  974. X$K    key_f32            kf32    FM
  975. X$K    key_f33            kf33    FN
  976. X$K    key_f34            kf34    FO
  977. X$K    key_f35            kf35    FP
  978. X$K    key_f36            kf36    FQ
  979. X$K    key_f37            kf37    FR
  980. X$K    key_f38            kf38    FS
  981. X$K    key_f39            kf39    FT
  982. X$K    key_f4            kf4    k4
  983. X$K    key_f40            kf40    FU
  984. X$K    key_f41            kf41    FV
  985. X$K    key_f42            kf42    FW
  986. X$K    key_f43            kf43    FX
  987. X$K    key_f44            kf44    FY
  988. X$K    key_f45            kf45    FZ
  989. X$K    key_f46            kf46    Fa
  990. X$K    key_f47            kf47    Fb
  991. X$K    key_f48            kf48    Fc
  992. X$K    key_f49            kf49    Fd
  993. X$K    key_f5            kf5    k5
  994. X$K    key_f50            kf50    Fe
  995. X$K    key_f51            kf51    Ff
  996. X$K    key_f52            kf52    Fg
  997. X$K    key_f53            kf53    Fh
  998. X$K    key_f54            kf54    Fi
  999. X$K    key_f55            kf55    Fj
  1000. X$K    key_f56            kf56    Fk
  1001. X$K    key_f57            kf57    Fl
  1002. X$K    key_f58            kf58    Fm
  1003. X$K    key_f59            kf59    Fn
  1004. X$K    key_f6            kf6    k6
  1005. X$K    key_f60            kf60    Fo
  1006. X$K    key_f61            kf61    Fp
  1007. X$K    key_f62            kf62    Fq
  1008. X$K    key_f63            kf63    Fr
  1009. X$K    key_f7            kf7    k7
  1010. X$K    key_f8            kf8    k8
  1011. X$K    key_f9            kf9    k9
  1012. X$K    key_find        kfnd    @0
  1013. X$K    key_help        khlp    %1
  1014. X$K    key_home        khome    kh
  1015. X$K    key_ic            kich1    kI
  1016. X$K    key_il            kil1    kA
  1017. X$K    key_left        kcub1    kl
  1018. X$K    key_ll            kll    kH
  1019. X$K    key_mark        kmrk    %2
  1020. X$K    key_message        kmsg    %3
  1021. X$K    key_move        kmov    %4
  1022. X$K    key_next        knxt    %5
  1023. X$K    key_npage        knp    kN
  1024. X$K    key_open        kopn    %6
  1025. X$K    key_options        kopt    %7
  1026. X$K    key_ppage        kpp    kP
  1027. X$K    key_previous        kprv    %8
  1028. X$K    key_print        kprt    %9
  1029. X$K    key_redo        krdo    %0
  1030. X$K    key_reference        kref    &1
  1031. X$K    key_refresh        krfr    &2
  1032. X$K    key_replace        krpl    &3
  1033. X$K    key_restart        krst    &4
  1034. X$K    key_resume        kres    &5
  1035. X$K    key_right        kcuf1    kr
  1036. X$K    key_save        ksav    &6
  1037. X$K    key_sbeg        kBEG    &9
  1038. X$K    key_scancel        kCAN    &0
  1039. X$K    key_scommand        kCMD    *1
  1040. X$K    key_scopy        kCPY    *2
  1041. X$K    key_screate        kCRT    *3
  1042. X$K    key_sdc            kDC    *4
  1043. X$K    key_sdl            kDL    *5
  1044. X$K    key_select        kslt    *6
  1045. X$K    key_send        kEND    *7
  1046. X$K    key_seol        kEOL    *8
  1047. X$K    key_sexit        kEXT    *9
  1048. X$K    key_sf            kind    kF
  1049. X$K    key_sfind        kFND    *0
  1050. X$K    key_shelp        kHLP    #1
  1051. X$K    key_shome        kHOM    #2
  1052. X$K    key_sic            kIC    #3
  1053. X$K    key_sleft        kLFT    #4
  1054. X$K    key_smessage        kMSG    %a
  1055. X$K    key_smove        kMOV    %b
  1056. X$K    key_snext        kNXT    %c
  1057. X$K    key_soptions        kOPT    %d
  1058. X$K    key_sprevious        kPRV    %e
  1059. X$K    key_sprint        kPRT    %f
  1060. X$K    key_sr            kri    kR
  1061. X$K    key_sredo        kRDO    %g
  1062. X$K    key_sreplace        kRPL    %h
  1063. X$K    key_sright        kRIT    %i
  1064. X$K    key_srsume        kRES    %j
  1065. X$K    key_ssave        kSAV    !1
  1066. X$K    key_ssuspend        kSPD    !2
  1067. X$K    key_stab        khts    kT
  1068. X$K    key_sundo        kUND    !3
  1069. X$K    key_suspend        kspd    &7
  1070. X$K    key_undo        kund    &8
  1071. X$K    key_up            kcuu1    ku
  1072. X$    keypad_local        rmkx    ke
  1073. X$    keypad_xmit        smkx    ks
  1074. X$K    lab_f0            lf0    l0
  1075. X$K    lab_f1            lf1    l1
  1076. X$K    lab_f10            lf10    la
  1077. X$K    lab_f2            lf2    l2
  1078. X$K    lab_f3            lf3    l3
  1079. X$K    lab_f4            lf4    l4
  1080. X$K    lab_f5            lf5    l5
  1081. X$K    lab_f6            lf6    l6
  1082. X$K    lab_f7            lf7    l7
  1083. X$K    lab_f8            lf8    l8
  1084. X$K    lab_f9            lf9    l9
  1085. X$    label_off        rmln    LF
  1086. X$    label_on        smln    LO
  1087. X$    meta_off        rmm    mo
  1088. X$    meta_on            smm    mm
  1089. X$    newline            nel    nw
  1090. X$K    pad_char        pad    pc
  1091. X$G    parm_dch        dch    DC
  1092. X$G    parm_delete_line    dl    DL
  1093. X$G    parm_down_cursor    cud    DO
  1094. X$G    parm_ich        ich    IC
  1095. X$G    parm_index        indn    SF
  1096. X$G    parm_insert_line    il    AL
  1097. X$G    parm_left_cursor    cub    LE
  1098. X$G    parm_right_cursor    cuf    RI
  1099. X$G    parm_rindex        rin    SR
  1100. X$G    parm_up_cursor        cuu    UP
  1101. X$G    pkey_key        pfkey    pk
  1102. X$G    pkey_local        pfloc    pl
  1103. X$G    pkey_xmit        pfx    px
  1104. X$G    plab_norm        pln    pn
  1105. X$    print_screen        mc0    ps
  1106. X$G    prtr_non        mc5p    pO
  1107. X$    prtr_off        mc4    pf
  1108. X$    prtr_on            mc5    po
  1109. X$G    repeat_char        rep    rp
  1110. X$    req_for_input        rfi    RF
  1111. X$     reset_1string        rs1    r1
  1112. X$     reset_2string        rs2    r2
  1113. X$     reset_3string        rs3    r3
  1114. X$K    reset_file        rf    rf
  1115. X$    restore_cursor        rc    rc
  1116. X$G    row_address        vpa    cv
  1117. X$    save_cursor        sc    sc
  1118. X$    scroll_forward        ind    sf
  1119. X$    scroll_reverse        ri    sr
  1120. X$G    set_attributes        sgr    sa
  1121. X$    set_left_margin        smgl    ML
  1122. X$    set_right_margin    smgr    MR
  1123. X$    set_tab            hts    st
  1124. X$G    set_window        wind    wi
  1125. X$    tab            ht    ta
  1126. X$G    to_status_line        tsl    ts
  1127. X$    underline_char        uc    uc
  1128. X$    up_half_line        hu    hu
  1129. X$     xoff_character        xoffc    XF
  1130. X$     xon_character        xonc    XN
  1131. X
  1132. Release 3.2 and 4 capabilities (AMIX)
  1133. X(some of the string attributes are guesses...)
  1134. X
  1135. X!    back_color_erase        bce    ut
  1136. X!    can_change            ccc    cc
  1137. X!    col_addr_glitch            xhpa    YA
  1138. X!    cpi_changes_res            cpix    YF
  1139. X!    cr_cancels_micro_mode        crxm    YB
  1140. X!    has_print_wheel            daisy    YC
  1141. X!    hue_lightness_saturation    hls    hl
  1142. X!    lpi_changes_res            lpix    YG
  1143. X!    non_dest_scroll_region        ndscr    ND
  1144. X!    row_addr_glitch            xvpa    YD
  1145. X!    semi_auto_right_margin        sam    YE
  1146. X#    bit_image_entwining        bitwin    Yo
  1147. X#    bit_image_type            bitype    Yp
  1148. X#    buffer_capacity            bufsz    Ya
  1149. X#    buttons                btns    BT
  1150. X#    dot_horz_spacing        spinh    Yc
  1151. X#    dot_vert_spacing        spinv    Yb
  1152. X#    max_attributes            ma    ma
  1153. X#    max_colors            colors    Co
  1154. X#    max_micro_address        maddr    Yd
  1155. X#    max_micro_jump            mjump    Ye
  1156. X#    max_pairs            pairs    pa
  1157. X#    maximum_windows            wnum    MW
  1158. X#    micro_char_size            mcs    Yf
  1159. X#    micro_line_size            mls    Yg
  1160. X#    no_color_video            ncv    NC
  1161. X#    number_of_pins            npins    Yh
  1162. X#    output_res_char            orc    Yi
  1163. X#    output_res_horz_inch        orhi    Yk
  1164. X#    output_res_line            orl    Yj
  1165. X#    output_res_vert_inch        orvi    Yl
  1166. X#    print_rate            cps    Ym
  1167. X#    wide_char_size            widcs    Yn
  1168. X$    alt_scancode_esc        scesa    S8
  1169. X$G    bit_image_carriage_return    bicr    Yv
  1170. X$G    bit_image_newline        binel    Zz
  1171. X$G    bit_image_repeat        birep    Xy
  1172. X$G    change_char_pitch        cpi    ZA
  1173. X$G    change_line_pitch        lpi    ZB
  1174. X$G    change_res_horz            chr    ZC
  1175. X$G    change_res_vert            cvr    ZD
  1176. X$G    char_set_names            csnm    Zy
  1177. X$    code_set_init            csin    ci
  1178. X$G    color_names            colornm    Yw
  1179. X$G    create_window            cwin    CW
  1180. X$G    define_bit_image_region        defbi    Yx
  1181. X$G    define_char            defc    ZE
  1182. X$    device_type            devt    dv
  1183. X$G    dial_phone            dial    DI
  1184. X$    display_clock            dclk    DK
  1185. X$    display_pc_char            dispc    S1
  1186. X$    end_bit_image_region        endbi    Yy
  1187. X$    enter_doublewide_mode        swidm    ZF
  1188. X$    enter_draft_quality        sdrfq    ZG
  1189. X$    enter_italics_mode        sitm    ZH
  1190. X$    enter_leftward_mode        slm    ZI
  1191. X$    enter_micro_mode        smicm    ZJ
  1192. X$    enter_near_letter_quality    snlq    ZK
  1193. X$    enter_normal_quality        snrmq    ZL
  1194. X$    enter_pc_charset_mode        smpch    S2
  1195. X$    enter_scancode_mode        smsc    S4
  1196. X$    enter_shadow_mode        sshm    ZM
  1197. X$    enter_subscript_mode        ssubm    ZN
  1198. X$    enter_superscript_mode        ssupm    ZO
  1199. X$    enter_upward_mode        sum    ZP
  1200. X$    exit_doublewide_mode        rwidm    ZQ
  1201. X$    exit_italics_mode        ritm    ZR
  1202. X$    exit_leftward_mode        rlm    ZS
  1203. X$    exit_micro_mode            rmicm    ZT
  1204. X$    exit_pc_charset_mode        rmpch    S3
  1205. X$    exit_scancode_mode        rmsc    S5
  1206. X$    exit_shadow_mode        rshm    ZU
  1207. X$    exit_subscript_mode        rsubm    ZV
  1208. X$    exit_superscript_mode        rsupm    ZW
  1209. X$    exit_upward_mode        rum    ZX
  1210. X$    fixed_pause            pause    PA
  1211. X$    flash_hook            hook    fh
  1212. X$    get_mouse            getm    Gm
  1213. X$G    goto_window            wingo    WG
  1214. X$    hangup                hup    HU
  1215. X$G    initialize_color        initc    Ic
  1216. X$G    initialize_pair            initp    Ip
  1217. X$    key_mouse            kmous    Km
  1218. X$    label_format            fln    Lf
  1219. X$G    micro_column_address        mhpa    ZY
  1220. X$    micro_down            mcud1    ZZ
  1221. X$    micro_left            mcub1    Za
  1222. X$    micro_right            mcuf1    Zb
  1223. X$G    micro_row_address        mvpa    Zc
  1224. X$    micro_up            mcuu1    Zd
  1225. X$    mouse_info            minfo    Mi
  1226. X$K    order_of_pins            porder    Ze
  1227. X$    orig_colors            oc    oc
  1228. X$    orig_pair            op    op
  1229. X$G    parm_down_micro            mcud    Zf
  1230. X$G    parm_left_micro            mcub    Zg
  1231. X$G    parm_right_micro        mcuf    Zh
  1232. X$G    parm_up_micro            mcuu    Zi
  1233. X$    pc_term_options            pctrm    S6
  1234. X$G    pkey_plab            pfxl    xl
  1235. X$    pulse                pulse    PU
  1236. X$    quick_dial            qdial    QD
  1237. X$    remove_clock            rmclk    RC
  1238. X$    req_mouse_pos            reqmp    RQ
  1239. X$    scancode_escape            scesc    S7
  1240. X$G    select_char_set            scs    Zj
  1241. X$    set0_des_seq            s0ds    s0
  1242. X$    set1_des_seq            s1ds    s1
  1243. X$    set2_des_seq            s2ds    s2
  1244. X$    set3_des_seq            s3ds    s3
  1245. X$G    set_a_background        setab    AB
  1246. X$G    set_a_foreground        setaf    AF
  1247. X$G    set_background            setb    Sb
  1248. X$    set_bottom_margin        smgb    Zk
  1249. X$G    set_bottom_margin_parm        smgbp    Zl
  1250. X$G    set_clock            sclk    SC
  1251. X$G    set_color_band            setcolor Yz
  1252. X$G    set_color_pair            scp    sp
  1253. X$G    set_foreground            setf    Sf
  1254. X$G    set_left_margin_parm        smglp    Zm
  1255. X$G    set_lr_margin            smglr    ML
  1256. X$G    set_page_length            slines    YZ
  1257. X$G    set_right_margin_parm        smgrp    Zn
  1258. X$G    set_tb_margin            smgtb    MT
  1259. X$    set_top_margin            smgt    Zo
  1260. X$G    set_top_margin_parm        smgtp    Zp
  1261. X$G    start_bit_image            sbim    Zq
  1262. X$G    start_char_set_def        scsd    Zr
  1263. X$    stop_bit_image            rbim    Zs
  1264. X$G    stop_char_set_def        rcsd    Zt
  1265. X$K    subscript_characters        subcs    Zu
  1266. X$K    superscript_characters        supcs    Zv
  1267. X$K    these_cause_cr            docr    Zw
  1268. X$    tone                tone    TO
  1269. X$    user0                u0    u0
  1270. X$    user1                u1    u1
  1271. X$    user2                u2    u2
  1272. X$    user3                u3    u3
  1273. X$    user4                u4    u4
  1274. X$    user5                u5    u5
  1275. X$    user6                u6    u6
  1276. X$    user7                u7    u7
  1277. X$    user8                u8    u8
  1278. X$    user9                u9    u9
  1279. X$    wait_tone            wait    WA
  1280. X$    zero_motion            zerom    Zx
  1281. X
  1282. X"Obsolete" termcap capabilities (variable and terminfo names are mine)
  1283. X
  1284. X$    backspace_if_not_bs    OTbc    bc
  1285. X!    backspaces_with_bs    OTbs    bs
  1286. X#    backspace_delay        OTdB    dB
  1287. X#    carriage_return_delay    OTdC    dC
  1288. X#    form_feed_delay        OTdF    dF
  1289. X#    new_line_delay        OTdN    dN
  1290. X#    horizontal_tab_delay    OTdT    dT
  1291. X#    vertical_tab_delay    OTdV    dV
  1292. X!    even_parity        OTEP    EP
  1293. X!    half_duplex        OTHD    HD
  1294. X#    number_of_function_keys    OTkn    kn
  1295. X$K    other_non_function_keys    OTko    ko
  1296. X!    lower_case_only        OTLC    LC
  1297. X$K    arrow_key_map        OTma    ma
  1298. X$    memory_lock_above    OTml    ml
  1299. X$    memory_unlock        OTmu    mu
  1300. X!    no_correctly_working_cr    OTnc    nc
  1301. X!    linefeed_is_newline    OTNL    NL
  1302. X$    linefeed_if_not_lf    OTnl    nl
  1303. X!    crt_without_scrolling    OTns    ns
  1304. X!    odd_parity        OTOP    OP
  1305. X!    has_hardware_tabs    OTpt    pt
  1306. X!    uppercase_only        OTUC    UC
  1307. X!    return_does_clr_eol    OTxr    xr
  1308. X!    tek_4025_insert_line    OTxx    xx
  1309. X#    magic_cookie_glitch_ul    OTug    ug
  1310. X
  1311. Caps used by the University of Waterloo (variable and terminfo names are mine)
  1312. X
  1313. X$K    key_interrupt_char    UWki    ki
  1314. X$K    key_kill_char        UWkk    kk
  1315. X$K    key_suspend_char    UWkz    kz
  1316. X!    initialization_messy    UWxc    xc
  1317. X!    index_at_bottom_does_cr    UWxl    xl
  1318. X
  1319. X!    rind_only_at_top    OTxq    xq
  1320. X
  1321. Different names for existing terminfo caps used by GNU Emacs:
  1322. X!    GNU_has_meta_key    GNUMT    MT
  1323. X#    GNU_tab_width        GNUtw    tw
  1324. X
  1325. Non standard capabilities:
  1326. X
  1327. X$    scroll_left        sl1    Sl
  1328. X$    scroll_right        sr1    Sr
  1329. X$G    parm_scroll_left    sl    SL
  1330. X$G    parm_scroll_right    sr    SR
  1331. X
  1332. Dummy (must be present and last):
  1333. X
  1334. X$K    _get_other        use    tc
  1335. END_OF_FILE
  1336. if test 12854 -ne `wc -c <'cap_list'`; then
  1337.     echo shar: \"'cap_list'\" unpacked with wrong size!
  1338. fi
  1339. # end of 'cap_list'
  1340. fi
  1341. if test -f 'findterm.c' -a "${1}" != "-c" ; then 
  1342.   echo shar: Will not clobber existing file \"'findterm.c'\"
  1343. else
  1344. echo shar: Extracting \"'findterm.c'\" \(4667 characters\)
  1345. sed "s/^X//" >'findterm.c' <<'END_OF_FILE'
  1346. X/* findterm.c
  1347. X *
  1348. X * By Ross Ridge
  1349. X * Public Domain
  1350. X * 92/02/01 07:29:56
  1351. X *
  1352. X */
  1353. X
  1354. X#include "defs.h"
  1355. X
  1356. X#include <ctype.h>
  1357. X#include <fcntl.h>
  1358. X#ifdef USE_STDDEF
  1359. X#include <sys/types.h>
  1360. X#endif
  1361. X#include <sys/stat.h>
  1362. X
  1363. X#ifdef USE_SCCS_IDS
  1364. static const char SCCSid[] = "@(#) mytinfo findterm.c 3.2 92/02/01 public domain, By Ross Ridge";
  1365. X#endif
  1366. static int linecnt;
  1367. X
  1368. static int
  1369. getln(f, buf, len)
  1370. XFILE *f;
  1371. register char *buf;
  1372. int len; {
  1373. X    register int c, i = 0;
  1374. X
  1375. X    while((c = getc(f)) == '#') {
  1376. X        linecnt++;
  1377. X        while((c = getc(f)) != '\n')
  1378. X            if (c == EOF)
  1379. X                return -1;
  1380. X    }
  1381. X
  1382. X    while(c != '\n') {
  1383. X        if (c == EOF)
  1384. X            return -1;
  1385. X        if (i < len) {
  1386. X            i++;
  1387. X            *buf++ = c;
  1388. X        }
  1389. X        c = getc(f);
  1390. X    }
  1391. X
  1392. X    while(isspace(*(buf-1))) {
  1393. X        buf--;
  1394. X        i--;
  1395. X    }
  1396. X
  1397. X    *buf = '\0';
  1398. X    return i;
  1399. X}
  1400. X
  1401. static int
  1402. X_findterm2(name, file, buf)
  1403. char *name, *buf;
  1404. char *file; {
  1405. X    char line[MAX_LINE];
  1406. X    FILE *f;
  1407. X    register char *sp, *dp;
  1408. X    int c;
  1409. X    int l;
  1410. X    int cont;
  1411. X    int fd;
  1412. X    struct stat st;
  1413. X
  1414. X    linecnt = 0;
  1415. X
  1416. X#ifdef DEBUG
  1417. X    printf("open: %s\n", file);
  1418. X#endif
  1419. X    fd = open(file, O_RDONLY);
  1420. X    if (fd == -1)
  1421. X        return -1;
  1422. X    if (fstat(fd, &st) == -1) {
  1423. X        close(fd);
  1424. X        return -1;
  1425. X    }
  1426. X    if ((st.st_mode & 0170000) == 0040000) {
  1427. X        sprintf(buf, "%s/%c/%s", file, name[0], name);
  1428. X        close(fd);
  1429. X        fd = open(buf, O_RDONLY);
  1430. X        if (fd == -1)
  1431. X            return -1;
  1432. X        if (read(fd, buf, MAX_BUF) < 12
  1433. X            || buf[0] != 032 || buf[1] != 1) {
  1434. X            close(fd);
  1435. X            return -1;
  1436. X        }
  1437. X        close(fd);
  1438. X        return 3;
  1439. X    }
  1440. X    f = fdopen(fd, "r");
  1441. X    if (f == NULL) {
  1442. X        close(fd);
  1443. X        return -1;
  1444. X    }
  1445. X
  1446. X    while ((l = getln(f, buf, MAX_LINE)) != -1) {
  1447. X        linecnt++;
  1448. X        if (!isspace(buf[0]) && l != 0) {
  1449. X            sp = buf + l - 1;
  1450. X            cont = 0;
  1451. X            switch(*sp) {
  1452. X            case '\\':
  1453. X                cont = 1;
  1454. X                *sp = '\0';
  1455. X                /* FALLTHROUGH */
  1456. X            case ':':
  1457. X                sp = buf;
  1458. X                dp = line;
  1459. X                while (*sp != ':') {
  1460. X                    if (*sp == '\0' && cont &&
  1461. X                        (l = getln(f, buf, MAX_LINE))
  1462. X                         != -1) {
  1463. X                        linecnt++;
  1464. X                        sp = buf;
  1465. X                        if (l > 0 && buf[l-1] == '\\')
  1466. X                            cont = 1;
  1467. X                        else
  1468. X                            cont = 0;
  1469. X                        continue;
  1470. X                    }
  1471. X                    if (*sp == '\0') {
  1472. X#ifdef DEBUG
  1473. X                        printf("bad line (%d)\n",
  1474. X                               linecnt);
  1475. X                        fclose(f);
  1476. X                        return -2;
  1477. X#else
  1478. X                        goto err;
  1479. X#endif
  1480. X                    }
  1481. X                    *dp++ = *sp++;
  1482. X                }
  1483. X                *dp = '\0';
  1484. X                if (!_tmatch(line, name))
  1485. X                    break;
  1486. X                if (!cont) {
  1487. X                    fclose(f);
  1488. X                    return 1;
  1489. X                }
  1490. X                l = strlen(buf);
  1491. X                dp = buf + l;
  1492. X                while((c = getc(f)) != EOF && l < MAX_BUF) {
  1493. X                    if (c == '\n')
  1494. X                        break;
  1495. X                    if (c == '\\') {
  1496. X                        c = getc(f);
  1497. X                        if (c == EOF)
  1498. X                            break;
  1499. X                        if (c == '\n') {
  1500. X                            c = getc(f);
  1501. X                            if (c == EOF)
  1502. X                                break;
  1503. X                            if (c == '#') {
  1504. X                                while((c = getc(f)) != EOF && c != '\n');
  1505. X                                if (c == EOF)
  1506. X                                    break;
  1507. X                                continue;
  1508. X                            }
  1509. X                            *dp++ = c;
  1510. X                            continue;
  1511. X                        }
  1512. X                        *dp++ = '\\';
  1513. X                        *dp++ = c;
  1514. X                        continue;
  1515. X                    } 
  1516. X                    *dp++ = c;
  1517. X                }
  1518. X                *dp = '\0';
  1519. X                fclose(f);
  1520. X                return 1;
  1521. X            case ',':
  1522. X                sp = buf;
  1523. X                dp = line;
  1524. X                while(*sp != ',')
  1525. X                    *dp++ = *sp++;
  1526. X                *dp = '\0';
  1527. X                if (!_tmatch(line, name))
  1528. X                    break;
  1529. X                dp = buf + l;
  1530. X                while ((c = getc(f)) != EOF && l < MAX_BUF) {
  1531. X                    if (c == '\n') {
  1532. X                        c = getc(f);
  1533. X                        if (isspace(c))
  1534. X                            continue;
  1535. X                        if (c == '\n') {
  1536. X                            ungetc(c, f);
  1537. X                            continue;
  1538. X                        }
  1539. X                        if (c == '#') {
  1540. X                            while((c = getc(f)) != EOF)
  1541. X                                if (c == '\n')
  1542. X                                    break;
  1543. X                            if (c == EOF)
  1544. X                                break;
  1545. X                            ungetc(c, f);
  1546. X                            continue;
  1547. X                        }
  1548. X                        break;
  1549. X                    }
  1550. X                    *dp++ = c;
  1551. X                    l++;
  1552. X                }
  1553. X                *dp = '\0';
  1554. X                fclose(f);
  1555. X                return 2;
  1556. X            default:
  1557. X            err:
  1558. X#ifdef DEBUG
  1559. X                printf("strange line (%d)\n", linecnt);
  1560. X#endif
  1561. X                break;
  1562. X            }
  1563. X        }
  1564. X    }
  1565. X    fclose(f);
  1566. X    return 0;
  1567. X}
  1568. X
  1569. int
  1570. X_findterm(name, path, buf)
  1571. char *name;
  1572. struct term_path *path;
  1573. char *buf; {
  1574. X    register char *s, *d;
  1575. X    int r = 0;
  1576. X    while(path->file != NULL) {
  1577. X        switch(path->type) {
  1578. X        case 0:
  1579. X            r = _findterm2(name, path->file, buf);
  1580. X            break;
  1581. X        case 1:
  1582. X            if (path->file[0] == '/') {
  1583. X                r = _findterm2(name, path->file, buf);
  1584. X            } else {
  1585. X                s = path->file;
  1586. X                d = buf;
  1587. X                while(*s != '\0' && *s != ':')
  1588. X                    *d++ = *s++;
  1589. X                *d = '\0';
  1590. X                if (_tmatch(buf, name)) {
  1591. X                    while(*s != '\0')
  1592. X                        *d++ = *s++;
  1593. X                    return 1;
  1594. X                }
  1595. X                r = 0;
  1596. X            }
  1597. X            break;
  1598. X        case 2:
  1599. X            if (path->file[0] == '/') {
  1600. X                r = _findterm2(name, path->file, buf);
  1601. X            } else {
  1602. X                s = path->file;
  1603. X                d = buf;
  1604. X                while(*s != '\0' && *s != ',')
  1605. X                    *d++ = *s++;
  1606. X                *d = '\0';
  1607. X                if (_tmatch(buf, name)) {
  1608. X                    while(*s != '\0')
  1609. X                        *d++ = *s++;
  1610. X                    return 2;
  1611. X                }
  1612. X                r = 0;
  1613. X            }
  1614. X            break;
  1615. X        default:
  1616. X            r = 0;
  1617. X            break;
  1618. X        }
  1619. X        if (r == 1 || r == 2 || r == 3) {
  1620. X#ifdef DEBUG
  1621. X            printf("found in %s\n", path->file);
  1622. X#endif
  1623. X            break;
  1624. X        }
  1625. X        path++;
  1626. X    }
  1627. X    return r;
  1628. X}
  1629. END_OF_FILE
  1630. if test 4667 -ne `wc -c <'findterm.c'`; then
  1631.     echo shar: \"'findterm.c'\" unpacked with wrong size!
  1632. fi
  1633. # end of 'findterm.c'
  1634. fi
  1635. if test -f 'gettcap.c' -a "${1}" != "-c" ; then 
  1636.   echo shar: Will not clobber existing file \"'gettcap.c'\"
  1637. else
  1638. echo shar: Extracting \"'gettcap.c'\" \(5172 characters\)
  1639. sed "s/^X//" >'gettcap.c' <<'END_OF_FILE'
  1640. X/*
  1641. X * gettcap.c
  1642. X *
  1643. X * By Ross Ridge
  1644. X * Public Domain
  1645. X * 92/02/01 07:30:00
  1646. X *
  1647. X */
  1648. X
  1649. X#include "defs.h"
  1650. X#include "term.h"
  1651. X
  1652. X#include <ctype.h>
  1653. X
  1654. X#ifdef USE_SCCS_IDS
  1655. static const char SCCSid[] = "@(#) mytinfo gettcap.c 3.2 92/02/01 public domain, By Ross Ridge";
  1656. X#endif
  1657. X
  1658. int
  1659. X_gettcap(sp, cur, path)
  1660. register char *sp;
  1661. TERMINAL *cur;
  1662. struct term_path *path; {
  1663. X    static char name[MAX_NAME];
  1664. X    static char entry[MAX_LINE];
  1665. X    register char *dp;
  1666. X    register TERMINAL *ct = cur;
  1667. X    int i, pad, fract, mul, ind;
  1668. X    char c, flag;
  1669. X
  1670. X    dp = entry;
  1671. X    while(*sp != ':' && *sp != '\0')
  1672. X        *dp++ = *sp++;
  1673. X    if (ct->name_all == NULL) {
  1674. X        *dp = '\0';
  1675. X        if ((ct->name_all = _addstr(entry)) == NULL)
  1676. X            return 1;
  1677. X        while(dp > entry && *--dp != '|');
  1678. X        ct->name_long = ct->name_all + (dp - entry) + 1;
  1679. X    }
  1680. X
  1681. X     while(*sp != '\0') {
  1682. X        while(*sp == ':')
  1683. X            sp++;
  1684. X        while(isspace(*sp))
  1685. X            sp++;
  1686. X        if (*sp == ':')
  1687. X            continue;
  1688. X        if (*sp == '\0')
  1689. X            break;
  1690. X        dp = name;
  1691. X        while (*sp != ':' && *sp != '#' && *sp != '=' &&
  1692. X               !isspace(*sp) && *sp != '\0')
  1693. X            *dp++ = *sp++;
  1694. X        *dp = '\0';
  1695. X#ifdef DEBUG
  1696. X        printf(" %s", name);
  1697. X#endif
  1698. X        switch(*sp) {
  1699. X        case '=':
  1700. X#ifdef DEBUG
  1701. X            putchar('$');
  1702. X#endif
  1703. X            ind = _findstrcode(name);
  1704. X            if (ind != -1)
  1705. X                flag = _strflags[ind];
  1706. X            else
  1707. X                flag = 'K';
  1708. X            dp = entry;
  1709. X            fract = pad = 0;
  1710. X            sp++;
  1711. X            if (isdigit(*sp) && flag != 'K') {
  1712. X                pad = *sp++ - '0';
  1713. X                while(isdigit(*sp))
  1714. X                    pad = pad * 10 + (*sp++ - '0');
  1715. X                if (*sp == '.' && isdigit(sp[1])) {
  1716. X                    sp++;
  1717. X                    fract = (*sp++ - '0');
  1718. X                }
  1719. X                if (*sp == '*') {
  1720. X                    mul = 1;
  1721. X                    sp++;
  1722. X                } else
  1723. X                    mul = 0;
  1724. X    
  1725. X            }
  1726. X            while(*sp != '\0' && *sp != ':') {
  1727. X                switch(*sp) {
  1728. X                case '\\':
  1729. X                    switch(*++sp) {
  1730. X                    case 'e':
  1731. X                    case 'E': *dp++ = '\033'; break;
  1732. X                    case 'l': *dp++ = '\012'; break;
  1733. X                    case 'n': *dp++ = '\n'; break;
  1734. X                    case 'r': *dp++ = '\r'; break;
  1735. X                    case 't': *dp++ = '\t'; break;
  1736. X                    case 'b': *dp++ = '\b'; break;
  1737. X                    case 'f': *dp++ = '\f'; break;
  1738. X                    case 's': *dp++ = ' '; break;
  1739. X
  1740. X                    case '^': 
  1741. X                    case '\\':
  1742. X                    case ',':
  1743. X                    case ':':
  1744. X                        *dp++ = *sp;
  1745. X                        break;
  1746. X
  1747. X                    case '0':
  1748. X                        if (!isdigit(*(sp + 1))) {
  1749. X                            *dp++ = '\200';
  1750. X                            break;
  1751. X                        }
  1752. X                        ;/* FALLTHROUGH */
  1753. X                    case '1':
  1754. X                    case '2':
  1755. X                    case '3':
  1756. X                    case '4':
  1757. X                    case '5':
  1758. X                    case '6':
  1759. X                    case '7':
  1760. X                        c = *sp - '0';
  1761. X                        if (sp[1] >= '0'
  1762. X                            && sp[1] <= '8')
  1763. X                            c = c * 8
  1764. X                                + (*++sp - '0');
  1765. X                        if (sp[1] >= '0'
  1766. X                            && sp[1] <= '8')
  1767. X                            c = c * 8
  1768. X                                + (*++sp - '0');
  1769. X                        switch((char)c) {
  1770. X                        case 0:
  1771. X                            if (flag == 'K')
  1772. X                                *dp++ = '\200';
  1773. X                            else {
  1774. X                                *dp++ = '\\';
  1775. X                                *dp++ = '0';
  1776. X                                *dp++ = '0';
  1777. X                                *dp++ = '0';
  1778. X                            }
  1779. X                            break;
  1780. X                        case '$':
  1781. X                        case '\'':
  1782. X                        case '\\':
  1783. X                            if (flag != 'K')
  1784. X                                *dp++ = '\\';
  1785. X                            /* FALLTHROUGH */
  1786. X                        default:
  1787. X                            if (flag == 'G'
  1788. X                                && c == '%')
  1789. X                                *dp++ = '\\';
  1790. X                            *dp++ = c;
  1791. X                            break;
  1792. X                        }
  1793. X                        break;
  1794. X                    default:
  1795. X                        *dp++ = '\\';
  1796. X                        *dp++ = *sp;
  1797. X                        break;
  1798. X                    }
  1799. X                    sp++;
  1800. X                    break;
  1801. X                case '^':
  1802. X                    if (*++sp >= 'A' && *sp <= '_') {
  1803. X                        *dp++ = *sp++ - '@';
  1804. X                    } else if (*sp >= 'a' && *sp <= 'z') {
  1805. X                        *dp++ = *sp++ - 'a' + 1;
  1806. X                    } else if (*sp == '@') {
  1807. X                        if (flag == 'K')
  1808. X                            *dp++ = '\200';
  1809. X                        else {
  1810. X                            *dp++ = '\\';
  1811. X                            *dp++ = '0';
  1812. X                            *dp++ = '0';
  1813. X                            *dp++ = '0';
  1814. X                        }
  1815. X                        sp++;
  1816. X                    } else 
  1817. X                        *dp++ = '^';
  1818. X                    break;
  1819. X                case '$':
  1820. X                    if (flag != 'K')
  1821. X                        *dp++ = '\\';
  1822. X                    /* FALLTHROUGH */
  1823. X                default:
  1824. X                    *dp++ = *sp++;
  1825. X                    break;
  1826. X                }
  1827. X            }
  1828. X            if (pad != 0 || fract != 0) {
  1829. X                if (fract == 0)
  1830. X                    sprintf(dp, "$<%d", pad);
  1831. X                else
  1832. X                    sprintf(dp, "$<%d.%d", pad, fract);
  1833. X                dp += strlen(dp);
  1834. X                if (mul) 
  1835. X                    *dp++ = '*';
  1836. X                *dp++ = '>';
  1837. X            }
  1838. X            *dp++ = '\0';
  1839. X            if(name[0] == 't' && name[1] == 'c' && name[2] == '\0'){
  1840. X                if (_getother(entry, path, ct))
  1841. X                    return 1;
  1842. X                break;
  1843. X            }
  1844. X            if (ind == -1)
  1845. X                break;
  1846. X            if (ct->strs[ind] != (char *) -1)
  1847. X                break;
  1848. X            if ((ct->strs[ind] = _addstr(entry)) == NULL)
  1849. X                return 1;
  1850. X            break;    
  1851. X        case '#':
  1852. X#ifdef DEBUG
  1853. X            putchar('#');
  1854. X#endif
  1855. X            i = atoi(++sp);
  1856. X            while(*sp != '\0' && *sp++ != ':');
  1857. X            ind = _findnumcode(name);
  1858. X            if (ind == -1)
  1859. X                break;
  1860. X            if (ct->nums[ind] != -2)
  1861. X                break;
  1862. X            ct->nums[ind] = i;
  1863. X            break;
  1864. X        default:
  1865. X            while(*sp != '\0' && *sp++ != ':');
  1866. X            if (*(dp - 1) == '@') {
  1867. X#ifdef DEBUG
  1868. X                putchar('@');
  1869. X#endif
  1870. X                *(dp - 1) = '\0';
  1871. X                ind = _findboolcode(name);
  1872. X                if (ind != -1) {
  1873. X#ifdef DEBUG
  1874. X                    putchar('!');
  1875. X#endif
  1876. X                    if (ct->bools[ind] == -1)
  1877. X                        ct->bools[ind] = 0;
  1878. X                    break;
  1879. X                }
  1880. X                ind = _findnumcode(name);
  1881. X                if (ind != -1) {
  1882. X#ifdef DEBUG
  1883. X                    putchar('#');
  1884. X#endif
  1885. X                    if (ct->nums[ind] == -2)
  1886. X                        ct->nums[ind] = -1;
  1887. X                    break;
  1888. X                }
  1889. X                ind = _findstrcode(name);
  1890. X                if (ind != -1) {
  1891. X#ifdef DEBUG
  1892. X                    putchar('$');
  1893. X#endif
  1894. X                    if (ct->strs[ind] == (char *) -1)
  1895. X                        ct->strs[ind] = NULL;
  1896. X                    break;
  1897. X                }
  1898. X                break;
  1899. X            }
  1900. X#ifdef DEBUG
  1901. X            putchar('!');
  1902. X#endif
  1903. X            ind = _findboolcode(name);
  1904. X            if (ind == -1)
  1905. X                break;
  1906. X            if (ct->bools[ind] != -1)
  1907. X                break;
  1908. X            ct->bools[ind] = 1;
  1909. X        }
  1910. X    }
  1911. X    return 0;
  1912. X}
  1913. END_OF_FILE
  1914. if test 5172 -ne `wc -c <'gettcap.c'`; then
  1915.     echo shar: \"'gettcap.c'\" unpacked with wrong size!
  1916. fi
  1917. # end of 'gettcap.c'
  1918. fi
  1919. if test -f 'gettinfo.c' -a "${1}" != "-c" ; then 
  1920.   echo shar: Will not clobber existing file \"'gettinfo.c'\"
  1921. else
  1922. echo shar: Extracting \"'gettinfo.c'\" \(5541 characters\)
  1923. sed "s/^X//" >'gettinfo.c' <<'END_OF_FILE'
  1924. X/*
  1925. X * gettinfo.c
  1926. X *
  1927. X * By Ross Ridge
  1928. X * Public Domain
  1929. X * 92/02/01 07:30:02
  1930. X *
  1931. X */
  1932. X
  1933. X#include "defs.h"
  1934. X#include "term.h"
  1935. X
  1936. X#include <ctype.h>
  1937. X
  1938. X#ifdef USE_SCCS_IDS
  1939. static const char SCCSid[] = "@(#) mytinfo gettinfo.c 3.2 92/02/01 public domain, By Ross Ridge";
  1940. X#endif
  1941. X
  1942. int _gettinfo(sp, cur, path)
  1943. register char *sp;
  1944. struct term_path *path;
  1945. TERMINAL *cur; {
  1946. X    static char name[MAX_NAME];
  1947. X    static char entry[MAX_LINE];
  1948. X    register char *dp;
  1949. X    register TERMINAL *ct = cur;
  1950. X    int ind, i, base;
  1951. X    char c, flag;
  1952. X
  1953. X    dp = entry;
  1954. X    while(*sp != ',' && *sp != '\0')
  1955. X        *dp++ = *sp++;
  1956. X    if (ct->name_all == NULL) {
  1957. X        *dp = '\0';
  1958. X        if ((ct->name_all = _addstr(entry)) == NULL)
  1959. X            return 1;
  1960. X        while(dp > entry && *--dp != '|');
  1961. X        ct->name_long = ct->name_all + (dp - entry) + 1;
  1962. X    }
  1963. X
  1964. X     while(*sp != '\0') {
  1965. X        while(*sp == ',')
  1966. X            sp++;
  1967. X        while(isspace(*sp))
  1968. X            sp++;
  1969. X        if (*sp == ',')
  1970. X            continue;
  1971. X        if (*sp == '\0')
  1972. X            break;
  1973. X        dp = name;
  1974. X        while (*sp != ',' && *sp != '#' && *sp != '=' && !isspace(*sp) && *sp != '\0')
  1975. X            *dp++ = *sp++;
  1976. X        *dp = '\0';
  1977. X#ifdef DEBUG
  1978. X        printf(" %s", name);
  1979. X#endif
  1980. X        switch(*sp) {
  1981. X        case '=':
  1982. X#ifdef DEBUG
  1983. X            putchar('$');
  1984. X#endif
  1985. X            dp = entry;
  1986. X            sp++;
  1987. X            ind = _findstrname(name);
  1988. X            if (ind != -1)
  1989. X                flag = _strflags[ind];
  1990. X            else {
  1991. X                ind = _findstrfname(name);
  1992. X                if (ind != -1)
  1993. X                    flag = _strflags[ind];
  1994. X                else
  1995. X                    flag = 'K';
  1996. X            }
  1997. X            while(*sp != '\0' && *sp != ',') {
  1998. X                switch(*sp) {
  1999. X                case '%':
  2000. X                    *dp++ = *sp++;
  2001. X                    if (*sp == '^' && flag == 'G')
  2002. X                        *dp++ = *sp++;
  2003. X                    break;
  2004. X                case '\\':
  2005. X                    switch(*++sp) {
  2006. X                    case 'e':
  2007. X                    case 'E': *dp++ = '\033'; break;
  2008. X                    case 'l': *dp++ = '\012'; break;
  2009. X                    case 'n': *dp++ = '\n'; break;
  2010. X                    case 'r': *dp++ = '\r'; break;
  2011. X                    case 't': *dp++ = '\t'; break;
  2012. X                    case 'b': *dp++ = '\b'; break;
  2013. X                    case 'f': *dp++ = '\f'; break;
  2014. X                    case 's': *dp++ = ' '; break;
  2015. X
  2016. X                    case '^': 
  2017. X                    case '\\':
  2018. X                    case ',':
  2019. X                    case ':':
  2020. X                        *dp++ = *sp; break;
  2021. X
  2022. X                    case '0':
  2023. X                        if (!isdigit(*(sp + 1))) {
  2024. X                            *dp++ = '\200';
  2025. X                            break;
  2026. X                        }
  2027. X                        /* FALLTHROUGH */
  2028. X                    case '1':
  2029. X                    case '2':
  2030. X                    case '3':
  2031. X                    case '4':
  2032. X                    case '5':
  2033. X                    case '6':
  2034. X                    case '7':
  2035. X                        c = *sp - '0';
  2036. X                        if (isdigit(sp[1]))
  2037. X                            c = c * 8 + (*++sp-'0');
  2038. X                        if (isdigit(sp[1]))
  2039. X                            c = c * 8 + (*++sp-'0');
  2040. X                        switch((char)c) {
  2041. X                        case 0:
  2042. X                            if (flag == 'K') 
  2043. X                                *dp++ = '\200';
  2044. X                            else {
  2045. X                                *dp++ = '\\';
  2046. X                                *dp++ = '0';
  2047. X                                *dp++ = '0';
  2048. X                                *dp++ = '0';
  2049. X                            }
  2050. X                            break;
  2051. X                        case '$':
  2052. X                        case '\'':
  2053. X                        case '\\':
  2054. X                            if (flag != 'K')
  2055. X                                *dp++ = '\\';
  2056. X                            /* FALLTHROUGH */
  2057. X                        default:
  2058. X                            if (flag == 'G'
  2059. X                                && c == '%')
  2060. X                                *dp++ = '\\';
  2061. X                            *dp++ = c;
  2062. X                            break;
  2063. X                        }
  2064. X                        break;
  2065. X                    default:
  2066. X                        *dp++ = '\\';
  2067. X                        *dp++ = *sp;
  2068. X                        break;
  2069. X                    }
  2070. X                    sp++;
  2071. X                    break;
  2072. X                case '^':
  2073. X                    if (*++sp >= 'A' && *sp <= '_') {
  2074. X                        *dp++ = *sp++ - '@';
  2075. X                    } else if (*sp >= 'a' && *sp <= 'z') {
  2076. X                        *dp++ = *sp++ - 'a' + 1;
  2077. X                    } else if (*sp == '@') {
  2078. X                        if (flag == 'K')
  2079. X                            *dp++ = '\200';
  2080. X                        else {
  2081. X                            *dp++ = '\\';
  2082. X                            *dp++ = '0';
  2083. X                            *dp++ = '0';
  2084. X                            *dp++ = '0';
  2085. X                        }
  2086. X                        sp++;
  2087. X                    } else 
  2088. X                        *dp++ = '^';
  2089. X                    break;
  2090. X                default:
  2091. X                    *dp++ = *sp++;
  2092. X                    break;
  2093. X                }
  2094. X            }
  2095. X            *dp++ = '\0';
  2096. X            if (strcmp(name, "use") == 0) {
  2097. X                if (_getother(entry, path, ct))
  2098. X                    return 1;
  2099. X                break;
  2100. X            }
  2101. X            if (ind == -1)
  2102. X                break;
  2103. X            if (ct->strs[ind] != (char *) -1)
  2104. X                break;
  2105. X            if ((ct->strs[ind] = _addstr(entry)) == NULL)
  2106. X                return 1;
  2107. X            break;    
  2108. X        case '#':
  2109. X#ifdef DEBUG
  2110. X            putchar('#');
  2111. X#endif
  2112. X#if 0
  2113. X            i = atoi(++sp);
  2114. X#else
  2115. X            sp++;
  2116. X            if (*sp == '0') {
  2117. X                sp++;
  2118. X                if (*sp == 'x' || *sp == 'X') {
  2119. X                    sp++;
  2120. X                    base = 16;
  2121. X                } else
  2122. X                    base = 8;
  2123. X            } else
  2124. X                base = 10;
  2125. X            i = 0;
  2126. X            while(1) {
  2127. X                if (isdigit(*sp))
  2128. X                    i = i * base + *sp - '0';
  2129. X                else if (base == 16 && isxdigit(*sp))
  2130. X                    i = i * base + tolower(*sp) - 'a' + 10;
  2131. X                else
  2132. X                    break;
  2133. X                sp++;
  2134. X            }
  2135. X#endif
  2136. X            while(*sp != '\0' && *sp != ',')
  2137. X                sp++;
  2138. X
  2139. X            ind = _findnumname(name);
  2140. X            if (ind != -1) {
  2141. X                if (ct->nums[ind] != -2)
  2142. X                    break;
  2143. X                ct->nums[ind] = i;
  2144. X            } else {
  2145. X                ind = _findnumfname(name);
  2146. X                if (ind != -1) {
  2147. X                    if (ct->nums[ind] != -2)
  2148. X                        break;
  2149. X                    ct->nums[ind] = i;
  2150. X                }
  2151. X            }
  2152. X            break;
  2153. X        default:
  2154. X            while(*sp != '\0' && *sp++ != ',');
  2155. X            if (*(dp - 1) == '@') {
  2156. X#ifdef DEBUG
  2157. X                putchar('@');
  2158. X#endif
  2159. X                *(dp - 1) = '\0';
  2160. X                ind = _findboolname(name);
  2161. X                if (ind != -1) {
  2162. X#ifdef DEBUG
  2163. X                    putchar('!');
  2164. X#endif
  2165. X                    ct->bools[ind] = 0;
  2166. X                    break;
  2167. X                }
  2168. X                ind = _findnumname(name);
  2169. X                if (ind != -1) {
  2170. X#ifdef DEBUG
  2171. X                    putchar('#');
  2172. X#endif
  2173. X                    ct->nums[ind] = -1;
  2174. X                    break;
  2175. X                }
  2176. X                ind = _findstrname(name);
  2177. X                if (ind != -1) {
  2178. X#ifdef DEBUG
  2179. X                    putchar('$');
  2180. X#endif
  2181. X                    ct->strs[ind] = NULL;
  2182. X                    break;
  2183. X                }
  2184. X                ind = _findboolfname(name);
  2185. X                if (ind != -1) {
  2186. X#ifdef DEBUG
  2187. X                    putchar('!');
  2188. X#endif
  2189. X                    ct->bools[ind] = 0;
  2190. X                    break;
  2191. X                }
  2192. X                ind = _findnumfname(name);
  2193. X                if (ind != -1) {
  2194. X#ifdef DEBUG
  2195. X                    putchar('#');
  2196. X#endif
  2197. X                    ct->nums[ind] = -1;
  2198. X                    break;
  2199. X                }
  2200. X                ind = _findstrfname(name);
  2201. X                if (ind != -1) {
  2202. X#ifdef DEBUG
  2203. X                    putchar('$');
  2204. X#endif
  2205. X                    ct->strs[ind] = NULL;
  2206. X                    break;
  2207. X                }
  2208. X                break;
  2209. X            }
  2210. X#ifdef DEBUG
  2211. X            putchar('!');
  2212. X#endif
  2213. X            ind = _findboolname(name);
  2214. X            if (ind == -1) {
  2215. X                ind = _findboolfname(name);
  2216. X                if (ind == -1)
  2217. X                    break;
  2218. X            }
  2219. X            if (ct->bools[ind] != -1)
  2220. X                break;
  2221. X            ct->bools[ind] = 1;
  2222. X            break;
  2223. X        }
  2224. X    }
  2225. X    return 0;
  2226. X}
  2227. END_OF_FILE
  2228. if test 5541 -ne `wc -c <'gettinfo.c'`; then
  2229.     echo shar: \"'gettinfo.c'\" unpacked with wrong size!
  2230. fi
  2231. # end of 'gettinfo.c'
  2232. fi
  2233. if test -f 'qsort.c' -a "${1}" != "-c" ; then 
  2234.   echo shar: Will not clobber existing file \"'qsort.c'\"
  2235. else
  2236. echo shar: Extracting \"'qsort.c'\" \(6250 characters\)
  2237. sed "s/^X//" >'qsort.c' <<'END_OF_FILE'
  2238. X/*
  2239. X * qsort.c
  2240. X *
  2241. X * This came from the GNU Emacs (18.55) tape.
  2242. X * Modified by Ross Ridge for use in mytinfo
  2243. X * 92/06/04 11:39:25
  2244. X *
  2245. X */
  2246. X
  2247. X#ifdef USE_MYQSORT
  2248. X
  2249. X#ifdef USE_SCCS_IDS
  2250. static const char SCCSid[] = "@(#) mytinfo qsort.c 3.3 92/06/04 public domain, By Ross Ridge";
  2251. X#endif
  2252. X
  2253. X/*
  2254. X * qsort.c:
  2255. X * Our own version of the system qsort routine which is faster by an average
  2256. X * of 25%, with lows and highs of 10% and 50%.
  2257. X * The THRESHold below is the insertion sort threshold, and has been adjusted
  2258. X * for records of size 48 bytes.
  2259. X * The MTHREShold is where we stop finding a better median.
  2260. X */
  2261. X
  2262. X#define        THRESH        4        /* threshold for insertion */
  2263. X
  2264. X#define        MTHRESH        6        /* threshold for median */
  2265. X
  2266. X
  2267. X
  2268. static  int        qsz;            /* size of each record */
  2269. static  compar_fn    qcmp;            /* the comparison routine */
  2270. X
  2271. static  int        thresh;            /* THRESHold in chars */
  2272. static  int        mthresh;        /* MTHRESHold in chars */
  2273. X
  2274. X/*
  2275. X * qst:
  2276. X * Do a quicksort
  2277. X * First, find the median element, and put that one in the first place as the
  2278. X * discriminator.  (This "median" is just the median of the first, last and
  2279. X * middle elements).  (Using this median instead of the first element is a big
  2280. X * win).  Then, the usual partitioning/swapping, followed by moving the
  2281. X * discriminator into the right place.  Then, figure out the sizes of the two
  2282. X * partions, do the smaller one recursively and the larger one via a repeat of
  2283. X * this code.  Stopping when there are less than THRESH elements in a partition
  2284. X * and cleaning up with an insertion sort (in our caller) is a huge win.
  2285. X * All data swaps are done in-line, which is space-losing but time-saving.
  2286. X * (And there are only three places where this is done).
  2287. X */
  2288. static void
  2289. qst (base, max)
  2290. X     char *base; char *max;
  2291. X{
  2292. X  register char *i, *j, *jj, *mid;
  2293. X  register int ii, c;
  2294. X  char *tmp;
  2295. X  int lo, hi;
  2296. X
  2297. X  lo = max - base;    /* number of elements as chars */
  2298. X  do
  2299. X    {
  2300. X      /*
  2301. X       * At the top here, lo is the number of characters of elements in the
  2302. X       * current partition.  (Which should be max - base).
  2303. X       * Find the median of the first, last, and middle element and make that the
  2304. X       * middle element.  Set j to largest of first and middle.  If max is larger
  2305. X       * than that guy, then it's that guy, else compare max with loser of first
  2306. X       * and take larger.  Things are set up to prefer the middle, then the first
  2307. X       * in case of ties.
  2308. X       */
  2309. X      mid = i = base + qsz * ((lo/qsz) >> 1);
  2310. X      if (lo >= mthresh)
  2311. X    {
  2312. X      j = ((*qcmp) ((anyptr)(jj = base), (anyptr)i) > 0 ? jj : i);
  2313. X      if ((*qcmp) ((anyptr)j, (anyptr)(tmp = max - qsz)) > 0)
  2314. X        {
  2315. X          j = (j == jj ? i : jj);    /* switch to first loser */
  2316. X          if ((*qcmp) ((anyptr)j, (anyptr)tmp) < 0)
  2317. X        j = tmp;
  2318. X        }
  2319. X      if (j != i)
  2320. X        {
  2321. X          ii = qsz;
  2322. X          do
  2323. X        {
  2324. X          c = *i;
  2325. X          *i++ = *j;
  2326. X          *j++ = c;
  2327. X        }
  2328. X          while(  --ii  );
  2329. X        }
  2330. X    }
  2331. X      /*
  2332. X       * Semi-standard quicksort partitioning/swapping
  2333. X       */
  2334. X      for (i = base, j = max - qsz; ;)
  2335. X    {
  2336. X      while (i < mid && (*qcmp) ((anyptr)i, (anyptr)mid) <= 0)
  2337. X        i += qsz;
  2338. X      while (j > mid)
  2339. X        {
  2340. X          if ((*qcmp) ((anyptr)mid, (anyptr)j) <= 0)
  2341. X        {
  2342. X          j -= qsz;
  2343. X          continue;
  2344. X        }
  2345. X          tmp = i + qsz;        /* value of i after swap */
  2346. X          if (i == mid)
  2347. X        {    /* j <-> mid, new mid is j */
  2348. X          mid = jj = j;
  2349. X        }
  2350. X          else
  2351. X        {            /* i <-> j */
  2352. X          jj = j;
  2353. X          j -= qsz;
  2354. X        }
  2355. X          goto  swap;
  2356. X        }
  2357. X      if (i == mid)
  2358. X        {
  2359. X          break;
  2360. X        }
  2361. X      else
  2362. X        {                /* i <-> mid, new mid is i */
  2363. X          jj = mid;
  2364. X          tmp = mid = i;        /* value of i after swap */
  2365. X          j -= qsz;
  2366. X        }
  2367. X    swap:
  2368. X      ii = qsz;
  2369. X      do
  2370. X        {
  2371. X          c = *i;
  2372. X          *i++ = *jj;
  2373. X          *jj++ = c;
  2374. X        }
  2375. X      while (--ii);
  2376. X      i = tmp;
  2377. X    }
  2378. X      /*
  2379. X       * Look at sizes of the two partitions, do the smaller one first by
  2380. X       * recursion, then do the larger one by making sure lo is its size,
  2381. X       * base and max are update correctly, and branching back.
  2382. X       * But only repeat (recursively or by branching) if the partition is
  2383. X       * of at least size THRESH.
  2384. X       */
  2385. X      i = (j = mid) + qsz;
  2386. X      if ((lo = j - base) <= (hi = max - i))
  2387. X    {
  2388. X      if (lo >= thresh)
  2389. X        qst (base, j);
  2390. X      base = i;
  2391. X      lo = hi;
  2392. X    }
  2393. X      else
  2394. X    {
  2395. X      if (hi >= thresh)
  2396. X        qst (i, max);
  2397. X      max = j;
  2398. X    }
  2399. X    }
  2400. X  while (lo >= thresh);
  2401. X}
  2402. X
  2403. X
  2404. X/*
  2405. X * qsort:
  2406. X * First, set up some global parameters for qst to share.  Then, quicksort
  2407. X * with qst(), and then a cleanup insertion sort ourselves.  Sound simple?
  2408. X * It's not...
  2409. X */
  2410. static void
  2411. qsort (base, n, size, compar)
  2412. X     anyptr base;
  2413. X     unsigned n;
  2414. X     mysize_t size;
  2415. X     compar_fn compar;
  2416. X{
  2417. X  register char *i, *j, *lo, *hi, *min;
  2418. X  register int c;
  2419. X  char *max;
  2420. X
  2421. X  if (n <= 1)  return;
  2422. X  qsz = size / sizeof(char); /* of course if sizeof(char) aint one it had
  2423. X                better be an even divisor of size      */
  2424. X  qcmp = compar;
  2425. X  thresh = qsz*THRESH;
  2426. X  mthresh = qsz*MTHRESH;
  2427. X  max = (char *)base + n*qsz;
  2428. X  if (n >= THRESH)
  2429. X    {
  2430. X      qst ((char *)base, max);
  2431. X      hi = (char *)base + thresh;
  2432. X    }
  2433. X  else
  2434. X    {
  2435. X      hi = max;
  2436. X    }
  2437. X  /*
  2438. X   * First put smallest element, which must be in the first THRESH, in
  2439. X   * the first position as a sentinel.  This is done just by searching
  2440. X   * the first THRESH elements (or the first n if n < THRESH), finding
  2441. X   * the min, and swapping it into the first position.
  2442. X   */
  2443. X  for (j = lo = (char *)base; (lo += qsz) < hi; )
  2444. X    {
  2445. X      if ((*qcmp) ((anyptr)j, (anyptr)lo) > 0)
  2446. X    j = lo;
  2447. X    }
  2448. X  if (j != (char *)base)
  2449. X    {            /* swap j into place */
  2450. X      for (i = (char *)base, hi = (char *)base + qsz; i < hi;)
  2451. X    {
  2452. X      c = *j;
  2453. X      *j++ = *i;
  2454. X      *i++ = c;
  2455. X    }
  2456. X    }
  2457. X  /*
  2458. X   * With our sentinel in place, we now run the following hyper-fast
  2459. X   * insertion sort.  For each remaining element, min, from [1] to [n-1],
  2460. X   * set hi to the index of the element AFTER which this one goes.
  2461. X   * Then, do the standard insertion sort shift on a character at a time
  2462. X   * basis for each element in the frob.
  2463. X   */
  2464. X  for (min = (char *)base; (hi = min += qsz) < max;)
  2465. X    {
  2466. X      while ( (*qcmp) ((anyptr)(hi -= qsz), (anyptr) min) > 0);
  2467. X      if ((hi += qsz) != min)
  2468. X    {
  2469. X      for (lo = min + qsz; --lo >= min;)
  2470. X        {
  2471. X          c = *lo;
  2472. X          for (i = j = lo; (j -= qsz) >= hi; i = j)
  2473. X        *i = *j;
  2474. X          *i = c;
  2475. X        }
  2476. X    }
  2477. X    }
  2478. X}
  2479. X
  2480. X
  2481. X#endif /* USE_MYQSORT */
  2482. END_OF_FILE
  2483. if test 6250 -ne `wc -c <'qsort.c'`; then
  2484.     echo shar: \"'qsort.c'\" unpacked with wrong size!
  2485. fi
  2486. # end of 'qsort.c'
  2487. fi
  2488. if test -f 'sprintf.c' -a "${1}" != "-c" ; then 
  2489.   echo shar: Will not clobber existing file \"'sprintf.c'\"
  2490. else
  2491. echo shar: Extracting \"'sprintf.c'\" \(8590 characters\)
  2492. sed "s/^X//" >'sprintf.c' <<'END_OF_FILE'
  2493. X/*
  2494. X * sprintf.c
  2495. X *
  2496. X * By Ross Ridge
  2497. X * Public Domain
  2498. X * 92/02/01 07:30:16
  2499. X *
  2500. X */
  2501. X
  2502. X#include "defs.h"
  2503. X
  2504. X#include <ctype.h>
  2505. X
  2506. X#ifdef USE_SCCS_IDS
  2507. static const char SCCSid[] = "@(#) mytinfo sprintf.c 3.2 92/02/01 public domain, By Ross Ridge";
  2508. X#endif
  2509. X
  2510. X#ifdef TEST
  2511. X#define USE_FAKE_STDIO
  2512. X#undef PRINTF
  2513. X#define sprintf _sprintf
  2514. X#endif
  2515. X
  2516. X#ifdef USE_FAKE_STDIO
  2517. X
  2518. X#ifdef PRINTF
  2519. X#undef putchar
  2520. X#define PUTCHAR(c) (cnt++, putchar(c))
  2521. X#else
  2522. X#define PUTCHAR(c) (*s++ = c)
  2523. X#endif
  2524. X
  2525. X#ifdef PRINTF
  2526. X#ifdef USE_STDARG
  2527. X#ifdef USE_PROTOTYPES
  2528. int
  2529. printf(char *fmt, ...) {
  2530. X#else
  2531. int printf(fmt)
  2532. char *fmt; {
  2533. X#endif
  2534. X#else
  2535. int printf(va_alist)
  2536. va_dcl {
  2537. X    register char *fmt;
  2538. X#endif
  2539. X    register int cnt;
  2540. X#else /* PRINTF */
  2541. X#ifdef lint
  2542. X/* VARARGS1 */
  2543. int
  2544. sprintf(str, fmt)
  2545. char *str;
  2546. char *fmt; {
  2547. X#else /* lint */
  2548. X#ifdef USE_STDARG
  2549. X#ifdef USE_PROTOTYPES
  2550. int sprintf(char *str, char *fmt, ...) {
  2551. X#else /* USE_PROTOTYPES */
  2552. int sprintf(str, fmt)
  2553. char *str;
  2554. char *fmt; {
  2555. X#endif /* else USE_PROTOTYPES */
  2556. X#else /* USE_STDARG */
  2557. int sprintf(va_alist)
  2558. va_dcl {
  2559. X    register char *fmt;
  2560. X    char *str;
  2561. X#endif /* else USE_STDARG */
  2562. X#endif /* else lint */
  2563. X    register char *s;
  2564. X#endif /* else PRINTF */
  2565. X    int minus;
  2566. X    int sharp;
  2567. X    int space;
  2568. X    int plus;
  2569. X    int zero;
  2570. X    int ell;
  2571. X    int prec;
  2572. X    int width;
  2573. X    int sign;
  2574. X    int pad;
  2575. X    char buf[100];
  2576. X    register long n;
  2577. X    register unsigned long u;
  2578. X    register char *d;
  2579. X    int l;
  2580. X    int k;
  2581. X    va_list args;
  2582. X
  2583. X#ifdef lint
  2584. X    args = (va_list) 0;
  2585. X#else
  2586. X#ifdef USE_STDARG
  2587. X    va_start(args, fmt);
  2588. X#else
  2589. X    va_start(args);
  2590. X#ifndef PRINTF
  2591. X    str = va_arg(args, char *);
  2592. X#endif
  2593. X    fmt = va_arg(args, char *);
  2594. X#endif
  2595. X#endif /* else lint */
  2596. X    
  2597. X
  2598. X#ifdef PRINTF
  2599. X    cnt = 0;
  2600. X#else
  2601. X    s = str;
  2602. X#endif
  2603. X
  2604. X    while(*fmt != '\0') {
  2605. X        if (*fmt == '%') {
  2606. X            fmt++;
  2607. X            if (*fmt == '%' || *fmt == '\0') {
  2608. X                PUTCHAR('%');
  2609. X                fmt++;
  2610. X                continue;
  2611. X            }
  2612. X            minus = plus = sharp = space = zero = ell = 0;
  2613. X            width = 0;
  2614. X            prec = -1;
  2615. X            do {
  2616. X                switch(*fmt) {
  2617. X                case '-': minus = 1; continue;
  2618. X                case '+': plus = 1; continue;
  2619. X                case ' ': space = 1; continue;
  2620. X                case '#': sharp = 1; continue;
  2621. X                }
  2622. X                break;
  2623. X            } while (*++fmt != '\0');
  2624. X            if (*fmt == '0') {
  2625. X                zero = 1;
  2626. X                fmt++;
  2627. X            }
  2628. X            if (*fmt == '*') {
  2629. X                width = va_arg(args, int);
  2630. X                fmt++;
  2631. X            } else if (isdigit(*fmt)) {
  2632. X                width = *fmt++ - '0';
  2633. X                while(isdigit(*fmt))
  2634. X                    width = 10 * width + *fmt++ - '0';
  2635. X            }
  2636. X            if (*fmt == '.') {
  2637. X                prec = 0;
  2638. X                fmt++;
  2639. X                if (*fmt == '*') {
  2640. X                    prec = va_arg(args, int);
  2641. X                    fmt++;
  2642. X                } else {
  2643. X                    while(isdigit(*fmt))
  2644. X                        prec = 10 * prec + *fmt++ - '0';
  2645. X                }
  2646. X            }
  2647. X            if (*fmt == 'l') {
  2648. X                ell = 1;
  2649. X                fmt++;
  2650. X            }
  2651. X            sign = 0;
  2652. X            l = 0;
  2653. X            d = buf;
  2654. X            switch(*fmt) {
  2655. X            case 'd':
  2656. X            case 'i':
  2657. X                if (ell)
  2658. X                    n = va_arg(args, long);
  2659. X                else
  2660. X                    n = va_arg(args, int);
  2661. X                if (n < 0) {
  2662. X                    sign = -1;
  2663. X                    n = -n;
  2664. X                } else {
  2665. X                    sign = 1;
  2666. X                }
  2667. X                while(n != 0) {
  2668. X                    *d++ = (n % 10) + '0';
  2669. X                    n /= 10;
  2670. X                }
  2671. X                break;
  2672. X            case 'o':
  2673. X                if (ell)
  2674. X                    u = va_arg(args, unsigned long);
  2675. X                else
  2676. X                    u = va_arg(args, unsigned );
  2677. X                while(u != 0) {
  2678. X                    *d++ = (u & 7) + '0';
  2679. X                    u >>= 3;
  2680. X                }
  2681. X                if (sharp)
  2682. X                    l = 1;
  2683. X                break;
  2684. X            case 'u':
  2685. X                if (ell)
  2686. X                    u = va_arg(args, unsigned long);
  2687. X                else
  2688. X                    u = va_arg(args, unsigned );
  2689. X                while(u != 0) {
  2690. X                    *d++ = (u % 10) + '0';
  2691. X                    u /= 10;
  2692. X                }
  2693. X                break;
  2694. X            case 'x':
  2695. X                if (ell)
  2696. X                    u = va_arg(args, unsigned long);
  2697. X                else
  2698. X                    u = va_arg(args, unsigned );
  2699. X                while(u != 0) {
  2700. X                    *d++ = "0123456789abcdef"[u & 15];
  2701. X                    u >>= 4;
  2702. X                }
  2703. X                if (sharp)
  2704. X                    l += 2;
  2705. X                break;
  2706. X            case 'X':
  2707. X                if (ell)
  2708. X                    u = va_arg(args, unsigned long);
  2709. X                else
  2710. X                    u = va_arg(args, unsigned );
  2711. X                while(u != 0) {
  2712. X                    /* just to be silly... */
  2713. X                    *d++ = (u & 15)["0123456789ABCDEF"];
  2714. X                    u >>= 4;
  2715. X                }
  2716. X                if (sharp)
  2717. X                    l += 2;
  2718. X                break;
  2719. X            case 's':
  2720. X                d = va_arg(args, char *);
  2721. X                l = strlen(d);
  2722. X                break;
  2723. X            case 'c':
  2724. X                buf[0] = va_arg(args, int);
  2725. X                l = 1;
  2726. X                break;
  2727. X            default:
  2728. X                PUTCHAR(*fmt++);
  2729. X                continue;
  2730. X            }
  2731. X            if (*fmt == 's' || *fmt == 'c') {
  2732. X                if (prec != -1 && l > prec) 
  2733. X                    l = prec;
  2734. X                pad = width - l;
  2735. X                if (zero) 
  2736. X                    while(pad-- > 0)
  2737. X                        PUTCHAR('0');
  2738. X                else if (!minus)
  2739. X                    while(pad-- > 0)
  2740. X                        PUTCHAR(' ');
  2741. X                while(l-- > 0)
  2742. X                    PUTCHAR(*d++);
  2743. X                if (minus)
  2744. X                    while(pad-- > 0)
  2745. X                        PUTCHAR(' ');
  2746. X            } else {
  2747. X                if (prec == -1)
  2748. X                    prec = 1;
  2749. X                k = d - buf;
  2750. X                if (k < prec)
  2751. X                    l += prec;
  2752. X                else
  2753. X                    l += k;
  2754. X                if (sign == -1)
  2755. X                    l++;
  2756. X                else if (sign == 1 && (space || plus))
  2757. X                    l++;
  2758. X                pad = width - l;
  2759. X                if (zero)
  2760. X                    while(pad-- > 0)
  2761. X                        PUTCHAR('0');
  2762. X                else if (!minus)
  2763. X                    while(pad-- > 0)
  2764. X                        PUTCHAR(' ');
  2765. X                if (*fmt == 'x' && sharp) {
  2766. X                    PUTCHAR('0');
  2767. X                    PUTCHAR('x');
  2768. X                } else if (*fmt == 'X' && sharp) {
  2769. X                    PUTCHAR('0');
  2770. X                    PUTCHAR('X');
  2771. X                } else if (*fmt == 'o' && sharp) {
  2772. X                    PUTCHAR('0');
  2773. X                } else if (sign == -1) {
  2774. X                    PUTCHAR('-');
  2775. X                } else if (sign == 1 && space) {
  2776. X                    PUTCHAR(' ');
  2777. X                } else if (sign == 1 && plus) {
  2778. X                    PUTCHAR('+');
  2779. X                }
  2780. X                while(k++ < prec)
  2781. X                    PUTCHAR('0');
  2782. X                while(d > buf)
  2783. X                    PUTCHAR(*--d);
  2784. X                if (!zero && minus)
  2785. X                    while(pad-- > 0)
  2786. X                        PUTCHAR(' ');
  2787. X            }
  2788. X            fmt++;
  2789. X        } else {
  2790. X            PUTCHAR(*fmt++);
  2791. X        }
  2792. X    }
  2793. X#ifdef PRINTF
  2794. X    return cnt;
  2795. X#else
  2796. X    *s = '\0';
  2797. X    return s - str;
  2798. X#endif
  2799. X}
  2800. X
  2801. X#endif /* USE_FAKE_STDIO */
  2802. X
  2803. X#ifdef TEST
  2804. X#ifndef PRINTF
  2805. X#undef sprintf
  2806. main(argc, argv)
  2807. int argc;
  2808. char *argv; {
  2809. X    char buf[256];
  2810. X
  2811. X    _sprintf(buf, "%d", 2);
  2812. X    printf("'%s'\n", buf);
  2813. X    sprintf(buf, "%d", 2);
  2814. X    printf("'%s'\n", buf);
  2815. X    _sprintf(buf, "%05d", 2);
  2816. X    printf("'%s'\n", buf);
  2817. X    sprintf(buf, "%05d", 2);
  2818. X    printf("'%s'\n", buf);
  2819. X    _sprintf(buf, "% 5d", 2);
  2820. X    printf("'%s'\n", buf);
  2821. X    sprintf(buf, "% 5d", 2);
  2822. X    printf("'%s'\n", buf);
  2823. X    _sprintf(buf, "%-5d", 2);
  2824. X    printf("'%s'\n", buf);
  2825. X    sprintf(buf, "%-5d", 2);
  2826. X    printf("'%s'\n", buf);
  2827. X    _sprintf(buf, "%5.3d", 2);
  2828. X    printf("'%s'\n", buf);
  2829. X    sprintf(buf, "%5.3d", 2);
  2830. X    printf("'%s'\n", buf);
  2831. X    _sprintf(buf, "%+d", 2);
  2832. X    printf("'%s'\n", buf);
  2833. X    sprintf(buf, "%+d", 2);
  2834. X    printf("'%s'\n", buf);
  2835. X    _sprintf(buf, "%#-1.2d", 2);
  2836. X    printf("'%s'\n", buf);
  2837. X    sprintf(buf, "%#-1.2d", 2);
  2838. X    printf("'%s'\n", buf);
  2839. X    _sprintf(buf, "% 5d", -2);
  2840. X    printf("'%s'\n", buf);
  2841. X    sprintf(buf, "% 5d", -2);
  2842. X    printf("'%s'\n", buf);
  2843. X    _sprintf(buf, "%-5d", -2);
  2844. X    printf("'%s'\n", buf);
  2845. X    sprintf(buf, "%-5d", -2);
  2846. X    printf("'%s'\n", buf);
  2847. X    _sprintf(buf, "%5.3d", -2);
  2848. X    printf("'%s'\n", buf);
  2849. X    sprintf(buf, "%5.3d", -2);
  2850. X    printf("'%s'\n", buf);
  2851. X    _sprintf(buf, "%%:%o:%x:%X:%ld:%u:%i", 10, 22, 333, -456L, 50000, 6);
  2852. X    printf("'%s'\n", buf);
  2853. X    sprintf(buf, "%%:%o:%x:%X:%ld:%u:%i", 10, 22, 333, -456L, 50000, 6);
  2854. X    printf("'%s'\n", buf);
  2855. X    _sprintf(buf, "%06o:%#6x:%#012.4X:%-5ld:%*u:%*.*i",
  2856. X        10, 22, 333, -456L, 8, 50000, 4, 2, 6);
  2857. X    printf("'%s'\n", buf);
  2858. X    sprintf(buf, "%06o:%#6x:%#012.4X:%-5ld:%*u:%*.*i",
  2859. X        10, 22, 333, -456L, 8, 50000, 4, 2, 6);
  2860. X    printf("'%s'\n", buf);
  2861. X    _sprintf(buf, "%s", "abcdefghi");
  2862. X    printf("'%s'\n", buf);
  2863. X    sprintf(buf, "%s", "abcdefghi");
  2864. X    printf("'%s'\n", buf);
  2865. X    _sprintf(buf, "%.4s", "abcdefghi");
  2866. X    printf("'%s'\n", buf);
  2867. X    sprintf(buf, "%.4s", "abcdefghi");
  2868. X    printf("'%s'\n", buf);
  2869. X    _sprintf(buf, "%4.4s", "abcdefghi");
  2870. X    printf("'%s'\n", buf);
  2871. X    sprintf(buf, "%4.4s", "abcdefghi");
  2872. X    printf("'%s'\n", buf);
  2873. X    _sprintf(buf, "%20s", "abcdefghi");
  2874. X    printf("'%s'\n", buf);
  2875. X    sprintf(buf, "%20s", "abcdefghi");
  2876. X    printf("'%s'\n", buf);
  2877. X    _sprintf(buf, "%-20s", "abcdefghi");
  2878. X    printf("'%s'\n", buf);
  2879. X    sprintf(buf, "%-20s", "abcdefghi");
  2880. X    printf("'%s'\n", buf);
  2881. X    _sprintf(buf, "%-20.20s", "abcdefghi");
  2882. X    printf("'%s'\n", buf);
  2883. X    sprintf(buf, "%-20.20s", "abcdefghi");
  2884. X    printf("'%s'\n", buf);
  2885. X    _sprintf(buf, "%#-0.20s", "abcdefghi");
  2886. X    printf("'%s'\n", buf);
  2887. X    sprintf(buf, "%#-0.20s", "abcdefghi");
  2888. X    printf("'%s'\n", buf);
  2889. X    _sprintf(buf, "%5s", "abcdefghi");
  2890. X    printf("'%s'\n", buf);
  2891. X    sprintf(buf, "%5s", "abcdefghi");
  2892. X    printf("'%s'\n", buf);
  2893. X    _sprintf(buf, "%015s", "abcdefghi");
  2894. X    printf("'%s'\n", buf);
  2895. X    sprintf(buf, "%015s", "abcdefghi");
  2896. X    printf("'%s'\n", buf);
  2897. X    _sprintf(buf, "%c", 'C');
  2898. X    printf("'%s'\n", buf);
  2899. X    sprintf(buf, "%c", 'C');
  2900. X    printf("'%s'\n", buf);
  2901. X    _sprintf(buf, "%5c", 'C');
  2902. X    printf("'%s'\n", buf);
  2903. X    sprintf(buf, "%5c", 'C');
  2904. X    printf("'%s'\n", buf);
  2905. X    _sprintf(buf, "%-5c", 'C');
  2906. X    printf("'%s'\n", buf);
  2907. X    sprintf(buf, "%-5c", 'C');
  2908. X    printf("'%s'\n", buf);
  2909. X    _sprintf(buf, "%d", 0);
  2910. X    printf("'%s'\n", buf);
  2911. X    sprintf(buf, "%d", 0);
  2912. X    printf("'%s'\n", buf);
  2913. X    _sprintf(buf, "%.d", 0);
  2914. X    printf("'%s'\n", buf);
  2915. X    sprintf(buf, "%.d", 0);
  2916. X    printf("'%s'\n", buf);
  2917. X    _sprintf(buf, "%5.0d", 0);
  2918. X    printf("'%s'\n", buf);
  2919. X    sprintf(buf, "%5.0d", 0);
  2920. X    printf("'%s'\n", buf);
  2921. X}
  2922. X#endif /* !PRINTF */
  2923. X#endif /* TEST */
  2924. END_OF_FILE
  2925. if test 8590 -ne `wc -c <'sprintf.c'`; then
  2926.     echo shar: \"'sprintf.c'\" unpacked with wrong size!
  2927. fi
  2928. # end of 'sprintf.c'
  2929. fi
  2930. if test -f 'tcapconv.c' -a "${1}" != "-c" ; then 
  2931.   echo shar: Will not clobber existing file \"'tcapconv.c'\"
  2932. else
  2933. echo shar: Extracting \"'tcapconv.c'\" \(4663 characters\)
  2934. sed "s/^X//" >'tcapconv.c' <<'END_OF_FILE'
  2935. X/*
  2936. X * tcapconv.c
  2937. X *
  2938. X * By Ross Ridge
  2939. X * Public Domain
  2940. X * 92/02/01 07:30:20
  2941. X *
  2942. X */
  2943. X
  2944. X#include "defs.h"
  2945. X#define SINGLE
  2946. X#include "term.h"
  2947. X
  2948. X#ifdef USE_SCCS_IDS
  2949. static const char SCCSid[] = "@(#) mytinfo tcapconv.c 3.2 92/02/01 public domain, By Ross Ridge";
  2950. X#endif
  2951. X
  2952. extern char **_sstrcodes[], **_sstrnames[];
  2953. X
  2954. static char *C_CR = "\r";
  2955. static char *C_LF = "\n";
  2956. static char *C_BS = "\b";
  2957. X/* static char *C_FF = "\f"; */
  2958. static char *C_HT = "\t";
  2959. X/* static char *C_VT = "\013"; */
  2960. X/* static char *C_NL = "\r\n"; */
  2961. X
  2962. X#define DEF(s) ((s) != (char *) -1 && (s) != NULL)
  2963. X#define NOTSET(s) ((s) == (char *) -1)
  2964. X
  2965. X/*
  2966. X * This routine fills in caps that either had defaults under termcap or
  2967. X * can be manufactured from obsolete termcap capabilities. 
  2968. X */
  2969. X
  2970. void
  2971. X_tcapdefault() {
  2972. X    char buf[MAX_LINE * 2 + 2];
  2973. X
  2974. X    if (NOTSET(carriage_return)) {
  2975. X        if (carriage_return_delay > 0) {
  2976. X            sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
  2977. X            carriage_return = _addstr(buf);
  2978. X        } else
  2979. X            carriage_return = _addstr(C_CR);
  2980. X    }
  2981. X    if (NOTSET(cursor_left)) {
  2982. X        if (backspace_delay > 0) {
  2983. X            sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
  2984. X            cursor_left = _addstr(buf);
  2985. X        } else if (backspaces_with_bs == 1)
  2986. X            cursor_left = _addstr(C_BS);
  2987. X        else if (DEF(backspace_if_not_bs))
  2988. X            cursor_left = _addstr(backspace_if_not_bs);
  2989. X    }
  2990. X/* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
  2991. X    if (NOTSET(cursor_down)) {
  2992. X        if (DEF(linefeed_if_not_lf)) 
  2993. X            cursor_down = _addstr(linefeed_if_not_lf);
  2994. X        else if (linefeed_is_newline != 1) {
  2995. X            if (new_line_delay > 0) {
  2996. X                sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
  2997. X                cursor_down = _addstr(buf);
  2998. X            } else
  2999. X                cursor_down = _addstr(C_LF);
  3000. X        }
  3001. X    }
  3002. X    if (NOTSET(scroll_forward) && crt_without_scrolling != 1) {
  3003. X        if (DEF(linefeed_if_not_lf)) 
  3004. X            cursor_down = _addstr(linefeed_if_not_lf);
  3005. X        else if (linefeed_is_newline != 1) {
  3006. X            if (new_line_delay > 0) {
  3007. X                sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
  3008. X                scroll_forward = _addstr(buf);
  3009. X            } else
  3010. X                scroll_forward = _addstr(C_LF);
  3011. X        }
  3012. X    }
  3013. X    if (NOTSET(newline)) {
  3014. X        if (linefeed_is_newline == 1) {
  3015. X            if (new_line_delay > 0) {
  3016. X                sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
  3017. X                newline = _addstr(buf);
  3018. X            } else
  3019. X                newline = _addstr(C_LF);
  3020. X        } else if (DEF(carriage_return) && DEF(scroll_forward)) {
  3021. X            strncpy(buf, carriage_return, MAX_LINE-2);
  3022. X            buf[MAX_LINE-1] = '\0';
  3023. X            strncat(buf, scroll_forward, MAX_LINE-strlen(buf)-1);
  3024. X            buf[MAX_LINE] = '\0';
  3025. X            newline = _addstr(buf);
  3026. X        } else if (DEF(carriage_return) && DEF(cursor_down)) {
  3027. X            strncpy(buf, carriage_return, MAX_LINE-2);
  3028. X            buf[MAX_LINE-1] = '\0';
  3029. X            strncat(buf, cursor_down, MAX_LINE-strlen(buf)-1);
  3030. X            buf[MAX_LINE] = '\0';
  3031. X            newline = _addstr(buf);
  3032. X        }
  3033. X    }
  3034. X
  3035. X/*
  3036. X * We wait until know to decide if we've got a working cr because even
  3037. X * one that doesn't work can be used for newline. Unfortunately the
  3038. X * space allocated for it is wasted.
  3039. X */
  3040. X    if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
  3041. X        carriage_return = NULL;
  3042. X
  3043. X/*
  3044. X * supposedly most termcap entries have ta now and '\t' is no longer a
  3045. X * default, but it doesn't seem to be true...
  3046. X */
  3047. X    if (NOTSET(tab)) {
  3048. X        if (horizontal_tab_delay > 0) {
  3049. X            sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
  3050. X            tab = _addstr(buf);
  3051. X        } else
  3052. X            tab = _addstr(C_HT);
  3053. X    }
  3054. X#if 0
  3055. X/* probably not needed and might confuse some programmes */
  3056. X    if (NOTSET(form_feed)) {
  3057. X        if (form_feed_delay > 0) {
  3058. X            sprintf(buf, "%s$<%d>", C_FF, form_feed_delay);
  3059. X            form_feed = _addstr(buf);
  3060. X        } else
  3061. X            form_feed = _addstr(C_FF);
  3062. X    }
  3063. X#endif
  3064. X    if (init_tabs == -1 && has_hardware_tabs == 1)
  3065. X        init_tabs = 8;
  3066. X
  3067. X    if (NOTSET(key_backspace))
  3068. X        key_backspace = _addstr(C_BS);
  3069. X    if (NOTSET(key_left))
  3070. X        key_left = _addstr(C_BS);
  3071. X    if (NOTSET(key_down))
  3072. X        key_down = _addstr(C_LF);
  3073. X}
  3074. X
  3075. void
  3076. X_tcapconv() {
  3077. X    char buf[MAX_LINE+1];
  3078. X
  3079. X    if (GNU_tab_width > 0 && init_tabs == -1)
  3080. X        init_tabs = GNU_tab_width;
  3081. X
  3082. X    if (GNU_has_meta_key == 1 && has_meta_key == -1)
  3083. X        has_meta_key = 1;
  3084. X
  3085. X/*
  3086. X * this is some what a kludge, but should work unless someone breaks
  3087. X * conventions.
  3088. X */
  3089. X    if (DEF(other_non_function_keys)) {
  3090. X        register char *s;
  3091. X        static char *o;
  3092. X        static char name[MAX_NAME] = "k";
  3093. X        char *str;
  3094. X        int ind;
  3095. X
  3096. X        s = strcpy(buf, other_non_function_keys);
  3097. X        while(*s != '\0') {
  3098. X            o = s;
  3099. X            while(*s != ',' && *s != '\0')
  3100. X                s++;
  3101. X            if (*s != '\0')
  3102. X                *s++ = '\0';
  3103. X            ind = _findstrcode(o);
  3104. X            if (ind == -1)
  3105. X                continue;
  3106. X            str = _term_buf.strs[ind];
  3107. X            if (!DEF(str))
  3108. X                continue;
  3109. X            strncpy(name + 1, strnames[ind], MAX_NAME - 2);
  3110. X            ind = _findstrname(name);
  3111. X            if (ind == -1)
  3112. X                continue;
  3113. X            if (!NOTSET(_term_buf.strs[ind]))
  3114. X                continue;
  3115. X            _term_buf.strs[ind] = _addstr(str);
  3116. X        }
  3117. X    }
  3118. X}
  3119. END_OF_FILE
  3120. if test 4663 -ne `wc -c <'tcapconv.c'`; then
  3121.     echo shar: \"'tcapconv.c'\" unpacked with wrong size!
  3122. fi
  3123. # end of 'tcapconv.c'
  3124. fi
  3125. if test -f 'ttest.c' -a "${1}" != "-c" ; then 
  3126.   echo shar: Will not clobber existing file \"'ttest.c'\"
  3127. else
  3128. echo shar: Extracting \"'ttest.c'\" \(5057 characters\)
  3129. sed "s/^X//" >'ttest.c' <<'END_OF_FILE'
  3130. X/*
  3131. X * ttest.c
  3132. X *
  3133. X * By Ross Ridge
  3134. X * Public Domain
  3135. X * 92/02/01 07:30:47
  3136. X *
  3137. X */
  3138. X#define NOTLIB
  3139. X#include "defs.h"
  3140. X#include "term.h"
  3141. X
  3142. static const char SCCSid[] = "@(#) mytinfo ttest.c 3.2 92/02/01 public domain, By Ross Ridge";
  3143. X
  3144. int
  3145. cup(x,y)
  3146. int x, y; {
  3147. X    if (columns < 2 || lines < 2)
  3148. X        return -1;
  3149. X    if (cursor_address != NULL) 
  3150. X        putp(tparm(cursor_address, y, x));
  3151. X    else if (cursor_home != NULL && cursor_down != NULL
  3152. X         && cursor_right != NULL) {
  3153. X        putp(cursor_home);
  3154. X        if (parm_down_cursor != NULL)
  3155. X            putp(tparm(parm_down_cursor, y));
  3156. X        else
  3157. X            for(; y > 0; y--)
  3158. X                putp(cursor_down);
  3159. X        if (parm_right_cursor != NULL)
  3160. X            putp(tparm(parm_right_cursor, y));
  3161. X        else
  3162. X            for(; y > 0; y--)
  3163. X                putp(cursor_right);
  3164. X    } else if (cursor_to_ll != NULL && cursor_up != NULL
  3165. X           && cursor_right != NULL) {
  3166. X        putp(cursor_to_ll);
  3167. X        if (parm_up_cursor != NULL)
  3168. X            putp(tparm(parm_up_cursor, y));
  3169. X        else
  3170. X            for(y++; y < columns ; y++)
  3171. X                putp(cursor_up);
  3172. X        if (parm_right_cursor != NULL)
  3173. X            putp(tparm(parm_right_cursor, y));
  3174. X        else
  3175. X            for(; y > 0; y--)
  3176. X                putp(cursor_right);
  3177. X    } else
  3178. X        return 1;
  3179. X    return 0;
  3180. X}
  3181. X
  3182. int
  3183. clear() {
  3184. X    int r;
  3185. X    if (clear_screen != NULL)
  3186. X        putp(clear_screen);
  3187. X    else if (clr_eos != NULL) {
  3188. X        r = cup(0,0);
  3189. X        if (r != 0)
  3190. X            return r;
  3191. X        putp(clr_eos);
  3192. X    } else
  3193. X        return -2;
  3194. X    return 0;
  3195. X}
  3196. X
  3197. void
  3198. nl() {
  3199. X    if (newline != NULL) 
  3200. X        putp(newline);
  3201. X    else if (carriage_return != NULL && cursor_down != NULL) {
  3202. X        putp(cursor_down);
  3203. X        putp(carriage_return);
  3204. X    } else 
  3205. X        quit(-1, "can't do a newline");
  3206. X    return;
  3207. X}
  3208. X
  3209. void
  3210. putln(s)
  3211. char *s; {
  3212. X    int i;
  3213. X
  3214. X    if (columns < 2 || auto_right_margin)
  3215. X        fputs(s, stdout);
  3216. X    else {
  3217. X        i = 0;
  3218. X        while(*s) {
  3219. X            putchar(*s);
  3220. X            s++;
  3221. X            if (++i == columns) {
  3222. X                nl();
  3223. X                i = 0;
  3224. X            }
  3225. X        }
  3226. X    }
  3227. X    nl();
  3228. X}
  3229. X
  3230. void
  3231. anykey() {
  3232. X    fputs("-- press any key --", stdout);
  3233. X    fflush(stdout);
  3234. X    getchar();
  3235. X    nl();
  3236. X}
  3237. X
  3238. void
  3239. do_cleanup(e)
  3240. int e; {
  3241. X    fflush(stdout);
  3242. X    fflush(stderr);
  3243. X    reset_shell_mode();
  3244. X    fprintf(stderr, "\n");
  3245. X}
  3246. X
  3247. X#ifdef USE_SGTTY
  3248. struct sgttyb new_tty;
  3249. X#else
  3250. struct termio new_tty;
  3251. X#endif
  3252. X
  3253. int
  3254. main(argc, argv)
  3255. int argc;
  3256. char **argv; {
  3257. X    int r;
  3258. X    register int i;
  3259. X
  3260. X    prg_name = argv[0];
  3261. X    cleanup = do_cleanup;
  3262. X
  3263. X    if (argc == 1)
  3264. X        setupterm(NULL, 1, (int *) 0);
  3265. X    else if (argc == 2)
  3266. X        setupterm(argv[1], 1, (int *) 0);
  3267. X    else {
  3268. X        fprintf(stderr, "usage: %s [terminal]\n", argv[0]);
  3269. X        return 1;
  3270. X    }
  3271. X    fflush(stderr);
  3272. X    fflush(stdout);
  3273. X#ifdef USE_SGTTY
  3274. X    ioctl(1, TIOCGETP, &new_tty);
  3275. X    new_tty.sg_flags &= ~(CRMOD | ECHO | XTABS);
  3276. X#ifdef CBREAK
  3277. X    new_tty.sg_flags |= CBREAK;
  3278. X#else
  3279. X    new_tty.sg_flags |= RAW;
  3280. X#endif
  3281. X    ioctl(1, TIOCSETP, &new_tty);
  3282. X#endif
  3283. X#ifdef USE_TERMIO
  3284. X    ioctl(1, TCGETA, &new_tty);
  3285. X    new_tty.c_lflag &= ~(ICANON | ECHO);
  3286. X    new_tty.c_oflag &= ~(OPOST);
  3287. X    new_tty.c_cc[VMIN] = 1;
  3288. X    new_tty.c_cc[VTIME] = 1;
  3289. X    ioctl(1, TCSETA, &new_tty);
  3290. X#endif
  3291. X    def_prog_mode();
  3292. X    
  3293. X    clear();
  3294. X    printf("columns = %d", columns);
  3295. X    nl();
  3296. X    printf("lines = %d", lines);
  3297. X    if (columns < 2)
  3298. X        quit(-1, "columns must be > 1");
  3299. X    nl();
  3300. X    anykey();
  3301. X    nl();
  3302. X    if (auto_right_margin) {
  3303. X        putln("auto_right_margin = TRUE");
  3304. X        nl();
  3305. X        for(i = 0; i < columns; i++)
  3306. X            putchar('1');
  3307. X        for(i = 0; i < columns / 2; i++)
  3308. X            putchar('2');
  3309. X        nl();
  3310. X    } else {
  3311. X        putln("auto_right_margin = FALSE");
  3312. X        nl();
  3313. X        for(i = 0; i < columns + columns / 2; i++)
  3314. X            putchar('1');
  3315. X        nl();
  3316. X        for(i = 0; i < columns / 2; i++)
  3317. X            putchar('2');
  3318. X        nl();
  3319. X    }
  3320. X    nl();
  3321. X    putln("***a line of 1's followed by a line of 2's");
  3322. X    nl();
  3323. X    anykey();
  3324. X    nl();
  3325. X
  3326. X    if (over_strike) {
  3327. X        putln("over_strike = TRUE");
  3328. X        if (cursor_left != NULL) {
  3329. X            for(i = 0; i < columns / 4 + 1; i++) {
  3330. X                putchar('/');
  3331. X                putp(cursor_left);
  3332. X                putchar('\\');
  3333. X            }
  3334. X        } else if (carriage_return != NULL) {
  3335. X            for(i = 0; i < columns / 4 + 1; i++) 
  3336. X                putchar('/');
  3337. X            putp(carriage_return);
  3338. X            for(i = 0; i < columns / 4 + 1; i++) 
  3339. X                putchar('\\');
  3340. X        }
  3341. X        nl();
  3342. X        nl();
  3343. X        putln("*** X's made from \\'s overstriking /'s");
  3344. X        nl();
  3345. X        anykey();
  3346. X        nl();
  3347. X    }
  3348. X
  3349. X    if (cup(0,0) == 0) {
  3350. X        clear();
  3351. X        putln("cup test");
  3352. X        for(i = 1; i < columns; i++)
  3353. X            putp(tparm(cursor_address, 0, i));
  3354. X        for(i = 0; i < lines; i++)
  3355. X            putp(tparm(cursor_address, i, columns - 1));
  3356. X        for(i = columns; i--;)
  3357. X            putp(tparm(cursor_address, lines - 1, i));
  3358. X        for(i = lines; i--;)
  3359. X            putp(tparm(cursor_address, i, 0));
  3360. X        nl();
  3361. X        anykey();
  3362. X    }
  3363. X    clear();
  3364. X
  3365. X    putln("Attribute test");
  3366. X    nl();
  3367. X    if (enter_blink_mode != NULL) {
  3368. X        putp(enter_blink_mode);
  3369. X        printf("blink");
  3370. X        putp(exit_attribute_mode);
  3371. X        nl();
  3372. X    }
  3373. X    if (enter_bold_mode != NULL) {
  3374. X        putp(enter_bold_mode);
  3375. X        printf("bold");
  3376. X        putp(exit_attribute_mode);
  3377. X        nl();
  3378. X    }
  3379. X    if (enter_dim_mode != NULL) {
  3380. X        putp(enter_dim_mode);
  3381. X        printf("dim");
  3382. X        putp(exit_attribute_mode);
  3383. X        nl();
  3384. X    }
  3385. X    if (enter_reverse_mode != NULL) {
  3386. X        putp(enter_reverse_mode);
  3387. X        printf("reverse");
  3388. X        putp(exit_attribute_mode);
  3389. X        nl();
  3390. X    }
  3391. X    if (enter_standout_mode != NULL) {
  3392. X        putp(enter_standout_mode);
  3393. X        printf("standout");
  3394. X        putp(exit_standout_mode);
  3395. X        nl();
  3396. X    }
  3397. X    if (enter_underline_mode != NULL) {
  3398. X        putp(enter_underline_mode);
  3399. X        printf("underline");
  3400. X        putp(exit_underline_mode);
  3401. X        nl();
  3402. X    }
  3403. X    nl();
  3404. X    anykey();
  3405. X
  3406. X    clear();
  3407. X    reset_shell_mode();
  3408. X    
  3409. X    return (0);
  3410. X}
  3411. END_OF_FILE
  3412. if test 5057 -ne `wc -c <'ttest.c'`; then
  3413.     echo shar: \"'ttest.c'\" unpacked with wrong size!
  3414. fi
  3415. # end of 'ttest.c'
  3416. fi
  3417. if test -f 'tty.c' -a "${1}" != "-c" ; then 
  3418.   echo shar: Will not clobber existing file \"'tty.c'\"
  3419. else
  3420. echo shar: Extracting \"'tty.c'\" \(7701 characters\)
  3421. sed "s/^X//" >'tty.c' <<'END_OF_FILE'
  3422. X/*
  3423. X * tty.c
  3424. X *
  3425. X * By Ross Ridge
  3426. X * Public Domain
  3427. X * 92/02/01 07:30:49
  3428. X *
  3429. X * Do some tty related things
  3430. X *
  3431. X */
  3432. X
  3433. X#include "defs.h"
  3434. X#include "term.h"
  3435. X
  3436. X#ifdef USE_SCCS_IDS
  3437. static const char SCCSid[] = "@(#) mytinfo tty.c 3.2 92/02/01 public domain, By Ross Ridge";
  3438. X#endif
  3439. X#ifndef EXTA_IS
  3440. X#define EXTA_IS 19200
  3441. X#endif
  3442. X
  3443. X#ifndef EXTB_IS
  3444. X#define EXTB_IS 38400
  3445. X#endif
  3446. X
  3447. X#ifdef lint
  3448. X#define ioctl _ioctl
  3449. X/* shutup lint */
  3450. X/* ARGSUSED */
  3451. X/* VARARGS1 */
  3452. static int ioctl(a, b, p) int a; long b; anyptr *p;  { return 0; }
  3453. X#endif
  3454. X
  3455. X#ifdef USE_TERMIO
  3456. X
  3457. X#ifdef USE_SMALLMEM
  3458. unsigned short _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
  3459. X                  1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
  3460. X#else
  3461. long _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
  3462. X            2400, 4800, 9600, EXTA_IS, EXTB_IS};
  3463. X#endif
  3464. X
  3465. static struct termio old;
  3466. X
  3467. int
  3468. X_lit_output() {
  3469. X    struct termio tmp;
  3470. X    if (ioctl(cur_term->fd, TCGETA, &old) == -1)
  3471. X        return 0;
  3472. X    if (!(old.c_oflag & OPOST) || !(old.c_oflag & ONLCR)) 
  3473. X        return 0;
  3474. X    memcpy((anyptr)&tmp, (anyptr)&old, sizeof(old));
  3475. X    tmp.c_oflag &= ~OPOST;
  3476. X    ioctl(cur_term->fd, TCSETA, &tmp);
  3477. X    return 1;
  3478. X}
  3479. X
  3480. void
  3481. X_norm_output() {
  3482. X    ioctl(cur_term->fd, TCSETA, &old);
  3483. X}
  3484. X    
  3485. int
  3486. X_check_tty() {
  3487. X    if ((cur_term->prog_mode.c_iflag & IXON) && cur_term->xon)
  3488. X        cur_term->pad = 0;
  3489. X    else
  3490. X        cur_term->pad = 1;
  3491. X    cur_term->baudrate = _baud_tbl[cur_term->prog_mode.c_cflag & CBAUD];
  3492. X    return OK;
  3493. X}
  3494. X
  3495. int
  3496. def_prog_mode() {
  3497. X#ifdef USE_WINSZ
  3498. X#ifdef TIOCGWINSZ
  3499. X    if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->prog_winsz) < 0)
  3500. X        return ERR;
  3501. X#endif
  3502. X#endif
  3503. X    if (ioctl(cur_term->fd, TCGETA, &cur_term->prog_mode) == 0
  3504. X            && _check_tty() == OK)
  3505. X        return OK;
  3506. X    return ERR;
  3507. X}
  3508. X
  3509. int
  3510. def_shell_mode() {
  3511. X    cur_term->termcap = 0;
  3512. X#ifdef USE_WINSZ
  3513. X#ifdef TIOCGWINSZ
  3514. X    if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->shell_winsz) < 0)
  3515. X        return ERR;
  3516. X#endif
  3517. X#endif
  3518. X    return ioctl(cur_term->fd, TCGETA, &cur_term->shell_mode)==0 ? OK : ERR;
  3519. X}
  3520. X
  3521. int
  3522. reset_prog_mode() {
  3523. X    return ioctl(cur_term->fd, TCSETA, &cur_term->prog_mode)==0 ? OK : ERR;
  3524. X}
  3525. X
  3526. int
  3527. reset_shell_mode() {
  3528. X    return ioctl(cur_term->fd, TCSETA, &cur_term->shell_mode)==0 ? OK : ERR;
  3529. X}
  3530. X
  3531. int
  3532. X_init_tty() {
  3533. X    cur_term->true_lines = lines;
  3534. X    cur_term->true_columns = columns;
  3535. X    if (pad_char == NULL)
  3536. X        cur_term->padch = '\000';
  3537. X    else
  3538. X        cur_term->padch = pad_char[0];
  3539. X    if (def_shell_mode() == ERR || def_prog_mode() == ERR) {
  3540. X        cur_term->pad = 0;
  3541. X        cur_term->baudrate = 1;
  3542. X        cur_term->xon = 0;
  3543. X        return OK;
  3544. X    }
  3545. X    cur_term->xon = (xoff_character == NULL || xoff_character[0] == '\021')
  3546. X            && (xon_character == NULL || xon_character[0] == '\023')
  3547. X            && xon_xoff;
  3548. X#ifdef USE_WINSZ
  3549. X#ifdef TIOCGWINSZ
  3550. X    if (cur_term->prog_winsz.ws_row != 0
  3551. X        && cur_term->prog_winsz.ws_col != 0) {
  3552. X        lines = cur_term->prog_winsz.ws_row;
  3553. X        columns = cur_term->prog_winsz.ws_col;
  3554. X    }
  3555. X#endif
  3556. X#endif
  3557. X    return OK;
  3558. X}
  3559. X
  3560. X#else
  3561. X
  3562. X#ifdef USE_SGTTY
  3563. X
  3564. X#ifdef USE_SMALLMEM
  3565. unsigned short _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
  3566. X                  1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
  3567. X#else
  3568. long _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
  3569. X            1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
  3570. X#endif
  3571. X
  3572. X
  3573. X#ifdef TIOCLGET
  3574. X
  3575. static int old;
  3576. X
  3577. int
  3578. X_lit_output() {
  3579. X    struct sgttyb buf;
  3580. X    int tmp;
  3581. X
  3582. X    ioctl(cur_term->fd, TIOCGETP, &buf);
  3583. X    if (buf.sg_flags & RAW)
  3584. X        return 0;
  3585. X    ioctl(cur_term->fd, TIOCLGET, &old);
  3586. X    if (old & LLITOUT)
  3587. X        return 0;
  3588. X    tmp = old | LLITOUT;
  3589. X    ioctl(cur_term->fd, TIOCLSET, &tmp);
  3590. X    return 1;
  3591. X}
  3592. X
  3593. void
  3594. X_norm_output() {
  3595. X    ioctl(cur_term->fd, TIOCLSET, &old);
  3596. X}
  3597. X
  3598. X#else
  3599. X
  3600. static struct sgttyb old;
  3601. X
  3602. int
  3603. X_lit_output() {
  3604. X    struct sgttyb tmp;
  3605. X    ioctl(cur_term->fd, TIOCGETP, &old);
  3606. X    if (old.sg_flags & RAW)
  3607. X        return 0;
  3608. X    memcpy((anyptr)&tmp, (anyptr)&old, sizeof(old));
  3609. X    tmp.sg_flags |= RAW;
  3610. X    ioctl(cur_term->fd, TIOCSETP, &tmp);
  3611. X    return 1;
  3612. X}
  3613. X
  3614. void
  3615. X_norm_output() {
  3616. X    ioctl(cur_term->fd, TIOCSETP, &old);
  3617. X}
  3618. X
  3619. X#endif 
  3620. X
  3621. int
  3622. X_check_tty() {
  3623. X    if (!(cur_term->prog_mode.v6.sg_flags & RAW) && cur_term->xon)
  3624. X        cur_term->pad = 0;
  3625. X    else
  3626. X        cur_term->pad = 1;
  3627. X    cur_term->baudrate = _baud_tbl[cur_term->prog_mode.v6.sg_ospeed & 0xf];
  3628. X    return OK;
  3629. X}
  3630. X
  3631. int
  3632. def_shell_mode() {
  3633. X    if (ioctl(cur_term->fd, TIOCGETP, &cur_term->shell_mode.v6) < 0)
  3634. X        return ERR;
  3635. X#ifdef TIOCGETC
  3636. X    if (ioctl(cur_term->fd, TIOCGETC, &cur_term->shell_mode.v7) < 0)
  3637. X        return ERR;
  3638. X#endif
  3639. X#ifdef TIOCLGET
  3640. X    if (ioctl(cur_term->fd, TIOCLGET, &cur_term->shell_mode.bsd) < 0)
  3641. X        return ERR;
  3642. X#endif
  3643. X#ifdef TIOCGLTC
  3644. X    if (ioctl(cur_term->fd, TIOCGLTC, &cur_term->shell_mode.bsd_new) < 0)
  3645. X        return ERR;
  3646. X#endif
  3647. X#ifdef USE_WINSZ
  3648. X#ifdef TIOCGWINSZ
  3649. X    if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->shell_winsz)<0)
  3650. X        return ERR;
  3651. X#endif
  3652. X#endif
  3653. X    cur_term->termcap = 0;
  3654. X    return OK;
  3655. X}
  3656. X
  3657. int
  3658. def_prog_mode() {
  3659. X    if (ioctl(cur_term->fd, TIOCGETP, &cur_term->prog_mode.v6) < 0)
  3660. X        return ERR;
  3661. X#ifdef TIOCGETC
  3662. X    if (ioctl(cur_term->fd, TIOCGETC, &cur_term->prog_mode.v7) < 0)
  3663. X        return ERR;
  3664. X#endif
  3665. X#ifdef TIOCLGET
  3666. X    if (ioctl(cur_term->fd, TIOCLGET, &cur_term->prog_mode.bsd) < 0)
  3667. X        return ERR;
  3668. X#endif
  3669. X#ifdef TIOCGLTC
  3670. X    if (ioctl(cur_term->fd, TIOCGLTC, &cur_term->prog_mode.bsd_new) < 0)
  3671. X        return ERR;
  3672. X#endif
  3673. X#ifdef USE_WINSZ
  3674. X#ifdef TIOCGWINSZ
  3675. X    if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->prog_winsz)<0)
  3676. X        return ERR;
  3677. X#endif
  3678. X#endif
  3679. X    return _check_tty();
  3680. X}
  3681. X
  3682. int
  3683. reset_shell_mode() {
  3684. X    if (ioctl(cur_term->fd, TIOCSETP, &cur_term->shell_mode.v6) < 0)
  3685. X        return ERR;
  3686. X#ifdef TIOCGETC
  3687. X    if (ioctl(cur_term->fd, TIOCSETC, &cur_term->shell_mode.v7) < 0)
  3688. X        return ERR;
  3689. X#endif
  3690. X#ifdef TIOCLGET
  3691. X    if (ioctl(cur_term->fd, TIOCLSET, &cur_term->shell_mode.bsd) < 0)
  3692. X        return ERR;
  3693. X#endif
  3694. X#ifdef TIOCGLTC
  3695. X    if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->shell_mode.bsd_new) < 0)
  3696. X        return ERR;
  3697. X#endif
  3698. X    return OK;
  3699. X}
  3700. X
  3701. int
  3702. reset_prog_mode() {
  3703. X    if (ioctl(cur_term->fd, TIOCSETP, &cur_term->prog_mode.v6) < 0)
  3704. X        return ERR;
  3705. X#ifdef TIOCGETC
  3706. X    if (ioctl(cur_term->fd, TIOCSETC, &cur_term->prog_mode.v7) < 0)
  3707. X        return ERR;
  3708. X#endif
  3709. X#ifdef TIOCLGET
  3710. X    if (ioctl(cur_term->fd, TIOCLSET, &cur_term->prog_mode.bsd) < 0)
  3711. X        return ERR;
  3712. X#endif
  3713. X#ifdef TIOCGLTC
  3714. X    if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->prog_mode.bsd_new) < 0)
  3715. X        return ERR;
  3716. X#endif
  3717. X    return OK;
  3718. X}
  3719. X
  3720. int
  3721. X_init_tty() {
  3722. X    cur_term->true_lines = lines;
  3723. X    cur_term->true_columns = columns;
  3724. X    if (pad_char == NULL)
  3725. X        cur_term->padch = '\000';
  3726. X    else
  3727. X        cur_term->padch = pad_char[0];
  3728. X    if (def_shell_mode() == ERR || def_prog_mode() == ERR) {
  3729. X        cur_term->pad = 0;
  3730. X        cur_term->baudrate = 1;
  3731. X        cur_term->xon = 0;
  3732. X        return OK;
  3733. X    }
  3734. X#ifndef TIOCGETC
  3735. X    cur_term->xon = (xoff_character == NULL || xoff_character[0] == '\021')
  3736. X            && (xon_character == NULL || xon_character[0] == '\023')
  3737. X                && xon_xoff;
  3738. X#else
  3739. X    if (xon_xoff) {
  3740. X        if (xon_character != NULL) {
  3741. X            cur_term->prog_mode.v7.t_startc = xon_character[0];
  3742. X            if (ioctl(cur_term->fd, TIOCSETC,
  3743. X                &cur_term->prog_mode.v7) < 0)
  3744. X                return ERR;
  3745. X        }
  3746. X        if (xoff_character != NULL) {
  3747. X            cur_term->prog_mode.v7.t_stopc = xoff_character[0];
  3748. X            if (ioctl(cur_term->fd, TIOCSETC,
  3749. X                      &cur_term->prog_mode.v7) < 0)
  3750. X                return ERR;
  3751. X        }
  3752. X    }
  3753. X    cur_term->xon = xon_xoff;
  3754. X#endif
  3755. X#ifdef USE_WINSZ
  3756. X#ifdef TIOCGWINSZ
  3757. X    if (cur_term->prog_winsz.ws_row != 0
  3758. X        && cur_term->prog_winsz.ws_col != 0) {
  3759. X        lines = cur_term->prog_winsz.ws_row;
  3760. X        columns = cur_term->prog_winsz.ws_col;
  3761. X    }
  3762. X#endif
  3763. X#endif
  3764. X    return OK;
  3765. X}
  3766. X
  3767. X#else
  3768. X
  3769. int
  3770. X_lit_output() {
  3771. X    return 0;
  3772. X}
  3773. X
  3774. void
  3775. X_norm_output() {
  3776. X    return;
  3777. X}
  3778. X
  3779. int
  3780. X_check_tty() {
  3781. X    return OK;
  3782. X}
  3783. X
  3784. int
  3785. def_prog_mode() {
  3786. X    return OK;
  3787. X}
  3788. X
  3789. int
  3790. reset_prog_mode() {
  3791. X    return OK;
  3792. X}
  3793. X
  3794. int
  3795. def_shell_mode() {
  3796. X    return OK;
  3797. X}
  3798. X
  3799. int
  3800. reset_shell_mode() {
  3801. X    return OK;
  3802. X}
  3803. X
  3804. int
  3805. X_init_tty() {
  3806. X    cur_term->pad = 1;
  3807. X    cur_term->padch = 0;
  3808. X    cur_term->baudrate = 1200;
  3809. X    cur_term->xon = 0;
  3810. X    cur_term->termcap = 0;
  3811. X    cur_term->true_lines = lines;
  3812. X    cur_term->true_columns = columns;
  3813. X}
  3814. X
  3815. X#endif
  3816. X
  3817. X#endif
  3818. END_OF_FILE
  3819. if test 7701 -ne `wc -c <'tty.c'`; then
  3820.     echo shar: \"'tty.c'\" unpacked with wrong size!
  3821. fi
  3822. # end of 'tty.c'
  3823. fi
  3824. echo shar: End of archive 2 \(of 3\).
  3825. cp /dev/null ark2isdone
  3826. MISSING=""
  3827. for I in 1 2 3 ; do
  3828.     if test ! -f ark${I}isdone ; then
  3829.     MISSING="${MISSING} ${I}"
  3830.     fi
  3831. done
  3832. if test "${MISSING}" = "" ; then
  3833.     echo You have unpacked all 3 archives.
  3834.     rm -f ark[1-9]isdone
  3835. else
  3836.     echo You still need to unpack the following archives:
  3837.     echo "        " ${MISSING}
  3838. fi
  3839. ##  End of shell archive.
  3840. exit 0
  3841.