Apache-Config-Preproc

 view release on metacpan or  search on metacpan

lib/Apache/Config/Preproc/ifmodule.pm  view on Meta::CPAN

package Apache::Config::Preproc::ifmodule;
use parent 'Apache::Config::Preproc::Expand';
use strict;
use warnings;
use Carp;
use IPC::Open3;

our $VERSION = '1.03';

sub new {
    my $class = shift;
    my $conf = shift;
    my $self = $class->SUPER::new($conf);
    local %_ = @_;
    my $v;
    if ($v = delete $_{preloaded}) {
	croak "preloaded must be an arrayref" unless ref($v) eq 'ARRAY';
	@{$self->{preloaded}}{@$v} = @$v;
    }
    if ($v = delete $_{probe}) {
	if (ref($v) eq 'ARRAY') {
	    $self->probe(@$v);
	} else {
	    $self->probe;
	}
    }
    return $self;
}

sub preloaded {
    my $self = shift;
    my $id = shift;
    if (my $v = shift) {
	$self->{preloaded}{$id} = $v;
    }
    return $self->{preloaded}{$id};
}

sub expand {
    my ($self, $d, $repl) = @_;
    if ($d->type eq 'section' && lc($d->name) eq 'ifmodule') {
	my $id = $d->value;
	my $negate = $id =~ s/^!//;
	my $res = $self->module_loaded($id);
	if ($negate) {
	    $res = !$res;
	}
	if ($res) {
	    push @$repl, $d->select;
	}
	return 1;
    }
    return 0;
}

# List of module sources and corresponding identifiers, obtained from the
# httpd-2.4.6 source.
my %modlist = (
    'event.c' => 'mpm_event_module',
    'prefork.c' => 'mpm_prefork_module',
    'worker.c' => 'mpm_worker_module',
    'mod_access_compat.c' => 'access_compat_module',
    'mod_actions.c' => 'actions_module',
    'mod_alias.c' => 'alias_module',
    'mod_allowmethods.c' => 'allowmethods_module',
    'mod_asis.c' => 'asis_module',
    'mod_auth_basic.c' => 'auth_basic_module',
    'mod_auth_digest.c' => 'auth_digest_module',
    'mod_auth_form.c' => 'auth_form_module',
    'mod_authn_anon.c' => 'authn_anon_module',
    'mod_authn_core.c' => 'authn_core_module',
    'mod_authn_dbd.c' => 'authn_dbd_module',
    'mod_authn_dbm.c' => 'authn_dbm_module',



( run in 0.787 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )