line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RedHat::XML; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.3'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
##################################################################### |
6
|
|
|
|
|
|
|
# XML.pm |
7
|
|
|
|
|
|
|
# by Patrick Devine |
8
|
|
|
|
|
|
|
# patrick@bubblehockey.org |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# This software is covered under the same terms as Perl itself. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# WARNING: |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This software is no where near finished and lots of stuff will |
15
|
|
|
|
|
|
|
# probably change before it is officially released (as 1.0). |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
590
|
use RedHat::SysConfig; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
477
|
|
19
|
|
|
|
|
|
|
@ISA = qw/ RedHat::SysConfig /; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$TAB = 2; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
##################################################################### |
24
|
|
|
|
|
|
|
# method: xml |
25
|
|
|
|
|
|
|
# function: creates a scalar containing all of the data necessary |
26
|
|
|
|
|
|
|
# for to create a kickstart file |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub xml { |
29
|
1
|
|
|
1
|
0
|
28
|
my $self = shift; |
30
|
1
|
|
|
|
|
2
|
my $version = shift; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
1
|
my $buf; |
33
|
1
|
|
|
|
|
2
|
my $settings = $self->{settings}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
2
|
$buf = _hash_pair( $settings, $TAB, '' ); |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
3
|
\$buf; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _hash_pair { |
44
|
4
|
|
|
4
|
|
5
|
my $data_set = shift; |
45
|
4
|
|
|
|
|
6
|
my $offset = shift; |
46
|
4
|
|
|
|
|
4
|
my $node_name = shift; |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
2
|
my $buf; |
49
|
|
|
|
|
|
|
|
50
|
4
|
100
|
|
|
|
12
|
if( ref( $data_set ) eq 'HASH' ) { |
|
|
50
|
|
|
|
|
|
51
|
2
|
|
|
|
|
3
|
for( sort keys %{ $data_set } ) { |
|
2
|
|
|
|
|
10
|
|
52
|
|
|
|
|
|
|
|
53
|
3
|
100
|
|
|
|
10
|
if( ref( $data_set->{$_} ) eq 'HASH' ) { |
|
|
50
|
|
|
|
|
|
54
|
1
|
|
|
|
|
4
|
$buf .= ' ' x $offset . "<$_>\n"; |
55
|
1
|
|
|
|
|
9
|
$buf .= _hash_pair( $data_set->{$_}, $offset + $TAB, '' ); |
56
|
1
|
|
|
|
|
3
|
$buf .= ' ' x $offset . "$_>\n"; |
57
|
|
|
|
|
|
|
} elsif( ref( $data_set->{$_} ) eq 'ARRAY' ) { |
58
|
|
|
|
|
|
|
#$buf .= ' ' x $offset . "<$_>\n"; |
59
|
0
|
|
|
|
|
0
|
$buf .= _hash_pair( $data_set->{$_}, $offset, $_ ); |
60
|
|
|
|
|
|
|
#$buf .= ' ' x $offset . "$_>\n"; |
61
|
|
|
|
|
|
|
} else { |
62
|
2
|
|
|
|
|
5
|
$buf .= ' ' x $offset . "<$_>"; |
63
|
2
|
|
|
|
|
7
|
$buf .= _hash_pair( $data_set->{$_}, 0, '' ) . "$_>\n"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} elsif( ref( $data_set ) eq 'ARRAY' ) { |
67
|
0
|
|
|
|
|
0
|
for my $array ( @{ $data_set } ) { |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
0
|
|
|
|
0
|
if( ref( $array ) eq 'ARRAY' ) { |
|
|
0
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
$buf .= ' ' x $offset . "<$node_name>"; |
70
|
0
|
|
|
|
|
0
|
$buf .= _hash_pair( $array, 0, '' ); |
71
|
0
|
|
|
|
|
0
|
$buf .= "$node_name>\n"; |
72
|
|
|
|
|
|
|
} elsif( ref( $array ) eq 'HASH' ) { |
73
|
0
|
|
|
|
|
0
|
$buf .= ' ' x $offset . "<$node_name>\n"; |
74
|
0
|
|
|
|
|
0
|
$buf .= _hash_pair( $array, $offset + $TAB, '' ); |
75
|
0
|
|
|
|
|
0
|
$buf .= ' ' x $offset . "$node_name>\n"; |
76
|
|
|
|
|
|
|
} else { |
77
|
0
|
|
|
|
|
0
|
$buf .= ' ' x $offset . "<$node_name>"; |
78
|
0
|
|
|
|
|
0
|
$buf .= _hash_pair( $array, 0, '' ); |
79
|
0
|
|
|
|
|
0
|
$buf .= "$node_name>\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} else { |
84
|
2
|
50
|
|
|
|
5
|
$buf .= ( $data_set ? "$data_set" : 'true' ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
10
|
$buf; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |