dougm 00/04/17 14:11:07 Modified: lib/ModPerl Code.pm src/modules/perl mod_perl.c mod_perl.h modperl_config.c modperl_config.h modperl_types.h Log: hook in xsinit add PerlSwitches directive Revision Changes Path 1.11 +6 -1 modperl-2.0/lib/ModPerl/Code.pm Index: Code.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Code.pm 2000/04/17 07:10:55 1.10 +++ Code.pm 2000/04/17 21:11:06 1.11 @@ -278,7 +278,7 @@ ); my @c_src_names = qw(interp log config gtop); -my @g_c_names = map { "modperl_$_" } qw(hooks directives); +my @g_c_names = map { "modperl_$_" } qw(hooks directives xsinit); my @c_names = ('mod_perl', (map "modperl_$_", @c_src_names), @g_c_names); sub c_files { [map { "$_.c" } @c_names] } sub o_files { [map { "$_.o" } @c_names] } @@ -360,6 +360,11 @@ } $self->postamble; + + my $xsinit = "$self->{path}/modperl_xsinit.c"; + warn "generating...$xsinit\n"; + + ExtUtils::Embed::xsinit($xsinit); } 1; 1.8 +8 -5 modperl-2.0/src/modules/perl/mod_perl.c Index: mod_perl.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- mod_perl.c 2000/04/17 07:10:55 1.7 +++ mod_perl.c 2000/04/17 21:11:06 1.8 @@ -2,13 +2,13 @@ void modperl_startup(server_rec *s, ap_pool_t *p) { + MP_dSCFG(s); PerlInterpreter *perl; int status; - char *argv[] = { "httpd", "/dev/null" }; - int argc = 2; + char **argv; + int argc; #ifdef MP_USE_GTOP - MP_dSCFG(s); MP_TRACE_m_do( scfg->gtop = modperl_gtop_new(p); modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse"); @@ -21,8 +21,10 @@ } perl_construct(perl); - - status = perl_parse(perl, NULL, argc, argv, NULL); + + argv = modperl_srv_config_argv_init(scfg, &argc); + + status = perl_parse(perl, xs_init, argc, argv, NULL); if (status) { perror("perl_parse"); @@ -63,6 +65,7 @@ } static command_rec modperl_cmds[] = { + MP_SRV_CMD_ITERATE("PerlSwitches", switches, "Perl Switches"), #ifdef MP_TRACE MP_SRV_CMD_TAKE1("PerlTrace", trace, "Trace level"), #endif 1.8 +1 -0 modperl-2.0/src/modules/perl/mod_perl.h Index: mod_perl.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- mod_perl.h 2000/04/17 07:10:55 1.7 +++ mod_perl.h 2000/04/17 21:11:06 1.8 @@ -38,5 +38,6 @@ #include "modperl_directives.h" void modperl_init(server_rec *s, ap_pool_t *p); +void xs_init(pTHXo); #endif /* MOD_PERL_H */ 1.5 +52 -1 modperl-2.0/src/modules/perl/modperl_config.c Index: modperl_config.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- modperl_config.c 2000/04/16 01:33:56 1.4 +++ modperl_config.c 2000/04/17 21:11:06 1.5 @@ -10,10 +10,42 @@ return NULL; } +#define scfg_push_argv(arg) \ + *(char **)ap_push_array(scfg->argv) = arg + modperl_srv_config_t *modperl_srv_config_new(ap_pool_t *p) { - return (modperl_srv_config_t *) + modperl_srv_config_t *scfg = (modperl_srv_config_t *) ap_pcalloc(p, sizeof(modperl_srv_config_t)); + + scfg->argv = ap_make_array(p, 2, sizeof(char *)); + + scfg_push_argv("httpd"); + + return scfg; +} + +#ifdef MP_TRACE +static void dump_argv(modperl_srv_config_t *scfg) +{ + int i; + char **argv = (char **)scfg->argv->elts; + fprintf(stderr, "modperl_srv_config_argv_init =>\n"); + for (i=0; i<scfg->argv->nelts; i++) { + fprintf(stderr, " %d = %s\n", i, argv[i]); + } +} +#endif + +char **modperl_srv_config_argv_init(modperl_srv_config_t *scfg, int *argc) +{ + scfg_push_argv("-e;0"); + + *argc = scfg->argv->nelts; + + MP_TRACE_g_do(dump_argv(scfg)); + + return (char **)scfg->argv->elts; } void *modperl_create_srv_config(ap_pool_t *p, server_rec *s) @@ -56,9 +88,28 @@ #define MP_CONFIG_BOOTSTRAP(parms) \ if (!scfg->mip) modperl_init(parms->server, parms->pool) +#define MP_SRV_CMD_TRACE \ + MP_TRACE_d(MP_FUNC, "%s %s\n", parms->cmd->name, arg) + +#define MP_SRV_CMD_CHECK \ +MP_SRV_CMD_TRACE; \ +{ \ + const char *err = ap_check_cmd_context(parms, GLOBAL_ONLY); \ + if (err) return err; \ +} + MP_DECLARE_SRV_CMD(trace) { + MP_SRV_CMD_CHECK; modperl_trace_level_set(arg); + return NULL; +} + +MP_DECLARE_SRV_CMD(switches) +{ + MP_dSCFG(parms->server); + MP_SRV_CMD_CHECK; + scfg_push_argv(arg); return NULL; } 1.6 +7 -0 modperl-2.0/src/modules/perl/modperl_config.h Index: modperl_config.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- modperl_config.h 2000/04/16 01:33:56 1.5 +++ modperl_config.h 2000/04/17 21:11:06 1.6 @@ -13,10 +13,13 @@ char *modperl_cmd_push_handlers(MpAV *handlers, char *name, ap_pool_t *p); +char **modperl_srv_config_argv_init(modperl_srv_config_t *scfg, int *argc); + #define MP_DECLARE_SRV_CMD(item) \ const char *modperl_cmd_##item(cmd_parms *parms, \ void *dummy, char *arg) MP_DECLARE_SRV_CMD(trace); +MP_DECLARE_SRV_CMD(switches); #ifdef USE_ITHREADS MP_DECLARE_SRV_CMD(interp_start); @@ -28,6 +31,10 @@ #define MP_SRV_CMD_TAKE1(name, item, desc) \ { name, modperl_cmd_##item, NULL, \ RSRC_CONF, TAKE1, desc } + +#define MP_SRV_CMD_ITERATE(name, item, desc) \ + { name, modperl_cmd_##item, NULL, \ + RSRC_CONF, ITERATE, desc } #define MP_dRCFG \ modperl_request_config_t *rcfg = \ 1.7 +1 -0 modperl-2.0/src/modules/perl/modperl_types.h Index: modperl_types.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_types.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- modperl_types.h 2000/04/17 07:10:55 1.6 +++ modperl_types.h 2000/04/17 21:11:06 1.7 @@ -84,6 +84,7 @@ #ifdef MP_USE_GTOP modperl_gtop_t *gtop; #endif + MpAV *argv; int flags; } modperl_srv_config_t;