177 for (j = 1;j < len;++j) {
179 fp->name = buf + j + 1;
180 fp->namelen = len - j - 1;
193 fp->size =
getlong(buf + i + 1,j - i - 1);
202 fp->id = buf + i + 1;
203 fp->idlen = j - i - 1;
234 if (*buf ==
'd')
fp->flagtrycwd = 1;
235 if (*buf ==
'-')
fp->flagtryretr = 1;
236 if (*buf ==
'l')
fp->flagtrycwd =
fp->flagtryretr = 1;
240 for (j = 1;j < len;++j)
241 if ((buf[j] ==
' ') && (buf[j - 1] !=
' ')) {
248 if ((j - i == 6) && (buf[i] ==
'f'))
270 if ((j - i == 4) && (buf[i + 1] ==
':')) {
272 minute =
getlong(buf + i + 2,2);
275 fp->mtime =
base +
guesstai(month,mday) + hour * 3600 + minute * 60;
276 }
else if ((j - i == 5) && (buf[i + 2] ==
':')) {
278 minute =
getlong(buf + i + 3,2);
281 fp->mtime =
base +
guesstai(month,mday) + hour * 3600 + minute * 60;
283 else if (j - i >= 4) {
291 fp->name = buf + j + 1;
292 fp->namelen = len - j - 1;
299 while ((i < len) && (buf[i] ==
' ')) ++i;
309 for (i = 0;i + 3 <
fp->namelen;++i)
310 if (
fp->name[i] ==
' ')
311 if (
fp->name[i + 1] ==
'-')
312 if (
fp->name[i + 2] ==
'>')
313 if (
fp->name[i + 3] ==
' ') {
319 if ((buf[1] ==
' ') || (buf[1] ==
'['))
321 if (
fp->name[0] ==
' ')
322 if (
fp->name[1] ==
' ')
323 if (
fp->name[2] ==
' ') {
336 for (i = 0;i < len;++i)
343 if (buf[i - 4] ==
'.')
344 if (buf[i - 3] ==
'D')
345 if (buf[i - 2] ==
'I')
346 if (buf[i - 1] ==
'R') {
352 while (buf[i] !=
' ')
if (++i == len)
return 0;
353 while (buf[i] ==
' ')
if (++i == len)
return 0;
354 while (buf[i] !=
' ')
if (++i == len)
return 0;
355 while (buf[i] ==
' ')
if (++i == len)
return 0;
357 while (buf[j] !=
'-')
if (++j == len)
return 0;
359 while (buf[j] ==
'-')
if (++j == len)
return 0;
361 while (buf[j] !=
'-')
if (++j == len)
return 0;
363 if (month < 0)
return 0;
364 while (buf[j] ==
'-')
if (++j == len)
return 0;
366 while (buf[j] !=
' ')
if (++j == len)
return 0;
368 while (buf[j] ==
' ')
if (++j == len)
return 0;
370 while (buf[j] !=
':')
if (++j == len)
return 0;
372 while (buf[j] ==
':')
if (++j == len)
return 0;
374 while ((buf[j] !=
':') && (buf[j] !=
' '))
if (++j == len)
return 0;
375 minute =
getlong(buf + i,j - i);
379 fp->mtime =
base +
totai(year,month,mday) + hour * 3600 + minute * 60;
388 if ((*buf >=
'0') && (*buf <=
'9')) {
391 while (buf[j] !=
'-')
if (++j == len)
return 0;
392 month =
getlong(buf + i,j - i) - 1;
393 while (buf[j] ==
'-')
if (++j == len)
return 0;
395 while (buf[j] !=
'-')
if (++j == len)
return 0;
397 while (buf[j] ==
'-')
if (++j == len)
return 0;
399 while (buf[j] !=
' ')
if (++j == len)
return 0;
401 if (year < 50) year += 2000;
402 if (year < 1000) year += 1900;
403 while (buf[j] ==
' ')
if (++j == len)
return 0;
405 while (buf[j] !=
':')
if (++j == len)
return 0;
407 while (buf[j] ==
':')
if (++j == len)
return 0;
409 while ((buf[j] !=
'A') && (buf[j] !=
'P'))
if (++j == len)
return 0;
410 minute =
getlong(buf + i,j - i);
411 if (hour == 12) hour = 0;
412 if (buf[j] ==
'A')
if (++j == len)
return 0;
413 if (buf[j] ==
'P') { hour += 12;
if (++j == len)
return 0; }
414 if (buf[j] ==
'M')
if (++j == len)
return 0;
416 while (buf[j] ==
' ')
if (++j == len)
return 0;
419 while (buf[j] !=
' ')
if (++j == len)
return 0;
423 while (buf[j] !=
' ')
if (++j == len)
return 0;
428 while (buf[j] ==
' ')
if (++j == len)
return 0;
431 fp->namelen = len - j;
435 fp->mtime =
base +
totai(year,month,mday) + hour * 3600 + minute * 60;
#define FTPPARSE_MTIME_REMOTEDAY
static long totai(long year, long month, long mday)
#define FTPPARSE_MTIME_UNKNOWN
#define FTPPARSE_SIZE_UNKNOWN
static long getlong(char *buf, int len)
#define FTPPARSE_MTIME_LOCAL
static long guesstai(long month, long mday)
static int getmonth(char *buf, int len)
#define FTPPARSE_SIZE_BINARY
static void initbase(void)
#define FTPPARSE_ID_UNKNOWN
#define FTPPARSE_MTIME_REMOTEMINUTE