1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2015, 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "tool_setup.h"
24 #define ENABLE_CURLX_PRINTF
25 /* use our own printf() functions */
28 #include "tool_cfgable.h"
29 #include "tool_msgs.h"
31 #include "memdebug.h" /* keep this as LAST include */
33 #define WARN_PREFIX "Warning: "
34 #define NOTE_PREFIX "Note: "
36 static void voutf(struct GlobalConfig *config,
41 size_t width = (79 - strlen(prefix));
47 print_buffer = curlx_mvaprintf(fmt, ap);
50 len = strlen(print_buffer);
54 fputs(prefix, config->errors);
59 while(!ISSPACE(ptr[cut]) && cut) {
63 /* not a single cutting position was found, just cut it at the
64 max text width then! */
67 (void)fwrite(ptr, cut + 1, 1, config->errors);
68 fputs("\n", config->errors);
69 ptr += cut + 1; /* skip the space too */
73 fputs(ptr, config->errors);
77 curl_free(print_buffer);
82 * Emit 'note' formatted message on configured 'errors' stream, if verbose was
85 void notef(struct GlobalConfig *config, const char *fmt, ...)
90 voutf(config, NOTE_PREFIX, fmt, ap);
95 * Emit warning formatted message on configured 'errors' stream unless
96 * mute (--silent) was selected.
99 void warnf(struct GlobalConfig *config, const char *fmt, ...)
103 voutf(config, WARN_PREFIX, fmt, ap);
107 * Emit help formatted message on given stream.
110 void helpf(FILE *errors, const char *fmt, ...)
115 fputs("curl: ", errors); /* prefix it */
116 vfprintf(errors, fmt, ap);
119 fprintf(errors, "curl: try 'curl --help' "
121 "or 'curl --manual' "
123 "for more information\n");