aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2010-04-29 00:49:04 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-04-29 08:55:11 +0200
commit38d2afcefb3519f7e6a3b7c3afda4f5bfb67bde9 (patch)
treee70c69372560b881ebf809773dbff97a4012dcee /lib/url.c
parent7f616eb513a692f3edf36bdbf34372186f5203f0 (diff)
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>
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/url.c b/lib/url.c
index a84e69d35..56dd5dc9e 100644
--- a/lib/url.c
+++ b/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:
/*