]> sjero.net Git - wget/blobdiff - src/ftp.c
[svn] Update copyright blurbs with the year 2000.
[wget] / src / ftp.c
index ab70114b33220b00005bc22e428d730bbeed8005..4c26cf7d30914b20609c79ca9d9933bb5a315624 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1,5 +1,5 @@
 /* File Transfer Protocol support.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
 
 This file is part of Wget.
 
@@ -648,6 +648,15 @@ Error in server response, closing control connection.\n"));
       expected_bytes = ftp_expected_bytes (ftp_last_respline);
     } /* cmd & DO_LIST */
 
+  /* Some FTP servers return the total length of file after REST
+     command, others just return the remaining size. */
+  if (*len && restval && expected_bytes
+      && (expected_bytes == *len - restval))
+    {
+      DEBUGP (("Lying FTP server found, adjusting.\n"));
+      expected_bytes = *len;
+    }
+
   /* If no transmission was required, then everything is OK.  */
   if (!(cmd & (DO_LIST | DO_RETR)))
     return RETRFINISHED;
@@ -685,16 +694,16 @@ Error in server response, closing control connection.\n"));
        }
     }
   else
-    fp = opt.dfp;
-  
-  /* Some FTP servers return the total length of file after REST command,
-     others just return the remaining size. */  
-  if (*len && restval && expected_bytes
-      && (expected_bytes == *len - restval))
-  {
-    DEBUGP (("Lying FTP server found, adjusting.\n"));
-    expected_bytes = *len;
-  }
+    {
+      fp = opt.dfp;
+      if (!restval)
+       {
+         /* This will silently fail for streams that don't correspond
+            to regular files, but that's OK.  */
+         rewind (fp);
+         clearerr (fp);
+       }
+    }
 
   if (*len)
     {
@@ -987,8 +996,16 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
        }
       logprintf (LOG_VERBOSE, _("%s (%s) - `%s' saved [%ld]\n\n"),
                 tms, tmrate, locf, len);
-      logprintf (LOG_NONVERBOSE, "%s URL: %s [%ld] -> \"%s\" [%d]\n",
-                tms, u->url, len, locf, count);
+      if (!opt.verbose && !opt.quiet)
+       {
+         /* Need to hide the password from the URL.  The `if' is here
+             so that we don't do the needless allocation every
+             time. */
+         char *hurl = str_url (u->proxy ? u->proxy : u, 1);
+         logprintf (LOG_NONVERBOSE, "%s URL: %s [%ld] -> \"%s\" [%d]\n",
+                    tms, hurl, len, locf, count);
+         free (hurl);
+       }
 
       if ((con->cmd & DO_LIST))
        /* This is a directory listing file. */
@@ -997,7 +1014,7 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
            /* --dont-remove-listing was specified, so do count this towards the
               number of bytes and files downloaded. */
            {
-             opt.downloaded += len;
+             downloaded_increase (len);
              opt.numurls++;
            }
 
@@ -1012,7 +1029,7 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
             downloaded if they're going to be deleted.  People seeding proxies,
             for instance, may want to know how many bytes and files they've
             downloaded through it. */
-         opt.downloaded += len;
+         downloaded_increase (len);
          opt.numurls++;
 
          if (opt.delete_after)
@@ -1133,7 +1150,7 @@ ftp_retrieve_list (struct urlinfo *u, struct fileinfo *f, ccon *con)
 
   while (f)
     {
-      if (opt.quota && opt.downloaded > opt.quota)
+      if (downloaded_exceeds_quota ())
        {
          --depth;
          return QUOTEXC;
@@ -1299,7 +1316,7 @@ ftp_retrieve_dirs (struct urlinfo *u, struct fileinfo *f, ccon *con)
     {
       int len;
 
-      if (opt.quota && opt.downloaded > opt.quota)
+      if (downloaded_exceeds_quota ())
        break;
       if (f->type != FT_DIRECTORY)
        continue;
@@ -1420,7 +1437,7 @@ ftp_retrieve_glob (struct urlinfo *u, ccon *con, int action)
        }
     }
   freefileinfo (start);
-  if (opt.quota && opt.downloaded > opt.quota)
+  if (downloaded_exceeds_quota ())
     return QUOTEXC;
   else
     /* #### Should we return `res' here?  */