#ifndef UCX_PRINTF_H
#define UCX_PRINTF_H
#include "common.h"
#include "string.h"
#include <stdarg.h>
#define cx_attr_printf(fmt_idx, arg_idx) \
__attribute__((__format__(printf, fmt_idx, arg_idx)))
#ifdef __cplusplus
extern "C" {
#endif
CX_EXPORT extern const unsigned cx_printf_sbo_size;
cx_attr_nonnull_arg(
1,
2,
3) cx_attr_printf(
3,
4) cx_attr_cstr_arg(
3)
CX_EXPORT int cx_fprintf(
void *stream, cx_write_func wfc,
const char *fmt, ...);
cx_attr_nonnull cx_attr_cstr_arg(
3)
CX_EXPORT int cx_vfprintf(
void *stream, cx_write_func wfc,
const char *fmt, va_list ap);
cx_attr_nonnull_arg(
1,
2) cx_attr_printf(
2,
3) cx_attr_cstr_arg(
2)
CX_EXPORT cxmutstr cx_asprintf_a(
const CxAllocator *allocator,
const char *fmt, ...);
#define cx_asprintf(fmt, ...) cx_asprintf_a(cxDefaultAllocator, fmt,
__VA_ARGS__)
cx_attr_nonnull cx_attr_cstr_arg(
2)
CX_EXPORT cxmutstr cx_vasprintf_a(
const CxAllocator *allocator,
const char *fmt, va_list ap);
#define cx_vasprintf(fmt, ap) cx_vasprintf_a(cxDefaultAllocator, fmt, ap)
#define cx_bprintf(buffer, fmt, ...) cx_fprintf((
void*)buffer, cxBufferWriteFunc, fmt,
__VA_ARGS__)
#define cx_sprintf(str, len, fmt, ...) cx_sprintf_a(cxDefaultAllocator, str, len, fmt,
__VA_ARGS__)
cx_attr_nonnull_arg(
1,
2,
3,
4) cx_attr_printf(
4,
5) cx_attr_cstr_arg(
4)
CX_EXPORT int cx_sprintf_a(
const CxAllocator *alloc,
char **str,
size_t *len,
const char *fmt, ...);
#define cx_vsprintf(str, len, fmt, ap) cx_vsprintf_a(cxDefaultAllocator, str, len, fmt, ap)
cx_attr_nonnull cx_attr_cstr_arg(
4) cx_attr_access_rw(
2) cx_attr_access_rw(
3)
CX_EXPORT int cx_vsprintf_a(
const CxAllocator *alloc,
char **str,
size_t *len,
const char *fmt, va_list ap);
#define cx_sprintf_s(buf, len, str, fmt, ...) cx_sprintf_sa(cxDefaultAllocator, buf, len, str, fmt,
__VA_ARGS__)
cx_attr_nonnull_arg(
1,
2,
4,
5) cx_attr_printf(
5,
6) cx_attr_cstr_arg(
5)
cx_attr_access_rw(
2) cx_attr_access_rw(
3) cx_attr_access_rw(
4)
CX_EXPORT int cx_sprintf_sa(
const CxAllocator *alloc,
char *buf,
size_t *len,
char **str,
const char *fmt, ...);
#define cx_vsprintf_s(buf, len, str, fmt, ap) cx_vsprintf_sa(cxDefaultAllocator, buf, len, str, fmt, ap)
cx_attr_nonnull cx_attr_cstr_arg(
5)
CX_EXPORT int cx_vsprintf_sa(
const CxAllocator *alloc,
char *buf,
size_t *len,
char **str,
const char *fmt, va_list ap);
#ifdef __cplusplus
}
#endif
#endif