dougm       01/03/25 09:42:27

  Modified:    lib/ModPerl Code.pm
               src/modules/perl mod_perl.c modperl_cmd.c modperl_cmd.h
                        modperl_config.c modperl_options.c modperl_types.h
  Log:
  PerlOptions needs to be usable per-directory (tho different set of options than 
per-server)
  
  Revision  Changes    Path
  1.52      +2 -3      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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Code.pm   2001/03/17 06:03:37     1.51
  +++ Code.pm   2001/03/25 17:42:26     1.52
  @@ -95,8 +95,7 @@
       Handler => [qw(NONE PARSED METHOD OBJECT ANON AUTOLOAD DYNAMIC)],
   );
   
  -my %flags_lookup = map { $_,1 } qw(Srv Dir);
  -my %flags_options = map { $_,1 } qw(Srv);
  +my %flags_options = map { $_,1 } qw(Srv Dir);
   
   sub new {
       my $class = shift;
  @@ -322,7 +321,7 @@
           my @lookup = ();
           my $lookup_proto = "";
           my @dumper;
  -        if ($flags_lookup{$class}) {
  +        if ($flags_options{$class}) {
               $lookup_proto = join canon_func('flags', 'lookup', $class),
                 'U32 ', '(const char *str)';
               push @lookup, "$lookup_proto {";
  
  
  
  1.40      +1 -1      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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- mod_perl.c        2001/03/16 05:52:29     1.39
  +++ mod_perl.c        2001/03/25 17:42:26     1.40
  @@ -234,7 +234,7 @@
   
   static const command_rec modperl_cmds[] = {  
       MP_CMD_SRV_ITERATE("PerlSwitches", switches, "Perl Switches"),
  -    MP_CMD_SRV_ITERATE("PerlOptions", options, "Perl Options"),
  +    MP_CMD_DIR_ITERATE("PerlOptions", options, "Perl Options"),
   #ifdef MP_TRACE
       MP_CMD_SRV_TAKE1("PerlTrace", trace, "Trace level"),
   #endif
  
  
  
  1.3       +9 -1      modperl-2.0/src/modules/perl/modperl_cmd.c
  
  Index: modperl_cmd.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- modperl_cmd.c     2001/03/17 06:08:05     1.2
  +++ modperl_cmd.c     2001/03/25 17:42:26     1.3
  @@ -46,11 +46,19 @@
   MP_CMD_SRV_DECLARE(options)
   {
       MP_dSCFG(parms->server);
  +    modperl_config_dir_t *dcfg = (modperl_config_dir_t *)dummy;
  +    int is_per_dir = parms->path ? 1 : 0;
  +    modperl_options_t *opts = is_per_dir ? dcfg->flags : scfg->flags;
       apr_pool_t *p = parms->pool;
       const char *error;
   
       MP_TRACE_d(MP_FUNC, "arg = %s\n", arg);
  -    error = modperl_options_set(p, scfg->flags, arg);
  +    if ((error = modperl_options_set(p, opts, arg)) && !is_per_dir) {
  +        /* maybe a per-directory option outside of a container */
  +        if (modperl_options_set(p, dcfg->flags, arg) == NULL) {
  +            error = NULL;
  +        }
  +    }
   
       if (error) {
           return error;
  
  
  
  1.2       +4 -0      modperl-2.0/src/modules/perl/modperl_cmd.h
  
  Index: modperl_cmd.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- modperl_cmd.h     2001/03/16 05:52:29     1.1
  +++ modperl_cmd.h     2001/03/25 17:42:26     1.2
  @@ -49,4 +49,8 @@
       AP_INIT_TAKE1( name, modperl_cmd_##item, NULL, \
         OR_ALL, desc )
   
  +#define MP_CMD_DIR_ITERATE(name, item, desc) \
  +    AP_INIT_TAKE1( name, modperl_cmd_##item, NULL, \
  +      OR_ALL, desc )
  +
   #endif /* MODPERL_CMD_H */
  
  
  
  1.28      +4 -0      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- modperl_config.c  2001/03/16 07:30:22     1.27
  +++ modperl_config.c  2001/03/25 17:42:26     1.28
  @@ -37,6 +37,8 @@
           }
       }
   
  +    mrg->flags = modperl_options_merge(p, base->flags, add->flags);
  +
       return mrg;
   }
   
  @@ -72,6 +74,8 @@
   {
       modperl_config_dir_t *dcfg = (modperl_config_dir_t *)
           apr_pcalloc(p, sizeof(modperl_config_dir_t));
  +
  +    dcfg->flags = modperl_options_new(p, MpDirType);
   
       MP_TRACE_d(MP_FUNC, "0x%lx\n", (unsigned long)dcfg);
   
  
  
  
  1.4       +38 -4     modperl-2.0/src/modules/perl/modperl_options.c
  
  Index: modperl_options.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_options.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- modperl_options.c 2001/03/04 18:49:39     1.3
  +++ modperl_options.c 2001/03/25 17:42:26     1.4
  @@ -1,18 +1,39 @@
   #include "mod_perl.h"
   
  +/* re-use the ->unset field to determine options type */
  +#define MpOptionsType(o)        (o)->unset
  +#define MpOptionsTypeDir(o)     MpOptionsType(o) == MpDir_f_UNSET
  +#define MpOptionsTypeSrv(o)     MpOptionsType(o) == MpSrv_f_UNSET
  +#define MpOptionsTypeDir_set(o) MpOptionsType(o) = MpDir_f_UNSET
  +#define MpOptionsTypeSrv_set(o) MpOptionsType(o) = MpSrv_f_UNSET
  +#define MP_OPTIONS_TYPE_DIR     MpDir_f_UNSET
  +#define MP_OPTIONS_TYPE_SRV     MpSrv_f_UNSET
  +
   static modperl_opts_t flags_lookup(modperl_options_t *o,
                                      const char *str)
   {
  -    switch (o->unset) {
  -      case MpSrv_f_UNSET:
  +    switch (MpOptionsType(o)) {
  +      case MP_OPTIONS_TYPE_SRV:
           return modperl_flags_lookup_srv(str);
  -      case MpDir_f_UNSET:
  +      case MP_OPTIONS_TYPE_DIR:
           return modperl_flags_lookup_dir(str);
         default:
           return '\0';
       };
   }
   
  +static const char *type_lookup(modperl_options_t *o)
  +{
  +    switch (MpOptionsType(o)) {
  +      case MP_OPTIONS_TYPE_SRV:
  +        return "server";
  +      case MP_OPTIONS_TYPE_DIR:
  +        return "directory";
  +      default:
  +        return "unknown";
  +    };
  +}
  +
   modperl_options_t *modperl_options_new(apr_pool_t *p, int type)
   {
       modperl_options_t *options = 
  @@ -36,7 +57,20 @@
       }
   
       if (!(opt = flags_lookup(o, str))) {
  -        error = apr_pstrcat(p, "Unknown PerlOption: ", str, NULL);
  +        error = apr_pstrcat(p, "Invalid per-", type_lookup(o),
  +                            " PerlOption: ", str, NULL);
  +
  +        if (MpOptionsTypeDir(o)) {
  +            modperl_options_t dummy;
  +            MpOptionsTypeSrv_set(&dummy);
  +
  +            if (flags_lookup(&dummy, str)) {
  +                error = apr_pstrcat(p, error,
  +                                    " (only allowed per-server)",
  +                                    NULL);
  +            }
  +        }
  +
           return error;
       }
       
  
  
  
  1.30      +1 -1      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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- modperl_types.h   2001/03/16 17:23:25     1.29
  +++ modperl_types.h   2001/03/25 17:42:27     1.30
  @@ -134,7 +134,7 @@
       MpAV *handlers_per_dir[MP_HANDLER_NUM_PER_DIR];
       MpHV *SetEnv;
       MpHV *SetVars;
  -    U8 flags;
  +    modperl_options_t *flags;
   #ifdef USE_ITHREADS
       modperl_interp_lifetime_e interp_lifetime;
   #endif
  
  
  

Reply via email to