httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gben...@apache.org
Subject cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
Date Thu, 23 May 2002 17:26:38 GMT
gbenson     02/05/23 10:26:38

  Modified:    perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
  Log:
  Handle the Include directive whilst parsing httpd.conf.
  
  Note that this has a slightly bizarre side-effect: if httpd.conf
  is a directory then it will be descended and all files it contains
  will be parsed.
  
  Revision  Changes    Path
  1.26      +42 -19    httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm
  
  Index: TestConfigParse.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TestConfigParse.pm	14 May 2002 23:11:14 -0000	1.25
  +++ TestConfigParse.pm	23 May 2002 17:26:38 -0000	1.26
  @@ -148,6 +148,47 @@
       }
   }
   
  +sub inherit_config_file_or_directory {
  +    my ($self, $item) = @_;
  +
  +    if (-d $item) {
  +        my $dir = $item;
  +        debug "descending config directory: $dir";
  +
  +        for my $entry (glob "$dir/*") {
  +            $self->inherit_config_file_or_directory($entry);
  +        }
  +        return;
  +    }
  +
  +    my $file = $item;
  +    debug "inheriting config file: $file";
  +
  +    my $fh = Symbol::gensym();
  +    open($fh, $file) or return;
  +
  +    my $c = $self->{inherit_config};
  +    while (<$fh>) {
  +        s/^\s*//; s/\s*$//; s/^\#.*//;
  +        next if /^$/;
  +        (my $directive, $_) = split /\s+/, $_, 2;
  +
  +        if ($directive eq "Include") {
  +            my $include = $self->server_file_rel2abs($_);
  +            $self->inherit_config_file_or_directory($include);
  +        }
  +
  +        #parse what we want
  +        while (my($spec, $wanted) = each %wanted_config) {
  +            next unless $wanted->{$directive};
  +            my $method = "parse_\L$spec";
  +            $self->$method($c, $directive);
  +        }
  +    }
  +
  +    close $fh;
  +}
  +
   sub inherit_config {
       my $self = shift;
   
  @@ -170,11 +211,6 @@
   
       return unless $file;
   
  -    debug "inheriting config file: $file";
  -
  -    my $fh = Symbol::gensym();
  -    open($fh, $file) or return;
  -
       my $c = $self->{inherit_config};
   
       #initialize array refs and such
  @@ -184,18 +220,7 @@
           }
       }
   
  -    while (<$fh>) {
  -        s/^\s*//; s/\s*$//; s/^\#.*//;
  -        next if /^$/;
  -        (my $directive, $_) = split /\s+/, $_, 2;
  -
  -        #parse what we want
  -        while (my($spec, $wanted) = each %wanted_config) {
  -            next unless $wanted->{$directive};
  -            my $method = "parse_\L$spec";
  -            $self->$method($c, $directive);
  -        }
  -    }
  +    $self->inherit_config_file_or_directory($file);
   
       #apply what we parsed
       while (my($spec, $wanted) = each %wanted_config) {
  @@ -207,8 +232,6 @@
               $cv->($self, $c, $directive);
           }
       }
  -
  -    close $fh;
   }
   
   sub get_httpd_static_modules {
  
  
  

Mime
View raw message