home *** CD-ROM | disk | FTP | other *** search
- From: wht@n4hgf.atl.ga.us (Warren Tucker)
- Newsgroups: comp.sources.misc
- Subject: v42i128: ecu - ECU Asynchronous Communications v3.30, Part30/37
- Date: 25 May 1994 14:59:03 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2s0am7$9tt@sparky.sterling.com>
- X-Md4-Signature: f43479e522fa9438ee28e663771ce9e6
-
- Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
- Posting-number: Volume 42, Issue 128
- Archive-name: ecu/part30
- Environment: SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2
- Supersedes: ecu: Volume 32, Issue 36-75
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: ecu330/doc/_p_sfunc.txt ecu330/ecu.h ecu330/ecushm.c
- # ecu330/gendial/template.c ecu330/gint.c ecu330/help/helpgen.c
- # Wrapped by kent@sparky on Mon May 23 13:41:02 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 30 (of 37)."'
- if test -f 'ecu330/doc/_p_sfunc.txt' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/doc/_p_sfunc.txt'\"
- else
- echo shar: Extracting \"'ecu330/doc/_p_sfunc.txt'\" \(10113 characters\)
- sed "s/^X//" >'ecu330/doc/_p_sfunc.txt' <<'END_OF_FILE'
- X.*s 1 "String Functions"
- X
- X.*s 2 "%argv"
- X
- Xusage: %argv(int0)
- X
- XThis function returns the string value of an argument passed
- Xto the procedure by the 'do' command. Argument 0 is the
- Xname of the procedure itself.
- XThe integer function %argc may be used to determine the
- Xnumber of arguments passed to the procedure. Specifying
- Xan argument number greater than the number of arguments
- Xpassed returns a null string (if procedure tracing is enabled
- Xwith the 'ptrace' comand, a warning will be displayed
- Xin this case).
- X.DS I
- XExample:
- X invocation from shell:
- X ecu -p test Quick Brown Fox
- X
- X invocation from interactive command line:
- X do test Quick Brown Fox
- X
- X invocation from procedure:
- X do 'test' 'Quick' 'Brown' 'Fox'
- X
- X results in:
- X %argv(0) = 'test'
- X %argv(1) = 'Quick'
- X %argv(2) = 'Brown'
- X %argv(3) = 'Fox'
- X %argv(4) = ''
- X.DE
- X
- X.B NOTE:
- Xthe interactive
- X.B dial
- Xcommand, the dialing directory menu and the initial setup menu
- Xall can automatically execute a procedure which matches
- Xa dialed
- X.B
- Xlogical telephone number.
- X.R
- XThere two arguments passed to these procedures, %argv(0) being
- Xthe procedure name as always. %argv(1) is set according to the following
- Xtable:
- X.DS I
- X invoker %argv(1)
- X------------------- -------------
- Xinitial setup menu !INITIAL
- Xinteractive dial !INTERACTIVE
- Xdialing menu !MENU
- X.DE
- XThus it is possible for the invoked procedure
- Xto determine that it has been automatically executed
- Xby testing %argv(1) for an exclamation point, or possibly
- Xthe entire argument.
- X
- X.*s 2 "%basename"
- X
- XUsage: %basename(str0,str1)
- X
- XThis function is similar to the UNIX basename(1) utility in
- Xthat it returns a filename minus a supplied suffix, if it is present.
- XUnlike the UNIX basename(C) program, %basename does not remove
- Xthe directory part of the filename.
- XSee also
- X.B %dirpart
- Xand
- X.B %filepart .
- X
- X.DS L
- XExamples:
- X
- X %basename('/u1/src/ecu/ecu.c','.c') = /u1/src/ecu/ecu
- X %basename('ecu.c','.c') = ecu
- X %basename('ecu.c','.x') = ecu.c
- X.DE
- X
- X.*s 2 "%cgetc"
- X
- Xusage: %cgetc
- X
- XThis function reads one character from the console keyboard
- Xand returns it. The character is not echoed.
- X
- X.*s 2 "%cgets"
- X
- Xusage: %cgets
- X
- XThis function reads a string from the console keyboard
- Xand returns it. Each character is echoed as it is typed
- Xand the user's normal erase and kill character is available
- Xto edit the input before terminating the read with ENTER.
- X
- X.*s 2 "%chr"
- X
- Xusage: %chr(int0)
- X
- XThis function returns the character value whose ASCII value
- Xis supplied in int0.
- X
- X.DS L
- XExample:
- X
- X set $s0 = %chr(4) places a ^D (EOT) character into $s0
- X.DE
- X
- X.*s 2 "%date"
- X
- Xusage: %date
- X
- XThis function returns the current date in the form 'mm-dd-yyyy'
- Xin the local time zone (daylight time if it applies).
- X
- X.*s 2 "%datez"
- X
- Xusage: %datez
- X
- XThis function returns the current date in the form 'mm-dd-yyyy'
- Xin the UTC (Z) time zone.
- X
- X.*s 2 "%day"
- X
- Xusage: %day
- X
- XThis function returns the current day of the week as a three character
- Xabbreviation: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
- Xin the local time zone (daylight time if it applies).
- X
- X.*s 2 "%dayz"
- X
- Xusage: %dayz
- X
- XThis function returns the current day of the week as a three character
- Xabbreviation: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
- Xin the UTC (Z) time zone.
- X
- X.*s 2 "%dir"
- X
- Xusage: %dir
- X
- XThis function returns the
- Xfull pathname of the current working directory.
- X
- X.*s 2 "%dirpart"
- X
- Xusage: %dirpart(str0)
- X
- XThis function returns the
- Xdirectory portion of the pathname supplied in str0.
- XSee also
- X.B %basename
- Xand
- X.B %filepart .
- X
- X
- X.DS L
- XExamples:
- X
- X%dirpart('/u1/src/src/foo.c') = "/u1/src/src"
- X%dirpart('foo.c') = "foo.c"
- X%dirpart('/usr') = ""
- X.DE
- X
- X.*s 2 "%edate"
- X
- Xusage: %edate(int0)
- X
- XThe value in int0 is expected to be a number of seconds since January 1,
- X1970 00:00 UTC (Universal Coordinated Time) as returned by
- Xthe integer functions %fatime and %fmtime.
- XThis function converts the value into a string representing the
- Xequivalent local time in the form 'mm-dd-yyyy hh:mm:ss'.
- X.DS L
- XExample:
- X
- Xset $i0=%fmtime('/xenix')
- X$i00 = 601178971 (0x23d5435b,04365241533)
- X
- Xset $s0=%edate($i0)
- X$s00 = '01-18-1989 21:09:31'
- X.DE
- X
- X.*s 2 "%envvar"
- X
- Xusage: %envvar()
- X
- XThis function returns the string value of an environment
- Xvariable.
- X
- X.DS L
- XExample:
- X
- X set $s0=%envvar('HOME') might set $s0 '/usr/user'
- X.DE
- X.DF L
- XTypical Environment Variables:
- X
- X HOME pathname of home directory
- X EDITOR user's preferred editor
- X PATH program execution searchlist
- X TERM terminal type
- X SHELL user's preferred shell
- X MAIL user's mail box file
- X ECUPROMPT ECU interactive command prompt
- X at beginning of execution
- X.DE
- X
- X.*s 2 "%errstr"
- X
- Xusage: %errstr(int0)
- X
- XThis function returns the system error message, given int0 as an
- X.B errno
- Xas returned by a file-related command.
- X.B fopen.
- X
- X.DS L
- XExample:
- X
- X echo %errstr(1)
- X Not owner
- X.DE
- X
- X.*s 2 "%etime"
- X
- Xusage: %etime(int0)
- X
- XThis function returns a string representation of elapsed time
- Xin the format 'hh:mm:ss'
- Xfor the integer parameter int0, a number of seconds.
- X
- X.DS L
- XExample:
- X
- X echo %etime(62)
- X 00:01:02
- X.DE
- X
- X.*s 2 "%filepart"
- X
- Xusage: %filepart(str0)
- X
- XThis function returns the
- Xfilename portion of the pathname supplied in str0.
- XSee also
- X.B %basename
- Xand
- X.B %dirpart .
- X
- X.DS L
- XExamples:
- X
- X%filepart('/u1/src/src/foo.c') = "foo.c"
- X%filepart('foo.c') = "foo.c"
- X.DE
- X
- X.*s 2 "%fmodestr"
- X
- Xusage: %fmodestr(int0)
- X
- XThis function returns a string representation of the
- Xfamiliar file mode string given the file mode integer int0.
- X
- X.DS L
- XExample:
- X
- X echo %fmodestr(0100755)
- X -rwxr-xr-x
- X
- X echo %fmodestr(%fmode('/usr/lib'))
- X drwxr-xr-x
- X.DE
- X
- X.*s 2 "%itos"
- X
- Xusage: %itos(int0[,format])
- X
- XThis function converts integer int0 to a string, optionally
- Xcontrolling the format of the conversion.
- X
- XIf the format parameter is missing, the conversion is to
- Xa minimum number of decimal characters necessary to
- Xhold the result.
- X
- XIf the format parameter is present, it must of consist of
- Xa non-null string made of one or both optional parts:
- X.DS L
- X decimal number of digits to be part of result string
- X (a leading zero indicates leading zeroes are to
- X appear in the string; no leading zero pads with
- X leading spaces
- X
- X a lower case letter from the following list:
- X d - decimal conversion
- X x - hexadecimal conversion
- X o - octal conversion
- X.DE
- X.DS L
- XExample:
- X
- X %itos(33) '33'
- X %itos(33,d) '33'
- X %itos(33,x) '21'
- X %itos(33,5d) ' 33'
- X %itos(33,010d) '0000000033'
- X %itos(33,10d) ' 33'
- X %itos(33,x) '21'
- X %itos(33,04x) '0021'
- X %itos(33,4x) ' 21'
- X %itos(33,o) '41'
- X %itos(33,4o) ' 41'
- X.DE
- X
- X.*s 2 "%left"
- X
- Xusage: %left(str0,int0)
- X
- XThis function returns the leftmost int0 characters of str0.
- XIf the length of the string is less than int0,
- Xthe entire str0 is returned.
- X.DS L
- XExample:
- X
- X if $s0 == 'abcdefg'
- X %left($s0,3) returns 'abc'
- X.DE
- X
- X.*s 2 "%line"
- X
- Xusage: %line
- X
- XThis function returns the name of the attached communications
- Xline in the form "/dev/ttyxx". If no line is currently
- Xattached, the function returns null.
- X
- X.*s 2 "%logname"
- X
- Xusage: %logname
- X
- XThis function returns the login name of the user executing
- XECU. Note: the name returned is the name supplied to a login
- Xprompt, not any current su(C) username that may be in effect.
- X
- X.*s 2 "%mid"
- X
- Xusage: %mid(str0,int0[,int1])
- X
- XThis function returns the middle portion of a string str0
- Xbeginning with the character at position int0 and for a length
- Xof int1 characters.
- XIf int0 is greater than or equal to the length of
- Xstro, a null string is returned.
- XIf the optional argument int1 is not supplied, or
- Xif the length of the string is less than int1,
- Xthe entire str0 is returned.
- X.DS L
- XExample:
- X
- X if $s0 == '0123456789abc'
- X %mid($s0,3,4) returns '3456'
- X %mid($s0,3) returns '3456789abc'
- X %mid($s0,10,2) returns 'ab'
- X %mid($s0,10,5) returns 'abc'
- X.DE
- X
- X.*s 2 "%month"
- X
- Xusage: %month
- X
- XThis function returns the current month as a three character
- Xabbreviation: 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'.
- X
- X.*s 2 "%rdesc"
- X
- Xusage: %rdesc
- X
- XThis function returns the
- Xdescription
- Xportion of the
- Xdialing directory entry for the currently connected remote.
- XIf no connection exists, the function returns null.
- X
- X.*s 2 "%right"
- X
- Xusage: %right(str0,int0)
- X
- XThis function returns the rightmost int0 characters of str0.
- XIf the length of the string is less than int0,
- Xthe entire str0 is returned.
- X.DS L
- XExample:
- X
- X if $s0 == 'abcdefg'
- X %right($s0,3) returns 'efg'
- X.DE
- X
- X.*s 2 "%rname"
- X
- Xusage: %rname
- X
- XThis function returns the
- Xlogical name
- Xportion of the
- Xdialing directory entry for the currently connected remote.
- XIf the remote was dialed directly, as in dial 5551212, the
- Xreturned value is the phone number.
- XIf no connection exists, the function returns null.
- X
- XThe value returned by this command may be overridden by use of the
- X.B rname
- Xprocedure command.
- X
- X.*s 2 "%rtelno"
- Xusage: %rtelno
- X
- XThis function returns the
- Xtelephone number
- Xportion of the
- Xdialing directory entry for the currently connected remote.
- XIf no connection exists, the function returns null.
- X
- X.*s 2 "%time"
- X
- Xusage: %time
- X
- XThis function returns the current time in the form 'hh:mm'
- Xin the local time zone (daylight time if it applies).
- X
- X.*s 2 "%times"
- X
- Xusage: %times
- X
- XThis function returns the current time in the form 'hh:mm:ss'
- Xin the local time zone (daylight time if it applies).
- X
- X.*s 2 "%timez"
- X
- Xusage: %timez
- X
- XThis function returns the current time in the form 'hh:mm'
- Xin the UTC (Z) time zone.
- X
- X.*s 2 "%timezs"
- X
- Xusage: %timezs
- X
- XThis function returns the current time in the form 'hh:mm:ss'
- Xin the UTC (Z) time zone.
- X
- X.*s 2 "%tty"
- X
- Xusage: %tty
- X
- XThis function returns the console tty name in the form "/dev/ttynn".
- X
- X.*s 2 "%uname"
- X
- Xusage: %uname
- X
- XThis function returns the system name you are executing ECU on as
- Xreported by uname(2)/uname(S). On SCO systems, if /etc/systemid
- Xexists and is readable, the name in that file isused in place of
- Xthe name from uname.
- END_OF_FILE
- if test 10113 -ne `wc -c <'ecu330/doc/_p_sfunc.txt'`; then
- echo shar: \"'ecu330/doc/_p_sfunc.txt'\" unpacked with wrong size!
- fi
- # end of 'ecu330/doc/_p_sfunc.txt'
- fi
- if test -f 'ecu330/ecu.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecu.h'\"
- else
- echo shar: Extracting \"'ecu330/ecu.h'\" \(10662 characters\)
- sed "s/^X//" >'ecu330/ecu.h' <<'END_OF_FILE'
- X/*+-----------------------------------------------------------------------
- X ecu.h -- TuckerWare Extended Calling Unit
- X wht@n4hgf.atl.ga.us
- X------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
- X/*:03-15-1994-14:23-wht@n4hgf-correct doc: ecuxenix.c now ecugrabbag.c */
- X/*:01-16-1994-17:01-wht@n4hgf-restore SIGCHLD equate for NetBSD */
- X/*:12-12-1993-13:32-wht@n4hgf-MOTSVR3 port */
- X/*:12-12-1993-13:03-wht@fep-use ecu_time.h for ftime/gettimeofday */
- X/*:12-11-1993-11:27-wht@n4hgf-lost an endif */
- X/*:12-10-1993-22:09-wht@n4vu-more Linux fixes + no default sun termios */
- X/*:11-14-1993-15:47-wht@n4hgf-more hpux port */
- X/*:10-02-1993-22:45-wht@n4hgf-add SIGPTR */
- X/*:08-01-1993-02:12-wht@n4hgf-add got_delim to LRWT */
- X/*:09-13-1992-12:52-wht@n4hgf-add tty_is_scoterm */
- X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:08-21-1992-13:39-wht@n4hgf-rewire direct/modem device use */
- X/*:07-21-1992-12:09-wht@n4hgf-3.2v4 only has sys/time.h if TCPRT installed */
- X/*:04-17-1992-20:10-wht@gyro-default tty, baud and parity moved to config.c */
- X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
- X/*:02-13-1992-06:35-wht@n4hgf-when port to many time() can be int/long/time_t */
- X/*:11-30-1991-13:46-wht@n4hgf-smap conditional compilation reorg */
- X/*:11-26-1991-20:17-wht@n4hgf-add shm->Ldcdwatch values */
- X/*:11-26-1991-19:37-wht@n4hgf-add STR_CLASSIFY */
- X/*:11-13-1991-16:29-wht@n4hgf-use if __STDC__ instead of defined(__STDC__) */
- X/*:11-11-1991-22:45-wht@n4hgf-redefinition of Ltermio's place in life */
- X/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
- X/*:08-13-1991-13:53-wht@n4hgf-UNIX and ISC nap() broken; XENIX still wins */
- X/*:08-09-1991-11:07-wht@n4hgf-configurable lock directory */
- X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
- X/*:01-25-1991-06:08-wht@n4hgf-mulltiple #define of ECULIBDIR */
- X/*:01-22-1991-14:33-wht@n4hgf-XENIX calloc/memmove fix */
- X/*:01-01-1991-21:36-wht@n4hgf-add GCC implies STDC */
- X/*:08-14-1990-20:39-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#ifndef _ecu_h
- X#define _ecu_h
- X
- X#include "ecu_config.h"
- X
- X#if !defined(STDIO_H_INCLUDED)
- X#include <stdio.h>
- X#endif
- X
- X#include <signal.h>
- X#include <ctype.h>
- X#include <errno.h>
- X#include <string.h>
- X#include <memory.h>
- X#include <fcntl.h>
- X#include "ecu_types.h"
- X#include "ecu_stat.h"
- X#include "ecu_time.h"
- X#include "ecushm.h"
- X#include "termecu.h"
- X#include "ttynaming.h"
- X#if !defined(OMIT_TERMIO_REFERENCES)
- X#include "ecutermio.h"
- X#endif /* OMIT_TERMIO_REFERENCES */
- X
- X/*
- X * if building prototypes, using lint, or otherwise need
- X * the source to make sense without the Overly Complex
- X * Makefile, turn the following on
- X */
- X#if defined(BUILDING_PROTOTYPES) || defined(lint)
- X#define ECULIBDIR "dummy"
- X#define HDBLIBDIR "dummy"
- X#define LOCK_DIR_NAME "dummy"
- X#define DEFAULT_TTY "/dev/tty1"
- X#define DEFAULT_BAUD_RATE 2400
- X#define DEFAULT_PARITY 'n'
- X#endif
- X
- X/*
- X * The various flavors of hardware flow control, most of them
- X * flakey or incomplete .... follow the identifer road
- X * (fgrep HW_FLOW_CONTROL) to see what it takes to
- X * include your vendor's attempt.
- X */
- X#if defined(RTSFLOW) && !defined(HW_FLOW_CONTROL) /* SCO */
- X#define HW_FLOW_CONTROL
- X#endif
- X#if defined(CRTSFL) && !defined(HW_FLOW_CONTROL) /* 3.2v4 and later */
- X#define HW_FLOW_CONTROL
- X#endif
- X#if defined(RTSXOFF) && !defined(HW_FLOW_CONTROL) /* SVR4 */
- X#define HW_FLOW_CONTROL
- X#endif
- X#if defined(CRTSCTS) && !defined(HW_FLOW_CONTROL) /* sun */
- X#define HW_FLOW_CONTROL
- X#endif
- X
- X/*
- X * Communication line variables that are not in shared memory
- X *
- X * One special note: Ltermio points to a buffer in shared memory
- X * used to hold the line's current termio structure. The shared
- X * memory buffer is defined as a simple array of longs so that
- X * friend code need not include termio.h if it does not need it.
- X * What's more, due to sgtty-based curses code, XENIX versions
- X * cannot include termio.h in some modules. ecushm.c has runtime
- X * code to initialize Ltermio to point to shm->Ltiobuf and to
- X * make sure shm->Ltiobuf is long enough.
- X */
- X#if defined(DECLARE_LINEVARS_PUBLIC)
- X#if !defined(OMIT_TERMIO_REFERENCES)
- Xstruct termio *Ltermio; /* attributes for the line to remote */
- X#endif
- Xuchar Ldial_debug_level;
- X
- X#else
- X#if !defined(OMIT_TERMIO_REFERENCES)
- Xextern struct termio *Ltermio;
- X
- X#endif
- Xextern uchar Ldial_debug_level;
- X
- X#endif
- X
- Xextern int zero_length_read_detected; /* see lgetc_xmtr in eculine.c */
- X
- X#ifdef M_I286
- Xlong time();
- X
- X#endif
- X
- Xlong Nap();
- X
- X#if __STDC__ /* sigh ... malloc and such types; SIGTYPE
- X * just a guess */
- X#define VTYPE void
- X#define VOLATILE volatile
- X#ifndef SIGTYPE
- X#define SIGTYPE void
- X#endif
- X#else
- X#define VTYPE char
- X#define VOLATILE
- X#ifndef SIGTYPE
- X#define SIGTYPE int
- X#endif
- X#endif
- X
- X#include "smap.h"
- X#if defined(MALLOC_3X)
- X#include <malloc.h>
- X#else
- XVTYPE *malloc();
- XVTYPE *calloc();
- XVTYPE *realloc();
- X
- X#endif
- X
- Xtypedef int (*PFV) (); /* pointer to function returning void */
- Xtypedef char (*PFC) (); /* pointer to function returning char */
- Xtypedef int (*PFI) (); /* pointer to function returning integer */
- Xtypedef long (*PFL) (); /* pointer to function returning long */
- Xtypedef SIGTYPE(*SIGPTR) (); /* pointer to signal handler */
- X
- X/*
- X * undef M_XENIX must come after any system header inclusion
- X */
- X#if defined(M_UNIX)
- X#undef M_XENIX /* now can truly distinquish between SCO
- X * XENIX and UNIX */
- X#endif /* M_UNIX */
- X
- X/*
- X * small dialect correction
- X */
- X#ifdef __NetBSD__
- X#define SIGCLD SIGCHLD
- X#endif
- X
- X#if defined(GNUC) || defined(__GNUC__) || (__STDC__ == 1)
- Xint strcmpi(char *s1, char *s2);
- X
- X#endif
- X
- X/*
- X * for better source line utilization, frequent use of
- X * fprintf and stderr warrants the following
- X */
- X#define pf printf
- X#define ff fprintf
- X#define se stderr
- X#define so stdout
- X
- X/*
- X * console tty information
- X */
- Xextern int tty_is_multiscreen; /* SCO multiscreen */
- Xextern int tty_is_scoterm; /* SCO scoterm */
- Xextern int tty_is_pty; /* bursty network connection? */
- Xextern int tty_not_char_special; /* /dev/null not considered char
- X * special */
- X
- X/*
- X * useful macros
- X */
- X#undef max /* just in case they ... */
- X#undef min /* ... were already defined */
- X#define max(a,b) (((a) > (b)) ? (a) : (b))
- X#define min(a,b) (((a) < (b)) ? (a) : (b))
- X
- X/*
- X * decide how to write to logfile
- X */
- X#define LOGPUTC putc /* fputc() or putc() */
- X
- X#define TTYIN 0
- X#define TTYOUT 1 /* ditto tty output */
- X#define TTYERR 2 /* ditty tty output error channel */
- X
- X/*
- X * xbell codes (see ecugrabbag.c)
- X */
- Xenum xbell
- X{
- X XBELL_DONE = 1, /* octaves or morse 'd' */
- X XBELL_ATTENTION, /* morse .-.-.- ATTENTION */
- X XBELL_C, /* morse -.-. C */
- X XBELL_3T /* 3 Ts --- really 'o' */
- X};
- X
- X/*
- X * lopen() and related routines error codes
- X */
- Xenum linst
- X{
- X LINST_OK = 0, /* no error */
- X LINST_INVALID = -50, /* for invalid tty name */
- X LINST_UNKPID, /* unknown pid using line */
- X LINST_LCKERR, /* lock file open error */
- X LINST_NODEV, /* device does not exist */
- X LINST_OPNFAIL, /* could not access line */
- X LINST_ALREADY, /* line already open */
- X LINST_ENABLED, /* line enabled for login */
- X LINST_ENABLED_IN_USE, /* line in use by incoming login */
- X LINST_DIALOUT_IN_USE, /* line in use by another dial out */
- X LINST_NOPTY, /* pty not supported */
- X LINST_WEGOTIT, /* not really an error: we already own the
- X * line (used by check_utmp()) */
- X LINST_ECUUNGETTY, /* ecuungetty unexpected response */
- X LINST_ECUUNGETTY2, /* ecuungetty execution error */
- X LINST_NOTCHR /* not a character special */
- X};
- X
- Xchar *LINST_text(); /* routine to return text for error code */
- Xextern char lopen_err_str[];
- X
- X/*
- X * filename sizes
- X */
- X#define CURR_DIRSIZ 256 /* current directory array size */
- X#define PHONEDIR_NAME_SIZE 256 /* phone directory */
- X
- X/*
- X * in case errno.h doesn't pick this up
- X */
- Xextern int errno;
- Xextern char *sys_errlist[];
- Xextern int sys_nerr;
- Xchar *errno_text(); /* see ecuutil.c */
- X
- Xchar *getenv();
- X
- X/*
- X * process IDs
- X */
- Xextern PID_T rcvr_pid;
- Xextern PID_T xmtr_pid;
- X
- X/*
- X * both of the following are set by xmtr_SIGINT_handler()
- X * 'sigint' reset by 1st detector/processor
- X * 'proc_interrupt' reset/handled by procedure monitor
- X * (execute_esd and execute_proc)
- X */
- Xextern int sigint;
- X
- X/* extern int proc_interrupt; <------ force using modules to declare it */
- X
- X/*
- X * procedure nesting level
- X * non-zero if procedure executing (see proc.c)
- X */
- Xextern int proc_level;
- Xextern int proc_trace;
- X
- X/*
- X * need_rcvr_restart() - check rcvr status
- X *
- X * If rcvr_pid == -2, queued restart has been requested by some function
- X * but we don't want to do it if a procedure is executing
- X */
- X#define need_rcvr_restart() \
- X ((rcvr_pid > 0) || ((rcvr_pid == -2) && !proc_level))
- X
- X/*
- X * 'hz' is getenv("HZ"); that not found, the value from sys/param.h
- X * 'hzmsec' is ceiling(clock period) in milliseconds
- X */
- Xextern int hz; /* HZ from environ or sys/param.h */
- Xextern ulong hzmsec; /* clock period in msec rounded up */
- X
- X/*
- X * lock file directory
- X */
- Xextern char *lock_dir_name; /* defined in ecuLCK.c */
- X
- X/*
- X * setcolor variables - see setcolor()
- X */
- Xextern ulong colors_current;
- Xextern ulong colors_normal;
- Xextern ulong colors_success;
- Xextern ulong colors_alert;
- Xextern ulong colors_error;
- Xextern ulong colors_notify;
- X
- X/*
- X * miscellaneuous
- X */
- Xextern char *eculibdir; /* lib dir, i.e., "/usr/local/lib/ecu" */
- Xextern char *ttype; /* getenv("TERM") */
- X
- X/*
- X * param to lgets_timeout in eculine.c
- X */
- Xtypedef struct lrwt
- X{
- X ulong to1; /* timeout for 1st character (granularity 20) */
- X ulong to2; /* timeout for each next char (granularity
- X * 20) */
- X int raw_flag; /* !=0, rtn full buffer, ==0, rtn filtered
- X * hayes result */
- X char *buffer; /* buffer to fill */
- X int bufsize; /* size of buffer */
- X int count; /* from proc, count rcvd */
- X char *delim; /* ending string for lgets_timeout_or_delim */
- X int echo_flag; /* echo incoming chars to screen */
- X int got_delim; /* set true if delim found */
- X}
- XLRWT;
- X
- X/*
- X * parameter structure for str_classify()
- X */
- Xtypedef struct str_classify
- X{
- X char *str; /* string to match */
- X int min_ch; /* minimum characters required */
- X int token; /* token for match */
- X}
- XSTR_CLASSIFY;
- X
- X/*
- X * shm->Ldcdwatch values
- X */
- X#define DCDW_OFF 0
- X#define DCDW_ON 1
- X#define DCDW_TERMINATE 2
- X
- X#ifdef DEBUG_SRP
- X#define start_rcvr_process(flag) _start_rcvr_process(flag,__FILE__,__LINE__)
- X#else
- X#define start_rcvr_process(flag) _start_rcvr_process(flag)
- X#endif
- X
- X#endif /* _ecu_h */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of ecu.h */
- END_OF_FILE
- if test 10662 -ne `wc -c <'ecu330/ecu.h'`; then
- echo shar: \"'ecu330/ecu.h'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecu.h'
- fi
- if test -f 'ecu330/ecushm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecushm.c'\"
- else
- echo shar: Extracting \"'ecu330/ecushm.c'\" \(10554 characters\)
- sed "s/^X//" >'ecu330/ecushm.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X ecushm.c - shared memory handler for ecu xmtr/rcvr comm
- X wht@n4hgf.atl.ga.us
- X
- X Signal handler purists will surely get aneurisms from looking
- X at what we do in here, but any OS that doesn't properly push
- X a stack frame for a signal event just won't play here. We even
- X fork() in a signal handler. That ought to make some of the
- X brethren gag.
- X
- X Defined functions:
- X shm_done()
- X shm_init()
- X shmr_notify_xmtr_of_DCD_loss()
- X shmr_notify_zmodem_frame()
- X shmr_process_rcvr_SIGUSR2()
- X shmx_connect()
- X shmx_make_rcvr_sleep(seconds)
- X shmx_process_xmtr_SIGUSR2()
- X shmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each)
- X shmx_unpause_rcvr()
- X
- X Sforzando (It., sfohr-tsahn'-doh). A direction to perform the
- X tone or chord with special stress, or marked and sudden emphasis.
- X -- Schirmer Pronouncing POCKET-MANUAL of Musical Terms, 1936.
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:11-25-1993-14:43-wht@n4hgf-3.281-fix typo in shm_done shmctl statement */
- X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
- X/*:09-10-1992-04:34-wht@n4hgf-add rcvrdisp semaphore */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:12-15-1991-14:22-wht@n4hgf-autorz initialized */
- X/*:12-13-1991-04:16-wht@n4hgf-move bell_notify_state to shm */
- X/*:11-12-1991-18:02-wht@n4hgf-remove obsolete shmx_rc_report */
- X/*:11-11-1991-14:59-wht@n4hgf-shmr_notify_xmtr_of_DCD_loss */
- X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "ecu.h"
- X
- X#if defined(CFG_MmapSHM)
- X#include <sys/mman.h>
- X#else
- X#include <sys/ipc.h>
- X#include <sys/shm.h>
- X#ifdef CFG_SemWithShm
- X#include <sys/sem.h>
- X
- Xunion semun
- X{
- X int val;
- X struct semid_ds *buf;
- X ushort *array;
- X} semctl_arg;
- X
- X#endif /* CFG_SemWithShm */
- X#endif /* CFG_MmapSHM */
- X
- X/* xmtr to rcvr cmds */
- X#define SHMX_MAKE_RCVR_SLEEP 1 /* sleep xi1=#seconds */
- X#define SHMX_UNPAUSE 2 /* no-op to un-pause() rcvr */
- X#define SHMX_SET_RCVR_LOG 3 /* log file manipulations
- X * xi1=append,xi2=raw,xs1=n ame */
- X
- X/* rcvr to xmtr cmds */
- X#define SHMR_NOTIFY_DCD_LOSS 1 /* rcvr detected DCD loss */
- X#define SHMR_NOTIFY_ZMODEM 2 /* rcvr detected ZMODEM frame */
- X
- Xextern char rcvr_log_file[]; /* if rcvr_log!= 0,log filename */
- Xextern int rcvr_log; /* rcvr log active if != 0 */
- Xextern FILE *rcvr_log_fp; /* rcvr log file */
- Xextern int rcvr_log_raw; /* if true, log all, else filter ctl chrs */
- Xextern int rcvr_log_flusheach;
- Xextern int rcvr_log_append; /* if true, append, else scratch */
- Xextern int rcvr_log_gen_title;
- X
- XECU_SDS FAR *shm; /* shared segment pointer */
- X#if !defined(CFG_MmapSHM)
- Xkey_t shm_key;
- Xint shm_shmid;
- X
- X#endif
- X
- X/*+-------------------------------------------------------------------------
- X shm_init()
- X Called by parent process (xmtr) to initialize environment
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshm_init()
- X{
- X uint save_LINESxCOLS;
- X extern uint LINESxCOLS;
- X
- X /*
- X * see the comments in ecu.h titled "Communication line variables" for
- X * an explanation of the following
- X */
- X if (sizeof(shm->Ltiobuf) < sizeof(struct termio))
- X {
- X pprintf("ecushm.h LTIOBUF_SIZE needs to be increased to %d.\n",
- X sizeof(struct termio));
- X
- X pputs("Please change it, remake and notify wht@n4hgf.atl.ga.us.\n");
- X termecu(TERMECU_CONFIG_ERROR);
- X }
- X
- X#if defined(CFG_MmapSHM)
- X shm = (ECU_SDS *) mmap(0, sizeof(ECU_SDS), PROT_READ | PROT_WRITE,
- X MAP_ANON | MAP_INHERIT | MAP_SHARED, -1, 0);
- X if (shm == (ECU_SDS *) - 1)
- X {
- X perror("mmap");
- X termecu(TERMECU_IPC_ERROR);
- X }
- X#else
- X shm_key = 0xEC000000L | getpid();
- X
- X if ((shm_shmid = shmget(shm_key, sizeof(ECU_SDS), IPC_CREAT | 0600)) < 0)
- X {
- X perror("shmget");
- X termecu(TERMECU_IPC_ERROR);
- X }
- X
- X if ((shm = (ECU_SDS FAR *) shmat(shm_shmid, (char FAR *)0, 0)) ==
- X (ECU_SDS FAR *) - 1)
- X {
- X perror("shmat");
- X termecu(TERMECU_IPC_ERROR);
- X }
- X
- X#ifdef CFG_SemWithShm
- X if ((shm->rcvrdisp_semid = semget(shm_key, 1, IPC_CREAT | 0600)) < 0)
- X {
- X perror("semget");
- X termecu(TERMECU_IPC_ERROR);
- X }
- X rcvrdisp_v(); /* first unlock */
- X#endif /* CFG_SemWithShm */
- X#endif /* CFG_MmapSHM */
- X
- X /*
- X * see the comments in ecu.h titled "Communication line variables" for
- X * an explanation of the following
- X */
- X Ltermio = (struct termio *)shm->Ltiobuf; /* cover termio buffer */
- X
- X shm->xcmd = 0; /* signal from xmtr to rcvr SIGUSR2 */
- X shm->xi1 = 0; /* parameters */
- X shm->xi2 = 0;
- X shm->xs1[0] = 0;
- X shm->rcmd = 0; /* signal from rcvr to xmtr SIGUSR2 */
- X shm->ri1 = 0; /* parameters */
- X shm->ri2 = 0;
- X shm->rs1[0] = 0;
- X shm->rcvd_chars = 0L;
- X shm->rcvd_chars_this_connect = 0L;
- X shm->bell_notify_state = 1; /* default to want bell notify */
- X shm->Ldcdwatch = 0; /* default DCD watcher to off */
- X shm->autorz = 1; /* default automatic rz to on */
- X shm->cursor_y = 0;
- X shm->cursor_x = 0;
- X shm->friend_space[0] = 0;
- X save_LINESxCOLS = LINESxCOLS;
- X LINESxCOLS = sizeof(shm->screen); /* avoid trap */
- X spaces((char *)shm->screen, sizeof(shm->screen));
- X LINESxCOLS = save_LINESxCOLS;
- X shm->rcvrdisp_ptr = shm->rcvrdisp_buffer;
- X shm->rcvrdisp_count = 0;
- X
- X} /* end of shm_init */
- X
- X/*+-------------------------------------------------------------------------
- X shm_done() -- finished with shm/sem -- clean up
- X
- XWe might make a trip thru here with the xmtr and rcvr, so
- Xignore EINVAL
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshm_done()
- X{
- X
- X#if defined(CFG_MmapSHM)
- X munmap(shm, sizeof(ECU_SDS));
- X#else
- X#ifdef CFG_SemWithShm
- X union semun semctl_arg;
- X
- X if (semctl(shm->rcvrdisp_semid, 0, IPC_RMID, &semctl_arg) && (errno != EINVAL))
- X pperror("semctl IPC_RMID");
- X#endif /* CFG_SemWithShm */
- X
- X if (shmctl(shm_shmid, IPC_RMID, (struct shmid_ds *)0) && (errno != EINVAL))
- X pperror("shmctl IPC_RMID");
- X#endif
- X
- X} /* end of shm_done */
- X
- X/*+-------------------------------------------------------------------------
- X shmx_connect() -- xmtr calls when modem connects
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmx_connect()
- X{
- X shm->rcvd_chars_this_connect = 0L;
- X} /* end of shmx_connect */
- X
- X/*+-------------------------------------------------------------------------
- X shmx_make_rcvr_sleep(seconds)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmx_make_rcvr_sleep(seconds)
- Xint seconds;
- X{
- X shm->xcmd = SHMX_MAKE_RCVR_SLEEP;
- X shm->xi1 = seconds;
- X kill_rcvr_process(SIGUSR2);
- X
- X} /* end of shmx_make_rcvr_sleep */
- X
- X/*+-------------------------------------------------------------------------
- X shmx_unpause_rcvr() - no-op SIGUSR2 to unpause receiver
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmx_unpause_rcvr()
- X{
- X shm->xcmd = SHMX_UNPAUSE;
- X kill_rcvr_process(SIGUSR2);
- X} /* end of shmx_unpause_rcvr */
- X
- X/*+-------------------------------------------------------------------------
- X shmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each)
- X
- Xnull logfilename stops logging
- Xappend_flag says whether to open for write or append
- Xraw_flag says whether or not to filter non-printable chars or not
- X(NL not filtered)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmx_set_rcvr_log(logfilename, append_flag, raw_flag, flush_each)
- Xchar *logfilename;
- Xint append_flag;
- Xint raw_flag;
- Xint flush_each;
- X{
- X shm->xcmd = SHMX_SET_RCVR_LOG;
- X shm->xi1 = append_flag;
- X shm->xi2 = raw_flag;
- X shm->xi3 = flush_each;
- X strcpy(shm->xs1, logfilename);
- X kill_rcvr_process(SIGUSR2);
- X} /* end of shmx_set_rcvr_log */
- X
- X/*+-------------------------------------------------------------------------
- X shmr_notify_xmtr_of_DCD_loss()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmr_notify_xmtr_of_DCD_loss()
- X{
- X shm->rcmd = SHMR_NOTIFY_DCD_LOSS;
- X kill(xmtr_pid, SIGUSR2);
- X} /* end of shmr_notify_xmtr_of_DCD_loss */
- X
- X/*+-------------------------------------------------------------------------
- X shmr_notify_zmodem_frame()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmr_notify_zmodem_frame()
- X{
- X shm->rcmd = SHMR_NOTIFY_ZMODEM; /* rcvr detected ZMODEM frame */
- X kill(xmtr_pid, SIGUSR2);
- X} /* end of shmr_notify_zmodem_frame */
- X
- X/*+-------------------------------------------------------------------------
- X shmx_process_xmtr_SIGUSR2()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmx_process_xmtr_SIGUSR2()
- X{
- X register rcmd;
- X register ri1, ri2;
- X int argc;
- X char *cptr;
- X char **argv;
- X ulong colors_save;
- X int lchar;
- X int success_flag;
- X
- X rcmd = shm->rcmd;
- X shm->rcmd = 0;
- X ri1 = shm->ri1;
- X ri2 = shm->ri2;
- X
- X switch (rcmd)
- X {
- X case SHMR_NOTIFY_DCD_LOSS:
- X lzero_length_read_detected();
- X break;
- X
- X case SHMR_NOTIFY_ZMODEM:
- X kill_rcvr_process(SIGUSR1);
- X success_flag = 0;
- X while ((lchar = lgetc_timeout(100L)) >= 0)
- X {
- X fputc(lchar, se);
- X if (lchar == '\n')
- X {
- X success_flag = 1;
- X break;
- X }
- X }
- X if (!success_flag)
- X fputs("\r\n", se);
- X colors_save = colors_current;
- X setcolor(colors_notify);
- X fputs("[automatic rz]", se);
- X setcolor(colors_save);
- X fputs("\r\n", se);
- X argc = 1;
- X cptr = "rz";
- X argv = &cptr;
- X receive_files_from_remote(argc, argv);
- X start_rcvr_process(1);
- X break;
- X }
- X
- X} /* end of shmx_process_xmtr_SIGUSR2 */
- X
- X/*+-------------------------------------------------------------------------
- X shmr_process_rcvr_SIGUSR2()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshmr_process_rcvr_SIGUSR2()
- X{
- X register xcmd;
- X register xi1, xi2, xi3;
- X char xs1[SHM_STRLEN];
- X
- X xcmd = shm->xcmd;
- X shm->xcmd = 0;
- X xi1 = shm->xi1;
- X xi2 = shm->xi2;
- X xi3 = shm->xi3;
- X strcpy(xs1, shm->xs1);
- X
- X switch (xcmd)
- X {
- X case SHMX_MAKE_RCVR_SLEEP:
- X sleep(xi1);
- X break;
- X
- X case SHMX_SET_RCVR_LOG:
- X if (rcvr_log) /* if already logging */
- X {
- X if (!rcvr_log_raw)
- X LOGPUTC('\n', rcvr_log_fp);
- X fclose(rcvr_log_fp);
- X rcvr_log = 0;
- X }
- X if (strlen(xs1) == 0) /* if all we wanted was to stop log
- X * ... */
- X break; /* ... then quit */
- X rcvr_log_gen_title = 1;
- X rcvr_log = 1;
- X rcvr_log_append = xi1;
- X rcvr_log_raw = xi2;
- X rcvr_log_flusheach = xi3;
- X strcpy(rcvr_log_file, xs1);
- X rcvr_log_open();
- X break;
- X
- X case SHMX_UNPAUSE:
- X break;
- X }
- X
- X} /* end of shmr_process_rcvr_SIGUSR2 */
- X
- X/* end of ecushm.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 10554 -ne `wc -c <'ecu330/ecushm.c'`; then
- echo shar: \"'ecu330/ecushm.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecushm.c'
- fi
- if test -f 'ecu330/gendial/template.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/gendial/template.c'\"
- else
- echo shar: Extracting \"'ecu330/gendial/template.c'\" \(10468 characters\)
- sed "s/^X//" >'ecu330/gendial/template.c' <<'END_OF_FILE'
- X
- X/*+-------------------------------------------------------------------------
- X template.c - DCE-specific portion of generic SCO UUCP dialer
- X wht@n4hgf.atl.ga.us
- X
- X Necessary DCE switch setting or other configuration:
- X Switch foo off: enable onhook upon loss of DTR
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:02-02-1992-18:01-root@n4hgf-proper ordering of DCE_result entries */
- X/*:01-26-1992-15:31-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
- X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "dialer.h"
- X
- X/*
- X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
- X * sees the transition; this value may be changed
- X * as necessary before each call to lflash_DTR(),
- X * but, generally, a constant value will do.
- X */
- Xlong DCE_DTR_low_msec = 500;
- X
- X/*
- X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
- X * DCE may be expected to be ready to be commanded
- X */
- Xlong DCE_DTR_high_msec = 500;
- X
- X/*
- X * DCE_write_pace_msec - milliseconds to pause between each character
- X * sent to the DCE (zero if streaming I/O is
- X * permitted); this value may be changed as
- X * necessary before each call to lwrite(), but, generally, a constant
- X * value will do. Note that this value is used to feed a value to Nap(),
- X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
- X * and .050 seconds on XENIX/86.
- X */
- Xlong DCE_write_pace_msec = 20;
- X
- X/*
- X * DCE_name - short name for DCE
- X * DCE_revision - revision number for this module
- X */
- Xchar *DCE_name = "Frobozz 9600";
- Xchar *DCE_revision = "1.10";
- X
- X/*
- X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
- X * and readying it for dial in access
- X * (BXXX mask); use a value of zero if the speed
- X * specified by the invoker is to be used.
- X * This value is useful for DCEs such as the early Hayes 2400
- X * which are so unfortunately compatible with their 1200 predecessor
- X * that they refuse to answer at 2400 baud unless you last spoke to
- X * them at that rate. For such bad boys, use B2400 below.
- X */
- Xint DCE_hangup_CBAUD = 0;
- X
- X/* int DCE_hangup_CBAUD = B2400; */
- X
- X/*
- X * DCE_results - a table of DCE response strings and a token
- X * code for each; when you call lread() or lread_ignore(),
- X * if the read routine detects one of the strings,
- X * the appropriate code is returned. If no string matches, then
- X * lread()/lread_ignore examines the DCE result string for a
- X * numeric value; if one is found, the numeric value or'd with
- X * 0x4000 is returned (in this way, e.g., you can read "modem
- X * S registers." If nothing agrees with this search, lread()
- X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
- X * will return -1. You may use any value between 0 and 0x3FFFFFFF.
- X * This module is the only consumer of the codes, although they
- X * are decoded by gendial.c's _lread().
- X *
- X * If one possible result is an "early substring" of another, like
- X * "CONNECT" is of "CONNECT 1200", then put such results later in the
- X * table than the larger result.
- X *
- X */
- X#define rfConnect 0x00400000
- X
- X#define rOk 0
- X#define rNoCarrier 1
- X#define rError 2
- X#define rNoDialTone 3
- X#define rBusy 4
- X#define rNoAnswer 5
- X#define rRring 6
- X#define rConnect300 (7 | rfConnect)
- X#define rConnect1200 (8 | rfConnect)
- X#define rConnect2400 (9 | rfConnect)
- X
- XDCE_RESULT DCE_results[] =
- X{
- X {"OK", rOk,},
- X {"NO CARRIER", rNoCarrier,},
- X {"ERROR", rError},
- X {"NO DIALTONE", rNoDialTone,},
- X {"BUSY", rBusy},
- X {"NO ANSWER", rNoAnswer},
- X {"CONNECT 1200", rConnect120},
- X {"CONNECT 2400", rConnect2400},
- X {"CONNECT", rConnect300},
- X {(char *)0, -1} /* end table */
- X};
- X
- X/*+-------------------------------------------------------------------------
- X DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
- X
- X DCE dependent function must validate baud rates supported by DCE
- X returns baud rate in struct termio c_cflag fashion
- X or terminates program with error
- X--------------------------------------------------------------------------*/
- Xint
- XDCE_baud_to_CBAUD(baud)
- Xunsigned int baud;
- X{
- X switch (baud)
- X {
- X case 50:
- X return (B50); /* delete the ones you dont handle */
- X case 75:
- X return (B75);
- X case 110:
- X return (B110);
- X case 134:
- X return (B134);
- X case 150:
- X return (B150);
- X case 300:
- X return (B300);
- X case 1200:
- X return (B1200);
- X case 2400:
- X return (B2400);
- X case 4800:
- X return (B4800);
- X case 9600:
- X return (B9600);
- X
- X#if defined(B19200)
- X case 19200:
- X return (B19200);
- X#else
- X#ifdef EXTA
- X case 19200:
- X return (EXTA);
- X#endif
- X#endif
- X
- X#if defined(B38400)
- X case 38400:
- X return (B38400);
- X#else
- X#ifdef EXTB
- X case 38400:
- X return (EXTB);
- X#endif
- X#endif
- X
- X }
- X myexit(RC_FAIL | RCE_SPEED);
- X#if defined(OPTIMIZE) || defined(__OPTIMIZE__) /* don't complain */
- X return (0); /* keep gcc from complaining about no rtn at
- X * end */
- X#endif
- X} /* end of DCE_baud_to_CBAUD */
- X
- X/*+-------------------------------------------------------------------------
- X DCE_hangup() - issue hangup command to DCE
- X
- XThis function should do whatever is necessary to ensure
- X1) any active connection is terminated
- X2) the DCE is ready to receive an incoming call if DTR is asserted
- X3) the DCE will not accept an incoming call if DTR is false
- X
- XThe function should return when done.
- X
- XAny necessary switch setting or other configuration necessary for this
- Xfunction to succeed should be documented at the top of the module.
- X--------------------------------------------------------------------------*/
- Xvoid
- XDCE_hangup()
- X{
- X DEBUG(3, "--> reseting %s\n", DCE_name);
- X lflash_DTR();
- X
- X} /* end of DCE_hangup */
- X
- X/*+-------------------------------------------------------------------------
- X DCE_dial(telno) - dial a remote DCE
- X
- XThis function should connect to the remote DCE and use any success
- Xindication to modify the tty baud rate if necessary before returning.
- X
- XUpon successful connection, return 0.
- X
- XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
- XRCE_XXX value from dialer.h.
- X
- Xlwrite() is used to write to the DCE.
- X
- Xlread() and lread_ignore() are used to read from the DCE. Read timeouts
- Xfrom calling lread() will result automatically in the proper error
- Xtermination of the program. Read timeouts from calling lread_ignore()
- Xreturn -1; you handle the execption here.
- X
- XAny necessary coding of phone numbers, switch settings or other
- Xconfiguration necessary for this function to succeed should be
- Xdocumented at the top of the module.
- X--------------------------------------------------------------------------*/
- Xint
- XDCE_dial(telno)
- Xchar *telno;
- X{
- X char cmd[80];
- X
- X/* preliminary setup */
- X
- X/* if root, let him see number, otherwise just say "remote system" */
- X DEBUG(1, "DIALING %s\n", (uid) ? "remote system" : telno);
- X
- X/* indicate non-root should not see DTE->DCE traffic */
- X secure = 1;
- X
- X/* issue the actual dialing command */
- X
- X/* indicate non-root can see DTE->DCE traffic */
- X secure = 0;
- X
- X return (0); /* succeeded */
- X
- X} /* end of DCE_dial */
- X
- X/**********************************************************
- X* You probably do not need to modify the code below here *
- X**********************************************************/
- X
- X/*+-------------------------------------------------------------------------
- X DCE_abort(sig) - dial attempt aborted
- X
- X sig = 0 if non-signal abort (read timeout, most likely)
- X != 0 if non-SIGALRM signal caught
- X
- X extern int dialing set 1 if dialing request was active,
- X else 0 if hangup request was active
- X
- XThis is a chance for the DCE-specific code to do anything it
- Xneeds to cl,ean up after a failure. Note that if a dialing
- Xcall fails, it is the responsibility of the higher-level
- Xprogram calling the dialer to call it again with a hangup request, so
- Xthis function is usually a no-op.
- X--------------------------------------------------------------------------*/
- Xvoid
- XDCE_abort(sig)
- Xint sig;
- X{
- X DEBUG(10, "DCE_abort(%d);\n", sig);
- X} /* end of DCE_abort */
- X
- X/*+-------------------------------------------------------------------------
- X DCE_exit(exitcode) - "last chance for gas" in this incarnation
- X
- XThe independent portion of the dialer program calls this routine in
- Xlieu of exit() in every case except one (see DCE_argv_hook() below).
- XNormally, this function just passes it's argument to exit(), but
- Xany necessary post-processing can be done. The function must,
- Xhowever, eventually call exit(exitcode);
- X--------------------------------------------------------------------------*/
- Xvoid
- XDCE_exit(exitcode)
- Xint exitcode;
- X{
- X DEBUG(10, "DCE_exit(%d);\n", exitcode);
- X exit(exitcode);
- X} /* end of DCE_exit */
- X
- X/*+-------------------------------------------------------------------------
- X DCE_argv_hook(argc,argv,optind,unrecognized_switches)
- X
- XThis hook gives DCE-specific code a chance to look over the entire
- Xcommand line, such as for -z Telebit processing.
- X
- Xargc andf argv are the same values passed to main(),
- X
- Xoptind is the value of optind at the end of normal getopt processing.
- X
- Xunrecognized_switches is the count of switches not handled by main().
- XSpecifically, -h and -x are standard switches.
- X
- XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
- Xany unrecognized switches, otherwise zero. If you keep your nose clean
- Xthough, you can do anything you need to do here and exit the program.
- X
- XNote: only simple switches (with no argument) may be used with this
- Xfacility if the functrion is to return,' since main()'s getopt() will
- Xstop processing switches if it runs into an unrecognized switch with an
- Xargument.
- X
- XIf the function returns a non-zero value, then the value will be passed
- XDIRECTLY to exit() with no further ado. Thus, a non-zero value must be
- Xof the format expected by dialer program callers, with RC_FAIL set as a
- Xminimum.
- X--------------------------------------------------------------------------*/
- Xint
- XDCE_argv_hook(argc, argv, optind, unrecognized_switches)
- Xint argc;
- Xchar **argv;
- Xint optind;
- Xint unrecognized_switches;
- X{
- X if (unrecognized_switches)
- X return (RC_FAIL | RCE_ARGS);
- X return (0);
- X} /* end of DCE_argv_hook */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 10468 -ne `wc -c <'ecu330/gendial/template.c'`; then
- echo shar: \"'ecu330/gendial/template.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/gendial/template.c'
- fi
- if test -f 'ecu330/gint.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/gint.c'\"
- else
- echo shar: Extracting \"'ecu330/gint.c'\" \(7568 characters\)
- sed "s/^X//" >'ecu330/gint.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X gint.c - ecu get integer parameter functions
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X gcol_range(param,col1,col2)
- X gint(param,int_returned)
- X gint_base(param,value)
- X gint_constant(param,value)
- X gintop(param,intop)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:12-20-1992-00:13-wht@n4hgf-add shift operators */
- X/*:12-12-1992-13:39-wht@n4hgf-use relop.h for OP_ definitions */
- X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
- X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
- X/*:01-31-1991-16:50-wht@n4hgf-reinstate octal with 0o prefix */
- X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "ecu.h"
- X#include "ecuerror.h"
- X#include "esd.h"
- X#include "var.h"
- X#include "relop.h"
- X
- X#define BASE_DEC 1
- X#define BASE_OCT 2
- X#define BASE_HEX 3
- X
- X/*+-------------------------------------------------------------------------
- X gint_constant(param,int_returned) - evaluate integer constant
- X--------------------------------------------------------------------------*/
- Xint
- Xgint_constant(param, value)
- XESD *param;
- Xlong *value;
- X{
- X register itmp;
- X int base = BASE_DEC;
- X int erc;
- X long new_value;
- X
- X if (erc = skip_cmd_break(param))
- X return (erc);
- X esd_null_terminate(param);
- X
- X/* get integer from string */
- X if ((!strncmp(param->pb + param->index, "0x", 2)) ||
- X (!strncmp(param->pb + param->index, "0X", 2)))
- X {
- X base = BASE_HEX;
- X param->index += 2;
- X }
- X else if ((!strncmp(param->pb + param->index, "0o", 2)) ||
- X (!strncmp(param->pb + param->index, "0O", 2)))
- X {
- X base = BASE_OCT;
- X param->index += 2;
- X }
- X
- X param->old_index = param->index;
- X switch (base)
- X {
- X case BASE_HEX:
- X sscanf(param->pb + param->index, "%lx", &new_value);
- X itmp = param->index + strspn(param->pb + param->index,
- X "0123456789ABCDEFabcdef");
- X erc = eInvalidHexNumber;
- X break;
- X case BASE_DEC:
- X sscanf(param->pb + param->index, "%ld", &new_value);
- X itmp = param->index + strspn(param->pb + param->index, "0123456789");
- X erc = eInvalidDecNumber;
- X break;
- X case BASE_OCT:
- X sscanf(param->pb + param->index, "%lo", &new_value);
- X itmp = param->index + strspn(param->pb + param->index, "01234567");
- X erc = eInvalidOctNumber;
- X break;
- X default:
- X return (eInternalLogicError);
- X }
- X
- X param->index = itmp;
- X if (isalnum(*(param->pb + itmp)))
- X param->old_index = itmp;
- X
- X if (param->old_index != param->index)
- X {
- X *value = new_value;
- X return (0);
- X }
- X return (erc);
- X
- X} /* end of gint_constant */
- X
- X/*+-------------------------------------------------------------------------
- X gint_base(param,value) - evaluate integer constant, variable or function
- X--------------------------------------------------------------------------*/
- Xint
- Xgint_base(param, value)
- XESD *param;
- Xlong *value;
- X{
- X register erc;
- X long *varptr;
- X
- X if (erc = skip_cmd_break(param))
- X return (erc);
- X
- X switch (param->pb[param->index]) /* look at first character */
- X {
- X case '$': /* '$i...' variable reference? */
- X if (param->index >= param->cb - 2)
- X return (eSyntaxError);
- X param->old_index = ++param->index;
- X if (to_lower(param->pb[param->index++]) != 'i')
- X return (eIllegalVarType);
- X if (erc = get_ivptr(param, &varptr, 0))
- X return (erc);
- X *value = *varptr;
- X return (0);
- X
- X case '%': /* '%...' function reference? */
- X param->index++;
- X if (erc = feval_int(param, value))
- X return (erc);
- X return (0);
- X
- X default:
- X break;
- X } /* end of switch statement */
- X
- X/* we did not catch any special cases with the switch statement must
- Xbe numeric integer */
- X
- X return (gint_constant(param, value));
- X
- X} /* end of gint_base() */
- X
- X/*+-------------------------------------------------------------------------
- X gintop(param,intop) - evaluate integer operator
- X--------------------------------------------------------------------------*/
- Xint
- Xgintop(param, intop)
- XESD *param;
- Xint *intop;
- X{
- X register erc;
- X
- X if (erc = skip_cmd_break(param))
- X return (erc);
- X switch (param->pb[param->index])
- X {
- X case '+':
- X param->index++;
- X *intop = OP_ADD;
- X break;
- X
- X case '-':
- X param->index++;
- X *intop = OP_SUB;
- X break;
- X
- X case '*':
- X param->index++;
- X *intop = OP_MUL;
- X break;
- X
- X case '/':
- X param->index++;
- X *intop = OP_DIV;
- X break;
- X
- X case '|':
- X if (*(param->pb + param->index + 1) == '|')
- X return (eInvalidIntOp);
- X param->index++;
- X *intop = OP_OR;
- X break;
- X
- X case '@':
- X param->index++;
- X *intop = OP_MOD;
- X break;
- X
- X case '^':
- X param->index++;
- X *intop = OP_XOR;
- X break;
- X
- X case '&':
- X if (*(param->pb + param->index + 1) == '&')
- X return (eInvalidIntOp);
- X param->index++;
- X *intop = OP_AND;
- X break;
- X
- X case '<':
- X if (*(param->pb + param->index + 1) != '<')
- X return (eInvalidIntOp);
- X param->index += 2;
- X *intop = OP_SHL;
- X break;
- X
- X case '>':
- X if (*(param->pb + param->index + 1) != '>')
- X return (eInvalidIntOp);
- X param->index += 2;
- X *intop = OP_SHR;
- X break;
- X
- X default:
- X return (eInvalidIntOp);
- X } /* end of switch statement */
- X
- X return (0);
- X
- X} /* end of gintop() */
- X
- X/*+-------------------------------------------------------------------------
- X gint(param,int_returned) - evaluate integer expression
- X--------------------------------------------------------------------------*/
- Xint
- Xgint(param, int_returned)
- XESD *param;
- Xlong *int_returned;
- X{
- X register erc;
- X long int1;
- X long int_accum = 0;
- X int intop;
- X int unary_minus = 0;
- X
- X if (erc = skip_cmd_break(param))
- X return (erc);
- X if (param->pb[param->index] == '-')
- X unary_minus++, param->index++;
- X
- X if (erc = gint_base(param, &int1))
- X return (erc);
- X int_accum = (unary_minus) ? -int1 : int1;
- X
- X while ((erc = gintop(param, &intop)) == 0)
- X {
- X if (erc = gint_base(param, &int1))
- X return (erc);
- X switch (intop)
- X {
- X case OP_ADD:
- X int_accum += int1;
- X break;
- X case OP_SUB:
- X int_accum -= int1;
- X break;
- X case OP_MUL:
- X int_accum *= int1;
- X break;
- X case OP_DIV:
- X int_accum /= int1;
- X break;
- X case OP_MOD:
- X int_accum %= int1;
- X break;
- X case OP_XOR:
- X int_accum ^= (unsigned)int1;
- X break;
- X case OP_AND:
- X int_accum &= (unsigned)int1;
- X break;
- X case OP_OR:
- X int_accum |= (unsigned)int1;
- X break;
- X case OP_SHL:
- X int_accum <<= (unsigned)int1;
- X break;
- X case OP_SHR:
- X int_accum >>= (unsigned)int1;
- X break;
- X default:
- X return (eInvalidIntOp);
- X }
- X }
- X param->index = param->old_index;
- X
- X *int_returned = int_accum;
- X return (0);
- X} /* end of gint() */
- X
- X/*+-------------------------------------------------------------------------
- X col_range(param,col1,col2) - get a column range
- X:$i0[-$i1]
- Xargument may be integer constant, function or variable, but not expression
- X--------------------------------------------------------------------------*/
- Xint
- Xgcol_range(param, col1, col2)
- XESD *param;
- Xulong *col1;
- Xulong *col2;
- X{
- X register erc;
- X
- X if (skip_cmd_char(param, ':') == 0)
- X {
- X if (erc = gint_base(param, col1))
- X return (erc);
- X
- X if (skip_cmd_char(param, '-') == 0) /* if hyphen found, range */
- X {
- X if (erc = gint_base(param, col2))
- X return (erc);
- X }
- X else
- X *col2 = *col1; /* otherwise, first and last columns same */
- X
- X if (*col1 > *col2)
- X {
- X pputs("Invalid column range: column 1 greater than column 2\n");
- X return (eFATAL_ALREADY);
- X }
- X }
- X else
- X erc = eBadParameter;
- X
- X return (erc);
- X} /* end of gcol_range() */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of gint.c */
- END_OF_FILE
- if test 7568 -ne `wc -c <'ecu330/gint.c'`; then
- echo shar: \"'ecu330/gint.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/gint.c'
- fi
- if test -f 'ecu330/help/helpgen.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/help/helpgen.c'\"
- else
- echo shar: Extracting \"'ecu330/help/helpgen.c'\" \(10358 characters\)
- sed "s/^X//" >'ecu330/help/helpgen.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X helpgen.c -- ecu command help file maker
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X build_ecudoc()
- X build_ecuhelp()
- X main(argc,argv,envp)
- X search_cmd_list(cmd)
- X show_cmds()
- X test_help()
- X usage()
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
- X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
- X/*:07-12-1991-14:50-wht@n4hgf-remove obsolete ecuhelp.txt generator */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X
- X#include "../ecu_types.h"
- X#include "../ecutermio.h"
- X
- X#define DECLARE_P_CMD
- X#define HELPGEN
- Xtypedef int (*PFI) (); /* pointer to function returning integer */
- X#include "../ecucmd.h"
- X
- X#include "../esd.h"
- X
- X#define PSRC "ecuhelp.src"
- X#define PDAT "ecuhelp.data"
- X#define PDOC "ecuhelp.doc"
- X
- Xlong start_pos[TOKEN_QUAN];
- Xint token_line[TOKEN_QUAN];
- XFILE *fpsrc; /* help source file */
- XFILE *fpdat; /* help data file */
- XFILE *fpdoc; /* help doc file */
- XFILE *fptxt; /* help nroff file */
- XP_CMD *pcmd;
- Xint src_line = 0;
- Xchar buf[128];
- X
- X/*+-------------------------------------------------------------------------
- X usage()
- X--------------------------------------------------------------------------*/
- Xusage()
- X{
- X fprintf(stderr, "usage: helpgen [-b] [-d] [-s] [-t]\n");
- X fprintf(stderr, " -b build %s from %s\n", PDAT, PSRC);
- X fprintf(stderr, " -d build %s from %s\n", PDOC, PDAT);
- X fprintf(stderr, " -s show list of commands\n");
- X fprintf(stderr, " -t test help\n");
- X fprintf(stderr, "At least one switch must be issued. They are executed\n");
- X fprintf(stderr, "in the order shown on the usage line.\n");
- X exit(1);
- X} /* end of usage */
- X
- X/*+-------------------------------------------------------------------------
- X search_cmd_list(cmd)
- X--------------------------------------------------------------------------*/
- XP_CMD *
- Xsearch_cmd_list(cmd)
- Xregister char *cmd;
- X{
- X register P_CMD *cmd_list = icmd_cmds;
- X
- X while (cmd_list->token != -1)
- X {
- X if (strcmp(cmd_list->cmd, cmd) == 0)
- X break;
- X cmd_list++;
- X }
- X if (cmd_list->token == -1)
- X return ((P_CMD *) 0);
- X else
- X return (cmd_list);
- X
- X} /* end of search_cmd_list */
- X
- X/*+-------------------------------------------------------------------------
- X show_cmds()
- Xcommands with null descriptions are "undocumented"
- X--------------------------------------------------------------------------*/
- Xvoid
- Xshow_cmds()
- X{
- X register int itmp;
- X register P_CMD *this = icmd_cmds;
- X register int longest_cmd = 0;
- X register int longest_descr = 0;
- X register int nl_flag = 0;
- X char s80[80];
- X P_CMD *longest_cmd_p = 0;
- X P_CMD *longest_descr_p = 0;
- X
- X while (this->token != -1)
- X {
- X if (!*this->descr)
- X {
- X this++;
- X continue;
- X }
- X itmp = strlen(this->cmd);
- X if (itmp > longest_cmd)
- X {
- X longest_cmd = itmp;
- X longest_cmd_p = this;
- X }
- X itmp = strlen(this->descr);
- X if (itmp > longest_descr)
- X {
- X longest_descr = itmp;
- X longest_descr_p = this;
- X }
- X this++;
- X }
- X this = icmd_cmds;
- X while (this->token != -1)
- X {
- X if ((!this->min_ch) || (!*this->descr))
- X {
- X this++;
- X continue;
- X }
- X strcpy(s80, this->cmd);
- X pad_zstr_to_len(s80, longest_cmd + 2);
- X for (itmp = 0; itmp < this->min_ch; itmp++)
- X s80[itmp] = to_upper(s80[itmp]);
- X fputs(s80, stderr);
- X
- X strcpy(s80, this->descr);
- X pad_zstr_to_len(s80, longest_descr + 1);
- X fputs(s80, stderr);
- X
- X if (nl_flag)
- X fputs("\r\n", stderr);
- X else
- X fputs("| ", stderr);
- X nl_flag = (nl_flag) ? 0 : 1;
- X
- X this++;
- X }
- X if (nl_flag)
- X fputs("\r\n", stderr);
- X
- X itmp = longest_cmd + longest_descr + 5;
- X sprintf(s80, "recwidth = %d\r\n", itmp);
- X fprintf(stderr, s80);
- X this = longest_cmd_p;
- X sprintf(s80, "longest cmd: %s: %s\r\n", this->cmd, this->descr);
- X fprintf(stderr, s80);
- X this = longest_descr_p;
- X sprintf(s80, "longest dsc: %s: %s\r\n", this->cmd, this->descr);
- X fprintf(stderr, s80);
- X
- X} /* end of show_cmds */
- X
- X/*+-------------------------------------------------------------------------
- X build_ecuhelp()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xbuild_ecuhelp()
- X{
- X register int itmp;
- X register char *cptr;
- X P_CMD *this;
- X
- X printf("\nBuilding %s\n", PDAT);
- X
- X/* use proc cmd entry for flag */
- X this = icmd_cmds;
- X while (this->token != -1)
- X {
- X this->proc = (PFI) 0;
- X this++;
- X }
- X
- X for (itmp = 0; itmp < TOKEN_QUAN; itmp++)
- X {
- X start_pos[itmp] = 0L;
- X token_line[itmp] = 0;
- X }
- X
- X if ((fpsrc = fopen(PSRC, "r")) == NULL)
- X {
- X perror(PSRC);
- X exit(1);
- X }
- X
- X if ((fpdat = fopen(PDAT, "w")) == NULL)
- X {
- X perror(PDAT);
- X exit(1);
- X }
- X
- X fwrite((char *)start_pos, sizeof(long), /* write null table */
- X TOKEN_QUAN, fpdat);
- X
- X while (fgets(buf, sizeof(buf), fpsrc) != NULL)
- X {
- X src_line++;
- X itmp = strlen(buf);
- X buf[--itmp] = 0; /* kill trailing nl */
- X if (buf[0] == '#') /* ignore comments */
- X continue;
- X if (buf[0] == '%') /* command indication */
- X {
- X SEARCH_CMD_LIST:
- X if (!(this = search_cmd_list(&buf[1])))
- X {
- X#ifdef notdef /* primarily because of 'eto' and 'fasi' */
- X printf("line %d: '%s' not in command table\n",
- X src_line, &buf[1]);
- X#endif
- X while (fgets(buf, sizeof(buf), fpsrc) != NULL)
- X {
- X src_line++;
- X itmp = strlen(buf);
- X buf[--itmp] = 0; /* kill trailing nl */
- X if (buf[0] == '%') /* command indication */
- X goto SEARCH_CMD_LIST;
- X }
- X break;
- X }
- X if (start_pos[this->token])
- X {
- X printf("line %d: '%s' already found on line %d\n",
- X src_line, &buf[1], token_line[this->token]);
- X exit(1);
- X }
- X fputs("\n", fpdat); /* terminate previous command description */
- X start_pos[this->token] = ftell(fpdat);
- X token_line[this->token] = src_line;
- X fputs(" ", fpdat);
- X cptr = &buf[1]; /* command text */
- X itmp = 0;
- X this->proc = (PFI) 1; /* indicate we save command info */
- X while (*cptr) /* show cmd and min chars required */
- X {
- X if (itmp < this->min_ch)
- X fputc(to_upper(*cptr++), fpdat);
- X else
- X fputc(to_lower(*cptr++), fpdat);
- X itmp++;
- X }
- X if (*this->descr)/* if description present */
- X fprintf(fpdat, " : %s\n \n", this->descr);
- X else
- X fputs("\n \n", fpdat);
- X continue;
- X }
- X fprintf(fpdat, " %s\n", buf);
- X }
- X
- X fseek(fpdat, 0L, 0); /* back to position table */
- X fwrite((char *)start_pos, sizeof(long), /* write actual table */
- X TOKEN_QUAN, fpdat);
- X fclose(fpsrc);
- X fputs("\n", fpdat); /* terminate last command */
- X fclose(fpdat);
- X
- X/* say which commands weren't in the help source */
- X this = icmd_cmds;
- X while (this->token != -1)
- X {
- X if (this->min_ch && !this->proc)
- X fprintf(stderr, "'%s' not in help source\n", this->cmd);
- X this++;
- X }
- X
- X} /* end of build_ecuhelp */
- X
- X/*+-------------------------------------------------------------------------
- X build_ecudoc()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xbuild_ecudoc()
- X{
- X register int itmp;
- X
- X printf("\nBuilding %s\n", PDOC);
- X if ((fpdat = fopen(PDAT, "r")) == NULL)
- X {
- X perror(PDAT);
- X exit(1);
- X }
- X if ((fpdoc = fopen(PDOC, "w")) == NULL)
- X {
- X perror(PDOC);
- X exit(1);
- X }
- X fprintf(fpdoc,
- X "\n ECU Command Help Documentation (PRELIMINARY)\n\n");
- X fprintf(fpdoc,
- X "Commands are accessed by pressing the HOME key followed by one\n");
- X fprintf(fpdoc,
- X "of the following commands (capitalized portions are sufficient\n");
- X fprintf(fpdoc,
- X "to invoke the command):\n");
- X fprintf(fpdoc, "\n");
- X fprintf(fpdoc,
- X "---------------------------------------------------------------------\n");
- X fread((char *)start_pos, sizeof(long), TOKEN_QUAN, fpdat);
- X
- X pcmd = icmd_cmds;
- X while (pcmd->token != -1)
- X {
- X if (!pcmd->token)
- X {
- X pcmd++;
- X continue;
- X }
- X if (pcmd->min_ch && !start_pos[pcmd->token])
- X {
- X printf("no help available for '%s'\n", pcmd->cmd);
- X pcmd++;
- X continue;
- X }
- X fseek(fpdat, start_pos[pcmd->token], 0);
- X while (fgets(buf, sizeof(buf), fpdat) != NULL)
- X {
- X itmp = strlen(buf);
- X buf[--itmp] = 0;
- X if (itmp == 0)
- X break;
- X fprintf(fpdoc, "%s\n", buf);
- X }
- X fprintf(fpdoc,
- X "---------------------------------------------------------------------\n");
- X pcmd++;
- X }
- X fclose(fpdat);
- X fclose(fpdoc);
- X} /* end of build_ecudoc */
- X
- X/*+-------------------------------------------------------------------------
- X test_help()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xtest_help()
- X{
- X register int itmp;
- X
- X/* test code */
- X printf("\nNow to test\n");
- X if ((fpdat = fopen(PDAT, "r")) == NULL)
- X {
- X perror(PDAT);
- X exit(1);
- X }
- X fread((char *)start_pos, sizeof(long), TOKEN_QUAN, fpdat);
- X
- X while (1)
- X {
- X printf("\ncommand: ");
- X fgets(buf, sizeof(buf), stdin);
- X itmp = strlen(buf);
- X buf[--itmp] = 0;
- X if (itmp == 0)
- X break;
- X if (!(pcmd = search_cmd_list(buf)))
- X {
- X printf("'%s' not found in ecu cmd table\n", buf);
- X continue;
- X }
- X if (pcmd->min_ch && !start_pos[pcmd->token])
- X {
- X printf("no help available for '%s'\n", buf);
- X continue;
- X }
- X fseek(fpdat, start_pos[pcmd->token], 0);
- X while (fgets(buf, sizeof(buf), fpdat) != NULL)
- X {
- X itmp = strlen(buf);
- X buf[--itmp] = 0;
- X if (itmp == 0)
- X break;
- X printf("%s\n", buf);
- X }
- X }
- X} /* end of test_help */
- X
- X/*+-------------------------------------------------------------------------
- X main(argc,argv,envp)
- X--------------------------------------------------------------------------*/
- Xmain(argc, argv, envp)
- Xint argc;
- Xchar **argv;
- Xchar **envp;
- X{
- X register int itmp;
- X int iargv;
- X int b_flag = 0;
- X int s_flag = 0;
- X int t_flag = 0;
- X int f_flag = 0;
- X int d_flag = 0;
- X
- X setbuf(stdout, NULL);
- X setbuf(stderr, NULL);
- X
- X if (argc < 1)
- X usage();
- X for (iargv = 1; iargv < argc; iargv++)
- X {
- X if (argv[iargv][0] == '-')
- X {
- X switch (itmp = (argv[iargv][1]))
- X {
- X case 'b':
- X b_flag = 1;
- X break;
- X case 's':
- X s_flag = 1;
- X break;
- X case 't':
- X t_flag = 1;
- X break;
- X case 'd':
- X d_flag = 1;
- X break;
- X default:
- X usage();
- X break;
- X }
- X }
- X else
- X usage();
- X }
- X if (!b_flag && !s_flag && !t_flag && !d_flag && !f_flag)
- X usage();
- X
- X if (b_flag)
- X build_ecuhelp();
- X if (d_flag)
- X build_ecudoc();
- X if (s_flag)
- X show_cmds();
- X if (t_flag)
- X test_help();
- X
- X exit(0);
- X} /* end of main */
- X/* end of helpgen.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 10358 -ne `wc -c <'ecu330/help/helpgen.c'`; then
- echo shar: \"'ecu330/help/helpgen.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/help/helpgen.c'
- fi
- echo shar: End of archive 30 \(of 37\).
- cp /dev/null ark30isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 37 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-