Commit 2e61045f authored by Greg Stein's avatar Greg Stein
Browse files

*) 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
parent ac6db1ab
Loading
Loading
Loading
Loading
+26 −14
Original line number Diff line number Diff line
@@ -431,7 +431,12 @@ struct module_struct {
				NULL, \
				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
 * data
@@ -439,11 +444,11 @@ struct module_struct {
 *        usually r->per_dir_config or s->module_config
 * @param m The module to get the data for.
 * @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);
#endif
#if AP_RBB_HACK
AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
                                        const module *m);

/**
 * Generic accessors for other modules to set at their own module-specific
 * 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
 * @param m The module to set the data for.
 * @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);
#endif
AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
                                      void *val);

#else /* AP_DEBUG */

#define ap_get_module_config(v,m)	\
    (((void **)(v))[(m)->module_index])
#define ap_set_module_config(v,m,val)	\
    ((((void **)(v))[(m)->module_index]) = (val))

#endif /* AP_DEBUG */


/**
 * Generic command handling function for strings
 * @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
 * @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
@@ -828,7 +838,7 @@ void *ap_create_request_config(apr_pool_t *p);
 * @return The config vector
 * @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
@@ -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 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... */
/**
@@ -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
 * @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) */

@@ -857,7 +869,7 @@ void *ap_create_conn_config(apr_pool_t *p);
 * @param access_name The list of possible names for .htaccess files
 * 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);

/**
+16 −0
Original line number Diff line number Diff line
@@ -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)
 */
AP_DECLARE(int) ap_rputc(int c, request_rec *r);

/**
 * Output a string for the current request
 * @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)
 */
AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);

/**
 * Write a buffer for the current request
 * @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)
 */
AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);

/**
 * Write an unspecified number of strings to the 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, ...)
 */
AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);

/**
 * Output data to the client in a printf format
 * @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)
 */
AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);

/**
 * Output data to the client in a printf format
 * @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)
 */
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 
 * 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)
 */
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
 * 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)
 */
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
 * 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);


/* 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)
 */ 
AP_DECLARE(void) ap_note_auth_failure(request_rec *r);

/**
 * Setup the output headers so that the client knows how to authenticate
 * 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)
 */ 
AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r);

/**
 * Setup the output headers so that the client knows how to authenticate
 * 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)
 */ 
AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r);

/**
 * Get the password from the request headers
 * @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)
 */
AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))

/**
 * This hook allows modules to perform any module-specific logging activities
 * 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)
 */
AP_DECLARE_HOOK(int,log_transaction,(request_rec *r))

/**
 * This hook allows modules to retrieve the http method from a request.  This
 * 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)
 */
AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r))

/**
 * Return the default port from 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))

typedef struct ap_bucket_error ap_bucket_error;

/**
 * A bucket referring to an HTTP error
 * This bucket can be passed down the filter stack to indicate that an
+6 −6
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ struct htaccess_result {
    /** the overrides allowed for the .htaccess file */
    int override;
    /** the configuration directives */
    void *htaccess;
    struct ap_conf_vector_t *htaccess;
    /** the next one, or NULL if no more; N.B. never change this */
    const struct htaccess_result *next;
};
@@ -729,9 +729,9 @@ struct request_rec {
     */

    /** Options set in config files, etc. */
    void *per_dir_config;
    struct ap_conf_vector_t *per_dir_config;
    /** 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
@@ -811,7 +811,7 @@ struct conn_rec {
    /** ID of this connection; unique at any point in time */
    long id; 
    /** 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
     *  requests on this conn */
    apr_table_t *notes;
@@ -883,9 +883,9 @@ struct server_rec {
    int is_virtual;
    /** Config vector containing pointers to modules' per-server config 
     *  structures. */
    void *module_config; 
    struct ap_conf_vector_t *module_config; 
    /** MIME type info, etc., before we start checking per-directory info */
    void *lookup_defaults;
    struct ap_conf_vector_t *lookup_defaults;

    /* Transaction handling */

+5 −0
Original line number Diff line number Diff line
@@ -325,6 +325,8 @@ static void log_error_and_cleanup(char *msg, apr_status_t sts, server_rec *s)
    cleanup_tables(NULL);
}

#if APR_HAS_SHARED_MEMORY

static void initialize_tables(server_rec *s, apr_pool_t *ctx)
{
    unsigned long idx;
@@ -392,6 +394,9 @@ static void initialize_tables(server_rec *s, apr_pool_t *ctx)
    return;
}

#endif /* APR_HAS_SHARED_MEMORY */


static void initialize_module(apr_pool_t *p, apr_pool_t *plog,
			      apr_pool_t *ptemp, server_rec *s)
{
+10 −8
Original line number Diff line number Diff line
@@ -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)
{
    server_rec *s = cmd->server;
    cgi_server_conf *conf =
    (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
    cgi_server_conf *conf = ap_get_module_config(s->module_config,
                                                 &cgi_module);

    conf->logname = arg;
    return NULL;
@@ -169,8 +169,8 @@ static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy,
					const char *arg)
{
    server_rec *s = cmd->server;
    cgi_server_conf *conf =
    (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
    cgi_server_conf *conf = ap_get_module_config(s->module_config,
                                                 &cgi_module);

    conf->logbytes = atol(arg);
    return NULL;
@@ -180,8 +180,8 @@ static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy,
					const char *arg)
{
    server_rec *s = cmd->server;
    cgi_server_conf *conf =
    (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
    cgi_server_conf *conf = ap_get_module_config(s->module_config,
                                                 &cgi_module);

    conf->bufbytes = atoi(arg);
    return NULL;
@@ -371,10 +371,12 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
    apr_procattr_t *procattr;
    apr_proc_t *procnew;
    apr_status_t rc = APR_SUCCESS;

#if defined(RLIMIT_CPU)  || defined(RLIMIT_NPROC) || \
    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


Loading