wht@tridom.uucp (Warren Tucker) (10/11/89)
---- Cut Here and unpack ---- #!/bin/sh # this is part 28 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file z/zmodem.c continued # CurArch=28 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 z/zmodem.c" sed 's/^X//' << 'SHAR_EOF' >> z/zmodem.c X xsendline(ZDLE); X c ^= 0100; Xsendit: X xsendline(lastsent = c); X break; X default: X if(Zctlesc && ! (c & 0140)) X { X xsendline(ZDLE); X c ^= 0100; X } X xsendline(lastsent = c); X } X } X} X X/* Decode two lower case hex digits into an 8 bit byte value */ Xzgethex() X{ X register int c; X X c = zgeth1(); X return(c); X} Xzgeth1() X{ X register int c,n; X X if((c = noxrd7()) < 0) X return(c); X n = c - '0'; X if(n > 9) X n -= ('a' - ':'); X if(n & ~0xF) X return(ERROR); X if((c = noxrd7()) < 0) X return(c); X c -= '0'; X if(c > 9) X c -= ('a' - ':'); X if(c & ~0xF) X return(ERROR); X c += (n<<4); X return(c); X} X X/* X * Read a byte,checking for ZMODEM escape encoding X * including CAN*5 which represents a quick abort X */ Xzdlread() X{ X register int c; X Xagain: X /* Quick check for non control characters */ X if((c = readline(Rxtimeout)) & 0140) X return(c); X switch(c) X { X case ZDLE: X break; X case 023: X case 0223: X case 021: X case 0221: X goto again; X default: X if(Zctlesc && !(c & 0140)) X { X goto again; X } X return(c); X } Xagain2: X if((c = readline(Rxtimeout)) < 0) X return(c); X if(c == CAN && (c = readline(Rxtimeout)) < 0) X return(c); X if(c == CAN && (c = readline(Rxtimeout)) < 0) X return(c); X if(c == CAN && (c = readline(Rxtimeout)) < 0) X return(c); X switch(c) X { X case CAN: X return(GOTCAN); X case ZCRCE: X case ZCRCG: X case ZCRCQ: X case ZCRCW: X return(c | GOTOR); X case ZRUB0: X return(0177); X case ZRUB1: X return(0377); X case 023: X case 0223: X case 021: X case 0221: X goto again2; X default: X if(Zctlesc && ! (c & 0140)) X { X goto again2; X } X if((c & 0140) == 0100) X return(c ^ 0100); X break; X } X sprintf(s128,"Bad escape sequence %x",c); X report_str(s128,1); X return(ERROR); X} X X/* X * Read a character from the modem line with timeout. X * Eat parity,XON and XOFF characters. X */ Xnoxrd7() X{ X register int c; X X for(;;) X { X if((c = readline(Rxtimeout)) < 0) X return(c); X switch(c &= 0177) X { X case XON: X case XOFF: X continue; X default: X if(Zctlesc && !(c & 0140)) X continue; X case '\r': X case '\n': X case ZDLE: X return(c); X } X } X} X X/* Store long integer pos in Txhdr */ Xstohdr(pos) Xlong pos; X{ X Txhdr[ZP0] = pos; X Txhdr[ZP1] = pos>>8; X Txhdr[ZP2] = pos>>16; X Txhdr[ZP3] = pos>>24; X} X X/* Recover a long integer from a header */ Xlong Xrclhdr(hdr) Xregister char *hdr; X{ X register long l; X X l = (hdr[ZP3] & 0377); X l = (l << 8) | (hdr[ZP2] & 0377); X l = (l << 8) | (hdr[ZP1] & 0377); X l = (l << 8) | (hdr[ZP0] & 0377); X return(l); X} X X/* end of zmodem.c */ X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF echo "File z/zmodem.c is complete" chmod 0644 z/zmodem.c || echo "restore of z/zmodem.c fails" echo "x - extracting z/zcurses.c (Text)" sed 's/^X//' << 'SHAR_EOF' > z/zcurses.c && X/* CHK=0xCE76 */ X/*+------------------------------------------------------------------------- X zcurses.c -- ecu file transfer program curses interface X X 000000000011111111112222222222333333333344444444445555555550 X 012345678901234567890123456789012345678901234567890123456789 X00.-[ prog+rev ]-- <dir> ------------------------------------. X01| ZMODEM_6____ _40_____________________________________ | X02| File ### of ###: _38__________________________________ | X03| File position: _8______ length: _8______ -rwxrwxrwx | X04| _55____________________________________________________ | transaction X05| _55____________________________________________________ | last rx/tx hdr X06| Comm I/O: rx _8______ tx _8______ bytes | X07| Baud rate: _5___ BINARY blklen: _____ comm mode: CBREAK | X08| Time started: session: HH:MM:SS this file: HH:MM:SS | X09| elpased: HH:MM:SS time: HH:MM:SS | X10| Error counts: this file: _4__ total: _6____ | X11| _55____________________________________________________ | err str X12| _55____________________________________________________ | comment str X13| _55____________________________________________________ | remote info X14`----------------------------------------------------------' X X Defined functions: X clear_area(win,row,col,len) X clear_area_char(win,row,col,len,fillchar) X get_elapsed_time(elapsed_seconds) X get_tod(type,tod) X mode_map(mode,mode_str) X report_comm_baud_rate(baud_rate) X report_error_count() X report_file_byte_io(count) X report_file_close() X report_file_open_length(length) X report_file_open_mode(file_mode) X report_file_open_tod() X report_file_rcv_started(filename,length,last_mod_time,file_mode) X report_file_send_open(filename,filestat) X report_init(title) X report_last_rxhdr(rptstr,error_flag) X report_last_txhdr(rptstr,error_flag) X report_mode(mode) X report_protocol_crc_type(str) X report_protocol_type(str) X report_rx_ind(status) X report_rx_tx_count() X report_rxblklen(blklen) X report_rxpos(rxpos) X report_str(rptstr,error_flag) X report_top_line(topstr) X report_transaction(str) X report_tx_ind(status) X report_txblklen(blklen) X report_txpos(txpos) X report_uninit(sig) X report_xfer_mode(str) X X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:07-03-1989-22:58-wht------------- ecu 2.00 ---------------- */ X/*:06-24-1989-16:51-wht-flush edits --- ecu 1.95 */ X X#include <curses.h> X#include <sys/types.h> X#include <sys/stat.h> X#include <ctype.h> X#include <signal.h> X#include <time.h> X#include <sys/timeb.h> X X#include "../pc_scr.h" X#include "zlint.h" X Xlong time(); Xextern char *tzname[]; Xstruct tm *localtime(); X X X#define WIN_LINES 15 X#define WIN_COLS 60 X#define WIN_TOPY 2 X#define WIN_LEFTX 8 X Xextern char curr_dir[]; Xextern char s128[]; Xextern char *bottom_label; Xextern int Filcnt; Xextern int ecusz_flag; /* ecusz == 1, ecurz == 0 */ Xextern int npats; Xextern long rxpos; Xextern int log_packets; X XWINDOW *win; Xint (*original_sigint_handler)(); Xint (*original_sigquit_handler)(); Xint (*original_sigterm_handler)(); Xint curses_installed = 0; /* curses not yet active */ Xint this_file_errors; Xint total_errors; Xlong current_seconds; Xlong start_seconds; Xlong elapsed_seconds; Xunsigned long total_data_chars_xfered = 0L; Xchar s256[256]; X Xchar *win_template[] = X{ X/*00000000001111111111222222222233333333334444444444555555555 */ X/*01234567890123456789012345678901234567890123456789012345678 */ X/*.----------------------------------------------------------. */ X " ", /* 1 */ X " File ### of ###: _____________________________________ ", /* 2 */ X " File position: ________ length: ________ ", /* 3 */ X " ", /* 4 */ X " tx: ______________________ rx: ______________________ ", /* 5 */ X " Comm I/O: rx ________ tx ________ bytes ", /* 6 */ X " Baud rate: _____ ______ blklen: _____ comm mode: ______ ", /* 7 */ X " Time started: session: --:--:-- this file: --:--:-- ", /* 8 */ X " elapsed: --:--:-- current: --:--:-- ", /* 9 */ X " Error counts: this file: ____ total: ______ ", /* 10 */ X " ", /* 11 */ X " ", /* 12 */ X " ", /* 13 */ X/*`----------------------------------------------------------' */ X(char *)0 X}; X X/*+----------------------------------------------------------------------- X char *get_elapsed_time(elapsed_seconds) X hh:mm:ss returned X static string address is returned X------------------------------------------------------------------------*/ Xchar *get_elapsed_time(elapsed_seconds) Xlong elapsed_seconds; X{ X static char elapsed_time_str[10]; X long 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/*+----------------------------------------------------------------------- X char *get_tod(type,tod) X X time of day types: X 0 hh:mm X 1 hh:mm:ss X 2 mm-dd-yyyy hh:mm X X static string address is returned X if tod != (char *)0, time is returned there too X------------------------------------------------------------------------*/ Xchar * Xget_tod(type,tod) Xint type; Xchar *tod; X{ X long cur_time = 0; X struct tm *lt; /* local time */ X static char tod_str[32]; X#if defined(M_XENIX) X struct timeb tp; X#endif X X cur_time = time((long *)0); X lt = localtime(&cur_time); X#if XENIX && MESSED_UP_DST X ftime(&tp); /* localtime() does not know about DST */ X if(tp.dstflag) /* so we adjust with ftime, which does know */ X { X cur_time += 3600L; /* problem in BSD too, but no ftime there */ X lt = localtime(&cur_time); X cur_time -= 3600L; X } X#endif X X switch(type) X { X case 0: X sprintf(tod_str,"%02d:%02d",lt->tm_hour,lt->tm_min); X break; X X default: X case 1: X sprintf(tod_str,"%02d:%02d:%02d",lt->tm_hour,lt->tm_min,lt->tm_sec); X break; X X case 2: X sprintf(tod_str,"%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 X if(tod != (char *)0) X strcpy(tod,tod_str); X X return(tod_str); X} /* end of get_tod */ X X/*+----------------------------------------------------------------------- X mode_map(mode,mode_str) build drwxrwxrwx string X------------------------------------------------------------------------*/ Xchar * Xmode_map(mode,mode_str) Xunsigned short mode; Xchar *mode_str; X{ Xregister unsigned ftype = mode & S_IFMT; Xregister char *rtn; Xstatic char result[12]; X X rtn = (mode_str == (char *)0) ? result : mode_str; X X /* drwxrwxrwx */ X /* 0123456789 */ X strcpy(rtn,"----------",mode); X X switch(ftype) X { X case S_IFIFO: *rtn = 'p'; break; /* FIFO (named pipe) */ X case S_IFDIR: *rtn = 'd'; break; /* directory */ X case S_IFCHR: *rtn = 'c'; break; /* character special */ X case S_IFBLK: *rtn = 'b'; break; /* block special */ X case S_IFREG: *rtn = '-'; break; /* regular */ X X#if defined(pyr) | defined(BSD4) X case S_IFLNK: *rtn = 'l'; break; /* symbolic link */ X case S_IFSOCK: *rtn = 's'; break; /* socket */ X#endif X X#if defined (M_XENIX) | defined(SYS5) X case S_IFNAM: /* name space entry */ X if(mode & S_INSEM) /* semaphore */ X { X *rtn = 's'; X break; X } X if(mode & S_INSHD) /* shared memory */ X { X *rtn = 'm'; X break; X } X#endif X X default: *rtn = '?'; break; /* ??? */ X } X X if(mode & 000400) *(rtn + 1) = 'r'; X if(mode & 000200) *(rtn + 2) = 'w'; X if(mode & 000100) *(rtn + 3) = 'x'; X if(mode & 004000) *(rtn + 3) = 's'; X if(mode & 000040) *(rtn + 4) = 'r'; X if(mode & 000020) *(rtn + 5) = 'w'; X if(mode & 000010) *(rtn + 6) = 'x'; X if(mode & 002000) *(rtn + 6) = 's'; X if(mode & 000004) *(rtn + 7) = 'r'; X if(mode & 000002) *(rtn + 8) = 'w'; X if(mode & 000001) *(rtn + 9) = 'x'; X if(mode & 001000) *(rtn + 9) = 't'; X X return(rtn); X X} /* end of mode_map */ X X/*+------------------------------------------------------------------------- X clear_area(win,row,col,len) X--------------------------------------------------------------------------*/ Xclear_area(win,row,col,len) XWINDOW *win; Xint row; Xint col; Xint len; X{ X wmove(win,row,col); X while(len-- > 0) X waddch(win,' '); X wmove(win,row,col); X X} /* end of clear_area */ X X/*+------------------------------------------------------------------------- X clear_area_char(win,row,col,len,fillchar) X--------------------------------------------------------------------------*/ Xclear_area_char(win,row,col,len,fillchar) XWINDOW *win; Xint row; Xint col; Xint len; Xchar fillchar; X{ X wmove(win,row,col); X while(len-- > 0) X waddch(win,fillchar); X wmove(win,row,col); X X} /* end of clear_area_char */ X X/*+------------------------------------------------------------------------- X report_top_line(topstr) X top line: row 1 col 17 length 40 X--------------------------------------------------------------------------*/ Xvoid Xreport_top_line(topstr) Xchar *topstr; X{ Xchar s42[42]; X clear_area(win,1,17,42); X if(strlen(topstr) < 40) X waddstr(win,topstr); X else X { X strncpy(s42,topstr,40); X s42[40] = 0; X waddstr(win,s42); X } X} /* end of report_top_line */ X X/*+------------------------------------------------------------------------- X report_xfer_mode(modestr) BINARY/ASCII X protocol xfer type: row 7 col 20 length 6 X--------------------------------------------------------------------------*/ Xreport_xfer_mode(str) Xchar *str; X{ Xchar s10[10]; X X if(strlen(str) > 6) X { X strncpy(s10,str,6); X s10[7] = 0; X str = s10; X } X clear_area(win,7,20,6); X waddstr(win,str); X wrefresh(win); X X} /* end of report_xfer_mode */ X X/*+------------------------------------------------------------------------- X report_protocol_type(str) X X protocol type: row 1 col 3 length 6 string X--------------------------------------------------------------------------*/ Xreport_protocol_type(str) Xregister char *str; X{ Xchar s10[10]; X X if(strlen(str) > 6) X { X strncpy(s10,str,6); X s10[7] = 0; X str = s10; X } X clear_area(win,1,3,6); X waddstr(win,str); X wrefresh(win); X X} /* end of report_protocol_type */ X X/*+------------------------------------------------------------------------- X report_protocol_crc_type(str) X X protocol crc type: row 1 col 9 length 6 X--------------------------------------------------------------------------*/ Xreport_protocol_crc_type(str) Xregister char *str; X{ Xchar s8[8]; X X if(strlen(str) > 6) X { X strncpy(s8,str,6); X s8[7] = 0; X str = s8; X } X clear_area(win,1,9,6); X waddstr(win,str); X wrefresh(win); X X} /* end of report_protocol_crc_type */ X X/*+------------------------------------------------------------------------- X report_uninit(sig) X--------------------------------------------------------------------------*/ Xvoid Xreport_uninit(sig) Xint sig; /* if -1, called by normal code, else kill() value */ X{ X float total = (float)total_data_chars_xfered; X X if(curses_installed) X { X if((total_data_chars_xfered != 0L) && (elapsed_seconds != 0L)) X { X sprintf(s128,"Data xfer rate ~= %6.0f chars/sec", X total / (float)elapsed_seconds); X if(log_packets) X { X write(log_packets,"info: ",6); X write(log_packets,s128,strlen(s128)); X write(log_packets,"\n",1); X } X report_top_line(s128); X } X report_file_byte_io(0L); X report_rx_tx_count(); X wmove(win,WIN_LINES - 1,WIN_COLS - 1); X wrefresh(win); X endwin(); X fprintf(stderr,"\r\n\r\n\r\n"); X fflush(stderr); X curses_installed = 0; X } X X} /* end of report_uninit */ X X/*+------------------------------------------------------------------------- X report_init(title) X--------------------------------------------------------------------------*/ Xvoid Xreport_init(title) Xchar *title; X{ X register int itmp; X register char *cptr; X char buf[80]; X X if(curses_installed) X return; X X initscr(); X crmode(); X noecho(); X nonl(); X clear(); X curses_installed = 1; X win = newwin(WIN_LINES,WIN_COLS,WIN_TOPY,WIN_LEFTX); X box(win,sVR,sHR); X wmove(win,0,0); waddch(win,sTL); X wmove(win,win->_maxy - 1,0); waddch(win,sBL); X wmove(win,win->_maxy - 1,win->_maxx - 1); waddch(win,sBR); X wmove(win,0,win->_maxx - 1); waddch(win,sTR); X wmove(win,0,2); X waddch(win,'['); X waddch(win,' '); X waddstr(win,title); X waddch(win,' '); X waddch(win,']'); X waddch(win,sHR); X waddch(win,sHR); X waddch(win,' '); X itmp = WIN_COLS - 2 - 7 - strlen(title); X curr_dir[itmp] = 0; X waddstr(win,curr_dir); X waddch(win,' '); X if(bottom_label) X { X strncpy(buf,bottom_label,WIN_COLS - 6); X buf[WIN_COLS - 6] = 0; X wmove(win,WIN_LINES - 1,2); X waddch(win,' '); X waddstr(win,buf); X waddch(win,' '); X } X X itmp = 0; X while(1) X { X if(win_template[itmp] == (char *)0) X break; X wmove(win,itmp + 1,1); X waddstr(win,win_template[itmp++]); X } X if(ecusz_flag) X { X clear_area(win,2,15,3); X sprintf(s128,"%3d",npats); X waddstr(win,s128); X#if defined(FORK_DEBUG) X sprintf(s128,"DEBUG ecusz pid %d",getpid()); X#endif X } X else /* ecurz */ X { X clear_area(win,2,11,8); /* clear "of ###" */ X waddstr(win,":"); X#if defined(FORK_DEBUG) X sprintf(s128,"DEBUG ecurz pid %d",getpid()); X#endif X } X X#if defined(FORK_DEBUG) X ecu_log_event(s128); X#endif X X clear_area(win,1,11,47); X report_error_count(); X clear_area(win,8,26,8); /* starting time */ X waddstr(win,get_tod(1,(char *)0)); X start_seconds = time((long *)0); X current_seconds = start_seconds; X X wrefresh(win); X X} /* end of report_init */ X X/*+------------------------------------------------------------------------- X report_rx_ind(status) X--------------------------------------------------------------------------*/ Xvoid Xreport_rx_ind(status) Xint status; X{ X#if defined(M_XENIX) X wmove(win,1,54); X waddch(win,(status) ? 'R' : ' '); X wmove(win,1,54); X wrefresh(win); X#endif X} /* end of report_rx_ind */ X X/*+------------------------------------------------------------------------- X report_tx_ind(status) X--------------------------------------------------------------------------*/ Xvoid Xreport_tx_ind(status) Xint status; X{ X#if defined(M_XENIX) X wmove(win,1,56); X waddch(win,(status) ? 'T' : ' '); X wmove(win,1,56); X wrefresh(win); X#endif X} /* end of report_tx_ind */ X X/*+------------------------------------------------------------------------- X report_rx_tx_count() X X rx char count: row 6 col 16 length 8 unsigned long X tx char count: row 6 col 29 length 8 unsigned long X now time of day: row 1 col 50 length 8 hh:mm:ss X This procedure may be counted upon to perform wrefresh(win) X Xelapsed time row 9 col 26 length 8 Xcurrent tod row 9 col 47 length 8 X--------------------------------------------------------------------------*/ Xreport_rx_tx_count() X{ X extern unsigned long rx_char_count; X extern unsigned long tx_char_count; X X register char *cptr; X X sprintf(s128,"%8ld",rx_char_count); X wmove(win,6,16); X waddstr(win,s128); X sprintf(s128,"%8ld",tx_char_count); X wmove(win,6,29); X waddstr(win,s128); X X /* now time of day */ X clear_area(win,9,47,8); X cptr = get_tod(1,(char *)0); X waddstr(win,cptr); X current_seconds = time((long *)0); X elapsed_seconds = current_seconds - start_seconds; X cptr = get_elapsed_time(elapsed_seconds); X clear_area(win,9,26,8); X waddstr(win,cptr); X wrefresh(win); /* calling procs expect this to occur always */ X X} /* end of report_rx_tx_count */ X X/*+------------------------------------------------------------------------- X report_mode(mode) X X comm mode row 7 col 52 length 6 X 3: save old tty stat, set raw mode with flow control X 2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g X 1: save old tty stat, set raw mode X 0: restore original tty mode X--------------------------------------------------------------------------*/ Xvoid Xreport_mode(mode) Xint mode; X{ Xchar *cptr; Xchar tmp[8]; X X clear_area(win,7,52,6); X switch(mode) X { X case 0: X cptr = "NORMAL"; X break; X case 1: X cptr = "RAW"; X break; X case 2: X cptr = "RAW-g"; X break; X case 3: X cptr = "RAW-f"; X break; X default: X sprintf(tmp,"%5u",mode); X cptr = tmp; X } X waddstr(win,cptr); X wrefresh(win); X if(log_packets) X { X write(log_packets,"mode: ",6); X write(log_packets,cptr,strlen(cptr)); X write(log_packets,"\n",1); X } X X} /* end of report_mode */ X X/*+------------------------------------------------------------------------- X report_rxblklen(blklen) Xrow 7 col 35 5 chars X--------------------------------------------------------------------------*/ Xvoid Xreport_rxblklen(blklen) Xint blklen; X{ X char tmp[10]; X X sprintf(tmp,"%5u",blklen); X clear_area(win,7,35,5); X waddstr(win,tmp); X wrefresh(win); X} /* end of report_rxblklen */ X X/*+------------------------------------------------------------------------- X report_txblklen(blklen) Xrow 7 col 35 5 chars X--------------------------------------------------------------------------*/ Xvoid Xreport_txblklen(blklen) Xint blklen; X{ X report_rxblklen(blklen); X} /* end of report_txblklen */ X X/*+------------------------------------------------------------------------- X report_rxpos(rxpos) row 3 col 19 len 8 X--------------------------------------------------------------------------*/ Xvoid Xreport_rxpos(rxpos) Xlong rxpos; X{ Xchar tmp[16]; X#if defined(M_XENIX) Xchar refr; X if(rdchk(0)) X { X read(0,&refr,1); X if(refr == 0x0C || refr == 0x012) /* ^L or ^R */ X { X write(2,"\033[2J",4); X nap((long)60); X touchwin(stdscr); X wrefresh(stdscr); X touchwin(win); X wrefresh(win); X } X } X#endif X X if((rxpos > 99999999L) || (rxpos < 0L)) X return; X X sprintf(tmp,"%8lu",rxpos); X wmove(win,3,19); X waddstr(win,tmp); X wrefresh(win); X report_rx_tx_count(); /* which will do a refresh */ X} /* end of report_rxpos */ X X/*+------------------------------------------------------------------------- X report_txpos(txpos) X--------------------------------------------------------------------------*/ Xvoid Xreport_txpos(txpos) Xlong txpos; X{ X report_rxpos(txpos); X} /* end of report_txpos */ X X/*+------------------------------------------------------------------------- X report_error_count() X DOES NOT PERFORM A REFRESH CYCLE X X this file: row 10 col 30 len 4 X total: row 10 col 43 len 6 X--------------------------------------------------------------------------*/ Xreport_error_count() X{ X char tmp[16]; X X clear_area(win,10,30,4); X sprintf(tmp,"%4d",this_file_errors); X waddstr(win,tmp); X X clear_area(win,10,43,6); X sprintf(tmp,"%6d",total_errors); X waddstr(win,tmp); X wrefresh(win); X X} /* end of report_error_count */ X X/*+------------------------------------------------------------------------- X report_last_txhdr(rptstr,error_flag) X 5,7,22 X--------------------------------------------------------------------------*/ Xvoid Xreport_last_txhdr(rptstr,error_flag) Xregister char *rptstr; Xint error_flag; X{ Xchar s24[24]; X X if(log_packets) X { X write(log_packets,"tx: ",6); X write(log_packets,rptstr,strlen(rptstr)); X write(log_packets,"\n",1); X } X X if(strlen(rptstr) > 22) X { X strncpy(s24,rptstr,22); X s24[23] = 0; X rptstr = s24; X } X clear_area(win,5,7,22); X waddstr(win,rptstr); X X if(error_flag) X { X ++this_file_errors; X ++total_errors; X report_error_count(); X } X X} /* end of report_last_txhdr */ X X/*+------------------------------------------------------------------------- X report_last_rxhdr(rptstr,error_flag) X 5,35,22 X--------------------------------------------------------------------------*/ Xvoid Xreport_last_rxhdr(rptstr,error_flag) Xregister char *rptstr; Xint error_flag; X{ Xchar s24[24]; Xextern int log_packets; X X if(log_packets) X { X write(log_packets,"rx: ",6); X write(log_packets,rptstr,strlen(rptstr)); X write(log_packets,"\n",1); X } X X if(strlen(rptstr) > 22) X { X strncpy(s24,rptstr,22); X s24[23] = 0; X rptstr = s24; X } X clear_area(win,5,35,22); X waddstr(win,rptstr); X X if(error_flag) X { X ++this_file_errors; X ++total_errors; X report_error_count(); X } X X} /* end of report_last_rxhdr */ X X/*+------------------------------------------------------------------------- X report_str(rptstr,error_flag) row 11/12 col 3 len 55 X X error_flag == 0 for status/progress message X == 1 for bump error count, unless rptstr is null X in which case, merely clear error string area X == 2 write string on bottom line (not an error) X == 3 write string on transaction line (not an error) X == -1 use error line but do not bump error count X--------------------------------------------------------------------------*/ Xvoid Xreport_str(rptstr,error_flag) Xregister char *rptstr; Xint error_flag; X{ Xchar s60[60]; Xextern int log_packets; X X if(strlen(rptstr) > 55) X { X strncpy(s60,rptstr,55); X s60[56] = 0; X rptstr = s60; X } X X switch(error_flag) X { X case 0: X clear_area(win,12,3,55); X break; X case 1: X ++this_file_errors; X ++total_errors; X report_error_count(); X case -1: X clear_area(win,11,3,55); X break; X case 2: X clear_area(win,13,3,55); X break; X case 3: X clear_area(win,4,3,55); X break; X } X X waddstr(win,rptstr); X wrefresh(win); X X if(log_packets) X { X write(log_packets,"info: ",6); X write(log_packets,rptstr,strlen(rptstr)); X write(log_packets,"\n",1); X } X X} /* end of report_str */ X X/*+------------------------------------------------------------------------- X report_transaction() X--------------------------------------------------------------------------*/ Xvoid Xreport_transaction(str) Xchar *str; X{ X report_str(str,3); X} /* end of report_transaction */ X X/*+------------------------------------------------------------------------- X report_file_open_tod() -- time of start of this file X X this file open time: row 8 col 47 length 8 X--------------------------------------------------------------------------*/ Xvoid Xreport_file_open_tod() X{ X clear_area(win,8,47,8); X waddstr(win,get_tod(1,(char *)0)); X wrefresh(win); X} /* end of report_file_open_tod */ X X/*+------------------------------------------------------------------------- X report_file_open_mode(file_mode) X mode map: row 4 col 46 len 10 X--------------------------------------------------------------------------*/ Xreport_file_open_mode(file_mode) Xunsigned short file_mode; X{ X clear_area(win,3,46,10); X waddstr(win,mode_map(file_mode,(char *)0)); X wrefresh(win); X} /* end of report_file_open_mode */ X X/*+------------------------------------------------------------------------- X report_file_open_length(long_length) X length: row 3 col 36 len 8 X--------------------------------------------------------------------------*/ Xreport_file_open_length(length) Xlong length; X{ X clear_area(win,3,36,8); X if(length <= 0) X waddstr(win,"unknown"); X else X { X sprintf(s128,"%8lu",length); X waddstr(win,s128); X } X wrefresh(win); X} /* end of report_file_open_length */ X X/*+------------------------------------------------------------------------- X report_file_send_open(filename,filestat) X X filename: row 2 col 20 len 38 X number: row 2 col 8 len 3 X length: row 3 col 36 len 8 X mode: row 3 col 46 len 10 X time of start of this file: row 4 col 47 length 8 hh:mm:ss X--------------------------------------------------------------------------*/ Xvoid Xreport_file_send_open(filename,filestat) Xchar *filename; Xstruct stat *filestat; X{ Xchar s50[50]; Xregister char *cptr = filename; X X if(log_packets) X { X write(log_packets,"file: ",6); X write(log_packets,filename,strlen(filename)); X write(log_packets,"\n",1); X } X X /* number */ X clear_area(win,2,8,3); X sprintf(s50,"%3d",Filcnt); X waddstr(win,s50); X X /* filename */ X if(strlen(filename) > 38) X { X strncpy(s50,filename,38); X s50[39] = 0; X cptr = s50; X } X clear_area(win,2,20,38); X waddstr(win,cptr); X X /* length */ X report_file_open_length(filestat->st_size); X X /* mode */ X report_file_open_mode(filestat->st_mode); X X /* time of start of this file */ X report_file_open_tod(); X X this_file_errors = 0; X report_error_count(); X} /* end of report_file_send_open */ X X/*+------------------------------------------------------------------------- X report_file_rcv_started(filename,length,last_mod_time,file_mode) X X filename: row 2 col 7 len 50 X length: row 3 col 36 len 8 if not xmodem X mode: row 3 col 46 len 10 X time of start of this file: row 4 col 47 length 8 hh:mm:ss X--------------------------------------------------------------------------*/ Xreport_file_rcv_started(filename,length,last_mod_time,file_mode) Xchar *filename; Xlong length; /* if < 0, "UNKNOWN" */ Xlong last_mod_time; /* not currently displayed */ Xunsigned short file_mode; /* UNIX file modifier or zero */ X{ Xregister char *cptr; SHAR_EOF echo "End of part 28" echo "File z/zcurses.c is continued in part 29" echo "29" > 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.