annotate lib/parse-dir-listing.c @ 969:e95ae20ddf0e

2008-11-30 Brian Masney <masneyb@gftp.org> * lib/ftps.c - warning fixes for the FTPS protocol when OpenSSL support is disabled.
author masneyb
date Sun, 30 Nov 2008 14:41:36 +0000
parents c7d7a081cd9c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
950
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1 /*****************************************************************************/
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
2 /* parse-dir-listing.c - contains functions for parsing the different types */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
3 /* of directory listings. */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
4 /* Copyright (C) 1998-2008 Brian Masney <masneyb@gftp.org> */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
5 /* */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
6 /* This program is free software; you can redistribute it and/or modify */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
7 /* it under the terms of the GNU General Public License as published by */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
8 /* the Free Software Foundation; either version 2 of the License, or */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
9 /* (at your option) any later version. */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
10 /* */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
11 /* This program is distributed in the hope that it will be useful, */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
14 /* GNU General Public License for more details. */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
15 /* */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
16 /* You should have received a copy of the GNU General Public License */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
17 /* along with this program; if not, write to the Free Software */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
18 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
19 /*****************************************************************************/
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
20
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
21 #include "gftp.h"
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
22 static const char cvsid[] = "$Id: protocols.c 952 2008-01-24 23:31:26Z masneyb $";
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
23
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
24 static char *
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
25 copy_token (/*@out@*/ char **dest, char *source)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
26 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
27 char *endpos, savepos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
28
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
29 endpos = source;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
30 while (*endpos != ' ' && *endpos != '\t' && *endpos != '\0')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
31 endpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
32 if (*endpos == '\0')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
33 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
34 *dest = NULL;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
35 return (NULL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
36 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
37
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
38 savepos = *endpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
39 *endpos = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
40 *dest = g_malloc0 ((gulong) (endpos - source + 1));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
41 strcpy (*dest, source);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
42 *endpos = savepos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
43
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
44 /* Skip the blanks till we get to the next entry */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
45 source = endpos + 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
46 while ((*source == ' ' || *source == '\t') && *source != '\0')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
47 source++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
48 return (source);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
49 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
50
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
51
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
52 static char *
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
53 goto_next_token (char *pos)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
54 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
55 while (*pos != ' ' && *pos != '\t' && *pos != '\0')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
56 pos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
57
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
58 while (*pos == ' ' || *pos == '\t')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
59 pos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
60
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
61 return (pos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
62 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
63
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
64
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
65 static time_t
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
66 parse_vms_time (char *str, char **endpos)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
67 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
68 struct tm curtime;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
69 time_t ret;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
70
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
71 /* 8-JUN-2004 13:04:14 */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
72 memset (&curtime, 0, sizeof (curtime));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
73
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
74 *endpos = strptime (str, "%d-%b-%Y %H:%M:%S", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
75 if (*endpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
76 *endpos = strptime (str, "%d-%b-%Y %H:%M", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
77
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
78 if (*endpos != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
79 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
80 ret = mktime (&curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
81 for (; **endpos == ' ' || **endpos == '\t'; (*endpos)++);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
82 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
83 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
84 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
85 ret = 0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
86 *endpos = goto_next_token (str);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
87 if (*endpos != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
88 *endpos = goto_next_token (*endpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
89 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
90
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
91 return (ret);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
92 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
93
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
94
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
95 time_t
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
96 parse_time (char *str, char **endpos)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
97 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
98 struct tm curtime, *loctime;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
99 time_t t, ret;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
100 char *tmppos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
101 size_t slen;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
102 int i, num;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
103
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
104 slen = strlen (str);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
105 memset (&curtime, 0, sizeof (curtime));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
106 curtime.tm_isdst = -1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
107
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
108 if (slen > 4 && isdigit ((int) str[0]) && str[2] == '-' &&
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
109 isdigit ((int) str[3]))
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
110 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
111 /* This is how DOS will return the date/time */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
112 /* 07-06-99 12:57PM */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
113
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
114 tmppos = strptime (str, "%m-%d-%y %I:%M%p", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
115 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
116 else if (slen > 4 && isdigit ((int) str[0]) && str[2] == '-' &&
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
117 isalpha (str[3]))
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
118 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
119 /* 10-Jan-2003 09:14 */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
120 tmppos = strptime (str, "%d-%h-%Y %H:%M", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
121 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
122 else if (slen > 4 && isdigit ((int) str[0]) && str[4] == '/')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
123 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
124 /* 2003/12/25 */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
125 tmppos = strptime (str, "%Y/%m/%d", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
126 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
127 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
128 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
129 /* This is how most UNIX, Novell, and MacOS ftp servers send their time */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
130 /* Jul 06 12:57 or Jul 6 1999 */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
131
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
132 if (strchr (str, ':') != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
133 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
134 tmppos = strptime (str, "%h %d %H:%M", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
135 t = time (NULL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
136 loctime = localtime (&t);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
137
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
138 if (curtime.tm_mon > loctime->tm_mon)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
139 curtime.tm_year = loctime->tm_year - 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
140 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
141 curtime.tm_year = loctime->tm_year;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
142 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
143 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
144 tmppos = strptime (str, "%h %d %Y", &curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
145 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
146
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
147 if (tmppos != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
148 ret = mktime (&curtime);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
149 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
150 ret = 0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
151
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
152 if (endpos != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
153 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
154 if (tmppos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
155 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
156 /* We cannot parse this date format. So, just skip this date field
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
157 and continue to the next token. This is mainly for the HTTP
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
158 support */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
159
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
160 *endpos = str;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
161 for (num = 0; num < 2 && **endpos != '\0'; num++)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
162 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
163 for (i=0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
164 (*endpos)[i] != ' ' && (*endpos)[i] != '\t' &&
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
165 (*endpos)[i] != '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
166 i++);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
167 *endpos += i;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
168
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
169 for (i=0; (*endpos)[i] == ' ' || (*endpos)[i] == '\t'; i++);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
170 *endpos += i;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
171 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
172 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
173 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
174 *endpos = tmppos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
175 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
176
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
177 return (ret);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
178 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
179
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
180
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
181 static mode_t
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
182 gftp_parse_vms_attribs (char **src, mode_t mask)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
183 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
184 char *endpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
185 mode_t ret;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
186
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
187 if (*src == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
188 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
189
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
190 if ((endpos = strchr (*src, ',')) != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
191 *endpos = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
192
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
193 ret = 0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
194 if (strchr (*src, 'R') != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
195 ret |= S_IRUSR | S_IRGRP | S_IROTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
196 if (strchr (*src, 'W') != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
197 ret |= S_IWUSR | S_IWGRP | S_IWOTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
198 if (strchr (*src, 'E') != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
199 ret |= S_IXUSR | S_IXGRP | S_IXOTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
200
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
201 *src = endpos + 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
202
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
203 return (ret & mask);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
204 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
205
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
206
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
207 static int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
208 gftp_parse_ls_vms (gftp_request * request, int fd, char *str, gftp_file * fle)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
209 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
210 char *curpos, *endpos, tempstr[1024];
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
211 int multiline;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
212 ssize_t len;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
213
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
214 /* .PINE-DEBUG1;1 9 21-AUG-2002 20:06 [MYERSRG] (RWED,RWED,,) */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
215 /* WWW.DIR;1 1 23-NOV-1999 05:47 [MYERSRG] (RWE,RWE,RE,E) */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
216
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
217 /* Multiline VMS
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
218 $MAIN.TPU$JOURNAL;1
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
219 1/18 8-JUN-2004 13:04:14 [NUCLEAR,FISSION] (RWED,RWED,RE,)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
220 TCPIP$FTP_SERVER.LOG;29
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
221 0/18 8-JUN-2004 14:42:04 [NUCLEAR,FISSION] (RWED,RWED,RE,)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
222 TCPIP$FTP_SERVER.LOG;28
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
223 5/18 8-JUN-2004 13:05:11 [NUCLEAR,FISSION] (RWED,RWED,RE,)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
224 TCPIP$FTP_SERVER.LOG;27
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
225 5/18 8-JUN-2004 13:03:51 [NUCLEAR,FISSION] (RWED,RWED,RE,) */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
226
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
227 if ((curpos = strchr (str, ';')) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
228 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
229
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
230 multiline = strchr (str, ' ') == NULL;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
231
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
232 *curpos = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
233 if (strlen (str) > 4 && strcmp (curpos - 4, ".DIR") == 0)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
234 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
235 fle->st_mode |= S_IFDIR;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
236 *(curpos - 4) = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
237 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
238
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
239 fle->file = g_strdup (str);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
240
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
241 if (multiline)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
242 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
243 if (request->get_next_dirlist_line == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
244 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
245
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
246 len = request->get_next_dirlist_line (request, fd, tempstr,
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
247 sizeof (tempstr));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
248 if (len <= 0)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
249 return ((int) len);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
250
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
251 for (curpos = tempstr; *curpos == ' ' || *curpos == '\t'; curpos++);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
252 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
253 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
254 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
255
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
256 fle->size = gftp_parse_file_size (curpos) * 512; /* Is this correct? */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
257
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
258 curpos = goto_next_token (curpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
259
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
260 fle->datetime = parse_vms_time (curpos, &curpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
261
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
262 if (*curpos != '[')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
263 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
264
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
265 if ((endpos = strchr (curpos, ']')) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
266 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
267
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
268 curpos = goto_next_token (endpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
269 if ((curpos = strchr (curpos, ',')) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
270 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
271 curpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
272
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
273 fle->st_mode = gftp_parse_vms_attribs (&curpos, S_IRWXU);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
274 fle->st_mode |= gftp_parse_vms_attribs (&curpos, S_IRWXG);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
275 fle->st_mode |= gftp_parse_vms_attribs (&curpos, S_IRWXO);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
276
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
277 fle->user = g_strdup ("");
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
278 fle->group = g_strdup ("");
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
279
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
280 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
281 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
282
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
283
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
284 static int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
285 gftp_parse_ls_mvs (char *str, gftp_file * fle)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
286 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
287 char *curpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
288
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
289 /* Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
290 /* SVI52A 3390 2003/12/10 8 216 FB 80 27920 PS CARDS.DELETES */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
291 /* SVI528 3390 2003/12/12 1 5 FB 80 24000 PO CLIST */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
292
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
293 curpos = goto_next_token (str + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
294 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
295 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
296
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
297 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
298 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
299 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
300
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
301 fle->datetime = parse_time (curpos, &curpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
302
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
303 curpos = goto_next_token (curpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
304 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
305 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
306
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
307 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
308 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
309 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
310
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
311 fle->size = gftp_parse_file_size (curpos) * 55996;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
312 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
313 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
314 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
315
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
316 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
317 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
318 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
319
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
320 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
321 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
322 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
323
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
324 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
325 if (curpos == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
326 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
327
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
328 if (strncmp (curpos, "PS", 2) == 0)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
329 fle->st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
330 else if (strncmp (curpos, "PO", 2) == 0)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
331 fle->st_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
332 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
333 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
334
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
335 curpos = goto_next_token (curpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
336
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
337 fle->user = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
338 fle->group = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
339 fle->file = g_strdup (curpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
340
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
341 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
342 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
343
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
344
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
345 static int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
346 gftp_parse_ls_eplf (char *str, gftp_file * fle)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
347 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
348 char *startpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
349 int isdir = 0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
350
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
351 startpos = str;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
352 while (startpos)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
353 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
354 startpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
355 switch (*startpos)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
356 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
357 case '/':
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
358 isdir = 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
359 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
360 case 's':
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
361 fle->size = gftp_parse_file_size (startpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
362 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
363 case 'm':
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
364 fle->datetime = strtol (startpos + 1, NULL, 10);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
365 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
366 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
367 startpos = strchr (startpos, ',');
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
368 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
369
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
370 if ((startpos = strchr (str, 9)) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
371 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
372
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
373 if (isdir)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
374 fle->st_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
375 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
376 fle->st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
377
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
378 fle->file = g_strdup (startpos + 1);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
379 fle->user = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
380 fle->group = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
381 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
382 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
383
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
384
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
385 static int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
386 gftp_parse_ls_unix (gftp_request * request, char *str, size_t slen,
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
387 gftp_file * fle)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
388 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
389 char *endpos, *startpos, *pos, *attribs;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
390 int cols;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
391
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
392 /* If there is no space between the attribs and links field, just make one */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
393 if (slen > 10)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
394 str[10] = ' ';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
395
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
396 /* Determine the number of columns */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
397 cols = 0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
398 pos = str;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
399 while (*pos != '\0')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
400 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
401 while (*pos != '\0' && *pos != ' ' && *pos != '\t')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
402 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
403 if (*pos == ':')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
404 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
405 pos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
406 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
407
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
408 cols++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
409
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
410 if (*pos == ':')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
411 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
412 cols++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
413 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
414 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
415
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
416 while (*pos == ' ' || *pos == '\t')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
417 pos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
418 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
419
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
420 startpos = str;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
421 /* Copy file attributes */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
422 if ((startpos = copy_token (&attribs, startpos)) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
423 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
424
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
425 if (strlen (attribs) < 10)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
426 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
427
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
428 fle->st_mode = gftp_convert_attributes_to_mode_t (attribs);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
429 g_free (attribs);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
430
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
431 if (cols >= 9)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
432 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
433 /* Skip the number of links */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
434 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
435
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
436 /* Copy the user that owns this file */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
437 if ((startpos = copy_token (&fle->user, startpos)) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
438 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
439
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
440 /* Copy the group that owns this file */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
441 if ((startpos = copy_token (&fle->group, startpos)) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
442 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
443 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
444 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
445 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
446 fle->group = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
447 if (cols == 8)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
448 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
449 if ((startpos = copy_token (&fle->user, startpos)) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
450 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
451 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
452 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
453 fle->user = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
454 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
455 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
456
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
457 if (request->server_type == GFTP_DIRTYPE_CRAY)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
458 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
459 /* See if this is a Cray directory listing. It has the following format:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
460 drwx------ 2 feiliu g913 DK common 4096 Sep 24 2001 wv */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
461 if (cols == 11 && strstr (str, "->") == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
462 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
463 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
464 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
465 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
466 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
467
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
468 /* See if this is a block or character device. We will store the major number
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
469 in the high word and the minor number in the low word. */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
470 if (GFTP_IS_SPECIAL_DEVICE (fle->st_mode) &&
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
471 (endpos = strchr (startpos, ',')) != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
472 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
473 fle->size = (unsigned long) strtol (startpos, NULL, 10) << 16;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
474
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
475 startpos = endpos + 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
476 while (*startpos == ' ')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
477 startpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
478
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
479 /* Get the minor number */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
480 if ((endpos = strchr (startpos, ' ')) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
481 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
482 fle->size |= strtol (startpos, NULL, 10) & 0xFF;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
483 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
484 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
485 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
486 /* This is a regular file */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
487 if ((endpos = strchr (startpos, ' ')) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
488 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
489 fle->size = gftp_parse_file_size (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
490 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
491
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
492 /* Skip the blanks till we get to the next entry */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
493 startpos = endpos + 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
494 while (*startpos == ' ')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
495 startpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
496
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
497 fle->datetime = parse_time (startpos, &startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
498
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
499 /* Skip the blanks till we get to the next entry */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
500 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
501
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
502 /* Parse the filename. If this file is a symbolic link, remove the -> part */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
503 if (S_ISLNK (fle->st_mode) && ((endpos = strstr (startpos, "->")) != NULL))
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
504 *(endpos - 1) = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
505
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
506 fle->file = g_strdup (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
507
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
508 /* Uncomment this if you want to strip the spaces off of the end of the file.
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
509 I don't want to do this by default since there are valid filenames with
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
510 spaces at the end of them. Some broken FTP servers like the Paradyne IPC
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
511 DSLAMS append a bunch of spaces at the end of the file.
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
512 for (endpos = fle->file + strlen (fle->file) - 1;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
513 *endpos == ' ';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
514 *endpos-- = '\0');
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
515 */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
516
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
517 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
518 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
519
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
520
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
521 static int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
522 gftp_parse_ls_nt (char *str, gftp_file * fle)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
523 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
524 char *startpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
525
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
526 startpos = str;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
527 fle->datetime = parse_time (startpos, &startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
528
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
529 fle->user = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
530 fle->group = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
531
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
532 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
533
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
534 if (startpos[0] == '<')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
535 fle->st_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
536 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
537 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
538 fle->st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
539 fle->size = gftp_parse_file_size (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
540 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
541
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
542 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
543 fle->file = g_strdup (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
544 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
545 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
546
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
547
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
548 static int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
549 gftp_parse_ls_novell (char *str, gftp_file * fle)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
550 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
551 char *startpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
552
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
553 if (str[12] != ' ')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
554 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
555
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
556 str[12] = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
557 fle->st_mode = gftp_convert_attributes_to_mode_t (str);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
558 startpos = str + 13;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
559
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
560 while ((*startpos == ' ' || *startpos == '\t') && *startpos != '\0')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
561 startpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
562
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
563 if ((startpos = copy_token (&fle->user, startpos)) == NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
564 return (GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
565
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
566 fle->group = g_strdup (_("unknown"));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
567
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
568 while (*startpos != '\0' && !isdigit (*startpos))
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
569 startpos++;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
570
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
571 fle->size = gftp_parse_file_size (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
572
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
573 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
574 fle->datetime = parse_time (startpos, &startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
575
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
576 startpos = goto_next_token (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
577 fle->file = g_strdup (startpos);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
578 return (0);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
579 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
580
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
581
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
582 int
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
583 gftp_parse_ls (gftp_request * request, const char *lsoutput, gftp_file * fle,
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
584 int fd)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
585 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
586 char *str, *endpos, tmpchar;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
587 int result, is_vms;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
588 size_t len;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
589
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
590 g_return_val_if_fail (lsoutput != NULL, GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
591 g_return_val_if_fail (fle != NULL, GFTP_EFATAL);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
592
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
593 str = g_strdup (lsoutput);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
594 memset (fle, 0, sizeof (*fle));
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
595
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
596 len = strlen (str);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
597 if (len > 0 && str[len - 1] == '\n')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
598 str[--len] = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
599 if (len > 0 && str[len - 1] == '\r')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
600 str[--len] = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
601
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
602 switch (request->server_type)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
603 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
604 case GFTP_DIRTYPE_CRAY:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
605 case GFTP_DIRTYPE_UNIX:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
606 result = gftp_parse_ls_unix (request, str, len, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
607 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
608 case GFTP_DIRTYPE_EPLF:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
609 result = gftp_parse_ls_eplf (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
610 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
611 case GFTP_DIRTYPE_NOVELL:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
612 result = gftp_parse_ls_novell (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
613 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
614 case GFTP_DIRTYPE_DOS:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
615 result = gftp_parse_ls_nt (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
616 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
617 case GFTP_DIRTYPE_VMS:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
618 result = gftp_parse_ls_vms (request, fd, str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
619 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
620 case GFTP_DIRTYPE_MVS:
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
621 result = gftp_parse_ls_mvs (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
622 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
623 default: /* autodetect */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
624 if (*lsoutput == '+')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
625 result = gftp_parse_ls_eplf (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
626 else if (isdigit ((int) str[0]) && str[2] == '-')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
627 result = gftp_parse_ls_nt (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
628 else if (str[1] == ' ' && str[2] == '[')
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
629 result = gftp_parse_ls_novell (str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
630 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
631 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
632 if ((endpos = strchr (str, ' ')) != NULL)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
633 {
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
634 /* If the first token in the string has a ; in it, then */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
635 /* we'll assume that this is a VMS directory listing */
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
636 tmpchar = *endpos;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
637 *endpos = '\0';
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
638 is_vms = strchr (str, ';') != NULL;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
639 *endpos = tmpchar;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
640 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
641 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
642 is_vms = 0;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
643
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
644 if (is_vms)
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
645 result = gftp_parse_ls_vms (request, fd, str, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
646 else
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
647 result = gftp_parse_ls_unix (request, str, len, fle);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
648 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
649 break;
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
650 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
651 g_free (str);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
652
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
653 return (result);
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
654 }
c7d7a081cd9c 2008-03-04 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
655