diff options
author | Daniel Stenberg <daniel@haxx.se> | 2015-08-29 23:56:28 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2015-09-11 08:53:53 +0200 |
commit | 481e0de00a9003b9c5220b120e3fc302d9b0932d (patch) | |
tree | cff919570ca5e120c731a342652691522e230c67 /src/tool_msgs.c | |
parent | df6a4d3519655b26137a90a440c5a99f4abe7e22 (diff) | |
download | curl-481e0de00a9003b9c5220b120e3fc302d9b0932d.tar.gz |
curl: point out unnecessary uses of -X in verbose mode
It uses 'Note:' as a prefix as opposed to the common 'Warning:' to take
down the tone a bit.
It adds a warning for using -XHEAD on other methods becasue that may
lead to a hanging connection.
Diffstat (limited to 'src/tool_msgs.c')
-rw-r--r-- | src/tool_msgs.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/tool_msgs.c b/src/tool_msgs.c index 38de977aa..565e28381 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -31,31 +31,27 @@ #include "memdebug.h" /* keep this as LAST include */ #define WARN_PREFIX "Warning: " -#define WARN_TEXTWIDTH (79 - (int)strlen(WARN_PREFIX)) +#define NOTE_PREFIX "Note: " -/* - * Emit warning formatted message on configured 'errors' stream unless - * mute (--silent) was selected. - */ - -void warnf(struct GlobalConfig *config, const char *fmt, ...) +static void voutf(struct GlobalConfig *config, + const char *prefix, + const char *fmt, + va_list ap) { + size_t width = (79 - (int)strlen(prefix)); if(!config->mute) { - va_list ap; - int len; + size_t len; char *ptr; char print_buffer[256]; - va_start(ap, fmt); len = vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap); - va_end(ap); ptr = print_buffer; while(len > 0) { - fputs(WARN_PREFIX, config->errors); + fputs(prefix, config->errors); - if(len > (int)WARN_TEXTWIDTH) { - int cut = WARN_TEXTWIDTH-1; + if(len > width) { + size_t cut = width-1; while(!ISSPACE(ptr[cut]) && cut) { cut--; @@ -63,7 +59,7 @@ void warnf(struct GlobalConfig *config, const char *fmt, ...) if(0 == cut) /* not a single cutting position was found, just cut it at the max text width then! */ - cut = WARN_TEXTWIDTH-1; + cut = width-1; (void)fwrite(ptr, cut + 1, 1, config->errors); fputs("\n", config->errors); @@ -79,6 +75,31 @@ void warnf(struct GlobalConfig *config, const char *fmt, ...) } /* + * Emit 'note' formatted message on configured 'errors' stream, if verbose was + * selected. + */ +void notef(struct GlobalConfig *config, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + if(config->tracetype) + voutf(config, NOTE_PREFIX, fmt, ap); + va_end(ap); +} + +/* + * Emit warning formatted message on configured 'errors' stream unless + * mute (--silent) was selected. + */ + +void warnf(struct GlobalConfig *config, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + voutf(config, WARN_PREFIX, fmt, ap); + va_end(ap); +} +/* * Emit help formatted message on given stream. */ |