1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Add support for download of hidden files from FTP.

This commit is contained in:
mtortonesi 2006-03-09 05:50:03 -08:00
parent c3cd00a5a1
commit d34270c536
2 changed files with 43 additions and 26 deletions

View File

@ -1,3 +1,8 @@
2006-03-09 Mauro Tortonesi <mauro@ferrara.linux.it>
* ftp.c (ftp_list): Try `LIST -a' command first and revert to `LIST'
in case of failure.
2006-03-06 Hrvoje Niksic <hniksic@xemacs.org>
* hash.c (TOLOWER): Fix definition when STANDALONE.

View File

@ -962,33 +962,45 @@ ftp_list (int csock, const char *file)
char *request, *respline;
int nwritten;
uerr_t err;
bool ok = false;
int i = 0;
/* Try `LIST -a' first and revert to `LIST' in case of failure. */
const char *list_commands[] = { "LIST -a",
"LIST" };
/* Send LIST request. */
request = ftp_request ("LIST", file);
nwritten = fd_write (csock, request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
return WRITEFAILED;
}
xfree (request);
/* Get appropriate respone. */
err = ftp_response (csock, &respline);
if (err != FTPOK)
return err;
if (*respline == '5')
{
xfree (respline);
return FTPNSFOD;
}
if (*respline != '1')
{
xfree (respline);
return FTPRERR;
}
xfree (respline);
/* All OK. */
return FTPOK;
do {
/* Send request. */
request = ftp_request (list_commands[i], file);
nwritten = fd_write (csock, request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
return WRITEFAILED;
}
xfree (request);
/* Get appropriate response. */
err = ftp_response (csock, &respline);
if (err == FTPOK)
{
if (*respline == '5')
{
err = FTPNSFOD;
}
else if (*respline == '1')
{
err = FTPOK;
ok = true;
}
else
{
err = FTPRERR;
}
xfree (respline);
}
++i;
} while (i < countof (list_commands) && !ok);
return err;
}
/* Sends the SYST command to the server. */