summaryrefslogtreecommitdiffstats
path: root/perl-install/modparm.pm
blob: 50130e1a9e21efa2777008cf5227a8c1e39c71aa (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
package modparm; # $Id$

use diagnostics;
use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use log;


sub get_options_result($@) {
    my ($module, @value) = @_;
    mapn {
	my ($a, $b) = @_;
	$b =~ s/^(\w+).*/$1/;
	$a ? "$b=$a" : ();
    } \@value, [get_options_name($module)];
}

sub get_options_name($) {
  my ($module) = @_;

  my @names;
  $modinfo = '/sbin/modinfo';
  -e $modinfo or $modinfo = '/usr/bin/modinfo';
  -e $modinfo or die _('modinfo is not available');
  my @line = `/sbin/modinfo -p $module`;
  print "yop : @line \n";
  foreach (@line) {
      chomp;
      s/int/: (integer/;
      s/string/: (string/;
      my ($f, $g) = /array \(min = (\d+), max = (\d+)\)/;
      my $c;
      if ($f == 1 && $g == 1) {
	  $c = _('1 character)');
      } else {
	  $c = sprintf("$f-$g %s)", _('characters'));
      }
      s/array \(min = \d+, max = \d+\)/$c/;
      if (/parm:\s+(.+)/) {
	  local $_ = $1;
	  s/\s+/ /;
	  s/, description /TOOLTIP=>/;
	  push @names, $_;
      }
  }
  print "yop : @names \n";
  @names;
}

1;