aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/printf_hook/printf_hook_builtin.h
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-10-11 11:12:38 +0200
committerMartin Willi <martin@revosec.ch>2013-10-11 11:12:38 +0200
commit5900d6d469d24faf7052ed24f013f02cb33a7095 (patch)
tree05fd3b8922ef17eadc2e16ca3f6f44f02d10fe87 /src/libstrongswan/utils/printf_hook/printf_hook_builtin.h
parent11282d0054d8a51f184a6f726f7f180ccf60e456 (diff)
parent795cbb98c6950d732f112063bd16de02ec54db67 (diff)
downloadstrongswan-5900d6d469d24faf7052ed24f013f02cb33a7095.tar.bz2
strongswan-5900d6d469d24faf7052ed24f013f02cb33a7095.tar.xz
Merge branch 'printf-hook'
Adds a custom printf hook implementation as a fallback if neither the glibc style hooks nor vstr is available. This can avoid the Vstr dependency on some systems at the cost of slower and less complete printf functions.
Diffstat (limited to 'src/libstrongswan/utils/printf_hook/printf_hook_builtin.h')
-rw-r--r--src/libstrongswan/utils/printf_hook/printf_hook_builtin.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/printf_hook/printf_hook_builtin.h b/src/libstrongswan/utils/printf_hook/printf_hook_builtin.h
new file mode 100644
index 000000000..409b5bf3d
--- /dev/null
+++ b/src/libstrongswan/utils/printf_hook/printf_hook_builtin.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2013 Martin Willi
+ * Copyright (C) 2013 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup printf_hook_builtin printf_hook_builtin
+ * @{ @ingroup utils
+ */
+
+#ifndef PRINTF_HOOK_BUILTIN_H_
+#define PRINTF_HOOK_BUILTIN_H_
+
+#include <stdarg.h>
+#include <stdio.h>
+
+int builtin_printf(const char *format, ...);
+int builtin_fprintf(FILE *stream, const char *format, ...);
+int builtin_sprintf(char *str, const char *format, ...);
+int builtin_snprintf(char *str, size_t size, const char *format, ...);
+int builtin_asprintf(char **str, const char *format, ...);
+
+int builtin_vprintf(const char *format, va_list ap);
+int builtin_vfprintf(FILE *stream, const char *format, va_list ap);
+int builtin_vsprintf(char *str, const char *format, va_list ap);
+int builtin_vsnprintf(char *str, size_t size, const char *format, va_list ap);
+int builtin_vasprintf(char **str, const char *format, va_list ap);
+
+#ifdef printf
+#undef printf
+#endif
+#ifdef fprintf
+#undef fprintf
+#endif
+#ifdef sprintf
+#undef sprintf
+#endif
+#ifdef snprintf
+#undef snprintf
+#endif
+#ifdef asprintf
+#undef asprintf
+#endif
+#ifdef vprintf
+#undef vprintf
+#endif
+#ifdef vfprintf
+#undef vfprintf
+#endif
+#ifdef vsprintf
+#undef vsprintf
+#endif
+#ifdef vsnprintf
+#undef vsnprintf
+#endif
+#ifdef vasprintf
+#undef vasprintf
+#endif
+
+#define printf builtin_printf
+#define fprintf builtin_fprintf
+#define sprintf builtin_sprintf
+#define snprintf builtin_snprintf
+#define asprintf builtin_asprintf
+
+#define vprintf builtin_vprintf
+#define vfprintf builtin_vfprintf
+#define vsprintf builtin_vsprintf
+#define vsnprintf builtin_vsnprintf
+#define vasprintf builtin_vasprintf
+
+#endif /** PRINTF_HOOK_BUILTIN_H_ @}*/