added doxygen comments
[strongswan.git] / src / libstrongswan / printf_hook.c
1 /**
2 * @file printf_hook.c
3 *
4 * @brief Printf hook definitions and arginfo functions.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include "printf_hook.h"
24
25 /**
26 * arginfo handler in printf() pointer
27 */
28 int arginfo_ptr(const struct printf_info *info, size_t n, int *argtypes)
29 {
30 if (n > 0)
31 {
32 argtypes[0] = PA_POINTER;
33 }
34 return 1;
35 }
36
37 /**
38 * arginfo handler for two prt arguments
39 */
40 int arginfo_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes)
41 {
42 if (n > 1)
43 {
44 argtypes[0] = PA_POINTER;
45 argtypes[1] = PA_POINTER;
46 }
47 return 2;
48 }
49
50 /**
51 * arginfo handler for one ptr, one int
52 */
53 int arginfo_ptr_int(const struct printf_info *info, size_t n, int *argtypes)
54 {
55 if (n > 1)
56 {
57 argtypes[0] = PA_POINTER;
58 argtypes[1] = PA_INT;
59 }
60 return 2;
61 }
62
63 /**
64 * arginfo handler for two int arguments
65 */
66 int arginfo_int_int(const struct printf_info *info, size_t n, int *argtypes)
67 {
68 if (n > 1)
69 {
70 argtypes[0] = PA_INT;
71 argtypes[1] = PA_INT;
72 }
73 return 2;
74 }
75
76 /**
77 * special arginfo handler respecting alt flag
78 */
79 int arginfo_int_alt_int_int(const struct printf_info *info, size_t n, int *argtypes)
80 {
81 if (info->alt)
82 {
83 if (n > 1)
84 {
85 argtypes[0] = PA_INT;
86 argtypes[1] = PA_INT;
87 }
88 return 2;
89 }
90
91 if (n > 0)
92 {
93 argtypes[0] = PA_INT;
94 }
95 return 1;
96 }
97
98 /**
99 * special arginfo handler respecting alt flag
100 */
101 int arginfo_ptr_alt_ptr_int(const struct printf_info *info, size_t n, int *argtypes)
102 {
103 if (info->alt)
104 {
105 if (n > 1)
106 {
107 argtypes[0] = PA_POINTER;
108 argtypes[1] = PA_INT;
109 }
110 return 2;
111 }
112
113 if (n > 0)
114 {
115 argtypes[0] = PA_POINTER;
116 }
117 return 1;
118 }