summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Querna <pquerna@apache.org>2005-05-04 22:23:00 +0000
committerPaul Querna <pquerna@apache.org>2005-05-04 22:23:00 +0000
commitda9a8de7534c1c010e94ef400ecfcf243820a401 (patch)
treebff42beee9cb8ed3cb42fbfd063d783c406790a2
parent5ceb57af0dfb82c8ccdb7702c4dd78ab8e4da49a (diff)
downloadhttpd-da9a8de7534c1c010e94ef400ecfcf243820a401.tar.gz
Add AP_INIT_TAKE_ARGV. There can be some inconsistent results because of the behavoir of ap_getword_conf. Do not rely upon any last argument that is "". If the argument is in the middle of the line, it should work correctly.
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
-rw-r--r--CHANGES3
-rw-r--r--include/ap_mmn.h3
-rw-r--r--include/http_config.h14
-rw-r--r--modules/generators/mod_autoindex.c12
-rw-r--r--server/config.c19
5 files changed, 44 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index c5af454b98..75743a3b05 100644
--- 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]
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
index 53de508b66..96245efe0d 100644
--- a/include/ap_mmn.h
+++ b/include/ap_mmn.h
@@ -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" */
@@ -101,7 +102,7 @@
#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
diff --git a/include/http_config.h b/include/http_config.h
index b09f0da16c..483cae56d2 100644
--- a/include/http_config.h
+++ b/include/http_config.h
@@ -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) \
diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c
index 8f2a0c0594..9a6cdcc335 100644
--- a/modules/generators/mod_autoindex.c
+++ b/modules/generators/mod_autoindex.c
@@ -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,
diff --git a/server/config.c b/server/config.c
index 71e8a8d60e..3b6af6fb20 100644
--- a/server/config.c
+++ b/server/config.c
@@ -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",