shell: switch to cbprintf as basis for printf functionality

Replace use of z_prf with cbprintf.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-11-03 15:14:16 -06:00 committed by Anas Nashif
commit 125c5752a6

View file

@ -6,13 +6,7 @@
#include <shell/shell_fprintf.h>
#include <shell/shell.h>
#ifdef CONFIG_NEWLIB_LIBC
typedef int (*out_func_t)(int c, void *ctx);
extern void z_vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap);
#else
extern int z_prf(int (*func)(), void *dest, char *format, va_list vargs);
#endif
#include <sys/cbprintf.h>
static int out_func(int c, void *ctx)
{
@ -39,11 +33,7 @@ static int out_func(int c, void *ctx)
void shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf,
const char *fmt, va_list args)
{
#if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_ARCH_POSIX)
(void)z_prf(out_func, (void *)sh_fprintf, (char *)fmt, args);
#else
z_vprintk(out_func, (void *)sh_fprintf, fmt, args);
#endif
(void)cbvprintf(out_func, (void *)sh_fprintf, fmt, args);
if (sh_fprintf->ctrl_blk->autoflush) {
shell_fprintf_buffer_flush(sh_fprintf);