home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / ecu / part24 < prev    next >
Encoding:
Internet Message Format  |  1994-05-24  |  64.6 KB

  1. From: wht@n4hgf.atl.ga.us (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v42i122:  ecu - ECU Asynchronous Communications v3.30, Part24/37
  4. Date: 24 May 1994 09:07:25 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2rt1mt$d46@sparky.sterling.com>
  9. X-Md4-Signature: 9f3350e0dbccaaf01efce4cb646b6eab
  10.  
  11. Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
  12. Posting-number: Volume 42, Issue 122
  13. Archive-name: ecu/part24
  14. Environment: SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2
  15. Supersedes: ecu: Volume 32, Issue 36-75
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  ecu330/Make.src ecu330/ecupde.c ecu330/ecutcap.c
  22. #   ecu330/kbdtest3.c
  23. # Wrapped by kent@sparky on Mon May 23 13:40:59 1994
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 24 (of 37)."'
  27. if test -f 'ecu330/Make.src' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'ecu330/Make.src'\"
  29. else
  30.   echo shar: Extracting \"'ecu330/Make.src'\" \(10236 characters\)
  31.   sed "s/^X//" >'ecu330/Make.src' <<'END_OF_FILE'
  32. X#+------------------------------------------------------------------- 
  33. X# Make.src - master Makefile source for ECU and related programs
  34. X# If THIS line is the third in the file you are reading, refer to
  35. X# the files README and Configure.
  36. X# wht@n4hgf.atl.ga.us
  37. X#--------------------------------------------------------------------
  38. X#+:EDITS:
  39. X#:05-04-1994-04:38-wht@n4hgf-ECU release 3.30
  40. X#:04-21-1994-16:26-wht@n4hgf-remove timetest
  41. X#:01-16-1994-15:53-wht@n4hgf-add ecumachdep.h
  42. X#:11-25-1993-15:16-wht@n4hgf-3.281-all: fixed
  43. X#:11-23-1993-10:56-wht@n4hgf-hpux and linux
  44. X#:07-14-1993-02:39-wht@n4hgf-'depecu' entry for make depend ecu alone
  45. X#:03-05-1993-13:24-wht@n4hgf-use mk.cpio to make cpio
  46. X#:09-10-1992-13:58-wht@n4hgf-ECU release 3.20
  47. X#:08-22-1992-15:37-wht@n4hgf-ECU release 3.20 BETA
  48. X#:07-17-1992-18:23-wht@n4hgf-new module nap.c
  49. X#:07-07-1992-20:04-wht@n4hgf-new installation mechanism
  50. X#:05-17-1992-18:50-wht@n4hgf-add cpio
  51. X#:02-10-1992-05:47-wht@n4hgf-mcs avail on some systems when non-COFF produced
  52. X#:09-03-1991-23:47-wht@n4hgf2-add timetest directory
  53. X#:09-02-1991-19:25-wht@n4hgf2-ckutio dif and fas.h left out of distribution
  54. X#:09-01-1991-16:22-wht@n4hgf2-generalize HDB config location
  55. X#:08-23-1991-13:35-wht@n4hgf-sun porting (3.13)
  56. X#:07-25-1991-12:55-wht@n4hgf-ECU release 3.10
  57. X#:04-21-1991-12:43-wht@n4hgf-convert to Make.src
  58. X
  59. XPROGRAM = ecu
  60. XINSTALLABLE = $(LBIN)/$(PROGRAM)
  61. X
  62. XECUSHARNAME=ecu330
  63. XMANSHARNAME=ecuman330
  64. X
  65. XLIBFUNCKEYMAP = $(ECULIBDIR)/funckeymap
  66. X
  67. XSHELL = /bin/sh
  68. X
  69. X.SUFFIXES:
  70. X.SUFFIXES: .o .c .h .l
  71. X.c.o:;    $(BINTIME) $(CC) -c $(CFLAGS) $*.c 
  72. X
  73. X
  74. XSRC    = \
  75. X    afterlint.c \
  76. X    bamboozle.c \
  77. X    cmdtbl.c \
  78. X    config.c \
  79. X    dutmp.c \
  80. X    ecu.c \
  81. X    ecuDCE.c \
  82. X    ecuLCK.c \
  83. X    ecuchdir.c \
  84. X    ecudump.c \
  85. X    ecufinsert.c \
  86. X    ecufkey.c \
  87. X    ecufork.c \
  88. X    ecugrabbag.c \
  89. X    ecuicmaux.c \
  90. X    ecuicmd.c \
  91. X    ecuicmhelp.c \
  92. X    ecuicmhist.c \
  93. X    eculine.c \
  94. X    eculock.c \
  95. X    ecunumrev.c \
  96. X    ecupde.c \
  97. X    ecuphdir.c \
  98. X    ecuphrase.c \
  99. X    ecurcvr.c \
  100. X    ecuscrdump.c \
  101. X    ecusetup.c \
  102. X    ecushm.c \
  103. X    ecusighdl.c \
  104. X    ecutcap.c \
  105. X    ecutermio.c \
  106. X    ecutime.c \
  107. X    ecutty.c \
  108. X    ecuuclc.c \
  109. X    ecuusage.c \
  110. X    ecuutil.c \
  111. X    ecuwinutil.c \
  112. X    ecuxfer.c \
  113. X    esdutil.c \
  114. X    expresp.c \
  115. X    fasiintf.c \
  116. X    feval.c \
  117. X    funckeymap.c \
  118. X    gendiff.c \
  119. X    gint.c \
  120. X    gstr.c \
  121. X    hdbintf.c \
  122. X    kbdtest.c \
  123. X    kbdtest3.c \
  124. X    logevent.c \
  125. X    lstat.c \
  126. X    makedirs.c \
  127. X    mkdirs.c \
  128. X    nap.c \
  129. X    pcmd.c \
  130. X    pcmdfile.c \
  131. X    pcmdif.c \
  132. X    pcmdtty.c \
  133. X    pcmdwhile.c \
  134. X    pcmdxfer.c \
  135. X    poutput.c \
  136. X    pprintf.c \
  137. X    proc.c \
  138. X    proc_error.c \
  139. X    procframe.c \
  140. X    regexp.c \
  141. X    smap.c \
  142. X    ttynaming.c \
  143. X    ugtext.c \
  144. X    utmpstat.c \
  145. X    var.c
  146. X
  147. XOBJ    = \
  148. X    bamboozle.o\
  149. X    cmdtbl.o\
  150. X    ecu.o\
  151. X    ecuLCK.o\
  152. X    ecudump.o\
  153. X    ecuchdir.o\
  154. X    ecufinsert.o\
  155. X    ecufkey.o\
  156. X    ecufork.o\
  157. X    ecuDCE.o\
  158. X    eculine.o\
  159. X    eculock.o\
  160. X    ecunumrev.o\
  161. X    ecuicmaux.o\
  162. X    ecuicmhelp.o\
  163. X    ecuicmhist.o\
  164. X    ecuicmd.o\
  165. X    ecugrabbag.o\
  166. X    ecupde.o\
  167. X    ecuphdir.o\
  168. X    ecuphrase.o\
  169. X    ecurcvr.o\
  170. X    ecuscrdump.o\
  171. X    ecusetup.o\
  172. X    ecushm.o\
  173. X    ecusighdl.o\
  174. X    ecutcap.o\
  175. X    ecutermio.o\
  176. X    ecutime.o\
  177. X    ecutty.o\
  178. X    ecuuclc.o\
  179. X    ecuusage.o\
  180. X    ecuutil.o\
  181. X    ecuwinutil.o\
  182. X    ecuxfer.o\
  183. X    esdutil.o\
  184. X    fasiintf.o\
  185. X    expresp.o\
  186. X    feval.o\
  187. X    gint.o\
  188. X    gstr.o\
  189. X    hdbintf.o\
  190. X    logevent.o\
  191. X    lstat.o\
  192. X    nap.o \
  193. X    mkdirs.o\
  194. X    funckeymap.o\
  195. X    pcmd.o\
  196. X    pcmdif.o\
  197. X    pcmdfile.o\
  198. X    pcmdtty.o\
  199. X    pcmdwhile.o\
  200. X    pcmdxfer.o\
  201. X    poutput.o\
  202. X    pprintf.o\
  203. X    proc.o\
  204. X    proc_error.o\
  205. X    procframe.o\
  206. X    regexp.o\
  207. X    ttynaming.o\
  208. X    ugtext.o\
  209. X    utmpstat.o\
  210. X    var.o
  211. X
  212. XHDR = \
  213. X    dialprog.h \
  214. X    dlent.h \
  215. X    dvent.h \
  216. X    ecu.h \
  217. X    ecu_config.h \
  218. X    ecu_pwd.h \
  219. X    ecu_stat.h \
  220. X    ecu_time.h \
  221. X    ecu_types.h \
  222. X    ecucmd.h \
  223. X    ecucurses.h \
  224. X    ecuerror.h \
  225. X    ecufkey.h \
  226. X    ecufork.h \
  227. X    ecukey.h \
  228. X    ecupde.h \
  229. X    ecumachdep.h \
  230. X    ecushm.h \
  231. X    ecutermio.h \
  232. X    ecutty.h \
  233. X    ecuungetty.h \
  234. X    ecuxkey.h \
  235. X    esd.h \
  236. X    feval.h \
  237. X    patchlevel.h \
  238. X    pc_scr.h \
  239. X    proc.h \
  240. X    relop.h \
  241. X    smap.h \
  242. X    termecu.h \
  243. X    ttynaming.h \
  244. X    utmpstatus.h \
  245. X    var.h 
  246. X
  247. XSHARFLS = \
  248. X    README* \
  249. X    BUGS \
  250. X    CHANGES \
  251. X    HISTORY \
  252. X    ESOTERIC \
  253. X    Configure \
  254. X    Make.src */Make.src \
  255. X    mk.cpio \
  256. X    $(SRC) $(HDR) \
  257. X    bperr/bperr.c \
  258. X    help/{*.[ch],ecuhelp.src} \
  259. X    ecuungetty/*.[ch] \
  260. X    z/*.[ch] \
  261. X    sea/{*.[ch],*.{doc,imp}} \
  262. X    gendial/{README,install_dialer,*.[ch]} \
  263. X    fasi/{Makefile,Master,Node,PATCHLEVEL} \
  264. X    fasi/{README,README.FASI,RELEASENOTES} \
  265. X    fasi/{Space.c,System,digi-pc8.h,fas.c,fas.h,idfasi} \
  266. X    ecufriend/*.[ch] \
  267. X    mapkey/README mapkey/keys.usa.ecu \
  268. X    xsel386/* \
  269. X    old_notes/README.* \
  270. X    doc/{README,Makefile,*.txt} models/* zgcc mkoldproto.l
  271. X
  272. XMAKEDIRS_OBJ =\
  273. X    makedirs.o\
  274. X    mkdirs.o\
  275. X    lstat.o
  276. X
  277. Xall: $(PROGRAM) .make.help .make.ug .make.z .make.s kbdtest3 makedirs
  278. X
  279. X$(PROGRAM): $(OBJ)
  280. X    echo 'char *makedate="@(#)'ecu `date` $(SYSTEM)'";'  >makedate.c
  281. X    $(CC) -c $(CFLAGS) makedate.c; rm makedate.c
  282. X    rm -f $@ $@~; if [ -f $@ ]; then mv $@ $@~; fi
  283. X    $(BINTIME) $(CC) -o $@ $(LDFLAGS) makedate.o $(OBJ) $(LIBS)
  284. X    rm makedate.o
  285. X
  286. X$(OBJ): Makefile
  287. X
  288. X.make.help:
  289. X    cd help; $(MAKE)
  290. X
  291. X.make.z:
  292. X    cd z; $(MAKE)
  293. X
  294. X.make.s:
  295. X    cd sea; $(MAKE)
  296. X
  297. X.make.ug:
  298. X    if [ $(CFG_UseUngetty) = yes ]; then \
  299. X        cd ecuungetty; $(MAKE); \
  300. X    fi
  301. X
  302. Xbperr/bperr: bperr/bperr.c
  303. X    cd bperr; $(MAKE) bperr
  304. X
  305. Xproc_error.c: ecuerror.h
  306. X    $(MAKE) bperr/bperr
  307. X    bperr/bperr
  308. X
  309. Xkbdtest3: kbdtest3.c ecutermio.o
  310. X    $(CC) -o $@ $(CFLAGS) kbdtest3.c ecutermio.o
  311. X
  312. X$(OBJ): ecushm.h
  313. X
  314. Xecu.fls: Makefile
  315. X    ls $(SRC) >ecu.fls
  316. X
  317. X# Not recommended
  318. Xprotos: ecu.fls afterlint mkoldproto
  319. X    echo ' ' > protos.h
  320. X    csh ./zgcc ecu.fls protos.h .
  321. X
  322. X# Not recommended
  323. Xallprotos:
  324. X    $(MAKE) protos
  325. X    cd z; $(MAKE) protos
  326. X    cd sea; $(MAKE) protos
  327. X
  328. Xmakedirs: $(MAKEDIRS_OBJ)
  329. X    $(CC) -o $@ $(LDFLAGS) $(MAKEDIRS_OBJ) $(LIBS)
  330. X
  331. X# install ecu
  332. Xiecu: makedirs ecu
  333. X    @echo Installing ECU in $(LBIN) and $(ECULIBDIR) ... please wait
  334. X    @if [ ! -d $(LBIN) ]; then \
  335. X        echo '\012'Attempting to make $(LBIN); \
  336. X        ./makedirs -m 755 $(LBIN); \
  337. X        ls -ld $(LBIN); \
  338. X    fi
  339. X    @rm -f $(INSTALLABLE) $(INSTALLABLE)~
  340. X    @if [ -f $(INSTALLABLE) ]; then \
  341. X        echo '\012'Cannot remove $(INSTALLABLE) - moving to $(INSTALLABLE)~ \
  342. X        mv $(INSTALLABLE) $(INSTALLABLE)~; \
  343. X    fi
  344. X    @cp $(PROGRAM) $(INSTALLABLE)
  345. X    @strip $(INSTALLABLE)
  346. X    @-if [ -x /usr/bin/mcs ]; then \
  347. X        /usr/bin/mcs -d $(INSTALLABLE) || echo mcs present but not COFF? ; \
  348. X    fi
  349. X    @chown bin $(INSTALLABLE)
  350. X    @chgrp bin $(INSTALLABLE)
  351. X    @chmod 711 $(INSTALLABLE)
  352. X    @echo '\012'Installed
  353. X    @ls -l $(INSTALLABLE)
  354. X    @if [ ! -d $(ECULIBDIR) ]; then \
  355. X        echo '\012'Attempting to make $(ECULIBDIR); \
  356. X        ./makedirs -m 755 $(ECULIBDIR); \
  357. X        ls -ld $(ECULIBDIR); \
  358. X    fi
  359. X    @-if [ -f $(LIBFUNCKEYMAP) ]; then \
  360. X        echo '\012'Saving your old $(LIBFUNCKEYMAP); \
  361. X        for i in  2 1; \
  362. X        do \
  363. X            j=`expr $$i + 1`; \
  364. X            mv $(LIBFUNCKEYMAP)-$$i $(LIBFUNCKEYMAP)-$$j 2>/dev/null; \
  365. X        done; \
  366. X        mv $(LIBFUNCKEYMAP) $(LIBFUNCKEYMAP)-1; \
  367. X        ls -l $(LIBFUNCKEYMAP)*; \
  368. X    fi
  369. X    @cp models/funckeymap $(ECULIBDIR)
  370. X    @chown bin $(LIBFUNCKEYMAP)
  371. X    @chgrp bin $(LIBFUNCKEYMAP)
  372. X    @chmod 644 $(LIBFUNCKEYMAP)
  373. X    @echo '\012'Installed
  374. X    @ls -l $(LIBFUNCKEYMAP)
  375. X
  376. X# install everything
  377. Xinstall: all makedirs #run as root
  378. X    @echo '\012'Starting full installation of ECU ... please wait
  379. X    @make iecu
  380. X    @if [ $(CFG_UseUngetty) = yes ]; then \
  381. X        cd ecuungetty; $(MAKE) install; \
  382. X    fi
  383. X    cd z; $(MAKE) install
  384. X    cd sea; $(MAKE) install
  385. X    cd help; $(MAKE) install
  386. X    @if [ ! -f $(HDBLIBDIR)/Devices ]; then \
  387. X        cp models/*.mi $(ECULIBDIR); \
  388. X        echo "==> edit $(ECULIBDIR)/*.mi for your tty lines per ecu.man"; \
  389. X    fi
  390. X    @echo '\012'Installation complete.  Follow the yellow brick road.
  391. X
  392. Xshar.fls: Makefile
  393. X    echo patchlevel.h > shar.fls
  394. X    csh -c 'ls $(SHARFLS) | sed -e "/patchlevel.h/d" | sort >> shar.fls'
  395. X
  396. X#for the author's laziness
  397. Xgendiff:
  398. X    gendiff -f -o ../ecu-3.30 -n Patch01 `cat shar.fls`
  399. X
  400. X# for shar 3.461
  401. Xshar: shar.fls
  402. X    echo 'shar -F -c -s "wht@n4hgf.atl.ga.us" -a \
  403. X    -E 'SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2' \
  404. X    -n$(ECUSHARNAME) -L57 -o/tmp/$(ECUSHARNAME) $(SHARFLS)'  > /tmp/ecu.csh.in
  405. X    csh /tmp/ecu.csh.in
  406. X    rm /tmp/ecu.csh.in
  407. X    cd doc;make
  408. X    shar -F -c -s "wht@n4hgf.atl.ga.us" -a \
  409. X    -E 'SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2' \
  410. X    -n$(MANSHARNAME) -L57 -o/tmp/$(MANSHARNAME) doc/ecu.man doc/proc.man
  411. X
  412. Xcpio: shar.fls
  413. X    ./mk.cpio /tmp/$(ECUSHARNAME).cpio
  414. X
  415. X# tools for making ecu
  416. Xafterlint: afterlint.c
  417. X    cc -O afterlint.c -o $@
  418. X    -if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $@; fi
  419. X    strip $@
  420. X
  421. Xmkoldproto: mkoldproto.l
  422. X    lex mkoldproto.l
  423. X    cc -O lex.yy.c -ll -o $@
  424. X    -if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $@; fi
  425. X    strip $@
  426. X    rm lex.yy.?
  427. X
  428. Xneat:
  429. X    rm -f core tags cscope.out makedate.c makedate.o
  430. X    rm -f *~ *# *.orig *.rej make.log a.out
  431. X    rm -f */*~ */*# */*.orig */*.rej
  432. X    rm -f makedirs kbdtest kbdtest3
  433. X    rm -f shar.fls cpio.fls /tmp/ecu.cpio.fls
  434. X    rm -f .make.* depend.tmp eddep.tmp Makefile.new *.bak *.BAK
  435. X    -cd help; $(MAKE) neat
  436. X    -cd z; $(MAKE) neat
  437. X    -cd sea; $(MAKE) neat
  438. X    -cd bperr; $(MAKE) neat
  439. X    -if [ $(CFG_UseUngetty) = yes ]; then \
  440. X        cd ecuungetty; $(MAKE) neat; \
  441. X    fi
  442. X
  443. Xclean: neat
  444. X    rm -f $(OBJ) makedirs.o
  445. X    rm -f config kbdtest kbdtest3 makedirs afterlint mkoldproto
  446. X    -cd help; $(MAKE) clean
  447. X    -cd z; $(MAKE) clean
  448. X    -cd sea; $(MAKE) clean
  449. X    -cd bperr; $(MAKE) clean
  450. X    -if [ $(CFG_UseUngetty) = yes ]; then \
  451. X        cd ecuungetty; $(MAKE) clean; \
  452. X    fi
  453. X    -if [ -f gendial/Makefile ]; then \
  454. X        cd gendial; $(MAKE) clean; \
  455. X    fi
  456. X    -if [ -f timetest/Makefile ]; then \
  457. X        cd timetest; $(MAKE) clean; \
  458. X    fi
  459. X
  460. Xclobber: clean
  461. X    rm -f $(PROGRAM) $(PROGRAM)~
  462. X    rm -f kbdtest3.out
  463. X    -cd help; $(MAKE) clobber
  464. X    -cd z; $(MAKE) clobber
  465. X    -cd sea; $(MAKE) clobber
  466. X    -cd bperr; $(MAKE) clobber
  467. X    -if [ $(CFG_UseUngetty) = yes ]; then \
  468. X        cd ecuungetty; $(MAKE) clobber; \
  469. X    fi
  470. X
  471. X#regenerate .o:.h dependencies automatically
  472. Xdepecu:
  473. X    rm -f depend.tmp
  474. X    grep '^#include' $(SRC) \
  475. X    | sed \
  476. X        -e '/</d'\
  477. X        -e 's?:[^"]*"\([^"]*\)".*?: \1?'\
  478. X        -e 's?\(.*\)\.c?\1.o?'\
  479. X     >> depend.tmp
  480. X
  481. X    echo '/^# DO NOT DELETE THIS LINE' >eddep.tmp
  482. X    echo '.+1,$$d' >>eddep.tmp
  483. X    echo 'r depend.tmp' >> eddep.tmp
  484. X    echo 'w' >> eddep.tmp
  485. X    cp Makefile Makefile.new
  486. X    ed Makefile.new < eddep.tmp
  487. X    rm eddep.tmp depend.tmp
  488. X    echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile.new
  489. X    echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY'>>Makefile.new
  490. X    echo '# see make depend above'>>Makefile.new
  491. X    mv Makefile Makefile.bak
  492. X    mv Makefile.new Makefile
  493. X
  494. Xdepend: depecu
  495. X    cd help; $(MAKE) depend
  496. X    cd z; $(MAKE) depend
  497. X    cd sea; $(MAKE) depend
  498. X    if [ $(CFG_UseUngetty) = yes ]; then \
  499. X        cd ecuungetty; $(MAKE) depend; \
  500. X    fi
  501. X
  502. X# DO NOT DELETE THIS LINE
  503. X# DEPENDENCIES MUST END AT END OF FILE
  504. X# IF YOU PUT STUFF HERE IT WILL GO AWAY
  505. X# see make depend above
  506. END_OF_FILE
  507.   if test 10236 -ne `wc -c <'ecu330/Make.src'`; then
  508.     echo shar: \"'ecu330/Make.src'\" unpacked with wrong size!
  509.   fi
  510.   # end of 'ecu330/Make.src'
  511. fi
  512. if test -f 'ecu330/ecupde.c' -a "${1}" != "-c" ; then 
  513.   echo shar: Will not clobber existing file \"'ecu330/ecupde.c'\"
  514. else
  515.   echo shar: Extracting \"'ecu330/ecupde.c'\" \(17101 characters\)
  516.   sed "s/^X//" >'ecu330/ecupde.c' <<'END_OF_FILE'
  517. X/*+-------------------------------------------------------------------------
  518. X    ecupde.c - various PDE-related functions
  519. X    wht@n4hgf.atl.ga.us
  520. X
  521. X  Defined functions:
  522. X    call_logical_telno(logical)
  523. X    choose_tty_for_pde(tpde)
  524. X    copy_pde_to_Lvariables(tpde,trial)
  525. X    logical_telno_to_pde(logical)
  526. X    pde_dial(tpde)
  527. X    pdetty_to_devtty(pdetty,devtty)
  528. X    phdir_list_read()
  529. X
  530. X--------------------------------------------------------------------------*/
  531. X/*+:EDITS:*/
  532. X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  533. X/*:05-29-1993-21:47-wht@n4hgf-better debug */
  534. X/*:05-29-1993-20:21-wht@n4hgf-change linst_err_text to LINST_text */
  535. X/*:03-27-1993-17:45-wht@n4hgf-SVR4 cc complained about strlen <= constant */
  536. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  537. X/*:09-05-1992-14:17-wht@n4hgf-was starting rcvr process too early on connect */
  538. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  539. X/*:05-13-1992-13:27-wht@n4hgf-active_pde use */
  540. X/*:04-24-1992-21:59-wht@n4hgf-more SCO tty name normalizing */
  541. X/*:12-02-1991-20:58-wht@n4hgf-breakout into separate module */
  542. X
  543. X#include "ecu.h"
  544. X#include "esd.h"
  545. X#include "var.h"
  546. X#include "ecupde.h"
  547. X#include "dvent.h"
  548. X#include "termecu.h"
  549. X#include "ecuerror.h"
  550. X#include "utmpstatus.h"
  551. X
  552. XDVE *hdb_choose_Any();
  553. XDVE *hdb_choose_Device();
  554. XPDE *phdir_list_search();
  555. Xchar *LINST_text();
  556. X
  557. Xextern char errmsg[];
  558. Xextern char *default_tty;
  559. Xextern int windows_active;
  560. X
  561. Xchar phonedir_name[PHONEDIR_NAME_SIZE];
  562. Xchar *phonedir_trigger = "#ECUPHONE\n";
  563. X
  564. X/*+-----------------------------------------------------------------------
  565. X    phdir_list_read()
  566. X
  567. Xreturn 0 if entire list read, else 1 if error (error msg in errmsg)
  568. X
  569. Xif file does not exist, create it, asking confirm only if in
  570. Xinteractive (curses) mode
  571. X------------------------------------------------------------------------*/
  572. Xint
  573. Xphdir_list_read()
  574. X{
  575. X    register token_number;
  576. X    register char *cptr;
  577. X    register char *token;
  578. X    int itmp;
  579. X    char readpde_buf[128];
  580. X    FILE *fp_phone;
  581. X    PDE *tpde;
  582. X    char *str_token();
  583. X
  584. X    if (!phonedir_name[0])
  585. X    {
  586. X        get_home_dir(phonedir_name);
  587. X        strcat(phonedir_name, "/.ecu/phone");
  588. X    }
  589. X
  590. X  TRY_OPEN:
  591. X    if (!(fp_phone = fopen(phonedir_name, "r")))
  592. X    {
  593. X        if (errno == ENOENT)
  594. X        {
  595. X            if (!want_pd_create(phonedir_name))
  596. X            {
  597. X                strcpy(errmsg, "non-existent file not created");
  598. X                return (1);
  599. X            }
  600. X            if ((itmp = open(phonedir_name,
  601. X                        O_RDWR | O_CREAT | O_TRUNC, 0600)) >= 0)
  602. X            {
  603. X                write(itmp, phonedir_trigger, strlen(phonedir_trigger));
  604. X                close(itmp);
  605. X                if (windows_active)    /* if called under curses */
  606. X                {
  607. X                    dirw_bot_msg("created new (empty) directory file");
  608. X                    ring_bell();
  609. X                    Nap(1000L);
  610. X                }
  611. X                goto TRY_OPEN;
  612. X            }
  613. X            if (errno == ENOENT)
  614. X            {
  615. X                strcpy(errmsg, "~/.ecu directory nonexistent!");
  616. X                ring_bell();
  617. X                return (1);
  618. X            }
  619. X        }
  620. X        strcpy(errmsg, errno_text(errno));
  621. X        return (1);
  622. X    }
  623. X
  624. X/* we have an open directory file */
  625. X    if (!fgets(readpde_buf, sizeof(readpde_buf), fp_phone) ||
  626. X        strcmp(readpde_buf, phonedir_trigger))
  627. X    {
  628. X        fclose(fp_phone);
  629. X        strcpy(errmsg, "not an ECU phone directory (or is pre-rev-3)");
  630. X        ring_bell();
  631. X        return (1);
  632. X    }
  633. X
  634. X    dirw_display_phonedir_name();
  635. X    phdir_list_erase();         /* clear any previous directory */
  636. X    while (fgets(readpde_buf, sizeof(readpde_buf), fp_phone))
  637. X    {
  638. X        if (readpde_buf[0] == '#')    /* comment? */
  639. X            continue;
  640. X        if (itmp = strlen(readpde_buf))    /* itmp = len; if > 0 ... */
  641. X        {
  642. X            itmp--;
  643. X            readpde_buf[itmp] = 0;    /* ... strip trailing NL */
  644. X        }
  645. X        cptr = readpde_buf;     /* first call to str_token, -> buff */
  646. X        while ((*cptr == 0x20) || (*cptr == 0x09))
  647. X            cptr++;             /* strip leading spaces */
  648. X        if (*cptr == 0)         /* if line all blank, skip it */
  649. X            continue;
  650. X
  651. X        if (!(tpde = (PDE *) malloc(sizeof(PDE))))
  652. X        {
  653. X            fclose(fp_phone);
  654. X            strcpy(errmsg, "Out of memory reading phone list");
  655. X            return (1);
  656. X        }
  657. X
  658. X        tpde->descr[0] = 0;
  659. X        tpde->logical[0] = 0;
  660. X        tpde->telno[0] = 0;
  661. X        tpde->tty[0] = 0;
  662. X        tpde->parity = 0;
  663. X        tpde->baud = 2400;
  664. X        tpde->redial = 0;
  665. X        tpde->prev = (PDE *) 0;
  666. X        tpde->next = (PDE *) 0;
  667. X        tpde->debug_level = 0;
  668. X        tpde->dcdwatch = 'n';/* do not modify shm->Ldcdwatch */
  669. X
  670. X        token_number = 0;
  671. X        while ((token = str_token(cptr, ":")))
  672. X        {
  673. X            cptr = (char *)0;/* further calls to str_token need NULL */
  674. X            switch (token_number)
  675. X            {
  676. X                case 0:     /* first field is logical name */
  677. X                    strncpy(tpde->logical, token, sizeof(tpde->logical));
  678. X                    tpde->logical[sizeof(tpde->logical) - 1] = 0;
  679. X                    break;
  680. X                case 1:     /* second field is tpde->telno phone number */
  681. X                    strncpy(tpde->telno, token, sizeof(tpde->telno));
  682. X                    tpde->telno[sizeof(tpde->telno) - 1] = 0;
  683. X                    break;
  684. X                case 2:     /* third field is line */
  685. X                    strncpy(tpde->tty, token, sizeof(tpde->tty));
  686. X                    tpde->tty[sizeof(tpde->tty) - 1] = 0;
  687. X                    break;
  688. X                case 3:     /* fourth field is baud rate */
  689. X                    tpde->baud = atoi(token);
  690. X                    break;
  691. X                case 4:     /* fifth field is parity */
  692. X                    switch (itmp = to_lower(token[0]))
  693. X                    {
  694. X                        case 'o':
  695. X                        case 'e':
  696. X                        case 'm':
  697. X                        case 's':
  698. X                            tpde->parity = itmp;
  699. X                            break;
  700. X                        default:
  701. X                        case 'n':
  702. X                            tpde->parity = 0;
  703. X                            break;
  704. X                    }
  705. X                    break;
  706. X                case 5:
  707. X                    strncpy(tpde->descr, token, sizeof(tpde->descr));
  708. X                    tpde->descr[sizeof(tpde->descr) - 1] = 0;
  709. X                    break;
  710. X                case 6:
  711. X                    if ((tpde->debug_level = (uchar) atoi(token)) > 9)
  712. X                        tpde->debug_level = 9;
  713. X                    break;
  714. X                case 7:
  715. X                    tpde->dcdwatch = to_lower(token[0]);
  716. X                    break;
  717. X            }                 /* end of switch(token_number) */
  718. X            token_number++;
  719. X        }                     /* end while not end of record */
  720. X
  721. X        phdir_list_add(tpde);
  722. X
  723. X    }                         /* while records left to ready */
  724. X
  725. X    fclose(fp_phone);
  726. X    return (0);
  727. X}                             /* end of phdir_list_read */
  728. X
  729. X/*+-------------------------------------------------------------------------
  730. X    pde_dial(tpde) - dial using a pde (using procedure if configured)
  731. X
  732. XIf the tpde->logical points to a valid procedure, use it,
  733. Xotherwise call DCE_dial()
  734. X
  735. Xreturns proc error code
  736. X        $i0 value ($s0 is also set, BTW)
  737. X
  738. Xassumes rcvr process dead (rcvr_pid == -1)
  739. X--------------------------------------------------------------------------*/
  740. Xint
  741. Xpde_dial(tpde)
  742. Xregister PDE *tpde;
  743. X{
  744. X    int status = 0;
  745. X    int restart_rcvr = need_rcvr_restart();
  746. X    char *cptr;
  747. X    extern int dcdwatch_set; /* see ldcdwatch() in eculine.c */
  748. X
  749. X    dcdwatch_set = 0;
  750. X
  751. X    kill_rcvr_process(SIGUSR1);
  752. X
  753. X    if (proc_level || !find_procedure(tpde->logical))
  754. X    {
  755. X        if (copy_pde_to_Lvariables(tpde, 0))
  756. X        {
  757. X            pprintf("%s: %s\n", tpde->logical, errmsg);
  758. X            pprintf("Current line is %s (%s)\n",
  759. X                shm->Lline, (shm->Liofd < 0) ? "closed" : "open");
  760. X            status = eFATAL_ALREADY;
  761. X        }
  762. X        else
  763. X            status = DCE_dial();
  764. X    }
  765. X    else
  766. X    {
  767. X        char *pargv[2];
  768. X
  769. X        pargv[0] = tpde->logical;
  770. X        pargv[1] = "!MENU";
  771. X        iv[0] = 0;
  772. X        if (do_proc(2, pargv))
  773. X            status = eFATAL_ALREADY;
  774. X        else
  775. X            status = (iv[0]) ? eConnectFailed : 0;
  776. X    }
  777. X
  778. X    /*
  779. X     * if we connected and a procedure did not change the DCD watcher,
  780. X     * then use the dialing directory choice
  781. X     */
  782. X    if (!status && !dcdwatch_set)
  783. X    {
  784. X        cptr = (char *)0;
  785. X        switch (tpde->dcdwatch)
  786. X        {
  787. X            case '0':
  788. X                ldcdwatch(DCDW_OFF);
  789. X                cptr = "OFF (ignore DCD loss)";
  790. X                break;
  791. X            case '1':
  792. X                ldcdwatch(DCDW_ON);
  793. X                cptr = "ON (detect DCD loss)";
  794. X                break;
  795. X            case 't':
  796. X                ldcdwatch(DCDW_TERMINATE);
  797. X                cptr = "TERMINATE (terminate ecu on DCD loss)";
  798. X                break;
  799. X            case 'n':
  800. X            default:
  801. X                break;
  802. X        }
  803. X        if (cptr)
  804. X        {
  805. X            ulong colors_save;
  806. X
  807. X            colors_save = colors_current;
  808. X            setcolor(colors_notify);
  809. X            pprintf("[DCD watcher set to %s]", cptr);
  810. X            setcolor(colors_save);
  811. X            fputs("\r\n", se);
  812. X            pputs("\n");
  813. X        }
  814. X    }
  815. X
  816. X    if (restart_rcvr)
  817. X        start_rcvr_process(1);
  818. X
  819. X    return (status);
  820. X
  821. X}                             /* end of pde_dial */
  822. X
  823. X/*+-------------------------------------------------------------------------
  824. X    pdetty_to_devtty(pdetty,devtty) -> pde tty field to complete pathname
  825. X--------------------------------------------------------------------------*/
  826. Xvoid
  827. Xpdetty_to_devtty(pdetty, devtty)
  828. Xchar *pdetty;
  829. Xchar *devtty;
  830. X{
  831. X    strcpy(devtty, "/dev/");
  832. X#ifdef M_SYSV
  833. X    if (strncmp(pdetty, "tty", 3))
  834. X        strcat(devtty, "tty");
  835. X#endif
  836. X    strcat(devtty, pdetty);
  837. X
  838. X}                             /* end of pdetty_to_devtty */
  839. X
  840. X/*+-------------------------------------------------------------------------
  841. X    choose_tty_for_pde(tpde) - new pde might mandate switching line
  842. X
  843. XReturns 1 if new line open needed
  844. X        0 if no new line open needed
  845. X       -1 if request cannot be satisfied
  846. X--------------------------------------------------------------------------*/
  847. Xint
  848. Xchoose_tty_for_pde(tpde)
  849. Xregister PDE *tpde;
  850. X{
  851. X    int itmp = 0;
  852. X    int rtn = 0;
  853. X    DVE *tdve;
  854. X    char newtty[64];
  855. X
  856. X#ifdef CHOOSE_DEBUG
  857. X    char s256[256];
  858. X
  859. X    sprintf(s256, "CHOOSE_TTY_FOR_PDE '%s' %u baud", tpde->tty, tpde->baud);
  860. X    ecu_log_event(getpid(), s256);
  861. X    errmsg[0] = 0;
  862. X#endif
  863. X
  864. X    /*
  865. X     * if desired line is Devices type
  866. X     */
  867. X    if ((tpde->tty[0] == '=') || (tpde->tty[0] == '/'))    /* Devices device type */
  868. X    {
  869. X        if (!(tdve = hdb_choose_Device(tpde->tty, tpde->baud)))
  870. X        {
  871. X            sprintf(errmsg, "no idle line matches type '%s' at %u baud",
  872. X                *tpde->tty ? tpde->tty : "Any", tpde->baud);
  873. X            rtn = -1;
  874. X            goto FUNC_RETURN;
  875. X        }
  876. X        sprintf(newtty, "/dev/%s", tdve->line);
  877. X        if ((itmp = lock_tty(newtty)) && (itmp != LINST_WEGOTIT))
  878. X        {
  879. X            sprintf(errmsg, "%s (%s): %s",
  880. X                tpde->tty, tdve->line, LINST_text(itmp));
  881. X            rtn = -1;
  882. X            goto FUNC_RETURN;
  883. X        }
  884. X        if ((itmp = reserve_line(newtty)) && (itmp != LINST_WEGOTIT))
  885. X        {
  886. X            sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
  887. X            rtn = -1;
  888. X            goto FUNC_RETURN;
  889. X        }
  890. X    }
  891. X
  892. X    /*
  893. X     * if desired line is a specific tty
  894. X     */
  895. X    else if (tpde->tty[0])
  896. X    {
  897. X        pdetty_to_devtty(tpde->tty, newtty);
  898. X        if ((shm->Liofd > 0) && !strcmp(newtty, shm->Lline))
  899. X        {
  900. X            rtn = 0;         /* requesting line we already have */
  901. X            goto FUNC_RETURN;
  902. X        }
  903. X        if ((itmp = lock_tty(newtty)) && (itmp != LINST_WEGOTIT))
  904. X        {
  905. X            sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
  906. X            rtn = -1;
  907. X            goto FUNC_RETURN;
  908. X        }
  909. X        if ((itmp = reserve_line(newtty)) && (itmp != LINST_WEGOTIT))
  910. X        {
  911. X            sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
  912. X            rtn = -1;
  913. X            goto FUNC_RETURN;
  914. X        }
  915. X    }
  916. X
  917. X    /*
  918. X     * if desired line is "Any" (any Devices type beginning with ACU)
  919. X     */
  920. X    else
  921. X        /* "Any" */
  922. X    {
  923. X        tdve = hdb_choose_Any(tpde->baud);
  924. X        if (!tdve)
  925. X        {
  926. X            sprintf(errmsg, "no idle ACU line at %u baud", tpde->baud);
  927. X            rtn = -1;
  928. X            goto FUNC_RETURN;
  929. X        }
  930. X        sprintf(newtty, "/dev/%s", tdve->line);
  931. X        if ((itmp = lock_tty(newtty)) && (itmp != LINST_WEGOTIT))
  932. X        {
  933. X            sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
  934. X            rtn = -1;
  935. X            goto FUNC_RETURN;
  936. X        }
  937. X        if ((itmp = reserve_line(newtty)) && (itmp != LINST_WEGOTIT))
  938. X        {
  939. X            sprintf(errmsg, "%s: %s", newtty, LINST_text(itmp));
  940. X            rtn = -1;
  941. X            goto FUNC_RETURN;
  942. X        }
  943. X    }
  944. X
  945. X    rtn = !(!strcmp(newtty, shm->Lline) && (shm->Liofd != -1));
  946. X    if (rtn)
  947. X    {
  948. X        lclose();
  949. X        strcpy(shm->Lline, newtty);
  950. X    }
  951. X
  952. X  FUNC_RETURN:
  953. X
  954. X#ifdef CHOOSE_DEBUG
  955. X    sprintf(s256, "CHOOSE_TTY_FOR_PDE rtn=%d line='%s' errmsg='%s' itmp=%d",
  956. X        rtn, shm->Lline, errmsg, itmp);
  957. X    ecu_log_event(getpid(), s256);
  958. X#endif
  959. X
  960. X    return (rtn);
  961. X
  962. X}                             /* end of choose_tty_for_pde */
  963. X
  964. X/*+-------------------------------------------------------------------------
  965. X    copy_pde_to_Lvariables(tpde,trial)
  966. X
  967. X'trial' controls whether this is a dry run (setup) or a live request
  968. Xif changing line, close old line and open new one
  969. Xif cannot change line, return -1, else 0
  970. X--------------------------------------------------------------------------*/
  971. Xint
  972. Xcopy_pde_to_Lvariables(tpde, trial)
  973. Xregister PDE *tpde;
  974. Xint trial;
  975. X{
  976. X    int reopen = 0;
  977. X    int lerr;
  978. X    DVE *tdve;
  979. X
  980. X#ifdef CHOOSE_DEBUG
  981. X    char s256[256];
  982. X
  983. X    sprintf(s256, "COPY_PDE1 trial=%d Lline='%s' pdetty='%s'",
  984. X        trial, shm->Lline, tpde->tty);
  985. X    ecu_log_event(getpid(), s256);
  986. X#endif
  987. X
  988. X    enddvent();                 /* krock safety */
  989. X
  990. X    if (!trial)
  991. X    {
  992. X        if ((reopen = choose_tty_for_pde(tpde)) < 0)
  993. X            return (-1);     /* errmsg[] updated */
  994. X    }
  995. X    else if ((!tpde->tty[0]) || (!strcmp(tpde->tty, "Any")))
  996. X    {
  997. X        if (!(tdve = hdb_choose_Any(tpde->baud)))
  998. X        {
  999. X            strcpy(errmsg, "no idle line matches type 'Any'");
  1000. X            return (-1);
  1001. X        }
  1002. X        strcpy(shm->Lline, "/dev/");
  1003. X        strncat(shm->Lline, tdve->line, sizeof(shm->Lline) - 5);
  1004. X        shm->Lline[sizeof(shm->Lline) - 1] = 0;
  1005. X    }
  1006. X    else if ((tpde->tty[0] == '/') || (tpde->tty[0] == '='))
  1007. X    {
  1008. X        if (!(tdve = hdb_choose_Device(tpde->tty, tpde->baud)))
  1009. X        {
  1010. X            sprintf(errmsg, "no idle line matches type '%s' at %u baud",
  1011. X                *tpde->tty ? tpde->tty : "Any", tpde->baud);
  1012. X            return (-1);
  1013. X        }
  1014. X        strcpy(shm->Lline, "/dev/");
  1015. X        strncat(shm->Lline, tdve->line, sizeof(shm->Lline) - 5);
  1016. X        shm->Lline[sizeof(shm->Lline) - 1] = 0;
  1017. X    }
  1018. X    else
  1019. X        pdetty_to_devtty(tpde->tty, shm->Lline);
  1020. X
  1021. X#ifdef CHOOSE_DEBUG
  1022. X    sprintf(s256, "COPY_PDE2  Lline='%s' reopen=%d", shm->Lline, reopen);
  1023. X    ecu_log_event(getpid(), s256);
  1024. X#endif
  1025. X
  1026. X    shm->Lbaud = tpde->baud;
  1027. X    strcpy(shm->Llogical, tpde->logical);
  1028. X    strcpy(shm->Ldescr, tpde->descr);
  1029. X    strcpy(shm->Ltelno, tpde->telno);
  1030. X    if (!shm->Ldescr[0])
  1031. X        strcpy(shm->Ldescr, shm->Llogical);
  1032. X    shm->Lparity = tpde->parity;
  1033. X    if (shm->Lbaud != tpde->baud)
  1034. X        shm->Lmodem_already_init = 0;
  1035. X    Ldial_debug_level = tpde->debug_level;
  1036. X    /* tpde->dcdwatch is explicitly unused here; must defer until connect  */
  1037. X
  1038. X    if (!trial)
  1039. X    {
  1040. X        if (reopen)
  1041. X        {
  1042. X            if (lerr = lopen())
  1043. X            {
  1044. X                tcap_curbotleft();
  1045. X                pprintf("%s: %s\n", shm->Lline, LINST_text(lerr));
  1046. X                lopen_error_reset();    /* clear static error area */
  1047. X                termecu(TERMECU_LINE_OPEN_ERROR);
  1048. X            }
  1049. X        }
  1050. X        else
  1051. X        {
  1052. X            lset_baud_rate(1);
  1053. X            lset_parity(1);
  1054. X        }
  1055. X    }
  1056. X    return (0);
  1057. X
  1058. X}                             /* end of copy_pde_to_Lvariables */
  1059. X
  1060. X/*+-----------------------------------------------------------------------
  1061. X    logical_telno_to_pde() - logical dial string to dialing info (PDE)
  1062. X
  1063. X    NOT USED BY THE CURSES DIRECTORY MANAGER
  1064. X
  1065. XA logical telephone number is one of:
  1066. X1. null,
  1067. X2. a symbolic identifer, or
  1068. X3. an actual telephone number.
  1069. X
  1070. XA symbolic identifer is a string whose initial character is a
  1071. Xletter.  An actual telephone number begins with a numeral.
  1072. X
  1073. XThis function converts a logical telephone number to a dialing
  1074. Xentry (PDE) from the directory or a constructed static one.  It
  1075. Xis called by command line processing when 'ecu logical-name' is
  1076. Xspecified or in response to a %dial logical-name.
  1077. X
  1078. XThe function returns one of the following:
  1079. X
  1080. X  directory or static PDE        if no error occurs
  1081. X  (PDE *)0                        if not numeric phone number
  1082. X                                and logical string not found in directory;
  1083. X                                global char[] errmsg has been plugged with
  1084. X                                error message
  1085. X
  1086. X------------------------------------------------------------------------*/
  1087. XPDE *
  1088. Xlogical_telno_to_pde(logical)
  1089. Xchar *logical;
  1090. X{
  1091. X    static PDE literal_number_pde;
  1092. X    register PDE *tpde = 0;
  1093. X    extern int phdir_list_quan;
  1094. X
  1095. X/*
  1096. X * if literal phone number, return homemade, static "PDE"
  1097. X * with most stuff dummied up with the status quo
  1098. X */
  1099. X    if (isdigit(*logical))
  1100. X    {
  1101. X        tpde = &literal_number_pde;
  1102. X        memset((char *)tpde, 0, sizeof(PDE));
  1103. X        tpde->baud = shm->Lbaud;
  1104. X        tpde->parity = shm->Lparity;
  1105. X        strncpy(tpde->logical, logical, DESTREF_LEN);
  1106. X        tpde->logical[DESTREF_LEN] = 0;
  1107. X        strncpy(tpde->telno, logical, DESTREF_LEN);
  1108. X        tpde->telno[DESTREF_LEN] = 0;
  1109. X        strncpy(tpde->tty, shm->Lline + 5, PDE_TTY_LEN);
  1110. X        tpde->tty[PDE_TTY_LEN] = 0;
  1111. X        if ((unsigned)(strlen(logical) + 8) <= (unsigned)PDE_DESCR_LEN)
  1112. X            sprintf(tpde->descr, "<telno %s>", logical);
  1113. X        else
  1114. X            strcpy(tpde->descr, "<telno>");
  1115. X        tpde->dcdwatch = 'n';
  1116. X        goto FUNC_RETURN;
  1117. X    }
  1118. X
  1119. X/*
  1120. X * if empty phone number, return homemade, static "PDE"
  1121. X * with most stuff dummied up with the status quo
  1122. X */
  1123. X    if (!*logical)
  1124. X    {
  1125. X        tpde = &literal_number_pde;
  1126. X        memset((char *)tpde, 0, sizeof(PDE));
  1127. X        tpde->baud = shm->Lbaud;
  1128. X        tpde->parity = shm->Lparity;
  1129. X        strcpy(tpde->tty, shm->Lline + 5);
  1130. X        if (!tpde->tty[0])
  1131. X            strcpy(tpde->tty, default_tty + 5);
  1132. X        strcpy(tpde->descr, "<direct connect>");
  1133. X        tpde->dcdwatch = 'n';
  1134. X        goto FUNC_RETURN;
  1135. X    }
  1136. X
  1137. X    /*
  1138. X     * read directory if necessary
  1139. X     */
  1140. X    if (!phdir_list_quan)
  1141. X    {
  1142. X        if (phdir_list_read() && !phdir_list_quan)
  1143. X        {                     /* if still no good, ... */
  1144. X            strcpy(errmsg, "phone directory empty");
  1145. X            tpde = 0;
  1146. X            goto FUNC_RETURN;
  1147. X        }
  1148. X    }
  1149. X
  1150. X    /*
  1151. X     * now, look up the entry
  1152. X     */
  1153. X    if (tpde = phdir_list_search(logical, 0))
  1154. X        goto FUNC_RETURN;
  1155. X
  1156. X    /*
  1157. X     * whoops ... not found
  1158. X     */
  1159. X    shm->Lrname[0] = 0;
  1160. X    shm->Ltelno[0] = 0;
  1161. X    shm->Ldescr[0] = 0;
  1162. X    strcpy(errmsg, "entry not found in directory");
  1163. X    tpde = 0;
  1164. X
  1165. X  FUNC_RETURN:
  1166. X
  1167. X#ifdef CHOOSE_DEBUG
  1168. X    {
  1169. X        char s256[256];
  1170. X
  1171. X        sprintf(s256, "LOGICAL->PDE %s=%s chosen tty=%s",
  1172. X            (tpde == &literal_number_pde) ? "TELNO" : "LOGICAL",
  1173. X            logical,
  1174. X            (tpde && tpde->tty[0]) ? tpde->tty : "<none>"
  1175. X            );
  1176. X        ecu_log_event(getpid(), s256);
  1177. X    }
  1178. X#endif
  1179. X
  1180. X    return (tpde);
  1181. X
  1182. X}                             /* end of logical_telno_to_pde */
  1183. X
  1184. X/*+-------------------------------------------------------------------------
  1185. X    call_logical_telno(logical) - call a logical or literal telephone number
  1186. X
  1187. X-1 if no such entry or pde_dial() status
  1188. X--------------------------------------------------------------------------*/
  1189. Xint
  1190. Xcall_logical_telno(logical)
  1191. Xchar *logical;
  1192. X{
  1193. X    int ret;
  1194. X    PDE *tpde;
  1195. X
  1196. X    if (tpde = logical_telno_to_pde(logical))
  1197. X        ret = pde_dial(tpde);
  1198. X    else
  1199. X    {
  1200. X        pprintf("%s: %s\n", logical, errmsg);
  1201. X        ret = eFATAL_ALREADY;
  1202. X    }
  1203. X
  1204. X    return (ret);
  1205. X
  1206. X}                             /* end of call_logical_telno */
  1207. X
  1208. X/* vi: set tabstop=4 shiftwidth=4: */
  1209. X/* end of ecupde.c */
  1210. END_OF_FILE
  1211.   if test 17101 -ne `wc -c <'ecu330/ecupde.c'`; then
  1212.     echo shar: \"'ecu330/ecupde.c'\" unpacked with wrong size!
  1213.   fi
  1214.   # end of 'ecu330/ecupde.c'
  1215. fi
  1216. if test -f 'ecu330/ecutcap.c' -a "${1}" != "-c" ; then 
  1217.   echo shar: Will not clobber existing file \"'ecu330/ecutcap.c'\"
  1218. else
  1219.   echo shar: Extracting \"'ecu330/ecutcap.c'\" \(17512 characters\)
  1220.   sed "s/^X//" >'ecu330/ecutcap.c' <<'END_OF_FILE'
  1221. X/*+-------------------------------------------------------------------------
  1222. X    ecutcap.c -- termcap stuff
  1223. X    wht@n4hgf.atl.ga.us
  1224. X
  1225. X  Defined functions:
  1226. X    tcap_blink_off()
  1227. X    tcap_blink_on()
  1228. X    tcap_bold_off()
  1229. X    tcap_bold_on()
  1230. X    tcap_clear_area_char(count,clrch)
  1231. X    tcap_clear_screen()
  1232. X    tcap_curbotleft()
  1233. X    tcap_curleft(count)
  1234. X    tcap_curright(count)
  1235. X    tcap_cursor(y,x)
  1236. X    tcap_delete_chars(count)
  1237. X    tcap_delete_lines(count)
  1238. X    tcap_draw_box(y,x,height,width,title,title_x)
  1239. X    tcap_draw_box_primitive(y,x,height,width)
  1240. X    tcap_eeod()
  1241. X    tcap_eeol()
  1242. X    tcap_gets(buf,bufsize,delim,wait_for_key)
  1243. X    tcap_horiz_rule(count)
  1244. X    tcap_init()
  1245. X    tcap_insert_chars(count)
  1246. X    tcap_insert_lines(count)
  1247. X    tcap_putc(character)
  1248. X    tcap_stand_end()
  1249. X    tcap_stand_out()
  1250. X    tcap_underscore_off()
  1251. X    tcap_underscore_on()
  1252. X    tcap_vbell()
  1253. X    tcap_vertical_rule(y,x,count)
  1254. X
  1255. X--------------------------------------------------------------------------*/
  1256. X/*+:EDITS:*/
  1257. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1258. X/*:01-06-1994-04:21-wht@n4hgf-clean up LINUX tcap_putc */
  1259. X/*:01-04-1994-05:32-wht@n4hgf-modify Linux port to balance braces */
  1260. X/*:01-04-1994-01:43-wht@n4hgf-protect against NULL tc_blink_on/off */
  1261. X/*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
  1262. X/*:07-23-1993-13:43-wht@n4hgf-tcap_clear_area_char had same buggy tputs call */
  1263. X/*:07-17-1993-12:19-wht@n4hgf-tcap_curleft and right had buggy tputs calls */
  1264. X/*:01-11-1993-16:04-wht@n4hgf-vbell defaults to bell */
  1265. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1266. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1267. X/*:03-10-1992-13:25-wht@n4hgf2-quick sanity check on ttype features */
  1268. X/*:02-24-1992-06:50-root@n4hgf-getenv COLUMNS not COLS */
  1269. X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
  1270. X/*:05-01-1991-04:05-wht@n4hgf-try to catch tbetz tc= infinite loop early */
  1271. X/*:03-20-1991-16:25-root@n4hgf-environment LINES/COLS overrides termcap li/co */
  1272. X/*:11-28-1990-14:52-wht@n4hgf-tcap support for non-ansi console */
  1273. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1274. X
  1275. X#ifdef LINUX
  1276. X#include <ncurses.h>
  1277. X#include <term.h>
  1278. X#endif
  1279. X#include "ecu.h"
  1280. X#include "ecukey.h"
  1281. X#include "pc_scr.h"
  1282. X
  1283. Xuint tcap_LINES;
  1284. Xuint tcap_COLS;
  1285. X
  1286. Xstatic char *tc_blink_on = "";
  1287. Xstatic char *tc_blink_off = "";
  1288. Xstatic char *tc_bold_on = "";
  1289. Xstatic char *tc_bold_off = "";
  1290. Xstatic char *tc_clear = "";
  1291. Xstatic char *tc_curleft = "";
  1292. Xstatic char *tc_curright = "";
  1293. Xstatic char *tc_delchar = "";
  1294. Xstatic char *tc_delline = "";
  1295. Xstatic char *tc_eeod = "";
  1296. Xstatic char *tc_eeol = "";
  1297. Xstatic char *tc_inschar = "";
  1298. Xstatic char *tc_insline = "";
  1299. Xstatic char *tc_move = "";
  1300. Xstatic char *tc_standout = "";
  1301. Xstatic char *tc_standend = "";
  1302. Xstatic char *tc_underscore_on = "";
  1303. Xstatic char *tc_underscore_off = "";
  1304. Xstatic char *tc_vbell = "";
  1305. X
  1306. X#ifndef LINUX
  1307. Xstatic char tc_strbuf[768];     /* absolutely blunderous overkill */
  1308. X#endif
  1309. Xstatic int tc_standout_width;
  1310. X
  1311. Xchar *tgetstr();
  1312. Xchar *tgoto();
  1313. Xchar *getenv();
  1314. X
  1315. Xvoid tcap_cursor();
  1316. Xvoid tcap_stand_out();
  1317. Xvoid tcap_stand_end();
  1318. X
  1319. X#ifdef LINUX
  1320. X#define TCAP_PUTC_TYPE int
  1321. XTCAP_PUTC_TYPE tcap_putc(int);
  1322. X
  1323. X#else
  1324. X#define TCAP_PUTC_TYPE void
  1325. XTCAP_PUTC_TYPE tcap_putc();
  1326. X
  1327. X#endif
  1328. X
  1329. X/*+-------------------------------------------------------------------------
  1330. X    tcap_init() - get termcap variables
  1331. X--------------------------------------------------------------------------*/
  1332. Xvoid
  1333. Xtcap_init()
  1334. X{
  1335. X#ifdef LINUX
  1336. X    int result;
  1337. X
  1338. X#else
  1339. X    char termbuf[1024];
  1340. X    char *cptr;
  1341. X
  1342. X#endif
  1343. X
  1344. X    if (!ttype || !*ttype)
  1345. X    {
  1346. X        ff(se, "invalid or missing TERM environment variable\r\n");
  1347. X        termecu(TERMECU_CURSES_ERROR);
  1348. X    }
  1349. X
  1350. X#ifdef LINUX
  1351. X    setupterm(ttype, 1, &result);
  1352. X    if (result == 1)
  1353. X    {
  1354. X        tcap_LINES = lines;
  1355. X        tcap_COLS = columns;
  1356. X        tc_standout_width = label_width;
  1357. X        tc_standout = enter_standout_mode;
  1358. X        tc_standend = exit_standout_mode;
  1359. X        tc_clear = clear_screen;
  1360. X        tc_curleft = cursor_left;
  1361. X        tc_curright = cursor_right;
  1362. X        tc_delchar = delete_character;
  1363. X        tc_delline = delete_line;
  1364. X        tc_eeod = clr_eos;
  1365. X        tc_eeol = clr_eol;
  1366. X        tc_inschar = insert_character;
  1367. X        tc_insline = insert_line;
  1368. X        tc_move = cursor_address;
  1369. X        tc_vbell = bell;
  1370. X        tc_underscore_on = enter_underline_mode;
  1371. X        tc_underscore_off = exit_underline_mode;
  1372. X        if (!tc_underscore_on || !tc_underscore_off)
  1373. X        {
  1374. X            tc_underscore_on = tc_standout;
  1375. X            tc_underscore_off = tc_standend;
  1376. X        }
  1377. X        tc_bold_on = enter_bold_mode;    /* for now */
  1378. X        tc_bold_off = exit_attribute_mode;    /* for now */
  1379. X        if (!tc_bold_on || !tc_bold_off)
  1380. X        {
  1381. X            tc_bold_on = tc_standout;
  1382. X            tc_bold_off = tc_standend;
  1383. X        }
  1384. X        tc_blink_on = enter_blink_mode;
  1385. X        tc_blink_off = exit_attribute_mode;
  1386. X        if (!tc_blink_on || !tc_blink_off)
  1387. X        {
  1388. X            tc_blink_on = tc_standout;
  1389. X            tc_blink_off = tc_standend;
  1390. X        }
  1391. X        if (!*tc_clear || !*tc_move)
  1392. X        {
  1393. X            ff(se, "Terminal type '%s' does not have the beef.\r\n",
  1394. X                ttype);
  1395. X            ff(se, "Try again with a screen-oriented terminal.\n");
  1396. X            termecu(TERMECU_CURSES_ERROR);
  1397. X        }
  1398. X        ff(se, enter_ca_mode);
  1399. X        return;
  1400. X    }
  1401. X#else
  1402. X    if (tgetent(termbuf, ttype) > 0)
  1403. X    {
  1404. X        tcap_LINES = tgetnum("li");
  1405. X        tcap_COLS = tgetnum("co");
  1406. X        if (cptr = getenv("LINES"))    /* environment override ... */
  1407. X            tcap_LINES = atoi(cptr);    /* ... for termcap systems */
  1408. X        if (cptr = getenv("COLUMNS"))
  1409. X            tcap_COLS = atoi(cptr);
  1410. X        if ((tc_standout_width = tgetnum("sg")) < 0)
  1411. X            tc_standout_width = 0;
  1412. X        cptr = tc_strbuf;
  1413. X        tc_standout = tgetstr("so", &cptr);
  1414. X        tc_standend = tgetstr("se", &cptr);
  1415. X        if (!tc_standout || !tc_standend)
  1416. X        {
  1417. X            tc_standout = "";
  1418. X            tc_standend = "";
  1419. X        }
  1420. X        tc_clear = tgetstr("cl", &cptr);
  1421. X        tc_curleft = tgetstr("kl", &cptr);
  1422. X        if (!tc_curleft)
  1423. X            tc_curleft = "\10";
  1424. X        tc_curright = tgetstr("kr", &cptr);
  1425. X        if (!tc_curright)
  1426. X            tc_curright = " ";
  1427. X        tc_delchar = tgetstr("dc", &cptr);
  1428. X        tc_delline = tgetstr("dl", &cptr);
  1429. X        tc_eeod = tgetstr("cd", &cptr);
  1430. X        tc_eeol = tgetstr("ce", &cptr);
  1431. X        tc_inschar = tgetstr("ic", &cptr);
  1432. X        tc_insline = tgetstr("al", &cptr);
  1433. X        tc_move = tgetstr("cm", &cptr);
  1434. X        tc_vbell = tgetstr("vb", &cptr);
  1435. X        if (!tc_vbell)
  1436. X            tc_vbell = "\7";
  1437. X        tc_underscore_on = tgetstr("us", &cptr);
  1438. X        tc_underscore_off = tgetstr("ue", &cptr);
  1439. X        if (!tc_underscore_on || !tc_underscore_off)
  1440. X        {
  1441. X            tc_underscore_on = tc_standout;
  1442. X            tc_underscore_off = tc_standend;
  1443. X        }
  1444. X        tc_bold_on = tc_standout;    /* for now */
  1445. X        tc_bold_off = tc_standend;    /* for now */
  1446. X        if (!tc_bold_on || !tc_bold_off)
  1447. X        {
  1448. X            tc_bold_on = tc_standout;
  1449. X            tc_bold_off = tc_standend;
  1450. X        }
  1451. X        tc_blink_on = tgetstr("mb", &cptr);    /* "XENIX extension" */
  1452. X        tc_blink_off = tgetstr("me", &cptr);    /* "XENIX extension" */
  1453. X        if (!tc_blink_on || !tc_blink_off)
  1454. X        {
  1455. X            tc_blink_on = tc_standout;
  1456. X            tc_blink_off = tc_standend;
  1457. X        }
  1458. X        if (!tc_clear || !tc_move)
  1459. X        {
  1460. X            ff(se, "Terminal type '%s' does not have the beef.\r\n",
  1461. X                ttype);
  1462. X            ff(se, "Try again with a screen-oriented terminal.\r\n");
  1463. X            termecu(TERMECU_CURSES_ERROR);
  1464. X        }
  1465. X        if (!tc_standout || !tc_standend || !*tc_standout || !*tc_standend)
  1466. X        {
  1467. X            ff(se, "Terminal type '%s' does not have standout.\r\n",
  1468. X                ttype);
  1469. X            ff(se, "We will continue, but this may be confusing.\7\r\n");
  1470. X            Nap(2000L);
  1471. X        }
  1472. X        return;
  1473. X    }
  1474. X#endif
  1475. X
  1476. X    ff(se, "Cannot find terminal type '%s' or entry in error\r\n",
  1477. X        ttype);
  1478. X    termecu(TERMECU_CURSES_ERROR);
  1479. X
  1480. X}                             /* end of tcap_init */
  1481. X
  1482. X/*+-------------------------------------------------------------------------
  1483. X    tcap_putc(character) - utility routine for tputs
  1484. X--------------------------------------------------------------------------*/
  1485. XTCAP_PUTC_TYPE
  1486. Xtcap_putc(character)
  1487. Xint character;
  1488. X{
  1489. X    char ch = character;
  1490. X
  1491. X    rcvrdisp(&ch, 1);
  1492. X#ifdef LINUX
  1493. X    return (0);
  1494. X#endif
  1495. X}                             /* end of tcap_putc */
  1496. X
  1497. X/*+-------------------------------------------------------------------------
  1498. X    tcap_horiz_rule(count) - horizontal rule starting at current position
  1499. X--------------------------------------------------------------------------*/
  1500. Xvoid
  1501. Xtcap_horiz_rule(count)
  1502. Xregister count;
  1503. X{
  1504. X    while (count--)
  1505. X        tcap_putc(sHR);
  1506. X    rcvrdisp_actual2();
  1507. X}                             /* end of tcap_horiz_rule */
  1508. X
  1509. X/*+-------------------------------------------------------------------------
  1510. X    tcap_vertical_rule(y,x,count) - vertical rule starting at y,x
  1511. X--------------------------------------------------------------------------*/
  1512. Xvoid
  1513. Xtcap_vertical_rule(y, x, count)
  1514. Xint y;
  1515. Xregister x;
  1516. Xregister count;
  1517. X{
  1518. X
  1519. X    while (count--)
  1520. X    {
  1521. X        tcap_cursor(y++, x);
  1522. X        tcap_putc(sVR);
  1523. X    }
  1524. X    rcvrdisp_actual2();
  1525. X
  1526. X}                             /* end of tcap_vertical_rule */
  1527. X
  1528. X/*+-------------------------------------------------------------------------
  1529. X    tcap_draw_box_primitive(y,x,height,width) - ruled box
  1530. X--------------------------------------------------------------------------*/
  1531. Xvoid
  1532. Xtcap_draw_box_primitive(y, x, height, width)
  1533. Xregister y;
  1534. Xint x;
  1535. Xint height;
  1536. Xint width;
  1537. X{
  1538. X    register i;
  1539. X
  1540. X    tcap_cursor(y, x);
  1541. X    tcap_putc(sTL);
  1542. X    if ((i = width - 2) > 0)
  1543. X        tcap_horiz_rule(i);
  1544. X    tcap_putc(sTR);
  1545. X    if ((i = height - 2) > 0)
  1546. X    {
  1547. X        tcap_vertical_rule(y + 1, x + width - 1, i);
  1548. X        tcap_vertical_rule(y + 1, x, i);
  1549. X    }
  1550. X    tcap_cursor(y + height - 1, x);
  1551. X    tcap_putc(sBL);
  1552. X    if ((i = width - 2) > 0)
  1553. X        tcap_horiz_rule(i);
  1554. X    tcap_putc(sBR);
  1555. X    rcvrdisp_actual2();
  1556. X
  1557. X}                             /* end of tcap_draw_box_primitive */
  1558. X
  1559. X/*+-------------------------------------------------------------------------
  1560. X    tcap_draw_box(y,x,height,width,title,title_x)
  1561. X--------------------------------------------------------------------------*/
  1562. Xvoid
  1563. Xtcap_draw_box(y, x, height, width, title, title_x)
  1564. Xint y;
  1565. Xint x;
  1566. Xint height;
  1567. Xint width;
  1568. Xchar *title;
  1569. Xint title_x;
  1570. X{
  1571. X    register stand = (title_x < 0);
  1572. X
  1573. X    if (stand)
  1574. X        title_x = -title_x;
  1575. X
  1576. X    tcap_draw_box_primitive(y, x, height, width);
  1577. X    tcap_cursor(y, x + title_x);
  1578. X    tcap_putc('[');
  1579. X    if (stand)
  1580. X        tcap_stand_out();
  1581. X    ff(se, " %s ", title);
  1582. X    if (stand)
  1583. X        tcap_stand_end();
  1584. X    tcap_putc(']');
  1585. X    rcvrdisp_actual2();
  1586. X
  1587. X}                             /* end of tcap_draw_box */
  1588. X
  1589. X/*+-------------------------------------------------------------------------
  1590. X    tcap_cursor(y,x)
  1591. X--------------------------------------------------------------------------*/
  1592. Xvoid
  1593. Xtcap_cursor(y, x)
  1594. Xuint y;
  1595. Xuint x;
  1596. X{
  1597. X    if (y >= tcap_LINES)
  1598. X        y = tcap_LINES - 1;
  1599. X    if (x >= tcap_COLS)
  1600. X        x = tcap_COLS - 1;
  1601. X    tputs(tgoto(tc_move, x, y), 1, tcap_putc);
  1602. X    rcvrdisp_actual2();
  1603. X
  1604. X}                             /* end of tcap_cursor */
  1605. X
  1606. X/*+-------------------------------------------------------------------------
  1607. X    tcap_curleft(count) - move cursor left
  1608. X--------------------------------------------------------------------------*/
  1609. Xvoid
  1610. Xtcap_curleft(count)
  1611. Xregister count;
  1612. X{
  1613. X    while (count--)
  1614. X        tputs(tc_curleft, 1, tcap_putc);
  1615. X    rcvrdisp_actual2();
  1616. X}                             /* end of tcap_curleft */
  1617. X
  1618. X/*+-------------------------------------------------------------------------
  1619. X    tcap_curright(count) - move cursor right
  1620. X--------------------------------------------------------------------------*/
  1621. Xvoid
  1622. Xtcap_curright(count)
  1623. Xregister count;
  1624. X{
  1625. X    while (count--)
  1626. X        tputs(tc_curright, 1, tcap_putc);
  1627. X    rcvrdisp_actual2();
  1628. X}                             /* end of tcap_curright */
  1629. X
  1630. X/*+-------------------------------------------------------------------------
  1631. X    tcap_curbotleft()
  1632. X--------------------------------------------------------------------------*/
  1633. Xvoid
  1634. Xtcap_curbotleft()
  1635. X{
  1636. X    tcap_cursor(tcap_LINES - 1, 0);
  1637. X}                             /* end of tcap_curbotleft */
  1638. X
  1639. X/*+-------------------------------------------------------------------------
  1640. X    tcap_insert_lines(count)
  1641. X--------------------------------------------------------------------------*/
  1642. Xvoid
  1643. Xtcap_insert_lines(count)
  1644. Xregister count;
  1645. X{
  1646. X    if (count && *tc_insline)
  1647. X    {
  1648. X        while (count--)
  1649. X            tputs(tc_insline, 1, tcap_putc);
  1650. X        rcvrdisp_actual2();
  1651. X    }
  1652. X}                             /* end of tcap_insert_lines */
  1653. X
  1654. X/*+-------------------------------------------------------------------------
  1655. X    tcap_delete_lines(count)
  1656. X--------------------------------------------------------------------------*/
  1657. Xvoid
  1658. Xtcap_delete_lines(count)
  1659. Xregister count;
  1660. X{
  1661. X    if (count && *tc_delline)
  1662. X    {
  1663. X        while (count--)
  1664. X            tputs(tc_delline, 1, tcap_putc);
  1665. X        rcvrdisp_actual2();
  1666. X    }
  1667. X}                             /* end of tcap_delete_lines */
  1668. X
  1669. X/*+-------------------------------------------------------------------------
  1670. X    tcap_insert_chars(count)
  1671. X--------------------------------------------------------------------------*/
  1672. Xvoid
  1673. Xtcap_insert_chars(count)
  1674. Xregister count;
  1675. X{
  1676. X    if (count && *tc_inschar)
  1677. X    {
  1678. X        while (count--)
  1679. X            tputs(tc_inschar, 1, tcap_putc);
  1680. X        rcvrdisp_actual2();
  1681. X    }
  1682. X}                             /* end of tcap_insert_chars */
  1683. X
  1684. X/*+-------------------------------------------------------------------------
  1685. X    tcap_delete_chars(count)
  1686. X--------------------------------------------------------------------------*/
  1687. Xvoid
  1688. Xtcap_delete_chars(count)
  1689. Xregister count;
  1690. X{
  1691. X    if (count && *tc_delchar)
  1692. X    {
  1693. X        while (count--)
  1694. X            tputs(tc_delchar, 1, tcap_putc);
  1695. X        rcvrdisp_actual2();
  1696. X    }
  1697. X}                             /* end of tcap_delete_chars */
  1698. X
  1699. X/*+-------------------------------------------------------------------------
  1700. X    tcap_vbell() - output visual bell
  1701. X--------------------------------------------------------------------------*/
  1702. Xvoid
  1703. Xtcap_vbell()
  1704. X{
  1705. X    if (*tc_vbell)
  1706. X    {
  1707. X        tputs(tc_vbell, 1, tcap_putc);
  1708. X        rcvrdisp_actual2();
  1709. X    }
  1710. X}                             /* end of tcap_vbell */
  1711. X
  1712. X/*+-------------------------------------------------------------------------
  1713. X    tcap_clear_screen()
  1714. X--------------------------------------------------------------------------*/
  1715. Xvoid
  1716. Xtcap_clear_screen()
  1717. X{
  1718. X    if (*tc_clear)
  1719. X    {
  1720. X        tputs(tc_clear, 1, tcap_putc);
  1721. X        rcvrdisp_actual2();
  1722. X    }
  1723. X}                             /* end of tcap_clear_screen */
  1724. X
  1725. X/*+-------------------------------------------------------------------------
  1726. X    tcap_eeol() - erase to end of line
  1727. X--------------------------------------------------------------------------*/
  1728. Xvoid
  1729. Xtcap_eeol()
  1730. X{
  1731. X    if (*tc_eeol)
  1732. X    {
  1733. X        tputs(tc_eeol, 1, tcap_putc);
  1734. X        rcvrdisp_actual2();
  1735. X    }
  1736. X}                             /* end of tcap_eeol */
  1737. X
  1738. X/*+-------------------------------------------------------------------------
  1739. X    tcap_eeod() - erase to end of display
  1740. X--------------------------------------------------------------------------*/
  1741. Xvoid
  1742. Xtcap_eeod()
  1743. X{
  1744. X    if (*tc_eeod)
  1745. X    {
  1746. X        tputs(tc_eeod, 1, tcap_putc);
  1747. X        rcvrdisp_actual2();
  1748. X    }
  1749. X}                             /* end of tcap_eeod */
  1750. X
  1751. X/*+-------------------------------------------------------------------------
  1752. X    tcap_stand_out()
  1753. X--------------------------------------------------------------------------*/
  1754. Xvoid
  1755. Xtcap_stand_out()
  1756. X{
  1757. X    if (*tc_standout)         /* && (tc_standout_width == 0)) */
  1758. X    {
  1759. X        tputs(tc_standout, 1, tcap_putc);
  1760. X        rcvrdisp_actual2();
  1761. X    }
  1762. X}                             /* end of tcap_stand_out */
  1763. X
  1764. X/*+-------------------------------------------------------------------------
  1765. X    tcap_stand_end()
  1766. X--------------------------------------------------------------------------*/
  1767. Xvoid
  1768. Xtcap_stand_end()
  1769. X{
  1770. X    if (*tc_standend)         /* && (tc_standout_width == 0)) */
  1771. X    {
  1772. X        tputs(tc_standend, 1, tcap_putc);
  1773. X        rcvrdisp_actual2();
  1774. X    }
  1775. X}                             /* end of tcap_stand_end */
  1776. X
  1777. X/*+-------------------------------------------------------------------------
  1778. X    tcap_bold_on()
  1779. X--------------------------------------------------------------------------*/
  1780. Xvoid
  1781. Xtcap_bold_on()
  1782. X{
  1783. X    if (*tc_bold_on)
  1784. X        tputs(tc_bold_on, 1, tcap_putc);
  1785. X    else if (*tc_standout)     /* && (tc_standout_width == 0)) */
  1786. X        tputs(tc_standout, 1, tcap_putc);
  1787. X    rcvrdisp_actual2();
  1788. X}                             /* end of tcap_bold_on */
  1789. X
  1790. X/*+-------------------------------------------------------------------------
  1791. X    tcap_bold_off()
  1792. X--------------------------------------------------------------------------*/
  1793. Xvoid
  1794. Xtcap_bold_off()
  1795. X{
  1796. X    if (*tc_bold_off)
  1797. X        tputs(tc_bold_off, 1, tcap_putc);
  1798. X    else if (*tc_standend)     /* && (tc_standout_width == 0)) */
  1799. X        tputs(tc_standend, 1, tcap_putc);
  1800. X    rcvrdisp_actual2();
  1801. X}                             /* end of tcap_bold_off */
  1802. X
  1803. X/*+-------------------------------------------------------------------------
  1804. X    tcap_underscore_on()
  1805. X--------------------------------------------------------------------------*/
  1806. Xvoid
  1807. Xtcap_underscore_on()
  1808. X{
  1809. X    if (*tc_underscore_on)
  1810. X        tputs(tc_underscore_on, 1, tcap_putc);
  1811. X    else if (*tc_standout)     /* && (tc_standout_width == 0)) */
  1812. X        tputs(tc_standout, 1, tcap_putc);
  1813. X    rcvrdisp_actual2();
  1814. X}                             /* end of tcap_underscore_on */
  1815. X
  1816. X/*+-------------------------------------------------------------------------
  1817. X    tcap_underscore_off()
  1818. X--------------------------------------------------------------------------*/
  1819. Xvoid
  1820. Xtcap_underscore_off()
  1821. X{
  1822. X    if (*tc_underscore_off)
  1823. X        tputs(tc_underscore_off, 1, tcap_putc);
  1824. X    else if (*tc_standend)     /* && (tc_standout_width == 0)) */
  1825. X        tputs(tc_standend, 1, tcap_putc);
  1826. X    rcvrdisp_actual2();
  1827. X}                             /* end of tcap_underscore_off */
  1828. X
  1829. X/*+-------------------------------------------------------------------------
  1830. X    tcap_blink_on()
  1831. X--------------------------------------------------------------------------*/
  1832. Xvoid
  1833. Xtcap_blink_on()
  1834. X{
  1835. X    if (*tc_blink_on)
  1836. X        tputs(tc_blink_on, 1, tcap_putc);
  1837. X    else if (*tc_standout)     /* && (tc_standout_width == 0)) */
  1838. X        tputs(tc_standout, 1, tcap_putc);
  1839. X    rcvrdisp_actual2();
  1840. X}                             /* end of tcap_blink_on */
  1841. X
  1842. X/*+-------------------------------------------------------------------------
  1843. X    tcap_blink_off()
  1844. X--------------------------------------------------------------------------*/
  1845. Xvoid
  1846. Xtcap_blink_off()
  1847. X{
  1848. X    if (*tc_blink_off)
  1849. X        tputs(tc_blink_off, 1, tcap_putc);
  1850. X    else if (*tc_standend)     /* && (tc_standout_width == 0)) */
  1851. X        tputs(tc_standend, 1, tcap_putc);
  1852. X    rcvrdisp_actual2();
  1853. X}                             /* end of tcap_blink_off */
  1854. X
  1855. X/*+-------------------------------------------------------------------------
  1856. X    tcap_clear_area_char(count,clrch)
  1857. X--------------------------------------------------------------------------*/
  1858. Xvoid
  1859. Xtcap_clear_area_char(count, clrch)
  1860. Xregister count;
  1861. Xregister clrch;
  1862. X{
  1863. X    register itmp = count;
  1864. X
  1865. X    while (itmp--)
  1866. X        tcap_putc(clrch);
  1867. X    itmp = count;
  1868. X    while (itmp--)
  1869. X        tputs(tc_curleft, 1, tcap_putc);
  1870. X    rcvrdisp_actual2();
  1871. X
  1872. X}                             /* end of tcap_clear_area_char */
  1873. X
  1874. X/* end of ecutcap.c */
  1875. X/* vi: set tabstop=4 shiftwidth=4: */
  1876. END_OF_FILE
  1877.   if test 17512 -ne `wc -c <'ecu330/ecutcap.c'`; then
  1878.     echo shar: \"'ecu330/ecutcap.c'\" unpacked with wrong size!
  1879.   fi
  1880.   # end of 'ecu330/ecutcap.c'
  1881. fi
  1882. if test -f 'ecu330/kbdtest3.c' -a "${1}" != "-c" ; then 
  1883.   echo shar: Will not clobber existing file \"'ecu330/kbdtest3.c'\"
  1884. else
  1885.   echo shar: Extracting \"'ecu330/kbdtest3.c'\" \(15519 characters\)
  1886.   sed "s/^X//" >'ecu330/kbdtest3.c' <<'END_OF_FILE'
  1887. X/* CHK=0x2F4F */
  1888. Xchar *revision = "3.30";
  1889. X
  1890. X/*+-----------------------------------------------------------------------
  1891. X    kbdtest3.c -- test keyboard values
  1892. X    wht@n4hgf.atl.ga.us
  1893. X
  1894. X  See ecu manual section titled Function Key Recognition
  1895. X
  1896. X  Defined functions:
  1897. X    dump_putc(ch)
  1898. X    dump_puts(str)
  1899. X    hex_dump16(int16)
  1900. X    hex_dump32(int32)
  1901. X    hex_dump4(int4)
  1902. X    hex_dump8(int8)
  1903. X    hex_dump_fp(fp,str,len,title,terse_flag)
  1904. X    k3ttymode(arg)
  1905. X    main(argc,argv)
  1906. X    read_kbd_string(buf,max)
  1907. X    termio_parity_text(cflag)
  1908. X    tputstrs(strs)
  1909. X    write_funckeymap_desc(fp,buf,buflen,name)
  1910. X    xtoasc(ch,incl_3char)
  1911. X
  1912. X------------------------------------------------------------------------*/
  1913. X/*+:EDITS:*/
  1914. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1915. X/*:01-11-1994-15:37-wht@n4hgf-remove explicit paths from stty and sed */
  1916. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1917. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  1918. X/*:04-19-1992-20:59-wht@n4hgf-nonansikeys to funckeymap */
  1919. X/*:02-22-1992-12:46-root@n4hgf-thank markd@phoenix.pub.uu.oz.au for typo fix */
  1920. X/*:01-06-1992-17:56-wht@tridom-much more error checking */
  1921. X/*:01-06-1992-17:56-wht@tridom-eliminate sun stty - causes problems */
  1922. X/*:08-28-1991-14:07-wht@n4hgf2-SVR4 cleanup by aega84!lh */
  1923. X/*:08-17-1991-13:58-root@n4hgf-make kbd entirely raw */
  1924. X/*:08-06-1991-13:12-wht@n4hgf-add parity reporting */
  1925. X/*:08-06-1991-13:12-wht@n4hgf-some terminals reinvent parity bit's use */
  1926. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1927. X/*:04-29-1991-18:24-wht@n4hgf-let us see what keyboards say */
  1928. X
  1929. X#include <stdio.h>
  1930. X#include <signal.h>
  1931. X#include <ctype.h>
  1932. X#include <sys/errno.h>
  1933. X#include <string.h>
  1934. X#include "ecu_config.h"
  1935. X#include "ecu_types.h"
  1936. X#include "ecu_stat.h"
  1937. X#include "ecutermio.h"
  1938. X
  1939. Xchar *ctime();
  1940. Xchar *getenv();
  1941. X
  1942. X#define VMIN_VALUE  32
  1943. X#define VTIME_VALUE 2
  1944. X
  1945. X#define TTYIN   0             /* mnemonic */
  1946. X#define TTYOUT  1             /* mnemonic */
  1947. X#define TTYERR  2             /* mnemonic */
  1948. X
  1949. Xstruct termio lv;             /* attributes for the line to remote */
  1950. Xstruct termio tv0;             /* for saving, changing TTY atributes */
  1951. Xstruct termio tv;             /* for saving, changing TTY atributes */
  1952. X
  1953. Xchar *strs_intro[] =
  1954. X{
  1955. X    "\n",
  1956. X    "Let's learn your keyboard.  I'll be making a file named kbdtest3.out\n",
  1957. X    "For each of the key names shown below, please press the key and wait.\n",
  1958. X    "\n",
  1959. X    "If you do not have a key on your keyboard, make an alternate choice\n",
  1960. X    "or press the space bar if nothing seems reasonable.\n",
  1961. X    "\n",
  1962. X    "If you press a key but don't see further activity after a second or two\n",
  1963. X    "press the slash '/' key unless you can choose a reasonable alternate.\n",
  1964. X    "Keys which produce duplicate the keystroke sequence of other keys are\n",
  1965. X    "not acceptable.\n",
  1966. X    "\n",
  1967. X    "Do not use the same key for more than one function.\n",
  1968. X    "\n",
  1969. X    (char *)0
  1970. X};
  1971. X
  1972. Xchar *strs_thanks[] =
  1973. X{
  1974. X    "\n",
  1975. X    "Thank you.  If you wish to mail me the contents of kbdtest3.out,\n",
  1976. X    "please include  a detailed description of the system and software\n",
  1977. X    "(i.e., \"Metrolink xterm keyboard on SCO 3.2r2\")\n",
  1978. X    "(I WANT you to mail me results for non-SCO/non-ISC-console keyboards.)\n",
  1979. X    "If you had to hack this program, mail it in its entirety as well.\n",
  1980. X    "\n",
  1981. X    "My address: wht@n4hgf.atl.ga.us or emory!n4hgf!wht\n",
  1982. X    (char *)0
  1983. X};
  1984. X
  1985. Xchar *strs_bktab[] =
  1986. X{
  1987. X    "You'll have to pick another function key (like F11?).  If you are\n",
  1988. X    "using an xterm here perhaps a <Shift>Tab VT100 override will help.\n",
  1989. X    (char *)0
  1990. X};
  1991. X
  1992. Xstruct keystruc
  1993. X{
  1994. X    char *ecuname;
  1995. X    char *peoplename;
  1996. X    int count;
  1997. X    unsigned char str[VMIN_VALUE + 1];
  1998. X};
  1999. X
  2000. Xstruct keystruc need_names[] =
  2001. X{
  2002. X    {"BkTab", "Back Tab (Shift Tab)"},    /* 0 */
  2003. X    {"CU5", "Unshifted Keypad 5"},    /* 1 */
  2004. X    {"F1", "F1"},             /* 2 */
  2005. X    {"F2", "F2"},             /* 3 */
  2006. X    {"F3", "F3"},             /* 4 */
  2007. X    {"F4", "F4"},             /* 5 */
  2008. X    {"F5", "F5"},             /* 6 */
  2009. X    {"F6", "F6"},             /* 7 */
  2010. X    {"F7", "F7"},             /* 8 */
  2011. X    {"F8", "F8"},             /* 9 */
  2012. X    {"F9", "F9"},             /* 10 */
  2013. X    {"F10", "F10"},             /* 11 */
  2014. X    {"F11", "F11"},             /* 12 */
  2015. X    {"F12", "F12"},             /* 13 */
  2016. X    {"Ins", "Ins"},             /* 14 */
  2017. X#define I_HOME    15
  2018. X    {"Home", "Home"},         /* 15 */
  2019. X#define I_END    16
  2020. X    {"End", "End"},             /* 16 */
  2021. X    {"PgUp", "PgUp"},         /* 17 */
  2022. X    {"PgDn", "PgDn"},         /* 18 */
  2023. X    {"CUU", "Cursor Up"},     /* 19 */
  2024. X    {"CUD", "Cursor Down"},     /* 21 */
  2025. X    {"CUL", "Cursor Left"},     /* 22 */
  2026. X    {"CUR", "Cursor Right"}, /* 23 */
  2027. X    {(char *)0, (char *)0}
  2028. X};
  2029. X
  2030. Xchar *parity_text = "<undetermined>";
  2031. Xstatic FILE *dumpfp;
  2032. X
  2033. X/*+-------------------------------------------------------------------------
  2034. X    dump_putc(ch)
  2035. X--------------------------------------------------------------------------*/
  2036. Xvoid
  2037. Xdump_putc(ch)
  2038. Xchar ch;
  2039. X{
  2040. X    fputc(ch, dumpfp);
  2041. X}                             /* end of dump_putc */
  2042. X
  2043. X/*+-------------------------------------------------------------------------
  2044. X    dump_puts(str)
  2045. X--------------------------------------------------------------------------*/
  2046. Xvoid
  2047. Xdump_puts(str)
  2048. Xchar *str;
  2049. X{
  2050. X    fputs(str, dumpfp);
  2051. X}                             /* end of dump_puts */
  2052. X
  2053. X/*+-----------------------------------------------------------------------
  2054. X    hex_dump#... subservient routines
  2055. X------------------------------------------------------------------------*/
  2056. Xvoid
  2057. Xhex_dump4(int4)
  2058. Xunsigned char int4;
  2059. X{
  2060. X    int4 &= 15;
  2061. X    dump_putc((int4 >= 10) ? (int4 + 'A' - 10) : (int4 + '0'));
  2062. X}
  2063. X
  2064. Xvoid
  2065. Xhex_dump8(int8)
  2066. Xunsigned char int8;
  2067. X{
  2068. X    hex_dump4(int8 >> 4);
  2069. X    hex_dump4(int8);
  2070. X}
  2071. X
  2072. Xvoid
  2073. Xhex_dump16(int16)
  2074. Xunsigned short int16;
  2075. X{
  2076. X    hex_dump8(int16 >> 8);
  2077. X    hex_dump8(int16);
  2078. X}
  2079. X
  2080. Xvoid
  2081. Xhex_dump32(int32)
  2082. Xunsigned long int32;
  2083. X{
  2084. X    hex_dump16(int32 >> 16);
  2085. X    hex_dump16(int32);
  2086. X}
  2087. X
  2088. X/*+-----------------------------------------------------------------
  2089. X    hex_dump_fp(fp,str,len,title,terse_flag)
  2090. X
  2091. X  if 'title' not NULL, title is printed... 'terse_flag'
  2092. X  controls whether or not the title is "conspicuous" with
  2093. X  hyphens before and after it making title line >70 chars long
  2094. X------------------------------------------------------------------*/
  2095. Xvoid
  2096. Xhex_dump_fp(fp, str, len, title, terse_flag)
  2097. XFILE *fp;
  2098. Xchar *str;
  2099. Xint len;
  2100. Xchar *title;
  2101. Xint terse_flag;
  2102. X{
  2103. X    int istr;
  2104. X    register ipos = 0;
  2105. X    register itmp;
  2106. X
  2107. X    dumpfp = fp;
  2108. X
  2109. X    if (title && (istr = strlen(title)))
  2110. X    {
  2111. X        if (!terse_flag)
  2112. X        {
  2113. X            ipos = (73 - istr) / 2;
  2114. X            itmp = ipos;
  2115. X            while (itmp--)
  2116. X                dump_putc('-');
  2117. X            dump_putc(' ');
  2118. X            if (istr & 1)
  2119. X                ipos--;
  2120. X        }
  2121. X        dump_puts(title);
  2122. X        if (!terse_flag)
  2123. X        {
  2124. X            dump_putc(' ');
  2125. X            while (ipos--)
  2126. X                dump_putc('-');
  2127. X        }
  2128. X        dump_puts("\n");
  2129. X
  2130. X    }
  2131. X
  2132. X    istr = 0;
  2133. X    while (istr < len)
  2134. X    {
  2135. X        hex_dump16(istr);
  2136. X        dump_putc(' ');
  2137. X        for (itmp = 0; itmp < 16; ++itmp)
  2138. X        {
  2139. X            ipos = istr + itmp;
  2140. X            if (ipos >= len)
  2141. X            {
  2142. X                if (!terse_flag)
  2143. X                    dump_puts("   ");
  2144. X                continue;
  2145. X            }
  2146. X            dump_putc(' ');
  2147. X            hex_dump8(str[ipos]);
  2148. X        }
  2149. X        dump_puts(" | ");
  2150. X        for (itmp = 0; itmp < 16; ++itmp)
  2151. X        {
  2152. X            ipos = istr + itmp;
  2153. X            if ((ipos) >= len)
  2154. X            {
  2155. X                if (!terse_flag)
  2156. X                    dump_putc(' ');
  2157. X            }
  2158. X            else
  2159. X            {
  2160. X                dump_putc((str[ipos] >= ' ' && str[ipos] < 0x7f)
  2161. X                    ? str[ipos] : '.');
  2162. X            }
  2163. X        }
  2164. X        if (dumpfp == stdout)
  2165. X            dump_puts(" |\r\n");
  2166. X        else
  2167. X            dump_puts(" |\n");
  2168. X        istr += 16;
  2169. X    }                         /* end of while(istr < len) */
  2170. X
  2171. X}                             /* end of hex_dump_fp */
  2172. X
  2173. X/*+-----------------------------------------------------------------------
  2174. X    xtoasc(character) - Make all chars "printable"
  2175. X
  2176. X  returns pointer to a static string containing printable version
  2177. X  of a character.  If control char, printed as "^A", etc.
  2178. X  if incl_3char set true, then space + ASCII assignment (e.g. "NUL") is
  2179. X  appended to the string for non-printable graphics
  2180. X------------------------------------------------------------------------*/
  2181. Xchar *
  2182. Xxtoasc(ch, incl_3char)
  2183. Xregister unsigned char ch;
  2184. Xint incl_3char;
  2185. X{
  2186. X    static char gg[8];
  2187. X    char *ascii_ctlstr =
  2188. X    "nulsohstxetxeotenqackbelbs ht nl vt ff cr so si dledc1dc2dc3dc4naksynetbcanem subescfs gs rs us sp ";
  2189. X
  2190. X    if (ch == 0x7F)
  2191. X        strcpy(gg, "del");
  2192. X    else if (ch == 0x9b)
  2193. X        strcpy(gg, "csi");
  2194. X    else if (ch > 0x7F)
  2195. X        sprintf(gg, "0x%02x", (unsigned char)ch);
  2196. X    else if (ch > 0x20)
  2197. X    {
  2198. X        gg[0] = ch;
  2199. X        gg[1] = 0;
  2200. X    }
  2201. X    else
  2202. X    {
  2203. X        strncpy(gg, ascii_ctlstr + (ch * 3), 3);
  2204. X        gg[3] = 0;
  2205. X    }
  2206. X    return (gg);
  2207. X}                             /* end of xtoasc */
  2208. X
  2209. X/*+-------------------------------------------------------------------------
  2210. X    write_funckeymap_desc(fp,buf,buflen,name)
  2211. X--------------------------------------------------------------------------*/
  2212. Xvoid
  2213. Xwrite_funckeymap_desc(fp, buf, buflen, name)
  2214. XFILE *fp;
  2215. Xunsigned char *buf;
  2216. Xint buflen;
  2217. Xchar *name;
  2218. X{
  2219. X    char s256[256];
  2220. X
  2221. X    sprintf(s256, "    %s:%s:", name, name);
  2222. X    while (strlen(s256) < (unsigned)20)
  2223. X        strcat(s256, " ");
  2224. X
  2225. X    while (buflen--)
  2226. X    {
  2227. X        strcat(s256, xtoasc(*buf++));
  2228. X        if (buflen)
  2229. X            strcat(s256, " ");
  2230. X    }
  2231. X    strcat(s256, "\n");
  2232. X
  2233. X    fputs(s256, fp);
  2234. X
  2235. X}                             /* end of write_funckeymap_desc */
  2236. X
  2237. X/*+-------------------------------------------------------------------------
  2238. X    tputstrs(strs)
  2239. X--------------------------------------------------------------------------*/
  2240. Xvoid
  2241. Xtputstrs(strs)
  2242. Xchar **strs;
  2243. X{
  2244. X    while (*strs)
  2245. X        fputs(*strs++, stdout);
  2246. X}                             /* end of tputstrs */
  2247. X
  2248. X/*+-----------------------------------------------------------------------
  2249. X    k3ttymode(arg) -- control user console (kbd/screen)
  2250. X
  2251. X  Where arg ==
  2252. X    0 restore attributes saved at start of execution
  2253. X    1 raw mode
  2254. X
  2255. X------------------------------------------------------------------------*/
  2256. Xvoid
  2257. Xk3ttymode(arg)
  2258. Xint arg;
  2259. X{
  2260. X    if (arg)
  2261. X    {
  2262. X        (void)ecugetattr(TTYIN, &tv);
  2263. X        tv.c_cflag &= ~(CS8 | PARENB | PARODD);
  2264. X        tv.c_cflag |= CS8;
  2265. X        tv.c_iflag &= ~(INLCR | ICRNL | IGNCR | IXOFF | ISTRIP);
  2266. X#if defined(IUCLC)
  2267. X        tv.c_iflag &= ~IUCLC;
  2268. X#endif
  2269. X        tv.c_lflag &= ~(ICANON | ISIG | ECHO);
  2270. X        tv.c_cc[VEOF] = '\01';
  2271. X        tv.c_cc[VEOL] = '\0';
  2272. X        tv.c_cc[VMIN] = VMIN_VALUE;
  2273. X        tv.c_cc[VTIME] = VTIME_VALUE;
  2274. X        (void)ecusetattr(TTYIN, TCSETAW, &tv);
  2275. X    }
  2276. X    else
  2277. X        (void)ecusetattr(TTYIN, TCSETAW, &tv0);
  2278. X}
  2279. X
  2280. X/*+-------------------------------------------------------------------------
  2281. X    read_kbd_string(buf,max)
  2282. X--------------------------------------------------------------------------*/
  2283. Xint
  2284. Xread_kbd_string(buf, maxsize)
  2285. Xunsigned char *buf;
  2286. Xint maxsize;
  2287. X{
  2288. X    int count = read(TTYIN, buf, maxsize);
  2289. X
  2290. X#if 0
  2291. X    int itmp;
  2292. X
  2293. X    for (itmp = 0; itmp < count; itmp++)
  2294. X        buf[itmp] &= 0x7F;
  2295. X#endif
  2296. X    return (count);
  2297. X
  2298. X}                             /* end of read_kbd_string */
  2299. X
  2300. X/*+-------------------------------------------------------------------------
  2301. X    termio_parity_text(cflag)
  2302. X--------------------------------------------------------------------------*/
  2303. Xchar *
  2304. Xtermio_parity_text(cflag)
  2305. Xunsigned short cflag;
  2306. X{
  2307. X    return ((cflag & PARENB) ? ((cflag & PARODD) ? "odd" : "even") : "none");
  2308. X}                             /* end of termio_parity_text */
  2309. X
  2310. X/*+-----------------------------------------------------------------------
  2311. X    main()
  2312. X------------------------------------------------------------------------*/
  2313. Xmain(argc, argv)
  2314. Xint argc;
  2315. Xchar **argv;
  2316. X{
  2317. X    int itmp;
  2318. X    int count;
  2319. X    int got_ctrl;
  2320. X    int found_dup;
  2321. X    int unusable = 0;
  2322. X    char ch;
  2323. X    char *ttype;
  2324. X    char *cptr;
  2325. X    struct keystruc *key = need_names;
  2326. X    struct keystruc *key2;
  2327. X    unsigned char instr[VMIN_VALUE + 1];
  2328. X
  2329. X#if !defined(sun)
  2330. X    char s128[128];
  2331. X
  2332. X#endif
  2333. X    FILE *fpout;
  2334. X    long now;
  2335. X    int errflg = 0;
  2336. X    char *outfile = "kbdtest3.out";
  2337. X
  2338. X/* extern char *optarg; */
  2339. X    extern int optind;
  2340. X
  2341. X    setbuf(stdout, NULL);
  2342. X    setbuf(stderr, NULL);
  2343. X
  2344. X    while ((itmp = getopt(argc, argv, "")) != -1)
  2345. X    {
  2346. X        switch (itmp)
  2347. X        {
  2348. X            case '?':
  2349. X                errflg++;
  2350. X        }
  2351. X    }
  2352. X
  2353. X    if (optind == (argc - 1))
  2354. X        outfile = argv[optind++];
  2355. X
  2356. X    if (errflg || (optind != argc))
  2357. X    {
  2358. X        (void)fprintf(stderr, "usage: %s [-hx] [outfile]\n");
  2359. X        exit(1);
  2360. X    }
  2361. X
  2362. X    printf("\n\n\necu kbdtest3 revision %s\n", revision);
  2363. X    tputstrs(strs_intro);
  2364. X    if (!(fpout = fopen(outfile, "a")))
  2365. X    {
  2366. X        perror(outfile);
  2367. X        exit(1);
  2368. X    }
  2369. X
  2370. X    ecugetattr(TTYIN, &tv0); /* get original status */
  2371. X    parity_text = termio_parity_text(tv0.c_cflag);
  2372. X
  2373. X    if (!(ttype = getenv("TERM")))
  2374. X        ttype = "??";
  2375. X    time(&now);
  2376. X    fprintf(fpout, "# funckeymap for '%s' under ", ttype);
  2377. X#if defined(M_SYSV)
  2378. X    fputs("SCO\n", fpout);
  2379. X#else
  2380. X#if defined(ISC)
  2381. X    fputs("ISC\n", fpout);
  2382. X#else
  2383. X#if defined(MOTSVR3)
  2384. X    fputs("MotSVR3\n", fpout);
  2385. X#else
  2386. X#if defined(sun)
  2387. X    fputs("SunOS\n", fpout);
  2388. X#else
  2389. X    fputs("??? OS\n", fpout);
  2390. X#endif /* sun */
  2391. X#endif /* MOTSVR3 */
  2392. X#endif /* ISC */
  2393. X#endif /* M_SYSV */
  2394. X
  2395. X    fprintf(fpout, "# built by kbdtest3 %s %s", revision, ctime(&now));
  2396. X    fprintf(fpout, "# keyboard parity required = %s\n", parity_text);
  2397. X#if !defined(sun)
  2398. X    fprintf(fpout, "# stty -a at kbdtest3 execution time:\n");
  2399. X    fclose(fpout);
  2400. X    strcpy(s128, "stty -a | sed -e 's/^/# /' >> ");
  2401. X    strcat(s128, outfile);
  2402. X    system(s128);
  2403. X    if (!(fpout = fopen(outfile, "a")))
  2404. X    {
  2405. X        perror(outfile);
  2406. X        exit(1);
  2407. X    }
  2408. X#endif
  2409. X    fprintf(fpout, "%s\n", ttype);
  2410. X
  2411. X    printf("Your keyboard driver parity is set to %s\n", parity_text);
  2412. X    printf("press ^D (0x04) to terminate program early\n\n");
  2413. X    k3ttymode(1);
  2414. X
  2415. X    while (key->ecuname)
  2416. X    {
  2417. X        key->count = -1;
  2418. X        printf("%-20.20s: ", key->peoplename);
  2419. X        count = read_kbd_string(instr, VMIN_VALUE);
  2420. X        if (!count)
  2421. X        {
  2422. X            printf("whoops ..... zero length read\n");
  2423. X            break;
  2424. X        }
  2425. X        if (!count)
  2426. X        {
  2427. X            perror("keyboard");
  2428. X            break;
  2429. X        }
  2430. X
  2431. X        if (!strcmp(key->ecuname, "BkTab") && (count == 1) &&
  2432. X            (instr[0] == 9))
  2433. X        {
  2434. X            printf("produced the same keystroke sequence as TAB\n");
  2435. X            tputstrs(strs_bktab);
  2436. X            continue;
  2437. X        }
  2438. X
  2439. X        if ((count == 1) && ((instr[0] & 0x7F) == 4))
  2440. X        {
  2441. X            printf("--abort--\n");
  2442. X            fputs("# User aborted entry.\n", fpout);
  2443. X            unusable = 2;
  2444. X            goto DONE;
  2445. X        }
  2446. X
  2447. X        if ((count == 1) && (instr[0] == '/'))
  2448. X        {
  2449. X            printf("--dead key--\n");
  2450. X            fprintf(fpout, "# %s: dead key and no reasonable alternate\n",
  2451. X                key->ecuname);
  2452. X        }
  2453. X        else if ((count == 1) && (instr[0] == ' '))
  2454. X        {
  2455. X            printf("--no key--\n");
  2456. X            fprintf(fpout, "# %s: no key and no reasonable alternate\n",
  2457. X                key->ecuname);
  2458. X        }
  2459. X        else
  2460. X        {
  2461. X            for (itmp = 0; itmp < count; itmp++)
  2462. X                printf("%02x ", instr[itmp]);
  2463. X            fputc(' ', stdout);
  2464. X            got_ctrl = 0;
  2465. X            for (itmp = 0; itmp < count; itmp++)
  2466. X            {
  2467. X                ch = instr[itmp] & 0x7F;
  2468. X                if ((ch < ' ') || (ch > '~'))
  2469. X                    ch = '.', got_ctrl = 1;
  2470. X                fputc(ch, stdout);
  2471. X            }
  2472. X            printf("\n");
  2473. X
  2474. X            key->count = count;
  2475. X            memcpy(key->str, instr, sizeof(key->str));
  2476. X            write_funckeymap_desc(fpout, (unsigned char *)instr, count,
  2477. X                key->ecuname);
  2478. X            if (!got_ctrl)
  2479. X            {
  2480. X                printf("This looks like a printable character string.\n");
  2481. X                printf("You might want to reconsider another key.\n");
  2482. X                fprintf(fpout, "# the above entry is suspect\n");
  2483. X            }
  2484. X        }
  2485. X
  2486. X        key++;
  2487. X    }
  2488. X    printf("\n");
  2489. X
  2490. X    /*
  2491. X     * check for dup sequences
  2492. X     */
  2493. X    found_dup = 0;
  2494. X    for (key = need_names, key2 = key + 1;; key2++)
  2495. X    {
  2496. X        if (!key2->ecuname)
  2497. X        {
  2498. X            key++;
  2499. X            if (!key->ecuname)
  2500. X                break;
  2501. X            key2 = key + 1;
  2502. X            if (!key2->ecuname)
  2503. X                break;
  2504. X        }
  2505. X        if ((key->count < 0) || (key2->count < 0) || (key->count != key2->count))
  2506. X            continue;
  2507. X        if (!memcmp(key->str, key2->str, key->count))
  2508. X        {
  2509. X            printf("'%s' and '%s' produced the same key sequence\n",
  2510. X                key->peoplename, key2->peoplename);
  2511. X            found_dup++;
  2512. X        }
  2513. X    }
  2514. X
  2515. X    if (found_dup)
  2516. X    {
  2517. X        fprintf(fpout,
  2518. X            "# found %d keystroke sequence duplication(s)\n", found_dup);
  2519. X        unusable = 1;
  2520. X    }
  2521. X
  2522. X    if (need_names[I_HOME].count < 0)
  2523. X    {
  2524. X        cptr = "# No Home key was successfully defined!\n";
  2525. X        printf(cptr + 2);
  2526. X        fprintf(fpout, cptr);
  2527. X        unusable = 1;
  2528. X    }
  2529. X    if (need_names[I_END].count < 0)
  2530. X    {
  2531. X        cptr = "# No End key was successfully defined!\n";
  2532. X        printf(cptr + 2);
  2533. X        fprintf(fpout, cptr);
  2534. X        unusable = 1;
  2535. X    }
  2536. X
  2537. X  DONE:
  2538. X    if (unusable)
  2539. X    {
  2540. X        printf("\nThis will be unusable.  Please try again.\n");
  2541. X        fprintf(fpout, "# above entry is unusable\n");
  2542. X    }
  2543. X    else
  2544. X    {
  2545. X        printf("\nRemember to set keyboard parity to \"%s\" ",
  2546. X            parity_text);
  2547. X        fputs("when using this entry.\n", stdout);
  2548. X        tputstrs(strs_thanks);
  2549. X    }
  2550. X
  2551. X    fputs("\n", fpout);
  2552. X    fclose(fpout);
  2553. X    k3ttymode(0);
  2554. X    exit(0);
  2555. X
  2556. X}                             /* end of main */
  2557. X/* vi: set tabstop=4 shiftwidth=4: */
  2558. END_OF_FILE
  2559.   if test 15519 -ne `wc -c <'ecu330/kbdtest3.c'`; then
  2560.     echo shar: \"'ecu330/kbdtest3.c'\" unpacked with wrong size!
  2561.   fi
  2562.   # end of 'ecu330/kbdtest3.c'
  2563. fi
  2564. echo shar: End of archive 24 \(of 37\).
  2565. cp /dev/null ark24isdone
  2566. MISSING=""
  2567. 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
  2568.     if test ! -f ark${I}isdone ; then
  2569.     MISSING="${MISSING} ${I}"
  2570.     fi
  2571. done
  2572. if test "${MISSING}" = "" ; then
  2573.     echo You have unpacked all 37 archives.
  2574.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2575. else
  2576.     echo You still must unpack the following archives:
  2577.     echo "        " ${MISSING}
  2578. fi
  2579. exit 0
  2580. exit 0 # Just in case...
  2581.