Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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>
#include <zephyr/sys/cbprintf_enums.h>

Go to the source code of this file.

Data Structures

struct  cbprintf_package_desc
 cbprintf package descriptor. More...
 
union  cbprintf_package_hdr
 cbprintf package header More...
 
struct  cbprintf_package_hdr_ext
 cbprintf package header with format string pointer. More...
 

Macros

#define CBPRINTF_PACKAGE_ALIGNMENT
 Required alignment of the buffer used for packaging.
 
#define CBPRINTF_PACKAGE_CONST_CHAR_RO   BIT(0)
 Assume that const char pointer is pointing to read only (constant) strings.
 
#define CBPRINTF_PACKAGE_ADD_RO_STR_POS   BIT(1)
 Append locations (within the package) of read-only string pointers.
 
#define CBPRINTF_PACKAGE_ADD_RW_STR_POS   BIT(2)
 Append locations (within the package) of read-write string pointers.
 
#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.
 
#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.
 
#define CBPRINTF_PACKAGE_ARGS_ARE_TAGGED   BIT(6)
 Indicate the incoming arguments are tagged.
 
#define CBPRINTF_PACKAGE_CONVERT_RO_STR   BIT(0)
 Append read-only strings from source package to destination package.
 
#define CBPRINTF_PACKAGE_COPY_RO_STR   CBPRINTF_PACKAGE_CONVERT_RO_STR __DEPRECATED_MACRO
 
#define CBPRINTF_PACKAGE_CONVERT_RW_STR   BIT(1)
 Append read-write strings from source package to destination package.
 
#define CBPRINTF_PACKAGE_COPY_RW_STR   CBPRINTF_PACKAGE_CONVERT_RW_STR __DEPRECATED_MACRO
 
#define CBPRINTF_PACKAGE_CONVERT_KEEP_RO_STR   BIT(2)
 Keep read-only location indexes in the package.
 
#define CBPRINTF_PACKAGE_COPY_KEEP_RO_STR   CBPRINTF_PACKAGE_CONVERT_KEEP_RO_STR __DEPRECATED_MACRO
 
#define CBPRINTF_PACKAGE_CONVERT_PTR_CHECK   BIT(3)
 Check format string if p argument was treated as s in the package.
 
#define CBPRINTF_MUST_RUNTIME_PACKAGE(flags, ...)    Z_CBPRINTF_MUST_RUNTIME_PACKAGE(flags, __VA_ARGS__)
 Determine if string must be packaged in run time.
 
#define CBPRINTF_STATIC_PACKAGE(packaged, inlen, outlen, align_offset, flags, ...)
 Statically package string.
 

Typedefs

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

Functions

int cbprintf_package (void *packaged, size_t len, uint32_t flags, const char *format,...)
 Capture state required to output formatted data later.
 
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.
 
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.
 
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.
 
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.
 
int cbpprintf_external (cbprintf_cb out, cbvprintf_external_formatter_func formatter, void *ctx, void *packaged)
 Generate the output for a previously captured format operation using an external formatter.
 
int cbprintf (cbprintf_cb out, void *ctx, const char *format,...)
 *printf-like output through a callback.
 
static int cbvprintf (cbprintf_cb out, void *ctx, const char *format, va_list ap)
 varargs-aware *printf-like output through a callback.
 
static int cbvprintf_tagged_args (cbprintf_cb out, void *ctx, const char *format, va_list ap)
 varargs-aware *printf-like output through a callback with tagged arguments.
 
static int cbpprintf (cbprintf_cb out, void *ctx, void *packaged)
 Generate the output for a previously captured format operation.
 
int fprintfcb (FILE *stream, const char *format,...)
 fprintf using Zephyrs cbprintf infrastructure.
 
int vfprintfcb (FILE *stream, const char *format, va_list ap)
 vfprintf using Zephyrs cbprintf infrastructure.
 
int printfcb (const char *format,...)
 printf using Zephyrs cbprintf infrastructure.
 
int vprintfcb (const char *format, va_list ap)
 vprintf using Zephyrs cbprintf infrastructure.
 
int snprintfcb (char *str, size_t size, const char *format,...)
 snprintf using Zephyrs cbprintf infrastructure.
 
int vsnprintfcb (char *str, size_t size, const char *format, va_list ap)
 vsnprintf using Zephyrs cbprintf infrastructure.