3 for $filename (@ARGV) {
4 open(SRC, $filename) || die "$filename: $!";
6 delete @tvars{keys %tvars};
10 if(($state == 0) && /struct configvar/ && /\[\]/) {
13 if(($state == 0) && /struct module/ && /=/) {
16 if(($state == 1) && /^\s*\/\*\*/) {
21 if(($state == 1) && /\{CONF_VAR_(\w+), \"([^\"]*)\"/) {
22 $var = $2; $type = $1; $def = "";
24 ($def) = /\.num = (\d+)/;
25 } elsif($type eq "BOOL") {
26 ($def) = /\.num = (\d+)/;
32 } elsif($type eq "STRING") {
33 ($def) = /\.str = L\"([^\"]*)\"/;
36 $tvars{$var} = {"doc" => $curdoc, "type" => $type, "def" => $def};
39 if(($state == 1) && /\s*\};$/) {
49 if(length($curdoc) > 0) {
54 if(($state == 3) && /\.name\s*=\s*\"([^\"]+)\"/) {
57 if(($state == 3) && /\s*\};$/) {
63 #$module =~ s/^.*\///;
64 #$module =~ s/\..*$//;
66 print STDERR "$filename is not a module\n";
68 print STDERR ("$filename is module $module and has " . scalar(keys %tvars) . " variables\n");
69 for $var (keys %tvars) {
70 $vars{"$module.$var"} = $tvars{$var};
74 print STDERR ("total number of variables: " . scalar(keys %vars) . "\n");
76 $types{"BOOL"} = "boolean";
77 $types{"INT"} = "integer";
78 $types{"STRING"} = "string";
79 $types{"IPV4"} = "IPv4 address";
83 $date = sprintf("%04i-%02i-%02i", $lt[5] + 1900, $lt[4] + 1, $lt[3]);
88 for $var (sort keys %vars) {
89 $_ .= ".TP\n.BI $var \" ";
90 $_ .= $types{$vars{$var}->{"type"}};
92 $_ .= $vars{$var}->{"doc"};
93 if(!($vars{$var}->{"type"} eq "IPV4")) {
94 $_ .= "\n\nDefault value: ";
95 $_ .= $vars{$var}->{"def"};