1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 00:28:48 -05:00

Here's an effort to avoid saying 'data not shown' in the debug parts when the

data is actually shown on screen. Like when you do 'curl -v host' with data
and debug info sent to the same terminal.
This commit is contained in:
Daniel Stenberg 2006-10-19 14:28:50 +00:00
parent 83884180ac
commit 5c3dc49f44

View File

@ -165,6 +165,7 @@ typedef enum {
#define CONF_DEFAULT 0 #define CONF_DEFAULT 0
#endif #endif
#define CONF_ISATTY (1<<0) /* output to tty! */
#define CONF_AUTO_REFERER (1<<4) /* the automatic referer-system please! */ #define CONF_AUTO_REFERER (1<<4) /* the automatic referer-system please! */
#define CONF_HEADER (1<<8) /* throw the header out too */ #define CONF_HEADER (1<<8) /* throw the header out too */
#define CONF_NOPROGRESS (1<<10) /* shut off the progress meter */ #define CONF_NOPROGRESS (1<<10) /* shut off the progress meter */
@ -240,6 +241,14 @@ typedef enum {
TRACE_PLAIN /* -v/--verbose type */ TRACE_PLAIN /* -v/--verbose type */
} trace; } trace;
struct OutStruct {
char *filename;
FILE *stream;
struct Configurable *config;
curl_off_t bytes; /* amount written so far */
curl_off_t init; /* original size (non-zero when appending) */
};
struct Configurable { struct Configurable {
bool remote_time; bool remote_time;
char *random_file; char *random_file;
@ -355,6 +364,8 @@ struct Configurable {
bool ignorecl; /* --ignore-content-length */ bool ignorecl; /* --ignore-content-length */
bool disable_sessionid; bool disable_sessionid;
struct OutStruct *outs;
}; };
#define WARN_PREFIX "Warning: " #define WARN_PREFIX "Warning: "
@ -2243,6 +2254,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
checkpasswd("proxy", &config->proxyuserpwd); checkpasswd("proxy", &config->proxyuserpwd);
break; break;
case 'v': case 'v':
/* the '%' thing here will cause the trace get sent to stderr */
GetStr(&config->trace_dump, (char *)"%"); GetStr(&config->trace_dump, (char *)"%");
config->tracetype = TRACE_PLAIN; config->tracetype = TRACE_PLAIN;
break; break;
@ -2621,14 +2633,6 @@ static void go_sleep(long ms)
#endif #endif
} }
struct OutStruct {
char *filename;
FILE *stream;
struct Configurable *config;
curl_off_t bytes; /* amount written so far */
curl_off_t init; /* original size (non-zero when appending) */
};
static size_t my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream) static size_t my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
{ {
size_t rc; size_t rc;
@ -3027,11 +3031,19 @@ int my_trace(CURL *handle, curl_infotype type,
case CURLINFO_SSL_DATA_IN: case CURLINFO_SSL_DATA_IN:
case CURLINFO_SSL_DATA_OUT: case CURLINFO_SSL_DATA_OUT:
if(!traced_data) { if(!traced_data) {
if(!newl) /* if the data is output to a tty and we're sending this debug trace
fprintf(config->trace_stream, "%s%s ", timebuf, s_infotype[type]); to stderr or stdout, we don't display the alert about the data not
fprintf(config->trace_stream, "[data not shown]\n"); being shown as the data _is_ shown then just not via this
newl = FALSE; function */
traced_data = TRUE; if(!(config->conf&CONF_ISATTY) ||
((config->trace_stream != stderr) &&
(config->trace_stream != stdout))) {
if(!newl)
fprintf(config->trace_stream, "%s%s ", timebuf, s_infotype[type]);
fprintf(config->trace_stream, "[data not shown]\n");
newl = FALSE;
traced_data = TRUE;
}
} }
break; break;
default: /* nada */ default: /* nada */
@ -3241,6 +3253,8 @@ operate(struct Configurable *config, int argc, char *argv[])
memset(&outs,0,sizeof(outs)); memset(&outs,0,sizeof(outs));
config->outs = &outs;
/* we get libcurl info right away */ /* we get libcurl info right away */
curlinfo = curl_version_info(CURLVERSION_NOW); curlinfo = curl_version_info(CURLVERSION_NOW);
@ -3691,7 +3705,7 @@ operate(struct Configurable *config, int argc, char *argv[])
&& outs.stream && isatty(fileno(outs.stream))) && outs.stream && isatty(fileno(outs.stream)))
/* we send the output to a tty, therefore we switch off the progress /* we send the output to a tty, therefore we switch off the progress
meter */ meter */
config->conf |= CONF_NOPROGRESS; config->conf |= CONF_NOPROGRESS|CONF_ISATTY;
if (urlnum > 1 && !(config->conf&CONF_MUTE)) { if (urlnum > 1 && !(config->conf&CONF_MUTE)) {
fprintf(stderr, "\n[%d/%d]: %s --> %s\n", fprintf(stderr, "\n[%d/%d]: %s --> %s\n",
@ -4294,7 +4308,7 @@ static void checkfds(void)
fd[1] == STDOUT_FILENO || fd[1] == STDOUT_FILENO ||
fd[1] == STDERR_FILENO ) fd[1] == STDERR_FILENO )
if (pipe(fd) < 0) if (pipe(fd) < 0)
return; /* Out of handles. This isn't really a big problem now, but return; /* Out of handles. This isn't really a big problem now, but
will be when we try to create a socket later. */ will be when we try to create a socket later. */
close(fd[0]); close(fd[0]);
close(fd[1]); close(fd[1]);