]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Preset the cmd_parms->limited field to the magic 'no limit active'
authorKen Coar <coar@apache.org>
Fri, 11 Aug 2000 23:41:53 +0000 (23:41 +0000)
committerKen Coar <coar@apache.org>
Fri, 11 Aug 2000 23:41:53 +0000 (23:41 +0000)
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
server/config.c

index 41be895732fc8416761267ad92e20985a1bd9ede..8f6bb91e9a6351914874d2b64fe56e8a07161286 100644 (file)
@@ -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 <Limit>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 <Limit> container, or by *not* being listed in a <LimiteExcept>
+ * 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
index acf65482353e9d32cf447809d29989dd3e2b3365..f94191a153efc5932d7f42bf0922ad2e4b4d6bc3 100644 (file)
@@ -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;