changeset 358:28a50fb598ed

2003-1-6 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/protocols.c lib/rfc959.c - added MVS directory parsing support. Also, in the VMS and EPLF directory formats, update the default file/directory perms to be -rw-r--r-- and drwx-r-xr-x respectively.
author masneyb
date Wed, 07 Jan 2004 11:45:01 +0000
parents d44a1b128fed
children 52c5ee1fa455
files ChangeLog lib/gftp.h lib/protocols.c lib/rfc959.c
diffstat 4 files changed, 89 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jan 06 16:31:22 2004 +0000
+++ b/ChangeLog	Wed Jan 07 11:45:01 2004 +0000
@@ -1,3 +1,9 @@
+2003-1-6 Brian Masney <masneyb@gftp.org>
+	* lib/gftp.h lib/protocols.c lib/rfc959.c - added MVS directory parsing
+	support. Also, in the VMS and EPLF directory formats, update the
+	default file/directory perms to be -rw-r--r-- and drwx-r-xr-x
+	respectively.
+
 2003-1-5 Brian Masney <masneyb@gftp.org>
 	* lib/gftp.h lib/misc.c src/gtk/gftpui.c - added GFTP_URL_USAGE
 	that is the sytax for a valid URL.
@@ -1953,7 +1959,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.197 2004/01/06 02:41:34 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.198 2004/01/07 11:44:59 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Tue Jan 06 16:31:22 2004 +0000
+++ b/lib/gftp.h	Wed Jan 07 11:45:01 2004 +0000
@@ -152,6 +152,7 @@
 #define GFTP_DIRTYPE_DOS	5	
 #define GFTP_DIRTYPE_VMS	6	
 #define GFTP_DIRTYPE_OTHER 	7
+#define GFTP_DIRTYPE_MVS	8
 
 /* Error types */
 #define GFTP_ERETRYABLE		-1		/* Temporary failure. The GUI
--- a/lib/protocols.c	Tue Jan 06 16:31:22 2004 +0000
+++ b/lib/protocols.c	Wed Jan 07 11:45:01 2004 +0000
@@ -1157,6 +1157,11 @@
       /* 10-Jan-2003 09:14 */
       tmppos = strptime (str, "%d-%h-%Y %H:%M", &curtime);
     }
+  else if (strlen (str) > 4 && isdigit ((int) str[0]) && str[4] == '/')
+    {
+      /* 2003/12/25 */
+      tmppos = strptime (str, "%Y/%m/%d", &curtime);
+    }
   else
     {
       /* This is how most UNIX, Novell, and MacOS ftp servers send their time */
@@ -1241,13 +1246,14 @@
     return (GFTP_EFATAL);
 
   *curpos = '\0';
-  fle->attribs = g_strdup ("----------");
   if (strlen (str) > 4 && strcmp (curpos - 4, ".DIR") == 0)
     {
       fle->isdir = 1;
-      *fle->attribs = 'd';
+      fle->attribs = g_strdup ("drwxr-xr-x");
       *(curpos - 4) = '\0';
     }
+  else
+   fle->attribs = g_strdup ("-rw-r--r--");
 
   fle->file = g_strdup (str);
 
@@ -1280,22 +1286,81 @@
 
   return (0);
 }
+
+
+static int
+gftp_parse_ls_mvs (char *str, gftp_file * fle)
+{
+  char *curpos;
+
+  /* Volume Unit    Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname */
+  /* SVI52A 3390   2003/12/10  8  216  FB      80 27920  PS  CARDS.DELETES */
+  /* SVI528 3390   2003/12/12  1    5  FB      80 24000  PO  CLIST */
+
+  curpos = goto_next_token (str + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  curpos = goto_next_token (curpos + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  if ((fle->datetime = parse_time (curpos, &curpos)) == 0)
+    return (GFTP_EFATAL);
+  curpos = goto_next_token (curpos);
+
+  curpos = goto_next_token (curpos + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  fle->size = gftp_parse_file_size (curpos) * 55996; 
+  curpos = goto_next_token (curpos + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  curpos = goto_next_token (curpos + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  curpos = goto_next_token (curpos + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  curpos = goto_next_token (curpos + 1);
+  if (curpos == NULL)
+    return (GFTP_EFATAL);
+
+  if (strncmp (curpos, "PS", 2) == 0)
+    fle->attribs = g_strdup ("-rw-r--r--");
+  else if (strncmp (curpos, "PO", 2) == 0)
+    fle->attribs = g_strdup ("drwxr-xr-x");
+  else
+    return (GFTP_EFATAL);
+
+  curpos = goto_next_token (curpos + 1);
+
+  fle->user = g_strdup (_("unknown"));
+  fle->group = g_strdup (_("unknown"));
+  fle->file = g_strdup (curpos);
+
+  return (0);
+}
   
 
 static int
 gftp_parse_ls_eplf (char *str, gftp_file * fle)
 {
   char *startpos;
+  int isdir = 0;
 
   startpos = str;
-  fle->attribs = g_strdup ("----------");
   while (startpos)
     {
       startpos++;
       switch (*startpos)
         {
         case '/':
-          *fle->attribs = 'd';
+          isdir = 1;
           break;
         case 's':
           fle->size = gftp_parse_file_size (startpos + 1);
@@ -1306,8 +1371,15 @@
         }
       startpos = strchr (startpos, ',');
     }
+
   if ((startpos = strchr (str, 9)) == NULL)
     return (GFTP_EFATAL);
+
+  if (isdir)
+    fle->attribs = g_strdup ("drwxr-xr-x");
+  else
+    fle->attribs = g_strdup ("-rw-r--r--");
+
   fle->file = g_strdup (startpos + 1);
   fle->user = g_strdup (_("unknown"));
   fle->group = g_strdup (_("unknown"));
@@ -1541,6 +1613,9 @@
       case GFTP_DIRTYPE_VMS:
         result = gftp_parse_ls_vms (str, fle);
         break;
+      case GFTP_DIRTYPE_MVS:
+        result = gftp_parse_ls_mvs (str, fle);
+        break;
       default: /* autodetect */
         if (*lsoutput == '+')
           result = gftp_parse_ls_eplf (str, fle);
--- a/lib/rfc959.c	Tue Jan 06 16:31:22 2004 +0000
+++ b/lib/rfc959.c	Wed Jan 07 11:45:01 2004 +0000
@@ -420,6 +420,8 @@
     request->server_type = GFTP_DIRTYPE_UNIX;
   else if (strcmp (stpos, "VMS") == 0)
     request->server_type = GFTP_DIRTYPE_VMS;
+  else if (strcmp (stpos, "MVS") == 0)
+    request->server_type = GFTP_DIRTYPE_MVS;
   else if (strcmp (stpos, "NETWARE") == 0)
     request->server_type = GFTP_DIRTYPE_NOVELL;
   else if (strcmp (stpos, "CRAY") == 0)