Sanity check s2length on recept.
[rsync/rsync.git] / progress.c
index 004b5d1..083b6df 100644 (file)
@@ -1,3 +1,24 @@
+/*  -*- c-file-style: "linux" -*-
+ * 
+ * Copyright (C) 1996-2000 by Andrew Tridgell 
+ * Copyright (C) Paul Mackerras 1996
+ * Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
 #include "rsync.h"
 
 static OFF_T  last_ofs;
@@ -58,39 +79,43 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
 
 void end_progress(OFF_T size)
 {
-       extern int do_progress, am_server;
+       extern int am_server;
 
-       if (do_progress && !am_server) {
-               struct timeval now;
-                gettimeofday(&now, NULL);
-                rprint_progress(size, size, &now, True);
+       if (!am_server) {
+               struct timeval now;
+               gettimeofday(&now, NULL);
+               rprint_progress(size, size, &now, True);
        }
        last_ofs   = 0;
-        start_ofs  = 0;
-        print_time.tv_sec  = print_time.tv_usec  = 0;
-        start_time.tv_sec  = start_time.tv_usec  = 0;
+       start_ofs  = 0;
+       print_time.tv_sec  = print_time.tv_usec  = 0;
+       start_time.tv_sec  = start_time.tv_usec  = 0;
 }
 
 void show_progress(OFF_T ofs, OFF_T size)
 {
-       extern int do_progress, am_server;
-        struct timeval now;
-
-        gettimeofday(&now, NULL);
+       extern int am_server;
+       struct timeval now;
 
-        if (!start_time.tv_sec && !start_time.tv_usec) {
-               start_time.tv_sec  = now.tv_sec;
-                start_time.tv_usec = now.tv_usec;
-                start_ofs          = ofs;
-        }
+       if (!start_time.tv_sec) {
+               gettimeofday(&now, NULL);
+               start_time.tv_sec  = now.tv_sec;
+               start_time.tv_usec = now.tv_usec;
+               start_ofs          = ofs;
+               if (am_server)
+                       return;
+       }
+       else {
+               if (am_server)
+                       return;
+               gettimeofday(&now, NULL);
+       }
 
-       if (do_progress
-            && !am_server
-            && ofs > last_ofs + 1000
-            && msdiff(&print_time, &now) > 250) {
-               rprint_progress(ofs, size, &now, False);
-                last_ofs = ofs;
-                print_time.tv_sec  = now.tv_sec;
-                print_time.tv_usec = now.tv_usec;
+       if (ofs > last_ofs + 1000
+        && msdiff(&print_time, &now) > 250) {
+               rprint_progress(ofs, size, &now, False);
+               last_ofs = ofs;
+               print_time.tv_sec  = now.tv_sec;
+               print_time.tv_usec = now.tv_usec;
        }
 }