home *** CD-ROM | disk | FTP | other *** search
- From: wht@n4hgf.atl.ga.us (Warren Tucker)
- Newsgroups: comp.sources.misc
- Subject: v42i123: ecu - ECU Asynchronous Communications v3.30, Part25/37
- Date: 24 May 1994 09:07:33 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2rt1n5$d4r@sparky.sterling.com>
- X-Md4-Signature: b0251f95d9ee1ae243c8efabde6eac2c
-
- Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
- Posting-number: Volume 42, Issue 123
- Archive-name: ecu/part25
- 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/ecufork.c ecu330/funckeymap.c
- # ecu330/gendial/dceMPAD.c ecu330/pcmdif.c ecu330/termecu.h
- # Wrapped by kent@sparky on Mon May 23 13:40:59 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 25 (of 37)."'
- if test -f 'ecu330/ecufork.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecufork.c'\"
- else
- echo shar: Extracting \"'ecu330/ecufork.c'\" \(14274 characters\)
- sed "s/^X//" >'ecu330/ecufork.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X ecufork.c -- ecu spawning ground
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X exec_cmd(cmdstr)
- X expand_wildcard_list(wild,expcmd)
- X find_executable(progname)
- X is_executable(progname)
- X shell(shellcmd)
- X smart_fork()
- X
- X This boy is no longer a boy. Now he is a man. He is a small
- X boy, but his heart is big. His name shall be Little Big Man.
- X -- Chief Lodge Skins
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
- X/*:01-06-1994-05:52-wht@n4hgf-clean up LINUX port */
- X/*:12-12-1993-13:27-wht@n4hgf-differentiate MAX_EXEC_ARG only for i286 */
- X/*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
- 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/*:04-29-1992-13:29-wht@n4hgf-ignore SIGQUIT when in executing a child */
- X/*:09-25-1991-18:02-wht@n4hgf2-find_executable flunks directories now */
- X/*:09-06-1991-04:20-wht@n4hgf2-expand_wildcard_list minor bug */
- X/*:08-29-1991-01:56-wht@n4hgf2-use max esd size instead of 5120 */
- X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
- X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
- X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "ecu.h"
- X#include "esd.h"
- X#include "ecufork.h"
- X
- Xextern int last_child_wait_status;
- Xextern int last_child_wait_pid;
- X
- X#ifdef M_I286
- X#define MAX_EXEC_ARG 512
- X#else
- X#define MAX_EXEC_ARG 2048
- X#endif /* M_I286 */
- X
- X#ifdef LINUX
- Xchar *expander_shell_path = "/bin/bash";
- Xchar *expander_shell = "bash";
- X
- X#else
- Xchar *expander_shell_path = "/bin/csh";
- Xchar *expander_shell = "csh";
- X
- X#endif
- X
- X/*+-------------------------------------------------------------------------
- X smart_fork()
- X--------------------------------------------------------------------------*/
- Xint
- Xsmart_fork()
- X{
- X register int count = 5;
- X register int pid;
- X
- X while (count--)
- X {
- X if ((pid = fork()) >= 0)
- X return (pid);
- X if (count)
- X Nap(40L);
- X }
- X return (-1);
- X} /* end of smart_fork */
- X
- X/*+-----------------------------------------------------------------------
- X shell(shellcmd)
- X
- X param 'shellcmd' is a shell command prefixed with either
- X a '!', '$', '>' character.
- X
- X '!' causes the command to run as a normal subshell of a process.
- X '$' causes the communications line to be stdin and stdout
- X for the spawned shell
- X '>' causes spawned shell to receive exactly sames files as ecu
- X------------------------------------------------------------------------*/
- Xvoid
- Xshell(shellcmd)
- Xchar *shellcmd;
- X{
- X register shellpid;
- X register itmp;
- X register char *cptr;
- X
- X#if defined(FORK_DEBUG)
- X char s80[80];
- X
- X#endif
- X int wait_status;
- X int restart_rcvr = need_rcvr_restart();
- X char *getenv();
- X
- X kill_rcvr_process(SIGUSR1); /* stop receiver process gracefully */
- X
- X signal(SIGINT, SIG_IGN);
- X signal(SIGQUIT, SIG_IGN);
- X signal(SIGUSR1, SIG_IGN);
- X signal(SIGUSR2, SIG_IGN);
- X signal(SIGCLD, SIG_DFL);
- X
- X if ((shellpid = smart_fork()) < 0)
- X {
- X ff(se, "Cannot fork\r\n");
- X if (restart_rcvr)
- X start_rcvr_process(1);
- X xmtr_signals();
- X return;
- X }
- X
- X#ifdef LINUX
- X endwin();
- X#endif
- X ttymode(0); /* set canonical tty mode */
- X if (shellpid == 0) /* we are the spawned (going to call shell) */
- X {
- X if (*shellcmd != '>')/* '>' prefix means leave fd's alone! */
- X {
- X
- X /*
- X * Hook-up our "standard output" to either the tty or the line
- X * as appropriate for '!' or '$'
- X */
- X close(TTYOUT);
- X fcntl(((*shellcmd == '$') ? shm->Liofd : TTYERR), F_DUPFD, TTYOUT);
- X if (*shellcmd == '$')
- X {
- X close(TTYIN);
- X fcntl(shm->Liofd, F_DUPFD, TTYIN);
- X }
- X close(shm->Liofd);
- X }
- X
- X child_signals(); /* signals for child */
- X
- X if (*shellcmd == '!')
- X {
- X if (!(cptr = getenv("SHELL")))
- X cptr = expander_shell_path;
- X }
- X else
- X cptr = "/bin/sh";
- X
- X shellcmd++;
- X child_signals();
- X if (!*shellcmd)
- X execl(cptr, cptr, (char *)0);
- X else
- X execl(cptr, cptr, "-c", shellcmd, (char *)0);
- X ff(se, "cannot execute %s\r\n", cptr); /* should not get here */
- X _exit(255); /* end of spawned process */
- X } /* end of if child process */
- X
- X#if defined(FORK_DEBUG)
- X sprintf(s80, "DEBUG fork shell pid %d", shellpid);
- X ecu_log_event(getpid(), s80); /* shell */
- X#endif
- X
- X while (((itmp = wait(&wait_status)) != shellpid) && (itmp != -1))
- X ;
- X last_child_wait_status = wait_status;
- X last_child_wait_pid = shellpid;
- X
- X xmtr_signals(); /* restore standard xmtr signals */
- X ttymode(1); /* control tty back to raw mode */
- X
- X/* any comm program will probably doodle with the line characteristics. */
- X/* we want to make sure they are restored to normal */
- X lreset_ksr(); /* restore comm line params */
- X
- X if (restart_rcvr)
- X start_rcvr_process(1);
- X
- X} /* end of shell */
- X
- X/*+-------------------------------------------------------------------------
- X is_executable(progname)
- X--------------------------------------------------------------------------*/
- Xis_executable(progname)
- Xchar *progname;
- X{
- X struct stat ss;
- X
- X if (stat(progname, &ss) < 0) /* if cannot stat, flunk */
- X return (0);
- X if ((ss.st_mode & 0111) == 0) /* if no --x--x--x, flunk */
- X return (0);
- X if ((ss.st_mode & S_IFMT) != S_IFREG) /* if no --x--x--x, flunk */
- X return (0);
- X return (1); /* whew, this OUGHT to work */
- X
- X} /* end of is_executable */
- X
- X/*+-------------------------------------------------------------------------
- X find_executable(progname)
- XPATH=':/usr/wht/bin:/bin:/usr/bin:/usr/wht/bin:/etc/tuckerware' len=56
- X--------------------------------------------------------------------------*/
- Xchar *
- Xfind_executable(progname)
- Xchar *progname;
- X{
- X register itmp;
- X static char *path_buf = (char *)0;
- X
- X#define PATHNAME_QUAN 32
- X static char *path_name[PATHNAME_QUAN + 1];
- X static char rtn_path[256];
- X static int path_count = 0;
- X char *cptr;
- X char *getenv();
- X
- X if (path_buf == (char *)0)
- X {
- X if ((cptr = getenv("PATH")) == (char *)0)
- X return (cptr);
- X if (!(path_buf = malloc(strlen(cptr) + 1)))
- X return ((char *)0);
- X strcpy(path_buf, cptr);
- X path_name[PATHNAME_QUAN + 1] = (char *)0;
- X cptr = path_buf;
- X for (path_count = 0; path_count < PATHNAME_QUAN; path_count++)
- X {
- X if (*cptr == 0)
- X break;
- X path_name[path_count] = cptr;
- X while ((*cptr != ':') && (*cptr != 0))
- X cptr++;
- X if (*cptr == ':')
- X *cptr++ = 0;
- X }
- X } /* end of get and process path env variable */
- X
- X/* look for executable */
- X for (itmp = 0; itmp < path_count; itmp++)
- X {
- X if (*path_name[itmp] == 0) /* if null path (./) */
- X strcpy(rtn_path, "./");
- X else
- X sprintf(rtn_path, "%s/", path_name[itmp]);
- X strcat(rtn_path, progname);
- X if (is_executable(rtn_path))
- X return (rtn_path);
- X }
- X return ((char *)0);
- X} /* end of find_executable */
- X
- X/*+-------------------------------------------------------------------------
- X exec_cmd(cmdstr) - execute an arbitrary program with arguments
- Xkills rcvr process if alive and restarts it when done if was alive
- X--------------------------------------------------------------------------*/
- Xexec_cmd(cmdstr)
- Xchar *cmdstr;
- X{
- X char *cmdpath;
- X char *cmdargv[MAX_EXEC_ARG];
- X int itmp;
- X int execpid;
- X int restart_rcvr = need_rcvr_restart();
- X int old_ttymode = get_ttymode();
- X int wait_status = 0;
- X char *strrchr();
- X
- X#if defined(FORK_DEBUG)
- X char s256[256];
- X
- X strcpy(s256, "DEBUG exec ");
- X strncat(s256, cmdstr, sizeof(s256) - 12);
- X s256[sizeof(s256) - 12] = 0;
- X ecu_log_event(getpid(), s256);
- X#endif
- X
- X build_arg_array(cmdstr, cmdargv, MAX_EXEC_ARG, &itmp);
- X if (itmp == MAX_EXEC_ARG)
- X {
- X ff(se, "Too many arguments to command\r\n");
- X return (-1);
- X }
- X else if (!itmp)
- X {
- X ff(se, "null command\r\n");
- X return (-1);
- X }
- X
- X if (*cmdargv[0] == '/')
- X {
- X cmdpath = cmdargv[0];
- X cmdargv[0] = strrchr(cmdargv[0], '/') + 1;
- X }
- X else
- X {
- X if ((cmdpath = find_executable(cmdargv[0])) == (char *)0)
- X {
- X ff(se, "Cannot find %s\r\n", cmdargv[0]);
- X return (-1);
- X }
- X }
- X
- X kill_rcvr_process(SIGUSR1); /* stop receiver process gracefully */
- X
- X/* this code executed by the father (forking) process */
- X/* wait on death of child (morbid in life, but ok here) */
- X
- X signal(SIGINT, SIG_IGN);
- X signal(SIGQUIT, SIG_IGN);
- X signal(SIGUSR1, SIG_IGN);
- X signal(SIGUSR2, SIG_IGN);
- X signal(SIGCLD, SIG_DFL);
- X
- X if ((execpid = smart_fork()) < 0)
- X {
- X ff(se, "Cannot fork\r\n");
- X if (restart_rcvr)
- X start_rcvr_process(1);
- X xmtr_signals();
- X return (-1);
- X }
- X
- X if (execpid == 0) /* we are the spawned (going to call exec) */
- X {
- X ttymode(0); /* set canonical tty mode */
- X child_signals();
- X execv(cmdpath, cmdargv);
- X perror(cmdpath);
- X _exit(255); /* end of spawned process */
- X } /* end of if child process */
- X
- X wait_status = 0;
- X while (((itmp = wait(&wait_status)) != execpid) && (itmp != -1))
- X ;
- X last_child_wait_status = wait_status;
- X last_child_wait_pid = execpid;
- X
- X/* resume our normally scheduled program */
- X lreset_ksr(); /* restore comm line params */
- X ttymode(old_ttymode); /* control tty back to original */
- X if (restart_rcvr)
- X start_rcvr_process(1);
- X xmtr_signals();
- X return (last_child_wait_status);
- X
- X} /* end of exec_cmd */
- X
- X/*+-------------------------------------------------------------------------
- X expand_wildcard_list(wild,&expcmd)
- X
- Xcalled with 'foo <wildcardlist>' for command expansion prior to exec()
- X or '<wildcardlist>' to expand a list of files.
- X
- XIf called with 'foo'-style wild, anything you want to protect from csh
- Xglobbing or other interpretation must be properly protected (quoted) --
- XAND quoting will be removed one level by the csh.
- X
- Xif return 0, wild has been expanded, expcmd must be free()'d when done
- Xif return -1, error, expcmd has error message (static message: DO NOT FREE)
- X--------------------------------------------------------------------------*/
- Xexpand_wildcard_list(wild, expcmd)
- Xchar *wild;
- Xchar **expcmd;
- X{
- X register char *cptr;
- X
- X#define P_READ 0
- X#define P_WRITE 1
- X PID_T pipe_pid;
- X int stdout_pipe[2];
- X int stderr_pipe[2];
- X int count;
- X int expcmd_size = 0;
- X int itmp;
- X int wait_status;
- X int restart_rcvr = need_rcvr_restart();
- X FILE *fp_pipe = (FILE *) 0;
- X char *echo_cmd;
- X static char static_s256[256]; /* MUST BE STATIC */
- X static char *pipe_err_msg = "system error: no pipe";
- X static char *mem_err_msg = "system error: no memory";
- X
- X if (strchr(wild, '<') || strchr(wild, '>') || strchr(wild, '&'))
- X {
- X *expcmd = "illegal characters: '<', '>' or '&'";
- X return (-1);
- X }
- X
- X if (pipe(stdout_pipe) < 0)
- X {
- X *expcmd = pipe_err_msg;
- X return (-1);
- X }
- X if (pipe(stderr_pipe) < 0)
- X {
- X close(stdout_pipe[P_READ]);
- X close(stdout_pipe[P_WRITE]);
- X *expcmd = pipe_err_msg;
- X return (-1);
- X }
- X if (!(echo_cmd = malloc(strlen(wild) + 10)))
- X {
- X close(stdout_pipe[P_READ]);
- X close(stdout_pipe[P_WRITE]);
- X close(stderr_pipe[P_READ]);
- X close(stderr_pipe[P_WRITE]);
- X *expcmd = mem_err_msg;
- X return (-1);
- X }
- X
- X strcpy(echo_cmd, "echo ");
- X strcat(echo_cmd, wild);
- X
- X kill_rcvr_process(SIGUSR1); /* stop receiver process gracefully */
- X
- X signal(SIGINT, SIG_IGN);
- X signal(SIGQUIT, SIG_IGN);
- X signal(SIGUSR1, SIG_IGN);
- X signal(SIGUSR2, SIG_IGN);
- X signal(SIGCLD, SIG_DFL);
- X
- X if ((pipe_pid = smart_fork()) == 0)
- X {
- X int null = open("/dev/null", O_WRONLY, 0);
- X
- X close(stdout_pipe[P_READ]);
- X close(TTYOUT);
- X dup(stdout_pipe[P_WRITE]);
- X close(stdout_pipe[P_WRITE]);
- X close(TTYERR);
- X dup(stderr_pipe[P_WRITE]);
- X close(stderr_pipe[P_WRITE]);
- X close(null);
- X child_signals();
- X execl(expander_shell_path, expander_shell, "-e", "-c", echo_cmd, (char *)0);
- X _exit(255);
- X }
- X
- X#if defined(FORK_DEBUG)
- X sprintf(static_s256, "DEBUG expand pid %d", pipe_pid);
- X ecu_log_event(getpid(), static_s256); /* expand_wildcard_list */
- X#endif
- X
- X free(echo_cmd);
- X
- X close(stdout_pipe[P_WRITE]);
- X close(stderr_pipe[P_WRITE]);
- X if (pipe_pid == -1)
- X {
- X close(stdout_pipe[P_READ]);
- X close(stderr_pipe[P_READ]);
- X *expcmd = "could not fork";
- X if (restart_rcvr)
- X start_rcvr_process(0);
- X xmtr_signals();
- X return (-1);
- X }
- X
- X if (!(*expcmd = malloc(expcmd_size = ESD_MAXSZ)))
- X {
- X close(stdout_pipe[P_READ]);
- X close(stderr_pipe[P_READ]);
- X kill(pipe_pid, SIGKILL);
- X *expcmd = mem_err_msg;
- X if (restart_rcvr)
- X start_rcvr_process(0);
- X xmtr_signals();
- X return (-1);
- X }
- X
- X if (!(fp_pipe = fdopen(stdout_pipe[P_READ], "r")) ||
- X ((count = fread(*expcmd, 1, expcmd_size, fp_pipe)) < 0))
- X {
- X free(*expcmd);
- X kill(pipe_pid, SIGKILL);
- X close(stdout_pipe[P_READ]);
- X close(stderr_pipe[P_READ]);
- X *expcmd = "error reading wild list expansion";
- X if (restart_rcvr)
- X start_rcvr_process(0);
- X xmtr_signals();
- X return (-1);
- X }
- X
- X /*
- X * make sure stdout is closed
- X */
- X if (fp_pipe)
- X fclose(fp_pipe);
- X close(stdout_pipe[P_READ]);
- X
- X /*
- X * place trailing null kill trailing new line
- X */
- X if (count)
- X {
- X cptr = (*expcmd) + count;
- X *cptr-- = 0;
- X if (*cptr == '\n')
- X {
- X *cptr = 0;
- X count--;
- X }
- X }
- X
- X /*
- X * if no expansion, read stderr to find out why
- X */
- X if (!count)
- X {
- X free(*expcmd);
- X count = read(stderr_pipe[P_READ], static_s256, sizeof(static_s256) - 1);
- X if (count < 0)
- X strcpy(static_s256, errno_text(errno));
- X else
- X static_s256[count] = 0;
- X if (static_s256[count - 1] == '\n')
- X static_s256[count - 1] = 0;
- X close(stderr_pipe[P_READ]);
- X if (strncmp(static_s256, "echo: ", 6))
- X *expcmd = static_s256;
- X else
- X *expcmd = static_s256 + 6;
- X if (restart_rcvr)
- X start_rcvr_process(0);
- X return (-1);
- X }
- X
- X /*
- X * clean up zombie
- X */
- X wait_status = 0;
- X while (((itmp = wait(&wait_status)) != pipe_pid) && (itmp != -1))
- X ;
- X
- X xmtr_signals();
- X
- X /*
- X * if bad termination status, read stderr
- X */
- X if (wait_status)
- X {
- X free(*expcmd);
- X count = read(stderr_pipe[P_READ], static_s256, sizeof(static_s256) - 1);
- X if (count < 0)
- X strcpy(static_s256, errno_text(errno));
- X else
- X static_s256[count] = 0;
- X if (static_s256[count - 1] == '\n')
- X static_s256[count - 1] = 0;
- X close(stderr_pipe[P_READ]);
- X if (strncmp(static_s256, "echo: ", 6))
- X *expcmd = static_s256;
- X else
- X *expcmd = static_s256 + 6;
- X if (restart_rcvr)
- X start_rcvr_process(0);
- X return (-1);
- X }
- X close(stderr_pipe[P_READ]);
- X
- X /*
- X * whew: we have (I think) a file list expansion
- X */
- X if (restart_rcvr)
- X start_rcvr_process(0);
- X
- X return (0);
- X} /* end of expand_wildcard_list */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of ecufork.c */
- END_OF_FILE
- if test 14274 -ne `wc -c <'ecu330/ecufork.c'`; then
- echo shar: \"'ecu330/ecufork.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecufork.c'
- fi
- if test -f 'ecu330/funckeymap.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/funckeymap.c'\"
- else
- echo shar: Extracting \"'ecu330/funckeymap.c'\" \(14339 characters\)
- sed "s/^X//" >'ecu330/funckeymap.c' <<'END_OF_FILE'
- X/* #define NONANSI_DEBUG */
- X/*+-----------------------------------------------------------------
- X funckeymap.c - keyboard function key -> ECU internal
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X fkmap_command(argc,argv)
- X funckeymap(buf,buflen)
- X funckeymap_define(bufptr)
- X funckeymap_display(fp)
- X funckeymap_display_single(tkde,fp)
- X funckeymap_init()
- X funckeymap_read(name)
- X
- X------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:03-27-1993-17:48-wht@n4hgf-SVR4 found mk_char_graphic decl out of scope */
- X/*:09-16-1992-13:33-wht@n4hgf-add fkmap -l name */
- X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
- X/*:08-30-1992-23:06-wht@n4hgf-add fkmap_command */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:08-28-1991-14:51-wht@n4hgf2-look correctly for funckeymap in ECULIBDIR */
- X/*:08-26-1991-05:45-wht@n4hgf2-# got included in key def */
- X/*:08-06-1991-13:19-wht@n4hgf-allow any code as first in key sequence */
- X/*:08-03-1991-14:44-wht@n4hgf-look for funckeymap in ECULIBDIR too */
- X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
- X/*:03-20-1991-03:06-root@n4hgf-no Metro Link problems here */
- X/*:03-20-1991-01:04-root@n4hgf-diagnose Metro Link xterm differences */
- X/*:01-10-1991-23:15-wht@n4hgf-string overflow rptd by spooley@compulink.co.uk */
- X/*:12-01-1990-12:51-wht@n4hgf-creation, borrowing from and using ecufkey.c */
- X
- X#include "ecu.h"
- X#include "ecuerror.h"
- X#include "ecukey.h"
- X#include "ecufkey.h"
- X#include "ecuxkey.h"
- X#include "ecufork.h"
- X
- Xchar *make_char_graphic();
- X
- Xextern int tty_not_char_special;
- Xextern char *dash_f_funckeytype;
- X
- XKDE funckeymap_table[KDE_COUNT];
- Xchar funckeymap_name[32] = "";
- X
- X#if defined(NONANSI_DEBUG)
- Xstatic FILE *nadbg = (FILE *) 0;
- X
- X#endif
- X
- X/*+-------------------------------------------------------------------------
- X funckeymap_init() - initialize function key mapping (recognition)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xfunckeymap_init()
- X{
- X register itmp;
- X register KDE *tkde;
- X
- X for (itmp = 0; itmp < KDE_COUNT; itmp++)
- X {
- X tkde = &funckeymap_table[itmp];
- X tkde->logical[0] = 0;
- X tkde->count = 0;
- X tkde->ikde = 0;
- X }
- X
- X funckeymap_name[0] = 0;
- X
- X} /* end of funckeymap_init */
- X
- X/*+-------------------------------------------------------------------------
- X funckeymap_define(bufptr) - use funckeymap line to define a mapping
- X
- X returns 0 good keydef
- X -1 if syntax error
- X--------------------------------------------------------------------------*/
- Xint
- Xfunckeymap_define(bufptr)
- Xregister char *bufptr;
- X{
- X register itmp;
- X register token_number = 0;
- X KDE *tkde = (KDE *) 0;
- X int ikde = 0;
- X int octothorpe = 0;
- X char *token;
- X char *arg_token();
- X char *str_token();
- X char *skip_ld_break();
- X
- X while (!octothorpe &&
- X (token = (token_number < 2) ? str_token(bufptr, ":")
- X : arg_token(bufptr, " \t")))
- X {
- X bufptr = (char *)0; /* further calls to arg_token need NULL */
- X token = skip_ld_break(token);
- X strip_trail_break(token);
- X
- X switch (token_number)
- X {
- X case 0: /* first field is key identifier */
- X if ((ikde = kde_name_to_ikde(token)) < 0)
- X {
- X pprintf(" %s is not a legal key identifier\r\n", token);
- X return (-1);
- X }
- X tkde = &funckeymap_table[ikde];
- X tkde->logical[0] = 0;
- X tkde->count = 0;
- X tkde->ikde = ikde;
- X break;
- X
- X case 1: /* second field is logical key name */
- X if (*token == '#')
- X goto MISSING_LABEL;
- X strncpy(tkde->logical, token, sizeof(tkde->logical));
- X tkde->logical[sizeof(tkde->logical) - 1] = 0;
- X break;
- X
- X case 2: /* third field is first token of sequence */
- X if (*token == '#')
- X goto MISSING_SEQUENCE;
- X
- X default: /* third and subsequent to define key */
- X if (*token == '#')
- X {
- X octothorpe = 1;
- X break;
- X }
- X if (tkde->count == sizeof(tkde->str))
- X {
- X pprintf(" %s: output count too long",
- X keyset_idstr(ikde));
- X return (-1);
- X }
- X if ((itmp = ascii_to_hex(token)) < 0)
- X {
- X pprintf(" %s: '%s' invalid\r\n",
- X keyset_idstr(ikde), token);
- X return (-1);
- X }
- X tkde->str[tkde->count] = itmp;
- X tkde->count++;
- X break;
- X } /* end of switch(token_number) */
- X
- X if (octothorpe)
- X break;
- X
- X token_number++;
- X
- X } /* end while not end of record */
- X
- X switch (token_number)
- X {
- X case 0:
- X pprintf("funckeymap_define logic error\n");
- X termecu(TERMECU_LOGIC_ERROR);
- X break;
- X
- X case 1:
- X MISSING_LABEL:
- X pprintf("%s: missing key label\r\n", keyset_idstr(ikde));
- X break;
- X
- X case 2:
- X MISSING_SEQUENCE:
- X pprintf("%s: missing char sequence\r\n", keyset_idstr(ikde));
- X break;
- X default:
- X /* special init string entry */
- X if (ikde == IKDE_InitStr)
- X fwrite(tkde->str, 1, tkde->count, stderr);
- X else if (tkde->count)
- X {
- X uchar ch = tkde->str[0];
- X extern uchar kbdeof; /* current input EOF */
- X extern uchar kbdeol2; /* current secondary input EOL */
- X extern uchar kbdeol; /* current input EOL */
- X extern uchar kbderase; /* current input ERASE */
- X extern uchar kbdintr; /* current input INTR */
- X extern uchar kbdkill; /* current input KILL */
- X extern uchar kbdquit; /* current input QUIT */
- X
- X if ((ch == kbdeof) || (ch == kbdeol2) ||
- X (ch == kbdeol) || (ch == kbderase) ||
- X (ch == kbdintr) || (ch == kbdkill) ||
- X (ch == kbdquit))
- X {
- X pprintf(
- X "%s: 1st char cannot be input control character\r\n",
- X keyset_idstr(ikde));
- X break;
- X }
- X }
- X return (0);
- X }
- X
- X return (-1); /* error */
- X
- X} /* end of funckeymap_define */
- X
- X/*+-------------------------------------------------------------------------
- X funckeymap_read(name) - read key-sequence-to-fkey map from funckeymap
- X--------------------------------------------------------------------------*/
- Xvoid
- Xfunckeymap_read(name)
- Xchar *name;
- X{
- X register itmp;
- X char buf[128];
- X FILE *fp_keys;
- X int errstat = 0;
- X static char ecukeys_name[128];
- X
- X#if defined(NONANSI_DEBUG)
- X if (!nadbg)
- X {
- X nadbg = fopen("/tmp/nadbg.log", "w");
- X setbuf(nadbg, NULL);
- X }
- X#endif
- X
- X funckeymap_init(); /* clear any previous key defns */
- X
- X if (!ecukeys_name[0])
- X {
- X get_home_dir(ecukeys_name);
- X strcat(ecukeys_name, "/.ecu/funckeymap");
- X }
- X
- X if (!(fp_keys = fopen(ecukeys_name, "r")))
- X {
- X strcpy(ecukeys_name, eculibdir);
- X strcat(ecukeys_name, "/funckeymap");
- X if (!(fp_keys = fopen(ecukeys_name, "r")))
- X {
- X ff(stderr, "'funckeymap' not in ~/.ecu or %s; unable to proceed\r\n",
- X eculibdir);
- X termecu(TERMECU_UNRECOVERABLE);
- X }
- X }
- X
- X/* find funckeymap name */
- X errstat = 1;
- X while ((itmp = kde_fgets(buf, sizeof(buf), fp_keys)) != KDETYPE_EOF)
- X {
- X if ((itmp == KDETYPE_COMMENT) || (itmp == KDETYPE_ENTRY))
- X continue;
- X if (!strcmp(buf, name))
- X {
- X errstat = 0; /* indicate success */
- X break;
- X }
- X }
- X if (errstat)
- X {
- X ff(stderr, "terminal type '%s'\r\n", name);
- X ff(stderr, "not found in %s; unable to proceed\r\n", ecukeys_name);
- X termecu(TERMECU_UNRECOVERABLE);
- X }
- X
- X/* read past any other funckeymap names matching this set */
- X errstat = 1;
- X while ((itmp = kde_fgets(buf, sizeof(buf), fp_keys)) != KDETYPE_EOF)
- X {
- X if (itmp == KDETYPE_ENTRY)
- X {
- X errstat = 0; /* indicate success */
- X break;
- X }
- X }
- X if (errstat)
- X {
- X ff(stderr,
- X "terminal type '%s' has null entry in %s; unable to proceed\r\n",
- X name, ecukeys_name);
- X termecu(TERMECU_UNRECOVERABLE);
- X }
- X
- X/* we found the definition ... process it */
- X errstat = 0;
- X itmp = KDETYPE_ENTRY;
- X do
- X {
- X if (itmp == KDETYPE_NAME)
- X break;
- X else if (itmp == KDETYPE_ENTRY)
- X {
- X if (funckeymap_define(buf))
- X errstat = 1;
- X }
- X }
- X while ((itmp = kde_fgets(buf, sizeof(buf), fp_keys)) != KDETYPE_EOF);
- X
- X/* finish up */
- X strncpy(funckeymap_name, name, sizeof(funckeymap_name));
- X funckeymap_name[sizeof(funckeymap_name) - 1] = 0;
- X fclose(fp_keys);
- X
- X if (!funckeymap_table[IKDE_HOME].count)
- X {
- X ff(stderr, "You MUST have a 'Home' key defined\r\n");
- X errstat = 2;
- X }
- X if (!funckeymap_table[IKDE_END].count)
- X {
- X ff(stderr, "You MUST have a 'End' key defined\r\n");
- X errstat = 2;
- X }
- X if ((errstat == 2) || (errstat && tty_not_char_special))
- X termecu(TERMECU_UNRECOVERABLE);
- X
- X if (errstat)
- X {
- X ff(stderr,
- X "WARNING: key mapping syntax errors\r\nContinue anyway (y,[n])? ");
- X if ((itmp = ttygetc(0)) == 'Y' || (itmp == 'y'))
- X {
- X ff(stderr, "YES\r\n");
- X return;
- X }
- X ff(stderr, "NO\r\n");
- X termecu(TERMECU_UNRECOVERABLE);
- X }
- X
- X} /* end of funckeymap_read */
- X
- X/*+-------------------------------------------------------------------------
- X funckeymap(buf,buflen) - map char sequence to ikde code
- X
- Xreturn XF_ code or XF_not_yet if no match yet, XF_no_way if no match possible
- X--------------------------------------------------------------------------*/
- Xuchar
- Xfunckeymap(buf, buflen)
- Xuchar *buf;
- Xint buflen;
- X{
- X register ikde;
- X register KDE *tkde;
- X int err_rtn = XF_no_way;
- X
- X if (!buflen)
- X return (XF_not_yet);
- X
- X#if defined(NONANSI_DEBUG)
- X if (nadbg)
- X hex_dump_fp(nadbg, buf, -buflen, "mapna", 1);
- X#endif
- X
- X for (ikde = 0, tkde = funckeymap_table; ikde <= IKDE_lastKey;
- X ikde++, tkde++)
- X {
- X#if defined(NONANSI_DEBUG)
- X if (nadbg)
- X fprintf(nadbg, "--> %s ", tkde->logical);
- X#endif
- X if ((tkde->count == buflen) && !memcmp(tkde->str, buf, buflen))
- X {
- X#if defined(NONANSI_DEBUG)
- X if (nadbg)
- X fprintf(nadbg, "yes\n");
- X#endif
- X return (tkde->ikde);
- X }
- X#if defined(NONANSI_DEBUG)
- X if (nadbg)
- X fprintf(nadbg, "no\n");
- X#endif
- X if ((tkde->count > buflen) &&
- X ((uchar) * (tkde->str + buflen) == *(buf + buflen)))
- X {
- X err_rtn = XF_not_yet;
- X }
- X }
- X return (err_rtn);
- X} /* end of funckeymap */
- X
- X/*+-------------------------------------------------------------------------
- X funckeymap_display_single(tkde,fp) - display single mapping on FILE fp
- X--------------------------------------------------------------------------*/
- Xvoid
- Xfunckeymap_display_single(ikde, fp)
- Xint ikde;
- XFILE *fp;
- X{
- X int keys_left;
- X char *keys;
- X char s64[64];
- X KDE *tkde;
- X
- X if ((unsigned)ikde > IKDE_lastKey)
- X return;
- X
- X tkde = &funckeymap_table[ikde];
- X sprintf(s64, " %s:%s: ",
- X keyset_idstr(ikde), tkde->logical);
- X s64[16] = 0;
- X if (fp == stderr)
- X pputs(s64);
- X else
- X fputs(s64, fp);
- X keys_left = tkde->count;
- X keys = tkde->str;
- X while (keys_left--)
- X {
- X if (fp == stderr)
- X {
- X pprintf("%s%s",
- X make_char_graphic(*keys++, 0),
- X (keys_left) ? " " : "");
- X }
- X else
- X {
- X fprintf(fp, "%s%s",
- X make_char_graphic(*keys++, 0),
- X (keys_left) ? " " : "");
- X }
- X }
- X if (fp == stderr)
- X pputs("\n");
- X else
- X fputs("\n", fp);
- X
- X} /* end of funckeymap_display_single */
- X
- X/*+-------------------------------------------------------------------------
- X funckeymap_display(fp) - display function key table of FILE fp
- X--------------------------------------------------------------------------*/
- Xvoid
- Xfunckeymap_display(fp)
- XFILE *fp;
- X{
- X int ikde;
- X char *ftype = 0;
- X
- X if (dash_f_funckeytype)
- X ftype = dash_f_funckeytype;
- X else
- X ftype = getenv("ECUFUNCKEY");
- X
- X if (ttype && ftype)
- X {
- X fprintf(fp, "#$TERM=%s -F/$ECUFUNCKEY=%s", ftype, ttype);
- X if (fp == stderr)
- X fputs("\r\n", fp);
- X else
- X fputs("\n", fp);
- X }
- X
- X if (ttype || ftype)
- X {
- X fputs((ftype) ? ftype : ttype, fp);
- X if (fp == stderr)
- X fputs("\r\n", fp);
- X else
- X fputs("\n", fp);
- X }
- X
- X for (ikde = 0; ikde <= IKDE_lastKey; ikde++)
- X funckeymap_display_single(ikde, fp);
- X
- X} /* end of funckeymap_display */
- X
- X/*+-------------------------------------------------------------------------
- X fkmap_command(argc,argv) - common interactive and procedure 'fkmap' cmd
- X
- Xreturn procedure error codes
- X--------------------------------------------------------------------------*/
- Xint
- Xfkmap_command(argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X register itmp;
- X int err = 0;
- X char *ftype = 0;
- X int iargv = 1;
- X char *arg;
- X char fkcmd[512 + 1];
- X char *fkcptr = fkcmd;
- X int fkclen = 0;
- X int ikde;
- X KDE save;
- X FILE *fp;
- X
- X while ((iargv < argc) && (*(arg = argv[iargv]) == '-'))
- X {
- X switch (*++arg)
- X {
- X case 'r': /* reset */
- X if (err)
- X break;
- X if (iargv != (argc - 1))
- X {
- X pputs("no arguments allowed for -r\n");
- X err = 1;
- X break;
- X }
- X if (dash_f_funckeytype)
- X ftype = dash_f_funckeytype;
- X else
- X ftype = getenv("ECUFUNCKEY");
- X if (ttype || ftype)
- X funckeymap_read((ftype) ? ftype : ttype);
- X if (!proc_level || proc_trace)
- X pputs("funckeymap reset to startup configuration\n");
- X return (0);
- X
- X case 's': /* save in file */
- X if (err)
- X break;
- X if (iargv != (argc - 2))
- X {
- X pputs("exactly one argument required for -s\n");
- X err = 1;
- X break;
- X }
- X iargv++;
- X if (!(fp = fopen(argv[iargv], "a")))
- X {
- X pperror(argv[iargv]);
- X return (eFATAL_ALREADY);
- X }
- X funckeymap_display(fp);
- X fclose(fp);
- X if (!proc_level || proc_trace)
- X pprintf("current mapping saved in %s\n", argv[iargv]);
- X return (0);
- X
- X case 'l': /* load entire */
- X if (err)
- X break;
- X if (iargv != (argc - 2))
- X {
- X pputs("exactly one argument required for -l\n");
- X err = 1;
- X break;
- X }
- X iargv++;
- X funckeymap_read(argv[iargv]);
- X return (0);
- X
- X default:
- X pprintf("unknown switch -%c\n", *arg);
- X err = 1;
- X }
- X iargv++;
- X }
- X
- X if (err)
- X {
- X fkmap_cmd_usage();
- X return (eFATAL_ALREADY);
- X }
- X
- X if (iargv == argc)
- X {
- X funckeymap_display(stderr);
- X return (0);
- X }
- X
- X arg = argv[iargv++];
- X if ((ikde = kde_name_to_ikde(arg)) < 0)
- X {
- X pprintf("key name '%s' not recognized\n", arg);
- X return (eFATAL_ALREADY);
- X }
- X sprintf(fkcptr, " %s:%s: ", keyset_idstr(ikde), keyset_idstr(ikde));
- X fkcptr += (itmp = strlen(fkcptr));
- X fkclen += itmp;
- X
- X if (iargv == argc)
- X {
- X funckeymap_display_single(&funckeymap_table[ikde], stderr);
- X return (0);
- X }
- X
- X while (iargv < argc)
- X {
- X arg = argv[iargv++];
- X itmp = strlen(arg);
- X if ((fkclen + itmp + 2) > sizeof(fkcmd))
- X {
- X pprintf("fkmap command may be no longer than %d characters\n",
- X sizeof(fkcmd) - 1);
- X return (eFATAL_ALREADY);
- X }
- X strcpy(fkcptr, arg);
- X fkcptr += itmp;
- X fkclen += itmp;
- X if (iargv != argc)
- X {
- X *fkcptr++ = ' ';
- X *fkcptr = 0;
- X fkclen++;
- X }
- X }
- X
- X save = funckeymap_table[ikde];
- X if (err = funckeymap_define(fkcmd))
- X funckeymap_table[ikde] = save;
- X
- X if (!err && (!proc_level || proc_trace))
- X funckeymap_display_single(ikde, stderr);
- X
- X return ((err) ? eFATAL_ALREADY : 0);
- X
- X} /* end of fkmap_command */
- X
- X/* end of funckeymap.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 14339 -ne `wc -c <'ecu330/funckeymap.c'`; then
- echo shar: \"'ecu330/funckeymap.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/funckeymap.c'
- fi
- if test -f 'ecu330/gendial/dceMPAD.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/gendial/dceMPAD.c'\"
- else
- echo shar: Extracting \"'ecu330/gendial/dceMPAD.c'\" \(14780 characters\)
- sed "s/^X//" >'ecu330/gendial/dceMPAD.c' <<'END_OF_FILE'
- X/* CHK=0xFF53 */
- X/*+-------------------------------------------------------------------------
- X dceMPAD.c - DCE-specific portion of generic SCO UUCP dialer
- X Driver for ATT Tridom MPAD VSAT modem emulation
- X wht@n4hgf.atl.ga.us
- 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:30-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
- X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
- X/*:03-12-1991-19:11-wht@n4hgf-if ecu dialing, show complete call progress */
- X/*:11-29-1990-18:31-r@n4hgf-revision/1st releasable */
- X/*:11-29-1990-17:48-wht@n4hgf-creation */
- 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 = 50;
- 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 = 50;
- 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 = 0;
- X
- X/*
- X * DCE_name - short name for DCE
- X * DCE_revision - revision number for this module
- X */
- Xchar *DCE_name = "ATT Tridom MPAD";
- Xchar *DCE_revision = "1.37";
- 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 * 0x40000000 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
- X/* flag bits */
- X#define rfConnect 0x00800000
- X#define rfMASK 0x0000FFFF /* mask off rfBits */
- X
- X/* unique codes */
- 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 ( 300 | rfConnect)
- X#define rConnect1200 ( 1200 | rfConnect)
- X#define rConnect2400 ( 2400 | rfConnect)
- X#define rConnect4800 ( 4800 | rfConnect)
- X#define rConnect9600 ( 9600 | rfConnect)
- X#define rConnect9600 ( 9600 | rfConnect)
- X#define rConnect19200 (19200 | rfConnect)
- X#define rConnect38400 (38400 | rfConnect)
- X
- XDCE_RESULT DCE_results[] =
- X{
- X {"OK", rOk,},
- X {"NO CARRIER", rNoCarrier,},
- X {"ERROR", rError},
- X {"BUSY", rBusy},
- X {"NO ANSWER", rNoAnswer},
- X {"NO DIAL TONE", rNoDialTone},
- X {"KDIR SENDX ERROR", rNoDialTone}, /* MPAD software error */
- X {"KDIR UNRESPONSIVE", rNoDialTone},
- X {"KDIR BUSY", rBusy},
- X {"KDIR BAD REQUEST", rError}, /* number 0 or >11 length */
- X {"NO SUCH NUMBER", rNoAnswer},
- X {"KDIR LOGIC ERROR", rNoDialTone}, /* MPAD software error */
- X {"KDIR NOT AVAIL", rNoDialTone},
- X {"TP4 STATE ERROR", rNoDialTone}, /* rain fade */
- X {"TP4 GIVE UP", rBusy}, /* rain fade */
- X {"TP4 ERROR RESP", rBusy}, /* transient problem */
- X {"NET DEACT", rNoDialTone}, /* net op deactivated port */
- X {"CONNECT 300", rConnect300},
- X {"CONNECT 1200", rConnect1200},
- X {"CONNECT 4800", rConnect4800},
- X {"CONNECT 9600", rConnect9600},
- X {"CONNECT 19200", rConnect19200},
- X {"CONNECT 38400", rConnect38400},
- 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 110:
- X return (B110);
- X case 300:
- X return (B300);
- X case 1200:
- X return (B1200);
- X case 2400:
- X return (B2400);
- 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 sync_MPAD() - sync modem with our DTE speed
- X--------------------------------------------------------------------------*/
- Xvoid
- Xsync_MPAD()
- X{
- X register int maxretry = 8;
- X register int count;
- X unsigned char rdchar;
- X
- X while (maxretry--)
- X {
- X lflush();
- X write(dce_fd, "a", 1);
- X count = 5;
- X while (count) /* wait 50-200 msec for character, depending
- X * on HZ */
- X {
- X if (rdchk(dce_fd))
- X break;
- X Nap(50L);
- X count--;
- X }
- X if (count && (read(dce_fd, &rdchar, 1) == 1) && (rdchar == 'a'))
- X return;
- X write(dce_fd, "atq0v1e1\r", 9);
- X Nap(500L);
- X }
- X
- X DEBUG(1, "MPAD SYNC FAILED\n", 0);
- X myexit(RC_FAIL | RCE_TIMOUT);
- X
- X} /* end of sync_MPAD */
- X
- X/*+-------------------------------------------------------------------------
- X init_MPAD() - init MPAD from scratch, assuming nothing
- X--------------------------------------------------------------------------*/
- Xvoid
- Xinit_MPAD()
- X{
- X register itmp;
- X int maxretry = 4;
- X char *init0 = "ATE0Q0V1X99S0=1S2=255\r";
- X
- X DEBUG(1, "--> reseting %s\n", dce_name);
- X lflash_DTR();
- X sync_MPAD();
- X
- X /*
- X * set to factory default (bless them for this command) and a few
- X * initial beachhead values
- X */
- X for (itmp = 0; itmp < maxretry; itmp++)
- X {
- X lwrite(init0);
- X if (lread(5) == rOk)
- X break;
- X }
- X if (itmp == maxretry)
- X {
- X DEBUG(1, "reset failed\n", 0);
- X myexit(RC_FAIL | RCE_TIMOUT);
- X }
- X
- X} /* end of init_MPAD */
- 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(1, "--> hanging up %s\n", dce_name);
- X lflash_DTR();
- X init_MPAD();
- X
- X} /* end of DCE_hangup */
- X
- X/*+-------------------------------------------------------------------------
- X DCE_dial(telno_str) - 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
- XMPAD Plus-specific comments:
- X Q0 do not be quiet
- X E0 do not echo
- X V1 verbal result codes
- X S0=0 dont allow connect while dialing
- X X99 full result codes
- X--------------------------------------------------------------------------*/
- Xint
- XDCE_dial(telno_str)
- Xchar *telno_str;
- X{
- X char cmd[128];
- X char phone[50];
- X int timeout;
- X int result;
- X char *cptr;
- X char *dialout_default = "ATQ0E0V1E0S0=0X99\r";
- X
- X#define MDVALID "0123456789NnSs()-"
- X
- X/* preliminary setup */
- X translate("=,-,", telno_str);
- X if (strspn(telno_str, MDVALID) != strlen(telno_str))
- X {
- X DEBUG(1, "phone number has invalid characters\n", 0);
- X return (RC_FAIL | RCE_PHNO);
- X }
- X if (decode_phone_number(telno_str, phone, sizeof(phone)))
- X {
- X DEBUG(1, "phone number too long\n", 0);
- X return (RC_FAIL | RCE_PHNO);
- X }
- X
- X/* walk through dialer codes, doing custom setup */
- X strcpy(cmd, "AT");
- X cptr = cmd + strlen(cmd);
- X
- X DEBUG(1, "--> issuing default setup command\n", 0);
- X sync_MPAD();
- X lwrite(dialout_default);
- X if (lread(5) != rOk)
- X {
- X DEBUG(1, "default dialout setup failed\n", 0);
- X return (RC_FAIL | RCE_NULL);
- X }
- X
- X/* issue the custom setup command */
- X if (*cptr)
- X {
- X DEBUG(1, "--> issuing custom setup cmd\n", 0);
- X strcat(cmd, "\r");
- X sync_MPAD();
- X lwrite(cmd);
- X if (lread(5) != rOk)
- X {
- X DEBUG(1, "custom modem setup failed\n", 0);
- X return (RC_FAIL | RCE_NULL);
- X }
- X }
- X
- X/*
- X * calculate a timeout for the connect
- X */
- X timeout = 20;
- X DEBUG(6, "wait for connect = %d seconds\n", timeout);
- X
- X/* indicate non-root should not see DTE->DCE traffic */
- X secure = 1;
- X
- X/*
- X * build and issue the actual dialing command
- X * if root, let him see number, otherwise just say "remote system"
- X */
- X DEBUG(1, "--> dialing %s\n", (!ecu_calling & uid) ? "remote system" : phone);
- X sprintf(cmd, "ATS7=%dDT%s\r", (timeout * 9) / 10, phone);
- X
- X /* cmd string can only be 40 characters including "AT" */
- X if (strlen(cmd) > 40)
- X {
- X DEBUG(1, "phone number string too long\n", 0);
- X cleanup(RC_FAIL | RCE_PHNO);
- X }
- X
- X sync_MPAD();
- X lwrite(cmd);
- X
- X/* indicate non-root can see DTE->DCE traffic */
- X secure = 0;
- X
- X/* wait for connect */
- X result = lread(timeout);
- X if (!(result & rfConnect))
- X {
- X switch (result & rfMASK)
- X {
- X case rNoCarrier:
- X return (RC_FAIL | RCE_NOCARR);
- X case rNoDialTone:
- X return (RC_FAIL | RCE_NOTONE);
- X case rBusy:
- X return (RC_FAIL | RCE_BUSY);
- X case rNoAnswer:
- X return (RC_FAIL | RCE_ANSWER);
- X case rError:
- X default:
- X return (RC_FAIL | RCE_NULL);
- X }
- X }
- 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 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 14780 -ne `wc -c <'ecu330/gendial/dceMPAD.c'`; then
- echo shar: \"'ecu330/gendial/dceMPAD.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/gendial/dceMPAD.c'
- fi
- if test -f 'ecu330/pcmdif.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/pcmdif.c'\"
- else
- echo shar: Extracting \"'ecu330/pcmdif.c'\" \(14664 characters\)
- sed "s/^X//" >'ecu330/pcmdif.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X pcmdif.c - ecu if procedure commands
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X _cmd_ifrel_common(param,relop)
- X _if_common(param,truth)
- X get_logicop(param,op_returned)
- X get_relop(param,op_returned)
- X get_truth_int(param,truth)
- X get_truth_str(param,truth)
- X pcmd_else(param)
- X pcmd_ifge(param)
- X pcmd_ifgt(param)
- X pcmd_ifi(param)
- X pcmd_ifle(param)
- X pcmd_iflt(param)
- X pcmd_ifnz(param)
- X pcmd_ifs(param)
- X pcmd_ifz(param)
- X test_truth_int(int1,relop,int2)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:12-20-1992-00:25-wht@n4hgf-flunk << or >> as relational operator */
- X/*:11-14-1992-22:37-wht@n4hgf-multiple else loses track of truth */
- X/*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
- X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
- X/*:08-26-1990-22:23-wht@n4hgf-fix zero-relative if commands */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include <ctype.h>
- X#include "ecu.h"
- X#include "ecuerror.h"
- X#include "esd.h"
- X#include "var.h"
- X#include "proc.h"
- X#include "relop.h"
- X
- Xextern PCB *pcb_stack[];
- Xextern int proc_trace;
- X
- X#define MAX_IF 40 /* damn enough */
- Xuchar if_level = 0;
- Xuchar truth_already[MAX_IF];
- X
- X/*+-------------------------------------------------------------------------
- X get_relop(param,&op_returned)
- X--------------------------------------------------------------------------*/
- Xint
- Xget_relop(param, op_returned)
- XESD *param;
- Xint *op_returned;
- X{
- X if (end_of_cmd(param))
- X return (eInvalidRelOp);
- X
- X switch (param->pb[param->index++]) /* index decremented in default */
- X {
- X case '=':
- X if ((param->cb != param->index) && (param->pb[param->index] == '='))
- X param->index++;
- X *op_returned = OP_EQ;
- X return (0);
- X
- X case '!':
- X if (param->cb == param->index)
- X return (eInvalidRelOp);
- X switch (param->pb[param->index])
- X {
- X case '=':
- X param->index++;
- X *op_returned = OP_NE;
- X return (0);
- X default:
- X return (eInvalidRelOp);
- X }
- X
- X case '<':
- X if (param->cb == param->index)
- X {
- X *op_returned = OP_LT;
- X return (0);
- X }
- X switch (param->pb[param->index])
- X {
- X case '<':
- X param->index++;
- X return (eInvalidRelOp);
- X case '>':
- X param->index++;
- X *op_returned = OP_NE;
- X return (0);
- X case '=':
- X param->index++;
- X *op_returned = OP_LE;
- X return (0);
- X default:
- X *op_returned = OP_LT;
- X return (0);
- X }
- X
- X case '>':
- X if (param->cb == param->index)
- X {
- X *op_returned = OP_LT;
- X return (0);
- X }
- X switch (param->pb[param->index])
- X {
- X case '>':
- X param->index++;
- X return (eInvalidRelOp);
- X case '=':
- X param->index++;
- X *op_returned = OP_GE;
- X return (0);
- X default:
- X *op_returned = OP_GT;
- X return (0);
- X }
- X default:
- X param->index--;
- X }
- X return (eInvalidRelOp);
- X} /* end of get_relop */
- X
- X/*+-------------------------------------------------------------------------
- X get_logicop(param,op_returned)
- X--------------------------------------------------------------------------*/
- Xint
- Xget_logicop(param, op_returned)
- XESD *param;
- Xint *op_returned;
- X{
- X register erc;
- X register char *cptr;
- X
- X if (erc = skip_cmd_break(param))
- X return (eInvalidLogicOp);
- X
- X if ((param->cb - param->index) < 2)
- X return (eInvalidLogicOp);
- X
- X cptr = param->pb + param->index;
- X erc = eInvalidLogicOp;
- X if (!strncmp(cptr, "&&", 2))
- X {
- X *op_returned = OP_AND;
- X erc = 0;
- X }
- X else if (!strncmp(cptr, "||", 2))
- X {
- X *op_returned = OP_OR;
- X erc = 0;
- X }
- X if (!erc)
- X param->index += 2;
- X return (erc);
- X
- X} /* end of get_logicop */
- X
- X/*+-------------------------------------------------------------------------
- X test_truth_int(int1,relop,int2)
- X--------------------------------------------------------------------------*/
- Xint
- Xtest_truth_int(int1, relop, int2)
- Xlong int1;
- Xint relop;
- Xlong int2;
- X{
- X register truth = 0;
- X
- X switch (relop)
- X {
- X case OP_EQ:
- X truth = (int1 == int2);
- X break;
- X case OP_NE:
- X truth = (int1 != int2);
- X break;
- X case OP_GT:
- X truth = (int1 > int2);
- X break;
- X case OP_LT:
- X truth = (int1 < int2);
- X break;
- X case OP_GE:
- X truth = (int1 >= int2);
- X break;
- X case OP_LE:
- X truth = (int1 <= int2);
- X break;
- X }
- X return (truth);
- X
- X} /* end of test_truth_int */
- X
- X/*+-------------------------------------------------------------------------
- X get_truth_int(param,truth)
- X--------------------------------------------------------------------------*/
- Xint
- Xget_truth_int(param, truth)
- XESD *param;
- Xint *truth;
- X{
- X register erc;
- X long int1;
- X long int2;
- X int operator;
- X int truth2;
- X
- X if (erc = gint(param, &int1))
- X return (erc);
- X if (erc = get_relop(param, &operator))
- X return (erc);
- X if (erc = gint(param, &int2))
- X return (erc);
- X *truth = test_truth_int(int1, operator, int2);
- X
- X while (!get_logicop(param, &operator))
- X {
- X if (erc = get_truth_int(param, &truth2))
- X return (erc);
- X switch (operator)
- X {
- X case OP_AND:
- X *truth &= truth2;
- X break;
- X
- X case OP_OR:
- X *truth |= truth2;
- X break;
- X }
- X }
- X return (0);
- X
- X} /* end of get_truth_int */
- X
- X/*+-------------------------------------------------------------------------
- X get_truth_str(param,truth)
- X--------------------------------------------------------------------------*/
- Xint
- Xget_truth_str(param, truth)
- XESD *param;
- Xint *truth;
- X{
- X register erc;
- X ESD *tesd1 = (ESD *) 0;
- X ESD *tesd2 = (ESD *) 0;
- X int operator;
- X int strcmp_result;
- X int truth2;
- X
- X if (!(tesd1 = esdalloc(ESD_NOMSZ)) || !(tesd2 = esdalloc(ESD_NOMSZ)))
- X {
- X erc = eNoMemory;
- X goto FUNC_RETURN;
- X }
- X
- X if (erc = gstr(param, tesd1, 1))
- X goto FUNC_RETURN;
- X if (erc = get_relop(param, &operator))
- X goto FUNC_RETURN;
- X if (erc = gstr(param, tesd2, 1))
- X goto FUNC_RETURN;
- X
- X strcmp_result = strcmp(tesd1->pb, tesd2->pb);
- X
- X switch (operator)
- X {
- X case OP_EQ:
- X *truth = (strcmp_result == 0);
- X break;
- X case OP_NE:
- X *truth = (strcmp_result != 0);
- X break;
- X case OP_GT:
- X *truth = (strcmp_result > 0);
- X break;
- X case OP_LT:
- X *truth = (strcmp_result < 0);
- X break;
- X case OP_GE:
- X *truth = (strcmp_result >= 0);
- X break;
- X case OP_LE:
- X *truth = (strcmp_result <= 0);
- X break;
- X default:
- X return (eInvalidStrOp);
- X }
- X
- X while (!get_logicop(param, &operator))
- X {
- X if (erc = get_truth_str(param, &truth2))
- X return (erc);
- X switch (operator)
- X {
- X case OP_AND:
- X *truth &= truth2;
- X break;
- X
- X case OP_OR:
- X *truth |= truth2;
- X break;
- X }
- X }
- X
- X erc = 0;
- X
- X FUNC_RETURN:
- X if (tesd1)
- X esdfree(tesd1);
- X if (tesd2)
- X esdfree(tesd2);
- X return (erc);
- X
- X} /* end of get_truth_str */
- X
- X/*+-------------------------------------------------------------------------
- X _if_common(param,truth)
- X--------------------------------------------------------------------------*/
- Xint
- X_if_common(param, truth)
- XESD *param;
- Xint truth;
- X{
- X register erc = 0;
- X char s80[80];
- X PCB *pcb;
- X ESD *else_line;
- X int label_on_else_line;
- X int truth2;
- X int save_index;
- X long int1;
- X
- X if (proc_trace > 1)
- X {
- X pprintf("if condition %s", (truth) ? "TRUE: " : "FALSE\n");
- X if (truth)
- X {
- X skip_cmd_break(param);
- X pputs(param->pb + param->index);
- X pputc('\n');
- X }
- X }
- X
- X truth_already[if_level] |= truth;
- X
- X/* if end of command, execute frame else conditionally execute rest of esd */
- X s80[0] = 0;
- X if (end_of_cmd(param))
- X erc = execute_frame(truth);
- X else if (truth)
- X erc = execute_esd(param);
- X else
- X param->index = param->cb;
- X
- X if (erc)
- X return (erc);
- X
- X/* check for else statement */
- X pcb = pcb_stack[proc_level - 1];
- X if (!pcb->current->next) /* if no next line, no "else" */
- X return (0);
- X
- X else_line = pcb->current->next->text;
- X else_line->index = else_line->old_index = 0;
- X if (label_on_else_line = (*else_line->pb != 0x20))
- X { /* strip label */
- X if (get_alphanum_zstr(else_line, s80, sizeof(s80)))
- X return (eInvalidLabel);
- X }
- X if (get_alphanum_zstr(else_line, s80, sizeof(s80)))
- X return (0); /* not "else" */
- X if (strcmp(s80, "else"))
- X return (0); /* not "else" */
- X if (label_on_else_line)
- X {
- X else_line->old_index = 0;
- X pputs("label not allowed on else statement\n");
- X return (eFATAL_ALREADY);
- X }
- X
- X/* we have an "else" condition */
- X pcb->current = pcb->current->next;
- X
- X trace_proc_cmd(pcb);
- X
- X if (end_of_cmd(else_line))
- X {
- X truth = !truth_already[if_level];
- X erc = execute_frame(truth);
- X }
- X else
- X {
- X save_index = else_line->old_index = else_line->index;
- X s80[0] = 0;
- X if ((*(else_line->pb + else_line->index) != '$') &&
- X get_alpha_zstr(else_line, s80, sizeof(s80)))
- X {
- X pputs("illegal command after 'else'\n");
- X return (eFATAL_ALREADY);
- X }
- X if (!strcmp(s80, "ifi"))
- X {
- X if (erc = get_truth_int(else_line, &truth2))
- X return (erc);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "ifs"))
- X {
- X if (erc = get_truth_str(else_line, &truth2))
- X return (erc);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "ifz"))
- X {
- X if (erc = gint(else_line, &int1))
- X return (erc);
- X truth2 = test_truth_int(int1, OP_EQ, 0L);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "ifnz"))
- X {
- X if (erc = gint(else_line, &int1))
- X return (erc);
- X truth2 = test_truth_int(int1, OP_NE, 0L);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "iflt"))
- X {
- X if (erc = gint(else_line, &int1))
- X return (erc);
- X truth2 = test_truth_int(int1, OP_LT, 0L);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "ifle"))
- X {
- X if (erc = gint(else_line, &int1))
- X return (erc);
- X truth2 = test_truth_int(int1, OP_LE, 0L);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "ifgt"))
- X {
- X if (erc = gint(else_line, &int1))
- X return (erc);
- X truth2 = test_truth_int(int1, OP_GT, 0L);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strcmp(s80, "ifge"))
- X {
- X if (erc = gint(else_line, &int1))
- X return (erc);
- X truth2 = test_truth_int(int1, OP_GE, 0L);
- X erc = _if_common(else_line, !truth_already[if_level] & truth2);
- X truth_already[if_level] |= truth2;
- X }
- X else if (!strncmp(s80, "while", 5))
- X {
- X pputs("'while' command not allowed as 'else' conditional\n");
- X pputs("put the statement inside braces\n");
- X return (eFATAL_ALREADY);
- X }
- X else
- X {
- X else_line->index = save_index;
- X if (truth)
- X erc = execute_esd(else_line);
- X }
- X }
- X
- X return (erc);
- X} /* end of _if_common */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifi(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifi(param)
- XESD *param;
- X{
- X register erc;
- X int truth;
- X
- X if (!proc_level)
- X return (eNotExecutingProc);
- X
- X if (if_level == MAX_IF)
- X {
- X pputs("if statements nested too deeply\n");
- X return (eFATAL_ALREADY);
- X }
- X if_level++;
- X truth_already[if_level] = 0;
- X
- X if (!(erc = get_truth_int(param, &truth)))
- X erc = _if_common(param, truth);
- X if_level--;
- X return (erc);
- X
- X} /* end of pcmd_ifi */
- X
- X/*+-------------------------------------------------------------------------
- X _cmd_ifrel_common(param,relop)
- X--------------------------------------------------------------------------*/
- Xint
- X_cmd_ifrel_common(param, relop)
- XESD *param;
- Xint relop;
- X{
- X register erc;
- X int truth;
- X long int1;
- X
- X if (!proc_level)
- X return (eNotExecutingProc);
- X
- X if (if_level == MAX_IF)
- X {
- X pputs("if statements nested too deeply\n");
- X return (eFATAL_ALREADY);
- X }
- X if_level++;
- X truth_already[if_level] = 0;
- X
- X if (erc = gint(param, &int1))
- X return (erc);
- X truth = test_truth_int(int1, relop, 0L);
- X erc = _if_common(param, truth);
- X if_level--;
- X return (erc);
- X
- X} /* end of _cmd_ifrel_common */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifz(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifz(param)
- XESD *param;
- X{
- X return (_cmd_ifrel_common(param, OP_EQ));
- X} /* end of pcmd_ifz */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifnz(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifnz(param)
- XESD *param;
- X{
- X return (_cmd_ifrel_common(param, OP_NE));
- X} /* end of pcmd_ifnz */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifle(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifle(param)
- XESD *param;
- X{
- X return (_cmd_ifrel_common(param, OP_LE));
- X} /* end of pcmd_ifle */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifge(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifge(param)
- XESD *param;
- X{
- X return (_cmd_ifrel_common(param, OP_GE));
- X} /* end of pcmd_ifge */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_iflt(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_iflt(param)
- XESD *param;
- X{
- X return (_cmd_ifrel_common(param, OP_LT));
- X} /* end of pcmd_iflt */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifgt(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifgt(param)
- XESD *param;
- X{
- X return (_cmd_ifrel_common(param, OP_GT));
- X} /* end of pcmd_ifgt */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_ifs(param)
- X--------------------------------------------------------------------------*/
- Xint
- Xpcmd_ifs(param)
- XESD *param;
- X{
- X register erc;
- X int truth;
- X
- X if (!proc_level)
- X return (eNotExecutingProc);
- X
- X if (if_level == MAX_IF)
- X {
- X pputs("if statements nested too deeply\n");
- X return (eFATAL_ALREADY);
- X }
- X if_level++;
- X truth_already[if_level] = 0;
- X
- X if (!(erc = get_truth_str(param, &truth)))
- X erc = _if_common(param, truth);
- X if_level--;
- X return (erc);
- X
- X} /* end of pcmd_ifs */
- X
- X/*+-------------------------------------------------------------------------
- X pcmd_else(param)
- X--------------------------------------------------------------------------*/
- X/*ARGSUSED*/
- Xint
- Xpcmd_else(param)
- XESD *param;
- X{
- X return (eElseCommand);
- X} /* end of pcmd_else */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of pcmdif.c */
- END_OF_FILE
- if test 14664 -ne `wc -c <'ecu330/pcmdif.c'`; then
- echo shar: \"'ecu330/pcmdif.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/pcmdif.c'
- fi
- if test -f 'ecu330/termecu.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/termecu.h'\"
- else
- echo shar: Extracting \"'ecu330/termecu.h'\" \(1750 characters\)
- sed "s/^X//" >'ecu330/termecu.h' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X termecu.h -- termecu (exit()) codes
- X wht@n4hgf.atl.ga.us
- X
- X 1 - 64 reserved for signals
- X 193 - 223 reserved for procedure 'exit' codes
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:40-wht@n4hgf-ECU release 3.30 */
- X/*:12-20-1992-12:02-wht@n4hgf-add TERMECU_SVC_NOT_AVAIL */
- X/*:09-16-1992-03:29-wht@n4hgf-add TERMECU_UNRECOVERABLE */
- X/*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
- X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
- X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#ifndef _termecu_h
- X#define _termecu_h
- X
- X#define TERMECU_OK 0
- X#define TERMECU_SIG1 1
- X#define TERMECU_SIGN 64
- X#define TERMECU_LINE_READ_ERROR 129
- X#define TERMECU_XMTR_WRITE_ERROR 130
- X#define TERMECU_XMTR_FATAL_ERROR 131
- X#define TERMECU_BSD4_IOCTL 132
- X#define TERMECU_SHM_ABL 133
- X#define TERMECU_SHM_RTL 134
- X#define TERMECU_NO_FORK_FOR_RCVR 135
- X#define TERMECU_TTYIN_READ_ERROR 136
- X#define TERMECU_LINE_OPEN_ERROR 137
- X#define TERMECU_PWENT_ERROR 138
- X#define TERMECU_USAGE 139
- X#define TERMECU_CONFIG_ERROR 140
- X#define TERMECU_CURSES_ERROR 141
- X#define TERMECU_RCVR_FATAL_ERROR 142
- X#define TERMECU_MALLOC 143
- X#define TERMECU_LOGIC_ERROR 144
- X#define TERMECU_GEOMETRY 145
- X#define TERMECU_IPC_ERROR 146
- X#define TERMECU_UNRECOVERABLE 147
- X#define TERMECU_SVC_NOT_AVAIL 148
- X
- X#define TERMECU_INIT_PROC_ERROR 192
- X
- X#define TERMECU_USER1 193
- X#define TERMECU_USERN 223
- X
- X#endif /* _termecu_h */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of termecu.h */
- END_OF_FILE
- if test 1750 -ne `wc -c <'ecu330/termecu.h'`; then
- echo shar: \"'ecu330/termecu.h'\" unpacked with wrong size!
- fi
- # end of 'ecu330/termecu.h'
- fi
- echo shar: End of archive 25 \(of 37\).
- cp /dev/null ark25isdone
- 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...
-