1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

*) Introduce "ap_conf_vector_t" type to assist with legibility and provide

some type safety. (unfortunately, our old "void*" is type-safe with the
   new one, but over time we should be better)

*) Propagate the new type to all appropriate functions.

*) Random cleaning, whitespace, stylistic nits.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88225 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Greg Stein
2001-02-18 02:58:53 +00:00
parent 19d4d315ef
commit dd9b08e321
16 changed files with 277 additions and 262 deletions

View File

@@ -431,7 +431,12 @@ struct module_struct {
NULL, \ NULL, \
MODULE_MAGIC_COOKIE MODULE_MAGIC_COOKIE
#if AP_RBB_HACK
/* CONFIGURATION VECTOR FUNCTIONS */
typedef struct ap_conf_vector_t ap_conf_vector_t;
#ifdef AP_DEBUG
/** /**
* Generic accessors for other modules to get at their own module-specific * Generic accessors for other modules to get at their own module-specific
* data * data
@@ -439,11 +444,11 @@ struct module_struct {
* usually r->per_dir_config or s->module_config * usually r->per_dir_config or s->module_config
* @param m The module to get the data for. * @param m The module to get the data for.
* @return The module-specific data * @return The module-specific data
* @deffunc void *ap_get_module_config(void *conf_vector, module *m) * @deffunc void *ap_get_module_config(const ap_conf_vector_t *cv, module *m)
*/ */
AP_DECLARE(void *) ap_get_module_config(void *conf_vector, module *m); AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
#endif const module *m);
#if AP_RBB_HACK
/** /**
* Generic accessors for other modules to set at their own module-specific * Generic accessors for other modules to set at their own module-specific
* data * data
@@ -451,16 +456,21 @@ AP_DECLARE(void *) ap_get_module_config(void *conf_vector, module *m);
* usually r->per_dir_config or s->module_config * usually r->per_dir_config or s->module_config
* @param m The module to set the data for. * @param m The module to set the data for.
* @param val The module-specific data to set * @param val The module-specific data to set
* @deffunc void ap_set_module_config(void *conf_vector, module *m, void *val) * @deffunc void ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val)
*/ */
AP_DECLARE(void) ap_set_module_config(void *conf_vector, module *m, void *val); AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
#endif void *val);
#else /* AP_DEBUG */
#define ap_get_module_config(v,m) \ #define ap_get_module_config(v,m) \
(((void **)(v))[(m)->module_index]) (((void **)(v))[(m)->module_index])
#define ap_set_module_config(v,m,val) \ #define ap_set_module_config(v,m,val) \
((((void **)(v))[(m)->module_index]) = (val)) ((((void **)(v))[(m)->module_index]) = (val))
#endif /* AP_DEBUG */
/** /**
* Generic command handling function for strings * Generic command handling function for strings
* @param cmd The command parameters for this directive * @param cmd The command parameters for this directive
@@ -820,7 +830,7 @@ AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server);
* @param p The pool to allocate the config vector out of * @param p The pool to allocate the config vector out of
* @return The config vector * @return The config vector
*/ */
void *ap_create_request_config(apr_pool_t *p); ap_conf_vector_t *ap_create_request_config(apr_pool_t *p);
/** /**
* Setup the config vector for per dir module configs * Setup the config vector for per dir module configs
@@ -828,7 +838,7 @@ void *ap_create_request_config(apr_pool_t *p);
* @return The config vector * @return The config vector
* @deffunc void *ap_create_per_dir_config(apr_pool_t *p) * @deffunc void *ap_create_per_dir_config(apr_pool_t *p)
*/ */
AP_CORE_DECLARE(void *) ap_create_per_dir_config(apr_pool_t *p); AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
/** /**
* Run all of the modules merge per dir config functions * Run all of the modules merge per dir config functions
@@ -836,7 +846,9 @@ AP_CORE_DECLARE(void *) ap_create_per_dir_config(apr_pool_t *p);
* @param base The base directory config structure * @param base The base directory config structure
* @param new The new directory config structure * @param new The new directory config structure
*/ */
void *ap_merge_per_dir_configs(apr_pool_t *p, void *base, void *new); ap_conf_vector_t *ap_merge_per_dir_configs(apr_pool_t *p,
ap_conf_vector_t *base,
ap_conf_vector_t *new);
/* For http_connection.c... */ /* For http_connection.c... */
/** /**
@@ -844,7 +856,7 @@ void *ap_merge_per_dir_configs(apr_pool_t *p, void *base, void *new);
* @param p The pool to allocate the config vector out of * @param p The pool to allocate the config vector out of
* @return The config vector * @return The config vector
*/ */
void *ap_create_conn_config(apr_pool_t *p); ap_conf_vector_t *ap_create_conn_config(apr_pool_t *p);
/* For http_core.c... (<Directory> command and virtual hosts) */ /* For http_core.c... (<Directory> command and virtual hosts) */
@@ -857,8 +869,8 @@ void *ap_create_conn_config(apr_pool_t *p);
* @param access_name The list of possible names for .htaccess files * @param access_name The list of possible names for .htaccess files
* int The status of the current request * int The status of the current request
*/ */
int ap_parse_htaccess(void **result, request_rec *r, int override, int ap_parse_htaccess(ap_conf_vector_t **result, request_rec *r, int override,
const char *path, const char *access_name); const char *path, const char *access_name);
/** /**
* Setup a virtual host * Setup a virtual host

View File

@@ -311,6 +311,7 @@ AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l);
* @deffunc int ap_rputc(int c, request_rec *r) * @deffunc int ap_rputc(int c, request_rec *r)
*/ */
AP_DECLARE(int) ap_rputc(int c, request_rec *r); AP_DECLARE(int) ap_rputc(int c, request_rec *r);
/** /**
* Output a string for the current request * Output a string for the current request
* @param str The string to output * @param str The string to output
@@ -319,6 +320,7 @@ AP_DECLARE(int) ap_rputc(int c, request_rec *r);
* @deffunc int ap_rputs(const char *str, request_rec *r) * @deffunc int ap_rputs(const char *str, request_rec *r)
*/ */
AP_DECLARE(int) ap_rputs(const char *str, request_rec *r); AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
/** /**
* Write a buffer for the current request * Write a buffer for the current request
* @param buf The buffer to write * @param buf The buffer to write
@@ -328,6 +330,7 @@ AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
* @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r) * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r)
*/ */
AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
/** /**
* Write an unspecified number of strings to the request * Write an unspecified number of strings to the request
* @param r The current request * @param r The current request
@@ -336,6 +339,7 @@ AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
* @deffunc int ap_rvputs(request_rec *r, ...) * @deffunc int ap_rvputs(request_rec *r, ...)
*/ */
AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...); AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
/** /**
* Output data to the client in a printf format * Output data to the client in a printf format
* @param r The current request * @param r The current request
@@ -345,6 +349,7 @@ AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
* @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist) * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist)
*/ */
AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist); AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
/** /**
* Output data to the client in a printf format * Output data to the client in a printf format
* @param r The current request * @param r The current request
@@ -397,6 +402,7 @@ AP_DECLARE(const char *) ap_get_status_line(int status);
* @deffunc int ap_setup_cleint_block(request_rec *r, int read_policy) * @deffunc int ap_setup_cleint_block(request_rec *r, int read_policy)
*/ */
AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy); AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
/** /**
* Determine if the client has sent any data. This also sends a * Determine if the client has sent any data. This also sends a
* 100 Continue resposne to HTTP/1.1 clients, so modules should not be called * 100 Continue resposne to HTTP/1.1 clients, so modules should not be called
@@ -407,6 +413,7 @@ AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy);
* @deffunc int ap_should_client_block(request_rec *r) * @deffunc int ap_should_client_block(request_rec *r)
*/ */
AP_DECLARE(int) ap_should_client_block(request_rec *r); AP_DECLARE(int) ap_should_client_block(request_rec *r);
/** /**
* Call this in a loop. It will put data into a buffer and return the length * Call this in a loop. It will put data into a buffer and return the length
* of the input block * of the input block
@@ -418,6 +425,7 @@ AP_DECLARE(int) ap_should_client_block(request_rec *r);
* @deffunc long ap_get_client_block(request_rec *r, char *buffer, int bufsiz) * @deffunc long ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
*/ */
AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz); AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz);
/** /**
* In HTTP/1.1, any method can have a body. However, most GET handlers * In HTTP/1.1, any method can have a body. However, most GET handlers
* wouldn't know what to do with a request body if they received one. * wouldn't know what to do with a request body if they received one.
@@ -431,6 +439,7 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz);
*/ */
AP_DECLARE(int) ap_discard_request_body(request_rec *r); AP_DECLARE(int) ap_discard_request_body(request_rec *r);
/* Sending a byterange */ /* Sending a byterange */
/** /**
@@ -441,6 +450,7 @@ AP_DECLARE(int) ap_discard_request_body(request_rec *r);
* @deffunc void ap_note_auth_failure(request_rec *r) * @deffunc void ap_note_auth_failure(request_rec *r)
*/ */
AP_DECLARE(void) ap_note_auth_failure(request_rec *r); AP_DECLARE(void) ap_note_auth_failure(request_rec *r);
/** /**
* Setup the output headers so that the client knows how to authenticate * Setup the output headers so that the client knows how to authenticate
* itself the next time, if an authentication request failed. This function * itself the next time, if an authentication request failed. This function
@@ -449,6 +459,7 @@ AP_DECLARE(void) ap_note_auth_failure(request_rec *r);
* @deffunc void ap_note_basic_auth_failure(request_rec *r) * @deffunc void ap_note_basic_auth_failure(request_rec *r)
*/ */
AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r); AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
/** /**
* Setup the output headers so that the client knows how to authenticate * Setup the output headers so that the client knows how to authenticate
* itself the next time, if an authentication request failed. This function * itself the next time, if an authentication request failed. This function
@@ -457,6 +468,7 @@ AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);
* @deffunc void ap_note_digest_auth_failure(request_rec *r) * @deffunc void ap_note_digest_auth_failure(request_rec *r)
*/ */
AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r); AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);
/** /**
* Get the password from the request headers * Get the password from the request headers
* @param r The current request * @param r The current request
@@ -528,6 +540,7 @@ AP_DECLARE(const char *) ap_method_name_of(int methnum);
* @deffunc ap_run_post_read_request(request_rec *r) * @deffunc ap_run_post_read_request(request_rec *r)
*/ */
AP_DECLARE_HOOK(int,post_read_request,(request_rec *r)) AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
/** /**
* This hook allows modules to perform any module-specific logging activities * This hook allows modules to perform any module-specific logging activities
* over and above the normal server things. * over and above the normal server things.
@@ -536,6 +549,7 @@ AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
* @deffunc int ap_run_log_transaction(request_rec *r) * @deffunc int ap_run_log_transaction(request_rec *r)
*/ */
AP_DECLARE_HOOK(int,log_transaction,(request_rec *r)) AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
/** /**
* This hook allows modules to retrieve the http method from a request. This * This hook allows modules to retrieve the http method from a request. This
* allows Apache modules to easily extend the methods that Apache understands * allows Apache modules to easily extend the methods that Apache understands
@@ -544,6 +558,7 @@ AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))
* @deffunc const char *ap_run_http_method(const request_rec *r) * @deffunc const char *ap_run_http_method(const request_rec *r)
*/ */
AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r)) AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r))
/** /**
* Return the default port from the current request * Return the default port from the current request
* @param r The current request * @param r The current request
@@ -553,6 +568,7 @@ AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r))
AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r)) AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
typedef struct ap_bucket_error ap_bucket_error; typedef struct ap_bucket_error ap_bucket_error;
/** /**
* A bucket referring to an HTTP error * A bucket referring to an HTTP error
* This bucket can be passed down the filter stack to indicate that an * This bucket can be passed down the filter stack to indicate that an

View File

@@ -505,7 +505,7 @@ struct htaccess_result {
/** the overrides allowed for the .htaccess file */ /** the overrides allowed for the .htaccess file */
int override; int override;
/** the configuration directives */ /** the configuration directives */
void *htaccess; struct ap_conf_vector_t *htaccess;
/** the next one, or NULL if no more; N.B. never change this */ /** the next one, or NULL if no more; N.B. never change this */
const struct htaccess_result *next; const struct htaccess_result *next;
}; };
@@ -729,9 +729,9 @@ struct request_rec {
*/ */
/** Options set in config files, etc. */ /** Options set in config files, etc. */
void *per_dir_config; struct ap_conf_vector_t *per_dir_config;
/** Notes on *this* request */ /** Notes on *this* request */
void *request_config; struct ap_conf_vector_t *request_config;
/** /**
* a linked list of the configuration directives in the .htaccess files * a linked list of the configuration directives in the .htaccess files
@@ -811,7 +811,7 @@ struct conn_rec {
/** ID of this connection; unique at any point in time */ /** ID of this connection; unique at any point in time */
long id; long id;
/** Notes on *this* connection */ /** Notes on *this* connection */
void *conn_config; struct ap_conf_vector_t *conn_config;
/** send note from one module to another, must remain valid for all /** send note from one module to another, must remain valid for all
* requests on this conn */ * requests on this conn */
apr_table_t *notes; apr_table_t *notes;
@@ -883,9 +883,9 @@ struct server_rec {
int is_virtual; int is_virtual;
/** Config vector containing pointers to modules' per-server config /** Config vector containing pointers to modules' per-server config
* structures. */ * structures. */
void *module_config; struct ap_conf_vector_t *module_config;
/** MIME type info, etc., before we start checking per-directory info */ /** MIME type info, etc., before we start checking per-directory info */
void *lookup_defaults; struct ap_conf_vector_t *lookup_defaults;
/* Transaction handling */ /* Transaction handling */

View File

@@ -325,6 +325,8 @@ static void log_error_and_cleanup(char *msg, apr_status_t sts, server_rec *s)
cleanup_tables(NULL); cleanup_tables(NULL);
} }
#if APR_HAS_SHARED_MEMORY
static void initialize_tables(server_rec *s, apr_pool_t *ctx) static void initialize_tables(server_rec *s, apr_pool_t *ctx)
{ {
unsigned long idx; unsigned long idx;
@@ -392,6 +394,9 @@ static void initialize_tables(server_rec *s, apr_pool_t *ctx)
return; return;
} }
#endif /* APR_HAS_SHARED_MEMORY */
static void initialize_module(apr_pool_t *p, apr_pool_t *plog, static void initialize_module(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s) apr_pool_t *ptemp, server_rec *s)
{ {

View File

@@ -158,8 +158,8 @@ static void *merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg) static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgi_server_conf *conf = cgi_server_conf *conf = ap_get_module_config(s->module_config,
(cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module); &cgi_module);
conf->logname = arg; conf->logname = arg;
return NULL; return NULL;
@@ -169,8 +169,8 @@ static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy,
const char *arg) const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgi_server_conf *conf = cgi_server_conf *conf = ap_get_module_config(s->module_config,
(cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module); &cgi_module);
conf->logbytes = atol(arg); conf->logbytes = atol(arg);
return NULL; return NULL;
@@ -180,8 +180,8 @@ static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy,
const char *arg) const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgi_server_conf *conf = cgi_server_conf *conf = ap_get_module_config(s->module_config,
(cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module); &cgi_module);
conf->bufbytes = atoi(arg); conf->bufbytes = atoi(arg);
return NULL; return NULL;
@@ -371,10 +371,12 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
apr_procattr_t *procattr; apr_procattr_t *procattr;
apr_proc_t *procnew; apr_proc_t *procnew;
apr_status_t rc = APR_SUCCESS; apr_status_t rc = APR_SUCCESS;
#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \ #if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS) defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
core_dir_config *conf;
conf = (core_dir_config *) ap_get_module_config(r->per_dir_config, &core_module); core_dir_config *conf = ap_get_module_config(r->per_dir_config,
&core_module);
#endif #endif

