enable STDERR
+banfunc aprintf
+banfunc fprintf
+banfunc msnprintf
+banfunc mvsnprintf
+banfunc printf
+banfunc vaprintf
+banfunc vfprintf
+banfunc vprintf
if(!already) { /* if there is no existing version */
const char *v = curl_version_info(CURLVERSION_NOW)->ssl_version;
if(v)
- msnprintf(ssl_ver, sizeof(ssl_ver), "%.*s", (int) strcspn(v, " "), v);
+ curl_msnprintf(ssl_ver, sizeof(ssl_ver),
+ "%.*s", (int)strcspn(v, " "), v);
already = TRUE;
}
return ssl_ver;
(void)argv;
for(i = 0; i < CURL_ARRAYSIZE(disabled); i++)
+ /* !checksrc! disable BANNEDFUNC 1 */
printf("%s\n", disabled[i]);
return 0;
if(tv_sec != cached_tv_sec) {
/* !checksrc! disable BANNEDFUNC 1 */
struct tm *now = localtime(&tv_sec); /* not thread safe either */
- msnprintf(hms_buf, sizeof(hms_buf), "%02d:%02d:%02d",
- now->tm_hour, now->tm_min, now->tm_sec);
+ curl_msnprintf(hms_buf, sizeof(hms_buf), "%02d:%02d:%02d",
+ now->tm_hour, now->tm_min, now->tm_sec);
cached_tv_sec = tv_sec;
}
return hms_buf;
"* ", "< ", "> ", "{ ", "} ", "{ ", "} "
};
if((timebuf && *timebuf) || (idsbuf && *idsbuf))
- fprintf(log, "%s%s%s", timebuf, idsbuf, s_infotype[type]);
+ curl_mfprintf(log, "%s%s%s", timebuf, idsbuf, s_infotype[type]);
else
fputs(s_infotype[type], log);
}
if(global->tracetime) {
tv = tvrealnow();
- msnprintf(timebuf, sizeof(timebuf), "%s.%06ld ",
- hms_for_sec(tv.tv_sec), (long)tv.tv_usec);
+ curl_msnprintf(timebuf, sizeof(timebuf), "%s.%06ld ",
+ hms_for_sec(tv.tv_sec), (long)tv.tv_usec);
}
else
timebuf[0] = 0;
!curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) {
if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) &&
conn_id >= 0) {
- msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2,
- xfer_id, conn_id);
+ curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2,
+ xfer_id, conn_id);
}
else {
- msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id);
+ curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_1, xfer_id);
}
}
else
((output != tool_stderr) && (output != stdout))) {
if(!newl)
log_line_start(output, timebuf, idsbuf, type);
- fprintf(output, "[%zu bytes data]\n", size);
+ curl_mfprintf(output, "[%zu bytes data]\n", size);
newl = FALSE;
traced_data = TRUE;
}
switch(type) {
case CURLINFO_TEXT:
- fprintf(output, "%s%s* %.*s", timebuf, idsbuf, (int)size, data);
+ curl_mfprintf(output, "%s%s* %.*s", timebuf, idsbuf, (int)size, data);
FALLTHROUGH();
default: /* in case a new one is introduced to shock us */
return 0;
/* without the hex output, we can fit more on screen */
width = 0x40;
- fprintf(stream, "%s%s%s, %zu bytes (0x%zx)\n", timebuf, idsbuf,
- text, size, size);
+ curl_mfprintf(stream, "%s%s%s, %zu bytes (0x%zx)\n", timebuf, idsbuf,
+ text, size, size);
for(i = 0; i < size; i += width) {
- fprintf(stream, "%04zx: ", i);
+ curl_mfprintf(stream, "%04zx: ", i);
if(tracetype == TRACE_BIN) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i + c < size)
- fprintf(stream, "%02x ", ptr[i + c]);
+ curl_mfprintf(stream, "%02x ", ptr[i + c]);
else
fputs(" ", stream);
}
break;
}
(void)infotype;
- fprintf(stream, "%c", ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x7F)) ?
- ptr[i + c] : UNPRINTABLE_CHAR);
+ curl_mfprintf(stream, "%c",
+ ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x7F)) ?
+ ptr[i + c] : UNPRINTABLE_CHAR);
/* check again for 0D0A, to avoid an extra \n if it is at width */
if((tracetype == TRACE_ASCII) &&
(i + c + 2 < size) && (ptr[i + c + 1] == 0x0D) &&
}
if(per->config->output_dir) {
- outs->filename = aprintf("%s/%s", per->config->output_dir,
- filename);
+ outs->filename = curl_maprintf("%s/%s", per->config->output_dir,
+ filename);
free(filename);
if(!outs->filename)
return CURL_WRITEFUNC_ERROR;
hdrcbdata->config->show_headers) {
/* still awaiting the Content-Disposition header, store the header in
memory. Since it is not null-terminated, we need an extra dance. */
- char *clone = aprintf("%.*s", (int)cb, str);
+ char *clone = curl_maprintf("%.*s", (int)cb, str);
if(clone) {
struct curl_slist *old = hdrcbdata->headlist;
hdrcbdata->headlist = curl_slist_append(old, clone);
value = memchr(ptr, ':', cb);
if(value) {
size_t namelen = value - ptr;
- fprintf(outs->stream, BOLD "%.*s" BOLDOFF ":", (int)namelen, ptr);
+ curl_mfprintf(outs->stream, BOLD "%.*s" BOLDOFF ":", (int)namelen, ptr);
#ifndef LINK
fwrite(&value[1], cb - namelen - 1, 1, outs->stream);
#else
!strcmp("https", scheme) ||
!strcmp("ftp", scheme) ||
!strcmp("ftps", scheme)) {
- fprintf(stream, "%.*s" LINK "%s" LINKST "%.*s" LINKOFF,
- space_skipped, location,
- finalurl,
- (int)loclen - space_skipped, loc);
+ curl_mfprintf(stream, "%.*s" LINK "%s" LINKST "%.*s" LINKOFF,
+ space_skipped, location,
+ finalurl,
+ (int)loclen - space_skipped, loc);
goto locdone;
}
num = MAX_BARLENGTH;
memset(line, '#', num);
line[num] = '\0';
- msnprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
+ curl_msnprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
- fprintf(bar->out, format, line, percent);
+ curl_mfprintf(bar->out, format, line, percent);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif
#endif
-/* make the tool use the libcurl *printf family */
-# undef printf
-# undef fprintf
-# undef msnprintf
-# undef vprintf
-# undef vfprintf
-# undef mvsnprintf
-# undef aprintf
-# undef vaprintf
-# define printf curl_mprintf
-# define fprintf curl_mfprintf
-# define msnprintf curl_msnprintf
-# define vprintf curl_mvprintf
-# define vfprintf curl_mvfprintf
-# define mvsnprintf curl_mvsnprintf
-# define aprintf curl_maprintf
-# define vaprintf curl_mvaprintf
-
#define checkprefix(a,b) curl_strnequal(b, STRCONST(a))
#define tool_safefree(ptr) \
char *bufp;
va_list ap;
va_start(ap, fmt);
- bufp = vaprintf(fmt, ap);
+ bufp = curl_mvaprintf(fmt, ap);
va_end(ap);
if(!bufp) {
ret = CURLE_OUT_OF_MEMORY;
const char *c;
for(i = 0; ((c = srchead[i]) != NULL); i++)
- fprintf(out, "%s\n", c);
+ curl_mfprintf(out, "%s\n", c);
/* Declare variables used for complex setopt values */
if(easysrc_decl) {
for(ptr = easysrc_decl->first; ptr; ptr = ptr->next)
- fprintf(out, " %s\n", ptr->data);
+ curl_mfprintf(out, " %s\n", ptr->data);
}
/* Set up complex values for setopt calls */
if(easysrc_data) {
- fprintf(out, "\n");
+ curl_mfprintf(out, "\n");
for(ptr = easysrc_data->first; ptr; ptr = ptr->next)
- fprintf(out, " %s\n", ptr->data);
+ curl_mfprintf(out, " %s\n", ptr->data);
}
- fprintf(out, "\n");
+ curl_mfprintf(out, "\n");
if(easysrc_code) {
for(ptr = easysrc_code->first; ptr; ptr = ptr->next) {
if(ptr->data[0]) {
- fprintf(out, " %s\n", ptr->data);
+ curl_mfprintf(out, " %s\n", ptr->data);
}
else {
- fprintf(out, "\n");
+ curl_mfprintf(out, "\n");
}
}
}
if(easysrc_clean) {
for(ptr = easysrc_clean->first; ptr; ptr = ptr->next)
- fprintf(out, " %s\n", ptr->data);
+ curl_mfprintf(out, " %s\n", ptr->data);
}
for(i = 0; ((c = srcend[i]) != NULL); i++)
- fprintf(out, "%s\n", c);
+ curl_mfprintf(out, "%s\n", c);
if(fopened)
curlx_fclose(out);
for(i = 0; i < (dotscore ? 2 : 1); i++) {
char *c;
if(dotscore)
- c = aprintf("%s" DIR_CHAR "%c%s", home, pref[i], &fname[1]);
+ c = curl_maprintf("%s" DIR_CHAR "%c%s", home, pref[i], &fname[1]);
else
- c = aprintf("%s" DIR_CHAR "%s", home, fname);
+ c = curl_maprintf("%s" DIR_CHAR "%s", home, fname);
if(c) {
int fd = curlx_open(c, O_RDONLY);
if(fd >= 0) {
continue;
}
if(conf_list[i].append) {
- char *c = aprintf("%s%s", home, conf_list[i].append);
+ char *c = curl_maprintf("%s%s", home, conf_list[i].append);
curl_free(home);
if(!c)
return NULL;
}
else {
char buffer[64];
- msnprintf(buffer, sizeof(buffer), "%c%.*s,-lib-ids", toggle ? '+' : '-',
- (int)len, name);
+ curl_msnprintf(buffer, sizeof(buffer), "%c%.*s,-lib-ids",
+ toggle ? '+' : '-', (int)len, name);
result = curl_global_trace(buffer);
if(result)
goto out;
if(ISBLANK(*pp))
pp++;
}
- msnprintf(buffer, sizeof(buffer), "%.*s", (int)plen, nextarg);
+ curl_msnprintf(buffer, sizeof(buffer), "%.*s", (int)plen, nextarg);
if(str2unummax(&config->localport, buffer, 65535))
return PARAM_BAD_USE;
if(!pp)
curlx_fclose(file);
if(err)
return err;
- config->ech_config = aprintf("ecl:%s",tmpcfg);
+ config->ech_config = curl_maprintf("ecl:%s",tmpcfg);
free(tmpcfg);
if(!config->ech_config)
return PARAM_NO_MEM;
char buffer[32];
warnf("A specified range MUST include at least one dash (-). "
"Appending one for you");
- msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-",
- value);
+ curl_msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-",
+ value);
free(config->range);
config->range = strdup(buffer);
if(!config->range)
else
opt = 0;
}
- printf(" %-*s %s\n", (int)opt, helptext[i].opt, helptext[i].desc);
+ curl_mprintf(" %-*s %s\n", (int)opt, helptext[i].opt, helptext[i].desc);
}
}
unsigned int i;
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i)
if(curl_strequal(categories[i].opt, category)) {
- printf("%s: %s\n", categories[i].opt, categories[i].desc);
+ curl_mprintf("%s: %s\n", categories[i].opt, categories[i].desc);
print_category(categories[i].category, cols);
return 0;
}
{
unsigned int i;
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i)
- printf(" %-11s %s\n", categories[i].opt, categories[i].desc);
+ curl_mprintf(" %-11s %s\n", categories[i].opt, categories[i].desc);
}
/* Prints all categories as a comma-separated list of given width */
if(i == CURL_ARRAYSIZE(categories) - 1) {
/* final category */
if(col + len + 1 < width)
- printf("%s.\n", categories[i].opt);
+ curl_mprintf("%s.\n", categories[i].opt);
else
/* start a new line first */
- printf("\n%s.\n", categories[i].opt);
+ curl_mprintf("\n%s.\n", categories[i].opt);
}
else if(col + len + 2 < width) {
- printf("%s, ", categories[i].opt);
+ curl_mprintf("%s, ", categories[i].opt);
col += len + 2;
}
else {
/* start a new line first */
- printf("\n%s, ", categories[i].opt);
+ curl_mprintf("\n%s, ", categories[i].opt);
col = len + 2;
}
}
else if(!category[2])
a = findshortopt(category[1]);
if(!a) {
- fprintf(tool_stderr, "Incorrect option name to show help for,"
- " see curl -h\n");
+ curl_mfprintf(tool_stderr, "Incorrect option name to show help for,"
+ " see curl -h\n");
}
else {
char cmdbuf[80];
if(a->letter != ' ')
- msnprintf(cmdbuf, sizeof(cmdbuf), "\n -%c, --", a->letter);
+ curl_msnprintf(cmdbuf, sizeof(cmdbuf), "\n -%c, --", a->letter);
else if(a->desc & ARG_NO)
- msnprintf(cmdbuf, sizeof(cmdbuf), "\n --no-%s", a->lname);
+ curl_msnprintf(cmdbuf, sizeof(cmdbuf), "\n --no-%s", a->lname);
else
- msnprintf(cmdbuf, sizeof(cmdbuf), "\n %s", category);
+ curl_msnprintf(cmdbuf, sizeof(cmdbuf), "\n %s", category);
#ifdef USE_MANUAL
if(a->cmd == C_XATTR)
/* this is the last option, which then ends when FILES starts */
#endif
}
#else
- fprintf(tool_stderr, "Cannot comply. "
- "This curl was built without built-in manual\n");
+ curl_mfprintf(tool_stderr, "Cannot comply. "
+ "This curl was built without built-in manual\n");
#endif
}
/* Otherwise print category and handle the case if the cat was not found */
{
const char *const *builtin;
if(is_debug())
- fprintf(tool_stderr, "WARNING: this libcurl is Debug-enabled, "
- "do not use in production\n\n");
+ curl_mfprintf(tool_stderr, "WARNING: this libcurl is Debug-enabled, "
+ "do not use in production\n\n");
- printf(CURL_ID "%s\n", curl_version());
+ curl_mprintf(CURL_ID "%s\n", curl_version());
#ifdef CURL_PATCHSTAMP
- printf("Release-Date: %s, security patched: %s\n",
- LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
+ curl_mprintf("Release-Date: %s, security patched: %s\n",
+ LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
#else
- printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
+ curl_mprintf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
#endif
if(built_in_protos[0]) {
#ifndef CURL_DISABLE_IPFS
}
}
#endif /* !CURL_DISABLE_IPFS */
- printf("Protocols:");
+ curl_mprintf("Protocols:");
for(builtin = built_in_protos; *builtin; ++builtin) {
/* Special case: do not list rtmp?* protocols.
They may only appear together with "rtmp" */
if(!curl_strnequal(*builtin, "rtmp", 4) || !builtin[0][4])
- printf(" %s", *builtin);
+ curl_mprintf(" %s", *builtin);
#ifndef CURL_DISABLE_IPFS
if(insert && insert == *builtin) {
- printf(" ipfs ipns");
+ curl_mprintf(" ipfs ipns");
insert = NULL;
}
#endif /* !CURL_DISABLE_IPFS */
feat_ext[feat_ext_count] = NULL;
qsort((void *)feat_ext, feat_ext_count, sizeof(*feat_ext),
struplocompare4sort);
- printf("Features:");
+ curl_mprintf("Features:");
for(builtin = feat_ext; *builtin; ++builtin)
- printf(" %s", *builtin);
+ curl_mprintf(" %s", *builtin);
puts(""); /* newline */
free((void *)feat_ext);
}
}
if(strcmp(CURL_VERSION, curlinfo->version)) {
- printf("WARNING: curl and libcurl versions do not match. "
- "Functionality may be affected.\n");
+ curl_mprintf("WARNING: curl and libcurl versions do not match. "
+ "Functionality may be affected.\n");
}
}
puts("Build-time engines:");
if(engines) {
for(; engines; engines = engines->next)
- printf(" %s\n", engines->data);
+ curl_mprintf(" %s\n", engines->data);
}
else {
puts(" <none>");
if(!ipfs_path) {
char *home = getenv("HOME");
if(home && *home)
- ipfs_path = aprintf("%s/.ipfs/", home);
+ ipfs_path = curl_maprintf("%s/.ipfs/", home);
/* fallback to "~/.ipfs", as that is the default location. */
}
if(!ipfs_path || ensure_trailing_slash(&ipfs_path))
goto fail;
- gateway_composed_file_path = aprintf("%sgateway", ipfs_path);
+ gateway_composed_file_path = curl_maprintf("%sgateway", ipfs_path);
if(!gateway_composed_file_path)
goto fail;
/* ensure the gateway path ends with a trailing slash */
ensure_trailing_slash(&gwpath);
- pathbuffer = aprintf("%s%s/%s%s", gwpath, protocol, cid,
- inputpath ? inputpath : "");
+ pathbuffer = curl_maprintf("%s%s/%s%s", gwpath, protocol, cid,
+ inputpath ? inputpath : "");
if(!pathbuffer) {
goto clean;
}
if(argc == 2 && !_tcscmp(argv[1], _T("--dump-module-paths"))) {
struct curl_slist *item, *head = GetLoadedModulePaths();
for(item = head; item; item = item->next)
- printf("%s\n", item->data);
+ curl_mprintf("%s\n", item->data);
curl_slist_free_all(head);
return head ? 0 : 1;
}
char *ptr;
char *print_buffer;
- print_buffer = vaprintf(fmt, ap);
+ print_buffer = curl_mvaprintf(fmt, ap);
if(!print_buffer)
return;
len = strlen(print_buffer);
va_start(ap, fmt);
DEBUGASSERT(!strchr(fmt, '\n'));
fputs("curl: ", tool_stderr); /* prefix it */
- vfprintf(tool_stderr, fmt, ap);
+ curl_mvfprintf(tool_stderr, fmt, ap);
va_end(ap);
fputs("\n", tool_stderr); /* newline it */
}
- fprintf(tool_stderr, "curl: try 'curl --help' "
+ curl_mfprintf(tool_stderr, "curl: try 'curl --help' "
#ifdef USE_MANUAL
- "or 'curl --manual' "
+ "or 'curl --manual' "
#endif
- "for more information\n");
+ "for more information\n");
}
/*
if(!config->synthetic_error && result &&
(!global->silent || global->showerror)) {
const char *msg = per->errorbuffer;
- fprintf(tool_stderr, "curl: (%d) %s\n", result,
- msg[0] ? msg : curl_easy_strerror(result));
+ curl_mfprintf(tool_stderr, "curl: (%d) %s\n", result,
+ msg[0] ? msg : curl_easy_strerror(result));
if(result == CURLE_PEER_FAILED_VERIFICATION)
fputs(CURL_CA_CERT_ERRORMSG, tool_stderr);
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
if(code >= 400) {
if(!global->silent || global->showerror)
- fprintf(tool_stderr,
- "curl: (%d) The requested URL returned error: %ld\n",
- CURLE_HTTP_RETURNED_ERROR, code);
+ curl_mfprintf(tool_stderr,
+ "curl: (%d) The requested URL returned error: %ld\n",
+ CURLE_HTTP_RETURNED_ERROR, code);
result = CURLE_HTTP_RETURNED_ERROR;
}
}
if((PARAM_OK == file2string(&etag_from_file, file)) &&
etag_from_file) {
- header = aprintf("If-None-Match: %s", etag_from_file);
+ header = curl_maprintf("If-None-Match: %s", etag_from_file);
tool_safefree(etag_from_file);
}
else
- header = aprintf("If-None-Match: \"\"");
+ header = curl_maprintf("If-None-Match: \"\"");
if(!header) {
if(file)
DEBUGASSERT(per->outfile);
if(config->output_dir && *config->output_dir) {
- char *d = aprintf("%s/%s", config->output_dir, per->outfile);
+ char *d = curl_maprintf("%s/%s", config->output_dir, per->outfile);
if(!d)
return CURLE_WRITE_ERROR;
free(per->outfile);
{
struct datauv *uv = (struct datauv *) req->data;
#if DEBUG_UV
- fprintf(tool_stderr, "parallel_event: on_uv_timeout\n");
+ curl_mfprintf(tool_stderr, "parallel_event: on_uv_timeout\n");
#endif
if(uv && uv->s) {
curl_multi_socket_action(uv->s->multi, CURL_SOCKET_TIMEOUT, 0,
struct datauv *uv = userp;
(void)multi;
#if DEBUG_UV
- fprintf(tool_stderr, "parallel_event: cb_timeout=%ld\n", timeout_ms);
+ curl_mfprintf(tool_stderr, "parallel_event: cb_timeout=%ld\n", timeout_ms);
#endif
if(timeout_ms < 0)
uv_timer_stop(&uv->timeout);
(void)easy;
#if DEBUG_UV
- fprintf(tool_stderr, "parallel_event: cb_socket, fd=%d, action=%x, p=%p\n",
- (int)s, action, socketp);
+ curl_mfprintf(tool_stderr, "parallel_event: cb_socket, "
+ "fd=%" FMT_SOCKET_T ", action=%x, p=%p\n", s, action, socketp);
#endif
switch(action) {
case CURL_POLL_IN:
while(!s->mcode && (s->still_running || s->more_transfers)) {
#if DEBUG_UV
- fprintf(tool_stderr, "parallel_event: uv_run(), mcode=%d, %d running, "
- "%d more\n", s->mcode, uv.s->still_running, s->more_transfers);
+ curl_mfprintf(tool_stderr, "parallel_event: uv_run(), "
+ "mcode=%d, %d running, %d more\n",
+ s->mcode, uv.s->still_running, s->more_transfers);
#endif
uv_run(uv.loop, UV_RUN_DEFAULT);
#if DEBUG_UV
- fprintf(tool_stderr, "parallel_event: uv_run() returned\n");
+ curl_mfprintf(tool_stderr, "parallel_event: uv_run() returned\n");
#endif
result = check_finished(s);
curl_multi_cleanup(s->multi);
#if DEBUG_UV
- fprintf(tool_stderr, "DONE parallel_event -> %d, mcode=%d, %d running, "
- "%d more\n",
+ curl_mfprintf(tool_stderr, "DONE parallel_event -> %d, mcode=%d, "
+ "%d running, %d more\n",
result, s->mcode, uv.s->still_running, s->more_transfers);
#endif
return result;
curl_multi_remove_handle(s->multi, easy);
if(ended->abort && (tres == CURLE_ABORTED_BY_CALLBACK)) {
- msnprintf(ended->errorbuffer, CURL_ERROR_SIZE,
- "Transfer aborted due to critical error "
- "in another transfer");
+ curl_msnprintf(ended->errorbuffer, CURL_ERROR_SIZE,
+ "Transfer aborted due to critical error "
+ "in another transfer");
}
tres = post_per_transfer(ended, tres, &retry, &delay);
progress_finalize(ended); /* before it goes away */
/* Check if we were asked to dump the embedded CA bundle */
else if(res == PARAM_CA_EMBED_REQUESTED) {
#ifdef CURL_CA_EMBED
- printf("%s", curl_ca_embed);
+ curl_mprintf("%s", curl_ca_embed);
#endif
}
else if(res == PARAM_LIBCURL_UNSUPPORTED_PROTOCOL)
char *newurl;
if(ptr)
/* there is a trailing slash on the path */
- newpath = aprintf("%s%s", path, encfile);
+ newpath = curl_maprintf("%s%s", path, encfile);
else
/* there is no trailing slash on the path */
- newpath = aprintf("%s/%s", path, encfile);
+ newpath = curl_maprintf("%s/%s", path, encfile);
curl_free(encfile);
else {
char buffer[32];
const char *p;
- msnprintf(buffer, sizeof(buffer), "%.*s", (int)plen, str);
+ curl_msnprintf(buffer, sizeof(buffer), "%.*s", (int)plen, str);
p = proto_token(buffer);
/* build a nice-looking prompt */
if(!i && last)
- msnprintf(prompt, sizeof(prompt),
- "Enter %s password for user '%s':",
- kind, *userpwd);
+ curl_msnprintf(prompt, sizeof(prompt),
+ "Enter %s password for user '%s':",
+ kind, *userpwd);
else
- msnprintf(prompt, sizeof(prompt),
- "Enter %s password for user '%s' on URL #%zu:",
- kind, *userpwd, i + 1);
+ curl_msnprintf(prompt, sizeof(prompt),
+ "Enter %s password for user '%s' on URL #%zu:",
+ kind, *userpwd, i + 1);
/* get password */
getpass_r(prompt, passwd, sizeof(passwd));
*line++ = '\0'; /* null-terminate, we have a local copy of the data */
#ifdef DEBUG_CONFIG
- fprintf(tool_stderr, "GOT: %s\n", option);
+ curl_mfprintf(tool_stderr, "GOT: %s\n", option);
#endif
/* pass spaces and separator(s) */
}
#ifdef DEBUG_CONFIG
- fprintf(tool_stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
+ curl_mfprintf(tool_stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
#endif
res = getparameter(option, param, &usedarg, config);
config = global->last;
const char unit[] = { 'k', 'M', 'G', 'T', 'P', 0 };
int k = 0;
if(bytes < 100000) {
- msnprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
+ curl_msnprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
return max5;
}
curl_off_t nbytes = bytes / 1024;
if(nbytes < 100) {
/* display with a decimal */
- msnprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
- CURL_FORMAT_CURL_OFF_T "%c", bytes/1024,
- (bytes%1024) / (1024/10), unit[k]);
+ curl_msnprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
+ CURL_FORMAT_CURL_OFF_T "%c", bytes/1024,
+ (bytes%1024) / (1024/10), unit[k]);
break;
}
else if(nbytes < 10000) {
/* no decimals */
- msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "%c", nbytes, unit[k]);
+ curl_msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
+ unit[k]);
break;
}
bytes = nbytes;
if(h <= 99) {
curl_off_t m = (seconds - (h * 3600)) / 60;
curl_off_t s = (seconds - (h * 3600)) - (m * 60);
- msnprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
- ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
+ curl_msnprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T
+ ":%02" CURL_FORMAT_CURL_OFF_T
+ ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
}
else {
/* this equals to more than 99 hours, switch to a more suitable output
curl_off_t d = seconds / 86400;
h = (seconds - (d * 86400)) / 3600;
if(d <= 999)
- msnprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
- "d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
+ curl_msnprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
+ "d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
else
- msnprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
+ curl_msnprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
}
}
}
}
if(dlknown && all_dltotal)
- msnprintf(dlpercen, sizeof(dlpercen), "%3" CURL_FORMAT_CURL_OFF_T,
- all_dlnow < (CURL_OFF_T_MAX/100) ?
- (all_dlnow * 100 / all_dltotal) :
- (all_dlnow / (all_dltotal/100)));
+ curl_msnprintf(dlpercen, sizeof(dlpercen), "%3" CURL_FORMAT_CURL_OFF_T,
+ all_dlnow < (CURL_OFF_T_MAX/100) ?
+ (all_dlnow * 100 / all_dltotal) :
+ (all_dlnow / (all_dltotal/100)));
if(ulknown && all_ultotal)
- msnprintf(ulpercen, sizeof(ulpercen), "%3" CURL_FORMAT_CURL_OFF_T,
- all_ulnow < (CURL_OFF_T_MAX/100) ?
- (all_ulnow * 100 / all_ultotal) :
- (all_ulnow / (all_ultotal/100)));
+ curl_msnprintf(ulpercen, sizeof(ulpercen), "%3" CURL_FORMAT_CURL_OFF_T,
+ all_ulnow < (CURL_OFF_T_MAX/100) ?
+ (all_ulnow * 100 / all_ultotal) :
+ (all_ulnow / (all_ultotal/100)));
/* get the transfer speed, the higher of the two */
(void)curl_multi_get_offt(multi, CURLMINFO_XFERS_ADDED, &xfers_added);
(void)curl_multi_get_offt(multi, CURLMINFO_XFERS_RUNNING, &xfers_running);
- fprintf(tool_stderr,
- "\r"
- "%-3s " /* percent downloaded */
- "%-3s " /* percent uploaded */
- "%s " /* Dled */
- "%s " /* Uled */
- "%5" CURL_FORMAT_CURL_OFF_T " " /* Xfers */
- "%5" CURL_FORMAT_CURL_OFF_T " " /* Live */
- " %s " /* Total time */
- "%s " /* Current time */
- "%s " /* Time left */
- "%s " /* Speed */
- "%5s" /* final newline */,
+ curl_mfprintf(tool_stderr,
+ "\r"
+ "%-3s " /* percent downloaded */
+ "%-3s " /* percent uploaded */
+ "%s " /* Dled */
+ "%s " /* Uled */
+ "%5" CURL_FORMAT_CURL_OFF_T " " /* Xfers */
+ "%5" CURL_FORMAT_CURL_OFF_T " " /* Live */
+ " %s " /* Total time */
+ "%s " /* Current time */
+ "%s " /* Time left */
+ "%s " /* Speed */
+ "%5s" /* final newline */,
- dlpercen, /* 3 letters */
- ulpercen, /* 3 letters */
- max5data(all_dlnow, buffer[0]),
- max5data(all_ulnow, buffer[1]),
- xfers_added,
- xfers_running,
- time_total,
- time_spent,
- time_left,
- max5data(speed, buffer[2]), /* speed */
- final ? "\n" :"");
+ dlpercen, /* 3 letters */
+ ulpercen, /* 3 letters */
+ max5data(all_dlnow, buffer[0]),
+ max5data(all_ulnow, buffer[1]),
+ xfers_added,
+ xfers_running,
+ time_total,
+ time_spent,
+ time_left,
+ max5data(speed, buffer[2]), /* speed */
+ final ? "\n" :"");
return TRUE;
}
return FALSE;
char preamble[80];
unsigned long rest = (unsigned long)lval;
const struct NameValueUnsigned *nv = NULL;
- msnprintf(preamble, sizeof(preamble),
- "curl_easy_setopt(hnd, %s, ", name);
+ curl_msnprintf(preamble, sizeof(preamble),
+ "curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */
if(!rest || ret)
break; /* handled them all */
/* replace with all spaces for continuation line */
- msnprintf(preamble, sizeof(preamble), "%*s", (int)strlen(preamble),
- "");
+ curl_msnprintf(preamble, sizeof(preamble), "%*s",
+ (int)strlen(preamble), "");
}
}
/* If any bits have no definition, output an explicit value.
char text[512];
const char *t;
if(glob->pos) {
- msnprintf(text, sizeof(text), "%s in URL position %zu:\n%s\n%*s^",
- glob->error,
- glob->pos, url, (int)glob->pos - 1, " ");
+ curl_msnprintf(text, sizeof(text), "%s in URL position %zu:\n%s\n%*s^",
+ glob->error,
+ glob->pos, url, (int)glob->pos - 1, " ");
t = text;
}
else
t = glob->error;
/* send error description to the error-stream */
- fprintf(error, "curl: (%d) %s\n", res, t);
+ curl_mfprintf(error, "curl: (%d) %s\n", res, t);
}
/* it failed, we cleanup */
glob_cleanup(glob);
}
else {
/* Invalid DECC feature value. */
- printf(" INVALID DECC FEATURE VALUE, %d: %d <= %s <= %d.\n",
- feat_value,
- feat_value_min, decc_feat_array[i].name, feat_value_max);
+ curl_mprintf(" INVALID DECC FEATURE VALUE, %d: %d <= %s <= %d.\n",
+ feat_value,
+ feat_value_min, decc_feat_array[i].name, feat_value_max);
}
}
else {
/* Invalid DECC feature name. */
- printf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name);
+ curl_mprintf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name);
}
}
us %= 1000000;
if(use_json)
- fprintf(stream, "\"%s\":", wovar->name);
+ curl_mfprintf(stream, "\"%s\":", wovar->name);
- fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU
- ".%06" CURL_FORMAT_CURL_OFF_TU, secs, us);
+ curl_mfprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU
+ ".%06" CURL_FORMAT_CURL_OFF_TU, secs, us);
}
else {
if(use_json)
- fprintf(stream, "\"%s\":null", wovar->name);
+ curl_mfprintf(stream, "\"%s\":null", wovar->name);
}
return 1; /* return 1 if anything was written */
DEBUGASSERT(!valid || strinfo);
if(valid && strinfo) {
if(use_json) {
- fprintf(stream, "\"%s\":", wovar->name);
+ curl_mfprintf(stream, "\"%s\":", wovar->name);
jsonWriteString(stream, strinfo, FALSE);
}
else
}
else {
if(use_json)
- fprintf(stream, "\"%s\":null", wovar->name);
+ curl_mfprintf(stream, "\"%s\":null", wovar->name);
}
curl_free((char *)CURL_UNCONST(freestr));
if(valid) {
if(use_json)
- fprintf(stream, "\"%s\":%ld", wovar->name, longinfo);
+ curl_mfprintf(stream, "\"%s\":%ld", wovar->name, longinfo);
else {
if(wovar->id == VAR_HTTP_CODE || wovar->id == VAR_HTTP_CODE_PROXY)
- fprintf(stream, "%03ld", longinfo);
+ curl_mfprintf(stream, "%03ld", longinfo);
else
- fprintf(stream, "%ld", longinfo);
+ curl_mfprintf(stream, "%ld", longinfo);
}
}
else {
if(use_json)
- fprintf(stream, "\"%s\":null", wovar->name);
+ curl_mfprintf(stream, "\"%s\":null", wovar->name);
}
return 1; /* return 1 if anything was written */
if(valid) {
if(use_json)
- fprintf(stream, "\"%s\":", wovar->name);
+ curl_mfprintf(stream, "\"%s\":", wovar->name);
- fprintf(stream, "%" CURL_FORMAT_CURL_OFF_T, offinfo);
+ curl_mfprintf(stream, "%" CURL_FORMAT_CURL_OFF_T, offinfo);
}
else {
if(use_json)
- fprintf(stream, "\"%s\":null", wovar->name);
+ curl_mfprintf(stream, "\"%s\":null", wovar->name);
}
return 1; /* return 1 if anything was written */
}
}
else {
- fprintf(tool_stderr,
- "curl: unknown --write-out variable: '%.*s'\n",
- (int)vlen, ptr);
+ curl_mfprintf(tool_stderr,
+ "curl: unknown --write-out variable: '%.*s'\n",
+ (int)vlen, ptr);
}
ptr = end + 1; /* pass the end */
}
/* The variables are sorted in alphabetical order but as a special case
curl_version (which is not actually a --write-out variable) is last. */
- fprintf(stream, "\"curl_version\":");
+ curl_mfprintf(stream, "\"curl_version\":");
jsonWriteString(stream, curl_version(), FALSE);
- fprintf(stream, "}");
+ curl_mfprintf(stream, "}");
}
void headerJSON(FILE *stream, struct per_transfer *per)
if(value) {
#ifdef DEBUGBUILD
if(getenv("CURL_FAKE_XATTR")) {
- printf("%s => %s\n", attr, value);
+ curl_mprintf("%s => %s\n", attr, value);
return 0;
}
#endif