]> sjero.net Git - wget/blobdiff - src/ftp-ls.c
[svn] Correct the conversion of month entries for NT and VMS.
[wget] / src / ftp-ls.c
index 338c1a4e27b3b270d3708e72342dbbd3d5b1c25a..28fcf9c2913e197bb0f3c90dd3d9b2965b4040d4 100644 (file)
@@ -146,7 +146,7 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
          break;
        default:
          cur.type = FT_UNKNOWN;
-         DEBUGP (("UNKOWN; "));
+         DEBUGP (("UNKNOWN; "));
          break;
        }
 
@@ -155,15 +155,16 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
          switch (cur.type)
            {
            case FT_PLAINFILE:
-             cur.perms = 420;
+             cur.perms = 0644;
              break;
            case FT_DIRECTORY:
-             cur.perms = 493;
+             cur.perms = 0755;
              break;
            default:
-             cur.perms = 1023;
+             /*cur.perms = 1023;*/     /* #### What is this?  --hniksic */
+             cur.perms = 0644;
            }
-         DEBUGP (("implicite perms %0o; ", cur.perms));
+         DEBUGP (("implicit perms %0o; ", cur.perms));
        }
        else
          {
@@ -440,9 +441,11 @@ ftp_parse_winnt_ls (const char *file)
       cur.name = xstrdup(tok);
       DEBUGP(("Name: '%s'\n", cur.name));
 
-      /* First column: mm-dd-yy */
+      /* First column: mm-dd-yy. Should atoi() on the month fail, january
+        will be assumed.  */
       tok = strtok(line, "-");
-      month = atoi(tok);
+      month = atoi(tok) - 1;
+      if (month < 0) month = 0;
       tok = strtok(NULL, "-");
       day = atoi(tok);
       tok = strtok(NULL, " ");
@@ -489,14 +492,14 @@ ftp_parse_winnt_ls (const char *file)
        {
          cur.type  = FT_DIRECTORY;
          cur.size  = 0;
-         cur.perms = 493; /* my gcc does not like 0755 ?? */
+         cur.perms = 0755;
          DEBUGP(("Directory\n"));
        }
       else
        {
          cur.type  = FT_PLAINFILE;
          cur.size  = atoi(tok);
-         cur.perms = 420; /* 0664 octal */
+         cur.perms = 0644;
          DEBUGP(("File, size %ld bytes\n", cur.size));
        }
 
@@ -563,7 +566,7 @@ ftp_parse_vms_ls (const char *file)
   int hour, min, sec;
   struct tm timestruct;
 
-  char *line, *tok, *p;          /* tokenizer */
+  char *line, *tok;             /* tokenizer */
   struct fileinfo *dir, *l, cur; /* list creation */
 
   fp = fopen (file, "rb");
@@ -666,9 +669,9 @@ ftp_parse_vms_ls (const char *file)
       }
       for (i=0; i<12; i++) if (!strcmp(tok,months[i])) break;
       /* Uknown months are mapped to January */
-      month = (i%12)+1
-      tok = strtok(NULL, " ");
-      year = atoi(tok)-1900;
+      month = i % 12 
+      tok = strtok (NULL, " ");
+      year = atoi (tok) - 1900;
       DEBUGP(("date parsed\n"));
 
       /* Fourth/Third column: Time hh:mm[:ss] */
@@ -814,8 +817,8 @@ ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
     {
       char *tmpu, *tmpp;        /* temporary, clean user and passwd */
 
-      tmpu = CLEANDUP (u->user);
-      tmpp = u->passwd ? CLEANDUP (u->passwd) : NULL;
+      tmpu = encode_string (u->user);
+      tmpp = u->passwd ? encode_string (u->passwd) : NULL;
       upwd = (char *)xmalloc (strlen (tmpu)
                             + (tmpp ? (1 + strlen (tmpp)) : 0) + 2);
       sprintf (upwd, "%s%s%s@", tmpu, tmpp ? ":" : "", tmpp ? tmpp : "");