summaryrefslogtreecommitdiffstats
path: root/perl-install/modparm.pm
diff options
context:
space:
mode:
authorMystery Man <unknown@mandriva.org>2000-11-08 00:01:16 +0000
committerMystery Man <unknown@mandriva.org>2000-11-08 00:01:16 +0000
commitd5c526273db473a7d87a26000585900fc10dda7d (patch)
tree0fdaabe7a00921b6cc556601b103d344fc7ac781 /perl-install/modparm.pm
parent9c164312d4bfff6d93e1c4529de6b992f2bebc44 (diff)
downloaddrakx-d5c526273db473a7d87a26000585900fc10dda7d.tar
drakx-d5c526273db473a7d87a26000585900fc10dda7d.tar.gz
drakx-d5c526273db473a7d87a26000585900fc10dda7d.tar.bz2
drakx-d5c526273db473a7d87a26000585900fc10dda7d.tar.xz
drakx-d5c526273db473a7d87a26000585900fc10dda7d.zip
This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.1'.
Diffstat (limited to 'perl-install/modparm.pm')
-rw-r--r--perl-install/modparm.pm84
1 files changed, 52 insertions, 32 deletions
diff --git a/perl-install/modparm.pm b/perl-install/modparm.pm
index 46dcb23b7..a630cdd5c 100644
--- a/perl-install/modparm.pm
+++ b/perl-install/modparm.pm
@@ -1,27 +1,15 @@
package modparm;
-use diagnostics;
-use strict;
-
-#-######################################################################################
-#- misc imports
-#-######################################################################################
-use common qw(:common :functional);
use log;
+my %modparm_hash;
-
-#-######################################################################################
-#- Functions
-#-######################################################################################
-sub read_modparm_file {
- my $file = -e "modparm.lst" ? "modparm.lst" : "$ENV{SHARE_PATH}/modparm.lst";
+sub read_modparm_file($) {
+ my ($file) = @_;
my @line;
- my %modparm_hash;
- local *F;
- open F, $file or log::l("missing $file: $!"), return;
- foreach (<F>) {
+ open F, $file;
+ while (<F>) {
chomp;
@line = split ':';
@@ -31,30 +19,62 @@ sub read_modparm_file {
desc => $line [4],
};
}
- \%modparm_hash;
+ close F;
}
-sub get_options_result($@) {
- my ($module, @value) = @_;
- my $modparm_hash = modparm::read_modparm_file;
+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 ";
+ }
+ }
- mapn {
- my ($a, $b) = @_;
- $a ? "$b=$a" : ()
- } \@value, [ keys %{$modparm_hash->{$module}} ];
+ return $options;
}
sub get_options_name($) {
my ($module) = @_;
- my @names;
- my $modparm_hash = modparm::read_modparm_file;
+ my @names = keys %{$modparm_hash{$module}};
+ my @result;
+ my $opttype;
+ my $default;
+
+ foreach (@names) {
+ $opttype = $modparm_hash{$module}{$_}{type};
+ $default = $modparm_hash{$module}{$_}{default};
- while (my ($k, $v) = each %{$modparm_hash->{$module} || {}}) {
- my $opttype = $v->{type};
- my $default = $v->{default};
- push @names, "$k ($v->{type})" . (defined($v->{default}) && "[$v->{default}]");
+ if (defined($default)) {
+ push @result, _("$_ ($opttype)[$default]");
+ } else {
+ push @result, _("$_ ($opttype)");
+ }
}
- @names;
+
+ 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;