]> sjero.net Git - wget/blobdiff - src/ftp.c
[svn] Support human-readable file size printing.
[wget] / src / ftp.c
index d2e031e731f8b3e863cbc25be01e978a0ba5663c..e138896c4dc4b40e83c2333bbbec871ba2b10a9e 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -220,6 +220,26 @@ ftp_do_port (int csock, int *local_sock)
 }
 #endif
 
+static void
+print_length (wgint size, wgint start, int authoritative)
+{
+  logprintf (LOG_VERBOSE, _("Length: %s"), with_thousand_seps (size));
+  if (size >= 1024)
+    logprintf (LOG_VERBOSE, " (%s)", human_readable (size));
+  if (start > 0)
+    {
+      if (start >= 1024)
+       logprintf (LOG_VERBOSE, _(", %s (%s) remaining"),
+                  with_thousand_seps (size - start),
+                  human_readable (size - start));
+      else
+       logprintf (LOG_VERBOSE, _(", %s remaining"),
+                  with_thousand_seps (size - start));
+    }
+  if (!authoritative)
+    logputs (LOG_VERBOSE, _(" (unauthoritative)\n"));
+}
+
 /* Retrieves a file with denoted parameters through opening an FTP
    connection to the server.  It always closes the data connection,
    and closes the control connection in case of error.  */
@@ -993,20 +1013,11 @@ Error in server response, closing control connection.\n"));
 
   if (*len)
     {
-      logprintf (LOG_VERBOSE, _("Length: %s"), legible (*len));
-      if (restval)
-       logprintf (LOG_VERBOSE, _(" [%s to go]"), legible (*len - restval));
-      logputs (LOG_VERBOSE, "\n");
+      print_length (*len, restval, 1);
       expected_bytes = *len;   /* for get_contents/show_progress */
     }
   else if (expected_bytes)
-    {
-      logprintf (LOG_VERBOSE, _("Length: %s"), legible (expected_bytes));
-      if (restval)
-       logprintf (LOG_VERBOSE, _(" [%s to go]"),
-                  legible (expected_bytes - restval));
-      logputs (LOG_VERBOSE, _(" (unauthoritative)\n"));
-    }
+    print_length (expected_bytes, restval, 0);
 
   /* Get the contents of the document.  */
   flags = 0;