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

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