From 38d2afcefb3519f7e6a3b7c3afda4f5bfb67bde9 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 29 Apr 2010 00:49:04 +0200 Subject: 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 --- src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 684869379..eff0f9a3b 100644 --- a/src/main.c +++ b/src/main.c @@ -4987,7 +4987,9 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) input.config = config; my_setopt(curl, CURLOPT_READDATA, &input); /* what call to read */ - my_setopt(curl, CURLOPT_READFUNCTION, my_fread); + if ((outfile && !curlx_strequal("-", outfile)) || + !curlx_strnequal(url, "telnet:", 7)) + my_setopt(curl, CURLOPT_READFUNCTION, my_fread); /* in 7.18.0, the CURLOPT_SEEKFUNCTION/DATA pair is taking over what CURLOPT_IOCTLFUNCTION/DATA pair previously provided for seeking */ -- cgit v1.2.3