lib: stop overriding system printf symbols

After this patch, the codebase no longer overrides system printf
functions. Instead it explicitly calls either the curl printf functions
`curl_m*printf()` or the system ones using their original names.

Also:
- drop unused `curl_printf.h` includes.
- checksrc: ban system printf functions, allow where necessary.

Follow-up to db98daab05 #18844
Follow-up to 4deea9396b #18814

Closes #18866
This commit is contained in:
Viktor Szakats 2025-10-04 12:58:49 +02:00
parent 13f10add17
commit b12da22db1
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
147 changed files with 1030 additions and 1145 deletions

View file

@ -41,17 +41,9 @@ path = [
"tests/valgrind.supp",
# checksrc control files
"docs/examples/.checksrc",
"lib/.checksrc",
"lib/curlx/.checksrc",
"lib/vauth/.checksrc",
"lib/vquic/.checksrc",
"lib/vssh/.checksrc",
"lib/vtls/.checksrc",
"scripts/.checksrc",
"src/.checksrc",
"tests/libtest/.checksrc",
"tests/server/.checksrc",
"tests/tunit/.checksrc",
"tests/unit/.checksrc",
]
SPDX-FileCopyrightText = "Daniel Stenberg, <daniel@haxx.se>, et al."
SPDX-License-Identifier = "curl"

View file

@ -1,9 +1,11 @@
allowfunc fclose
allowfunc fdopen
allowfunc fopen
allowfunc fprintf
allowfunc gmtime
allowfunc localtime
allowfunc open
allowfunc printf
allowfunc snprintf
allowfunc socket
allowfunc sscanf

View file

View file

@ -28,12 +28,9 @@ include Makefile.inc
CMAKE_DIST = CMakeLists.txt curl_config.h.cmake
CHECKSRC_DIST = .checksrc \
curlx/.checksrc vauth/.checksrc vquic/.checksrc vssh/.checksrc vtls/.checksrc
EXTRA_DIST = config-mac.h config-os400.h config-plan9.h config-riscos.h \
config-win32.h curl_config.h.in $(LIB_RCFILES) libcurl.def \
$(CMAKE_DIST) Makefile.soname optiontable.pl $(CHECKSRC_DIST)
$(CMAKE_DIST) Makefile.soname optiontable.pl
lib_LTLIBRARIES = libcurl.la

View file

@ -42,8 +42,7 @@
#include "curlx/strparse.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -270,7 +269,7 @@ static CURLcode altsvc_out(struct altsvc *as, FILE *fp)
}
}
#endif
fprintf(fp,
curl_mfprintf(fp,
"%s %s%s%s %u "
"%s %s%s%s %u "
"\"%d%02d%02d "

View file

@ -105,8 +105,7 @@
#define HTTPSRR_WORKS
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -782,7 +781,7 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data,
* accordingly to save a call to getservbyname in inside C-Ares
*/
hints.ai_flags = ARES_AI_NUMERICSERV;
msnprintf(service, sizeof(service), "%d", port);
curl_msnprintf(service, sizeof(service), "%d", port);
ares->num_pending = 1;
ares_getaddrinfo(ares->channel, data->state.async.hostname,
service, &hints, async_ares_addrinfo_cb, data);

View file

@ -73,8 +73,7 @@
#endif
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -220,7 +219,7 @@ static CURL_THREAD_RETURN_T CURL_STDCALL getaddrinfo_thread(void *arg)
char service[12];
int rc;
msnprintf(service, sizeof(service), "%d", addr_ctx->port);
curl_msnprintf(service, sizeof(service), "%d", addr_ctx->port);
rc = Curl_getaddrinfo_ex(addr_ctx->hostname, service,
&addr_ctx->hints, &addr_ctx->res);

View file

@ -25,8 +25,7 @@
#include "curl_setup.h"
#include "bufq.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -46,8 +46,7 @@
#include "multiif.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -44,8 +44,7 @@
#include "select.h"
#include "cf-h2-proxy.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -101,7 +100,7 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf,
return result;
ts->authority = /* host:port with IPv6 support */
aprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,
curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,
ipv6_ip ? "]" : "", port);
if(!ts->authority)
return CURLE_OUT_OF_MEMORY;
@ -556,44 +555,44 @@ static int proxy_h2_fr_print(const nghttp2_frame *frame,
{
switch(frame->hd.type) {
case NGHTTP2_DATA: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[DATA, len=%d, eos=%d, padlen=%d]",
(int)frame->hd.length,
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
(int)frame->data.padlen);
}
case NGHTTP2_HEADERS: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
(int)frame->hd.length,
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
}
case NGHTTP2_PRIORITY: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[PRIORITY, len=%d, flags=%d]",
(int)frame->hd.length, frame->hd.flags);
}
case NGHTTP2_RST_STREAM: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
(int)frame->hd.length, frame->hd.flags,
frame->rst_stream.error_code);
}
case NGHTTP2_SETTINGS: {
if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
return msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
}
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
}
case NGHTTP2_PUSH_PROMISE:
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[PUSH_PROMISE, len=%d, hend=%d]",
(int)frame->hd.length,
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
case NGHTTP2_PING:
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[PING, len=%d, ack=%d]",
(int)frame->hd.length,
frame->hd.flags & NGHTTP2_FLAG_ACK);
@ -605,17 +604,18 @@ static int proxy_h2_fr_print(const nghttp2_frame *frame,
if(len)
memcpy(scratch, frame->goaway.opaque_data, len);
scratch[len] = '\0';
return msnprintf(buffer, blen, "FRAME[GOAWAY, error=%d, reason='%s', "
return curl_msnprintf(buffer, blen,
"FRAME[GOAWAY, error=%d, reason='%s', "
"last_stream=%d]", frame->goaway.error_code,
scratch, frame->goaway.last_stream_id);
}
case NGHTTP2_WINDOW_UPDATE: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[WINDOW_UPDATE, incr=%d]",
frame->window_update.window_size_increment);
}
default:
return msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
frame->hd.type, (int)frame->hd.length,
frame->hd.flags);
}

View file

@ -34,8 +34,7 @@
#include "multiif.h"
#include "select.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -38,8 +38,7 @@
#include "select.h"
#include "vquic/vquic.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -60,8 +60,7 @@
#include "select.h"
#include "vquic/vquic.h" /* for quic cfilters */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -662,7 +661,8 @@ static CURLcode is_connected(struct Curl_cfilter *cf,
#ifdef USE_UNIX_SOCKETS
if(conn->unix_domain_socket)
msnprintf(viamsg, sizeof(viamsg), "over %s", conn->unix_domain_socket);
curl_msnprintf(viamsg, sizeof(viamsg), "over %s",
conn->unix_domain_socket);
else
#endif
{
@ -673,7 +673,7 @@ static CURLcode is_connected(struct Curl_cfilter *cf,
port = conn->conn_to_port;
else
port = conn->remote_port;
msnprintf(viamsg, sizeof(viamsg), "port %u", port);
curl_msnprintf(viamsg, sizeof(viamsg), "port %u", port);
}
failf(data, "Failed to connect to %s %s %s%s%safter "

View file

@ -82,8 +82,7 @@
#include "curlx/strerr.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -37,8 +37,7 @@
#include "curlx/warnless.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -45,8 +45,7 @@
#include "curlx/strparse.h"
#include "uint-table.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -895,7 +894,7 @@ void Curl_cpool_print(struct cpool *cpool)
if(!cpool)
return;
fprintf(stderr, "=Bundle cache=\n");
curl_mfprintf(stderr, "=Bundle cache=\n");
Curl_hash_start_iterate(cpool->dest2bundle, &iter);
@ -906,15 +905,15 @@ void Curl_cpool_print(struct cpool *cpool)
bundle = he->ptr;
fprintf(stderr, "%s -", he->key);
curl_mfprintf(stderr, "%s -", he->key);
curr = Curl_llist_head(bundle->conns);
while(curr) {
conn = Curl_node_elem(curr);
fprintf(stderr, " [%p %d]", (void *)conn, conn->refcount);
curl_mfprintf(stderr, " [%p %d]", (void *)conn, conn->refcount);
curr = Curl_node_next(curr);
}
fprintf(stderr, "\n");
curl_mfprintf(stderr, "\n");
he = Curl_hash_next_element(&iter);
}

View file

@ -75,8 +75,7 @@
#include "http_proxy.h"
#include "socks.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -267,7 +266,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
case AF_UNIX:
if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
su = (struct sockaddr_un*)sa;
msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
}
else
addr[0] = 0; /* socket with no name */

View file

