55cf6e01272ec475edea32aa9b7923de2d36cb42Christian Maeder/* Licensed to the Apache Software Foundation (ASF) under one or more
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * contributor license agreements. See the NOTICE file distributed with
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * this work for additional information regarding copyright ownership.
b43458b4d81f7451112cecbd757f3a05216e7088Kristina Sojakova * The ASF licenses this file to You under the Apache License, Version 2.0
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * (the "License"); you may not use this file except in compliance with
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * the License. You may obtain a copy of the License at
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu *
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * http://www.apache.org/licenses/LICENSE-2.0
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova *
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * Unless required by applicable law or agreed to in writing, software
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * distributed under the License is distributed on an "AS IS" BASIS,
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * See the License for the specific language governing permissions and
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * limitations under the License.
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova */
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#define APR_WANT_STRFUNC
b2e01ef1b5d4c7a62260eb792291e8e1b10e545bIulia Ignatov#include "apr_want.h"
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#include "httpd.h"
9f85afecbd79b3df5a0bb17bd28cd0b288dc3213Kristina Sojakova#include "http_config.h"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova#include "http_core.h"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova
44e934cd533a334ae00a65b83dba146c1352b0aaIulia Ignatov/* Possibly get rid of the macros we defined in httpd.h */
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#if defined(strchr)
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#undef strchr
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#endif
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova#if defined (strrchr)
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova#undef strrchr
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#endif
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#if defined (strstr)
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#undef strstr
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#endif
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
b43458b4d81f7451112cecbd757f3a05216e7088Kristina Sojakova#if defined(ap_strchr)
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#undef ap_strchr
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaAP_DECLARE(char *) ap_strchr(char *s, int c);
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#endif
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaAP_DECLARE(char *) ap_strchr(char *s, int c)
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova{
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova return strchr(s,c);
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder}
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder#if defined(ap_strchr_c)
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder#undef ap_strchr_c
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaAP_DECLARE(const char *) ap_strchr_c(const char *s, int c);
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#endif
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaAP_DECLARE(const char *) ap_strchr_c(const char *s, int c)
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova{
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova return strchr(s,c);
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova}
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova#if defined(ap_strrchr)
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova#undef ap_strrchr
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina SojakovaAP_DECLARE(char *) ap_strrchr(char *s, int c);
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder#endif
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova
b43458b4d81f7451112cecbd757f3a05216e7088Kristina SojakovaAP_DECLARE(char *) ap_strrchr(char *s, int c)
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova{
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova return strrchr(s,c);
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova}
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#if defined(ap_strrchr_c)
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#undef ap_strrchr_c
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaAP_DECLARE(const char *) ap_strrchr_c(const char *s, int c);
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#endif
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
abd5fc85dc7e19b1614890182436940e922963a4Kristina SojakovaAP_DECLARE(const char *) ap_strrchr_c(const char *s, int c)
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova{
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova return strrchr(s,c);
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova}
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#if defined(ap_strstr)
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#undef ap_strstr
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaAP_DECLARE(char *) ap_strstr(char *s, const char *c);
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova#endif
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaAP_DECLARE(char *) ap_strstr(char *s, const char *c)
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova{
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova return strstr(s,c);
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder}
80d2ec8f37d5ddec13c14b17b1bab01e9c94630aChristian Maeder
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder#if defined(ap_strstr_c)
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova#undef ap_strstr_c
168d206b4e5fd436c98239a1b6629c651f54c8eeKristina SojakovaAP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c);
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder#endif
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina SojakovaAP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c)
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova{
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova return strstr(s,c);
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova}
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova#if defined(ap_get_module_config)
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder#undef ap_get_module_config
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina SojakovaAP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova const module *m);
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder#endif
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina SojakovaAP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova const module *m)
168d206b4e5fd436c98239a1b6629c651f54c8eeKristina Sojakova{
80d2ec8f37d5ddec13c14b17b1bab01e9c94630aChristian Maeder return ((void **)cv)[m->module_index];
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova}
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova#if defined(ap_get_core_module_config)
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova#undef ap_get_core_module_config
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina SojakovaAP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv);
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova#endif
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina SojakovaAP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv)
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova{
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova return ((void **)cv)[AP_CORE_MODULE_INDEX];
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova}
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina Sojakova#if defined(ap_get_server_module_loglevel)
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina Sojakova#undef ap_get_server_module_loglevel
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina SojakovaAP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index);
2cb6df4f21c52732336579a79f7e5d28299b3500Iulia Ignatov#endif
2cb6df4f21c52732336579a79f7e5d28299b3500Iulia Ignatov
b2e01ef1b5d4c7a62260eb792291e8e1b10e545bIulia IgnatovAP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index)
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder{
if (module_index < 0 || s->log.module_levels == NULL ||
s->log.module_levels[module_index] < 0)
{
return s->log.level;
}
return s->log.module_levels[module_index];
}
#if defined(ap_get_conn_module_loglevel)
#undef ap_get_conn_module_loglevel
AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index);
#endif
AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index)
{
const struct ap_logconf *l = (c)->log ? (c)->log : &(c)->base_server->log;
if (module_index < 0 || l->module_levels == NULL ||
l->module_levels[module_index] < 0)
{
return l->level;
}
return l->module_levels[module_index];
}
#if defined(ap_get_conn_server_module_loglevel)
#undef ap_get_conn_server_module_loglevel
AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
const server_rec *s,
int module_index);
#endif
AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
const server_rec *s,
int module_index)
{
const struct ap_logconf *l = (c->log && c->log != &c->base_server->log) ?
c->log : &s->log;
if (module_index < 0 || l->module_levels == NULL ||
l->module_levels[module_index] < 0)
{
return l->level;
}
return l->module_levels[module_index];
}
#if defined(ap_get_request_module_loglevel)
#undef ap_get_request_module_loglevel
AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *c, int module_index);
#endif
AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int module_index)
{
const struct ap_logconf *l = r->log ? r->log :
r->connection->log ? r->connection->log :
&r->server->log;
if (module_index < 0 || l->module_levels == NULL ||
l->module_levels[module_index] < 0)
{
return l->level;
}
return l->module_levels[module_index];
}
/**
* Generic accessors for other modules to set at their own module-specific
* data
* @param conf_vector The vector in which the modules configuration is stored.
* usually r->per_dir_config or s->module_config
* @param m The module to set the data for.
* @param val The module-specific data to set
* @fn void ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val)
*/
#if defined(ap_set_module_config)
#undef ap_set_module_config
AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
void *val);
#endif
AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
void *val)
{
((void **)cv)[m->module_index] = val;
}
#if defined(ap_set_core_module_config)
#undef ap_set_core_module_config
AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val);
#endif
AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val)
{
((void **)cv)[AP_CORE_MODULE_INDEX] = val;
}
#if defined(apr_palloc)
#undef apr_palloc
#endif
AP_DECLARE(void *) ap_palloc_debug(apr_pool_t *p, apr_size_t size)
{
/* poison uninitialized memory */
return memset(apr_palloc(p, size), 0xEE, size);
}
#if defined(apr_pcalloc)
#undef apr_pcalloc
#endif
AP_DECLARE(void *) ap_pcalloc_debug(apr_pool_t *p, apr_size_t size)
{
return memset(apr_palloc(p, size), 0, size);
}