1 |
--- lib/Qpsmtpd.pm.dirs 2005-07-31 07:54:36.000000000 +0200 |
2 |
+++ lib/Qpsmtpd.pm 2005-08-20 18:25:17.340983977 +0200 |
3 |
@@ -87,7 +87,10 @@ |
4 |
# database or whatever. |
5 |
# |
6 |
sub config { |
7 |
- my ($self, $c, $type) = @_; |
8 |
+ my ($self, $c, $arg) = @_; |
9 |
+ unless (ref $arg) { |
10 |
+ $arg = { type => $arg }; |
11 |
+ } |
12 |
|
13 |
#warn "SELF->config($c) ", ref $self; |
14 |
|
15 |
@@ -96,17 +99,13 @@ |
16 |
timeout => 1200, |
17 |
); |
18 |
|
19 |
- my ($rc, @config) = $self->run_hooks("config", $c); |
20 |
- @config = () unless $rc == OK; |
21 |
+ my ($rc, @config) = $self->run_hooks("config", $c, $arg); |
22 |
+ unless ($rc == OK) { |
23 |
+ @config = $self->get_qmail_config($c, $arg); |
24 |
+ @config = $defaults{$c} if (!@config and $defaults{$c}); |
25 |
+ } |
26 |
|
27 |
- if (wantarray) { |
28 |
- @config = $self->get_qmail_config($c, $type) unless @config; |
29 |
- @config = $defaults{$c} if (!@config and $defaults{$c}); |
30 |
- return @config; |
31 |
- } |
32 |
- else { |
33 |
- return ($config[0] || $self->get_qmail_config($c, $type) || $defaults{$c}); |
34 |
- } |
35 |
+ return wantarray ? @config : $config[0]; |
36 |
} |
37 |
|
38 |
sub config_dir { |
39 |
@@ -122,13 +121,18 @@ |
40 |
} |
41 |
|
42 |
sub plugin_dir { |
43 |
+ my $self = shift; |
44 |
+ my $plugin_dir = $self->config('plugin_dir', {nolog => 1}); |
45 |
+ unless (defined($plugin_dir)) { |
46 |
my ($name) = ($0 =~ m!(.*?)/([^/]+)$!); |
47 |
- my $dir = "$name/plugins"; |
48 |
+ $plugin_dir = "$name/plugins"; |
49 |
+ } |
50 |
+ return $plugin_dir; |
51 |
} |
52 |
|
53 |
sub get_qmail_config { |
54 |
- my ($self, $config, $type) = @_; |
55 |
- $self->log(LOGDEBUG, "trying to get config for $config"); |
56 |
+ my ($self, $config, $arg) = @_; |
57 |
+ $self->log(LOGDEBUG, "trying to get config for $config") unless($arg->{nolog}); |
58 |
if ($self->{_config_cache}->{$config}) { |
59 |
return wantarray ? @{$self->{_config_cache}->{$config}} : $self->{_config_cache}->{$config}->[0]; |
60 |
} |
61 |
@@ -136,7 +140,7 @@ |
62 |
|
63 |
my $configfile = "$configdir/$config"; |
64 |
|
65 |
- if ($type and $type eq "map") { |
66 |
+ if ($arg->{type} and $arg->{type} eq "map") { |
67 |
return +{} unless -e $configfile . ".cdb"; |
68 |
eval { require CDB_File }; |
69 |
|