@ -53,8 +53,7 @@
#include "content_encoding.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -89,8 +89,7 @@ Example set of cookies:
#include "llist.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -1479,7 +1478,7 @@ void Curl_cookie_cleanup(struct CookieInfo *ci)
*/
static char *get_netscape_format(const struct Cookie *co)
{
return aprintf(
return curl_maprintf(
"%s" /* httponly preamble */
"%s%s\t" /* domain */
"%s\t" /* tailmatch */
@ -1575,7 +1574,7 @@ static CURLcode cookie_output(struct Curl_easy *data,
error = CURLE_OUT_OF_MEMORY;
goto error;
}
fprintf(out, "%s\n", format_ptr);
curl_mfprintf(out, "%s\n", format_ptr);
free(format_ptr);
}

View file

@ -42,8 +42,7 @@
#include "select.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -53,8 +53,8 @@
#include "fake_addrinfo.h"
#include "curlx/inet_pton.h"
#include "curlx/warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -30,8 +30,8 @@
#include "urldata.h"
#include "rand.h"
#include "curl_fopen.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -122,7 +122,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
if(dir) {
/* The temp filename should not end up too long for the target file
system */
tempstore = aprintf("%s%s.tmp", dir, randbuf);
tempstore = curl_maprintf("%s%s.tmp", dir, randbuf);
free(dir);
}

View file

@ -29,8 +29,7 @@
#include "curl_gssapi.h"
#include "sendf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -244,8 +243,9 @@ stub_gss_init_sec_context(OM_uint32 *min,
}
/* Token format: creds:target:type:padding */
used = msnprintf(token, length, "%s:%.*s:%d:", creds,
(int)target_desc.length, (const char *)target_desc.value,
used = curl_msnprintf(token, length, "%s:%.*s:%d:", creds,
(int)target_desc.length,
(const char *)target_desc.value,
ctx->sent);
gss_release_buffer(&minor_status, &target_desc);
@ -387,7 +387,7 @@ static size_t display_gss_error(OM_uint32 status, int type,
&status_string);
if(maj_stat == GSS_S_COMPLETE && status_string.length > 0) {
if(GSS_LOG_BUFFER_LEN > len + status_string.length + 3) {
len += msnprintf(buf + len, GSS_LOG_BUFFER_LEN - len,
len += curl_msnprintf(buf + len, GSS_LOG_BUFFER_LEN - len,
"%.*s. ", (int)status_string.length,
(char *)status_string.value);
}

View file

@ -119,8 +119,8 @@
#include "curl_endian.h"
#include "curl_des.h"
#include "curl_md4.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -567,14 +567,15 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
return CURLE_OUT_OF_MEMORY;
/* Create the BLOB structure */
msnprintf((char *)ptr + HMAC_MD5_LENGTH, NTLMv2_BLOB_LEN,
curl_msnprintf((char *)ptr + HMAC_MD5_LENGTH, NTLMv2_BLOB_LEN,
"%c%c%c%c" /* NTLMv2_BLOB_SIGNATURE */
"%c%c%c%c" /* Reserved = 0 */
"%c%c%c%c%c%c%c%c", /* Timestamp */
NTLMv2_BLOB_SIGNATURE[0], NTLMv2_BLOB_SIGNATURE[1],
NTLMv2_BLOB_SIGNATURE[2], NTLMv2_BLOB_SIGNATURE[3],
0, 0, 0, 0,
LONGQUARTET(tw.dwLowDateTime), LONGQUARTET(tw.dwHighDateTime));
LONGQUARTET(tw.dwLowDateTime),
LONGQUARTET(tw.dwHighDateTime));
memcpy(ptr + 32, challenge_client, 8);
if(ntlm->target_info_len)

View file

@ -24,8 +24,6 @@
*
***************************************************************************/
#include <curl/mprintf.h>
#define MERR_OK 0
#define MERR_MEM 1
#define MERR_TOO_LARGE 2
@ -36,29 +34,4 @@ extern const unsigned char Curl_ldigits[];
/* Upper-case digits. */
extern const unsigned char Curl_udigits[];
#ifdef BUILDING_LIBCURL
/*
* This header should be included by ALL code in libcurl that uses any
* *rintf() functions.
*/
# 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
#endif /* BUILDING_LIBCURL */
#endif /* HEADER_CURL_PRINTF_H */

View file

@ -37,8 +37,7 @@
#include <curl/curl.h>
#include <librtmp/rtmp.h>
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -386,7 +385,7 @@ void Curl_rtmp_version(char *version, size_t len)
else
suff[0] = '\0';
msnprintf(version, len, "librtmp/%d.%d%s",
curl_msnprintf(version, len, "librtmp/%d.%d%s",
RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
suff);
}

View file

@ -51,8 +51,8 @@
#include "curl_sasl.h"
#include "curlx/warnless.h"
#include "sendf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -983,6 +983,8 @@ extern curl_calloc_callback Curl_ccalloc;
#define Curl_safefree(ptr) \
do { free((ptr)); (ptr) = NULL;} while(0)
#include <curl/curl.h> /* for CURL_EXTERN, mprintf.h */
#ifdef CURLDEBUG
#ifdef __clang__
# define ALLOC_FUNC __attribute__((__malloc__))
@ -1007,8 +1009,6 @@ extern curl_calloc_callback Curl_ccalloc;
# define ALLOC_SIZE2(n, s)
#endif
#include <curl/curl.h> /* for CURL_EXTERN */
extern FILE *curl_dbg_logfile;
/* memory functions */

View file

@ -47,8 +47,7 @@
#include "vtls/vtls.h"
#include "vquic/vquic.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -102,14 +101,14 @@ static size_t trc_print_ids(struct Curl_easy *data, char *buf, size_t maxlen)
data->conn->connection_id : data->state.recent_conn_id;
if(data->id >= 0) {
if(cid >= 0)
return msnprintf(buf, maxlen, CURL_TRC_FMT_IDSDC, data->id, cid);
return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSDC, data->id, cid);
else
return msnprintf(buf, maxlen, CURL_TRC_FMT_IDSD, data->id);
return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSD, data->id);
}
else if(cid >= 0)
return msnprintf(buf, maxlen, CURL_TRC_FMT_IDSC, cid);
return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSC, cid);
else {
return msnprintf(buf, maxlen, "[x-x] ");
return curl_msnprintf(buf, maxlen, "[x-x] ");
}
}
@ -143,7 +142,7 @@ void Curl_debug(struct Curl_easy *data, curl_infotype type,
if(CURL_TRC_IDS(data) && (size < TRC_LINE_MAX)) {
len = trc_print_ids(data, buf, TRC_LINE_MAX);
len += msnprintf(buf + len, TRC_LINE_MAX - len, "%.*s",
len += curl_msnprintf(buf + len, TRC_LINE_MAX - len, "%.*s",
(int)size, ptr);
len = trc_end_buf(buf, len, TRC_LINE_MAX, FALSE);
Curl_set_in_callback(data, TRUE);
@ -189,7 +188,7 @@ void Curl_failf(struct Curl_easy *data, const char *fmt, ...)
size_t len;
char error[CURL_ERROR_SIZE + 2];
va_start(ap, fmt);
len = mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
len = curl_mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
if(data->set.errorbuffer && !data->state.errorbuf) {
strcpy(data->set.errorbuffer, error);
@ -220,15 +219,15 @@ static void trc_infof(struct Curl_easy *data,
if(CURL_TRC_IDS(data))
len += trc_print_ids(data, buf + len, TRC_LINE_MAX - len);
if(feat)
len += msnprintf(buf + len, TRC_LINE_MAX - len, "[%s] ", feat->name);
len += curl_msnprintf(buf + len, TRC_LINE_MAX - len, "[%s] ", feat->name);
if(opt_id) {
if(opt_id_idx > 0)
len += msnprintf(buf + len, TRC_LINE_MAX - len, "[%s-%d] ",
len += curl_msnprintf(buf + len, TRC_LINE_MAX - len, "[%s-%d] ",
opt_id, opt_id_idx);
else
len += msnprintf(buf + len, TRC_LINE_MAX - len, "[%s] ", opt_id);
len += curl_msnprintf(buf + len, TRC_LINE_MAX - len, "[%s] ", opt_id);
}
len += mvsnprintf(buf + len, TRC_LINE_MAX - len, fmt, ap);
len += curl_mvsnprintf(buf + len, TRC_LINE_MAX - len, fmt, ap);
len = trc_end_buf(buf, len, TRC_LINE_MAX, TRUE);
trc_write(data, CURLINFO_TEXT, buf, len);
}

View file

View file

@ -35,8 +35,7 @@
#include "cw-out.h"
#include "cw-pause.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -34,8 +34,7 @@
#include "sendf.h"
#include "cw-pause.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -59,9 +59,9 @@
#include "escape.h"
#include "progress.h"
#include "dict.h"
#include "curl_printf.h"
/* The last 2 #include files should be: */
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
@ -144,7 +144,7 @@ static CURLcode sendf(struct Curl_easy *data, const char *fmt, ...)
char *sptr;
va_list ap;
va_start(ap, fmt);
s = vaprintf(fmt, ap); /* returns an allocated string */
s = curl_mvaprintf(fmt, ap); /* returns an allocated string */
va_end(ap);
if(!s)
return CURLE_OUT_OF_MEMORY; /* failure */

View file

@ -28,8 +28,7 @@
#include <openssl/crypto.h>
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -41,8 +41,7 @@
#include "escape.h"
#include "urlapi-int.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -513,7 +512,7 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data,
/* Only use HTTPS RR for HTTP(S) transfers */
char *qname = NULL;
if(port != PORT_HTTPS) {
qname = aprintf("_%d._https.%s", port, hostname);
qname = curl_maprintf("_%d._https.%s", port, hostname);
if(!qname)
goto error;
}
@ -890,7 +889,8 @@ static void doh_show(struct Curl_easy *data,
len = sizeof(buffer) - len;
for(j = 0; j < 16; j += 2) {
size_t l;
msnprintf(ptr, len, "%s%02x%02x", j ? ":" : "", d->addr[i].ip.v6[j],
curl_msnprintf(ptr, len, "%s%02x%02x", j ? ":" : "",
d->addr[i].ip.v6[j],
d->addr[i].ip.v6[j + 1]);
l = strlen(ptr);
len -= l;

View file

@ -26,12 +26,12 @@
#include "dynhds.h"
#include "strcase.h"
/* The last 3 #include files should be in this order */
#ifdef USE_NGHTTP2
#include <stdint.h>
#include <nghttp2/nghttp2.h>
#endif /* USE_NGHTTP2 */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -80,8 +80,7 @@
#include "easy_lock.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -157,42 +156,42 @@ static CURLcode global_init(long flags, bool memoryfuncs)
}
if(Curl_trc_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_trc_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_trc_init failed\n"));
goto fail;
}
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_ssl_init failed\n"));
goto fail;
}
if(!Curl_vquic_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_vquic_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_vquic_init failed\n"));
goto fail;
}
if(Curl_win32_init(flags)) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: win32_init failed\n"));
goto fail;
}
if(Curl_amiga_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_amiga_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_amiga_init failed\n"));
goto fail;
}
if(Curl_macos_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_macos_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_macos_init failed\n"));
goto fail;
}
if(Curl_async_global_init()) {
DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: resolver_global_init failed\n"));
goto fail;
}
if(Curl_ssh_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssh_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_ssh_init failed\n"));
goto fail;
}
@ -361,7 +360,7 @@ CURL *curl_easy_init(void)
result = global_init(CURL_GLOBAL_DEFAULT, TRUE);
if(result) {
/* something in the global init failed, return nothing */
DEBUGF(fprintf(stderr, "Error: curl_global_init failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: curl_global_init failed\n"));
global_init_unlock();
return NULL;
}
@ -371,7 +370,7 @@ CURL *curl_easy_init(void)
/* We use curl_open() with undefined URL so far */
result = Curl_open(&data);
if(result) {
DEBUGF(fprintf(stderr, "Error: Curl_open failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: Curl_open failed\n"));
return NULL;
}
@ -407,7 +406,7 @@ static int events_timer(CURLM *multi, /* multi handle */
struct events *ev = userp;
(void)multi;
#if DEBUG_EV_POLL
fprintf(stderr, "events_timer: set timeout %ldms\n", timeout_ms);
curl_mfprintf(stderr, "events_timer: set timeout %ldms\n", timeout_ms);
#endif
ev->ms = timeout_ms;
ev->msbump = TRUE;
@ -559,7 +558,7 @@ static unsigned int populate_fds(struct pollfd *fds, struct events *ev)
f->events = m->socket.events;
f->revents = 0;
#if DEBUG_EV_POLL
fprintf(stderr, "poll() %d check socket %d\n", numfds, f->fd);
curl_mfprintf(stderr, "poll() %d check socket %d\n", numfds, f->fd);
#endif
f++;
numfds++;
@ -579,11 +578,11 @@ static CURLcode poll_fds(struct events *ev,
if(numfds) {
/* wait for activity or timeout */
#if DEBUG_EV_POLL
fprintf(stderr, "poll(numfds=%u, timeout=%ldms)\n", numfds, ev->ms);
curl_mfprintf(stderr, "poll(numfds=%u, timeout=%ldms)\n", numfds, ev->ms);
#endif
*pollrc = Curl_poll(fds, numfds, ev->ms);
#if DEBUG_EV_POLL
fprintf(stderr, "poll(numfds=%u, timeout=%ldms) -> %d\n",
curl_mfprintf(stderr, "poll(numfds=%u, timeout=%ldms) -> %d\n",
numfds, ev->ms, *pollrc);
#endif
if(*pollrc < 0)
@ -591,7 +590,7 @@ static CURLcode poll_fds(struct events *ev,
}
else {
#if DEBUG_EV_POLL
fprintf(stderr, "poll, but no fds, wait timeout=%ldms\n", ev->ms);
curl_mfprintf(stderr, "poll, but no fds, wait timeout=%ldms\n", ev->ms);
#endif
*pollrc = 0;
if(ev->ms > 0)
@ -629,7 +628,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
if(!pollrc) {
/* timeout! */
ev->ms = 0;
/* fprintf(stderr, "call curl_multi_socket_action(TIMEOUT)\n"); */
/* curl_mfprintf(stderr, "call curl_multi_socket_action(TIMEOUT)\n"); */
mcode = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0,
&ev->running_handles);
}
@ -658,7 +657,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
timediff_t timediff = curlx_timediff(curlx_now(), before);
if(timediff > 0) {
#if DEBUG_EV_POLL
fprintf(stderr, "poll timeout %ldms not updated, decrease by "
curl_mfprintf(stderr, "poll timeout %ldms not updated, decrease by "
"time spent %ldms\n", ev->ms, (long)timediff);
#endif
if(timediff > ev->ms)

View file

@ -36,9 +36,9 @@ struct Curl_easy;
#include "escape.h"
#include "strdup.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -31,8 +31,7 @@
#include <stdlib.h>
#include <ares.h>
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -178,7 +177,7 @@ int r_getaddrinfo(const char *node,
if(env) {
rc = ares_set_servers_ports_csv(channel, env);
if(rc) {
fprintf(stderr, "ares_set_servers_ports_csv failed: %d", rc);
curl_mfprintf(stderr, "ares_set_servers_ports_csv failed: %d", rc);
/* Cleanup */
ares_destroy(channel);
return EAI_MEMORY; /* we can't run */

View file

@ -69,8 +69,8 @@
#include "curlx/fopen.h"
#include "curlx/warnless.h"
#include "curl_range.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -488,8 +488,8 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
static const char accept_ranges[]= { "Accept-ranges: bytes\r\n" };
if(expected_size >= 0) {
headerlen =
msnprintf(header, sizeof(header), "Content-Length: %" FMT_OFF_T "\r\n",
expected_size);
curl_msnprintf(header, sizeof(header),
"Content-Length: %" FMT_OFF_T "\r\n", expected_size);
result = Curl_client_write(data, CLIENTWRITE_HEADER, header, headerlen);
if(result)
return result;
@ -507,7 +507,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
headerlen =
msnprintf(header, sizeof(header),
curl_msnprintf(header, sizeof(header),
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6],
tm->tm_mday,

View file

@ -38,8 +38,8 @@ struct Curl_easy;
#include "strdup.h"
#include "rand.h"
#include "curlx/warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -72,8 +72,8 @@
#include "strdup.h"
#include "curlx/strerr.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -1209,7 +1209,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
source++;
}
*dest = 0;
msnprintf(dest, 20, ",%d,%d", (int)(port >> 8), (int)(port & 0xff));
curl_msnprintf(dest, 20, ",%d,%d", (int)(port >> 8), (int)(port & 0xff));
result = Curl_pp_sendf(data, &ftpc->pp, "%s %s", mode[fcmd], target);
if(result) {
@ -1422,7 +1422,7 @@ static CURLcode ftp_state_list(struct Curl_easy *data,
}
}
cmd = aprintf("%s%s%.*s",
cmd = curl_maprintf("%s%s%.*s",
data->set.str[STRING_CUSTOMREQUEST] ?
data->set.str[STRING_CUSTOMREQUEST] :
(data->state.list_only ? "NLST" : "LIST"),
@ -1887,7 +1887,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
ftpc->newhost = control_address_dup(data, conn);
}
else
ftpc->newhost = aprintf("%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
ftpc->newhost = curl_maprintf("%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
if(!ftpc->newhost)
return CURLE_OUT_OF_MEMORY;
@ -2093,7 +2093,7 @@ static CURLcode ftp_state_mdtm_resp(struct Curl_easy *data,
if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */
char timebuf[24];
msnprintf(timebuf, sizeof(timebuf),
curl_msnprintf(timebuf, sizeof(timebuf),
"%04d%02d%02d %02d:%02d:%02d GMT",
year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
@ -2128,8 +2128,9 @@ static CURLcode ftp_state_mdtm_resp(struct Curl_easy *data,
/* format: "Tue, 15 Nov 1994 12:45:26" */
headerbuflen =
msnprintf(headerbuf, sizeof(headerbuf),
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
curl_msnprintf(headerbuf, sizeof(headerbuf),
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d "
"GMT\r\n",
Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6],
tm->tm_mday,
Curl_month[tm->tm_mon],
@ -2349,8 +2350,9 @@ static CURLcode ftp_state_size_resp(struct Curl_easy *data,
#ifdef CURL_FTP_HTTPSTYLE_HEAD
if(filesize != -1) {
char clbuf[128];
int clbuflen = msnprintf(clbuf, sizeof(clbuf),
"Content-Length: %" FMT_OFF_T "\r\n", filesize);
int clbuflen = curl_msnprintf(clbuf, sizeof(clbuf),
"Content-Length: %" FMT_OFF_T "\r\n",
filesize);
result = client_write_header(data, clbuf, clbuflen);
if(result)
return result;
@ -3937,7 +3939,7 @@ static CURLcode wc_statemach(struct Curl_easy *data,
struct Curl_llist_node *head = Curl_llist_head(&wildcard->filelist);
struct curl_fileinfo *finfo = Curl_node_elem(head);
char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename);
char *tmp_path = curl_maprintf("%s%s", wildcard->path, finfo->filename);
if(!tmp_path)
return CURLE_OUT_OF_MEMORY;

View file

@ -52,8 +52,7 @@
#include "multiif.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -40,9 +40,9 @@
#include "url.h"
#include "escape.h"
#include "curlx/warnless.h"
#include "curl_printf.h"
/* The last 2 #include files should be: */
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
/*
@ -153,7 +153,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
DEBUGASSERT(path);
if(query)
gopherpath = aprintf("%s?%s", path, query);
gopherpath = curl_maprintf("%s?%s", path, query);
else
gopherpath = strdup(path);

View file

@ -51,16 +51,16 @@ void Curl_hash_print(struct Curl_hash *h,
if(!h)
return;
fprintf(stderr, "=Hash dump=\n");
curl_mfprintf(stderr, "=Hash dump=\n");
Curl_hash_start_iterate(h, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
if(iter.slot_index != last_index) {
fprintf(stderr, "index %d:", (int)iter.slot_index);
curl_mfprintf(stderr, "index %d:", (int)iter.slot_index);
if(last_index != UINT_MAX) {
fprintf(stderr, "\n");
curl_mfprintf(stderr, "\n");
}
last_index = iter.slot_index;
}
@ -68,13 +68,13 @@ void Curl_hash_print(struct Curl_hash *h,
if(func)
func(he->ptr);
else
fprintf(stderr, " [key=%.*s, he=%p, ptr=%p]",
curl_mfprintf(stderr, " [key=%.*s, he=%p, ptr=%p]",
(int)he->key_len, (char *)he->key,
(void *)he, (void *)he->ptr);
he = Curl_hash_next_element(&iter);
}
fprintf(stderr, "\n");
curl_mfprintf(stderr, "\n");
}
#endif

View file

@ -30,8 +30,7 @@
#include "headers.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -64,8 +64,7 @@
#include "easy_lock.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -176,7 +175,7 @@ create_dnscache_id(const char *name,
len = buflen - 7;
/* store and lower case the name */
Curl_strntolower(ptr, name, len);
return msnprintf(&ptr[len], 7, ":%u", port) + len;
return curl_msnprintf(&ptr[len], 7, ":%u", port) + len;
}
struct dnscache_prune_data {

View file

@ -49,8 +49,8 @@
#include "hash.h"
#include "share.h"
#include "url.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -125,7 +125,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
hints.ai_family = PF_INET;
hints.ai_socktype = SOCK_STREAM;
if(port) {
msnprintf(sbuf, sizeof(sbuf), "%d", port);
curl_msnprintf(sbuf, sizeof(sbuf), "%d", port);
sbufptr = sbuf;
}

View file

@ -52,8 +52,8 @@
#include "url.h"
#include "curlx/inet_pton.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -62,13 +62,14 @@
#ifdef DEBUG_ADDRINFO
static void dump_addrinfo(const struct Curl_addrinfo *ai)
{
printf("dump_addrinfo:\n");
curl_mprintf("dump_addrinfo:\n");
for(; ai; ai = ai->ai_next) {
char buf[INET6_ADDRSTRLEN];
printf(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
curl_mprintf(" fam %2d, CNAME %s, ",
ai->ai_family,
ai->ai_canonname ? ai->ai_canonname : "<none>");
Curl_printable_address(ai, buf, sizeof(buf));
printf("%s\n", buf);
curl_mprintf("%s\n", buf);
}
}
#else
@ -122,7 +123,7 @@ struct Curl_addrinfo *Curl_sync_getaddrinfo(struct Curl_easy *data,
#endif
if(port) {
msnprintf(sbuf, sizeof(sbuf), "%d", port);
curl_msnprintf(sbuf, sizeof(sbuf), "%d", port);
sbufptr = sbuf;
}

View file

@ -41,8 +41,7 @@
#include "strdup.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -308,7 +307,7 @@ static CURLcode hsts_push(struct Curl_easy *data,
if(result)
return result;
msnprintf(e.expire, sizeof(e.expire), "%d%02d%02d %02d:%02d:%02d",
curl_msnprintf(e.expire, sizeof(e.expire), "%d%02d%02d %02d:%02d:%02d",
stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
}
@ -331,13 +330,13 @@ static CURLcode hsts_out(struct stsentry *sts, FILE *fp)
CURLcode result = Curl_gmtime((time_t)sts->expires, &stamp);
if(result)
return result;
fprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n",
curl_mfprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n",
sts->includeSubDomains ? ".": "", sts->host,
stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
}
else
fprintf(fp, "%s%s \"%s\"\n",
curl_mfprintf(fp, "%s%s \"%s\"\n",
sts->includeSubDomains ? ".": "", sts->host, UNLIMITED);
return CURLE_OK;
}

View file

@ -87,8 +87,7 @@
#include "curl_ctype.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -337,7 +336,7 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy)
pwd = data->state.aptr.passwd;
}
out = aprintf("%s:%s", user ? user : "", pwd ? pwd : "");
out = curl_maprintf("%s:%s", user ? user : "", pwd ? pwd : "");
if(!out)
return CURLE_OUT_OF_MEMORY;
@ -351,7 +350,7 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy)
}
free(*userp);
*userp = aprintf("%sAuthorization: Basic %s\r\n",
*userp = curl_maprintf("%sAuthorization: Basic %s\r\n",
proxy ? "Proxy-" : "",
authorization);
free(authorization);
@ -381,7 +380,7 @@ static CURLcode http_output_bearer(struct Curl_easy *data)
userp = &data->state.aptr.userpwd;
free(*userp);
*userp = aprintf("Authorization: Bearer %s\r\n",
*userp = curl_maprintf("Authorization: Bearer %s\r\n",
data->set.str[STRING_BEARER]);
if(!*userp) {
@ -1795,7 +1794,7 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
*/
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
msnprintf(datestr, sizeof(datestr),
curl_msnprintf(datestr, sizeof(datestr),
"%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
condp,
Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6],
@ -1936,7 +1935,7 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
#endif
if(!curl_strequal("Host:", ptr)) {
aptr->host = aprintf("Host:%s\r\n", &ptr[5]);
aptr->host = curl_maprintf("Host:%s\r\n", &ptr[5]);
if(!aptr->host)
return CURLE_OUT_OF_MEMORY;
}
@ -1952,10 +1951,11 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
(conn->remote_port == PORT_HTTP)) )
/* if(HTTPS on port 443) OR (HTTP on port 80) then do not include
the port number in the host string */
aptr->host = aprintf("Host: %s%s%s\r\n", conn->bits.ipv6_ip ? "[" : "",
aptr->host = curl_maprintf("Host: %s%s%s\r\n",
conn->bits.ipv6_ip ? "[" : "",
host, conn->bits.ipv6_ip ? "]" : "");
else
aptr->host = aprintf("Host: %s%s%s:%d\r\n",
aptr->host = curl_maprintf("Host: %s%s%s:%d\r\n",
conn->bits.ipv6_ip ? "[" : "",
host, conn->bits.ipv6_ip ? "]" : "",
conn->remote_port);
@ -2494,7 +2494,7 @@ static CURLcode http_range(struct Curl_easy *data,
!Curl_checkheaders(data, STRCONST("Range"))) {
/* if a line like this was already allocated, free the previous one */
free(data->state.aptr.rangeline);
data->state.aptr.rangeline = aprintf("Range: bytes=%s\r\n",
data->state.aptr.rangeline = curl_maprintf("Range: bytes=%s\r\n",
data->state.range);
}
else if((httpreq == HTTPREQ_POST || httpreq == HTTPREQ_PUT) &&
@ -2508,8 +2508,8 @@ static CURLcode http_range(struct Curl_easy *data,
remote part so we tell the server (and act accordingly) that we
upload the whole file (again) */
data->state.aptr.rangeline =
aprintf("Content-Range: bytes 0-%" FMT_OFF_T "/%" FMT_OFF_T "\r\n",
req_clen - 1, req_clen);
curl_maprintf("Content-Range: bytes 0-%" FMT_OFF_T "/"
"%" FMT_OFF_T "\r\n", req_clen - 1, req_clen);
}
else if(data->state.resume_from) {
@ -2521,14 +2521,15 @@ static CURLcode http_range(struct Curl_easy *data,
data->state.infilesize :
(data->state.resume_from + req_clen);
data->state.aptr.rangeline =
aprintf("Content-Range: bytes %s%" FMT_OFF_T "/%" FMT_OFF_T "\r\n",
curl_maprintf("Content-Range: bytes %s%" FMT_OFF_T "/"
"%" FMT_OFF_T "\r\n",
data->state.range, total_len-1, total_len);
}
else {
/* Range was selected and then we just pass the incoming range and
append total size */
data->state.aptr.rangeline =
aprintf("Content-Range: bytes %s/%" FMT_OFF_T "\r\n",
curl_maprintf("Content-Range: bytes %s/%" FMT_OFF_T "\r\n",
data->state.range, req_clen);
}
if(!data->state.aptr.rangeline)
@ -2931,7 +2932,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
/* setup the authentication headers, how that method and host are known */
char *pq = NULL;
if(data->state.up.query) {
pq = aprintf("%s?%s", data->state.up.path, data->state.up.query);
pq = curl_maprintf("%s?%s", data->state.up.path, data->state.up.query);
if(!pq)
return CURLE_OUT_OF_MEMORY;
}

View file

@ -32,8 +32,7 @@
#include "http1.h"
#include "urlapi-int.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -47,8 +47,8 @@
#include "transfer.h"
#include "curlx/dynbuf.h"
#include "headers.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
@ -734,7 +734,7 @@ static CURLcode http2_send_ping(struct Curl_cfilter *cf,
void Curl_http2_ver(char *p, size_t len)
{
nghttp2_info *h2 = nghttp2_version(0);
(void)msnprintf(p, len, "nghttp2/%s", h2->version_str);
(void)curl_msnprintf(p, len, "nghttp2/%s", h2->version_str);
}
static CURLcode nw_out_flush(struct Curl_cfilter *cf,
@ -1214,45 +1214,45 @@ static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen)
{
switch(frame->hd.type) {
case NGHTTP2_DATA: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[DATA, len=%d, eos=%d, padlen=%d]",
(int)frame->hd.length,
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
(int)frame->data.padlen);
}
case NGHTTP2_HEADERS: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
(int)frame->hd.length,
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
}
case NGHTTP2_PRIORITY: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[PRIORITY, len=%d, flags=%d]",
(int)frame->hd.length, frame->hd.flags);
}
case NGHTTP2_RST_STREAM: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
(int)frame->hd.length, frame->hd.flags,
frame->rst_stream.error_code);
}
case NGHTTP2_SETTINGS: {
if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
return msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
}
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
}
case NGHTTP2_PUSH_PROMISE: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[PUSH_PROMISE, len=%d, hend=%d]",
(int)frame->hd.length,
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
}
case NGHTTP2_PING: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[PING, len=%d, ack=%d]",
(int)frame->hd.length,
frame->hd.flags&NGHTTP2_FLAG_ACK);
@ -1265,17 +1265,18 @@ static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen)
if(len)
memcpy(scratch, frame->goaway.opaque_data, len);
scratch[len] = '\0';
return msnprintf(buffer, blen, "FRAME[GOAWAY, error=%d, reason='%s', "
return curl_msnprintf(buffer, blen,
"FRAME[GOAWAY, error=%d, reason='%s', "
"last_stream=%d]", frame->goaway.error_code,
scratch, frame->goaway.last_stream_id);
}
case NGHTTP2_WINDOW_UPDATE: {
return msnprintf(buffer, blen,
return curl_msnprintf(buffer, blen,
"FRAME[WINDOW_UPDATE, incr=%d]",
frame->window_update.window_size_increment);
}
default:
return msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
frame->hd.type, (int)frame->hd.length,
frame->hd.flags);
}
@ -1592,7 +1593,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
if(!strcmp(HTTP_PSEUDO_AUTHORITY, (const char *)name)) {
/* pseudo headers are lower case */
int rc = 0;
char *check = aprintf("%s:%d", cf->conn->host.name,
char *check = curl_maprintf("%s:%d", cf->conn->host.name,
cf->conn->remote_port);
if(!check)
/* no memory */
@ -1640,7 +1641,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
}
stream->push_headers = headp;
}
h = aprintf("%s:%s", name, value);
h = curl_maprintf("%s:%s", name, value);
if(h)
stream->push_headers[stream->push_headers_used++] = h;
return 0;
@ -1671,7 +1672,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
cf_h2_header_error(cf, data_s, stream, result);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
msnprintf(buffer, sizeof(buffer), HTTP_PSEUDO_STATUS ":%u\r",
curl_msnprintf(buffer, sizeof(buffer), HTTP_PSEUDO_STATUS ":%u\r",
stream->status_code);
result = Curl_headers_push(data_s, buffer, CURLH_PSEUDO);
if(result) {

View file

@ -39,8 +39,7 @@
#include <time.h>
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -245,13 +244,13 @@ static CURLcode make_headers(struct Curl_easy *data,
struct curl_slist *l;
bool again = TRUE;
msnprintf(date_hdr_key, DATE_HDR_KEY_LEN, "X-%.*s-Date",
curl_msnprintf(date_hdr_key, DATE_HDR_KEY_LEN, "X-%.*s-Date",
(int)plen, provider1);
/* provider1 ucfirst */
Curl_strntolower(&date_hdr_key[2], provider1, plen);
date_hdr_key[2] = Curl_raw_toupper(provider1[0]);
msnprintf(date_full_hdr, DATE_FULL_HDR_LEN,
curl_msnprintf(date_full_hdr, DATE_FULL_HDR_LEN,
"x-%.*s-date:%s", (int)plen, provider1, timestamp);
/* provider1 lowercase */
Curl_strntolower(&date_full_hdr[2], provider1, plen);
@ -265,7 +264,7 @@ static CURLcode make_headers(struct Curl_easy *data,
fullhost = Curl_memdup0(data->state.aptr.host, pos);
}
else
fullhost = aprintf("host:%s", hostname);
fullhost = curl_maprintf("host:%s", hostname);
if(fullhost)
head = Curl_slist_append_nodup(NULL, fullhost);
@ -329,7 +328,7 @@ static CURLcode make_headers(struct Curl_easy *data,
if(!tmp_head)
goto fail;
head = tmp_head;
*date_header = aprintf("%s: %s\r\n", date_hdr_key, timestamp);
*date_header = curl_maprintf("%s: %s\r\n", date_hdr_key, timestamp);
}
else {
const char *value;
@ -417,7 +416,7 @@ static const char *parse_content_sha_hdr(struct Curl_easy *data,
const char *value;
size_t len;
key_len = msnprintf(key, sizeof(key), "x-%.*s-content-sha256",
key_len = curl_msnprintf(key, sizeof(key), "x-%.*s-content-sha256",
(int)plen, provider1);
value = Curl_checkheaders(data, key, key_len);
@ -490,7 +489,7 @@ static CURLcode calc_s3_payload_hash(struct Curl_easy *data,
}
/* format the required content-sha256 header */
msnprintf(header, CONTENT_SHA256_HDR_LEN,
curl_msnprintf(header, CONTENT_SHA256_HDR_LEN,
"x-%.*s-content-sha256: %s", (int)plen, provider1, sha_hex);
ret = CURLE_OK;
@ -850,7 +849,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
result = CURLE_OUT_OF_MEMORY;
canonical_request =
aprintf("%s\n" /* HTTPRequestMethod */
curl_maprintf("%s\n" /* HTTPRequestMethod */
"%s\n" /* CanonicalURI */
"%s\n" /* CanonicalQueryString */
"%s\n" /* CanonicalHeaders */
@ -869,18 +868,21 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
infof(data, "aws_sigv4: Canonical request (enclosed in []) - [%s]",
canonical_request);
request_type = aprintf("%.*s4_request",
(int)curlx_strlen(&provider0), curlx_str(&provider0));
request_type = curl_maprintf("%.*s4_request",
(int)curlx_strlen(&provider0),
curlx_str(&provider0));
if(!request_type)
goto fail;
/* provider0 is lowercased *after* aprintf() so that the buffer can be
written to */
/* provider0 is lowercased *after* curl_maprintf() so that the buffer
can be written to */
Curl_strntolower(request_type, request_type, curlx_strlen(&provider0));
credential_scope = aprintf("%s/%.*s/%.*s/%s", date,
(int)curlx_strlen(&region), curlx_str(&region),
(int)curlx_strlen(&service), curlx_str(&service),
credential_scope = curl_maprintf("%s/%.*s/%.*s/%s", date,
(int)curlx_strlen(&region),
curlx_str(&region),
(int)curlx_strlen(&service),
curlx_str(&service),
request_type);
if(!credential_scope)
goto fail;
@ -895,11 +897,12 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
* Google allows using RSA key instead of HMAC, so this code might change
* in the future. For now we only support HMAC.
*/
str_to_sign = aprintf("%.*s4-HMAC-SHA256\n" /* Algorithm */
str_to_sign = curl_maprintf("%.*s4-HMAC-SHA256\n" /* Algorithm */
"%s\n" /* RequestDateTime */
"%s\n" /* CredentialScope */
"%s", /* HashedCanonicalRequest in hex */
(int)curlx_strlen(&provider0), curlx_str(&provider0),
(int)curlx_strlen(&provider0),
curlx_str(&provider0),
timestamp,
credential_scope,
sha_hex);
@ -913,7 +916,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
infof(data, "aws_sigv4: String to sign (enclosed in []) - [%s]",
str_to_sign);
secret = aprintf("%.*s4%s", (int)curlx_strlen(&provider0),
secret = curl_maprintf("%.*s4%s", (int)curlx_strlen(&provider0),
curlx_str(&provider0), data->state.aptr.passwd ?
data->state.aptr.passwd : "");
if(!secret)
@ -933,7 +936,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
infof(data, "aws_sigv4: Signature - %s", sha_hex);
auth_headers = aprintf("Authorization: %.*s4-HMAC-SHA256 "
auth_headers = curl_maprintf("Authorization: %.*s4-HMAC-SHA256 "
"Credential=%s/%s, "
"SignedHeaders=%s, "
"Signature=%s\r\n"
@ -944,7 +947,8 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
*/
"%s"
"%s", /* optional sha256 header includes \r\n */
(int)curlx_strlen(&provider0), curlx_str(&provider0),
(int)curlx_strlen(&provider0),
curlx_str(&provider0),
user,
credential_scope,
curlx_dyn_ptr(&signed_headers),

View file

@ -27,7 +27,6 @@
#ifndef CURL_DISABLE_HTTP
#include "urldata.h" /* it includes http_chunks.h */
#include "curl_printf.h"
#include "curl_trc.h"
#include "sendf.h" /* for the client write stuff */
#include "curlx/dynbuf.h"
@ -584,7 +583,7 @@ static CURLcode add_chunk(struct Curl_easy *data,
int hdlen;
size_t n;
hdlen = msnprintf(hd, sizeof(hd), "%zx\r\n", nread);
hdlen = curl_msnprintf(hd, sizeof(hd), "%zx\r\n", nread);
if(hdlen <= 0)
return CURLE_READ_ERROR;
/* On a soft-limited bufq, we do not need to check that all was written */

View file

@ -32,8 +32,7 @@
#include "http_digest.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -149,11 +148,11 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
if(tmp) {
size_t urilen = tmp - (const char *)uripath;
/* typecast is fine here since the value is always less than 32 bits */
path = (unsigned char *) aprintf("%.*s", (int)urilen, uripath);
path = (unsigned char *)curl_maprintf("%.*s", (int)urilen, uripath);
}
}
if(!tmp)
path = (unsigned char *) strdup((const char *) uripath);
path = (unsigned char *)strdup((const char *) uripath);
if(!path)
return CURLE_OUT_OF_MEMORY;
@ -164,9 +163,8 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
if(result)
return result;
*allocuserpwd = aprintf("%sAuthorization: Digest %s\r\n",
proxy ? "Proxy-" : "",
response);
*allocuserpwd = curl_maprintf("%sAuthorization: Digest %s\r\n",
proxy ? "Proxy-" : "", response);
free(response);
if(!*allocuserpwd)
return CURLE_OUT_OF_MEMORY;

View file

@ -34,8 +34,7 @@
#include "vtls/vtls.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -219,8 +218,8 @@ CURLcode Curl_output_negotiate(struct Curl_easy *data,
if(result)
return result;
userp = aprintf("%sAuthorization: Negotiate %s\r\n", proxy ? "Proxy-" : "",
base64);
userp = curl_maprintf("%sAuthorization: Negotiate %s\r\n",
proxy ? "Proxy-" : "", base64);
if(proxy) {
#ifndef CURL_DISABLE_PROXY

View file

@ -49,8 +49,7 @@
#include "curl_sspi.h"
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -210,7 +209,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
Curl_bufref_len(&ntlmmsg), &base64, &len);
if(!result) {
free(*allocuserpwd);
*allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
proxy ? "Proxy-" : "",
base64);
free(base64);
@ -229,7 +228,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
Curl_bufref_len(&ntlmmsg), &base64, &len);
if(!result) {
free(*allocuserpwd);
*allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
proxy ? "Proxy-" : "",
base64);
free(base64);

View file

@ -44,8 +44,7 @@
#include "vauth/vauth.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -236,7 +235,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq,
if(result)
goto out;
authority = aprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
ipv6_ip ?"]" : "", port);
if(!authority) {
result = CURLE_OUT_OF_MEMORY;

View file

@ -33,8 +33,7 @@
#include "sendf.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -45,8 +45,7 @@
#endif
#endif /* USE_LIBIDN2 */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -54,8 +54,8 @@
#include "curlx/inet_ntop.h"
#include "if2ip.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -153,7 +153,7 @@ if2ip_result_t Curl_if2ip(int af,
}
if(scopeid)
msnprintf(scope, sizeof(scope), "%%%u", scopeid);
curl_msnprintf(scope, sizeof(scope), "%%%u", scopeid);
#endif
}
else
@ -162,7 +162,7 @@ if2ip_result_t Curl_if2ip(int af,
&((struct sockaddr_in *)(void *)iface->ifa_addr)->sin_addr;
res = IF2IP_FOUND;
ip = curlx_inet_ntop(af, addr, ipstr, sizeof(ipstr));
msnprintf(buf, buf_size, "%s%s", ip, scope);
curl_msnprintf(buf, buf_size, "%s%s", ip, scope);
break;
}
}

View file

@ -78,8 +78,7 @@
#include "curlx/warnless.h"
#include "curl_ctype.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -1943,7 +1942,7 @@ static CURLcode imap_sendf(struct Curl_easy *data,
DEBUGASSERT(fmt);
/* Calculate the tag based on the connection ID and command ID */
msnprintf(imapc->resptag, sizeof(imapc->resptag), "%c%03d",
curl_msnprintf(imapc->resptag, sizeof(imapc->resptag), "%c%03d",
'A' + curlx_sltosi((long)(data->conn->connection_id % 26)),
++imapc->cmdid);

View file

@ -93,8 +93,8 @@
#include "curlx/multibyte.h"
#include "curlx/base64.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -746,7 +746,7 @@ static void ldap_trace_low(const char *fmt, ...)
return;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
curl_mvfprintf(stderr, fmt, args);
va_end(args);
}
#endif /* DEBUG_LDAP */

View file

@ -82,8 +82,7 @@
#include <mbedtls/md4.h>
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -77,8 +77,7 @@
#include <wincrypt.h>
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -31,8 +31,7 @@
#include "urldata.h"
#include "curlx/fopen.h" /* for CURLX_FOPEN_LOW() */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -114,7 +113,7 @@ static bool countcheck(const char *func, int line, const char *source)
curl_dbg_log("LIMIT %s:%d %s reached memlimit\n",
source, line, func);
/* log to stderr also */
fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
curl_mfprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
source, line, func);
fflush(curl_dbg_logfile); /* because it might crash now */
/* !checksrc! disable ERRNOVAR 1 */
@ -469,7 +468,7 @@ void curl_dbg_log(const char *format, ...)
return;
va_start(ap, format);
nchars = mvsnprintf(buf, sizeof(buf), format, ap);
nchars = curl_mvsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
if(nchars > (int)sizeof(buf) - 1)

View file

@ -49,8 +49,8 @@ struct Curl_easy;
#include "rand.h"
#include "slist.h"
#include "curlx/dynbuf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -1688,7 +1688,7 @@ CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
s = vaprintf(fmt, ap);
s = curl_mvaprintf(fmt, ap);
va_end(ap);
if(s) {

View file

@ -38,12 +38,11 @@
#include "url.h"
#include "escape.h"
#include "curlx/warnless.h"
#include "curl_printf.h"
#include "curl_memory.h"
#include "multiif.h"
#include "rand.h"
/* The last #include file should be: */
/* The last 2 #includes file should be: */
#include "curl_memory.h"
#include "memdebug.h"
/* first byte is command.

View file

@ -54,8 +54,8 @@
#include "socketpair.h"
#include "socks.h"
#include "urlapi-int.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -522,7 +522,7 @@ static void debug_print_sock_hash(void *p)
{
struct Curl_sh_entry *sh = (struct Curl_sh_entry *)p;
fprintf(stderr, " [readers %u][writers %u]",
curl_mfprintf(stderr, " [readers %u][writers %u]",
sh->readers, sh->writers);
}
#endif
@ -4004,11 +4004,13 @@ static void multi_xfer_dump(struct Curl_multi *multi, unsigned int mid,
(void)multi;
if(!data) {
fprintf(stderr, "mid=%u, entry=NULL, bug in xfer table?\n", mid);
curl_mfprintf(stderr, "mid=%u, entry=NULL, bug in xfer table?\n", mid);
}
else {
fprintf(stderr, "mid=%u, magic=%s, p=%p, id=%" FMT_OFF_T ", url=%s\n",
mid, (data->magic == CURLEASY_MAGIC_NUMBER) ? "GOOD" : "BAD!",
curl_mfprintf(stderr, "mid=%u, magic=%s, p=%p, id=%" FMT_OFF_T
", url=%s\n",
mid,
(data->magic == CURLEASY_MAGIC_NUMBER) ? "GOOD" : "BAD!",
(void *)data, data->id, data->state.url);
}
}
@ -4017,7 +4019,7 @@ static void multi_xfer_tbl_dump(struct Curl_multi *multi)
{
unsigned int mid;
void *entry;
fprintf(stderr, "=== multi xfer table (count=%u, capacity=%u\n",
curl_mfprintf(stderr, "=== multi xfer table (count=%u, capacity=%u\n",
Curl_uint_tbl_count(&multi->xfers),
Curl_uint_tbl_capacity(&multi->xfers));
if(Curl_uint_tbl_first(&multi->xfers, &mid, &entry)) {
@ -4025,7 +4027,7 @@ static void multi_xfer_tbl_dump(struct Curl_multi *multi)
while(Curl_uint_tbl_next(&multi->xfers, mid, &mid, &entry))
multi_xfer_dump(multi, mid, entry);
}
fprintf(stderr, "===\n");
curl_mfprintf(stderr, "===\n");
fflush(stderr);
}
#endif /* DEBUGBUILD */

View file

@ -40,8 +40,8 @@
#include "curlx/warnless.h"
#include "multihandle.h"
#include "socks.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -42,8 +42,7 @@
#include "curlx/fopen.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -437,7 +436,7 @@ NETRCcode Curl_parsenetrc(struct store_netrc *store, const char *host,
return NETRC_FILE_MISSING; /* no home directory found (or possibly out
of memory) */
filealloc = aprintf("%s%s.netrc", home, DIR_CHAR);
filealloc = curl_maprintf("%s%s.netrc", home, DIR_CHAR);
if(!filealloc) {
free(homea);
return NETRC_OUT_OF_MEMORY;
@ -448,7 +447,7 @@ NETRCcode Curl_parsenetrc(struct store_netrc *store, const char *host,
#ifdef _WIN32
if(retcode == NETRC_FILE_MISSING) {
/* fallback to the old-style "_netrc" file */
filealloc = aprintf("%s%s_netrc", home, DIR_CHAR);
filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR);
if(!filealloc) {
free(homea);
return NETRC_OUT_OF_MEMORY;

View file

@ -64,7 +64,8 @@ UNITTEST bool Curl_cidr4_match(const char *ipv4, /* 1.2.3.4 address */
unsigned int haddr = htonl(address);
unsigned int hcheck = htonl(check);
#if 0
fprintf(stderr, "Host %s (%x) network %s (%x) bits %u mask %x => %x\n",
curl_mfprintf(stderr, "Host %s (%x) network %s (%x) "
"bits %u mask %x => %x\n",
ipv4, haddr, network, hcheck, bits, mask,
(haddr ^ hcheck) & mask);
#endif

View file

@ -52,8 +52,8 @@
#include "connect.h"
#include "curl_sasl.h"
#include "strcase.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -619,7 +619,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
if(result)
goto out;
hosturl = aprintf("%s://%s%s%s:%d",
hosturl = curl_maprintf("%s://%s%s%s:%d",
conn->handler->scheme,
conn->bits.ipv6_ip ? "[" : "",
conn->host.name,

View file

@ -39,8 +39,7 @@
#include "vtls/vtls.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -77,8 +77,8 @@
#include "curl_md5.h"
#include "curlx/warnless.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -600,7 +600,7 @@ static CURLcode pop3_perform_apop(struct Curl_easy *data,
/* Convert the calculated 16 octet digest into a 32 byte hex string */
for(i = 0; i < MD5_DIGEST_LEN; i++)
msnprintf(&secret[2 * i], 3, "%02x", digest[i]);
curl_msnprintf(&secret[2 * i], 3, "%02x", digest[i]);
result = Curl_pp_sendf(data, &pop3c->pp, "APOP %s %s", conn->user, secret);

View file

@ -29,7 +29,6 @@
#include "multiif.h"
#include "progress.h"
#include "curlx/timeval.h"
#include "curl_printf.h"
/* check rate limits within this many recent milliseconds, at minimum. */
#define MIN_RATE_LIMIT_PERIOD 3000
@ -48,7 +47,8 @@ static void time2str(char *r, curl_off_t seconds)
if(h <= 99) {
curl_off_t m = (seconds - (h * 3600)) / 60;
curl_off_t s = (seconds - (h * 3600)) - (m * 60);
msnprintf(r, 9, "%2" FMT_OFF_T ":%02" FMT_OFF_T ":%02" FMT_OFF_T, h, m, s);
curl_msnprintf(r, 9, "%2" FMT_OFF_T ":%02" FMT_OFF_T ":%02" FMT_OFF_T,
h, m, s);
}
else {
/* this equals to more than 99 hours, switch to a more suitable output
@ -56,9 +56,9 @@ static void time2str(char *r, curl_off_t seconds)
curl_off_t d = seconds / 86400;
h = (seconds - (d * 86400)) / 3600;
if(d <= 999)
msnprintf(r, 9, "%3" FMT_OFF_T "d %02" FMT_OFF_T "h", d, h);
curl_msnprintf(r, 9, "%3" FMT_OFF_T "d %02" FMT_OFF_T "h", d, h);
else
msnprintf(r, 9, "%7" FMT_OFF_T "d", d);
curl_msnprintf(r, 9, "%7" FMT_OFF_T "d", d);
}
}
@ -71,7 +71,7 @@ static char *max6data(curl_off_t bytes, char *max6)
const char unit[] = { 'k', 'M', 'G', 'T', 'P', 0 };
int k = 0;
if(bytes < 1000000) {
msnprintf(max6, 7, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
curl_msnprintf(max6, 7, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
return max6;
}
@ -79,14 +79,15 @@ static char *max6data(curl_off_t bytes, char *max6)
curl_off_t nbytes = bytes / 1024;
if(nbytes < 1000) {
/* xxx.yU */
msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T
curl_msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T
".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
(bytes%1024) / (1024/10), unit[k]);
break;
}
else if(nbytes < 100000) {
/* xxxxxU */
msnprintf(max6, 7, "%5" CURL_FORMAT_CURL_OFF_T "%c", nbytes, unit[k]);
curl_msnprintf(max6, 7, "%5" CURL_FORMAT_CURL_OFF_T "%c",
nbytes, unit[k]);
break;
}
bytes = nbytes;
@ -122,7 +123,7 @@ int Curl_pgrsDone(struct Curl_easy *data)
if(!data->progress.hide && !data->progress.callback)
/* only output if we do not use a progress callback and we are not
* hidden */
fprintf(data->set.err, "\n");
curl_mfprintf(data->set.err, "\n");
data->progress.speeder_c = 0; /* reset the progress meter display */
return 0;
@ -500,11 +501,11 @@ static void progress_meter(struct Curl_easy *data)
if(!p->headers_out) {
if(data->state.resume_from) {
fprintf(data->set.err,
curl_mfprintf(data->set.err,
"** Resuming transfer from byte position %" FMT_OFF_T "\n",
data->state.resume_from);
}
fprintf(data->set.err,
curl_mfprintf(data->set.err,
" %% Total %% Received %% Xferd Average Speed "
"Time Time Time Current\n"
" Dload Upload "
@ -542,7 +543,7 @@ static void progress_meter(struct Curl_easy *data)
/* Get the percentage of data transferred so far */
total_estm.percent = pgrs_est_percent(total_expected_size, total_cur_size);
fprintf(data->set.err,
curl_mfprintf(data->set.err,
"\r"
"%3" FMT_OFF_T " %s "
"%3" FMT_OFF_T " %s "

View file

@ -31,8 +31,7 @@
#include "psl.h"
#include "share.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -38,8 +38,7 @@
#include "rand.h"
#include "escape.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -32,8 +32,7 @@
#include "curlx/multibyte.h"
#include "curlx/timeval.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -36,8 +36,7 @@
#include "url.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -41,8 +41,8 @@
#include "cfilters.h"
#include "strdup.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -482,7 +482,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
if(data->set.str[STRING_RTSP_TRANSPORT]) {
free(data->state.aptr.rtsp_transport);
data->state.aptr.rtsp_transport =
aprintf("Transport: %s\r\n",
curl_maprintf("Transport: %s\r\n",
data->set.str[STRING_RTSP_TRANSPORT]);
if(!data->state.aptr.rtsp_transport)
return CURLE_OUT_OF_MEMORY;
@ -508,7 +508,8 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
data->set.str[STRING_ENCODING]) {
free(data->state.aptr.accept_encoding);
data->state.aptr.accept_encoding =
aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
curl_maprintf("Accept-Encoding: %s\r\n",
data->set.str[STRING_ENCODING]);
if(!data->state.aptr.accept_encoding) {
result = CURLE_OUT_OF_MEMORY;
@ -545,7 +546,8 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
/* Referrer */
Curl_safefree(data->state.aptr.ref);
if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer")))
data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
data->state.aptr.ref = curl_maprintf("Referer: %s\r\n",
data->state.referer);
p_referrer = data->state.aptr.ref;
@ -561,7 +563,8 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
/* Check to see if there is a range set in the custom headers */
if(!Curl_checkheaders(data, STRCONST("Range")) && data->state.range) {
free(data->state.aptr.rangeline);
data->state.aptr.rangeline = aprintf("Range: %s\r\n", data->state.range);
data->state.aptr.rangeline = curl_maprintf("Range: %s\r\n",
data->state.range);
p_range = data->state.aptr.rangeline;
}
}

View file

@ -45,8 +45,8 @@
#include "curlx/timediff.h"
#include "curlx/wait.h"
#include "curlx/warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -56,8 +56,7 @@
#include "curlx/warnless.h"
#include "ws.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -55,8 +55,7 @@
#include "strdup.h"
#include "escape.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -52,8 +52,7 @@
#include <wincrypt.h>
#endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -34,8 +34,7 @@
#include "hsts.h"
#include "url.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -42,8 +42,7 @@
#include "escape.h"
#include "curl_endian.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -718,7 +717,7 @@ static CURLcode smb_send_setup(struct Curl_easy *data)
p += sizeof(lm);
memcpy(p, nt, sizeof(nt));
p += sizeof(nt);
p += msnprintf(p, byte_count - sizeof(nt) - sizeof(lm),
p += curl_msnprintf(p, byte_count - sizeof(nt) - sizeof(lm),
"%s%c" /* user */
"%s%c" /* domain */
"%s%c" /* OS */
@ -750,7 +749,7 @@ static CURLcode smb_send_tree_connect(struct Curl_easy *data,
msg.andx.command = SMB_COM_NO_ANDX_COMMAND;
msg.pw_len = 0;
p += msnprintf(p, byte_count,
p += curl_msnprintf(p, byte_count,
"\\\\%s\\" /* hostname */
"%s%c" /* share */
"%s", /* service */

View file

@ -81,8 +81,7 @@
#include "idn.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -712,14 +711,14 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data,
(!Curl_is_ASCII_name(host.name)));
if(host.name) {
from = aprintf("<%s@%s>%s", address, host.name, suffix);
from = curl_maprintf("<%s@%s>%s", address, host.name, suffix);
Curl_free_idnconverted_hostname(&host);
}
else
/* An invalid mailbox was provided but we will simply let the server
worry about that and reply with a 501 error */
from = aprintf("<%s>%s", address, suffix);
from = curl_maprintf("<%s>%s", address, suffix);
free(address);
}
@ -754,14 +753,14 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data,
utf8 = TRUE;
if(host.name) {
auth = aprintf("<%s@%s>%s", address, host.name, suffix);
auth = curl_maprintf("<%s@%s>%s", address, host.name, suffix);
Curl_free_idnconverted_hostname(&host);
}
else
/* An invalid mailbox was provided but we will simply let the server
worry about it */
auth = aprintf("<%s>%s", address, suffix);
auth = curl_maprintf("<%s>%s", address, suffix);
free(address);
}
else
@ -806,7 +805,7 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data,
/* Calculate the optional SIZE parameter */
if(smtpc->size_supported && data->state.infilesize > 0) {
size = aprintf("%" FMT_OFF_T, data->state.infilesize);
size = curl_maprintf("%" FMT_OFF_T, data->state.infilesize);
if(!size) {
result = CURLE_OUT_OF_MEMORY;

View file

@ -134,8 +134,7 @@ int Curl_socketpair(int domain, int type, int protocol,
#include "curlx/timeval.h" /* needed before select.h */
#include "select.h" /* for Curl_poll */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -45,8 +45,7 @@
#include "curlx/inet_pton.h"
#include "url.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -37,8 +37,7 @@
#include "curlx/warnless.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -160,7 +159,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
return CURLE_OUT_OF_MEMORY;
service.length = serviceptr_length +
strlen(conn->socks_proxy.host.name) + 1;
msnprintf(service.value, service.length + 1, "%s@%s",
curl_msnprintf(service.value, service.length + 1, "%s@%s",
serviceptr, conn->socks_proxy.host.name);
gss_major_status = gss_import_name(&gss_minor_status, &service,

View file

@ -38,8 +38,8 @@
#include "curlx/multibyte.h"
#include "curlx/warnless.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -104,7 +104,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
if(strchr(service, '/'))
service_name = strdup(service);
else
service_name = aprintf("%s/%s", service, conn->socks_proxy.host.name);
service_name = curl_maprintf("%s/%s",
service, conn->socks_proxy.host.name);
if(!service_name)
return CURLE_OUT_OF_MEMORY;

View file

@ -60,8 +60,7 @@
#include "curlx/warnless.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -814,7 +813,7 @@ static CURLcode check_telnet_options(struct Curl_easy *data,
DEBUGF(infof(data, "set a non ASCII username in telnet"));
return CURLE_BAD_FUNCTION_ARGUMENT;
}
msnprintf(buffer, sizeof(buffer), "USER,%s", data->conn->user);
curl_msnprintf(buffer, sizeof(buffer), "USER,%s", data->conn->user);
beg = curl_slist_append(tn->telnet_vars, buffer);
if(!beg) {
curl_slist_free_all(tn->telnet_vars);
@ -957,9 +956,10 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn)
failf(data, "Tool long telnet TTYPE");
return CURLE_SEND_ERROR;
}
len = msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC,
CURL_SE);
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
@ -976,9 +976,10 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn)
failf(data, "Tool long telnet XDISPLOC");
return CURLE_SEND_ERROR;
}
len = msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC,
CURL_SE);
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
err = SOCKERRNO;
@ -987,7 +988,7 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn)
printsub(data, '>', &temp[2], len-2);
break;
case CURL_TELOPT_NEW_ENVIRON:
len = msnprintf((char *)temp, sizeof(temp), "%c%c%c%c",
len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c",
CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
CURL_TELQUAL_IS);
for(v = tn->telnet_vars; v; v = v->next) {
@ -998,17 +999,17 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn)
if(len + tmplen < (int)sizeof(temp)-6) {
char *s = strchr(v->data, ',');
if(!s)
len += msnprintf((char *)&temp[len], sizeof(temp) - len,
len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
"%c%s", CURL_NEW_ENV_VAR, v->data);
else {
size_t vlen = s - v->data;
len += msnprintf((char *)&temp[len], sizeof(temp) - len,
len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
"%c%.*s%c%s", CURL_NEW_ENV_VAR,
(int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s);
}
}
}
msnprintf((char *)&temp[len], sizeof(temp) - len,
curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
"%c%c", CURL_IAC, CURL_SE);
len += 2;
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);

View file

@ -65,8 +65,7 @@
#include "curlx/strerr.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -474,7 +473,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
return CURLE_TFTP_ILLEGAL; /* too long filename field */
}
msnprintf((char *)state->spacket.data + 2,
curl_msnprintf((char *)state->spacket.data + 2,
state->blksize,
"%s%c%s%c", filename, '\0', mode, '\0');
sbytes = 4 + strlen(filename) + strlen(mode);
@ -483,7 +482,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
if(!data->set.tftp_no_options) {
char buf[64];
/* add tsize option */
msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
curl_msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
data->state.upload && (data->state.infilesize != -1) ?
data->state.infilesize : 0);
@ -495,7 +494,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
(char *)state->spacket.data + sbytes, buf);
/* add blksize option */
msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
curl_msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
if(result == CURLE_OK)
result = tftp_option_add(state, &sbytes,
(char *)state->spacket.data + sbytes,
@ -505,7 +504,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
(char *)state->spacket.data + sbytes, buf);
/* add timeout option */
msnprintf(buf, sizeof(buf), "%d", state->retry_time);
curl_msnprintf(buf, sizeof(buf), "%d", state->retry_time);
if(result == CURLE_OK)
result = tftp_option_add(state, &sbytes,
(char *)state->spacket.data + sbytes,

View file

@ -83,8 +83,7 @@
#include "setopt.h"
#include "headers.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -623,7 +622,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
if(data->set.str[STRING_USERAGENT]) {
free(data->state.aptr.uagent);
data->state.aptr.uagent =
aprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
curl_maprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
if(!data->state.aptr.uagent)
return CURLE_OUT_OF_MEMORY;
}

View file

@ -25,8 +25,7 @@
#include "curl_setup.h"
#include "uint-bset.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -26,8 +26,7 @@
#include "uint-bset.h"
#include "uint-spbset.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -25,8 +25,7 @@
#include "curl_setup.h"
#include "uint-table.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"

View file

@ -126,8 +126,8 @@
#include "headers.h"
#include "curlx/strerr.h"
#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@ -504,7 +504,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
data = calloc(1, sizeof(struct Curl_easy));
if(!data) {
/* this is a serious error */
DEBUGF(fprintf(stderr, "Error: calloc of Curl_easy failed\n"));
DEBUGF(curl_mfprintf(stderr, "Error: calloc of Curl_easy failed\n"));
return CURLE_OUT_OF_MEMORY;
}
@ -1785,7 +1785,8 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
if(data->set.str[STRING_DEFAULT_PROTOCOL] &&
!Curl_is_absolute_url(data->state.url, NULL, 0, TRUE)) {
char *url = aprintf("%s://%s", data->set.str[STRING_DEFAULT_PROTOCOL],
char *url = curl_maprintf("%s://%s",
data->set.str[STRING_DEFAULT_PROTOCOL],
data->state.url);
if(!url)
return CURLE_OUT_OF_MEMORY;
@ -1997,7 +1998,7 @@ static CURLcode setup_range(struct Curl_easy *data)
free(s->range);
if(s->resume_from)
s->range = aprintf("%" FMT_OFF_T "-", s->resume_from);
s->range = curl_maprintf("%" FMT_OFF_T "-", s->resume_from);
else
s->range = strdup(data->set.str[STRING_SET_RANGE]);
@ -2055,9 +2056,10 @@ static CURLcode setup_connection_internals(struct Curl_easy *data,
}
#ifdef USE_IPV6
conn->destination = aprintf("%u/%d/%s", conn->scope_id, port, hostname);
conn->destination = curl_maprintf("%u/%d/%s", conn->scope_id, port,
hostname);
#else
conn->destination = aprintf("%d/%s", port, hostname);
conn->destination = curl_maprintf("%d/%s", port, hostname);
#endif
if(!conn->destination)
return CURLE_OUT_OF_MEMORY;
@ -2105,7 +2107,8 @@ static char *detect_proxy(struct Curl_easy *data,
(void)data;
#endif
msnprintf(proxy_env, sizeof(proxy_env), "%s_proxy", conn->handler->scheme);
curl_msnprintf(proxy_env, sizeof(proxy_env), "%s_proxy",
conn->handler->scheme);
/* read the protocol proxy: */
proxy = curl_getenv(proxy_env);
@ -2323,7 +2326,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
if(strcmp("/", path)) {
is_unix_proxy = TRUE;
free(host);
host = aprintf(UNIX_SOCKET_PREFIX"%s", path);
host = curl_maprintf(UNIX_SOCKET_PREFIX"%s", path);
if(!host) {
result = CURLE_OUT_OF_MEMORY;
goto error;
@ -2671,7 +2674,7 @@ static CURLcode parse_remote_port(struct Curl_easy *data,
char portbuf[16];
CURLUcode uc;
conn->remote_port = data->set.use_port;
msnprintf(portbuf, sizeof(portbuf), "%d", conn->remote_port);
curl_msnprintf(portbuf, sizeof(portbuf), "%d", conn->remote_port);
uc = curl_url_set(data->state.uh, CURLUPART_PORT, portbuf, 0);
if(uc)
return CURLE_OUT_OF_MEMORY;
@ -2982,7 +2985,7 @@ static CURLcode parse_connect_to_string(struct Curl_easy *data,
else {
/* check whether the URL's hostname matches */
size_t hostname_to_match_len;
char *hostname_to_match = aprintf("%s%s%s",
char *hostname_to_match = curl_maprintf("%s%s%s",
conn->bits.ipv6_ip ? "[" : "",
conn->host.name,
conn->bits.ipv6_ip ? "]" : "");
@ -3703,7 +3706,7 @@ static CURLcode create_conn(struct Curl_easy *data,
*/
result = Curl_ssl_conn_config_init(data, conn);
if(result) {
DEBUGF(fprintf(stderr, "Error: init connection ssl config\n"));
DEBUGF(curl_mfprintf(stderr, "Error: init connection ssl config\n"));
goto out;
}

Some files were not shown because too many files have changed in this diff Show more