]> granicus.if.org Git - apache/commitdiff
Add AP_INIT_TAKE_ARGV. There can be some inconsistent results because of the behavoir...
authorPaul Querna <pquerna@apache.org>
Wed, 4 May 2005 22:23:00 +0000 (22:23 +0000)
committerPaul Querna <pquerna@apache.org>
Wed, 4 May 2005 22:23:00 +0000 (22:23 +0000)
This is updated from the version sent to dev@httpd to fix the behavoir with 0 arguments.

* include/http_config.h: minor MMN bump for the new interface.
* modules/generators/mod_autoindex.c: Migrate IndexOptions to the new ARGV command type.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@168202 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
include/http_config.h
modules/generators/mod_autoindex.c
server/config.c

diff --git a/CHANGES b/CHANGES
index c5af454b98103c590f2689192770f0aebd30a708..75743a3b054ba016783a579b3cf450223f8b3045 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.5
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Add AP_INIT_TAKE_ARGV for configuration commands. (minor MMN bump) 
+     [Paul Querna]
+
   *) worker and event mpms: don't take down the whole server for a transient
      thread creation failure.  PR 34514 [Greg Ames]
 
index 53de508b667bca349759279d7c694fe0273ae2aa..96245efe0d065766c3bda0814b9993877c6efea0 100644 (file)
@@ -94,6 +94,7 @@
  *                        with ap_ in the win32 os.h.
  * 20050305.0 (2.1.4-dev) added pid and generation fields to worker_score
  * 20050305.1 (2.1.5-dev) added ap_vhost_iterate_given_conn.
+ * 20050305.2 (2.1.5-dev) added AP_INIT_TAKE_ARGV.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20050305
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index b09f0da16c950999aad228a2751824b0cc6bc19b..483cae56d22fd6142589f763b70bf287d5d3de5b 100644 (file)
@@ -57,7 +57,8 @@ enum cmd_how {
     TAKE3,                     /**< three arguments only */
     TAKE23,                    /**< two or three arguments */
     TAKE123,                   /**< one, two or three arguments */
-    TAKE13                     /**< one or three arguments */
+    TAKE13,                    /**< one or three arguments */
+    TAKE_ARGV                  /**< an argc and argv are passed */
 };
 /**
  * This structure is passed to a command which is being invoked,
@@ -78,6 +79,9 @@ typedef union {
     /** function to call for a raw-args */
     const char *(*raw_args) (cmd_parms *parms, void *mconfig,
                             const char *args);
+    /** function to call for a argv/argc */
+    const char *(*take_argv) (cmd_parms *parms, void *mconfig,
+                            int argc, char *const argv[]);
     /** function to call for a take1 */
     const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
     /** function to call for a take2 */
@@ -94,6 +98,8 @@ typedef union {
 # define AP_NO_ARGS    func.no_args
 /** This configuration directive will handle it's own parsing of arguments*/
 # define AP_RAW_ARGS   func.raw_args
+/** This configuration directive will handle it's own parsing of arguments*/
+# define AP_TAKE_ARGV  func.take_argv
 /** This configuration directive takes 1 argument*/
 # define AP_TAKE1      func.take1
 /** This configuration directive takes 2 arguments */
@@ -109,6 +115,9 @@ typedef union {
 /** method of declaring a directive with raw argument parsing */
 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
     { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
+/** method of declaring a directive with raw argument parsing */
+# define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
+    { directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
 /** method of declaring a directive which takes 1 argument */
 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
     { directive, { .take1=func }, mconfig, where, TAKE1, help }
@@ -146,6 +155,7 @@ typedef const char *(*cmd_func) ();
 
 # define AP_NO_ARGS  func
 # define AP_RAW_ARGS func
+# define AP_TAKE_ARGV func
 # define AP_TAKE1    func
 # define AP_TAKE2    func
 # define AP_TAKE3    func
@@ -155,6 +165,8 @@ typedef const char *(*cmd_func) ();
     { directive, func, mconfig, where, RAW_ARGS, help }
 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
     { directive, func, mconfig, where, RAW_ARGS, help }
+# define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE_ARGV, help }
 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
     { directive, func, mconfig, where, TAKE1, help }
 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
index 8f2a0c05945f11574646e8899cc45e4d17f5d517..9a6cdcc3352ed9b1c6b57eb9cc0e21b6d8a0a1f7 100644 (file)
@@ -312,8 +312,9 @@ static const char *add_readme(cmd_parms *cmd, void *d, const char *name)
     return NULL;
 }
 
-static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr)
+static const char *add_opts(cmd_parms *cmd, void *d, int argc, char *const argv[])
 {
+    int i;
     char *w;
     apr_int32_t opts;
     apr_int32_t opts_add;
@@ -324,10 +325,11 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr)
     opts = d_cfg->opts;
     opts_add = d_cfg->incremented_opts;
     opts_remove = d_cfg->decremented_opts;
-    while (optstr[0]) {
+
+    for (i = 0; i < argc; i++) {
         int option = 0;
+        w = argv[i];
 
-        w = ap_getword_conf(cmd->pool, &optstr);
         if ((*w == '+') || (*w == '-')) {
             action = *(w++);
         }
@@ -554,8 +556,8 @@ static const command_rec autoindex_cmds[] =
     AP_INIT_ITERATE2("AddAltByEncoding", add_alt, BY_ENCODING, DIR_CMD_PERMS,
                      "alternate descriptive text followed by one or more "
                      "content encodings"),
-    AP_INIT_RAW_ARGS("IndexOptions", add_opts, NULL, DIR_CMD_PERMS,
-                     "one or more index options [+|-][]"),
+    AP_INIT_TAKE_ARGV("IndexOptions", add_opts, NULL, DIR_CMD_PERMS,
+                      "one or more index options [+|-][]"),
     AP_INIT_TAKE2("IndexOrderDefault", set_default_order, NULL, DIR_CMD_PERMS,
                   "{Ascending,Descending} {Name,Size,Description,Date}"),
     AP_INIT_ITERATE("IndexIgnore", add_ignore, NULL, DIR_CMD_PERMS,
index 71e8a8d60eca3d5093898c7bfd2f468d87addcff..3b6af6fb20142afcf2859e62257811c38616661a 100644 (file)
@@ -648,6 +648,8 @@ AP_DECLARE(module *) ap_find_linked_module(const char *name)
  * invoking the function...
  */
 
+#define AP_MAX_ARGC 64
+
 static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
                               void *mconfig, const char *args)
 {
@@ -667,6 +669,23 @@ static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
 #endif
         return cmd->AP_RAW_ARGS(parms, mconfig, args);
 
+    case TAKE_ARGV:
+        {
+            char *argv[AP_MAX_ARGC];
+            int argc = 0;
+
+            do {
+                w = ap_getword_conf(parms->pool, &args);
+                if (*w == '\0' && *args == '\0') {
+                    break;
+                }
+                argv[argc] = w;
+                argc++;
+            } while (argc < AP_MAX_ARGC && *args != '\0');
+
+            return cmd->AP_TAKE_ARGV(parms, mconfig, argc, argv);
+        }
+
     case NO_ARGS:
         if (*args != 0)
             return apr_pstrcat(parms->pool, cmd->name, " takes no arguments",