IPP.pm

filter: Statementstmt 98.8% 88 / 89 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 95.2% 20 / 21 Podpod 0.0% 0 / 1 totaltotal 97.3% 112 / 115 CC 5 SCAR 4.5
CC
5
Cov
99%
BEGIN
4.0
registerConstants
2.0
__ANON__
1.1
CRAP 1.6
« IPPMethods.pm ↑ Summary
1 ###
2 # Copyright (c) 2004 Matthias Hilbig <bighil@cpan.org>
3 # All rights reserved.
4 #
5 # This program is free software; you may redistribute it and/or modify it
6 # under the same terms as Perl itself.
7 #
8  
9 package Net::IPP::IPP;
10  
11 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 require Exporter;
15 2 our @ISA = ("Exporter");
16  
17 2 our @EXPORT_OK;
18 2 our %EXPORT_TAGS;
19  
20 2 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=13.9
21
22 ###
23 # register constants
24 # (modified standard perl constant.pm without all the checking)
25 #
26 14 ▶sub registerConstants($$) {
Subroutine registerConstants: called CC=2 SCAR=6.9
Pod undocumented
27 14 my $tableref = shift;
28 14 my %constants = %{+shift};
29  
30 14 foreach my $name ( keys %constants ) {
31 258 my $pkg = caller;
32  
33 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 258 my $full_name = "${pkg}::$name";
35  
36 258 my $scalar = $constants{$name};
37 0 ▶ *$full_name = sub () { $scalar };
Subroutine __ANON__: not called CC=1 SCAR=1.2
38  
39 258 $tableref->{$scalar} = $name;
40 }
41 }
42  
43 # print debug messages
44 2 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 # constants used in IPP request hash as keys
47 # (let no IPP attribute collide with these names)
48 2 ▶use constant URL => "__url__";
Subroutine BEGIN: called CC=1 SCAR=0.0
49 2 ▶use constant OPERATION => "__operation__";
Subroutine BEGIN: called CC=1 SCAR=0.0
50 2 ▶use constant STATUS => "__status__";
Subroutine BEGIN: called CC=1 SCAR=0.0
51 2 ▶use constant REQUEST_ID => "__request-id__";
Subroutine BEGIN: called CC=1 SCAR=0.0
52 2 ▶use constant GROUPS => "__groups__";
Subroutine BEGIN: called CC=1 SCAR=0.0
53 2 ▶use constant TYPE => "__type__";
Subroutine BEGIN: called CC=1 SCAR=0.0
54 2 ▶use constant VALUE => "__value__";
Subroutine BEGIN: called CC=1 SCAR=0.0
55 2 ▶use constant DATA => "__data__";
Subroutine BEGIN: called CC=1 SCAR=0.0
56 2 ▶use constant VERSION => "__version__";
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 ▶use constant HP_BUGFIX => "__hp-bugfix__";
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 ▶use constant HTTP_CODE => "__http-code__";
Subroutine BEGIN: called CC=1 SCAR=0.0
59 2 ▶use constant HTTP_MESSAGE => "__http-message__";
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 # IPP Version
62 2 ▶use constant IPP_MAJOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 2 ▶use constant IPP_MINOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 # IPP Types
66  
67 2 our %type;
68 2 registerConstants(\%type, {
69 DELETE_ATTRIBUTE => 0x16,
70 INTEGER => 0x21,
71 BOOLEAN => 0x22,
72 ENUM => 0x23,
73 OCTET_STRING => 0x30,
74 DATE_TIME => 0x31,
75 RESOLUTION => 0x32,
76 RANGE_OF_INTEGER => 0x33,
77 BEG_COLLECTION => 0x34,
78 TEXT_WITH_LANGUAGE => 0x35,
79 NAME_WITH_LANGUAGE => 0x36,
80 END_COLLECTION => 0x37,
81 TEXT_WITHOUT_LANGUAGE => 0x41,
82 NAME_WITHOUT_LANGUAGE => 0x42,
83 KEYWORD => 0x44,
84 URI => 0x45,
85 URI_SCHEME => 0x46,
86 CHARSET => 0x47,
87 NATURAL_LANGUAGE => 0x48,
88 MIME_MEDIA_TYPE => 0x49,
89 MEMBER_ATTR_NAME => 0x4A,
90 });
91  
92 # IPP Group tags
93  
94 2 our %group;
95 2 registerConstants(\%group, {
96 OPERATION_ATTRIBUTES => 0x01,
97 JOB_ATTRIBUTES => 0x02,
98 END_OF_ATTRIBUTES => 0x03,
99 PRINTER_ATTRIBUTES => 0x04,
100 UNSUPPORTED_ATTRIBUTES => 0x05,
101 SUBSCRIPTION_ATTRIBUTES => 0x06,
102 EVENT_NOTIFICATION_ATTRIBUTES => 0x07
103 });
104  
105 # IPP Operations
106  
107 2 our %operation;
108 2 registerConstants(\%operation, {
109 IPP_PRINT_JOB => 0x0002,
110 IPP_PRINT_URI => 0x0003,
111 IPP_VALIDATE_JOB => 0x0004,
112 IPP_CREATE_JOB => 0x0005,
113 IPP_SEND_DOCUMENT => 0x0006,
114 IPP_SEND_URI => 0x0007,
115 IPP_CANCEL_JOB => 0x0008,
116 IPP_GET_JOB_ATTRIBUTES => 0x0009,
117 IPP_GET_JOBS => 0x000a,
118 IPP_GET_PRINTER_ATTRIBUTES => 0x000b,
119 IPP_HOLD_JOB => 0x000c,
120 IPP_RELEASE_JOB => 0x000d,
121 IPP_RESTART_JOB => 0x000e,
122  
123 IPP_PAUSE_PRINTER => 0x0010,
124 IPP_RESUME_PRINTER => 0x0011,
125 IPP_PURGE_JOBS => 0x0012,
126 IPP_SET_PRINTER_ATTRIBUTES => 0x0013,
127 IPP_SET_JOB_ATTRIBUTES => 0x0014,
128 IPP_GET_PRINTER_SUPPORTED_VALUES => 0x0015,
129 IPP_CREATE_PRINTER_SUBSCRIPTION => 0x0016,
130 IPP_CREATE_JOB_SUBSCRIPTION => 0x0017,
131 IPP_GET_SUBSCRIPTION_ATTRIBUTES => 0x0018,
132 IPP_GET_SUBSCRIPTIONS => 0x0019,
133 IPP_RENEW_SUBSCRIPTION => 0x001a,
134 IPP_CANCEL_SUBSCRIPTION => 0x001b,
135 IPP_GET_NOTIFICATIONS => 0x001c,
136 IPP_SEND_NOTIFICATIONS => 0x001d,
137  
138 IPP_GET_PRINT_SUPPORT_FILES => 0x0021,
139 IPP_ENABLE_PRINTER => 0x0022,
140 IPP_DISABLE_PRINTER => 0x0023,
141 IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB => 0x0024,
142 IPP_HOLD_NEW_JOBS => 0x0025,
143 IPP_RELEASE_HELD_NEW_JOBS => 0x0026,
144 IPP_DEACTIVATE_PRINTER => 0x0027,
145 IPP_ACTIVATE_PRINTER => 0x0028,
146 IPP_RESTART_PRINTER => 0x0029,
147 IPP_SHUTDOWN_PRINTER => 0x002a,
148 IPP_STARTUP_PRINTER => 0x002b,
149 IPP_REPROCESS_JOB => 0x002c,
150 IPP_CANCEL_CURRENT_JOB => 0x002d,
151 IPP_SUSPEND_CURRENT_JOB => 0x002e,
152 IPP_RESUME_JOB => 0x002f,
153 IPP_PROMOTE_JOB => 0x0030,
154 IPP_SCHEDULE_JOB_AFTER => 0x0031,
155  
156 # IPP private Operations start at 0x4000
157 CUPS_GET_DEFAULT => 0x4001,
158 CUPS_GET_PRINTERS => 0x4002,
159 CUPS_ADD_PRINTER => 0x4003,
160 CUPS_DELETE_PRINTER => 0x4004,
161 CUPS_GET_CLASSES => 0x4005,
162 CUPS_ADD_CLASS => 0x4006,
163 CUPS_DELETE_CLASS => 0x4007,
164 CUPS_ACCEPT_JOBS => 0x4008,
165 CUPS_REJECT_JOBS => 0x4009,
166 CUPS_SET_DEFAULT => 0x400a,
167 CUPS_GET_DEVICES => 0x400b,
168 CUPS_GET_PPDS => 0x400c,
169 CUPS_MOVE_JOB => 0x400d,
170 CUPS_ADD_DEVICE => 0x400e,
171 CUPS_DELETE_DEVICE => 0x400f,
172 });
173  
174 # Finishings
175  
176 2 our %finishing;
177 2 registerConstants(\%finishing, {
178 FINISHINGS_NONE => 3,
179 FINISHINGS_STAPLE => 4,
180 FINISHINGS_PUNCH => 5,
181 FINISHINGS_COVER => 6,
182 FINISHINGS_BIND => 7,
183 FINISHINGS_SADDLE_STITCH => 8,
184 FINISHINGS_EDGE_STITCH => 9,
185 FINISHINGS_FOLD => 10,
186 FINISHINGS_TRIM => 11,
187 FINISHINGS_BALE => 12,
188 FINISHINGS_BOOKLET_MAKER => 13,
189 FINISHINGS_JOB_OFFSET => 14,
190 FINISHINGS_STAPLE_TOP_LEFT => 20,
191 FINISHINGS_STAPLE_BOTTOM_LEFT => 21,
192 FINISHINGS_STAPLE_TOP_RIGHT => 22,
193 FINISHINGS_STAPLE_BOTTOM_RIGHT => 23,
194 FINISHINGS_EDGE_STITCH_LEFT => 24,
195 FINISHINGS_EDGE_STITCH_TOP => 25,
196 FINISHINGS_EDGE_STITCH_RIGHT => 26,
197 FINISHINGS_EDGE_STITCH_BOTTOM => 27,
198 FINISHINGS_STAPLE_DUAL_LEFT => 28,
199 FINISHINGS_STAPLE_DUAL_TOP => 29,
200 FINISHINGS_STAPLE_DUAL_RIGHT => 30,
201 FINISHINGS_STAPLE_DUAL_BOTTOM => 31,
202 FINISHINGS_BIND_LEFT => 50,
203 FINISHINGS_BIND_TOP => 51,
204 FINISHINGS_BIND_RIGHT => 52,
205 FINISHINGS_BIND_BOTTOM => 53,
206 });
207  
208 # IPP Printer state
209  
210 2 our %printerState;
211 2 registerConstants(\%printerState, {
212 STATE_IDLE=>3,
213 STATE_PROCESSING => 4,
214 STATE_STOPPED => 5,
215 });
216  
217 # Job state
218  
219 2 our %jobState;
220 2 registerConstants(\%jobState, {
221 JOBSTATE_PENDING => 3,
222 JOBSTATE_PENDING_HELD => 4,
223 JOBSTATE_PROCESSING => 5,
224 JOBSTATE_PROCESSING_STOPPED => 6,
225 JOBSTATE_CANCELED => 7,
226 JOBSTATE_ABORTED => 8,
227 JOBSTATE_COMPLETED => 9,
228 });
229  
230 # Orientations
231  
232 2 our %orientation;
233 2 registerConstants(\%orientation, {
234 ORIENTATION_PORTRAIT => 3, # no rotation
235 ORIENTATION_LANDSCAPE => 4, # 90 degrees counter-clockwise
236 ORIENTATION_REVERSE_LANDSCAPE => 5, # 90 degrees clockwise
237 ORIENTATION_REVERSE_PORTRAIT => 6, # 180 degrees
238 });
239  
240 2 our %statusCodes = (
241 0x0000 => "successful-ok",
242 0x0001 => "successful-ok-ignored-or-substituted-attributes",
243 0x0002 => "successful-ok-conflicting-attributes",
244 0x0003 => "successful-ok-ignored-subscriptions",
245 0x0004 => "successful-ok-ignored-notifications",
246 0x0005 => "successful-ok-too-many-events",
247 0x0006 => "successful-ok-but-cancel-subscription",
248 # Client errors
249 0x0400 => "client-error-bad-request",
250 0x0401 => "client-error-forbidden",
251 0x0402 => "client-error-not-authenticated",
252 0x0403 => "client-error-not-authorized",
253 0x0404 => "client-error-not-possible",
254 0x0405 => "client-error-timeout",
255 0x0406 => "client-error-not-found",
256 0x0407 => "client-error-gone",
257 0x0408 => "client-error-request-entity-too-large",
258 0x0409 => "client-error-request-value-too-long",
259 0x040a => "client-error-document-format-not-supported",
260 0x040b => "client-error-attributes-or-values-not-supported",
261 0x040c => "client-error-uri-scheme-not-supported",
262 0x040d => "client-error-charset-not-supported",
263 0x040e => "client-error-conflicting-attributes",
264 0x040f => "client-error-compression-not-supported",
265 0x0410 => "client-error-compression-error",
266 0x0411 => "client-error-document-format-error",
267 0x0412 => "client-error-document-access-error",
268 0x0413 => "client-error-attributes-not-settable",
269 0x0414 => "client-error-ignored-all-subscriptions",
270 0x0415 => "client-error-too-many-subscriptions",
271 0x0416 => "client-error-ignored-all-notifications",
272 0x0417 => "client-error-print-support-file-not-found",
273 #Server errors
274 0x0500 => "server-error-internal-error",
275 0x0501 => "server-error-operation-not-supported",
276 0x0502 => "server-error-service-unavailable",
277 0x0503 => "server-error-version-not-supported",
278 0x0504 => "server-error-device-error",
279 0x0505 => "server-error-temporary-error",
280 0x0506 => "server-error-not-accepting-jobs",
281 0x0507 => "server-error-busy",
282 0x0508 => "server-error-job-canceled",
283 0x0509 => "server-error-multiple-document-jobs-not-supported",
284 0x050a => "server-error-printer-is-deactivated"
285 );
286  
287 #
288 # All constants are subroutines, so
289 # export all subroutines, except "registerConstants"
290 #
291 2 foreach my $keyname (keys %{Net::IPP::IPP::}) {
292 318 ▶ if ($keyname ne "registerConstants") {
Branch: 1 branch
BranchTrueFalseTotal
if ($keyname ne "registerConstants") 316 2 318
293 316 local *key = ${Net::IPP::IPP::}{$keyname};
294 316 ▶ push (@EXPORT_OK, $keyname) if *key{CODE};
Branch: 1 branch
BranchTrueFalseTotal
if *key{"CODE"} 258 58 316
295 }
296 }
297  
298 2 %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
299 }
300  
301 2 1;
302 __END__
« IPPMethods.pm ↑ Summary