Re: Config directives question
On Fri, 30 Jun 2000, Doug MacEachern wrote: > On Fri, 30 Jun 2000, Matt Sergeant wrote: > > > Is there any way I can write RAW_ARGS config directives like: > > > > > > ... > > > > > > And have the bit between the tags passed through to apache for processing? > > The eagle book only seems to detail processing all the directives between > > the tags myself. But I want to be more modular than that. Am I missing > > some documentation somewhere? > > nope, that functionality was missing, i was wanting this too for the > Apache::DBIPool module that'll be part of my tutorial mod_perl-2.0 > section at oracon: > > >DBIPoolStart 10 >DBIPoolMax 20 >DBIPoolMaxSpare 10 >DBIPoolMinSpare 5 >DBIUserName dougm >DBIPassWord XxXx > > > more on that later :) - glad I signed up for that session now - look forward to meeting you there. Shame it can't be done right now though, and I can't really justify adding that sort of functionality to AxKit at the moment. I guess I'll have to setup a custom parser to call my own callbacks. -- Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org | AxKit: http://axkit.org
Re: Config directives question
On Fri, 30 Jun 2000, Matt Sergeant wrote: > Is there any way I can write RAW_ARGS config directives like: > > > ... > > > And have the bit between the tags passed through to apache for processing? > The eagle book only seems to detail processing all the directives between > the tags myself. But I want to be more modular than that. Am I missing > some documentation somewhere? nope, that functionality was missing, i was wanting this too for the Apache::DBIPool module that'll be part of my tutorial mod_perl-2.0 section at oracon: DBIPoolStart 10 DBIPoolMax 20 DBIPoolMaxSpare 10 DBIPoolMinSpare 5 DBIUserName dougm DBIPassWord XxXx more on that later :) anyhow, with the patch below, here's a modified TrafficCop.pm (from the eagle book): sub TrafficCopSpeedLimits ($$$;*) { my($cfg, $parms, $district, $cfg_fh) = @_; $district =~ s/>$//; my $config = $parms->create_per_dir_config; my $errmsg = $parms->command_loop($config); die $errmsg if $errmsg; $cfg->{district}->{$district} = $config; } sub TrafficCopSpeedLimits_END () {} handles this in httpd.conf: TrafficCopTicket StreetSweeping Tuesday Friday and the configuration test dumper: sub test { my $r = shift; $r->send_http_header('text/plain'); require Data::Dumper; my $cfg = Apache::ModuleConfig->get($r); print "$Class configuration:\n"; print Data::Dumper::Dumper($cfg) if $cfg; while (my($key, $val) = each %{ $cfg->{district} }) { my $tcfg = Apache::ModuleConfig->get($val); print "$key configuration:\n"; print Data::Dumper::Dumper($tcfg) if $tcfg; } } prints: Apache::TrafficCop configuration: $VAR1 = bless( { 'district' => { 'charlestown' => 136503732 } }, 'Apache::TrafficCop' ); charlestown configuration: $VAR1 = bless( { 'Ticket' => { 'StreetSweeping' => [ 'Tuesday', 'Friday' ] } }, 'Apache::TrafficCop' ); Index: src/modules/perl/ModuleConfig.xs === RCS file: /home/cvs/modperl/src/modules/perl/ModuleConfig.xs,v retrieving revision 1.10 diff -u -r1.10 ModuleConfig.xs --- src/modules/perl/ModuleConfig.xs2000/04/03 04:48:52 1.10 +++ src/modules/perl/ModuleConfig.xs2000/06/30 19:31:44 @@ -75,6 +75,9 @@ *type = MP_TYPE_SRV; return s->module_config; } +else if(SvIOK(sv)) { +return (void *)SvIV(sv); +} else { croak("Argument is not an Apache or Apache::Server object"); } @@ -192,6 +195,27 @@ OUTPUT: buff RETVAL + +void * +create_per_dir_config(parms) +Apache::CmdParms parms + +CODE: +RETVAL = ap_create_per_dir_config(parms->pool); + +OUTPUT: +RETVAL + +const char * +command_loop(parms, config) +Apache::CmdParms parms +void *config + +CODE: +RETVAL = ap_srm_command_loop(parms, config); + +OUTPUT: +RETVAL char * path(parms)
Re: Config directives question
Matt Sergeant <[EMAIL PROTECTED]> wrote: >Is there any way I can write RAW_ARGS config directives like: > > >... > > >And have the bit between the tags passed through to apache for processing? >The eagle book only seems to detail processing all the directives between >the tags myself. But I want to be more modular than that. Am I missing >some documentation somewhere? Not sure if this helps, but digging around in Apache 1.3.12 came up with CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l) API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config) The second one explains the first thus: while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) { const char *errmsg = ap_handle_command(parms, config, l); if (errmsg) { return errmsg; } } The first one is not to be used outside the core, but it would seem to be what you are wanting. (Lines 981 - 1029 of src/main/http_config.c) However, looking in http_core.c around line 1200 reveals the following comment: /* access.conf commands... * * The *only* thing that can appear in access.conf at top level is a * section. NB we need to have a way to cut the srm_command_loop * invoked by dirsection (i.e., ) short when is seen. * We do that by returning an error, which dirsection itself recognizes and * discards as harmless. Cheesy, but it works. */ So... you can make return an error, recognize it as such, and continue on with the config file... Everything between and is then read by the regular Apache config process using the ap_srm_command_loop call, which is an exported api call. Not sure how this translates to perl without looking in the mod_perl book, which happens to not be with me at the moment, but perhaps this can point you in the right direction. -- James Smith <[EMAIL PROTECTED]>, 979-862-3725 Texas A&M CIS Operating Systems Group, Unix
Config directives question
Is there any way I can write RAW_ARGS config directives like: ... And have the bit between the tags passed through to apache for processing? The eagle book only seems to detail processing all the directives between the tags myself. But I want to be more modular than that. Am I missing some documentation somewhere? -- Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org | AxKit: http://axkit.org