curl_mprintf / curl_msprintf / curl_msnprintf / curl_mvprintf / curl_mvsprintf / curl_mvsnprintf / curl_maprintf / curl_mvaprintf

Syntax

#include <curl/curl.h>

int curl_mprintf(const char * format , ...);

int curl_msprintf(char * buffer , const char * format , ...);

int curl_msnprintf(char * buffer , size_t maxlength , const char * format , ...);

int curl_mvprintf(const char * format , va_list args );

int curl_mvsprintf(char * buffer , const char * format , va_list args);

int curl_mvsnprintf(char * buffer , size_t maxlength , const char * format , va_list args);

char *curl_maprintf(const char * format , ...);

char *curl_mvaprintf(const char * format , va_list args);

Parameters

Depends on the function For more information on normal printf functions, see the relevant MAN pages.

Return Values

Depends on the function The curl_maprintf and curl_mvaprintf functions return a pointer to a newly allocated string, or NULL if it failed.

All other functions return the number of characters they actually outputted.

Description

These are all functions that produce output according to a format string and given arguments. These are mostly clones of the well-known C-style functions and there will be no detailed description of all available formatting rules and usage here.

See this table for notable exceptions.

curl_mprintf Normal printf clone.
curl_msprintf Normal sprintf clone.
curl_msnprintf snprintf clone. Many systems do not have this. Similar to sprintf but with an extra argument after the buffer that specifies the length of the target buffer.
curl_mvprintf Normal vprintf clone.
curl_mvsprintf Normal vsprintf clone.
curl_mvsnprintf vsnprintf clone. Many systems do not have this. It is just like vsprintf but with an extra argument after the buffer that specifies the length of the target buffer.
curl_maprintf Like printf but returns the output string as a string allocated by malloc. The returned string must be freed by the receiver.
curl_mvaprintf Like curl_maprintf but takes a va_list pointer argument instead of a variable amount of arguments.

To use all of these cloned functions instead of the usual functions, #define _MPRINTF_REPLACE before you include the <curl/mprintf.h> file. Then all the usual functions such as printf, sprintf, etc., will use the curl-functions instead.

Availability

These functions will be removed from the API in a near future.

Do Not Call From

curl_maprintf

None.

curl_mprintf

None.

curl_msnprintf

None.

curl_msprintf

None.

curl_mvaprintf

None.

curl_mvprintf

None.

curl_mvsnprintf

None.

curl_mvsprintf

None.

See Also

HTTP Client Library (libcurl)
libcurl API Functions
libcurl Error Codes

Revision History

2013/09/18 Conversion
2013/05/08 Automated cleanup pass.
2012/05/04 Initial version.


CONFIDENTIAL