BSD 4_4 release
[unix-history] / usr / src / usr.bin / uucp / uucico / gio.c
index 84d1887..1f943bf 100644 (file)
@@ -1,6 +1,15 @@
+/*-
+ * Copyright (c) 1985, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)gio.c      5.4 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)gio.c      8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 #include "uucp.h"
 #include "pk.h"
 
 #include "uucp.h"
 #include "pk.h"
@@ -11,6 +20,8 @@ jmp_buf Failbuf;
 int Retries = 0;
 struct pack *Pk;
 
 int Retries = 0;
 struct pack *Pk;
 
+extern long Bytes_Sent, Bytes_Received;
+
 pkfail()
 {
        longjmp(Failbuf, 1);
 pkfail()
 {
        longjmp(Failbuf, 1);
@@ -92,6 +103,7 @@ FILE *fp1;
        struct timeb t1, t2;
        long bytes;
        char text[BUFSIZ];
        struct timeb t1, t2;
        long bytes;
        char text[BUFSIZ];
+       float ft;
 
        if(setjmp(Failbuf))
                return FAIL;
 
        if(setjmp(Failbuf))
                return FAIL;
@@ -126,13 +138,15 @@ FILE *fp1;
                --t2.time;
                mil += 1000;
        }
                --t2.time;
                mil += 1000;
        }
-       sprintf(text, "sent data %ld bytes %ld.%02d secs",
-                               bytes, (long)t2.time, mil/10);
-       sysacct(bytes, t2.time - t1.time);
+       ft = (float)t2.time + (float)mil/1000.;
+       sprintf(text, "sent data %ld bytes %.2f secs %ld bps",
+               bytes, ft, (long)((float)bytes*8./ft));
+       sysacct(bytes, t2.time);
+       Bytes_Sent += bytes;
        if (Retries > 0) 
                sprintf((char *)text+strlen(text)," %d retries", Retries);
        DEBUG(1, "%s\n", text);
        if (Retries > 0) 
                sprintf((char *)text+strlen(text)," %d retries", Retries);
        DEBUG(1, "%s\n", text);
-       syslog(text);
+       log_xferstats(text);
        return SUCCESS;
 }
 
        return SUCCESS;
 }
 
@@ -145,6 +159,7 @@ FILE *fp2;
        int mil;
        long bytes;
        char text[BUFSIZ];
        int mil;
        long bytes;
        char text[BUFSIZ];
+       float ft;
 
        if(setjmp(Failbuf))
                return FAIL;
 
        if(setjmp(Failbuf))
                return FAIL;
@@ -180,19 +195,23 @@ FILE *fp2;
                --t2.time;
                mil += 1000;
        }
                --t2.time;
                mil += 1000;
        }
-       sprintf(text, "received data %ld bytes %ld.%02d secs",
-                               bytes, (long)t2.time, mil/10);
-       sysacct(bytes, t2.time - t1.time);
+       ft = (float)t2.time + (float)mil/1000.;
+       sprintf(text, "received data %ld bytes %.2f secs %ld bps",
+               bytes, ft, (long)((float)bytes*8./ft));
+       sysacct(bytes, t2.time);
+       Bytes_Received += bytes;
        if (Retries > 0) 
                sprintf((char *)text+strlen(text)," %d retries", Retries);
        DEBUG(1, "%s\n", text);
        if (Retries > 0) 
                sprintf((char *)text+strlen(text)," %d retries", Retries);
        DEBUG(1, "%s\n", text);
-       syslog(text);
+       log_xferstats(text);
        return SUCCESS;
 }
 
        return SUCCESS;
 }
 
-/* call ultouch every TC calls to either grdblk or gwrblk -- rti!trt */
+#if !defined(BSD4_2) && !defined(USG)
+/* call ultouch every TC calls to either grdblk or gwrblk */
 #define        TC      20
 static int tc = TC;
 #define        TC      20
 static int tc = TC;
+#endif !BSD4_2 && !USG
 
 /*ARGSUSED*/
 grdblk(blk, len,  fn)
 
 /*ARGSUSED*/
 grdblk(blk, len,  fn)
@@ -201,11 +220,13 @@ char *blk;
 {
        register int i, ret;
 
 {
        register int i, ret;
 
+#if !defined(BSD4_2) && !defined(USG)
        /* call ultouch occasionally */
        if (--tc < 0) {
                tc = TC;
                ultouch();
        }
        /* call ultouch occasionally */
        if (--tc < 0) {
                tc = TC;
                ultouch();
        }
+#endif !BSD4_2 && !USG
        for (i = 0; i < len; i += ret) {
                ret = pkread(Pk, blk, len - i);
                if (ret < 0)
        for (i = 0; i < len; i += ret) {
                ret = pkread(Pk, blk, len - i);
                if (ret < 0)
@@ -221,13 +242,12 @@ char *blk;
 gwrblk(blk, len, fn)
 register char *blk;
 {
 gwrblk(blk, len, fn)
 register char *blk;
 {
-       register int ret;
-
-       /* call ultouch occasionally -- rti!trt */
+#if !defined(BSD4_2) && !defined(USG)
+       /* call ultouch occasionally */
        if (--tc < 0) {
                tc = TC;
                ultouch();
        }
        if (--tc < 0) {
                tc = TC;
                ultouch();
        }
-       ret = pkwrite(Pk, blk, len);
-       return ret;
+#endif !BSD4_2 && !USG
+       return  pkwrite(Pk, blk, len);
 }
 }