line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail/Salsa/Config.pm |
3
|
|
|
|
|
|
|
# Last Modification: Thu May 27 18:32:49 WEST 2004 |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright (c) 2004 Henrique Dias . All rights reserved. |
6
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or modify |
7
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package Mail::Salsa::Config; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
18
|
use 5.008000; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
44
|
|
12
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
13
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Exporter; |
16
|
1
|
|
|
1
|
|
6
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
21
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
22
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# This allows declaration use Mail::Salsa::Config ':all'; |
25
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
26
|
|
|
|
|
|
|
# will save memory. |
27
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
) ] ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our @EXPORT = qw( |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Preloaded methods go here. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_config { |
42
|
0
|
|
|
0
|
0
|
|
my $config = &load_config( |
43
|
|
|
|
|
|
|
file => undef, |
44
|
|
|
|
|
|
|
defaults => {}, |
45
|
|
|
|
|
|
|
@_, |
46
|
|
|
|
|
|
|
); |
47
|
0
|
|
|
|
|
|
return($config); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub load_config { |
51
|
0
|
|
|
0
|
0
|
|
my $args = {@_}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $wloop = <
|
54
|
|
|
|
|
|
|
while() { |
55
|
|
|
|
|
|
|
study; |
56
|
|
|
|
|
|
|
/^\\w/ or next; |
57
|
|
|
|
|
|
|
my (\$k, \$v) = split(/ *= */); |
58
|
|
|
|
|
|
|
\$v =~ s/\\s+\$//g; |
59
|
|
|
|
|
|
|
\$v =~ /^(.+)\$/; |
60
|
|
|
|
|
|
|
\$config{\$k} = (ref(\$args->{defaults}->{\$k}) eq "ARRAY") ? [map {/^(.+)\$/} split(/ *, */, \$1)] : \$1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
ENDCODE |
63
|
0
|
|
|
|
|
|
my %config = %{$args->{defaults}}; |
|
0
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
open(CONFIG, join("", "<", $args->{file})) or die("No such configuration file\n"); |
65
|
0
|
|
|
|
|
|
eval($wloop); |
66
|
0
|
|
|
|
|
|
close(CONFIG); |
67
|
0
|
|
|
|
|
|
return(\%config); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |