telnet: Allow programatic use of telnet.
The main change is to allow input from user-specified methods, when they are specified with CURLOPT_READFUNCTION. All calls to fflush(stdout) in telnet.c were removed, which makes using 'curl telnet://foo.com' painful since prompts and other data are not always returned to the user promptly. Use 'curl --no-buffer telnet://foo.com' instead. In general, the user should have their CURLOPT_WRITEFUNCTION do a fflush for interactive use. Also fix assumption that reading from stdin never returns < 0. Old code could crash in that case. Call progress functions in telnet main loop. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:

committed by
Daniel Stenberg

parent
7f616eb513
commit
38d2afcefb
14
lib/url.c
14
lib/url.c
@@ -690,6 +690,8 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
|
||||
|
||||
/* use fread as default function to read input */
|
||||
set->fread_func = (curl_read_callback)fread;
|
||||
set->is_fread_set = 0;
|
||||
set->is_fwrite_set = 0;
|
||||
|
||||
set->seek_func = ZERO_NULL;
|
||||
set->seek_client = ZERO_NULL;
|
||||
@@ -1825,18 +1827,26 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
||||
* Set data write callback
|
||||
*/
|
||||
data->set.fwrite_func = va_arg(param, curl_write_callback);
|
||||
if(!data->set.fwrite_func)
|
||||
if(!data->set.fwrite_func) {
|
||||
data->set.is_fwrite_set = 0;
|
||||
/* When set to NULL, reset to our internal default function */
|
||||
data->set.fwrite_func = (curl_write_callback)fwrite;
|
||||
}
|
||||
else
|
||||
data->set.is_fwrite_set = 0;
|
||||
break;
|
||||
case CURLOPT_READFUNCTION:
|
||||
/*
|
||||
* Read data callback
|
||||
*/
|
||||
data->set.fread_func = va_arg(param, curl_read_callback);
|
||||
if(!data->set.fread_func)
|
||||
if(!data->set.fread_func) {
|
||||
data->set.is_fread_set = 0;
|
||||
/* When set to NULL, reset to our internal default function */
|
||||
data->set.fread_func = (curl_read_callback)fread;
|
||||
}
|
||||
else
|
||||
data->set.is_fread_set = 1;
|
||||
break;
|
||||
case CURLOPT_SEEKFUNCTION:
|
||||
/*
|
||||
|
Reference in New Issue
Block a user