wht@tridom.uucp (Warren Tucker) (10/09/89)
---- Cut Here and unpack ---- #!/bin/sh # this is part 9 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file ecushm.c continued # CurArch=9 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 echo "x - Continuing file ecushm.c" sed 's/^X//' << 'SHAR_EOF' >> ecushm.c X perror(shm_name); X umask(old_umask); X exit(11); X } X close(fd); X X if((shm_key = ftok(shm_name,1)) < 0) X { X fputs("ftok of ",se); X perror(shm_name); X umask(old_umask); X unlink(shm_name); X exit(11); X } X unlink(shm_name); X X if((shm_shmid = shmget(shm_key,sizeof(ECU_SDS),IPC_CREAT | 0600)) < 0) X { X perror("shmget"); X umask(old_umask); X exit(11); X } X X if(((char FAR *)shm = shmat(shm_shmid,(char FAR *)0,0)) == (char FAR *)-1) X { X perror("shmat"); X umask(old_umask); X exit(11); X } X X umask(old_umask); X X shm->xcmd = 0; /* signal from xmtr to rcvr SIGUSR2 */ X shm->xi1 = 0; /* parameters */ X shm->xi2 = 0; X shm->xs1[0] = 0; X shm->rcmd = 0; /* signal from rcvr to xmtr SIGUSR2 */ X shm->ri1 = 0; /* parameters */ X shm->ri2 = 0; X shm->rs1[0] = 0; X shm->rcvd_chars = 0L; X shm->rcvd_chars_this_connect = 0L; X X if(shmctl(shm_shmid,IPC_RMID,(struct shmid_ds *)0)) X perror("shmctl IPC_RMID"); X X return(0); X} /* end of shm_init */ X X/*+------------------------------------------------------------------------- X shm_done() -- finished with shm -- clean up X--------------------------------------------------------------------------*/ Xshm_done() X{ X} /* end of shm_done */ X X/*+------------------------------------------------------------------------- X shmx_rc_report(prcvr_chars,prcvr_chars_this_connect) X xmtr calls to get rcvr stats X--------------------------------------------------------------------------*/ Xshmx_rc_report(prcvd_chars,prcvd_chars_this_connect) Xlong *prcvd_chars; Xlong *prcvd_chars_this_connect; X{ X *prcvd_chars = shm->rcvd_chars; X *prcvd_chars_this_connect = shm->rcvd_chars_this_connect; X} /* end of shmx_rc_report */ X X/*+------------------------------------------------------------------------- X shmx_connect() -- xmtr calls when modem connects X--------------------------------------------------------------------------*/ Xvoid Xshmx_connect() X{ X shm->rcvd_chars_this_connect = 0L; X} /* end of shmx_connect */ X X/*+------------------------------------------------------------------------- X shmr_rcvd_chars(count) -- rcvr/xmtr calls when char(s) rcvd X--------------------------------------------------------------------------*/ Xvoid Xshmr_rcvd_chars(count) Xint count; X{ X shm->rcvd_chars += count; X shm->rcvd_chars_this_connect += count; X} /* end of shmr_rcvd_chars */ X X/*+------------------------------------------------------------------------- X shmx_make_rcvr_sleep(seconds) X--------------------------------------------------------------------------*/ Xvoid Xshmx_make_rcvr_sleep(seconds) Xint seconds; X{ X shm->xcmd = SHMX_MAKE_RCVR_SLEEP; X shm->xi1 = seconds; X kill_rcvr_process(SIGUSR2); X X} /* end of shmx_make_rcvr_sleep */ X X/*+------------------------------------------------------------------------- X shmx_set_rcvr_ansi(mode) X--------------------------------------------------------------------------*/ Xvoid Xshmx_set_rcvr_ansi(mode) Xint mode; X{ X shm->xcmd = SHMX_SET_RCVR_ANSI; X shm->xi1 = mode; X kill_rcvr_process(SIGUSR2); X X} /* end of shmx_set_rcvr_ansi */ X X/*+------------------------------------------------------------------------- X shmx_set_rcvr_log(logfilename,append_flag,raw_flag) X Xnull logfilename stops logging Xappend_flag says whether to open for write or append Xraw_flag says whether or not to filter non-printable chars or not X(NL not filtered) X--------------------------------------------------------------------------*/ Xvoid Xshmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each) Xchar *logfilename; X{ X shm->xcmd = SHMX_SET_RCVR_LOG; X shm->xi1 = append_flag; X shm->xi2 = raw_flag; X shm->xi3 = flush_each; X strcpy(shm->xs1,logfilename); X kill_rcvr_process(SIGUSR2); X} /* end of shmx_set_rcvr_log */ X X/*+------------------------------------------------------------------------- X shmx_set_rcvr_nl_control() X--------------------------------------------------------------------------*/ Xvoid Xshmx_set_rcvr_nl_control() X{ X shm->xcmd = SHMX_SET_RCVR_NL_CTRL; X shm->xi1 = Ladd_nl_incoming; X shm->xi2 = Ladd_nl_outgoing; X kill_rcvr_process(SIGUSR2); X X} /* end of shmx_set_rcvr_nl_control */ X X/*+------------------------------------------------------------------------- X shmx_set_rcvr_bn(bn_value) X--------------------------------------------------------------------------*/ Xvoid Xshmx_set_rcvr_bn(bn_value) Xint bn_value; X{ X shm->xcmd = SHMX_SET_RCVR_BN; X shm->xi1 = bn_value; X kill_rcvr_process(SIGUSR2); X X} /* end of shmx_set_rcvr_bn */ X X/*+------------------------------------------------------------------------- X shmr_set_xmtr_bn_1() X--------------------------------------------------------------------------*/ Xvoid Xshmr_set_xmtr_bn_1() X{ X shm->rcmd = SHMR_SET_XMTR_BN1; X kill(xmtr_pid,SIGUSR2); X X} /* end of shmr_set_xmtr_bn_1 */ X X/*+------------------------------------------------------------------------- X shmx_process_xmtr_SIGUSR2() X--------------------------------------------------------------------------*/ Xvoid Xshmx_process_xmtr_SIGUSR2() X{ Xregister rcmd; Xregister ri1,ri2; X X rcmd = shm->rcmd; X shm->rcmd = 0; X ri1 = shm->ri1; X ri2 = shm->ri2; X X switch(rcmd) X { X case SHMR_SET_XMTR_BN1: X want_bell_notify = 1; X break; X } X X} /* end of shmx_process_xmtr_SIGUSR2 */ X X/*+------------------------------------------------------------------------- X shmr_process_rcvr_SIGUSR2() X--------------------------------------------------------------------------*/ Xvoid Xshmr_process_rcvr_SIGUSR2() X{ Xregister xcmd; Xregister xi1,xi2,xi3; Xchar xs1[SHM_STRLEN]; X X xcmd = shm->xcmd; X shm->xcmd = 0; X xi1 = shm->xi1; X xi2 = shm->xi2; X xi3 = shm->xi3; X strcpy(xs1,shm->xs1); X X switch(xcmd) X { X case SHMX_MAKE_RCVR_SLEEP: X sleep(xi1); X break; X X case SHMX_SET_RCVR_BN: X want_bell_notify = xi1; X break; X X case SHMX_SET_RCVR_NL_CTRL: X Ladd_nl_incoming = xi1; X Ladd_nl_outgoing = xi2; X break; X X case SHMX_SET_RCVR_LOG: X if(rcvr_log) /* if already logging */ X { X if(!rcvr_log_raw) X putc('\n',rcvr_log_fp); X fclose(rcvr_log_fp); X rcvr_log = 0; X } X if(strlen(xs1) == 0) /* if all we wanted was to stop log ... */ X break; /* ... then quit */ X rcvr_log = 1; X rcvr_log_append = xi1; X rcvr_log_raw = xi2; X rcvr_log_flusheach = xi3; X strcpy(rcvr_log_file,xs1); X rcvr_log_open(); X break; X X case SHMX_SET_RCVR_ANSI: X ansi_filter_control(xi1); X break; X } X X} /* end of shmr_process_rcvr_SIGUSR2 */ X X/* end of ecushm.c */ X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF echo "File ecushm.c is complete" chmod 0644 ecushm.c || echo "restore of ecushm.c fails" echo "x - extracting ecusighdl.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ecusighdl.c && X/* CHK=0xFBB9 */ X/*+----------------------------------------------------------------------- X ecusighdl.c - xmtr/rcvr individual process signal handlers X Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved X X Defined functions: X child_signals() X hangup(sig) X kill_rcvr_process(sig) X rcvr_SIGHUP_handler() X rcvr_SIGINT_handler() X rcvr_SIGTERM_handler() X rcvr_SIGUSR1_handler() X rcvr_SIGUSR2_handler() X rcvr_common_signal_handler() X rcvr_signals() X start_rcvr_process(notify_flag) X xmtr_SIGHUP_handler(sig) X xmtr_SIGINT_handler() X xmtr_SIGTERM_handler(sig) X xmtr_SIGUSR2_handler() X xmtr_bsd4_SIGCHLD_handler() X xmtr_signals() X xmtr_xenix_SIGCLD_handler() X X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */ X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */ X X#include "ecu.h" X#include "ecufork.h" X Xextern int errno; Xextern int rcvr_pid; Xextern int xmtr_pid; Xextern int windows_active; Xextern int current_ttymode; X Xint interrupt = 0; /* interrupt indicator */ Xint proc_interrupt = 0; /* procedure interrupt indicator */ Xint last_child_wait_status = 0; Xint last_child_wait_pid = 0; X Xvoid rcvr(); Xvoid hangup(); X Xvoid rcvr_common_signal_handler(); Xvoid rcvr_SIGTERM_handler(); Xvoid rcvr_SIGINT_handler(); Xvoid rcvr_SIGUSR1_handler(); Xvoid rcvr_SIGUSR2_handler(); Xvoid rcvr_SIGHUP_handler(); Xvoid xmtr_SIGINT_handler(); Xvoid xmtr_SIGHUP_handler(); Xvoid xmtr_SIGTERM_handler(); Xvoid xmtr_xenix_SIGCLD_handler(); X X/*+----------------------------------------------------------------------- X start_rcvr_process(notify_flag) X------------------------------------------------------------------------*/ Xstart_rcvr_process(notify_flag) Xint notify_flag; X{ Xchar s40[40]; Xextern ulong current_colors; Xulong colors_at_entry = current_colors; X X fflush(so); X fflush(se); X X if(rcvr_pid > 0) /* if process already active,just ... */ X return(rcvr_pid); /* ... return the process id */ X X rcvr_pid = smart_fork(); X if(rcvr_pid == 0) /* if we are the (spawned) rcvr process */ X { X if(notify_flag) X { X setcolor(0x07000800L); /* gray */ X fputs("[interactive mode]",se); X setcolor(colors_at_entry); X fputs("\r\n",se); X } X X rcvr(); /* run until killed */ X /*NOTREACHED*/ X } X else if(rcvr_pid > 0) /* we are the father (xmtr) process */ X { X#if defined(FORK_DEBUG) X sprintf(s40,"DEBUG rcvr pid %d",rcvr_pid); X ecu_log_event(s40); /* rcvr */ X#endif X return(rcvr_pid); X } X else X { X rcvr_pid = -1; /* no receiver active */ X ff(se,"\r\n\ncould not fork for receive\r\n"); X hangup(HANGUP_NO_FORK_FOR_RCVR); X /*NOTREACHED*/ X } X} /* end of start_rcvr_process */ X X/*+----------------------------------------------------------------------- X kill_rcvr_process(sig) -- kill rcvr process with signal 'sig' X------------------------------------------------------------------------*/ Xvoid Xkill_rcvr_process(sig) Xint sig; X{ X X if(rcvr_pid > 0) /* if we have forked a rcvr process */ X { X kill(rcvr_pid,sig); X if(sig != SIGUSR2) /* rcvr does not die on this signal */ X rcvr_pid = -1; X } X X} /* end of kill_rcvr_process */ X X/*+----------------------------------------------------------------------- X hangup(sig) -- terminate program (with comm line cleanup) X X close comm line X return any ungetty'd line X return user's console to normal status X unlink shm name X terminate program X see ecuhangup.h X------------------------------------------------------------------------*/ Xvoid Xhangup(sig) Xint sig; X{ Xint isig; Xint save_errno = errno; Xextern char initial_procedure[]; X X if(xmtr_pid == getpid()) /* if we are xmtr */ X { X for(isig = 1; isig < NSIG; isig++) X signal(isig,SIG_IGN); X kill_rcvr_process(SIGUSR1); X if(Lmodem_off_hook) X hayes_ATH(); X if(Liofd != -1) X lclose(); /* close line */ X X /* make SURE we release any line acquired from getty */ X ungetty_return_line(); X X if(windows_active) X windows_end_signal(); X ttymode(0); /* normal tty status */ X shm_done(); X if(sig > NSIG) X { X char s64[64]; X setcolor(0x04070400L); /* fgnd: red on blk, bgnd: red on wht */ X if(sig == HANGUP_INIT_PROC_ERROR) X pprintf("initial procedure '%s' failed\n",initial_procedure); X else if((sig > HANGUP_INIT_PROC_ERROR) && X (sig <= HANGUP_INIT_PROC_ERROR + 32)) X { X pprintf("procedure command: exit %d\n", X sig - HANGUP_INIT_PROC_ERROR); X } X else X { X sprintf(s64,"## XMTR process error %d, errno = %d",sig, X save_errno); X pputs(s64); X pputs("\n"); X ecu_log_event(s64); X errno = save_errno; X if(errno) X pperror("errno may not apply, but"); X } X } X setcolor(0x04070A00L); /* fgnd: lt_grn on blk, bgnd: red on wht */ X } X else /* we are rcvr */ X { X if(sig > NSIG) X { X char s64[64]; X sprintf(s64,"## RCVR process error %d, errno = %d",sig,save_errno); X setcolor(0x04070400); /* fgnd: red on blk, bgnd: red on wht */ X pputs(s64); X pputs("\n"); X ecu_log_event(s64); X errno = save_errno; X if(errno) X pperror("errno may not apply, but"); X } X setcolor(0x04070A00L); /* fgnd: lt_grn on blk, bgnd: red on wht */ X kill(xmtr_pid,SIGHUP); X } X exit(sig); X /*NOTREACHED*/ X X} /* end of hangup */ X Xvoid Xrcvr_common_signal_handler() X{ Xextern int rcvr_log; Xextern int rcvr_log_raw; Xextern FILE *rcvr_log_fp; X X if(rcvr_log) X { X if(!rcvr_log_raw) X fputs("\n",rcvr_log_fp); X fclose(rcvr_log_fp); X } X X exit(0); X} Xvoid Xrcvr_SIGTERM_handler() X{ X rcvr_common_signal_handler(); X} Xvoid Xrcvr_SIGINT_handler() X{ X signal(SIGINT,rcvr_SIGINT_handler); X} Xvoid Xrcvr_SIGUSR1_handler() X{ X rcvr_common_signal_handler(); X} Xvoid Xrcvr_SIGUSR2_handler() X{ X signal(SIGUSR2,rcvr_SIGUSR2_handler); X shmr_process_rcvr_SIGUSR2(); X} Xvoid Xrcvr_SIGHUP_handler() X{ X rcvr_common_signal_handler(); X} X/*+------------------------------------------------------------------------- X xmtr_SIGINT_handler() X--------------------------------------------------------------------------*/ Xvoid Xxmtr_SIGINT_handler() X{ X signal(SIGINT,xmtr_SIGINT_handler); X interrupt = 1; X proc_interrupt = 1; X} /* end of xmtr_SIGINT_handler */ X Xvoid Xxmtr_SIGHUP_handler(sig) Xint sig; X{ X hangup(sig); X} Xvoid Xxmtr_SIGTERM_handler(sig) Xint sig; X{ X hangup(sig); X} X Xvoid Xxmtr_SIGUSR2_handler() X{ X signal(SIGUSR2,xmtr_SIGUSR2_handler); X shmx_process_xmtr_SIGUSR2(); X} X X/*+------------------------------------------------------------------------- X xmtr_xenix_SIGCLD_handler() X--------------------------------------------------------------------------*/ Xvoid Xxmtr_xenix_SIGCLD_handler() X{ Xchar s40[40]; X XWAIT: X errno = 0; X if((last_child_wait_pid = wait(&last_child_wait_status)) < 0) X { X if(errno == EINTR) X goto WAIT; X } X X#if defined(FORK_DEBUG) X sprintf(s40,"DEBUG fork SIGCLD pid %d term %x", X last_child_wait_pid,last_child_wait_status); X ecu_log_event(s40); /* xmtr_xenix_SIGCLD_handler() */ X#endif X signal(SIGCLD,xmtr_xenix_SIGCLD_handler); X X} /* end of xmtr_xenix_SIGCLD_handler */ X X/*+------------------------------------------------------------------------- X child_signals() - signal() calls for children processes X--------------------------------------------------------------------------*/ Xvoid Xchild_signals() X{ X signal(SIGHUP,SIG_DFL); X signal(SIGINT,SIG_DFL); X signal(SIGTERM,SIG_DFL); X signal(SIGQUIT,SIG_DFL); X signal(SIGUSR1,SIG_DFL); X signal(SIGUSR2,SIG_DFL); X signal(SIGCLD,SIG_DFL); X} /* end of child_signals */ X X/*+------------------------------------------------------------------------- X xmtr_signals() X--------------------------------------------------------------------------*/ Xvoid Xxmtr_signals() X{ X signal(SIGHUP,xmtr_SIGHUP_handler); X signal(SIGQUIT,SIG_DFL); X signal(SIGINT,xmtr_SIGINT_handler); X signal(SIGTERM,xmtr_SIGTERM_handler); X signal(SIGCLD,xmtr_xenix_SIGCLD_handler); X signal(SIGUSR2,xmtr_SIGUSR2_handler); X} /* end of xmtr_signals */ X X/*+------------------------------------------------------------------------- X rcvr_signals() X--------------------------------------------------------------------------*/ Xvoid Xrcvr_signals() X{ X signal(SIGHUP,rcvr_SIGHUP_handler); X signal(SIGQUIT,SIG_DFL); X signal(SIGTERM,rcvr_SIGTERM_handler); X signal(SIGINT,rcvr_SIGINT_handler); X signal(SIGUSR1,rcvr_SIGUSR1_handler); X signal(SIGUSR2,rcvr_SIGUSR2_handler); X} /* end of rcvr_signals */ X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 ecusighdl.c || echo "restore of ecusighdl.c fails" echo "x - extracting ecutcap.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ecutcap.c && X/* CHK=0x2720 */ X/*+------------------------------------------------------------------------- X ecutcap.c -- termcap stuff X Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved X X Defined functions: X clear_screen() X curbotleft() X curmove(y,x) X del_line() X draw_box(y,x,height,width,title,title_x) X draw_box_primitive(y,x,height,width) X eeol() X horiz_rule(count) X ins_line() X putc_stderr(character) X read_termcap() X stand_end() X stand_out() X tcap_clear_area_char(count,clrch) X tcap_gets(buf,bufsize,delim,wait_for_key) X vbell() X vertical_rule(y,x,count) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */ X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */ X X#include "ecu.h" X#include "ecukey.h" X#include "pc_scr.h" X Xchar *tcap_eeol = ""; Xchar *tcap_standout = ""; Xchar *tcap_standend = ""; Xchar *tcap_vbell = ""; Xchar *tcap_move = ""; Xchar *tcap_clear = ""; Xchar *tcap_delline = ""; Xchar *tcap_insline = ""; Xchar *tcap_curleft = ""; Xchar tcap_strbuf[150]; Xint tcap_standout_width; Xint tcap_LINES; Xint tcap_COLS; X Xchar *tgetstr(); Xchar *tgoto(); Xchar *getenv(); X Xvoid curmove(); Xvoid stand_out(); Xvoid stand_end(); X X/*+------------------------------------------------------------------------- X read_termcap() - get termcap variables X--------------------------------------------------------------------------*/ Xvoid Xread_termcap() X{ Xchar termbuf[1024]; Xchar *strbuf = tcap_strbuf; X X if(tgetent(termbuf,getenv("TERM")) > 0) X { X tcap_standout = tgetstr("so",&strbuf); X tcap_standend = tgetstr("se",&strbuf); X tcap_vbell = tgetstr("vb",&strbuf); X tcap_eeol = tgetstr("ce",&strbuf); X tcap_move = tgetstr("cm",&strbuf); X tcap_clear = tgetstr("cl",&strbuf); X tcap_delline = tgetstr("dl",&strbuf); X tcap_insline = tgetstr("al",&strbuf); X tcap_curleft = tgetstr("kl",&strbuf); X if((tcap_standout_width = tgetnum("sg")) < 0) X tcap_standout_width = 0; X tcap_LINES = tgetnum("li"); X tcap_COLS = tgetnum("co"); X } X X} /* end of read_termcap */ X X/*+------------------------------------------------------------------------- X horiz_rule(count) - horizontal rule starting at current position X--------------------------------------------------------------------------*/ Xvoid Xhoriz_rule(count) Xregister count; X{ X while(count--) X fputc(sHR,se); X} /* end of horiz_rule */ X X/*+------------------------------------------------------------------------- X vertical_rule(y,x,count) - vertical rule starting at y,x X--------------------------------------------------------------------------*/ Xvoid Xvertical_rule(y,x,count) Xint y; Xregister x; Xregister count; X{ X X while(count--) X { X curmove(y++,x); X fputc(sVR,se); X } X X} /* end of vertical_rule */ X X/*+------------------------------------------------------------------------- X draw_box_primitive(y,x,height,width) - ruled box X--------------------------------------------------------------------------*/ Xvoid Xdraw_box_primitive(y,x,height,width) Xregister y; Xint x; Xint height; Xint width; X{ Xregister i; X X curmove(y,x); X fputc(sTL,se); X if((i = width - 2) > 0) X horiz_rule(i); X fputc(sTR,se); X if((i = height - 2) > 0) X { X vertical_rule(y + 1,x + width - 1,i); X vertical_rule(y + 1,x,i); X } X curmove(y + height - 1,x); X fputc(sBL,se); X if((i = width - 2) > 0) X horiz_rule(i); X fputc(sBR,se); X X} /* end of draw_box_primitive */ X X/*+------------------------------------------------------------------------- X draw_box(y,x,height,width,title,title_x) X--------------------------------------------------------------------------*/ Xvoid Xdraw_box(y,x,height,width,title,title_x) Xchar *title; X{ Xregister stand = (title_x < 0); X X if(stand) X title_x = -title_x; X X draw_box_primitive(y,x,height,width); X curmove(y,x + title_x); X fputc('[',se); X if(stand) X stand_out(); X fprintf(so," %s ",title); X if(stand) X stand_end(); X fputc(']',se); X X} /* end of draw_box */ X X/*+------------------------------------------------------------------------- X putc_stderr(character) X--------------------------------------------------------------------------*/ Xvoid Xputc_stderr(character) Xint character; X{ X fputc(character,se); X} /* end of putc_stderr */ X X/*+------------------------------------------------------------------------- X curmove(y,x) X--------------------------------------------------------------------------*/ Xvoid Xcurmove(y,x) Xuint y; Xuint x; X{ X if(y >= tcap_LINES) X y = tcap_LINES - 1; X if(x >= tcap_COLS) X x = tcap_COLS - 1; X tputs(tgoto(tcap_move,x,y),1,putc_stderr); X} /* end of curmove */ X X/*+------------------------------------------------------------------------- X curbotleft() X--------------------------------------------------------------------------*/ Xvoid Xcurbotleft() X{ X curmove(tcap_LINES - 1,0); X} /* end of curbotleft */ X X/*+------------------------------------------------------------------------- X ins_line() X--------------------------------------------------------------------------*/ Xvoid Xins_line() X{ X if(*tcap_insline) X tputs(tcap_insline,1,putc_stderr); X} /* end of ins_line */ X X/*+------------------------------------------------------------------------- X del_line() X--------------------------------------------------------------------------*/ Xvoid Xdel_line() X{ X if(*tcap_delline) X tputs(tcap_delline,1,putc_stderr); X} /* end of del_line */ X X/*+------------------------------------------------------------------------- X vbell() - output visual bell X--------------------------------------------------------------------------*/ Xvoid Xvbell() X{ X if(*tcap_vbell) X tputs(tcap_vbell,1,putc_stderr); X} /* end of vbell */ X X/*+------------------------------------------------------------------------- X clear_screen() X--------------------------------------------------------------------------*/ Xvoid Xclear_screen() X{ X if(*tcap_clear) X tputs(tcap_clear,1,putc_stderr); X} /* end of clear_screen */ X X/*+------------------------------------------------------------------------- X eeol() - erase to end line X--------------------------------------------------------------------------*/ Xvoid Xeeol() X{ X if(*tcap_eeol) X tputs(tcap_eeol,1,putc_stderr); X} /* end of eeol */ X X/*+------------------------------------------------------------------------- X stand_out() X--------------------------------------------------------------------------*/ Xvoid Xstand_out() X{ X if(*tcap_standout) /* && (tcap_standout_width == 0)) */ X tputs(tcap_standout,1,putc_stderr); X} /* end of stand_out */ X X/*+------------------------------------------------------------------------- X stand_end() X--------------------------------------------------------------------------*/ Xvoid Xstand_end() X{ X if(*tcap_standend) /* && (tcap_standout_width == 0)) */ X tputs(tcap_standend,1,putc_stderr); X} /* end of stand_end */ X X/*+------------------------------------------------------------------------- X tcap_clear_area_char(count,clrch) X--------------------------------------------------------------------------*/ Xvoid Xtcap_clear_area_char(count,clrch) Xregister count; Xregister clrch; X{ Xregister itmp = count; X while(itmp--) X fputc(clrch,se); X itmp = count; X while(itmp--) X fputs(tcap_curleft,se); X X} /* end of tcap_clear_area_char */ X X/*+------------------------------------------------------------------------- X numchars = tcap_gets(buf,bufsize,&delim,wait_for_key) X XThis procedure reads a string and returns the number Xof characters read. -1 is returned if an abort is signaled by the Xkeyboard user. X--------------------------------------------------------------------------*/ Xint Xtcap_gets(buf,bufsize,delim,wait_for_key) Xchar *buf; Xregister bufsize; /* includes room for null..field is 1 less */ Xregister uchar *delim; Xint wait_for_key; X{ Xregister count; Xregister itmp; Xregister char *cptr = buf; X X if(!wait_for_key) X tcap_clear_area_char(bufsize-1,'_'); X X count = 0; /* no characters in string */ X *cptr = 0; /* start with null string */ X X while(1) X { X *delim = ttygetc(1); X if((*delim < 0x20) || (*delim >= 0x7F)) X { X switch(*delim) X { X case CR: X *delim = NL; X case NL: X return(count); X X case BS: X if(count) X { X count--; X *--cptr = 0; X fputc(0x08,se); X fputc('_',se); X fputs(tcap_curleft,se); X } X continue; X X case ESC: X case CTL_U: X itmp = count; X while(itmp--) X { X *--cptr = 0; X fputc(0x08,se); X } X itmp = count; X while(itmp--) X fputc('_',se); X itmp = count; X while(itmp--) X fputs(tcap_curleft,se); X cptr = buf; X count = 0; X if(*delim == ESC) X return(-1); X continue; X X default: X return(-1); X } /* end of switch(*delim) */ X /*NOTREACHED*/ X } /* end of if read delimiter */ X X if(count == bufsize-1) X continue; X if(wait_for_key) X { X tcap_clear_area_char(bufsize-1,'_'); X wait_for_key = 0; X } X fputc(*delim,se); X *cptr++ = *delim; X *cptr = 0; X count++; X } /* end of while can get character */ X X} /* end of tcap_gets */ X X X/* end of ecutcap.c */ X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 ecutcap.c || echo "restore of ecutcap.c fails" echo "x - extracting ecutime.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ecutime.c && X/* CHK=0xA2BB */ X/*+------------------------------------------------------------------------- X ecutime.c -- ecu time-related functions X Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved X X Defined functions: X epoch_secs_to_str(epoch_secs,type,buf) X get_elapsed_time(elapsed_seconds) X get_tod(type,buf) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */ X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */ X X#include <sys/types.h> X#include <time.h> X#include <sys/timeb.h> X X/*+------------------------------------------------------------------------- X get_month() - month 1-12 X--------------------------------------------------------------------------*/ Xint Xget_month() X{ Xlong time(); Xlong epoch_secs = time((long *)0); Xstruct tm *lt = localtime(&epoch_secs); X return(lt->tm_mon + 1); X} /* end of get_month */ X X/*+------------------------------------------------------------------------- X get_day() - day 0-6 X--------------------------------------------------------------------------*/ Xint Xget_day() X{ Xlong time(); Xlong epoch_secs = time((long *)0); Xstruct tm *lt = localtime(&epoch_secs); X return(lt->tm_wday); X} /* end of get_day */ X X/*+----------------------------------------------------------------------- X char *epoch_secs_to_str(epoch_secs,type,buf) X X time of day types: X 0 hh:mm X 1 hh:mm:ss X 2 mm-dd-yyyy hh:mm X 3 mm-dd-yyyy hh:mm:ss X 4 mm-dd-yyyy hh:mm:ss (UTC hh:mm) X 5 mm-dd-yyyy X X returns 'buf' address X X------------------------------------------------------------------------*/ Xchar * Xepoch_secs_to_str(epoch_secs,type,buf) Xlong epoch_secs; Xint type; Xchar *buf; X{ Xstruct tm *lt; /* local time */ Xstruct tm *gmtime(); Xstruct tm *localtime(); X X lt = localtime(&epoch_secs); X switch(type) X { X default: X case 0: X sprintf(buf,"%02d:%02d",lt->tm_hour,lt->tm_min); X break; X X case 1: X sprintf(buf,"%02d:%02d:%02d",lt->tm_hour,lt->tm_min,lt->tm_sec); X break; X X case 2: X sprintf(buf,"%02d-%02d-%04d %02d:%02d", X lt->tm_mon + 1,lt->tm_mday,lt->tm_year + 1900, X lt->tm_hour,lt->tm_min); X break; X X case 3: X sprintf(buf,"%02d-%02d-%04d %02d:%02d:%02d", X lt->tm_mon + 1,lt->tm_mday,lt->tm_year + 1900, X lt->tm_hour,lt->tm_min,lt->tm_sec); X break; X X case 4: X sprintf(buf,"%02d-%02d-%04d %02d:%02d:%02d", X lt->tm_mon + 1,lt->tm_mday,lt->tm_year + 1900, X lt->tm_hour,lt->tm_min,lt->tm_sec); X lt = gmtime(&epoch_secs); X sprintf(&buf[strlen(buf) ]," (UTC %02d:%02d)", X lt->tm_hour,lt->tm_min); X break; X X case 5: X sprintf(buf,"%02d-%02d-%04d", X lt->tm_mon + 1,lt->tm_mday,lt->tm_year + 1900); X break; X X } X X return(buf); X} /* end of epoch_secs_to_str */ X X/*+----------------------------------------------------------------------- X char *get_tod(type,buf) Xreturns 'buf' address X------------------------------------------------------------------------*/ Xchar * Xget_tod(type,buf) Xint type; Xchar *buf; X{ Xlong time(); X return(epoch_secs_to_str(time((long *)0),type,buf)); X} /* end of get_tod */ X X/*+----------------------------------------------------------------------- X char *get_elapsed_time(elapsed_seconds) X "hh:mm:ss" returned X static string address is returned X------------------------------------------------------------------------*/ Xchar * Xget_elapsed_time(elapsed_seconds) Xlong elapsed_seconds; X{ Xstatic char elapsed_time_str[40]; Xlong hh,mm,ss; X X hh = elapsed_seconds / 3600; X elapsed_seconds -= hh * 3600; X mm = elapsed_seconds / 60L; X elapsed_seconds -= mm * 60L; X ss = elapsed_seconds; X X sprintf(elapsed_time_str,"%02ld:%02ld:%02ld",hh,mm,ss); X return(elapsed_time_str); X} /* end of get_elapsed_time */ X X/* end of ecutime.c */ X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 ecutime.c || echo "restore of ecutime.c fails" echo "x - extracting ecutty.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ecutty.c && X/* CHK=0x6EC3 */ X/*+------------------------------------------------------------------------- X ecutty.c X Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved X SHAR_EOF echo "End of part 9" echo "File ecutty.c is continued in part 10" echo "10" > s2_seq_.tmp exit 0 -- ------------------------------------------------------------------- Warren Tucker, Tridom Corporation ...!gatech!emory!tridom!wht Ker-au'-lo-phon. An 8-foot partial flue-stop, having metal pipes surmounted by adjustable rings, and with a hole bored near the top of each pipe, producing a soft and "reedy" tone.