Zephyr Project API  3.1.0
A Scalable Open Source RTOS
cbprintf.h File Reference
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/toolchain.h>
#include <string.h>
#include <stdio.h>
#include <zephyr/sys/cbprintf_internal.h>

Go to the source code of this file.

Macros

#define CBPRINTF_PACKAGE_ALIGNMENT
 Required alignment of the buffer used for packaging. More...
 
#define CBPRINTF_PACKAGE_CONST_CHAR_RO   BIT(0)
 Assume that const char pointer is pointing to read only (constant) strings. More...
 
#define CBPRINTF_PACKAGE_ADD_RO_STR_POS   BIT(1)
 Append locations (within the package) of read-only string pointers.`. More...
 
#define CBPRINTF_PACKAGE_ADD_RW_STR_POS   BIT(2)
 Append locations (within the package) of read-write string pointers. More...
 
#define CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(n)    (n << Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET)
 Indicate that n first string format arguments are char pointers to read-only location. More...
 
#define CBPRINTF_PACKAGE_ADD_STRING_IDXS    (CBPRINTF_PACKAGE_ADD_RO_STR_POS | CBPRINTF_PACKAGE_CONST_CHAR_RO)
 Append indexes of read-only string arguments in the package. More...
 
#define CBPRINTF_PACKAGE_COPY_RO_STR   BIT(0)
 Append read-only strings from source package to destination package. More...
 
#define CBPRINTF_PACKAGE_COPY_RW_STR   BIT(1)
 Append read-write strings from source package to destination package. More...
 
#define CBPRINTF_PACKAGE_COPY_KEEP_RO_STR   BIT(2)
 Keep read-only location indexes in the package. More...
 
#define CBPRINTF_MUST_RUNTIME_PACKAGE(flags, ...)    Z_CBPRINTF_MUST_RUNTIME_PACKAGE(flags, __VA_ARGS__)
 Determine if string must be packaged in run time. More...
 
#define CBPRINTF_STATIC_PACKAGE(packaged, inlen, outlen, align_offset, flags, ...)
 Statically package string. More...
 

Typedefs

typedef int(* cbprintf_cb) ()
 Signature for a cbprintf callback function. More...
 
typedef int(* cbprintf_convert_cb) (const void *buf, size_t len, void *ctx)
 Signature for a cbprintf multibyte callback function. More...
 
typedef int(* cbvprintf_exteral_formatter_func) (cbprintf_cb out, void *ctx, const char *fmt, va_list ap)
 Signature for a external formatter function identical to cbvprintf. More...
 

Functions

int cbprintf_package (void *packaged, size_t len, uint32_t flags, const char *format,...)
 Capture state required to output formatted data later. More...
 
int cbvprintf_package (void *packaged, size_t len, uint32_t flags, const char *format, va_list ap)
 Capture state required to output formatted data later. More...
 
int cbprintf_package_convert (void *in_packaged, size_t in_len, cbprintf_convert_cb cb, void *ctx, uint32_t flags, uint16_t *strl, size_t strl_len)
 Convert a package. More...
 
static int cbprintf_package_copy (void *in_packaged, size_t in_len, void *packaged, size_t len, uint32_t flags, uint16_t *strl, size_t strl_len)
 Copy package with optional appending of strings. More...
 
static int cbprintf_fsc_package (void *in_packaged, size_t in_len, void *packaged, size_t len)
 Convert package to fully self-contained (fsc) package. More...
 
int cbpprintf_external (cbprintf_cb out, cbvprintf_exteral_formatter_func formatter, void *ctx, void *packaged)
 Generate the output for a previously captured format operation using an external formatter. More...
 
int cbprintf (cbprintf_cb out, void *ctx, const char *format,...)
 *printf-like output through a callback. More...
 
int cbvprintf (cbprintf_cb out, void *ctx, const char *format, va_list ap)
 varargs-aware *printf-like output through a callback. More...
 
static int cbpprintf (cbprintf_cb out, void *ctx, void *packaged)
 Generate the output for a previously captured format operation. More...
 
int fprintfcb (FILE *stream, const char *format,...)
 fprintf using Zephyrs cbprintf infrastructure. More...
 
int vfprintfcb (FILE *stream, const char *format, va_list ap)
 vfprintf using Zephyrs cbprintf infrastructure. More...
 
int printfcb (const char *format,...)
 printf using Zephyrs cbprintf infrastructure. More...
 
int vprintfcb (const char *format, va_list ap)
 vprintf using Zephyrs cbprintf infrastructure. More...
 
int snprintfcb (char *str, size_t size, const char *format,...)
 snprintf using Zephyrs cbprintf infrastructure. More...
 
int vsnprintfcb (char *str, size_t size, const char *format, va_list ap)
 vsnprintf using Zephyrs cbprintf infrastructure. More...