home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-04 | 49.1 KB | 2,058 lines |
- #!/bin/sh
- # This is tinfo, a shell archive (shar 3.10)
- # made 04/02/1990 08:46 UTC by ross@contact
- # Source directory /usr/spool/users/ross/src/tinfo/Shar
- #
- # existing files WILL be overwritten
- #
- # This is part 1 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 5721 -rw-r--r-- Makefile
- # 275 -rw-r--r-- TODO
- # 3708 -rw-r--r-- README
- # 4731 -rw-r--r-- README.doc
- # 6056 -rw-r--r-- INSTALL
- # 483 -rw-rw-r-- DECL
- # 1470 -rw-r--r-- fillterm.c
- # 4428 -rw-r--r-- findterm.c
- # 551 -rw-r--r-- tmatch.c
- # 1903 -rw-r--r-- terminfo.c
- # 318 -rw-r--r-- compar.c
- # 2565 -rw-r--r-- termcap.c
- # 4051 -rw-r--r-- tputs.c
- # 7042 -rw-r--r-- tty.c
- # 16585 -rw-r--r-- tparm.c
- # 1141 -rw-r--r-- tiget.c
- # 2435 -rw-r--r-- tgoto.c
- # 3998 -rw-r--r-- buildpath.c
- # 5023 -rw-r--r-- tcapconv.c
- # 6363 -rw-r--r-- qsort.c
- # 6271 -rw-r--r-- gettcap.c
- # 7453 -rw-r--r-- gettinfo.c
- # 671 -rw-r--r-- getother.c
- # 1508 -rw-r--r-- addstr.c
- # 2908 -rw-r--r-- mktermhead.c
- # 3281 -rw-r--r-- mkcaplist.c
- # 3629 -rw-r--r-- mkcapsort.c
- # 2211 -rw-r--r-- readcaps.c
- # 470 -rw-r--r-- tcapvars.c
- # 2151 -rw-r--r-- mkbinorder.c
- # 2512 -rw-r--r-- gettbin.c
- # 992 -rw-r--r-- quit.c
- # 4213 -rw-r--r-- ttest.c
- # 3264 -rw-r--r-- caps.c
- # 25042 -rw-r--r-- conv.c
- # 1993 -rw-r--r-- bsearch.c
- # 1327 -rw-r--r-- strtok.c
- # 1740 -rw-r--r-- fake_stdio.c
- # 8573 -rw-r--r-- sprintf.c
- # 1295 -rw-r--r-- clear.c
- # 2146 -rw-r--r-- term.tail
- # 3602 -rw-r--r-- defs.h
- # 1816 -rw-r--r-- config.h
- # 8689 -rw-r--r-- cap_list
- # 4429 -rw-r--r-- terminfo.src
- # 1552 -rw-r--r-- bin_order
- # 1221 -rw-r--r-- fake_stdio.h
- # 3726 -rw-r--r-- conv.1
- # 1850 -rw-r--r-- config.h.xenix
- #
- touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
- if [ -s /tmp/s3_touch$$ ]
- then
- TOUCH=can
- else
- TOUCH=cannot
- fi
- rm -f /tmp/s3_touch$$
- if test -r s3_seq_.tmp
- then echo "Must unpack archives in sequence!"
- next=`cat s3_seq_.tmp`; echo "Please unpack part $next next"
- exit 1; fi
- # ============= Makefile ==============
- echo "x - extracting Makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > Makefile &&
- X#
- X# Makefile
- X#
- X# By Ross Ridge
- X# Public Domain
- X# 90/04/02 04:21:20
- X#
- X# make the terminfo/termcap library
- X#
- X# @(#) Makefile 1.6.1.2
- X#
- X# See the file INSTALL for configuration instructions
- X#
- X
- XCC = cc
- XCFLAGS = $(DFLAGS) -O
- X
- X#CFLAGS = $(DFLAGS) -W1 -Ox
- X#CC = gcc
- X#CFLAGS = $(DFLAGS) -O -Wall -Wpointer-arith -fstrength-reduce -ansi
- X
- XLDFLAGS = $(DFLAGS)
- X
- XCAPS = 1000
- X
- XAR = ar
- XARFLAGS = qcv
- X
- X# System V should use echo instead of ranlib
- XRANLIB = ranlib
- X#RANLIB = echo
- X
- XSHELL = /bin/sh
- X
- XALLCSRCS = fillterm.c findterm.c tmatch.c terminfo.c compar.c\
- Xtermcap.c tputs.c tty.c tparm.c tiget.c tgoto.c buildpath.c\
- Xtcapconv.c qsort.c gettcap.c gettinfo.c getother.c addstr.c\
- Xmktermhead.c mkcaplist.c mkcapsort.c readcaps.c tcapvars.c\
- Xmkbinorder.c gettbin.c quit.c ttest.c caps.c conv.c\
- Xbsearch.c strtok.c fake_stdio.c sprintf.c clear.c
- XALLSRCS = $(ALLCSRCS)\
- Xterm.tail defs.h config.h cap_list terminfo.src bin_order fake_stdio.h conv.1
- XALLOTHERS = Makefile TODO README README.doc INSTALL DECL
- XALL = $(ALLSRCS) $(ALLOTHERS)
- X
- XSRCS = capsort.c caplist.c fillterm.c findterm.c tmatch.c\
- Xterminfo.c compar.c bsearch.c strtok.c binorder.c\
- Xtermcap.c tputs.c tty.c tparm.c tiget.c tgoto.c buildpath.c\
- Xtcapconv.c gettcap.c gettinfo.c getother.c addstr.c tcapvars.c\
- Xgettbin.c fake_stdio.c sprintf.c
- XOBJS = capsort.o caplist.o fillterm.o findterm.o tmatch.o\
- Xterminfo.o compar.o bsearch.o strtok.o binorder.o\
- Xtermcap.o tputs.o tty.o tparm.o tiget.o tgoto.o buildpath.o\
- Xtcapconv.o gettcap.o gettinfo.o getother.o addstr.o tcapvars.o\
- Xgettbin.o fake_stdio.o sprintf.o
- X
- XLINTFLAGS = # -Z -O -C
- X
- XDEFS_H = defs.h config.h fake_stdio.h
- X
- Xtinfo.a: $(OBJS)
- X rm -f tinfo.a
- X $(AR) $(ARFLAGS) tinfo.a $(OBJS)
- X $(RANLIB) tinfo.a
- X
- Xtinfo_g.a: $(OBJS)
- X rm -f tinfo_g.a
- X $(AR) $(ARFLAGS) tinfo_g.a $(OBJS)
- X $(RANLIB) tinfo_g.a
- X
- Xtinfo_p.a: $(OBJS)
- X rm -f tinfo_p.a
- X $(AR) $(ARFLAGS) tinfo_p.a $(OBJS)
- X $(RANLIB) tinfo_p.a
- X
- Xdebug:
- X $(MAKE) DFLAGS="-g" CFLAGS="${CFLAGS} -DDEBUG" tinfo_g.a
- X
- Xprofiled: mv mktermhead mkcaplist mkcapsort mkbinorder
- X @if test ! -d Profile; then mkdir Profile; fi
- X @if test ! -d Objs; then mkdir Objs; fi
- X -mv -f Profile/*.o . 2> /dev/null
- X $(MAKE) DFLAGS="-p" tinfo_p.a
- X -mv -f $(OBJS) Profile 2> /dev/null
- X -mv -f Objs/*.o . 2> /dev/null
- X rm -f mon.out
- X
- Xrm:
- X rm -f $(OBJS)
- X
- Xmv:
- X -mv -f $(OBJS) Objs 2> /dev/null
- X
- Xtest: ttest tputs.test tparm.test readcaps.test caps sprintf.test
- X
- Xttest: ttest.o quit.o debug
- X $(CC) -o ttest -g $(LDFLAGS) ttest.o quit.o tinfo_g.a
- X
- Xttest.o: ttest.c $(DEFS_H) term.h
- X $(CC) -c -g $(CFLAGS) ttest.c
- X
- Xcaps: caps.o quit.o debug
- X $(CC) -o caps -g $(LDFLAGS) caps.o quit.o tinfo_g.a
- X
- Xcaps.o: ttest.c $(DEFS_H) term.h
- X $(CC) -c -g $(CFLAGS) caps.c
- X
- X.SUFFIXES: .test
- X
- X.c.test:
- X $(CC) -o $< -DTEST -g $(LDFLAGS) $(CFLAGS) $< -o $@
- X
- Xtputs.test: tputs.c term.h $(DEFS_H)
- X
- Xtparm.test: tparm.c term.h $(DEFS_H)
- X
- Xreadcaps.test: readcaps.c $(DEFS_H)
- X
- Xsprintf.test: sprintf.c $(DEFS_H)
- X
- Xcapsort.c: mkcapsort
- X ./mkcapsort > capsort.c
- X
- Xmkcapsort: mkcapsort.o caplist.o compar.o qsort.o
- X $(CC) $(LDFLAGS) -o mkcapsort mkcapsort.o caplist.o compar.o \
- Xqsort.o
- X
- Xbinorder.c: mkbinorder bin_order
- X ./mkbinorder bin_order > binorder.c
- X
- Xmkbinorder.o: mkbinorder.c term.h $(DEFS_H)
- X
- Xmkbinorder: mkbinorder.o capsort.o caplist.o compar.o bsearch.o
- X $(CC) $(LDFLAGS) -o mkbinorder mkbinorder.o capsort.o \
- Xcaplist.o compar.o bsearch.o
- X
- Xterm.h: term.head term.tail
- X cat term.head term.tail > term.h
- X
- Xterm.head: mktermhead cap_list
- X ./mktermhead -n $(CAPS) cap_list > term.head
- X
- Xcaplist.c: mkcaplist cap_list
- X ./mkcaplist -n $(CAPS) cap_list > caplist.c
- X
- Xmktermhead: mktermhead.o readcaps.o
- X $(CC) $(LDFLAGS) -o mktermhead mktermhead.o readcaps.o
- X
- Xmkcaplist: mkcaplist.o readcaps.o
- X $(CC) $(LDFLAGS) -o mkcaplist mkcaplist.o readcaps.o
- X
- Xcap2info: conv
- X rm -f cap2info
- X ln conv cap2info
- X
- Xtic: conv
- X rm -f tic
- X ln conv tic
- X
- Xconv: conv.o quit.o tinfo.a
- X $(CC) $(LDFLAGS) -o conv conv.o quit.o tinfo.a
- X
- Xclear: clear.tcap clear.tinfo
- X
- Xclear.tcap: clear.c tinfo.a $(DEFS_H)
- X $(CC) $(LDFLAGS) $(CFLAGS) -o clear.tcap clear.c tinfo.a
- X
- Xclear.tinfo: clear.c tinfo.a $(DEFS_H) term.h
- X $(CC) $(LDFLAGS) $(CFLAGS) -DUSE_TERMINFO -o clear.tinfo clear.c tinfo.a
- X
- Xquit.o mktermhead.o mkcaplist.o readcaps.o: $(DEFS_H)
- X
- Xconv.o mkcapsort.o: term.h $(DEFS_H)
- X
- X$(OBJS): $(DEFS_H) term.h
- X
- Xprintf.o: sprintf.c $(DEFS_H)
- X -mv -f sprintf.o sprintf..o
- X $(CC) $(CFLAGS) -c -DUSE_FAKE_STDIO -DPRINTF sprintf.c
- X -mv -f sprintf.o printf.o
- X -mv -f sprintf..o sprintf.o
- X
- Xprint: $(ALL)
- X pr $(ALL) | lpr
- X
- Xlint: $(SRCS) term.h $(DEFS_H)
- X lint $(LINTFLAGS) $(SRCS)
- X
- Xclean:
- X rm -f *.o mkcapsort capsort.c term.head caplist.c
- X rm -f mkbinorder binorder.c mkcaplist mktermhead
- X rm -f Debug/*.o Profile/*.o Objs/*.o
- X
- Xspotless: clean
- X rm -f tinfo.a term.h tparm.test tputs.test tinfo_g.a
- X rm -f tinfo_p.a ttest sprintf.test clear.tcap clear.tinfo
- X rm -f readcaps.test caps cap2info conv tic
- X rm -f core a.out
- X# rm -rf Shar
- X
- Xall: tinfo.a term.h conv cap2info tic clear
- X
- Xlorder: $(OBJS)
- X rm -f tinfo.a
- X $(AR) $(ARFLAGS) `lorder $(OBJS) | tsort`
- X $(RANLIB) tinfo.a
- X
- X#
- X#.DEFAULT: $(ALLSRCS)
- X# test -f SCCS/s.$< && get SCCS/s.$<
- X#
- X#get:
- X# get SCCS
- X#
- X#edit:
- X# get -e SCCS
- X#
- X#create: $(ALLSRCS)
- X# for i in $(ALLSRCS); do echo $$i:; admin -i$$i -fb -fi -aross SCCS/s.$$i; done
- X#
- X#nuke: spotless
- X# -mv -f $(ALLSRCS) Backup 2> /dev/null
- X# rm -f makerrs
- X#
- X#shar: $(ALLOTHERS)
- X# rm -rf Shar
- X# mkdir Shar
- X# cp $(ALLOTHERS) Shar
- X# (cd Shar;for i in $(ALLSRCS);do echo "$$i:";get -r1 ../SCCS/s.$$i;done)
- X# rm -f Shar/config.h
- X# get -r1.3.1 -p SCCS/s.config.h > Shar/config.h
- X# get -r1.3.2 -p SCCS/s.config.h > Shar/config.h.xenix
- X# get -r1.6.1 -p s.Makefile > Shar/Makefile
- X# chmod u+w Shar/*
- X# (cd Shar; shar -l50 -o"part" -c -v -w -n"tinfo" $(ALL) config.h.xenix)
- SHAR_EOF
- chmod 0644 Makefile || echo "restore of Makefile fails"
- case $TOUCH in
- can)
- touch -am 0402044690 Makefile
- ;;
- esac
- set `wc -c Makefile`;Wc_c=$1
- case "$Wc_c" in
- "5721") ;;
- *) echo original size 5721, current size $Wc_c ;;
- esac
- # ============= TODO ==============
- echo "x - extracting TODO (Text)"
- sed 's/^X//' << 'SHAR_EOF' > TODO &&
- X- SysV R3.2 (R4?) caps (eg. colour)
- X- tinfoconv?
- X- tcapconv: handle cursor key map
- X- better hack for tgoto
- X- don't call bsearch directly
- X- (perfect?) hash table lookup
- X- make tparm work with '%\066'
- X- GNU's tparam
- X- conv: handle translations to termcap
- X- doc's, doc's, doc's
- SHAR_EOF
- chmod 0644 TODO || echo "restore of TODO fails"
- case $TOUCH in
- can)
- touch -am 0402044690 TODO
- ;;
- esac
- set `wc -c TODO`;Wc_c=$1
- case "$Wc_c" in
- "275") ;;
- *) echo original size 275, current size $Wc_c ;;
- esac
- # ============= README ==============
- echo "x - extracting README (Text)"
- sed 's/^X//' << 'SHAR_EOF' > README &&
- XThis is a beta-release. It is public domain, and comes with no guarantees.
- XBy Ross Ridge (ross@contact.uucp).
- X
- XThis library is a merging of termcap and terminfo. It has all termcap and
- Xterminfo functions, and reads both termcap and terminfo databases. It can
- Xalso get terminal descriptions from terminfo source files.
- X
- XThis library is designed useful on sites that use programmes the use
- Xboth the terminfo and termcap databases. New terminal descriptions
- Xdon't need to be added to both, and users maintaining their own private
- Xdatabases wouldn't to have both. Sites that only have termcap can
- Xuse this library to compile programmes that use terminfo, and they don't
- Xneed to have a terminfo database online to use it either.
- X
- XYou should be able to compile this library on almost all versions of
- XUnix. Much of the developement was done on '386 Xenix, but an earlier
- Xversion compiled successfuly under BSD 4.3 with both cc and gcc.
- XThere hasn't been a terrible amount of real world testing of the library
- Xbut it has been used with rn, vi and nethack.
- X
- XThe environment variables TERMCAP and TERMINFO can have multiple filenames
- Xseperated by space a feature not in terminfo and not in all termcaps.
- XThis is very handy users for users that maintain private databases,
- Xas they don't have to copy the entire database.
- X TERMCAP="$HOME/.termcap /etc/termcap"
- X TERMINFO="$HOME/terminfo /usr/lib/terminfo"
- X export TERMCAP TERMINFO
- XThe library will also check in compiled in default locations for terminal
- Xdescriptions. Like most termcaps, the TERMCAP variable can also contain
- Xthe complete termcap terminal description, usually supplied from tset at login.
- XThe TERMINFO variable can also contain a complete terminfo description, but
- Xthere is no programme like tset to supply it.
- X
- XParameterized strings can either be in termcap or terminfo format regardless
- Xof which type of description they come from. Two extensions to the standard
- Xtermcap % codes are supported, GNU's %a, %m, %b, and %f, and the University
- Xof Waterloo's, %-, %a, and %s.
- X
- XUnlike termcap, programmes that use this library can only use capabilities
- Xthat it knows about. However it is fairly simple to add to list of
- Xcapabilities it knows. Included in the list are all terminfo capabilities
- Xto Release 3.0 of System V, obsolete termcap capabilities, a few caps used
- Xby UW, a couple by GNU Emacs, and a few I tacked onto the end.
- X
- XTermcap and terminfo source descriptions can be mixed in one file, however
- Xbecause of this termcap databases must be in a certain style. All contination
- Xlines of a termcap entry must be indented from the left margin by white space.
- XThis shouldn't be a problem with most sites since this is style that most
- Xtermcap files are distributed, but local additions may not adhere to this
- Xstyle. Another possible problem is that termcap entries should end with
- Xa colon (:), but in most distributed termcaps there are entries that
- Xdon't. If a one line termcap entry doesn't end with a colon, it will be
- Xignored.
- X
- XIncluded in the package is conv, an "all-in-one" programme that will compile
- Xterminfo sources to binary format and translate termcap to terminfo.
- X
- XSee the file INSTALL for instructions on configuring and installing this
- Xlibrary. The file README.doc lists the functions supported by the library,
- Xand gives short description of the conv programme. conv.1 is the start
- Xof man page for conv. terminfo.src contains a few sample terminal
- Xdescriptions in terminfo source format.
- X
- XPlease let me know of any bugs you find, and any ideas you have for
- Ximprovement.
- X
- XRoss Ridge
- X
- Xross@contact.uucp
- Xuunet!mnetor!becker!contact!ross
- X(if the above fails you can try these:)
- Xross@watcsc.waterloo.edu
- Xrridge@watmath.waterloo.edu
- SHAR_EOF
- chmod 0644 README || echo "restore of README fails"
- case $TOUCH in
- can)
- touch -am 0402044690 README
- ;;
- esac
- set `wc -c README`;Wc_c=$1
- case "$Wc_c" in
- "3708") ;;
- *) echo original size 3708, current size $Wc_c ;;
- esac
- # ============= README.doc ==============
- echo "x - extracting README.doc (Text)"
- sed 's/^X//' << 'SHAR_EOF' > README.doc &&
- X----------------------------------------------------------------------------
- Xconv [-b] [-c [-OUGd]] [-i] [-B [-D dir]] [-I] [-k] [-t term] [file]
- Xtic [file]
- Xcap2info [-t term] [-OUGdk] [file]
- X
- X-c convert from termcap
- X-i convert from terminfo source
- X-b convert from terminfo binary
- X-B convert to terminfo binary
- X-I convert to terminfo source
- X
- XThe following switches are available when converting from termcap:
- X-d don't supply any defaults for missing capabilities
- X-O include obsolete termcap capabilities
- X-G include GNU capabilities
- X-U include UW capabilities
- X
- X-k keep comments
- X-D dir directory to put terminfo binaries in
- X
- X-t term name of terminal to translate
- Xfile filename of termcap/terminfo database to use
- X
- XIf a file is specifed and no terminal is given the entire file we be translated.
- XIf no terminal and no file is specified then the terminal name will be taken
- Xfrom the environment varible TERM. Unless compiling to a terminfo binary,
- Xoutput is to stdout.
- X----------------------------------------------------------------------------
- X
- Xchar *tparm(char *str, ...); /* up to nine parameters */
- Xchar *tgoto(char *str, int column, int row);
- X
- Xtparm and tgoto support the following termcap and terminfo % codes:
- X
- XTerminfo % Codes
- X
- X %% output a '%'
- X %[[:][-+# ][width][.precision]][doxXs]
- X output pop according to the printf format
- X %c output pop as a char
- X %'c' push character constant c.
- X %{n} push decimal constant n.
- X %p[1-9] push paramter [1-9]
- X %g[a-z] push variable [a-z]
- X %P[a-z] put pop in variable [a-z]
- X %l push the length of pop (a string)
- X %+ add pop to pop and push the result
- X %- subtract pop from pop and push the result
- X %* multiply pop and pop and push the result
- X %& bitwise and pop and pop and push the result
- X %| bitwise or pop and pop and push the result
- X %^ bitwise xor pop and pop and push the result
- X %~ push the bitwise not of pop
- X %= compare if pop and pop are equal and push the result
- X %> compare if pop is less than pop and push the result
- X %< compare if pop is greater than pop and push the result
- X %A logical and pop and pop and push the result
- X %O logical or pop and pop and push the result
- X %! push the logical not of pop
- X %? condition %t if_true [%e if_false] %;
- X if condtion evaulates as true then evaluate if_true,
- X else evaluate if_false. elseif's can be done:
- X%? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %;
- X %i add one to parameters 1 and 2. (ANSI)
- X
- XTermcap Codes
- X
- X %% output a %
- X %. output parameter as a character
- X %d output parameter as a decimal number
- X %2 output parameter in printf format %02d
- X %3 output parameter in printf format %03d
- X %+x add the character x to parameter and output it as a character
- X(UW) %-x subtract parameter FROM the character x and output it as a char
- X(UW) %ax add the character x to parameter
- X(GNU) %a[+*-/=][cp]x
- X GNU arithmetic.
- X(UW) %sx subtract parameter FROM the character x
- X %>xy if parameter > character x then add character y to parameter
- X %B convert to BCD (parameter = (parameter/10)*16 + parameter%16)
- X %D Delta Data encode (parameter = parameter - 2*(paramter%16))
- X %i increment the first two parameters by one
- X %n xor the first two parameters by 0140
- X(GNU) %m xor the first two parameters by 0177
- X %r swap the first two parameters
- X(GNU) %b backup to previous parameter
- X(GNU) %f skip this parameter
- X
- X(GNU) used by GNU Emacs termcap libraries
- X(UW) used by the University of Waterloo (MFCF) termcap libraries
- X
- XNote the two definitions of %a, the GNU defintion is used if the characters
- Xafter the 'a' are valid, otherwise the UW definition is used.
- X----------------------------------------------------------------------------
- X
- Xint setupterm(char *term; int fd; int *err);
- Xint set_curterm(TERMINAL *new);
- Xint del_curterm(TERMINAL *old);
- Xchar *tparm(char *str, ...); /* see above */
- Xint tputs(char *str, int count, int (*putc)());
- Xint putp(str);
- Xint tigetflag(char *cap);
- Xint tigetnum(char *cap);
- Xchar *tigetstr(char *cap);
- Xint def_prog_mode();
- Xint def_shell_mode();
- Xint reset_prog_mode();
- Xint reset_shell_mode();
- Xchar *boolnames[], *boolcodes[], *boolfnames[];
- Xchar *numnames[], *numcodes[], *numfnames[];
- Xchar *strnames[], *strcodes[], *strfnames[];
- X
- XThese functions work just like the terminfo functions. Note, restartterm(),
- Xvidputs(), vidattr(), and mvcur() are not available.
- X----------------------------------------------------------------------------
- X
- Xint tgetent(char *buf, char *term);
- Xint tgetflag(char *cap);
- Xint tgetnum(char *cap);
- Xchar *tgetstr(char *cap, char **area);
- Xchar *tgoto(char *cap, int column, int row);
- Xint tputs(char *str, int count, int (*putc)());
- X
- XThese functions work just like termcap functions.
- X----------------------------------------------------------------------------
- SHAR_EOF
- chmod 0644 README.doc || echo "restore of README.doc fails"
- case $TOUCH in
- can)
- touch -am 0402044690 README.doc
- ;;
- esac
- set `wc -c README.doc`;Wc_c=$1
- case "$Wc_c" in
- "4731") ;;
- *) echo original size 4731, current size $Wc_c ;;
- esac
- # ============= INSTALL ==============
- echo "x - extracting INSTALL (Text)"
- sed 's/^X//' << 'SHAR_EOF' > INSTALL &&
- XTo compile the library you are going to have to edit the Makefile and
- Xthe config.h header. In the Makefile you have to specify the compiler
- Xand any compiler/loader options. config.h will have to be edited to
- Xreflect your compiler, system and to enable certain features.
- X
- X
- XDefines in config.h
- X===================
- X
- XUSE_ANSIC
- X
- XNormally this will be defined automaticly if __STDC__ is defined but
- Xsome compilers lie, so you can undefine this if necessary.
- X
- XUSE_TERMIO
- X
- XDefine this if your system uses the termio tty driver. System III and
- XSystem V use termio.
- X
- XUSE_SGTTY
- X
- XDefine this if your system uses the "sgtty" tty driver. V7 Unix and BSD
- Xuse sgtty.
- X
- XUSE_WINSZ
- X
- XIf you defined USE_SGTTY you can define this if your system supports
- XSIGWINSZ and the accompaning ioctls. If this is defined the library
- Xwill get number of columns and lines from the tty driver not the
- Xterminal description. BSD 4.3 supports SIGWINSZ.
- X
- XDo not define both USE_TERMIO and USE_SGTTY. If your system supports both
- Xyou'd probably be better of defining USE_TERMIO, unless you want to
- Xdefine USE_WINSZ. If your system supports neither termio or sgtty you
- Xcan leave USE_TERMIO and USE_SGTTY undefined, but this only recomened
- Xfor micros.
- X
- XUSE_STRINGS
- X
- XIf you define this then the header file <strings.h> will be included
- Xand BSD type string library assumed (index instead of strchr), otherwise
- X<string.h> will included. If you have BSD type system define this.
- XIf you have an ANSI C, System III, or System V type system leave it
- Xundefined.
- X
- XUSE_MYBSEARCH
- X
- XIf your system's C library doesn't include bsearch, define this.
- XMost System V systems have bsearch.
- X
- XUSE_MYSTRTOK
- X
- XIf your system's C library doesn't include strtok, define this.
- XMost ANSI C, System III, and System V systems have this.
- X
- XUSE_MYQSORT
- X
- XIf your system's C library doesn't include qsort, define this.
- XAll most all systems should have this function, if it doesn't complain
- Xto your vendor.
- X
- XUSE_MEMORY
- X
- XIf your system has a <memory.h> header define this. If USE_MEMORY
- Xis not defined bcopy will used instead of memcpy.
- X
- XUSE_SMALLMEM
- X
- XUse you can define use this to save some memory, but it doesn't
- Xsave much at moment, and will only slow the library down.
- X
- XUSE_FAKE_STDIO
- X
- XIf you define this then the library won't use the real stdio but a
- Xfake one instead. This is for compatiblity with termcap and vi which don't
- Xuse stdio.
- X
- XUSE_DOPRNT
- X
- XIf you don't have a vfprintf function, but you have a _doprnt function
- Xdefine this. If you don't have either than you can compile the library
- Xbut not the support programmes. System V has vfprintf and most Unixes
- Xhave a _doprnt (but probably not documented). BSD has released a freely
- Xdistributable vfprintf for BSD Unixes.
- X
- XUSE_UPBC_KLUDGE
- X
- XDefine this if you want the library's tgoto to work like termcap's tgoto
- Xand avoid putting ^D, and \n into an output string by using the
- Xcursor up and backspace strings.
- X
- XUSE_EXTERN_UPBC
- X
- XIf you defined USE_UPBC_KLUDGE you can define this so tgoto will,
- Xlike termcap's tgoto, get the cursor up and backspace strings from the
- Xexterns UP and BC instead from the libraries internal record.
- X
- XUSE_LITOUT_KLUDGE
- X
- XDon't define this. It's another kludge for tgoto.
- X
- XIf neither USE_UPBC_KLUDGE or USE_LITOUT_KLUDGE is defined than tgoto
- Xwon't worry about putting ^D, and \n in a string.
- X
- XUSE_PROTOTYPES
- X
- XDefine this if your compiler supports ANSI C style prototypes.
- X
- XUSE_STDLIB
- X
- XDefine this if your system has an <stdlib.h> header.
- X
- XUSE_STDARG
- X
- XDefine this if your system has an <stdarg.h> header. If this isn't
- Xdefined <varargs.h> will be included instead.
- X
- XUSE_STDDEF
- X
- XDefine this if your system has an <stddef.h> header. If this isn't
- Xdefined <sys/types.h> will be included instead.
- X
- Xtypedef char *anyptr;
- X
- XYou should change the typedef to a type that any pointer can be assigned
- Xto or from. ANSI C compilers can use "typedef void *anyptr", most
- Xother compilers should use "typedef char *anyptr".
- X
- XTERMCAPFILE
- X
- XDefine this to a string containing the default termcap file(s) to look
- Xfor terminal descriptions in. Multiple filenames should be seperated
- Xby spaces and environment variables can be specfied by prefixing them
- Xwith dolar signs ($).
- X #define TERMCAPFILE "$TERMCAPFILE $HOME/.termcap /etc/termcap"
- X
- XTERMINFOSRC
- X
- XDefine this to a string containing the default terminfo source file to
- Xlook for terminal descriptions in.
- X
- XTERMINFODIR
- X
- XDefine this as the directory containing the default terminfo database,
- Xusually "/usr/lib/terminfo".
- X
- X
- Xdefs.h
- X======
- X
- XYou may also need to edit defs.h. If the type size_t isn't defined
- Xin <stddef.h>, <sys/types.h> or some other header, typedef it somewhere
- Xhere ("typedef unsigned long size_t", or "typedef unsigned size_t").
- XYou may also want to change the definitions of MAX_BUF, MAX_LINE,
- Xand MAX_NAME. Unless you are seriously starved for memory I don't
- Xrecomend making them smaller.
- X
- X
- Xcap_list
- X========
- X
- XYou can add new capabilities to the file cap_list. You must provide
- Xa type, terminfo variable name, terminfo capname, and termcap name for
- Xall capabilities and you must make sure they are all unique.
- X
- X
- XMaking in the library
- X=====================
- X
- XOnce you've configured the package you can just type "make" and it
- Xwill build the library and the "term.h" header. You can enter
- X"make all" to make the library and the support programmes, conv,
- Xcap2info, tic, and caps. If you want a profiled library you can
- Xenter "make profiled". You can remove all the intermediate files
- Xwith "make clean", and you remove the target files as well with
- X"make spotless".
- X
- X
- XInstalling the library
- X======================
- X
- XAs for installing it, that's up to you. Depending on how much you
- Xplan to use the libraries and whether or not you have termcap and/or
- Xterminfo already you can install them "standard" places (ie. /usr/lib,
- X/usr/include, /usr/bin), in local directories, or just leave them in
- Xthe source directory. However if you are compiling programmes that
- Xuse terminfo and linking it with this library you must make sure that
- Xthis library's term.h file is used and not the system supplied one.
- SHAR_EOF
- chmod 0644 INSTALL || echo "restore of INSTALL fails"
- case $TOUCH in
- can)
- touch -am 0402044690 INSTALL
- ;;
- esac
- set `wc -c INSTALL`;Wc_c=$1
- case "$Wc_c" in
- "6056") ;;
- *) echo original size 6056, current size $Wc_c ;;
- esac
- # ============= DECL ==============
- echo "x - extracting DECL (Text)"
- sed 's/^X//' << 'SHAR_EOF' > DECL &&
- Xint setupterm(char *, int, int *);
- Xint set_curterm(TERMINAL *);
- Xint del_curterm(TERMINAL *);
- Xchar *tparm(char *, ...);
- Xint tputs(char *, int, int (*)());
- Xint putp(char *);
- Xint def_prog_mode(void);
- Xint def_shell_mode(void);
- Xint reset_prog_mode(void);
- Xint reset_shell_mode(void);
- Xint tigetnum(char *);
- Xint tigetflag(char *);
- Xchar *tigetstr(char *);
- Xint tgetent(char *, char *);
- Xint tgetnum(char *);
- Xint tgetflag(char *);
- Xchar *tgetstr(char *, char * *);
- Xchar *tgoto(char *, int, int);
- SHAR_EOF
- chmod 0664 DECL || echo "restore of DECL fails"
- case $TOUCH in
- can)
- touch -am 0402044690 DECL
- ;;
- esac
- set `wc -c DECL`;Wc_c=$1
- case "$Wc_c" in
- "483") ;;
- *) echo original size 483, current size $Wc_c ;;
- esac
- # ============= fillterm.c ==============
- echo "x - extracting fillterm.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > fillterm.c &&
- X/*
- X * fillterm.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/22 03:43:31
- X *
- X */
- X
- X#include "defs.h"
- X#include "term.h"
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) fillterm.c 1.1";
- X#endif
- XTERMINAL _term_buf;
- XTERMINAL *cur_term;
- X
- Xint _fillterm(name, path, buf)
- Xchar *name, *buf;
- Xstruct term_path *path; {
- X register int i, r;
- X
- X r = -1;
- X
- X for(i = NUM_OF_BOOLS; i;)
- X _term_buf.bools[--i] = -1;
- X for(i = NUM_OF_NUMS; i;)
- X _term_buf.nums[--i] = -2;
- X for(i = NUM_OF_STRS; i;)
- X _term_buf.strs[--i] = (char *) -1;
- X
- X _term_buf.name_all = NULL;
- X
- X r = _findterm(name, path, buf);
- X switch(r) {
- X case 1:
- X if (_gettcap(buf, &_term_buf, path) != 0)
- X return -3;
- X _tcapconv();
- X _tcapdefault();
- X break;
- X case 2:
- X if (_gettinfo(buf, &_term_buf, path) != 0)
- X return -3;
- X break;
- X case 3:
- X if (_gettbin(buf, &_term_buf) != 0)
- X return -3;
- X break;
- X default:
- X return r;
- X }
- X
- X if ((_term_buf.name = _addstr(name)) == NULL)
- X return -3;
- X
- X for(i = NUM_OF_BOOLS; i;)
- X if (_term_buf.bools[--i] == -1)
- X _term_buf.bools[i] = 0;
- X for(i = NUM_OF_NUMS; i;)
- X if (_term_buf.nums[--i] == -2)
- X _term_buf.nums[i] = -1;
- X for(i = NUM_OF_STRS; i;)
- X if (_term_buf.strs[--i] == (char *) -1)
- X _term_buf.strs[i] = NULL;
- X
- X _term_buf.fd = 1;
- X _term_buf.pad = 1;
- X _term_buf.baudrate = 0;
- X _term_buf.strbuf = _endstr();
- X
- X cur_term = (TERMINAL *) malloc(sizeof(_term_buf));
- X if (cur_term == NULL)
- X return -3;
- X memcpy((anyptr)cur_term, (anyptr)&_term_buf, sizeof(_term_buf));
- X
- X return 1;
- X}
- SHAR_EOF
- chmod 0644 fillterm.c || echo "restore of fillterm.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 fillterm.c
- ;;
- esac
- set `wc -c fillterm.c`;Wc_c=$1
- case "$Wc_c" in
- "1470") ;;
- *) echo original size 1470, current size $Wc_c ;;
- esac
- # ============= findterm.c ==============
- echo "x - extracting findterm.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > findterm.c &&
- X/* findterm.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/22 03:43:31
- X *
- X */
- X
- X#include "defs.h"
- X
- X#include <ctype.h>
- X#include <fcntl.h>
- X#include <sys/stat.h>
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) findterm.c 1.1";
- X#endif
- Xstatic int linecnt;
- X
- Xstatic int getln(f, buf, len)
- XFILE *f;
- Xregister char *buf;
- Xint len; {
- X register int c, i = 0;
- X
- X while((c = getc(f)) == '#') {
- X linecnt++;
- X while((c = getc(f)) != '\n')
- X if (c == EOF)
- X return -1;
- X }
- X
- X while(c != '\n') {
- X if (c == EOF)
- X return -1;
- X if (i < len) {
- X i++;
- X *buf++ = c;
- X }
- X c = getc(f);
- X }
- X
- X while(isspace(*(buf-1))) {
- X buf--;
- X i--;
- X }
- X
- X *buf = '\0';
- X return i;
- X}
- X
- Xint _findterm2(name, file, buf)
- Xchar *name, *buf;
- Xchar *file; {
- X char line[MAX_LINE];
- X FILE *f;
- X register char *sp, *dp;
- X int c;
- X int l;
- X int cont;
- X int fd;
- X struct stat st;
- X
- X linecnt = 0;
- X
- X#ifdef DEBUG
- X printf("open: %s\n", file);
- X#endif
- X fd = open(file, O_RDONLY);
- X if (fd == -1)
- X return -1;
- X if (fstat(fd, &st) == -1)
- X return -1;
- X if ((st.st_mode & 0170000) == 0040000) {
- X sprintf(buf, "%s/%c/%s", file, name[0], name);
- X close(fd);
- X fd = open(buf, O_RDONLY);
- X if (fd == -1)
- X return -1;
- X if (read(fd, buf, MAX_BUF) < 12
- X || buf[0] != 032 || buf[1] != 1) {
- X close(fd);
- X return -1;
- X }
- X close(fd);
- X return 3;
- X }
- X f = fdopen(fd, "r");
- X if (f == NULL)
- X return -1;
- X
- X while ((l = getln(f, buf, MAX_LINE)) != -1) {
- X linecnt++;
- X if (!isspace(buf[0]) && l != 0) {
- X sp = buf + l - 1;
- X cont = 0;
- X switch(*sp) {
- X case '\\':
- X cont = 1;
- X *sp = '\0';
- X /* FALLTHROUGH */
- X case ':':
- X sp = buf;
- X dp = line;
- X while (*sp != ':') {
- X if (*sp == '\0' && cont &&
- X (l = getln(f, buf, MAX_LINE))
- X != -1) {
- X linecnt++;
- X sp = buf;
- X if (l > 0 && buf[l-1] == '\\')
- X cont = 1;
- X else
- X cont = 0;
- X continue;
- X }
- X if (*sp == '\0') {
- X#ifdef DEBUG
- X printf("bad line (%d)\n",
- X linecnt);
- X fclose(f);
- X return -2;
- X#else
- X goto err;
- X#endif
- X }
- X *dp++ = *sp++;
- X }
- X *dp = '\0';
- X if (!_tmatch(line, name))
- X break;
- X l = strlen(buf);
- X dp = buf + l;
- X while((c = getc(f)) != EOF && l < MAX_BUF) {
- X if (c == '\n')
- X break;
- X if (c == '\\') {
- X c = getc(f);
- X if (c == EOF)
- X break;
- X if (c == '\n') {
- X c = getc(f);
- X if (c == EOF)
- X break;
- X if (c == '#') {
- X while((c = getc(f)) != EOF && c != '\n');
- X if (c == EOF)
- X break;
- X continue;
- X }
- X *dp++ = c;
- X continue;
- X }
- X *dp++ = '\\';
- X *dp++ = c;
- X continue;
- X }
- X *dp++ = c;
- X }
- X *dp = '\0';
- X return 1;
- X case ',':
- X sp = buf;
- X dp = line;
- X while(*sp != ',')
- X *dp++ = *sp++;
- X *dp = '\0';
- X if (!_tmatch(line, name))
- X break;
- X dp = buf + l;
- X while ((c = getc(f)) != EOF && l < MAX_BUF) {
- X if (c == '\n') {
- X c = getc(f);
- X if (isspace(c))
- X continue;
- X if (c == '\n') {
- X ungetc(c, f);
- X continue;
- X }
- X if (c == '#') {
- X while((c = getc(f)) != EOF)
- X if (c == '\n')
- X break;
- X if (c == EOF)
- X break;
- X ungetc(c, f);
- X continue;
- X }
- X break;
- X }
- X *dp++ = c;
- X l++;
- X }
- X *dp = '\0';
- X return 2;
- X default:
- X err:
- X#ifdef DEBUG
- X printf("strange line (%d)\n", linecnt);
- X#endif
- X break;
- X }
- X }
- X }
- X return 0;
- X}
- X
- Xint _findterm(name, path, buf)
- Xchar *name;
- Xstruct term_path *path;
- Xchar *buf; {
- X register char *s, *d;
- X int r = 0;
- X while(path->file != NULL) {
- X switch(path->type) {
- X case 0:
- X r = _findterm2(name, path->file, buf);
- X break;
- X case 1:
- X if (path->file[0] == '/') {
- X r = _findterm2(name, path->file, buf);
- X } else {
- X s = path->file;
- X d = buf;
- X while(*s != '\0' && *s != ':')
- X *d++ = *s++;
- X *d = '\0';
- X if (_tmatch(buf, name)) {
- X while(*s != '\0')
- X *d++ = *s++;
- X return 1;
- X }
- X r = 0;
- X }
- X break;
- X case 2:
- X if (path->file[0] == '/') {
- X r = _findterm2(name, path->file, buf);
- X } else {
- X s = path->file;
- X d = buf;
- X while(*s != '\0' && *s != ',')
- X *d++ = *s++;
- X *d = '\0';
- X if (_tmatch(buf, name)) {
- X while(*s != '\0')
- X *d++ = *s++;
- X return 2;
- X }
- X r = 0;
- X }
- X break;
- X default:
- X r = 0;
- X break;
- X }
- X if (r == 1 || r == 2 || r == 3) {
- X#ifdef DEBUG
- X printf("found in %s\n", path->file);
- X#endif
- X break;
- X }
- X path++;
- X }
- X return r;
- X}
- SHAR_EOF
- chmod 0644 findterm.c || echo "restore of findterm.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 findterm.c
- ;;
- esac
- set `wc -c findterm.c`;Wc_c=$1
- case "$Wc_c" in
- "4428") ;;
- *) echo original size 4428, current size $Wc_c ;;
- esac
- # ============= tmatch.c ==============
- echo "x - extracting tmatch.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > tmatch.c &&
- X/*
- X * tmatch.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/22 03:43:32
- X *
- X * See if a terminal name matches a list of terminal names from a
- X * terminal description
- X *
- X */
- X
- X#include "defs.h"
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) tmatch.c 1.1";
- X#endif
- Xint _tmatch(line, name)
- Xchar *line, *name; {
- X char term[MAX_LINE];
- X char *sp, *dp;
- X
- X sp = line;
- X while (*sp != '\0') {
- X dp = term;
- X while (*sp != '\0' && *sp != '|')
- X *dp++ = *sp++;
- X *dp = '\0';
- X if (strcmp(term, name) == 0)
- X return 1;
- X if (*sp == '|')
- X sp++;
- X }
- X return 0;
- X}
- SHAR_EOF
- chmod 0644 tmatch.c || echo "restore of tmatch.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 tmatch.c
- ;;
- esac
- set `wc -c tmatch.c`;Wc_c=$1
- case "$Wc_c" in
- "551") ;;
- *) echo original size 551, current size $Wc_c ;;
- esac
- # ============= terminfo.c ==============
- echo "x - extracting terminfo.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > terminfo.c &&
- X/*
- X * terminfo.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/27 18:29:45
- X *
- X * terminfo compatible libary functions
- X *
- X */
- X
- X#include "defs.h"
- X#include "term.h"
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) terminfo.c 1.2";
- X#endif
- X#ifdef USE_FAKE_STDIO
- X
- Xstatic int printerr(msg)
- Xchar *msg; {
- X return write(2, msg, strlen(msg));
- X}
- X
- X#define RETERR(e, msg) { (err == NULL ? (printerr(msg), exit(1), 0) : (*err = e)); return ERR; }
- X
- X#else
- X
- X#define RETERR(e, msg) { (err == NULL ? (fprintf(stderr, msg), exit(1), 0) : (*err = e)); return ERR; }
- X
- X#endif
- X
- Xint setupterm(term, fd, err)
- Xchar *term;
- Xint fd;
- Xint *err; {
- X struct term_path *path;
- X char *s, *getenv();
- X int r = -1;
- X char buf[MAX_BUF];
- X
- X
- X if (term == NULL)
- X term = getenv("TERM");
- X if (term == NULL)
- X RETERR(0, "TERM not set\n")
- X
- X path = _buildpath("$TERMINFO", 2,
- X "$MYTERMINFO", 2,
- X "$TERMCAP", 1,
- X#ifdef TERMINFODIR
- X TERMINFODIR, 0,
- X#endif
- X#ifdef TERMINFOSRC
- X TERMINFOSRC, 0,
- X#endif
- X#ifdef TERMCAPFILE
- X TERMCAPFILE, 0,
- X#endif
- X NULL, -1);
- X
- X if (path == NULL)
- X RETERR(0, "malloc error\n");
- X
- X r = _fillterm(term, path, buf);
- X
- X _delpath(path);
- X
- X switch(r) {
- X case -3:
- X RETERR(0, "malloc error\n");
- X case -2:
- X RETERR(-1, "bad format\n");
- X case -1:
- X RETERR(-1, "database not found\n");
- X case 0:
- X RETERR(0, "terminal not found\n");
- X case 1:
- X cur_term->fd = fd;
- X _term_buf.fd = fd;
- X if (_init_tty() == ERR)
- X RETERR(0, "problem initializing tty\n");
- X if ((s = getenv("LINES")) != NULL && atoi(s) > 0)
- X lines = atoi(s);
- X if ((s = getenv("COLUMNS")) != NULL && atoi(s) > 0)
- X columns = atoi(s);
- X if (err != NULL)
- X *err = 1;
- X return OK;
- X default:
- X RETERR(0, "oops...\n");
- X }
- X}
- X
- Xint set_curterm(p)
- XTERMINAL *p; {
- X cur_term = p;
- X if (_init_tty() == ERR)
- X return ERR;
- X if (_check_tty() == ERR)
- X return ERR;
- X return OK;
- X}
- X
- Xint del_curterm(p)
- XTERMINAL *p; {
- X _del_strs(p);
- X free((anyptr) p);
- X
- X return OK;
- X}
- SHAR_EOF
- chmod 0644 terminfo.c || echo "restore of terminfo.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 terminfo.c
- ;;
- esac
- set `wc -c terminfo.c`;Wc_c=$1
- case "$Wc_c" in
- "1903") ;;
- *) echo original size 1903, current size $Wc_c ;;
- esac
- # ============= compar.c ==============
- echo "x - extracting compar.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > compar.c &&
- X/*
- X * compar.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/22 03:43:32
- X *
- X */
- X
- X#include "defs.h"
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) compar.c 1.1";
- X#endif
- X/* compare two elements a sorted list of pointers to strings */
- Xint _compar(a, b)
- Xanyptr a, b; {
- X return (strcmp(**(char ***)a, **(char ***)b));
- X}
- SHAR_EOF
- chmod 0644 compar.c || echo "restore of compar.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 compar.c
- ;;
- esac
- set `wc -c compar.c`;Wc_c=$1
- case "$Wc_c" in
- "318") ;;
- *) echo original size 318, current size $Wc_c ;;
- esac
- # ============= termcap.c ==============
- echo "x - extracting termcap.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > termcap.c &&
- X/*
- X * termcap.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/22 03:43:33
- X *
- X * termcap compatibility functions
- X *
- X */
- X
- X#include "defs.h"
- X#include "term.h"
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) termcap.c 1.1";
- X#endif
- Xint tgetent(buf, term)
- Xchar *term, *buf; {
- X char *s, *getenv();
- X struct term_path *path;
- X int r = -1;
- X int fd;
- X
- X if (term == NULL)
- X term = getenv("TERM");
- X if (term == NULL)
- X return 0;
- X
- X path = _buildpath("$TERMCAP", 1,
- X "$MYTERMINFO", 2,
- X "$TERMINFO", 2,
- X#ifdef TERMCAPFILE
- X TERMCAPFILE, 0,
- X#endif
- X#ifdef TERMINFOSRC
- X TERMINFOSRC, 0,
- X#endif
- X#ifdef TERMINFODIR
- X TERMINFODIR, 0,
- X#endif
- X NULL, -1);
- X
- X if (path == NULL)
- X return -1;
- X
- X r = _fillterm(term, path, buf);
- X
- X _delpath(path);
- X
- X switch(r) {
- X case -3:
- X case -2:
- X case -1:
- X return -1;
- X case 0:
- X return 0;
- X case 1:
- X if (isatty(1))
- X fd = 1;
- X else if (isatty(2))
- X fd = 2;
- X else if (isatty(3)) /* V10 /dev/tty ?? */
- X fd = 3;
- X else if (isatty(0))
- X fd = 0;
- X else
- X fd = 1;
- X
- X cur_term->fd = fd;
- X _term_buf.fd = fd;
- X
- X if (_init_tty() == ERR)
- X return 0;
- X if ((s = getenv("LINES")) != NULL && atoi(s) > 0)
- X lines = atoi(s);
- X if ((s = getenv("COLUMNS")) != NULL && atoi(s) > 0)
- X columns = atoi(s);
- X cur_term->termcap = 1;
- X return 1;
- X default:
- X return -1;
- X }
- X}
- X
- Xextern char **_sboolcodes[], **_snumcodes[], **_sstrcodes[];
- X
- Xextern int _compar();
- X
- Xstatic char cap2[3];
- Xstatic char *p2c = cap2;
- Xstatic char **p2p2c = &p2c;
- X
- Xint tgetnum(cap)
- Xchar *cap; {
- X register char ***match;
- X
- X cap2[0] = cap[0];
- X cap2[1] = cap[1];
- X cap2[2] = '\0';
- X
- X match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumcodes,
- X NUM_OF_NUMS, sizeof(char **), _compar);
- X if (match == NULL)
- X return -1;
- X return cur_term->nums[*match - numcodes];
- X}
- X
- Xint tgetflag(cap)
- Xchar *cap; {
- X register char ***match;
- X
- X cap2[0] = cap[0];
- X cap2[1] = cap[1];
- X cap2[2] = '\0';
- X match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolcodes,
- X NUM_OF_BOOLS, sizeof(char **), _compar);
- X if (match == NULL)
- X return 0;
- X return cur_term->bools[*match - boolcodes];
- X}
- X
- Xchar *tgetstr(cap, area)
- Xchar *cap;
- Xchar **area; {
- X register char *sp, *dp;
- X register char ***match;
- X
- X cap2[0] = cap[0];
- X cap2[1] = cap[1];
- X cap2[2] = '\0';
- X
- X match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrcodes,
- X NUM_OF_STRS, sizeof(char **), _compar);
- X if (match == NULL)
- X return NULL;
- X sp = cur_term->strs[*match - strcodes];
- X if (area == NULL || sp == NULL)
- X return sp;
- X dp = *area;
- X while (*sp != '\0')
- X *dp++ = *sp++;
- X *dp++ = '\0';
- X sp = *area;
- X *area = dp;
- X return sp;
- X}
- X
- X
- SHAR_EOF
- chmod 0644 termcap.c || echo "restore of termcap.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 termcap.c
- ;;
- esac
- set `wc -c termcap.c`;Wc_c=$1
- case "$Wc_c" in
- "2565") ;;
- *) echo original size 2565, current size $Wc_c ;;
- esac
- # ============= tputs.c ==============
- echo "x - extracting tputs.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > tputs.c &&
- X/*
- X * tputs.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/27 18:29:20
- X *
- X * Output a terminal capability string with any needed padding
- X *
- X */
- X
- X#include "defs.h"
- X#include "term.h"
- X
- X#include <ctype.h>
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) tputs.c 1.2";
- X#endif
- X#ifdef TEST
- X#define def_prog_mode() (OK)
- X#define _norm_output() ((void)(0))
- X#define _lit_output() (1)
- X#endif
- X
- X/*
- X * BITSPERCHAR (as actually transmitted over a serial line) is usually 10
- X * (not 8). 1 stop bit, 1 start bit, 7 data bits, and one parity bit.
- X */
- X
- X#define BITSPERCHAR 10
- X
- X#ifdef USE_FAKE_STDIO
- X#undef putchar
- X#endif
- X
- X#define PUTCHAR(c) (outc == (int (*)()) 0 ? (putchar(c)):(*outc)(c))
- X
- Xint tputs(sp, count, outc)
- Xregister char *sp;
- Xint count;
- Xregister int (*outc)();
- X{
- X register int l;
- X register long cnt;
- X int must_pad, multiply_pad;
- X int forced_lit = 0;
- X
- X if (cur_term->termcap) {
- X _figure_termcap();
- X }
- X
- X while(*sp != '\0') {
- X switch(*sp) {
- X case '\\':
- X switch(*++sp) {
- X case 'n': PUTCHAR('\n'); sp++; break;
- X case 'b': PUTCHAR('\b'); sp++; break;
- X case 't': PUTCHAR('\t'); sp++; break;
- X case 'r': PUTCHAR('\r'); sp++; break;
- X case 'f': PUTCHAR('\f'); sp++; break;
- X case 'l': PUTCHAR('\012'); sp++; break;
- X case 's': PUTCHAR(' '); sp++; break;
- X case 'e': case 'E': PUTCHAR('\033'); sp++; break;
- X
- X case '^':
- X case '\\':
- X case ',':
- X case ':':
- X case '\'':
- X case '$':
- X PUTCHAR(*sp++);
- X break;
- X
- X case '0':
- X if (*(sp + 1) < '0' || *(sp + 1) > '7') {
- X PUTCHAR('\200'); /* I'd prefer \0 */
- X sp++;
- X break;
- X }
- X ;/* FALLTHROUGH */
- X case '1': case '2': case '3': case '4':
- X case '5': case '6': case '7':
- X l = *sp++ - '0';
- X if (*sp >= '0' && *sp <= '7') {
- X l = l * 8 + (*sp++ - '0');
- X if (*sp >= '0' && *sp <= '7')
- X l = l * 8 + (*sp++ - '0');
- X }
- X PUTCHAR(l);
- X break;
- X
- X case '\0':
- X PUTCHAR('\\');
- X break;
- X
- X case '@':
- X if (!forced_lit)
- X forced_lit = _lit_output();
- X sp++;
- X break;
- X
- X default:
- X PUTCHAR('\\');
- X PUTCHAR(*sp++);
- X break;
- X }
- X break;
- X case '^':
- X if (*++sp == '\0')
- X break;
- X l = *sp - '@';
- X if (l > 31)
- X l -= 32;
- X if (l < 0 || l > 31) {
- X PUTCHAR('^');
- X PUTCHAR(*sp++);
- X } else {
- X PUTCHAR(l);
- X sp++;
- X }
- X break;
- X case '$':
- X if (*++sp != '<') {
- X PUTCHAR('$');
- X break;
- X }
- X must_pad = 0;
- X multiply_pad = 0;
- X l = 0;
- X sp++;
- X while (isdigit(*sp))
- X l = l * 10 + (*sp++ - '0');
- X l *= 10;
- X if (*sp == '.') {
- X sp++;
- X if (isdigit(*sp))
- X l += *sp++ - '0';
- X }
- X if (*sp == '/') {
- X must_pad = 1;
- X if (*++sp == '*') {
- X multiply_pad = 1;
- X sp++;
- X }
- X } else if (*sp == '*') {
- X multiply_pad = 1;
- X if (*++sp == '/') {
- X must_pad = 1;
- X sp++;
- X }
- X }
- X if (*sp != '>') {
- X PUTCHAR('p');
- X PUTCHAR('a');
- X PUTCHAR('d');
- X PUTCHAR('?');
- X break;
- X }
- X sp++;
- X#ifdef TEST
- X printf("\nl = %d", l);
- X#endif
- X if (cur_term->pad || must_pad) {
- X cnt = ((long) l * cur_term->baudrate * (multiply_pad ? count : 1) + (10000 * BITSPERCHAR / 2)) / (10000 * BITSPERCHAR);
- X#ifdef TEST
- X printf("; cnt = %d\n", cnt);
- X#endif
- X while(cnt--)
- X PUTCHAR(cur_term->padch);
- X }
- X#ifdef TEST
- X printf("\n");
- X#endif
- X break;
- X default:
- X PUTCHAR(*sp++);
- X }
- X }
- X if (forced_lit)
- X _norm_output();
- X return OK;
- X}
- X
- Xint putp(str)
- Xchar *str; {
- X return(tputs(str, 1,(int (*)()) 0));
- X}
- X
- X#ifdef TEST
- X
- XTERMINAL test_term, *cur_term = &test_term;
- X
- Xvoid putch(c)
- Xint c; {
- X c &= 0xff;
- X if (c > 127 || c < 0) {
- X printf("\\%03o", c);
- X } else if (c < 32) {
- X printf("^%c", c + '@');
- X } else if (c == 127) {
- X printf("^?");
- X } else {
- X putchar(c);
- X }
- X}
- X
- Xchar line[MAX_LINE];
- X
- Xint main(argc, argv)
- Xint argc;
- Xchar **argv; {
- X test_term.termcap = 0;
- X test_term.baudrate = 1200;
- X test_term.pad = 0;
- X test_term.padch = 0;
- X if (argc > 1)
- X test_term.baudrate = atoi(argv[1]);
- X if (argc > 2)
- X test_term.padch = argv[2][0];
- X if (argc > 3)
- X test_term.pad = 1;
- X
- X putchar('\n');
- X
- X while(gets(line) != NULL) {
- X tputs(line, 7, putch);
- X putchar('\n');
- X }
- X return 0;
- X}
- X#endif
- SHAR_EOF
- chmod 0644 tputs.c || echo "restore of tputs.c fails"
- case $TOUCH in
- can)
- touch -am 0402044690 tputs.c
- ;;
- esac
- set `wc -c tputs.c`;Wc_c=$1
- case "$Wc_c" in
- "4051") ;;
- *) echo original size 4051, current size $Wc_c ;;
- esac
- # ============= tty.c ==============
- echo "x - extracting tty.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > tty.c &&
- X/*
- X * tty.c
- X *
- X * By Ross Ridge
- X * Public Domain
- X * 90/03/22 03:43:34
- X *
- X * Do some tty related things
- X *
- X */
- X
- X#include "defs.h"
- X#include "term.h"
- X
- X#ifdef USE_SCCS_IDS
- Xstatic char SCCSid[] = "@(#) tty.c 1.1";
- X#endif
- X#ifndef EXTA_IS
- X#define EXTA_IS 19200
- X#endif
- X
- X#ifndef EXTB_IS
- X#define EXTB_IS 38400
- X#endif
- X
- X#ifdef lint
- X#define ioctl _ioctl
- X/* shutup lint */
- X/* ARGSUSED */
- X/* VARARGS2 */
- Xint ioctl(a, b, p) int a; long b; anyptr *p; { return 0; }
- X#endif
- X
- X#ifdef USE_TERMIO
- X
- X#ifdef USE_SMALLMEM
- Xunsigned short _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
- X 1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
- X#else
- Xlong _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
- X 2400, 4800, 9600, EXTA_IS, EXTB_IS};
- X#endif
- X
- Xstatic struct termio old;
- X
- Xint _lit_output() {
- X struct termio tmp;
- X ioctl(cur_term->fd, TCGETA, &old);
- X if (!(old.c_oflag & OPOST) || !(old.c_oflag & ONLCR))
- X return 0;
- X memcpy((anyptr)&tmp, (anyptr)&old, sizeof(old));
- X tmp.c_oflag &= ~OPOST;
- X ioctl(cur_term->fd, TCSETA, &tmp);
- X return 0;
- X}
- X
- Xvoid _norm_output() {
- X ioctl(cur_term->fd, TCSETA, &old);
- X}
- X
- Xint _check_tty() {
- X if ((cur_term->prog_mode.c_iflag & IXON) && cur_term->xon)
- X cur_term->pad = 0;
- X else
- X cur_term->pad = 1;
- X cur_term->baudrate = _baud_tbl[cur_term->prog_mode.c_cflag & CBAUD];
- X return OK;
- X}
- X
- Xint def_prog_mode() {
- X if (ioctl(cur_term->fd, TCGETA, &cur_term->prog_mode) == 0
- X && _check_tty() == OK)
- X return OK;
- X return ERR;
- X}
- X
- Xint def_shell_mode() {
- X cur_term->termcap = 0;
- X return ioctl(cur_term->fd, TCGETA, &cur_term->shell_mode)==0 ? OK : ERR;
- X}
- X
- Xint reset_prog_mode() {
- X return ioctl(cur_term->fd, TCSETA, &cur_term->prog_mode)==0 ? OK : ERR;
- X}
- X
- Xint reset_shell_mode() {
- X return ioctl(cur_term->fd, TCSETA, &cur_term->shell_mode)==0 ? OK : ERR;
- X}
- X
- Xint _init_tty() {
- X cur_term->true_lines = lines;
- X cur_term->true_columns = columns;
- X if (pad_char == NULL)
- X cur_term->padch = '\000';
- X else
- X cur_term->padch = pad_char[0];
- X cur_term->xon = xon_xoff && (xon_character == NULL || xon_character[0] == '\023') && (xoff_character == NULL || xoff_character[0] == '\021');
- X return def_shell_mode()==ERR ? ERR : def_prog_mode()==ERR ? ERR : OK;
- X}
- X
- X#else
- X
- X#ifdef USE_SGTTY
- X
- X#ifdef USE_SMALLMEM
- Xunsigned short _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
- X 1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
- X#else
- Xlong _baud_tbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
- X 1800, 2400, 4800, 9600, EXTA_IS, EXTB_IS};
- X#endif
- X
- X
- X#ifdef TIOCLGET
- X
- Xstatic int old;
- X
- Xint _lit_output() {
- X struct sgttyb buf;
- X int tmp;
- X
- X ioctl(cur_term->fd, TIOCGETP, &buf);
- X if (buf.sg_flags & RAW)
- X return 0;
- X ioctl(cur_term->fd, TIOCLGET, &old);
- X if (old & LLITOUT)
- X return 0;
- X tmp = old | LLITOUT;
- X ioctl(cur_term->fd, TIOCLSET, &tmp);
- X return 1;
- X}
- X
- Xvoid _norm_output() {
- X ioctl(cur_term->fd, TIOCLSET, &old);
- X}
- X
- X#else
- X
- Xstatic struct sgttyb old;
- X
- Xint _lit_output() {
- X struct sgttyb tmp;
- X ioctl(cur_term->fd, TIOCGETP, &old);
- X if (old.sg_flags & RAW)
- X return 0;
- X memcpy((anyptr)&tmp, (anyptr)&old, sizeof(old));
- X tmp.sg_flags |= RAW;
- X ioctl(cur_term->fd, TIOCSETP, &tmp);
- X return 1;
- X}
- X
- Xvoid _norm_output() {
- X ioctl(cur_term->fd, TIOCSETP, &old);
- X}
- X
- X#endif
- X
- Xint _check_tty() {
- X if (!(cur_term->prog_mode.v6.sg_flags & RAW) && cur_term->xon)
- X cur_term->pad = 0;
- X else
- X cur_term->pad = 1;
- X cur_term->baudrate = _baud_tbl[cur_term->prog_mode.v6.sg_ospeed & 0xf];
- X return OK;
- X}
- X
- Xint def_shell_mode() {
- X if (ioctl(cur_term->fd, TIOCGETP, &cur_term->shell_mode.v6) < 0)
- X return ERR;
- X#ifdef TIOCGETC
- X if (ioctl(cur_term->fd, TIOCGETC, &cur_term->shell_mode.v7) < 0)
- X return ERR;
- X#endif
- X#ifdef TIOCLGET
- X if (ioctl(cur_term->fd, TIOCLGET, &cur_term->shell_mode.bsd) < 0)
- X return ERR;
- X#endif
- X#ifdef TIOCGLTC
- X if (ioctl(cur_term->fd, TIOCGLTC, &cur_term->shell_mode.bsd_new) < 0)
- X return ERR;
- X#endif
- X#ifdef USE_WINSZ
- X#ifdef TIOCGWINSZ
- X if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->shell_mode.bsd_winsz)<0)
- X return ERR;
- X#endif
- X#endif
- X cur_term->termcap = 0;
- X return OK;
- X}
- X
- Xint def_prog_mode() {
- X if (ioctl(cur_term->fd, TIOCGETP, &cur_term->prog_mode.v6) < 0)
- X return ERR;
- X#ifdef TIOCGETC
- X if (ioctl(cur_term->fd, TIOCGETC, &cur_term->prog_mode.v7) < 0)
- X return ERR;
- X#endif
- X#ifdef TIOCLGET
- X if (ioctl(cur_term->fd, TIOCLGET, &cur_term->prog_mode.bsd) < 0)
- X return ERR;
- X#endif
- X#ifdef TIOCGLTC
- X if (ioctl(cur_term->fd, TIOCGLTC, &cur_term->prog_mode.bsd_new) < 0)
- X return ERR;
- X#endif
- X#ifdef USE_WINSZ
- X#ifdef TIOCGWINSZ
- X if (ioctl(cur_term->fd, TIOCGWINSZ, &cur_term->prog_mode.bsd_winsz)<0)
- X return ERR;
- X#endif
- X#endif
- X return _check_tty();
- X}
- X
- Xint reset_shell_mode() {
- X if (ioctl(cur_term->fd, TIOCSETP, &cur_term->shell_mode.v6) < 0)
- X return ERR;
- X#ifdef TIOCGETC
- X if (ioctl(cur_term->fd, TIOCSETC, &cur_term->shell_mode.v7) < 0)
- X return ERR;
- X#endif
- X#ifdef TIOCLGET
- X if (ioctl(cur_term->fd, TIOCLSET, &cur_term->shell_mode.bsd) < 0)
- X return ERR;
- X#endif
- X#ifdef TIOCGLTC
- X if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->shell_mode.bsd_new) < 0)
- X return ERR;
- X#endif
- X return OK;
- X}
- SHAR_EOF
- echo "End of tinfo part 1"
- echo "File tty.c is continued in part 2"
- echo "2" > s3_seq_.tmp
- exit 0
- --
- Ross Ridge //
- "The Great HTMU" [oo]
- ross@contact.uucp -()-
- ross@watcsc.waterloo.edu //
-
-
-