forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhpux-driver.pl
executable file
·125 lines (112 loc) · 3.1 KB
/
hpux-driver.pl
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# hpux-driver.pl
# Functions for webmin print and smb drivers.
# Very similar to the webmin driver, but with a different interface
# program selector
$webmin_windows_driver = 1;
$webmin_print_driver = 1;
# is_windows_driver(path)
# Returns a driver structure if some path is a windows driver
sub is_windows_driver
{
return &is_webmin_windows_driver(@_);
}
# is_driver(path)
# Returns a structure containing the details of a driver
sub is_driver
{
return &is_webmin_driver(@_);
}
# create_windows_driver(&printer, &driver)
# Creates a new windows printer driver
sub create_windows_driver
{
return &create_webmin_windows_driver(@_);
}
# create_driver(&printer, &driver)
# Creates a new local printer driver and returns the path
sub create_driver
{
return &create_webmin_driver(@_);
}
# delete_driver(name)
sub delete_driver
{
&delete_webmin_driver(@_);
}
# driver_input(&printer, &driver)
sub driver_input
{
local ($prn, $drv) = @_;
printf "<tr> <td><input type=radio name=drv value=0 %s> %s</td>\n",
$drv->{'mode'} == 0 ? "checked" : "", $text{'webmin_none'};
print "<td>($text{'webmin_remotemsg'})</td> </tr>\n";
printf "<tr> <td><input type=radio name=drv value=2 %s> %s</td>\n",
$drv->{'mode'} == 2 ? "checked" : "", $text{'webmin_model'};
print "<td><select name=iface>\n";
opendir(DIR, $config{'model_path'});
while($f = readdir(DIR)) {
if ($f =~ /^\./) { next; }
$path = "$config{'model_path'}/$f";
printf "<option value=\"$path\" %s>$f\n",
$path eq $prn{'iface'} ? "selected" : "";
}
closedir(DIR);
print "</select></td> </tr>\n";
if (&has_ghostscript()) {
local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
if ($out =~ /Available devices:\n((\s+.*\n)+)/) {
print "<tr> <td valign=top>\n";
printf "<input type=radio name=drv value=1 %s>\n",
$drv->{'mode'} == 1 ? "checked" : "";
print "$text{'webmin_driver'}</td> <td valign=top>";
foreach $d (split(/\s+/, $1)) { $drvsupp{$d}++; }
print "<select name=driver size=7>\n";
foreach $d (&list_webmin_drivers()) {
if ($drvsupp{$d->[0]}) {
printf "<option %s>%s\n",
$d->[1] eq $drv->{'type'} ? "selected" : "",
$d->[1];
}
}
print "</select> ";
print "<select name=dpi size=7>\n";
printf "<option value=\"\" %s>Default\n",
$drv->{'dpi'} ? "" : "selected";
foreach $d (75, 100, 150, 200, 300, 600) {
printf "<option value=\"$d\" %s>$d DPI\n",
$drv->{'dpi'} == $d ? "selected" : "";
}
print "</select></td> </tr>\n";
}
else {
print "<tr> <td colspan=2>",
&text('webmin_edrivers', "<tt>$config{'gs_path'}</tt>"),
"</td> </tr>\n";
}
}
else {
print "<tr> <td colspan=2>",
&text('webmin_egs', "<tt>$config{'gs_path'}</tt>"),
"</td> </tr>\n";
}
return undef;
}
# parse_driver()
# Parse driver selection from %in and return a driver structure
sub parse_driver
{
if ($in{'drv'} == 0) {
return { 'mode' => 0 };
}
elsif ($in{'drv'} == 2) {
(-x $in{'iface'}) || &error("'$in{'iface'}' does not exist");
return { 'mode' => 2,
'program' => $in{'iface'} };
}
elsif ($in{'drv'} == 1) {
return { 'mode' => 1,
'type' => $in{'driver'},
'dpi' => $in{'dpi'} };
}
}
1;