Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kam-printing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
kam-printing
Commits
93e36c25
Commit
93e36c25
authored
13 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
First bits of PPD generator
parent
7249e8c3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ppd/PPD.pm
+133
-0
133 additions, 0 deletions
ppd/PPD.pm
ppd/gen-hp
+21
-0
21 additions, 0 deletions
ppd/gen-hp
with
154 additions
and
0 deletions
ppd/PPD.pm
0 → 100644
+
133
−
0
View file @
93e36c25
package
PPD
;
use
strict
;
use
warnings
;
use
Exporter
'
import
';
our
@EXPORT
=
qw(get set maybe_set generate)
;
my
%options
=
();
sub
format_value
($$)
{
my
(
$type
,
$value
)
=
@_
;
$type
//
=
'
q
';
if
(
$type
eq
'
q
')
{
# Quoted value
return
'
"
'
.
$value
.
'
"
';
}
elsif
(
$type
eq
'
i
')
{
# Invocation value
return
'
"
'
.
$value
.
'
"
';
}
elsif
(
$type
eq
'
s
')
{
# String value
return
$value
;
}
elsif
(
$type
eq
'
b
')
{
# Boolean value
return
$value
?
"
True
"
:
"
False
";
}
else
{
die
"
Unknown type '
$type
'
\n
";
}
}
sub
get
($)
{
my
(
$key
,
$value
)
=
@_
;
my
(
$section
,
$opt
)
=
split
/\//
,
$key
;
my
$o
=
$options
{
$section
}{
$opt
};
if
(
$o
)
{
return
$o
->
{'
value
'};
}
else
{
return
;
}
}
sub
set
($$)
{
my
(
$key
,
$value
)
=
@_
;
my
(
$section
,
$opt
)
=
split
/\//
,
$key
;
my
(
$opt2
,
$type
)
=
split
/:/
,
$opt
;
$options
{
$section
}{
$opt2
}
=
{
'
type
'
=>
$type
,
'
value
'
=>
$value
};
}
sub
maybe_set
($$)
{
my
(
$key
,
$value
)
=
@_
;
my
(
$section
,
$opt
)
=
split
/\//
,
$key
;
my
(
$opt2
,
$type
)
=
split
/:/
,
$opt
;
$options
{
$section
}{
$opt2
}
//
=
{
'
type
'
=>
$type
,
'
value
'
=>
$value
};
}
sub
mand
($)
{
my
(
$key
)
=
@_
;
my
(
$section
,
$opt
)
=
split
/\//
,
$key
;
$options
{
$section
}{
$opt
}
=
undef
;
}
# Section "f": file description
set
('
f/FormatVersion
',
'
4.3
');
set
('
f/LanguageEncoding:s
',
'
ISOLatin1
');
set
('
f/LanguageVersion:s
',
'
English
');
mand
('
f/FileVersion
');
mand
('
f/PCFileName
');
# Section "p": product description
mand
('
p/Manufacturer
');
mand
('
p/ModelName
');
mand
('
p/NickName
');
mand
('
p/ShortNickName
');
mand
('
p/Product
');
mand
('
p/PSVersion
');
# Section "d": device capabilities
set
('
d/ColorDevice:b
',
0
);
set
('
d/DefaultColorSpace:q
',
'
Gray
');
set
('
d/FileSystem:b
',
0
);
sub
heading
($)
{
my
(
$h
)
=
@_
;
print
"
\n
";
print
"
%*
",
"
=
"
x
length
$h
,
"
\n
";
print
"
%*
",
$h
,
"
\n
";
print
"
%*
",
"
=
"
x
length
$h
,
"
\n
";
print
"
\n
";
}
sub
emit
($)
{
my
(
$section
)
=
@_
;
my
$opts
=
$options
{
$section
};
for
my
$k
(
sort
keys
%$opts
)
{
my
$v
=
$opts
->
{
$k
};
if
(
!
$v
)
{
print
STDERR
"
ERROR: Value of mandatory option
$k
is missing
\n
";
}
else
{
print
"
*
$k
:
",
format_value
(
$v
->
{'
type
'},
$v
->
{'
value
'}),
"
\n
";
}
}
}
sub
fill_missing
()
{
my
$model
=
get
('
p/ModelName
');
if
(
defined
$model
)
{
maybe_set
('
p/Product
',
"
(
$model
)
");
maybe_set
('
p/NickName
',
$model
);
maybe_set
('
p/ShortNickName
',
$model
);
}
my
$psver
=
get
('
p/PSVersion
');
if
(
defined
(
$psver
)
&&
$psver
=~
/\((\d)/
)
{
maybe_set
('
d/LanguageLevel
',
$
1
);
}
}
sub
generate
()
{
print
"
*PPD-Adobe:
",
get
('
f/FormatVersion
'),
"
\n
";
print
"
*% PPD file generated by UCW PPD generator
\n
";
fill_missing
();
heading
("
File version
");
emit
('
f
');
heading
("
Product information
");
emit
('
p
');
heading
("
Device capabilities
");
emit
('
d
');
}
42
;
This diff is collapsed.
Click to expand it.
ppd/gen-hp
0 → 100755
+
21
−
0
View file @
93e36c25
#!/usr/bin/perl
use
strict
;
use
warnings
;
use
lib
"
.
";
use
PPD
;
set
('
f/FileVersion
',
'
1.0
');
set
('
f/PCFileName
',
'
HP4350.PPD
');
set
('
p/Manufacturer
',
'
HP
');
set
('
p/ModelName
',
'
HP LaserJet 4350
');
set
('
p/PSVersion
',
'
(3010.107) 0
');
set
('
d/Throughput
',
35
);
set
('
d/TTRasterizer:s
',
'
Type42
');
set
('
d/VariablePaperSize:b
',
1
);
set
('
d/Protocols:b
',
'
PJL TBCP
');
generate
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment