1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Fix the FTP parser test program to handle multiline responses

... so all the tests with responses stretching multiple lines are
actually tested in their entirety.

(cherry picked from commit aa9a847c00,
 resolving a conflict due to the use of get_test_opt)
This commit is contained in:
Jonas Fonseca 2008-02-27 13:17:46 +01:00 committed by Kalle Olavi Niemitalo
parent 577c241438
commit 1ad9d5b2b8

View File

@ -20,7 +20,6 @@ main(int argc, char *argv[])
{
struct ftp_file_info ftp_info = INIT_FTP_FILE_INFO;
unsigned char *response = "";
int responselen = 0;
int i;
for (i = 1; i < argc; i++) {
@ -33,18 +32,30 @@ main(int argc, char *argv[])
if (get_test_opt(&arg, "response", &i, argc, argv, "a string")) {
response = arg;
responselen = strlen(response);
} else {
die("Unknown argument '%s'", arg - 2);
}
}
if (!responselen)
if (!*response)
die("Usage: %s --response \"string\"", argv[0]);
if (parse_ftp_file_info(&ftp_info, response, responselen))
return 0;
while (*response) {
unsigned char *start = response;
return 1;
response = strchr(response, '\n');
if (!response) {
response = start + strlen(start);
} else {
if (response > start && response[-1] == '\r')
response[-1] = 0;
*response++ = 0;
}
if (!parse_ftp_file_info(&ftp_info, start, strlen(start)))
return 1;
}
return 0;
}