/src/httpd/server/util_debug.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Licensed to the Apache Software Foundation (ASF) under one or more |
2 | | * contributor license agreements. See the NOTICE file distributed with |
3 | | * this work for additional information regarding copyright ownership. |
4 | | * The ASF licenses this file to You under the Apache License, Version 2.0 |
5 | | * (the "License"); you may not use this file except in compliance with |
6 | | * the License. You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | |
17 | | #define APR_WANT_STRFUNC |
18 | | #include "apr_want.h" |
19 | | |
20 | | #include "httpd.h" |
21 | | #include "http_config.h" |
22 | | #include "http_core.h" |
23 | | |
24 | | /* Possibly get rid of the macros we defined in httpd.h */ |
25 | | #if defined(strchr) |
26 | | #undef strchr |
27 | | #endif |
28 | | |
29 | | #if defined (strrchr) |
30 | | #undef strrchr |
31 | | #endif |
32 | | |
33 | | #if defined (strstr) |
34 | | #undef strstr |
35 | | #endif |
36 | | |
37 | | |
38 | | #if defined(ap_strchr) |
39 | | #undef ap_strchr |
40 | | AP_DECLARE(char *) ap_strchr(char *s, int c); |
41 | | #endif |
42 | | |
43 | | AP_DECLARE(char *) ap_strchr(char *s, int c) |
44 | 0 | { |
45 | 0 | return strchr(s,c); |
46 | 0 | } |
47 | | |
48 | | #if defined(ap_strchr_c) |
49 | | #undef ap_strchr_c |
50 | | AP_DECLARE(const char *) ap_strchr_c(const char *s, int c); |
51 | | #endif |
52 | | |
53 | | AP_DECLARE(const char *) ap_strchr_c(const char *s, int c) |
54 | 0 | { |
55 | 0 | return strchr(s,c); |
56 | 0 | } |
57 | | |
58 | | #if defined(ap_strrchr) |
59 | | #undef ap_strrchr |
60 | | AP_DECLARE(char *) ap_strrchr(char *s, int c); |
61 | | #endif |
62 | | |
63 | | AP_DECLARE(char *) ap_strrchr(char *s, int c) |
64 | 0 | { |
65 | 0 | return strrchr(s,c); |
66 | 0 | } |
67 | | |
68 | | #if defined(ap_strrchr_c) |
69 | | #undef ap_strrchr_c |
70 | | AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c); |
71 | | #endif |
72 | | |
73 | | AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c) |
74 | 0 | { |
75 | 0 | return strrchr(s,c); |
76 | 0 | } |
77 | | |
78 | | #if defined(ap_strstr) |
79 | | #undef ap_strstr |
80 | | AP_DECLARE(char *) ap_strstr(char *s, const char *c); |
81 | | #endif |
82 | | |
83 | | AP_DECLARE(char *) ap_strstr(char *s, const char *c) |
84 | 0 | { |
85 | 0 | return strstr(s,c); |
86 | 0 | } |
87 | | |
88 | | #if defined(ap_strstr_c) |
89 | | #undef ap_strstr_c |
90 | | AP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c); |
91 | | #endif |
92 | | |
93 | | AP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c) |
94 | 0 | { |
95 | 0 | return strstr(s,c); |
96 | 0 | } |
97 | | |
98 | | #if defined(ap_get_module_config) |
99 | | #undef ap_get_module_config |
100 | | AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, |
101 | | const module *m); |
102 | | #endif |
103 | | |
104 | | AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, |
105 | | const module *m) |
106 | 0 | { |
107 | 0 | return ((void **)cv)[m->module_index]; |
108 | 0 | } |
109 | | |
110 | | AP_DECLARE(int) ap_get_module_flags(const module *m) |
111 | 0 | { |
112 | 0 | if (m->version < AP_MODULE_FLAGS_MMN_MAJOR |
113 | 0 | || (m->version == AP_MODULE_FLAGS_MMN_MAJOR |
114 | 0 | && (m->minor_version < AP_MODULE_FLAGS_MMN_MINOR))) { |
115 | 0 | return 0; |
116 | 0 | } |
117 | | |
118 | 0 | return m->flags; |
119 | 0 | } |
120 | | |
121 | | #if defined(ap_get_core_module_config) |
122 | | #undef ap_get_core_module_config |
123 | | AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv); |
124 | | #endif |
125 | | |
126 | | AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv) |
127 | 0 | { |
128 | 0 | return ((void **)cv)[AP_CORE_MODULE_INDEX]; |
129 | 0 | } |
130 | | |
131 | | |
132 | | #if defined(ap_get_server_module_loglevel) |
133 | | #undef ap_get_server_module_loglevel |
134 | | AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index); |
135 | | #endif |
136 | | |
137 | | AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index) |
138 | 0 | { |
139 | 0 | if (module_index < 0 || s->log.module_levels == NULL || |
140 | 0 | s->log.module_levels[module_index] < 0) |
141 | 0 | { |
142 | 0 | return s->log.level; |
143 | 0 | } |
144 | | |
145 | 0 | return s->log.module_levels[module_index]; |
146 | 0 | } |
147 | | |
148 | | #if defined(ap_get_conn_module_loglevel) |
149 | | #undef ap_get_conn_module_loglevel |
150 | | AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index); |
151 | | #endif |
152 | | |
153 | | AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index) |
154 | 0 | { |
155 | 0 | const struct ap_logconf *l = (c)->log ? (c)->log : &(c)->base_server->log; |
156 | 0 | if (module_index < 0 || l->module_levels == NULL || |
157 | 0 | l->module_levels[module_index] < 0) |
158 | 0 | { |
159 | 0 | return l->level; |
160 | 0 | } |
161 | | |
162 | 0 | return l->module_levels[module_index]; |
163 | 0 | } |
164 | | |
165 | | #if defined(ap_get_conn_server_module_loglevel) |
166 | | #undef ap_get_conn_server_module_loglevel |
167 | | AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c, |
168 | | const server_rec *s, |
169 | | int module_index); |
170 | | #endif |
171 | | |
172 | | AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c, |
173 | | const server_rec *s, |
174 | | int module_index) |
175 | 0 | { |
176 | 0 | const struct ap_logconf *l = (c->log && c->log != &c->base_server->log) ? |
177 | 0 | c->log : &s->log; |
178 | 0 | if (module_index < 0 || l->module_levels == NULL || |
179 | 0 | l->module_levels[module_index] < 0) |
180 | 0 | { |
181 | 0 | return l->level; |
182 | 0 | } |
183 | | |
184 | 0 | return l->module_levels[module_index]; |
185 | 0 | } |
186 | | |
187 | | #if defined(ap_get_request_module_loglevel) |
188 | | #undef ap_get_request_module_loglevel |
189 | | AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *c, int module_index); |
190 | | #endif |
191 | | |
192 | | AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int module_index) |
193 | 0 | { |
194 | 0 | const struct ap_logconf *l = r->log ? r->log : |
195 | 0 | r->connection->log ? r->connection->log : |
196 | 0 | &r->server->log; |
197 | 0 | if (module_index < 0 || l->module_levels == NULL || |
198 | 0 | l->module_levels[module_index] < 0) |
199 | 0 | { |
200 | 0 | return l->level; |
201 | 0 | } |
202 | | |
203 | 0 | return l->module_levels[module_index]; |
204 | 0 | } |
205 | | |
206 | | /** |
207 | | * Generic accessors for other modules to set at their own module-specific |
208 | | * data |
209 | | * @param conf_vector The vector in which the modules configuration is stored. |
210 | | * usually r->per_dir_config or s->module_config |
211 | | * @param m The module to set the data for. |
212 | | * @param val The module-specific data to set |
213 | | * @fn void ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val) |
214 | | */ |
215 | | #if defined(ap_set_module_config) |
216 | | #undef ap_set_module_config |
217 | | AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, |
218 | | void *val); |
219 | | #endif |
220 | | |
221 | | AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, |
222 | | void *val) |
223 | 0 | { |
224 | 0 | ((void **)cv)[m->module_index] = val; |
225 | 0 | } |
226 | | |
227 | | |
228 | | #if defined(ap_set_core_module_config) |
229 | | #undef ap_set_core_module_config |
230 | | AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val); |
231 | | #endif |
232 | | |
233 | | AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val) |
234 | 0 | { |
235 | 0 | ((void **)cv)[AP_CORE_MODULE_INDEX] = val; |
236 | 0 | } |
237 | | |
238 | | #if defined(apr_palloc) |
239 | | #undef apr_palloc |
240 | | #endif |
241 | | AP_DECLARE(void *) ap_palloc_debug(apr_pool_t *p, apr_size_t size) |
242 | 0 | { |
243 | | /* poison uninitialized memory */ |
244 | 0 | return memset(apr_palloc(p, size), 0xEE, size); |
245 | 0 | } |
246 | | |
247 | | #if defined(apr_pcalloc) |
248 | | #undef apr_pcalloc |
249 | | #endif |
250 | | AP_DECLARE(void *) ap_pcalloc_debug(apr_pool_t *p, apr_size_t size) |
251 | 0 | { |
252 | 0 | return memset(apr_palloc(p, size), 0, size); |
253 | 0 | } |