1 /* fprintf.c */
2
3 /*
4 * Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 #include <stdarg.h>
10 #include <stdio.h>
11 #include <zephyr/sys/cbprintf.h>
12
13 #define DESC(d) ((void *)d)
14
fprintf(FILE * ZRESTRICT stream,const char * ZRESTRICT format,...)15 int fprintf(FILE *ZRESTRICT stream, const char *ZRESTRICT format, ...)
16 {
17 va_list vargs;
18 int r;
19
20 va_start(vargs, format);
21 r = cbvprintf(fputc, DESC(stream), format, vargs);
22 va_end(vargs);
23
24 return r;
25 }
26
vfprintf(FILE * ZRESTRICT stream,const char * ZRESTRICT format,va_list vargs)27 int vfprintf(FILE *ZRESTRICT stream, const char *ZRESTRICT format,
28 va_list vargs)
29 {
30 int r;
31
32 r = cbvprintf(fputc, DESC(stream), format, vargs);
33
34 return r;
35 }
36
printf(const char * ZRESTRICT format,...)37 int printf(const char *ZRESTRICT format, ...)
38 {
39 va_list vargs;
40 int r;
41
42 va_start(vargs, format);
43 r = cbvprintf(fputc, DESC(stdout), format, vargs);
44 va_end(vargs);
45
46 return r;
47 }
48
vprintf(const char * ZRESTRICT format,va_list vargs)49 int vprintf(const char *ZRESTRICT format, va_list vargs)
50 {
51 int r;
52
53 r = cbvprintf(fputc, DESC(stdout), format, vargs);
54
55 return r;
56 }
57