After a while of thinking, I suspect that the a better algorithm
would be:
int threedigits(char *buffer)
{
threedigits = isdigit(buffer[0]) && isdigit(buffer[0])
&& isdigit(buffer[0]);
}
//...
while(TRUE)
{
get_next_answer(buffer);
if (buffer[0] == '#') remove_first_char(buffer); // MS FTP fix
if (threedigits(buffer, 0, 3) && buffer[3] == ' ') break;
}
process_answer(buffer);
//...
The most RFC-compliant code should store the three digits from the
beginning of the first line of the answer if the fourth character
is '-', and then compare whether the last line has the same digits at
the beginning (and report an error if not), but it would be required
with very crazy servers anyway ;-)
Michal