1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef SHELL_FPRINTF_H__
- #define SHELL_FPRINTF_H__
- #include <zephyr.h>
- #include <stdbool.h>
- #include <stddef.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef void (*shell_fprintf_fwrite)(const void *user_ctx,
- const char *data,
- size_t length);
- struct shell_fprintf_control_block {
- size_t buffer_cnt;
- bool autoflush;
- };
- struct shell_fprintf {
- uint8_t *buffer;
- size_t buffer_size;
- shell_fprintf_fwrite fwrite;
- const void *user_ctx;
- struct shell_fprintf_control_block *ctrl_blk;
- };
- #define Z_SHELL_FPRINTF_DEFINE(_name, _user_ctx, _buf, _size, \
- _autoflush, _fwrite) \
- static struct shell_fprintf_control_block \
- _name##_shell_fprintf_ctx = { \
- .autoflush = _autoflush, \
- .buffer_cnt = 0 \
- }; \
- static const struct shell_fprintf _name = { \
- .buffer = _buf, \
- .buffer_size = _size, \
- .fwrite = _fwrite, \
- .user_ctx = _user_ctx, \
- .ctrl_blk = &_name##_shell_fprintf_ctx \
- }
- void z_shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf,
- char const *fmt, va_list args);
- void z_shell_fprintf_buffer_flush(const struct shell_fprintf *sh_fprintf);
- #ifdef __cplusplus
- }
- #endif
- #endif
|