--- lib/Qpsmtpd.pm.dirs 2005-07-31 07:54:36.000000000 +0200 +++ lib/Qpsmtpd.pm 2005-08-20 18:25:17.340983977 +0200 @@ -87,7 +87,10 @@ # database or whatever. # sub config { - my ($self, $c, $type) = @_; + my ($self, $c, $arg) = @_; + unless (ref $arg) { + $arg = { type => $arg }; + } #warn "SELF->config($c) ", ref $self; @@ -96,17 +99,13 @@ timeout => 1200, ); - my ($rc, @config) = $self->run_hooks("config", $c); - @config = () unless $rc == OK; + my ($rc, @config) = $self->run_hooks("config", $c, $arg); + unless ($rc == OK) { + @config = $self->get_qmail_config($c, $arg); + @config = $defaults{$c} if (!@config and $defaults{$c}); + } - if (wantarray) { - @config = $self->get_qmail_config($c, $type) unless @config; - @config = $defaults{$c} if (!@config and $defaults{$c}); - return @config; - } - else { - return ($config[0] || $self->get_qmail_config($c, $type) || $defaults{$c}); - } + return wantarray ? @config : $config[0]; } sub config_dir { @@ -122,13 +121,18 @@ } sub plugin_dir { + my $self = shift; + my $plugin_dir = $self->config('plugin_dir', {nolog => 1}); + unless (defined($plugin_dir)) { my ($name) = ($0 =~ m!(.*?)/([^/]+)$!); - my $dir = "$name/plugins"; + $plugin_dir = "$name/plugins"; + } + return $plugin_dir; } sub get_qmail_config { - my ($self, $config, $type) = @_; - $self->log(LOGDEBUG, "trying to get config for $config"); + my ($self, $config, $arg) = @_; + $self->log(LOGDEBUG, "trying to get config for $config") unless($arg->{nolog}); if ($self->{_config_cache}->{$config}) { return wantarray ? @{$self->{_config_cache}->{$config}} : $self->{_config_cache}->{$config}->[0]; } @@ -136,7 +140,7 @@ my $configfile = "$configdir/$config"; - if ($type and $type eq "map") { + if ($arg->{type} and $arg->{type} eq "map") { return +{} unless -e $configfile . ".cdb"; eval { require CDB_File };