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

  1. From: wht@n4hgf.atl.ga.us (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v42i128:  ecu - ECU Asynchronous Communications v3.30, Part30/37
  4. Date: 25 May 1994 14:59:03 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2s0am7$9tt@sparky.sterling.com>
  9. X-Md4-Signature: f43479e522fa9438ee28e663771ce9e6
  10.  
  11. Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
  12. Posting-number: Volume 42, Issue 128
  13. Archive-name: ecu/part30
  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/doc/_p_sfunc.txt ecu330/ecu.h ecu330/ecushm.c
  22. #   ecu330/gendial/template.c ecu330/gint.c ecu330/help/helpgen.c
  23. # Wrapped by kent@sparky on Mon May 23 13:41:02 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 30 (of 37)."'
  27. if test -f 'ecu330/doc/_p_sfunc.txt' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'ecu330/doc/_p_sfunc.txt'\"
  29. else
  30.   echo shar: Extracting \"'ecu330/doc/_p_sfunc.txt'\" \(10113 characters\)
  31.   sed "s/^X//" >'ecu330/doc/_p_sfunc.txt' <<'END_OF_FILE'
  32. X.*s 1 "String Functions"
  33. X
  34. X.*s 2 "%argv"
  35. X
  36. Xusage: %argv(int0)
  37. X
  38. XThis function returns the string value of an argument passed
  39. Xto the procedure by the 'do' command.  Argument 0 is the
  40. Xname of the procedure itself.
  41. XThe integer function %argc may be used to determine the
  42. Xnumber of arguments passed to the procedure.  Specifying
  43. Xan argument number greater than the number of arguments
  44. Xpassed returns a null string (if procedure tracing is enabled
  45. Xwith the 'ptrace' comand, a warning will be displayed
  46. Xin this case).
  47. X.DS I
  48. XExample:
  49. X    invocation from shell:
  50. X    ecu -p test Quick Brown Fox
  51. X
  52. X    invocation from interactive command line:
  53. X    do test Quick Brown Fox
  54. X
  55. X    invocation from procedure:
  56. X    do 'test' 'Quick' 'Brown' 'Fox'
  57. X    
  58. X    results in:
  59. X    %argv(0) = 'test'
  60. X    %argv(1) = 'Quick'
  61. X    %argv(2) = 'Brown'
  62. X    %argv(3) = 'Fox'
  63. X    %argv(4) = ''
  64. X.DE
  65. X
  66. X.B NOTE:
  67. Xthe interactive
  68. X.B dial
  69. Xcommand, the dialing directory menu and the initial setup menu
  70. Xall can automatically execute a procedure which matches
  71. Xa dialed
  72. X.B
  73. Xlogical telephone number.
  74. X.R
  75. XThere two arguments passed to these procedures, %argv(0) being
  76. Xthe procedure name as always.  %argv(1) is set according to the following
  77. Xtable:
  78. X.DS I
  79. X invoker              %argv(1)
  80. X-------------------  -------------
  81. Xinitial setup menu   !INITIAL
  82. Xinteractive dial     !INTERACTIVE
  83. Xdialing menu         !MENU
  84. X.DE
  85. XThus it is possible for the invoked procedure
  86. Xto determine that it has been automatically executed
  87. Xby testing %argv(1) for an exclamation point, or possibly
  88. Xthe entire argument.
  89. X
  90. X.*s 2 "%basename"
  91. X
  92. XUsage: %basename(str0,str1)
  93. X
  94. XThis function is similar to the UNIX basename(1) utility in
  95. Xthat it returns a filename minus a supplied suffix, if it is present.
  96. XUnlike the UNIX basename(C) program, %basename does not remove
  97. Xthe directory part of the filename.
  98. XSee also
  99. X.B %dirpart
  100. Xand
  101. X.B %filepart .
  102. X
  103. X.DS L
  104. XExamples:
  105. X
  106. X    %basename('/u1/src/ecu/ecu.c','.c') = /u1/src/ecu/ecu
  107. X    %basename('ecu.c','.c') = ecu
  108. X    %basename('ecu.c','.x') = ecu.c
  109. X.DE
  110. X
  111. X.*s 2 "%cgetc"
  112. X
  113. Xusage: %cgetc
  114. X
  115. XThis  function reads one character from the console keyboard
  116. Xand returns it.  The character is not echoed.
  117. X
  118. X.*s 2 "%cgets"
  119. X
  120. Xusage: %cgets
  121. X
  122. XThis function reads a string from the console keyboard
  123. Xand returns it.  Each character is echoed as it is typed
  124. Xand the user's normal erase and kill character is available
  125. Xto edit the input before terminating the read with ENTER.
  126. X
  127. X.*s 2 "%chr"
  128. X
  129. Xusage: %chr(int0)
  130. X
  131. XThis function returns the character value whose ASCII value
  132. Xis supplied in int0.
  133. X
  134. X.DS L
  135. XExample:
  136. X
  137. X    set $s0 = %chr(4)  places a ^D (EOT) character into $s0
  138. X.DE
  139. X
  140. X.*s 2 "%date"
  141. X
  142. Xusage: %date
  143. X
  144. XThis function returns the current date in the form 'mm-dd-yyyy'
  145. Xin the local time zone (daylight time if it applies).
  146. X
  147. X.*s 2 "%datez"
  148. X
  149. Xusage: %datez
  150. X
  151. XThis function returns the current date in the form 'mm-dd-yyyy'
  152. Xin the UTC (Z) time zone.
  153. X
  154. X.*s 2 "%day"
  155. X
  156. Xusage: %day
  157. X
  158. XThis function returns the current day of the week as a three character
  159. Xabbreviation: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
  160. Xin the local time zone (daylight time if it applies).
  161. X
  162. X.*s 2 "%dayz"
  163. X
  164. Xusage: %dayz
  165. X
  166. XThis function returns the current day of the week as a three character
  167. Xabbreviation: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
  168. Xin the UTC (Z) time zone.
  169. X
  170. X.*s 2 "%dir"
  171. X
  172. Xusage: %dir
  173. X
  174. XThis function returns the
  175. Xfull pathname of the current working directory.
  176. X
  177. X.*s 2 "%dirpart"
  178. X
  179. Xusage: %dirpart(str0)
  180. X
  181. XThis function returns the
  182. Xdirectory portion of the pathname supplied in str0.
  183. XSee also
  184. X.B %basename
  185. Xand
  186. X.B %filepart .
  187. X
  188. X
  189. X.DS L
  190. XExamples:
  191. X
  192. X%dirpart('/u1/src/src/foo.c') = "/u1/src/src"
  193. X%dirpart('foo.c') = "foo.c"
  194. X%dirpart('/usr') = ""
  195. X.DE
  196. X
  197. X.*s 2 "%edate"
  198. X
  199. Xusage: %edate(int0)
  200. X
  201. XThe value in int0 is expected to be a number of seconds since January 1,
  202. X1970 00:00 UTC (Universal Coordinated Time) as returned by
  203. Xthe integer functions %fatime and %fmtime.
  204. XThis function converts the value into a string representing the
  205. Xequivalent local time in the form 'mm-dd-yyyy hh:mm:ss'.
  206. X.DS L
  207. XExample:
  208. X
  209. Xset $i0=%fmtime('/xenix')
  210. X$i00 = 601178971 (0x23d5435b,04365241533)
  211. X
  212. Xset $s0=%edate($i0)
  213. X$s00 = '01-18-1989 21:09:31'
  214. X.DE
  215. X
  216. X.*s 2 "%envvar"
  217. X
  218. Xusage: %envvar()
  219. X
  220. XThis function returns the string value of an environment
  221. Xvariable.
  222. X
  223. X.DS L
  224. XExample:
  225. X
  226. X    set $s0=%envvar('HOME') might set $s0 '/usr/user'
  227. X.DE
  228. X.DF L
  229. XTypical Environment Variables:
  230. X
  231. X    HOME          pathname of home directory
  232. X    EDITOR        user's preferred editor
  233. X    PATH          program execution searchlist
  234. X    TERM          terminal type
  235. X    SHELL         user's preferred shell
  236. X    MAIL          user's mail box file
  237. X    ECUPROMPT     ECU interactive command prompt
  238. X                  at beginning of execution
  239. X.DE
  240. X
  241. X.*s 2 "%errstr"
  242. X
  243. Xusage: %errstr(int0)
  244. X
  245. XThis function returns the system error message, given int0 as an
  246. X.B errno
  247. Xas returned by a file-related command.
  248. X.B fopen.
  249. X
  250. X.DS L
  251. XExample:
  252. X
  253. X    echo %errstr(1)
  254. X    Not owner
  255. X.DE
  256. X
  257. X.*s 2 "%etime"
  258. X
  259. Xusage: %etime(int0)
  260. X
  261. XThis function returns a string representation of elapsed time
  262. Xin the format 'hh:mm:ss'
  263. Xfor the integer parameter int0, a number of seconds.
  264. X
  265. X.DS L
  266. XExample:
  267. X
  268. X    echo %etime(62)
  269. X    00:01:02
  270. X.DE
  271. X
  272. X.*s 2 "%filepart"
  273. X
  274. Xusage: %filepart(str0)
  275. X
  276. XThis function returns the
  277. Xfilename portion of the pathname supplied in str0.
  278. XSee also
  279. X.B %basename
  280. Xand
  281. X.B %dirpart .
  282. X
  283. X.DS L
  284. XExamples:
  285. X
  286. X%filepart('/u1/src/src/foo.c') = "foo.c"
  287. X%filepart('foo.c') = "foo.c"
  288. X.DE
  289. X
  290. X.*s 2 "%fmodestr"
  291. X
  292. Xusage: %fmodestr(int0)
  293. X
  294. XThis function returns a string representation of the
  295. Xfamiliar file mode string given the file mode integer int0.
  296. X
  297. X.DS L
  298. XExample:
  299. X
  300. X    echo %fmodestr(0100755)
  301. X    -rwxr-xr-x
  302. X
  303. X    echo %fmodestr(%fmode('/usr/lib'))
  304. X    drwxr-xr-x
  305. X.DE
  306. X
  307. X.*s 2 "%itos"
  308. X
  309. Xusage: %itos(int0[,format])
  310. X
  311. XThis function converts integer int0 to a string, optionally
  312. Xcontrolling the format of the conversion.
  313. X
  314. XIf the format parameter is missing, the conversion is to
  315. Xa minimum number of decimal characters necessary to
  316. Xhold the result.
  317. X
  318. XIf the format parameter is present, it must of consist of
  319. Xa non-null string made of one or both optional parts:
  320. X.DS L
  321. X    decimal number of digits to be part of result string
  322. X    (a leading zero indicates leading zeroes are to
  323. X    appear in the string; no leading zero pads with
  324. X    leading spaces
  325. X
  326. X    a lower case letter from the following list:
  327. X        d - decimal conversion
  328. X        x - hexadecimal conversion
  329. X        o - octal conversion
  330. X.DE
  331. X.DS L
  332. XExample:
  333. X
  334. X    %itos(33)           '33'
  335. X    %itos(33,d)         '33'
  336. X    %itos(33,x)         '21'
  337. X    %itos(33,5d)        '   33'
  338. X    %itos(33,010d)      '0000000033'
  339. X    %itos(33,10d)       '        33'
  340. X    %itos(33,x)         '21'
  341. X    %itos(33,04x)       '0021'
  342. X    %itos(33,4x)        '  21'
  343. X    %itos(33,o)         '41'
  344. X    %itos(33,4o)        '    41'
  345. X.DE
  346. X
  347. X.*s 2 "%left"
  348. X
  349. Xusage: %left(str0,int0)
  350. X
  351. XThis function returns the leftmost int0 characters of str0.
  352. XIf the length of the string is less than int0,
  353. Xthe entire str0 is returned.
  354. X.DS L
  355. XExample:
  356. X
  357. X    if $s0 == 'abcdefg'
  358. X    %left($s0,3) returns 'abc'
  359. X.DE
  360. X
  361. X.*s 2 "%line"
  362. X
  363. Xusage: %line
  364. X
  365. XThis function returns the name of the attached communications
  366. Xline in the form "/dev/ttyxx".  If no line is currently
  367. Xattached, the function returns null.
  368. X
  369. X.*s 2 "%logname"
  370. X
  371. Xusage: %logname
  372. X
  373. XThis function returns the login name of the user executing
  374. XECU.  Note: the name returned is the name supplied to a login
  375. Xprompt, not any current su(C) username that may be in effect.
  376. X
  377. X.*s 2 "%mid"
  378. X
  379. Xusage: %mid(str0,int0[,int1])
  380. X
  381. XThis function returns the middle portion of a string str0
  382. Xbeginning with the character at position int0 and for a length
  383. Xof int1 characters.
  384. XIf int0 is greater than or equal to the length of
  385. Xstro, a null string is returned.
  386. XIf the optional argument int1 is not supplied, or
  387. Xif the length of the string is less than int1,
  388. Xthe entire str0 is returned.
  389. X.DS L
  390. XExample:
  391. X
  392. X    if $s0 == '0123456789abc'
  393. X    %mid($s0,3,4)  returns '3456'
  394. X    %mid($s0,3)    returns '3456789abc'
  395. X    %mid($s0,10,2) returns 'ab'
  396. X    %mid($s0,10,5) returns 'abc'
  397. X.DE
  398. X
  399. X.*s 2 "%month"
  400. X
  401. Xusage: %month
  402. X
  403. XThis function returns the current month as a three character
  404. Xabbreviation: 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'.
  405. X
  406. X.*s 2 "%rdesc"
  407. X
  408. Xusage: %rdesc
  409. X
  410. XThis function returns the
  411. Xdescription
  412. Xportion of the
  413. Xdialing directory entry for the currently connected remote.
  414. XIf no connection exists, the function returns null.
  415. X
  416. X.*s 2 "%right"
  417. X
  418. Xusage: %right(str0,int0)
  419. X
  420. XThis function returns the rightmost int0 characters of str0.
  421. XIf the length of the string is less than int0,
  422. Xthe entire str0 is returned.
  423. X.DS L
  424. XExample:
  425. X
  426. X    if $s0 == 'abcdefg'
  427. X    %right($s0,3) returns 'efg'
  428. X.DE
  429. X
  430. X.*s 2 "%rname"
  431. X
  432. Xusage: %rname
  433. X
  434. XThis function returns the
  435. Xlogical name
  436. Xportion of the
  437. Xdialing directory entry for the currently connected remote.
  438. XIf the remote was dialed directly, as in dial 5551212, the
  439. Xreturned value is the phone number.
  440. XIf no connection exists, the function returns null.
  441. X
  442. XThe value returned by this command may be overridden by use of the
  443. X.B rname
  444. Xprocedure command.
  445. X
  446. X.*s 2 "%rtelno"
  447. Xusage: %rtelno
  448. X
  449. XThis function returns the
  450. Xtelephone number
  451. Xportion of the
  452. Xdialing directory entry for the currently connected remote.
  453. XIf no connection exists, the function returns null.
  454. X
  455. X.*s 2 "%time"
  456. X
  457. Xusage: %time
  458. X
  459. XThis function returns the current time in the form 'hh:mm'
  460. Xin the local time zone (daylight time if it applies).
  461. X
  462. X.*s 2 "%times"
  463. X
  464. Xusage: %times
  465. X
  466. XThis function returns the current time in the form 'hh:mm:ss'
  467. Xin the local time zone (daylight time if it applies).
  468. X
  469. X.*s 2 "%timez"
  470. X
  471. Xusage: %timez
  472. X
  473. XThis function returns the current time in the form 'hh:mm'
  474. Xin the UTC (Z) time zone.
  475. X
  476. X.*s 2 "%timezs"
  477. X
  478. Xusage: %timezs
  479. X
  480. XThis function returns the current time in the form 'hh:mm:ss'
  481. Xin the UTC (Z) time zone.
  482. X
  483. X.*s 2 "%tty"
  484. X
  485. Xusage: %tty
  486. X
  487. XThis function returns the console tty name in the form "/dev/ttynn".
  488. X
  489. X.*s 2 "%uname"
  490. X
  491. Xusage: %uname
  492. X
  493. XThis function returns the system name you are executing ECU on as
  494. Xreported by uname(2)/uname(S).  On SCO systems, if /etc/systemid
  495. Xexists and is readable, the name in that file isused in place of
  496. Xthe name from uname.
  497. END_OF_FILE
  498.   if test 10113 -ne `wc -c <'ecu330/doc/_p_sfunc.txt'`; then
  499.     echo shar: \"'ecu330/doc/_p_sfunc.txt'\" unpacked with wrong size!
  500.   fi
  501.   # end of 'ecu330/doc/_p_sfunc.txt'
  502. fi
  503. if test -f 'ecu330/ecu.h' -a "${1}" != "-c" ; then 
  504.   echo shar: Will not clobber existing file \"'ecu330/ecu.h'\"
  505. else
  506.   echo shar: Extracting \"'ecu330/ecu.h'\" \(10662 characters\)
  507.   sed "s/^X//" >'ecu330/ecu.h' <<'END_OF_FILE'
  508. X/*+-----------------------------------------------------------------------
  509. X    ecu.h -- TuckerWare Extended Calling Unit
  510. X    wht@n4hgf.atl.ga.us
  511. X------------------------------------------------------------------------*/
  512. X/*+:EDITS:*/
  513. X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  514. X/*:03-15-1994-14:23-wht@n4hgf-correct doc: ecuxenix.c now ecugrabbag.c */
  515. X/*:01-16-1994-17:01-wht@n4hgf-restore SIGCHLD equate for NetBSD */
  516. X/*:12-12-1993-13:32-wht@n4hgf-MOTSVR3 port */
  517. X/*:12-12-1993-13:03-wht@fep-use ecu_time.h for ftime/gettimeofday */
  518. X/*:12-11-1993-11:27-wht@n4hgf-lost an endif */
  519. X/*:12-10-1993-22:09-wht@n4vu-more Linux fixes + no default sun termios */
  520. X/*:11-14-1993-15:47-wht@n4hgf-more hpux port */
  521. X/*:10-02-1993-22:45-wht@n4hgf-add SIGPTR */
  522. X/*:08-01-1993-02:12-wht@n4hgf-add got_delim to LRWT */
  523. X/*:09-13-1992-12:52-wht@n4hgf-add tty_is_scoterm */
  524. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  525. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  526. X/*:08-21-1992-13:39-wht@n4hgf-rewire direct/modem device use */
  527. X/*:07-21-1992-12:09-wht@n4hgf-3.2v4 only has sys/time.h if TCPRT installed */
  528. X/*:04-17-1992-20:10-wht@gyro-default tty, baud and parity moved to config.c */
  529. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  530. X/*:02-13-1992-06:35-wht@n4hgf-when port to many time() can be int/long/time_t */
  531. X/*:11-30-1991-13:46-wht@n4hgf-smap conditional compilation reorg */
  532. X/*:11-26-1991-20:17-wht@n4hgf-add shm->Ldcdwatch values */
  533. X/*:11-26-1991-19:37-wht@n4hgf-add STR_CLASSIFY */
  534. X/*:11-13-1991-16:29-wht@n4hgf-use if __STDC__ instead of defined(__STDC__) */
  535. X/*:11-11-1991-22:45-wht@n4hgf-redefinition of Ltermio's place in life */
  536. X/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
  537. X/*:08-13-1991-13:53-wht@n4hgf-UNIX and ISC nap() broken; XENIX still wins */
  538. X/*:08-09-1991-11:07-wht@n4hgf-configurable lock directory */
  539. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  540. X/*:01-25-1991-06:08-wht@n4hgf-mulltiple #define of ECULIBDIR */
  541. X/*:01-22-1991-14:33-wht@n4hgf-XENIX calloc/memmove fix */
  542. X/*:01-01-1991-21:36-wht@n4hgf-add GCC implies STDC */
  543. X/*:08-14-1990-20:39-wht@n4hgf-ecu3.00-flush old edit history */
  544. X
  545. X#ifndef _ecu_h
  546. X#define _ecu_h
  547. X
  548. X#include "ecu_config.h"
  549. X
  550. X#if !defined(STDIO_H_INCLUDED)
  551. X#include <stdio.h>
  552. X#endif
  553. X
  554. X#include <signal.h>
  555. X#include <ctype.h>
  556. X#include <errno.h>
  557. X#include <string.h>
  558. X#include <memory.h>
  559. X#include <fcntl.h>
  560. X#include "ecu_types.h"
  561. X#include "ecu_stat.h"
  562. X#include "ecu_time.h"
  563. X#include "ecushm.h"
  564. X#include "termecu.h"
  565. X#include "ttynaming.h"
  566. X#if !defined(OMIT_TERMIO_REFERENCES)
  567. X#include "ecutermio.h"
  568. X#endif /* OMIT_TERMIO_REFERENCES */
  569. X
  570. X/*
  571. X * if building prototypes, using lint, or otherwise need
  572. X * the source to make sense without the Overly Complex
  573. X * Makefile, turn the following on
  574. X */
  575. X#if defined(BUILDING_PROTOTYPES) || defined(lint)
  576. X#define ECULIBDIR "dummy"
  577. X#define HDBLIBDIR "dummy"
  578. X#define LOCK_DIR_NAME "dummy"
  579. X#define DEFAULT_TTY "/dev/tty1"
  580. X#define DEFAULT_BAUD_RATE 2400
  581. X#define DEFAULT_PARITY 'n'
  582. X#endif
  583. X
  584. X/*
  585. X * The various flavors of hardware flow control, most of them
  586. X * flakey or incomplete .... follow the identifer road
  587. X * (fgrep HW_FLOW_CONTROL) to see what it takes to
  588. X * include your vendor's attempt.
  589. X */
  590. X#if defined(RTSFLOW) && !defined(HW_FLOW_CONTROL)    /* SCO */
  591. X#define HW_FLOW_CONTROL
  592. X#endif
  593. X#if defined(CRTSFL) && !defined(HW_FLOW_CONTROL)    /* 3.2v4 and later */
  594. X#define HW_FLOW_CONTROL
  595. X#endif
  596. X#if defined(RTSXOFF) && !defined(HW_FLOW_CONTROL)    /* SVR4 */
  597. X#define HW_FLOW_CONTROL
  598. X#endif
  599. X#if defined(CRTSCTS) && !defined(HW_FLOW_CONTROL)    /* sun */
  600. X#define HW_FLOW_CONTROL
  601. X#endif
  602. X
  603. X/*
  604. X * Communication line variables that are not in shared memory
  605. X *
  606. X * One special note: Ltermio points to a buffer in shared memory
  607. X * used to hold the line's current termio structure.  The shared
  608. X * memory buffer is defined as a simple array of longs so that
  609. X * friend code need not include termio.h if it does not need it.
  610. X * What's more, due to sgtty-based curses code, XENIX versions
  611. X * cannot include termio.h in some modules.  ecushm.c has runtime
  612. X * code to initialize Ltermio to point to shm->Ltiobuf and to
  613. X * make sure shm->Ltiobuf is long enough.
  614. X */
  615. X#if defined(DECLARE_LINEVARS_PUBLIC)
  616. X#if !defined(OMIT_TERMIO_REFERENCES)
  617. Xstruct termio *Ltermio;         /* attributes for the line to remote */
  618. X#endif
  619. Xuchar Ldial_debug_level;
  620. X
  621. X#else
  622. X#if !defined(OMIT_TERMIO_REFERENCES)
  623. Xextern struct termio *Ltermio;
  624. X
  625. X#endif
  626. Xextern uchar Ldial_debug_level;
  627. X
  628. X#endif
  629. X
  630. Xextern int zero_length_read_detected;    /* see lgetc_xmtr in eculine.c */
  631. X
  632. X#ifdef M_I286
  633. Xlong time();
  634. X
  635. X#endif
  636. X
  637. Xlong Nap();
  638. X
  639. X#if __STDC__                 /* sigh ... malloc and such types; SIGTYPE
  640. X                              * just a guess */
  641. X#define VTYPE void
  642. X#define VOLATILE volatile
  643. X#ifndef SIGTYPE
  644. X#define SIGTYPE void
  645. X#endif
  646. X#else
  647. X#define VTYPE char
  648. X#define VOLATILE
  649. X#ifndef SIGTYPE
  650. X#define SIGTYPE int
  651. X#endif
  652. X#endif
  653. X
  654. X#include "smap.h"
  655. X#if defined(MALLOC_3X)
  656. X#include <malloc.h>
  657. X#else
  658. XVTYPE *malloc();
  659. XVTYPE *calloc();
  660. XVTYPE *realloc();
  661. X
  662. X#endif
  663. X
  664. Xtypedef int (*PFV) ();         /* pointer to function returning void */
  665. Xtypedef char (*PFC) ();         /* pointer to function returning char */
  666. Xtypedef int (*PFI) ();         /* pointer to function returning integer */
  667. Xtypedef long (*PFL) ();         /* pointer to function returning long */
  668. Xtypedef SIGTYPE(*SIGPTR) (); /* pointer to signal handler */
  669. X
  670. X/*
  671. X * undef M_XENIX must come after any system header inclusion
  672. X */
  673. X#if defined(M_UNIX)
  674. X#undef M_XENIX                 /* now can truly distinquish between SCO
  675. X                              * XENIX and UNIX */
  676. X#endif /* M_UNIX */
  677. X
  678. X/*
  679. X * small dialect correction
  680. X */
  681. X#ifdef __NetBSD__
  682. X#define SIGCLD SIGCHLD
  683. X#endif
  684. X
  685. X#if defined(GNUC) || defined(__GNUC__) || (__STDC__ == 1)
  686. Xint strcmpi(char *s1, char *s2);
  687. X
  688. X#endif
  689. X
  690. X/*
  691. X * for better source line utilization, frequent use of
  692. X * fprintf and stderr warrants the following
  693. X */
  694. X#define pf    printf
  695. X#define ff    fprintf
  696. X#define se    stderr
  697. X#define so    stdout
  698. X
  699. X/*
  700. X * console tty information
  701. X */
  702. Xextern int tty_is_multiscreen;    /* SCO multiscreen */
  703. Xextern int tty_is_scoterm;     /* SCO scoterm */
  704. Xextern int tty_is_pty;         /* bursty network connection? */
  705. Xextern int tty_not_char_special;    /* /dev/null not considered char
  706. X                                     * special */
  707. X
  708. X/*
  709. X * useful macros
  710. X */
  711. X#undef max                     /* just in case they ... */
  712. X#undef min                     /* ... were already defined */
  713. X#define max(a,b) (((a) > (b)) ? (a) : (b))
  714. X#define min(a,b) (((a) < (b)) ? (a) : (b))
  715. X
  716. X/*
  717. X * decide how to write to logfile
  718. X */
  719. X#define LOGPUTC putc         /* fputc() or putc() */
  720. X
  721. X#define TTYIN    0
  722. X#define TTYOUT  1             /* ditto tty output */
  723. X#define TTYERR  2             /* ditty tty output error channel */
  724. X
  725. X/*
  726. X * xbell codes (see ecugrabbag.c)
  727. X */
  728. Xenum xbell
  729. X{
  730. X    XBELL_DONE = 1,             /* octaves or morse 'd' */
  731. X    XBELL_ATTENTION,         /* morse .-.-.- ATTENTION */
  732. X    XBELL_C,                 /* morse -.-. C */
  733. X    XBELL_3T                 /* 3 Ts --- really 'o' */
  734. X};
  735. X
  736. X/*
  737. X * lopen() and related routines error codes
  738. X */
  739. Xenum linst
  740. X{
  741. X    LINST_OK = 0,             /* no error */
  742. X    LINST_INVALID = -50,     /* for invalid tty name */
  743. X    LINST_UNKPID,             /* unknown pid using line */
  744. X    LINST_LCKERR,             /* lock file open error */
  745. X    LINST_NODEV,             /* device does not exist */
  746. X    LINST_OPNFAIL,             /* could not access line */
  747. X    LINST_ALREADY,             /* line already open */
  748. X    LINST_ENABLED,             /* line enabled for login */
  749. X    LINST_ENABLED_IN_USE,     /* line in use by incoming login */
  750. X    LINST_DIALOUT_IN_USE,     /* line in use by another dial out */
  751. X    LINST_NOPTY,             /* pty not supported */
  752. X    LINST_WEGOTIT,             /* not really an error: we already own the
  753. X                              * line (used by check_utmp()) */
  754. X    LINST_ECUUNGETTY,         /* ecuungetty unexpected response */
  755. X    LINST_ECUUNGETTY2,         /* ecuungetty execution error */
  756. X    LINST_NOTCHR             /* not a character special */
  757. X};
  758. X
  759. Xchar *LINST_text();             /* routine to return text for error code */
  760. Xextern char lopen_err_str[];
  761. X
  762. X/*
  763. X * filename sizes
  764. X */
  765. X#define CURR_DIRSIZ 256         /* current directory array size */
  766. X#define PHONEDIR_NAME_SIZE 256    /* phone directory */
  767. X
  768. X/*
  769. X * in case errno.h doesn't pick this up
  770. X */
  771. Xextern int errno;
  772. Xextern char *sys_errlist[];
  773. Xextern int sys_nerr;
  774. Xchar *errno_text();             /* see ecuutil.c */
  775. X
  776. Xchar *getenv();
  777. X
  778. X/*
  779. X * process IDs
  780. X */
  781. Xextern PID_T rcvr_pid;
  782. Xextern PID_T xmtr_pid;
  783. X
  784. X/*
  785. X * both of the following are set by xmtr_SIGINT_handler()
  786. X * 'sigint' reset by 1st detector/processor
  787. X * 'proc_interrupt' reset/handled by procedure monitor
  788. X *                  (execute_esd and execute_proc)
  789. X */
  790. Xextern int sigint;
  791. X
  792. X/* extern int proc_interrupt; <------ force using modules to declare it */
  793. X
  794. X/*
  795. X * procedure nesting level
  796. X * non-zero if procedure executing (see proc.c)
  797. X */
  798. Xextern int proc_level;
  799. Xextern int proc_trace;
  800. X
  801. X/*
  802. X * need_rcvr_restart() - check rcvr status
  803. X *
  804. X * If rcvr_pid == -2, queued restart has been requested by some function
  805. X * but we don't want to do it if a procedure is executing
  806. X */
  807. X#define need_rcvr_restart() \
  808. X    ((rcvr_pid > 0) || ((rcvr_pid == -2) && !proc_level))
  809. X
  810. X/*
  811. X * 'hz' is getenv("HZ"); that not found, the value from sys/param.h
  812. X * 'hzmsec' is ceiling(clock period) in milliseconds
  813. X */
  814. Xextern int hz;                 /* HZ from environ or sys/param.h */
  815. Xextern ulong hzmsec;         /* clock period in msec rounded up */
  816. X
  817. X/*
  818. X * lock file directory
  819. X */
  820. Xextern char *lock_dir_name;     /* defined in ecuLCK.c */
  821. X
  822. X/*
  823. X * setcolor variables - see setcolor()
  824. X */
  825. Xextern ulong colors_current;
  826. Xextern ulong colors_normal;
  827. Xextern ulong colors_success;
  828. Xextern ulong colors_alert;
  829. Xextern ulong colors_error;
  830. Xextern ulong colors_notify;
  831. X
  832. X/*
  833. X * miscellaneuous
  834. X */
  835. Xextern char *eculibdir;         /* lib dir, i.e., "/usr/local/lib/ecu" */
  836. Xextern char *ttype;             /* getenv("TERM") */
  837. X
  838. X/*
  839. X * param to lgets_timeout in eculine.c
  840. X */
  841. Xtypedef struct lrwt
  842. X{
  843. X    ulong to1;                 /* timeout for 1st character (granularity 20) */
  844. X    ulong to2;                 /* timeout for each next char (granularity
  845. X                              * 20) */
  846. X    int raw_flag;             /* !=0, rtn full buffer, ==0, rtn filtered
  847. X                              * hayes result */
  848. X    char *buffer;             /* buffer to fill */
  849. X    int bufsize;             /* size of buffer */
  850. X    int count;                 /* from proc, count rcvd */
  851. X    char *delim;             /* ending string for lgets_timeout_or_delim */
  852. X    int echo_flag;             /* echo incoming chars to screen */
  853. X    int got_delim;             /* set true if delim found */
  854. X}
  855. XLRWT;
  856. X
  857. X/*
  858. X * parameter structure for str_classify()
  859. X */
  860. Xtypedef struct str_classify
  861. X{
  862. X    char *str;                 /* string to match */
  863. X    int min_ch;                 /* minimum characters required */
  864. X    int token;                 /* token for match */
  865. X}
  866. XSTR_CLASSIFY;
  867. X
  868. X/*
  869. X * shm->Ldcdwatch values
  870. X */
  871. X#define DCDW_OFF        0
  872. X#define DCDW_ON            1
  873. X#define DCDW_TERMINATE    2
  874. X
  875. X#ifdef DEBUG_SRP
  876. X#define start_rcvr_process(flag) _start_rcvr_process(flag,__FILE__,__LINE__)
  877. X#else
  878. X#define start_rcvr_process(flag) _start_rcvr_process(flag)
  879. X#endif
  880. X
  881. X#endif /* _ecu_h */
  882. X
  883. X/* vi: set tabstop=4 shiftwidth=4: */
  884. X/* end of ecu.h */
  885. END_OF_FILE
  886.   if test 10662 -ne `wc -c <'ecu330/ecu.h'`; then
  887.     echo shar: \"'ecu330/ecu.h'\" unpacked with wrong size!
  888.   fi
  889.   # end of 'ecu330/ecu.h'
  890. fi
  891. if test -f 'ecu330/ecushm.c' -a "${1}" != "-c" ; then 
  892.   echo shar: Will not clobber existing file \"'ecu330/ecushm.c'\"
  893. else
  894.   echo shar: Extracting \"'ecu330/ecushm.c'\" \(10554 characters\)
  895.   sed "s/^X//" >'ecu330/ecushm.c' <<'END_OF_FILE'
  896. X/*+-------------------------------------------------------------------------
  897. X    ecushm.c - shared memory handler for ecu xmtr/rcvr comm
  898. X    wht@n4hgf.atl.ga.us
  899. X
  900. X  Signal handler purists will surely get aneurisms from looking
  901. X  at what we do in here, but any OS that doesn't properly push
  902. X  a stack frame for a signal event just won't play here.  We even
  903. X  fork() in a signal handler.  That ought to make some of the
  904. X  brethren gag.
  905. X
  906. X  Defined functions:
  907. X    shm_done()
  908. X    shm_init()
  909. X    shmr_notify_xmtr_of_DCD_loss()
  910. X    shmr_notify_zmodem_frame()
  911. X    shmr_process_rcvr_SIGUSR2()
  912. X    shmx_connect()
  913. X    shmx_make_rcvr_sleep(seconds)
  914. X    shmx_process_xmtr_SIGUSR2()
  915. X    shmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each)
  916. X    shmx_unpause_rcvr()
  917. X
  918. X  Sforzando (It., sfohr-tsahn'-doh).  A direction to perform the
  919. X  tone or chord with special stress, or marked and sudden emphasis.
  920. X  -- Schirmer Pronouncing POCKET-MANUAL of Musical Terms, 1936.
  921. X
  922. X--------------------------------------------------------------------------*/
  923. X/*+:EDITS:*/
  924. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  925. X/*:11-25-1993-14:43-wht@n4hgf-3.281-fix typo in shm_done shmctl statement */
  926. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  927. X/*:09-10-1992-04:34-wht@n4hgf-add rcvrdisp semaphore */
  928. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  929. X/*:12-15-1991-14:22-wht@n4hgf-autorz initialized */
  930. X/*:12-13-1991-04:16-wht@n4hgf-move bell_notify_state to shm */
  931. X/*:11-12-1991-18:02-wht@n4hgf-remove obsolete shmx_rc_report */
  932. X/*:11-11-1991-14:59-wht@n4hgf-shmr_notify_xmtr_of_DCD_loss */
  933. X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
  934. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  935. X
  936. X#include "ecu.h"
  937. X
  938. X#if defined(CFG_MmapSHM)
  939. X#include <sys/mman.h>
  940. X#else
  941. X#include <sys/ipc.h>
  942. X#include <sys/shm.h>
  943. X#ifdef CFG_SemWithShm
  944. X#include <sys/sem.h>
  945. X
  946. Xunion semun
  947. X{
  948. X    int val;
  949. X    struct semid_ds *buf;
  950. X    ushort *array;
  951. X} semctl_arg;
  952. X
  953. X#endif /* CFG_SemWithShm */
  954. X#endif /* CFG_MmapSHM */
  955. X
  956. X/* xmtr to rcvr cmds */
  957. X#define SHMX_MAKE_RCVR_SLEEP    1    /* sleep xi1=#seconds */
  958. X#define SHMX_UNPAUSE            2    /* no-op to un-pause() rcvr */
  959. X#define SHMX_SET_RCVR_LOG        3    /* log file manipulations
  960. X                                     * xi1=append,xi2=raw,xs1=n ame */
  961. X
  962. X/* rcvr to xmtr cmds */
  963. X#define SHMR_NOTIFY_DCD_LOSS    1    /* rcvr detected DCD loss */
  964. X#define SHMR_NOTIFY_ZMODEM        2    /* rcvr detected ZMODEM frame */
  965. X
  966. Xextern char rcvr_log_file[]; /* if rcvr_log!= 0,log filename */
  967. Xextern int rcvr_log;         /* rcvr log active if != 0 */
  968. Xextern FILE *rcvr_log_fp;     /* rcvr log file */
  969. Xextern int rcvr_log_raw;     /* if true, log all, else filter ctl chrs */
  970. Xextern int rcvr_log_flusheach;
  971. Xextern int rcvr_log_append;     /* if true, append, else scratch */
  972. Xextern int rcvr_log_gen_title;
  973. X
  974. XECU_SDS FAR *shm;             /* shared segment pointer */
  975. X#if !defined(CFG_MmapSHM)
  976. Xkey_t shm_key;
  977. Xint shm_shmid;
  978. X
  979. X#endif
  980. X
  981. X/*+-------------------------------------------------------------------------
  982. X    shm_init()
  983. X  Called by parent process (xmtr) to initialize environment
  984. X--------------------------------------------------------------------------*/
  985. Xvoid
  986. Xshm_init()
  987. X{
  988. X    uint save_LINESxCOLS;
  989. X    extern uint LINESxCOLS;
  990. X
  991. X    /*
  992. X     * see the comments in ecu.h titled "Communication line variables" for
  993. X     * an explanation of the following
  994. X     */
  995. X    if (sizeof(shm->Ltiobuf) < sizeof(struct termio))
  996. X    {
  997. X        pprintf("ecushm.h LTIOBUF_SIZE needs to be increased to %d.\n",
  998. X            sizeof(struct termio));
  999. X
  1000. X        pputs("Please change it, remake and notify wht@n4hgf.atl.ga.us.\n");
  1001. X        termecu(TERMECU_CONFIG_ERROR);
  1002. X    }
  1003. X
  1004. X#if defined(CFG_MmapSHM)
  1005. X    shm = (ECU_SDS *) mmap(0, sizeof(ECU_SDS), PROT_READ | PROT_WRITE,
  1006. X        MAP_ANON | MAP_INHERIT | MAP_SHARED, -1, 0);
  1007. X    if (shm == (ECU_SDS *) - 1)
  1008. X    {
  1009. X        perror("mmap");
  1010. X        termecu(TERMECU_IPC_ERROR);
  1011. X    }
  1012. X#else
  1013. X    shm_key = 0xEC000000L | getpid();
  1014. X
  1015. X    if ((shm_shmid = shmget(shm_key, sizeof(ECU_SDS), IPC_CREAT | 0600)) < 0)
  1016. X    {
  1017. X        perror("shmget");
  1018. X        termecu(TERMECU_IPC_ERROR);
  1019. X    }
  1020. X
  1021. X    if ((shm = (ECU_SDS FAR *) shmat(shm_shmid, (char FAR *)0, 0)) ==
  1022. X        (ECU_SDS FAR *) - 1)
  1023. X    {
  1024. X        perror("shmat");
  1025. X        termecu(TERMECU_IPC_ERROR);
  1026. X    }
  1027. X
  1028. X#ifdef CFG_SemWithShm
  1029. X    if ((shm->rcvrdisp_semid = semget(shm_key, 1, IPC_CREAT | 0600)) < 0)
  1030. X    {
  1031. X        perror("semget");
  1032. X        termecu(TERMECU_IPC_ERROR);
  1033. X    }
  1034. X    rcvrdisp_v();             /* first unlock */
  1035. X#endif /* CFG_SemWithShm */
  1036. X#endif /* CFG_MmapSHM */
  1037. X
  1038. X    /*
  1039. X     * see the comments in ecu.h titled "Communication line variables" for
  1040. X     * an explanation of the following
  1041. X     */
  1042. X    Ltermio = (struct termio *)shm->Ltiobuf;    /* cover termio buffer */
  1043. X
  1044. X    shm->xcmd = 0;             /* signal from xmtr to rcvr SIGUSR2 */
  1045. X    shm->xi1 = 0;             /* parameters */
  1046. X    shm->xi2 = 0;
  1047. X    shm->xs1[0] = 0;
  1048. X    shm->rcmd = 0;             /* signal from rcvr to xmtr SIGUSR2 */
  1049. X    shm->ri1 = 0;             /* parameters */
  1050. X    shm->ri2 = 0;
  1051. X    shm->rs1[0] = 0;
  1052. X    shm->rcvd_chars = 0L;
  1053. X    shm->rcvd_chars_this_connect = 0L;
  1054. X    shm->bell_notify_state = 1;    /* default to want bell notify */
  1055. X    shm->Ldcdwatch = 0;         /* default DCD watcher to off */
  1056. X    shm->autorz = 1;         /* default automatic rz to on */
  1057. X    shm->cursor_y = 0;
  1058. X    shm->cursor_x = 0;
  1059. X    shm->friend_space[0] = 0;
  1060. X    save_LINESxCOLS = LINESxCOLS;
  1061. X    LINESxCOLS = sizeof(shm->screen);    /* avoid trap */
  1062. X    spaces((char *)shm->screen, sizeof(shm->screen));
  1063. X    LINESxCOLS = save_LINESxCOLS;
  1064. X    shm->rcvrdisp_ptr = shm->rcvrdisp_buffer;
  1065. X    shm->rcvrdisp_count = 0;
  1066. X
  1067. X}                             /* end of shm_init */
  1068. X
  1069. X/*+-------------------------------------------------------------------------
  1070. X    shm_done() -- finished with shm/sem -- clean up
  1071. X
  1072. XWe might make a trip thru here with the xmtr and rcvr, so
  1073. Xignore EINVAL
  1074. X--------------------------------------------------------------------------*/
  1075. Xvoid
  1076. Xshm_done()
  1077. X{
  1078. X
  1079. X#if defined(CFG_MmapSHM)
  1080. X    munmap(shm, sizeof(ECU_SDS));
  1081. X#else
  1082. X#ifdef CFG_SemWithShm
  1083. X    union semun semctl_arg;
  1084. X
  1085. X    if (semctl(shm->rcvrdisp_semid, 0, IPC_RMID, &semctl_arg) && (errno != EINVAL))
  1086. X        pperror("semctl IPC_RMID");
  1087. X#endif /* CFG_SemWithShm */
  1088. X
  1089. X    if (shmctl(shm_shmid, IPC_RMID, (struct shmid_ds *)0) && (errno != EINVAL))
  1090. X        pperror("shmctl IPC_RMID");
  1091. X#endif
  1092. X
  1093. X}                             /* end of shm_done */
  1094. X
  1095. X/*+-------------------------------------------------------------------------
  1096. X    shmx_connect() -- xmtr calls when modem connects
  1097. X--------------------------------------------------------------------------*/
  1098. Xvoid
  1099. Xshmx_connect()
  1100. X{
  1101. X    shm->rcvd_chars_this_connect = 0L;
  1102. X}                             /* end of shmx_connect */
  1103. X
  1104. X/*+-------------------------------------------------------------------------
  1105. X    shmx_make_rcvr_sleep(seconds)
  1106. X--------------------------------------------------------------------------*/
  1107. Xvoid
  1108. Xshmx_make_rcvr_sleep(seconds)
  1109. Xint seconds;
  1110. X{
  1111. X    shm->xcmd = SHMX_MAKE_RCVR_SLEEP;
  1112. X    shm->xi1 = seconds;
  1113. X    kill_rcvr_process(SIGUSR2);
  1114. X
  1115. X}                             /* end of shmx_make_rcvr_sleep */
  1116. X
  1117. X/*+-------------------------------------------------------------------------
  1118. X    shmx_unpause_rcvr() - no-op SIGUSR2 to unpause receiver
  1119. X--------------------------------------------------------------------------*/
  1120. Xvoid
  1121. Xshmx_unpause_rcvr()
  1122. X{
  1123. X    shm->xcmd = SHMX_UNPAUSE;
  1124. X    kill_rcvr_process(SIGUSR2);
  1125. X}                             /* end of shmx_unpause_rcvr */
  1126. X
  1127. X/*+-------------------------------------------------------------------------
  1128. X    shmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each)
  1129. X
  1130. Xnull logfilename stops logging
  1131. Xappend_flag says whether to open for write or append
  1132. Xraw_flag says whether or not to filter non-printable chars or not
  1133. X(NL not filtered)
  1134. X--------------------------------------------------------------------------*/
  1135. Xvoid
  1136. Xshmx_set_rcvr_log(logfilename, append_flag, raw_flag, flush_each)
  1137. Xchar *logfilename;
  1138. Xint append_flag;
  1139. Xint raw_flag;
  1140. Xint flush_each;
  1141. X{
  1142. X    shm->xcmd = SHMX_SET_RCVR_LOG;
  1143. X    shm->xi1 = append_flag;
  1144. X    shm->xi2 = raw_flag;
  1145. X    shm->xi3 = flush_each;
  1146. X    strcpy(shm->xs1, logfilename);
  1147. X    kill_rcvr_process(SIGUSR2);
  1148. X}                             /* end of shmx_set_rcvr_log */
  1149. X
  1150. X/*+-------------------------------------------------------------------------
  1151. X    shmr_notify_xmtr_of_DCD_loss()
  1152. X--------------------------------------------------------------------------*/
  1153. Xvoid
  1154. Xshmr_notify_xmtr_of_DCD_loss()
  1155. X{
  1156. X    shm->rcmd = SHMR_NOTIFY_DCD_LOSS;
  1157. X    kill(xmtr_pid, SIGUSR2);
  1158. X}                             /* end of shmr_notify_xmtr_of_DCD_loss */
  1159. X
  1160. X/*+-------------------------------------------------------------------------
  1161. X    shmr_notify_zmodem_frame()
  1162. X--------------------------------------------------------------------------*/
  1163. Xvoid
  1164. Xshmr_notify_zmodem_frame()
  1165. X{
  1166. X    shm->rcmd = SHMR_NOTIFY_ZMODEM;    /* rcvr detected ZMODEM frame */
  1167. X    kill(xmtr_pid, SIGUSR2);
  1168. X}                             /* end of shmr_notify_zmodem_frame */
  1169. X
  1170. X/*+-------------------------------------------------------------------------
  1171. X    shmx_process_xmtr_SIGUSR2()
  1172. X--------------------------------------------------------------------------*/
  1173. Xvoid
  1174. Xshmx_process_xmtr_SIGUSR2()
  1175. X{
  1176. X    register rcmd;
  1177. X    register ri1, ri2;
  1178. X    int argc;
  1179. X    char *cptr;
  1180. X    char **argv;
  1181. X    ulong colors_save;
  1182. X    int lchar;
  1183. X    int success_flag;
  1184. X
  1185. X    rcmd = shm->rcmd;
  1186. X    shm->rcmd = 0;
  1187. X    ri1 = shm->ri1;
  1188. X    ri2 = shm->ri2;
  1189. X
  1190. X    switch (rcmd)
  1191. X    {
  1192. X        case SHMR_NOTIFY_DCD_LOSS:
  1193. X            lzero_length_read_detected();
  1194. X            break;
  1195. X
  1196. X        case SHMR_NOTIFY_ZMODEM:
  1197. X            kill_rcvr_process(SIGUSR1);
  1198. X            success_flag = 0;
  1199. X            while ((lchar = lgetc_timeout(100L)) >= 0)
  1200. X            {
  1201. X                fputc(lchar, se);
  1202. X                if (lchar == '\n')
  1203. X                {
  1204. X                    success_flag = 1;
  1205. X                    break;
  1206. X                }
  1207. X            }
  1208. X            if (!success_flag)
  1209. X                fputs("\r\n", se);
  1210. X            colors_save = colors_current;
  1211. X            setcolor(colors_notify);
  1212. X            fputs("[automatic rz]", se);
  1213. X            setcolor(colors_save);
  1214. X            fputs("\r\n", se);
  1215. X            argc = 1;
  1216. X            cptr = "rz";
  1217. X            argv = &cptr;
  1218. X            receive_files_from_remote(argc, argv);
  1219. X            start_rcvr_process(1);
  1220. X            break;
  1221. X    }
  1222. X
  1223. X}                             /* end of shmx_process_xmtr_SIGUSR2 */
  1224. X
  1225. X/*+-------------------------------------------------------------------------
  1226. X    shmr_process_rcvr_SIGUSR2()
  1227. X--------------------------------------------------------------------------*/
  1228. Xvoid
  1229. Xshmr_process_rcvr_SIGUSR2()
  1230. X{
  1231. X    register xcmd;
  1232. X    register xi1, xi2, xi3;
  1233. X    char xs1[SHM_STRLEN];
  1234. X
  1235. X    xcmd = shm->xcmd;
  1236. X    shm->xcmd = 0;
  1237. X    xi1 = shm->xi1;
  1238. X    xi2 = shm->xi2;
  1239. X    xi3 = shm->xi3;
  1240. X    strcpy(xs1, shm->xs1);
  1241. X
  1242. X    switch (xcmd)
  1243. X    {
  1244. X        case SHMX_MAKE_RCVR_SLEEP:
  1245. X            sleep(xi1);
  1246. X            break;
  1247. X
  1248. X        case SHMX_SET_RCVR_LOG:
  1249. X            if (rcvr_log)     /* if already logging */
  1250. X            {
  1251. X                if (!rcvr_log_raw)
  1252. X                    LOGPUTC('\n', rcvr_log_fp);
  1253. X                fclose(rcvr_log_fp);
  1254. X                rcvr_log = 0;
  1255. X            }
  1256. X            if (strlen(xs1) == 0)    /* if all we wanted was to stop log
  1257. X                                     * ... */
  1258. X                break;         /* ... then quit */
  1259. X            rcvr_log_gen_title = 1;
  1260. X            rcvr_log = 1;
  1261. X            rcvr_log_append = xi1;
  1262. X            rcvr_log_raw = xi2;
  1263. X            rcvr_log_flusheach = xi3;
  1264. X            strcpy(rcvr_log_file, xs1);
  1265. X            rcvr_log_open();
  1266. X            break;
  1267. X
  1268. X        case SHMX_UNPAUSE:
  1269. X            break;
  1270. X    }
  1271. X
  1272. X}                             /* end of shmr_process_rcvr_SIGUSR2 */
  1273. X
  1274. X/* end of ecushm.c */
  1275. X/* vi: set tabstop=4 shiftwidth=4: */
  1276. END_OF_FILE
  1277.   if test 10554 -ne `wc -c <'ecu330/ecushm.c'`; then
  1278.     echo shar: \"'ecu330/ecushm.c'\" unpacked with wrong size!
  1279.   fi
  1280.   # end of 'ecu330/ecushm.c'
  1281. fi
  1282. if test -f 'ecu330/gendial/template.c' -a "${1}" != "-c" ; then 
  1283.   echo shar: Will not clobber existing file \"'ecu330/gendial/template.c'\"
  1284. else
  1285.   echo shar: Extracting \"'ecu330/gendial/template.c'\" \(10468 characters\)
  1286.   sed "s/^X//" >'ecu330/gendial/template.c' <<'END_OF_FILE'
  1287. X
  1288. X/*+-------------------------------------------------------------------------
  1289. X    template.c - DCE-specific portion of generic SCO UUCP dialer
  1290. X    wht@n4hgf.atl.ga.us
  1291. X
  1292. X Necessary DCE switch setting or other configuration:
  1293. X   Switch foo off: enable onhook upon loss of DTR
  1294. X--------------------------------------------------------------------------*/
  1295. X/*+:EDITS:*/
  1296. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1297. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1298. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1299. X/*:02-02-1992-18:01-root@n4hgf-proper ordering of DCE_result entries */
  1300. X/*:01-26-1992-15:31-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
  1301. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1302. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1303. X
  1304. X#include "dialer.h"
  1305. X
  1306. X/*
  1307. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  1308. X *                    sees the transition; this value may be changed
  1309. X *                    as necessary before each call to lflash_DTR(),
  1310. X * but, generally, a constant value will do.
  1311. X */
  1312. Xlong DCE_DTR_low_msec = 500;
  1313. X
  1314. X/*
  1315. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  1316. X *                     DCE may be expected to be ready to be commanded
  1317. X */
  1318. Xlong DCE_DTR_high_msec = 500;
  1319. X
  1320. X/*
  1321. X * DCE_write_pace_msec - milliseconds to pause between each character
  1322. X *                       sent to the DCE (zero if streaming I/O is
  1323. X *                       permitted); this value may be changed as
  1324. X * necessary before each call to lwrite(), but, generally, a constant
  1325. X * value will do.  Note that this value is used to feed a value to Nap(),
  1326. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  1327. X * and .050 seconds on XENIX/86.
  1328. X */
  1329. Xlong DCE_write_pace_msec = 20;
  1330. X
  1331. X/*
  1332. X * DCE_name     - short name for DCE
  1333. X * DCE_revision - revision number for this module
  1334. X */
  1335. Xchar *DCE_name = "Frobozz 9600";
  1336. Xchar *DCE_revision = "1.10";
  1337. X
  1338. X/*
  1339. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  1340. X *                    and readying it for dial in access
  1341. X *                    (BXXX mask); use a value of zero if the speed
  1342. X *                    specified by the invoker is to be used.
  1343. X * This value is useful for DCEs such as the early Hayes 2400
  1344. X * which are so unfortunately compatible with their 1200 predecessor
  1345. X * that they refuse to answer at 2400 baud unless you last spoke to
  1346. X * them at that rate. For such bad boys, use B2400 below.
  1347. X */
  1348. Xint DCE_hangup_CBAUD = 0;
  1349. X
  1350. X/* int DCE_hangup_CBAUD = B2400; */
  1351. X
  1352. X/*
  1353. X * DCE_results - a table of DCE response strings and a token
  1354. X *               code for each; when you call lread() or lread_ignore(),
  1355. X *               if the read routine detects one of the strings,
  1356. X * the appropriate code is returned.  If no string matches, then
  1357. X * lread()/lread_ignore examines the DCE result string for a
  1358. X * numeric value; if one is found, the numeric value or'd with
  1359. X * 0x4000 is returned (in this way, e.g., you can read "modem
  1360. X * S registers."  If nothing agrees with this search, lread()
  1361. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  1362. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  1363. X * This module is the only consumer  of the codes, although they
  1364. X * are decoded by gendial.c's _lread().
  1365. X *
  1366. X * If one possible result is an "early substring" of another, like
  1367. X * "CONNECT" is of "CONNECT 1200", then put such results later in the
  1368. X * table than the larger result.
  1369. X *
  1370. X */
  1371. X#define rfConnect        0x00400000
  1372. X
  1373. X#define rOk                0
  1374. X#define rNoCarrier        1
  1375. X#define rError            2
  1376. X#define rNoDialTone        3
  1377. X#define rBusy            4
  1378. X#define rNoAnswer        5
  1379. X#define rRring            6
  1380. X#define rConnect300        (7 | rfConnect)
  1381. X#define rConnect1200    (8 | rfConnect)
  1382. X#define rConnect2400    (9 | rfConnect)
  1383. X
  1384. XDCE_RESULT DCE_results[] =
  1385. X{
  1386. X    {"OK", rOk,},
  1387. X    {"NO CARRIER", rNoCarrier,},
  1388. X    {"ERROR", rError},
  1389. X    {"NO DIALTONE", rNoDialTone,},
  1390. X    {"BUSY", rBusy},
  1391. X    {"NO ANSWER", rNoAnswer},
  1392. X    {"CONNECT 1200", rConnect120},
  1393. X    {"CONNECT 2400", rConnect2400},
  1394. X    {"CONNECT", rConnect300},
  1395. X    {(char *)0, -1}             /* end table */
  1396. X};
  1397. X
  1398. X/*+-------------------------------------------------------------------------
  1399. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  1400. X
  1401. X  DCE dependent function must validate baud rates supported by DCE
  1402. X  returns baud rate in struct termio c_cflag fashion
  1403. X  or terminates program with error
  1404. X--------------------------------------------------------------------------*/
  1405. Xint
  1406. XDCE_baud_to_CBAUD(baud)
  1407. Xunsigned int baud;
  1408. X{
  1409. X    switch (baud)
  1410. X    {
  1411. X        case 50:
  1412. X            return (B50);     /* delete the ones you dont handle */
  1413. X        case 75:
  1414. X            return (B75);
  1415. X        case 110:
  1416. X            return (B110);
  1417. X        case 134:
  1418. X            return (B134);
  1419. X        case 150:
  1420. X            return (B150);
  1421. X        case 300:
  1422. X            return (B300);
  1423. X        case 1200:
  1424. X            return (B1200);
  1425. X        case 2400:
  1426. X            return (B2400);
  1427. X        case 4800:
  1428. X            return (B4800);
  1429. X        case 9600:
  1430. X            return (B9600);
  1431. X
  1432. X#if defined(B19200)
  1433. X        case 19200:
  1434. X            return (B19200);
  1435. X#else
  1436. X#ifdef EXTA
  1437. X        case 19200:
  1438. X            return (EXTA);
  1439. X#endif
  1440. X#endif
  1441. X
  1442. X#if defined(B38400)
  1443. X        case 38400:
  1444. X            return (B38400);
  1445. X#else
  1446. X#ifdef EXTB
  1447. X        case 38400:
  1448. X            return (EXTB);
  1449. X#endif
  1450. X#endif
  1451. X
  1452. X    }
  1453. X    myexit(RC_FAIL | RCE_SPEED);
  1454. X#if defined(OPTIMIZE) || defined(__OPTIMIZE__)    /* don't complain */
  1455. X    return (0);                 /* keep gcc from complaining about no rtn at
  1456. X                              * end */
  1457. X#endif
  1458. X}                             /* end of DCE_baud_to_CBAUD */
  1459. X
  1460. X/*+-------------------------------------------------------------------------
  1461. X    DCE_hangup() - issue hangup command to DCE
  1462. X
  1463. XThis function should do whatever is necessary to ensure
  1464. X1) any active connection is terminated
  1465. X2) the DCE is ready to receive an incoming call if DTR is asserted
  1466. X3) the DCE will not accept an incoming call if DTR is false
  1467. X
  1468. XThe function should return when done.
  1469. X
  1470. XAny necessary switch setting or other configuration necessary for this
  1471. Xfunction to succeed should be documented at the top of the module.
  1472. X--------------------------------------------------------------------------*/
  1473. Xvoid
  1474. XDCE_hangup()
  1475. X{
  1476. X    DEBUG(3, "--> reseting %s\n", DCE_name);
  1477. X    lflash_DTR();
  1478. X
  1479. X}                             /* end of DCE_hangup */
  1480. X
  1481. X/*+-------------------------------------------------------------------------
  1482. X    DCE_dial(telno) - dial a remote DCE
  1483. X
  1484. XThis function should connect to the remote DCE and use any success
  1485. Xindication to modify the tty baud rate if necessary before returning.
  1486. X
  1487. XUpon successful connection, return 0.
  1488. X
  1489. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  1490. XRCE_XXX value from dialer.h.
  1491. X
  1492. Xlwrite() is used to write to the DCE.
  1493. X
  1494. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  1495. Xfrom calling lread() will result automatically in the proper error
  1496. Xtermination of the program.  Read timeouts from calling lread_ignore()
  1497. Xreturn -1; you handle the execption here.
  1498. X
  1499. XAny necessary coding of phone numbers, switch settings or other
  1500. Xconfiguration necessary for this function to succeed should be
  1501. Xdocumented at the top of the module.
  1502. X--------------------------------------------------------------------------*/
  1503. Xint
  1504. XDCE_dial(telno)
  1505. Xchar *telno;
  1506. X{
  1507. X    char cmd[80];
  1508. X
  1509. X/* preliminary setup */
  1510. X
  1511. X/* if root, let him see number, otherwise just say "remote system" */
  1512. X    DEBUG(1, "DIALING %s\n", (uid) ? "remote system" : telno);
  1513. X
  1514. X/* indicate non-root should not see DTE->DCE traffic */
  1515. X    secure = 1;
  1516. X
  1517. X/* issue the actual dialing command */
  1518. X
  1519. X/* indicate non-root can see DTE->DCE traffic */
  1520. X    secure = 0;
  1521. X
  1522. X    return (0);                 /* succeeded */
  1523. X
  1524. X}                             /* end of DCE_dial */
  1525. X
  1526. X/**********************************************************
  1527. X*  You probably do not need to modify the code below here *
  1528. X**********************************************************/
  1529. X
  1530. X/*+-------------------------------------------------------------------------
  1531. X    DCE_abort(sig) - dial attempt aborted
  1532. X
  1533. X sig =  0 if non-signal abort (read timeout, most likely)
  1534. X     != 0 if non-SIGALRM signal caught
  1535. X
  1536. X extern int dialing set  1 if dialing request was active,
  1537. X                    else 0 if hangup request was active
  1538. X
  1539. XThis is a chance for the DCE-specific code to do anything it
  1540. Xneeds to cl,ean up after a failure.  Note that if a dialing
  1541. Xcall fails, it is the responsibility of the higher-level
  1542. Xprogram calling the dialer to call it again with a hangup request, so
  1543. Xthis function is usually a no-op.
  1544. X--------------------------------------------------------------------------*/
  1545. Xvoid
  1546. XDCE_abort(sig)
  1547. Xint sig;
  1548. X{
  1549. X    DEBUG(10, "DCE_abort(%d);\n", sig);
  1550. X}                             /* end of DCE_abort */
  1551. X
  1552. X/*+-------------------------------------------------------------------------
  1553. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  1554. X
  1555. XThe independent portion of the dialer program calls this routine in
  1556. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  1557. XNormally, this function just passes it's argument to exit(), but
  1558. Xany necessary post-processing can be done.  The function must,
  1559. Xhowever, eventually call exit(exitcode);
  1560. X--------------------------------------------------------------------------*/
  1561. Xvoid
  1562. XDCE_exit(exitcode)
  1563. Xint exitcode;
  1564. X{
  1565. X    DEBUG(10, "DCE_exit(%d);\n", exitcode);
  1566. X    exit(exitcode);
  1567. X}                             /* end of DCE_exit */
  1568. X
  1569. X/*+-------------------------------------------------------------------------
  1570. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  1571. X
  1572. XThis hook gives DCE-specific code a chance to look over the entire
  1573. Xcommand line, such as for -z Telebit processing.
  1574. X
  1575. Xargc andf argv are the same values passed to main(),
  1576. X
  1577. Xoptind is the value of optind at the end of normal getopt processing.
  1578. X
  1579. Xunrecognized_switches is the count of switches not handled by main().
  1580. XSpecifically, -h and -x are standard switches.
  1581. X
  1582. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  1583. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  1584. Xthough, you can do anything you need to do here and exit the program.
  1585. X
  1586. XNote: only simple switches (with no argument) may be used with this
  1587. Xfacility if the functrion is to return,' since main()'s getopt() will
  1588. Xstop processing switches if it runs into an unrecognized switch with an
  1589. Xargument.
  1590. X
  1591. XIf the function returns a non-zero value, then the value will be passed
  1592. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  1593. Xof the format expected by dialer program callers, with RC_FAIL set as a
  1594. Xminimum.
  1595. X--------------------------------------------------------------------------*/
  1596. Xint
  1597. XDCE_argv_hook(argc, argv, optind, unrecognized_switches)
  1598. Xint argc;
  1599. Xchar **argv;
  1600. Xint optind;
  1601. Xint unrecognized_switches;
  1602. X{
  1603. X    if (unrecognized_switches)
  1604. X        return (RC_FAIL | RCE_ARGS);
  1605. X    return (0);
  1606. X}                             /* end of DCE_argv_hook */
  1607. X
  1608. X/* vi: set tabstop=4 shiftwidth=4: */
  1609. END_OF_FILE
  1610.   if test 10468 -ne `wc -c <'ecu330/gendial/template.c'`; then
  1611.     echo shar: \"'ecu330/gendial/template.c'\" unpacked with wrong size!
  1612.   fi
  1613.   # end of 'ecu330/gendial/template.c'
  1614. fi
  1615. if test -f 'ecu330/gint.c' -a "${1}" != "-c" ; then 
  1616.   echo shar: Will not clobber existing file \"'ecu330/gint.c'\"
  1617. else
  1618.   echo shar: Extracting \"'ecu330/gint.c'\" \(7568 characters\)
  1619.   sed "s/^X//" >'ecu330/gint.c' <<'END_OF_FILE'
  1620. X/*+-------------------------------------------------------------------------
  1621. X    gint.c - ecu get integer parameter functions
  1622. X    wht@n4hgf.atl.ga.us
  1623. X
  1624. X  Defined functions:
  1625. X    gcol_range(param,col1,col2)
  1626. X    gint(param,int_returned)
  1627. X    gint_base(param,value)
  1628. X    gint_constant(param,value)
  1629. X    gintop(param,intop)
  1630. X
  1631. X--------------------------------------------------------------------------*/
  1632. X/*+:EDITS:*/
  1633. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1634. X/*:12-20-1992-00:13-wht@n4hgf-add shift operators */
  1635. X/*:12-12-1992-13:39-wht@n4hgf-use relop.h for OP_ definitions */
  1636. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1637. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  1638. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1639. X/*:01-31-1991-16:50-wht@n4hgf-reinstate octal with 0o prefix */
  1640. X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
  1641. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1642. X
  1643. X#include "ecu.h"
  1644. X#include "ecuerror.h"
  1645. X#include "esd.h"
  1646. X#include "var.h"
  1647. X#include "relop.h"
  1648. X
  1649. X#define BASE_DEC    1
  1650. X#define BASE_OCT    2
  1651. X#define BASE_HEX      3
  1652. X
  1653. X/*+-------------------------------------------------------------------------
  1654. X    gint_constant(param,int_returned) - evaluate integer constant
  1655. X--------------------------------------------------------------------------*/
  1656. Xint
  1657. Xgint_constant(param, value)
  1658. XESD *param;
  1659. Xlong *value;
  1660. X{
  1661. X    register itmp;
  1662. X    int base = BASE_DEC;
  1663. X    int erc;
  1664. X    long new_value;
  1665. X
  1666. X    if (erc = skip_cmd_break(param))
  1667. X        return (erc);
  1668. X    esd_null_terminate(param);
  1669. X
  1670. X/* get integer from string */
  1671. X    if ((!strncmp(param->pb + param->index, "0x", 2)) ||
  1672. X        (!strncmp(param->pb + param->index, "0X", 2)))
  1673. X    {
  1674. X        base = BASE_HEX;
  1675. X        param->index += 2;
  1676. X    }
  1677. X    else if ((!strncmp(param->pb + param->index, "0o", 2)) ||
  1678. X        (!strncmp(param->pb + param->index, "0O", 2)))
  1679. X    {
  1680. X        base = BASE_OCT;
  1681. X        param->index += 2;
  1682. X    }
  1683. X
  1684. X    param->old_index = param->index;
  1685. X    switch (base)
  1686. X    {
  1687. X        case BASE_HEX:
  1688. X            sscanf(param->pb + param->index, "%lx", &new_value);
  1689. X            itmp = param->index + strspn(param->pb + param->index,
  1690. X                "0123456789ABCDEFabcdef");
  1691. X            erc = eInvalidHexNumber;
  1692. X            break;
  1693. X        case BASE_DEC:
  1694. X            sscanf(param->pb + param->index, "%ld", &new_value);
  1695. X            itmp = param->index + strspn(param->pb + param->index, "0123456789");
  1696. X            erc = eInvalidDecNumber;
  1697. X            break;
  1698. X        case BASE_OCT:
  1699. X            sscanf(param->pb + param->index, "%lo", &new_value);
  1700. X            itmp = param->index + strspn(param->pb + param->index, "01234567");
  1701. X            erc = eInvalidOctNumber;
  1702. X            break;
  1703. X        default:
  1704. X            return (eInternalLogicError);
  1705. X    }
  1706. X
  1707. X    param->index = itmp;
  1708. X    if (isalnum(*(param->pb + itmp)))
  1709. X        param->old_index = itmp;
  1710. X
  1711. X    if (param->old_index != param->index)
  1712. X    {
  1713. X        *value = new_value;
  1714. X        return (0);
  1715. X    }
  1716. X    return (erc);
  1717. X
  1718. X}                             /* end of gint_constant */
  1719. X
  1720. X/*+-------------------------------------------------------------------------
  1721. X    gint_base(param,value) - evaluate integer constant, variable or function
  1722. X--------------------------------------------------------------------------*/
  1723. Xint
  1724. Xgint_base(param, value)
  1725. XESD *param;
  1726. Xlong *value;
  1727. X{
  1728. X    register erc;
  1729. X    long *varptr;
  1730. X
  1731. X    if (erc = skip_cmd_break(param))
  1732. X        return (erc);
  1733. X
  1734. X    switch (param->pb[param->index])    /* look at first character */
  1735. X    {
  1736. X        case '$':             /* '$i...' variable reference? */
  1737. X            if (param->index >= param->cb - 2)
  1738. X                return (eSyntaxError);
  1739. X            param->old_index = ++param->index;
  1740. X            if (to_lower(param->pb[param->index++]) != 'i')
  1741. X                return (eIllegalVarType);
  1742. X            if (erc = get_ivptr(param, &varptr, 0))
  1743. X                return (erc);
  1744. X            *value = *varptr;
  1745. X            return (0);
  1746. X
  1747. X        case '%':             /* '%...' function reference? */
  1748. X            param->index++;
  1749. X            if (erc = feval_int(param, value))
  1750. X                return (erc);
  1751. X            return (0);
  1752. X
  1753. X        default:
  1754. X            break;
  1755. X    }                         /* end of switch statement */
  1756. X
  1757. X/* we did not catch any special cases with the switch statement must
  1758. Xbe numeric integer */
  1759. X
  1760. X    return (gint_constant(param, value));
  1761. X
  1762. X}                             /* end of gint_base() */
  1763. X
  1764. X/*+-------------------------------------------------------------------------
  1765. X    gintop(param,intop) - evaluate integer operator
  1766. X--------------------------------------------------------------------------*/
  1767. Xint
  1768. Xgintop(param, intop)
  1769. XESD *param;
  1770. Xint *intop;
  1771. X{
  1772. X    register erc;
  1773. X
  1774. X    if (erc = skip_cmd_break(param))
  1775. X        return (erc);
  1776. X    switch (param->pb[param->index])
  1777. X    {
  1778. X        case '+':
  1779. X            param->index++;
  1780. X            *intop = OP_ADD;
  1781. X            break;
  1782. X
  1783. X        case '-':
  1784. X            param->index++;
  1785. X            *intop = OP_SUB;
  1786. X            break;
  1787. X
  1788. X        case '*':
  1789. X            param->index++;
  1790. X            *intop = OP_MUL;
  1791. X            break;
  1792. X
  1793. X        case '/':
  1794. X            param->index++;
  1795. X            *intop = OP_DIV;
  1796. X            break;
  1797. X
  1798. X        case '|':
  1799. X            if (*(param->pb + param->index + 1) == '|')
  1800. X                return (eInvalidIntOp);
  1801. X            param->index++;
  1802. X            *intop = OP_OR;
  1803. X            break;
  1804. X
  1805. X        case '@':
  1806. X            param->index++;
  1807. X            *intop = OP_MOD;
  1808. X            break;
  1809. X
  1810. X        case '^':
  1811. X            param->index++;
  1812. X            *intop = OP_XOR;
  1813. X            break;
  1814. X
  1815. X        case '&':
  1816. X            if (*(param->pb + param->index + 1) == '&')
  1817. X                return (eInvalidIntOp);
  1818. X            param->index++;
  1819. X            *intop = OP_AND;
  1820. X            break;
  1821. X
  1822. X        case '<':
  1823. X            if (*(param->pb + param->index + 1) != '<')
  1824. X                return (eInvalidIntOp);
  1825. X            param->index += 2;
  1826. X            *intop = OP_SHL;
  1827. X            break;
  1828. X
  1829. X        case '>':
  1830. X            if (*(param->pb + param->index + 1) != '>')
  1831. X                return (eInvalidIntOp);
  1832. X            param->index += 2;
  1833. X            *intop = OP_SHR;
  1834. X            break;
  1835. X
  1836. X        default:
  1837. X            return (eInvalidIntOp);
  1838. X    }                         /* end of switch statement */
  1839. X
  1840. X    return (0);
  1841. X
  1842. X}                             /* end of gintop() */
  1843. X
  1844. X/*+-------------------------------------------------------------------------
  1845. X    gint(param,int_returned) - evaluate integer expression
  1846. X--------------------------------------------------------------------------*/
  1847. Xint
  1848. Xgint(param, int_returned)
  1849. XESD *param;
  1850. Xlong *int_returned;
  1851. X{
  1852. X    register erc;
  1853. X    long int1;
  1854. X    long int_accum = 0;
  1855. X    int intop;
  1856. X    int unary_minus = 0;
  1857. X
  1858. X    if (erc = skip_cmd_break(param))
  1859. X        return (erc);
  1860. X    if (param->pb[param->index] == '-')
  1861. X        unary_minus++, param->index++;
  1862. X
  1863. X    if (erc = gint_base(param, &int1))
  1864. X        return (erc);
  1865. X    int_accum = (unary_minus) ? -int1 : int1;
  1866. X
  1867. X    while ((erc = gintop(param, &intop)) == 0)
  1868. X    {
  1869. X        if (erc = gint_base(param, &int1))
  1870. X            return (erc);
  1871. X        switch (intop)
  1872. X        {
  1873. X            case OP_ADD:
  1874. X                int_accum += int1;
  1875. X                break;
  1876. X            case OP_SUB:
  1877. X                int_accum -= int1;
  1878. X                break;
  1879. X            case OP_MUL:
  1880. X                int_accum *= int1;
  1881. X                break;
  1882. X            case OP_DIV:
  1883. X                int_accum /= int1;
  1884. X                break;
  1885. X            case OP_MOD:
  1886. X                int_accum %= int1;
  1887. X                break;
  1888. X            case OP_XOR:
  1889. X                int_accum ^= (unsigned)int1;
  1890. X                break;
  1891. X            case OP_AND:
  1892. X                int_accum &= (unsigned)int1;
  1893. X                break;
  1894. X            case OP_OR:
  1895. X                int_accum |= (unsigned)int1;
  1896. X                break;
  1897. X            case OP_SHL:
  1898. X                int_accum <<= (unsigned)int1;
  1899. X                break;
  1900. X            case OP_SHR:
  1901. X                int_accum >>= (unsigned)int1;
  1902. X                break;
  1903. X            default:
  1904. X                return (eInvalidIntOp);
  1905. X        }
  1906. X    }
  1907. X    param->index = param->old_index;
  1908. X
  1909. X    *int_returned = int_accum;
  1910. X    return (0);
  1911. X}                             /* end of gint() */
  1912. X
  1913. X/*+-------------------------------------------------------------------------
  1914. X    col_range(param,col1,col2) - get a column range
  1915. X:$i0[-$i1]
  1916. Xargument may be integer constant, function or variable, but not expression
  1917. X--------------------------------------------------------------------------*/
  1918. Xint
  1919. Xgcol_range(param, col1, col2)
  1920. XESD *param;
  1921. Xulong *col1;
  1922. Xulong *col2;
  1923. X{
  1924. X    register erc;
  1925. X
  1926. X    if (skip_cmd_char(param, ':') == 0)
  1927. X    {
  1928. X        if (erc = gint_base(param, col1))
  1929. X            return (erc);
  1930. X
  1931. X        if (skip_cmd_char(param, '-') == 0)    /* if hyphen found, range */
  1932. X        {
  1933. X            if (erc = gint_base(param, col2))
  1934. X                return (erc);
  1935. X        }
  1936. X        else
  1937. X            *col2 = *col1;     /* otherwise, first and last columns same */
  1938. X
  1939. X        if (*col1 > *col2)
  1940. X        {
  1941. X            pputs("Invalid column range: column 1 greater than column 2\n");
  1942. X            return (eFATAL_ALREADY);
  1943. X        }
  1944. X    }
  1945. X    else
  1946. X        erc = eBadParameter;
  1947. X
  1948. X    return (erc);
  1949. X}                             /* end of gcol_range() */
  1950. X
  1951. X/* vi: set tabstop=4 shiftwidth=4: */
  1952. X/* end of gint.c */
  1953. END_OF_FILE
  1954.   if test 7568 -ne `wc -c <'ecu330/gint.c'`; then
  1955.     echo shar: \"'ecu330/gint.c'\" unpacked with wrong size!
  1956.   fi
  1957.   # end of 'ecu330/gint.c'
  1958. fi
  1959. if test -f 'ecu330/help/helpgen.c' -a "${1}" != "-c" ; then 
  1960.   echo shar: Will not clobber existing file \"'ecu330/help/helpgen.c'\"
  1961. else
  1962.   echo shar: Extracting \"'ecu330/help/helpgen.c'\" \(10358 characters\)
  1963.   sed "s/^X//" >'ecu330/help/helpgen.c' <<'END_OF_FILE'
  1964. X/*+-------------------------------------------------------------------------
  1965. X    helpgen.c -- ecu command help file maker
  1966. X    wht@n4hgf.atl.ga.us
  1967. X
  1968. X  Defined functions:
  1969. X    build_ecudoc()
  1970. X    build_ecuhelp()
  1971. X    main(argc,argv,envp)
  1972. X    search_cmd_list(cmd)
  1973. X    show_cmds()
  1974. X    test_help()
  1975. X    usage()
  1976. X
  1977. X--------------------------------------------------------------------------*/
  1978. X/*+:EDITS:*/
  1979. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1980. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1981. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  1982. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1983. X/*:07-12-1991-14:50-wht@n4hgf-remove obsolete ecuhelp.txt generator */
  1984. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1985. X
  1986. X#include <stdio.h>
  1987. X#include <ctype.h>
  1988. X
  1989. X#include "../ecu_types.h"
  1990. X#include "../ecutermio.h"
  1991. X
  1992. X#define DECLARE_P_CMD
  1993. X#define HELPGEN
  1994. Xtypedef int (*PFI) ();         /* pointer to function returning integer */
  1995. X#include "../ecucmd.h"
  1996. X
  1997. X#include "../esd.h"
  1998. X
  1999. X#define PSRC    "ecuhelp.src"
  2000. X#define PDAT    "ecuhelp.data"
  2001. X#define PDOC    "ecuhelp.doc"
  2002. X
  2003. Xlong start_pos[TOKEN_QUAN];
  2004. Xint token_line[TOKEN_QUAN];
  2005. XFILE *fpsrc;                 /* help source file */
  2006. XFILE *fpdat;                 /* help data file */
  2007. XFILE *fpdoc;                 /* help doc file */
  2008. XFILE *fptxt;                 /* help nroff file */
  2009. XP_CMD *pcmd;
  2010. Xint src_line = 0;
  2011. Xchar buf[128];
  2012. X
  2013. X/*+-------------------------------------------------------------------------
  2014. X    usage()
  2015. X--------------------------------------------------------------------------*/
  2016. Xusage()
  2017. X{
  2018. X    fprintf(stderr, "usage: helpgen [-b] [-d] [-s] [-t]\n");
  2019. X    fprintf(stderr, " -b build %s from %s\n", PDAT, PSRC);
  2020. X    fprintf(stderr, " -d build %s from %s\n", PDOC, PDAT);
  2021. X    fprintf(stderr, " -s show list of commands\n");
  2022. X    fprintf(stderr, " -t test help\n");
  2023. X    fprintf(stderr, "At least one switch must be issued.  They are executed\n");
  2024. X    fprintf(stderr, "in the order shown on the usage line.\n");
  2025. X    exit(1);
  2026. X}                             /* end of usage */
  2027. X
  2028. X/*+-------------------------------------------------------------------------
  2029. X    search_cmd_list(cmd)
  2030. X--------------------------------------------------------------------------*/
  2031. XP_CMD *
  2032. Xsearch_cmd_list(cmd)
  2033. Xregister char *cmd;
  2034. X{
  2035. X    register P_CMD *cmd_list = icmd_cmds;
  2036. X
  2037. X    while (cmd_list->token != -1)
  2038. X    {
  2039. X        if (strcmp(cmd_list->cmd, cmd) == 0)
  2040. X            break;
  2041. X        cmd_list++;
  2042. X    }
  2043. X    if (cmd_list->token == -1)
  2044. X        return ((P_CMD *) 0);
  2045. X    else
  2046. X        return (cmd_list);
  2047. X
  2048. X}                             /* end of search_cmd_list */
  2049. X
  2050. X/*+-------------------------------------------------------------------------
  2051. X    show_cmds()
  2052. Xcommands with null descriptions are "undocumented"
  2053. X--------------------------------------------------------------------------*/
  2054. Xvoid
  2055. Xshow_cmds()
  2056. X{
  2057. X    register int itmp;
  2058. X    register P_CMD *this = icmd_cmds;
  2059. X    register int longest_cmd = 0;
  2060. X    register int longest_descr = 0;
  2061. X    register int nl_flag = 0;
  2062. X    char s80[80];
  2063. X    P_CMD *longest_cmd_p = 0;
  2064. X    P_CMD *longest_descr_p = 0;
  2065. X
  2066. X    while (this->token != -1)
  2067. X    {
  2068. X        if (!*this->descr)
  2069. X        {
  2070. X            this++;
  2071. X            continue;
  2072. X        }
  2073. X        itmp = strlen(this->cmd);
  2074. X        if (itmp > longest_cmd)
  2075. X        {
  2076. X            longest_cmd = itmp;
  2077. X            longest_cmd_p = this;
  2078. X        }
  2079. X        itmp = strlen(this->descr);
  2080. X        if (itmp > longest_descr)
  2081. X        {
  2082. X            longest_descr = itmp;
  2083. X            longest_descr_p = this;
  2084. X        }
  2085. X        this++;
  2086. X    }
  2087. X    this = icmd_cmds;
  2088. X    while (this->token != -1)
  2089. X    {
  2090. X        if ((!this->min_ch) || (!*this->descr))
  2091. X        {
  2092. X            this++;
  2093. X            continue;
  2094. X        }
  2095. X        strcpy(s80, this->cmd);
  2096. X        pad_zstr_to_len(s80, longest_cmd + 2);
  2097. X        for (itmp = 0; itmp < this->min_ch; itmp++)
  2098. X            s80[itmp] = to_upper(s80[itmp]);
  2099. X        fputs(s80, stderr);
  2100. X
  2101. X        strcpy(s80, this->descr);
  2102. X        pad_zstr_to_len(s80, longest_descr + 1);
  2103. X        fputs(s80, stderr);
  2104. X
  2105. X        if (nl_flag)
  2106. X            fputs("\r\n", stderr);
  2107. X        else
  2108. X            fputs("| ", stderr);
  2109. X        nl_flag = (nl_flag) ? 0 : 1;
  2110. X
  2111. X        this++;
  2112. X    }
  2113. X    if (nl_flag)
  2114. X        fputs("\r\n", stderr);
  2115. X
  2116. X    itmp = longest_cmd + longest_descr + 5;
  2117. X    sprintf(s80, "recwidth = %d\r\n", itmp);
  2118. X    fprintf(stderr, s80);
  2119. X    this = longest_cmd_p;
  2120. X    sprintf(s80, "longest cmd: %s: %s\r\n", this->cmd, this->descr);
  2121. X    fprintf(stderr, s80);
  2122. X    this = longest_descr_p;
  2123. X    sprintf(s80, "longest dsc: %s: %s\r\n", this->cmd, this->descr);
  2124. X    fprintf(stderr, s80);
  2125. X
  2126. X}                             /* end of show_cmds */
  2127. X
  2128. X/*+-------------------------------------------------------------------------
  2129. X    build_ecuhelp()
  2130. X--------------------------------------------------------------------------*/
  2131. Xvoid
  2132. Xbuild_ecuhelp()
  2133. X{
  2134. X    register int itmp;
  2135. X    register char *cptr;
  2136. X    P_CMD *this;
  2137. X
  2138. X    printf("\nBuilding %s\n", PDAT);
  2139. X
  2140. X/* use proc cmd entry for flag */
  2141. X    this = icmd_cmds;
  2142. X    while (this->token != -1)
  2143. X    {
  2144. X        this->proc = (PFI) 0;
  2145. X        this++;
  2146. X    }
  2147. X
  2148. X    for (itmp = 0; itmp < TOKEN_QUAN; itmp++)
  2149. X    {
  2150. X        start_pos[itmp] = 0L;
  2151. X        token_line[itmp] = 0;
  2152. X    }
  2153. X
  2154. X    if ((fpsrc = fopen(PSRC, "r")) == NULL)
  2155. X    {
  2156. X        perror(PSRC);
  2157. X        exit(1);
  2158. X    }
  2159. X
  2160. X    if ((fpdat = fopen(PDAT, "w")) == NULL)
  2161. X    {
  2162. X        perror(PDAT);
  2163. X        exit(1);
  2164. X    }
  2165. X
  2166. X    fwrite((char *)start_pos, sizeof(long),    /* write null table */
  2167. X        TOKEN_QUAN, fpdat);
  2168. X
  2169. X    while (fgets(buf, sizeof(buf), fpsrc) != NULL)
  2170. X    {
  2171. X        src_line++;
  2172. X        itmp = strlen(buf);
  2173. X        buf[--itmp] = 0;     /* kill trailing nl */
  2174. X        if (buf[0] == '#')     /* ignore comments */
  2175. X            continue;
  2176. X        if (buf[0] == '%')     /* command indication */
  2177. X        {
  2178. X          SEARCH_CMD_LIST:
  2179. X            if (!(this = search_cmd_list(&buf[1])))
  2180. X            {
  2181. X#ifdef notdef                 /* primarily because of 'eto' and 'fasi' */
  2182. X                printf("line %d: '%s' not in command table\n",
  2183. X                    src_line, &buf[1]);
  2184. X#endif
  2185. X                while (fgets(buf, sizeof(buf), fpsrc) != NULL)
  2186. X                {
  2187. X                    src_line++;
  2188. X                    itmp = strlen(buf);
  2189. X                    buf[--itmp] = 0;    /* kill trailing nl */
  2190. X                    if (buf[0] == '%')    /* command indication */
  2191. X                        goto SEARCH_CMD_LIST;
  2192. X                }
  2193. X                break;
  2194. X            }
  2195. X            if (start_pos[this->token])
  2196. X            {
  2197. X                printf("line %d: '%s' already found on line %d\n",
  2198. X                    src_line, &buf[1], token_line[this->token]);
  2199. X                exit(1);
  2200. X            }
  2201. X            fputs("\n", fpdat);    /* terminate previous command description */
  2202. X            start_pos[this->token] = ftell(fpdat);
  2203. X            token_line[this->token] = src_line;
  2204. X            fputs("   ", fpdat);
  2205. X            cptr = &buf[1];     /* command text */
  2206. X            itmp = 0;
  2207. X            this->proc = (PFI) 1;    /* indicate we save command info */
  2208. X            while (*cptr)     /* show cmd and min chars required */
  2209. X            {
  2210. X                if (itmp < this->min_ch)
  2211. X                    fputc(to_upper(*cptr++), fpdat);
  2212. X                else
  2213. X                    fputc(to_lower(*cptr++), fpdat);
  2214. X                itmp++;
  2215. X            }
  2216. X            if (*this->descr)/* if description present */
  2217. X                fprintf(fpdat, " : %s\n \n", this->descr);
  2218. X            else
  2219. X                fputs("\n \n", fpdat);
  2220. X            continue;
  2221. X        }
  2222. X        fprintf(fpdat, " %s\n", buf);
  2223. X    }
  2224. X
  2225. X    fseek(fpdat, 0L, 0);     /* back to position table */
  2226. X    fwrite((char *)start_pos, sizeof(long),    /* write actual table */
  2227. X        TOKEN_QUAN, fpdat);
  2228. X    fclose(fpsrc);
  2229. X    fputs("\n", fpdat);         /* terminate last command */
  2230. X    fclose(fpdat);
  2231. X
  2232. X/* say which commands weren't in the help source */
  2233. X    this = icmd_cmds;
  2234. X    while (this->token != -1)
  2235. X    {
  2236. X        if (this->min_ch && !this->proc)
  2237. X            fprintf(stderr, "'%s' not in help source\n", this->cmd);
  2238. X        this++;
  2239. X    }
  2240. X
  2241. X}                             /* end of build_ecuhelp */
  2242. X
  2243. X/*+-------------------------------------------------------------------------
  2244. X    build_ecudoc()
  2245. X--------------------------------------------------------------------------*/
  2246. Xvoid
  2247. Xbuild_ecudoc()
  2248. X{
  2249. X    register int itmp;
  2250. X
  2251. X    printf("\nBuilding %s\n", PDOC);
  2252. X    if ((fpdat = fopen(PDAT, "r")) == NULL)
  2253. X    {
  2254. X        perror(PDAT);
  2255. X        exit(1);
  2256. X    }
  2257. X    if ((fpdoc = fopen(PDOC, "w")) == NULL)
  2258. X    {
  2259. X        perror(PDOC);
  2260. X        exit(1);
  2261. X    }
  2262. X    fprintf(fpdoc,
  2263. X        "\n     ECU  Command  Help  Documentation  (PRELIMINARY)\n\n");
  2264. X    fprintf(fpdoc,
  2265. X        "Commands are accessed by pressing the HOME key followed by one\n");
  2266. X    fprintf(fpdoc,
  2267. X        "of the following commands (capitalized portions are sufficient\n");
  2268. X    fprintf(fpdoc,
  2269. X        "to invoke the command):\n");
  2270. X    fprintf(fpdoc, "\n");
  2271. X    fprintf(fpdoc,
  2272. X        "---------------------------------------------------------------------\n");
  2273. X    fread((char *)start_pos, sizeof(long), TOKEN_QUAN, fpdat);
  2274. X
  2275. X    pcmd = icmd_cmds;
  2276. X    while (pcmd->token != -1)
  2277. X    {
  2278. X        if (!pcmd->token)
  2279. X        {
  2280. X            pcmd++;
  2281. X            continue;
  2282. X        }
  2283. X        if (pcmd->min_ch && !start_pos[pcmd->token])
  2284. X        {
  2285. X            printf("no help available for '%s'\n", pcmd->cmd);
  2286. X            pcmd++;
  2287. X            continue;
  2288. X        }
  2289. X        fseek(fpdat, start_pos[pcmd->token], 0);
  2290. X        while (fgets(buf, sizeof(buf), fpdat) != NULL)
  2291. X        {
  2292. X            itmp = strlen(buf);
  2293. X            buf[--itmp] = 0;
  2294. X            if (itmp == 0)
  2295. X                break;
  2296. X            fprintf(fpdoc, "%s\n", buf);
  2297. X        }
  2298. X        fprintf(fpdoc,
  2299. X            "---------------------------------------------------------------------\n");
  2300. X        pcmd++;
  2301. X    }
  2302. X    fclose(fpdat);
  2303. X    fclose(fpdoc);
  2304. X}                             /* end of build_ecudoc */
  2305. X
  2306. X/*+-------------------------------------------------------------------------
  2307. X    test_help()
  2308. X--------------------------------------------------------------------------*/
  2309. Xvoid
  2310. Xtest_help()
  2311. X{
  2312. X    register int itmp;
  2313. X
  2314. X/* test code */
  2315. X    printf("\nNow to test\n");
  2316. X    if ((fpdat = fopen(PDAT, "r")) == NULL)
  2317. X    {
  2318. X        perror(PDAT);
  2319. X        exit(1);
  2320. X    }
  2321. X    fread((char *)start_pos, sizeof(long), TOKEN_QUAN, fpdat);
  2322. X
  2323. X    while (1)
  2324. X    {
  2325. X        printf("\ncommand: ");
  2326. X        fgets(buf, sizeof(buf), stdin);
  2327. X        itmp = strlen(buf);
  2328. X        buf[--itmp] = 0;
  2329. X        if (itmp == 0)
  2330. X            break;
  2331. X        if (!(pcmd = search_cmd_list(buf)))
  2332. X        {
  2333. X            printf("'%s' not found in ecu cmd table\n", buf);
  2334. X            continue;
  2335. X        }
  2336. X        if (pcmd->min_ch && !start_pos[pcmd->token])
  2337. X        {
  2338. X            printf("no help available for '%s'\n", buf);
  2339. X            continue;
  2340. X        }
  2341. X        fseek(fpdat, start_pos[pcmd->token], 0);
  2342. X        while (fgets(buf, sizeof(buf), fpdat) != NULL)
  2343. X        {
  2344. X            itmp = strlen(buf);
  2345. X            buf[--itmp] = 0;
  2346. X            if (itmp == 0)
  2347. X                break;
  2348. X            printf("%s\n", buf);
  2349. X        }
  2350. X    }
  2351. X}                             /* end of test_help */
  2352. X
  2353. X/*+-------------------------------------------------------------------------
  2354. X    main(argc,argv,envp)
  2355. X--------------------------------------------------------------------------*/
  2356. Xmain(argc, argv, envp)
  2357. Xint argc;
  2358. Xchar **argv;
  2359. Xchar **envp;
  2360. X{
  2361. X    register int itmp;
  2362. X    int iargv;
  2363. X    int b_flag = 0;
  2364. X    int s_flag = 0;
  2365. X    int t_flag = 0;
  2366. X    int f_flag = 0;
  2367. X    int d_flag = 0;
  2368. X
  2369. X    setbuf(stdout, NULL);
  2370. X    setbuf(stderr, NULL);
  2371. X
  2372. X    if (argc < 1)
  2373. X        usage();
  2374. X    for (iargv = 1; iargv < argc; iargv++)
  2375. X    {
  2376. X        if (argv[iargv][0] == '-')
  2377. X        {
  2378. X            switch (itmp = (argv[iargv][1]))
  2379. X            {
  2380. X                case 'b':
  2381. X                    b_flag = 1;
  2382. X                    break;
  2383. X                case 's':
  2384. X                    s_flag = 1;
  2385. X                    break;
  2386. X                case 't':
  2387. X                    t_flag = 1;
  2388. X                    break;
  2389. X                case 'd':
  2390. X                    d_flag = 1;
  2391. X                    break;
  2392. X                default:
  2393. X                    usage();
  2394. X                    break;
  2395. X            }
  2396. X        }
  2397. X        else
  2398. X            usage();
  2399. X    }
  2400. X    if (!b_flag && !s_flag && !t_flag && !d_flag && !f_flag)
  2401. X        usage();
  2402. X
  2403. X    if (b_flag)
  2404. X        build_ecuhelp();
  2405. X    if (d_flag)
  2406. X        build_ecudoc();
  2407. X    if (s_flag)
  2408. X        show_cmds();
  2409. X    if (t_flag)
  2410. X        test_help();
  2411. X
  2412. X    exit(0);
  2413. X}                             /* end of main */
  2414. X/* end of helpgen.c */
  2415. X/* vi: set tabstop=4 shiftwidth=4: */
  2416. END_OF_FILE
  2417.   if test 10358 -ne `wc -c <'ecu330/help/helpgen.c'`; then
  2418.     echo shar: \"'ecu330/help/helpgen.c'\" unpacked with wrong size!
  2419.   fi
  2420.   # end of 'ecu330/help/helpgen.c'
  2421. fi
  2422. echo shar: End of archive 30 \(of 37\).
  2423. cp /dev/null ark30isdone
  2424. MISSING=""
  2425. 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
  2426.     if test ! -f ark${I}isdone ; then
  2427.     MISSING="${MISSING} ${I}"
  2428.     fi
  2429. done
  2430. if test "${MISSING}" = "" ; then
  2431.     echo You have unpacked all 37 archives.
  2432.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2433. else
  2434.     echo You still must unpack the following archives:
  2435.     echo "        " ${MISSING}
  2436. fi
  2437. exit 0
  2438. exit 0 # Just in case...
  2439.