patch:
- this patch implements PerlSetVar and PerlAddVar
changes:
- the first patch was broken, you cannot use apr_table_overlap for merging
SetVar tables(in merge_table_overlap_item) , because we want to overlap
only the values for the keys which arenot in the current dir_config table.
So I had to do it manually. Do you think we should submit a patch for
apr_table_overlap, to have a third flag that does what we want?
- now the test in the next patch (of dir_config) is done properly and
tests the failure I didn't notice in the previous patch.
Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.71
diff -u -r1.71 mod_perl.c
--- src/modules/perl/mod_perl.c 2001/09/17 23:36:35 1.71
+++ src/modules/perl/mod_perl.c 2001/09/28 10:38:25
@@ -167,7 +167,7 @@
if (!modperl_config_apply_PerlRequire(s, scfg, perl, p)) {
exit(1);
}
-
+
#ifdef USE_ITHREADS
if (!MpSrvENABLE(scfg)) {
@@ -408,6 +408,8 @@
MP_CMD_SRV_ITERATE("PerlModule", modules, "PerlModule"),
MP_CMD_SRV_ITERATE("PerlRequire", requires, "PerlRequire"),
MP_CMD_DIR_ITERATE("PerlOptions", options, "Perl Options"),
+ MP_CMD_DIR_TAKE2("PerlSetVar", set_var, "PerlSetVar"),
+ MP_CMD_DIR_ITERATE2("PerlAddVar", add_var, "PerlAddVar"),
#ifdef MP_TRACE
MP_CMD_SRV_TAKE1("PerlTrace", trace, "Trace level"),
#endif
Index: src/modules/perl/modperl_cmd.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
retrieving revision 1.6
diff -u -r1.6 modperl_cmd.c
--- src/modules/perl/modperl_cmd.c 2001/08/08 16:20:31 1.6
+++ src/modules/perl/modperl_cmd.c 2001/09/28 10:38:26
@@ -60,6 +60,38 @@
return NULL;
}
+MP_CMD_SRV_DECLARE2(set_var)
+{
+ MP_dSCFG(parms->server);
+ modperl_config_dir_t *dcfg = (modperl_config_dir_t *)dummy;
+
+ if (parms->path) {
+ apr_table_set(dcfg->SetVar, arg1, arg2);
+ MP_TRACE_d(MP_FUNC, "DIR: arg1 = %s, arg2 = %s\n", arg1, arg2);
+ }
+ else {
+ apr_table_set(scfg->SetVar, arg1, arg2);
+ MP_TRACE_d(MP_FUNC, "SRV: arg1 = %s, arg2 = %s\n", arg1, arg2);
+ }
+ return NULL;
+}
+
+MP_CMD_SRV_DECLARE2(add_var)
+{
+ MP_dSCFG(parms->server);
+ modperl_config_dir_t *dcfg = (modperl_config_dir_t *)dummy;
+
+ if (parms->path) {
+ apr_table_add(dcfg->SetVar, arg1, arg2);
+ MP_TRACE_d(MP_FUNC, "DIR: arg1 = %s, arg2 = %s\n", arg1, arg2);
+ }
+ else {
+ apr_table_add(scfg->SetVar, arg1, arg2);
+ MP_TRACE_d(MP_FUNC, "SRV: arg1 = %s, arg2 = %s\n", arg1, arg2);
+ }
+ return NULL;
+}
+
MP_CMD_SRV_DECLARE(options)
{
MP_dSCFG(parms->server);
Index: src/modules/perl/modperl_cmd.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.h,v
retrieving revision 1.6
diff -u -r1.6 modperl_cmd.h
--- src/modules/perl/modperl_cmd.h 2001/09/06 06:00:08 1.6
+++ src/modules/perl/modperl_cmd.h 2001/09/28 10:38:26
@@ -4,17 +4,18 @@
char *modperl_cmd_push_handlers(MpAV **handlers, const char *name,
apr_pool_t *p);
-
#define MP_CMD_SRV_DECLARE(item) \
-const char *modperl_cmd_##item(cmd_parms *parms, \
- void *dummy, const char *arg)
+const char *modperl_cmd_##item(cmd_parms *parms, void *dummy, \
+ const char *arg)
#define MP_CMD_SRV_DECLARE2(item) \
-const char *modperl_cmd_##item(cmd_parms *parms, \
- void *dummy, const char *arg1, const char *arg2)
+const char *modperl_cmd_##item(cmd_parms *parms, void *dummy, \
+ const char *arg1, const char *arg2)
MP_CMD_SRV_DECLARE(trace);
MP_CMD_SRV_DECLARE(switches);
MP_CMD_SRV_DECLARE(modules);
MP_CMD_SRV_DECLARE(requires);
+MP_CMD_SRV_DECLARE2(set_var);
+MP_CMD_SRV_DECLARE2(add_var);
MP_CMD_SRV_DECLARE(options);
#ifdef USE_ITHREADS
@@ -54,6 +55,10 @@
AP_INIT_ITERATE( name, modperl_cmd_##item, NULL, \
RSRC_CONF, desc )
+#define MP_CMD_SRV_ITERATE2(name, item, desc) \
+ AP_INIT_ITERATE2( name, modperl_cmd_##item, NULL, \
+ RSRC_CONF, desc )
+
#define MP_CMD_DIR_TAKE1(name, item, desc) \
AP_INIT_TAKE1( name, modperl_cmd_##item, NULL, \
OR_ALL, desc )
@@ -64,6 +69,10 @@
#define MP_CMD_DIR_ITERATE(name, item, desc) \
AP_INIT_ITERATE( name, modperl_cmd_##item, NULL, \
+ OR_ALL, desc )
+
+#define MP_CMD_DIR_ITERATE2(name, item, desc) \
+ AP_INIT_ITERATE2( name, modperl_cmd_##item, NULL, \
OR_ALL, desc )
#endif /* MODPERL_CMD_H */
Index: src/modules/perl/modperl_config.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v
retrieving revision 1.37
diff -u -r1.37 modperl_config.c
--- src/modules/perl/modperl_config.c 2001/09/17 23:36:36 1.37
+++ src/modules/perl/modperl_config.c 2001/09/28 10:38:26
@@ -13,8 +13,26 @@
}
#define merge_item(item) \
-mrg->item = add->item ? add->item : base->item
+ mrg->item = add->item ? add->item : base->item
+/* take the 'base' values, and override with 'add' values if any */
+#define merge_table_overlap_item(item) \
+ { \
+ apr_array_header_t *arr = apr_table_elts(base->item); \
+ apr_table_entry_t *entries = (apr_table_entry_t *)arr->elts; \
+ int i; \
+ mrg->item = apr_table_copy(p, add->item); \
+ for (i = 0; i < arr->nelts; i++) { \
+ char *val; \
+ if ((val = (char *)apr_table_get(mrg->item, entries[i].key))){ \
+ continue; \
+ } \
+ else if ((val = (char *)apr_table_get(base->item, entries[i].key))){ \
+ apr_table_set(mrg->item, entries[i].key, val); \
+ } \
+ } \
+ }
+
#define merge_handlers(merge_flag, array) \
if (merge_flag(mrg)) { \
mrg->array = modperl_handler_array_merge(p, \
@@ -41,8 +59,10 @@
#endif
mrg->flags = modperl_options_merge(p, base->flags, add->flags);
+
+ merge_table_overlap_item(SetVar);
- /* XXX: check if Perl*Handler is disabled */
+ /* XXX: check if Perl*Handler is disabled */
for (i=0; i < MP_HANDLER_NUM_PER_DIR; i++) {
merge_handlers(MpDirMERGE_HANDLERS, handlers_per_dir[i]);
}
@@ -76,6 +96,8 @@
scfg->argv = apr_array_make(p, 2, sizeof(char *));
+ scfg->SetVar = apr_table_make(p, 2);
+
modperl_config_srv_argv_push((char *)ap_server_argv0);
MP_TRACE_d(MP_FUNC, "0x%lx\n", (unsigned long)scfg);
@@ -90,6 +112,8 @@
dcfg->flags = modperl_options_new(p, MpDirType);
+ dcfg->SetVar = apr_table_make(p, 2);
+
MP_TRACE_d(MP_FUNC, "0x%lx\n", (unsigned long)dcfg);
return dcfg;
@@ -158,6 +182,8 @@
merge_item(PerlModule);
merge_item(PerlRequire);
+ merge_table_overlap_item(SetVar);
+
merge_item(threaded_mpm);
#ifdef USE_ITHREADS
Index: src/modules/perl/modperl_types.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_types.h,v
retrieving revision 1.46
diff -u -r1.46 modperl_types.h
--- src/modules/perl/modperl_types.h 2001/08/30 05:15:51 1.46
+++ src/modules/perl/modperl_types.h 2001/09/28 10:38:26
@@ -110,7 +110,7 @@
} modperl_interp_scope_e;
typedef struct {
- MpHV *SetVars;
+ MpHV *SetVar;
MpAV *PassEnv;
MpAV *PerlRequire, *PerlModule;
MpAV *handlers_per_srv[MP_HANDLER_NUM_PER_SRV];
@@ -137,7 +137,7 @@
char *PerlDispatchHandler;
MpAV *handlers_per_dir[MP_HANDLER_NUM_PER_DIR];
MpHV *SetEnv;
- MpHV *SetVars;
+ MpHV *SetVar;
modperl_options_t *flags;
#ifdef USE_ITHREADS
modperl_interp_scope_e interp_scope;
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]