123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #ifndef NRF_FPRINTF_H__
- #define NRF_FPRINTF_H__
- #include <stdbool.h>
- #include <stddef.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef void (* nrf_fprintf_fwrite)(void const * p_user_ctx, char const * p_str, size_t length);
- typedef struct nrf_fprintf_ctx
- {
- char * const p_io_buffer;
- size_t const io_buffer_size;
- size_t io_buffer_cnt;
- bool auto_flush;
- void const * const p_user_ctx;
- nrf_fprintf_fwrite fwrite;
- } nrf_fprintf_ctx_t;
- #define NRF_FPRINTF_DEF(name, _p_user_ctx, _p_io_buffer, _io_buffer_size, _auto_flush, _fwrite) \
- static nrf_fprintf_ctx_t name = \
- { \
- .p_io_buffer = _p_io_buffer, \
- .io_buffer_size = _io_buffer_size, \
- .io_buffer_cnt = 0, \
- .auto_flush = _auto_flush, \
- .p_user_ctx = _p_user_ctx, \
- .fwrite = _fwrite \
- }
- void nrf_fprintf(nrf_fprintf_ctx_t * const p_ctx,
- char const * p_fmt,
- ...);
- void nrf_fprintf_buffer_flush(nrf_fprintf_ctx_t * const p_ctx);
- #ifdef __cplusplus
- }
- #endif
- #endif
|