printf-hook-builtin: Add a new "builtin" backend using its own printf() routines
[strongswan.git] / src / libstrongswan / utils / printf_hook / printf_hook_builtin.h
1 /*
2 * Copyright (C) 2013 Martin Willi
3 * Copyright (C) 2013 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup printf_hook_builtin printf_hook_builtin
18 * @{ @ingroup utils
19 */
20
21 #ifndef PRINTF_HOOK_BUILTIN_H_
22 #define PRINTF_HOOK_BUILTIN_H_
23
24 #include <stdarg.h>
25 #include <stdio.h>
26
27 int builtin_printf(const char *format, ...);
28 int builtin_fprintf(FILE *stream, const char *format, ...);
29 int builtin_sprintf(char *str, const char *format, ...);
30 int builtin_snprintf(char *str, size_t size, const char *format, ...);
31 int builtin_asprintf(char **str, const char *format, ...);
32
33 int builtin_vprintf(const char *format, va_list ap);
34 int builtin_vfprintf(FILE *stream, const char *format, va_list ap);
35 int builtin_vsprintf(char *str, const char *format, va_list ap);
36 int builtin_vsnprintf(char *str, size_t size, const char *format, va_list ap);
37 int builtin_vasprintf(char **str, const char *format, va_list ap);
38
39 #ifdef printf
40 #undef printf
41 #endif
42 #ifdef fprintf
43 #undef fprintf
44 #endif
45 #ifdef sprintf
46 #undef sprintf
47 #endif
48 #ifdef snprintf
49 #undef snprintf
50 #endif
51 #ifdef asprintf
52 #undef asprintf
53 #endif
54 #ifdef vprintf
55 #undef vprintf
56 #endif
57 #ifdef vfprintf
58 #undef vfprintf
59 #endif
60 #ifdef vsprintf
61 #undef vsprintf
62 #endif
63 #ifdef vsnprintf
64 #undef vsnprintf
65 #endif
66 #ifdef vasprintf
67 #undef vasprintf
68 #endif
69
70 #define printf builtin_printf
71 #define fprintf builtin_fprintf
72 #define sprintf builtin_sprintf
73 #define snprintf builtin_snprintf
74 #define asprintf builtin_asprintf
75
76 #define vprintf builtin_vprintf
77 #define vfprintf builtin_vfprintf
78 #define vsprintf builtin_vsprintf
79 #define vsnprintf builtin_vsnprintf
80 #define vasprintf builtin_vasprintf
81
82 #endif /** PRINTF_HOOK_BUILTIN_H_ @}*/