summaryrefslogtreecommitdiffstats
path: root/lib/libmytinfo
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-10-06 23:38:41 +0000
committerache <ache@FreeBSD.org>1994-10-06 23:38:41 +0000
commitb32637dd9bf4e7ee14b7c850eff0ebc0fe42076a (patch)
tree42730d0413bbd6de0453b7861f6e510473226e61 /lib/libmytinfo
downloadFreeBSD-src-b32637dd9bf4e7ee14b7c850eff0ebc0fe42076a.zip
FreeBSD-src-b32637dd9bf4e7ee14b7c850eff0ebc0fe42076a.tar.gz
Moved from ports + several enhacmenets
Diffstat (limited to 'lib/libmytinfo')
-rw-r--r--lib/libmytinfo/EXAMPLES/terminfo.src104
-rw-r--r--lib/libmytinfo/INSTALL211
-rw-r--r--lib/libmytinfo/Makefile75
-rw-r--r--lib/libmytinfo/README75
-rw-r--r--lib/libmytinfo/README.doc125
-rw-r--r--lib/libmytinfo/addstr.c88
-rw-r--r--lib/libmytinfo/bin_order48
-rw-r--r--lib/libmytinfo/bsearch.c97
-rw-r--r--lib/libmytinfo/buildpath.c203
-rw-r--r--lib/libmytinfo/cap_list529
-rw-r--r--lib/libmytinfo/caps.c173
-rw-r--r--lib/libmytinfo/compar.c40
-rw-r--r--lib/libmytinfo/config.h89
-rw-r--r--lib/libmytinfo/defs.h198
-rw-r--r--lib/libmytinfo/fillterm.c81
-rw-r--r--lib/libmytinfo/findcap.c149
-rw-r--r--lib/libmytinfo/findterm.c286
-rw-r--r--lib/libmytinfo/getother.c49
-rw-r--r--lib/libmytinfo/gettbin.c127
-rw-r--r--lib/libmytinfo/gettcap.c273
-rw-r--r--lib/libmytinfo/gettinfo.c303
-rw-r--r--lib/libmytinfo/mkbinorder.c116
-rw-r--r--lib/libmytinfo/mkcaplist.c166
-rw-r--r--lib/libmytinfo/mkcapsort.c134
-rw-r--r--lib/libmytinfo/mktermhead.c160
-rw-r--r--lib/libmytinfo/mkversion.c35
-rw-r--r--lib/libmytinfo/quit.c72
-rw-r--r--lib/libmytinfo/readcaps.c151
-rw-r--r--lib/libmytinfo/tcapconv.c194
-rw-r--r--lib/libmytinfo/tcapvars.c36
-rw-r--r--lib/libmytinfo/tconv.1180
-rw-r--r--lib/libmytinfo/tconv.c1384
-rw-r--r--lib/libmytinfo/term.tail131
-rw-r--r--lib/libmytinfo/termcap.c165
-rw-r--r--lib/libmytinfo/terminfo.c132
-rw-r--r--lib/libmytinfo/tgoto.c148
-rw-r--r--lib/libmytinfo/tiget.c51
-rw-r--r--lib/libmytinfo/tmatch.c37
-rw-r--r--lib/libmytinfo/tparm.c806
-rw-r--r--lib/libmytinfo/tputs.c266
-rw-r--r--lib/libmytinfo/tty.c446
-rw-r--r--lib/libmytinfo/version.h10
42 files changed, 8143 insertions, 0 deletions
diff --git a/lib/libmytinfo/EXAMPLES/terminfo.src b/lib/libmytinfo/EXAMPLES/terminfo.src
new file mode 100644
index 0000000..0fed13e
--- /dev/null
+++ b/lib/libmytinfo/EXAMPLES/terminfo.src
@@ -0,0 +1,104 @@
+#
+# terminfo.src
+#
+# By Ross Ridge
+# Public Domain
+# 92/02/01 07:30:32
+#
+# Some sample terminfo definitions
+#
+# @(#) mytinfo terminfo.src 3.2 92/02/01 public domain, By Ross Ridge
+#
+#
+dumb|dumb terminal, gn, co#80,
+#
+# Note not all ANSI terminals will support all of these capabilities.
+# This doesn't define any real terminal, and probably wouldn't work
+# with any real terminal either.
+#
+ansi-all|ANS X3.64-1979 terminal,
+ cr=^M, cud1=^J, ind=^J, nel=^M^J, bell=^G, cub1=^H,
+ cuu1=\EM, ff=^L, ht=^I,
+ .ind=\ED, .nel=\EE, hts=\EH, hd=\EK, hu=\EL, ri=\EM,
+ .ich1=\E[@, .ich=\E[%p1%d@, .cuu1=\E[A, cuu=\E[%p1%dA,
+ cud1=\E[B, .cud=\E[%p1%dB, cuf1=\E[C, cuf=\E[%p1%dC,
+ .cub1=\E[D, cub=\E[%p1%dD, .cnl=\E[%p1%dE, .cpl=\E[%p1%dF,
+ .hpa=\E[%i%p1%dG, cup=\E[%i%p1%d;%p2%dH, .cht=\E[%p1%dI,
+ ed=\E[J, el=\E[K, el1=\E[1K, il1=\E[L, il=\E[%p1%dL,
+ dl1=\E[M, dl=\E[%p1%dM, .ef=\E[N, .ea=\E[O,
+ dch1=\E[P, dch=\E[%p1%dP, .sem=\E[%p1%dQ,
+ .cpr=\E[%i%p1%d;%p2%dR, indn=\E[%p1%dS, .ind=\E[S,
+ rin=\E[%p1%dT, .ri=\E[T, .np=\E[%p1%dU, .pp=\E[%p1%dU,
+ .ctc=\E[%p1%dW, ech=\E[%p1%dX, .cvt=\E[%p1%dY,
+ cbt=\E[Z, hpa=\E[%i%p1%d`, .hpr=\E[%p1%da,
+ rep=%p1%c%?%p2%{1}%>%t\E[%p2%{1}%-%db%;,
+ .da=\E[c, vpa=\E[%i%p1%dd, .vpr=\E[%p1%e,
+ .hvp=\E[%i%p1%d;%p2%df, tbc=\E[3g,
+ mc=\E[0i, mc4=\E[4i, mc5=\E[5i,
+ sgr=\E[%?%p6%t;1%;%?%p5%p1%|%t;2%;%?%p2%t;4%;%?%p4%t;6%;%?%p3%p1%|%t;7%;%?%p7%t;8%;m,
+ smso=\E[1;7m, rmso=\E[m, smul=\E[4m, rmul=\E[m,
+ blink=\E[6m, bold=\E[1m, invis=\E[8m, rev=\E[7m,
+ sgr0=\E[m, .dsr=\E[%p1%dn, .daq=\E[%p1%do,
+ .sl=\E[%p1%d\s@, .sr=\E[%p1%d\sA, clear=\E[H\EJ, home=\E[H,
+ smir=\E[4h, rmir=\E[4l,
+ is2=\E[1Q\E[1;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\E[6;12h\E[m,
+ rs2=\Ec\E[1Q\E[1;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\E[6;12h\E[m\E[H\EJ,
+ansi-all-8|ANS X3.64-1979 terminal (8 bit),
+ cr=^M, cud1=^J, ind=^J, nel=^M^J, bell=^G, cub1=^H,
+ cuu1=\215, ff=^L, ht=^I,
+ .ind=\204, .nel=\205, hts=\207, hd=\213, hu=\214, ri=\215,
+ .ich1=\233@, .ich=\E%p1%d@, .cuu1=\233A, cuu=\233%p1%dA,
+ cud1=\233B, .cud=\233%p1%dB, cuf1=\233C, cuf=\233%p1%dC,
+ .cub1=\233D, cub=\233%p1%dD, .cnl=\233%p1%dE, .cpl=\233%p1%dF,
+ .hpa=\233%i%p1%dG, cup=\233%i%p1%d;%p2%dH, .cht=\233%p1%dI,
+ ed=\233J, el=\233K, el1=\2331K, il1=\233L, il=\233%p1%dL,
+ dl1=\233M, dl=\233%p1%dM, .ef=\233N, .ea=\233O,
+ dch1=\233P, dch=\233%p1%dP, .sem=\233%p1%dQ,
+ .cpr=\233%i%p1%d;%p2%dR, indn=\233%p1%dS, .ind=\233S,
+ rin=\233%p1%dT, .ri=\233T, .np=\233%p1%dU, .pp=\233%p1%dU,
+ .ctc=\233%p1%dW, ech=\233%p1%dX, .cvt=\233%p1%dY,
+ cbt=\233Z, hpa=\233%i%p1%d`, .hpr=\233%p1%da,
+ rep=%p1%c%?%p2%{1}%>%t\233%p2%{1}%-%db%;,
+ .da=\233c, vpa=\233%i%p1%dd, .vpr=\233%p1%e,
+ .hvp=\233%i%p1%d;%p2%df, tbc=\2333g,
+ mc=\2330i, mc4=\2334i, mc5=\2334i,
+ sgr=\233%?%p6%t;1%;%?%p5%p1%|%t;2%;%?%p2%t;4%;%?%p4%t;6%;%?%p3%p1%|%t;7%;%?%p7%t;8%;m,
+ smso=\2331;7m, rmso=\233m, smul=\2334m, rmul=\233m,
+ blink=\2336m, bold=\2331m, invis=\2338m, rev=\2337m,
+ sgr0=\233m, .dsr=\233%p1%dn, .daq=\233%p1%do,
+ .sl=\233%p1%d\s@, .sr=\233%p1%d\sA, clear=\233H\EJ, home=\233H,
+ smir=\2334h, rmir=\2334l,
+ is2=\2331Q\2331;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\2336;12h\233m,
+ rs2=\Ec\2331Q\2331;2;3;4;5;7;10;11;13;14;16;15;17;18;19;20l\2336;12h\233m\233H\EJ,
+#
+# Not tested...
+#
+vt100|dec vt100,
+ xon, UWxc, msgr,
+ cols#80, lines#24, it#8, vt#3,
+ cr=\r, csr=^[[%i%p1%d;%p2%dr, tbc=^[[3g, clear=^[[;H^[[2J$<100>,
+ el=^[[K$<3>, ed=^[[J$<50>, cup=^[[%i%p1%d;%p2%dH$<5>, cud1=^[[B,
+ home=^[[H, cub1=^[[D, cuf1=^[[C$<2>, cuu1=^[[A$<2>, blink=^[[5m$<2>,
+ bold=^[[1m$<2>, rev=^[[7m$<2>, smso=^[[7m$<2>, smul=^[[4m$<2>,
+ sgr0=^[[m^N$<2>, rmso=^[[m$<2>, rmul=^[[m$<2>, hts=^[H, ht=^I,
+ is2=^[[1;24r^[[?1l^[[?3l^[[30h^[[?7h^[>, bell=^G,
+ kbs=\b, kcud1=^[[B, kf0=^[OP, kf1=^[OQ, kf2=^[OR, kf3=^[OS,
+ kcub1=^[[D, kcuf1=^[[C, kcuu1=^[[A, lf0=PF1, lf1=PF2,
+ lf2=PF3, lf3=PF4, nel=\r^[D, cud=^[[%p1%dB, cub=^[[%p1%dD,
+ cuf=^[[%p1%dC, cuu=^[[%p1%dA, rc=^[8, sc=^[7, ind=^[D, ri=^[M$<5>,
+ sgr=^[[0;%?%p4%t;5%;%?%p6%t;1%;%?%p3%p1%|%t;7%;%?%p2%t;4%;m%?%p1%t^N%e^O%;$<2>,
+ smacs=^O, rmacs=^N,
+vt100-am|vt100 with automatic margins,
+ am, xenl, @el, @ed,
+ use=vt100,
+vt102|dec vt102,
+ is=\E<\E[1;24r\E[?1l\E[?3l\E[?5l\E[?7h\E>,
+ il=\E[%p1%dL, dch=\E[%p1%dP, dl=\E[%p1%dM,
+ il1=\E[L, dch1=\E[P, dl1=\E[M,
+ mir, rmir=\E[4l, smir=\E[4h,
+ use=vt100,
+vt200|vt220|vt200-js|vt220-js|dec vt200 series with jump scroll,
+ clear=\E[H\E[J, rmso=\E[27m, rmul=\E[24m,
+ is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H,
+ rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
+ use=vt102,
diff --git a/lib/libmytinfo/INSTALL b/lib/libmytinfo/INSTALL
new file mode 100644
index 0000000..3a0276d
--- /dev/null
+++ b/lib/libmytinfo/INSTALL
@@ -0,0 +1,211 @@
+Compiling this package requires a fair bit of knowledge about your system.
+There are no automatic configuration programmes or prepared configuration
+files for different type of systems. You will need to edit the Makefile
+to specify things like which compiler to use and any options it needs.
+The file config.h needs to be edited to reflect the system you are
+using and to enable and/or disable certain features.
+
+Defines in config.h
+===================
+
+USE_ANSIC
+
+Normally this will be defined automaticly if __STDC__ is defined, but
+if your compile isn't truly ANSI C compliant you may need to undefine this.
+
+USE_TERMIO
+
+Define this if your system uses the termio tty driver. System III and
+System V use termio.
+
+USE_SGTTY
+
+Define this if your system uses the "sgtty" tty driver. V7 Unix and BSD
+use sgtty.
+
+USE_WINSZ
+
+If you defined USE_SGTTY you can define this if your system supports
+SIGWINSZ and the accompaning ioctls. If this is defined the library
+will get number of columns and lines from the tty driver not the
+terminal description. BSD 4.3 supports SIGWINSZ. This will also work
+if USE_TERMIO is defined on some hybrid System V machines such as Release 4.
+
+Do not define both USE_TERMIO and USE_SGTTY. If your system supports both
+you'd probably be better of defining USE_TERMIO. If your system supports
+neither termio or sgtty you can leave USE_TERMIO and USE_SGTTY undefined,
+but this is only recommended for use with micomputers.
+
+USE_STRINGS
+
+If you define this then the header file <strings.h> will be included
+and BSD type string library assumed (index instead of strchr), otherwise
+<string.h> will included. If you have a BSD type system define this.
+If you have an ANSI C, System III, or System V type of system leave it
+undefined.
+
+USE_MYBSEARCH
+
+If your system's C library doesn't include bsearch, define this.
+Most System V systems have bsearch. However even your C library has this
+function you still may want to define USE_MYBSEARCH, see USE_SHORT_BSEARCH
+below. ("MYBSEARCH" is misnomer, I didn't write this routine.)
+
+USE_SHORT_BSEARCH
+
+If you define USE_MYBSEARCH you can define this so that the bsearch
+routine that library uses the type short instead of size_t (usually long)
+for it's arguments. This results a large speedup on 68000 based machines
+and possibly a significant speedup on others as well. However on some CPU's
+defining this will only make things slower.
+
+USE_MYSTRTOK
+
+If your system's C library doesn't include strtok, define this.
+Most ANSI C, System III, and System V systems have this.
+
+USE_MYQSORT
+
+If your system's C library doesn't include qsort, define this.
+All most all systems should have this function, if it doesn't complain
+to your vendor. The qsort routine comes from the GNU Emacs distribution.
+
+USE_MYMKDIR
+
+Define this if your system doesn't have the mkdir library function call.
+My routine simply calls the system command mkdir, you may have to
+edit mkdir.c if the pathname of that command isn't "/bin/mkdir".
+
+USE_MEMORY
+
+If your system has a <memory.h> header define this. If USE_MEMORY
+is not defined bcopy will used instead of memcpy.
+
+USE_SMALLMEM
+
+Use you can define use this to save some memory, but it doesn't
+save much at moment, and will only slow the library down.
+
+USE_FAKE_STDIO
+
+If you define this then the library won't use the real stdio but a
+fake one instead. This is for compatiblity with termcap and vi which
+don't use stdio.
+
+USE_DOPRNT
+
+If you don't have a vfprintf function, but you have a _doprnt function
+define this. If you don't have either than you can compile the library
+but not the support programmes. System V has vfprintf and most Unixes
+have a _doprnt (but probably not documented). BSD has released a freely
+distributable vfprintf for BSD Unixes.
+
+USE_UPBC_KLUDGE
+
+Define this if you want the library's tgoto to work like termcap's tgoto
+and avoid putting ^D, and \n into an output string by using the cursor up
+and backspace strings.
+
+USE_EXTERN_UPBC
+
+If you defined USE_UPBC_KLUDGE you can define this so tgoto will,
+like termcap's tgoto, get the cursor up and backspace strings from the
+externs UP and BC instead from the library's internal record.
+
+USE_LITOUT_KLUDGE
+
+Don't define this. It's another kludge for tgoto.
+
+If neither USE_UPBC_KLUDGE or USE_LITOUT_KLUDGE is defined then tgoto
+won't worry about putting ^D, and \n in a string.
+
+USE_PROTOTYPES
+
+Define this if your compiler supports ANSI C style prototypes.
+
+USE_STDLIB
+
+Define this if your system has an <stdlib.h> header.
+
+USE_STDARG
+
+Define this if your system has an <stdarg.h> header. If this isn't
+defined <varargs.h> will be included instead.
+
+USE_STDDEF
+
+Define this if your system has an <stddef.h> header. If this isn't
+defined <sys/types.h> will be included instead.
+
+typedef char *anyptr;
+
+You should change the typedef to a type that any pointer can be assigned
+to or from. ANSI C compilers can use "typedef void *anyptr", most
+other compilers should use "typedef char *anyptr".
+
+#define mysize_t unsigned
+
+"mysize_t" needs to defined as the type of the size of an object, or
+the type of the sizeof operator. Traditional usage is "unsigned", for
+ANSI C you should define mysize_t as "size_t".
+
+TERMCAPFILE
+
+Define this to a string containing the default termcap file(s) to look
+for terminal descriptions in. Multiple filenames should be seperated
+by spaces and environment variables can be specfied by prefixing them
+with dolar signs ($). eg:
+ #define TERMCAPFILE "$TERMCAPFILE $HOME/.termcap /etc/termcap"
+
+TERMINFOSRC
+
+Define this to a string containing the default terminfo source file to
+look for terminal descriptions in.
+
+TERMINFODIR
+
+Define this as the directory containing the default terminfo database,
+usually "/usr/lib/terminfo".
+
+Any of TERMCAPFILE, TERMINFOSRC or TERMINFODIR can be left undefined.
+
+
+defs.h
+======
+
+You may also need to edit defs.h and change the definitions of MAX_BUF,
+MAX_LINE, and MAX_NAME. Unless you are seriously starved for memory I
+don't recomend making them smaller.
+
+
+cap_list
+========
+
+You can add new capabilities to the file cap_list. You must provide
+a type, terminfo variable name, terminfo capname, and termcap name for
+all capabilities and you must make sure they are all unique.
+
+
+Making in the library
+=====================
+
+Once you've configured the package you can just type "make" and it
+will build the library and the "term.h" header. You can enter
+"make all" to make the library and the support programmes, tconv,
+cap2info, tic, clear, tput and tset. If you want a profiled library
+you can enter "make profiled". You can remove all the intermediate
+files with "make clean". "make spotless" will remove the target
+files as well.
+
+
+Installing the library
+======================
+
+As for installing it, that's up to you. Depending on how much you
+plan to use the libraries and whether or not you have termcap and/or
+terminfo already you can install them "standard" places (ie. /usr/lib,
+/usr/include, /usr/bin), in local directories, or just leave them in
+the source directory. However if you are compiling programmes that
+use terminfo and linking it with this library you must make sure that
+this library's term.h file is included in your programme and not the
+system supplied one.
diff --git a/lib/libmytinfo/Makefile b/lib/libmytinfo/Makefile
new file mode 100644
index 0000000..cbcbee3
--- /dev/null
+++ b/lib/libmytinfo/Makefile
@@ -0,0 +1,75 @@
+LIB= mytinfo
+BINDIR= /usr/bin
+SRCS= addstr.c binorder.c buildpath.c caplist.c capsort.c compar.c\
+ fillterm.c findcap.c findterm.c getother.c gettbin.c\
+ gettcap.c gettinfo.c tcapconv.c tcapvars.c termcap.c\
+ terminfo.c tgoto.c tiget.c tmatch.c tparm.c tputs.c tty.c version.c
+MAN1= tconv.1
+MLINKS= tconv.1 tic.1 tconv.1 captoinfo.1
+CLEANFILES+= binorder.c caplist.c capsort.c mkbinorder mkcaplist \
+ mkcapsort mktermhead mkversion readcaps.o term.h* \
+ version.c quit.o tconv clear.t* *.test caps tput \
+ tset ttest
+
+CFLAGS+=-Wall
+
+CAPS= 1000
+
+all: $${_LIBS} tconv caps
+
+beforeinstall: term.h
+ -cmp -s term.h ${DESTDIR}/usr/include/term.h > \
+ /dev/null 2>&1 || \
+ $(INSTALL) $(COPY) -o ${BINOWN} -g ${BINGRP} -m 444 term.h \
+ ${DESTDIR}/usr/include
+
+afterinstall:
+ $(INSTALL) $(COPY) $(STRIP) -o $(BINOWN) -g $(BINGRP) -m $(BINMODE) \
+ tconv caps ${DESTDIR}${BINDIR}
+ rm -f ${DESTDIR}${BINDIR}/tic
+ ln ${DESTDIR}${BINDIR}/tconv ${DESTDIR}${BINDIR}/tic
+ rm -f ${DESTDIR}${BINDIR}/captoinfo
+ ln ${DESTDIR}${BINDIR}/tconv ${DESTDIR}${BINDIR}/captoinfo
+
+capsort.c: mkcapsort
+ ./mkcapsort > capsort.c
+
+mkcapsort: mkcapsort.c caplist.o compar.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o mkcapsort ${.CURDIR}/mkcapsort.c caplist.o compar.o
+
+binorder.c: mkbinorder ${.CURDIR}/bin_order
+ ./mkbinorder ${.CURDIR}/bin_order > binorder.c
+
+mkbinorder: mkbinorder.c capsort.o caplist.o compar.o findcap.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o mkbinorder ${.CURDIR}/mkbinorder.c capsort.o \
+ caplist.o compar.o findcap.o
+
+version.c: mkversion
+ ./mkversion > version.c
+
+mkversion: mkversion.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o mkversion ${.CURDIR}/mkversion.c
+
+term.h: term.head ${.CURDIR}/term.tail
+ cat term.head ${.CURDIR}/term.tail > term.h
+
+term.head: mktermhead ${.CURDIR}/cap_list
+ ./mktermhead -n $(CAPS) ${.CURDIR}/cap_list > term.head
+
+caplist.c: mkcaplist ${.CURDIR}/cap_list
+ ./mkcaplist -n $(CAPS) ${.CURDIR}/cap_list > caplist.c
+
+mktermhead: mktermhead.c readcaps.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o mktermhead ${.CURDIR}/mktermhead.c readcaps.o
+
+mkcaplist: mkcaplist.c readcaps.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o mkcaplist ${.CURDIR}/mkcaplist.c readcaps.o
+
+tconv: tconv.c quit.o version.o $${_LIBS}
+ $(CC) ${CFLAGS} $(LDFLAGS) -L. -o tconv ${.CURDIR}/tconv.c quit.o version.o -l$(LIB)
+
+caps: caps.c quit.o version.o $${_LIBS}
+ $(CC) $(CFLAGS) -o caps $(LDFLAGS) -L. ${.CURDIR}/caps.c quit.o version.o -l$(LIB)
+
+.include <bsd.lib.mk>
+
diff --git a/lib/libmytinfo/README b/lib/libmytinfo/README
new file mode 100644
index 0000000..ea65c94
--- /dev/null
+++ b/lib/libmytinfo/README
@@ -0,0 +1,75 @@
+Mytinfo is Public Domain and comes with no guarantees.
+By Ross Ridge (ross@zooid.guild.org).
+
+Mytinfo is a single library that combines the functionality of the
+standard Unix termcap and terminfo libraries. It has the special
+ability of being able to fetch terminal descriptions from both
+termcap and terminfo databases regardless of which set of functions,
+termcap or terminfo, are used. It can even read terminal descriptions
+from terminfo source files.
+
+You should be able to compile this library on almost all versions of Unix.
+Much of it's development was done on '386 Xenix, but I've sucessfuly built
+mytinfo under BSD 4.3, HP-UX 2.1 (System III), SunOS 3.5, and Amix
+(System V R4). There hasn't been a large amount of testing of the support
+programmes that come with the library, but the library itself has been in
+use on a couple of public access Unix sites for over two years. It has
+successfully linked and run with many programmes such as rn, vi and nethack.
+
+Included in the package is tconv, an "all-in-one" programme that will
+compile terminfo sources to binary format and also translate termcap to
+either terminfo source or binary. tic and cap2info are just links
+to the tconv programme. I've also written replacement for tset,
+that uses the mytinfo library, in case tset doesn't come with your
+system or if you aren't too pleased with the one that did. Since this
+is the newest part of the package it probably still has a few bugs.
+You'll also find tput, as well two versions of clear, one that uses
+termcap and the other that uses terminfo.
+
+The environment variables TERMCAP and TERMINFO can have multiple
+filenames separated by a space, a feature not in terminfo and not in
+most termcaps. This is very handy for users that maintain their own
+private databases, as they don't have to have a copy the entire
+database. Eg:
+ TERMCAP="$HOME/.termcap /etc/termcap"
+ TERMINFO="$HOME/terminfo /usr/lib/terminfo"
+ export TERMCAP TERMINFO
+The library will also check compiled-in default locations for terminal
+descriptions. Like most termcaps, the TERMCAP variable can also
+contain the complete termcap terminal description, usually supplied
+from tset at login. The TERMINFO variable can also contain a complete
+terminfo description, but there is no programme like tset to supply it.
+
+Unlike termcap, this library can only use capabilities that it knows about.
+However it does knows about all the standard ones, and you can easily
+add your own to it's list. Included in the list are all terminfo
+capabilities to Release 4 of System V, obsolete termcap capabilities, a
+few caps used from the University of Waterloo (UW), a couple from GNU Emacs,
+and a few I made up myself. Two extensions to the standard termcap % codes
+are supported, GNU's %a, %m, %b, and %f, and UW's %-, %a, and %s.
+
+Termcap and terminfo source descriptions can be mixed in one file, but
+because of this termcap databases must be in a certain style. All
+continuation lines of a termcap entry must be indented from the left
+margin by white space. This shouldn't be a problem with most sites
+since this is the style that most termcap files are distributed, but local
+additions may not adhere to this style. Another possible problem is
+that termcap entries should end with a colon (:), but in most
+distributed termcaps there are entries that don't. If a one line
+termcap entry doesn't end with a colon, it will be ignored. A quick
+way to find these is "tconv -c /etc/termcap > /dev/null".
+
+See the file INSTALL for instructions on configuring and installing
+this library. The file README.doc lists the functions supported by the
+library, and gives short description of the tconv programme. tconv.1 is
+a simple man page for tconv. terminfo.src contains a few sample
+terminal descriptions in terminfo source format. TODO is a list of
+possible enhancements too the library, your comments and additions
+are welcome.
+
+Please let me know of any bugs you find, as well as any ideas you have
+for improvement.
+
+Ross Ridge
+
+ross@zooid.guild.org
diff --git a/lib/libmytinfo/README.doc b/lib/libmytinfo/README.doc
new file mode 100644
index 0000000..04e1409
--- /dev/null
+++ b/lib/libmytinfo/README.doc
@@ -0,0 +1,125 @@
+----------------------------------------------------------------------------
+tconv [-b] [-c [-OUGd]] [-i] [-B [-D dir]] [-I] [-k] [-t term] [file]
+tic [file]
+cap2info [-t term] [-OUGdk] [file]
+
+-c convert from termcap
+-i convert from terminfo source
+-b convert from terminfo binary
+-B convert to terminfo binary
+-I convert to terminfo source
+
+The following switches are available when converting from termcap:
+-d don't supply any defaults for missing capabilities
+-O include obsolete termcap capabilities
+-G include GNU capabilities
+-U include UW capabilities
+
+-k keep comments
+-D dir directory to put terminfo binaries in
+
+-t term name of terminal to translate
+file filename of termcap/terminfo database to use
+
+If a file is specifed and no terminal is given the entire file we be translated.
+If no terminal and no file is specified then the terminal name will be taken
+from the environment varible TERM. Unless compiling to a terminfo binary,
+output is to stdout.
+----------------------------------------------------------------------------
+
+char *tparm(char *str, ...); /* up to nine parameters */
+char *tgoto(char *str, int column, int row);
+
+tparm and tgoto support the following termcap and terminfo % codes:
+
+Terminfo % Codes
+
+ %% output a '%'
+ %[[:][-+# ][width][.precision]][doxXs]
+ output pop according to the printf format
+ %c output pop as a char
+ %'c' push character constant c.
+ %{n} push decimal constant n.
+ %p[1-9] push paramter [1-9]
+ %g[a-z] push variable [a-z]
+ %P[a-z] put pop in variable [a-z]
+ %l push the length of pop (a string)
+ %+ add pop to pop and push the result
+ %- subtract pop from pop and push the result
+ %* multiply pop and pop and push the result
+ %& bitwise and pop and pop and push the result
+ %| bitwise or pop and pop and push the result
+ %^ bitwise xor pop and pop and push the result
+ %~ push the bitwise not of pop
+ %= compare if pop and pop are equal and push the result
+ %> compare if pop is less than pop and push the result
+ %< compare if pop is greater than pop and push the result
+ %A logical and pop and pop and push the result
+ %O logical or pop and pop and push the result
+ %! push the logical not of pop
+ %? condition %t if_true [%e if_false] %;
+ if condtion evaulates as true then evaluate if_true,
+ else evaluate if_false. elseif's can be done:
+%? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %;
+ %i add one to parameters 1 and 2. (ANSI)
+
+Termcap Codes
+
+ %% output a %
+ %. output parameter as a character
+ %d output parameter as a decimal number
+ %2 output parameter in printf format %02d
+ %3 output parameter in printf format %03d
+ %+x add the character x to parameter and output it as a character
+(UW) %-x subtract parameter FROM the character x and output it as a char
+(UW) %ax add the character x to parameter
+(GNU) %a[+*-/=][cp]x
+ GNU arithmetic.
+(UW) %sx subtract parameter FROM the character x
+ %>xy if parameter > character x then add character y to parameter
+ %B convert to BCD (parameter = (parameter/10)*16 + parameter%16)
+ %D Delta Data encode (parameter = parameter - 2*(paramter%16))
+ %i increment the first two parameters by one
+ %n xor the first two parameters by 0140
+(GNU) %m xor the first two parameters by 0177
+ %r swap the first two parameters
+(GNU) %b backup to previous parameter
+(GNU) %f skip this parameter
+
+(GNU) used by GNU Emacs termcap libraries
+(UW) used by the University of Waterloo (MFCF) termcap libraries
+
+Note the two definitions of %a, the GNU defintion is used if the characters
+after the 'a' are valid for it, otherwise the UW definition is used.
+----------------------------------------------------------------------------
+
+int setupterm(char *term; int fd; int *err);
+int set_curterm(TERMINAL *new);
+int del_curterm(TERMINAL *old);
+char *tparm(char *str, ...); /* see above */
+int tputs(char *str, int count, int (*putc)());
+int putp(str);
+int tigetflag(char *cap);
+int tigetnum(char *cap);
+char *tigetstr(char *cap);
+int def_prog_mode();
+int def_shell_mode();
+int reset_prog_mode();
+int reset_shell_mode();
+char *boolnames[], *boolcodes[], *boolfnames[];
+char *numnames[], *numcodes[], *numfnames[];
+char *strnames[], *strcodes[], *strfnames[];
+
+These functions work just like the terminfo functions. Note restartterm(),
+vidputs(), vidattr(), and mvcur() are not available.
+----------------------------------------------------------------------------
+
+int tgetent(char *buf, char *term);
+int tgetflag(char *cap);
+int tgetnum(char *cap);
+char *tgetstr(char *cap, char **area);
+char *tgoto(char *cap, int column, int row);
+int tputs(char *str, int count, int (*putc)());
+
+These functions work just like termcap functions.
+----------------------------------------------------------------------------
diff --git a/lib/libmytinfo/addstr.c b/lib/libmytinfo/addstr.c
new file mode 100644
index 0000000..50fb411
--- /dev/null
+++ b/lib/libmytinfo/addstr.c
@@ -0,0 +1,88 @@
+/*
+ * addstr.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:34:01
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#include <ctype.h>
+
+#ifdef USE_SCCS_IDS
+static char const SCCSid[] = "@(#) mytinfo addstr.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+/*
+ * I think this routine could be improved, as it is now it searches a
+ * linked list of strbufs for one that has enough room left for the
+ * string. The only thing else I can think of doing would be to
+ * expand a buffer by realloc and then fix the string pointers if it
+ * moves.
+ */
+
+static struct strbuf *strbuf = NULL;
+
+struct strbuf *
+_endstr() {
+ register struct strbuf *p;
+
+ p = strbuf;
+ strbuf = NULL;
+ return p;
+}
+
+char *
+_addstr(s)
+register char *s; {
+ register struct strbuf *p;
+ register int l;
+
+ if (s == NULL) {
+ strbuf = NULL;
+ return NULL;
+ }
+
+ if (strbuf == NULL) {
+ strbuf = (struct strbuf *) malloc(sizeof(struct strbuf));
+ if (strbuf == NULL)
+ return NULL;
+ strbuf->len = 0;
+ strbuf->next = NULL;
+ }
+ l = strlen(s) + 1;
+ if (l > MAX_CHUNK)
+ return NULL;
+ p = strbuf;
+ while (l + p->len > MAX_CHUNK) {
+ if (p->next == NULL) {
+ p->next = (struct strbuf *)
+ malloc(sizeof(struct strbuf));
+ p = p->next;
+ if (p == NULL)
+ return NULL;
+ p->len = 0;
+ p->next = NULL;
+ break;
+ }
+ p = p->next;
+ }
+ s = strcpy(p->buf + p->len, s);
+ p->len += l;
+ return s;
+}
+
+void
+_del_strs(p)
+TERMINAL *p; {
+ struct strbuf *q;
+
+ q = p->strbuf;
+ while(q != NULL) {
+ p->strbuf = q->next;
+ free((anyptr) q);
+ q = p->strbuf;
+ }
+}
diff --git a/lib/libmytinfo/bin_order b/lib/libmytinfo/bin_order
new file mode 100644
index 0000000..e00d342
--- /dev/null
+++ b/lib/libmytinfo/bin_order
@@ -0,0 +1,48 @@
+ bin_order
+
+ By Ross Ridge
+ Public Domain
+ 92/02/01 07:29:39
+
+ Order of entries in a terminfo binary
+
+ @(#) mytinfo bin_order 3.2 92/02/01 public domain, By Ross Ridge
+
+
+!
+bw am xsb xhp xenl eo gn hc km hs in da db mir msgr os eslok xt hz ul
+xon nxon mc5i chts nrrmc npc ndscr ccc bce hls xhpa crxm daisy xvpa sam
+cpix lpix
+
+#
+cols it lines lm xmc pb vt wsl nlab lh lw ma wnum colors pairs ncv bufsz
+spinv spinh maddr mjump mcs mls npins orc orl orhi orvi cps widcs btns
+bitwin bitype
+
+$
+cbt bel cr csr tbc clear el ed hpa cmdch cup cud1 home civis cub1 mrcup cnorm
+cuf1 ll cuu1 cvvis dch1 dl1 dsl hd smacs blink bold smcup smdc dim smir invis
+prot rev smso smul ech rmacs sgr0 rmcup rmdc rmir rmso rmul flash ff fsl is1
+is2 is3 if ich1 il1 ip kbs ktbc kclr kctab kdch1 kdl1 kcud1 krmir kel ked
+kf0 kf1 kf10 kf2 kf3 kf4 kf5 kf6 kf7 kf8 kf9 khome kich1 kil1 kcub1 kll
+knp kpp kcuf1 kind kri khts kcuu1 rmkx smkx lf0 lf1 lf10 lf2 lf3 lf4 lf5
+lf6 lf7 lf8 lf9 rmm smm nel pad dch dl cud ich indn il cub cuf rin cuu pfkey
+pfloc pfx mc0 mc4 mc5 rep rs1 rs2 rs3 rf rc vpa sc ind ri sgr hts wind ht
+tsl uc hu iprog ka1 ka3 kb2 kc1 kc3 mc5p rmp acsc pln kcbt smxon rmxon
+smam rmam xonc xoffc enacs smln rmln kbeg kcan kclo kcmd kcpy kcrt kend
+kent kext kfnd khlp kmrk kmsg kmov knxt kopn kopt kprv kprt krdo kref
+krfr krpl krst kres ksav kspd kund kBEG kCAN kCMD kCPY kCRT kDC kDL kslt
+kEND kEOL kEXT kFND kHLP kHOM kIC kLFT kMSG kMOV kNXT kOPT kPRV kPRT kRDO
+kRPL kRIT kRES kSAV kSPD kUND rfi kf11 kf12 kf13 kf14 kf15 kf16 kf17 kf18
+kf19 kf20 kf21 kf22 kf23 kf24 kf25 kf26 kf27 kf28 kf29 kf30 kf31 kf32
+kf33 kf34 kf35 kf36 kf37 kf38 kf39 kf40 kf41 kf42 kf43 kf44 kf45 kf46 kf47
+kf48 kf49 kf50 kf51 kf52 kf53 kf54 kf55 kf56 kf57 kf58 kf59 kf60 kf61 kf62
+kf63 el1 mgc smgl smgr fln sclk dclk rmclk cwin wingo hup dial qdial tone
+pulse hook pause wait u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 op oc initc initp scp
+setf setb cpi lpi chr cvr defc swidm sdrfq sitm slm smicm snlq snrmq sshm
+ssubm ssupm sum rwidm ritm rlm rmicm rshm rsubm rsupm rum mhpa mcud1 mcub1
+mcuf1 mvpa mcuu1 porder mcud mcub mcuf mcuu scs smgb smgbp smglp smgrp smgt
+smgtp sbim scsd rbim rcsd subcs supcs docr zerom csnm kmous minfo reqmp
+getm setaf setab pfxl devt csin s0ds s1ds s2ds s3ds smglr smgtb birep binel
+bicr colornm defbi endbi setcolor slines dispc smpch rmpch smsc rmsc pctrm
+scesc scesa
diff --git a/lib/libmytinfo/bsearch.c b/lib/libmytinfo/bsearch.c
new file mode 100644
index 0000000..34fc0fd
--- /dev/null
+++ b/lib/libmytinfo/bsearch.c
@@ -0,0 +1,97 @@
+/*
+ * bsearch.c
+ *
+ * This is something I found on watmath. I've made some minor changes for use
+ * in this package.
+ *
+ * 92/06/04 11:35:15
+ */
+
+#if 0
+#ifndef lint
+static char *RCSid = "$OHeader: /usr/mfcf/src/accounts/libuw/RCS/bsearch.c,v 1.1 88/06/11 20:41:48 root Exp $";
+#endif
+#endif
+
+#include "defs.h"
+
+#ifdef USE_MYBSEARCH
+
+#ifdef USE_SCCS_IDS
+static char const SCCSid[] = "@(#) mytinfo bsearch.c 3.4 92/06/04 public domain, By Ross Ridge";
+#endif
+
+#ifdef USE_SHORT_BSEARCH
+#define fast_int short
+#else
+#define fast_int mysize_t
+#endif
+
+/*
+ * bsearch - find an element of a sorted vector
+ *
+ * found = bsearch(key, array, dimension, width, compare)
+ * returns a pointer to the specified element in the array,
+ * or (char*)0 if the element can't be found.
+ * key
+ * pointer to the element to be searched for in the array
+ * array
+ * address of an array of elements
+ * dimension
+ * number of elements in the array
+ * width
+ * sizeof(type) of each element
+ * compare
+ * pointer to a function taking (char *) pointers to two elements
+ * and returning <0, 0, or >0 as the first element comes before,
+ * at, or after the second element. A compare function is provided
+ * for comparing strings.
+*/
+#if 0
+/*
+ * $OLog: bsearch.c,v $
+ * Revision 1.1 88/06/11 20:41:48 root
+ * Initial revision
+ *
+*/
+#endif
+
+ static anyptr
+bsearch(key, array, dimension, iwidth, compare)
+ anyptr key;
+ anyptr array;
+ int dimension;
+ mysize_t iwidth;
+ compar_fn compare;
+{
+ register fast_int start; /* offset to start of current interval */
+ register fast_int end; /* offset to end+1 of current interval */
+ register fast_int middle; /* offset to middle of current interval */
+ auto int status;
+ register fast_int width;
+
+ width = iwidth / sizeof(char);
+
+ start = 0;
+ middle = 0;
+ end = dimension;
+
+ while (start < end) {
+
+ middle = (start + end) / 2;
+
+ status = (*compare)(key, ((char *)array + middle*width));
+
+ if (status < 0)
+ end = middle;
+
+ else if (status > 0)
+ start = middle + 1;
+
+ else return (anyptr)(((char *)array) + middle*width);
+ }
+
+ return 0;
+}
+
+#endif /* USE_MYBSEARCH */
diff --git a/lib/libmytinfo/buildpath.c b/lib/libmytinfo/buildpath.c
new file mode 100644
index 0000000..b901ea6
--- /dev/null
+++ b/lib/libmytinfo/buildpath.c
@@ -0,0 +1,203 @@
+/*
+ * buildpath.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:42
+ *
+ * _buildpath builds a list of file names and terminal descriprions extracted
+ * from its arguments. It returns a pointer to a structure that is used by
+ * other routines as the list of file names to search for terminal
+ * descriptions. It is passed a variable number of arguments consisting
+ * of file name and type pairs. The file name can actually be a list of
+ * file names seperated by spaces and any environment variables specified
+ * by a dollar sign ($) followed by its name are substituted in. A type
+ * of 1 indicates that the file name may actually be termcap description
+ * and a type of 2 indicates it may be a terminfo description. A type of 0
+ * indicates that the file name can only be a file name (or list of them).
+ *
+ */
+
+#include "defs.h"
+
+#include <ctype.h>
+
+#ifndef __FreeBSD__
+#include "strtok.c"
+#endif
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo buildpath.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+/* more memory is allocated for file names every HUNK file names */
+#define HUNK 32
+
+/* characters that seperate file names in a list */
+#define SEPERATORS " :"
+
+static struct term_path *path = NULL; /* the list of files */
+static int files = 0; /* # of files in the list */
+static int size = 0; /* # of files there is space for */
+
+/* add a file name, type pair to the list */
+static int
+addfile(file, type)
+char *file;
+int type; {
+ int l;
+ char *s;
+
+ if (file == NULL) {
+ if (type != -1)
+ return -1;
+ } else if (file[0] == '\0')
+ return -1;
+
+#ifdef DEBUG
+ if (file != NULL)
+ printf("addfile: %s\n", file);
+#endif
+
+ if (files >= size) {
+ size += HUNK;
+ if (path == NULL)
+ path = (struct term_path *)
+ malloc(size * sizeof(struct term_path));
+ else
+ path = (struct term_path *)
+ realloc((anyptr) path,
+ size * sizeof(struct term_path));
+ if (path == NULL)
+ return 0;
+ }
+ if (file == NULL) {
+ path[files].file = file;
+ } else {
+ l = strlen(file) + 1;
+ s = (char *) malloc(l * sizeof(char));
+ if (s == NULL)
+ return 0;
+ path[files].file = strcpy(s, file);
+ }
+ path[files].type = type;
+
+ return ++files;
+}
+
+/* deallocate space used by the path list */
+void
+_delpath(ppath)
+struct term_path *ppath; {
+ struct term_path *p;
+
+ p = ppath;
+ while(p->file != NULL) {
+ free((anyptr)p->file);
+ p++;
+ }
+
+ free((anyptr)ppath);
+}
+
+/* build a list of paths. see above */
+#ifdef lint
+/*VARARGS2*/
+struct term_path *
+_buildpath(file, type)
+char *file;
+int type;
+#else
+#ifdef USE_STDARG
+#ifdef USE_PROTOTYPES
+struct term_path *_buildpath(char *file, int type, ...)
+#else
+struct term_path *_buildpath(file, type)
+char *file;
+int type;
+#endif /* USE_PROTOTYPES */
+#else /* USE_STDARG */
+struct term_path *_buildpath(va_alist)
+va_dcl
+#endif /* USE_STDARG */
+#endif /* lint */
+{
+#ifndef lint
+#ifndef USE_STDARG
+ char *file;
+ int type;
+#endif
+#endif
+ va_list ap;
+ register char *s, *d, *e;
+ char line[MAX_BUF+1];
+ char name[MAX_NAME+1];
+ int i,j;
+
+ size = 0;
+ files = 0;
+ path = NULL;
+
+#ifdef lint
+ ap = NULL;
+#else
+#ifdef USE_STDARG
+ va_start(ap, type);
+#else
+ va_start(ap);
+ file = va_arg(ap, char *);
+ type = va_arg(ap, int);
+#endif
+#endif
+
+ while (type >= 0 && type <= 2) {
+ s = file;
+ d = line;
+ i = 0;
+ while(*s != '\0') {
+ if (*s == '$') {
+ s++;
+ j = 0;
+ while(*s != '\0' && (*s == '_' || isalnum(*s)))
+ if (j < MAX_NAME) {
+ name[j] = *s++;
+ j++;
+ } else
+ break;
+ name[j] = '\0';
+ e = getenv(name);
+ if (e != NULL) {
+ while(*e != '\0') {
+ if (i < MAX_BUF) {
+ *d++ = *e++;
+ i++;
+ } else
+ break;
+ }
+ } else if (*s == '/')
+ s++;
+ } else {
+ if (i < MAX_BUF) {
+ *d++ = *s++;
+ i++;
+ } else
+ break;
+ }
+ }
+ *d = '\0';
+ if (type == 0 || line[0] == '/') {
+ s = strtok(line, SEPERATORS);
+ while(s != NULL) {
+ if (addfile(s, 0) == 0)
+ return NULL;
+ s = strtok(NULL, SEPERATORS);
+ }
+ } else
+ if (addfile(line, type) == 0)
+ return NULL;
+ file = va_arg(ap, char *);
+ type = va_arg(ap, int);
+ }
+ addfile(NULL, -1);
+ return path;
+}
diff --git a/lib/libmytinfo/cap_list b/lib/libmytinfo/cap_list
new file mode 100644
index 0000000..6432790
--- /dev/null
+++ b/lib/libmytinfo/cap_list
@@ -0,0 +1,529 @@
+ cap_list
+
+ By Ross Ridge
+ Public Domain
+ 92/02/01 07:29:44
+
+ @(#) mytinfo cap_list 3.2 92/02/01 public domain, By Ross Ridge
+
+types: ! = boolean, # = number, $ = string, $G = string with parameters,
+ $K = string that never is outputed (with tputs).
+
+type variable capname termcap
+
+Standard terminfo capabilities:
+
+! auto_left_margin bw bw
+! auto_right_margin am am
+! ceol_standout_glitch xhp xs
+! dest_tabs_magic_smso xt xt
+! eat_newline_glitch xenl xn
+! erase_overstrike eo eo
+! generic_type gn gn
+! hard_copy hc hc
+! hard_cursor chts HC
+! has_meta_key km km
+! has_status_line hs hs
+! insert_null_glitch in in
+! memory_above da da
+! memory_below db db
+! move_insert_mode mir mi
+! move_standout_mode msgr ms
+! needs_xon_xoff nxon nx
+! no_esc_ctlc xsb xb
+! no_pad_char npc NP
+! non_rev_rmcup nrrmc NR
+! over_strike os os
+! prtr_silent mc5i 5i
+! status_line_esc_ok eslok es
+! tilde_glitch hz hz
+! transparent_underline ul ul
+! xon_xoff xon xo
+# columns cols co
+# init_tabs it it
+# label_height lh lh
+# label_width lw lw
+# lines lines li
+# lines_of_memory lm lm
+# magic_cookie_glitch xmc sg
+# num_labels nlab Nl
+# padding_baud_rate pb pb
+# virtual_terminal vt vt
+# width_status_line wsl ws
+$K acs_chars acsc ac
+$ back_tab cbt bt
+$ bell bel bl
+$ carriage_return cr cr
+$G change_scroll_region csr cs
+$ char_padding rmp rP
+$ clear_all_tabs tbc ct
+$ clear_margins mgc MC
+$ clear_screen clear cl
+$ clr_bol el1 cb
+$ clr_eol el ce
+$ clr_eos ed cd
+$G column_address hpa ch
+$K command_character cmdch CC
+$G cursor_address cup cm
+$ cursor_down cud1 do
+$ cursor_home home ho
+$ cursor_invisible civis vi
+$ cursor_left cub1 le
+$G cursor_mem_address mrcup CM
+$ cursor_normal cnorm ve
+$ cursor_right cuf1 nd
+$ cursor_to_ll ll ll
+$ cursor_up cuu1 up
+$ cursor_visible cvvis vs
+$ delete_character dch1 dc
+$ delete_line dl1 dl
+$ dis_status_line dsl ds
+$ down_half_line hd hd
+$ ena_acs enacs eA
+$ enter_alt_charset_mode smacs as
+$ enter_am_mode smam SA
+$ enter_blink_mode blink mb
+$ enter_bold_mode bold md
+$ enter_ca_mode smcup ti
+$ enter_delete_mode smdc dm
+$ enter_dim_mode dim mh
+$ enter_insert_mode smir im
+$ enter_protected_mode prot mp
+$ enter_reverse_mode rev mr
+$ enter_secure_mode invis mk
+$ enter_standout_mode smso so
+$ enter_underline_mode smul us
+$ enter_xon_mode smxon SX
+$G erase_chars ech ec
+$ exit_alt_charset_mode rmacs ae
+$ exit_am_mode rmam RA
+$ exit_attribute_mode sgr0 me
+$ exit_ca_mode rmcup te
+$ exit_delete_mode rmdc ed
+$ exit_insert_mode rmir ei
+$ exit_standout_mode rmso se
+$ exit_underline_mode rmul ue
+$ exit_xon_mode rmxon RX
+$ flash_screen flash vb
+$ form_feed ff ff
+$ from_status_line fsl fs
+$ init_1string is1 i1
+$ init_2string is2 is
+$ init_3string is3 i3
+$K init_file if if
+$K init_prog iprog iP
+$ insert_character ich1 ic
+$ insert_line il1 al
+$ insert_padding ip ip
+$K key_a1 ka1 K1
+$K key_a3 ka3 K3
+$K key_b2 kb2 K2
+$K key_backspace kbs kb
+$K key_beg kbeg @1
+$K key_btab kcbt kB
+$K key_c1 kc1 K4
+$K key_c3 kc3 K5
+$K key_cancel kcan @2
+$K key_catab ktbc ka
+$K key_clear kclr kC
+$K key_close kclo @3
+$K key_command kcmd @4
+$K key_copy kcpy @5
+$K key_create kcrt @6
+$K key_ctab kctab kt
+$K key_dc kdch1 kD
+$K key_dl kdl1 kL
+$K key_down kcud1 kd
+$K key_eic krmir kM
+$K key_end kend @7
+$K key_enter kent @8
+$K key_eol kel kE
+$K key_eos ked kS
+$K key_exit kext @9
+$K key_f0 kf0 k0
+$K key_f1 kf1 k1
+$K key_f10 kf10 k;
+$K key_f11 kf11 F1
+$K key_f12 kf12 F2
+$K key_f13 kf13 F3
+$K key_f14 kf14 F4
+$K key_f15 kf15 F5
+$K key_f16 kf16 F6
+$K key_f17 kf17 F7
+$K key_f18 kf18 F8
+$K key_f19 kf19 F9
+$K key_f2 kf2 k2
+$K key_f20 kf20 FA
+$K key_f21 kf21 FB
+$K key_f22 kf22 FC
+$K key_f23 kf23 FD
+$K key_f24 kf24 FE
+$K key_f25 kf25 FF
+$K key_f26 kf26 FG
+$K key_f27 kf27 FH
+$K key_f28 kf28 FI
+$K key_f29 kf29 FJ
+$K key_f3 kf3 k3
+$K key_f30 kf30 FK
+$K key_f31 kf31 FL
+$K key_f32 kf32 FM
+$K key_f33 kf33 FN
+$K key_f34 kf34 FO
+$K key_f35 kf35 FP
+$K key_f36 kf36 FQ
+$K key_f37 kf37 FR
+$K key_f38 kf38 FS
+$K key_f39 kf39 FT
+$K key_f4 kf4 k4
+$K key_f40 kf40 FU
+$K key_f41 kf41 FV
+$K key_f42 kf42 FW
+$K key_f43 kf43 FX
+$K key_f44 kf44 FY
+$K key_f45 kf45 FZ
+$K key_f46 kf46 Fa
+$K key_f47 kf47 Fb
+$K key_f48 kf48 Fc
+$K key_f49 kf49 Fd
+$K key_f5 kf5 k5
+$K key_f50 kf50 Fe
+$K key_f51 kf51 Ff
+$K key_f52 kf52 Fg
+$K key_f53 kf53 Fh
+$K key_f54 kf54 Fi
+$K key_f55 kf55 Fj
+$K key_f56 kf56 Fk
+$K key_f57 kf57 Fl
+$K key_f58 kf58 Fm
+$K key_f59 kf59 Fn
+$K key_f6 kf6 k6
+$K key_f60 kf60 Fo
+$K key_f61 kf61 Fp
+$K key_f62 kf62 Fq
+$K key_f63 kf63 Fr
+$K key_f7 kf7 k7
+$K key_f8 kf8 k8
+$K key_f9 kf9 k9
+$K key_find kfnd @0
+$K key_help khlp %1
+$K key_home khome kh
+$K key_ic kich1 kI
+$K key_il kil1 kA
+$K key_left kcub1 kl
+$K key_ll kll kH
+$K key_mark kmrk %2
+$K key_message kmsg %3
+$K key_move kmov %4
+$K key_next knxt %5
+$K key_npage knp kN
+$K key_open kopn %6
+$K key_options kopt %7
+$K key_ppage kpp kP
+$K key_previous kprv %8
+$K key_print kprt %9
+$K key_redo krdo %0
+$K key_reference kref &1
+$K key_refresh krfr &2
+$K key_replace krpl &3
+$K key_restart krst &4
+$K key_resume kres &5
+$K key_right kcuf1 kr
+$K key_save ksav &6
+$K key_sbeg kBEG &9
+$K key_scancel kCAN &0
+$K key_scommand kCMD *1
+$K key_scopy kCPY *2
+$K key_screate kCRT *3
+$K key_sdc kDC *4
+$K key_sdl kDL *5
+$K key_select kslt *6
+$K key_send kEND *7
+$K key_seol kEOL *8
+$K key_sexit kEXT *9
+$K key_sf kind kF
+$K key_sfind kFND *0
+$K key_shelp kHLP #1
+$K key_shome kHOM #2
+$K key_sic kIC #3
+$K key_sleft kLFT #4
+$K key_smessage kMSG %a
+$K key_smove kMOV %b
+$K key_snext kNXT %c
+$K key_soptions kOPT %d
+$K key_sprevious kPRV %e
+$K key_sprint kPRT %f
+$K key_sr kri kR
+$K key_sredo kRDO %g
+$K key_sreplace kRPL %h
+$K key_sright kRIT %i
+$K key_srsume kRES %j
+$K key_ssave kSAV !1
+$K key_ssuspend kSPD !2
+$K key_stab khts kT
+$K key_sundo kUND !3
+$K key_suspend kspd &7
+$K key_undo kund &8
+$K key_up kcuu1 ku
+$ keypad_local rmkx ke
+$ keypad_xmit smkx ks
+$K lab_f0 lf0 l0
+$K lab_f1 lf1 l1
+$K lab_f10 lf10 la
+$K lab_f2 lf2 l2
+$K lab_f3 lf3 l3
+$K lab_f4 lf4 l4
+$K lab_f5 lf5 l5
+$K lab_f6 lf6 l6
+$K lab_f7 lf7 l7
+$K lab_f8 lf8 l8
+$K lab_f9 lf9 l9
+$ label_off rmln LF
+$ label_on smln LO
+$ meta_off rmm mo
+$ meta_on smm mm
+$ newline nel nw
+$K pad_char pad pc
+$G parm_dch dch DC
+$G parm_delete_line dl DL
+$G parm_down_cursor cud DO
+$G parm_ich ich IC
+$G parm_index indn SF
+$G parm_insert_line il AL
+$G parm_left_cursor cub LE
+$G parm_right_cursor cuf RI
+$G parm_rindex rin SR
+$G parm_up_cursor cuu UP
+$G pkey_key pfkey pk
+$G pkey_local pfloc pl
+$G pkey_xmit pfx px
+$G plab_norm pln pn
+$ print_screen mc0 ps
+$G prtr_non mc5p pO
+$ prtr_off mc4 pf
+$ prtr_on mc5 po
+$G repeat_char rep rp
+$ req_for_input rfi RF
+$ reset_1string rs1 r1
+$ reset_2string rs2 r2
+$ reset_3string rs3 r3
+$K reset_file rf rf
+$ restore_cursor rc rc
+$G row_address vpa cv
+$ save_cursor sc sc
+$ scroll_forward ind sf
+$ scroll_reverse ri sr
+$G set_attributes sgr sa
+$ set_left_margin smgl ML
+$ set_right_margin smgr MR
+$ set_tab hts st
+$G set_window wind wi
+$ tab ht ta
+$G to_status_line tsl ts
+$ underline_char uc uc
+$ up_half_line hu hu
+$ xoff_character xoffc XF
+$ xon_character xonc XN
+
+Release 3.2 and 4 capabilities (AMIX)
+(some of the string attributes are guesses...)
+
+! back_color_erase bce ut
+! can_change ccc cc
+! col_addr_glitch xhpa YA
+! cpi_changes_res cpix YF
+! cr_cancels_micro_mode crxm YB
+! has_print_wheel daisy YC
+! hue_lightness_saturation hls hl
+! lpi_changes_res lpix YG
+! non_dest_scroll_region ndscr ND
+! row_addr_glitch xvpa YD
+! semi_auto_right_margin sam YE
+# bit_image_entwining bitwin Yo
+# bit_image_type bitype Yp
+# buffer_capacity bufsz Ya
+# buttons btns BT
+# dot_horz_spacing spinh Yc
+# dot_vert_spacing spinv Yb
+# max_attributes ma ma
+# max_colors colors Co
+# max_micro_address maddr Yd
+# max_micro_jump mjump Ye
+# max_pairs pairs pa
+# maximum_windows wnum MW
+# micro_char_size mcs Yf
+# micro_line_size mls Yg
+# no_color_video ncv NC
+# number_of_pins npins Yh
+# output_res_char orc Yi
+# output_res_horz_inch orhi Yk
+# output_res_line orl Yj
+# output_res_vert_inch orvi Yl
+# print_rate cps Ym
+# wide_char_size widcs Yn
+$ alt_scancode_esc scesa S8
+$G bit_image_carriage_return bicr Yv
+$G bit_image_newline binel Zz
+$G bit_image_repeat birep Xy
+$G change_char_pitch cpi ZA
+$G change_line_pitch lpi ZB
+$G change_res_horz chr ZC
+$G change_res_vert cvr ZD
+$G char_set_names csnm Zy
+$ code_set_init csin ci
+$G color_names colornm Yw
+$G create_window cwin CW
+$G define_bit_image_region defbi Yx
+$G define_char defc ZE
+$ device_type devt dv
+$G dial_phone dial DI
+$ display_clock dclk DK
+$ display_pc_char dispc S1
+$ end_bit_image_region endbi Yy
+$ enter_doublewide_mode swidm ZF
+$ enter_draft_quality sdrfq ZG
+$ enter_italics_mode sitm ZH
+$ enter_leftward_mode slm ZI
+$ enter_micro_mode smicm ZJ
+$ enter_near_letter_quality snlq ZK
+$ enter_normal_quality snrmq ZL
+$ enter_pc_charset_mode smpch S2
+$ enter_scancode_mode smsc S4
+$ enter_shadow_mode sshm ZM
+$ enter_subscript_mode ssubm ZN
+$ enter_superscript_mode ssupm ZO
+$ enter_upward_mode sum ZP
+$ exit_doublewide_mode rwidm ZQ
+$ exit_italics_mode ritm ZR
+$ exit_leftward_mode rlm ZS
+$ exit_micro_mode rmicm ZT
+$ exit_pc_charset_mode rmpch S3
+$ exit_scancode_mode rmsc S5
+$ exit_shadow_mode rshm ZU
+$ exit_subscript_mode rsubm ZV
+$ exit_superscript_mode rsupm ZW
+$ exit_upward_mode rum ZX
+$ fixed_pause pause PA
+$ flash_hook hook fh
+$ get_mouse getm Gm
+$G goto_window wingo WG
+$ hangup hup HU
+$G initialize_color initc Ic
+$G initialize_pair initp Ip
+$ key_mouse kmous Km
+$ label_format fln Lf
+$G micro_column_address mhpa ZY
+$ micro_down mcud1 ZZ
+$ micro_left mcub1 Za
+$ micro_right mcuf1 Zb
+$G micro_row_address mvpa Zc
+$ micro_up mcuu1 Zd
+$ mouse_info minfo Mi
+$K order_of_pins porder Ze
+$ orig_colors oc oc
+$ orig_pair op op
+$G parm_down_micro mcud Zf
+$G parm_left_micro mcub Zg
+$G parm_right_micro mcuf Zh
+$G parm_up_micro mcuu Zi
+$ pc_term_options pctrm S6
+$G pkey_plab pfxl xl
+$ pulse pulse PU
+$ quick_dial qdial QD
+$ remove_clock rmclk RC
+$ req_mouse_pos reqmp RQ
+$ scancode_escape scesc S7
+$G select_char_set scs Zj
+$ set0_des_seq s0ds s0
+$ set1_des_seq s1ds s1
+$ set2_des_seq s2ds s2
+$ set3_des_seq s3ds s3
+$G set_a_background setab AB
+$G set_a_foreground setaf AF
+$G set_background setb Sb
+$ set_bottom_margin smgb Zk
+$G set_bottom_margin_parm smgbp Zl
+$G set_clock sclk SC
+$G set_color_band setcolor Yz
+$G set_color_pair scp sp
+$G set_foreground setf Sf
+$G set_left_margin_parm smglp Zm
+$G set_lr_margin smglr ML
+$G set_page_length slines YZ
+$G set_right_margin_parm smgrp Zn
+$G set_tb_margin smgtb MT
+$ set_top_margin smgt Zo
+$G set_top_margin_parm smgtp Zp
+$G start_bit_image sbim Zq
+$G start_char_set_def scsd Zr
+$ stop_bit_image rbim Zs
+$G stop_char_set_def rcsd Zt
+$K subscript_characters subcs Zu
+$K superscript_characters supcs Zv
+$K these_cause_cr docr Zw
+$ tone tone TO
+$ user0 u0 u0
+$ user1 u1 u1
+$ user2 u2 u2
+$ user3 u3 u3
+$ user4 u4 u4
+$ user5 u5 u5
+$ user6 u6 u6
+$ user7 u7 u7
+$ user8 u8 u8
+$ user9 u9 u9
+$ wait_tone wait WA
+$ zero_motion zerom Zx
+
+"Obsolete" termcap capabilities (variable and terminfo names are mine)
+
+$ backspace_if_not_bs OTbc bc
+! backspaces_with_bs OTbs bs
+# backspace_delay OTdB dB
+# carriage_return_delay OTdC dC
+# form_feed_delay OTdF dF
+# new_line_delay OTdN dN
+# horizontal_tab_delay OTdT dT
+# vertical_tab_delay OTdV dV
+! even_parity OTEP EP
+! half_duplex OTHD HD
+# number_of_function_keys OTkn kn
+$K other_non_function_keys OTko ko
+! lower_case_only OTLC LC
+$K arrow_key_map OTma ma
+$ memory_lock_above OTml ml
+$ memory_unlock OTmu mu
+! no_correctly_working_cr OTnc nc
+! linefeed_is_newline OTNL NL
+$ linefeed_if_not_lf OTnl nl
+! crt_without_scrolling OTns ns
+! odd_parity OTOP OP
+! has_hardware_tabs OTpt pt
+! uppercase_only OTUC UC
+! return_does_clr_eol OTxr xr
+! tek_4025_insert_line OTxx xx
+# magic_cookie_glitch_ul OTug ug
+
+Caps used by the University of Waterloo (variable and terminfo names are mine)
+
+$K key_interrupt_char UWki ki
+$K key_kill_char UWkk kk
+$K key_suspend_char UWkz kz
+! initialization_messy UWxc xc
+! index_at_bottom_does_cr UWxl xl
+
+! rind_only_at_top OTxq xq
+
+Different names for existing terminfo caps used by GNU Emacs:
+! GNU_has_meta_key GNUMT MT
+# GNU_tab_width GNUtw tw
+
+Non standard capabilities:
+
+$ scroll_left sl1 Sl
+$ scroll_right sr1 Sr
+$G parm_scroll_left sl SL
+$G parm_scroll_right sr SR
+
+Dummy (must be present and last):
+
+$K _get_other use tc
diff --git a/lib/libmytinfo/caps.c b/lib/libmytinfo/caps.c
new file mode 100644
index 0000000..9d4f00f
--- /dev/null
+++ b/lib/libmytinfo/caps.c
@@ -0,0 +1,173 @@
+/*
+ * caps.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:45
+ *
+ * caps [-c | -t] [term]
+ *
+ * -c use termcap names instead of terminfo variable names
+ * -t use terminfo capnames instead of variables names
+ * term name of terminal to use
+ *
+ * prints out all the capabilities given the specified terminal. If no
+ * terminal is given, it is taken from the environment variable TERM.
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+#include <term.h>
+
+const char SCCSid[] = "@(#) mytinfo caps.c 3.2 92/02/01 public domain, By Ross Ridge";
+
+/* output a string in a human readable format */
+void
+putstr(s)
+char *s; {
+ while(*s != '\0') {
+ switch(*s) {
+ case '\n': printf("\\n"); break;
+ case '\b': printf("\\b"); break;
+ case '\t': printf("\\t"); break;
+ case '\r': printf("\\r"); break;
+ case '\f': printf("\\f"); break;
+ case ' ': printf("\\s"); break;
+ case '\177': printf("^?"); break;
+ case '\200': printf("\\0"); break;
+ default:
+ if (*s > 0 && *s < 32)
+ printf("^%c", *s + 64);
+ else if (*s < 0)
+ printf("\\%03o", *s & 0xff);
+ else
+ putchar(*s);
+ break;
+ }
+ s++;
+ }
+}
+
+void
+do_cleanup(e)
+int e; {
+ fprintf(stderr, "usage: %s [-c | -t ] [terminal]\n", prg_name);
+ return;
+}
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ int names = 0;
+ register int i;
+ int flag, num;
+ char *str;
+
+ prg_name = argv[0];
+ cleanup = do_cleanup;
+
+ if (argc > 3)
+ quit(-1, "argument count");
+
+ if (argc == 1)
+ setupterm(NULL, 2, (int *) 0);
+ else if (argc == 2) {
+ if (argv[1][0] != '-')
+ setupterm(argv[1], 2, (int *) 0);
+ else {
+ if (argv[1][1] == 'c')
+ names = 2;
+ else if (argv[1][1] == 't')
+ names = 1;
+ else
+ quit(-1, "unknown switch '%c'", argv[1][1]);
+ setupterm(NULL, 2, (int *) 0);
+ }
+ } else {
+ if (argv[1][0] != '-')
+ quit(-1, "bad switch");
+ if (argv[1][1] == 'c')
+ names = 2;
+ else if (argv[1][1] == 't')
+ names = 1;
+ else
+ quit(-1, "unknown switch '%c'", argv[1][1]);
+ setupterm(argv[2], 2, (int *) 0);
+
+ }
+
+ fflush(stderr);
+ fflush(stdout);
+ printf("\n");
+#ifdef _CUR_TERM
+ printf("%s: %s\n", cur_term->name, cur_term->name_all);
+ printf("pad: %d xon: %d termcap: %d\n",
+ cur_term->pad, cur_term->xon, cur_term->termcap);
+ printf("true_columns: %d true_lines: %d baudrate: %lu\n",
+ cur_term->true_columns, cur_term->true_lines,
+ (unsigned long) cur_term->baudrate);
+ printf("\n");
+#endif
+
+ printf("Booleans:\n");
+ for(i = 0; boolnames[i] != NULL; i++) {
+#ifdef _CUR_TERM
+ flag = cur_term->bools[i];
+#else
+ flag = tigetflag(boolnames[i]);
+#endif
+ if (flag != -1 && flag != 0) {
+ switch(names) {
+ case 0:
+ printf(" %s\n", boolfnames[i]);
+ break;
+ case 1:
+ printf(" %s\n", boolnames[i]);
+ break;
+ case 2:
+ printf(" %s\n", boolcodes[i]);
+ break;
+ }
+ }
+ }
+
+ printf("\nNumerics:\n");
+ for(i = 0; numnames[i] != NULL; i++) {
+ num = tigetnum(numnames[i]);
+ if (num != -2 && num != -1) {
+ switch(names) {
+ case 0:
+ printf(" %-32s: %d\n", numfnames[i], num);
+ break;
+ case 1:
+ printf(" %-5s: %d\n", numnames[i], num);
+ break;
+ case 2:
+ printf(" %-2s: %d\n", numcodes[i], num);
+ break;
+ }
+ }
+ }
+ printf("\nStrings:\n");
+ for(i = 0; strnames[i] != NULL; i++) {
+ str = tigetstr(strnames[i]);
+ if (str != (char *) -1 && str != (char *) 0) {
+ switch(names) {
+ case 0:
+ printf(" %-32s: ", strfnames[i]);
+ break;
+ case 1:
+ printf(" %-5s: ", strnames[i]);
+ break;
+ case 2:
+ printf(" %-2s: ", strcodes[i]);
+ break;
+ }
+ putstr(str);
+ putchar('\n');
+ }
+ }
+ return 0;
+}
diff --git a/lib/libmytinfo/compar.c b/lib/libmytinfo/compar.c
new file mode 100644
index 0000000..f8998d3
--- /dev/null
+++ b/lib/libmytinfo/compar.c
@@ -0,0 +1,40 @@
+/*
+ * compar.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/06/04 11:36:24
+ *
+ */
+
+#include "defs.h"
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo compar.c 3.3 92/06/04 public domain, By Ross Ridge";
+#endif
+
+/* compare two elements a sorted list of pointers to strings */
+int
+_compar(a, b)
+#ifdef USE_ANSIC
+void const *a;
+void const *b; {
+#else
+anyptr a, b; {
+#endif
+ register char *aa = **(char ***)a;
+ register char *bb = **(char ***)b;
+
+ /* An optimization trick from C News, compare the first
+ * two chars of the string here to avoid a the overhead of a
+ * call to strcmp.
+ */
+
+#ifdef __GNUC__
+ return ((*aa - *bb) ? : strcmp(aa, bb));
+#else
+ if (*aa != *bb)
+ return *aa - *bb;
+ return strcmp(aa, bb);
+#endif
+}
diff --git a/lib/libmytinfo/config.h b/lib/libmytinfo/config.h
new file mode 100644
index 0000000..486fa3a
--- /dev/null
+++ b/lib/libmytinfo/config.h
@@ -0,0 +1,89 @@
+/*
+ * config.h
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/19 18:56:28
+ *
+ * @(#) mytinfo config.h 3.3 92/02/19 public domain, By Ross Ridge
+ *
+ * Read the file INSTALL for more information on configuring mytinfo
+ *
+ */
+
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+#ifdef __STDC__
+#define USE_ANSIC /* undefine this if your compiler lies */
+#endif
+
+#define USE_TERMIOS /* use POSIX termios */
+#undef USE_TERMIO /* use termio (SysIII, SysV) */
+#undef USE_SGTTY /* use sgtty (v7, BSD) */
+#define USE_WINSZ /* get window size from the tty driver */
+#undef USE_STRINGS /* include <strings.h> instead of <string.h> */
+#undef USE_MYBSEARCH /* your library doesn't have bsearch */
+#undef USE_MYSTRTOK /* your library doesn't have strtok */
+#undef USE_MYQSORT /* your library doesn't have qsort */
+#undef USE_MYMKDIR /* your library doesn't have mkdir */
+#define USE_MEMORY /* you have an <memory.h> header */
+#undef USE_FAKE_STDIO /* don't use real stdio */
+#undef USE_DOPRNT /* no vfprintf, use _doprnt */
+#undef USE_TERMINFO /* look in terminfo dirs for entry */
+#define USE_TERMCAP /* look in termcap dirs for entry */
+
+#undef USE_SHORT_BSEARCH /* speeds up MYBSEARCH on most machines */
+
+#undef USE_SMALLMEM /* save some memory */
+
+#undef USE_UPBC_KLUDGE /* do tgoto like real togo */
+#undef USE_EXTERN_UPBC /* get cuu1 and cub1 from externs UP and BC */
+#undef USE_LITOUT_KLUDGE /* an alternate tgoto kludge, not recommened */
+
+
+#ifndef USE_ANSIC
+
+#undef USE_PROTOTYPES /* use ANSI C prototypes */
+#undef USE_STDLIB /* you have a <stdlib.h> */
+#undef USE_STDARG /* you have a <stdarg.h> */
+#undef USE_STDDEF /* you have a <stddef.h> */
+
+#define const
+#define volatile
+#define noreturn /* a function that doesn't return */
+
+typedef char *anyptr; /* a type that any pointer can be assigned to */
+
+#define mysize_t unsigned /* size_t, the size of an object */
+
+#else /* USE_ANSIC */
+
+#define USE_PROTOTYPES
+#define USE_STDLIB
+#define USE_STDARG
+#define USE_STDDEF
+
+typedef void *anyptr;
+
+#define mysize_t size_t
+
+#ifdef __GNUC__
+#define noreturn volatile
+#else
+#define noreturn
+#endif
+
+#endif /* USE_ANSIC */
+
+#ifdef __FreeBSD__
+#define TERMCAPFILE "$TERMCAPFILE $HOME/.termcap /usr/share/misc/termcap"
+#else
+#define TERMCAPFILE "$TERMCAPFILE $HOME/.termcap /etc/termcap"
+#endif
+
+#define TERMINFOSRC "/usr/lib/terminfo/terminfo.src"
+
+#define TERMINFODIR "/usr/lib/terminfo"
+
+#endif
diff --git a/lib/libmytinfo/defs.h b/lib/libmytinfo/defs.h
new file mode 100644
index 0000000..cab2fae
--- /dev/null
+++ b/lib/libmytinfo/defs.h
@@ -0,0 +1,198 @@
+/*
+ * defs.h
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/06/04 11:37:02
+ *
+ * @(#) mytinfo defs.h 3.3 92/06/04 public domain, By Ross Ridge
+ */
+
+#ifndef _DEFS_H_
+#define _DEFS_H_
+
+#ifdef TEST
+#undef NOTLIB
+#define NOTLIB
+#endif
+
+#include "config.h"
+
+#ifdef NOTLIB
+#undef USE_FAKE_STDIO
+#endif
+
+#ifdef USE_STDDEF
+#include <stddef.h>
+#else
+#include <sys/types.h>
+#endif
+
+#ifdef USE_STDLIB
+#include <stdlib.h>
+#else
+#ifdef USE_PROTOTYPES
+anyptr malloc(mysize_t);
+anyptr realloc(anyptr, mysize_t);
+char *getenv(char const *);
+#else
+anyptr malloc();
+anyptr realloc();
+char *getenv();
+#endif
+#endif
+
+#ifdef USE_STDARG
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#ifndef _VA_LIST
+#define _VA_LIST
+#endif
+
+#ifdef USE_FAKE_STDIO
+#include "fake_stdio.h"
+#define sprintf _fake_sprintf
+#ifdef USE_PROTOTYPES
+int sprintf(char *, char *, ...);
+#else
+int sprintf();
+#endif
+#else /* USE_FAKE_STDIO */
+#if 0
+#include <stdio.h>
+#else
+#undef NULL
+#include <stdio.h>
+#endif
+#endif /* !USE_FAKE_STDIO */
+
+#ifdef USE_STRINGS
+#include <strings.h>
+#define strchr(s, c) index(s, c)
+#define strrchr(s, c) rindex(s, c)
+#ifndef USE_MYSTRTOK
+#ifdef USE_PROTOTYPES
+char *strtok(char *, char *);
+#else
+char *strtok();
+#endif
+#endif
+#else
+#include <string.h>
+#endif
+
+#ifdef USE_MEMORY
+#include <memory.h>
+#else
+#define memcpy(b, a, n) bcopy(a, b, n)
+#endif
+
+#include <errno.h>
+
+#define MAX_BUF 4096
+#define MAX_LINE 640
+#define MAX_NAME 128
+
+#define MAX_CHUNK MAX_LINE
+
+#define MAX_DEPTH 32
+
+#define MAX_VARNAME 32
+#define MAX_TINFONAME 5
+#define MAX_TCAPNAME 2
+
+struct caplist {
+ char type;
+ char flag;
+ char var[MAX_VARNAME + 1];
+ char tinfo[MAX_TINFONAME + 1];
+ char tcap[MAX_TCAPNAME + 1];
+};
+
+struct term_path {
+ char *file;
+ int type; /* 0 = file, 1 = TERMCAP env, 2 = TERMINFO env */
+};
+
+struct _terminal;
+
+#ifdef USE_PROTOTYPES
+
+int _gettcap(char *, struct _terminal *, struct term_path *);
+int _gettinfo(char *, struct _terminal *, struct term_path *);
+int _fillterm(char *, struct term_path *, char *);
+int _findterm(char *, struct term_path *, char *);
+int _init_tty(void), _lit_output(void), _check_tty(void);
+void _figure_termcap(void);
+int _tmatch(char *, char *);
+void _norm_output(void);
+int readcaps(FILE *, struct caplist *, int);
+noreturn void quit(int, char *, ...);
+#ifdef lint
+extern void (*cleanup)();
+#else
+extern void (*cleanup)(int);
+#endif
+struct term_path *_buildpath(char *, int, ...);
+void _delpath(struct term_path *);
+char *_addstr(char *);
+struct strbuf *_endstr(void);
+void _del_strs(struct _terminal *);
+void _tcapconv(void);
+void _tcapdefault(void);
+int _getother(char *, struct term_path *, struct _terminal *);
+int _gettbin(char *, struct _terminal *);
+int _findboolcode(char *), _findnumcode(char *), _findstrcode(char *);
+int _findboolname(char *), _findnumname(char *), _findstrname(char *);
+int _findboolfname(char *), _findnumfname(char *), _findstrfname(char *);
+
+#ifdef USE_ANSIC
+int _compar(void const *, void const *);
+typedef int (*compar_fn)(void const *, void const *);
+#else
+int _compar(anyptr, anyptr);
+typedef int (*compar_fn)(anyptr, anyptr);
+#endif
+
+#else /* USE_PROTOTYPES */
+
+int _gettcap(), _gettinfo(), _fillterm(), _findterm(), _init_tty();
+int _lit_output(), _check_tty();
+void _figure_termcap();
+int _tmatch();
+void _norm_output();
+int readcaps();
+noreturn void /* GOTO */ quit(/*FORMAT2*/);
+extern void (*cleanup)();
+struct term_path *_buildpath();
+void _delpath();
+char *_addstr();
+struct strbuf *_endstr();
+void _del_strs();
+void _tcapconv();
+void _tcapdefault();
+int _getother();
+int _gettbin();
+int _findboolcode(), _findnumcode(), _findstrcode();
+int _findboolname(), _findnumname(), _findstrname();
+int _findboolfname(), _findnumfname(), _findstrfname();
+int _compar();
+typedef int (*compar_fn)();
+
+#endif /* USE_PROTOTYPES */
+
+extern char _strflags[];
+
+extern char _mytinfo_version[];
+
+/* for quit.c */
+extern int sys_nerr;
+#if __FreeBSD__ != 2
+extern char *sys_errlist[];
+#endif
+extern char *prg_name;
+
+#endif /* _DEFS_H_ */
diff --git a/lib/libmytinfo/fillterm.c b/lib/libmytinfo/fillterm.c
new file mode 100644
index 0000000..4797f1a
--- /dev/null
+++ b/lib/libmytinfo/fillterm.c
@@ -0,0 +1,81 @@
+/*
+ * fillterm.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:54
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo fillterm.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+TERMINAL _term_buf;
+TERMINAL *cur_term;
+
+int
+_fillterm(name, path, buf)
+char *name, *buf;
+struct term_path *path; {
+ register int i, r;
+
+ r = -1;
+
+ for(i = NUM_OF_BOOLS; i;)
+ _term_buf.bools[--i] = -1;
+ for(i = NUM_OF_NUMS; i;)
+ _term_buf.nums[--i] = -2;
+ for(i = NUM_OF_STRS; i;)
+ _term_buf.strs[--i] = (char *) -1;
+
+ _term_buf.name_all = NULL;
+
+ r = _findterm(name, path, buf);
+ switch(r) {
+ case 1:
+ if (_gettcap(buf, &_term_buf, path) != 0)
+ return -3;
+ _tcapconv();
+ _tcapdefault();
+ break;
+ case 2:
+ if (_gettinfo(buf, &_term_buf, path) != 0)
+ return -3;
+ break;
+ case 3:
+ if (_gettbin(buf, &_term_buf) != 0)
+ return -3;
+ break;
+ default:
+ return r;
+ }
+
+ if ((_term_buf.name = _addstr(name)) == NULL)
+ return -3;
+
+ for(i = NUM_OF_BOOLS; i;)
+ if (_term_buf.bools[--i] == -1)
+ _term_buf.bools[i] = 0;
+ for(i = NUM_OF_NUMS; i;)
+ if (_term_buf.nums[--i] == -2)
+ _term_buf.nums[i] = -1;
+ for(i = NUM_OF_STRS; i;)
+ if (_term_buf.strs[--i] == (char *) -1)
+ _term_buf.strs[i] = NULL;
+
+ _term_buf.fd = 1;
+ _term_buf.pad = 1;
+ _term_buf.baudrate = 0;
+ _term_buf.strbuf = _endstr();
+
+ cur_term = (TERMINAL *) malloc(sizeof(_term_buf));
+ if (cur_term == NULL)
+ return -3;
+ memcpy((anyptr)cur_term, (anyptr)&_term_buf, sizeof(_term_buf));
+
+ return r;
+}
diff --git a/lib/libmytinfo/findcap.c b/lib/libmytinfo/findcap.c
new file mode 100644
index 0000000..81ede3f
--- /dev/null
+++ b/lib/libmytinfo/findcap.c
@@ -0,0 +1,149 @@
+/*
+ * findcap.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:55
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#include "bsearch.c"
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo findcap.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+extern char **_sboolcodes[], **_snumcodes[], **_sstrcodes[];
+extern char **_sboolnames[], **_snumnames[], **_sstrnames[];
+extern char **_sboolfnames[], **_snumfnames[], **_sstrfnames[];
+
+static char **p2p2c;
+
+int
+_findboolcode(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolcodes,
+ NUM_OF_BOOLS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - boolcodes;
+}
+
+int
+_findboolname(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolnames,
+ NUM_OF_BOOLS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - boolnames;
+}
+
+int
+_findboolfname(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolfnames,
+ NUM_OF_BOOLS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - boolfnames;
+}
+
+int
+_findnumcode(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumcodes,
+ NUM_OF_NUMS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - numcodes;
+}
+
+int
+_findnumname(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumnames,
+ NUM_OF_NUMS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - numnames;
+}
+
+int
+_findnumfname(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumfnames,
+ NUM_OF_NUMS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - numfnames;
+}
+
+int
+_findstrcode(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrcodes,
+ NUM_OF_STRS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - strcodes;
+}
+
+int
+_findstrname(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrnames,
+ NUM_OF_STRS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - strnames;
+}
+
+int
+_findstrfname(s)
+char *s; {
+ char ***match;
+
+ p2p2c = &s;
+
+ match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrfnames,
+ NUM_OF_STRS, sizeof(p2p2c), _compar);
+ if (match == NULL)
+ return -1;
+ return *match - strfnames;
+}
diff --git a/lib/libmytinfo/findterm.c b/lib/libmytinfo/findterm.c
new file mode 100644
index 0000000..04f6ef6
--- /dev/null
+++ b/lib/libmytinfo/findterm.c
@@ -0,0 +1,286 @@
+/* findterm.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:56
+ *
+ */
+
+#include "defs.h"
+
+#include <ctype.h>
+#include <fcntl.h>
+#ifdef USE_STDDEF
+#include <sys/types.h>
+#endif
+#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <unistd.h>
+#endif
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo findterm.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+static int linecnt;
+
+static int
+getln(f, buf, len)
+FILE *f;
+register char *buf;
+int len; {
+ register int c, i = 0;
+
+ while((c = getc(f)) == '#') {
+ linecnt++;
+ while((c = getc(f)) != '\n')
+ if (c == EOF)
+ return -1;
+ }
+
+ while(c != '\n') {
+ if (c == EOF)
+ return -1;
+ if (i < len) {
+ i++;
+ *buf++ = c;
+ }
+ c = getc(f);
+ }
+
+ while(isspace(*(buf-1))) {
+ buf--;
+ i--;
+ }
+
+ *buf = '\0';
+ return i;
+}
+
+static int
+_findterm2(name, file, buf)
+char *name, *buf;
+char *file; {
+ char line[MAX_LINE];
+ FILE *f;
+ register char *sp, *dp;
+ int c;
+ int l;
+ int cont;
+ int fd;
+ struct stat st;
+
+ linecnt = 0;
+
+#ifdef DEBUG
+ printf("open: %s\n", file);
+#endif
+ fd = open(file, O_RDONLY);
+ if (fd == -1)
+ return -1;
+ if (fstat(fd, &st) == -1) {
+ close(fd);
+ return -1;
+ }
+ if ((st.st_mode & 0170000) == 0040000) {
+ sprintf(buf, "%s/%c/%s", file, name[0], name);
+ close(fd);
+ fd = open(buf, O_RDONLY);
+ if (fd == -1)
+ return -1;
+ if (read(fd, buf, MAX_BUF) < 12
+ || buf[0] != 032 || buf[1] != 1) {
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return 3;
+ }
+ f = fdopen(fd, "r");
+ if (f == NULL) {
+ close(fd);
+ return -1;
+ }
+
+ while ((l = getln(f, buf, MAX_LINE)) != -1) {
+ linecnt++;
+ if (!isspace(buf[0]) && l != 0) {
+ sp = buf + l - 1;
+ cont = 0;
+ switch(*sp) {
+ case '\\':
+ cont = 1;
+ *sp = '\0';
+ /* FALLTHROUGH */
+ case ':':
+ sp = buf;
+ dp = line;
+ while (*sp != ':') {
+ if (*sp == '\0' && cont &&
+ (l = getln(f, buf, MAX_LINE))
+ != -1) {
+ linecnt++;
+ sp = buf;
+ if (l > 0 && buf[l-1] == '\\')
+ cont = 1;
+ else
+ cont = 0;
+ continue;
+ }
+ if (*sp == '\0') {
+#ifdef DEBUG
+ printf("bad line (%d)\n",
+ linecnt);
+ fclose(f);
+ return -2;
+#else
+ goto err;
+#endif
+ }
+ *dp++ = *sp++;
+ }
+ *dp = '\0';
+ if (!_tmatch(line, name))
+ break;
+ if (!cont) {
+ fclose(f);
+ return 1;
+ }
+ l = strlen(buf);
+ dp = buf + l;
+ while((c = getc(f)) != EOF && l < MAX_BUF) {
+ if (c == '\n')
+ break;
+ if (c == '\\') {
+ c = getc(f);
+ if (c == EOF)
+ break;
+ if (c == '\n') {
+ c = getc(f);
+ if (c == EOF)
+ break;
+ if (c == '#') {
+ while((c = getc(f)) != EOF && c != '\n');
+ if (c == EOF)
+ break;
+ continue;
+ }
+ *dp++ = c;
+ continue;
+ }
+ *dp++ = '\\';
+ *dp++ = c;
+ continue;
+ }
+ *dp++ = c;
+ }
+ *dp = '\0';
+ fclose(f);
+ return 1;
+ case ',':
+ sp = buf;
+ dp = line;
+ while(*sp != ',')
+ *dp++ = *sp++;
+ *dp = '\0';
+ if (!_tmatch(line, name))
+ break;
+ dp = buf + l;
+ while ((c = getc(f)) != EOF && l < MAX_BUF) {
+ if (c == '\n') {
+ c = getc(f);
+ if (isspace(c))
+ continue;
+ if (c == '\n') {
+ ungetc(c, f);
+ continue;
+ }
+ if (c == '#') {
+ while((c = getc(f)) != EOF)
+ if (c == '\n')
+ break;
+ if (c == EOF)
+ break;
+ ungetc(c, f);
+ continue;
+ }
+ break;
+ }
+ *dp++ = c;
+ l++;
+ }
+ *dp = '\0';
+ fclose(f);
+ return 2;
+ default:
+ err:
+#ifdef DEBUG
+ printf("strange line (%d)\n", linecnt);
+#endif
+ break;
+ }
+ }
+ }
+ fclose(f);
+ return 0;
+}
+
+int
+_findterm(name, path, buf)
+char *name;
+struct term_path *path;
+char *buf; {
+ register char *s, *d;
+ int r = 0;
+ while(path->file != NULL) {
+ switch(path->type) {
+ case 0:
+ r = _findterm2(name, path->file, buf);
+ break;
+ case 1:
+ if (path->file[0] == '/') {
+ r = _findterm2(name, path->file, buf);
+ } else {
+ s = path->file;
+ d = buf;
+ while(*s != '\0' && *s != ':')
+ *d++ = *s++;
+ *d = '\0';
+ if (_tmatch(buf, name)) {
+ while(*s != '\0')
+ *d++ = *s++;
+ return 1;
+ }
+ r = 0;
+ }
+ break;
+ case 2:
+ if (path->file[0] == '/') {
+ r = _findterm2(name, path->file, buf);
+ } else {
+ s = path->file;
+ d = buf;
+ while(*s != '\0' && *s != ',')
+ *d++ = *s++;
+ *d = '\0';
+ if (_tmatch(buf, name)) {
+ while(*s != '\0')
+ *d++ = *s++;
+ return 2;
+ }
+ r = 0;
+ }
+ break;
+ default:
+ r = 0;
+ break;
+ }
+ if (r == 1 || r == 2 || r == 3) {
+#ifdef DEBUG
+ printf("found in %s\n", path->file);
+#endif
+ break;
+ }
+ path++;
+ }
+ return r;
+}
diff --git a/lib/libmytinfo/getother.c b/lib/libmytinfo/getother.c
new file mode 100644
index 0000000..2542f66
--- /dev/null
+++ b/lib/libmytinfo/getother.c
@@ -0,0 +1,49 @@
+/*
+ * getother.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:58
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo getother.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+int
+_getother(name, path, ct)
+char *name;
+struct term_path *path;
+TERMINAL *ct; {
+ static int depth = 0;
+ int r;
+ char buf[MAX_BUF];
+
+ if (depth >= MAX_DEPTH)
+ return 1; /* infinite loop */
+
+#ifdef DEBUG
+ printf("\ngetother: %s\n", name);
+#endif
+
+ switch(_findterm(name, path, buf)) {
+ case -3:
+ return 1;
+ case 1:
+ depth++;
+ r = _gettcap(buf, ct, path);
+ break;
+ case 2:
+ depth++;
+ r = _gettinfo(buf, ct, path);
+ break;
+ default:
+ return 0;
+ }
+ depth--;
+ return r;
+}
diff --git a/lib/libmytinfo/gettbin.c b/lib/libmytinfo/gettbin.c
new file mode 100644
index 0000000..202f4cb
--- /dev/null
+++ b/lib/libmytinfo/gettbin.c
@@ -0,0 +1,127 @@
+/*
+ * gettbin.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:29:59
+ *
+ * Get a terminfo binary entry
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo gettbin.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+extern int _boolorder[], _numorder[], _strorder[];
+
+#ifdef TRUE_BYTE_ORDERING
+/* 8 bit char, 16 bit short, lsb first, twos complement */
+#define convshort(s) (*(short *)(s))
+
+#else
+
+#ifdef TWOS_COPLEMENT
+/* 8 bit char, 16 bit short, lsb last, twos complement */
+#define convshort(s) ((short)(((s[0] & 0377) << 8) | (s[1] & 0377)))
+
+#else
+
+/* anything else... */
+
+static short
+convshort(s)
+char *s; {
+ register int a,b;
+
+ a = (int) s[0] & 0377;
+ b = (int) s[1] & 0377;
+
+ if (a == 0377 && b == 0377)
+ return -1;
+ if (a == 0376 && b == 0377)
+ return -2;
+
+ return a + b * 256;
+}
+#endif
+#endif
+
+int
+_gettbin(buf, cur)
+char *buf;
+TERMINAL *cur; {
+ register char *s;
+ int i;
+ int sz_names, sz_bools, sz_nums, sz_offs, sz_strs;
+ int n_bools, n_nums, n_strs;
+ char *strtbl;
+
+ buf[MAX_BUF-1] = '\0';
+ s = buf;
+
+ if (convshort(s) != 0432)
+ return 1;
+ sz_names = convshort(s + 2);
+ sz_bools = convshort(s + 4);
+ n_nums = convshort(s + 6);
+ n_strs = convshort(s + 8);
+ sz_strs = convshort(s + 10);
+
+ n_bools = sz_bools;
+ sz_nums = n_nums * 2;
+ sz_offs = n_strs * 2;
+
+ if ((sz_names + sz_bools) & 1)
+ sz_bools++;
+
+ if (12 + sz_names + sz_bools + sz_nums + sz_offs + sz_strs >= MAX_BUF)
+ return 1;
+
+ s += 12;
+ if ((cur->name_all = _addstr(s)) == NULL)
+ return 1;
+ s += sz_names;
+ while(--s >= buf + 12) {
+ if (*s == '|') {
+ if ((cur->name_long = _addstr(s + 1)) == NULL)
+ return 1;
+ break;
+ }
+ }
+
+ s = buf + 12 + sz_names;
+ for(i = 0; i < n_bools && _boolorder[i] != -1; i++, s++) {
+ if (cur->bools[_boolorder[i]] == -1 && *s == 1)
+ cur->bools[_boolorder[i]] = 1;
+ }
+
+ s = buf + 12 + sz_names + sz_bools;
+ for(i = 0; i < n_nums && _numorder[i] != -1; i++, s += 2) {
+ if (convshort(s) == -2)
+ cur->nums[_numorder[i]] = -1;
+ else if (cur->nums[_numorder[i]] == -2 && convshort(s) != -1)
+ cur->nums[_numorder[i]] = convshort(s);
+ }
+
+ s = buf + 12 + sz_names + sz_bools + sz_nums;
+ strtbl = s + sz_offs;
+ for(i = 0; i < n_strs && _strorder[i] != -1; i++, s += 2) {
+ if (convshort(s) == -2)
+ cur->strs[_strorder[i]] = NULL;
+ else if (cur->strs[_strorder[i]] == (char *) -1
+ && convshort(s) != -1) {
+#ifdef DEBUG
+ printf("$%s ", strnames[_strorder[i]]);
+#endif
+ if ((cur->strs[_strorder[i]]
+ = _addstr(strtbl + convshort(s))) == NULL)
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/lib/libmytinfo/gettcap.c b/lib/libmytinfo/gettcap.c
new file mode 100644
index 0000000..c3acf08
--- /dev/null
+++ b/lib/libmytinfo/gettcap.c
@@ -0,0 +1,273 @@
+/*
+ * gettcap.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:00
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#include <ctype.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo gettcap.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+int
+_gettcap(sp, cur, path)
+register char *sp;
+TERMINAL *cur;
+struct term_path *path; {
+ static char name[MAX_NAME];
+ static char entry[MAX_LINE];
+ register char *dp;
+ register TERMINAL *ct = cur;
+ int i, pad, fract, mul = 0, ind;
+ char c, flag;
+
+ dp = entry;
+ while(*sp != ':' && *sp != '\0')
+ *dp++ = *sp++;
+ if (ct->name_all == NULL) {
+ *dp = '\0';
+ if ((ct->name_all = _addstr(entry)) == NULL)
+ return 1;
+ while(dp > entry && *--dp != '|');
+ ct->name_long = ct->name_all + (dp - entry) + 1;
+ }
+
+ while(*sp != '\0') {
+ while(*sp == ':')
+ sp++;
+ while(isspace(*sp))
+ sp++;
+ if (*sp == ':')
+ continue;
+ if (*sp == '\0')
+ break;
+ dp = name;
+ while (*sp != ':' && *sp != '#' && *sp != '=' &&
+ !isspace(*sp) && *sp != '\0')
+ *dp++ = *sp++;
+ *dp = '\0';
+#ifdef DEBUG
+ printf(" %s", name);
+#endif
+ switch(*sp) {
+ case '=':
+#ifdef DEBUG
+ putchar('$');
+#endif
+ ind = _findstrcode(name);
+ if (ind != -1)
+ flag = _strflags[ind];
+ else
+ flag = 'K';
+ dp = entry;
+ fract = pad = 0;
+ sp++;
+ if (isdigit(*sp) && flag != 'K') {
+ pad = *sp++ - '0';
+ while(isdigit(*sp))
+ pad = pad * 10 + (*sp++ - '0');
+ if (*sp == '.' && isdigit(sp[1])) {
+ sp++;
+ fract = (*sp++ - '0');
+ }
+ if (*sp == '*') {
+ mul = 1;
+ sp++;
+ } else
+ mul = 0;
+
+ }
+ while(*sp != '\0' && *sp != ':') {
+ switch(*sp) {
+ case '\\':
+ switch(*++sp) {
+ case 'e':
+ case 'E': *dp++ = '\033'; break;
+ case 'l': *dp++ = '\012'; break;
+ case 'n': *dp++ = '\n'; break;
+ case 'r': *dp++ = '\r'; break;
+ case 't': *dp++ = '\t'; break;
+ case 'b': *dp++ = '\b'; break;
+ case 'f': *dp++ = '\f'; break;
+ case 's': *dp++ = ' '; break;
+
+ case '^':
+ case '\\':
+ case ',':
+ case ':':
+ *dp++ = *sp;
+ break;
+
+ case '0':
+ if (!isdigit(*(sp + 1))) {
+ *dp++ = '\200';
+ break;
+ }
+ ;/* FALLTHROUGH */
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ c = *sp - '0';
+ if (sp[1] >= '0'
+ && sp[1] <= '8')
+ c = c * 8
+ + (*++sp - '0');
+ if (sp[1] >= '0'
+ && sp[1] <= '8')
+ c = c * 8
+ + (*++sp - '0');
+ switch((char)c) {
+ case 0:
+ if (flag == 'K')
+ *dp++ = '\200';
+ else {
+ *dp++ = '\\';
+ *dp++ = '0';
+ *dp++ = '0';
+ *dp++ = '0';
+ }
+ break;
+ case '$':
+ case '\'':
+ case '\\':
+ if (flag != 'K')
+ *dp++ = '\\';
+ /* FALLTHROUGH */
+ default:
+ if (flag == 'G'
+ && c == '%')
+ *dp++ = '\\';
+ *dp++ = c;
+ break;
+ }
+ break;
+ default:
+ *dp++ = '\\';
+ *dp++ = *sp;
+ break;
+ }
+ sp++;
+ break;
+ case '^':
+ if (*++sp >= 'A' && *sp <= '_') {
+ *dp++ = *sp++ - '@';
+ } else if (*sp >= 'a' && *sp <= 'z') {
+ *dp++ = *sp++ - 'a' + 1;
+ } else if (*sp == '@') {
+ if (flag == 'K')
+ *dp++ = '\200';
+ else {
+ *dp++ = '\\';
+ *dp++ = '0';
+ *dp++ = '0';
+ *dp++ = '0';
+ }
+ sp++;
+ } else
+ *dp++ = '^';
+ break;
+ case '$':
+ if (flag != 'K')
+ *dp++ = '\\';
+ /* FALLTHROUGH */
+ default:
+ *dp++ = *sp++;
+ break;
+ }
+ }
+ if (pad != 0 || fract != 0) {
+ if (fract == 0)
+ sprintf(dp, "$<%d", pad);
+ else
+ sprintf(dp, "$<%d.%d", pad, fract);
+ dp += strlen(dp);
+ if (mul)
+ *dp++ = '*';
+ *dp++ = '>';
+ }
+ *dp++ = '\0';
+ if(name[0] == 't' && name[1] == 'c' && name[2] == '\0'){
+ if (_getother(entry, path, ct))
+ return 1;
+ break;
+ }
+ if (ind == -1)
+ break;
+ if (ct->strs[ind] != (char *) -1)
+ break;
+ if ((ct->strs[ind] = _addstr(entry)) == NULL)
+ return 1;
+ break;
+ case '#':
+#ifdef DEBUG
+ putchar('#');
+#endif
+ i = atoi(++sp);
+ while(*sp != '\0' && *sp++ != ':');
+ ind = _findnumcode(name);
+ if (ind == -1)
+ break;
+ if (ct->nums[ind] != -2)
+ break;
+ ct->nums[ind] = i;
+ break;
+ default:
+ while(*sp != '\0' && *sp++ != ':');
+ if (*(dp - 1) == '@') {
+#ifdef DEBUG
+ putchar('@');
+#endif
+ *(dp - 1) = '\0';
+ ind = _findboolcode(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('!');
+#endif
+ if (ct->bools[ind] == -1)
+ ct->bools[ind] = 0;
+ break;
+ }
+ ind = _findnumcode(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('#');
+#endif
+ if (ct->nums[ind] == -2)
+ ct->nums[ind] = -1;
+ break;
+ }
+ ind = _findstrcode(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('$');
+#endif
+ if (ct->strs[ind] == (char *) -1)
+ ct->strs[ind] = NULL;
+ break;
+ }
+ break;
+ }
+#ifdef DEBUG
+ putchar('!');
+#endif
+ ind = _findboolcode(name);
+ if (ind == -1)
+ break;
+ if (ct->bools[ind] != -1)
+ break;
+ ct->bools[ind] = 1;
+ }
+ }
+ return 0;
+}
diff --git a/lib/libmytinfo/gettinfo.c b/lib/libmytinfo/gettinfo.c
new file mode 100644
index 0000000..d0ef43b
--- /dev/null
+++ b/lib/libmytinfo/gettinfo.c
@@ -0,0 +1,303 @@
+/*
+ * gettinfo.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:02
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#include <ctype.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo gettinfo.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+int _gettinfo(sp, cur, path)
+register char *sp;
+struct term_path *path;
+TERMINAL *cur; {
+ static char name[MAX_NAME];
+ static char entry[MAX_LINE];
+ register char *dp;
+ register TERMINAL *ct = cur;
+ int ind, i, base;
+ char c, flag;
+
+ dp = entry;
+ while(*sp != ',' && *sp != '\0')
+ *dp++ = *sp++;
+ if (ct->name_all == NULL) {
+ *dp = '\0';
+ if ((ct->name_all = _addstr(entry)) == NULL)
+ return 1;
+ while(dp > entry && *--dp != '|');
+ ct->name_long = ct->name_all + (dp - entry) + 1;
+ }
+
+ while(*sp != '\0') {
+ while(*sp == ',')
+ sp++;
+ while(isspace(*sp))
+ sp++;
+ if (*sp == ',')
+ continue;
+ if (*sp == '\0')
+ break;
+ dp = name;
+ while (*sp != ',' && *sp != '#' && *sp != '=' && !isspace(*sp) && *sp != '\0')
+ *dp++ = *sp++;
+ *dp = '\0';
+#ifdef DEBUG
+ printf(" %s", name);
+#endif
+ switch(*sp) {
+ case '=':
+#ifdef DEBUG
+ putchar('$');
+#endif
+ dp = entry;
+ sp++;
+ ind = _findstrname(name);
+ if (ind != -1)
+ flag = _strflags[ind];
+ else {
+ ind = _findstrfname(name);
+ if (ind != -1)
+ flag = _strflags[ind];
+ else
+ flag = 'K';
+ }
+ while(*sp != '\0' && *sp != ',') {
+ switch(*sp) {
+ case '%':
+ *dp++ = *sp++;
+ if (*sp == '^' && flag == 'G')
+ *dp++ = *sp++;
+ break;
+ case '\\':
+ switch(*++sp) {
+ case 'e':
+ case 'E': *dp++ = '\033'; break;
+ case 'l': *dp++ = '\012'; break;
+ case 'n': *dp++ = '\n'; break;
+ case 'r': *dp++ = '\r'; break;
+ case 't': *dp++ = '\t'; break;
+ case 'b': *dp++ = '\b'; break;
+ case 'f': *dp++ = '\f'; break;
+ case 's': *dp++ = ' '; break;
+
+ case '^':
+ case '\\':
+ case ',':
+ case ':':
+ *dp++ = *sp; break;
+
+ case '0':
+ if (!isdigit(*(sp + 1))) {
+ *dp++ = '\200';
+ break;
+ }
+ /* FALLTHROUGH */
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ c = *sp - '0';
+ if (isdigit(sp[1]))
+ c = c * 8 + (*++sp-'0');
+ if (isdigit(sp[1]))
+ c = c * 8 + (*++sp-'0');
+ switch((char)c) {
+ case 0:
+ if (flag == 'K')
+ *dp++ = '\200';
+ else {
+ *dp++ = '\\';
+ *dp++ = '0';
+ *dp++ = '0';
+ *dp++ = '0';
+ }
+ break;
+ case '$':
+ case '\'':
+ case '\\':
+ if (flag != 'K')
+ *dp++ = '\\';
+ /* FALLTHROUGH */
+ default:
+ if (flag == 'G'
+ && c == '%')
+ *dp++ = '\\';
+ *dp++ = c;
+ break;
+ }
+ break;
+ default:
+ *dp++ = '\\';
+ *dp++ = *sp;
+ break;
+ }
+ sp++;
+ break;
+ case '^':
+ if (*++sp >= 'A' && *sp <= '_') {
+ *dp++ = *sp++ - '@';
+ } else if (*sp >= 'a' && *sp <= 'z') {
+ *dp++ = *sp++ - 'a' + 1;
+ } else if (*sp == '@') {
+ if (flag == 'K')
+ *dp++ = '\200';
+ else {
+ *dp++ = '\\';
+ *dp++ = '0';
+ *dp++ = '0';
+ *dp++ = '0';
+ }
+ sp++;
+ } else
+ *dp++ = '^';
+ break;
+ default:
+ *dp++ = *sp++;
+ break;
+ }
+ }
+ *dp++ = '\0';
+ if (strcmp(name, "use") == 0) {
+ if (_getother(entry, path, ct))
+ return 1;
+ break;
+ }
+ if (ind == -1)
+ break;
+ if (ct->strs[ind] != (char *) -1)
+ break;
+ if ((ct->strs[ind] = _addstr(entry)) == NULL)
+ return 1;
+ break;
+ case '#':
+#ifdef DEBUG
+ putchar('#');
+#endif
+#if 0
+ i = atoi(++sp);
+#else
+ sp++;
+ if (*sp == '0') {
+ sp++;
+ if (*sp == 'x' || *sp == 'X') {
+ sp++;
+ base = 16;
+ } else
+ base = 8;
+ } else
+ base = 10;
+ i = 0;
+ while(1) {
+ if (isdigit(*sp))
+ i = i * base + *sp - '0';
+ else if (base == 16 && isxdigit(*sp))
+ i = i * base + tolower(*sp) - 'a' + 10;
+ else
+ break;
+ sp++;
+ }
+#endif
+ while(*sp != '\0' && *sp != ',')
+ sp++;
+
+ ind = _findnumname(name);
+ if (ind != -1) {
+ if (ct->nums[ind] != -2)
+ break;
+ ct->nums[ind] = i;
+ } else {
+ ind = _findnumfname(name);
+ if (ind != -1) {
+ if (ct->nums[ind] != -2)
+ break;
+ ct->nums[ind] = i;
+ }
+ }
+ break;
+ default:
+ while(*sp != '\0' && *sp++ != ',');
+ if (*(dp - 1) == '@') {
+#ifdef DEBUG
+ putchar('@');
+#endif
+ *(dp - 1) = '\0';
+ ind = _findboolname(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('!');
+#endif
+ ct->bools[ind] = 0;
+ break;
+ }
+ ind = _findnumname(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('#');
+#endif
+ ct->nums[ind] = -1;
+ break;
+ }
+ ind = _findstrname(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('$');
+#endif
+ ct->strs[ind] = NULL;
+ break;
+ }
+ ind = _findboolfname(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('!');
+#endif
+ ct->bools[ind] = 0;
+ break;
+ }
+ ind = _findnumfname(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('#');
+#endif
+ ct->nums[ind] = -1;
+ break;
+ }
+ ind = _findstrfname(name);
+ if (ind != -1) {
+#ifdef DEBUG
+ putchar('$');
+#endif
+ ct->strs[ind] = NULL;
+ break;
+ }
+ break;
+ }
+#ifdef DEBUG
+ putchar('!');
+#endif
+ ind = _findboolname(name);
+ if (ind == -1) {
+ ind = _findboolfname(name);
+ if (ind == -1)
+ break;
+ }
+ if (ct->bools[ind] != -1)
+ break;
+ ct->bools[ind] = 1;
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/lib/libmytinfo/mkbinorder.c b/lib/libmytinfo/mkbinorder.c
new file mode 100644
index 0000000..0bcc474
--- /dev/null
+++ b/lib/libmytinfo/mkbinorder.c
@@ -0,0 +1,116 @@
+/*
+ * mkbinorder.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:04
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+#include <term.h>
+
+const char SCCSid[] = "@(#) mytinfo mkbinorder.c 3.2 92/02/01 public domain, By Ross Ridge";
+
+char cap[MAX_NAME];
+char *p2c = cap;
+char **p2p2c = &p2c;
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ int r;
+ int ind;
+ FILE *f;
+
+ if (argc == 1)
+ f = stdin;
+ else if (argc == 2) {
+ f = fopen(argv[1], "r");
+ if (f == NULL) {
+ fprintf(stderr, "can't open %s\n", argv[1]);
+ exit(1);
+ }
+ } else {
+ fprintf(stderr, "argument count\n");
+ exit(1);
+ }
+
+ do {
+ r = fscanf(f, "%s", cap);
+ } while(r == 1 && strcmp(cap, "!") != 0);
+ if (r != 1) {
+ fprintf(stderr, "expected '!'\n");
+ exit(1);
+ }
+
+ puts("/*");
+ puts(" * binorder.c");
+ puts(" *");
+ puts(" * This file was generated automatically");
+ puts(" *");
+ puts(" */\n");
+
+ puts("int _boolorder[] = {");
+
+ while(1) {
+ r = fscanf(f, "%s", cap);
+ cap[MAX_TINFONAME] = '\0';
+ if (r != 1) {
+ fprintf(stderr, "unexpected EOF\n");
+ exit(1);
+ }
+ if (strcmp(cap, "#") == 0)
+ break;
+ ind = _findboolname(cap);
+ if (ind == -1) {
+ fprintf(stderr, "unknown bool name '%s'\n", cap);
+ continue;
+ }
+ printf("\t%d,\n", ind);
+ }
+ puts("\t-1");
+ puts("};\n");
+
+ puts("int _numorder[] = {");
+
+ while(1) {
+ r = fscanf(f, "%s", cap);
+ cap[MAX_TINFONAME] = '\0';
+ if (r != 1) {
+ fprintf(stderr, "unexpected EOF\n");
+ exit(1);
+ }
+ if (strcmp(cap, "$") == 0)
+ break;
+ ind = _findnumname(cap);
+ if (ind == -1) {
+ fprintf(stderr, "unknown num name '%s'\n", cap);
+ continue;
+ }
+ printf("\t%d,\n", ind);
+ }
+ puts("\t-1");
+ puts("};\n");
+
+ puts("int _strorder[] = {");
+
+ while(1) {
+ r = fscanf(f, "%s", cap);
+ cap[MAX_TINFONAME] = '\0';
+ if (r != 1)
+ break;
+ ind = _findstrname(cap);
+ if (ind == -1) {
+ fprintf(stderr, "unknown str name '%s'\n", cap);
+ continue;
+ }
+ printf("\t%d,\n", ind);
+ }
+ puts("\t-1");
+ puts("};\n");
+
+ return 0;
+}
diff --git a/lib/libmytinfo/mkcaplist.c b/lib/libmytinfo/mkcaplist.c
new file mode 100644
index 0000000..2fedf2d
--- /dev/null
+++ b/lib/libmytinfo/mkcaplist.c
@@ -0,0 +1,166 @@
+/*
+ * mkcaplist.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:05
+ *
+ * mkcaplist [-n caps] [file]
+ *
+ * makes caplist.c from the cap_list file
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+
+const char SCCSid[] = "@(#) mytinfo mkcaplist.c 3.2 92/02/01 public domain, By Ross Ridge";
+
+#define DEFAULT_CAPS 1000
+
+struct caplist *list;
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ FILE *f;
+ int caps = DEFAULT_CAPS;
+ int n;
+ register int i;
+
+ if (argc > 2 && argv[1][0] == '-' && argv[1][1] == 'n') {
+ caps = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ }
+
+ if (argc == 1) {
+ f = stdin;
+ } else if (argc == 2) {
+ f = fopen(argv[1], "r");
+ if (f == NULL) {
+ fprintf(stderr, "%s: can't open '%s'\n", argv[0],
+ argv[1]);
+ return 1;
+ }
+ } else {
+ fprintf(stderr, "%s: too many arguments\n", argv[0]);
+ fprintf(stderr, "usage: %s [-n caps] [file]\n", argv[0]);
+ return 1;
+ }
+
+ list = (struct caplist *) malloc(caps * sizeof(struct caplist));
+ if (list == NULL) {
+ fprintf(stderr, "%s: malloc failed.\n", argv[0]);
+ return 1;
+ }
+
+ n = readcaps(f, list, caps);
+ if (n > caps) {
+ fprintf(stderr, "%s: too many caps, use -n.\n", argv[0]);
+ return 1;
+ }
+ if (n == 0) {
+ fprintf(stderr, "%s: no caps in file.\n", argv[0]);
+ return 1;
+ }
+ if (n == -1) {
+ fprintf(stderr, "%s: bad caps line.\n", argv[0]);
+ return 1;
+ }
+ if (n == -2) {
+ fprintf(stderr, "%s: unexpected EOF.\n", argv[0]);
+ return 1;
+ }
+
+ puts("/*");
+ puts(" * caplist.c ");
+ puts(" *");
+ puts(" * This file was generated automatically.");
+ puts(" *");
+ puts(" */");
+ putchar('\n');
+
+ puts("char *boolnames[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '!')
+ printf("\t\"%s\",\n", list[i].tinfo);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *boolcodes[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '!')
+ printf("\t\"%s\",\n", list[i].tcap);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *boolfnames[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '!')
+ printf("\t\"%s\",\n", list[i].var);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *numnames[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '#')
+ printf("\t\"%s\",\n", list[i].tinfo);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *numcodes[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '#')
+ printf("\t\"%s\",\n", list[i].tcap);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *numfnames[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '#')
+ printf("\t\"%s\",\n", list[i].var);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *strnames[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '$')
+ printf("\t\"%s\",\n", list[i].tinfo);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *strcodes[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '$')
+ printf("\t\"%s\",\n", list[i].tcap);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char *strfnames[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '$')
+ printf("\t\"%s\",\n", list[i].var);
+ puts("\t(char *)0");
+ puts("};");
+ putchar('\n');
+
+ puts("char _strflags[] = {");
+ for (i = 0; i < n; i++)
+ if (list[i].type == '$')
+ printf("\t'%c',\n", list[i].flag);
+ puts("\t'\\0'");
+ puts("};");
+ putchar('\n');
+
+ return 0;
+}
diff --git a/lib/libmytinfo/mkcapsort.c b/lib/libmytinfo/mkcapsort.c
new file mode 100644
index 0000000..21c1a4a
--- /dev/null
+++ b/lib/libmytinfo/mkcapsort.c
@@ -0,0 +1,134 @@
+/*
+ * mkcapsort.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/06/04 11:38:02
+ *
+ * mkcapsort
+ *
+ * make the sorted lists of pointers to strins
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_MYQSORT
+#include "qsort.c"
+#endif
+
+const char SCCSid[] = "@(#) mytinfo mkcapsort.c 3.3 92/06/04 public domain, By Ross Ridge";
+
+char **sboolnames[NUM_OF_BOOLS], **sboolcodes[NUM_OF_BOOLS], **sboolfnames[NUM_OF_BOOLS];
+char **snumnames[NUM_OF_NUMS], **snumcodes[NUM_OF_NUMS], **snumfnames[NUM_OF_NUMS];
+char **sstrnames[NUM_OF_STRS], **sstrcodes[NUM_OF_STRS], **sstrfnames[NUM_OF_STRS];
+
+
+int
+main() {
+ register int i;
+
+ i = NUM_OF_BOOLS;
+ while(i) {
+ i--;
+ sboolnames[i] = &boolnames[i];
+ sboolcodes[i] = &boolcodes[i];
+ sboolfnames[i] = &boolfnames[i];
+ }
+
+ i = NUM_OF_NUMS;
+ while(i) {
+ i--;
+ snumnames[i] = &numnames[i];
+ snumcodes[i] = &numcodes[i];
+ snumfnames[i] = &numfnames[i];
+ }
+
+ i = NUM_OF_STRS;
+ while(i) {
+ i--;
+ sstrnames[i] = &strnames[i];
+ sstrcodes[i] = &strcodes[i];
+ sstrfnames[i] = &strfnames[i];
+ }
+
+ qsort((anyptr) sboolnames, NUM_OF_BOOLS, sizeof(*sboolnames), _compar);
+ qsort((anyptr) sboolcodes, NUM_OF_BOOLS, sizeof(*sboolcodes), _compar);
+ qsort((anyptr) sboolfnames, NUM_OF_BOOLS, sizeof(*sboolfnames),_compar);
+ qsort((anyptr) snumnames, NUM_OF_NUMS, sizeof(*snumnames), _compar);
+ qsort((anyptr) snumcodes, NUM_OF_NUMS, sizeof(*snumcodes), _compar);
+ qsort((anyptr) snumfnames, NUM_OF_NUMS, sizeof(*snumfnames), _compar);
+ qsort((anyptr) sstrnames, NUM_OF_STRS, sizeof(*sstrnames), _compar);
+ qsort((anyptr) sstrcodes, NUM_OF_STRS, sizeof(*sstrcodes), _compar);
+ qsort((anyptr) sstrfnames, NUM_OF_STRS, sizeof(*sstrfnames), _compar);
+
+ printf("/*\n");
+ printf(" * capsort.c\n");
+ printf(" *\n");
+ printf(" * This file was generated automatically.\n");
+ printf(" *\n");
+ printf(" */\n\n");
+
+ puts("extern char *boolnames[], *boolcodes[], *boolfnames[];");
+ puts("extern char *numnames[], *numcodes[], *numfnames[];");
+ puts("extern char *strnames[], *strcodes[], *strfnames[];");
+ putchar('\n');
+
+ printf("char **_sboolnames[] = {\n");
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ printf("\tboolnames + %d,\n", sboolnames[i] - boolnames);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_sboolcodes[] = {\n");
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ printf("\tboolcodes + %d,\n", sboolcodes[i] - boolcodes);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_sboolfnames[] = {\n");
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ printf("\tboolfnames + %d,\n", sboolfnames[i] - boolfnames);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_snumnames[] = {\n");
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ printf("\tnumnames + %d,\n", snumnames[i] - numnames);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_snumcodes[] = {\n");
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ printf("\tnumcodes + %d,\n", snumcodes[i] - numcodes);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_snumfnames[] = {\n");
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ printf("\tnumfnames + %d,\n", snumfnames[i] - numfnames);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_sstrnames[] = {\n");
+ for(i = 0; i < NUM_OF_STRS; i++)
+ printf("\tstrnames + %d,\n", sstrnames[i] - strnames);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_sstrcodes[] = {\n");
+ for(i = 0; i < NUM_OF_STRS; i++)
+ printf("\tstrcodes + %d,\n", sstrcodes[i] - strcodes);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ printf("char **_sstrfnames[] = {\n");
+ for(i = 0; i < NUM_OF_STRS; i++)
+ printf("\tstrfnames + %d,\n", sstrfnames[i] - strfnames);
+ printf(" (char **) 0\n");
+ printf("};\n\n");
+
+ return 0;
+}
diff --git a/lib/libmytinfo/mktermhead.c b/lib/libmytinfo/mktermhead.c
new file mode 100644
index 0000000..f70079b
--- /dev/null
+++ b/lib/libmytinfo/mktermhead.c
@@ -0,0 +1,160 @@
+/*
+ * mktermhead.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/06/04 11:38:57
+ *
+ * mktermhead [-n caps] file
+ *
+ * generates term.head
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+
+const char SCCSid[] = "@(#) mytinfo mktermhead.c 3.3 92/06/04 public domain, By Ross Ridge";
+
+#define DEFAULT_CAPS 1000
+
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ FILE *f;
+ int caps = DEFAULT_CAPS;
+ int n;
+ register int i;
+ int nb, ns, nn;
+ struct caplist *list;
+
+ if (argc > 2 && argv[1][0] == '-' && argv[1][1] == 'n') {
+ caps = atoi(argv[2]);
+ argv += 2;
+ argc -= 2;
+ }
+
+ if (argc == 1) {
+ f = stdin;
+ } else if (argc == 2) {
+ f = fopen(argv[1], "r");
+ if (f == NULL) {
+ fprintf(stderr, "%s: can't open '%s'\n", argv[0],
+ argv[1]);
+ return 1;
+ }
+ } else {
+ fprintf(stderr, "%s: too many arguments\n", argv[0]);
+ fprintf(stderr, "usage: %s [-n caps] [file]\n", argv[0]);
+ return 1;
+ }
+
+ list = (struct caplist *) malloc(caps * sizeof(struct caplist));
+ if (list == NULL) {
+ fprintf(stderr, "%s: malloc failed.\n", argv[0]);
+ return 1;
+ }
+
+ n = readcaps(f, list, caps);
+ if (n > caps) {
+ fprintf(stderr, "%s: too many caps, use -n.\n", argv[0]);
+ return 1;
+ }
+ switch(n) {
+ case 0:
+ fprintf(stderr, "%s: no caps in file.\n", argv[0]);
+ return 1;
+ case -1:
+ fprintf(stderr, "%s: bad caps line.\n", argv[0]);
+ return 1;
+ case -2:
+ fprintf(stderr, "%s: unexpected EOF.\n", argv[0]);
+ return 1;
+ }
+
+ puts("/*");
+ puts(" * term.h ");
+ puts(" *");
+ puts(" * This file was generated automatically.");
+ puts(" *");
+ puts(" */");
+ putchar('\n');
+ puts("#ifndef _TERM_H_");
+ puts("#define _TERM_H_");
+ putchar('\n');
+ nb = 0;
+ for (i = 0; i < n; i++) {
+ if (list[i].type == '!') {
+ printf("#define %-*s (_CUR_TERM.bools[%d])\n",
+ MAX_VARNAME, list[i].var, nb);
+ nb++;
+ }
+ }
+
+ nn = 0;
+ for (i = 0; i < n; i++) {
+ if (list[i].type == '#') {
+ printf("#define %-*s (_CUR_TERM.nums[%d])\n",
+ MAX_VARNAME, list[i].var, nn);
+ nn++;
+ }
+ }
+
+ ns = 0;
+ for (i = 0; i < n; i++) {
+ if (list[i].type == '$') {
+ printf("#define %-*s (_CUR_TERM.strs[%d])\n",
+ MAX_VARNAME, list[i].var, ns);
+ ns++;
+ }
+ }
+
+ putchar('\n');
+
+ printf ("#define NUM_OF_BOOLS\t%d\n", nb);
+ printf ("#define NUM_OF_NUMS\t%d\n", nn);
+ printf ("#define NUM_OF_STRS\t%d\n", ns);
+
+ putchar('\n');
+ puts("#ifndef OVERRIDE");
+ puts("#undef _USE_SGTTY");
+#ifdef USE_SGTTY
+ puts("#define _USE_SGTTY");
+#endif
+ puts("#undef _USE_TERMIO");
+#ifdef USE_TERMIO
+ puts("#define _USE_TERMIO");
+#endif
+ puts("#undef _USE_TERMIOS");
+#ifdef USE_TERMIOS
+ puts("#define _USE_TERMIOS");
+#endif
+ puts("#undef _USE_SMALLMEM");
+#ifdef USE_SMALLMEM
+ puts("#define _USE_SMALLMEM");
+#endif
+ puts("#undef _USE_PROTOTYPES");
+#ifdef USE_PROTOTYPES
+ puts("#define _USE_PROTOTYPES");
+#endif
+ puts("#undef _USE_WINSZ");
+#ifdef USE_WINSZ
+ puts("#define _USE_WINSZ");
+#endif
+ puts("#undef _USE_TERMINFO");
+#ifdef USE_TERMINFO
+ puts("#define _USE_TERMINFO");
+#endif
+ puts("#undef _USE_TERMCAP");
+#ifdef USE_TERMCAP
+ puts("#define _USE_TERMCAP");
+#endif
+ puts("#undef _MAX_CHUNK");
+ printf("#define _MAX_CHUNK %d\n", MAX_CHUNK);
+ puts("#endif /* OVERRIDE */");
+ putchar('\n');
+
+ return 0;
+}
diff --git a/lib/libmytinfo/mkversion.c b/lib/libmytinfo/mkversion.c
new file mode 100644
index 0000000..b34ac73
--- /dev/null
+++ b/lib/libmytinfo/mkversion.c
@@ -0,0 +1,35 @@
+/*
+ * mkversion.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:09
+ *
+ * generates version.c
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+
+#include "version.h"
+
+const char SCCSid[] = "@(#) mytinfo mkversion.c 3.2 92/02/01 public domain, By Ross Ridge";
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ puts("/*");
+ puts(" * version.c ");
+ puts(" *");
+ puts(" * This file was generated automatically.");
+ puts(" *");
+ puts(" */");
+ putchar('\n');
+
+ printf("char _mytinfo_version[] = \"@(#) mytinfo: Release %d, Patchlevel %d (ache).\";\n",
+ RELEASE, PATCHLEVEL);
+
+ return 0;
+}
diff --git a/lib/libmytinfo/quit.c b/lib/libmytinfo/quit.c
new file mode 100644
index 0000000..f30fb50
--- /dev/null
+++ b/lib/libmytinfo/quit.c
@@ -0,0 +1,72 @@
+/*
+ * quit.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:14
+ *
+ * quit with a diagnostic message printed on stderr
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo quit.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+char *prg_name;
+
+#if defined(USE_PROTOTYPES) && !defined(lint)
+void (*cleanup)(int);
+#else
+void (*cleanup)();
+#endif
+
+/* PRINTFLIKE2 */
+noreturn
+#ifdef USE_STDARG
+#ifdef USE_PROTOTYPES
+void
+quit(int e, char *fmt, ...)
+#else
+void quit(e, fmt)
+int e;
+char *fmt;
+#endif
+#else
+void quit(va_alist)
+va_dcl
+#endif
+{
+#ifndef USE_STDARG
+ int e;
+ char *fmt;
+#endif
+ va_list ap;
+
+#ifdef USE_STDARG
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+ e = va_arg(ap, int);
+ fmt = va_arg(ap, char *);
+#endif
+
+ (*cleanup)(e);
+
+ if (e != 0)
+ fprintf(stderr, "%s: ", prg_name);
+#ifdef USE_DOPRNT
+ _doprnt(fmt, ap, stderr);
+#else
+ vfprintf(stderr, fmt, ap);
+#endif
+ putc('\n', stderr);
+ if (e > 0 && e < sys_nerr) {
+ fprintf(stderr, "%d - %s\n", e, sys_errlist[e]);
+ }
+ fflush(stderr);
+ exit(e);
+}
diff --git a/lib/libmytinfo/readcaps.c b/lib/libmytinfo/readcaps.c
new file mode 100644
index 0000000..47a76f8
--- /dev/null
+++ b/lib/libmytinfo/readcaps.c
@@ -0,0 +1,151 @@
+/*
+ * readcaps.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:15
+ *
+ * Read in the cap_list file
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+
+#include <ctype.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo readcaps.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+#ifdef __GNUC__
+__inline__
+#endif
+static int
+skipline(f)
+register FILE *f; {
+ register int c;
+
+ do {
+ c = getc(f);
+ if (c == EOF)
+ return EOF;
+#ifdef TEST
+ putchar(c);
+#endif
+ } while (c != '\n');
+
+ return 0;
+}
+
+#ifdef __GNUC__
+__inline__
+#endif
+static int
+getfield(f, s, len)
+register FILE *f;
+register char *s;
+int len; {
+ register int c;
+ int i;
+#ifdef TEST
+ char *start = s;
+#endif
+
+ do {
+ c = getc(f);
+ if (c == EOF)
+ return EOF;
+ } while (c != '\n' && isspace(c));
+ if (c == '\n')
+ return 0;
+
+ i = 0;
+ while(!isspace(c)) {
+ if (i++ < len)
+ *s++ = c;
+ c = getc(f);
+ if (c == EOF)
+ return EOF;
+
+ }
+ *s = '\0';
+#ifdef TEST
+ printf(" %s", start);
+#endif
+ return c;
+}
+
+int
+readcaps(f, buf, max)
+FILE *f;
+register struct caplist *buf;
+int max; {
+ int type;
+ register int count;
+ int c;
+ static char dummy;
+
+ count = 0;
+ type = getc(f);
+ while(type != EOF) {
+ if (type == '$' || type == '!' || type == '#') {
+ if (count >= max)
+ return count + 1;
+#ifdef TEST
+ putchar(type);
+#endif
+ buf[count].type = type;
+
+ if (type == '$') {
+ c = getc(f);
+ if (c == EOF)
+ break;
+ if (c == 'G')
+ buf[count].flag = 'G';
+ else if (c == 'K')
+ buf[count].flag = 'K';
+ else
+ buf[count].flag = ' ';
+ }
+
+ c = getfield(f, buf[count].var, MAX_VARNAME);
+ if (c == EOF || c == '\n' || c == 0)
+ return -1;
+ c = getfield(f, buf[count].tinfo, MAX_TINFONAME);
+ if (c == EOF || c == '\n' || c == 0)
+ return -1;
+ c = getfield(f, buf[count].tcap, MAX_TCAPNAME);
+ if (c == EOF || c == 0)
+ return -1;
+ if (c != '\n')
+ if (getfield(f, &dummy, 1) != 0)
+ return -1;
+ count++;
+#ifdef TEST
+ putchar('\n');
+#endif
+ } else {
+#ifdef TEST
+ putchar(type);
+#endif
+ if (type != '\n' && skipline(f) == EOF)
+ return -1;
+ }
+ type = getc(f);
+ }
+ return count;
+}
+
+#ifdef TEST
+struct caplist list[1000];
+
+int
+main() {
+ int ret;
+
+ ret = readcaps(stdin, list, 1000);
+ printf("ret = %d\n", ret);
+ return 0;
+}
+#endif
diff --git a/lib/libmytinfo/tcapconv.c b/lib/libmytinfo/tcapconv.c
new file mode 100644
index 0000000..6a28b11
--- /dev/null
+++ b/lib/libmytinfo/tcapconv.c
@@ -0,0 +1,194 @@
+/*
+ * tcapconv.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:20
+ *
+ */
+
+#include "defs.h"
+#define SINGLE
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tcapconv.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+extern char **_sstrcodes[], **_sstrnames[];
+
+static char *C_CR = "\r";
+static char *C_LF = "\n";
+static char *C_BS = "\b";
+/* static char *C_FF = "\f"; */
+static char *C_HT = "\t";
+/* static char *C_VT = "\013"; */
+/* static char *C_NL = "\r\n"; */
+
+#define DEF(s) ((s) != (char *) -1 && (s) != NULL)
+#define NOTSET(s) ((s) == (char *) -1)
+
+/*
+ * This routine fills in caps that either had defaults under termcap or
+ * can be manufactured from obsolete termcap capabilities.
+ */
+
+void
+_tcapdefault() {
+ char buf[MAX_LINE * 2 + 2];
+ int set_scroll_forward_to_lf;
+
+ if (NOTSET(carriage_return)) {
+ if (carriage_return_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
+ carriage_return = _addstr(buf);
+ } else
+ carriage_return = _addstr(C_CR);
+ }
+ if (NOTSET(cursor_left)) {
+ if (backspace_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
+ cursor_left = _addstr(buf);
+ } else if (backspaces_with_bs == 1)
+ cursor_left = _addstr(C_BS);
+ else if (DEF(backspace_if_not_bs))
+ cursor_left = _addstr(backspace_if_not_bs);
+ }
+/* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
+ if (NOTSET(cursor_down)) {
+ if (DEF(linefeed_if_not_lf))
+ cursor_down = _addstr(linefeed_if_not_lf);
+ else if (linefeed_is_newline != 1) {
+ if (new_line_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
+ cursor_down = _addstr(buf);
+ } else
+ cursor_down = _addstr(C_LF);
+ }
+ }
+ set_scroll_forward_to_lf = 0;
+ if (NOTSET(scroll_forward) && crt_without_scrolling != 1) {
+ set_scroll_forward_to_lf = 1;
+ if (DEF(linefeed_if_not_lf))
+ scroll_forward = _addstr(linefeed_if_not_lf);
+ else if (linefeed_is_newline != 1) {
+ if (new_line_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
+ scroll_forward = _addstr(buf);
+ } else
+ scroll_forward = _addstr(C_LF);
+ }
+ }
+ if (NOTSET(newline)) {
+ if (linefeed_is_newline == 1) {
+ if (new_line_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
+ newline = _addstr(buf);
+ } else
+ newline = _addstr(C_LF);
+ } else if (DEF(carriage_return) && carriage_return_delay <= 0) {
+ if (set_scroll_forward_to_lf) {
+ strncpy(buf, carriage_return, MAX_LINE-2);
+ buf[MAX_LINE-1] = '\0';
+ strncat(buf, scroll_forward, MAX_LINE-strlen(buf)-1);
+ } else if (DEF(linefeed_if_not_lf)) {
+ strncpy(buf, carriage_return, MAX_LINE-2);
+ buf[MAX_LINE-1] = '\0';
+ strncat(buf, linefeed_if_not_lf, MAX_LINE-strlen(buf)-1);
+ }
+ else if (new_line_delay > 0)
+ sprintf(buf, "%s%s$<%d>", carriage_return, C_LF, new_line_delay);
+ else {
+ strncpy(buf, carriage_return, MAX_LINE-2);
+ buf[MAX_LINE-1] = '\0';
+ strncat(buf, C_LF, MAX_LINE-strlen(buf)-1);
+ }
+ buf[MAX_LINE-1] = '\0';
+ newline = _addstr(buf);
+ }
+ }
+
+/*
+ * We wait until know to decide if we've got a working cr because even
+ * one that doesn't work can be used for newline. Unfortunately the
+ * space allocated for it is wasted.
+ */
+ if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
+ carriage_return = NULL;
+
+/*
+ * supposedly most termcap entries have ta now and '\t' is no longer a
+ * default, but it doesn't seem to be true...
+ */
+ if (NOTSET(tab)) {
+ if (horizontal_tab_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
+ tab = _addstr(buf);
+ } else
+ tab = _addstr(C_HT);
+ }
+#if 0
+/* probably not needed and might confuse some programmes */
+ if (NOTSET(form_feed)) {
+ if (form_feed_delay > 0) {
+ sprintf(buf, "%s$<%d>", C_FF, form_feed_delay);
+ form_feed = _addstr(buf);
+ } else
+ form_feed = _addstr(C_FF);
+ }
+#endif
+ if (init_tabs == -1 && has_hardware_tabs == 1)
+ init_tabs = 8;
+
+ if (NOTSET(key_backspace))
+ key_backspace = _addstr(C_BS);
+ if (NOTSET(key_left))
+ key_left = _addstr(C_BS);
+ if (NOTSET(key_down))
+ key_down = _addstr(C_LF);
+}
+
+void
+_tcapconv() {
+ char buf[MAX_LINE+1];
+
+ if (GNU_tab_width > 0 && init_tabs == -1)
+ init_tabs = GNU_tab_width;
+
+ if (GNU_has_meta_key == 1 && has_meta_key == -1)
+ has_meta_key = 1;
+
+/*
+ * this is some what a kludge, but should work unless someone breaks
+ * conventions.
+ */
+ if (DEF(other_non_function_keys)) {
+ register char *s;
+ static char *o;
+ static char name[MAX_NAME] = "k";
+ char *str;
+ int ind;
+
+ s = strcpy(buf, other_non_function_keys);
+ while(*s != '\0') {
+ o = s;
+ while(*s != ',' && *s != '\0')
+ s++;
+ if (*s != '\0')
+ *s++ = '\0';
+ ind = _findstrcode(o);
+ if (ind == -1)
+ continue;
+ str = _term_buf.strs[ind];
+ if (!DEF(str))
+ continue;
+ strncpy(name + 1, strnames[ind], MAX_NAME - 2);
+ ind = _findstrname(name);
+ if (ind == -1)
+ continue;
+ if (!NOTSET(_term_buf.strs[ind]))
+ continue;
+ _term_buf.strs[ind] = _addstr(str);
+ }
+ }
+}
diff --git a/lib/libmytinfo/tcapvars.c b/lib/libmytinfo/tcapvars.c
new file mode 100644
index 0000000..52e339c
--- /dev/null
+++ b/lib/libmytinfo/tcapvars.c
@@ -0,0 +1,36 @@
+/*
+ * tcapvars.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:21
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tcapvars.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+char PC;
+short ospeed;
+char *UP, *BC;
+
+void
+_figure_termcap() {
+#if defined(USE_SGTTY) || defined(USE_TERMIO) || defined(USE_TERMIOS)
+#ifdef USE_TERMIOS
+ extern speed_t _baud_tbl[];
+#else
+#ifdef USE_SMALLMEM
+ extern unsigned short _baud_tbl[];
+#else
+ extern long _baud_tbl[];
+#endif
+#endif
+ cur_term->padch = PC;
+ cur_term->baudrate = _baud_tbl[ospeed];
+#endif
+}
diff --git a/lib/libmytinfo/tconv.1 b/lib/libmytinfo/tconv.1
new file mode 100644
index 0000000..e1e91f6
--- /dev/null
+++ b/lib/libmytinfo/tconv.1
@@ -0,0 +1,180 @@
+.\" @(#) mytinfo tconv.1 3.2 92/02/01 public domain, By Ross Ridge
+.TH TCONV 1 "92/02/01" "mytinfo"
+.SH NAME
+tconv \- convert between termcap, terminfo source and terminfo binary
+.SH SYNOPSIS
+.B tconv
+[\fB\-b\fR]
+[\fB\-c\fR\ [\fB\-OUGd\fR]]
+[\fB\-i\fR]
+[\fB\-B\fR\ [\fB\-D\fR\ dir]]
+[\fB\-I\fR]
+[\fB\-k\fR]
+[\fB\-V\fR]
+[\fB\-t\fR\ term]
+[file]
+.br
+.B tic
+[file]
+.br
+.B captoinfo
+[\fB\-t\fR\ term]
+[\fB\-OUGdk\fR]]
+[file]
+.SH DESCRIPTION
+.I tconv
+converts between the three terminal descriptions,
+termcap, terminfo source, and terminfo binary,
+that the
+.I tinfo
+library uses.
+It performs the same functions of
+.IR captoinfo (1M)
+and
+.IR tic (1M)
+of System V.
+It also can be used to generate a terminfo source listing from a terminfo
+binary, one of the functions of System V's
+.IR infocmp (1M).
+.SS Translation Options
+.PD 0
+.TP
+.B \-c
+convert from termcap
+.TP
+.B \-i
+convert from terminfo source
+.TP
+.B \-b
+convert from terminfo binary
+.TP
+.B \-B
+convert to terminfo binary
+.TP
+.B \-I
+convert to terminfo source
+.PD
+.PP
+If a file is specified, one of
+.B \-c
+or
+.B \-i
+must specified and the whole file while be translated.
+If no file is specified then the input options will only restrict looking
+for the terminal to be translated in places likely have descriptions
+of the desired type
+(ie. with the
+.B -c
+option in the
+.B TERMCAP
+environment variable, and in
+.IR /etc/termcap ,
+with the
+.B -i
+option in the
+.B TERMINFO
+environment variable, and in
+.IR /usr/lib/terminfo ),
+otherwise
+.I tconv
+will look in all available databases.
+If neither
+.B \-I
+or
+.B \-B
+are given the
+.B \-I
+option will be assumed.
+If the
+.B \-B
+option is used, the compiled output will be put in the the
+terminfo database, otherwise standard output is used.
+.PP
+You cannot translate from terminfo binary to terminfo binary.
+Translating from terminfo source to terminfo source is possible,
+but not of much use in most cases, as
+.B use=
+fields will be followed and incorporated into the output terminal
+description.
+.PP
+.I tconv
+should be able translate all standard termcap parameterized strings
+terminfo format, but complex strings using GNU's %a code may be
+too hard to translate.
+If
+.I tconv
+thinks a termcap string is already in terminfo format (if a %p
+code appears in the string), it won't try to translate it.
+String capabilities that don't take parameters won't be translated.
+.PP
+.B
+.SS Termcap options
+The following options are available when translating termcap entries
+(\fB\-c\fR options is used).
+.PP
+.PD 0
+.TP
+.B \-d
+don't supply any defaults for missing capabilities
+.TP
+.B \-O
+include obsolete termcap capabilities
+.TP
+.B \-G
+include GNU capabilities
+.TP
+.B \-U
+include UW capabilities
+.PD
+.SS Other Options
+.PD 0
+.TP
+.B \-k
+keep comments when translating a file
+.TP
+.B \-V
+print version information and exit
+.TP
+.BI \-D " " dir
+directory to put terminfo binaries in
+.TP
+.BI \-t " " term
+terminal name to translate
+.PD
+.PP
+If no terminal specified with the
+.B \-t
+option, then the terminal name to to translate will be taken from the
+environment variable
+.BR TERM .
+.SH FILES
+.PD 0
+.TP 2i
+.B /usr/lib/terminfo
+The default location to get and put terminfo binaries.
+.TP
+.B /usr/lib/terminfo/terminfo.src
+The default filename of the terminfo source file.
+.TP
+.B /etc/termcap
+The default filename of the termcap database.
+.PD
+.SH "SEE ALSO"
+captoinfo(1M),
+tic(1M),
+infocmp(1M),
+termcap(3),
+curses(3X),
+term(4),
+termcap(4),
+terminfo(4).
+.SH DIAGNOSTICS
+The line number of a warning message when translating a file
+may refer to the last line of an entry instead of the line in the entry
+that generated the warning.
+.SH BUGS
+More warning messages could be generated.
+.I tconv
+can't translate to termcap. Binaries generated will have cancelled
+capabilities marked as cancelled, which is incompatible with
+System V Release 2.0 terminfo.
diff --git a/lib/libmytinfo/tconv.c b/lib/libmytinfo/tconv.c
new file mode 100644
index 0000000..55996d4
--- /dev/null
+++ b/lib/libmytinfo/tconv.c
@@ -0,0 +1,1384 @@
+/*
+ * tconv.c
+ *
+ * Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:23
+ *
+ * tconv [-b] [-c [-OUGd]] [-i] [-B [-D dir]] [-I] [-k] [-V] [-t term] [file]
+ *
+ * -c convert from termcap
+ * -i convert from terminfo source
+ * -b convert from terminfo binary
+ * -B convert to terminfo binary
+ * -I convert to terminfo source
+ * -V print version info
+ *
+ * The following switches are available when converting from termcap:
+ * -d don't supply any defaults for missing capabilities
+ * -O include obsolete termcap capabilities
+ * -G include GNU capabilities
+ * -U include UW capabilities
+ *
+ * -k keep comments
+ * -D dir directory to put terminfo binaries in
+ *
+ * -t term name of terminal to translate
+ * file filename of termcap/terminfo database to use
+ *
+ * If a file is specifed and no terminal is given the entire file we be
+ * translated.
+ * If no terminal and no file is specified then the terminal name will be
+ * taken from the environment variable TERM.
+ * Unless compiling to a terminfo binary, output is to stdout.
+ *
+ */
+
+#define NOTLIB
+#include "defs.h"
+#define SINGLE
+#include <term.h>
+
+#include <ctype.h>
+#include <fcntl.h>
+#ifdef USE_STDDEF
+#include <sys/types.h>
+#endif
+#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <unistd.h>
+#endif
+
+#ifndef __FreeBSD__
+#include "strtok.c"
+#include "mkdir.c"
+#endif
+
+#ifndef lint
+static const char SCCSid[] = "@(#) mytinfo tconv.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+extern int errno;
+
+/* the right margin of the output */
+#define LINELEN 76
+
+struct term_path *path; /* returned from _buildpath */
+
+TERMINAL _term_buf;
+char buf[MAX_BUF+1]; /* buffer for the termcap entry */
+
+int noOT = 1; /* -O */
+int noGNU = 1; /* -G */
+int noUW = 1; /* -W */
+int dodefault = 1; /* -d */
+int keepcomments = 0; /* -k */
+int compile = 0; /* -B */
+int from_tcap = 0; /* -c */
+int from_tinfo = 0; /* -i */
+int from_tbin = 0; /* -b */
+char *directory = NULL; /* -D */
+
+int continued = 0;
+int termcap = 1;
+
+int lineno = 0; /* current line number */
+
+/* print the first part of a warning message */
+void
+warn() {
+ if (lineno == 0)
+ fprintf(stderr, "warning: ");
+ else
+ fprintf(stderr, "(%s)%d: warning: ",
+ _term_buf.name_long, lineno);
+}
+
+/* output a string indenting at the beginning of a line, and wraping
+ * at the right margin.
+ */
+void
+putstr(s)
+char *s; {
+ static pos = 0;
+ int l;
+
+ if (s == NULL) {
+ if (pos != 0) {
+ pos = 0;
+ putchar('\n');
+ }
+ return;
+ }
+
+ if (termcap && noOT && *s == 'O')
+ return;
+ if (termcap && noGNU && *s == 'G')
+ return;
+ if (termcap && noUW && *s == 'U')
+ return;
+
+ l = strlen(s) + 2;
+
+ if (l + pos > LINELEN && pos != 0) {
+ putchar('\n');
+ pos = 0;
+ }
+
+ if (pos == 0) {
+ putchar('\t');
+ pos = 8;
+ } else
+ putchar(' ');
+
+ printf("%s,", s);
+
+ pos += l;
+}
+
+#ifndef MAX_PUSHED
+/* maximum # of parameters that can be pushed onto the stack */
+#define MAX_PUSHED 16
+#endif
+
+int stack[MAX_PUSHED]; /* the stack */
+int stackptr; /* the next empty place on the stack */
+int onstack; /* the top of stack */
+int seenm; /* seen a %m */
+int seenn; /* seen a %n */
+int seenr; /* seen a %r */
+int param; /* current parameter */
+char *dp; /* pointer to the end of the converted string */
+
+/* push onstack on to the stack */
+void
+push() {
+ if (stackptr > MAX_PUSHED) {
+ warn();
+ fprintf(stderr, "string to complex to covert\n");
+ } else
+ stack[stackptr++] = onstack;
+}
+
+/* pop the top of the stack into onstack */
+void
+pop() {
+ if (stackptr == 0)
+ if (onstack == 0) {
+ warn();
+ fprintf(stderr, "I'm confused\n");
+ } else
+ onstack = 0;
+ else
+ onstack = stack[--stackptr];
+ param++;
+}
+
+/* convert a character to a terminfo push */
+static int
+cvtchar(sp)
+register char *sp; {
+ char c;
+ int l;
+
+ switch(*sp) {
+ case '\\':
+ switch(*++sp) {
+ case '\'':
+ case '$':
+ case '\\':
+ case '%':
+ c = *sp;
+ l = 2;
+ break;
+ case '\0':
+ c = '\\';
+ l = 1;
+ break;
+ case '0':
+ if (sp[1] == '0' && sp[2] == '0') {
+ c = '\0';
+ l = 4;
+ } else {
+ c = '\200'; /* '\0' ???? */
+ l = 2;
+ }
+ break;
+ default:
+ c = *sp;
+ l = 2;
+ break;
+ }
+ break;
+ default:
+ c = *sp;
+ l = 1;
+ }
+ c &= 0177;
+ if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
+ *dp++ = '%'; *dp++ = '\''; *dp++ = c; *dp++ = '\'';
+ } else {
+ *dp++ = '%'; *dp++ = '{';
+ if (c > 99)
+ *dp++ = c / 100 + '0';
+ if (c > 9)
+ *dp++ = (c / 10) % 10 + '0';
+ *dp++ = c % 10 + '0';
+ *dp++ = '}';
+ }
+ return l;
+}
+
+/* push n copies of param on the terminfo stack if not already there */
+void
+getparm(parm, n)
+int parm;
+int n; {
+ if (seenr) {
+ if (parm == 1)
+ parm = 2;
+ else if (parm == 2)
+ parm = 1;
+ }
+ if (onstack == parm) {
+ if (n > 1) {
+ warn();
+ fprintf(stderr, "string may not be optimal");
+ *dp++ = '%'; *dp++ = 'P'; *dp++ = 'a';
+ while(n--) {
+ *dp++ = '%'; *dp++ = 'g'; *dp++ = 'a';
+ }
+ }
+ return;
+ }
+ if (onstack != 0)
+ push();
+
+ onstack = parm;
+
+ while(n--) { /* %p0 */
+ *dp++ = '%'; *dp++ = 'p'; *dp++ = '0' + parm;
+ }
+
+ if (seenn && parm < 3) { /* %{96}%^ */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '9'; *dp++ = '6'; *dp++ = '}';
+ *dp++ = '%'; *dp++ = '^';
+ }
+
+ if (seenm && parm < 3) { /* %{127}%^ */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '1'; *dp++ = '2'; *dp++ = '7';
+ *dp++ = '}'; *dp++ = '%'; *dp++ = '^';
+ }
+}
+
+/* convert a string to terminfo format */
+char *
+convstr(s, i)
+register char *s;
+int i; {
+ static char line[MAX_LINE];
+ register char *cap;
+ int nocode = 0;
+
+ stackptr = 0;
+ onstack = 0;
+ seenm = 0;
+ seenn = 0;
+ seenr = 0;
+ param = 1;
+
+ dp = line;
+ cap = strnames[i];
+#if 0
+ if (cap[0] == 'k'
+ || ((cap[0] == 'i' || cap[0] == 'r') && cap[1] == 's'
+ && (cap[2] == '1' || cap[2] == '2' || cap[2] == '3')))
+ /* if (k.* || [ir]s[123]) */
+ nocode = 1;
+#else
+ if (_strflags[i] != 'G')
+ nocode = 1;
+#endif
+ if (!nocode) {
+ char *d = s;
+ while(*s != '\0') {
+ if (s[0] == '\\' && s[1] != '\0')
+ s++;
+ else if (s[0] == '%' && s[1] != '\0') {
+ if (s[1] == 'p') {
+ if (termcap) {
+ warn();
+ fprintf(stderr,
+"string '%s' already in terminfo format\n", strcodes[i]);
+ nocode = 1;
+ break;
+ } else
+ nocode = 1;
+ }
+ s++;
+ }
+ s++;
+ }
+ if (!nocode && !termcap) {
+ warn();
+ fprintf(stderr,
+"string '%s' not in terminfo format, converting...\n", cap);
+ }
+ s = d;
+ }
+ while(*s != '\0') {
+ switch(*s) {
+ case '%':
+ s++;
+ if (nocode) {
+ *dp++ = '%';
+ break;
+ }
+ switch(*s++) {
+ case '%': *dp++ = '%'; break;
+ case 'r':
+ if (seenr++ == 1) {
+ warn();
+ fprintf(stderr, "seen %%r twice\n");
+ }
+ break;
+ case 'm':
+ if (seenm++ == 1) {
+ warn();
+ fprintf(stderr, "seen %%m twice\n");
+ }
+ break;
+ case 'n':
+ if (seenn++ == 1) {
+ warn();
+ fprintf(stderr, "seen %%n twice\n");
+ }
+ break;
+ case 'i': *dp++ = '%'; *dp++ = 'i'; break;
+ case '6':
+ case 'B':
+ getparm(param, 2);
+ /* %{6}%*%+ */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '6';
+ *dp++ = '}'; *dp++ = '%'; *dp++ = '*';
+ *dp++ = '%'; *dp++ = '+';
+ break;
+ case '8':
+ case 'D':
+ getparm(param, 2);
+ /* %{2}%*%- */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '2';
+ *dp++ = '}'; *dp++ = '%'; *dp++ = '*';
+ *dp++ = '%'; *dp++ = '-';
+ break;
+ case '>':
+ getparm(param, 2);
+ /* %?%{x}%>%t%{y}%+%; */
+ *dp++ = '%'; *dp++ = '?';
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '>';
+ *dp++ = '%'; *dp++ = 't';
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '+';
+ *dp++ = '%'; *dp++ = ';';
+ break;
+ case 'a':
+ if ((*s == '=' || *s == '+' || *s == '-'
+ || *s == '*' || *s == '/')
+ && (s[1] == 'p' || s[1] == 'c')
+ && s[2] != '\0') {
+ int l;
+ l = 2;
+ if (*s != '=')
+ getparm(param, 1);
+ if (s[1] == 'p') {
+ getparm(param + s[2] - '@', 1);
+ if (param != onstack) {
+ pop();
+ param--;
+ }
+ l++;
+ } else
+ l += cvtchar(s + 2);
+ switch(*s) {
+ case '+':
+ *dp++ = '%'; *dp++ = '+';
+ break;
+ case '-':
+ *dp++ = '%'; *dp++ = '-';
+ break;
+ case '*':
+ *dp++ = '%'; *dp++ = '*';
+ break;
+ case '/':
+ *dp++ = '%'; *dp++ = '/';
+ break;
+ case '=':
+ if (seenr)
+ if (param == 1)
+ onstack = 2;
+ else if (param == 2)
+ onstack = 1;
+ else
+ onstack = param;
+ else
+ onstack = param;
+ break;
+ }
+ s += l;
+ break;
+ }
+ getparm(param, 1);
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '+';
+ break;
+ case '+':
+ getparm(param, 1);
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '+';
+ *dp++ = '%'; *dp++ = 'c';
+ pop();
+ break;
+ case 's':
+ s += cvtchar(s);
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = '-';
+ break;
+ case '-':
+ s += cvtchar(s);
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = '-';
+ *dp++ = '%'; *dp++ = 'c';
+ pop();
+ break;
+ case '.':
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = 'c';
+ pop();
+ break;
+ case '2':
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = '0';
+ *dp++ = '2'; *dp++ = 'd';
+ pop();
+ break;
+ case '3':
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = '0';
+ *dp++ = '3'; *dp++ = 'd';
+ pop();
+ break;
+ case 'd':
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = 'd';
+ pop();
+ break;
+ case 'f':
+ param++;
+ break;
+ case 'b':
+ param--;
+ break;
+ default:
+ warn();
+ *dp++ = '%';
+ s--;
+ fprintf(stderr, "'%s' unknown %% code %c",
+ strcodes[i], *s);
+ if (*s >= 0 && *s < 32)
+ fprintf(stderr, "^%c\n", *s + '@');
+ else if (*s < 0 || *s >= 127)
+ fprintf(stderr, "\\%03o\n", *s & 0377);
+ else
+ fprintf(stderr, "%c\n", *s);
+ break;
+ }
+ break;
+ case '\\':
+ if (!compile) {*dp++ = *s++; *dp++ = *s++; break;}
+ /* FALLTHROUGH */
+ case '\n':
+ if (!compile) {*dp++ = '\\'; *dp++ = 'n'; s++; break;}
+ /* FALLTHROUGH */
+ case '\t':
+ if (!compile) {*dp++ = '\\'; *dp++ = 't'; s++; break;}
+ /* FALLTHROUGH */
+ case '\r':
+ if (!compile) {*dp++ = '\\'; *dp++ = 'r'; s++; break;}
+ /* FALLTHROUGH */
+ case '\200':
+ if (!compile) {*dp++ = '\\'; *dp++ = '0'; s++; break;}
+ /* FALLTHROUGH */
+ case '\f':
+ if (!compile) {*dp++ = '\\'; *dp++ = 'f'; s++; break;}
+ /* FALLTHROUGH */
+ case '\b':
+ if (!compile) {*dp++ = '\\'; *dp++ = 'b'; s++; break;}
+ /* FALLTHROUGH */
+ case ' ':
+ if (!compile) {*dp++ = '\\'; *dp++ = 's'; s++; break;}
+ /* FALLTHROUGH */
+ case '^':
+ if (!compile) {*dp++ = '\\'; *dp++ = '^'; s++; break;}
+ /* FALLTHROUGH */
+ case ':':
+ if (!compile) {*dp++ = '\\'; *dp++ = ':'; s++; break;}
+ /* FALLTHROUGH */
+ case ',':
+ if (!compile) {*dp++ = '\\'; *dp++ = ','; s++; break;}
+ /* FALLTHROUGH */
+#if 0
+ case '\'':
+ if (!compile) {*dp++ = '\\'; *dp++ = '\''; s++; break;}
+ /* FALLTHROUGH */
+#endif
+ default:
+ if (compile)
+ *dp++ = *s++;
+ else if (*s > 0 && *s < 32) {
+ *dp++ = '^';
+ *dp++ = *s + '@';
+ s++;
+ } else if (*s <= 0 || *s >= 127) {
+ *dp++ = '\\';
+ *dp++ = ((*s & 0300) >> 6) + '0';
+ *dp++ = ((*s & 0070) >> 3) + '0';
+ *dp++ = (*s & 0007) + '0';
+ s++;
+ } else
+ *dp++ = *s++;
+ break;
+ }
+ }
+ *dp = '\0';
+ return line;
+}
+
+#define LSB(n) ((unsigned) (n) & 0377)
+#define MSB(n) (((unsigned) (n) >> 8) & 0377)
+
+void
+writebin(fd, name)
+int fd;
+char *name; {
+ static char bin[MAX_BUF + 1];
+ register char *s;
+ register char *d;
+ register int i;
+ register char *t;
+ register int n;
+ char *strtbl;
+ int sz_name, n_bools, n_nums, n_offs, sz_strs;
+ extern int _boolorder[], _numorder[], _strorder[];
+
+ strncpy(bin + 12, name, 127);
+ bin[12 + 128] = '\0';
+ sz_name = strlen(name) + 1;
+ if (sz_name > 128)
+ sz_name = 128;
+
+ s = bin + 12 + sz_name;
+ for(i = 0; _boolorder[i] != -1; i++) {
+ switch(_term_buf.bools[i]) {
+ case -1: *s++ = 0; break;
+ case 0: *s++ = 0377; break;
+ default: *s++ = 1; break;
+ }
+ }
+ n_bools = i;
+ if ((sz_name + n_bools) & 1)
+ n_bools++;
+
+ s = bin + 12 + sz_name + n_bools;
+ for(i = 0; _numorder[i] != -1; i++) {
+ n = _term_buf.nums[_numorder[i]];
+ switch(n) {
+ case -2: *s++ = 0377; *s++ = 0377; break;
+ case -1: *s++ = 0376; *s++ = 0377; break;
+ default:
+ *s++ = LSB(n);
+ *s++ = MSB(n);
+ }
+ }
+ n_nums = i;
+
+ s = bin + 12 + sz_name + n_bools + n_nums * 2;
+ for(i = 0; _strorder[i] != -1; i++) {
+ if (_term_buf.strs[_strorder[i]] == (char *) 0) {
+ *s++ = 0376; *s++ = 0377;
+ } else {
+ *s++ = 0377; *s++ = 0377;
+ }
+ }
+ n_offs = i;
+
+ s = bin + 12 + sz_name + n_bools + n_nums * 2;
+ strtbl = d = s + n_offs * 2;
+ for(i = 0; _strorder[i] != -1; i++) {
+ t = _term_buf.strs[_strorder[i]];
+ if (t == (char *) -1 || t == (char *) 0)
+ s += 2;
+ else {
+ n = d - strtbl;
+ *s++ = LSB(n);
+ *s++ = MSB(n);
+ t = convstr(t, _strorder[i]);
+ while(*t != '\0') {
+ *d++ = *t++;
+ if (d >= bin + MAX_BUF - 1) {
+ warn();
+ fprintf(stderr,
+ "compiled entry to big\n");
+ *d++ = '\0';
+ goto toobig;
+ }
+ }
+ *d++ = '\0';
+ }
+ }
+
+toobig:
+ sz_strs = d - strtbl;
+
+ bin[0] = 032;
+ bin[1] = 01;
+ bin[2] = LSB(sz_name);
+ bin[3] = MSB(sz_name);
+ bin[4] = LSB(n_bools);
+ bin[5] = MSB(n_bools);
+ bin[6] = LSB(n_nums);
+ bin[7] = MSB(n_nums);
+ bin[8] = LSB(n_offs);
+ bin[9] = MSB(n_offs);
+ bin[10] = LSB(sz_strs);
+ bin[11] = MSB(sz_strs);
+
+ if (write(fd, bin, d - bin) == -1)
+ quit(errno, "can't write binary file");
+
+ return;
+}
+
+void
+find_directory() {
+ struct term_path *p;
+ struct stat st;
+
+ if (directory != NULL)
+ return;
+
+ p = path;
+ while(p->type != -1 && p->file != NULL) {
+ if (stat(p->file, &st) == 0) {
+ if ((st.st_mode & 0170000) == 0040000) {
+ directory = p->file;
+ return;
+ }
+ }
+ p++;
+ }
+ quit(-1, "can't find a terminfo directory");
+}
+
+/* convert a terminal name to a binary filename */
+char *
+binfile(name)
+char *name; {
+ static char line[MAX_LINE+1];
+
+ sprintf(line, "%s/%c/%s", directory, *name, name);
+ return line;
+}
+
+char *
+bindir(name)
+char *name; {
+ static char line[MAX_LINE+1];
+
+ sprintf(line, "%s/%c", directory, *name);
+ return line;
+}
+
+int
+badname(name)
+char *name; {
+ while(*name) {
+ if (*name == '/' || !isgraph(*name))
+ return 1;
+ name++;
+ }
+ return 0;
+}
+
+/* output a terminfo binary */
+void
+outputbin(name)
+char *name; {
+ register char *s, *d, *last;
+ char tmp[MAX_LINE+1];
+ char line[MAX_LINE+1];
+ int fd;
+
+ find_directory();
+
+ s = name;
+ d = line;
+ while(*s != '\0' && d < line + MAX_LINE) {
+ *d++ = *s++;
+ }
+
+ while(d > line && d[-1] == '|') {
+ d--;
+ }
+
+ *d = '\0';
+
+ s = strtok(line, "|");
+ last = NULL;
+
+ while(s != NULL && last == NULL) {
+ if (*s == '\0') {
+ ;
+ } else if (badname(s)) {
+ if (lineno)
+ warn();
+ fprintf(stderr, "bad terminal name '%s', ingored.\n",
+ s);
+ } else {
+ if (access(bindir(s), 2) == -1) {
+ if (errno != ENOENT)
+ quit(errno,
+ "can't access directory '%s'",
+ bindir(s));
+ if (mkdir(bindir(s), 0777) == -1)
+ quit(errno, "can't make directory '%s'",
+ bindir(s));
+ }
+ fd = open(binfile(s), O_WRONLY | O_CREAT | O_EXCL,
+ 0666);
+ if (fd == -1) {
+ if (errno != EEXIST)
+ quit(errno, "can't open file '%s'",
+ binfile(s));
+ if (unlink(binfile(s)) == -1)
+ quit(errno, "can't unlink file '%s'",
+ binfile(s));
+ fd = open(binfile(s),
+ O_WRONLY | O_CREAT | O_EXCL, 0666);
+ if (fd == -1)
+ quit(errno, "can't create file '%s'",
+ binfile(s));
+ }
+ writebin(fd, name);
+ close(fd);
+ last = s;
+ }
+ s = strtok(NULL, "|");
+ }
+
+ if (last == NULL) {
+ if (lineno)
+ warn();
+ fprintf(stderr, "no terminal name, entry ignored.\n");
+ return;
+ }
+
+ while(s != NULL && s + strlen(s) != d) {
+ if (*s == '\0' || strcmp(s, last) == 0) {
+ ;
+ } else if (badname(s)) {
+ if (lineno)
+ warn();
+ fprintf(stderr, "bad terminal name '%s', ingored.\n",
+ s);
+ } else {
+ if (access(bindir(s), 2) == -1) {
+ if (errno != ENOENT)
+ quit(errno,
+ "can't access directory '%s'",
+ bindir(s));
+ if (mkdir(bindir(s), 0777) == -1)
+ quit(errno, "can't make directory '%s'",
+ bindir(s));
+ }
+ if (access(binfile(s), 0) == -1) {
+ if (errno != ENOENT)
+ quit(errno, "can't access file '%s'",
+ binfile(s));
+ } else if (unlink(binfile(s)) == -1) {
+ quit(errno, "can't unlink file '%s'",
+ binfile(s));
+ }
+ strcpy(tmp, binfile(last));
+ if (link(tmp, binfile(s)) == -1) {
+ quit(errno, "can't link '%s' to '%s'",
+ last, binfile(s));
+ }
+ }
+ s = strtok(NULL, "|");
+ }
+ return;
+}
+
+/* output an entry in terminfo source format */
+void
+outputinfo(name)
+char *name; {
+ int i;
+ char line[MAX_LINE];
+
+ printf("%s,\n", name);
+
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ if (_term_buf.bools[i] == 0) {
+ sprintf(line, "%s@", boolnames[i]);
+ putstr(line);
+ } else if (_term_buf.bools[i] != -1)
+ putstr(boolnames[i]);
+
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ if (_term_buf.nums[i] == -1) {
+ sprintf(line, "%s@", numnames[i]);
+ putstr(line);
+ } else if (_term_buf.nums[i] != -2) {
+ sprintf(line, "%s#%d", numnames[i], _term_buf.nums[i]);
+ putstr(line);
+ }
+
+ for(i = 0; i < NUM_OF_STRS; i++)
+ if (_term_buf.strs[i] == NULL) {
+ sprintf(line, "%s@", strnames[i]);
+ putstr(line);
+ } else if (_term_buf.strs[i] != (char *) -1) {
+ sprintf(line, "%s=%s", strnames[i],
+ convstr(_term_buf.strs[i], i));
+ putstr(line);
+ }
+ putstr(NULL);
+}
+
+/* convert a terminfo entry to binary format */
+void
+convtinfo() {
+ int i, r;
+
+ termcap = 0;
+
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ _term_buf.bools[i] = -1;
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ _term_buf.nums[i] = -2;
+ for(i = 0; i < NUM_OF_STRS; i++)
+ _term_buf.strs[i] = (char *) -1;
+
+ _term_buf.name_all = NULL;
+
+ r = _gettinfo(buf, &_term_buf, path);
+ if (r != 0) {
+ if (lineno == 0)
+ quit(-1, "problem reading entry");
+ else {
+ warn();
+ fprintf(stderr, "problem reading entry\n");
+ }
+ }
+
+ if (compile)
+ outputbin(_term_buf.name_all);
+ else
+ outputinfo(_term_buf.name_all);
+ return;
+}
+
+/* convert a terminfo binary to terminfo source */
+void
+convtbin() {
+ int i, r;
+
+ termcap = 0;
+
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ _term_buf.bools[i] = -1;
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ _term_buf.nums[i] = -2;
+ for(i = 0; i < NUM_OF_STRS; i++)
+ _term_buf.strs[i] = (char *) -1;
+
+ _term_buf.name_all = NULL;
+
+ r = _gettbin(buf, &_term_buf);
+ if (r != 0) {
+ if (lineno == 0)
+ quit(-1, "problem reading entry");
+ else {
+ warn();
+ fprintf(stderr, "problem reading entry\n");
+ }
+ }
+
+ outputinfo(_term_buf.name_all);
+
+ return;
+}
+
+/* convert a termcap entry to terminfo format */
+void
+convtcap() {
+ int i, r;
+ char *name;
+
+ termcap = 1;
+
+ for(i = 0; i < NUM_OF_BOOLS; i++)
+ _term_buf.bools[i] = -1;
+ for(i = 0; i < NUM_OF_NUMS; i++)
+ _term_buf.nums[i] = -2;
+ for(i = 0; i < NUM_OF_STRS; i++)
+ _term_buf.strs[i] = (char *) -1;
+
+ _term_buf.name_all = NULL;
+
+
+#if DEBUG
+ printf("%s\n", buf);
+#endif
+ r = _gettcap(buf, &_term_buf, path);
+ if (r != 0) {
+ if (lineno == 0)
+ quit(-1, "problem reading entry");
+ else {
+ warn();
+ fprintf(stderr, "problem reading entry\n");
+ }
+ }
+
+ if (dodefault && !continued)
+ _tcapdefault();
+
+ _tcapconv();
+
+ name = _term_buf.name_all;
+#if DEBUG
+ printf("...%s\n", name);
+#endif
+ if (name[0] != '\0' && name[1] != '\0' && name[2] == '|')
+ name += 3; /* skip the 2 letter code */
+
+ if (compile)
+ outputbin(name);
+ else
+ outputinfo(name);
+}
+
+void
+convbinfile(file)
+char *file; {
+ register FILE *f;
+ int r;
+
+ f = fopen(file, "r");
+
+ if (f == NULL)
+ quit(errno, "can't open '%s'", file);
+
+ r = fread(buf, sizeof(char), MAX_BUF, f);
+ if (r < 12 || buf[0] != 032 || buf[1] != 01)
+ quit(-1, "file '%s' corrupted", file);
+
+ convtbin();
+}
+
+/* convert a termcap file to terminfo format */
+void
+convtcfile(file)
+char *file; {
+ int nocolon;
+ register int c;
+ register char *d;
+ register FILE *f;
+
+ f = fopen(file, "r");
+
+ if (f == NULL)
+ quit(errno, "can't open '%s'", file);
+
+ d = buf;
+ c = getc(f);
+ while(c != EOF) {
+ lineno++;
+ if (c == '#') {
+ if (keepcomments) {
+ do {
+ putchar(c);
+ c = getc(f);
+ } while(c != '\n' && c != EOF);
+ putchar('\n');
+ } else
+ do
+ c = getc(f);
+ while(c != '\n' && c != EOF);
+ if (c != EOF)
+ c = getc(f);
+ continue;
+ }
+ while(isspace(c) && c != '\n')
+ c = getc(f);
+ if (c == '\n' && buf == d) {
+ c = getc(f);
+ continue;
+ }
+
+ while(c != EOF) {
+ if (c == '\\') {
+ c = getc(f);
+ if (c == EOF)
+ break;
+ if (c == '\n') {
+ c = getc(f);
+ break;
+ }
+ *d++ = '\\';
+ *d++ = c;
+ } else if (c == '\n') {
+ *d = '\0';
+ if (*--d == ':') {
+ nocolon = 0;
+ *d-- = '\0';
+ } else {
+ nocolon = 1;
+ }
+ while(d > buf && *d != ':')
+ d--;
+ if (d[1] == 't' && d[2] == 'c' && d[3] == '=') {
+ continued = 1;
+ d[1] = '\0';
+ } else
+ continued = 0;
+ convtcap();
+ if (nocolon) {
+ warn();
+ fprintf(stderr,
+ "entry doesn't end with :\n");
+ }
+ _term_buf.strbuf = _endstr();
+ _del_strs(&_term_buf);
+ if (continued) {
+ printf("\tuse=%s,\n", d + 4);
+ }
+ d = buf;
+ c = getc(f);
+ break;
+ } else
+ *d++ = c;
+ c = getc(f);
+ }
+ }
+}
+
+static int
+getln(f, buf, len)
+FILE *f;
+register char *buf;
+int len; {
+ register int c, i = 0;
+
+ while((c = getc(f)) == '#') {
+ lineno++;
+ if (keepcomments) {
+ putchar('#');
+ while((c = getc(f)) != '\n') {
+ if (c == EOF)
+ return -1;
+ putchar(c);
+ }
+ putchar('\n');
+ } else {
+ while((c = getc(f)) != '\n')
+ if (c == EOF)
+ return -1;
+ }
+ }
+
+ lineno++;
+ while(c != '\n') {
+ if (c == EOF)
+ return -1;
+ if (i < len) {
+ i++;
+ *buf++ = c;
+ }
+ c = getc(f);
+ }
+
+ while(isspace(*(buf-1))) {
+ buf--;
+ i--;
+ }
+
+ *buf = '\0';
+ return i;
+}
+
+void
+convtifile(file)
+char *file; {
+ static char line[MAX_LINE+1];
+ int l;
+ int n;
+ register FILE *f;
+
+ f = fopen(file, "r");
+
+ if (f == NULL)
+ quit(errno, "can't open '%s'", file);
+
+ lineno = 0;
+
+ l = getln(f, line, MAX_LINE);
+ while(l != -1) {
+ if (line[l-1] == ':') {
+ strncpy(buf, line, MAX_BUF);
+ convtcap();
+ } else if (line[l-1] == '\\') {
+ n = MAX_BUF;
+ do {
+ line[--l] = '\0';
+ if (n > 0)
+ strncpy(buf + MAX_BUF - n, line, n);
+ n -= l;
+ l = getln(f, line, MAX_LINE);
+ } while(l != -1 && line[l-1] == '\\');
+ if (n > 0 && l != -1)
+ strncpy(buf + MAX_BUF - n, line, n);
+ convtcap();
+ } else if (line[l-1] == ',') {
+ n = MAX_BUF;
+ do {
+ if (n > 0)
+ strncpy(buf + MAX_BUF - n, line, n);
+ n -= l;
+ l = getln(f, line, MAX_LINE);
+ } while(l != -1 && isspace(line[0]));
+#if 0
+ printf("buf = '%s'\n", buf);
+#endif
+ convtinfo();
+ continue;
+ } else if (line[0] != '\0') {
+ warn();
+ fprintf(stderr, "malformed line\n");
+ if (keepcomments) {
+ printf("%s\n", line);
+ }
+ }
+ l = getln(f, line, MAX_LINE);
+ }
+ return;
+}
+
+/* dummy routine for quit */
+/* ARGSUSED */
+void
+do_cleanup(e)
+int e; {
+ return;
+}
+
+/* print out usage, called by quit */
+/* ARGSUSED */
+void
+usage(e)
+int e; {
+ fprintf(stderr,
+"usage: %s [-b] [-c [-OUGd]] [-i] [-B [-D dir]] [-I] [-k] [-V]\n\t[-t term] [file]\n",
+ prg_name);
+ return;
+}
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ extern char *optarg;
+ extern int optind;
+ extern int opterr;
+ char *term = NULL;
+ char *file = NULL;
+ int r;
+ char c;
+ int pversion = 0;
+
+ prg_name = strrchr(argv[0], '/');
+ if (prg_name == NULL)
+ prg_name = argv[0];
+ else
+ prg_name++;
+
+ cleanup = usage;
+
+ opterr = 0;
+
+ if (strcmp(prg_name, "tic") == 0)
+ compile = 1;
+
+ while ((c = getopt(argc, argv, "bciBIOGUdkVD:t:")) != -1) {
+ switch(c) {
+ case 'O':
+ noOT = 0;
+ break;
+ case 'G':
+ noGNU = 0;
+ break;
+ case 'U':
+ noUW = 0;
+ break;
+ case 'D':
+ if (directory != NULL)
+ quit(-1, "more than one directory specified");
+ directory = optarg;
+ break;
+ case 't':
+ if (term != NULL)
+ quit(-1, "more than one terminal specified");
+ term = optarg;
+ break;
+ case 'd': dodefault = 0; break;
+ case 'k': keepcomments = 1; break;
+ case 'b': from_tbin = 1; break;
+ case 'c': from_tcap = 1; break;
+ case 'i': from_tinfo = 1; break;
+ case 'B': compile = 1; break;
+ case 'I': compile = 0; break;
+ case 'V': pversion = 1; break;
+ case '?':
+ default:
+ quit(-1, "bad or missing command line argument");
+ }
+ }
+
+ if (pversion) {
+ quit(0, "%s\n%s", _mytinfo_version, SCCSid);
+ }
+
+ if (optind == argc - 1)
+ file = argv[optind];
+ else if (optind != argc)
+ quit(-1, "wrong number of arguments");
+
+ if (from_tbin + from_tcap + from_tinfo > 1)
+ quit(-1, "more than one input file type specified");
+
+ if (!from_tcap && !from_tinfo && !from_tbin && file != NULL) {
+ if (strcmp(prg_name, "cap2info") == 0
+ || strcmp(prg_name, "captoinfo") == 0)
+ from_tcap = 1;
+ else if (strcmp(prg_name, "tic") == 0)
+ from_tinfo = 1;
+ else
+ quit(-1, "no input file type specified");
+ }
+
+ if (from_tbin && compile)
+ quit(-1, "can't convert from binary to binary");
+
+ if (file != NULL) {
+ if (from_tbin) {
+ cleanup = do_cleanup;
+ convbinfile(file);
+ exit(0);
+ }
+ if (!compile)
+ path = _buildpath(file, 0, NULL, -1);
+ else {
+ path = _buildpath(file, 0,
+ "$TERMINFO", 2,
+ "$MYTERMINFO", 2,
+#ifdef TERMINFODIR
+ TERMINFODIR, 0,
+#endif
+ NULL, -1);
+ }
+ if (path == NULL)
+ quit(-1, "can't build path");
+ if (term == NULL) {
+ cleanup = do_cleanup;
+ if (from_tcap && !compile)
+ convtcfile(file);
+ else
+ convtifile(file);
+ exit(0);
+ }
+ } else if (from_tcap && !compile)
+ path = _buildpath("$TERMCAP", 1,
+#ifdef TERMCAPFILE
+ TERMCAPFILE, 0,
+#endif
+ NULL, -1);
+ else if (from_tinfo || from_tbin)
+ path = _buildpath("$TERMINFO", 2,
+ "$MYTERMINFO", 2,
+#ifdef TERMINFODIR
+ TERMINFODIR, 0,
+#endif
+#ifdef TERMINFOSRC
+ TERMINFOSRC, 0,
+#endif
+ NULL, -1);
+ else if (from_tcap)
+ path = _buildpath("$TERMCAP", 1,
+#ifdef TERMCAPFILE
+ TERMCAPFILE, 0,
+#endif
+ "$TERMINFO", 2,
+ "$MYTERMINFO", 2,
+#ifdef TERMINFODIR
+ TERMINFODIR, 0,
+#endif
+ NULL, -1);
+ else
+ path = _buildpath(
+#ifdef USE_TERMINFO
+ "$MYTERMINFO", 2,
+ "$TERMINFO", 2,
+#ifdef TERMINFODIR
+ TERMINFODIR, 0,
+#endif
+#ifdef TERMINFOSRC
+ TERMINFOSRC, 0,
+#endif
+#endif
+#ifdef USE_TERMCAP
+ "$TERMCAP", 1,
+#ifdef TERMCAPFILE
+ TERMCAPFILE, 0,
+#endif
+#endif
+ NULL, -1);
+ if (term == NULL) {
+ term = getenv("TERM");
+ if (term == NULL)
+ quit(-1, "no terminal type given");
+ }
+
+ cleanup = do_cleanup;
+
+ r = _findterm(term, path, buf);
+ switch(r) {
+ case 1:
+ convtcap();
+ break;
+ case 2:
+ convtinfo();
+ break;
+ case 3:
+ if (compile)
+ quit(-1, "entry is already compiled");
+ convtbin();
+ break;
+ default:
+ quit(-1, "can't find a terminal entry for '%s'", term);
+ }
+
+ exit(0);
+ return 0;
+}
diff --git a/lib/libmytinfo/term.tail b/lib/libmytinfo/term.tail
new file mode 100644
index 0000000..bba7264
--- /dev/null
+++ b/lib/libmytinfo/term.tail
@@ -0,0 +1,131 @@
+/*
+ * 92/02/01 07:30:28
+ * @(#) mytinfo term.tail 3.2 92/02/01 public domain, By Ross Ridge
+ *
+ */
+
+#if defined(_USE_TERMIO) || defined(_USE_TERMIOS)
+#ifndef ICANON
+#ifdef _USE_TERMIO
+#include <termio.h>
+#else
+#include <termios.h>
+#endif
+#endif
+#if defined(_USE_WINSZ) && defined(__FreeBSD__)
+#include <sys/ioctl.h>
+#endif
+#if defined(_USE_WINSZ) && defined(xenix)
+#include <sys/stream.h>
+#include <sys/ptem.h>
+#endif
+#endif
+
+#ifdef _USE_SGTTY
+#ifndef CBREAK
+#include <sgtty.h>
+#endif
+#endif
+
+typedef struct _terminal {
+ int fd;
+#ifdef _USE_SMALLMEM
+#ifdef _USE_TERMIOS
+ speed_t baudrate;
+#else
+ unsigned short baudrate;
+#endif
+ unsigned pad:1, xon:1, termcap:1;
+#else
+ int pad;
+ int xon;
+ int termcap;
+#ifdef _USE_TERMIOS
+ speed_t baudrate;
+#else
+ long baudrate;
+#endif
+#endif
+ char padch;
+ short true_lines, true_columns;
+ struct strbuf {
+ struct strbuf *next;
+#ifdef _USE_SMALLMEM
+ short len;
+#else
+ int len;
+#endif
+ char buf[_MAX_CHUNK];
+ } *strbuf;
+ char *name, *name_long, *name_all;
+#ifdef _USE_SGTTY
+ struct sgtty_str {
+ struct sgttyb v6;
+#ifdef TIOCGETC
+ struct tchars v7;
+#endif
+#ifdef TIOCLGET
+ int bsd;
+#endif
+#ifdef TIOCGLTC
+ struct ltchars bsd_new;
+#endif
+ } prog_mode, shell_mode;
+#else /* _USE_SGTTY */
+#ifdef _USE_TERMIOS
+ struct termios prog_mode, shell_mode;
+#else
+#ifdef _USE_TERMIO
+ struct termio prog_mode, shell_mode;
+#endif
+#endif
+#endif /* else _USE_SGTTY */
+#ifdef _USE_WINSZ
+#ifdef TIOCGWINSZ
+ struct winsize prog_winsz, shell_winsz;
+#endif
+#endif
+ char bools[NUM_OF_BOOLS];
+ short nums[NUM_OF_NUMS];
+ char *strs[NUM_OF_STRS];
+} TERMINAL;
+
+#ifndef _CUR_TERM
+#ifdef SINGLE
+#define _CUR_TERM _term_buf
+#else
+#define _CUR_TERM (*cur_term)
+#endif
+#endif
+
+extern TERMINAL *cur_term;
+extern TERMINAL _term_buf;
+
+#ifndef __P
+#if defined(_USE_PROTOTYPES) && (defined(__STDC__) || defined(__cplusplus))
+#define __P(protos) protos /* full-blown ANSI C */
+#else
+#define __P(protos) () /* traditional C preprocessor */
+#endif
+#endif
+
+extern char *tparm __P((char *, ...));
+extern int setupterm __P((char *, int, int *)), set_curterm __P((TERMINAL *));
+extern int del_curterm __P((TERMINAL *)), tputs __P((char *, int, int (*)(char)));
+extern int putp __P((char *));
+extern int tigetflag __P((char *)), tigetnum __P((char *));
+extern char *tigetstr __P((char *));
+extern int def_prog_mode __P((void)), def_shell_mode __P((void));
+extern int reset_prog_mode __P((void)), reset_shell_mode __P((void));
+
+extern char *boolnames[], *boolcodes[], *boolfnames[];
+extern char *numnames[], *numcodes[], *numfnames[];
+extern char *strnames[], *strcodes[], *strfnames[];
+
+#ifndef OK
+#undef ERR
+#define OK (0)
+#define ERR (-1)
+#endif
+
+#endif /* _TERM_H_ */
diff --git a/lib/libmytinfo/termcap.c b/lib/libmytinfo/termcap.c
new file mode 100644
index 0000000..39961e1
--- /dev/null
+++ b/lib/libmytinfo/termcap.c
@@ -0,0 +1,165 @@
+/*
+ * termcap.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/06/01 07:43:08
+ *
+ * termcap compatibility functions
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+#ifdef __FreeBSD__
+#include <unistd.h>
+#endif
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo termcap.c 3.3 92/06/01 public domain, By Ross Ridge";
+#endif
+
+extern char _mytinfo_version[];
+/* not static */
+char *force = _mytinfo_version;
+
+int
+tgetent(buf, term)
+char *term, *buf; {
+ char *s;
+ struct term_path *path;
+ int r = -1;
+ int fd;
+
+ if (term == NULL)
+ term = getenv("TERM");
+ if (term == NULL)
+ return 0;
+
+ path = _buildpath(
+#ifdef USE_TERMINFO
+ "$MYTERMINFO", 2,
+ "$TERMINFO", 2,
+#ifdef TERMINFODIR
+ TERMINFODIR, 0,
+#endif
+#ifdef TERMINFOSRC
+ TERMINFOSRC, 0,
+#endif
+#endif
+#ifdef USE_TERMCAP
+ "$TERMCAP", 1,
+#ifdef TERMCAPFILE
+ TERMCAPFILE, 0,
+#endif
+#endif
+ NULL, -1);
+
+ if (path == NULL)
+ return -1;
+
+#if 1
+ {
+ char buf1[MAX_BUF];
+ r = _fillterm(term, path, buf1);
+ }
+#else
+ r = _fillterm(term, path, buf);
+#endif
+
+ _delpath(path);
+
+ switch(r) {
+ case -3:
+ case -2:
+ case -1:
+ return -1;
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ if (isatty(1))
+ fd = 1;
+ else if (isatty(2))
+ fd = 2;
+ else if (isatty(3)) /* V10 /dev/tty ?? */
+ fd = 3;
+ else if (isatty(0))
+ fd = 0;
+ else
+ fd = 1;
+
+ cur_term->fd = fd;
+ _term_buf.fd = fd;
+
+ if (_init_tty() == ERR)
+ return 0;
+ if ((s = getenv("LINES")) != NULL && atoi(s) > 0)
+ lines = atoi(s);
+ if ((s = getenv("COLUMNS")) != NULL && atoi(s) > 0)
+ columns = atoi(s);
+ cur_term->termcap = 1;
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+static char cap2[3];
+
+int
+tgetnum(cap)
+char *cap; {
+ int ind;
+
+ cap2[0] = cap[0];
+ cap2[1] = cap[1];
+ cap2[2] = '\0';
+
+ ind = _findnumcode(cap2);
+ if (ind == -1)
+ return -1;
+ return cur_term->nums[ind];
+}
+
+int
+tgetflag(cap)
+char *cap; {
+ int ind;
+
+ cap2[0] = cap[0];
+ cap2[1] = cap[1];
+ cap2[2] = '\0';
+
+ ind = _findboolcode(cap2);
+ if (ind == -1)
+ return 0;
+ return cur_term->bools[ind];
+}
+
+char *
+tgetstr(cap, area)
+char *cap;
+char **area; {
+ register char *sp, *dp;
+ int ind;
+
+ cap2[0] = cap[0];
+ cap2[1] = cap[1];
+ cap2[2] = '\0';
+
+ ind = _findstrcode(cap2);
+ if (ind == -1)
+ return NULL;
+ sp = cur_term->strs[ind];
+ if (area == NULL || sp == NULL)
+ return sp;
+ dp = *area;
+ while (*sp != '\0')
+ *dp++ = *sp++;
+ *dp++ = '\0';
+ sp = *area;
+ *area = dp;
+ return sp;
+}
diff --git a/lib/libmytinfo/terminfo.c b/lib/libmytinfo/terminfo.c
new file mode 100644
index 0000000..1e81b37
--- /dev/null
+++ b/lib/libmytinfo/terminfo.c
@@ -0,0 +1,132 @@
+/*
+ * terminfo.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:30
+ *
+ * terminfo compatible libary functions
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo terminfo.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+extern char _mytinfo_version[];
+/* not static */
+char *force = _mytinfo_version;
+
+#ifdef USE_FAKE_STDIO
+
+#ifdef __GNUC__
+__inline__
+#endif
+static int
+printerr(msg)
+char *msg; {
+ return write(2, msg, strlen(msg));
+}
+
+#define RETERR(e, msg) { (err == NULL ? (printerr(msg), exit(1), 0) \
+ : (*err = e)); return ERR; }
+
+#else
+
+#define RETERR(e, msg) { (err == NULL ? (fprintf(stderr, msg), exit(1), 0) \
+ : (*err = e)); return ERR; }
+
+#endif
+
+int
+setupterm(term, fd, err)
+char *term;
+int fd;
+int *err; {
+ struct term_path *path;
+ char *s;
+ int r = -1;
+ char buf[MAX_BUF];
+
+
+ if (term == NULL)
+ term = getenv("TERM");
+ if (term == NULL)
+ RETERR(0, "TERM not set\n")
+
+ path = _buildpath(
+#ifdef USE_TERMINFO
+ "$MYTERMINFO", 2,
+ "$TERMINFO", 2,
+#ifdef TERMINFODIR
+ TERMINFODIR, 0,
+#endif
+#ifdef TERMINFOSRC
+ TERMINFOSRC, 0,
+#endif
+#endif
+#ifdef USE_TERMCAP
+ "$TERMCAP", 1,
+#ifdef TERMCAPFILE
+ TERMCAPFILE, 0,
+#endif
+#endif
+ NULL, -1);
+
+ if (path == NULL)
+ RETERR(0, "malloc error\n");
+
+ r = _fillterm(term, path, buf);
+
+ _delpath(path);
+
+ switch(r) {
+ case -3:
+ RETERR(0, "malloc error\n");
+ case -2:
+ RETERR(-1, "bad format\n");
+ case -1:
+ RETERR(-1, "database not found\n");
+ case 0:
+ RETERR(0, "terminal not found\n");
+ case 1:
+ case 2:
+ case 3:
+ cur_term->fd = fd;
+ _term_buf.fd = fd;
+ if (_init_tty() == ERR)
+ RETERR(0, "problem initializing tty\n");
+ if ((s = getenv("LINES")) != NULL && atoi(s) > 0)
+ lines = atoi(s);
+ if ((s = getenv("COLUMNS")) != NULL && atoi(s) > 0)
+ columns = atoi(s);
+ if (err != NULL)
+ *err = 1;
+ return OK;
+ default:
+ RETERR(0, "oops...\n");
+ }
+}
+
+int
+set_curterm(p)
+TERMINAL *p; {
+ cur_term = p;
+ if (_init_tty() == ERR)
+ return ERR;
+ if (_check_tty() == ERR)
+ return ERR;
+ return OK;
+}
+
+int
+del_curterm(p)
+TERMINAL *p; {
+ _del_strs(p);
+ free((anyptr) p);
+
+ return OK;
+}
diff --git a/lib/libmytinfo/tgoto.c b/lib/libmytinfo/tgoto.c
new file mode 100644
index 0000000..e94a660
--- /dev/null
+++ b/lib/libmytinfo/tgoto.c
@@ -0,0 +1,148 @@
+/*
+ * tgoto.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:33
+ *
+ * A few kludged attempts to worry outputing ^D's and NL's...
+ * My advice is to get a decent terminal.
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tgoto.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+#ifdef USE_LITOUT_KLUDGE
+
+/*
+ * This kludge works by telling tputs to switch the tty driver to
+ * "literal output" when printing the string so we don't have worry
+ * about newlines and EOTs. The problem is that ioctls used to
+ * switch modes might flush buffers and cause other problems.
+ */
+
+
+char *
+tgoto(str, x, y)
+char *str;
+int x,y; {
+ register char *sp;
+
+ static char buf[MAX_LINE] = {'\\', '@'};
+
+ sp = str = tparm(str, y, x);
+
+ while (*sp != '\0') {
+ if (*sp == '\004' || *sp == '\n') {
+ strncpy(buf + 2, str, MAX_LINE - 2);
+ buf[MAX_LINE - 2] = '\0';
+ return buf;
+ }
+ sp++;
+ }
+ return sp;
+}
+#else
+
+#ifdef USE_UPBC_KLUDGE
+
+#ifdef USE_EXTERN_UPBC
+extern char *BC, *UP;
+#else
+#define BC cursor_left
+#define UP cursor_right
+#endif
+
+#ifdef __GNUC__
+__inline__
+#endif
+static int
+checkit(s)
+register char *s; {
+ while(*s != '\0') {
+ if (*s == '\004' || *s == '\n')
+ return 1;
+ s++;
+ }
+ return 0;
+}
+
+/*
+ * Major kludge, basically we just change the parmeters until we get
+ * a string that doesn't contain a newline or EOT.
+ */
+
+char *
+tgoto(str, x, y)
+char *str;
+int x,y; {
+ static char buf[MAX_LINE];
+ register char *orig, *s;
+ int l;
+
+ orig = tparm(str, y, x);
+
+ if (!checkit(orig))
+ return orig;
+
+ s = tparm(str, y + 1, x);
+
+ if (!checkit(s)) {
+ if (BC == NULL)
+ return s;
+ l = strlen(s);
+ strncpy(buf, s, MAX_LINE - 1);
+ if (l < MAX_LINE - 1)
+ strncpy(buf + l, BC, MAX_LINE - 1 - l);
+ return s;
+ }
+
+ s = tparm(str, y, x + 1);
+
+ if (!checkit(s)) {
+ if (UP == NULL)
+ return s;
+ l = strlen(s);
+ strncpy(buf, s, MAX_LINE - 1);
+ if (l < MAX_LINE - 1)
+ strncpy(buf + l, UP, MAX_LINE - 1 - l);
+ return s;
+ }
+
+ s = tparm(str, y + 1, x + 1);
+
+ if (!checkit(s)) {
+ if (UP == NULL || BC == NULL)
+ return s;
+ l = strlen(s);
+ strncpy(buf, s, MAX_LINE - 1);
+ if (l < MAX_LINE - 1)
+ strncpy(buf + l, UP, MAX_LINE - 1 - l);
+ l += strlen(UP);
+ if (l < MAX_LINE - 1)
+ strncpy(buf + l, BC, MAX_LINE - 1 - l);
+ return s;
+ }
+
+ return orig;
+}
+
+#else
+
+/* the simple tgoto, don't worry about any of this newline/EOT crap */
+
+char *
+tgoto(str, x, y)
+char *str;
+int x,y; {
+ return tparm(str, y, x);
+}
+
+#endif
+
+#endif
diff --git a/lib/libmytinfo/tiget.c b/lib/libmytinfo/tiget.c
new file mode 100644
index 0000000..e312422
--- /dev/null
+++ b/lib/libmytinfo/tiget.c
@@ -0,0 +1,51 @@
+/*
+ * tiget.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:34
+ *
+ * The various tiget terminfo functions.
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tiget.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+int
+tigetnum(cap)
+char *cap; {
+ int ind;
+
+ ind = _findnumname(cap);
+ if (ind == -1)
+ return -2;
+ return cur_term->nums[ind];
+}
+
+int
+tigetflag(cap)
+char *cap; {
+ int ind;
+
+ ind = _findboolname(cap);
+ if (ind == -1)
+ return -1;
+ return cur_term->bools[ind];
+}
+
+char *
+tigetstr(cap)
+char *cap; {
+ int ind;
+
+ ind = _findstrname(cap);
+ if (ind == -1)
+ return (char *) -1;
+ return cur_term->strs[ind];
+}
+
+
diff --git a/lib/libmytinfo/tmatch.c b/lib/libmytinfo/tmatch.c
new file mode 100644
index 0000000..afccda7
--- /dev/null
+++ b/lib/libmytinfo/tmatch.c
@@ -0,0 +1,37 @@
+/*
+ * tmatch.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:35
+ *
+ * See if a terminal name matches a list of terminal names from a
+ * terminal description
+ *
+ */
+
+#include "defs.h"
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tmatch.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+int
+_tmatch(line, name)
+char *line, *name; {
+ char term[MAX_LINE];
+ char *sp, *dp;
+
+ sp = line;
+ while (*sp != '\0') {
+ dp = term;
+ while (*sp != '\0' && *sp != '|')
+ *dp++ = *sp++;
+ *dp = '\0';
+ if (strcmp(term, name) == 0)
+ return 1;
+ if (*sp == '|')
+ sp++;
+ }
+ return 0;
+}
diff --git a/lib/libmytinfo/tparm.c b/lib/libmytinfo/tparm.c
new file mode 100644
index 0000000..573f788
--- /dev/null
+++ b/lib/libmytinfo/tparm.c
@@ -0,0 +1,806 @@
+/*
+ * tparm.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:36
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#include <ctype.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tparm.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+
+#ifndef MAX_PUSHED
+#define MAX_PUSHED 32
+#endif
+
+#define ARG 1
+#define NUM 2
+
+#define INTEGER 1
+#define STRING 2
+
+typedef struct stack_str {
+ int type;
+ int argnum;
+ int value;
+} stack;
+
+static stack S[MAX_PUSHED];
+static stack vars['z'-'a'+1];
+static int pos = 0;
+
+static struct arg_str {
+ int type;
+ int integer;
+ char *string;
+} arg_list[10];
+
+static int argcnt;
+
+static va_list tparm_args;
+
+static int
+pusharg(arg)
+int arg; {
+ if (pos == MAX_PUSHED)
+ return 1;
+ S[pos].type = ARG;
+ S[pos++].argnum = arg;
+ return 0;
+}
+
+static int
+pushnum(num)
+int num; {
+ if (pos == MAX_PUSHED)
+ return 1;
+ S[pos].type = NUM;
+ S[pos++].value = num;
+ return 0;
+}
+
+/* VARARGS2 */
+static int
+getarg(argnum, type, p)
+int argnum, type;
+anyptr p; {
+ while (argcnt < argnum) {
+ arg_list[argcnt].type = INTEGER;
+ arg_list[argcnt++].integer = (int) va_arg(tparm_args, int);
+ }
+ if (argcnt > argnum) {
+ if (arg_list[argnum].type != type)
+ return 1;
+ else if (type == STRING)
+ *(char **)p = arg_list[argnum].string;
+ else
+ *(int *)p = arg_list[argnum].integer;
+ } else {
+ arg_list[argcnt].type = type;
+ if (type == STRING)
+ *(char **)p = arg_list[argcnt++].string
+ = (char *) va_arg(tparm_args, char *);
+ else
+ *(int *)p = arg_list[argcnt++].integer = (int) va_arg(tparm_args, int);
+ }
+ return 0;
+}
+
+
+static int
+popstring(str)
+char **str; {
+ if (pos-- == 0)
+ return 1;
+ if (S[pos].type != ARG)
+ return 1;
+ return(getarg(S[pos].argnum, STRING, (anyptr) str));
+}
+
+static int
+popnum(num)
+int *num; {
+ if (pos-- == 0)
+ return 1;
+ switch (S[pos].type) {
+ case ARG:
+ return (getarg(S[pos].argnum, INTEGER, (anyptr) num));
+ case NUM:
+ *num = S[pos].value;
+ return 0;
+ }
+ return 1;
+}
+
+static int
+cvtchar(sp, c)
+register char *sp, *c; {
+ switch(*sp) {
+ case '\\':
+ switch(*++sp) {
+ case '\'':
+ case '$':
+ case '\\':
+ case '%':
+ *c = *sp;
+ return 2;
+ case '\0':
+ *c = '\\';
+ return 1;
+ case '0':
+ if (sp[1] == '0' && sp[2] == '0') {
+ *c = '\0';
+ return 4;
+ }
+ *c = '\200'; /* '\0' ???? */
+ return 2;
+ default:
+ *c = *sp;
+ return 2;
+ }
+ default:
+ *c = *sp;
+ return 1;
+ }
+}
+
+static int termcap;
+
+/* sigh... this has got to be the ugliest code I've ever written.
+ Trying to handle everything has its cost, I guess.
+
+ It actually isn't to hard to figure out if a given % code is supposed
+ to be interpeted with its termcap or terminfo meaning since almost
+ all terminfo codes are invalid unless something has been pushed on
+ the stack and termcap strings will never push things on the stack
+ (%p isn't used by termcap). So where we have a choice we make the
+ decision by wether or not somthing has been pushed on the stack.
+ The static variable termcap keeps track of this; it starts out set
+ to 1 and is incremented as each argument processed by a termcap % code,
+ however if something is pushed on the stack it's set to 0 and the
+ rest of the % codes are interpeted as terminfo % codes. Another way
+ of putting it is that if termcap equals one we haven't decided either
+ way yet, if it equals zero we're looking for terminfo codes, and if
+ its greater than 1 we're looking for termcap codes.
+
+ Terminfo % codes:
+
+ %% output a '%'
+ %[[:][-+# ][width][.precision]][doxXs]
+ output pop according to the printf format
+ %c output pop as a char
+ %'c' push character constant c.
+ %{n} push decimal constant n.
+ %p[1-9] push paramter [1-9]
+ %g[a-z] push variable [a-z]
+ %P[a-z] put pop in variable [a-z]
+ %l push the length of pop (a string)
+ %+ add pop to pop and push the result
+ %- subtract pop from pop and push the result
+ %* multiply pop and pop and push the result
+ %& bitwise and pop and pop and push the result
+ %| bitwise or pop and pop and push the result
+ %^ bitwise xor pop and pop and push the result
+ %~ push the bitwise not of pop
+ %= compare if pop and pop are equal and push the result
+ %> compare if pop is less than pop and push the result
+ %< compare if pop is greater than pop and push the result
+ %A logical and pop and pop and push the result
+ %O logical or pop and pop and push the result
+ %! push the logical not of pop
+ %? condition %t if_true [%e if_false] %;
+ if condtion evaulates as true then evaluate if_true,
+ else evaluate if_false. elseif's can be done:
+%? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %;
+ %i add one to parameters 1 and 2. (ANSI)
+
+ Termcap Codes:
+
+ %% output a %
+ %. output parameter as a character
+ %d output parameter as a decimal number
+ %2 output parameter in printf format %02d
+ %3 output parameter in printf format %03d
+ %+x add the character x to parameter and output it as a character
+(UW) %-x subtract parameter FROM the character x and output it as a char
+(UW) %ax add the character x to parameter
+(GNU) %a[+*-/=][cp]x
+ GNU arithmetic.
+(UW) %sx subtract parameter FROM the character x
+ %>xy if parameter > character x then add character y to parameter
+ %B convert to BCD (parameter = (parameter/10)*16 + parameter%16)
+ %D Delta Data encode (parameter = parameter - 2*(paramter%16))
+ %i increment the first two parameters by one
+ %n xor the first two parameters by 0140
+(GNU) %m xor the first two parameters by 0177
+ %r swap the first two parameters
+(GNU) %b backup to previous parameter
+(GNU) %f skip this parameter
+
+ Note the two definitions of %a, the GNU defintion is used if the characters
+ after the 'a' are valid, otherwise the UW definition is used.
+
+ (GNU) used by GNU Emacs termcap libraries
+ (UW) used by the University of Waterloo (MFCF) termcap libraries
+
+*/
+
+#ifdef lint
+/* VARARGS1 */
+char *
+tparm(str)
+char *str; {
+#else /* lint */
+#ifdef USE_STDARG
+#ifdef USE_PROTOTYPES
+char *tparm(char *str, ...) {
+#else /* USE_PROTOTYPES */
+char *tparm(str)
+char *str; {
+#endif /* USE_PROTOTYPES */
+#else /* USE_STDARG */
+char *tparm(va_alist)
+va_dcl {
+ char *str;
+#endif
+#endif
+ static char OOPS[] = "OOPS";
+ static char buf[MAX_LINE];
+ register char *sp, *dp;
+ register char *fmt;
+ char conv_char;
+ char scan_for;
+ int scan_depth = 0, if_depth;
+ static int i, j;
+ static char *s, c;
+ char fmt_buf[MAX_LINE];
+ char sbuf[MAX_LINE];
+
+#ifdef USE_STDARG
+ va_start(tparm_args, str);
+#else
+ va_start(tparm_args);
+ str = (char *) va_arg(tparm_args, char *);
+#endif
+
+ sp = str;
+ dp = buf;
+ scan_for = 0;
+ if_depth = 0;
+ argcnt = 0;
+ pos = 0;
+ termcap = 1;
+ while(*sp != '\0') {
+ switch(*sp) {
+ case '\\':
+ if (scan_for) {
+ if (*++sp != '\0')
+ sp++;
+ break;
+ }
+ *dp++ = *sp++;
+ if (*sp != '\0')
+ *dp++ = *sp++;
+ break;
+ case '%':
+ sp++;
+ if (scan_for) {
+ if (*sp == scan_for && if_depth == scan_depth) {
+ if (scan_for == ';')
+ if_depth--;
+ scan_for = 0;
+ } else if (*sp == '?')
+ if_depth++;
+ else if (*sp == ';') {
+ if (if_depth == 0)
+ return OOPS;
+ else
+ if_depth--;
+ }
+ sp++;
+ break;
+ }
+ fmt = NULL;
+ switch(*sp) {
+ case '%':
+ *dp++ = *sp++;
+ break;
+ case '+':
+ if (!termcap) {
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i += j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ }
+ ;/* FALLTHROUGH */
+ case 'C':
+ if (*sp == 'C') {
+ if (getarg(termcap - 1, INTEGER, &i))
+ return OOPS;
+ if (i >= 96) {
+ i /= 96;
+ if (i == '$')
+ *dp++ = '\\';
+ *dp++ = i;
+ }
+ }
+ fmt = "%c";
+ /* FALLTHROUGH */
+ case 'a':
+ if (!termcap)
+ return OOPS;
+ if (getarg(termcap - 1, INTEGER, (anyptr) &i))
+ return OOPS;
+ if (*++sp == '\0')
+ return OOPS;
+ if ((sp[1] == 'p' || sp[1] == 'c')
+ && sp[2] != '\0' && fmt == NULL) {
+ /* GNU aritmitic parameter, what they
+ realy need is terminfo. */
+ int val, lc;
+ if (sp[1] == 'p'
+ && getarg(termcap - 1 + sp[2] - '@',
+ INTEGER, (anyptr) &val))
+ return OOPS;
+ if (sp[1] == 'c') {
+ lc = cvtchar(sp + 2, &c) + 2;
+ /* Mask out 8th bit so \200 can be
+ used for \0 as per GNU doc's */
+ val = c & 0177;
+ } else
+ lc = 2;
+ switch(sp[0]) {
+ case '=':
+ break;
+ case '+':
+ val = i + val;
+ break;
+ case '-':
+ val = i - val;
+ break;
+ case '*':
+ val = i * val;
+ break;
+ case '/':
+ val = i / val;
+ break;
+ default:
+ /* Not really GNU's %a after all... */
+ lc = cvtchar(sp, &c);
+ val = c + i;
+ break;
+ }
+ arg_list[termcap - 1].integer = val;
+ sp += lc;
+ break;
+ }
+ sp += cvtchar(sp, &c);
+ arg_list[termcap - 1].integer = c + i;
+ if (fmt == NULL)
+ break;
+ sp--;
+ /* FALLTHROUGH */
+ case '-':
+ if (!termcap) {
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i -= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ }
+ fmt = "%c";
+ /* FALLTHROUGH */
+ case 's':
+ if (termcap && (fmt == NULL || *sp == '-')) {
+ if (getarg(termcap - 1, INTEGER, &i))
+ return OOPS;
+ if (*++sp == '\0')
+ return OOPS;
+ sp += cvtchar(sp, &c);
+ arg_list[termcap - 1].integer = c - i;
+ if (fmt == NULL)
+ break;
+ sp--;
+ }
+ if (!termcap)
+ return OOPS;
+ ;/* FALLTHROUGH */
+ case '.':
+ if (termcap && fmt == NULL)
+ fmt = "%c";
+ ;/* FALLTHROUGH */
+ case 'd':
+ if (termcap && fmt == NULL)
+ fmt = "%d";
+ ;/* FALLTHROUGH */
+ case '2':
+ if (termcap && fmt == NULL)
+ fmt = "%02d";
+ ;/* FALLTHROUGH */
+ case '3':
+ if (termcap && fmt == NULL)
+ fmt = "%03d";
+ ;/* FALLTHROUGH */
+ case ':': case ' ': case '#': case 'u':
+ case 'x': case 'X': case 'o': case 'c':
+ case '0': case '1': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ if (fmt == NULL) {
+ if (termcap)
+ return OOPS;
+ if (*sp == ':')
+ sp++;
+ fmt = fmt_buf;
+ *fmt++ = '%';
+ while(*sp != 's' && *sp != 'x' && *sp != 'X' && *sp != 'd' && *sp != 'o' && *sp != 'c' && *sp != 'u') {
+ if (*sp == '\0')
+ return OOPS;
+ *fmt++ = *sp++;
+ }
+ *fmt++ = *sp;
+ *fmt = '\0';
+ fmt = fmt_buf;
+ }
+ conv_char = fmt[strlen(fmt) - 1];
+ if (conv_char == 's') {
+ if (popstring(&s))
+ return OOPS;
+ sprintf(sbuf, fmt, s);
+ } else {
+ if (termcap) {
+ if (getarg(termcap++ - 1,
+ INTEGER, &i))
+ return OOPS;
+ } else
+ if (popnum(&i))
+ return OOPS;
+ if (i == 0 && conv_char == 'c')
+ strcpy(sbuf, "\000");
+ else
+ sprintf(sbuf, fmt, i);
+ }
+ sp++;
+ fmt = sbuf;
+ while(*fmt != '\0') {
+ if (*fmt == '$')
+ *dp++ = '\\';
+ *dp++ = *fmt++;
+ }
+ break;
+ case 'r':
+ if (!termcap || getarg(1, INTEGER, &i))
+ return OOPS;
+ arg_list[1].integer = arg_list[0].integer;
+ arg_list[0].integer = i;
+ sp++;
+ break;
+ case 'i':
+ if (getarg(1, INTEGER, &i)
+ || arg_list[0].type != INTEGER)
+ return OOPS;
+ arg_list[1].integer++;
+ arg_list[0].integer++;
+ sp++;
+ break;
+ case 'n':
+ if (!termcap || getarg(1, INTEGER, &i))
+ return OOPS;
+ arg_list[0].integer ^= 0140;
+ arg_list[1].integer ^= 0140;
+ sp++;
+ break;
+ case '>':
+ if (!termcap) {
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i = (i > j);
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ }
+ if (getarg(termcap-1, INTEGER, &i))
+ return OOPS;
+ sp += cvtchar(sp, &c);
+ if (i > c) {
+ sp += cvtchar(sp, &c);
+ arg_list[termcap-1].integer += c;
+ } else
+ sp += cvtchar(sp, &c);
+ sp++;
+ break;
+ case 'B':
+ if (!termcap || getarg(termcap-1, INTEGER, &i))
+ return OOPS;
+ arg_list[termcap-1].integer = 16*(i/10)+i%10;
+ sp++;
+ break;
+ case 'D':
+ if (!termcap || getarg(termcap-1, INTEGER, &i))
+ return OOPS;
+ arg_list[termcap-1].integer = i - 2 * (i % 16);
+ sp++;
+ break;
+ case 'p':
+ if (termcap > 1)
+ return OOPS;
+ if (*++sp == '\0')
+ return OOPS;
+ if (*sp == '0')
+ i = 9;
+ else
+ i = *sp - '1';
+ if (i < 0 || i > 9)
+ return OOPS;
+ if (pusharg(i))
+ return OOPS;
+ termcap = 0;
+ sp++;
+ break;
+ case 'P':
+ if (termcap || *++sp == '\0')
+ return OOPS;
+ i = *sp++ - 'a';
+ if (i < 0 || i > 25)
+ return OOPS;
+ if (pos-- == 0)
+ return OOPS;
+ switch(vars[i].type = S[pos].type) {
+ case ARG:
+ vars[i].argnum = S[pos].argnum;
+ break;
+ case NUM:
+ vars[i].value = S[pos].value;
+ break;
+ }
+ break;
+ case 'g':
+ if (termcap || *++sp == '\0')
+ return OOPS;
+ i = *sp++ - 'a';
+ if (i < 0 || i > 25)
+ return OOPS;
+ switch(vars[i].type) {
+ case ARG:
+ if (pusharg(vars[i].argnum))
+ return OOPS;
+ break;
+ case NUM:
+ if (pushnum(vars[i].value))
+ return OOPS;
+ break;
+ }
+ break;
+ case '\'':
+ if (termcap > 1)
+ return OOPS;
+ if (*++sp == '\0')
+ return OOPS;
+ sp += cvtchar(sp, &c);
+ if (pushnum(c) || *sp++ != '\'')
+ return OOPS;
+ termcap = 0;
+ break;
+ case '{':
+ if (termcap > 1)
+ return OOPS;
+ i = 0;
+ sp++;
+ while(isdigit(*sp))
+ i = 10 * i + *sp++ - '0';
+ if (*sp++ != '}' || pushnum(i))
+ return OOPS;
+ termcap = 0;
+ break;
+ case 'l':
+ if (termcap || popstring(&s))
+ return OOPS;
+ i = strlen(s);
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '*':
+ if (termcap || popnum(&j) || popnum(&i))
+ return OOPS;
+ i *= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '/':
+ if (termcap || popnum(&j) || popnum(&i))
+ return OOPS;
+ i /= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case 'm':
+ if (termcap) {
+ if (getarg(1, INTEGER, &i))
+ return OOPS;
+ arg_list[0].integer ^= 0177;
+ arg_list[1].integer ^= 0177;
+ sp++;
+ break;
+ }
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i %= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '&':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i &= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '|':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i |= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '^':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i ^= j;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '=':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i = (i == j);
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '<':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i = (i < j);
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case 'A':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i = (i && j);
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case 'O':
+ if (popnum(&j) || popnum(&i))
+ return OOPS;
+ i = (i || j);
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '!':
+ if (popnum(&i))
+ return OOPS;
+ i = !i;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '~':
+ if (popnum(&i))
+ return OOPS;
+ i = ~i;
+ if (pushnum(i))
+ return OOPS;
+ sp++;
+ break;
+ case '?':
+ if (termcap > 1)
+ return OOPS;
+ termcap = 0;
+ if_depth++;
+ sp++;
+ break;
+ case 't':
+ if (popnum(&i) || if_depth == 0)
+ return OOPS;
+ if (!i) {
+ scan_for = 'e';
+ scan_depth = if_depth;
+ }
+ sp++;
+ break;
+ case 'e':
+ if (if_depth == 0)
+ return OOPS;
+ scan_for = ';';
+ scan_depth = if_depth;
+ sp++;
+ break;
+ case ';':
+ if (if_depth-- == 0)
+ return OOPS;
+ sp++;
+ break;
+ case 'b':
+ if (--termcap < 1)
+ return OOPS;
+ sp++;
+ break;
+ case 'f':
+ if (!termcap++)
+ return OOPS;
+ sp++;
+ break;
+ }
+ break;
+ default:
+ if (scan_for)
+ sp++;
+ else
+ *dp++ = *sp++;
+ break;
+ }
+ }
+ va_end(tparm_args);
+ *dp = '\0';
+ return buf;
+}
+
+#ifdef TEST
+
+void
+putch(c)
+char c; {
+ if (c < 0) {
+ printf("\\%03o", c);
+ } else if (c < 32) {
+ printf("^%c", c + '@');
+ } else if (c == 127) {
+ printf("^?");
+ } else {
+ putchar(c);
+ }
+}
+
+char line[MAX_LINE];
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ register char *sp;
+ putchar('\n');
+
+ while(fgets(line, sizeof(line), stdin) != NULL) {
+ line[strlen(line)-1] = '\0';
+ sp = tparm(line, 1, -2, 30, 0, "bob was here");
+ while(*sp)
+ putch(*sp++);
+ putchar('\n');
+ }
+ return 0;
+}
+#endif
diff --git a/lib/libmytinfo/tputs.c b/lib/libmytinfo/tputs.c
new file mode 100644
index 0000000..d6fd3fa
--- /dev/null
+++ b/lib/libmytinfo/tputs.c
@@ -0,0 +1,266 @@
+/*
+ * tputs.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/06/04 11:41:15
+ *
+ * Output a terminal capability string with any needed padding
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#include <ctype.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tputs.c 3.3 92/06/04 public domain, By Ross Ridge";
+#endif
+
+#ifdef TEST
+#define def_prog_mode() (OK)
+#define _norm_output() ((void)(0))
+#define _lit_output() (1)
+#endif
+
+/*
+ * BITSPERCHAR (as actually transmitted over a serial line) is usually 10
+ * (not 8). 1 stop bit, 1 start bit, 7 data bits, and one parity bit.
+ */
+
+#define BITSPERCHAR 10
+
+#ifdef USE_FAKE_STDIO
+#undef putchar
+#endif
+
+#ifdef USE_PROTOTYPES
+#define PUTCHAR(c) (outc == (int (*)(char)) 0 ? (putchar(c)):(*outc)(c))
+#else
+#define PUTCHAR(c) (outc == (int (*)()) 0 ? (putchar(c)):(*outc)(c))
+#endif
+
+int
+tputs(sp, count, outc)
+register char *sp;
+int count;
+#ifdef USE_PROTOTYPES
+register int (*outc)(char);
+#else
+register int (*outc)();
+#endif
+{
+ register int l;
+ register long cnt;
+ int must_pad, multiply_pad;
+ int forced_lit = 0;
+
+ /* some programmes expect this behaviour from tputs */
+ if (sp == NULL) {
+#ifdef DEBUG
+ fprintf(stderr, "tputs: NULL\n");
+#endif
+ return 0;
+ }
+
+ if (cur_term->termcap) {
+ _figure_termcap();
+ }
+
+ while(*sp != '\0') {
+ switch(*sp) {
+ case '\\':
+ switch(*++sp) {
+ case 'n': PUTCHAR('\n'); sp++; break;
+ case 'b': PUTCHAR('\b'); sp++; break;
+ case 't': PUTCHAR('\t'); sp++; break;
+ case 'r': PUTCHAR('\r'); sp++; break;
+ case 'f': PUTCHAR('\f'); sp++; break;
+ case 'l': PUTCHAR('\012'); sp++; break;
+ case 's': PUTCHAR(' '); sp++; break;
+ case 'e': case 'E': PUTCHAR('\033'); sp++; break;
+
+ case '^':
+ case '\\':
+ case ',':
+ case ':':
+ case '\'':
+ case '$':
+ PUTCHAR(*sp++);
+ break;
+
+ case '0':
+ if (*(sp + 1) < '0' || *(sp + 1) > '7') {
+ PUTCHAR('\200'); /* I'd prefer \0 */
+ sp++;
+ break;
+ }
+ ;/* FALLTHROUGH */
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7':
+ l = *sp++ - '0';
+ if (*sp >= '0' && *sp <= '7') {
+ l = l * 8 + (*sp++ - '0');
+ if (*sp >= '0' && *sp <= '7')
+ l = l * 8 + (*sp++ - '0');
+ }
+ PUTCHAR(l);
+ break;
+
+ case '\0':
+ PUTCHAR('\\');
+ break;
+
+ case '@':
+ if (!forced_lit)
+ forced_lit = _lit_output();
+ sp++;
+ break;
+
+ default:
+ PUTCHAR('\\');
+ PUTCHAR(*sp++);
+ break;
+ }
+ break;
+ case '^':
+ if (*++sp == '\0')
+ break;
+ l = *sp - '@';
+ if (l > 31)
+ l -= 32;
+ if (l < 0 || l > 31) {
+ PUTCHAR('^');
+ PUTCHAR(*sp++);
+ } else {
+ PUTCHAR(l);
+ sp++;
+ }
+ break;
+ case '$':
+ if (*++sp != '<') {
+ PUTCHAR('$');
+ break;
+ }
+ must_pad = 0;
+ multiply_pad = 0;
+ l = 0;
+ sp++;
+ while (isdigit(*sp))
+ l = l * 10 + (*sp++ - '0');
+ l *= 10;
+ if (*sp == '.') {
+ sp++;
+ if (isdigit(*sp))
+ l += *sp++ - '0';
+ }
+ if (*sp == '/') {
+ must_pad = 1;
+ if (*++sp == '*') {
+ multiply_pad = 1;
+ sp++;
+ }
+ } else if (*sp == '*') {
+ multiply_pad = 1;
+ if (*++sp == '/') {
+ must_pad = 1;
+ sp++;
+ }
+ }
+ if (*sp != '>') {
+ PUTCHAR('p');
+ PUTCHAR('a');
+ PUTCHAR('d');
+ PUTCHAR('?');
+ break;
+ }
+ sp++;
+#ifdef TEST
+ printf("\nl = %d", l);
+#endif
+ if (cur_term->pad || must_pad) {
+ cnt = ((long) l * cur_term->baudrate
+ * (multiply_pad ? count : 1)
+ + (10000L * BITSPERCHAR / 2L))
+ / (10000L * BITSPERCHAR);
+#ifdef TEST
+ printf("; cnt = %ld\n", cnt);
+#endif
+ while(cnt--)
+ PUTCHAR(cur_term->padch);
+ }
+#ifdef TEST
+ printf("\n");
+#endif
+ break;
+ default:
+ PUTCHAR(*sp++);
+ }
+ }
+ if (forced_lit)
+ _norm_output();
+ return OK;
+}
+
+int
+putp(str)
+char *str; {
+#ifdef USE_PROTOTYPES
+ return(tputs(str, 1,(int (*)(char)) 0));
+#else
+ return(tputs(str, 1,(int (*)()) 0));
+#endif
+}
+
+#ifdef TEST
+
+TERMINAL test_term, *cur_term = &test_term;
+
+int
+#ifdef USE_PROTOTYPES
+putch(char c)
+#else
+putch(c)
+char c;
+#endif
+{
+ if (c & 0x80) {
+ printf("\\%03o", c);
+ } else if (c < 32) {
+ printf("^%c", c + '@');
+ } else if (c == 127) {
+ printf("^?");
+ } else {
+ putchar(c);
+ }
+ return 0;
+}
+
+char line[MAX_LINE];
+
+int
+main(argc, argv)
+int argc;
+char **argv; {
+ test_term.termcap = 0;
+ test_term.baudrate = 1200;
+ test_term.pad = 0;
+ test_term.padch = 0;
+ if (argc > 1)
+ test_term.baudrate = atoi(argv[1]);
+ if (argc > 2)
+ test_term.padch = argv[2][0];
+ if (argc > 3)
+ test_term.pad = 1;
+
+ putchar('\n');
+
+ while(fgets(line, sizeof(line), stdin) != NULL) {
+ line[strlen(line)-1] = '\0';
+ tputs(line, 7, putch);
+ putchar('\n');
+ }
+ return 0;
+}
+#endif
diff --git a/lib/libmytinfo/tty.c b/lib/libmytinfo/tty.c
new file mode 100644
index 0000000..640fb47
--- /dev/null
+++ b/lib/libmytinfo/tty.c
@@ -0,0 +1,446 @@
+/*
+ * tty.c
+ *
+ * By Ross Ridge
+ * Public Domain
+ * 92/02/01 07:30:49
+ *
+ * Do some tty related things
+ *
+ */
+
+#include "defs.h"
+#include <term.h>
+
+#ifdef USE_SCCS_IDS
+static const char SCCSid[] = "@(#) mytinfo tty.c 3.2 92/02/01 public domain, By Ross Ridge";
+#endif
+#ifndef EXTA_IS
+#define EXTA_IS 19200
+#endif
+
+#ifndef EXTB_IS
+#define EXTB_IS 38400
+#endif
+
+#ifdef lint
+#define ioctl _ioctl
+/* shutup lint */
+/* ARGSUSED */
+/* VARARGS1 */
+static int ioctl(a, b, p) int a; long b; anyptr *p; { return 0; }
+#endif
+
+#if defined(USE_TERMIO) || defined(USE_TERMIOS)
+
+#ifdef USE_TERMIOS
+speed_t _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
+ 2400, 4800, 9600, EXTA_IS, EXTB_IS
+#ifdef B57600
+ ,57600
+#endif
+#ifdef B115200
+ ,115200
+#endif
+ };
+#else
+#ifdef USE_SMALLMEM
+unsigned short _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
+ 1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
+#else
+long _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
+ 2400, 4800, 9600, EXTA_IS, EXTB_IS};
+#endif
+#endif
+
+#ifdef USE_TERMIO
+static struct termio old;
+#else
+static struct termios old;
+#endif
+
+int
+_lit_output() {
+#ifdef USE_TERMIO
+ struct termio tmp;
+ if (ioctl(cur_term->fd, TCGETA, &old) == -1)
+ return 0;
+#else
+ struct termios tmp;
+ if (tcgetattr(cur_term->fd, &old) == -1)
+ return 0;
+#endif
+ if (!(old.c_oflag & OPOST) || !(old.c_oflag & ONLCR))
+ return 0;
+ memcpy((anyptr)&tmp, (anyptr)&old, sizeof(old));
+ tmp.c_oflag &= ~OPOST;
+#ifdef USE_TERMIO
+ ioctl(cur_term->fd, TCSETA, &tmp);
+#else
+ tcsetattr(cur_term->fd, TCSADRAIN, &tmp);
+#endif
+ return 1;
+}
+
+void
+_norm_output() {
+#ifdef USE_TERMIO
+ ioctl(cur_term->fd, TCSETA, &old);
+#else
+ tcsetattr(cur_term->fd, TCSADRAIN, &old);
+#endif
+}
+
+int
+_check_tty() {
+ if ((cur_term->prog_mode.c_iflag & IXON) && cur_term->xon)
+ cur_term->pad = 0;
+ else
+ cur_term->pad = 1;
+#ifdef USE_TERMIO
+ cur_term->baudrate = _baud_tbl[cur_term->prog_mode.c_cflag & CBAUD];
+#else
+ cur_term->baudrate = cfgetospeed(&cur_term->prog_mode);
+#endif
+ return OK;
+}
+
+int
+def_prog_mode() {
+#ifdef USE_WINSZ
+#ifdef TIOCGWINSZ
+ if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->prog_winsz) < 0)
+ return ERR;
+#endif
+#endif
+#ifdef USE_TERMIO
+ if (ioctl(cur_term->fd, TCGETA, &cur_term->prog_mode) == 0
+#else
+ if (tcgetattr(cur_term->fd, &cur_term->prog_mode) == 0
+#endif
+ && _check_tty() == OK)
+ return OK;
+ return ERR;
+}
+
+int
+def_shell_mode() {
+ cur_term->termcap = 0;
+#ifdef USE_WINSZ
+#ifdef TIOCGWINSZ
+ if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->shell_winsz) < 0)
+ return ERR;
+#endif
+#endif
+#ifdef USE_TERMIO
+ return ioctl(cur_term->fd, TCGETA, &cur_term->shell_mode)==0 ? OK : ERR;
+#else
+ return tcgetattr(cur_term->fd, &cur_term->shell_mode)==0 ? OK : ERR;
+#endif
+}
+
+int
+reset_prog_mode() {
+#ifdef USE_TERMIO
+ return ioctl(cur_term->fd, TCSETA, &cur_term->prog_mode)==0 ? OK : ERR;
+#else
+ return tcsetattr(cur_term->fd, TCSADRAIN, &cur_term->prog_mode)==0 ? OK : ERR;
+#endif
+}
+
+int
+reset_shell_mode() {
+#ifdef USE_TERMIO
+ return ioctl(cur_term->fd, TCSETA, &cur_term->shell_mode)==0 ? OK : ERR;
+#else
+ return tcsetattr(cur_term->fd, TCSADRAIN, &cur_term->shell_mode)==0 ? OK : ERR;
+#endif
+}
+
+int
+_init_tty() {
+ cur_term->true_lines = lines;
+ cur_term->true_columns = columns;
+ if (pad_char == NULL)
+ cur_term->padch = '\000';
+ else
+ cur_term->padch = pad_char[0];
+ if (def_shell_mode() == ERR || def_prog_mode() == ERR) {
+ cur_term->pad = 0;
+ cur_term->baudrate = 1;
+ cur_term->xon = 0;
+ return OK;
+ }
+ cur_term->xon = (xoff_character == NULL || xoff_character[0] == '\021')
+ && (xon_character == NULL || xon_character[0] == '\023')
+ && xon_xoff;
+#ifdef USE_WINSZ
+#ifdef TIOCGWINSZ
+ if (cur_term->prog_winsz.ws_row != 0
+ && cur_term->prog_winsz.ws_col != 0) {
+ lines = cur_term->prog_winsz.ws_row;
+ columns = cur_term->prog_winsz.ws_col;
+ }
+#endif
+#endif
+ return OK;
+}
+
+#else
+
+#ifdef USE_SGTTY
+
+#ifdef USE_SMALLMEM
+unsigned short _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
+ 1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
+#else
+long _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
+ 1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
+#endif
+
+
+#ifdef TIOCLGET
+
+static int old;
+
+int
+_lit_output() {
+ struct sgttyb buf;
+ int tmp;
+
+ ioctl(cur_term->fd, TIOCGETP, &buf);
+ if (buf.sg_flags & RAW)
+ return 0;
+ ioctl(cur_term->fd, TIOCLGET, &old);
+ if (old & LLITOUT)
+ return 0;
+ tmp = old | LLITOUT;
+ ioctl(cur_term->fd, TIOCLSET, &tmp);
+ return 1;
+}
+
+void
+_norm_output() {
+ ioctl(cur_term->fd, TIOCLSET, &old);
+}
+
+#else
+
+static struct sgttyb old;
+
+int
+_lit_output() {
+ struct sgttyb tmp;
+ ioctl(cur_term->fd, TIOCGETP, &old);
+ if (old.sg_flags & RAW)
+ return 0;
+ memcpy((anyptr)&tmp, (anyptr)&old, sizeof(old));
+ tmp.sg_flags |= RAW;
+ ioctl(cur_term->fd, TIOCSETP, &tmp);
+ return 1;
+}
+
+void
+_norm_output() {
+ ioctl(cur_term->fd, TIOCSETP, &old);
+}
+
+#endif
+
+int
+_check_tty() {
+ if (!(cur_term->prog_mode.v6.sg_flags & RAW) && cur_term->xon)
+ cur_term->pad = 0;
+ else
+ cur_term->pad = 1;
+ cur_term->baudrate = _baud_tbl[cur_term->prog_mode.v6.sg_ospeed & 0xf];
+ return OK;
+}
+
+int
+def_shell_mode() {
+ if (ioctl(cur_term->fd, TIOCGETP, &cur_term->shell_mode.v6) < 0)
+ return ERR;
+#ifdef TIOCGETC
+ if (ioctl(cur_term->fd, TIOCGETC, &cur_term->shell_mode.v7) < 0)
+ return ERR;
+#endif
+#ifdef TIOCLGET
+ if (ioctl(cur_term->fd, TIOCLGET, &cur_term->shell_mode.bsd) < 0)
+ return ERR;
+#endif
+#ifdef TIOCGLTC
+ if (ioctl(cur_term->fd, TIOCGLTC, &cur_term->shell_mode.bsd_new) < 0)
+ return ERR;
+#endif
+#ifdef USE_WINSZ
+#ifdef TIOCGWINSZ
+ if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->shell_winsz)<0)
+ return ERR;
+#endif
+#endif
+ cur_term->termcap = 0;
+ return OK;
+}
+
+int
+def_prog_mode() {
+ if (ioctl(cur_term->fd, TIOCGETP, &cur_term->prog_mode.v6) < 0)
+ return ERR;
+#ifdef TIOCGETC
+ if (ioctl(cur_term->fd, TIOCGETC, &cur_term->prog_mode.v7) < 0)
+ return ERR;
+#endif
+#ifdef TIOCLGET
+ if (ioctl(cur_term->fd, TIOCLGET, &cur_term->prog_mode.bsd) < 0)
+ return ERR;
+#endif
+#ifdef TIOCGLTC
+ if (ioctl(cur_term->fd, TIOCGLTC, &cur_term->prog_mode.bsd_new) < 0)
+ return ERR;
+#endif
+#ifdef USE_WINSZ
+#ifdef TIOCGWINSZ
+ if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->prog_winsz)<0)
+ return ERR;
+#endif
+#endif
+ return _check_tty();
+}
+
+int
+reset_shell_mode() {
+ if (ioctl(cur_term->fd, TIOCSETP, &cur_term->shell_mode.v6) < 0)
+ return ERR;
+#ifdef TIOCGETC
+ if (ioctl(cur_term->fd, TIOCSETC, &cur_term->shell_mode.v7) < 0)
+ return ERR;
+#endif
+#ifdef TIOCLGET
+ if (ioctl(cur_term->fd, TIOCLSET, &cur_term->shell_mode.bsd) < 0)
+ return ERR;
+#endif
+#ifdef TIOCGLTC
+ if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->shell_mode.bsd_new) < 0)
+ return ERR;
+#endif
+ return OK;
+}
+
+int
+reset_prog_mode() {
+ if (ioctl(cur_term->fd, TIOCSETP, &cur_term->prog_mode.v6) < 0)
+ return ERR;
+#ifdef TIOCGETC
+ if (ioctl(cur_term->fd, TIOCSETC, &cur_term->prog_mode.v7) < 0)
+ return ERR;
+#endif
+#ifdef TIOCLGET
+ if (ioctl(cur_term->fd, TIOCLSET, &cur_term->prog_mode.bsd) < 0)
+ return ERR;
+#endif
+#ifdef TIOCGLTC
+ if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->prog_mode.bsd_new) < 0)
+ return ERR;
+#endif
+ return OK;
+}
+
+int
+_init_tty() {
+ cur_term->true_lines = lines;
+ cur_term->true_columns = columns;
+ if (pad_char == NULL)
+ cur_term->padch = '\000';
+ else
+ cur_term->padch = pad_char[0];
+ if (def_shell_mode() == ERR || def_prog_mode() == ERR) {
+ cur_term->pad = 0;
+ cur_term->baudrate = 1;
+ cur_term->xon = 0;
+ return OK;
+ }
+#ifndef TIOCGETC
+ cur_term->xon = (xoff_character == NULL || xoff_character[0] == '\021')
+ && (xon_character == NULL || xon_character[0] == '\023')
+ && xon_xoff;
+#else
+ if (xon_xoff) {
+ if (xon_character != NULL) {
+ cur_term->prog_mode.v7.t_startc = xon_character[0];
+ if (ioctl(cur_term->fd, TIOCSETC,
+ &cur_term->prog_mode.v7) < 0)
+ return ERR;
+ }
+ if (xoff_character != NULL) {
+ cur_term->prog_mode.v7.t_stopc = xoff_character[0];
+ if (ioctl(cur_term->fd, TIOCSETC,
+ &cur_term->prog_mode.v7) < 0)
+ return ERR;
+ }
+ }
+ cur_term->xon = xon_xoff;
+#endif
+#ifdef USE_WINSZ
+#ifdef TIOCGWINSZ
+ if (cur_term->prog_winsz.ws_row != 0
+ && cur_term->prog_winsz.ws_col != 0) {
+ lines = cur_term->prog_winsz.ws_row;
+ columns = cur_term->prog_winsz.ws_col;
+ }
+#endif
+#endif
+ return OK;
+}
+
+#else
+
+int
+_lit_output() {
+ return 0;
+}
+
+void
+_norm_output() {
+ return;
+}
+
+int
+_check_tty() {
+ return OK;
+}
+
+int
+def_prog_mode() {
+ return OK;
+}
+
+int
+reset_prog_mode() {
+ return OK;
+}
+
+int
+def_shell_mode() {
+ return OK;
+}
+
+int
+reset_shell_mode() {
+ return OK;
+}
+
+int
+_init_tty() {
+ cur_term->pad = 1;
+ cur_term->padch = 0;
+ cur_term->baudrate = 1200;
+ cur_term->xon = 0;
+ cur_term->termcap = 0;
+ cur_term->true_lines = lines;
+ cur_term->true_columns = columns;
+}
+
+#endif
+
+#endif
diff --git a/lib/libmytinfo/version.h b/lib/libmytinfo/version.h
new file mode 100644
index 0000000..917223d
--- /dev/null
+++ b/lib/libmytinfo/version.h
@@ -0,0 +1,10 @@
+/*
+ * version.h
+ *
+ * By Ross Ridge
+ * Public Domain
+ *
+ */
+
+#define RELEASE 3
+#define PATCHLEVEL 0
OpenPOWER on IntegriCloud