View File

@@ -440,8 +440,8 @@ static int cgid_server(void *data)
mode_t omask; mode_t omask;
apr_socklen_t len; apr_socklen_t len;
server_rec *main_server = data; server_rec *main_server = data;
cgid_server_conf *sconf = (cgid_server_conf *)ap_get_module_config( cgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
main_server->module_config, &cgid_module); &cgid_module);
apr_signal(SIGCHLD, SIG_IGN); apr_signal(SIGCHLD, SIG_IGN);
if (unlink(sconf->sockname) < 0 && errno != ENOENT) { if (unlink(sconf->sockname) < 0 && errno != ENOENT) {
@@ -640,8 +640,8 @@ static void *merge_cgid_config(apr_pool_t *p, void *basev, void *overridesv)
static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg) static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgid_server_conf *conf = cgid_server_conf *conf = ap_get_module_config(s->module_config,
(cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module); &cgid_module);
conf->logname = arg; conf->logname = arg;
return NULL; return NULL;
@@ -650,8 +650,8 @@ static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy, const char *arg) static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy, const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgid_server_conf *conf = cgid_server_conf *conf = ap_get_module_config(s->module_config,
(cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module); &cgid_module);
conf->logbytes = atol(arg); conf->logbytes = atol(arg);
return NULL; return NULL;
@@ -660,8 +660,8 @@ static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy, const char
static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy, const char *arg) static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy, const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgid_server_conf *conf = cgid_server_conf *conf = ap_get_module_config(s->module_config,
(cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module); &cgid_module);
conf->bufbytes = atoi(arg); conf->bufbytes = atoi(arg);
return NULL; return NULL;
@@ -670,8 +670,8 @@ static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy, const char
static const char *set_script_socket(cmd_parms *cmd, void *dummy, const char *arg) static const char *set_script_socket(cmd_parms *cmd, void *dummy, const char *arg)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
cgid_server_conf *conf = cgid_server_conf *conf = ap_get_module_config(s->module_config,
(cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module); &cgid_module);
conf->sockname = ap_server_root_relative(cmd->pool, arg); conf->sockname = ap_server_root_relative(cmd->pool, arg);
return NULL; return NULL;
@@ -820,7 +820,6 @@ static int cgid_handler(request_rec *r)
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
char argsbuffer[HUGE_STRING_LEN]; char argsbuffer[HUGE_STRING_LEN];
void *sconf;
cgid_server_conf *conf; cgid_server_conf *conf;
int is_included; int is_included;
int sd; int sd;
@@ -839,8 +838,7 @@ static int cgid_handler(request_rec *r)
return DECLINED; return DECLINED;
} }
sconf = r->server->module_config; conf = ap_get_module_config(r->server->module_config, &cgid_module);
conf = (cgid_server_conf *) ap_get_module_config(sconf, &cgid_module);
is_included = !strcmp(r->protocol, "INCLUDED"); is_included = !strcmp(r->protocol, "INCLUDED");
if ((argv0 = strrchr(r->filename, '/')) != NULL) if ((argv0 = strrchr(r->filename, '/')) != NULL)
@@ -1125,8 +1123,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb, char *comman
apr_bucket *b; apr_bucket *b;
struct sockaddr_un unix_addr; struct sockaddr_un unix_addr;
apr_file_t *tempsock = NULL; apr_file_t *tempsock = NULL;
void *sconf = r->server->module_config; cgid_server_conf *conf = ap_get_module_config(r->server->module_config,
cgid_server_conf *conf = (cgid_server_conf *) ap_get_module_config(sconf, &cgid_module); &cgid_module);
add_ssi_vars(r, f->next); add_ssi_vars(r, f->next);
env = ap_create_environment(r->pool, r->subprocess_env); env = ap_create_environment(r->pool, r->subprocess_env);

