diff -ur lrzsz-0.12.21/src/lrz.c newlrzsz/src/lrz.c --- lrzsz-0.12.21/src/lrz.c 2003-08-21 16:22:01.000000000 -0500 +++ newlrzsz/src/lrz.c 2003-08-21 17:05:53.000000000 -0500 @@ -68,6 +68,7 @@ unsigned Baudrate = 2400; FILE *fout; +char *dszlogpath; int Lastrx; @@ -192,6 +193,9 @@ zmputs(Attn); canit(STDOUT_FILENO); io_mode(0,0); + if (dszlogpath) { + dszlog(dszlogpath, 'L', 0, 0, 0, errors, 0, 0); + } error(128+n,0,_("caught signal %d; exiting"), n); } @@ -265,6 +269,13 @@ if ((cp=getenv("ZMODEM_RESTRICTED"))!=NULL) Restricted=2; + dszlogpath = getenv("DSZLOG"); + if (access(dszlogpath, F_OK) == 0) { + if (unlink(dszlogpath) != 0) { + perror("unlink dszlog"); + } + } + /* make temporary and unfinished files */ umask(0077); @@ -559,6 +570,7 @@ signal(SIGINT, bibi); signal(SIGTERM, bibi); signal(SIGPIPE, bibi); + signal(SIGHUP, bibi); if (wcreceive(npats, patts)==ERROR) { exitcode=0200; canit(STDOUT_FILENO); @@ -685,9 +697,9 @@ #endif if (c) goto fubar; - } else { + } else { /* Not Xmodem, not Zmodem, so Ymodem */ for (;;) { - if (Verbose > 1 + if (Verbose > 1 || dszlogpath #ifdef ENABLE_SYSLOG || enable_syslog #endif @@ -712,7 +724,7 @@ if (wcrx(&zi)==ERROR) goto fubar; - if (Verbose > 1 + if (Verbose > 1 || dszlogpath #ifdef ENABLE_SYSLOG || enable_syslog #endif @@ -734,16 +746,19 @@ lsyslog(LOG_INFO,"%s/%s: %ld Bytes, %ld BPS", shortname,protname(),zi.bytes_received, bps); #endif + if (dszlogpath) dszlog(dszlogpath, 'R', + zi.bytes_received, zi.fname, + bps, errors, 0, 0); } } } - } else { + } else { /* Xmodem */ char dummy[128]; dummy[0]='\0'; /* pre-ANSI HPUX cc demands this */ dummy[1]='\0'; /* procheader uses name + 1 + strlen(name) */ zi.bytes_total = DEFBYTL; - if (Verbose > 1 + if (Verbose > 1 || dszlogpath #ifdef ENABLE_SYSLOG || enable_syslog #endif @@ -782,7 +797,7 @@ if (wcrx(&zi)==ERROR) { goto fubar; } - if (Verbose > 1 + if (Verbose > 1 || dszlogpath #ifdef ENABLE_SYSLOG || enable_syslog #endif @@ -803,6 +818,10 @@ lsyslog(LOG_INFO,"%s/%s: %ld Bytes, %ld BPS", shortname,protname(),zi.bytes_received, bps); #endif + if (dszlogpath) dszlog(dszlogpath, 'R', + zi.bytes_received, zi.fname, + bps, errors, 0, 0); + } } return OK; @@ -812,6 +831,13 @@ lsyslog(LOG_ERR,"%s/%s: got error", shortname ? shortname : "no.name", protname()); #endif + if (dszlogpath) { + double d = timing(0,NULL); + dszlog(dszlogpath, 'E', zi.bytes_received, zi.fname, + (zi.bytes_received-zi.bytes_skipped)/((d) ? d : 0.5), + errors, 0, 0); + } + canit(STDOUT_FILENO); if (Topipe && fout) { pclose(fout); return ERROR; @@ -1783,10 +1809,18 @@ rzfiles(struct zm_fileinfo *zi) { register int c; + long bps; for (;;) { timing(1,NULL); c = rzfile(zi); + { + double d; + d=timing(0,NULL); + if (d==0) + d=0.5; /* can happen if timing uses time() */ + bps=(zi->bytes_received-zi->bytes_skipped)/d; + } switch (c) { case ZEOF: if (Verbose > 1 @@ -1794,12 +1828,6 @@ || enable_syslog #endif ) { - double d; - long bps; - d=timing(0,NULL); - if (d==0) - d=0.5; /* can happen if timing uses time() */ - bps=(zi->bytes_received-zi->bytes_skipped)/d; if (Verbose > 1) { vstringf( _("\rBytes received: %7ld/%7ld BPS:%-6ld \r\n"), @@ -1807,6 +1835,8 @@ } DO_SYSLOG_FNAME((LOG_INFO, "%s/%s: %ld Bytes, %ld BPS",shortname, protname(), (long) zi->bytes_total,bps)); + if (dszlogpath) dszlog(dszlogpath, 'z', zi->bytes_received, + zi->fname, bps, errors, 0, 0); } /* FALL THROUGH */ case ZSKIP: @@ -1815,6 +1845,8 @@ if (Verbose) vstringf(_("Skipped")); DO_SYSLOG_FNAME((LOG_INFO, "%s/%s: skipped",shortname,protname())); + if (dszlogpath) dszlog(dszlogpath, 'E', zi->bytes_received, + zi->fname, bps, errors, 0, 0); } switch (tryz()) { case ZCOMPL: @@ -1829,6 +1861,8 @@ return c; case ERROR: DO_SYSLOG_FNAME((LOG_INFO, "%s/%s: error",shortname,protname())); + if (dszlogpath) dszlog(dszlogpath, 'E', zi->bytes_received, + zi->fname, bps, errors, 0, 0); return ERROR; } } diff -ur lrzsz-0.12.21/src/lsyslog.c newlrzsz/src/lsyslog.c --- lrzsz-0.12.21/src/lsyslog.c 1998-12-29 11:27:55.000000000 -0600 +++ newlrzsz/src/lsyslog.c 2003-08-21 16:47:53.000000000 -0500 @@ -26,6 +26,8 @@ #include #endif +#include + #if __STDC__ # include # define VA_START(args, lastarg) va_start(args, lastarg) @@ -79,3 +81,23 @@ #endif } +void dszlog(char *logname, char status, unsigned long num_bytes, char *fname, + int cps, int retry_events, int flow_events, int blocksize) { + + FILE *mylog; + if ((mylog = fopen(logname, "a"))) { + fprintf(mylog, "%c %6ld %5ld bps %4ld cps %3d errors %5u %4d %s %ld\r\n", + status, + num_bytes, + cps*8, /* XXX where to get DTE from? */ + cps, + retry_events, + flow_events, /* XXX where is flow_control? */ + blocksize, + fname, + -1 /* serial number */ + ); + fclose(mylog); + } +} + diff -ur lrzsz-0.12.21/src/lsz.c newlrzsz/src/lsz.c --- lrzsz-0.12.21/src/lsz.c 2003-08-21 16:22:01.000000000 -0500 +++ newlrzsz/src/lsz.c 2003-08-21 17:02:18.000000000 -0500 @@ -59,6 +59,8 @@ extern int errno; #endif +char *dszlogpath; + unsigned Baudrate=2400; /* Default, should be set by first mode() call */ unsigned Txwindow; /* Control the size of the transmitted window */ unsigned Txwspac; /* Spacing between zcrcq requests */ @@ -223,6 +225,9 @@ canit(STDOUT_FILENO); fflush (stdout); io_mode (io_mode_fd,0); + if (dszlogpath) { + dszlog(dszlogpath, 'L', 0, 0, 0, errors, 0, 0); + } if (n == 99) error (0, 0, _ ("io_mode(,2) in rbsb.c not implemented\n")); else @@ -332,6 +337,14 @@ } if ((cp=getenv("ZMODEM_RESTRICTED"))!=NULL) Restricted=1; + + dszlogpath = getenv("DSZLOG"); + if (access(dszlogpath, F_OK) == 0) { + if (unlink(dszlogpath) != 0) { + perror("unlink dszlog"); + } + } + from_cu(); chkinvok(argv[0]); @@ -1113,6 +1126,12 @@ if (enable_syslog) lsyslog(LOG_INFO, _("%s/%s: error occured"),protname(),shortname); #endif + if (dszlogpath) { + double d = timing(0,NULL); + dszlog(dszlogpath, 'E', zi.bytes_sent, zi.fname, + zi.bytes_sent/((d) ? d : 0.5), + errors, 0, blklen); + } return ERROR; case ZSKIP: error(0,0, _("skipped: %s"),name); @@ -1120,6 +1139,13 @@ if (enable_syslog) lsyslog(LOG_INFO, _("%s/%s: skipped"),protname(),shortname); #endif + if (dszlogpath) { + double d = timing(0,NULL); + /* XXX is Zmodem skip really deserving a 'E' ? */ + dszlog(dszlogpath, 'E', zi.bytes_sent, zi.fname, + zi.bytes_sent/((d) ? d : 0.5), + errors, 0, blklen); + } return OK; } if (!zmodem_requested && wctx(&zi)==ERROR) @@ -1128,12 +1154,18 @@ if (enable_syslog) lsyslog(LOG_INFO, _("%s/%s: error occured"),protname(),shortname); #endif + if (dszlogpath) { + double d = timing(0,NULL); + dszlog(dszlogpath, 'E', zi.bytes_sent, zi.fname, + zi.bytes_sent/((d) ? d : 0.5), + errors, 0, blklen); + } return ERROR; } if (Unlinkafter) unlink(oname); - if (Verbose > 1 + if (Verbose > 1 || dszlogpath #ifdef ENABLE_SYSLOG || enable_syslog #endif @@ -1152,6 +1184,11 @@ lsyslog(LOG_INFO, "%s/%s: %ld Bytes, %ld BPS",shortname, protname(), (long) zi.bytes_sent,bps); #endif + if (dszlogpath) { + char whichprot = (protocol==ZM_ZMODEM)? 'Z' : 'S'; + dszlog(dszlogpath, whichprot, zi.bytes_sent, + zi.fname, bps, errors, 0, blklen); + } } return 0; }