home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume21
/
ecu
/
part18
< prev
next >
Wrap
Text File
|
1991-08-05
|
55KB
|
2,382 lines
Newsgroups: comp.sources.misc
From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
Subject: v21i070: ecu - ECU async comm package rev 3.10, Part18/37
Message-ID: <1991Aug4.015901.9219@sparky.IMD.Sterling.COM>
X-Md4-Signature: 44090c46690eb739d81a4a6ba6f6cc04
Date: Sun, 4 Aug 1991 01:59:01 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
Posting-number: Volume 21, Issue 70
Archive-name: ecu/part18
Environment: SCO, XENIX, ISC
Supersedes: ecu3: Volume 16, Issue 25-59
---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is ecu310.18 (part 18 of ecu310)
# do not concatenate these parts, unpack them in order with /bin/sh
# file proc.c continued
#
if touch 2>&1 | fgrep 'amc' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 18; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping proc.c'
else
echo 'x - continuing file proc.c'
sed 's/^X//' << 'SHAR_EOF' >> 'proc.c' &&
X/*:04-30-1991-03:19-root@n4hgf-add search for .ep in ecu lib ep subdir */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecuerror.h"
X#include "ecukey.h"
X#include "esd.h"
X#include "var.h"
X#include "proc.h"
X
X#define NEED_P_CMD
X#include "ecucmd.h"
X
Xextern int rcvr_pid;
Xextern int sigint;
Xextern int proc_interrupt;
X
XPCB *pcb_stack[PROC_STACK_MAX];
X
Xint proc_level = 0;
Xint proctrace = 0;
X
Xchar goto_label[64];
X
X/*+-------------------------------------------------------------------------
X _get_goto_label(param)
X--------------------------------------------------------------------------*/
Xint
X_get_goto_label(param)
XESD *param;
X{
Xregister erc;
Xregister ESD *label_esd;
X
X goto_label[0] = 0;
X if(erc = get_alphanum_zstr(param,goto_label,sizeof(goto_label)))
X {
X if((label_esd = esdalloc(64)) == (ESD *)0)
X return(eNoMemory);
X if(!(erc = gstr(param,label_esd,0)))
X strcpy(goto_label,label_esd->pb);
X esdfree(label_esd);
X }
X
X return(erc);
X
X} /* end of _get_goto_label */
X
X/*+-------------------------------------------------------------------------
X pcmd_goto(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_goto(param)
XESD *param;
X{
X
X if(!proc_level)
X return(eNotExecutingProc);
X if(_get_goto_label(param))
X return(eInvalidLabel);
X return(eProcAttn_GOTO);
X
X} /* end of pcmd_goto */
X
X/*+-------------------------------------------------------------------------
X pcmd_gotob(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_gotob(param)
XESD *param;
X{
X
X if(!proc_level)
X return(eNotExecutingProc);
X if(_get_goto_label(param))
X return(eInvalidLabel);
X return(eProcAttn_GOTOB);
X
X} /* end of pcmd_gotob */
X
X/*+-------------------------------------------------------------------------
X _cmd_gosub_common(param,type)
X--------------------------------------------------------------------------*/
Xint
X_cmd_gosub_common(param,type)
XESD *param;
Xint type;
X{
Xint erc;
XLCB *current_save;
Xint index_save;
X
X if(_get_goto_label(param))
X return(eInvalidLabel);
X current_save = pcb_stack[proc_level - 1]->current;
X index_save = current_save->text->index;
X if(!(erc = execute_proc(pcb_stack[proc_level - 1],type)))
X {
X pcb_stack[proc_level - 1]->current = current_save;
X current_save->text->index = index_save;
X }
X return(erc);
X
X} /* end of _cmd_gosub_common */
X
X/*+-------------------------------------------------------------------------
X pcmd_gosub(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_gosub(param)
XESD *param;
X{
X if(!proc_level)
X return(eNotExecutingProc);
X return(_cmd_gosub_common(param,eProcAttn_GOTO));
X} /* end of pcmd_gosub */
X
X/*+-------------------------------------------------------------------------
X pcmd_gosubb(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_gosubb(param)
XESD *param;
X{
X if(!proc_level)
X return(eNotExecutingProc);
X return(_cmd_gosub_common(param,eProcAttn_GOTO));
X} /* end of pcmd_gosubb */
X
X/*+-------------------------------------------------------------------------
X pcmd_return(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_return(param)
XESD *param;
X{
Xlong value = 0;
X if(!gint(param,&value))
X {
X if((value < 0) || (value > 255))
X value = 255;
X if(proctrace)
X pprintf("return value %ld\n",value);
X if(value)
X value += e_USER;
X return((int)value);
X }
X return(eProcAttn_RETURN);
X} /* end of pcmd_return */
X
X/*+-------------------------------------------------------------------------
X find_labelled_lcb(label,first,last)
Xsearch for match between label
X--------------------------------------------------------------------------*/
XLCB *
Xfind_labelled_lcb(label,first,last)
Xchar *label;
Xregister LCB *first;
XLCB *last;
X{
Xregister llen = strlen(label);
XESD *text;
X
X while(first)
X {
X text = first->text;
X if((text->cb >= llen) && (!strncmp(text->pb,label,llen))
X && (!text->pb[llen] || isspace(text->pb[llen])))
X return(first);
X
X if(first == last)
X return((LCB *)0);
X first = first->next;
X }
X pputs("find_labelled_lab logic error\n");
X return((LCB *)0);
X
X} /* end of find_labelled_lcb */
X
X/*+-------------------------------------------------------------------------
X execute_goto(pcb,goto_type)
X--------------------------------------------------------------------------*/
Xexecute_goto(pcb,goto_type)
XPCB *pcb;
Xint goto_type;
X{
XLCB *next = (LCB *)0; /* next lcb to execute */
X
X switch(goto_type)
X {
X case eProcAttn_GOTO:
X if(!(next = find_labelled_lcb(goto_label,pcb->current,pcb->last)))
X next = find_labelled_lcb(goto_label,pcb->first,pcb->current);
X break;
X case eProcAttn_GOTOB:
X if(!(next = find_labelled_lcb(goto_label,pcb->first,pcb->current)))
X next = find_labelled_lcb(goto_label,pcb->current,pcb->last);
X break;
X }
X if(next)
X {
X pcb->current = next;
X return(0);
X }
X pprintf("goto/gosub label not found: %s\n",goto_label);
X return(eFATAL_ALREADY);
X
X} /* end of execute_goto */
X
X/*+-------------------------------------------------------------------------
X show_error_position(pcb)
Xcursor MUST be at left margin when this is called
X--------------------------------------------------------------------------*/
Xvoid
Xshow_error_position(pcb)
XPCB *pcb;
X{
XESD *tesd = pcb->current->text;
Xregister itmp = tesd->old_index;
Xchar tag[64];
X
X sprintf(tag,"%s %u> ",pcb->argv[0],pcb->current->lineno);
X pputs(tag);
X pputs(tesd->pb);
X pputs("\n");
X itmp = strlen(tag) + tesd->old_index;
X while(itmp--)
X pputc(' ');
X pputs("^\n");
X
X} /* end of show_error_position */
X
X/*+-------------------------------------------------------------------------
X find_proc_cmd(cmd_list,cmd)
X--------------------------------------------------------------------------*/
XP_CMD *
Xfind_proc_cmd(cmd_list,cmd)
Xregister P_CMD *cmd_list;
Xregister char *cmd;
X{
X while(cmd_list->token != -1)
X {
X if(!strcmp(cmd_list->cmd,cmd))
X break;
X cmd_list++;
X }
X return((cmd_list->token == -1) ? (P_CMD *)0 : cmd_list);
X
X} /* end of find_proc_cmd */
X
X/*+-------------------------------------------------------------------------
X execute_esd(tesd)
X--------------------------------------------------------------------------*/
Xexecute_esd(tesd)
XESD *tesd;
X{
Xint erc;
XP_CMD *pcmd;
Xstatic P_CMD *set_pcmd = (P_CMD *)0; /* quick access to 'set' */
Xchar cmd[32];
X
X /* if interrupt, exit */
X if(sigint)
X {
X proc_interrupt = 1;
X return(eCONINT);
X }
X
X /* if blank, skip it */
X if(skip_cmd_break(tesd))
X return(0);
X
X /* if comment, skip it */
X if(!skip_cmd_char(tesd,'#'))
X return(0);
X
X if(*(tesd->pb + tesd->index) == '{')
X {
X pputs("invalid '{'\n");
X return(eFATAL_ALREADY);
X }
X
X while(1)
X {
X /* get command -- allow leading '$' to assume 'set' command */
X if(*(tesd->pb + tesd->index) == '$')
X {
X /* find 'set' in the list -- save for rapid access later */
X if(set_pcmd)
X pcmd = set_pcmd;
X else if((pcmd = find_proc_cmd(icmd_cmds,"set")) == (P_CMD *)0)
X return(eInternalLogicError);
X else
X set_pcmd = pcmd;
X }
X else
X {
X if(get_alphanum_zstr(tesd,cmd,sizeof(cmd)))
X return(eIllegalCommand);
X /* find it in the list */
X if((pcmd = find_proc_cmd(icmd_cmds,cmd)) == (P_CMD *)0)
X return(eIllegalCommand);
X }
X
X /* check to see if this command available for procedure */
X if(!pcmd->proc)
X return(eInteractiveCmd);
X
X /* execute the command */
X if(erc = (*pcmd->proc)(tesd))
X return(erc);
X
X /* look for comment */
X if(!skip_cmd_char(tesd,'#'))
X break;
X
X /* look for multiple commands on line */
X if(skip_cmd_char(tesd,';'))
X break;
X
X /* if blank after ';', skip it */
X if(skip_cmd_break(tesd))
X break;
X }
X return(0);
X
X} /* end of execute_esd */
X
X/*+-------------------------------------------------------------------------
X execute_labelled_esd(tesd)
X--------------------------------------------------------------------------*/
Xexecute_labelled_esd(tesd)
XESD *tesd;
X{
Xregister index = 0;
Xregister cb = tesd->cb;
Xregister char *pb = tesd->pb;
X
X/* reset indices */
X tesd->index = index;
X tesd->old_index = index;
X
X/* if comment, skip it */
X if(!skip_cmd_char(tesd,'#'))
X return(0);
X
X/* skip over any label */
X while(!isspace(*(pb + index)) && (index < cb))
X index++;
X tesd->index = index;
X tesd->old_index = index;
X
X return(execute_esd(tesd));
X} /* end of execute_labelled_esd */
X
X/*+-------------------------------------------------------------------------
X dump_proc(pcb)
X--------------------------------------------------------------------------*/
Xvoid
Xdump_proc(pcb)
XPCB *pcb;
X{
Xint itmp;
XLCB *lcb;
X
X pprintf("------ pcb @ 0x%08lx -----------------\n",pcb);
X pprintf("argc=%d first=0x%08lx last=0x%08lx\n",pcb->argc,
X pcb->first,pcb->last);
X for(itmp = 0; itmp < pcb->argc; itmp++)
X {
X pprintf("argv(%d) @ 0x%lx: '%s'\n",itmp,pcb->argv[itmp],
X pcb->argv[itmp]);
X }
X pputs("\n");
X lcb = pcb->first;
X while(lcb)
X {
X pprintf("lcb @ 0x%08lx lineno=%u\n",lcb,lcb->lineno);
X pputs("\n");
X lcb = lcb->next;
X }
X pflush();
X} /* end of dump_proc */
X
X/*+-------------------------------------------------------------------------
X trace_proc_cmd(pcb) - if asked, show command
X--------------------------------------------------------------------------*/
Xvoid
Xtrace_proc_cmd(pcb)
XPCB *pcb;
X{
X if(proctrace)
X {
X pprintf("%s %u> ",pcb->argv[0],pcb->current->lineno);
X pputs(pcb->current->text->pb);
X pputc('\n');
X }
X
X} /* end of trace_proc_cmd */
X
X/*+-------------------------------------------------------------------------
X execute_proc(pcb,use_goto_label) - execute a memory-resident procedure
X--------------------------------------------------------------------------*/
Xexecute_proc(pcb,use_goto_label)
XPCB *pcb;
Xint use_goto_label;
X{
Xint erc = 0;
X
X if(proc_level == PROC_STACK_MAX)
X return(eProcStackTooDeep);
X
X pcb_stack[proc_level++] = pcb;
X if(use_goto_label)
X {
X if(erc = execute_goto(pcb,use_goto_label))
X return(erc);
X }
X else
X pcb->current = pcb->first;
X
X mkv_proc_starting(pcb);
X
X while(pcb->current)
X {
X /* execute the command */
X trace_proc_cmd(pcb);
X if(erc = execute_labelled_esd(pcb->current->text))
X {
X /* handle other classes of errors */
X switch(erc & 0xF000)
X {
X case e_WARNING: /* warning */
X erc = 0;
X break;
X
X case e_FATAL: /* fatal */
X goto PROC_RETURN;
X
X case e_ProcAttn: /* proc attention */
X switch(erc)
X {
X case eProcAttn_GOTO:
X case eProcAttn_GOTOB:
X if(erc = execute_goto(pcb,erc))
X break; /* didn't find it */
X continue; /* pcb->current is now goto target */
X
X case eProcAttn_RETURN:
X erc = 0;
X break;
X
X case eProcAttn_Interrupt:
X case eProcAttn_ESCAPE:
X pprintf(
X "procedure %s interrupted.\n",pcb->argv[0]);
X erc = eFATAL_ALREADY;
X break;
X
X default:
X pprintf("procedure error 0x%x\n",erc);
X erc = eFATAL_ALREADY;
X break;
X }
X goto PROC_RETURN;
X
X default: /* must be proc return error code */
X goto PROC_RETURN;
X break;
X }
X }
X
X if(proc_interrupt)
X {
X proc_interrupt = 0;
X sigint = 0;
X pprintf("procedure %s interrupted\n",pcb->argv[0]);
X erc = eFATAL_ALREADY;
X }
X
X if(erc)
X break;
X pcb->current = pcb->current->next;
X }
X
XPROC_RETURN:
X mkv_proc_terminating(pcb);
X if(erc)
X {
X if((erc > 0) && (erc < e_USER))
X {
X pprintf(">>procedure %s returned %d\n",pcb->argv[0],erc);
X erc |= e_USER;
X }
X else if((erc > e_USER) && (erc <= 0x1FFF))
X {
X ; /* already said it */
X }
X else
X {
X if(erc != eFATAL_ALREADY)
X {
X proc_error(erc);
X erc = eFATAL_ALREADY;
X }
X show_error_position(pcb);
X }
X }
X pcb_stack[--proc_level] = (PCB *)0;
X if(erc && !proc_level)
X plog_control((char *)0);
X return(erc);
X} /* end of execute_proc */
X
X/*+-------------------------------------------------------------------------
X free_lcb_chain(lcb)
X--------------------------------------------------------------------------*/
Xvoid
Xfree_lcb_chain(lcb)
Xregister LCB *lcb;
X{
XLCB *plcb;
X
X while(lcb)
X {
X if(lcb->text)
X esdfree(lcb->text);
X plcb = lcb;
X lcb = lcb->next;
X free((char *)plcb);
X }
X
X} /* end of free_lcb_chain */
X
X/*+-------------------------------------------------------------------------
X find_procedure(name) - find procedure if it exists
X--------------------------------------------------------------------------*/
Xchar *
Xfind_procedure(name)
Xchar *name;
X{
Xstatic char procpath[256];
X
X/*
X * try to find proc file in current directory
X */
X strcpy(procpath,name);
X strcat(procpath,".ep");
X if(!access(procpath,4))
X return(procpath);
X if(proctrace && (errno != ENOENT))
X pperror(procpath);
X
X/*
X * try to find proc file in home .ecu subdirectory
X */
X get_home_dir(procpath);
X strcat(procpath,"/.ecu/");
X strcat(procpath,name);
X strcat(procpath,".ep");
X if(!access(procpath,4))
X return(procpath);
X if(proctrace && (errno != ENOENT))
X pperror(procpath);
X
X/*
X * try to find proc file in library ep subdirectory
X */
X strcpy(procpath,ECULIBDIR);
X strcat(procpath,"/ep/");
X strcat(procpath,name);
X strcat(procpath,".ep");
X if(!access(procpath,4))
X return(procpath);
X if(proctrace && (errno != ENOENT) && (errno != ENOTDIR))
X pperror(procpath);
X
X/*
X * no luck
X */
X return((char *)0);
X
X} /* end of find_procedure */
X
X/*+-------------------------------------------------------------------------
X do_proc(argc,argv) - read in a disk-based procedure and execute it
X--------------------------------------------------------------------------*/
Xdo_proc(argc,argv)
Xint argc;
Xchar **argv;
X{
Xregister itmp;
Xint itmp2;
Xint erc;
Xint iargv;
Xchar *pargv[MAX_PARGV];
Xint ipargv = 0;
Xchar s256[256];
Xchar *procpath;
XFILE *fp;
XPCB *pcb = (PCB *)0;
XLCB *lcb = (LCB *)0;
XLCB *plcb;
Xushort line_count = 0;
Xextern ulong colors_current;
Xulong colors_at_entry = colors_current;
X
X proc_interrupt = 0;
X sigint = 0;
X for(iargv = 0; iargv < argc; iargv++)
X {
X if(ipargv == MAX_PARGV)
X {
X pprintf("\nToo many arguments to %s invocation\n",pargv[0]);
X erc = eFATAL_ALREADY;
X goto RETURN;
X }
X pargv[ipargv++] = argv[iargv];
X }
X
X if(!ipargv)
X {
X pputs("\nno procedure name given\n");
X erc = eFATAL_ALREADY;
X goto RETURN;
X }
X
X if(!(procpath = find_procedure(pargv[0])))
X {
X pprintf("\nprocedure %s not found\n",pargv[0]);
X erc = eFATAL_ALREADY;
X goto RETURN;
X }
X fp = fopen(procpath,"r");
X if(!fp)
X {
X pperror(procpath);
X erc = eFATAL_ALREADY;
X goto RETURN;
X }
X if(proctrace)
X pprintf("DO: %s\n",procpath);
X
X if(!(pcb = (PCB *)malloc(sizeof(PCB))))
X {
X erc = eNoMemory;
X goto RETURN;
X }
X
X pcb->argv = pargv;
X pcb->argc = ipargv;
X pcb->first = (LCB *)0;
X
X plcb = (LCB *)0;
X line_count = 0;
X while(1)
X {
X if(fgets(s256,sizeof(s256),fp) == NULL)
X break;
X line_count++;
X
X itmp = strlen(s256) - 1; /* skip blank lines */
X if(!itmp)
X continue;
X s256[itmp] = 0; /* kill trailing NL */
X for(itmp2 = 0; itmp2 < itmp; itmp2++)
X { /* convert tabs to spaces so we don't have to scan for each */
X if(s256[itmp2] == TAB)
X s256[itmp2] = SPACE;
X }
X if(s256[0] == '#') /* skip comments */
X continue;
X
X if(!(lcb = (LCB *)malloc(sizeof(LCB))))
X {
X fclose(fp);
X erc = eNoMemory;
X goto RETURN;
X }
X
X lcb->prev = plcb;
X lcb->next = (LCB *)0;
X lcb->lineno = line_count;
X
X if(plcb)
X plcb->next = lcb;
X else
X pcb->first = lcb;
X
X if((lcb->text = esdalloc(itmp)) == (ESD *)0)
X {
X fclose(fp);
X erc = eNoMemory;
X goto RETURN;
X }
X strcpy(lcb->text->pb,s256);
X lcb->text->cb = itmp;
X esd_null_terminate(lcb->text);
X plcb = lcb;
X }
X fclose(fp);
X pcb->last = lcb;
X if(line_count)
X erc = execute_proc(pcb,0);
X else
X erc = eProcEmpty;
X
XRETURN:
X if(pcb)
X {
X if(pcb->first)
X free_lcb_chain(pcb->first);
X free((char *)pcb);
X }
X if((erc > e_USER) && (erc <= 0x1FFF))
X erc -= e_USER;
X if(erc > e_USER)
X setcolor(colors_at_entry);
X return(erc);
X
X} /* end of do_proc */
X
X/*+-------------------------------------------------------------------------
X pcmd_do(param)
X--------------------------------------------------------------------------*/
Xpcmd_do(param)
XESD *param;
X{
Xint erc;
Xregister ipargv;
Xchar *cmd_copy;
Xchar *pargv[MAX_PARGV];
XESD *pargv_esd[MAX_PARGV];
Xint pargc = 0;
X
X if(!(cmd_copy = (char *)malloc(param->cb)))
X return(eNoMemory);
X strcpy(cmd_copy,param->pb + param->old_index);
X while(pargc != MAX_PARGV)
X {
X if(end_of_cmd(param))
X break;
X if((pargv_esd[pargc] = esdalloc(256)) == (ESD *)0)
X {
X erc = eNoMemory;
X goto RETURN;
X }
X if(erc = gstr(param,pargv_esd[pargc],1))
X goto RETURN;
X pargv[pargc] = pargv_esd[pargc]->pb;
X pargc++;
X }
X
X if(pargc < MAX_PARGV)
X erc = do_proc(pargc,pargv);
X else
X {
X pprintf("too many arguments to procedure\n");
X erc = eFATAL_ALREADY;
X }
X
XRETURN:
X free(cmd_copy);
X for(ipargv = 0; ipargv < pargc; ipargv++)
X esdfree(pargv_esd[ipargv]);
X return(erc);
X
X} /* end of pcmd_do */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of proc.c */
SHAR_EOF
echo 'File proc.c is complete' &&
$TOUCH -am 0725125991 'proc.c' &&
chmod 0644 proc.c ||
echo 'restore of proc.c failed'
Wc_c="`wc -c < 'proc.c'`"
test 17690 -eq "$Wc_c" ||
echo 'proc.c: original size 17690, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= proc.h ==============
if test -f 'proc.h' -a X"$1" != X"-c"; then
echo 'x - skipping proc.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting proc.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'proc.h' &&
X/*+-------------------------------------------------------------------------
X proc.h
X wht@n4hgf.Mt-Park.GA.US
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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
Xtypedef struct lcb_type
X{
X ESD *text; /* line's text buffer */
X struct lcb_type *next; /* next lcb in chain; if==NULL, no more in chain */
X struct lcb_type *prev; /* previous lcb in chain; if==NULL, top of chain */
X ushort lineno; /* line number */
X} LCB;
X
Xtypedef struct pcb_type
X{
X int argc;
X char **argv;
X LCB *first; /* first in procedure */
X LCB *last; /* last in procedure */
X LCB *current; /* currently executing or last executed line */
X char *mkvs_last; /* actually MKV *, but ... */
X char *mkvi_last; /* ... see var.c for details */
X} PCB;
X
X#define MAX_PARGV 20 /* max args to procedure, including name */
X#define PROC_STACK_MAX 10 /* max proc nest */
SHAR_EOF
$TOUCH -am 0725125991 'proc.h' &&
chmod 0644 proc.h ||
echo 'restore of proc.h failed'
Wc_c="`wc -c < 'proc.h'`"
test 988 -eq "$Wc_c" ||
echo 'proc.h: original size 988, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= proc_error.c ==============
if test -f 'proc_error.c' -a X"$1" != X"-c"; then
echo 'x - skipping proc_error.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting proc_error.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'proc_error.c' &&
X/* CHK=0xD771 */
X/*+-------------------------------------------------------------------------
X proc_error.c - print ecu procedure error
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:07-06-1991-22:58-build_err-creation from ecuerror.h */
X
X#include "ecu.h"
X#include "ecuerror.h"
X
X/*+-------------------------------------------------------------------------
X proc_error(erc) - print error message
X--------------------------------------------------------------------------*/
Xvoid
Xproc_error(erc)
Xint erc;
X{
X switch(erc)
X {
X case eProcEmpty:
X pputs("empty procedure\n");
X break;
X case eConnectFailed:
X pputs("failed to connect\n");
X break;
X case eNoSwitches:
X pputs("no switch(es) to command\n");
X break;
X case eIllegalCommand:
X pputs("invalid command\n");
X break;
X case eNoMemory:
X pputs("no more memory available\n");
X break;
X case eSyntaxError:
X pputs("syntax error\n");
X break;
X case eIllegalVarNumber:
X pputs("number is invalid or out of range\n");
X break;
X case eIllegalVarType:
X pputs("unrecognized variable type\n");
X break;
X case eNotInteger:
X pputs("integer expected and not found\n");
X break;
X case eCONINT:
X pputs("abort due to interrupt\n");
X break;
X case eInvalidFunction:
X pputs("invalid function name\n");
X break;
X case eMissingLeftParen:
X pputs("did not find expected left paren\n");
X break;
X case eMissingRightParen:
X pputs("did not find expected right paren\n");
X break;
X case eCommaExpected:
X pputs("expected comma not found\n");
X break;
X case eProcStackTooDeep:
X pputs("procedure stack depth exceeded\n");
X break;
X case eInvalidRelOp:
X pputs("invalid relational operator\n");
X break;
X case eInvalidIntOp:
X pputs("invalid integer operator\n");
X break;
X case eInvalidStrOp:
X pputs("invalid string operator\n");
X break;
X case eNotExecutingProc:
X pputs("not executing DO at this time\n");
X break;
X case eInvalidLabel:
X pputs("invalid label\n");
X break;
X case eInternalLogicError:
X pputs("internal logic error ... whoops\n");
X break;
X case eEOF:
X pputs("end of file or read error\n");
X break;
X case eBufferTooSmall:
X pputs("string too long\n");
X break;
X case eNoParameter:
X pputs("expected parameter not found\n");
X break;
X case eBadParameter:
X pputs("bad parameter\n");
X break;
X case eInvalidHexNumber:
X pputs("invalid hexadecimal digit\n");
X break;
X case eInvalidDecNumber:
X pputs("invalid decimal digit\n");
X break;
X case eInvalidOctNumber:
X pputs("invalid octal digit\n");
X break;
X case eInteractiveCmd:
X pputs("interactive command\n");
X break;
X case eNoLineAttached:
X pputs("no line (modem) attached\n");
X break;
X case eBadFileNumber:
X pputs("file number out of range\n");
X break;
X case eNotImplemented:
X pputs("not implemented\n");
X break;
X case eDuplicateMatch:
X pputs("more than one condition matches\n");
X break;
X case eColonExpected:
X pputs("expected colon not found\n");
X break;
X case eLabelInvalidHere:
X pputs("label not allowed on this statement\n");
X break;
X case eNoCloseFrame:
X pputs("missing '}' for '{'\n");
X break;
X case eNoFrame:
X pputs("missing command or command group after 'while' or 'if'\n");
X break;
X case eMissingCommand:
X pputs("expected command not found\n");
X break;
X case eBreakCommand:
X pputs("'break' outside 'while'\n");
X break;
X case eContinueCommand:
X pputs("'continue' outside 'while'\n");
X break;
X case eElseCommand:
X pputs("'else' without matching 'if'\n");
X break;
X case eInvalidVarName:
X pputs("invalid variable name\n");
X break;
X case eNoSuchVariable:
X pputs("variable by this name not defined\n");
X break;
X case eInvalidLogicOp:
X pputs("invalid logical operator\n");
X break;
X case eExpectRespondFail:
X pputs("expect-respond failed\n");
X break;
X case eProcAttn_GOTO:
X pputs("GOTO detected\n");
X break;
X case eProcAttn_GOTOB:
X pputs("GOTOB detected\n");
X break;
X case eProcAttn_RETURN:
X pputs("RETURN detected\n");
X break;
X case eProcAttn_ESCAPE:
X pputs("ESCAPE detected\n");
X break;
X case eProcAttn_Interrupt:
X pputs("procedure interrupted\n");
X break;
X case eFATAL_ALREADY:
X case eWARNING_ALREADY:
X break;
X default:
X pprintf("unknown error %x\n",erc);
X break;
X }
X} /* end of proc_error */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of proc_error.c */
SHAR_EOF
$TOUCH -am 0725125991 'proc_error.c' &&
chmod 0644 proc_error.c ||
echo 'restore of proc_error.c failed'
Wc_c="`wc -c < 'proc_error.c'`"
test 4464 -eq "$Wc_c" ||
echo 'proc_error.c: original size 4464, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= procframe.c ==============
if test -f 'procframe.c' -a X"$1" != X"-c"; then
echo 'x - skipping procframe.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting procframe.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'procframe.c' &&
X/*+-------------------------------------------------------------------------
X procframe.c - execute frame of procedure statements
X wht@n4hgf.Mt-Park.GA.US
X
X Defined functions:
X pcmd_break(param);
X pcmd_continue(param);
X execute_frame(truth)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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 <ctype.h>
X#include "ecu.h"
X#include "ecukey.h"
X#include "ecuerror.h"
X#include "esd.h"
X#include "var.h"
X#include "proc.h"
X
Xextern PCB *pcb_stack[PROC_STACK_MAX];
Xextern int proc_level;
Xextern int proc_interrupt;
Xextern int proctrace;
X
X/*+-------------------------------------------------------------------------
X pcmd_break(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_break(param)
XESD *param;
X{
X return(eBreakCommand);
X} /* end of pcmd_break */
X
X/*+-------------------------------------------------------------------------
X pcmd_continue(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_continue(param)
XESD *param;
X{
X return(eContinueCommand);
X} /* end of pcmd_continue */
X
X/*+-------------------------------------------------------------------------
X execute_frame(truth)
X
X pcb_stack[proc_level - 1]->current points to lcb behind frame: one
X statement or { statements }
X
X if truth true, execute frame, else skip it
X--------------------------------------------------------------------------*/
Xint
Xexecute_frame(truth)
Xint truth;
X{
Xregister itmp;
Xint erc = 0;
XPCB *pcb = pcb_stack[proc_level - 1];
XLCB *original_lcb = pcb->current;
XLCB *begin_lcb;
XESD *text;
Xint nest_level = 0;
Xint remember_break = 0;
X
X if(!(pcb->current = pcb->current->next))
X {
X pcb->current = original_lcb;
X return(eNoFrame);
X }
X
X text = pcb->current->text;
X text->old_index = text->index = 0;
X
X if(*text->pb != SPACE) /* tabs were converted to spaces at read time */
X return(eLabelInvalidHere);
X skip_cmd_break(text);
X
X/* handle single statement frame */
X if(*(text->pb + text->index) != '{')
X {
X itmp = text->cb - text->index;
X if( ((itmp > 2) && !strncmp(text->pb + text->index,"if",2)))
X {
X pputs("command must appear inside {} or on same line as else\n");
X erc = eFATAL_ALREADY;
X }
X else if( ((itmp > 5) && !strncmp(text->pb + text->index,"while",5)))
X {
X pputs("command must appear inside {} within this context\n");
X erc = eFATAL_ALREADY;
X }
X else if(truth)
X {
X trace_proc_cmd(pcb);
X erc = execute_esd(text);
X }
X return(erc);
X }
X
X/* we've got a {} frame */
X begin_lcb = pcb->current;
X pcb->current = pcb->current->next;
X while(pcb->current)
X {
X if(proc_interrupt)
X return(eCONINT);
X text = pcb->current->text;
X text->old_index = text->index = 0;
X if(*text->pb != SPACE) /* tabs were converted to spaces at read time */
X return(eLabelInvalidHere);
X skip_cmd_break(text);
X if(*(text->pb + text->index) == '}')
X {
X if(!nest_level)
X {
X text->index = text->cb;
X if(remember_break)
X return(eBreakCommand);
X return(0);
X }
X nest_level--;
X }
X else if(truth)
X {
X trace_proc_cmd(pcb);
X if(erc = execute_esd(text))
X {
X if(erc != eBreakCommand)
X return(erc);
X remember_break = 1;
X truth = 0;
X }
X }
X else if(*(text->pb + text->index) == '{')
X nest_level++;
X pcb->current = pcb->current->next;
X }
X pcb->current = begin_lcb;
X return(eNoCloseFrame);
X
X} /* end of execute_frame */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of procframe.c */
SHAR_EOF
$TOUCH -am 0725125991 'procframe.c' &&
chmod 0644 procframe.c ||
echo 'restore of procframe.c failed'
Wc_c="`wc -c < 'procframe.c'`"
test 3545 -eq "$Wc_c" ||
echo 'procframe.c: original size 3545, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= regexp.c ==============
if test -f 'regexp.c' -a X"$1" != X"-c"; then
echo 'x - skipping regexp.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting regexp.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'regexp.c' &&
X/*+-------------------------------------------------------------------------
X regexp.c -- regular expression functions made sane
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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 "stdio_lint.h"
X#include "lint_args.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();
X
Xextern int proctrace;
Xextern int proc_level;
X
Xchar *braslist[NBRA];
Xchar *braelist[NBRA];
Xint nbra,ebra;
Xchar *match_start,*match_end,*locs;
Xint sed;
Xint nodelim;
Xint circf;
Xint low;
Xint size;
X
Xchar bittab[] = { 1,2,4,8,16,32,64,128 };
X
Xjmp_buf compile_error_jmpbuf;
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 != '{')))
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 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 } 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 '(':
X if(nbra >= NBRA)
X longjmp(compile_error_jmpbuf,43);
X *bracketp++ = nbra;
X *ep++ = CBRA;
X *ep++ = nbra++;
X continue;
X
X case ')':
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 '{':
X if(lastep == (char *) (0))
X goto defchar;
X *lastep |= RNGE;
X cflg = 0;
Xnlim:
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 } 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++ != '}')
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 /* Drop through to default to use \ to turn off special chars */
X
Xdefchar:
X default:
X lastep = ep;
X *ep++ = CCHR;
X *ep++ = c;
X }
X }
X}
X
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 } 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 } while(*p1++);
X return(0);
X}
X
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)) return(1);
X lp -= ct;
X }
X return(0);
X
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 } while(ISTHERE(c));
X ep += 16;
X goto star;
X
Xstar:
X do
X {
X if(--lp == locs)
X break;
X if(advance(lp,ep))
X return(1);
X } while(lp > curlp);
X return(0);
X
X }
X}
X
Xvoid
Xgetrnge(regexp)
Xregister char *regexp;
X{
X low = *regexp++ & 0377;
X size = ((*regexp & 0377) == 255) ? 20000 : (*regexp & 0377) - low;
X}
X
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}
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 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#define CMPBUF_SIZE 256
Xchar cmpbuf[CMPBUF_SIZE];
X
X/*+-------------------------------------------------------------------------
X regexp_operation(match_str,regexp_str,rtn_value)
X
Xone stop operation: determine if 'match_str' matches 'regexp_str',
Xreturning the index of the match in *rtn_value and setting #I0 to
Xthe length of the match
X--------------------------------------------------------------------------*/
Xint
Xregexp_operation(match_str,regexp_str,rtn_value)
Xchar *match_str;
Xchar *regexp_str;
Xlong *rtn_value;
X{
Xchar *emsg;
Xchar *match;
Xint matchlen;
X
X if(regexp_compile(regexp_str,cmpbuf,sizeof(cmpbuf),&emsg))
X {
X pprintf("compile 1 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 && proctrace)
X pprintf("%match set $i00 = %ld\n",iv[0]);
X }
X else
X *rtn_value = -1;
X
X return(0);
X} /* end of regexp_operation */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of regexp.c */
SHAR_EOF
$TOUCH -am 0725125991 'regexp.c' &&
chmod 0644 regexp.c ||
echo 'restore of regexp.c failed'
Wc_c="`wc -c < 'regexp.c'`"
test 10453 -eq "$Wc_c" ||
echo 'regexp.c: original size 10453, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= relop.h ==============
if test -f 'relop.h' -a X"$1" != X"-c"; then
echo 'x - skipping relop.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting relop.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'relop.h' &&
X/*+-------------------------------------------------------------------------
X relop.h - operator definitions (relative and logical)
X wht@n4hgf.Mt-Park.GA.US
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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#define OP_EQ 1
X#define OP_NE 2
X#define OP_LT 3
X#define OP_LE 4
X#define OP_GT 5
X#define OP_GE 6
X
X#define OP_AND 20
X#define OP_OR 21
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of relop.h */
SHAR_EOF
$TOUCH -am 0725125991 'relop.h' &&
chmod 0644 relop.h ||
echo 'restore of relop.h failed'
Wc_c="`wc -c < 'relop.h'`"
test 566 -eq "$Wc_c" ||
echo 'relop.h: original size 566, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= smap.c ==============
if test -f 'smap.c' -a X"$1" != X"-c"; then
echo 'x - skipping smap.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting smap.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'smap.c' &&
X/* CHK=0x7CB8 */
X/*
X * @(#)smap.c 1.2 30/08/88 16:28:19 agc
X *
X * Copyright 1988, Joypace Ltd., UK. This product is "careware".
X * If you find it useful, I suggest that you send what you think
X * it is worth to the charity of your choice.
X *
X * Alistair G. Crooks, +44 5805 3114
X * Joypace Ltd.,
X * 2 Vale Road,
X * Hawkhurst,
X * Kent TN18 4BU,
X * UK.
X *
X * UUCP Europe ...!mcvax!unido!nixpbe!nixbln!agc
X * UUCP everywhere else ...!uunet!linus!nixbur!nixpbe!nixbln!agc
X *
X * smap.c - source file for debugging aids.
X */
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:04-19-1990-03:08-wht@n4hgf-GCC run found unused vars -- rm them */
X/*:03-25-1990-14:12-wht@n4hgf------ x2.70 ------- */
X/*:07-03-1989-22:57-wht------ x2.00 ----- */
X/*:06-24-1989-16:52-wht-flush edits --- ecu 1.95 */
X
X#ifndef __GNUC__
X#ifndef NOMEMCHECK
X
X#include <stdio.h>
X#include <signal.h>
X#include "stdio_lint.h"
X#include "lint_args.h"
X
Xtypedef struct _slotstr
X{
X char *s_ptr; /* the allocated area */
X unsigned int s_size; /* its size */
X char s_freed; /* whether it's been freed yet */
X char s_blkno; /* program block reference number */
X} SLOT;
X
X#ifndef MAXSLOTS
X#define MAXSLOTS 4096
X#endif /* MAXSLOTS */
X
Xstatic SLOT slots[MAXSLOTS];
Xstatic int slotc;
Xstatic int blkno;
X
X#define WARNING(s1, s2) (void) fprintf(stderr, s1, s2)
X
X/* __STDC__ dependency hasn't invaded this module yet */
Xchar *malloc();
Xchar *calloc();
Xchar *realloc();
Xvoid _abort();
X
X/*+-------------------------------------------------------------------------
X _dump_malloc()
X--------------------------------------------------------------------------*/
Xvoid
X_dump_malloc()
X{
Xregister islot;
Xregister slot_count = 0;
Xchar dfile[32];
Xchar title[64];
XFILE *fp;
XSLOT *slot;
X
X sprintf(dfile,"/tmp/m%05d.dmp",getpid());
X fp = fopen(dfile,"w");
X fprintf(stderr,"\r\n\n\ndumping malloc status to %s\r\n",dfile);
X for(islot = 0; islot < slotc; islot++)
X {
X slot = &slots[islot];
X if(slot->s_freed)
X continue;
X sprintf(title,"%d (%d) %08x size %u",
X slot_count,islot,slot->s_ptr,slot->s_size);
X hex_dump_fp(fp,slot->s_ptr,slot->s_size,title,0);
X slot_count++;
X }
X fclose(fp);
X fprintf(stderr,"done\r\n");
X
X} /* end of _dump_malloc */
X
X
X/*
X * _malloc - wrapper around malloc. Warns if unusual size given, or the
X * real malloc returns a 0 pointer. Returns a pointer to the
X * malloc'd area
X */
Xchar *
X_malloc(size)
Xunsigned int size;
X{
X register SLOT *sp;
X char *ptr;
X register int i;
X
X if(size == 0)
X WARNING("_malloc: unusual size %d bytes\r\n",size);
X if((ptr = (char *) malloc(size)) == (char *) 0)
X _abort("_malloc: unable to malloc %u bytes\r\n",size);
X for(i = 0,sp = slots ; i < slotc ; i++,sp++)
X if(sp->s_ptr == ptr)
X break;
X if(i == slotc)
X {
X if(slotc == MAXSLOTS - 1)
X {
X _dump_malloc();
X _abort("_malloc: run out of slots\r\n","");
X }
X sp = &slots[slotc++];
X }
X else if(!sp->s_freed)
X WARNING("_malloc: malloc returned a non-freed pointer\r\n","");
X sp->s_size = size;
X sp->s_freed = 0;
X sp->s_ptr = ptr;
X sp->s_blkno = blkno;
X#ifndef NO_EXTRA_HELP
X memset(sp->s_ptr,0x12,sp->s_size);
X#endif
X return(sp->s_ptr);
X}
X
X
X/*
X * _calloc - wrapper for calloc. Calls _malloc to allocate the area, and
X * then sets the contents of the area to NUL bytes. Returns its address.
X */
Xchar *
X_calloc(nel,size)
Xint nel;
Xunsigned int size;
X{
X unsigned int tot;
X register char *ptr;
X
X tot = nel * size;
X ptr = _malloc(tot);
X if(ptr == (char *)0)
X return((char *)0);
X memset(ptr,0,tot);
X return(ptr);
X}
X
X
X/*
X * _realloc - wrapper for realloc. Checks area already alloc'd and
X * not freed. Returns its address
X */
Xchar *
X_realloc(ptr,size)
Xchar *ptr;
Xunsigned int size;
X{
X register SLOT *sp;
X register int i;
X
X for(i = 0,sp = slots ; i < slotc ; i++,sp++)
X if(sp->s_ptr == ptr)
X break;
X if(i == slotc)
X _abort("_realloc: realloc on unallocated area\r\n","");
X if(sp->s_freed)
X WARNING("_realloc: realloc on freed area\r\n","");
X if((sp->s_ptr = (char *) realloc(ptr,size)) == (char *)0)
X WARNING("_realloc: realloc failure %d bytes\r\n",size);
X sp->s_size = size;
X sp->s_blkno = blkno;
X return(sp->s_ptr);
X}
X
X
X/*
X * _free - wrapper for free. Loop through allocated slots, until you
X * find the one corresponding to pointer. If none, then it's an attempt
X * to free an unallocated area. If it's already freed, then tell user.
X */
Xvoid
X_free(ptr)
Xchar *ptr;
X{
X register SLOT *sp;
X register int i;
X
X for(i = 0,sp = slots ; i < slotc ; i++,sp++)
X if(sp->s_ptr == ptr)
X break;
X if(i == slotc)
X _abort("_free: free not previously malloc'd\r\n","");
X if(sp->s_freed)
X _abort("_free: free after previous freeing\r\n","");
X (void) free(sp->s_ptr);
X sp->s_freed = 1;
X}
X
X
X/*
X * _blkstart - start of a program block. Increase the block reference
X * number by one.
X */
Xvoid
X_blkstart()
X{
X blkno += 1;
X}
X
X
X/*
X * _blkend - end of a program block. Check all areas allocated in this
X * block have been freed. Decrease the block number by one.
X */
Xvoid
X_blkend()
X{
X register SLOT *sp;
X register int i;
X
X if(blkno == 0)
X {
X WARNING("_blkend: unmatched call to _blkend\r\n","");
X return;
X }
X for(i = 0,sp = slots ; i < slotc ; i++,sp++)
X if(sp->s_blkno == blkno && !sp->s_freed)
X WARNING("_blkend: %d bytes unfreed\r\n",sp->s_size);
X blkno -= 1;
X}
X
X
X/*
X * _blkignore - find the slot corresponding to ptr, and set its block
X * number to zero, to avoid _blkend picking it up when checking.
X */
Xvoid
X_blkignore(ptr)
Xchar *ptr;
X{
X register SLOT *sp;
X register int i;
X
X for(i = 0,sp = slots ; i < slotc ; i++,sp++)
X if(sp->s_ptr == ptr)
X break;
X if(i == slotc)
X WARNING("_blkignore: pointer has not been allocated\r\n","");
X else
X sp->s_blkno = 0;
X}
X
X/*
X * _abort - print a warning on stderr, and send a SIGQUIT to ourself
X */
X#if !defined(BUILDING_LINT_ARGS)
Xstatic void
X_abort(s1,s2)
Xchar *s1;
Xchar *s2;
X{
X#ifdef M_I386
Xchar *kaboom = (char *)90000000;
X
X WARNING(s1,s2);
X *kaboom = 1;
X#else
X WARNING(s1,s2);
X (void) kill(getpid(),SIGIOT); /* core dump here */
X#endif
X}
X#endif
X#endif /* NOMEMCHECK */
X#endif /* __GNUC__ */
SHAR_EOF
$TOUCH -am 0725125991 'smap.c' &&
chmod 0644 smap.c ||
echo 'restore of smap.c failed'
Wc_c="`wc -c < 'smap.c'`"
test 6019 -eq "$Wc_c" ||
echo 'smap.c: original size 6019, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= smap.h ==============
if test -f 'smap.h' -a X"$1" != X"-c"; then
echo 'x - skipping smap.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting smap.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'smap.h' &&
X/*
X * @(#)smap.h 1.1 30/08/88 16:07:36 agc
X *
X * Copyright 1988, Joypace Ltd., UK. This product is "careware".
X * If you find it useful, I suggest that you send what you think
X * it is worth to the charity of your choice.
X *
X * Alistair G. Crooks, +44 5805 3114
X * Joypace Ltd.,
X * 2 Vale Road,
X * Hawkhurst,
X * Kent TN18 4BU,
X * UK.
X *
X * UUCP Europe ...!mcvax!unido!nixpbe!nixbln!agc
X * UUCP everywhere else ...!uunet!linus!nixbur!nixpbe!nixbln!agc
X *
X * smap.h - include file for debugging aids. This file must be included,
X * before any calls, in any source file that calls malloc, calloc,
X * realloc, or free. (Note alloca is not included in this list).
X */
X/*+:EDITS:*/
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 WHT
X#define NOMEMCHECK
X#endif
X
X#ifndef __GNUC__
X#if !defined(VTYPE)
X#if defined(__STDC__) /* sigh ... malloc and such types */
X#define VTYPE void
X#else
X#define VTYPE char
X#endif
X#endif
X
X#ifdef NOMEMCHECK
X#define _blkstart()
X#define _blkend()
X#define _blkignore(p)
XVTYPE *malloc();
XVTYPE *calloc();
XVTYPE *realloc();
Xvoid free();
X#else /* not NOMEMCHECK */
X#ifndef malloc
X#define malloc _malloc
X#define calloc _calloc
X#define realloc _realloc
X#define free _free
XVTYPE *_malloc();
XVTYPE *_calloc();
XVTYPE *_realloc();
Xvoid _free();
X#endif /* not malloc */
Xvoid _blkstart();
Xvoid _blkend();
Xvoid _blkignore();
X#endif /* not NOMEMCHECK */
X
X#endif /* __GNUC__ */
SHAR_EOF
$TOUCH -am 0725125991 'smap.h' &&
chmod 0644 smap.h ||
echo 'restore of smap.h failed'
Wc_c="`wc -c < 'smap.h'`"
test 1476 -eq "$Wc_c" ||
echo 'smap.h: original size 1476, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= stdio_lint.h ==============
if test -f 'stdio_lint.h' -a X"$1" != X"-c"; then
echo 'x - skipping stdio_lint.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting stdio_lint.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'stdio_lint.h' &&
X/*+-------------------------------------------------------------------------
X stdio_lint.h -- prototyping for library routines
X wht@n4hgf.Mt-Park.GA.US
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:01-18-1991-11:55-wht@n4hgf-fix strchr/strrchr per steve@nshore.ncoast.org */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#if defined(__STDC__)
Xchar *gets(char *);
Xchar *getenv(char *);
Xint access(char *,int);
Xint chmod(char *,int);
Xint close(int);
Xint creat(char *,int);
Xint dup(int);
Xint fcloseall(void);
Xint isatty(int);
Xlong lseek(int,long,int);
Xint puts(char *);
Xint read(int,char *,unsigned int);
X#ifndef __GNUC__
Xint stat(char *,struct stat *);
Xint fstat(int,struct stat *);
X#endif
Xlong time(long *);
Xint unlink(char *);
Xint write(int,char *,unsigned int);
X#else
Xchar *fgets();
Xvoid free();
Xchar *getenv();
Xchar *gets();
Xlong ftell();
Xlong lseek();
Xvoid perror();
Xvoid rewind();
Xvoid setbuf();
Xlong time();
Xchar *strcpy();
Xchar *strncpy();
Xchar *strcat();
Xchar *strncat();
Xchar *strchr();
Xchar *strrchr();
X#endif
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125991 'stdio_lint.h' &&
chmod 0644 stdio_lint.h ||
echo 'restore of stdio_lint.h failed'
Wc_c="`wc -c < 'stdio_lint.h'`"
test 1173 -eq "$Wc_c" ||
echo 'stdio_lint.h: original size 1173, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= termecu.h ==============
if test -f 'termecu.h' -a X"$1" != X"-c"; then
echo 'x - skipping termecu.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting termecu.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'termecu.h' &&
X/*+-------------------------------------------------------------------------
X termecu.h -- termecu (exit()) codes
X wht@n4hgf.Mt-Park.GA.US
X
X 1 - 64 reserved for signals
X 193 - 223 reserved for procedure 'exit' codes
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
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#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
SHAR_EOF
true || echo 'restore of termecu.h failed'
fi
echo 'End of ecu310 part 18'
echo 'File termecu.h is continued in part 19'
echo 19 > _shar_seq_.tmp
exit 0
--------------------------------------------------------------------
Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
Hacker Extraordinaire d' async PADs, pods, proteins and protocols
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.