mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Support new WinNT ftp listing format
This commit is contained in:
parent
7c0270cdb5
commit
022dbcb343
@ -1,3 +1,8 @@
|
|||||||
|
2012-09-29 Merinov Nikolay <kim.roader@gmail.com>
|
||||||
|
|
||||||
|
* ftp-ls.c (ftp_parse_winnt_ls): Support filename extracting with
|
||||||
|
new listing format.
|
||||||
|
|
||||||
2012-09-29 Tim Ruehsen <tim.ruehsen@gmx.de>
|
2012-09-29 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||||
|
|
||||||
* url.h (CHOMP_BUFFER): Add definition.
|
* url.h (CHOMP_BUFFER): Add definition.
|
||||||
|
35
src/ftp-ls.c
35
src/ftp-ls.c
@ -434,6 +434,7 @@ ftp_parse_winnt_ls (const char *file)
|
|||||||
struct tm timestruct;
|
struct tm timestruct;
|
||||||
|
|
||||||
char *line, *tok; /* tokenizer */
|
char *line, *tok; /* tokenizer */
|
||||||
|
char *filename;
|
||||||
struct fileinfo *dir, *l, cur; /* list creation */
|
struct fileinfo *dir, *l, cur; /* list creation */
|
||||||
|
|
||||||
fp = fopen (file, "rb");
|
fp = fopen (file, "rb");
|
||||||
@ -449,19 +450,16 @@ ftp_parse_winnt_ls (const char *file)
|
|||||||
{
|
{
|
||||||
len = clean_line (line);
|
len = clean_line (line);
|
||||||
|
|
||||||
/* Extracting name is a bit of black magic and we have to do it
|
/* Name begins at 39 column of the listing if date presented in `mm-dd-yy'
|
||||||
before `strtok' inserted extra \0 characters in the line
|
format or at 41 column if date presented in `mm-dd-yyyy' format. Thus,
|
||||||
string. For the moment let us just suppose that the name starts at
|
we cannot extract name before we parse date. Using this information we
|
||||||
column 39 of the listing. This way we could also recognize
|
also can recognize filenames that begin with a series of space
|
||||||
filenames that begin with a series of space characters (but who
|
characters (but who really wants to use such filenames anyway?). */
|
||||||
really wants to use such filenames anyway?). */
|
|
||||||
if (len < 40) goto continue_loop;
|
if (len < 40) goto continue_loop;
|
||||||
tok = line + 39;
|
filename = line + 39;
|
||||||
cur.name = xstrdup(tok);
|
|
||||||
DEBUGP (("Name: '%s'\n", cur.name));
|
|
||||||
|
|
||||||
/* First column: mm-dd-yy. Should atoi() on the month fail, january
|
/* First column: mm-dd-yy or mm-dd-yyyy. Should atoi() on the month fail,
|
||||||
will be assumed. */
|
january will be assumed. */
|
||||||
tok = strtok(line, "-");
|
tok = strtok(line, "-");
|
||||||
if (tok == NULL) goto continue_loop;
|
if (tok == NULL) goto continue_loop;
|
||||||
month = atoi(tok) - 1;
|
month = atoi(tok) - 1;
|
||||||
@ -473,7 +471,20 @@ ftp_parse_winnt_ls (const char *file)
|
|||||||
if (tok == NULL) goto continue_loop;
|
if (tok == NULL) goto continue_loop;
|
||||||
year = atoi(tok);
|
year = atoi(tok);
|
||||||
/* Assuming the epoch starting at 1.1.1970 */
|
/* Assuming the epoch starting at 1.1.1970 */
|
||||||
if (year <= 70) year += 100;
|
if (year <= 70)
|
||||||
|
{
|
||||||
|
year += 100;
|
||||||
|
}
|
||||||
|
else if (year >= 1900)
|
||||||
|
{
|
||||||
|
year -= 1900;
|
||||||
|
filename += 2;
|
||||||
|
}
|
||||||
|
/* Now it is possible to determine the position of the first symbol in
|
||||||
|
filename. */
|
||||||
|
cur.name = xstrdup(filename);
|
||||||
|
DEBUGP (("Name: '%s'\n", cur.name));
|
||||||
|
|
||||||
|
|
||||||
/* Second column: hh:mm[AP]M, listing does not contain value for
|
/* Second column: hh:mm[AP]M, listing does not contain value for
|
||||||
seconds */
|
seconds */
|
||||||
|
Loading…
Reference in New Issue
Block a user