]> sjero.net Git - wget/blobdiff - src/ftp.c
[svn] * *.{gmo,po,pot}: Regenerated after modifying wget --help output.
[wget] / src / ftp.c
index a5473916650b93877d5ce7fbfc61e125f8cbf69e..da37ee77e9fd8057187ac0babc6e496ebf4f2af3 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -90,7 +90,7 @@ ftp_expected_bytes (const char *s)
        ++s;
       if (!*s)
        return 0;
-      if (tolower (*s) != 'b')
+      if (TOLOWER (*s) != 'b')
        continue;
       if (strncasecmp (s, "byte", 4))
        continue;
@@ -243,8 +243,8 @@ Error in server response, closing control connection.\n"));
        }
       /* Third: Set type to Image (binary).  */
       if (!opt.server_response)
-       logprintf (LOG_VERBOSE, "==> TYPE %c ... ", toupper (u->ftp_type));
-      err = ftp_type (&con->rbuf, toupper (u->ftp_type));
+       logprintf (LOG_VERBOSE, "==> TYPE %c ... ", TOUPPER (u->ftp_type));
+      err = ftp_type (&con->rbuf, TOUPPER (u->ftp_type));
       /* FTPRERR, WRITEFAILED, FTPUNKNOWNTYPE */
       switch (err)
        {
@@ -268,7 +268,7 @@ Error in server response, closing control connection.\n"));
          logputs (LOG_VERBOSE, "\n");
          logprintf (LOG_NOTQUIET,
                     _("Unknown type `%c', closing control connection.\n"),
-                    toupper (u->ftp_type));
+                    TOUPPER (u->ftp_type));
          CLOSE (csock);
          rbuf_uninitialize (&con->rbuf);
          return err;
@@ -711,10 +711,18 @@ Error in server response, closing control connection.\n"));
   /* Close data connection socket.  */
   closeport (dtsock);
   /* Close the local file.  */
-  if (!opt.dfp || con->cmd & DO_LIST)
-    fclose (fp);
-  else
-    fflush (fp);
+  {
+    /* Close or flush the file.  We have to be careful to check for
+       error here.  Checking the result of fwrite() is not enough --
+       errors could go unnoticed!  */
+    int flush_res;
+    if (!opt.dfp || con->cmd & DO_LIST)
+      flush_res = fclose (fp);
+    else
+      flush_res = fflush (fp);
+    if (flush_res == EOF)
+      res = -2;
+  }
   /* If get_contents couldn't write to fp, bail out.  */
   if (res == -2)
     {
@@ -1060,7 +1068,7 @@ ftp_retrieve_list (struct urlinfo *u, struct fileinfo *f, ccon *con)
 
   /* Increase the depth.  */
   ++depth;
-  if (opt.reclevel && depth > opt.reclevel)
+  if (opt.reclevel != INFINITE_RECURSION && depth > opt.reclevel)
     {
       DEBUGP ((_("Recursion depth %d exceeded max. depth %d.\n"),
               depth, opt.reclevel));
@@ -1213,7 +1221,7 @@ Already have correct symlink %s -> %s\n\n"),
       else if (f->tstamp == -1)
        logprintf (LOG_NOTQUIET, _("%s: corrupt time-stamp.\n"), u->local);
 
-      if (f->perms && dlthis)
+      if (f->perms && f->type == FT_PLAINFILE && dlthis)
        chmod (u->local, f->perms);
       else
        DEBUGP (("Unrecognized permissions for %s.\n", u->local));
@@ -1228,7 +1236,8 @@ Already have correct symlink %s -> %s\n\n"),
       f = f->next;
     } /* while */
   /* We do not want to call ftp_retrieve_dirs here */
-  if (opt.recursive && !(opt.reclevel && depth >= opt.reclevel))
+  if (opt.recursive &&
+      !(opt.reclevel != INFINITE_RECURSION && depth >= opt.reclevel))
     err = ftp_retrieve_dirs (u, orig, con);
   else if (opt.recursive)
     DEBUGP ((_("Will not retrieve dirs since depth is %d (max %d).\n"),