![]() |
ucx
UAP Common Extensions
|
Wrapper for write functions with a printf-like interface. More...
Go to the source code of this file.
Macros | |
#define | cx_attr_printf(fmt_idx, arg_idx) __attribute__((__format__(printf, fmt_idx, arg_idx))) |
Attribute for printf-like functions. | |
#define | cx_asprintf(fmt, ...) cx_asprintf_a(cxDefaultAllocator, fmt, __VA_ARGS__) |
A asprintf like function which allocates space for a string the result is written to. | |
#define | cx_vasprintf(fmt, ap) cx_vasprintf_a(cxDefaultAllocator, fmt, ap) |
A vasprintf like function which allocates space for a string the result is written to. | |
#define | cx_bprintf(buffer, fmt, ...) |
A printf like function which writes the output to a CxBuffer. | |
#define | cx_sprintf(str, len, fmt, ...) cx_sprintf_a(cxDefaultAllocator, str, len, fmt, __VA_ARGS__) |
An sprintf like function which reallocates the string when the buffer is not large enough. | |
#define | cx_vsprintf(str, len, fmt, ap) cx_vsprintf_a(cxDefaultAllocator, str, len, fmt, ap) |
An sprintf like function which reallocates the string when the buffer is not large enough. | |
#define | cx_sprintf_s(buf, len, str, fmt, ...) cx_sprintf_sa(cxDefaultAllocator, buf, len, str, fmt, __VA_ARGS__) |
An sprintf like function which allocates a new string when the buffer is not large enough. | |
#define | cx_vsprintf_s(buf, len, str, fmt, ap) cx_vsprintf_sa(cxDefaultAllocator, buf, len, str, fmt, ap) |
An sprintf like function which allocates a new string when the buffer is not large enough. | |
Functions | |
int | cx_fprintf (void *stream, cx_write_func wfc, const char *fmt,...) |
A fprintf like function which writes the output to a stream by using a write_func. | |
int | cx_vfprintf (void *stream, cx_write_func wfc, const char *fmt, va_list ap) |
A vfprintf like function which writes the output to a stream by using a write_func. | |
cxmutstr | cx_asprintf_a (const CxAllocator *allocator, const char *fmt,...) |
A asprintf like function which allocates space for a string the result is written to. | |
cxmutstr | cx_vasprintf_a (const CxAllocator *allocator, const char *fmt, va_list ap) |
A vasprintf like function which allocates space for a string the result is written to. | |
int | cx_sprintf_a (CxAllocator *alloc, char **str, size_t *len, const char *fmt,...) |
An sprintf like function which reallocates the string when the buffer is not large enough. | |
int | cx_vsprintf_a (CxAllocator *alloc, char **str, size_t *len, const char *fmt, va_list ap) |
An sprintf like function which reallocates the string when the buffer is not large enough. | |
int | cx_sprintf_sa (CxAllocator *alloc, char *buf, size_t *len, char **str, const char *fmt,...) |
An sprintf like function which allocates a new string when the buffer is not large enough. | |
int | cx_vsprintf_sa (CxAllocator *alloc, char *buf, size_t *len, char **str, const char *fmt, va_list ap) |
An sprintf like function which allocates a new string when the buffer is not large enough. | |
Variables | |
const unsigned | cx_printf_sbo_size |
The maximum string length that fits into stack memory. | |
Wrapper for write functions with a printf-like interface.
#define cx_asprintf | ( | fmt, | |
... ) cx_asprintf_a(cxDefaultAllocator, fmt, __VA_ARGS__) |
A asprintf
like function which allocates space for a string the result is written to.
NULL
.fmt | (char* ) format string |
... | additional arguments |
cxmutstr
) the formatted string #define cx_attr_printf | ( | fmt_idx, | |
arg_idx ) __attribute__((__format__(printf, fmt_idx, arg_idx))) |
Attribute for printf-like functions.
fmt_idx | index of the format string parameter |
arg_idx | index of the first formatting argument |
#define cx_bprintf | ( | buffer, | |
fmt, | |||
... ) |
A printf
like function which writes the output to a CxBuffer.
buffer | (CxBuffer* ) a pointer to the buffer the data is written to |
fmt | (char* ) the format string |
... | additional arguments |
int
) the total number of bytes written or an error code from stdlib printf implementation #define cx_sprintf | ( | str, | |
len, | |||
fmt, | |||
... ) cx_sprintf_a(cxDefaultAllocator, str, len, fmt, __VA_ARGS__) |
An sprintf
like function which reallocates the string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
str | (char** ) a pointer to the string buffer |
len | (size_t* ) a pointer to the length of the buffer |
fmt | (char* ) the format string |
... | additional arguments |
int
) the length of produced string or an error code from stdlib printf implementation #define cx_sprintf_s | ( | buf, | |
len, | |||
str, | |||
fmt, | |||
... ) cx_sprintf_sa(cxDefaultAllocator, buf, len, str, fmt, __VA_ARGS__) |
An sprintf
like function which allocates a new string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
The location of the resulting string will always be stored to str
. When the buffer was sufficiently large, buf
itself will be stored to the location of str
.
buf
will be poisoned after the call, because this function tries to produce the string in buf
, first.buf | (char* ) a pointer to the buffer |
len | (size_t* ) a pointer to the length of the buffer |
str | (char** ) a pointer where the location of the result shall be stored |
fmt | (char* ) the format string |
... | additional arguments |
int
) the length of produced string or an error code from stdlib printf implementation #define cx_vasprintf | ( | fmt, | |
ap ) cx_vasprintf_a(cxDefaultAllocator, fmt, ap) |
A vasprintf
like function which allocates space for a string the result is written to.
NULL
.fmt | (char* ) format string |
ap | (va_list ) argument list |
cxmutstr
) the formatted string #define cx_vsprintf | ( | str, | |
len, | |||
fmt, | |||
ap ) cx_vsprintf_a(cxDefaultAllocator, str, len, fmt, ap) |
An sprintf
like function which reallocates the string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
str | (char** ) a pointer to the string buffer |
len | (size_t* ) a pointer to the length of the buffer |
fmt | (char* ) the format string |
ap | (va_list ) argument list |
int
) the length of produced string or an error code from stdlib printf implementation #define cx_vsprintf_s | ( | buf, | |
len, | |||
str, | |||
fmt, | |||
ap ) cx_vsprintf_sa(cxDefaultAllocator, buf, len, str, fmt, ap) |
An sprintf
like function which allocates a new string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
The location of the resulting string will always be stored to str
. When the buffer was sufficiently large, buf
itself will be stored to the location of str
.
buf
will be poisoned after the call, because this function tries to produce the string in buf
, first.buf | (char* ) a pointer to the buffer |
len | (size_t* ) a pointer to the length of the buffer |
str | (char** ) a pointer where the location of the result shall be stored |
fmt | (char* ) the format string |
ap | (va_list ) argument list |
int
) the length of produced string or an error code from stdlib printf implementation cxmutstr cx_asprintf_a | ( | const CxAllocator * | allocator, |
const char * | fmt, | ||
... ) |
A asprintf
like function which allocates space for a string the result is written to.
NULL
.allocator | the CxAllocator used for allocating the string |
fmt | format string |
... | additional arguments |
int cx_fprintf | ( | void * | stream, |
cx_write_func | wfc, | ||
const char * | fmt, | ||
... ) |
A fprintf
like function which writes the output to a stream by using a write_func.
stream | the stream the data is written to |
wfc | the write function |
fmt | format string |
... | additional arguments |
int cx_sprintf_a | ( | CxAllocator * | alloc, |
char ** | str, | ||
size_t * | len, | ||
const char * | fmt, | ||
... ) |
An sprintf
like function which reallocates the string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
alloc | the allocator to use |
str | a pointer to the string buffer |
len | a pointer to the length of the buffer |
fmt | the format string |
... | additional arguments |
int cx_sprintf_sa | ( | CxAllocator * | alloc, |
char * | buf, | ||
size_t * | len, | ||
char ** | str, | ||
const char * | fmt, | ||
... ) |
An sprintf
like function which allocates a new string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
The location of the resulting string will always be stored to str
. When the buffer was sufficiently large, buf
itself will be stored to the location of str
.
buf
will be poisoned after the call, because this function tries to produce the string in buf
, first.alloc | the allocator to use |
buf | a pointer to the buffer |
len | a pointer to the length of the buffer |
str | a pointer where the location of the result shall be stored |
fmt | the format string |
... | additional arguments |
cxmutstr cx_vasprintf_a | ( | const CxAllocator * | allocator, |
const char * | fmt, | ||
va_list | ap ) |
A vasprintf
like function which allocates space for a string the result is written to.
NULL
.allocator | the CxAllocator used for allocating the string |
fmt | format string |
ap | argument list |
int cx_vfprintf | ( | void * | stream, |
cx_write_func | wfc, | ||
const char * | fmt, | ||
va_list | ap ) |
A vfprintf
like function which writes the output to a stream by using a write_func.
stream | the stream the data is written to |
wfc | the write function |
fmt | format string |
ap | argument list |
int cx_vsprintf_a | ( | CxAllocator * | alloc, |
char ** | str, | ||
size_t * | len, | ||
const char * | fmt, | ||
va_list | ap ) |
An sprintf
like function which reallocates the string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
alloc | the allocator to use |
str | a pointer to the string buffer |
len | a pointer to the length of the buffer |
fmt | the format string |
ap | argument list |
int cx_vsprintf_sa | ( | CxAllocator * | alloc, |
char * | buf, | ||
size_t * | len, | ||
char ** | str, | ||
const char * | fmt, | ||
va_list | ap ) |
An sprintf
like function which allocates a new string when the buffer is not large enough.
The size of the buffer will be updated in len
when necessary.
The location of the resulting string will always be stored to str
. When the buffer was sufficiently large, buf
itself will be stored to the location of str
.
buf
will be poisoned after the call, because this function tries to produce the string in buf
, first.alloc | the allocator to use |
buf | a pointer to the buffer |
len | a pointer to the length of the buffer |
str | a pointer where the location of the result shall be stored |
fmt | the format string |
ap | argument list |