home *** CD-ROM | disk | FTP | other *** search
- From: wht@n4hgf.atl.ga.us (Warren Tucker)
- Newsgroups: comp.sources.misc
- Subject: v42i125: ecu - ECU Asynchronous Communications v3.30, Part27/37
- Date: 24 May 1994 09:07:51 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2rt1nn$d5r@sparky.sterling.com>
- X-Md4-Signature: db720bf5d44a3f93ac1d98193e18e0fc
-
- Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
- Posting-number: Volume 42, Issue 125
- Archive-name: ecu/part27
- 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/ecuchdir.c ecu330/ecuwinutil.c ecu330/fasi/Space.c
- # ecu330/gendial/dceUSR24v.c ecu330/regexp.c
- # Wrapped by kent@sparky on Mon May 23 13:41:01 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 27 (of 37)."'
- if test -f 'ecu330/ecuchdir.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecuchdir.c'\"
- else
- echo shar: Extracting \"'ecu330/ecuchdir.c'\" \(13231 characters\)
- sed "s/^X//" >'ecu330/ecuchdir.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X ecuchdir.c - ECU change directory command/history
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X cd_array_delete(arg,narg)
- X cd_array_delete_usage()
- X cd_array_init()
- X cd_array_read()
- X cd_array_save()
- X change_directory(dirname,arg_present_flag)
- X expand_dirname(dirname,maxlen)
- X pop_directory(arg,arg_present,pcmd)
- X push_directory(dirname,arg_present,pcmd)
- X
- X Paraphrase: "It just goes to show you: no matter where you find
- X yourself -- there you are!" -- Pogo
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
- 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/*:09-25-1991-18:24-wht@n4hgf2-fix seg viol in popd w/o argument on Sun */
- X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
- X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
- X/*:05-21-1991-18:53-wht@n4hgf-add push_directory and pop_directory */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "ecu.h"
- X#include "ecukey.h"
- X#include "ecutty.h"
- X#include "termecu.h"
- X
- Xint push_directory();
- X
- X#define CD_PATHLEN 256
- X
- X#define CD_QUAN 44
- Xchar *cd_array[CD_QUAN];
- Xuint cd_in_use = 0;
- X
- X#define DIR_PUSH_MAX 10
- Xchar *dir_push_stack[DIR_PUSH_MAX];
- Xuint dir_push_level = 0;
- X
- Xextern char curr_dir[CURR_DIRSIZ]; /* current working directory */
- Xextern int proc_trace;
- Xextern char errmsg[];
- Xextern int errno;
- X
- X/*+-------------------------------------------------------------------------
- X cd_array_read() - read ~/.ecu/dir
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcd_array_read()
- X{
- X char dirpath[CD_PATHLEN];
- X FILE *fpcd;
- X FILE *fopen();
- X register char *cptr;
- X char *skip_ld_break();
- X
- X get_home_dir(dirpath);
- X strcat(dirpath, "/.ecu/dir");
- X if ((fpcd = fopen(dirpath, "r")) == (FILE *) 0)
- X return; /* none found */
- X
- X for (cd_in_use = 0; cd_in_use < CD_QUAN; cd_in_use++)
- X {
- X if (fgets(dirpath, sizeof(dirpath), fpcd) == (char *)0)
- X break;
- X dirpath[strlen(dirpath) - 1] = 0;
- X cptr = skip_ld_break(dirpath);
- X if (strlen(cptr) == 0)
- X {
- X --cd_in_use;
- X continue;
- X }
- X strcpy(cd_array[cd_in_use], cptr);
- X }
- X fclose(fpcd);
- X} /* end of cd_array_read */
- X
- X/*+-------------------------------------------------------------------------
- X cd_array_save() - save ~/.ecu/dir
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcd_array_save()
- X{
- X register icd;
- X char savepath[256];
- X FILE *fpcd;
- X FILE *fopen();
- X
- X get_home_dir(savepath);
- X strcat(savepath, "/.ecu/dir");
- X
- X if (cd_in_use == 0)
- X {
- X ff(se, "No directory list to save in %s\r\n", savepath);
- X return;
- X }
- X if ((fpcd = fopen(savepath, "w")) == (FILE *) 0)
- X {
- X ff(se, "%s could not be opened\r\n", savepath);
- X return;
- X }
- X
- X for (icd = 0; icd < cd_in_use; icd++)
- X fprintf(fpcd, "%s\n", cd_array[icd]);
- X fclose(fpcd);
- X ff(se, "%d entries saved in %s\r\n", cd_in_use, savepath);
- X
- X} /* end of cd_array_save */
- X
- X/*+-------------------------------------------------------------------------
- X cd_array_delete_usage()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcd_array_delete_usage()
- X{
- X ff(se, "usage: d[elete] <1st> [<last>]\r\n");
- X} /* end of cd_array_delete_usage */
- X
- X/*+-------------------------------------------------------------------------
- X cd_array_delete(arg,narg)
- X--------------------------------------------------------------------------*/
- Xcd_array_delete(arg, narg)
- Xchar **arg;
- Xint narg;
- X{
- X uint first; /* 1st to delete */
- X uint last; /* last to delete */
- X
- X if ((narg < 2) || (narg > 3))
- X {
- X cd_array_delete_usage();
- X return (-1);
- X }
- X
- X first = atoi(arg[1]) - 1;
- X if (narg == 2)
- X last = first;
- X else
- X last = atoi(arg[2]) - 1;
- X
- X if ((first > (cd_in_use - 1)) || (last > (cd_in_use - 1)) || (last < first))
- X {
- X cd_array_delete_usage();
- X return (-1);
- X }
- X
- X if (last == (cd_in_use - 1))
- X {
- X cd_in_use = first;
- X }
- X else
- X {
- X int count_less = last - first + 1;
- X
- X last++;
- X while (last != cd_in_use)
- X strcpy(cd_array[first++], cd_array[last++]);
- X cd_in_use -= count_less;
- X }
- X return (0);
- X} /* end of cd_array_delete */
- X
- X/*+-------------------------------------------------------------------------
- X cd_array_init()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcd_array_init()
- X{
- X register itmp;
- X
- X/*allocate change_directory stack */
- X for (itmp = 0; itmp < CD_QUAN; itmp++)
- X {
- X if (!(cd_array[itmp] = malloc(CD_PATHLEN + 1)))
- X {
- X ff(se, "Not enough memory for cd stack\r\n");
- X termecu(TERMECU_MALLOC);
- X }
- X *cd_array[itmp] = 0;
- X }
- X (void)cd_array_read();
- X} /* end of cd_array_init */
- X
- X/*+-------------------------------------------------------------------------
- X expand_dirname(dirname,maxlen) - convert dirname with shell chars
- X--------------------------------------------------------------------------*/
- Xexpand_dirname(dirname, maxlen)
- Xchar *dirname;
- Xint maxlen;
- X{
- X char s256[256];
- X char *expcmd;
- X
- X if (!find_shell_chars(dirname))
- X return (0);
- X
- X sprintf(s256, "`ls -d %s`", dirname);
- X if (expand_wildcard_list(s256, &expcmd))
- X {
- X strcpy(errmsg, "No such directory");
- X return (-1);
- X }
- X strncpy(dirname, expcmd, maxlen);
- X dirname[maxlen - 1] = 0;
- X free(expcmd);
- X if (strchr(dirname, ' '))
- X {
- X strcpy(errmsg, "Too many files");
- X return (-1);
- X }
- X return (0);
- X
- X} /* end of expand_dirname */
- X
- X/*+-------------------------------------------------------------------------
- X change_directory(dirname,arg_present_flag) - 'cd' interactive cmd hdlr
- X
- X Change directory to 'dirname' if arg_present_flag is true,
- X else if flag 0, ask for new directory name and change to it
- X This procedure maintains the global variable 'curr_dir' that
- X reflects the ecu transmitter process current working directory.
- X--------------------------------------------------------------------------*/
- Xint
- Xchange_directory(dirname, arg_present_flag)
- Xchar *dirname;
- Xint arg_present_flag;
- X{
- X register icd;
- X register itmp;
- X char s256[256];
- X uchar delim;
- X
- X#define BLD_ARG_MAX 5
- X char *arg[BLD_ARG_MAX];
- X int narg;
- X int longest;
- X int pushing = 0;
- X
- X if (cd_in_use == 0)
- X cd_array_read();
- X
- X fputs(" ", se);
- X
- X if (arg_present_flag) /* if there is an argument ... */
- X {
- X if (isdigit(*dirname)) /* ... and first char is digit */
- X {
- X icd = atoi(dirname) - 1;
- X if ((icd < 0) || (icd >= cd_in_use))
- X goto DISPLAY_CD_ARRAY;
- X strncpy(s256, cd_array[icd], sizeof(s256) - 1);
- X }
- X else
- X strncpy(s256, dirname, sizeof(s256) - 1); /* literal dir spec */
- X
- X s256[sizeof(s256) - 1] = 0;
- X }
- X else
- X /* no arg to cd command */
- X {
- X DISPLAY_CD_ARRAY:
- X fputs("\r\n", se);
- X longest = 0;
- X for (icd = 0; icd < CD_QUAN / 2; icd++)
- X {
- X if (icd >= cd_in_use)
- X break;
- X if (longest < (itmp = strlen(cd_array[icd])))
- X longest = itmp;
- X }
- X longest += 4;
- X if (longest < 36)
- X longest += 4;
- X for (icd = 0; icd < CD_QUAN / 2; icd++)
- X {
- X if (icd >= cd_in_use)
- X break;
- X sprintf(s256, "%2d %s ", icd + 1, cd_array[icd]);
- X fputs(s256, se);
- X if (icd + CD_QUAN / 2 >= cd_in_use)
- X fputs("\r\n", se);
- X else
- X {
- X itmp = longest - strlen(s256);
- X while (itmp-- > 0)
- X fputc(' ', se);
- X sprintf(s256, "%2d %s\r\n",
- X icd + 1 + CD_QUAN / 2, cd_array[icd + CD_QUAN / 2]);
- X fputs(s256, se);
- X
- X }
- X }
- X fputs("current dir: ", se);
- X tcap_stand_out();
- X ff(se, " %s ", curr_dir);
- X tcap_stand_end();
- X tcap_eeol();
- X fputs("\r\n", se);
- X
- X GET_NEW_DIR:
- X fputs(
- X "New dir, <#>, %save, %read, %del, %xmitcd, %pushd, <enter>: ", se);
- X ttygets(s256, sizeof(s256), TG_CRLF, &delim, (int *)0);
- X
- X TRY_AGAIN:
- X if ((delim == ESC) || !strlen(s256))
- X {
- X ff(se, "no directory change\r\n");
- X return (0);
- X }
- X else if (s256[0] == '%')
- X {
- X if (pushing)
- X {
- X ff(se, "syntax error\r\n");
- X return (-1);
- X }
- X build_str_array(s256, arg, BLD_ARG_MAX, &narg);
- X
- X if (minunique("save", &s256[1], 1))
- X {
- X cd_array_save();
- X goto GET_NEW_DIR;
- X }
- X else if (minunique("read", &s256[1], 1))
- X {
- X cd_array_read();
- X goto DISPLAY_CD_ARRAY;
- X }
- X else if (minunique("delete", &s256[1], 1))
- X {
- X if (cd_array_delete(arg, narg))
- X goto GET_NEW_DIR;
- X else
- X goto DISPLAY_CD_ARRAY;
- X }
- X else if (minunique("xmitcd", &s256[1], 1))
- X {
- X lputs("cd ");
- X lputs(curr_dir);
- X lputc('\r');
- X return (0);
- X }
- X else if (minunique("pushd", &s256[1], 1))
- X {
- X strcpy(s256, arg[1]);
- X pushing = 1;
- X goto TRY_AGAIN;
- X }
- X else
- X {
- X ff(se, "Invalid cd subcommand\r\n");
- X goto GET_NEW_DIR;
- X }
- X }
- X else if (icd = atoi(s256))
- X {
- X icd--;
- X if (icd >= cd_in_use)
- X goto GET_NEW_DIR;
- X strncpy(s256, cd_array[icd], sizeof(s256) - 1);
- X s256[sizeof(s256) - 1] = 0;
- X }
- X }
- X if (pushing)
- X {
- X if (push_directory(s256, 1, 1))
- X return (-1);
- X }
- X else
- X {
- X if (expand_dirname(s256, sizeof(s256)))
- X {
- X ff(se, "%s\r\n", errmsg);
- X return (-1);
- X }
- X if (chdir(s256) < 0) /* now change to the new directory */
- X {
- X perror(s256); /* print error if we get one */
- X ff(se, "\r\n");
- X return (-1);
- X }
- X get_curr_dir(curr_dir, sizeof(curr_dir));
- X fputs("confirmed: ", se);
- X tcap_stand_out();
- X ff(se, " %s ", curr_dir);
- X tcap_stand_end();
- X fputs("\r\n", se);
- X }
- X
- X for (icd = 0; icd < cd_in_use; icd++)
- X {
- X if (strcmp(curr_dir, cd_array[icd]) == 0)
- X return (0);
- X }
- X if (cd_in_use == CD_QUAN)
- X {
- X for (icd = 1; icd < CD_QUAN; icd++)
- X {
- X strcpy(cd_array[icd - 1], cd_array[icd]);
- X }
- X strcpy(cd_array[CD_QUAN - 1], curr_dir);
- X }
- X else
- X strcpy(cd_array[cd_in_use++], curr_dir);
- X
- X return (0);
- X
- X} /* end of change_directory */
- X
- X/*+-------------------------------------------------------------------------
- X push_directory(dirname,arg_present,pcmd) - 'pushd' function
- X
- XThis function performs 'pushd' actions for both the interactive
- Xand procedure 'pushd' commands
- X
- Xdirname is new directory name if arg_present true
- Xpcmd true if procedure command or cd %p interactive, else interactive command
- X
- Xreturns -1 if error, else 0
- X--------------------------------------------------------------------------*/
- Xint
- Xpush_directory(dirname, arg_present, pcmd)
- Xchar *dirname;
- Xint arg_present;
- Xint pcmd;
- X{
- X register itmp;
- X char s256[256];
- X
- X if (!pcmd)
- X ff(se, "\r\n");
- X
- X if (!arg_present)
- X {
- X if (!dir_push_level)
- X {
- X if (!pcmd || proc_trace)
- X pprintf("---: no directories pushed\n");
- X }
- X else
- X {
- X for (itmp = 0; itmp < dir_push_level; itmp++)
- X pprintf("%3d: %s\n", itmp, dir_push_stack[itmp]);
- X }
- X pprintf("cwd: %s\n", curr_dir);
- X return (0);
- X }
- X
- X if (dir_push_level == DIR_PUSH_MAX)
- X {
- X pputs("too many pushds\n");
- X return (-1);
- X }
- X
- X if (!dir_push_stack[dir_push_level])
- X {
- X if (!(dir_push_stack[dir_push_level] = malloc(CD_PATHLEN)))
- X {
- X pputs("no memory for pushd\n");
- X return (-1);
- X }
- X }
- X
- X get_curr_dir(dir_push_stack[dir_push_level], CD_PATHLEN);
- X
- X strncpy(s256, dirname, sizeof(s256) - 1);
- X s256[sizeof(s256) - 1] = 0;
- X if (expand_dirname(s256, sizeof(s256)))
- X {
- X pprintf("'%s': %s\n", s256, errmsg);
- X return (-1);
- X }
- X if (chdir(s256) < 0) /* now change to the new directory */
- X {
- X pperror(s256); /* print error if we get one */
- X return (-1);
- X }
- X get_curr_dir(curr_dir, sizeof(curr_dir));
- X
- X if (pcmd && proc_trace)
- X pprintf("pushed to directory %s\n", curr_dir);
- X else
- X {
- X fputs("confirmed: ", se);
- X tcap_stand_out();
- X ff(se, " %s ", curr_dir);
- X tcap_stand_end();
- X ff(se, " (level %d)\r\n", dir_push_level);
- X }
- X
- X dir_push_level++;
- X return (0);
- X
- X} /* end of push_directory */
- X
- X/*+-------------------------------------------------------------------------
- X pop_directory(arg,arg_present,pcmd) - 'popd' function
- X
- XThis function performs 'popd' actions for both the interactive
- Xand procedure 'popd' commands
- X
- Xarg is empty if arg_present false
- Xif not empty, it is == 'all' or a numeric level to pop to
- Xpcmd true if procedure command, else interactive command
- X
- Xreturns -1 if error, else 0
- X--------------------------------------------------------------------------*/
- Xint
- Xpop_directory(arg, arg_present, pcmd)
- Xchar *arg;
- Xint arg_present;
- Xint pcmd;
- X{
- X int new_level = -1;
- X
- X if (!pcmd)
- X pputs("\n");
- X
- X if (!dir_push_level)
- X {
- X if (!pcmd || proc_trace)
- X {
- X pprintf("---: no directories pushed\n");
- X pprintf("cwd: %s\n", curr_dir);
- X }
- X return (-1);
- X }
- X
- X if (!arg_present)
- X new_level = dir_push_level - 1;
- X else if (minunique("all", arg, 1))
- X new_level = 0;
- X else if (isdigit(*arg))
- X new_level = atoi(arg);
- X else
- X {
- X pprintf("argument error: '%s'\n", arg);
- X return (-1);
- X }
- X
- X if ((new_level < 0) || (new_level > (dir_push_level - 1)))
- X {
- X pprintf("invalid popd argument (or not pushed to level): '%s'\n", arg);
- X return (-1);
- X }
- X
- X dir_push_level = new_level;
- X if (chdir(dir_push_stack[dir_push_level]) < 0)
- X {
- X pperror(dir_push_stack[dir_push_level]);
- X return (-1);
- X }
- X get_curr_dir(curr_dir, sizeof(curr_dir));
- X
- X if (pcmd && proc_trace)
- X pprintf("popped to directory %s (level %d)\n", curr_dir, dir_push_level);
- X else
- X {
- X fputs("confirmed: ", se);
- X tcap_stand_out();
- X ff(se, " %s ", curr_dir);
- X tcap_stand_end();
- X ff(se, " (level %d)\r\n", dir_push_level);
- X }
- X
- X return (0);
- X
- X} /* end of pop_directory */
- X
- X/* end of ecuchdir.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 13231 -ne `wc -c <'ecu330/ecuchdir.c'`; then
- echo shar: \"'ecu330/ecuchdir.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecuchdir.c'
- fi
- if test -f 'ecu330/ecuwinutil.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecuwinutil.c'\"
- else
- echo shar: Extracting \"'ecu330/ecuwinutil.c'\" \(12629 characters\)
- sed "s/^X//" >'ecu330/ecuwinutil.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X ecuwinutil.c - curses window utilities
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X clear_area(win,y,x,len)
- X clear_area_char(win,y,x,len,fillchar)
- X winbox(win)
- X window_create(title,title_x,tly,tlx,lines,cols)
- X window_setup(win,title,title_x)
- X windows_end(botleft_flag)
- X windows_end_signal()
- X windows_start()
- X winget_single(win,nondelim_list,delim_list)
- X wingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
- X
- X It's hard to get ivory in Africa, but in Alabama the
- X Tuscaloosa. -- Groucho
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
- X/*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
- X/*:09-15-1993-11:31-wht@n4hgf-endwin on non-SCO per bob@vancouver.zadall.com */
- X/*:08-17-1993-14:04-wht@n4hgf-add OLD_WINGETS for compatibility */
- X/*:08-13-1993-04:04-wht@n4hgf-add highlight_delete function to wingets */
- 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-09-1992-16:08-root@n4hgf-ruling characters only on SCO (tcap curses) */
- X/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
- X/*:08-01-1991-03:52-wht@n4hgf-when editing string, set cursor to end */
- X/*:07-25-1991-12:57-wht@n4hgf-ECU release 3.10 */
- X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "ecucurses.h"
- X#include <errno.h>
- X#include <ctype.h>
- X#include "ecukey.h"
- X#include "ecuxkey.h"
- X#include "termecu.h"
- X#include "pc_scr.h"
- X
- X#if !defined(ushort)
- X#define ushort unsigned short
- X#endif
- X#if !defined(uchar)
- X#define uchar unsigned char
- X#endif
- X#if !defined(uint)
- X#define uint unsigned int
- X#endif
- X#if !defined(ulong)
- X#define ulong unsigned long
- X#endif
- X
- Xextern int tty_is_multiscreen;
- X
- X#ifdef M_SYSV
- Xunsigned char sTL = at_TL;
- Xunsigned char sTR = at_TR;
- Xunsigned char sBL = at_BL;
- Xunsigned char sBR = at_BR;
- Xunsigned char sLT = at_LT;
- Xunsigned char sRT = at_RT;
- Xunsigned char sVR = at_VR;
- Xunsigned char sHR = at_HR;
- X
- X#else
- X#ifdef LINUX
- Xchtype sTL = vanilla_TL;
- Xchtype sTR = vanilla_TR;
- Xchtype sBL = vanilla_BL;
- Xchtype sBR = vanilla_BR;
- Xchtype sLT = vanilla_LT;
- Xchtype sRT = vanilla_RT;
- Xchtype sVR = vanilla_VR;
- Xchtype sHR = vanilla_HR;
- X
- X#else
- Xunsigned char sTL = vanilla_TL;
- Xunsigned char sTR = vanilla_TR;
- Xunsigned char sBL = vanilla_BL;
- Xunsigned char sBR = vanilla_BR;
- Xunsigned char sLT = vanilla_LT;
- Xunsigned char sRT = vanilla_RT;
- Xunsigned char sVR = vanilla_VR;
- Xunsigned char sHR = vanilla_HR;
- X
- X#endif
- X#endif
- X
- Xint windows_active = 0;
- X
- Xint ttymode_before_window_start;
- X
- X/*+-------------------------------------------------------------------------
- X clear_area_char(win,y,x,len,fillchar)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xclear_area_char(win, y, x, len, fillchar)
- XWINDOW *win;
- Xint y;
- Xint x;
- Xint len;
- Xchar fillchar;
- X{
- X wmove(win, y, x);
- X while (len-- > 0)
- X waddch(win, fillchar & 0xFF);
- X wmove(win, y, x);
- X
- X} /* end of clear_area_char */
- X
- X/*+-------------------------------------------------------------------------
- X clear_area(win,y,x,len)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xclear_area(win, y, x, len)
- XWINDOW *win;
- Xint y;
- Xint x;
- Xint len;
- X{
- X clear_area_char(win, y, x, len, ' ');
- X} /* end of clear_area_char */
- X
- X/*+-------------------------------------------------------------------------
- X windows_start()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xwindows_start()
- X{
- X extern int tty_not_char_special;
- X static int initscr_already_performed = 0;
- X
- X if (tty_not_char_special)
- X {
- X errno = ENOTTY;
- X fprintf(stderr, "curses features unavailable when stdin not tty\r\n");
- X termecu(TERMECU_CURSES_ERROR);
- X }
- X
- X ttymode_before_window_start = get_ttymode();
- X ttymode(0);
- X if (!initscr_already_performed && !initscr())
- X {
- X fprintf(stderr, "curses init failure ... check terminal type\r\n");
- X termecu(TERMECU_CURSES_ERROR);
- X }
- X initscr_already_performed = 1;
- X scrollok(stdscr, 0);
- X savetty();
- X raw();
- X noecho();
- X nonl();
- X clear();
- X#if defined(M_TERMINFO) && !defined(LINUX) && !defined(BSD)
- X typeahead(-1);
- X#endif
- X windows_active = 1;
- X
- X#if defined(M_SYSV)
- X if (!tty_is_multiscreen)
- X {
- X sTL = vanilla_TL;
- X sTR = vanilla_TR;
- X sBL = vanilla_BL;
- X sBR = vanilla_BR;
- X sLT = vanilla_LT;
- X sRT = vanilla_RT;
- X sVR = vanilla_VR;
- X sHR = vanilla_HR;
- X }
- X#endif
- X
- X#if defined(LINUX)
- X sTL = ACS_ULCORNER;
- X sTR = ACS_URCORNER;
- X sBL = ACS_LLCORNER;
- X sBR = ACS_LRCORNER;
- X sLT = ACS_LTEE;
- X sRT = ACS_RTEE;
- X sVR = ACS_VLINE;
- X sHR = ACS_HLINE;
- X#endif
- X
- X wclear(stdscr);
- X touchwin(stdscr);
- X wrefresh(stdscr);
- X
- X} /* end of windows_start */
- X
- X/*+-------------------------------------------------------------------------
- X windows_end(botleft_flag)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xwindows_end(botleft_flag)
- Xint botleft_flag;
- X{
- X if (!windows_active)
- X return;
- X#if !defined(M_UNIX) && !defined(M_XENIX)
- X endwin();
- X#else
- X refresh();
- X#endif
- X if (botleft_flag)
- X tcap_cursor(LINES - 1, 0);
- X ttymode(ttymode_before_window_start);
- X windows_active = 0;
- X} /* end of windows_end */
- X
- X/*+-------------------------------------------------------------------------
- X windows_end_signal() -- called by termecu()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xwindows_end_signal()
- X{
- X windows_end(0);
- X} /* end of windows_end_signal */
- X
- X/*+-------------------------------------------------------------------------
- X winbox(win)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xwinbox(win)
- XWINDOW *win;
- X{
- X
- X#if defined(SVR4)
- X box(win, (unsigned long)sVR, (unsigned long)sHR);
- X#else
- X box(win, sVR, sHR);
- X#if !defined(LINUX)
- X wmove(win, 0, 0);
- X waddch(win, (unsigned)sTL);
- X wmove(win, win->_maxy - 1, 0);
- X waddch(win, (unsigned)sBL);
- X wmove(win, win->_maxy - 1, win->_maxx - 1);
- X waddch(win, (unsigned)sBR);
- X wmove(win, 0, win->_maxx - 1);
- X waddch(win, (unsigned)sTR);
- X#endif
- X#endif
- X
- X} /* end of winbox */
- X
- X/*+-------------------------------------------------------------------------
- X window_setup(win,title,title_x)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xwindow_setup(win, title, title_x)
- XWINDOW *win;
- Xchar *title;
- Xint title_x;
- X{
- X register stand = (title_x < 0);
- X
- X if (stand)
- X title_x = -title_x;
- X
- X touchwin(win);
- X scrollok(win, 0); /* do not scroll */
- X winbox(win);
- X wmove(win, 0, title_x);
- X if (stand)
- X wstandout(win);
- X waddch(win, '[');
- X wprintw(win, " %s ", title);
- X waddch(win, ']');
- X if (stand)
- X wstandend(win);
- X} /* end of window_setup */
- X
- X/*+-------------------------------------------------------------------------
- X window_create(title,title_x,tly,tlx,lines,cols)
- Xif title_x negative, make title "stand" out
- X--------------------------------------------------------------------------*/
- XWINDOW *
- Xwindow_create(title, title_x, tly, tlx, lines, cols)
- Xchar *title;
- Xint title_x;
- Xint tly;
- Xint tlx;
- Xint lines;
- Xint cols;
- X{
- X register WINDOW *nwin = newwin(lines, cols, tly, tlx);
- X
- X if (nwin)
- X window_setup(nwin, title, title_x);
- X else
- X {
- X fprintf(stderr, "\r\ncurses error: cannot create new window\r\n");
- X termecu(TERMECU_CURSES_ERROR);
- X }
- X return (nwin);
- X} /* end of window_create */
- X
- X/*+-------------------------------------------------------------------------
- X wingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
- X
- XThis procedure reads a string from win and returns the number
- Xof characters read.
- X
- XIf edit is non-zero and pwgpos is not null, the inital string
- Xposition is set by dereferencing the pointer.
- X
- XThe terminating delim is returned in 'delim'.
- X
- XIf pwgpos is not null, the ending string position is returned in
- Xthe integer pointed to.
- X
- X-1 is returned if an ESCape is typed by the keyboard user,
- Xotherwise the count of characters in the string.
- X
- XThe entire line must be contained on one line (no line wrap supported).
- X--------------------------------------------------------------------------*/
- Xint
- Xwingets(win, y, x, buf, bufsize, delim, edit, pwgpos)
- XWINDOW *win;
- Xint y;
- Xregister x;
- Xregister char *buf;
- Xint bufsize; /* includes room for null..field is 1 less */
- Xregister uchar *delim;
- Xint edit;
- Xint *pwgpos;
- X{
- X register count = 0;
- X register pos = 0;
- X int insert_mode = 0;
- X
- X#ifndef OLD_WINGETS
- X int highlight_delete = 0;
- X
- X#endif
- X int rtn_val = 0;
- X
- X bufsize--;
- X if (edit && strlen(buf))
- X {
- X#ifndef OLD_WINGETS
- X highlight_delete = 1;
- X#endif
- X clear_area_char(win, y, x, bufsize, ' ');
- X wstandout(win);
- X waddstr(win, buf);
- X wstandend(win);
- X count = pos = strlen(buf);
- X if (pwgpos)
- X {
- X pos = *pwgpos;
- X if ((pos < 0) || (pos > count))
- X pos = count;
- X }
- X }
- X else
- X {
- X clear_area_char(win, y, x, bufsize, '_');
- X *buf = 0;
- X }
- X
- X wmove(win, y, x + pos);
- X
- X while (1)
- X {
- X wrefresh(win);
- X *delim = ttygetc(1);
- X if ((*delim < 0x20) || (*delim >= 0x7F))
- X {
- X#ifndef OLD_WINGETS
- X if (highlight_delete)
- X {
- X clear_area_char(win, y, x, bufsize, '_');
- X waddstr(win, buf);
- X wmove(win, y, x + pos);
- X highlight_delete = 0;
- X }
- X#endif
- X switch (*delim)
- X {
- X case CRET:
- X *delim = NL;
- X case NL:
- X wrefresh(win);
- X rtn_val = count;
- X goto FUNC_RETURN;
- X
- X case BS:
- X case DEL:
- X if (count)
- X {
- X if (count == pos)
- X {
- X *(buf + --count) = 0;
- X wmove(win, y, x + count);
- X waddch(win, '_');
- X wmove(win, y, x + count);
- X pos--;
- X }
- X else
- X {
- X if (!pos)
- X continue;
- X mem_cpy(buf + pos - 1, buf + pos, count - pos);
- X *(buf + --count) = 0;
- X wmove(win, y, x + --pos);
- X waddstr(win, buf + pos);
- X waddch(win, '_');
- X wmove(win, y, x + pos);
- X }
- X }
- X continue;
- X
- X case XFcurlf:
- X if (pos)
- X wmove(win, y, x + --pos);
- X continue;
- X
- X case XFcurrt:
- X if (pos < count)
- X wmove(win, y, x + ++pos);
- X continue;
- X
- X case XFins:
- X insert_mode = !insert_mode;
- X continue;
- X
- X case ESC:
- X rtn_val = -1;
- X goto FUNC_RETURN;
- X
- X case CTL_U:
- X clear_area_char(win, y, x, bufsize, '_');
- X count = 0;
- X pos = 0;
- X *buf = 0;
- X continue;
- X
- X default:
- X *(buf + count) = 0;
- X rtn_val = count;
- X goto FUNC_RETURN;
- X
- X } /* end of switch(*delim) */
- X /* NOTREACHED */
- X } /* end of if read delimiter */
- X
- X#ifndef OLD_WINGETS
- X if (highlight_delete)
- X {
- X clear_area_char(win, y, x, bufsize, '_');
- X count = 0;
- X pos = 0;
- X highlight_delete = 0;
- X }
- X#endif
- X
- X if (count == bufsize)
- X {
- X ring_bell();
- X continue;
- X }
- X
- X if (insert_mode && (pos != count))
- X {
- X waddch(win, *delim);
- X waddstr(win, buf + pos);
- X mem_cpy(buf + pos + 1, buf + pos, count - pos);
- X *(buf + pos++) = *delim;
- X *(buf + ++count) = 0;
- X wmove(win, y, x + pos);
- X }
- X else
- X {
- X waddch(win, *delim);
- X *(buf + pos) = *delim;
- X if (pos == count)
- X *(buf + ++count) = 0;
- X pos++;
- X }
- X } /* end of while can get character */
- X
- X FUNC_RETURN:
- X if (pwgpos)
- X *pwgpos = pos;
- X return (rtn_val);
- X
- X} /* end of wingets */
- X
- X/*+-------------------------------------------------------------------------
- X winget_single(win,nondelim_list,delim_list)
- X
- XThis procedure assumes cursor is positioned, repeats reading a non-echoing
- Xcharacter from the keyboard until it matches a character in nondelim_list
- Xor delim_list. delim_list is expected to contain printable characters
- Xand no upper-case characters.
- X
- XIf no match occurs, the bell is rung and the keyboard is read again.
- X
- XIf the input character matches a character in delim_list, the index (0-n)
- Xof the character in delim_list is returned. If a match occurs, an
- Xupper-case version of the matching character is placed in the window.
- X
- XIf the input character matches a character in nondelim_list, the character
- Xis returned or'ed with 0x1000
- X
- X--------------------------------------------------------------------------*/
- Xint
- Xwinget_single(win, nondelim_list, delim_list)
- XWINDOW *win;
- Xregister uchar *nondelim_list;
- Xregister uchar *delim_list;
- X{
- X register itmp;
- X register nlen = strlen(nondelim_list);
- X register dlen = strlen(delim_list);
- X register unsigned int ichar;
- X
- X wrefresh(win);
- X
- X while (1)
- X {
- X ichar = to_lower(ttygetc(1));
- X for (itmp = 0; itmp < nlen; itmp++)
- X {
- X if (ichar == nondelim_list[itmp])
- X {
- X if (isprint(ichar))
- X waddch(win, to_upper(ichar));
- X wrefresh(win);
- X return (itmp);
- X }
- X }
- X for (itmp = 0; itmp < dlen; itmp++)
- X {
- X if (ichar == delim_list[itmp])
- X return (ichar | 0x1000);
- X }
- X ring_bell();
- X }
- X
- X} /* end of winget_single */
- X
- X/* end of ecuwinutil.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 12629 -ne `wc -c <'ecu330/ecuwinutil.c'`; then
- echo shar: \"'ecu330/ecuwinutil.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecuwinutil.c'
- fi
- if test -f 'ecu330/fasi/Space.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/fasi/Space.c'\"
- else
- echo shar: Extracting \"'ecu330/fasi/Space.c'\" \(8855 characters\)
- sed "s/^X//" >'ecu330/fasi/Space.c' <<'END_OF_FILE'
- X/* Async device configuration file for the FAS async driver. */
- X
- X/*
- X * COM1(STD) + COM2(DIGIBOARD PC-8)
- 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/*:07-25-1991-12:57-wht@n4hgf-ECU release 3.10 */
- X/*:01-20-1991-16:17-wht@n4hgf-add fas_names */
- X/*:01-20-1991-05:01-wht@n4hgf-changed buffer sizes */
- X/*:01-16-1991-22:13-wht@n4hgf-creation */
- X
- X/* FAS was developed by ( ==> BUT DO NOT CONTACT HIM ABOUT THIS HACK )
- XUwe Doering INET : gemini@geminix.in-berlin.de
- XBillstedter Pfad 17 b UUCP : ...!unido!fub!geminix.in-berlin.de!gemini
- X1000 Berlin 20
- XGermany
- X*/
- X
- X/* Alas, SCO idinstall has no -z (Define) option like ISC does */
- X#if !defined(FASI)
- X#define FASI
- X#endif
- X#if !defined(SCO)
- X#define SCO
- X#endif
- X
- X#if defined(FASI)
- X/* {quan,irq,addr1-addr2,type} */
- Xchar *fasi_space_ident =
- X"FAS/i 2.08:{1,4,03f8-03ff,COM1},{8,3,0210-024f,DIGI-PC8}";
- X
- X#endif /* FASI */
- X
- X#if !defined (M_I286) && !defined(__STDC__) && !defined(__GNUC__)
- X#ident "@(#)space.c 2.08.0 COM1(STD) + COM2(DIGIBOARD PC-8)";
- X#endif
- X
- X#include <sys/param.h>
- X#include <sys/types.h>
- X#include <sys/signal.h>
- X#include <sys/buf.h>
- X#include <sys/dir.h>
- X#if defined (XENIX)
- X#include <sys/page.h>
- X#include <sys/seg.h>
- X#endif
- X#include <sys/user.h>
- X#include <sys/errno.h>
- X#include <sys/tty.h>
- X#include <sys/conf.h>
- X#include <sys/sysinfo.h>
- X#include <sys/file.h>
- X#if !defined (XENIX) && !defined(CBAUD)
- X#include <sys/termio.h>
- X#endif
- X#include <sys/ioctl.h>
- X#if !defined(FASI)
- X#include <macros.h>
- X#endif
- X#if defined (HAVE_VPIX)
- X#if !defined (XENIX)
- X#include <sys/tss.h>
- X#include <sys/immu.h>
- X#include <sys/region.h>
- X#endif
- X#include <sys/proc.h>
- X#include <sys/v86.h>
- X#endif
- X
- X#if defined (XENIX)
- X#include "fas.h"
- X#include "digi-pc8.h"
- X#else
- X#include <local/fas.h>
- X#include <local/digi-pc8.h>
- X#endif
- X
- X/* This is the number of devices to be handled by this driver.
- X You may define up to 16 devices. If this number is changed
- X the arrays below must be filled in accordingly.
- X*/
- X#define NUM_PHYSICAL_UNITS 9
- X
- X#if NUM_PHYSICAL_UNITS > MAX_UNITS
- X#undef NUM_PHYSICAL_UNITS
- X#define NUM_PHYSICAL_UNITS MAX_UNITS
- X#endif
- X
- X/* let the driver know the number of devices */
- Xuint fas_physical_units = NUM_PHYSICAL_UNITS;
- X
- X/* array of base port addresses
- X If you deliberately want to force off the FIFOs of a UART you have
- X to "or" the NO_FIFO macro to its base port address. This is useful
- X for mouse devices where you need immediate response to the mouse
- X movement.
- X*/
- Xulong fas_port[NUM_PHYSICAL_UNITS] =
- X{
- X 0x3f8,
- X COM21, COM22, COM23, COM24, COM25, COM26, COM27, COM28
- X};
- X
- X/*
- X * array of port names
- X * Note this is a kludge to enable kmem seeking programs to
- X * determine which tty is associated with which tty struct
- X * and is <yetch> duplication of information appearing in
- X * the Node (/etc/node.d/fas) file
- X */
- X#if defined(FASI)
- Xstruct fas_name fas_names[NUM_PHYSICAL_UNITS * 2] =
- X{
- X {"1a"},
- X {"2a"},
- X {"2b"},
- X {"2c"},
- X {"2d"},
- X {"2e"},
- X {"2f"},
- X {"2g"},
- X {"2h"},
- X {"1A"},
- X {"2A"},
- X {"2B"},
- X {"2C"},
- X {"2D"},
- X {"2E"},
- X {"2F"},
- X {"2G"},
- X {"2H"}
- X};
- X
- X#endif
- X
- X/* array of interrupt vectors */
- Xuint fas_vec[NUM_PHYSICAL_UNITS] =
- X{
- X 4,
- X 3, 3, 3, 3, 3, 3, 3, 3
- X};
- X
- X/* initialization sequence for serial card
- X This array contains pairs of values of the form:
- X
- X portaddress, value,
- X :
- X :
- X portaddress, value,
- X 0
- X
- X For every line `value' will be written to `portaddress'. If
- X `value' is replaced with the macro `READ_PORT' then a value
- X is read from `portaddress' instead. The value itself will be
- X discarded. Therefor this makes only sense if the read access
- X to the port has a side effect like setting or resetting
- X certain flags.
- X
- X NOTE: This array *must* be terminated with a value of 0
- X in the portaddress column!
- X*/
- Xuint fas_init_seq[] =
- X{
- X 0
- X};
- X
- X/* initial modem control port info
- X This value is ored into the modem control value for each UART. This is
- X normaly used to force out2 which is used to enable the interrupts of
- X the standard com1 and com2 ports. Several brands of cards have modes
- X that allow them to work in compatible mode like com1 and com2 or as a
- X shared interrupts card. One of these cards is the AST 4-port card. When
- X this card is used in shared interrupts mode out2 must _not_ be set.
- X
- X Note: This is one of the major trouble-spots with shared interrupts
- X cards. Check your manual.
- X*/
- Xuint fas_mcb[NUM_PHYSICAL_UNITS] =
- X{
- X MC_SET_OUT2,
- X MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2,
- X MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2
- X};
- X
- X/* array of modem control flags
- X You can choose which signals to use for modem control. See fas.h
- X for possible names and values. Whether or not modem control is
- X used is determined by the minor device number at open time.
- X*/
- Xulong fas_modem[NUM_PHYSICAL_UNITS] =
- X{
- X EO_DTR | EI_DTR | CA_DCD,
- X EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD,
- X EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD,
- X EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD,
- X EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD
- X};
- X
- X/* array of hardware flow control flags
- X You can choose which signals to use for hardware handshake. See fas.h
- X for possible names and values. Whether or not hardware handshake is
- X used is determined by the minor device number at open time and by the
- X RTSFLOW/CTSFLOW termio(7) flags.
- X*/
- Xulong fas_flow[NUM_PHYSICAL_UNITS] =
- X{
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS,
- X HI_RTS | HO_CTS_ON_DSR | HX_RTS
- X};
- X
- X/* array of control register addresses
- X There are serial boards available that have all serial ports
- X multiplexed to one address location in order to save I/O address
- X space (Bell Tech HUB-6 card etc.). This multiplexing is controlled
- X by a special register that needs to be written to before the actual
- X port registers can be accessed. This array contains the addresses
- X of these special registers.
- X Enter the addresses on a per unit base. An address of zero
- X disables this feature.
- X*/
- Xuint fas_ctl_port[NUM_PHYSICAL_UNITS] =
- X{
- X 0,
- X 0, 0, 0, 0, 0, 0, 0, 0
- X};
- X
- X/* array of control register values
- X These values are written to the corresponding control register
- X before the first access to the actual port registers. If not only
- X entire UART chips (blocks of 8 contiguous addresses) but even the
- X single registers of the UART chips need to be multiplexed to one
- X address you have to "or" a bit mask (shifted 8 times to the left)
- X to the control register value. This mask determines at which bit
- X locations the UART chip register number is "xored" into the control
- X register value at runtime. This implies that you can also use
- X negative logic by setting the bits in the control register value
- X to 1 at the locations corresponding to the bit mask.
- X*/
- Xuint fas_ctl_val[NUM_PHYSICAL_UNITS] =
- X{
- X 0,
- X 0, 0, 0, 0, 0, 0, 0, 0
- X};
- X
- X/* additional configurations for shared interrupts boards
- X If you have a shared interrupts board, you may have to acknowledge
- X interrupts by writing to a special register. The following arrays
- X contain the special register addresses and the corresponding values
- X that are written to them in response to an interrupt.
- X*/
- X
- X/* array of int ack register addresses
- X These registers are written to every time after all interrupt
- X sources in all of the UARTs that are tied to the corresponding
- X interrupt vector have been cleared.
- X Enter the addresses on a per vector base. An address of zero
- X disables this feature.
- X*/
- Xuint fas_int_ack_port[NUM_INT_VECTORS] =
- X{
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0
- X};
- X
- X/* array of int ack values
- X These values are written to the corresponding int ack register
- X in response to an interrupt.
- X*/
- Xuint fas_int_ack[NUM_INT_VECTORS] =
- X{
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0,
- X 0, 0, 0, 0
- X};
- X
- X/* NOTHING NEEDS TO BE CHANGED BELOW THIS LINE.
- X ============================================
- X*/
- X
- X/* array of structures to hold all info for a physical minor device */
- Xstruct fas_info fas_info[NUM_PHYSICAL_UNITS];
- X
- X/* array of ttys for logical minor devices */
- Xstruct tty fas_tty[NUM_PHYSICAL_UNITS * 2];
- X
- X/* array of pointers to fas_info structures
- X this prevents time consuming multiplications for index calculation
- X*/
- Xstruct fas_info *fas_info_ptr[NUM_PHYSICAL_UNITS];
- X
- X/* array of pointers to fas_tty structures
- X this prevents time consuming multiplications for index calculation
- X*/
- Xstruct tty *fas_tty_ptr[NUM_PHYSICAL_UNITS * 2];
- END_OF_FILE
- if test 8855 -ne `wc -c <'ecu330/fasi/Space.c'`; then
- echo shar: \"'ecu330/fasi/Space.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/fasi/Space.c'
- fi
- if test -f 'ecu330/gendial/dceUSR24v.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/gendial/dceUSR24v.c'\"
- else
- echo shar: Extracting \"'ecu330/gendial/dceUSR24v.c'\" \(12151 characters\)
- sed "s/^X//" >'ecu330/gendial/dceUSR24v.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X dceUSR24v.c - DCE-specific portion of generic SCO UUCP dialer
- X Driver for USR Courier 2400 - optimized for rapid use as voice dialer
- X wht@n4hgf.atl.ga.us
- X
- X This is for attended voice applications where speed of operation is
- X more important than superb reliability. The modem I had in mind
- X here is an old (simple and reliable) USR 2400 I had lying around
- X doing nothing. Now it is a voice line dialer. Autoanswer is always
- X turned off whenever we can do it. No one goes after the modem
- X anywhere near once per minute. We can dispense with delays and
- X brick outhouse initialization.
- X
- X Necessary DCE switch setting or other configuration:
- X enable onhook upon loss of DTR
- X
- XThis dialer does not use the X6 quick dial feature, nor voice detection.
- XQuick dial tone recognition often fqails due to the telco granting
- Xdial tone ahead of the actual time it is ready to accept dialing.
- XVoice recognition fails when dialing 0+ with a credit card, as in "Thank
- Xyou for using ATT" - CLICK - "VOICE".
- 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: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/*:07-25-1991-04:34-wht@n4hgf-add naps around writes */
- X/*:04-16-1991-18:18-wht@n4hgf-creation from template */
- 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 = 100L;
- 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 = 50L;
- 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 = "USR Courier 2400 quick voice";
- Xchar *DCE_revision = "1.00";
- 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 = 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#define rfMASK 0x000000FF
- 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 rVoice 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 {"VOICE", rVoice},
- X {"CONNECT 1200", rConnect1200},
- 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__)
- X return (0); /* I wish this wasn't necessary to avoid
- X * warnings */
- 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
- XYou must set any switches necessary to make modem hang up on loss of DTR
- X--------------------------------------------------------------------------*/
- Xvoid
- XDCE_hangup()
- X{
- X
- X DEBUG(1, "--> hanging up %s\n", dce_name);
- X lflash_DTR();
- X
- X lwrite("ATQ0S0=0\r");
- X Nap(20L);
- 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--------------------------------------------------------------------------*/
- 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 *sptr;
- X char *dptr;
- X char ch;
- X int len;
- X
- X sptr = telno_str;
- X dptr = phone + 1;
- X *dptr = 0;
- X while (ch = *sptr++)
- X {
- X if (isdigit(ch) || (ch == ','))
- X {
- X *dptr++ = ch;
- X *dptr = 0;
- X }
- X }
- X
- X telno_str = phone + 1;
- X if (((len = strlen(phone + 1)) == 10) &&
- X ((phone[1 + 1] == '0') || (phone[1 + 1] == '1')))
- X {
- X phone[0] = '1';
- X telno_str = phone;
- X }
- X
- X/*
- X * build and issue the actual dialing command
- X */
- X DEBUG(1, "--> dialing %s\n", telno_str);
- X sprintf(cmd, "ATe1Q0V1S0=0S7=120X3DT%s\r", telno_str);
- X DCE_write_pace_msec = 20;
- X lwrite("AA");
- X DCE_write_pace_msec = 0;
- X lwrite(cmd);
- 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 rVoice: /* if you get voice, certainly wrong number */
- 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/* indicate non-root can see DTE->DCE traffic */
- X secure = 0;
- 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 12151 -ne `wc -c <'ecu330/gendial/dceUSR24v.c'`; then
- echo shar: \"'ecu330/gendial/dceUSR24v.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/gendial/dceUSR24v.c'
- fi
- if test -f 'ecu330/regexp.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/regexp.c'\"
- else
- echo shar: Extracting \"'ecu330/regexp.c'\" \(12818 characters\)
- sed "s/^X//" >'ecu330/regexp.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X regexp.c -- regular expression functions made sane
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X advance(lp,ep)
- X compile(pattern,ep,endbuf,seof)
- X ecmp(a,b,count)
- X getrnge(regexp)
- X regexp_compile(regexp,cmpbuf,cmpbuf_size,emsg)
- X regexp_operation(match_str,regexp_str,rtn_value)
- X regexp_scan(cmpbuf,str_to_search,match,matchlen)
- X step(p1,p2)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:40-wht@n4hgf-ECU release 3.30 */
- 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/*:08-28-1991-14:07-wht@n4hgf2-SVR4 cleanup by aega84!lh */
- 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#include <stdio.h>
- X#include "ecuerror.h"
- X#include "esd.h"
- X#include "var.h"
- X#include <setjmp.h>
- X
- X#define CBRA 2
- X#define CCHR 4
- X#define CDOT 8
- X#define CCL 12
- X#define CDOL 20
- X#define CCEOF 22
- X#define CKET 24
- X#define CBACK 36
- X
- X#define STAR 01
- X#define RNGE 03
- X
- X#define NBRA 9
- X
- X#define PLACE(c) ep[c >> 3] |= bittab[c & 07]
- X#define ISTHERE(c) (ep[c >> 3] & bittab[c & 07])
- X
- Xvoid getrnge();
- Xint advance();
- Xint ecmp();
- X
- Xextern int proc_level;
- Xextern int proc_trace;
- X
- Xchar *braslist[NBRA];
- Xchar *braelist[NBRA];
- Xint nbra;
- Xint ebra;
- Xchar *match_start;
- Xchar *match_end;
- Xchar *locs;
- Xint sed;
- Xint nodelim;
- Xint circf;
- Xint low;
- Xint size;
- Xunsigned char bittab[] =
- X{1, 2, 4, 8, 16, 32, 64, 128};
- Xjmp_buf compile_error_jmpbuf;
- X
- X/*+-------------------------------------------------------------------------
- X compile(pattern,ep,endbuf,seof)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcompile(pattern, ep, endbuf, seof)
- Xchar *pattern;
- Xregister char *ep;
- Xchar *endbuf;
- Xint seof;
- X{
- X register char *sp = pattern;
- X register c;
- X register eof = seof;
- X char *lastep = pattern;
- X int cclcnt;
- X char bracket[NBRA], *bracketp;
- X int closed;
- X char neg;
- X int lc;
- X int i, cflg;
- X
- X lastep = 0;
- X if ((c = *sp++) == eof || c == '\n')
- X {
- X if (c == '\n')
- X {
- X --sp;
- X nodelim = 1;
- X }
- X if (*ep == 0 && !sed)
- X longjmp(compile_error_jmpbuf, 41);
- X return;
- X }
- X bracketp = bracket;
- X circf = closed = nbra = ebra = 0;
- X if (c == '^')
- X circf++;
- X else
- X --sp;
- X while (1)
- X {
- X if (ep >= endbuf)
- X longjmp(compile_error_jmpbuf, 50);
- X c = *sp++;
- X if (c != '*' && ((c != '\\') || (*sp != 0x7B)))
- X lastep = ep;
- X if (c == eof)
- X {
- X *ep++ = CCEOF;
- X return;
- X }
- X switch (c)
- X {
- X
- X case '.':
- X *ep++ = CDOT;
- X continue;
- X
- X case '\n':
- X if (!sed)
- X {
- X --sp;
- X *ep++ = CCEOF;
- X nodelim = 1;
- X return;
- X }
- X else
- X longjmp(compile_error_jmpbuf, 36);
- X case '*':
- X if (lastep == 0 || *lastep == CBRA || *lastep == CKET)
- X goto defchar;
- X *lastep |= STAR;
- X continue;
- X
- X case '$':
- X if (*sp != eof && *sp != '\n')
- X goto defchar;
- X *ep++ = CDOL;
- X continue;
- X
- X case '[':
- X if (&ep[17] >= endbuf)
- X longjmp(compile_error_jmpbuf, 50);
- X
- X *ep++ = CCL;
- X lc = 0;
- X for (i = 0; i < 16; i++)
- X ep[i] = 0;
- X
- X neg = 0;
- X if ((c = *sp++) == '^')
- X {
- X neg = 1;
- X c = *sp++;
- X }
- X
- X do
- X {
- X if (c == '\0' || c == '\n')
- X longjmp(compile_error_jmpbuf, 49);
- X if (c == '-' && lc != 0)
- X {
- X if ((c = *sp++) == ']')
- X {
- X PLACE('-');
- X break;
- X }
- X while (lc < c)
- X {
- X PLACE(lc);
- X lc++;
- X }
- X }
- X if (c == '\\')
- X {
- X switch (c = *sp++)
- X {
- X case 'n':
- X c = '\n';
- X break;
- X }
- X }
- X lc = c;
- X PLACE(c);
- X }
- X while ((c = *sp++) != ']');
- X if (neg)
- X {
- X for (cclcnt = 0; cclcnt < 16; cclcnt++)
- X ep[cclcnt] ^= -1;
- X ep[0] &= 0376;
- X }
- X
- X ep += 16;
- X
- X continue;
- X
- X case '\\':
- X switch (c = *sp++)
- X {
- X
- X case 0x28: /* open paren */
- X if (nbra >= NBRA)
- X longjmp(compile_error_jmpbuf, 43);
- X *bracketp++ = nbra;
- X *ep++ = CBRA;
- X *ep++ = nbra++;
- X continue;
- X
- X case 0x29: /* close paren */
- X if (bracketp <= bracket || ++ebra != nbra)
- X longjmp(compile_error_jmpbuf, 42);
- X *ep++ = CKET;
- X *ep++ = *--bracketp;
- X closed++;
- X continue;
- X
- X case 0x7B: /* open brace */
- X if (lastep == (char *)(0))
- X goto defchar;
- X *lastep |= RNGE;
- X cflg = 0;
- X nlim:
- X c = *sp++;
- X i = 0;
- X do
- X {
- X if ('0' <= c && c <= '9')
- X i = 10 * i + c - '0';
- X else
- X longjmp(compile_error_jmpbuf, 16);
- X }
- X while (((c = *sp++) != '\\') && (c != ','));
- X if (i >= 255)
- X longjmp(compile_error_jmpbuf, 11);
- X *ep++ = i;
- X if (c == ',')
- X {
- X if (cflg++)
- X longjmp(compile_error_jmpbuf, 44);
- X if ((c = *sp++) == '\\')
- X *ep++ = 255;
- X else
- X {
- X --sp;
- X goto nlim;
- X /* get 2'nd number */
- X }
- X }
- X if (*sp++ != 0x7D) /* close brace */
- X longjmp(compile_error_jmpbuf, 45);
- X if (!cflg) /* one number */
- X *ep++ = i;
- X else if ((ep[-1] & 0377) < (ep[-2] & 0377))
- X longjmp(compile_error_jmpbuf, 46);
- X continue;
- X
- X case '\n':
- X longjmp(compile_error_jmpbuf, 36);
- X
- X case 'n':
- X c = '\n';
- X goto defchar;
- X
- X default:
- X if (c >= '1' && c <= '9')
- X {
- X if ((c -= '1') >= closed)
- X longjmp(compile_error_jmpbuf, 25);
- X *ep++ = CBACK;
- X *ep++ = c;
- X continue;
- X }
- X }
- X
- X /*
- X * Drop through to default to use \ to turn off special
- X * chars
- X */
- X
- X defchar:
- X default:
- X lastep = ep;
- X *ep++ = CCHR;
- X *ep++ = c;
- X }
- X }
- X} /* end of compile */
- X
- X/*+-------------------------------------------------------------------------
- X step(p1,p2)
- X--------------------------------------------------------------------------*/
- Xint
- Xstep(p1, p2)
- Xregister char *p1, *p2;
- X{
- X register c;
- X
- X if (circf)
- X {
- X match_start = p1;
- X return (advance(p1, p2));
- X }
- X /* fast check for first character */
- X if (*p2 == CCHR)
- X {
- X c = p2[1];
- X do
- X {
- X if (*p1 != c)
- X continue;
- X if (advance(p1, p2))
- X {
- X match_start = p1;
- X return (1);
- X }
- X }
- X while (*p1++);
- X return (0);
- X }
- X /* regular algorithm */
- X do
- X {
- X if (advance(p1, p2))
- X {
- X match_start = p1;
- X return (1);
- X }
- X }
- X while (*p1++);
- X return (0);
- X} /* end of step */
- X
- X/*+-------------------------------------------------------------------------
- X advance(lp,ep)
- X--------------------------------------------------------------------------*/
- Xint
- Xadvance(lp, ep)
- Xregister char *lp, *ep;
- X{
- X register char *curlp;
- X char c;
- X char *bbeg;
- X int ct;
- X
- X while (1)
- X switch (*ep++)
- X {
- X
- X case CCHR:
- X if (*ep++ == *lp++)
- X continue;
- X return (0);
- X
- X case CDOT:
- X if (*lp++)
- X continue;
- X return (0);
- X
- X case CDOL:
- X if (*lp == 0)
- X continue;
- X return (0);
- X
- X case CCEOF:
- X match_end = lp;
- X return (1);
- X
- X case CCL:
- X c = *lp++ & 0177;
- X if (ISTHERE(c))
- X {
- X ep += 16;
- X continue;
- X }
- X return (0);
- X case CBRA:
- X braslist[*ep++] = lp;
- X continue;
- X
- X case CKET:
- X braelist[*ep++] = lp;
- X continue;
- X
- X case CCHR | RNGE:
- X c = *ep++;
- X getrnge(ep);
- X while (low--)
- X if (*lp++ != c)
- X return (0);
- X curlp = lp;
- X while (size--)
- X if (*lp++ != c)
- X break;
- X if (size < 0)
- X lp++;
- X ep += 2;
- X goto star;
- X
- X case CDOT | RNGE:
- X getrnge(ep);
- X while (low--)
- X if (*lp++ == '\0')
- X return (0);
- X curlp = lp;
- X while (size--)
- X if (*lp++ == '\0')
- X break;
- X if (size < 0)
- X lp++;
- X ep += 2;
- X goto star;
- X
- X case CCL | RNGE:
- X getrnge(ep + 16);
- X while (low--)
- X {
- X c = *lp++ & 0177;
- X if (!ISTHERE(c))
- X return (0);
- X }
- X curlp = lp;
- X while (size--)
- X {
- X c = *lp++ & 0177;
- X if (!ISTHERE(c))
- X break;
- X }
- X if (size < 0)
- X lp++;
- X ep += 18; /* 16 + 2 */
- X goto star;
- X
- X case CBACK:
- X bbeg = braslist[*ep];
- X ct = braelist[*ep++] - bbeg;
- X
- X if (ecmp(bbeg, lp, ct))
- X {
- X lp += ct;
- X continue;
- X }
- X return (0);
- X
- X case CBACK | STAR:
- X bbeg = braslist[*ep];
- X ct = braelist[*ep++] - bbeg;
- X curlp = lp;
- X while (ecmp(bbeg, lp, ct))
- X lp += ct;
- X
- X while (lp >= curlp)
- X {
- X if (advance(lp, ep))
- X return (1);
- X lp -= ct;
- X }
- X return (0);
- X
- X case CDOT | STAR:
- X curlp = lp;
- X while (*lp++) ;
- X goto star;
- X
- X case CCHR | STAR:
- X curlp = lp;
- X while (*lp++ == *ep) ;
- X ep++;
- X goto star;
- X
- X case CCL | STAR:
- X curlp = lp;
- X do
- X {
- X c = *lp++ & 0177;
- X }
- X while (ISTHERE(c));
- X ep += 16;
- X goto star;
- X
- X star:
- X do
- X {
- X if (--lp == locs)
- X break;
- X if (advance(lp, ep))
- X return (1);
- X }
- X while (lp > curlp);
- X return (0);
- X
- X }
- X} /* end of advance */
- X
- X/*+-------------------------------------------------------------------------
- X getrnge(regexp)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xgetrnge(regexp)
- Xregister char *regexp;
- X{
- X low = *regexp++ & 0377;
- X size = ((*regexp & 0377) == 255) ? 20000 : (*regexp & 0377) - low;
- X} /* end of getrnge */
- X
- X/*+-------------------------------------------------------------------------
- X ecmp(a,b,count)
- X--------------------------------------------------------------------------*/
- Xint
- Xecmp(a, b, count)
- Xregister char *a, *b;
- Xregister count;
- X{
- X while (count--)
- X if (*a++ != *b++)
- X return (0);
- X return (1);
- X} /* end of ecmp */
- X
- X/*+-------------------------------------------------------------------------
- X itmp = regexp_compile(regexp,cmpbuf,cmpbuf_size,emsg)
- X
- Xreturns 0 if no compile error,
- Xelse error occurred (*emsg points to error message text)
- X--------------------------------------------------------------------------*/
- Xint
- Xregexp_compile(regexp, cmpbuf, cmpbuf_size, emsg)
- Xchar *regexp;
- Xchar *cmpbuf;
- Xint cmpbuf_size;
- Xchar **emsg;
- X{
- X register int itmp;
- X static char errm[40];
- X
- X if (itmp = setjmp(compile_error_jmpbuf))
- X {
- X switch (itmp)
- X {
- X case 11:
- X *emsg = "Range endpoint too large";
- X break;
- X case 16:
- X *emsg = "Bad number";
- X break;
- X case 25:
- X *emsg = "\"\\digit\" out of range";
- X break;
- X case 36:
- X *emsg = "Illegal or missing delimiter";
- X break;
- X case 41:
- X *emsg = "No previous regular expression";
- X break;
- X case 42:
- X *emsg = "More \\)'s than \\('s in regular expression";
- X break;
- X case 43:
- X *emsg = "More \\('s than \\)'s in regular expression";
- X break;
- X case 44:
- X *emsg = "More than 2 numbers in \\{ \\}";
- X break;
- X case 45:
- X *emsg = "} expected after \\";
- X break;
- X case 46:
- X *emsg = "First number exceeds second in \\{ \\}";
- X break;
- X case 49:
- X *emsg = "[] imbalance";
- X break;
- X case 50:
- X *emsg = "Regular expression too complex";
- X break;
- X default:
- X sprintf(errm, "Unknown regexp compile error %d", itmp);
- X *emsg = errm;
- X break;
- X }
- X return (itmp);
- X }
- X
- X compile(regexp, cmpbuf, cmpbuf + cmpbuf_size, 0);
- X return (0);
- X} /* end of regexp_compile */
- X
- X/*+-------------------------------------------------------------------------
- X regexp_scan(cmpbuf,str_to_search,&match,&matchlen)
- Xreturn 1 if string match found, else 0
- Xif string matches, match receives pointer to first byte, matchlen = length
- Xof matching string
- X--------------------------------------------------------------------------*/
- Xregexp_scan(cmpbuf, str_to_search, match, matchlen)
- Xchar *cmpbuf;
- Xchar *str_to_search;
- Xchar **match;
- Xint *matchlen;
- X{
- X register int itmp = step(str_to_search, cmpbuf);
- X
- X if (itmp)
- X {
- X *match = match_start;
- X *matchlen = (int)(match_end - match_start);
- X }
- X return (itmp);
- X} /* end of regexp_scan */
- X
- X/*+-------------------------------------------------------------------------
- X regexp_operation(match_str,regexp_str,rtn_value)
- X
- Xone stop operation used by procedure language:
- Xdetermine if 'match_str' matches 'regexp_str', returning the index of
- Xthe match in *rtn_value and setting #I0 to the length of the match
- X
- Xreturns 0 if no error, else eFATAL_ALREADY after printing the error message
- X--------------------------------------------------------------------------*/
- Xint
- Xregexp_operation(match_str, regexp_str, rtn_value)
- Xchar *match_str;
- Xchar *regexp_str;
- Xlong *rtn_value;
- X{
- X#define CMPBUF_SIZE 512
- X char cmpbuf[CMPBUF_SIZE];
- X char *emsg;
- X char *match;
- X int matchlen;
- X
- X if (regexp_compile(regexp_str, cmpbuf, sizeof(cmpbuf), &emsg))
- X {
- X pprintf("regexp compile error: %s\n", emsg);
- X return (eFATAL_ALREADY);
- X }
- X
- X if (regexp_scan(cmpbuf, match_str, &match, &matchlen))
- X {
- X *rtn_value = (long)(match - match_str);
- X iv[0] = (long)matchlen;
- X if (proc_level && proc_trace)
- X pprintf("%match set $i00 = %ld\n", iv[0]);
- X }
- X else
- X *rtn_value = -1L;
- X
- X return (0);
- X} /* end of regexp_operation */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of regexp.c */
- END_OF_FILE
- if test 12818 -ne `wc -c <'ecu330/regexp.c'`; then
- echo shar: \"'ecu330/regexp.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/regexp.c'
- fi
- echo shar: End of archive 27 \(of 37\).
- cp /dev/null ark27isdone
- 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...
-