]> sjero.net Git - wget/blobdiff - src/ftp-ls.c
[svn] Use octal constants.
[wget] / src / ftp-ls.c
index 4eb39cf2badabd0558711c3014a6962036db52f5..bd3309c62004608553fb65b947ff407a898fae92 100644 (file)
@@ -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
          {
@@ -410,7 +411,7 @@ ftp_parse_winnt_ls (const char *file)
   FILE *fp;
   int len;
   int year, month, day;         /* for time analysis */
-  int hour, min, sec;
+  int hour, min;
   struct tm timestruct;
 
   char *line, *tok;             /* tokenizer */
@@ -450,22 +451,23 @@ ftp_parse_winnt_ls (const char *file)
       /* Assuming the epoch starting at 1.1.1970 */
       if (year <= 70) year += 100;
 
-      /* Second column: hh:mm[AP]M */
+      /* Second column: hh:mm[AP]M, listing does not contain value for
+         seconds */
       tok = strtok(NULL,  ":");
       hour = atoi(tok);
       tok = strtok(NULL,  "M");
       min = atoi(tok);
-      /* Adjust hour from AM/PM */
+      /* Adjust hour from AM/PM. Just for the record, the sequence goes
+         11:00AM, 12:00PM, 01:00PM ... 11:00PM, 12:00AM, 01:00AM . */
       tok+=2;
+      if (hour == 12)  hour  = 0;
       if (*tok == 'P') hour += 12;
-      /* Listing does not contain value for seconds */
-      sec = 0;
 
       DEBUGP(("YYYY/MM/DD HH:MM - %d/%02d/%02d %02d:%02d\n", 
               year+1900, month, day, hour, min));
       
       /* Build the time-stamp (copy & paste from above) */
-      timestruct.tm_sec   = sec;
+      timestruct.tm_sec   = 0;
       timestruct.tm_min   = min;
       timestruct.tm_hour  = hour;
       timestruct.tm_mday  = day;
@@ -488,14 +490,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));
        }
 
@@ -583,6 +585,7 @@ ftp_parse_vms_ls (const char *file)
   /* Line loop to end of file: */
   while ((line = read_whole_line (fp)))
     {
+      char *p;
       i = clean_line (line);
       if (!i) break;
 
@@ -669,13 +672,17 @@ ftp_parse_vms_ls (const char *file)
       year = atoi(tok)-1900;
       DEBUGP(("date parsed\n"));
 
-      /* Fourth/Third column: Time hh:mm:ss */
-      tok = strtok(NULL,  ":");
-      hour = atoi(tok);
-      tok = strtok(NULL,  ":");
-      min = atoi(tok);
-      tok = strtok(NULL,  " ");
-      sec = atoi(tok);
+      /* Fourth/Third column: Time hh:mm[:ss] */
+      tok = strtok (NULL, " ");
+      hour = min = sec = 0;
+      p = tok;
+      hour = atoi (p);
+      for (; *p && *p != ':'; ++p);
+      if (*p)
+       min = atoi (++p);
+      for (; *p && *p != ':'; ++p);
+      if (*p)
+       sec = atoi (++p);
 
       DEBUGP(("YYYY/MM/DD HH:MM:SS - %d/%02d/%02d %02d:%02d:%02d\n", 
               year+1900, month, day, hour, min, sec));