Handle hostnames with upper-case letters
[webmin.git] / fdisk / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'fdisk-lib.pl';
5
6 # parse_webmin_log(user, script, action, type, object, &params)
7 # Converts logged information from this module into human-readable form
8 sub parse_webmin_log
9 {
10 local ($user, $script, $action, $type, $object, $p) = @_;
11 if ($type eq 'part') {
12         return &text("log_${action}", &part_name2($object, $p->{'np'}));
13         }
14 elsif ($action eq 'mkfs' || $action eq 'tunefs' || $action eq 'fsck') {
15         return &text("log_${action}", "<tt>".uc($p->{'type'})."</tt>",
16                      &part_name($object));
17         }
18 elsif ($action eq 'hdparm') {
19         return &text('log_hdparm', &device_name($object));
20         }
21 else {
22         return undef;
23         }
24 }
25
26 sub part_name2
27 {
28 return $_[0] =~ /^\/dev\/(s|h)d([a-z])$/ ?
29         &text('select_part', $1 eq 's' ? 'SCSI' : 'IDE', uc($2), $_[1]) :
30        $_[0] =~ /rd\/c(\d+)d(\d+)$/ ?
31         &text('select_mpart', "$1", "$2", $_[1]) :
32        $_[0] =~ /ida\/c(\d+)d(\d+)$/ ?
33         &text('select_cpart', "$1", "$2", $_[1]) :
34         $_[0];
35 }
36
37 sub part_name
38 {
39 return $_[0] =~ /^\/dev\/(s|h)d([a-z])(\d+)$/ ?
40         &text('select_part', $1 eq 's' ? 'SCSI' : 'IDE', uc($2), "$3") :
41        $_[0] =~ /rd\/c(\d+)d(\d+)p(\d+)$/ ?
42         &text('select_mpart', "$1", "$2", "$3") :
43        $_[0] =~ /ida\/c(\d+)d(\d+)p(\d+)$/ ?
44         &text('select_cpart', "$1", "$2", "$3") :
45         $_[0];
46 }
47
48 sub device_name
49 {
50 return $_[0] =~ /^\/dev\/(s|h)d([a-z])$/ ?
51         &text('select_device', $1 eq 's' ? 'SCSI' : 'IDE', uc($2)) :
52        $_[0] =~ /rd\/c(\d+)d(\d+)$/ ?
53         &text('select_mylex', "$1", "$2") :
54        $_[0] =~ /ida\/c(\d+)d(\d+)$/ ?
55         &text('select_cpq', "$1", "$2") :
56         $_[0];
57 }