View File

@@ -148,7 +148,7 @@ static void *create_core_dir_config(apr_pool_t *a, char *dir)
conf->limit_req_body = 0; conf->limit_req_body = 0;
conf->limit_xml_body = AP_LIMIT_UNSET; conf->limit_xml_body = AP_LIMIT_UNSET;
conf->sec = apr_array_make(a, 2, sizeof(void *)); conf->sec = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
#ifdef WIN32 #ifdef WIN32
conf->script_interpreter_source = INTERPRETER_SOURCE_UNSET; conf->script_interpreter_source = INTERPRETER_SOURCE_UNSET;
#endif #endif
@@ -318,8 +318,8 @@ static void *create_core_server_config(apr_pool_t *a, server_rec *s)
#endif #endif
conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME; conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME;
conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION; conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION;
conf->sec = apr_array_make(a, 40, sizeof(void *)); conf->sec = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
conf->sec_url = apr_array_make(a, 40, sizeof(void *)); conf->sec_url = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
return (void *)conf; return (void *)conf;
} }
@@ -406,7 +406,7 @@ AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
* components (where a "special" section has infinite components). * components (where a "special" section has infinite components).
*/ */
struct reorder_sort_rec { struct reorder_sort_rec {
void *elt; ap_conf_vector_t *elt;
int orig_index; int orig_index;
}; };
@@ -417,8 +417,8 @@ static int reorder_sorter(const void *va, const void *vb)
core_dir_config *core_a; core_dir_config *core_a;
core_dir_config *core_b; core_dir_config *core_b;
core_a = (core_dir_config *)ap_get_module_config(a->elt, &core_module); core_a = ap_get_module_config(a->elt, &core_module);
core_b = (core_dir_config *)ap_get_module_config(b->elt, &core_module); core_b = ap_get_module_config(b->elt, &core_module);
if (IS_SPECIAL(core_a)) { if (IS_SPECIAL(core_a)) {
if (!IS_SPECIAL(core_b)) { if (!IS_SPECIAL(core_b)) {
return 1; return 1;
@@ -448,14 +448,14 @@ void ap_core_reorder_directories(apr_pool_t *p, server_rec *s)
apr_array_header_t *sec; apr_array_header_t *sec;
struct reorder_sort_rec *sortbin; struct reorder_sort_rec *sortbin;
int nelts; int nelts;
void **elts; ap_conf_vector_t **elts;
int i; int i;
apr_pool_t *tmp; apr_pool_t *tmp;
sconf = ap_get_module_config(s->module_config, &core_module); sconf = ap_get_module_config(s->module_config, &core_module);
sec = sconf->sec; sec = sconf->sec;
nelts = sec->nelts; nelts = sec->nelts;
elts = (void **)sec->elts; elts = (ap_conf_vector_t **)sec->elts;
/* we have to allocate tmp space to do a stable sort */ /* we have to allocate tmp space to do a stable sort */
apr_pool_create(&tmp, p); apr_pool_create(&tmp, p);

View File

@@ -331,9 +331,9 @@ static int get_path_info(request_rec *r)
static int directory_walk(request_rec *r) static int directory_walk(request_rec *r)
{ {
core_server_config *sconf = ap_get_module_config(r->server->module_config, core_server_config *sconf = ap_get_module_config(r->server->module_config,
&core_module); &core_module);
void *per_dir_defaults = r->server->lookup_defaults; ap_conf_vector_t *per_dir_defaults = r->server->lookup_defaults;
void **sec = (void **) sconf->sec->elts; ap_conf_vector_t **sec = (ap_conf_vector_t **) sconf->sec->elts;
int num_sec = sconf->sec->nelts; int num_sec = sconf->sec->nelts;
char *test_filename; char *test_filename;
char *test_dirname; char *test_dirname;
@@ -343,6 +343,9 @@ static int directory_walk(request_rec *r)
#if defined(HAVE_UNC_PATHS) || defined(NETWARE) #if defined(HAVE_UNC_PATHS) || defined(NETWARE)
unsigned iStart = 1; unsigned iStart = 1;
#endif #endif
ap_conf_vector_t *entry_config;
ap_conf_vector_t *this_conf;
core_dir_config *entry_core;
/* /*
* Are we dealing with a file? If not, we can (hopefuly) safely assume we * Are we dealing with a file? If not, we can (hopefuly) safely assume we
@@ -372,16 +375,12 @@ static int directory_walk(request_rec *r)
if (!ap_os_is_path_absolute(r->filename)) if (!ap_os_is_path_absolute(r->filename))
{ {
void *this_conf, *entry_config; const char *entry_dir;
core_dir_config *entry_core;
char *entry_dir;
for (j = 0; j < num_sec; ++j) { for (j = 0; j < num_sec; ++j) {
entry_config = sec[j]; entry_config = sec[j];
entry_core = ap_get_module_config(entry_config, &core_module);
entry_core = (core_dir_config *)
ap_get_module_config(entry_config, &core_module);
entry_dir = entry_core->d; entry_dir = entry_core->d;
this_conf = NULL; this_conf = NULL;
@@ -398,8 +397,8 @@ static int directory_walk(request_rec *r)
if (this_conf) if (this_conf)
per_dir_defaults = ap_merge_per_dir_configs(r->pool, per_dir_defaults = ap_merge_per_dir_configs(r->pool,
per_dir_defaults, per_dir_defaults,
this_conf); this_conf);
} }
r->per_dir_config = per_dir_defaults; r->per_dir_config = per_dir_defaults;
@@ -410,7 +409,7 @@ static int directory_walk(request_rec *r)
/* XXX This needs to be rolled into APR, the APR function will not /* XXX This needs to be rolled into APR, the APR function will not
* be allowed to fold the case of any non-existant segment of the path: * be allowed to fold the case of any non-existant segment of the path:
*/ */
r->filename = ap_os_case_canonical_filename(r->pool, r->filename); r->filename = ap_os_case_canonical_filename(r->pool, r->filename);
/* TODO This is rather silly right here, we should simply be setting /* TODO This is rather silly right here, we should simply be setting
* filename and path_info at the end of our directory_walk * filename and path_info at the end of our directory_walk
@@ -420,10 +419,10 @@ static int directory_walk(request_rec *r)
return res; return res;
} }
/* XXX This becomes mute, and will already happen above for elements /* XXX This becomes moot, and will already happen above for elements
* that actually exist: * that actually exist:
*/ */
r->filename = ap_os_canonical_filename(r->pool, r->filename); r->filename = ap_os_canonical_filename(r->pool, r->filename);
test_filename = apr_pstrdup(r->pool, r->filename); test_filename = apr_pstrdup(r->pool, r->filename);
@@ -500,8 +499,8 @@ static int directory_walk(request_rec *r)
j = 0; j = 0;
for (; i <= num_dirs; ++i) { for (; i <= num_dirs; ++i) {
int overrides_here; int overrides_here;
core_dir_config *core_dir = (core_dir_config *) core_dir_config *core_dir = ap_get_module_config(per_dir_defaults,
ap_get_module_config(per_dir_defaults, &core_module); &core_module);
/* /*
* XXX: this could be made faster by only copying the next component * XXX: this could be made faster by only copying the next component
@@ -530,13 +529,10 @@ static int directory_walk(request_rec *r)
*/ */
for (; j < num_sec; ++j) { for (; j < num_sec; ++j) {
void *entry_config = sec[j];
core_dir_config *entry_core;
char *entry_dir; char *entry_dir;
void *this_conf;
entry_core = (core_dir_config *) entry_config = sec[j];
ap_get_module_config(entry_config, &core_module); entry_core = ap_get_module_config(entry_config, &core_module);
entry_dir = entry_core->d; entry_dir = entry_core->d;
if (entry_core->r if (entry_core->r
@@ -546,10 +542,11 @@ static int directory_walk(request_rec *r)
* XXX: The net test may be wrong... may fail ap_os_is_path_absolute * XXX: The net test may be wrong... may fail ap_os_is_path_absolute
*/ */
|| (entry_core->d_components > 1 || (entry_core->d_components > 1
&& entry_core->d_components > i)) && entry_core->d_components > i)
#else #else
|| entry_core->d_components > i) || entry_core->d_components > i
#endif /* def HAVE_DRIVE_LETTERS || NETWARE */ #endif /* def HAVE_DRIVE_LETTERS || NETWARE */
)
break; break;
this_conf = NULL; this_conf = NULL;
@@ -563,10 +560,10 @@ static int directory_walk(request_rec *r)
if (this_conf) { if (this_conf) {
per_dir_defaults = ap_merge_per_dir_configs(r->pool, per_dir_defaults = ap_merge_per_dir_configs(r->pool,
per_dir_defaults, per_dir_defaults,
this_conf); this_conf);
core_dir = (core_dir_config *) core_dir = ap_get_module_config(per_dir_defaults,
ap_get_module_config(per_dir_defaults, &core_module); &core_module);
} }
#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE) #if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE)
/* So that other top-level directory sections (e.g. "e:/") aren't /* So that other top-level directory sections (e.g. "e:/") aren't
@@ -587,11 +584,11 @@ static int directory_walk(request_rec *r)
if (i >= iStart) if (i >= iStart)
#endif #endif
if (overrides_here) { if (overrides_here) {
void *htaccess_conf = NULL; ap_conf_vector_t *htaccess_conf = NULL;
res = ap_parse_htaccess(&htaccess_conf, r, overrides_here, res = ap_parse_htaccess(&htaccess_conf, r, overrides_here,
apr_pstrdup(r->pool, test_dirname), apr_pstrdup(r->pool, test_dirname),
sconf->access_name); sconf->access_name);
if (res) if (res)
return res; return res;
@@ -610,17 +607,15 @@ static int directory_walk(request_rec *r)
* regexes. * regexes.
*/ */
for (; j < num_sec; ++j) { for (; j < num_sec; ++j) {
void *entry_config = sec[j];
core_dir_config *entry_core;
entry_core = (core_dir_config *) entry_config = sec[j];
ap_get_module_config(entry_config, &core_module); entry_core = ap_get_module_config(entry_config, &core_module);
if (entry_core->r) { if (entry_core->r) {
if (!ap_regexec(entry_core->r, test_dirname, 0, NULL, REG_NOTEOL)) { if (!ap_regexec(entry_core->r, test_dirname, 0, NULL, REG_NOTEOL)) {
per_dir_defaults = per_dir_defaults = ap_merge_per_dir_configs(r->pool,
ap_merge_per_dir_configs(r->pool, per_dir_defaults, per_dir_defaults,
entry_config); entry_config);
} }
} }
} }
@@ -648,12 +643,13 @@ static int directory_walk(request_rec *r)
static int location_walk(request_rec *r) static int location_walk(request_rec *r)
{ {
core_server_config *sconf = ap_get_module_config(r->server->module_config, core_server_config *sconf = ap_get_module_config(r->server->module_config,
&core_module); &core_module);
void *per_dir_defaults = r->per_dir_config; ap_conf_vector_t *per_dir_defaults = r->per_dir_config;
void **url = (void **) sconf->sec_url->elts; ap_conf_vector_t **url = (ap_conf_vector_t **) sconf->sec_url->elts;
int len, num_url = sconf->sec_url->nelts; int len, num_url = sconf->sec_url->nelts;
char *test_location; char *test_location;
void *this_conf, *entry_config; ap_conf_vector_t *this_conf;
ap_conf_vector_t *entry_config;
core_dir_config *entry_core; core_dir_config *entry_core;
char *entry_url; char *entry_url;
int j; int j;
@@ -684,8 +680,7 @@ static int location_walk(request_rec *r)
entry_config = url[j]; entry_config = url[j];
entry_core = (core_dir_config *) entry_core = ap_get_module_config(entry_config, &core_module);
ap_get_module_config(entry_config, &core_module);
entry_url = entry_core->d; entry_url = entry_core->d;
len = strlen(entry_url); len = strlen(entry_url);
@@ -702,13 +697,14 @@ static int location_walk(request_rec *r)
} }
} }
else if (!strncmp(test_location, entry_url, len) && else if (!strncmp(test_location, entry_url, len) &&
(entry_url[len - 1] == '/' || (entry_url[len - 1] == '/' ||
test_location[len] == '/' || test_location[len] == '\0')) test_location[len] == '/' || test_location[len] == '\0'))
this_conf = entry_config; this_conf = entry_config;
if (this_conf) if (this_conf)
per_dir_defaults = ap_merge_per_dir_configs(r->pool, per_dir_defaults = ap_merge_per_dir_configs(r->pool,
per_dir_defaults, this_conf); per_dir_defaults,
this_conf);
} }
r->per_dir_config = per_dir_defaults; r->per_dir_config = per_dir_defaults;
@@ -717,9 +713,10 @@ static int location_walk(request_rec *r)
static int file_walk(request_rec *r) static int file_walk(request_rec *r)
{ {
core_dir_config *conf = ap_get_module_config(r->per_dir_config, &core_module); core_dir_config *conf = ap_get_module_config(r->per_dir_config,
void *per_dir_defaults = r->per_dir_config; &core_module);
void **file = (void **) conf->sec->elts; ap_conf_vector_t *per_dir_defaults = r->per_dir_config;
ap_conf_vector_t **file = (ap_conf_vector_t **) conf->sec->elts;
int num_files = conf->sec->nelts; int num_files = conf->sec->nelts;
char *test_file; char *test_file;
@@ -735,7 +732,8 @@ static int file_walk(request_rec *r)
/* Go through the file entries, and check for matches. */ /* Go through the file entries, and check for matches. */
if (num_files) { if (num_files) {
void *this_conf, *entry_config; ap_conf_vector_t *this_conf;
ap_conf_vector_t *entry_config;
core_dir_config *entry_core; core_dir_config *entry_core;
char *entry_file; char *entry_file;
int j; int j;
@@ -747,8 +745,7 @@ static int file_walk(request_rec *r)
entry_config = file[j]; entry_config = file[j];
entry_core = (core_dir_config *) entry_core = ap_get_module_config(entry_config, &core_module);
ap_get_module_config(entry_config, &core_module);
entry_file = entry_core->d; entry_file = entry_core->d;
this_conf = NULL; this_conf = NULL;
@@ -768,8 +765,8 @@ static int file_walk(request_rec *r)
if (this_conf) if (this_conf)
per_dir_defaults = ap_merge_per_dir_configs(r->pool, per_dir_defaults = ap_merge_per_dir_configs(r->pool,
per_dir_defaults, per_dir_defaults,
this_conf); this_conf);
} }
r->per_dir_config = per_dir_defaults; r->per_dir_config = per_dir_defaults;
} }

View File

@@ -138,8 +138,8 @@ static const char *add_alias_internal(cmd_parms *cmd, void *dummy,
int use_regex) int use_regex)
{ {
server_rec *s = cmd->server; server_rec *s = cmd->server;
alias_server_conf *conf = alias_server_conf *conf = ap_get_module_config(s->module_config,
(alias_server_conf *) ap_get_module_config(s->module_config, &alias_module); &alias_module);
alias_entry *new = apr_array_push(conf->aliases); alias_entry *new = apr_array_push(conf->aliases);
/* XX r can NOT be relative to DocumentRoot here... compat bug. */ /* XX r can NOT be relative to DocumentRoot here... compat bug. */
@@ -182,8 +182,8 @@ static const char *add_redirect_internal(cmd_parms *cmd,
{ {
alias_entry *new; alias_entry *new;
server_rec *s = cmd->server; server_rec *s = cmd->server;
alias_server_conf *serverconf = alias_server_conf *serverconf = ap_get_module_config(s->module_config,
(alias_server_conf *) ap_get_module_config(s->module_config, &alias_module); &alias_module);
int status = (int) (long) cmd->info; int status = (int) (long) cmd->info;
regex_t *r = NULL; regex_t *r = NULL;
const char *f = arg2; const char *f = arg2;
@@ -377,9 +377,8 @@ static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, int doe
static int translate_alias_redir(request_rec *r) static int translate_alias_redir(request_rec *r)
{ {
void *sconf = r->server->module_config; ap_conf_vector_t *sconf = r->server->module_config;
alias_server_conf *serverconf = alias_server_conf *serverconf = ap_get_module_config(sconf, &alias_module);
(alias_server_conf *) ap_get_module_config(sconf, &alias_module);
char *ret; char *ret;
int status; int status;

View File

@@ -127,10 +127,8 @@ static const char *set_language_priority(cmd_parms *cmd, void *n,
static const char *cache_negotiated_docs(cmd_parms *cmd, void *dummy, static const char *cache_negotiated_docs(cmd_parms *cmd, void *dummy,
int arg) int arg)
{ {
void *server_conf = cmd->server->module_config; ap_set_module_config(cmd->server->module_config, &negotiation_module,
(arg ? "Cache" : NULL));
ap_set_module_config(server_conf, &negotiation_module,
(arg ? "Cache" : NULL));
return NULL; return NULL;
} }

View File

@@ -347,9 +347,7 @@ static const char *cmd_rewriteengine(cmd_parms *cmd,
rewrite_perdir_conf *dconf = in_dconf; rewrite_perdir_conf *dconf = in_dconf;
rewrite_server_conf *sconf; rewrite_server_conf *sconf;
sconf = sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
(rewrite_server_conf *)ap_get_module_config(cmd->server->module_config,
&rewrite_module);
if (cmd->path == NULL) { /* is server command */ if (cmd->path == NULL) { /* is server command */
sconf->state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED); sconf->state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED);
@@ -368,8 +366,7 @@ static const char *cmd_rewriteoptions(cmd_parms *cmd,
rewrite_server_conf *sconf; rewrite_server_conf *sconf;
const char *err; const char *err;
sconf = (rewrite_server_conf *) sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
ap_get_module_config(cmd->server->module_config, &rewrite_module);
if (cmd->path == NULL) { /* is server command */ if (cmd->path == NULL) { /* is server command */
err = cmd_rewriteoptions_setoption(cmd->pool, err = cmd_rewriteoptions_setoption(cmd->pool,
@@ -400,8 +397,7 @@ static const char *cmd_rewritelog(cmd_parms *cmd, void *dconf, const char *a1)
{ {
rewrite_server_conf *sconf; rewrite_server_conf *sconf;
sconf = (rewrite_server_conf *) sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
ap_get_module_config(cmd->server->module_config, &rewrite_module);
sconf->rewritelogfile = a1; sconf->rewritelogfile = a1;
@@ -412,8 +408,7 @@ static const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, const char *
{ {
rewrite_server_conf *sconf; rewrite_server_conf *sconf;
sconf = (rewrite_server_conf *) sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
ap_get_module_config(cmd->server->module_config, &rewrite_module);
sconf->rewriteloglevel = atoi(a1); sconf->rewriteloglevel = atoi(a1);
@@ -427,8 +422,7 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1,
rewritemap_entry *newmap; rewritemap_entry *newmap;
apr_finfo_t st; apr_finfo_t st;
sconf = (rewrite_server_conf *) sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
ap_get_module_config(cmd->server->module_config, &rewrite_module);
newmap = apr_array_push(sconf->rewritemaps); newmap = apr_array_push(sconf->rewritemaps);
@@ -546,8 +540,7 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
const char *err; const char *err;
int rc; int rc;
sconf = (rewrite_server_conf *) sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
ap_get_module_config(cmd->server->module_config, &rewrite_module);
/* make a new entry in the internal temporary rewrite rule list */ /* make a new entry in the internal temporary rewrite rule list */
if (cmd->path == NULL) { /* is server command */ if (cmd->path == NULL) { /* is server command */
@@ -691,8 +684,7 @@ static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf,
const char *err; const char *err;
int mode; int mode;
sconf = (rewrite_server_conf *) sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
ap_get_module_config(cmd->server->module_config, &rewrite_module);
/* make a new entry in the internal rewrite rule list */ /* make a new entry in the internal rewrite rule list */
if (cmd->path == NULL) { /* is server command */ if (cmd->path == NULL) { /* is server command */
@@ -1012,7 +1004,6 @@ static void init_child(apr_pool_t *p, server_rec *s)
static int hook_uri2file(request_rec *r) static int hook_uri2file(request_rec *r)
{ {
void *sconf;
rewrite_server_conf *conf; rewrite_server_conf *conf;
const char *var; const char *var;
const char *thisserver; const char *thisserver;
@@ -1030,9 +1021,7 @@ static int hook_uri2file(request_rec *r)
/* /*
* retrieve the config structures * retrieve the config structures
*/ */
sconf = r->server->module_config; conf = ap_get_module_config(r->server->module_config, &rewrite_module);
conf = (rewrite_server_conf *)ap_get_module_config(sconf,
&rewrite_module);
/* /*
* only do something under runtime if the engine is really enabled, * only do something under runtime if the engine is really enabled,
@@ -2634,7 +2623,6 @@ static char *expand_tildepaths(request_rec *r, char *uri)
static char *lookup_map(request_rec *r, char *name, char *key) static char *lookup_map(request_rec *r, char *name, char *key)
{ {
void *sconf;
rewrite_server_conf *conf; rewrite_server_conf *conf;
apr_array_header_t *rewritemaps; apr_array_header_t *rewritemaps;
rewritemap_entry *entries; rewritemap_entry *entries;
@@ -2645,9 +2633,7 @@ static char *lookup_map(request_rec *r, char *name, char *key)
int i; int i;
/* get map configuration */ /* get map configuration */
sconf = r->server->module_config; conf = ap_get_module_config(r->server->module_config, &rewrite_module);
conf = (rewrite_server_conf *)ap_get_module_config(sconf,
&rewrite_module);
rewritemaps = conf->rewritemaps; rewritemaps = conf->rewritemaps;
entries = (rewritemap_entry *)rewritemaps->elts; entries = (rewritemap_entry *)rewritemaps->elts;

View File

@@ -122,12 +122,12 @@
module userdir_module; module userdir_module;
typedef struct userdir_config { typedef struct {
int globally_disabled; int globally_disabled;
char *userdir; char *userdir;
apr_table_t *enabled_users; apr_table_t *enabled_users;
apr_table_t *disabled_users; apr_table_t *disabled_users;
} userdir_config; } userdir_config;
/* /*
* Server config for this module: global disablement flag, a list of usernames * Server config for this module: global disablement flag, a list of usernames
@@ -137,14 +137,14 @@ typedef struct userdir_config {
static void *create_userdir_config(apr_pool_t *p, server_rec *s) static void *create_userdir_config(apr_pool_t *p, server_rec *s)
{ {
userdir_config userdir_config *newcfg = apr_pcalloc(p, sizeof(*newcfg));
* newcfg = (userdir_config *) apr_pcalloc(p, sizeof(userdir_config));
newcfg->globally_disabled = 0; newcfg->globally_disabled = 0;
newcfg->userdir = DEFAULT_USER_DIR; newcfg->userdir = DEFAULT_USER_DIR;
newcfg->enabled_users = apr_table_make(p, 4); newcfg->enabled_users = apr_table_make(p, 4);
newcfg->disabled_users = apr_table_make(p, 4); newcfg->disabled_users = apr_table_make(p, 4);
return (void *) newcfg;
return newcfg;
} }
#define O_DEFAULT 0 #define O_DEFAULT 0
@@ -153,15 +153,10 @@ static void *create_userdir_config(apr_pool_t *p, server_rec *s)
static const char *set_user_dir(cmd_parms *cmd, void *dummy, const char *arg) static const char *set_user_dir(cmd_parms *cmd, void *dummy, const char *arg)
{ {
userdir_config userdir_config *s_cfg = ap_get_module_config(cmd->server->module_config,
* s_cfg = (userdir_config *) ap_get_module_config &userdir_module);
(
cmd->server->module_config,
&userdir_module
);
char *username; char *username;
const char const char *usernames = arg;
*usernames = arg;
char *kw = ap_getword_conf(cmd->pool, &usernames); char *kw = ap_getword_conf(cmd->pool, &usernames);
apr_table_t *usertable; apr_table_t *usertable;
@@ -219,9 +214,9 @@ static const command_rec userdir_cmds[] = {
static int translate_userdir(request_rec *r) static int translate_userdir(request_rec *r)
{ {
void *server_conf = r->server->module_config; ap_conf_vector_t *server_conf = r->server->module_config;
const userdir_config *s_cfg = const userdir_config *s_cfg = ap_get_module_config(server_conf,
(userdir_config *) ap_get_module_config(server_conf, &userdir_module); &userdir_module);
char *name = r->uri; char *name = r->uri;
const char *userdirs = s_cfg->userdir; const char *userdirs = s_cfg->userdir;
const char *w, *dname; const char *w, *dname;
@@ -233,11 +228,7 @@ static int translate_userdir(request_rec *r)
* If the URI doesn't match our basic pattern, we've nothing to do with * If the URI doesn't match our basic pattern, we've nothing to do with
* it. * it.
*/ */
if ( if (s_cfg->userdir == NULL || name[0] != '/' || name[1] != '~') {
(s_cfg->userdir == NULL) ||
(name[0] != '/') ||
(name[1] != '~')
) {
return DECLINED; return DECLINED;
} }
@@ -271,10 +262,8 @@ static int translate_userdir(request_rec *r)
* If there's a global interdiction on UserDirs, check to see if this * If there's a global interdiction on UserDirs, check to see if this
* name is one of the Blessed. * name is one of the Blessed.
*/ */
if ( if (s_cfg->globally_disabled
s_cfg->globally_disabled && && apr_table_get(s_cfg->enabled_users, w) == NULL) {
(apr_table_get(s_cfg->enabled_users, w) == NULL)
) {
return DECLINED; return DECLINED;
} }

View File

@@ -122,20 +122,20 @@ module AP_MODULE_DECLARE_DATA env_module;
static void *create_env_dir_config(apr_pool_t *p, char *dummy) static void *create_env_dir_config(apr_pool_t *p, char *dummy)
{ {
env_dir_config_rec *new = env_dir_config_rec *conf = apr_palloc(p, sizeof(*conf));
(env_dir_config_rec *) apr_palloc(p, sizeof(env_dir_config_rec));
new->vars = apr_table_make(p, 50); conf->vars = apr_table_make(p, 50);
new->unsetenv = ""; conf->unsetenv = "";
new->vars_present = 0; conf->vars_present = 0;
return (void *) new;
return conf;
} }
static void *merge_env_dir_configs(apr_pool_t *p, void *basev, void *addv) static void *merge_env_dir_configs(apr_pool_t *p, void *basev, void *addv)
{ {
env_dir_config_rec *base = (env_dir_config_rec *) basev; env_dir_config_rec *base = basev;
env_dir_config_rec *add = (env_dir_config_rec *) addv; env_dir_config_rec *add = addv;
env_dir_config_rec *new = env_dir_config_rec *newconf = apr_palloc(p, sizeof(*newconf));
(env_dir_config_rec *) apr_palloc(p, sizeof(env_dir_config_rec));
apr_table_t *new_table; apr_table_t *new_table;
apr_table_entry_t *elts; apr_table_entry_t *elts;
@@ -170,17 +170,17 @@ static void *merge_env_dir_configs(apr_pool_t *p, void *basev, void *addv)
uenv = ap_getword_conf(p, &unset); uenv = ap_getword_conf(p, &unset);
} }
new->vars = new_table; newconf->vars = new_table;
new->vars_present = base->vars_present || add->vars_present; newconf->vars_present = base->vars_present || add->vars_present;
return new; return newconf;
} }
static const char *add_env_module_vars_passed(cmd_parms *cmd, void *sconf_, static const char *add_env_module_vars_passed(cmd_parms *cmd, void *sconf_,
const char *arg) const char *arg)
{ {
env_dir_config_rec *sconf=sconf_; env_dir_config_rec *sconf = sconf_;
apr_table_t *vars = sconf->vars; apr_table_t *vars = sconf->vars;
char *env_var; char *env_var;
char *name_ptr; char *name_ptr;
@@ -199,7 +199,7 @@ static const char *add_env_module_vars_passed(cmd_parms *cmd, void *sconf_,
static const char *add_env_module_vars_set(cmd_parms *cmd, void *sconf_, static const char *add_env_module_vars_set(cmd_parms *cmd, void *sconf_,
const char *arg) const char *arg)
{ {
env_dir_config_rec *sconf=sconf_; env_dir_config_rec *sconf = sconf_;
apr_table_t *vars = sconf->vars; apr_table_t *vars = sconf->vars;
char *name, *value; char *name, *value;
@@ -224,11 +224,12 @@ static const char *add_env_module_vars_set(cmd_parms *cmd, void *sconf_,
static const char *add_env_module_vars_unset(cmd_parms *cmd, void *sconf_, static const char *add_env_module_vars_unset(cmd_parms *cmd, void *sconf_,
const char *arg) const char *arg)
{ {
env_dir_config_rec *sconf=sconf_; env_dir_config_rec *sconf = sconf_;
sconf->unsetenv = sconf->unsetenv
? apr_pstrcat(cmd->pool, sconf->unsetenv, " ", arg, NULL)
: arg;
sconf->unsetenv = sconf->unsetenv ?
apr_pstrcat(cmd->pool, sconf->unsetenv, " ", arg, NULL) :
arg;
return NULL; return NULL;
} }
@@ -260,7 +261,7 @@ static int fixup_env_module(request_rec *r)
static void register_hooks(apr_pool_t *p) static void register_hooks(apr_pool_t *p)
{ {
ap_hook_fixups(fixup_env_module,NULL,NULL,APR_HOOK_MIDDLE); ap_hook_fixups(fixup_env_module, NULL, NULL, APR_HOOK_MIDDLE);
} }
module AP_MODULE_DECLARE_DATA env_module = module AP_MODULE_DECLARE_DATA env_module =

View File

@@ -138,39 +138,40 @@ module AP_MODULE_DECLARE_DATA headers_module;
static void *create_headers_config(apr_pool_t *p, server_rec *s) static void *create_headers_config(apr_pool_t *p, server_rec *s)
{ {
headers_conf *a = headers_conf *conf = apr_pcalloc(p, sizeof(*conf));
(headers_conf *) apr_pcalloc(p, sizeof(headers_conf));
a->headers = apr_array_make(p, 2, sizeof(header_entry)); conf->headers = apr_array_make(p, 2, sizeof(header_entry));
return a;
return conf;
} }
static void *create_headers_dir_config(apr_pool_t *p, char *d) static void *create_headers_dir_config(apr_pool_t *p, char *d)
{ {
return (headers_conf *) create_headers_config(p, NULL); return create_headers_config(p, NULL);
} }
static void *merge_headers_config(apr_pool_t *p, void *basev, void *overridesv) static void *merge_headers_config(apr_pool_t *p, void *basev, void *overridesv)
{ {
headers_conf *a = headers_conf *newconf = apr_pcalloc(p, sizeof(*newconf));
(headers_conf *) apr_pcalloc(p, sizeof(headers_conf)); headers_conf *base = basev;
headers_conf *base = (headers_conf *) basev, *overrides = (headers_conf *) overridesv; headers_conf *overrides = overridesv;
a->headers = apr_array_append(p, base->headers, overrides->headers); newconf->headers = apr_array_append(p, base->headers, overrides->headers);
return a; return newconf;
} }
static const char *header_cmd(cmd_parms *cmd, void *indirconf, static const char *header_cmd(cmd_parms *cmd, void *indirconf,
const char *action, const char *inhdr, const char *value) const char *action, const char *inhdr,
const char *value)
{ {
headers_conf *dirconf = indirconf; headers_conf *dirconf = indirconf;
char *hdr = apr_pstrdup(cmd->pool, inhdr); char *hdr = apr_pstrdup(cmd->pool, inhdr);
header_entry *new; header_entry *new;
server_rec *s = cmd->server; server_rec *s = cmd->server;
headers_conf *serverconf = headers_conf *serverconf = ap_get_module_config(s->module_config,
(headers_conf *) ap_get_module_config(s->module_config, &headers_module); &headers_module);
char *colon; char *colon;
if (cmd->path) { if (cmd->path) {
@@ -240,12 +241,10 @@ static void do_headers_fixup(request_rec *r, apr_array_header_t *headers)
static int fixup_headers(request_rec *r) static int fixup_headers(request_rec *r)
{ {
void *sconf = r->server->module_config; headers_conf *serverconf = ap_get_module_config(r->server->module_config,
headers_conf *serverconf = &headers_module);
(headers_conf *) ap_get_module_config(sconf, &headers_module); headers_conf *dirconf = ap_get_module_config(r->per_dir_config,
void *dconf = r->per_dir_config; &headers_module);
headers_conf *dirconf =
(headers_conf *) ap_get_module_config(dconf, &headers_module);
do_headers_fixup(r, serverconf->headers); do_headers_fixup(r, serverconf->headers);
do_headers_fixup(r, dirconf->headers); do_headers_fixup(r, dirconf->headers);
@@ -255,7 +254,7 @@ static int fixup_headers(request_rec *r)
static void register_hooks(apr_pool_t *p) static void register_hooks(apr_pool_t *p)
{ {
ap_hook_fixups(fixup_headers,NULL,NULL,APR_HOOK_MIDDLE); ap_hook_fixups(fixup_headers, NULL, NULL, APR_HOOK_MIDDLE);
} }
module AP_MODULE_DECLARE_DATA headers_module = module AP_MODULE_DECLARE_DATA headers_module =

View File

@@ -166,32 +166,17 @@ typedef void *(*merger_func) (apr_pool_t *, void *, void *);
* overridden). * overridden).
*/ */
#ifndef ap_get_module_config static ap_conf_vector_t *create_empty_config(apr_pool_t *p)
AP_DECLARE(void *) ap_get_module_config(void *conf_vector, module *m)
{ {
void **confv = (void **) conf_vector; void *conf_vector = apr_pcalloc(p, sizeof(void *) *
return confv[m->module_index]; (total_modules + DYNAMIC_MODULE_LIMIT));
} return conf_vector;
#endif
#ifndef ap_set_module_config
AP_DECLARE(void) ap_set_module_config(void *conf_vector, module *m, void *val)
{
void **confv = (void **) conf_vector;
confv[m->module_index] = val;
}
#endif
static void *create_empty_config(apr_pool_t *p)
{
void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) *
(total_modules + DYNAMIC_MODULE_LIMIT));
return (void *) conf_vector;
} }
static void *create_default_per_dir_config(apr_pool_t *p) static ap_conf_vector_t *create_default_per_dir_config(apr_pool_t *p)
{ {
void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT)); void **conf_vector = apr_pcalloc(p, sizeof(void *) *
(total_modules + DYNAMIC_MODULE_LIMIT));
module *modp; module *modp;
for (modp = top_module; modp; modp = modp->next) { for (modp = top_module; modp; modp = modp->next) {
@@ -201,13 +186,14 @@ static void *create_default_per_dir_config(apr_pool_t *p)
conf_vector[modp->module_index] = (*df) (p, NULL); conf_vector[modp->module_index] = (*df) (p, NULL);
} }
return (void *) conf_vector; return (ap_conf_vector_t *) conf_vector;
} }
void * ap_conf_vector_t *ap_merge_per_dir_configs(apr_pool_t *p,
ap_merge_per_dir_configs(apr_pool_t *p, void *base, void *new) ap_conf_vector_t *base,
ap_conf_vector_t *new)
{ {
void **conf_vector = (void **) apr_palloc(p, sizeof(void *) * total_modules); void **conf_vector = apr_palloc(p, sizeof(void *) * total_modules);
void **base_vector = (void **) base; void **base_vector = (void **) base;
void **new_vector = (void **) new; void **new_vector = (void **) new;
module *modp; module *modp;
@@ -222,12 +208,13 @@ void *
conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i]; conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
} }
return (void *) conf_vector; return (ap_conf_vector_t *) conf_vector;
} }
static void *create_server_config(apr_pool_t *p, server_rec *s) static ap_conf_vector_t *create_server_config(apr_pool_t *p, server_rec *s)
{ {
void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT)); void **conf_vector = apr_pcalloc(p, sizeof(void *) *
(total_modules + DYNAMIC_MODULE_LIMIT));
module *modp; module *modp;
for (modp = top_module; modp; modp = modp->next) { for (modp = top_module; modp; modp = modp->next) {
@@ -235,10 +222,11 @@ static void *create_server_config(apr_pool_t *p, server_rec *s)
conf_vector[modp->module_index] = (*modp->create_server_config) (p, s); conf_vector[modp->module_index] = (*modp->create_server_config) (p, s);
} }
return (void *) conf_vector; return (ap_conf_vector_t *) conf_vector;
} }
static void merge_server_configs(apr_pool_t *p, void *base, void *virt) static void merge_server_configs(apr_pool_t *p, ap_conf_vector_t *base,
ap_conf_vector_t *virt)
{ {
/* Can reuse the 'virt' vector for the spine of it, since we don't /* Can reuse the 'virt' vector for the spine of it, since we don't
* have to deal with the moral equivalent of .htaccess files here... * have to deal with the moral equivalent of .htaccess files here...
@@ -259,17 +247,17 @@ static void merge_server_configs(apr_pool_t *p, void *base, void *virt)
} }
} }
void *ap_create_request_config(apr_pool_t *p) ap_conf_vector_t *ap_create_request_config(apr_pool_t *p)
{ {
return create_empty_config(p); return create_empty_config(p);
} }
void *ap_create_conn_config(apr_pool_t *p) ap_conf_vector_t *ap_create_conn_config(apr_pool_t *p)
{ {
return create_empty_config(p); return create_empty_config(p);
} }
AP_CORE_DECLARE(void *) ap_create_per_dir_config(apr_pool_t *p) AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p)
{ {
return create_empty_config(p); return create_empty_config(p);
} }
@@ -765,8 +753,8 @@ AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_
AP_CORE_DECLARE(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod) AP_CORE_DECLARE(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod)
{ {
void *mconfig = ap_get_module_config(config, mod); ap_conf_vector_t *mconfig = ap_get_module_config(config, mod);
void *sconfig = ap_get_module_config(parms->server->module_config, mod); ap_conf_vector_t *sconfig = ap_get_module_config(parms->server->module_config, mod);
if (!mconfig && mod->create_dir_config) { if (!mconfig && mod->create_dir_config) {
mconfig = (*mod->create_dir_config) (parms->pool, parms->path); mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
@@ -1356,8 +1344,9 @@ void ap_process_resource_config(server_rec *s, const char *fname,
ap_cfg_closefile(cfp); ap_cfg_closefile(cfp);
} }
AP_DECLARE(void)ap_process_config_tree(server_rec *s, ap_directive_t *conftree, AP_DECLARE(void) ap_process_config_tree(server_rec *s,
apr_pool_t *p, apr_pool_t *ptemp) ap_directive_t *conftree,
apr_pool_t *p, apr_pool_t *ptemp)
{ {
const char *errmsg; const char *errmsg;
cmd_parms parms; cmd_parms parms;
@@ -1381,17 +1370,18 @@ AP_DECLARE(void)ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
} }
} }
int ap_parse_htaccess(void **result, request_rec *r, int override, int ap_parse_htaccess(ap_conf_vector_t **result, request_rec *r, int override,
const char *d, const char *access_name) { const char *d, const char *access_name)
{
configfile_t *f = NULL; configfile_t *f = NULL;
cmd_parms parms; cmd_parms parms;
char *filename = NULL; char *filename = NULL;
const struct htaccess_result *cache; const struct htaccess_result *cache;
struct htaccess_result *new; struct htaccess_result *new;
void *dc = NULL; ap_conf_vector_t *dc = NULL;
apr_status_t status; apr_status_t status;
/* firstly, search cache */ /* firstly, search cache */
for (cache = r->htaccess; cache != NULL; cache = cache->next) for (cache = r->htaccess; cache != NULL; cache = cache->next)
if (cache->override == override && strcmp(cache->dir, d) == 0) { if (cache->override == override && strcmp(cache->dir, d) == 0) {
if (cache->htaccess != NULL) if (cache->htaccess != NULL)
@@ -1434,7 +1424,8 @@ int ap_parse_htaccess(void **result, request_rec *r, int override,
*result = dc; *result = dc;
break; break;
} else { } else {
if (!APR_STATUS_IS_ENOENT(status) && !APR_STATUS_IS_ENOTDIR(status)) { if (!APR_STATUS_IS_ENOENT(status)
&& !APR_STATUS_IS_ENOTDIR(status)) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r, ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r,
"%s pcfg_openfile: unable to check htaccess file, " "%s pcfg_openfile: unable to check htaccess file, "
"ensure it is readable", "ensure it is readable",
@@ -1447,20 +1438,23 @@ int ap_parse_htaccess(void **result, request_rec *r, int override,
} }
} }
/* cache it */ /* cache it */
new = apr_palloc(r->pool, sizeof(struct htaccess_result)); new = apr_palloc(r->pool, sizeof(struct htaccess_result));
new->dir = parms.path; new->dir = parms.path;
new->override = override; new->override = override;
new->htaccess = dc; new->htaccess = dc;
/* add to head of list */
/* add to head of list */
new->next = r->htaccess; new->next = r->htaccess;
r->htaccess = new; r->htaccess = new;
return OK; return OK;
} }
AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, const char *hostname, AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
server_rec *main_server, server_rec **ps) const char *hostname,
server_rec *main_server,
server_rec **ps)
{ {
server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec)); server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec));

View File

@@ -60,42 +60,61 @@
#include "apr_want.h" #include "apr_want.h"
#include "httpd.h" #include "httpd.h"
#include "http_config.h"
#ifdef AP_DEBUG #ifdef AP_DEBUG
# undef strchr
/* get rid of the macros we defined in httpd.h */
#undef strchr
#undef strrchr
#undef strstr
char *ap_strchr(char *s, int c) char *ap_strchr(char *s, int c)
{ {
return strchr(s,c); return strchr(s,c);
} }
const char *ap_strchr_c(const char *s, int c) const char *ap_strchr_c(const char *s, int c)
{ {
return strchr(s,c); return strchr(s,c);
} }
# undef strrchr
char *ap_strrchr(char *s, int c) char *ap_strrchr(char *s, int c)
{ {
return strrchr(s,c); return strrchr(s,c);
} }
const char *ap_strrchr_c(const char *s, int c) const char *ap_strrchr_c(const char *s, int c)
{ {
return strrchr(s,c); return strrchr(s,c);
} }
#undef strstr
char *ap_strstr(char *s, char *c) char *ap_strstr(char *s, char *c)
{ {
return strstr(s,c); return strstr(s,c);
} }
const char *ap_strstr_c(const char *s, const char *c) const char *ap_strstr_c(const char *s, const char *c)
{ {
return strstr(s,c); return strstr(s,c);
} }
AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
const module *m)
{
return ((void **)cv)[m->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
* @deffunc void ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val)
*/
AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
void *val)
{
((void **)cv)[m->module_index] = val;
}
#endif /* AP_DEBUG */ #endif /* AP_DEBUG */