Handle hostnames with upper-case letters
[webmin.git] / lpadmin / irix-driver.pl
1 # irix-driver.pl
2 # Functions for webmin print and smb drivers.
3 # Very similar to the webmin driver, but with a different interface
4 # program selector
5
6 $webmin_windows_driver = 1;
7 $webmin_print_driver = 1;
8
9 # is_windows_driver(path)
10 # Returns a driver structure if some path is a windows driver
11 sub is_windows_driver
12 {
13 return &is_webmin_windows_driver(@_);
14 }
15
16 # is_driver(path)
17 # Returns a structure containing the details of a driver
18 sub is_driver
19 {
20 return &is_webmin_driver(@_);
21 }
22
23 # create_windows_driver(&printer, &driver)
24 # Creates a new windows printer driver
25 sub create_windows_driver
26 {
27 return &create_webmin_windows_driver(@_);
28 }
29
30 # create_driver(&printer, &driver)
31 # Creates a new local printer driver and returns the path
32 sub create_driver
33 {
34 return &create_webmin_driver(@_);
35 }
36
37 # delete_driver(name)
38 sub delete_driver
39 {
40 &delete_webmin_driver(@_);
41 }
42
43 # driver_input(&printer, &driver)
44 sub driver_input
45 {
46 local ($prn, $drv) = @_;
47
48 printf "<tr> <td><input type=radio name=drv value=0 %s> %s</td>\n",
49         $drv->{'mode'} == 0 ? "checked" : "", $text{'webmin_none'};
50 print "<td>($text{'webmin_remotemsg'})</td> </tr>\n";
51
52 printf "<tr> <td><input type=radio name=drv value=2 %s> %s</td>\n",
53         $drv->{'mode'} == 2 ? "checked" : "", $text{'webmin_model'};
54 print "<td><select name=iface>\n";
55 opendir(DIR, $config{'model_path'});
56 while($f = readdir(DIR)) {
57         if ($f =~ /^\./) { next; }
58         $path = "$config{'model_path'}/$f";
59         printf "<option value=\"$path\" %s>$f\n",
60                 $path eq $prn{'iface'} ? "selected" : "";
61         }
62 closedir(DIR);
63 print "</select></td> </tr>\n";
64
65 if (&has_ghostscript()) {
66         local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
67         if ($out =~ /Available devices:\n((\s+.*\n)+)/) {
68                 print "<tr> <td valign=top>\n";
69                 printf "<input type=radio name=drv value=1 %s>\n",
70                         $drv->{'mode'} == 1 ? "checked" : "";
71                 print "$text{'webmin_driver'}</td> <td valign=top>";
72                 foreach $d (split(/\s+/, $1)) { $drvsupp{$d}++; }
73                 print "<select name=driver size=7>\n";
74                 foreach $d (&list_webmin_drivers()) {
75                         if ($drvsupp{$d->[0]}) {
76                                 printf "<option %s>%s\n",
77                                     $d->[1] eq $drv->{'type'} ? "selected" : "",
78                                     $d->[1];
79                                 }
80                         }
81                 print "</select>&nbsp;&nbsp;";
82                 print "<select name=dpi size=7>\n";
83                 printf "<option value=\"\" %s>Default\n",
84                         $drv->{'dpi'} ? "" : "selected";
85                 foreach $d (75, 100, 150, 200, 300, 600) {
86                         printf "<option value=\"$d\" %s>$d DPI\n",
87                                 $drv->{'dpi'} == $d ? "selected" : "";
88                         }
89                 print "</select></td> </tr>\n";
90                 }
91         else {
92                 print "<tr> <td colspan=2>",
93                       &text('webmin_edrivers', "<tt>$config{'gs_path'}</tt>"),
94                       "</td> </tr>\n";
95                 }
96         }
97 else {
98         print "<tr> <td colspan=2>",
99               &text('webmin_egs', "<tt>$config{'gs_path'}</tt>"),
100               "</td> </tr>\n";
101         }
102 return undef;
103 }
104
105 # parse_driver()
106 # Parse driver selection from %in and return a driver structure
107 sub parse_driver
108 {
109 if ($in{'drv'} == 0) {
110         return { 'mode' => 0 };
111         }
112 elsif ($in{'drv'} == 2) {
113         (-x $in{'iface'}) || &error("'$in{'iface'}' does not exist");
114         return { 'mode' => 2,
115                  'program' => $in{'iface'} };
116         }
117 elsif ($in{'drv'} == 1) {
118         return { 'mode' => 1,
119                  'type' => $in{'driver'},
120                  'dpi' => $in{'dpi'} };
121         }
122 }
123
124 1;
125