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

[svn] Fix printing of FTP response.

This commit is contained in:
hniksic 2005-05-05 03:10:51 -07:00
parent 91479b4c8e
commit ce06e4297f
2 changed files with 19 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
* ftp-basic.c (ftp_response): Fix printing FTP server response.
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org> 2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
* retr.c (limit_bandwidth_reset): Reset sleep_adjust. * retr.c (limit_bandwidth_reset): Reset sleep_adjust.

View File

@ -58,26 +58,34 @@ char ftp_last_respline[128];
it. <CR> and <LF> characters are stripped from the line, and the it. <CR> and <LF> characters are stripped from the line, and the
line is 0-terminated. All the response lines but the last one are line is 0-terminated. All the response lines but the last one are
skipped. The last line is determined as described in RFC959. */ skipped. The last line is determined as described in RFC959. */
uerr_t uerr_t
ftp_response (int fd, char **ret_line) ftp_response (int fd, char **ret_line)
{ {
while (1) while (1)
{ {
char *p;
char *line = fd_read_line (fd); char *line = fd_read_line (fd);
if (!line) if (!line)
return FTPRERR; return FTPRERR;
/* Strip trailing CRLF before printing the line, so that
escnonprint doesn't include bogus \012 and \015. */
p = strchr (line, '\0');
if (p > line && p[-1] == '\n')
*--p = '\0';
if (p > line && p[-1] == '\r')
*--p = '\0';
if (opt.server_response) if (opt.server_response)
logputs (LOG_NOTQUIET, escnonprint (line)); logprintf (LOG_NOTQUIET, "%s\n", escnonprint (line));
else else
DEBUGP (("%s", escnonprint (line))); DEBUGP (("%s\n", escnonprint (line)));
/* The last line of output is the one that begins with "ddd ". */
if (ISDIGIT (line[0]) && ISDIGIT (line[1]) && ISDIGIT (line[2]) if (ISDIGIT (line[0]) && ISDIGIT (line[1]) && ISDIGIT (line[2])
&& line[3] == ' ') && line[3] == ' ')
{ {
char *p = line + strlen (line);
if (p > line && p[-1] == '\n')
*--p = '\0';
if (p > line && p[-1] == '\r')
*--p = '\0';
strncpy (ftp_last_respline, line, sizeof (ftp_last_respline)); strncpy (ftp_last_respline, line, sizeof (ftp_last_respline));
ftp_last_respline[sizeof (ftp_last_respline) - 1] = '\0'; ftp_last_respline[sizeof (ftp_last_respline) - 1] = '\0';
*ret_line = line; *ret_line = line;