Loading src/tool_helpers.c +23 Changes for src/tool_helpers.c: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -89,3 +89,26 @@ int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store) return 1; } void customrequest_helper(struct OperationConfig *config, HttpReq req, char *method) { /* this mirrors the HttpReq enum in tool_sdecls.h */ const char *dflt[]= { "GET", "GET", "HEAD", "POST", "POST" }; if(curl_strequal(method, dflt[req])) { notef(config->global, "Unnecessary use of -X or --request, %s is already " "inferred.\n", dflt[req]); } else if(curl_strequal(method, "head")) { warnf(config->global, "Setting custom HTTP method to HEAD may not work the way you " "want.\n"); } } src/tool_helpers.h +4 −1 Changes for src/tool_helpers.h: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading @@ -28,5 +28,8 @@ const char *param2text(int res); int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store); void customrequest_helper(struct OperationConfig *config, HttpReq req, char *method); #endif /* HEADER_CURL_TOOL_HELPERS_H */ src/tool_msgs.c +36 −15 Changes for src/tool_msgs.c: 36 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -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--; Loading @@ -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); Loading @@ -78,6 +74,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. */ Loading src/tool_msgs.h +1 Changes for src/tool_msgs.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "tool_setup.h" void warnf(struct GlobalConfig *config, const char *fmt, ...); void notef(struct GlobalConfig *config, const char *fmt, ...); void helpf(FILE *errors, const char *fmt, ...); Loading src/tool_operate.c +1 Changes for src/tool_operate.c: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1108,6 +1108,7 @@ static CURLcode operate_do(struct GlobalConfig *global, my_setopt_enum(curl, CURLOPT_TIMECONDITION, (long)config->timecond); my_setopt(curl, CURLOPT_TIMEVALUE, (long)config->condtime); my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest); customrequest_helper(config, config->httpreq, config->customrequest); my_setopt(curl, CURLOPT_STDERR, global->errors); /* three new ones in libcurl 7.3: */ Loading Loading
src/tool_helpers.c +23 Changes for src/tool_helpers.c: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -89,3 +89,26 @@ int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store) return 1; } void customrequest_helper(struct OperationConfig *config, HttpReq req, char *method) { /* this mirrors the HttpReq enum in tool_sdecls.h */ const char *dflt[]= { "GET", "GET", "HEAD", "POST", "POST" }; if(curl_strequal(method, dflt[req])) { notef(config->global, "Unnecessary use of -X or --request, %s is already " "inferred.\n", dflt[req]); } else if(curl_strequal(method, "head")) { warnf(config->global, "Setting custom HTTP method to HEAD may not work the way you " "want.\n"); } }
src/tool_helpers.h +4 −1 Changes for src/tool_helpers.h: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading @@ -28,5 +28,8 @@ const char *param2text(int res); int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store); void customrequest_helper(struct OperationConfig *config, HttpReq req, char *method); #endif /* HEADER_CURL_TOOL_HELPERS_H */
src/tool_msgs.c +36 −15 Changes for src/tool_msgs.c: 36 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -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--; Loading @@ -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); Loading @@ -78,6 +74,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. */ Loading
src/tool_msgs.h +1 Changes for src/tool_msgs.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "tool_setup.h" void warnf(struct GlobalConfig *config, const char *fmt, ...); void notef(struct GlobalConfig *config, const char *fmt, ...); void helpf(FILE *errors, const char *fmt, ...); Loading
src/tool_operate.c +1 Changes for src/tool_operate.c: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1108,6 +1108,7 @@ static CURLcode operate_do(struct GlobalConfig *global, my_setopt_enum(curl, CURLOPT_TIMECONDITION, (long)config->timecond); my_setopt(curl, CURLOPT_TIMEVALUE, (long)config->condtime); my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest); customrequest_helper(config, config->httpreq, config->customrequest); my_setopt(curl, CURLOPT_STDERR, global->errors); /* three new ones in libcurl 7.3: */ Loading