home *** CD-ROM | disk | FTP | other *** search
- From: wht@n4hgf.atl.ga.us (Warren Tucker)
- Newsgroups: comp.sources.misc
- Subject: v42i122: ecu - ECU Asynchronous Communications v3.30, Part24/37
- Date: 24 May 1994 09:07:25 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2rt1mt$d46@sparky.sterling.com>
- X-Md4-Signature: 9f3350e0dbccaaf01efce4cb646b6eab
-
- Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
- Posting-number: Volume 42, Issue 122
- Archive-name: ecu/part24
- Environment: SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2
- Supersedes: ecu: Volume 32, Issue 36-75
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: ecu330/Make.src ecu330/ecupde.c ecu330/ecutcap.c
- # ecu330/kbdtest3.c
- # Wrapped by kent@sparky on Mon May 23 13:40:59 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 24 (of 37)."'
- if test -f 'ecu330/Make.src' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/Make.src'\"
- else
- echo shar: Extracting \"'ecu330/Make.src'\" \(10236 characters\)
- sed "s/^X//" >'ecu330/Make.src' <<'END_OF_FILE'
- X#+-------------------------------------------------------------------
- X# Make.src - master Makefile source for ECU and related programs
- X# If THIS line is the third in the file you are reading, refer to
- X# the files README and Configure.
- X# wht@n4hgf.atl.ga.us
- X#--------------------------------------------------------------------
- X#+:EDITS:
- X#:05-04-1994-04:38-wht@n4hgf-ECU release 3.30
- X#:04-21-1994-16:26-wht@n4hgf-remove timetest
- X#:01-16-1994-15:53-wht@n4hgf-add ecumachdep.h
- X#:11-25-1993-15:16-wht@n4hgf-3.281-all: fixed
- X#:11-23-1993-10:56-wht@n4hgf-hpux and linux
- X#:07-14-1993-02:39-wht@n4hgf-'depecu' entry for make depend ecu alone
- X#:03-05-1993-13:24-wht@n4hgf-use mk.cpio to make cpio
- X#:09-10-1992-13:58-wht@n4hgf-ECU release 3.20
- X#:08-22-1992-15:37-wht@n4hgf-ECU release 3.20 BETA
- X#:07-17-1992-18:23-wht@n4hgf-new module nap.c
- X#:07-07-1992-20:04-wht@n4hgf-new installation mechanism
- X#:05-17-1992-18:50-wht@n4hgf-add cpio
- X#:02-10-1992-05:47-wht@n4hgf-mcs avail on some systems when non-COFF produced
- X#:09-03-1991-23:47-wht@n4hgf2-add timetest directory
- X#:09-02-1991-19:25-wht@n4hgf2-ckutio dif and fas.h left out of distribution
- X#:09-01-1991-16:22-wht@n4hgf2-generalize HDB config location
- X#:08-23-1991-13:35-wht@n4hgf-sun porting (3.13)
- X#:07-25-1991-12:55-wht@n4hgf-ECU release 3.10
- X#:04-21-1991-12:43-wht@n4hgf-convert to Make.src
- X
- XPROGRAM = ecu
- XINSTALLABLE = $(LBIN)/$(PROGRAM)
- X
- XECUSHARNAME=ecu330
- XMANSHARNAME=ecuman330
- X
- XLIBFUNCKEYMAP = $(ECULIBDIR)/funckeymap
- X
- XSHELL = /bin/sh
- X
- X.SUFFIXES:
- X.SUFFIXES: .o .c .h .l
- X.c.o:; $(BINTIME) $(CC) -c $(CFLAGS) $*.c
- X
- X
- XSRC = \
- X afterlint.c \
- X bamboozle.c \
- X cmdtbl.c \
- X config.c \
- X dutmp.c \
- X ecu.c \
- X ecuDCE.c \
- X ecuLCK.c \
- X ecuchdir.c \
- X ecudump.c \
- X ecufinsert.c \
- X ecufkey.c \
- X ecufork.c \
- X ecugrabbag.c \
- X ecuicmaux.c \
- X ecuicmd.c \
- X ecuicmhelp.c \
- X ecuicmhist.c \
- X eculine.c \
- X eculock.c \
- X ecunumrev.c \
- X ecupde.c \
- X ecuphdir.c \
- X ecuphrase.c \
- X ecurcvr.c \
- X ecuscrdump.c \
- X ecusetup.c \
- X ecushm.c \
- X ecusighdl.c \
- X ecutcap.c \
- X ecutermio.c \
- X ecutime.c \
- X ecutty.c \
- X ecuuclc.c \
- X ecuusage.c \
- X ecuutil.c \
- X ecuwinutil.c \
- X ecuxfer.c \
- X esdutil.c \
- X expresp.c \
- X fasiintf.c \
- X feval.c \
- X funckeymap.c \
- X gendiff.c \
- X gint.c \
- X gstr.c \
- X hdbintf.c \
- X kbdtest.c \
- X kbdtest3.c \
- X logevent.c \
- X lstat.c \
- X makedirs.c \
- X mkdirs.c \
- X nap.c \
- X pcmd.c \
- X pcmdfile.c \
- X pcmdif.c \
- X pcmdtty.c \
- X pcmdwhile.c \
- X pcmdxfer.c \
- X poutput.c \
- X pprintf.c \
- X proc.c \
- X proc_error.c \
- X procframe.c \
- X regexp.c \
- X smap.c \
- X ttynaming.c \
- X ugtext.c \
- X utmpstat.c \
- X var.c
- X
- XOBJ = \
- X bamboozle.o\
- X cmdtbl.o\
- X ecu.o\
- X ecuLCK.o\
- X ecudump.o\
- X ecuchdir.o\
- X ecufinsert.o\
- X ecufkey.o\
- X ecufork.o\
- X ecuDCE.o\
- X eculine.o\
- X eculock.o\
- X ecunumrev.o\
- X ecuicmaux.o\
- X ecuicmhelp.o\
- X ecuicmhist.o\
- X ecuicmd.o\
- X ecugrabbag.o\
- X ecupde.o\
- X ecuphdir.o\
- X ecuphrase.o\
- X ecurcvr.o\
- X ecuscrdump.o\
- X ecusetup.o\
- X ecushm.o\
- X ecusighdl.o\
- X ecutcap.o\
- X ecutermio.o\
- X ecutime.o\
- X ecutty.o\
- X ecuuclc.o\
- X ecuusage.o\
- X ecuutil.o\
- X ecuwinutil.o\
- X ecuxfer.o\
- X esdutil.o\
- X fasiintf.o\
- X expresp.o\
- X feval.o\
- X gint.o\
- X gstr.o\
- X hdbintf.o\
- X logevent.o\
- X lstat.o\
- X nap.o \
- X mkdirs.o\
- X funckeymap.o\
- X pcmd.o\
- X pcmdif.o\
- X pcmdfile.o\
- X pcmdtty.o\
- X pcmdwhile.o\
- X pcmdxfer.o\
- X poutput.o\
- X pprintf.o\
- X proc.o\
- X proc_error.o\
- X procframe.o\
- X regexp.o\
- X ttynaming.o\
- X ugtext.o\
- X utmpstat.o\
- X var.o
- X
- XHDR = \
- X dialprog.h \
- X dlent.h \
- X dvent.h \
- X ecu.h \
- X ecu_config.h \
- X ecu_pwd.h \
- X ecu_stat.h \
- X ecu_time.h \
- X ecu_types.h \
- X ecucmd.h \
- X ecucurses.h \
- X ecuerror.h \
- X ecufkey.h \
- X ecufork.h \
- X ecukey.h \
- X ecupde.h \
- X ecumachdep.h \
- X ecushm.h \
- X ecutermio.h \
- X ecutty.h \
- X ecuungetty.h \
- X ecuxkey.h \
- X esd.h \
- X feval.h \
- X patchlevel.h \
- X pc_scr.h \
- X proc.h \
- X relop.h \
- X smap.h \
- X termecu.h \
- X ttynaming.h \
- X utmpstatus.h \
- X var.h
- X
- XSHARFLS = \
- X README* \
- X BUGS \
- X CHANGES \
- X HISTORY \
- X ESOTERIC \
- X Configure \
- X Make.src */Make.src \
- X mk.cpio \
- X $(SRC) $(HDR) \
- X bperr/bperr.c \
- X help/{*.[ch],ecuhelp.src} \
- X ecuungetty/*.[ch] \
- X z/*.[ch] \
- X sea/{*.[ch],*.{doc,imp}} \
- X gendial/{README,install_dialer,*.[ch]} \
- X fasi/{Makefile,Master,Node,PATCHLEVEL} \
- X fasi/{README,README.FASI,RELEASENOTES} \
- X fasi/{Space.c,System,digi-pc8.h,fas.c,fas.h,idfasi} \
- X ecufriend/*.[ch] \
- X mapkey/README mapkey/keys.usa.ecu \
- X xsel386/* \
- X old_notes/README.* \
- X doc/{README,Makefile,*.txt} models/* zgcc mkoldproto.l
- X
- XMAKEDIRS_OBJ =\
- X makedirs.o\
- X mkdirs.o\
- X lstat.o
- X
- Xall: $(PROGRAM) .make.help .make.ug .make.z .make.s kbdtest3 makedirs
- X
- X$(PROGRAM): $(OBJ)
- X echo 'char *makedate="@(#)'ecu `date` $(SYSTEM)'";' >makedate.c
- X $(CC) -c $(CFLAGS) makedate.c; rm makedate.c
- X rm -f $@ $@~; if [ -f $@ ]; then mv $@ $@~; fi
- X $(BINTIME) $(CC) -o $@ $(LDFLAGS) makedate.o $(OBJ) $(LIBS)
- X rm makedate.o
- X
- X$(OBJ): Makefile
- X
- X.make.help:
- X cd help; $(MAKE)
- X
- X.make.z:
- X cd z; $(MAKE)
- X
- X.make.s:
- X cd sea; $(MAKE)
- X
- X.make.ug:
- X if [ $(CFG_UseUngetty) = yes ]; then \
- X cd ecuungetty; $(MAKE); \
- X fi
- X
- Xbperr/bperr: bperr/bperr.c
- X cd bperr; $(MAKE) bperr
- X
- Xproc_error.c: ecuerror.h
- X $(MAKE) bperr/bperr
- X bperr/bperr
- X
- Xkbdtest3: kbdtest3.c ecutermio.o
- X $(CC) -o $@ $(CFLAGS) kbdtest3.c ecutermio.o
- X
- X$(OBJ): ecushm.h
- X
- Xecu.fls: Makefile
- X ls $(SRC) >ecu.fls
- X
- X# Not recommended
- Xprotos: ecu.fls afterlint mkoldproto
- X echo ' ' > protos.h
- X csh ./zgcc ecu.fls protos.h .
- X
- X# Not recommended
- Xallprotos:
- X $(MAKE) protos
- X cd z; $(MAKE) protos
- X cd sea; $(MAKE) protos
- X
- Xmakedirs: $(MAKEDIRS_OBJ)
- X $(CC) -o $@ $(LDFLAGS) $(MAKEDIRS_OBJ) $(LIBS)
- X
- X# install ecu
- Xiecu: makedirs ecu
- X @echo Installing ECU in $(LBIN) and $(ECULIBDIR) ... please wait
- X @if [ ! -d $(LBIN) ]; then \
- X echo '\012'Attempting to make $(LBIN); \
- X ./makedirs -m 755 $(LBIN); \
- X ls -ld $(LBIN); \
- X fi
- X @rm -f $(INSTALLABLE) $(INSTALLABLE)~
- X @if [ -f $(INSTALLABLE) ]; then \
- X echo '\012'Cannot remove $(INSTALLABLE) - moving to $(INSTALLABLE)~ \
- X mv $(INSTALLABLE) $(INSTALLABLE)~; \
- X fi
- X @cp $(PROGRAM) $(INSTALLABLE)
- X @strip $(INSTALLABLE)
- X @-if [ -x /usr/bin/mcs ]; then \
- X /usr/bin/mcs -d $(INSTALLABLE) || echo mcs present but not COFF? ; \
- X fi
- X @chown bin $(INSTALLABLE)
- X @chgrp bin $(INSTALLABLE)
- X @chmod 711 $(INSTALLABLE)
- X @echo '\012'Installed
- X @ls -l $(INSTALLABLE)
- X @if [ ! -d $(ECULIBDIR) ]; then \
- X echo '\012'Attempting to make $(ECULIBDIR); \
- X ./makedirs -m 755 $(ECULIBDIR); \
- X ls -ld $(ECULIBDIR); \
- X fi
- X @-if [ -f $(LIBFUNCKEYMAP) ]; then \
- X echo '\012'Saving your old $(LIBFUNCKEYMAP); \
- X for i in 2 1; \
- X do \
- X j=`expr $$i + 1`; \
- X mv $(LIBFUNCKEYMAP)-$$i $(LIBFUNCKEYMAP)-$$j 2>/dev/null; \
- X done; \
- X mv $(LIBFUNCKEYMAP) $(LIBFUNCKEYMAP)-1; \
- X ls -l $(LIBFUNCKEYMAP)*; \
- X fi
- X @cp models/funckeymap $(ECULIBDIR)
- X @chown bin $(LIBFUNCKEYMAP)
- X @chgrp bin $(LIBFUNCKEYMAP)
- X @chmod 644 $(LIBFUNCKEYMAP)
- X @echo '\012'Installed
- X @ls -l $(LIBFUNCKEYMAP)
- X
- X# install everything
- Xinstall: all makedirs #run as root
- X @echo '\012'Starting full installation of ECU ... please wait
- X @make iecu
- X @if [ $(CFG_UseUngetty) = yes ]; then \
- X cd ecuungetty; $(MAKE) install; \
- X fi
- X cd z; $(MAKE) install
- X cd sea; $(MAKE) install
- X cd help; $(MAKE) install
- X @if [ ! -f $(HDBLIBDIR)/Devices ]; then \
- X cp models/*.mi $(ECULIBDIR); \
- X echo "==> edit $(ECULIBDIR)/*.mi for your tty lines per ecu.man"; \
- X fi
- X @echo '\012'Installation complete. Follow the yellow brick road.
- X
- Xshar.fls: Makefile
- X echo patchlevel.h > shar.fls
- X csh -c 'ls $(SHARFLS) | sed -e "/patchlevel.h/d" | sort >> shar.fls'
- X
- X#for the author's laziness
- Xgendiff:
- X gendiff -f -o ../ecu-3.30 -n Patch01 `cat shar.fls`
- X
- X# for shar 3.461
- Xshar: shar.fls
- X echo 'shar -F -c -s "wht@n4hgf.atl.ga.us" -a \
- X -E 'SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2' \
- X -n$(ECUSHARNAME) -L57 -o/tmp/$(ECUSHARNAME) $(SHARFLS)' > /tmp/ecu.csh.in
- X csh /tmp/ecu.csh.in
- X rm /tmp/ecu.csh.in
- X cd doc;make
- X shar -F -c -s "wht@n4hgf.atl.ga.us" -a \
- X -E 'SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2' \
- X -n$(MANSHARNAME) -L57 -o/tmp/$(MANSHARNAME) doc/ecu.man doc/proc.man
- X
- Xcpio: shar.fls
- X ./mk.cpio /tmp/$(ECUSHARNAME).cpio
- X
- X# tools for making ecu
- Xafterlint: afterlint.c
- X cc -O afterlint.c -o $@
- X -if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $@; fi
- X strip $@
- X
- Xmkoldproto: mkoldproto.l
- X lex mkoldproto.l
- X cc -O lex.yy.c -ll -o $@
- X -if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $@; fi
- X strip $@
- X rm lex.yy.?
- X
- Xneat:
- X rm -f core tags cscope.out makedate.c makedate.o
- X rm -f *~ *# *.orig *.rej make.log a.out
- X rm -f */*~ */*# */*.orig */*.rej
- X rm -f makedirs kbdtest kbdtest3
- X rm -f shar.fls cpio.fls /tmp/ecu.cpio.fls
- X rm -f .make.* depend.tmp eddep.tmp Makefile.new *.bak *.BAK
- X -cd help; $(MAKE) neat
- X -cd z; $(MAKE) neat
- X -cd sea; $(MAKE) neat
- X -cd bperr; $(MAKE) neat
- X -if [ $(CFG_UseUngetty) = yes ]; then \
- X cd ecuungetty; $(MAKE) neat; \
- X fi
- X
- Xclean: neat
- X rm -f $(OBJ) makedirs.o
- X rm -f config kbdtest kbdtest3 makedirs afterlint mkoldproto
- X -cd help; $(MAKE) clean
- X -cd z; $(MAKE) clean
- X -cd sea; $(MAKE) clean
- X -cd bperr; $(MAKE) clean
- X -if [ $(CFG_UseUngetty) = yes ]; then \
- X cd ecuungetty; $(MAKE) clean; \
- X fi
- X -if [ -f gendial/Makefile ]; then \
- X cd gendial; $(MAKE) clean; \
- X fi
- X -if [ -f timetest/Makefile ]; then \
- X cd timetest; $(MAKE) clean; \
- X fi
- X
- Xclobber: clean
- X rm -f $(PROGRAM) $(PROGRAM)~
- X rm -f kbdtest3.out
- X -cd help; $(MAKE) clobber
- X -cd z; $(MAKE) clobber
- X -cd sea; $(MAKE) clobber
- X -cd bperr; $(MAKE) clobber
- X -if [ $(CFG_UseUngetty) = yes ]; then \
- X cd ecuungetty; $(MAKE) clobber; \
- X fi
- X
- X#regenerate .o:.h dependencies automatically
- Xdepecu:
- X rm -f depend.tmp
- X grep '^#include' $(SRC) \
- X | sed \
- X -e '/</d'\
- X -e 's?:[^"]*"\([^"]*\)".*?: \1?'\
- X -e 's?\(.*\)\.c?\1.o?'\
- X >> depend.tmp
- X
- X echo '/^# DO NOT DELETE THIS LINE' >eddep.tmp
- X echo '.+1,$$d' >>eddep.tmp
- X echo 'r depend.tmp' >> eddep.tmp
- X echo 'w' >> eddep.tmp
- X cp Makefile Makefile.new
- X ed Makefile.new < eddep.tmp
- X rm eddep.tmp depend.tmp
- X echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile.new
- X echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY'>>Makefile.new
- X echo '# see make depend above'>>Makefile.new
- X mv Makefile Makefile.bak
- X mv Makefile.new Makefile
- X
- Xdepend: depecu
- X cd help; $(MAKE) depend
- X cd z; $(MAKE) depend
- X cd sea; $(MAKE) depend
- X if [ $(CFG_UseUngetty) = yes ]; then \
- X cd ecuungetty; $(MAKE) depend; \
- X fi
- X
- X# DO NOT DELETE THIS LINE
- X# DEPENDENCIES MUST END AT END OF FILE
- X# IF YOU PUT STUFF HERE IT WILL GO AWAY
- X# see make depend above
- END_OF_FILE
- if test 10236 -ne `wc -c <'ecu330/Make.src'`; then
- echo shar: \"'ecu330/Make.src'\" unpacked with wrong size!
- fi
- # end of 'ecu330/Make.src'
- fi
- if test -f 'ecu330/ecupde.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecupde.c'\"
- else
- echo shar: Extracting \"'ecu330/ecupde.c'\" \(17101 characters\)
- sed "s/^X//" >'ecu330/ecupde.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X ecupde.c - various PDE-related functions
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X call_logical_telno(logical)
- X choose_tty_for_pde(tpde)
- X copy_pde_to_Lvariables(tpde,trial)
- X logical_telno_to_pde(logical)
- X pde_dial(tpde)
- X pdetty_to_devtty(pdetty,devtty)
- X phdir_list_read()
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
- X/*:05-29-1993-21:47-wht@n4hgf-better debug */
- X/*:05-29-1993-20:21-wht@n4hgf-change linst_err_text to LINST_text */
- X/*:03-27-1993-17:45-wht@n4hgf-SVR4 cc complained about strlen <= constant */
- X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
- X/*:09-05-1992-14:17-wht@n4hgf-was starting rcvr process too early on connect */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:05-13-1992-13:27-wht@n4hgf-active_pde use */
- X/*:04-24-1992-21:59-wht@n4hgf-more SCO tty name normalizing */
- X/*:12-02-1991-20:58-wht@n4hgf-breakout into separate module */
- X
- X#include "ecu.h"
- X#include "esd.h"
- X#include "var.h"
- X#include "ecupde.h"
- X#include "dvent.h"
- X#include "termecu.h"
- X#include "ecuerror.h"
- X#include "utmpstatus.h"
- X
- XDVE *hdb_choose_Any();
- XDVE *hdb_choose_Device();
- XPDE *phdir_list_search();
- Xchar *LINST_text();
- X
- Xextern char errmsg[];
- Xextern char *default_tty;
- Xextern int windows_active;
- X
- Xchar phonedir_name[PHONEDIR_NAME_SIZE];
- Xchar *phonedir_trigger = "#ECUPHONE\n";
- X
- X/*+-----------------------------------------------------------------------
- X phdir_list_read()
- X
- Xreturn 0 if entire list read, else 1 if error (error msg in errmsg)
- X
- Xif file does not exist, create it, asking confirm only if in
- Xinteractive (curses) mode
- X------------------------------------------------------------------------*/
- Xint
- Xphdir_list_read()
- X{
- X register token_number;
- X register char *cptr;
- X register char *token;
- X int itmp;
- X char readpde_buf[128];
- X FILE *fp_phone;
- X PDE *tpde;
- X char *str_token();
- X
- X if (!phonedir_name[0])
- X {
- X get_home_dir(phonedir_name);
- X strcat(phonedir_name, "/.ecu/phone");
- X }
- X
- X TRY_OPEN:
- X if (!(fp_phone = fopen(phonedir_name, "r")))
- X {
- X if (errno == ENOENT)
- X {
- X if (!want_pd_create(phonedir_name))
- X {
- X strcpy(errmsg, "non-existent file not created");
- X return (1);
- X }
- X if ((itmp = open(phonedir_name,
- X O_RDWR | O_CREAT | O_TRUNC, 0600)) >= 0)
- X {
- X write(itmp, phonedir_trigger, strlen(phonedir_trigger));
- X close(itmp);
- X if (windows_active) /* if called under curses */
- X {
- X dirw_bot_msg("created new (empty) directory file");
- X ring_bell();
- X Nap(1000L);
- X }
- X goto TRY_OPEN;
- X }
- X if (errno == ENOENT)
- X {
- X strcpy(errmsg, "~/.ecu directory nonexistent!");
- X ring_bell();
- X return (1);
- X }
- X }
- X strcpy(errmsg, errno_text(errno));
- X return (1);
- X }
- X
- X/* we have an open directory file */
- X if (!fgets(readpde_buf, sizeof(readpde_buf), fp_phone) ||
- X strcmp(readpde_buf, phonedir_trigger))
- X {
- X fclose(fp_phone);
- X strcpy(errmsg, "not an ECU phone directory (or is pre-rev-3)");
- X ring_bell();
- X return (1);
- X }
- X
- X dirw_display_phonedir_name();
- X phdir_list_erase(); /* clear any previous directory */
- X while (fgets(readpde_buf, sizeof(readpde_buf), fp_phone))
- X {
- X if (readpde_buf[0] == '#') /* comment? */
- X continue;
- X if (itmp = strlen(readpde_buf)) /* itmp = len; if > 0 ... */
- X {
- X itmp--;
- X readpde_buf[itmp] = 0; /* ... strip trailing NL */
- X }
- X cptr = readpde_buf; /* first call to str_token, -> buff */
- X while ((*cptr == 0x20) || (*cptr == 0x09))
- X cptr++; /* strip leading spaces */
- X if (*cptr == 0) /* if line all blank, skip it */
- X continue;
- X
- X if (!(tpde = (PDE *) malloc(sizeof(PDE))))
- X {
- X fclose(fp_phone);
- X strcpy(errmsg, "Out of memory reading phone list");
- X return (1);
- X }
- X
- X tpde->descr[0] = 0;
- X tpde->logical[0] = 0;
- X tpde->telno[0] = 0;
- X tpde->tty[0] = 0;
- X tpde->parity = 0;
- X tpde->baud = 2400;
- X tpde->redial = 0;
- X tpde->prev = (PDE *) 0;
- X tpde->next = (PDE *) 0;
- X tpde->debug_level = 0;
- X tpde->dcdwatch = 'n';/* do not modify shm->Ldcdwatch */
- X
- X token_number = 0;
- X while ((token = str_token(cptr, ":")))
- X {
- X cptr = (char *)0;/* further calls to str_token need NULL */
- X switch (token_number)
- X {
- X case 0: /* first field is logical name */
- X strncpy(tpde->logical, token, sizeof(tpde->logical));
- X tpde->logical[sizeof(tpde->logical) - 1] = 0;
- X break;
- X case 1: /* second field is tpde->telno phone number */
- X strncpy(tpde->telno, token, sizeof(tpde->telno));
- X tpde->telno[sizeof(tpde->telno) - 1] = 0;
- X break;
- X case 2: /* third field is line */
- X strncpy(tpde->tty, token, sizeof(tpde->tty));
- X tpde->tty[sizeof(tpde->tty) - 1] = 0;
- X break;
- X case 3: /* fourth field is baud rate */
- X tpde->baud = atoi(token);
- X break;
- X case 4: /* fifth field is parity */
- X switch (itmp = to_lower(token[0]))
- X {
- X case 'o':
- X case 'e':
- X case 'm':
- X case 's':
- X tpde->parity = itmp;
- X break;
- X default:
- X case 'n':
- X tpde->parity = 0;
- X break;
- X }
- X break;
- X case 5:
- X strncpy(tpde->descr, token, sizeof(tpde->descr));
- X tpde->descr[sizeof(tpde->descr) - 1] = 0;
- X break;
- X case 6:
- X if ((tpde->debug_level = (uchar) atoi(token)) > 9)
- X tpde->debug_level = 9;
- X break;
- X case 7:
- X tpde->dcdwatch = to_lower(token[0]);
- X break;
- X } /* end of switch(token_number) */
- X token_number++;
- X } /* end while not end of record */
- X
- X phdir_list_add(tpde);
- X
- X } /* while records left to ready */
- X
- X fclose(fp_phone);
- X return (0);
- X} /* end of phdir_list_read */
- X
- X/*+-------------------------------------------------------------------------
- X pde_dial(tpde) - dial using a pde (using procedure if configured)
- X
- XIf the tpde->logical points to a valid procedure, use it,
- Xotherwise call DCE_dial()
- X
- Xreturns proc error code
- X $i0 value ($s0 is also set, BTW)
- X
- Xassumes rcvr process dead (rcvr_pid == -1)
- X--------------------------------------------------------------------------*/
- Xint
- Xpde_dial(tpde)
- Xregister PDE *tpde;
- X{
- X int status = 0;
- X int restart_rcvr = need_rcvr_restart();
- X char *cptr;
- X extern int dcdwatch_set; /* see ldcdwatch() in eculine.c */
- X
- X dcdwatch_set = 0;
- X
- X kill_rcvr_process(SIGUSR1);
- X
- X if (proc_level || !find_procedure(tpde->logical))
- X {
- X if (copy_pde_to_Lvariables(tpde, 0))
- X {
- X pprintf("%s: %s\n", tpde->logical, errmsg);
- X pprintf("Current line is %s (%s)\n",
- X shm->Lline, (shm->Liofd < 0) ? "closed" : "open");
- X status = eFATAL_ALREADY;
- X }
- X else
- X status = DCE_dial();
- X }
- X else
- X {
- X char *pargv[2];
- X
- X pargv[0] = tpde->logical;
- X pargv[1] = "!MENU";
- X iv[0] = 0;
- X if (do_proc(2, pargv))
- X status = eFATAL_ALREADY;
- X else
- X status = (iv[0]) ? eConnectFailed : 0;
- X }
- X
- X /*
- X * if we connected and a procedure did not change the DCD watcher,
- X * then use the dialing directory choice
- X */
- X if (!status && !dcdwatch_set)
- X {
- X cptr = (char *)0;
- X switch (tpde->dcdwatch)
- X {
- X case '0':
- X ldcdwatch(DCDW_OFF);
- X cptr = "OFF (ignore DCD loss)";
- X break;
- X case '1':
- X ldcdwatch(DCDW_ON);
- X cptr = "ON (detect DCD loss)";
- X break;
- X case 't':
- X ldcdwatch(DCDW_TERMINATE);
- X cptr = "TERMINATE (terminate ecu on DCD loss)";
- X break;
- X case 'n':
- X default:
- X break;
- X }
- X if (cptr)
- X {
- X ulong colors_save;
- X
- X colors_save = colors_current;
- X setcolor(colors_notify);
- X pprintf("[DCD watcher set to %s]", cptr);
- X setcolor(colors_save);
- X fputs("\r\n", se);
- X pputs("\n");
- X }
- X }
- X
- X if (restart_rcvr)
- X start_rcvr_process(1);
- X
- X return (status);
- X
- X} /* end of pde_dial */
- X
- X/*+-------------------------------------------------------------------------
- X pdetty_to_devtty(pdetty,devtty) -> pde tty field to complete pathname
- X--------------------------------------------------------------------------*/
- Xvoid
- Xpdetty_to_devtty(pdetty, devtty)
- Xchar *pdetty;
- Xchar *devtty;
- X{
- X strcpy(devtty, "/dev/");
- X#ifdef M_SYSV
- X if (strncmp(pdetty, "tty", 3))
- X strcat(devtty, "tty");
- X#endif
- X strcat(devtty, pdetty);
- X
- X} /* end of pdetty_to_devtty */
- X
- X/*+-------------------------------------------------------------------------
- X choose_tty_for_pde(tpde) - new pde might mandate switching line
- X
- XReturns 1 if new line open needed
- X 0 if no new line open needed
- X -1 if request cannot be satisfied
- X--------------------------------------------------------------------------*/
- Xint
- Xchoose_tty_for_pde(tpde)
- Xregister PDE *tpde;
- X{
- X int itmp = 0;
- X int rtn = 0;
- X DVE *tdve;
- X char newtty[64];
- X
- X#ifdef CHOOSE_DEBUG
- X char s256[256];
- X
- X sprintf(s256, "CHOOSE_TTY_FOR_PDE '%s' %u baud", tpde->tty, tpde->baud);
- X ecu_log_event(getpid(), s256);
- X errmsg[0] = 0;
- X#endif
- X
- X /*
- X * if desired line is Devices type
- X */
- X if ((tpde->tty[0] == '=') || (tpde->tty[0] == '/')) /* Devices device type */
- X {
- X if (!(tdve = hdb_choose_Device(tpde->tty, tpde->baud)))
- X {
- X sprintf(errmsg, "no idle line matches type '%s' at %u baud",
- X *tpde->tty ? tpde->tty : "Any", tpde->baud);
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X sprintf(newtty, "/dev/%s", tdve->line);
- X if ((itmp = lock_tty(newtty)) && (itmp != LINST_WEGOTIT))
- X {
- X sprintf(errmsg, "%s (%s): %s",
- X tpde->tty, tdve->line, LINST_text(itmp));
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X if ((itmp = reserve_line(newtty)) && (itmp != LINST_WEGOTIT))
- X {
- X sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X }
- X
- X /*
- X * if desired line is a specific tty
- X */
- X else if (tpde->tty[0])
- X {
- X pdetty_to_devtty(tpde->tty, newtty);
- X if ((shm->Liofd > 0) && !strcmp(newtty, shm->Lline))
- X {
- X rtn = 0; /* requesting line we already have */
- X goto FUNC_RETURN;
- X }
- X if ((itmp = lock_tty(newtty)) && (itmp != LINST_WEGOTIT))
- X {
- X sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X if ((itmp = reserve_line(newtty)) && (itmp != LINST_WEGOTIT))
- X {
- X sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X }
- X
- X /*
- X * if desired line is "Any" (any Devices type beginning with ACU)
- X */
- X else
- X /* "Any" */
- X {
- X tdve = hdb_choose_Any(tpde->baud);
- X if (!tdve)
- X {
- X sprintf(errmsg, "no idle ACU line at %u baud", tpde->baud);
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X sprintf(newtty, "/dev/%s", tdve->line);
- X if ((itmp = lock_tty(newtty)) && (itmp != LINST_WEGOTIT))
- X {
- X sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X if ((itmp = reserve_line(newtty)) && (itmp != LINST_WEGOTIT))
- X {
- X sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
- X rtn = -1;
- X goto FUNC_RETURN;
- X }
- X }
- X
- X rtn = !(!strcmp(newtty, shm->Lline) && (shm->Liofd != -1));
- X if (rtn)
- X {
- X lclose();
- X strcpy(shm->Lline, newtty);
- X }
- X
- X FUNC_RETURN:
- X
- X#ifdef CHOOSE_DEBUG
- X sprintf(s256, "CHOOSE_TTY_FOR_PDE rtn=%d line='%s' errmsg='%s' itmp=%d",
- X rtn, shm->Lline, errmsg, itmp);
- X ecu_log_event(getpid(), s256);
- X#endif
- X
- X return (rtn);
- X
- X} /* end of choose_tty_for_pde */
- X
- X/*+-------------------------------------------------------------------------
- X copy_pde_to_Lvariables(tpde,trial)
- X
- X'trial' controls whether this is a dry run (setup) or a live request
- Xif changing line, close old line and open new one
- Xif cannot change line, return -1, else 0
- X--------------------------------------------------------------------------*/
- Xint
- Xcopy_pde_to_Lvariables(tpde, trial)
- Xregister PDE *tpde;
- Xint trial;
- X{
- X int reopen = 0;
- X int lerr;
- X DVE *tdve;
- X
- X#ifdef CHOOSE_DEBUG
- X char s256[256];
- X
- X sprintf(s256, "COPY_PDE1 trial=%d Lline='%s' pdetty='%s'",
- X trial, shm->Lline, tpde->tty);
- X ecu_log_event(getpid(), s256);
- X#endif
- X
- X enddvent(); /* krock safety */
- X
- X if (!trial)
- X {
- X if ((reopen = choose_tty_for_pde(tpde)) < 0)
- X return (-1); /* errmsg[] updated */
- X }
- X else if ((!tpde->tty[0]) || (!strcmp(tpde->tty, "Any")))
- X {
- X if (!(tdve = hdb_choose_Any(tpde->baud)))
- X {
- X strcpy(errmsg, "no idle line matches type 'Any'");
- X return (-1);
- X }
- X strcpy(shm->Lline, "/dev/");
- X strncat(shm->Lline, tdve->line, sizeof(shm->Lline) - 5);
- X shm->Lline[sizeof(shm->Lline) - 1] = 0;
- X }
- X else if ((tpde->tty[0] == '/') || (tpde->tty[0] == '='))
- X {
- X if (!(tdve = hdb_choose_Device(tpde->tty, tpde->baud)))
- X {
- X sprintf(errmsg, "no idle line matches type '%s' at %u baud",
- X *tpde->tty ? tpde->tty : "Any", tpde->baud);
- X return (-1);
- X }
- X strcpy(shm->Lline, "/dev/");
- X strncat(shm->Lline, tdve->line, sizeof(shm->Lline) - 5);
- X shm->Lline[sizeof(shm->Lline) - 1] = 0;
- X }
- X else
- X pdetty_to_devtty(tpde->tty, shm->Lline);
- X
- X#ifdef CHOOSE_DEBUG
- X sprintf(s256, "COPY_PDE2 Lline='%s' reopen=%d", shm->Lline, reopen);
- X ecu_log_event(getpid(), s256);
- X#endif
- X
- X shm->Lbaud = tpde->baud;
- X strcpy(shm->Llogical, tpde->logical);
- X strcpy(shm->Ldescr, tpde->descr);
- X strcpy(shm->Ltelno, tpde->telno);
- X if (!shm->Ldescr[0])
- X strcpy(shm->Ldescr, shm->Llogical);
- X shm->Lparity = tpde->parity;
- X if (shm->Lbaud != tpde->baud)
- X shm->Lmodem_already_init = 0;
- X Ldial_debug_level = tpde->debug_level;
- X /* tpde->dcdwatch is explicitly unused here; must defer until connect */
- X
- X if (!trial)
- X {
- X if (reopen)
- X {
- X if (lerr = lopen())
- X {
- X tcap_curbotleft();
- X pprintf("%s: %s\n", shm->Lline, LINST_text(lerr));
- X lopen_error_reset(); /* clear static error area */
- X termecu(TERMECU_LINE_OPEN_ERROR);
- X }
- X }
- X else
- X {
- X lset_baud_rate(1);
- X lset_parity(1);
- X }
- X }
- X return (0);
- X
- X} /* end of copy_pde_to_Lvariables */
- X
- X/*+-----------------------------------------------------------------------
- X logical_telno_to_pde() - logical dial string to dialing info (PDE)
- X
- X NOT USED BY THE CURSES DIRECTORY MANAGER
- X
- XA logical telephone number is one of:
- X1. null,
- X2. a symbolic identifer, or
- X3. an actual telephone number.
- X
- XA symbolic identifer is a string whose initial character is a
- Xletter. An actual telephone number begins with a numeral.
- X
- XThis function converts a logical telephone number to a dialing
- Xentry (PDE) from the directory or a constructed static one. It
- Xis called by command line processing when 'ecu logical-name' is
- Xspecified or in response to a %dial logical-name.
- X
- XThe function returns one of the following:
- X
- X directory or static PDE if no error occurs
- X (PDE *)0 if not numeric phone number
- X and logical string not found in directory;
- X global char[] errmsg has been plugged with
- X error message
- X
- X------------------------------------------------------------------------*/
- XPDE *
- Xlogical_telno_to_pde(logical)
- Xchar *logical;
- X{
- X static PDE literal_number_pde;
- X register PDE *tpde = 0;
- X extern int phdir_list_quan;
- X
- X/*
- X * if literal phone number, return homemade, static "PDE"
- X * with most stuff dummied up with the status quo
- X */
- X if (isdigit(*logical))
- X {
- X tpde = &literal_number_pde;
- X memset((char *)tpde, 0, sizeof(PDE));
- X tpde->baud = shm->Lbaud;
- X tpde->parity = shm->Lparity;
- X strncpy(tpde->logical, logical, DESTREF_LEN);
- X tpde->logical[DESTREF_LEN] = 0;
- X strncpy(tpde->telno, logical, DESTREF_LEN);
- X tpde->telno[DESTREF_LEN] = 0;
- X strncpy(tpde->tty, shm->Lline + 5, PDE_TTY_LEN);
- X tpde->tty[PDE_TTY_LEN] = 0;
- X if ((unsigned)(strlen(logical) + 8) <= (unsigned)PDE_DESCR_LEN)
- X sprintf(tpde->descr, "<telno %s>", logical);
- X else
- X strcpy(tpde->descr, "<telno>");
- X tpde->dcdwatch = 'n';
- X goto FUNC_RETURN;
- X }
- X
- X/*
- X * if empty phone number, return homemade, static "PDE"
- X * with most stuff dummied up with the status quo
- X */
- X if (!*logical)
- X {
- X tpde = &literal_number_pde;
- X memset((char *)tpde, 0, sizeof(PDE));
- X tpde->baud = shm->Lbaud;
- X tpde->parity = shm->Lparity;
- X strcpy(tpde->tty, shm->Lline + 5);
- X if (!tpde->tty[0])
- X strcpy(tpde->tty, default_tty + 5);
- X strcpy(tpde->descr, "<direct connect>");
- X tpde->dcdwatch = 'n';
- X goto FUNC_RETURN;
- X }
- X
- X /*
- X * read directory if necessary
- X */
- X if (!phdir_list_quan)
- X {
- X if (phdir_list_read() && !phdir_list_quan)
- X { /* if still no good, ... */
- X strcpy(errmsg, "phone directory empty");
- X tpde = 0;
- X goto FUNC_RETURN;
- X }
- X }
- X
- X /*
- X * now, look up the entry
- X */
- X if (tpde = phdir_list_search(logical, 0))
- X goto FUNC_RETURN;
- X
- X /*
- X * whoops ... not found
- X */
- X shm->Lrname[0] = 0;
- X shm->Ltelno[0] = 0;
- X shm->Ldescr[0] = 0;
- X strcpy(errmsg, "entry not found in directory");
- X tpde = 0;
- X
- X FUNC_RETURN:
- X
- X#ifdef CHOOSE_DEBUG
- X {
- X char s256[256];
- X
- X sprintf(s256, "LOGICAL->PDE %s=%s chosen tty=%s",
- X (tpde == &literal_number_pde) ? "TELNO" : "LOGICAL",
- X logical,
- X (tpde && tpde->tty[0]) ? tpde->tty : "<none>"
- X );
- X ecu_log_event(getpid(), s256);
- X }
- X#endif
- X
- X return (tpde);
- X
- X} /* end of logical_telno_to_pde */
- X
- X/*+-------------------------------------------------------------------------
- X call_logical_telno(logical) - call a logical or literal telephone number
- X
- X-1 if no such entry or pde_dial() status
- X--------------------------------------------------------------------------*/
- Xint
- Xcall_logical_telno(logical)
- Xchar *logical;
- X{
- X int ret;
- X PDE *tpde;
- X
- X if (tpde = logical_telno_to_pde(logical))
- X ret = pde_dial(tpde);
- X else
- X {
- X pprintf("%s: %s\n", logical, errmsg);
- X ret = eFATAL_ALREADY;
- X }
- X
- X return (ret);
- X
- X} /* end of call_logical_telno */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of ecupde.c */
- END_OF_FILE
- if test 17101 -ne `wc -c <'ecu330/ecupde.c'`; then
- echo shar: \"'ecu330/ecupde.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecupde.c'
- fi
- if test -f 'ecu330/ecutcap.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecutcap.c'\"
- else
- echo shar: Extracting \"'ecu330/ecutcap.c'\" \(17512 characters\)
- sed "s/^X//" >'ecu330/ecutcap.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X ecutcap.c -- termcap stuff
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X tcap_blink_off()
- X tcap_blink_on()
- X tcap_bold_off()
- X tcap_bold_on()
- X tcap_clear_area_char(count,clrch)
- X tcap_clear_screen()
- X tcap_curbotleft()
- X tcap_curleft(count)
- X tcap_curright(count)
- X tcap_cursor(y,x)
- X tcap_delete_chars(count)
- X tcap_delete_lines(count)
- X tcap_draw_box(y,x,height,width,title,title_x)
- X tcap_draw_box_primitive(y,x,height,width)
- X tcap_eeod()
- X tcap_eeol()
- X tcap_gets(buf,bufsize,delim,wait_for_key)
- X tcap_horiz_rule(count)
- X tcap_init()
- X tcap_insert_chars(count)
- X tcap_insert_lines(count)
- X tcap_putc(character)
- X tcap_stand_end()
- X tcap_stand_out()
- X tcap_underscore_off()
- X tcap_underscore_on()
- X tcap_vbell()
- X tcap_vertical_rule(y,x,count)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:01-06-1994-04:21-wht@n4hgf-clean up LINUX tcap_putc */
- X/*:01-04-1994-05:32-wht@n4hgf-modify Linux port to balance braces */
- X/*:01-04-1994-01:43-wht@n4hgf-protect against NULL tc_blink_on/off */
- X/*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
- X/*:07-23-1993-13:43-wht@n4hgf-tcap_clear_area_char had same buggy tputs call */
- X/*:07-17-1993-12:19-wht@n4hgf-tcap_curleft and right had buggy tputs calls */
- X/*:01-11-1993-16:04-wht@n4hgf-vbell defaults to bell */
- X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:03-10-1992-13:25-wht@n4hgf2-quick sanity check on ttype features */
- X/*:02-24-1992-06:50-root@n4hgf-getenv COLUMNS not COLS */
- X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
- X/*:05-01-1991-04:05-wht@n4hgf-try to catch tbetz tc= infinite loop early */
- X/*:03-20-1991-16:25-root@n4hgf-environment LINES/COLS overrides termcap li/co */
- X/*:11-28-1990-14:52-wht@n4hgf-tcap support for non-ansi console */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#ifdef LINUX
- X#include <ncurses.h>
- X#include <term.h>
- X#endif
- X#include "ecu.h"
- X#include "ecukey.h"
- X#include "pc_scr.h"
- X
- Xuint tcap_LINES;
- Xuint tcap_COLS;
- X
- Xstatic char *tc_blink_on = "";
- Xstatic char *tc_blink_off = "";
- Xstatic char *tc_bold_on = "";
- Xstatic char *tc_bold_off = "";
- Xstatic char *tc_clear = "";
- Xstatic char *tc_curleft = "";
- Xstatic char *tc_curright = "";
- Xstatic char *tc_delchar = "";
- Xstatic char *tc_delline = "";
- Xstatic char *tc_eeod = "";
- Xstatic char *tc_eeol = "";
- Xstatic char *tc_inschar = "";
- Xstatic char *tc_insline = "";
- Xstatic char *tc_move = "";
- Xstatic char *tc_standout = "";
- Xstatic char *tc_standend = "";
- Xstatic char *tc_underscore_on = "";
- Xstatic char *tc_underscore_off = "";
- Xstatic char *tc_vbell = "";
- X
- X#ifndef LINUX
- Xstatic char tc_strbuf[768]; /* absolutely blunderous overkill */
- X#endif
- Xstatic int tc_standout_width;
- X
- Xchar *tgetstr();
- Xchar *tgoto();
- Xchar *getenv();
- X
- Xvoid tcap_cursor();
- Xvoid tcap_stand_out();
- Xvoid tcap_stand_end();
- X
- X#ifdef LINUX
- X#define TCAP_PUTC_TYPE int
- XTCAP_PUTC_TYPE tcap_putc(int);
- X
- X#else
- X#define TCAP_PUTC_TYPE void
- XTCAP_PUTC_TYPE tcap_putc();
- X
- X#endif
- X
- X/*+-------------------------------------------------------------------------
- X tcap_init() - get termcap variables
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_init()
- X{
- X#ifdef LINUX
- X int result;
- X
- X#else
- X char termbuf[1024];
- X char *cptr;
- X
- X#endif
- X
- X if (!ttype || !*ttype)
- X {
- X ff(se, "invalid or missing TERM environment variable\r\n");
- X termecu(TERMECU_CURSES_ERROR);
- X }
- X
- X#ifdef LINUX
- X setupterm(ttype, 1, &result);
- X if (result == 1)
- X {
- X tcap_LINES = lines;
- X tcap_COLS = columns;
- X tc_standout_width = label_width;
- X tc_standout = enter_standout_mode;
- X tc_standend = exit_standout_mode;
- X tc_clear = clear_screen;
- X tc_curleft = cursor_left;
- X tc_curright = cursor_right;
- X tc_delchar = delete_character;
- X tc_delline = delete_line;
- X tc_eeod = clr_eos;
- X tc_eeol = clr_eol;
- X tc_inschar = insert_character;
- X tc_insline = insert_line;
- X tc_move = cursor_address;
- X tc_vbell = bell;
- X tc_underscore_on = enter_underline_mode;
- X tc_underscore_off = exit_underline_mode;
- X if (!tc_underscore_on || !tc_underscore_off)
- X {
- X tc_underscore_on = tc_standout;
- X tc_underscore_off = tc_standend;
- X }
- X tc_bold_on = enter_bold_mode; /* for now */
- X tc_bold_off = exit_attribute_mode; /* for now */
- X if (!tc_bold_on || !tc_bold_off)
- X {
- X tc_bold_on = tc_standout;
- X tc_bold_off = tc_standend;
- X }
- X tc_blink_on = enter_blink_mode;
- X tc_blink_off = exit_attribute_mode;
- X if (!tc_blink_on || !tc_blink_off)
- X {
- X tc_blink_on = tc_standout;
- X tc_blink_off = tc_standend;
- X }
- X if (!*tc_clear || !*tc_move)
- X {
- X ff(se, "Terminal type '%s' does not have the beef.\r\n",
- X ttype);
- X ff(se, "Try again with a screen-oriented terminal.\n");
- X termecu(TERMECU_CURSES_ERROR);
- X }
- X ff(se, enter_ca_mode);
- X return;
- X }
- X#else
- X if (tgetent(termbuf, ttype) > 0)
- X {
- X tcap_LINES = tgetnum("li");
- X tcap_COLS = tgetnum("co");
- X if (cptr = getenv("LINES")) /* environment override ... */
- X tcap_LINES = atoi(cptr); /* ... for termcap systems */
- X if (cptr = getenv("COLUMNS"))
- X tcap_COLS = atoi(cptr);
- X if ((tc_standout_width = tgetnum("sg")) < 0)
- X tc_standout_width = 0;
- X cptr = tc_strbuf;
- X tc_standout = tgetstr("so", &cptr);
- X tc_standend = tgetstr("se", &cptr);
- X if (!tc_standout || !tc_standend)
- X {
- X tc_standout = "";
- X tc_standend = "";
- X }
- X tc_clear = tgetstr("cl", &cptr);
- X tc_curleft = tgetstr("kl", &cptr);
- X if (!tc_curleft)
- X tc_curleft = "\10";
- X tc_curright = tgetstr("kr", &cptr);
- X if (!tc_curright)
- X tc_curright = " ";
- X tc_delchar = tgetstr("dc", &cptr);
- X tc_delline = tgetstr("dl", &cptr);
- X tc_eeod = tgetstr("cd", &cptr);
- X tc_eeol = tgetstr("ce", &cptr);
- X tc_inschar = tgetstr("ic", &cptr);
- X tc_insline = tgetstr("al", &cptr);
- X tc_move = tgetstr("cm", &cptr);
- X tc_vbell = tgetstr("vb", &cptr);
- X if (!tc_vbell)
- X tc_vbell = "\7";
- X tc_underscore_on = tgetstr("us", &cptr);
- X tc_underscore_off = tgetstr("ue", &cptr);
- X if (!tc_underscore_on || !tc_underscore_off)
- X {
- X tc_underscore_on = tc_standout;
- X tc_underscore_off = tc_standend;
- X }
- X tc_bold_on = tc_standout; /* for now */
- X tc_bold_off = tc_standend; /* for now */
- X if (!tc_bold_on || !tc_bold_off)
- X {
- X tc_bold_on = tc_standout;
- X tc_bold_off = tc_standend;
- X }
- X tc_blink_on = tgetstr("mb", &cptr); /* "XENIX extension" */
- X tc_blink_off = tgetstr("me", &cptr); /* "XENIX extension" */
- X if (!tc_blink_on || !tc_blink_off)
- X {
- X tc_blink_on = tc_standout;
- X tc_blink_off = tc_standend;
- X }
- X if (!tc_clear || !tc_move)
- X {
- X ff(se, "Terminal type '%s' does not have the beef.\r\n",
- X ttype);
- X ff(se, "Try again with a screen-oriented terminal.\r\n");
- X termecu(TERMECU_CURSES_ERROR);
- X }
- X if (!tc_standout || !tc_standend || !*tc_standout || !*tc_standend)
- X {
- X ff(se, "Terminal type '%s' does not have standout.\r\n",
- X ttype);
- X ff(se, "We will continue, but this may be confusing.\7\r\n");
- X Nap(2000L);
- X }
- X return;
- X }
- X#endif
- X
- X ff(se, "Cannot find terminal type '%s' or entry in error\r\n",
- X ttype);
- X termecu(TERMECU_CURSES_ERROR);
- X
- X} /* end of tcap_init */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_putc(character) - utility routine for tputs
- X--------------------------------------------------------------------------*/
- XTCAP_PUTC_TYPE
- Xtcap_putc(character)
- Xint character;
- X{
- X char ch = character;
- X
- X rcvrdisp(&ch, 1);
- X#ifdef LINUX
- X return (0);
- X#endif
- X} /* end of tcap_putc */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_horiz_rule(count) - horizontal rule starting at current position
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_horiz_rule(count)
- Xregister count;
- X{
- X while (count--)
- X tcap_putc(sHR);
- X rcvrdisp_actual2();
- X} /* end of tcap_horiz_rule */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_vertical_rule(y,x,count) - vertical rule starting at y,x
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_vertical_rule(y, x, count)
- Xint y;
- Xregister x;
- Xregister count;
- X{
- X
- X while (count--)
- X {
- X tcap_cursor(y++, x);
- X tcap_putc(sVR);
- X }
- X rcvrdisp_actual2();
- X
- X} /* end of tcap_vertical_rule */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_draw_box_primitive(y,x,height,width) - ruled box
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_draw_box_primitive(y, x, height, width)
- Xregister y;
- Xint x;
- Xint height;
- Xint width;
- X{
- X register i;
- X
- X tcap_cursor(y, x);
- X tcap_putc(sTL);
- X if ((i = width - 2) > 0)
- X tcap_horiz_rule(i);
- X tcap_putc(sTR);
- X if ((i = height - 2) > 0)
- X {
- X tcap_vertical_rule(y + 1, x + width - 1, i);
- X tcap_vertical_rule(y + 1, x, i);
- X }
- X tcap_cursor(y + height - 1, x);
- X tcap_putc(sBL);
- X if ((i = width - 2) > 0)
- X tcap_horiz_rule(i);
- X tcap_putc(sBR);
- X rcvrdisp_actual2();
- X
- X} /* end of tcap_draw_box_primitive */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_draw_box(y,x,height,width,title,title_x)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_draw_box(y, x, height, width, title, title_x)
- Xint y;
- Xint x;
- Xint height;
- Xint width;
- Xchar *title;
- Xint title_x;
- X{
- X register stand = (title_x < 0);
- X
- X if (stand)
- X title_x = -title_x;
- X
- X tcap_draw_box_primitive(y, x, height, width);
- X tcap_cursor(y, x + title_x);
- X tcap_putc('[');
- X if (stand)
- X tcap_stand_out();
- X ff(se, " %s ", title);
- X if (stand)
- X tcap_stand_end();
- X tcap_putc(']');
- X rcvrdisp_actual2();
- X
- X} /* end of tcap_draw_box */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_cursor(y,x)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_cursor(y, x)
- Xuint y;
- Xuint x;
- X{
- X if (y >= tcap_LINES)
- X y = tcap_LINES - 1;
- X if (x >= tcap_COLS)
- X x = tcap_COLS - 1;
- X tputs(tgoto(tc_move, x, y), 1, tcap_putc);
- X rcvrdisp_actual2();
- X
- X} /* end of tcap_cursor */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_curleft(count) - move cursor left
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_curleft(count)
- Xregister count;
- X{
- X while (count--)
- X tputs(tc_curleft, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_curleft */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_curright(count) - move cursor right
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_curright(count)
- Xregister count;
- X{
- X while (count--)
- X tputs(tc_curright, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_curright */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_curbotleft()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_curbotleft()
- X{
- X tcap_cursor(tcap_LINES - 1, 0);
- X} /* end of tcap_curbotleft */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_insert_lines(count)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_insert_lines(count)
- Xregister count;
- X{
- X if (count && *tc_insline)
- X {
- X while (count--)
- X tputs(tc_insline, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_insert_lines */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_delete_lines(count)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_delete_lines(count)
- Xregister count;
- X{
- X if (count && *tc_delline)
- X {
- X while (count--)
- X tputs(tc_delline, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_delete_lines */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_insert_chars(count)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_insert_chars(count)
- Xregister count;
- X{
- X if (count && *tc_inschar)
- X {
- X while (count--)
- X tputs(tc_inschar, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_insert_chars */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_delete_chars(count)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_delete_chars(count)
- Xregister count;
- X{
- X if (count && *tc_delchar)
- X {
- X while (count--)
- X tputs(tc_delchar, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_delete_chars */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_vbell() - output visual bell
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_vbell()
- X{
- X if (*tc_vbell)
- X {
- X tputs(tc_vbell, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_vbell */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_clear_screen()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_clear_screen()
- X{
- X if (*tc_clear)
- X {
- X tputs(tc_clear, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_clear_screen */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_eeol() - erase to end of line
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_eeol()
- X{
- X if (*tc_eeol)
- X {
- X tputs(tc_eeol, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_eeol */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_eeod() - erase to end of display
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_eeod()
- X{
- X if (*tc_eeod)
- X {
- X tputs(tc_eeod, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_eeod */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_stand_out()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_stand_out()
- X{
- X if (*tc_standout) /* && (tc_standout_width == 0)) */
- X {
- X tputs(tc_standout, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_stand_out */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_stand_end()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_stand_end()
- X{
- X if (*tc_standend) /* && (tc_standout_width == 0)) */
- X {
- X tputs(tc_standend, 1, tcap_putc);
- X rcvrdisp_actual2();
- X }
- X} /* end of tcap_stand_end */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_bold_on()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_bold_on()
- X{
- X if (*tc_bold_on)
- X tputs(tc_bold_on, 1, tcap_putc);
- X else if (*tc_standout) /* && (tc_standout_width == 0)) */
- X tputs(tc_standout, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_bold_on */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_bold_off()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_bold_off()
- X{
- X if (*tc_bold_off)
- X tputs(tc_bold_off, 1, tcap_putc);
- X else if (*tc_standend) /* && (tc_standout_width == 0)) */
- X tputs(tc_standend, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_bold_off */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_underscore_on()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_underscore_on()
- X{
- X if (*tc_underscore_on)
- X tputs(tc_underscore_on, 1, tcap_putc);
- X else if (*tc_standout) /* && (tc_standout_width == 0)) */
- X tputs(tc_standout, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_underscore_on */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_underscore_off()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_underscore_off()
- X{
- X if (*tc_underscore_off)
- X tputs(tc_underscore_off, 1, tcap_putc);
- X else if (*tc_standend) /* && (tc_standout_width == 0)) */
- X tputs(tc_standend, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_underscore_off */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_blink_on()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_blink_on()
- X{
- X if (*tc_blink_on)
- X tputs(tc_blink_on, 1, tcap_putc);
- X else if (*tc_standout) /* && (tc_standout_width == 0)) */
- X tputs(tc_standout, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_blink_on */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_blink_off()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_blink_off()
- X{
- X if (*tc_blink_off)
- X tputs(tc_blink_off, 1, tcap_putc);
- X else if (*tc_standend) /* && (tc_standout_width == 0)) */
- X tputs(tc_standend, 1, tcap_putc);
- X rcvrdisp_actual2();
- X} /* end of tcap_blink_off */
- X
- X/*+-------------------------------------------------------------------------
- X tcap_clear_area_char(count,clrch)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtcap_clear_area_char(count, clrch)
- Xregister count;
- Xregister clrch;
- X{
- X register itmp = count;
- X
- X while (itmp--)
- X tcap_putc(clrch);
- X itmp = count;
- X while (itmp--)
- X tputs(tc_curleft, 1, tcap_putc);
- X rcvrdisp_actual2();
- X
- X} /* end of tcap_clear_area_char */
- X
- X/* end of ecutcap.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 17512 -ne `wc -c <'ecu330/ecutcap.c'`; then
- echo shar: \"'ecu330/ecutcap.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecutcap.c'
- fi
- if test -f 'ecu330/kbdtest3.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/kbdtest3.c'\"
- else
- echo shar: Extracting \"'ecu330/kbdtest3.c'\" \(15519 characters\)
- sed "s/^X//" >'ecu330/kbdtest3.c' <<'END_OF_FILE'
- X/* CHK=0x2F4F */
- Xchar *revision = "3.30";
- X
- X/*+-----------------------------------------------------------------------
- X kbdtest3.c -- test keyboard values
- X wht@n4hgf.atl.ga.us
- X
- X See ecu manual section titled Function Key Recognition
- X
- X Defined functions:
- X dump_putc(ch)
- X dump_puts(str)
- X hex_dump16(int16)
- X hex_dump32(int32)
- X hex_dump4(int4)
- X hex_dump8(int8)
- X hex_dump_fp(fp,str,len,title,terse_flag)
- X k3ttymode(arg)
- X main(argc,argv)
- X read_kbd_string(buf,max)
- X termio_parity_text(cflag)
- X tputstrs(strs)
- X write_funckeymap_desc(fp,buf,buflen,name)
- X xtoasc(ch,incl_3char)
- X
- X------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:01-11-1994-15:37-wht@n4hgf-remove explicit paths from stty and sed */
- X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
- X/*:04-19-1992-20:59-wht@n4hgf-nonansikeys to funckeymap */
- X/*:02-22-1992-12:46-root@n4hgf-thank markd@phoenix.pub.uu.oz.au for typo fix */
- X/*:01-06-1992-17:56-wht@tridom-much more error checking */
- X/*:01-06-1992-17:56-wht@tridom-eliminate sun stty - causes problems */
- X/*:08-28-1991-14:07-wht@n4hgf2-SVR4 cleanup by aega84!lh */
- X/*:08-17-1991-13:58-root@n4hgf-make kbd entirely raw */
- X/*:08-06-1991-13:12-wht@n4hgf-add parity reporting */
- X/*:08-06-1991-13:12-wht@n4hgf-some terminals reinvent parity bit's use */
- X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
- X/*:04-29-1991-18:24-wht@n4hgf-let us see what keyboards say */
- X
- X#include <stdio.h>
- X#include <signal.h>
- X#include <ctype.h>
- X#include <sys/errno.h>
- X#include <string.h>
- X#include "ecu_config.h"
- X#include "ecu_types.h"
- X#include "ecu_stat.h"
- X#include "ecutermio.h"
- X
- Xchar *ctime();
- Xchar *getenv();
- X
- X#define VMIN_VALUE 32
- X#define VTIME_VALUE 2
- X
- X#define TTYIN 0 /* mnemonic */
- X#define TTYOUT 1 /* mnemonic */
- X#define TTYERR 2 /* mnemonic */
- X
- Xstruct termio lv; /* attributes for the line to remote */
- Xstruct termio tv0; /* for saving, changing TTY atributes */
- Xstruct termio tv; /* for saving, changing TTY atributes */
- X
- Xchar *strs_intro[] =
- X{
- X "\n",
- X "Let's learn your keyboard. I'll be making a file named kbdtest3.out\n",
- X "For each of the key names shown below, please press the key and wait.\n",
- X "\n",
- X "If you do not have a key on your keyboard, make an alternate choice\n",
- X "or press the space bar if nothing seems reasonable.\n",
- X "\n",
- X "If you press a key but don't see further activity after a second or two\n",
- X "press the slash '/' key unless you can choose a reasonable alternate.\n",
- X "Keys which produce duplicate the keystroke sequence of other keys are\n",
- X "not acceptable.\n",
- X "\n",
- X "Do not use the same key for more than one function.\n",
- X "\n",
- X (char *)0
- X};
- X
- Xchar *strs_thanks[] =
- X{
- X "\n",
- X "Thank you. If you wish to mail me the contents of kbdtest3.out,\n",
- X "please include a detailed description of the system and software\n",
- X "(i.e., \"Metrolink xterm keyboard on SCO 3.2r2\")\n",
- X "(I WANT you to mail me results for non-SCO/non-ISC-console keyboards.)\n",
- X "If you had to hack this program, mail it in its entirety as well.\n",
- X "\n",
- X "My address: wht@n4hgf.atl.ga.us or emory!n4hgf!wht\n",
- X (char *)0
- X};
- X
- Xchar *strs_bktab[] =
- X{
- X "You'll have to pick another function key (like F11?). If you are\n",
- X "using an xterm here perhaps a <Shift>Tab VT100 override will help.\n",
- X (char *)0
- X};
- X
- Xstruct keystruc
- X{
- X char *ecuname;
- X char *peoplename;
- X int count;
- X unsigned char str[VMIN_VALUE + 1];
- X};
- X
- Xstruct keystruc need_names[] =
- X{
- X {"BkTab", "Back Tab (Shift Tab)"}, /* 0 */
- X {"CU5", "Unshifted Keypad 5"}, /* 1 */
- X {"F1", "F1"}, /* 2 */
- X {"F2", "F2"}, /* 3 */
- X {"F3", "F3"}, /* 4 */
- X {"F4", "F4"}, /* 5 */
- X {"F5", "F5"}, /* 6 */
- X {"F6", "F6"}, /* 7 */
- X {"F7", "F7"}, /* 8 */
- X {"F8", "F8"}, /* 9 */
- X {"F9", "F9"}, /* 10 */
- X {"F10", "F10"}, /* 11 */
- X {"F11", "F11"}, /* 12 */
- X {"F12", "F12"}, /* 13 */
- X {"Ins", "Ins"}, /* 14 */
- X#define I_HOME 15
- X {"Home", "Home"}, /* 15 */
- X#define I_END 16
- X {"End", "End"}, /* 16 */
- X {"PgUp", "PgUp"}, /* 17 */
- X {"PgDn", "PgDn"}, /* 18 */
- X {"CUU", "Cursor Up"}, /* 19 */
- X {"CUD", "Cursor Down"}, /* 21 */
- X {"CUL", "Cursor Left"}, /* 22 */
- X {"CUR", "Cursor Right"}, /* 23 */
- X {(char *)0, (char *)0}
- X};
- X
- Xchar *parity_text = "<undetermined>";
- Xstatic FILE *dumpfp;
- X
- X/*+-------------------------------------------------------------------------
- X dump_putc(ch)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdump_putc(ch)
- Xchar ch;
- X{
- X fputc(ch, dumpfp);
- X} /* end of dump_putc */
- X
- X/*+-------------------------------------------------------------------------
- X dump_puts(str)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdump_puts(str)
- Xchar *str;
- X{
- X fputs(str, dumpfp);
- X} /* end of dump_puts */
- X
- X/*+-----------------------------------------------------------------------
- X hex_dump#... subservient routines
- X------------------------------------------------------------------------*/
- Xvoid
- Xhex_dump4(int4)
- Xunsigned char int4;
- X{
- X int4 &= 15;
- X dump_putc((int4 >= 10) ? (int4 + 'A' - 10) : (int4 + '0'));
- X}
- X
- Xvoid
- Xhex_dump8(int8)
- Xunsigned char int8;
- X{
- X hex_dump4(int8 >> 4);
- X hex_dump4(int8);
- X}
- X
- Xvoid
- Xhex_dump16(int16)
- Xunsigned short int16;
- X{
- X hex_dump8(int16 >> 8);
- X hex_dump8(int16);
- X}
- X
- Xvoid
- Xhex_dump32(int32)
- Xunsigned long int32;
- X{
- X hex_dump16(int32 >> 16);
- X hex_dump16(int32);
- X}
- X
- X/*+-----------------------------------------------------------------
- X hex_dump_fp(fp,str,len,title,terse_flag)
- X
- X if 'title' not NULL, title is printed... 'terse_flag'
- X controls whether or not the title is "conspicuous" with
- X hyphens before and after it making title line >70 chars long
- X------------------------------------------------------------------*/
- Xvoid
- Xhex_dump_fp(fp, str, len, title, terse_flag)
- XFILE *fp;
- Xchar *str;
- Xint len;
- Xchar *title;
- Xint terse_flag;
- X{
- X int istr;
- X register ipos = 0;
- X register itmp;
- X
- X dumpfp = fp;
- X
- X if (title && (istr = strlen(title)))
- X {
- X if (!terse_flag)
- X {
- X ipos = (73 - istr) / 2;
- X itmp = ipos;
- X while (itmp--)
- X dump_putc('-');
- X dump_putc(' ');
- X if (istr & 1)
- X ipos--;
- X }
- X dump_puts(title);
- X if (!terse_flag)
- X {
- X dump_putc(' ');
- X while (ipos--)
- X dump_putc('-');
- X }
- X dump_puts("\n");
- X
- X }
- X
- X istr = 0;
- X while (istr < len)
- X {
- X hex_dump16(istr);
- X dump_putc(' ');
- X for (itmp = 0; itmp < 16; ++itmp)
- X {
- X ipos = istr + itmp;
- X if (ipos >= len)
- X {
- X if (!terse_flag)
- X dump_puts(" ");
- X continue;
- X }
- X dump_putc(' ');
- X hex_dump8(str[ipos]);
- X }
- X dump_puts(" | ");
- X for (itmp = 0; itmp < 16; ++itmp)
- X {
- X ipos = istr + itmp;
- X if ((ipos) >= len)
- X {
- X if (!terse_flag)
- X dump_putc(' ');
- X }
- X else
- X {
- X dump_putc((str[ipos] >= ' ' && str[ipos] < 0x7f)
- X ? str[ipos] : '.');
- X }
- X }
- X if (dumpfp == stdout)
- X dump_puts(" |\r\n");
- X else
- X dump_puts(" |\n");
- X istr += 16;
- X } /* end of while(istr < len) */
- X
- X} /* end of hex_dump_fp */
- X
- X/*+-----------------------------------------------------------------------
- X xtoasc(character) - Make all chars "printable"
- X
- X returns pointer to a static string containing printable version
- X of a character. If control char, printed as "^A", etc.
- X if incl_3char set true, then space + ASCII assignment (e.g. "NUL") is
- X appended to the string for non-printable graphics
- X------------------------------------------------------------------------*/
- Xchar *
- Xxtoasc(ch, incl_3char)
- Xregister unsigned char ch;
- Xint incl_3char;
- X{
- X static char gg[8];
- X char *ascii_ctlstr =
- X "nulsohstxetxeotenqackbelbs ht nl vt ff cr so si dledc1dc2dc3dc4naksynetbcanem subescfs gs rs us sp ";
- X
- X if (ch == 0x7F)
- X strcpy(gg, "del");
- X else if (ch == 0x9b)
- X strcpy(gg, "csi");
- X else if (ch > 0x7F)
- X sprintf(gg, "0x%02x", (unsigned char)ch);
- X else if (ch > 0x20)
- X {
- X gg[0] = ch;
- X gg[1] = 0;
- X }
- X else
- X {
- X strncpy(gg, ascii_ctlstr + (ch * 3), 3);
- X gg[3] = 0;
- X }
- X return (gg);
- X} /* end of xtoasc */
- X
- X/*+-------------------------------------------------------------------------
- X write_funckeymap_desc(fp,buf,buflen,name)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xwrite_funckeymap_desc(fp, buf, buflen, name)
- XFILE *fp;
- Xunsigned char *buf;
- Xint buflen;
- Xchar *name;
- X{
- X char s256[256];
- X
- X sprintf(s256, " %s:%s:", name, name);
- X while (strlen(s256) < (unsigned)20)
- X strcat(s256, " ");
- X
- X while (buflen--)
- X {
- X strcat(s256, xtoasc(*buf++));
- X if (buflen)
- X strcat(s256, " ");
- X }
- X strcat(s256, "\n");
- X
- X fputs(s256, fp);
- X
- X} /* end of write_funckeymap_desc */
- X
- X/*+-------------------------------------------------------------------------
- X tputstrs(strs)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtputstrs(strs)
- Xchar **strs;
- X{
- X while (*strs)
- X fputs(*strs++, stdout);
- X} /* end of tputstrs */
- X
- X/*+-----------------------------------------------------------------------
- X k3ttymode(arg) -- control user console (kbd/screen)
- X
- X Where arg ==
- X 0 restore attributes saved at start of execution
- X 1 raw mode
- X
- X------------------------------------------------------------------------*/
- Xvoid
- Xk3ttymode(arg)
- Xint arg;
- X{
- X if (arg)
- X {
- X (void)ecugetattr(TTYIN, &tv);
- X tv.c_cflag &= ~(CS8 | PARENB | PARODD);
- X tv.c_cflag |= CS8;
- X tv.c_iflag &= ~(INLCR | ICRNL | IGNCR | IXOFF | ISTRIP);
- X#if defined(IUCLC)
- X tv.c_iflag &= ~IUCLC;
- X#endif
- X tv.c_lflag &= ~(ICANON | ISIG | ECHO);
- X tv.c_cc[VEOF] = '\01';
- X tv.c_cc[VEOL] = '\0';
- X tv.c_cc[VMIN] = VMIN_VALUE;
- X tv.c_cc[VTIME] = VTIME_VALUE;
- X (void)ecusetattr(TTYIN, TCSETAW, &tv);
- X }
- X else
- X (void)ecusetattr(TTYIN, TCSETAW, &tv0);
- X}
- X
- X/*+-------------------------------------------------------------------------
- X read_kbd_string(buf,max)
- X--------------------------------------------------------------------------*/
- Xint
- Xread_kbd_string(buf, maxsize)
- Xunsigned char *buf;
- Xint maxsize;
- X{
- X int count = read(TTYIN, buf, maxsize);
- X
- X#if 0
- X int itmp;
- X
- X for (itmp = 0; itmp < count; itmp++)
- X buf[itmp] &= 0x7F;
- X#endif
- X return (count);
- X
- X} /* end of read_kbd_string */
- X
- X/*+-------------------------------------------------------------------------
- X termio_parity_text(cflag)
- X--------------------------------------------------------------------------*/
- Xchar *
- Xtermio_parity_text(cflag)
- Xunsigned short cflag;
- X{
- X return ((cflag & PARENB) ? ((cflag & PARODD) ? "odd" : "even") : "none");
- X} /* end of termio_parity_text */
- X
- X/*+-----------------------------------------------------------------------
- X main()
- X------------------------------------------------------------------------*/
- Xmain(argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X int itmp;
- X int count;
- X int got_ctrl;
- X int found_dup;
- X int unusable = 0;
- X char ch;
- X char *ttype;
- X char *cptr;
- X struct keystruc *key = need_names;
- X struct keystruc *key2;
- X unsigned char instr[VMIN_VALUE + 1];
- X
- X#if !defined(sun)
- X char s128[128];
- X
- X#endif
- X FILE *fpout;
- X long now;
- X int errflg = 0;
- X char *outfile = "kbdtest3.out";
- X
- X/* extern char *optarg; */
- X extern int optind;
- X
- X setbuf(stdout, NULL);
- X setbuf(stderr, NULL);
- X
- X while ((itmp = getopt(argc, argv, "")) != -1)
- X {
- X switch (itmp)
- X {
- X case '?':
- X errflg++;
- X }
- X }
- X
- X if (optind == (argc - 1))
- X outfile = argv[optind++];
- X
- X if (errflg || (optind != argc))
- X {
- X (void)fprintf(stderr, "usage: %s [-hx] [outfile]\n");
- X exit(1);
- X }
- X
- X printf("\n\n\necu kbdtest3 revision %s\n", revision);
- X tputstrs(strs_intro);
- X if (!(fpout = fopen(outfile, "a")))
- X {
- X perror(outfile);
- X exit(1);
- X }
- X
- X ecugetattr(TTYIN, &tv0); /* get original status */
- X parity_text = termio_parity_text(tv0.c_cflag);
- X
- X if (!(ttype = getenv("TERM")))
- X ttype = "??";
- X time(&now);
- X fprintf(fpout, "# funckeymap for '%s' under ", ttype);
- X#if defined(M_SYSV)
- X fputs("SCO\n", fpout);
- X#else
- X#if defined(ISC)
- X fputs("ISC\n", fpout);
- X#else
- X#if defined(MOTSVR3)
- X fputs("MotSVR3\n", fpout);
- X#else
- X#if defined(sun)
- X fputs("SunOS\n", fpout);
- X#else
- X fputs("??? OS\n", fpout);
- X#endif /* sun */
- X#endif /* MOTSVR3 */
- X#endif /* ISC */
- X#endif /* M_SYSV */
- X
- X fprintf(fpout, "# built by kbdtest3 %s %s", revision, ctime(&now));
- X fprintf(fpout, "# keyboard parity required = %s\n", parity_text);
- X#if !defined(sun)
- X fprintf(fpout, "# stty -a at kbdtest3 execution time:\n");
- X fclose(fpout);
- X strcpy(s128, "stty -a | sed -e 's/^/# /' >> ");
- X strcat(s128, outfile);
- X system(s128);
- X if (!(fpout = fopen(outfile, "a")))
- X {
- X perror(outfile);
- X exit(1);
- X }
- X#endif
- X fprintf(fpout, "%s\n", ttype);
- X
- X printf("Your keyboard driver parity is set to %s\n", parity_text);
- X printf("press ^D (0x04) to terminate program early\n\n");
- X k3ttymode(1);
- X
- X while (key->ecuname)
- X {
- X key->count = -1;
- X printf("%-20.20s: ", key->peoplename);
- X count = read_kbd_string(instr, VMIN_VALUE);
- X if (!count)
- X {
- X printf("whoops ..... zero length read\n");
- X break;
- X }
- X if (!count)
- X {
- X perror("keyboard");
- X break;
- X }
- X
- X if (!strcmp(key->ecuname, "BkTab") && (count == 1) &&
- X (instr[0] == 9))
- X {
- X printf("produced the same keystroke sequence as TAB\n");
- X tputstrs(strs_bktab);
- X continue;
- X }
- X
- X if ((count == 1) && ((instr[0] & 0x7F) == 4))
- X {
- X printf("--abort--\n");
- X fputs("# User aborted entry.\n", fpout);
- X unusable = 2;
- X goto DONE;
- X }
- X
- X if ((count == 1) && (instr[0] == '/'))
- X {
- X printf("--dead key--\n");
- X fprintf(fpout, "# %s: dead key and no reasonable alternate\n",
- X key->ecuname);
- X }
- X else if ((count == 1) && (instr[0] == ' '))
- X {
- X printf("--no key--\n");
- X fprintf(fpout, "# %s: no key and no reasonable alternate\n",
- X key->ecuname);
- X }
- X else
- X {
- X for (itmp = 0; itmp < count; itmp++)
- X printf("%02x ", instr[itmp]);
- X fputc(' ', stdout);
- X got_ctrl = 0;
- X for (itmp = 0; itmp < count; itmp++)
- X {
- X ch = instr[itmp] & 0x7F;
- X if ((ch < ' ') || (ch > '~'))
- X ch = '.', got_ctrl = 1;
- X fputc(ch, stdout);
- X }
- X printf("\n");
- X
- X key->count = count;
- X memcpy(key->str, instr, sizeof(key->str));
- X write_funckeymap_desc(fpout, (unsigned char *)instr, count,
- X key->ecuname);
- X if (!got_ctrl)
- X {
- X printf("This looks like a printable character string.\n");
- X printf("You might want to reconsider another key.\n");
- X fprintf(fpout, "# the above entry is suspect\n");
- X }
- X }
- X
- X key++;
- X }
- X printf("\n");
- X
- X /*
- X * check for dup sequences
- X */
- X found_dup = 0;
- X for (key = need_names, key2 = key + 1;; key2++)
- X {
- X if (!key2->ecuname)
- X {
- X key++;
- X if (!key->ecuname)
- X break;
- X key2 = key + 1;
- X if (!key2->ecuname)
- X break;
- X }
- X if ((key->count < 0) || (key2->count < 0) || (key->count != key2->count))
- X continue;
- X if (!memcmp(key->str, key2->str, key->count))
- X {
- X printf("'%s' and '%s' produced the same key sequence\n",
- X key->peoplename, key2->peoplename);
- X found_dup++;
- X }
- X }
- X
- X if (found_dup)
- X {
- X fprintf(fpout,
- X "# found %d keystroke sequence duplication(s)\n", found_dup);
- X unusable = 1;
- X }
- X
- X if (need_names[I_HOME].count < 0)
- X {
- X cptr = "# No Home key was successfully defined!\n";
- X printf(cptr + 2);
- X fprintf(fpout, cptr);
- X unusable = 1;
- X }
- X if (need_names[I_END].count < 0)
- X {
- X cptr = "# No End key was successfully defined!\n";
- X printf(cptr + 2);
- X fprintf(fpout, cptr);
- X unusable = 1;
- X }
- X
- X DONE:
- X if (unusable)
- X {
- X printf("\nThis will be unusable. Please try again.\n");
- X fprintf(fpout, "# above entry is unusable\n");
- X }
- X else
- X {
- X printf("\nRemember to set keyboard parity to \"%s\" ",
- X parity_text);
- X fputs("when using this entry.\n", stdout);
- X tputstrs(strs_thanks);
- X }
- X
- X fputs("\n", fpout);
- X fclose(fpout);
- X k3ttymode(0);
- X exit(0);
- X
- X} /* end of main */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 15519 -ne `wc -c <'ecu330/kbdtest3.c'`; then
- echo shar: \"'ecu330/kbdtest3.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/kbdtest3.c'
- fi
- echo shar: End of archive 24 \(of 37\).
- cp /dev/null ark24isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 37 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-