cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: FTP upload status bar patch

From: Alex Suykov <sscart_at_ukr.net>
Date: Sat, 23 Apr 2005 07:29:00 +0300

Wed, 20 Apr 2005 09:30:42 +0200 (CEST)
Daniel Stenberg <daniel-curl_at_haxx.se> ΞΑΠΙΣΑΜ:

> > To put it short: this breaks how "curl -T file [URL]" works, as it will spit
> > out the progress meter to get mixed with the output.
>
> .... for http:// URLs I should add.
Yeah, I really disregarded HTTP. The following might be ok for
people who use both FTP and HTTP. I assumed HTTP is the only protocol
that generates downstream data during upload, but I know nothing
about gopher, telnet, ldap. Probably some of them should be added
to output_expected()

> > out the progress meter to get mixed with the output.
By the way, do you mean only visual effect on the screen here?
As far as I can see, output may go into stdout, status bar is written into stderr,
and there's no way for them to mix.

diff -Nurb curl-cvs-2005.04.17.orig/src/main.c curl-cvs-2005.04.17/src/main.c
--- curl-cvs-2005.04.17.orig/src/main.c 2005-03-29 01:17:49.000000000 +0300
+++ curl-cvs-2005.04.17/src/main.c 2005-04-21 20:39:56.000000000 +0300
@@ -2901,6 +2901,17 @@
 #define RETRY_SLEEP_MAX 600000 /* ms == 10 minutes */

 static int
+output_expected(char* url, char* uploadfile)
+{
+ if(!uploadfile)
+ return 1; /* download */
+ if(checkprefix("http://", url))
+ return 1; /* HTTP upload */
+
+ return 0; /* non-HTTP upload, probably no output should be expected */
+};
+
+static int
 operate(struct Configurable *config, int argc, char *argv[])
 {
   char errorbuffer[CURL_ERROR_SIZE];
@@ -3396,7 +3407,8 @@
         if(uploadfile && config->resume_from_current)
           config->resume_from = -1; /* -1 will then force get-it-yourself */

- if(outs.stream && isatty(fileno(outs.stream)))
+ if(output_expected(url, uploadfile)
+ && outs.stream && isatty(fileno(outs.stream)))
           /* we send the output to a tty, therefore we switch off the progress
              meter */
           a
           config->conf |= CONF_NOPROGRESS;
Received on 2005-04-23