From db1852bded080360384772f70fe22012cecc6d12 Mon Sep 17 00:00:00 2001 From: Ken Coar Date: Fri, 11 Aug 2000 23:41:53 +0000 Subject: [PATCH] Preset the cmd_parms->limited field to the magic 'no limit active' value, and add some prototype API routines for expanding support for arbitrary extension HTTP methods. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86053 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_config.h | 18 +++++++++++++++-- server/config.c | 47 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/include/http_config.h b/include/http_config.h index 41be895732..8f6bb91e9a 100644 --- a/include/http_config.h +++ b/include/http_config.h @@ -279,14 +279,14 @@ struct configfile_t { * to carry a large variety of miscellaneous data which is all of * use to *somebody*... */ -struct cmd_parms_struct - { +struct cmd_parms_struct { /** Argument to command from cmd_table */ void *info; /** Which allow-override bits are set */ int override; /** Which methods are ed */ int limited; + apr_array_header_t *limited_xmethods; /** Config file structure. */ configfile_t *config_file; @@ -482,6 +482,20 @@ API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val); */ API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, void *, const char *); + +/** + * Return true if the specified method is limited by being listed in + * a container, or by *not* being listed in a + * container. + * + * @param method Pointer to a string specifying the method to check. + * @param cmd Pointer to the cmd_parms structure passed to the + * directive handler. + * @return 0 if the method is not limited in the current scope + * @deffunc ap_method_is_limited(cmd_parms *cmd, const char *method) + */ +API_EXPORT(int) ap_method_is_limited(cmd_parms *cmd, const char *method); + /** * Generic command handling function for strings, always sets the value * to a lowercase string diff --git a/server/config.c b/server/config.c index acf6548235..f94191a153 100644 --- a/server/config.c +++ b/server/config.c @@ -378,6 +378,34 @@ int ap_invoke_handler(request_rec *r) return HTTP_INTERNAL_SERVER_ERROR; } +API_EXPORT(int) ap_method_is_limited(cmd_parms *cmd, const char *method) { + int methnum; + int i; + char **xmethod; + + methnum = ap_method_number_of(method); + /* + * The simple case: a method hard-coded into Apache. + */ + if (methnum != M_INVALID) { + return (methnum & cmd->limited); + } + /* + * Some extension method we don't know implicitly. + */ + if ((cmd->limited_xmethods == NULL) + || (cmd->limited_xmethods->nelts == 0)) { + return 0; + } + xmethod = (char **) cmd->limited_xmethods->elts; + for (i = 0; i < cmd->limited_xmethods->nelts; ++i) { + if (strcmp(method, xmethod[i]) == 0) { + return 1; + } + } + return 0; +} + API_EXPORT(void) ap_register_hooks(module *m) { if(m->register_hooks) @@ -948,11 +976,11 @@ static const char * ap_build_config_sub(apr_pool_t *p, apr_pool_t *temp_pool, return NULL; } -const char * ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool, - cmd_parms *parms, - ap_directive_t **current, - ap_directive_t **curr_parent, - char *orig_directive) +const char *ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool, + cmd_parms *parms, + ap_directive_t **current, + ap_directive_t **curr_parent, + char *orig_directive) { char l[MAX_STRING_LEN]; char *bracket; @@ -1300,8 +1328,9 @@ void ap_process_resource_config(server_rec *s, const char *fname, fname = ap_server_root_relative(p, fname); /* don't require conf/httpd.conf if we have a -C or -c switch */ - if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) && - !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) { + if ((ap_server_pre_read_config->nelts + || ap_server_post_read_config->nelts) + && !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) { if (apr_stat(&finfo, fname, p) != APR_SUCCESS) return; } @@ -1349,6 +1378,7 @@ API_EXPORT(void)ap_process_config_tree(server_rec *s, ap_directive_t *conftree, parms.temp_pool = ptemp; parms.server = s; parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT); + parms.limited = -1; errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults); if (errmsg) { @@ -1363,8 +1393,7 @@ API_EXPORT(void)ap_process_config_tree(server_rec *s, ap_directive_t *conftree, } int ap_parse_htaccess(void **result, request_rec *r, int override, - const char *d, const char *access_name) -{ + const char *d, const char *access_name) { configfile_t *f = NULL; cmd_parms parms; char *filename = NULL; -- 2.50.1