# HG changeset patch # User masneyb # Date 1087354622 0 # Node ID 7334a74db6f6f1f1cfff6aac60f502ed72355106 # Parent 632036c6e4a485d57cd568eb266b9cf67b9e9f97 2004-6-15 Brian Masney * lib/protocols.c - added supported for multiline VMS directory listings. Also, parse the date correctly for single line VMS directory listings * lib/gftp.h lib/local.c lib/rfc2068.c lib/rfc959.c lib/sshv.c - added function pointer get_next_dirlist_line to gftp_request structure. This will retrieve the next line of input for the directory listing. This is only implemented in the FTP protocol at the moment. It shouldn't be needed in the other protocols diff -r 632036c6e4a4 -r 7334a74db6f6 ChangeLog --- a/ChangeLog Wed Jun 16 00:59:07 2004 +0000 +++ b/ChangeLog Wed Jun 16 02:57:02 2004 +0000 @@ -1,4 +1,14 @@ 2004-6-15 Brian Masney + * lib/protocols.c - added supported for multiline VMS directory + listings. Also, parse the date correctly for single line VMS + directory listings + + * lib/gftp.h lib/local.c lib/rfc2068.c lib/rfc959.c lib/sshv.c - + added function pointer get_next_dirlist_line to gftp_request structure. + This will retrieve the next line of input for the directory listing. + This is only implemented in the FTP protocol at the moment. It shouldn't + be needed in the other protocols + * lib/gftp.h lib/sshv2.c src/gtk/gtkui.c src/text/textui.c - added support for RSA SecurID passwords @@ -2507,7 +2517,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.270 2004/06/16 00:59:07 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.271 2004/06/16 02:57:02 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 632036c6e4a4 -r 7334a74db6f6 lib/gftp.h --- a/lib/gftp.h Wed Jun 16 00:59:07 2004 +0000 +++ b/lib/gftp.h Wed Jun 16 02:57:02 2004 +0000 @@ -429,6 +429,10 @@ int (*get_next_file) ( gftp_request * request, gftp_file *fle, int fd ); + ssize_t (*get_next_dirlist_line) ( gftp_request * request, + int fd, + char *buf, + size_t buflen ); off_t (*get_file_size) ( gftp_request * request, const char *filename ); int (*chdir) ( gftp_request * request, @@ -941,7 +945,8 @@ int gftp_parse_ls ( gftp_request * request, const char *lsoutput, - gftp_file *fle ); + gftp_file *fle, + int fd ); int gftp_get_all_subdirs ( gftp_transfer * transfer, void (*update_func) diff -r 632036c6e4a4 -r 7334a74db6f6 lib/local.c --- a/lib/local.c Wed Jun 16 00:59:07 2004 +0000 +++ b/lib/local.c Wed Jun 16 02:57:02 2004 +0000 @@ -654,6 +654,7 @@ request->abort_transfer = local_end_transfer; /* NOTE: uses end_transfer */ request->list_files = local_list_files; request->get_next_file = local_get_next_file; + request->get_next_dirlist_line = NULL; request->get_file_size = local_get_file_size; request->chdir = local_chdir; request->rmdir = local_rmdir; diff -r 632036c6e4a4 -r 7334a74db6f6 lib/protocols.c --- a/lib/protocols.c Wed Jun 16 00:59:07 2004 +0000 +++ b/lib/protocols.c Wed Jun 16 02:57:02 2004 +0000 @@ -1169,6 +1169,36 @@ } +static time_t +parse_vms_time (char *str, char **endpos) +{ + struct tm curtime; + time_t ret; + + /* 8-JUN-2004 13:04:14 */ + memset (&curtime, 0, sizeof (curtime)); + + *endpos = strptime (str, "%d-%b-%Y %H:%M:%S", &curtime); + if (*endpos == NULL) + *endpos = strptime (str, "%d-%b-%Y %H:%M", &curtime); + + if (*endpos != NULL) + { + ret = mktime (&curtime); + for (; **endpos == ' ' || **endpos == '\t'; (*endpos)++); + } + else + { + ret = 0; + *endpos = goto_next_token (str); + if (*endpos != NULL) + *endpos = goto_next_token (*endpos); + } + + return (ret); +} + + time_t parse_time (char *str, char **endpos) { @@ -1278,44 +1308,68 @@ static int -gftp_parse_ls_vms (char *str, gftp_file * fle) +gftp_parse_ls_vms (gftp_request * request, int fd, char *str, gftp_file * fle) { - char *curpos, *endpos; + char *curpos, *endpos, tempstr[1024]; + int multiline; + ssize_t len; /* .PINE-DEBUG1;1 9 21-AUG-2002 20:06 [MYERSRG] (RWED,RWED,,) */ /* WWW.DIR;1 1 23-NOV-1999 05:47 [MYERSRG] (RWE,RWE,RE,E) */ + /* Multiline VMS + $MAIN.TPU$JOURNAL;1 + 1/18 8-JUN-2004 13:04:14 [NUCLEAR,FISSION] (RWED,RWED,RE,) + TCPIP$FTP_SERVER.LOG;29 + 0/18 8-JUN-2004 14:42:04 [NUCLEAR,FISSION] (RWED,RWED,RE,) + TCPIP$FTP_SERVER.LOG;28 + 5/18 8-JUN-2004 13:05:11 [NUCLEAR,FISSION] (RWED,RWED,RE,) + TCPIP$FTP_SERVER.LOG;27 + 5/18 8-JUN-2004 13:03:51 [NUCLEAR,FISSION] (RWED,RWED,RE,) */ + if ((curpos = strchr (str, ';')) == NULL) return (GFTP_EFATAL); + multiline = strchr (str, ' ') == NULL; + *curpos = '\0'; if (strlen (str) > 4 && strcmp (curpos - 4, ".DIR") == 0) { fle->isdir = 1; - fle->attribs = g_strdup ("drwxr-xr-x"); + fle->attribs = g_strdup ("d---------"); *(curpos - 4) = '\0'; } else - fle->attribs = g_strdup ("-rw-r--r--"); + fle->attribs = g_strdup ("----------"); fle->file = g_strdup (str); - curpos = goto_next_token (curpos + 1); + if (multiline) + { + if (request->get_next_dirlist_line == NULL) + return (GFTP_EFATAL); + + len = request->get_next_dirlist_line (request, fd, tempstr, + sizeof (tempstr)); + if (len <= 0) + return ((int) len); + + for (curpos = tempstr; *curpos == ' ' || *curpos == '\t'; curpos++); + } + else + curpos = goto_next_token (curpos + 1); + fle->size = gftp_parse_file_size (curpos) * 512; /* Is this correct? */ - curpos = goto_next_token (curpos); - - fle->datetime = parse_time (curpos, &curpos); curpos = goto_next_token (curpos); + fle->datetime = parse_vms_time (curpos, &curpos); + if (*curpos != '[') return (GFTP_EFATAL); - curpos++; + if ((endpos = strchr (curpos, ']')) == NULL) return (GFTP_EFATAL); - *endpos = '\0'; - fle->user = g_strdup (curpos); - fle->group = g_strdup (""); curpos = goto_next_token (endpos + 1); if ((curpos = strchr (curpos, ',')) == NULL) @@ -1326,6 +1380,9 @@ gftp_parse_vms_attribs (fle->attribs + 4, &curpos); gftp_parse_vms_attribs (fle->attribs + 7, &curpos); + fle->user = g_strdup (""); + fle->group = g_strdup (""); + return (0); } @@ -1619,7 +1676,8 @@ int -gftp_parse_ls (gftp_request * request, const char *lsoutput, gftp_file * fle) +gftp_parse_ls (gftp_request * request, const char *lsoutput, gftp_file * fle, + int fd) { char *str, *endpos, tmpchar; int result, is_vms; @@ -1653,7 +1711,7 @@ result = gftp_parse_ls_nt (str, fle); break; case GFTP_DIRTYPE_VMS: - result = gftp_parse_ls_vms (str, fle); + result = gftp_parse_ls_vms (request, fd, str, fle); break; case GFTP_DIRTYPE_MVS: result = gftp_parse_ls_mvs (str, fle); @@ -1680,7 +1738,7 @@ is_vms = 0; if (is_vms) - result = gftp_parse_ls_vms (str, fle); + result = gftp_parse_ls_vms (request, fd, str, fle); else result = gftp_parse_ls_unix (request, str, len, fle); } diff -r 632036c6e4a4 -r 7334a74db6f6 lib/rfc2068.c --- a/lib/rfc2068.c Wed Jun 16 00:59:07 2004 +0000 +++ b/lib/rfc2068.c Wed Jun 16 02:57:02 2004 +0000 @@ -922,6 +922,7 @@ request->abort_transfer = rfc2068_end_transfer; /* NOTE: uses end_transfer */ request->list_files = rfc2068_list_files; request->get_next_file = rfc2068_get_next_file; + request->get_next_dirlist_line = NULL; request->get_file_size = rfc2068_get_file_size; request->chdir = rfc2068_chdir; request->rmdir = NULL; diff -r 632036c6e4a4 -r 7334a74db6f6 lib/rfc959.c --- a/lib/rfc959.c Wed Jun 16 00:59:07 2004 +0000 +++ b/lib/rfc959.c Wed Jun 16 02:57:02 2004 +0000 @@ -1457,11 +1457,29 @@ } +static ssize_t +rfc959_get_next_dirlist_line (gftp_request * request, int fd, + char *buf, size_t buflen) +{ + ssize_t (*oldread_func) (gftp_request * request, void *ptr, size_t size, + int fd); + rfc959_parms * parms; + ssize_t len; + + parms = request->protocol_data; + + oldread_func = request->read_function; + request->read_function = parms->data_conn_read; + len = gftp_get_line (request, &parms->dataconn_rbuf, buf, buflen, fd); + request->read_function = oldread_func; + + return (len); +} + + int rfc959_get_next_file (gftp_request * request, gftp_file * fle, int fd) { - ssize_t (*oldread_func) (gftp_request * request, void *ptr, size_t size, - int fd); rfc959_parms * parms; char tempstr[1024]; ssize_t len; @@ -1483,19 +1501,15 @@ do { - oldread_func = request->read_function; - request->read_function = parms->data_conn_read; - len = gftp_get_line (request, &parms->dataconn_rbuf, tempstr, - sizeof (tempstr), fd); - request->read_function = oldread_func; - + len = rfc959_get_next_dirlist_line (request, fd, tempstr, + sizeof (tempstr)); if (len <= 0) { gftp_file_destroy (fle); return ((int) len); } - if (gftp_parse_ls (request, tempstr, fle) != 0) + if (gftp_parse_ls (request, tempstr, fle, fd) != 0) { if (strncmp (tempstr, "total", strlen ("total")) != 0 && strncmp (tempstr, _("total"), strlen (_("total"))) != 0) @@ -1797,6 +1811,7 @@ request->abort_transfer = rfc959_abort_transfer; request->list_files = rfc959_list_files; request->get_next_file = rfc959_get_next_file; + request->get_next_dirlist_line = rfc959_get_next_dirlist_line; request->get_file_size = rfc959_get_file_size; request->chdir = rfc959_chdir; request->rmdir = rfc959_rmdir; diff -r 632036c6e4a4 -r 7334a74db6f6 lib/sshv2.c --- a/lib/sshv2.c Wed Jun 16 00:59:07 2004 +0000 +++ b/lib/sshv2.c Wed Jun 16 02:57:02 2004 +0000 @@ -1301,7 +1301,7 @@ if (longname[longnamelen - 1] == '/') longname[--longnamelen] = '\0'; - if ((ret = gftp_parse_ls (request, longname, fle)) < 0) + if ((ret = gftp_parse_ls (request, longname, fle, 0)) < 0) { gftp_file_destroy (fle); return (ret); @@ -2286,6 +2286,7 @@ request->abort_transfer = sshv2_end_transfer; /* NOTE: uses sshv2_end_transfer */ request->list_files = sshv2_list_files; request->get_next_file = sshv2_get_next_file; + request->get_next_dirlist_line = NULL; request->get_file_size = sshv2_get_file_size; request->chdir = sshv2_chdir; request->rmdir = sshv2_rmdir;