changeset 120:05f50c1761d9 noffle

[svn] Applied patch from Matija Nalis: Counters for monitoring --fetch progress.
author enz
date Wed, 19 Jul 2000 08:02:45 +0100
parents f50cc311e29a
children a0a96e1021c3
files ChangeLog src/client.c src/client.h src/fetch.c
diffstat 4 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 30 08:10:45 2000 +0100
+++ b/ChangeLog	Wed Jul 19 08:02:45 2000 +0100
@@ -2,6 +2,16 @@
 NOFFLE ChangeLog
 -------------------------------------------------------------------------------
 
+Fri Jul 14 2000 Matija Nalis <mnalis-sf@voyager.hr>
+
+ * Added counter for --fetch so one can see how much it is until the
+   end of the transfer.
+
+Fri Jul 14 2000 Matija Nalis <mnalis-sf@voyager.hr>
+
+ * Added counter for --fetch so one can see how much it is until the
+   end of the transfer.
+
 Fri Jun 30 2000 Markus Enzenberger <markus.enzenberger@t-online.de>
 
   * src/server.c: Leave online mode, if the connection to a remote server
--- a/src/client.c	Fri Jun 30 08:10:45 2000 +0100
+++ b/src/client.c	Wed Jul 19 08:02:45 2000 +0100
@@ -1,7 +1,7 @@
 /*
   client.c
 
-  $Id: client.c 156 2000-06-24 20:29:52Z bears $
+  $Id: client.c 174 2000-07-19 07:02:45Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -957,13 +957,13 @@
 }
 
 static Bool
-retrieveAndStoreArt( const char *msgId )
+retrieveAndStoreArt( const char *msgId, int artcnt, int artmax )
 {
     Bool err;
     DynStr *s = NULL;
     Str line;
 
-    Log_inf( "Retrieving %s", msgId );
+    Log_inf( "[%d/%d] Retrieving %s", artcnt, artmax, msgId );
     s = new_DynStr( 5000 );
     while ( getTxtLn( line, &err ) && ! err )
         DynStr_appLn( s, line );
@@ -1015,11 +1015,11 @@
     else if ( getStat() != STAT_ART_FOLLOWS )
         retrievingFailed( msgId, client.lastStat );
     else
-        retrieveAndStoreArt( msgId );
+        retrieveAndStoreArt( msgId, 0, 0 );
 }
 
 void
-Client_retrieveArtList( const char *list )
+Client_retrieveArtList( const char *list, int *artcnt, int artmax )
 {
     Str msgId;
     DynStr *s;
@@ -1049,7 +1049,7 @@
     {
         if ( getStat() != STAT_ART_FOLLOWS )
             retrievingFailed( msgId, client.lastStat );
-        else if ( ! retrieveAndStoreArt( msgId ) )
+        else if ( ! retrieveAndStoreArt( msgId, ++(*artcnt), artmax ) )
             break;
     }
     del_DynStr( s );
--- a/src/client.h	Fri Jun 30 08:10:45 2000 +0100
+++ b/src/client.h	Wed Jul 19 08:02:45 2000 +0100
@@ -3,7 +3,7 @@
 
   Noffle acting as client to other NNTP-servers
 
-  $Id: client.h 60 2000-05-09 22:28:38Z uh1763 $
+  $Id: client.h 174 2000-07-19 07:02:45Z enz $
 */
 
 #ifndef CLIENT_H
@@ -73,7 +73,7 @@
   All ARTICLE commands are sent and then all answers read.
 */
 void
-Client_retrieveArtList( const char *list );
+Client_retrieveArtList( const char *list, int *artcnt, int artmax );
 
 /*
   Store IDs of first and last article of group selected by
--- a/src/fetch.c	Fri Jun 30 08:10:45 2000 +0100
+++ b/src/fetch.c	Wed Jul 19 08:02:45 2000 +0100
@@ -1,7 +1,7 @@
 /*
   fetch.c
 
-  $Id: fetch.c 135 2000-06-05 08:57:05Z bears $
+  $Id: fetch.c 174 2000-07-19 07:02:45Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -153,11 +153,13 @@
     Str msgId;
     DynStr *list;
     const char *p;
-    int count = 0;
+    int count = 0, artcnt = 0, artmax = 0;
 
     ASSERT( fetch.ready );
     Log_dbg( "Retrieving articles marked for download" );
     list = new_DynStr( 10000 );
+    if ( Req_first( fetch.serv, msgId ) ) do { artmax++; } while ( Req_next( msgId ) );
+    Log_inf( "%d TOTAL messages to download", artmax);
     if ( Req_first( fetch.serv, msgId ) )
         do
         {
@@ -165,7 +167,7 @@
             if ( ++count % 20 == 0 ) /* Send max. 20 ARTICLE cmds at once */
             {
                 p = DynStr_str( list );
-                Client_retrieveArtList( p );
+                Client_retrieveArtList( p, &artcnt, artmax );
                 while ( ( p = Utl_getLn( msgId, p ) ) )
                     Req_remove( fetch.serv, msgId );
                 DynStr_clear( list );
@@ -173,7 +175,7 @@
         }
         while ( Req_next( msgId ) );
     p = DynStr_str( list );
-    Client_retrieveArtList( p );
+    Client_retrieveArtList( p, &artcnt, artmax );
     while ( ( p = Utl_getLn( msgId, p ) ) )
         Req_remove( fetch.serv, msgId );
     del_DynStr( list );