- this patch implements PerlSetVar and PerlAddVar
(the tests are in the dir_config patch to follow)
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/27 17:15:29
@@ -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/27 17:15:29
@@ -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/27 17:15:29
@@ -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/27 17:15:29
@@ -13,8 +13,13 @@
}
#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) \
+ mrg->item = apr_table_copy(p, base->item); \
+ apr_table_overlap(mrg->item, add->item, APR_OVERLAP_TABLES_SET)
+
#define merge_handlers(merge_flag, array) \
if (merge_flag(mrg)) { \
mrg->array = modperl_handler_array_merge(p, \
@@ -42,7 +47,9 @@
mrg->flags = modperl_options_merge(p, base->flags, add->flags);
- /* XXX: check if Perl*Handler is disabled */
+ merge_table_overlap_item(SetVar);
+
+ /* 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 +83,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 +99,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 +169,8 @@
merge_item(PerlModule);
merge_item(PerlRequire);
+ merge_table_overlap_item(SetVar);
+
merge_item(threaded_mpm);
#ifdef USE_ITHREADS
@@ -246,3 +259,4 @@
return TRUE;
}
+
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/27 17:15:29
@@ -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]