blob: a630cdd5c82744a6580205f8946608353bbff189 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package modparm;
use log;
my %modparm_hash;
sub read_modparm_file($) {
my ($file) = @_;
my @line;
open F, $file;
while (<F>) {
chomp;
@line = split ':';
$modparm_hash{$line[0]}{$line[1]} = {
type => $line[2],
default => $line[3],
desc => $line [4],
};
}
close F;
}
sub get_options_result($;$) {
my ($module,$value) = @_;
my @names = keys %{$modparm_hash{$module}};
my $options;
my $result;
my $i;
for $i (0..$#$value) {
$result = $ {$value->[$i]};
if ($result != "") {
$options .= "$names[$i]=$result ";
}
}
return $options;
}
sub get_options_name($) {
my ($module) = @_;
my @names = keys %{$modparm_hash{$module}};
my @result;
my $opttype;
my $default;
foreach (@names) {
$opttype = $modparm_hash{$module}{$_}{type};
$default = $modparm_hash{$module}{$_}{default};
if (defined($default)) {
push @result, _("$_ ($opttype)[$default]");
} else {
push @result, _("$_ ($opttype)");
}
}
return \@result;
}
sub get_options_value($) {
my ($module) = @_;
my @names = keys %{$modparm_hash{$module}};
my @result;
for $i (0..$#names) {
my $value = "";
$result[$i] = \$value;
}
return \@result;
}
read_modparm_file("/tmp/modparm.txt");
1;
|