| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#################################################### |
|
2
|
|
|
|
|
|
|
## Config::Framework.pm |
|
3
|
|
|
|
|
|
|
## Andrew N. Hicox |
|
4
|
|
|
|
|
|
|
## |
|
5
|
|
|
|
|
|
|
## This package provides configuration info to |
|
6
|
|
|
|
|
|
|
## homegrown modules. |
|
7
|
|
|
|
|
|
|
################################################### |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## Global Stuff ################################### |
|
11
|
|
|
|
|
|
|
package Config::Framework; |
|
12
|
1
|
|
|
1
|
|
7263
|
use 5.6.0; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
53
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1803
|
use Data::DumpXML; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Data::DumpXML::Parser; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
require Exporter; |
|
19
|
|
|
|
|
|
|
use AutoLoader qw(AUTOLOAD); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## Class Global Values ############################ |
|
22
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
23
|
|
|
|
|
|
|
our $VERSION = '2.5'; |
|
24
|
|
|
|
|
|
|
our $errstr = (); |
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ($VERSION, $errstr); |
|
26
|
|
|
|
|
|
|
our @temp = split (/\//,$0); |
|
27
|
|
|
|
|
|
|
our %GLOB_CONFIG = ( |
|
28
|
|
|
|
|
|
|
#name of program running this code |
|
29
|
|
|
|
|
|
|
'program' => $temp[$#temp], |
|
30
|
|
|
|
|
|
|
#virtual root: everything lives under this |
|
31
|
|
|
|
|
|
|
'v_root' => "", |
|
32
|
|
|
|
|
|
|
#global configuration files live in this subdirectory |
|
33
|
|
|
|
|
|
|
'config_loc' => "", |
|
34
|
|
|
|
|
|
|
#sybase home directory |
|
35
|
|
|
|
|
|
|
'SYBASE' => "/", |
|
36
|
|
|
|
|
|
|
#oracle home directory |
|
37
|
|
|
|
|
|
|
'ORACLE_HOME' => "/", |
|
38
|
|
|
|
|
|
|
#set this library path |
|
39
|
|
|
|
|
|
|
'LD_LIBRARY_PATH' => "/", |
|
40
|
|
|
|
|
|
|
#where sendmail resides |
|
41
|
|
|
|
|
|
|
'sendmail' => "", |
|
42
|
|
|
|
|
|
|
#someone to phone home to when things go really wrong |
|
43
|
|
|
|
|
|
|
'admin' => "", |
|
44
|
|
|
|
|
|
|
#export these keys from GLOB_CONFIG to the shell environment |
|
45
|
|
|
|
|
|
|
'EnvExportList' => [ |
|
46
|
|
|
|
|
|
|
"SYBASE", |
|
47
|
|
|
|
|
|
|
"ORACLE_HOME", |
|
48
|
|
|
|
|
|
|
"ORACLE_SID", |
|
49
|
|
|
|
|
|
|
"ARTCPPORT", |
|
50
|
|
|
|
|
|
|
"LD_LIBRARY_PATH" |
|
51
|
|
|
|
|
|
|
], |
|
52
|
|
|
|
|
|
|
#we're using this encryption module |
|
53
|
|
|
|
|
|
|
'Crypt' => "", |
|
54
|
|
|
|
|
|
|
#it's under the virtual doormat |
|
55
|
|
|
|
|
|
|
'Key' => "", |
|
56
|
|
|
|
|
|
|
#automatically load child configs |
|
57
|
|
|
|
|
|
|
'LoadChildren' => 1 |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## new ############################################ |
|
62
|
|
|
|
|
|
|
sub new { |
|
63
|
|
|
|
|
|
|
my $class = shift(); |
|
64
|
|
|
|
|
|
|
my $self = bless ({@_}, $class); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#insert default global config items unless overriden by user input |
|
67
|
|
|
|
|
|
|
foreach (keys %GLOB_CONFIG){ $self->{$_} = $GLOB_CONFIG{$_} unless exists($self->{$_}); } |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#export items in EnvExportList |
|
70
|
|
|
|
|
|
|
foreach (@{$self->{'EnvExportList'}}){ $main::ENV{$_} = $self->{$_} if exists($self->{$_}); } |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#export other user-defined export items |
|
73
|
|
|
|
|
|
|
foreach (keys %{$self->{'Export'}}){ $main::ENV{$_} = $self->{'Export'}->{$_}; } |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#set up a shortcut to the applications 'framework' directory |
|
76
|
|
|
|
|
|
|
$self->{'FrameworkDir'} = "$self->{'v_root'}/$self->{'config_loc'}/ApplicationFrameworks/$self->{'program'}"; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#fix string-specified files for multiple file compatibility |
|
79
|
|
|
|
|
|
|
if ((exists ($self->{'File'})) && (ref ($self->{'File'}) ne "ARRAY")){ |
|
80
|
|
|
|
|
|
|
my $temp = $self->{'File'}; |
|
81
|
|
|
|
|
|
|
delete($self->{'File'}); |
|
82
|
|
|
|
|
|
|
push (@{$self->{'File'}}, $temp); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#load all of the specified configs |
|
86
|
|
|
|
|
|
|
foreach (@{$self->{'File'}}){ |
|
87
|
|
|
|
|
|
|
$self->LoadConfig(File => $_) || do { |
|
88
|
|
|
|
|
|
|
$errstr = "new: "; |
|
89
|
|
|
|
|
|
|
$errstr.= $self->{'errstr'}; |
|
90
|
|
|
|
|
|
|
return (undef); |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#load the secure config, if directed |
|
95
|
|
|
|
|
|
|
if ($self->{'GetSecure'}){ |
|
96
|
|
|
|
|
|
|
$self->LoadConfig( |
|
97
|
|
|
|
|
|
|
File => "$self->{'v_root'}/$self->{'config_loc'}/passwds.xml", |
|
98
|
|
|
|
|
|
|
configNamespace => "Secure" |
|
99
|
|
|
|
|
|
|
) || do { |
|
100
|
|
|
|
|
|
|
$errstr = "new: can't load secure config: $self->{'errstr'}"; |
|
101
|
|
|
|
|
|
|
return (undef); |
|
102
|
|
|
|
|
|
|
}; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#weed out descriptors under Secure namespace |
|
106
|
|
|
|
|
|
|
#ugly hack |
|
107
|
|
|
|
|
|
|
foreach (keys %{$self->{'Secure'}}){ |
|
108
|
|
|
|
|
|
|
if (ref ($self->{'Secure'}->{$_}) eq "HASH"){ |
|
109
|
|
|
|
|
|
|
if (exists($self->{'Secure'}->{$_}->{'content'})){ |
|
110
|
|
|
|
|
|
|
$self->{'Secure'}->{$_} = $self->{'Secure'}->{$_}->{'content'}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#send back the constructed object |
|
116
|
|
|
|
|
|
|
return ($self); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
## True for perl include ########################## |
|
122
|
|
|
|
|
|
|
1; |
|
123
|
|
|
|
|
|
|
__END__ |