mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05: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:
parent
577c241438
commit
1ad9d5b2b8
@ -20,7 +20,6 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct ftp_file_info ftp_info = INIT_FTP_FILE_INFO;
|
struct ftp_file_info ftp_info = INIT_FTP_FILE_INFO;
|
||||||
unsigned char *response = "";
|
unsigned char *response = "";
|
||||||
int responselen = 0;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < argc; 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")) {
|
if (get_test_opt(&arg, "response", &i, argc, argv, "a string")) {
|
||||||
response = arg;
|
response = arg;
|
||||||
responselen = strlen(response);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
die("Unknown argument '%s'", arg - 2);
|
die("Unknown argument '%s'", arg - 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!responselen)
|
if (!*response)
|
||||||
die("Usage: %s --response \"string\"", argv[0]);
|
die("Usage: %s --response \"string\"", argv[0]);
|
||||||
|
|
||||||
if (parse_ftp_file_info(&ftp_info, response, responselen))
|
while (*response) {
|
||||||
return 0;
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user