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.
This commit is contained in:
parent
397bef882b
commit
aa9a847c00
@ -34,7 +34,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++) {
|
||||
@ -56,18 +55,30 @@ main(int argc, char *argv[])
|
||||
die("--response expects a string");
|
||||
response = argv[i];
|
||||
}
|
||||
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;
|
||||
|
||||
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