diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-12-07 05:37:40 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-12-07 05:37:40 +0200 |
commit | 7a06349587e2fe0cb1b5c74185d2f507173409c4 (patch) | |
tree | fb488c11d0b6185defa43cc717ab0c37356fb538 /lib/Apache/Config/Preproc/ifmodule.pm | |
parent | b4cf13ffdacb47686cdee6b31155f325800c9bcc (diff) | |
download | acpp-7a06349587e2fe0cb1b5c74185d2f507173409c4.tar.gz acpp-7a06349587e2fe0cb1b5c74185d2f507173409c4.tar.bz2 |
Rename module to Apache::Config::Preproc
Diffstat (limited to 'lib/Apache/Config/Preproc/ifmodule.pm')
-rw-r--r-- | lib/Apache/Config/Preproc/ifmodule.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Apache/Config/Preproc/ifmodule.pm b/lib/Apache/Config/Preproc/ifmodule.pm new file mode 100644 index 0000000..9fe73b7 --- /dev/null +++ b/lib/Apache/Config/Preproc/ifmodule.pm @@ -0,0 +1,34 @@ +package Apache::Config::Preproc::ifmodule; +use strict; +use warnings; + +sub new { + bless {}, shift +} + +sub expand { + my ($self, $tree, $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($tree, $id); + if ($negate) { + $res = !$res; + } + if ($res) { + push @$repl, $d->select; + } + return 1; + } + return 0; +} + +sub module_loaded { + my ($self, $tree, $id) = @_; + return grep { + (split /\s+/, $_->value)[0] eq $id + } $tree->directive('loadmodule'); +} + +1; + |