]> granicus.if.org Git - apache/blob - server/util_debug.c
Merge r1741310, r1741461 from trunk:
[apache] / server / util_debug.c
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 {
45     return strchr(s,c);
46 }
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 {
55     return strchr(s,c);
56 }
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 {
65     return strrchr(s,c);
66 }
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 {
75     return strrchr(s,c);
76 }
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 {
85     return strstr(s,c);
86 }
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 {
95     return strstr(s,c);
96 }
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 {
107     return ((void **)cv)[m->module_index];
108 }
109
110 #if defined(ap_get_core_module_config)
111 #undef ap_get_core_module_config
112 AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv);
113 #endif
114
115 AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv)
116 {
117     return ((void **)cv)[AP_CORE_MODULE_INDEX];
118 }
119
120
121 #if defined(ap_get_server_module_loglevel)
122 #undef ap_get_server_module_loglevel
123 AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index);
124 #endif
125
126 AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index)
127 {
128     if (module_index < 0 || s->log.module_levels == NULL ||
129         s->log.module_levels[module_index] < 0)
130     {
131         return s->log.level;
132     }
133
134     return s->log.module_levels[module_index];
135 }
136
137 #if defined(ap_get_conn_module_loglevel)
138 #undef ap_get_conn_module_loglevel
139 AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index);
140 #endif
141
142 AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index)
143 {
144     const struct ap_logconf *l = (c)->log ? (c)->log : &(c)->base_server->log;
145     if (module_index < 0 || l->module_levels == NULL ||
146         l->module_levels[module_index] < 0)
147     {
148         return l->level;
149     }
150
151     return l->module_levels[module_index];
152 }
153
154 #if defined(ap_get_conn_server_module_loglevel)
155 #undef ap_get_conn_server_module_loglevel
156 AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
157                                                    const server_rec *s,
158                                                    int module_index);
159 #endif
160
161 AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
162                                                    const server_rec *s,
163                                                    int module_index)
164 {
165     const struct ap_logconf *l = (c->log && c->log != &c->base_server->log) ?
166                                  c->log : &s->log;
167     if (module_index < 0 || l->module_levels == NULL ||
168         l->module_levels[module_index] < 0)
169     {
170         return l->level;
171     }
172
173     return l->module_levels[module_index];
174 }
175
176 #if defined(ap_get_request_module_loglevel)
177 #undef ap_get_request_module_loglevel
178 AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *c, int module_index);
179 #endif
180
181 AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int module_index)
182 {
183     const struct ap_logconf *l = r->log             ? r->log             :
184                                  r->connection->log ? r->connection->log :
185                                  &r->server->log;
186     if (module_index < 0 || l->module_levels == NULL ||
187         l->module_levels[module_index] < 0)
188     {
189         return l->level;
190     }
191
192     return l->module_levels[module_index];
193 }
194
195 /**
196  * Generic accessors for other modules to set at their own module-specific
197  * data
198  * @param conf_vector The vector in which the modules configuration is stored.
199  *        usually r->per_dir_config or s->module_config
200  * @param m The module to set the data for.
201  * @param val The module-specific data to set
202  * @fn void ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val)
203  */
204 #if defined(ap_set_module_config)
205 #undef ap_set_module_config
206 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
207                                       void *val);
208 #endif
209
210 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
211                                       void *val)
212 {
213     ((void **)cv)[m->module_index] = val;
214 }
215
216
217 #if defined(ap_set_core_module_config)
218 #undef ap_set_core_module_config
219 AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val);
220 #endif
221
222 AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val)
223 {
224     ((void **)cv)[AP_CORE_MODULE_INDEX] = val;
225 }