17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #include "uucp.h"
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate int Retries;
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate Report and log file transfer rate statistics.
367c478bd9Sstevel@tonic-gate This is ugly because we are not using floating point.
377c478bd9Sstevel@tonic-gate */
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate void
statlog(direction,bytes,millisecs,breakmsg)407c478bd9Sstevel@tonic-gate statlog( direction, bytes, millisecs, breakmsg)
417c478bd9Sstevel@tonic-gate char *direction;
427c478bd9Sstevel@tonic-gate unsigned long bytes;
437c478bd9Sstevel@tonic-gate time_t millisecs;
447c478bd9Sstevel@tonic-gate char *breakmsg; /* "PARTIAL FILE" or "" */
457c478bd9Sstevel@tonic-gate {
467c478bd9Sstevel@tonic-gate char text[ 100 ];
477c478bd9Sstevel@tonic-gate unsigned long bytes1000;
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate /* bytes1000 = bytes * 1000; */
507c478bd9Sstevel@tonic-gate /* on fast machines, times(2) resolution may not be enough */
517c478bd9Sstevel@tonic-gate /* so millisecs may be zero. just use 1 as best guess */
527c478bd9Sstevel@tonic-gate if ( millisecs == 0 )
537c478bd9Sstevel@tonic-gate millisecs = 1;
54*2a8bcb4eSToomas Soome
55*2a8bcb4eSToomas Soome
567c478bd9Sstevel@tonic-gate if (bytes < 1<<22)
577c478bd9Sstevel@tonic-gate bytes1000 = (bytes*1000/millisecs);
587c478bd9Sstevel@tonic-gate else
597c478bd9Sstevel@tonic-gate bytes1000 = ((bytes/millisecs)*1000);
60*2a8bcb4eSToomas Soome
617c478bd9Sstevel@tonic-gate (void) sprintf(text, "%s %lu / %lu.%.3lu secs, %lu bytes/sec %s",
627c478bd9Sstevel@tonic-gate direction, bytes, millisecs/1000, millisecs%1000,
637c478bd9Sstevel@tonic-gate bytes1000, breakmsg );
647c478bd9Sstevel@tonic-gate if (Retries) {
657c478bd9Sstevel@tonic-gate sprintf(text + strlen(text), " %d retries", Retries);
667c478bd9Sstevel@tonic-gate Retries = 0;
677c478bd9Sstevel@tonic-gate }
687c478bd9Sstevel@tonic-gate /* bytes1000/millisecs, breakmsg ); */
697c478bd9Sstevel@tonic-gate CDEBUG(4, "%s\n", text);
707c478bd9Sstevel@tonic-gate usyslog(text);
717c478bd9Sstevel@tonic-gate return;
727c478bd9Sstevel@tonic-gate }
737c478bd9Sstevel@tonic-gate
74*2a8bcb4eSToomas Soome static unsigned long filesize; /* size of file been
757c478bd9Sstevel@tonic-gate transferred or received */
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate return the size of file been transferred or received
787c478bd9Sstevel@tonic-gate */
797c478bd9Sstevel@tonic-gate unsigned long
getfilesize()807c478bd9Sstevel@tonic-gate getfilesize()
817c478bd9Sstevel@tonic-gate {
827c478bd9Sstevel@tonic-gate return(filesize);
837c478bd9Sstevel@tonic-gate }
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate update the size of file been transferred or received
877c478bd9Sstevel@tonic-gate */
887c478bd9Sstevel@tonic-gate void
putfilesize(bytes)897c478bd9Sstevel@tonic-gate putfilesize(bytes)
907c478bd9Sstevel@tonic-gate unsigned long bytes;
917c478bd9Sstevel@tonic-gate {
927c478bd9Sstevel@tonic-gate filesize = bytes;
937c478bd9Sstevel@tonic-gate return;
947c478bd9Sstevel@tonic-gate }
95