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

use diagnostics;
use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common qw(:common :functional);
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 @line = `/sbin/modinfo -p $module`;
  foreach (@line) {
      chomp;
      s/int/i/;
      s/string/string/;
      s/short/h/;
      s/long/l/;
      s/(\S) array \(min = (\d+), max = (\d+))/$2-$3$1/;
      s/(\d)-\1i/$1i/;
      if (/parm:\s+(*+)/) {
	  my ($name, $type) = split '\s', $1;
	  push @names, "$name ($type)";
      }
  }
  @names;
}

1;