Root/
1 | #include "libsa.h"␊ |
2 | ␊ |
3 | static void (*print)(char *);␊ |
4 | ␊ |
5 | void __printf_init(void (*print_fn)(char*))␊ |
6 | {␊ |
7 | ␉print = print_fn ? print_fn : NULL;␊ |
8 | }␊ |
9 | ␊ |
10 | void __printf(const char * format, ...)␊ |
11 | {␊ |
12 | ␉char buf[4096];␊ |
13 | ␉va_list ap;␊ |
14 | ␉␊ |
15 | ␉if (print != NULL)␊ |
16 | ␉{␊ |
17 | ␉␉va_start(ap, format);␊ |
18 | ␉␉vsnprintf(buf, sizeof(buf), format, ap);␊ |
19 | ␉␉va_end(ap);␊ |
20 | ␉␉print(buf);␊ |
21 | ␉}␊ |
22 | } |