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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package modules::parameters; # $Id$
use diagnostics;
use strict;
#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use modules;
sub parameters {
my ($module) = @_;
if (!$::isStandalone && !$::testing) {
($module) = modules::extract_modules('/tmp', $module);
}
my @parameters;
foreach (common::join_lines(run_program::get_stdout('modinfo', '-p', $module))) {
chomp;
next if /^warning:/;
(my $name, $_) = /(\w+)(?::|\s+)(.*)/s or warn "modules::parameters::get_options_name($module): unknown line\n";
if (c::kernel_version() =~ /^\Q2.6/) {
push @parameters, [ $name, '', $_ ];
next;
}
my $c_types = 'int|string|short|byte|char|long';
my ($is_a_number, $description, $min, $max) = (0, '', 1, 1);
if (/^($c_types) array \(min = (\d+), max = (\d+)\),?\s*(.*)/s) {
$_ = $4;
#- seems like "char" are buggy entries
($is_a_number, $min, $max) = ($1 ne 'string', $2, $3) if $1 ne 'char';
} elsif (/^($c_types),?\s*(.*)/s) {
$_ = $2;
#- here "char" really are size-limited strings, modinfo does not display the size limit (but since we do not care about it, it does not matter :)
$is_a_number = $1 ne 'string' if $1 ne 'char';
} else {
#- for things like "no format character" or "unknown format character"
}
if (/^description "(.*)",?\s*/s) {
($description, $_) = ($1, $2);
}
#- print "STILL HAVE ($_)\n" if $_;
my $format = $min == 1 && $max == 1 ?
($is_a_number ? N("a number") : '') :
$min == $max ?
($is_a_number ? N("%d comma separated numbers", $min) : N("%d comma separated strings", $min)) :
$min == 1 ?
($is_a_number ? N("comma separated numbers") : N("comma separated strings")) :
''; #- too weird and buggy, do not display it
push @parameters, [ $name, $format, $description ];
}
@parameters;
}
1;
|