Coverage Report

Created: 2025-12-11 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libcups/cups/ipp-support.c
Line
Count
Source
1
//
2
// Internet Printing Protocol support functions for CUPS.
3
//
4
// Copyright © 2022-2025 by OpenPrinting.
5
// Copyright © 2007-2018 by Apple Inc.
6
// Copyright © 1997-2007 by Easy Software Products, all rights reserved.
7
//
8
// Licensed under Apache License v2.0.  See the file "LICENSE" for more
9
// information.
10
//
11
12
#include "cups-private.h"
13
14
15
//
16
// Local globals...
17
//
18
19
static const char * const ipp_states[] =// ipp_state_t strings
20
{
21
  "IPP_STATE_ERROR",
22
  "IPP_STATE_IDLE",
23
  "IPP_STATE_HEADER",
24
  "IPP_STATE_ATTRIBUTE",
25
  "IPP_STATE_DATA"
26
};
27
static const char * const ipp_status_oks[] =
28
{         // "OK" status codes; (name) = abandoned
29
  "successful-ok",
30
  "successful-ok-ignored-or-substituted-attributes",
31
  "successful-ok-conflicting-attributes",
32
  "successful-ok-ignored-subscriptions",
33
  "(successful-ok-ignored-notifications)",
34
  "successful-ok-too-many-events",
35
  "(successful-ok-but-cancel-subscription)",
36
  "successful-ok-events-complete"
37
};
38
static const char * const ipp_status_400s[] =
39
{         // Client errors; (name) = abandoned
40
  "client-error-bad-request",
41
  "client-error-forbidden",
42
  "client-error-not-authenticated",
43
  "client-error-not-authorized",
44
  "client-error-not-possible",
45
  "client-error-timeout",
46
  "client-error-not-found",
47
  "client-error-gone",
48
  "client-error-request-entity-too-large",
49
  "client-error-request-value-too-long",
50
  "client-error-document-format-not-supported",
51
  "client-error-attributes-or-values-not-supported",
52
  "client-error-uri-scheme-not-supported",
53
  "client-error-charset-not-supported",
54
  "client-error-conflicting-attributes",
55
  "client-error-compression-not-supported",
56
  "client-error-compression-error",
57
  "client-error-document-format-error",
58
  "client-error-document-access-error",
59
  "client-error-attributes-not-settable",
60
  "client-error-ignored-all-subscriptions",
61
  "client-error-too-many-subscriptions",
62
  "(client-error-ignored-all-notifications)",
63
  "(client-error-client-print-support-file-not-found)",
64
  "client-error-document-password-error",
65
  "client-error-document-permission-error",
66
  "client-error-document-security-error",
67
  "client-error-document-unprintable-error",
68
  "client-error-account-info-needed",
69
  "client-error-account-closed",
70
  "client-error-account-limit-reached",
71
  "client-error-account-authorization-failed",
72
  "client-error-not-fetchable"
73
};
74
static const char * const ipp_status_500s[] =
75
{         // Server errors
76
  "server-error-internal-error",
77
  "server-error-operation-not-supported",
78
  "server-error-service-unavailable",
79
  "server-error-version-not-supported",
80
  "server-error-device-error",
81
  "server-error-temporary-error",
82
  "server-error-not-accepting-jobs",
83
  "server-error-busy",
84
  "server-error-job-canceled",
85
  "server-error-multiple-document-jobs-not-supported",
86
  "server-error-printer-is-deactivated",
87
  "server-error-too-many-jobs",
88
  "server-error-too-many-documents"
89
};
90
static const char * const ipp_status_1000s[] =
91
{         // CUPS internal errors
92
  "cups-authentication-canceled",
93
  "cups-pki-error",
94
  "cups-upgrade-required",
95
  "cups-oauth"
96
};
97
static const char * const ipp_std_ops[] =
98
{
99
  // 0x0000 - 0x000f
100
  "0x0000",
101
  "0x0001",
102
  "Print-Job",        // RFC 8011
103
  "Print-URI",        // RFC 8011
104
  "Validate-Job",     // RFC 8011
105
  "Create-Job",       // RFC 8011
106
  "Send-Document",      // RFC 8011
107
  "Send-URI",       // RFC 8011
108
  "Cancel-Job",       // RFC 8011
109
  "Get-Job-Attributes",     // RFC 8011
110
  "Get-Jobs",       // RFC 8011
111
  "Get-Printer-Attributes",   // RFC 8011
112
  "Hold-Job",       // RFC 8011
113
  "Release-Job",      // RFC 8011
114
  "Restart-Job",      // RFC 8011
115
  "0x000f",
116
117
  // 0x0010 - 0x001f
118
  "Pause-Printer",      // RFC 8011
119
  "Resume-Printer",     // RFC 8011
120
  "Purge-Jobs",       // RFC 8011
121
  "Set-Printer-Attributes",   // RFC 3380
122
  "Set-Job-Attributes",     // RFC 3380
123
  "Get-Printer-Supported-Values", // RFC 3380
124
  "Create-Printer-Subscriptions", // RFC 3995
125
  "Create-Job-Subscriptions",   // RFC 3995
126
  "Get-Subscription-Attributes",  // RFC 3995
127
  "Get-Subscriptions",      // RFC 3995
128
  "Renew-Subscription",     // RFC 3995
129
  "Cancel-Subscription",    // RFC 3995
130
  "Get-Notifications",      // RFC 3996
131
  "(Send-Notifications)",
132
  "Get-Resource-Attributes",    // IPP System
133
  "(Get-Resource-Data)",
134
135
  // 0x0020 - 0x002f
136
  "Get-Resources",      // IPP System
137
  "(Get-Printer-Support-Files)",
138
  "Enable-Printer",     // RFC 3998
139
  "Disable-Printer",      // RFC 3998
140
  "Pause-Printer-After-Current-Job",  // RFC 3998
141
  "Hold-New-Jobs",      // RFC 3998
142
  "Release-Held-New-Jobs",    // RFC 3998
143
  "Deactivate-Printer",     // RFC 3998
144
  "Activate-Printer",     // RFC 3998
145
  "Restart-Printer",      // RFC 3998
146
  "Shutdown-Printer",     // RFC 3998
147
  "Startup-Printer",      // RFC 3998
148
  "Reprocess-Job",      // RFC 3998
149
  "Cancel-Current-Job",     // RFC 3998
150
  "Suspend-Current-Job",    // RFC 3998
151
  "Resume-Job",       // RFC 3998
152
153
  // 0x0030 - 0x003f
154
  "Promote-Job",      // RFC 3998
155
  "Schedule-Job-After",     // RFC 3998
156
  "0x0032",
157
  "Cancel-Document",      // IPP DocObject
158
  "Get-Document-Attributes",    // IPP DocObject
159
  "Get-Documents",      // IPP DocObject
160
  "Delete-Document",      // IPP DocObject
161
  "Set-Document-Attributes",    // IPP DocObject
162
  "Cancel-Jobs",      // IPP JobExt
163
  "Cancel-My-Jobs",     // IPP JobExt
164
  "Resubmit-Job",     // IPP JobExt
165
  "Close-Job",        // IPP JobExt
166
  "Identify-Printer",     // IPP NODRIVER
167
  "Validate-Document",      // IPP NODRIVER
168
  "Add-Document-Images",    // IPP Scan
169
  "Acknowledge-Document",   // IPP INFRA
170
171
  // 0x0040 - 0x004f
172
  "Acknowledge-Identify-Printer", // IPP INFRA
173
  "Acknowledge-Job",      // IPP INFRA
174
  "Fetch-Document",     // IPP INFRA
175
  "Fetch-Job",        // IPP INFRA
176
  "Get-Output-Device-Attributes", // IPP INFRA
177
  "Update-Active-Jobs",     // IPP INFRA
178
  "Deregister-Output-Device",   // IPP INFRA
179
  "Update-Document-Status",   // IPP INFRA
180
  "Update-Job-Status",      // IPP INFRA
181
  "Update-Output-Device-Attributes",  // IPP INFRA
182
  "Get-Next-Document-Data",   // IPP Scan
183
  "Allocate-Printer-Resources",   // IPP System
184
  "Create-Printer",     // IPP System
185
  "Deallocate-Printer-Resources", // IPP System
186
  "Delete-Printer",     // IPP System
187
  "Get-Printers",     // IPP System
188
189
  // 0x0050 - 0x005f
190
  "Shutdown-One-Printer",   // IPP System
191
  "Startup-One-Printer",    // IPP System
192
  "Cancel-Resource",      // IPP System
193
  "Create-Resource",      // IPP System
194
  "Install-Resource",     // IPP System
195
  "Send-Resource-Data",     // IPP System
196
  "Set-Resource-Attributes",    // IPP System
197
  "Create-Resource-Subscriptions",  // IPP System
198
  "Create-System-Subscriptions",  // IPP System
199
  "Disable-All-Printers",   // IPP System
200
  "Enable-All-Printers",    // IPP System
201
  "Get-System-Attributes",    // IPP System
202
  "Get-System-Supported-Values",  // IPP System
203
  "Pause-All-Printers",     // IPP System
204
  "Pause-All-Printers-After-Current-Job",
205
          // IPP System
206
  "Register-Output-Device",   // IPP System
207
208
  // 0x0060 - 0x006a
209
  "Restart-System",     // IPP System
210
  "Resume-All-Printers",    // IPP System
211
  "Set-System-Attributes",    // IPP System
212
  "Shutdown-All-Printers",    // IPP System
213
  "Startup-All-Printers",   // IPP System
214
  "Get-Printer-Resources",    // IPP System
215
  "Get-User-Printer-Attributes",  // IPP EPX
216
  "Restart-One-Printer",    // IPP System
217
  "Acknowledge-Encrypted-Job-Attributes",
218
          // IPP TRUSTNOONE
219
  "Fetch-Encrypted-Job-Attributes", // IPP TRUSTNOONE
220
  "Get-Encrypted-Job-Attributes"  // IPP TRUSTNOONE
221
};
222
static const char * const ipp_cups_ops[] =
223
{
224
  "CUPS-Get-Default",
225
  "CUPS-Get-Printers",
226
  "CUPS-Add-Modify-Printer",
227
  "CUPS-Delete-Printer",
228
  "CUPS-Get-Classes",
229
  "CUPS-Add-Modify-Class",
230
  "CUPS-Delete-Class",
231
  "CUPS-Accept-Jobs",
232
  "CUPS-Reject-Jobs",
233
  "CUPS-Set-Default",
234
  "CUPS-Get-Devices",
235
  "CUPS-Get-PPDs",
236
  "CUPS-Move-Job",
237
  "CUPS-Authenticate-Job",
238
  "CUPS-Get-PPD"
239
};
240
static const char * const ipp_cups_ops2[] =
241
{
242
  "CUPS-Get-Document",
243
  "CUPS-Create-Local-Printer"
244
};
245
static const char * const ipp_tag_names[] =
246
{         // Value/group tag names
247
  "zero",       // 0x00
248
  "operation-attributes-tag",   // 0x01
249
  "job-attributes-tag",     // 0x02
250
  "end-of-attributes-tag",    // 0x03
251
  "printer-attributes-tag",   // 0x04
252
  "unsupported-attributes-tag",   // 0x05
253
  "subscription-attributes-tag",  // 0x06 - RFC 3995
254
  "event-notification-attributes-tag",  // 0x07 - RFC 3995
255
  "resource-attributes-tag",    // 0x08 - IPP System
256
  "document-attributes-tag",    // 0x09 - IPP DocObject
257
  "system-attributes-tag",    // 0x0a - IPP System
258
  "0x0b",       // 0x0b
259
  "0x0c",       // 0x0c
260
  "0x0d",       // 0x0d
261
  "0x0e",       // 0x0e
262
  "0x0f",       // 0x0f
263
  "unsupported",      // 0x10
264
  "default",        // 0x11
265
  "unknown",        // 0x12
266
  "no-value",       // 0x13
267
  "0x14",       // 0x14
268
  "not-settable",     // 0x15 - RFC 3380
269
  "delete-attribute",     // 0x16 - RFC 3380
270
  "admin-define",     // 0x17 - RFC 3380
271
  "0x18",       // 0x18
272
  "0x19",       // 0x19
273
  "0x1a",       // 0x1a
274
  "0x1b",       // 0x1b
275
  "0x1c",       // 0x1c
276
  "0x1d",       // 0x1d
277
  "0x1e",       // 0x1e
278
  "0x1f",       // 0x1f
279
  "0x20",       // 0x20
280
  "integer",        // 0x21
281
  "boolean",        // 0x22
282
  "enum",       // 0x23
283
  "0x24",       // 0x24
284
  "0x25",       // 0x25
285
  "0x26",       // 0x26
286
  "0x27",       // 0x27
287
  "0x28",       // 0x28
288
  "0x29",       // 0x29
289
  "0x2a",       // 0x2a
290
  "0x2b",       // 0x2b
291
  "0x2c",       // 0x2c
292
  "0x2d",       // 0x2d
293
  "0x2e",       // 0x2e
294
  "0x2f",       // 0x2f
295
  "octetString",      // 0x30
296
  "dateTime",       // 0x31
297
  "resolution",       // 0x32
298
  "rangeOfInteger",     // 0x33
299
  "collection",       // 0x34
300
  "textWithLanguage",     // 0x35
301
  "nameWithLanguage",     // 0x36
302
  "endCollection",      // 0x37
303
  "0x38",       // 0x38
304
  "0x39",       // 0x39
305
  "0x3a",       // 0x3a
306
  "0x3b",       // 0x3b
307
  "0x3c",       // 0x3c
308
  "0x3d",       // 0x3d
309
  "0x3e",       // 0x3e
310
  "0x3f",       // 0x3f
311
  "0x40",       // 0x40
312
  "textWithoutLanguage",    // 0x41
313
  "nameWithoutLanguage",    // 0x42
314
  "0x43",       // 0x43
315
  "keyword",        // 0x44
316
  "uri",        // 0x45
317
  "uriScheme",        // 0x46
318
  "charset",        // 0x47
319
  "naturalLanguage",      // 0x48
320
  "mimeMediaType",      // 0x49
321
  "memberAttrName"      // 0x4a
322
};
323
static const char * const ipp_document_states[] =
324
{         // document-state-enums
325
  "pending",
326
  "4",
327
  "processing",
328
  "processing-stopped",     // IPP INFRA
329
  "canceled",
330
  "aborted",
331
  "completed"
332
};
333
static const char * const ipp_finishings[] =
334
{         // finishings enums
335
  "none",
336
  "staple",
337
  "punch",
338
  "cover",
339
  "bind",
340
  "saddle-stitch",
341
  "edge-stitch",
342
  "fold",
343
  "trim",
344
  "bale",
345
  "booklet-maker",
346
  "jog-offset",
347
  "coat",       // IPP FIN
348
  "laminate",       // IPP FIN
349
  "17",
350
  "18",
351
  "19",
352
  "staple-top-left",      // IPP FIN
353
  "staple-bottom-left",     // IPP FIN
354
  "staple-top-right",     // IPP FIN
355
  "staple-bottom-right",    // IPP FIN
356
  "edge-stitch-left",     // IPP FIN
357
  "edge-stitch-top",      // IPP FIN
358
  "edge-stitch-right",      // IPP FIN
359
  "edge-stitch-bottom",     // IPP FIN
360
  "staple-dual-left",     // IPP FIN
361
  "staple-dual-top",      // IPP FIN
362
  "staple-dual-right",      // IPP FIN
363
  "staple-dual-bottom",     // IPP FIN
364
  "staple-triple-left",     // IPP FIN
365
  "staple-triple-top",      // IPP FIN
366
  "staple-triple-right",    // IPP FIN
367
  "staple-triple-bottom",   // IPP FIN
368
  "36",
369
  "37",
370
  "38",
371
  "39",
372
  "40",
373
  "41",
374
  "42",
375
  "43",
376
  "44",
377
  "45",
378
  "46",
379
  "47",
380
  "48",
381
  "49",
382
  "bind-left",        // IPP FIN
383
  "bind-top",       // IPP FIN
384
  "bind-right",       // IPP FIN
385
  "bind-bottom",      // IPP FIN
386
  "54",
387
  "55",
388
  "56",
389
  "57",
390
  "58",
391
  "59",
392
  "trim-after-pages",     // IPP FIN
393
  "trim-after-documents",   // IPP FIN
394
  "trim-after-copies",      // IPP FIN
395
  "trim-after-job",     // IPP FIN
396
  "64",
397
  "65",
398
  "66",
399
  "67",
400
  "68",
401
  "69",
402
  "punch-top-left",     // IPP FIN
403
  "punch-bottom-left",      // IPP FIN
404
  "punch-top-right",      // IPP FIN
405
  "punch-bottom-right",     // IPP FIN
406
  "punch-dual-left",      // IPP FIN
407
  "punch-dual-top",     // IPP FIN
408
  "punch-dual-right",     // IPP FIN
409
  "punch-dual-bottom",      // IPP FIN
410
  "punch-triple-left",      // IPP FIN
411
  "punch-triple-top",     // IPP FIN
412
  "punch-triple-right",     // IPP FIN
413
  "punch-triple-bottom",    // IPP FIN
414
  "punch-quad-left",      // IPP FIN
415
  "punch-quad-top",     // IPP FIN
416
  "punch-quad-right",     // IPP FIN
417
  "punch-quad-bottom",      // IPP FIN
418
  "punch-multiple-left",    // IPP FIN
419
  "punch-multiple-top",     // IPP FIN
420
  "punch-multiple-right",   // IPP FIN
421
  "punch-multiple-bottom",    // IPP FIN
422
  "fold-accordion",     // IPP FIN
423
  "fold-double-gate",     // IPP FIN
424
  "fold-gate",        // IPP FIN
425
  "fold-half",        // IPP FIN
426
  "fold-half-z",      // IPP FIN
427
  "fold-left-gate",     // IPP FIN
428
  "fold-letter",      // IPP FIN
429
  "fold-parallel",      // IPP FIN
430
  "fold-poster",      // IPP FIN
431
  "fold-right-gate",      // IPP FIN
432
  "fold-z",       // IPP FIN
433
  "fold-engineering-z"      // IPP FIN
434
};
435
static const char * const ipp_finishings_vendor[] =
436
{
437
  // 0x40000000 to 0x4000000F
438
  "0x40000000",
439
  "0x40000001",
440
  "0x40000002",
441
  "0x40000003",
442
  "0x40000004",
443
  "0x40000005",
444
  "0x40000006",
445
  "0x40000007",
446
  "0x40000008",
447
  "0x40000009",
448
  "0x4000000A",
449
  "0x4000000B",
450
  "0x4000000C",
451
  "0x4000000D",
452
  "0x4000000E",
453
  "0x4000000F",
454
  // 0x40000010 to 0x4000001F
455
  "0x40000010",
456
  "0x40000011",
457
  "0x40000012",
458
  "0x40000013",
459
  "0x40000014",
460
  "0x40000015",
461
  "0x40000016",
462
  "0x40000017",
463
  "0x40000018",
464
  "0x40000019",
465
  "0x4000001A",
466
  "0x4000001B",
467
  "0x4000001C",
468
  "0x4000001D",
469
  "0x4000001E",
470
  "0x4000001F",
471
  // 0x40000020 to 0x4000002F
472
  "0x40000020",
473
  "0x40000021",
474
  "0x40000022",
475
  "0x40000023",
476
  "0x40000024",
477
  "0x40000025",
478
  "0x40000026",
479
  "0x40000027",
480
  "0x40000028",
481
  "0x40000029",
482
  "0x4000002A",
483
  "0x4000002B",
484
  "0x4000002C",
485
  "0x4000002D",
486
  "0x4000002E",
487
  "0x4000002F",
488
  // 0x40000030 to 0x4000003F
489
  "0x40000030",
490
  "0x40000031",
491
  "0x40000032",
492
  "0x40000033",
493
  "0x40000034",
494
  "0x40000035",
495
  "0x40000036",
496
  "0x40000037",
497
  "0x40000038",
498
  "0x40000039",
499
  "0x4000003A",
500
  "0x4000003B",
501
  "0x4000003C",
502
  "0x4000003D",
503
  "0x4000003E",
504
  "0x4000003F",
505
  // 0x40000040 - 0x4000004F
506
  "0x40000040",
507
  "0x40000041",
508
  "0x40000042",
509
  "0x40000043",
510
  "0x40000044",
511
  "0x40000045",
512
  "cups-punch-top-left",    // AirPrint
513
  "cups-punch-bottom-left",   // AirPrint
514
  "cups-punch-top-right",   // AirPrint
515
  "cups-punch-bottom-right",    // AirPrint
516
  "cups-punch-dual-left",   // AirPrint
517
  "cups-punch-dual-top",    // AirPrint
518
  "cups-punch-dual-right",    // AirPrint
519
  "cups-punch-dual-bottom",   // AirPrint
520
  "cups-punch-triple-left",   // AirPrint
521
  "cups-punch-triple-top",    // AirPrint
522
  // 0x40000050 - 0x4000005F
523
  "cups-punch-triple-right",    // AirPrint
524
  "cups-punch-triple-bottom",   // AirPrint
525
  "cups-punch-quad-left",   // AirPrint
526
  "cups-punch-quad-top",    // AirPrint
527
  "cups-punch-quad-right",    // AirPrint
528
  "cups-punch-quad-bottom",   // AirPrint
529
  "0x40000056",
530
  "0x40000057",
531
  "0x40000058",
532
  "0x40000059",
533
  "cups-fold-accordion",    // AirPrint
534
  "cups-fold-double-gate",    // AirPrint
535
  "cups-fold-gate",     // AirPrint
536
  "cups-fold-half",     // AirPrint
537
  "cups-fold-half-z",     // AirPrint
538
  "cups-fold-left-gate",    // AirPrint
539
  // 0x40000060 - 0x40000064
540
  "cups-fold-letter",     // AirPrint
541
  "cups-fold-parallel",     // AirPrint
542
  "cups-fold-poster",     // AirPrint
543
  "cups-fold-right-gate",   // AirPrint
544
  "cups-fold-z"       // AirPrint
545
};
546
static const char * const ipp_job_states[] =
547
{         // job-state enums
548
  "pending",
549
  "pending-held",
550
  "processing",
551
  "processing-stopped",
552
  "canceled",
553
  "aborted",
554
  "completed"
555
};
556
static const char * const ipp_orientation_requesteds[] =
557
{         // orientation-requested enums
558
  "portrait",
559
  "landscape",
560
  "reverse-landscape",
561
  "reverse-portrait",
562
  "none"
563
};
564
static const char * const ipp_print_qualities[] =
565
{         // print-quality enums
566
  "draft",
567
  "normal",
568
  "high"
569
};
570
static const char * const ipp_printer_states[] =
571
{         // printer-state enums
572
  "idle",
573
  "processing",
574
  "stopped"
575
};
576
static const char * const ipp_resource_states[] =
577
{         // resource-state enums
578
  "pending",
579
  "available",
580
  "installed",
581
  "canceled",
582
  "aborted"
583
};
584
static const char * const ipp_system_states[] =
585
{         // system-state enums
586
  "idle",
587
  "processing",
588
  "stopped"
589
};
590
591
592
//
593
// Local functions...
594
//
595
596
static size_t ipp_col_string(ipp_t *col, char *buffer, size_t bufsize);
597
598
599
//
600
// 'ippAttributeString()' - Convert the attribute's value to a string.
601
//
602
// This function converts an attribute's values into a string and returns the
603
// number of bytes that would be written, not including the trailing `nul`.  The
604
// buffer pointer can be NULL to get the required length, just like
605
// `(v)snprintf`.
606
//
607
608
size_t          // O - Number of bytes less `nul`
609
ippAttributeString(
610
    ipp_attribute_t *attr,    // I - Attribute
611
    char            *buffer,    // I - String buffer or `NULL`
612
    size_t          bufsize)    // I - Size of string buffer
613
0
{
614
0
  int   i;      // Looping var
615
0
  char    *bufptr,    // Pointer into buffer
616
0
    *bufend,    // End of buffer
617
0
    temp[256];    // Temporary string
618
0
  const char  *ptr,     // Pointer into string
619
0
    *end;     // Pointer to end of string
620
0
  _ipp_value_t  *val;     // Current value
621
622
623
  // Range check input...
624
0
  if (!attr || !attr->name)
625
0
  {
626
0
    if (buffer)
627
0
      *buffer = '\0';
628
629
0
    return (0);
630
0
  }
631
632
  // Setup buffer pointers...
633
0
  bufptr = buffer;
634
0
  if (buffer)
635
0
    bufend = buffer + bufsize - 1;
636
0
  else
637
0
    bufend = NULL;
638
639
  // Loop through the values...
640
0
  for (i = attr->num_values, val = attr->values; i > 0; i --, val ++)
641
0
  {
642
0
    if (val > attr->values)
643
0
    {
644
0
      if (buffer && bufptr < bufend)
645
0
        *bufptr++ = ',';
646
0
      else
647
0
        bufptr ++;
648
0
    }
649
650
0
    switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
651
0
    {
652
0
      case IPP_TAG_ENUM :
653
0
          ptr = ippEnumString(attr->name, val->integer);
654
655
0
          if (buffer && bufptr < bufend)
656
0
            cupsCopyString(bufptr, ptr, (size_t)(bufend - bufptr + 1));
657
658
0
          bufptr += strlen(ptr);
659
0
          break;
660
661
0
      case IPP_TAG_INTEGER :
662
0
          if (buffer && bufptr < bufend)
663
0
            bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d", val->integer);
664
0
          else
665
0
            bufptr += snprintf(temp, sizeof(temp), "%d", val->integer);
666
0
          break;
667
668
0
      case IPP_TAG_BOOLEAN :
669
0
          if (buffer && bufptr < bufend)
670
0
            cupsCopyString(bufptr, val->boolean ? "true" : "false", (size_t)(bufend - bufptr + 1));
671
672
0
          bufptr += val->boolean ? 4 : 5;
673
0
          break;
674
675
0
      case IPP_TAG_RANGE :
676
0
          if (buffer && bufptr < bufend)
677
0
            bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d-%d", val->range.lower, val->range.upper);
678
0
          else
679
0
            bufptr += snprintf(temp, sizeof(temp), "%d-%d", val->range.lower, val->range.upper);
680
0
          break;
681
682
0
      case IPP_TAG_RESOLUTION :
683
0
    if (val->resolution.xres == val->resolution.yres)
684
0
    {
685
0
      if (buffer && bufptr < bufend)
686
0
        bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d%s", val->resolution.xres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
687
0
      else
688
0
        bufptr += snprintf(temp, sizeof(temp), "%d%s", val->resolution.xres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
689
0
    }
690
0
    else if (buffer && bufptr < bufend)
691
0
            bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
692
0
          else
693
0
            bufptr += snprintf(temp, sizeof(temp), "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
694
0
          break;
695
696
0
      case IPP_TAG_DATE :
697
0
          {
698
0
            unsigned year;    // Year
699
700
0
            year = ((unsigned)val->date[0] << 8) | (unsigned)val->date[1];
701
702
0
      if (val->date[9] == 0 && val->date[10] == 0)
703
0
        snprintf(temp, sizeof(temp), "%04u-%02u-%02uT%02u:%02u:%02uZ",
704
0
           year, val->date[2], val->date[3], val->date[4],
705
0
           val->date[5], val->date[6]);
706
0
      else
707
0
        snprintf(temp, sizeof(temp),
708
0
                 "%04u-%02u-%02uT%02u:%02u:%02u%c%02u%02u",
709
0
           year, val->date[2], val->date[3], val->date[4],
710
0
           val->date[5], val->date[6], val->date[8], val->date[9],
711
0
           val->date[10]);
712
713
0
            if (buffer && bufptr < bufend)
714
0
              cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr + 1));
715
716
0
            bufptr += strlen(temp);
717
0
          }
718
0
          break;
719
720
0
      case IPP_TAG_TEXT :
721
0
      case IPP_TAG_NAME :
722
0
      case IPP_TAG_KEYWORD :
723
0
      case IPP_TAG_CHARSET :
724
0
      case IPP_TAG_URI :
725
0
      case IPP_TAG_URISCHEME :
726
0
      case IPP_TAG_MIMETYPE :
727
0
      case IPP_TAG_LANGUAGE :
728
0
      case IPP_TAG_TEXTLANG :
729
0
      case IPP_TAG_NAMELANG :
730
0
    if (!val->string.text)
731
0
      break;
732
733
0
          for (ptr = val->string.text; *ptr; ptr ++)
734
0
          {
735
0
            if (*ptr == '\\' || *ptr == '\"' || *ptr == '[')
736
0
            {
737
0
              if (buffer && bufptr < bufend)
738
0
                *bufptr = '\\';
739
0
              bufptr ++;
740
0
            }
741
742
0
            if (buffer && bufptr < bufend)
743
0
              *bufptr = *ptr;
744
0
            bufptr ++;
745
0
          }
746
747
0
          if (val->string.language)
748
0
          {
749
           /*
750
            * Add "[language]" to end of string...
751
            */
752
753
0
            if (buffer && bufptr < bufend)
754
0
              *bufptr = '[';
755
0
            bufptr ++;
756
757
0
            if (buffer && bufptr < bufend)
758
0
              cupsCopyString(bufptr, val->string.language, (size_t)(bufend - bufptr));
759
0
            bufptr += strlen(val->string.language);
760
761
0
            if (buffer && bufptr < bufend)
762
0
              *bufptr = ']';
763
0
            bufptr ++;
764
0
          }
765
0
          break;
766
767
0
      case IPP_TAG_BEGIN_COLLECTION :
768
0
          if (buffer && bufptr < bufend)
769
0
            bufptr += ipp_col_string(val->collection, bufptr, (size_t)(bufend - bufptr + 1));
770
0
          else
771
0
            bufptr += ipp_col_string(val->collection, NULL, 0);
772
0
          break;
773
774
0
      case IPP_TAG_STRING :
775
0
          for (ptr = val->unknown.data, end = ptr + val->unknown.length;
776
0
               ptr < end; ptr ++)
777
0
          {
778
0
            if (*ptr == '\\' || _cups_isspace(*ptr))
779
0
            {
780
0
              if (buffer && bufptr < bufend)
781
0
                *bufptr = '\\';
782
0
              bufptr ++;
783
784
0
              if (buffer && bufptr < bufend)
785
0
                *bufptr = *ptr;
786
0
              bufptr ++;
787
0
            }
788
0
            else if (!isprint(*ptr & 255))
789
0
            {
790
0
              if (buffer && bufptr < bufend)
791
0
                bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "\\%03o", *ptr & 255);
792
0
              else
793
0
                bufptr += snprintf(temp, sizeof(temp), "\\%03o", *ptr & 255);
794
0
            }
795
0
            else
796
0
            {
797
0
              if (buffer && bufptr < bufend)
798
0
                *bufptr = *ptr;
799
0
              bufptr ++;
800
0
            }
801
0
          }
802
0
          break;
803
804
0
      default :
805
0
          ptr = ippTagString(attr->value_tag);
806
0
          if (buffer && bufptr < bufend)
807
0
            cupsCopyString(bufptr, ptr, (size_t)(bufend - bufptr + 1));
808
0
          bufptr += strlen(ptr);
809
0
          break;
810
0
    }
811
0
  }
812
813
  // Nul-terminate and return...
814
0
  if (buffer && bufptr < bufend)
815
0
    *bufptr = '\0';
816
0
  else if (bufend)
817
0
    *bufend = '\0';
818
819
0
  return ((size_t)(bufptr - buffer));
820
0
}
821
822
823
//
824
// 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
825
//                               given requested-attributes attribute.
826
//
827
// This function creates a (sorted) CUPS array of attribute names matching the
828
// list of "requested-attribute" values supplied in an IPP request.  All IANA-
829
// registered values are supported in addition to the CUPS IPP extension
830
// attributes.
831
//
832
// The "request" argument specifies the request message that was read from
833
// the client.
834
//
835
// `NULL` is returned if all attributes should be returned.  Otherwise, the
836
// result is a sorted array of attribute names, where
837
// `cupsArrayFind(array, "attribute-name")` will return a non-`NULL` pointer.
838
// The array must be freed using @link cupsArrayDelete@.
839
//
840
841
cups_array_t *        // O - CUPS array or `NULL` if all
842
ippCreateRequestedArray(ipp_t *request) // I - IPP request
843
0
{
844
0
  size_t    i, j,   // Looping vars
845
0
      count;    // Number of values
846
0
  bool      added;    // Was name added?
847
0
  ipp_op_t    op;   // IPP operation code
848
0
  ipp_attribute_t *requested; // requested-attributes attribute
849
0
  cups_array_t    *ra;    // Requested attributes array
850
0
  const char    *value;   // Current value
851
  // The following lists come from the current IANA IPP registry of attributes
852
0
  static const char * const document_description[] =
853
0
  {         // document-description group
854
0
    "compression",
855
0
    "copies-actual",
856
0
    "cover-back-actual",
857
0
    "cover-front-actual",
858
0
    "current-page-order",
859
0
    "date-time-at-completed",
860
0
    "date-time-at-creation",
861
0
    "date-time-at-processing",
862
0
    "detailed-status-messages",
863
0
    "document-access-errors",
864
0
    "document-charset",
865
0
    "document-format",
866
0
    "document-format-details",    // IPP JobExt
867
0
    "document-format-detected",   // IPP JobExt
868
0
    "document-job-id",
869
0
    "document-job-uri",
870
0
    "document-message",
871
0
    "document-metadata",
872
0
    "document-name",
873
0
    "document-natural-language",
874
0
    "document-number",
875
0
    "document-printer-uri",
876
0
    "document-state",
877
0
    "document-state-message",
878
0
    "document-state-reasons",
879
0
    "document-uri",
880
0
    "document-uuid",      // IPP NODRIVER
881
0
    "errors-count",     // IPP JobExt
882
0
    "finishings-actual",
883
0
    "finishings-col-actual",
884
0
    "force-front-side-actual",
885
0
    "imposition-template-actual",
886
0
    "impressions",
887
0
    "impressions-col",
888
0
    "impressions-completed",
889
0
    "impressions-completed-col",
890
0
    "impressions-completed-current-copy",
891
0
    "insert-sheet-actual",
892
0
    "k-octets",
893
0
    "k-octets-processed",
894
0
    "last-document",
895
0
    "materials-col-actual",   // IPP 3D
896
0
    "media-actual",
897
0
    "media-col-actual",
898
0
    "media-input-tray-check-actual",
899
0
    "media-sheets",
900
0
    "media-sheets-col",
901
0
    "media-sheets-completed",
902
0
    "media-sheets-completed-col",
903
0
    "more-info",
904
0
    "multiple-object-handling-actual",  // IPP 3D
905
0
    "number-up-actual",
906
0
    "orientation-requested-actual",
907
0
    "output-bin-actual",
908
0
    "output-device-assigned",
909
0
    "overrides-actual",
910
0
    "page-delivery-actual",
911
0
    "page-order-received-actual",
912
0
    "page-ranges-actual",
913
0
    "pages",
914
0
    "pages-col",
915
0
    "pages-completed",
916
0
    "pages-completed-col",
917
0
    "pages-completed-current-copy",
918
0
    "platform-temperature-actual",  // IPP 3D
919
0
    "presentation-direction-number-up-actual",
920
0
    "print-accuracy-actual",    // IPP 3D
921
0
    "print-base-actual",    // IPP 3D
922
0
    "print-color-mode-actual",
923
0
    "print-content-optimize-actual",  // IPP JobExt
924
0
    "print-objects-actual",   // IPP 3D
925
0
    "print-quality-actual",
926
0
    "print-rendering-intent-actual",
927
0
    "print-scaling-actual",   // IPP Paid Printing
928
0
    "print-supports-actual",    // IPP 3D
929
0
    "printer-resolution-actual",
930
0
    "printer-up-time",
931
0
    "separator-sheets-actual",
932
0
    "sheet-completed-copy-number",
933
0
    "sides-actual",
934
0
    "time-at-completed",
935
0
    "time-at-creation",
936
0
    "time-at-processing",
937
0
    "warnings-count",     // IPP JobExt
938
0
    "x-image-position-actual",
939
0
    "x-image-shift-actual",
940
0
    "x-side1-image-shift-actual",
941
0
    "x-side2-image-shift-actual",
942
0
    "y-image-position-actual",
943
0
    "y-image-shift-actual",
944
0
    "y-side1-image-shift-actual",
945
0
    "y-side2-image-shift-actual"
946
0
  };
947
0
  static const char * const document_template[] =
948
0
  {         // document-template group
949
0
    "baling-type-supported",    // IPP FIN
950
0
    "baling-when-supported",    // IPP FIN
951
0
    "binding-reference-edge-supported", // IPP FIN
952
0
    "binding-type-supported",   // IPP FIN
953
0
    "chamber-humidity",     // IPP 3D
954
0
    "chamber-humidity-default",   // IPP 3D
955
0
    "chamber-humidity-supported", // IPP 3D
956
0
    "chamber-temperature",    // IPP 3D
957
0
    "chamber-temperature-default",  // IPP 3D
958
0
    "chamber-temperature-supported",  // IPP 3D
959
0
    "coating-sides-supported",    // IPP FIN
960
0
    "coating-type-supported",   // IPP FIN
961
0
    "copies",
962
0
    "copies-default",
963
0
    "copies-supported",
964
0
    "cover-back",     // IPP PPX
965
0
    "cover-back-default",   // IPP PPX
966
0
    "cover-back-supported",   // IPP PPX
967
0
    "cover-front",      // IPP PPX
968
0
    "cover-front-default",    // IPP PPX
969
0
    "cover-front-supported",    // IPP PPX
970
0
    "covering-name-supported",    // IPP FIN
971
0
    "feed-orientation",
972
0
    "feed-orientation-default",
973
0
    "feed-orientation-supported",
974
0
    "finishing-template-supported", // IPP FIN
975
0
    "finishings",
976
0
    "finishings-col",     // IPP FIN
977
0
    "finishings-col-database",    // IPP FIN
978
0
    "finishings-col-default",   // IPP FIN
979
0
    "finishings-col-ready",   // IPP FIN
980
0
    "finishings-col-supported",   // IPP FIN
981
0
    "finishings-default",
982
0
    "finishings-ready",
983
0
    "finishings-supported",
984
0
    "folding-direction-supported",  // IPP FIN
985
0
    "folding-offset-supported",   // IPP FIN
986
0
    "folding-reference-edge-supported", // IPP FIN
987
0
    "force-front-side",     // IPP PPX
988
0
    "force-front-side-default",   // IPP PPX
989
0
    "force-front-side-supported", // IPP PPX
990
0
    "imposition-template",    // IPP PPX
991
0
    "imposition-template-default",  // IPP PPX
992
0
    "imposition-template-supported",  // IPP PPX
993
0
    "insert-count-supported",   // IPP PPX
994
0
    "insert-sheet",     // IPP PPX
995
0
    "insert-sheet-default",   // IPP PPX
996
0
    "insert-sheet-supported",   // IPP PPX
997
0
    "laminating-sides-supported", // IPP FIN
998
0
    "laminating-type-supported",  // IPP FIN
999
0
    "material-amount-units-supported",  // IPP 3D
1000
0
    "material-diameter-supported",  // IPP 3D
1001
0
    "material-purpose-supported", // IPP 3D
1002
0
    "material-rate-supported",    // IPP 3D
1003
0
    "material-rate-units-supported",  // IPP 3D
1004
0
    "material-shell-thickness-supported",
1005
          // IPP 3D
1006
0
    "material-temperature-supported", // IPP 3D
1007
0
    "material-type-supported",    // IPP 3D
1008
0
    "materials-col",      // IPP 3D
1009
0
    "materials-col-database",   // IPP 3D
1010
0
    "materials-col-default",    // IPP 3D
1011
0
    "materials-col-ready",    // IPP 3D
1012
0
    "materials-col-supported",    // IPP 3D
1013
0
    "max-materials-col-supported",  // IPP 3D
1014
0
    "max-page-ranges-supported",
1015
0
    "max-stitching-locations-supported",// IPP FIN
1016
0
    "media",
1017
0
    "media-back-coating-supported", // IPP JobExt
1018
0
    "media-bottom-margin-supported",  // IPP JobExt
1019
0
    "media-col",      // IPP JobExt
1020
0
    "media-col-default",    // IPP JobExt
1021
0
    "media-col-ready",      // IPP JobExt
1022
0
    "media-col-supported",    // IPP JobExt
1023
0
    "media-color-supported",    // IPP JobExt
1024
0
    "media-default",
1025
0
    "media-front-coating-supported",  // IPP JobExt
1026
0
    "media-grain-supported",    // IPP JobExt
1027
0
    "media-hole-count-supported", // IPP JobExt
1028
0
    "media-info-supported",   // IPP JobExt
1029
0
    "media-input-tray-check",   // IPP PPX
1030
0
    "media-input-tray-check-default", // IPP PPX
1031
0
    "media-input-tray-check-supported", // IPP PPX
1032
0
    "media-key-supported",    // IPP JobExt
1033
0
    "media-left-margin-supported",  // IPP JobExt
1034
0
    "media-order-count-supported",  // IPP JobExt
1035
0
    "media-overprint",      // IPP NODRIVER
1036
0
    "media-overprint-distance-supported",
1037
          // IPP NODRIVER
1038
0
    "media-overprint-method-supported", // IPP NODRIVER
1039
0
    "media-overprint-supported",  // IPP NODRIVER
1040
0
    "media-pre-printed-supported",  // IPP JobExt
1041
0
    "media-ready",
1042
0
    "media-recycled-supported",   // IPP JobExt
1043
0
    "media-right-margin-supported", // IPP JobExt
1044
0
    "media-size-supported",   // IPP JobExt
1045
0
    "media-source-supported",   // IPP JobExt
1046
0
    "media-supported",
1047
0
    "media-thickness-supported",  // IPP JobExt
1048
0
    "media-top-margin-supported", // IPP JobExt
1049
0
    "media-type-supported",   // IPP JobExt
1050
0
    "media-weight-metric-supported",  // IPP JobExt
1051
0
    "multiple-document-handling",
1052
0
    "multiple-document-handling-default",
1053
0
    "multiple-document-handling-supported",
1054
0
    "multiple-object-handling",   // IPP 3D
1055
0
    "multiple-object-handling-default", // IPP 3D
1056
0
    "multiple-object-handling-supported",
1057
          // IPP 3D
1058
0
    "number-up",
1059
0
    "number-up-default",
1060
0
    "number-up-supported",
1061
0
    "orientation-requested",
1062
0
    "orientation-requested-default",
1063
0
    "orientation-requested-supported",
1064
0
    "output-device",      // IPP JobExt
1065
0
    "output-device-supported",    // IPP JobExt
1066
0
    "output-mode",      // CUPS extension
1067
0
    "output-mode-default",    // CUPS extension
1068
0
    "output-mode-supported",    // CUPS extension
1069
0
    "overrides",
1070
0
    "overrides-supported",
1071
0
    "page-delivery",      // IPP PPX
1072
0
    "page-delivery-default",    // IPP PPX
1073
0
    "page-delivery-supported",    // IPP PPX
1074
0
    "page-ranges",
1075
0
    "page-ranges-supported",
1076
0
    "platform-temperature",   // IPP 3D
1077
0
    "platform-temperature-default", // IPP 3D
1078
0
    "platform-temperature-supported", // IPP 3D
1079
0
    "preferred-attributes-supported", // IPP NODRIVER
1080
0
    "presentation-direction-number-up", // IPP PPX
1081
0
    "presentation-direction-number-up-default",
1082
          // IPP PPX
1083
0
    "presentation-direction-number-up-supported",
1084
          // IPP PPX
1085
0
    "print-accuracy",     // IPP 3D
1086
0
    "print-accuracy-default",   // IPP 3D
1087
0
    "print-accuracy-supported",   // IPP 3D
1088
0
    "print-base",     // IPP 3D
1089
0
    "print-base-default",   // IPP 3D
1090
0
    "print-base-supported",   // IPP 3D
1091
0
    "print-color-mode",     // IPP NODRIVER
1092
0
    "print-color-mode-default",   // IPP NODRIVER
1093
0
    "print-color-mode-supported", // IPP NODRIVER
1094
0
    "print-content-optimize",   // IPP JobExt
1095
0
    "print-content-optimize-default", // IPP JobExt
1096
0
    "print-content-optimize-supported", // IPP JobExt
1097
0
    "print-objects",      // IPP 3D
1098
0
    "print-objects-default",    // IPP 3D
1099
0
    "print-objects-supported",    // IPP 3D
1100
0
    "print-processing-attributes-supported",
1101
          // IPP NODRIVER
1102
0
    "print-quality",
1103
0
    "print-quality-default",
1104
0
    "print-quality-supported",
1105
0
    "print-rendering-intent",   // IPP NODRIVER
1106
0
    "print-rendering-intent-default", // IPP NODRIVER
1107
0
    "print-rendering-intent-supported", // IPP NODRIVER
1108
0
    "print-scaling",      // IPP NODRIVER
1109
0
    "print-scaling-default",    // IPP NODRIVER
1110
0
    "print-scaling-supported",    // IPP NODRIVER
1111
0
    "print-supports",     // IPP 3D
1112
0
    "print-supports-default",   // IPP 3D
1113
0
    "print-supports-supported",   // IPP 3D
1114
0
    "printer-resolution",
1115
0
    "printer-resolution-default",
1116
0
    "printer-resolution-supported",
1117
0
    "punching-hole-diameter-configured",// IPP FIN
1118
0
    "punching-locations-supported", // IPP FIN
1119
0
    "punching-offset-supported",  // IPP FIN
1120
0
    "punching-reference-edge-supported",// IPP FIN
1121
0
    "separator-sheets",     // IPP PPX
1122
0
    "separator-sheets-default",   // IPP PPX
1123
0
    "separator-sheets-supported", // IPP PPX
1124
0
    "separator-sheets-type-supported",  // IPP PPX
1125
0
    "sides",
1126
0
    "sides-default",
1127
0
    "sides-supported",
1128
0
    "stitching-angle-supported",  // IPP FIN
1129
0
    "stitching-locations-supported",  // IPP FIN
1130
0
    "stitching-method-supported", // IPP FIN
1131
0
    "stitching-offset-supported", // IPP FIN
1132
0
    "stitching-reference-edge-supported",
1133
          // IPP FIN
1134
0
    "x-image-position",     // IPP PPX
1135
0
    "x-image-position-default",   // IPP PPX
1136
0
    "x-image-position-supported", // IPP PPX
1137
0
    "x-image-shift",      // IPP PPX
1138
0
    "x-image-shift-default",    // IPP PPX
1139
0
    "x-image-shift-supported",    // IPP PPX
1140
0
    "x-side1-image-shift",    // IPP PPX
1141
0
    "x-side1-image-shift-default",  // IPP PPX
1142
0
    "x-side1-image-shift-supported",  // IPP PPX
1143
0
    "x-side2-image-shift",    // IPP PPX
1144
0
    "x-side2-image-shift-default",  // IPP PPX
1145
0
    "x-side2-image-shift-supported",  // IPP PPX
1146
0
    "y-image-position",     // IPP PPX
1147
0
    "y-image-position-default",   // IPP PPX
1148
0
    "y-image-position-supported", // IPP PPX
1149
0
    "y-image-shift",      // IPP PPX
1150
0
    "y-image-shift-default",    // IPP PPX
1151
0
    "y-image-shift-supported",    // IPP PPX
1152
0
    "y-side1-image-shift",    // IPP PPX
1153
0
    "y-side1-image-shift-default",  // IPP PPX
1154
0
    "y-side1-image-shift-supported",  // IPP PPX
1155
0
    "y-side2-image-shift",    // IPP PPX
1156
0
    "y-side2-image-shift-default",  // IPP PPX
1157
0
    "y-side2-image-shift-supported" // IPP PPX
1158
0
  };
1159
0
  static const char * const job_description[] =
1160
0
  {         // job-description group
1161
0
    "chamber-humidity-actual",    // IPP 3D
1162
0
    "chamber-temperature-actual", // IPP 3D
1163
0
    "client-info",      // IPP JobExt
1164
0
    "compression-supplied",
1165
0
    "copies-actual",
1166
0
    "cover-back-actual",
1167
0
    "cover-front-actual",
1168
0
    "current-page-order",
1169
0
    "date-time-at-completed",
1170
0
    "date-time-at-completed-estimated", // IPP PPX
1171
0
    "date-time-at-creation",
1172
0
    "date-time-at-processing",
1173
0
    "date-time-at-processing-estimated",// IPP PPX
1174
0
    "destination-statuses",
1175
0
    "document-charset-supplied",
1176
0
    "document-digital-signature-supplied",
1177
0
    "document-format-details-supplied",
1178
0
    "document-format-supplied",
1179
0
    "document-message-supplied",
1180
0
    "document-metadata",
1181
0
    "document-name-supplied",
1182
0
    "document-natural-language-supplied",
1183
0
    "document-overrides-actual",
1184
0
    "errors-count",
1185
0
    "finishings-actual",
1186
0
    "finishings-col-actual",
1187
0
    "force-front-side-actual",
1188
0
    "imposition-template-actual",
1189
0
    "impressions-completed-current-copy",
1190
0
    "insert-sheet-actual",
1191
0
    "job-account-id-actual",
1192
0
    "job-accounting-sheets-actual",
1193
0
    "job-accounting-user-id-actual",
1194
0
    "job-attribute-fidelity",
1195
0
    "job-charge-info",      // CUPS extension
1196
0
    "job-detailed-status-message",
1197
0
    "job-document-access-errors",
1198
0
    "job-error-sheet-actual",
1199
0
    "job-hold-until-actual",
1200
0
    "job-id",
1201
0
    "job-impressions",
1202
0
    "job-impressions-col",    // IPP JobExt
1203
0
    "job-impressions-completed",
1204
0
    "job-impressions-completed-col",  // IPP JobExt
1205
0
    "job-k-octets",
1206
0
    "job-k-octets-processed",
1207
0
    "job-mandatory-attributes",
1208
0
    "job-media-progress",   // CUPS extension
1209
0
    "job-media-sheets",
1210
0
    "job-media-sheets-col",   // IPP JobExt
1211
0
    "job-media-sheets-completed",
1212
0
    "job-media-sheets-completed-col", // IPP JobExt
1213
0
    "job-message-from-operator",
1214
0
    "job-more-info",
1215
0
    "job-name",
1216
0
    "job-originating-host-name",  // CUPS extension
1217
0
    "job-originating-user-name",
1218
0
    "job-originating-user-uri",   // IPP NODRIVER
1219
0
    "job-pages",      // IPP JobExt
1220
0
    "job-pages-col",      // IPP JobExt
1221
0
    "job-pages-completed",    // IPP JobExt
1222
0
    "job-pages-completed-col",    // IPP JobExt
1223
0
    "job-pages-completed-current-copy",
1224
0
    "job-printer-state-message",  // CUPS extension
1225
0
    "job-printer-state-reasons",  // CUPS extension
1226
0
    "job-printer-up-time",
1227
0
    "job-printer-uri",
1228
0
    "job-priority-actual",
1229
0
    "job-processing-time",    // IPP JobExt
1230
0
    "job-resource-ids",     // IPP System
1231
0
    "job-save-printer-make-and-model",
1232
0
    "job-sheet-message-actual",
1233
0
    "job-sheets-actual",
1234
0
    "job-sheets-col-actual",
1235
0
    "job-state",
1236
0
    "job-state-message",
1237
0
    "job-state-reasons",
1238
0
    "job-storage",      // IPP EPX
1239
0
    "job-uri",
1240
0
    "job-uuid",       // IPP NODRIVER
1241
0
    "materials-col-actual",   // IPP 3D
1242
0
    "media-actual",
1243
0
    "media-col-actual",
1244
0
    "media-check-input-tray-actual",
1245
0
    "multiple-document-handling-actual",
1246
0
    "multiple-object-handling-actual",  // IPP 3D
1247
0
    "number-of-documents",
1248
0
    "number-of-intervening-jobs",
1249
0
    "number-up-actual",
1250
0
    "orientation-requested-actual",
1251
0
    "original-requesting-user-name",
1252
0
    "output-bin-actual",
1253
0
    "output-device-assigned",
1254
0
    "output-device-job-state",    // IPP INFRA
1255
0
    "output-device-job-state-message",  // IPP INFRA
1256
0
    "output-device-job-state-reasons",  // IPP INFRA
1257
0
    "output-device-uuid-assigned",  // IPP INFRA
1258
0
    "overrides-actual",
1259
0
    "page-delivery-actual",
1260
0
    "page-order-received-actual",
1261
0
    "page-ranges-actual",
1262
0
    "parent-job-id",      // IPP EPX
1263
0
    "parent-job-uuid",      // IPP EPX
1264
0
    "platform-temperature-actual",  // IPP 3D
1265
0
    "presentation-direction-number-up-actual",
1266
0
    "print-accuracy-actual",    // IPP 3D
1267
0
    "print-base-actual",    // IPP 3D
1268
0
    "print-color-mode-actual",
1269
0
    "print-content-optimize-actual",
1270
0
    "print-objects-actual",   // IPP 3D
1271
0
    "print-quality-actual",
1272
0
    "print-rendering-intent-actual",
1273
0
    "print-scaling-actual",   // IPP Paid Printing
1274
0
    "print-supports-actual",    // IPP 3D
1275
0
    "printer-resolution-actual",
1276
0
    "separator-sheets-actual",
1277
0
    "sheet-collate-actual",
1278
0
    "sheet-completed-copy-number",
1279
0
    "sheet-completed-document-number",
1280
0
    "sides-actual",
1281
0
    "time-at-completed",
1282
0
    "time-at-completed-estimated",  // IPP PPX
1283
0
    "time-at-creation",
1284
0
    "time-at-processing",
1285
0
    "time-at-processing-estimated", // IPP PPX
1286
0
    "warnings-count",     // IPP JobExt
1287
0
    "x-image-position-actual",
1288
0
    "x-image-shift-actual",
1289
0
    "x-side1-image-shift-actual",
1290
0
    "x-side2-image-shift-actual",
1291
0
    "y-image-position-actual",
1292
0
    "y-image-shift-actual",
1293
0
    "y-side1-image-shift-actual",
1294
0
    "y-side2-image-shift-actual"
1295
0
  };
1296
0
  static const char * const job_template[] =
1297
0
  {         // job-template group
1298
0
    "accuracy-units-supported",   // IPP 3D
1299
0
    "baling-type-supported",    // IPP FIN
1300
0
    "baling-when-supported",    // IPP FIN
1301
0
    "binding-reference-edge-supported", // IPP FIN
1302
0
    "binding-type-supported",   // IPP FIN
1303
0
    "chamber-humidity",     // IPP 3D
1304
0
    "chamber-humidity-default",   // IPP 3D
1305
0
    "chamber-humidity-supported", // IPP 3D
1306
0
    "chamber-temperature",    // IPP 3D
1307
0
    "chamber-temperature-default",  // IPP 3D
1308
0
    "chamber-temperature-supported",  // IPP 3D
1309
0
    "coating-sides-supported",    // IPP FIN
1310
0
    "coating-type-supported",   // IPP FIN
1311
0
    "confirmation-sheet-print",   // IPP FaxOut
1312
0
    "confirmation-sheet-print-default",
1313
0
    "copies",
1314
0
    "copies-default",
1315
0
    "copies-supported",
1316
0
    "cover-back",     // IPP PPX
1317
0
    "cover-back-default",   // IPP PPX
1318
0
    "cover-back-supported",   // IPP PPX
1319
0
    "cover-front",      // IPP PPX
1320
0
    "cover-front-default",    // IPP PPX
1321
0
    "cover-front-supported",    // IPP PPX
1322
0
    "cover-sheet-info",     // IPP FaxOut
1323
0
    "cover-sheet-info-default",   // IPP FaxOut
1324
0
    "cover-sheet-info-supported", // IPP FaxOut
1325
0
    "covering-name-supported",    // IPP FIN
1326
0
    "destination-uri-schemes-supported",// IPP FaxOut
1327
0
    "destination-uris",     // IPP FaxOut
1328
0
    "destination-uris-supported",
1329
0
    "feed-orientation",
1330
0
    "feed-orientation-default",
1331
0
    "feed-orientation-supported",
1332
0
    "finishings",
1333
0
    "finishings-col",     // IPP FIN
1334
0
    "finishings-col-database",    // IPP FIN
1335
0
    "finishings-col-default",   // IPP FIN
1336
0
    "finishings-col-ready",   // IPP FIN
1337
0
    "finishings-col-supported",   // IPP FIN
1338
0
    "finishings-default",
1339
0
    "finishings-ready",
1340
0
    "finishings-supported",
1341
0
    "folding-direction-supported",  // IPP FIN
1342
0
    "folding-offset-supported",   // IPP FIN
1343
0
    "folding-reference-edge-supported", // IPP FIN
1344
0
    "force-front-side",     // IPP PPX
1345
0
    "force-front-side-default",   // IPP PPX
1346
0
    "force-front-side-supported", // IPP PPX
1347
0
    "imposition-template",    // IPP PPX
1348
0
    "imposition-template-default",  // IPP PPX
1349
0
    "imposition-template-supported",  // IPP PPX
1350
0
    "insert-count-supported",   // IPP PPX
1351
0
    "insert-sheet",     // IPP PPX
1352
0
    "insert-sheet-default",   // IPP PPX
1353
0
    "insert-sheet-supported",   // IPP PPX
1354
0
    "job-account-id",     // IPP JobExt
1355
0
    "job-account-id-default",   // IPP JobExt
1356
0
    "job-account-id-supported",   // IPP JobExt
1357
0
    "job-accounting-output-bin-supported",
1358
          // IPP PPX
1359
0
    "job-accounting-sheets",    // IPP PPX
1360
0
    "job-accounting-sheets-default",  // IPP PPX
1361
0
    "job-accounting-sheets-supported",  // IPP PPX
1362
0
    "job-accounting-sheets-type-supported",
1363
          // IPP PPX
1364
0
    "job-accounting-user-id",   // IPP JobExt
1365
0
    "job-accounting-user-id-default", // IPP JobExt
1366
0
    "job-accounting-user-id-supported", // IPP JobExt
1367
0
    "job-cancel-after",     // IPP JobExt
1368
0
    "job-cancel-after-default",   // IPP JobExt
1369
0
    "job-cancel-after-supported", // IPP JobExt
1370
0
    "job-complete-before",    // IPP PPX
1371
0
    "job-complete-before-supported",  // IPP PPX
1372
0
    "job-complete-before-time",   // IPP PPX
1373
0
    "job-complete-before-time-supported",
1374
          // IPP PPX
1375
0
    "job-delay-output-until",   // IPP JobExt
1376
0
    "job-delay-output-until-default", // IPP JobExt
1377
0
    "job-delay-output-until-supported", // IPP JobExt
1378
0
    "job-delay-output-until-time",  // IPP JobExt
1379
0
    "job-delay-output-until-time-default",
1380
          // IPP JobExt
1381
0
    "job-delay-output-until-time-supported",
1382
          // IPP JobExt
1383
0
    "job-error-action",     // IPP NODRIVER
1384
0
    "job-error-action-default",   // IPP NODRIVER
1385
0
    "job-error-action-supported", // IPP NODRIVER
1386
0
    "job-error-sheet",      // IPP PPX
1387
0
    "job-error-sheet-default",    // IPP PPX
1388
0
    "job-error-sheet-supported",  // IPP PPX
1389
0
    "job-error-sheet-type-supported", // IPP PPX
1390
0
    "job-error-sheet-when-supported", // IPP PPX
1391
0
    "job-hold-until",
1392
0
    "job-hold-until-default",
1393
0
    "job-hold-until-supported",
1394
0
    "job-hold-until-time",    // IPP JobExt
1395
0
    "job-hold-until-time-supported",  // IPP JobExt
1396
0
    "job-message-to-operator",    // IPP PPX
1397
0
    "job-message-to-operator-supported",// IPP PPX
1398
0
    "job-phone-number",     // IPP PPX
1399
0
    "job-phone-number-default",   // IPP PPX
1400
0
    "job-phone-number-supported", // IPP PPX
1401
0
    "job-priority",
1402
0
    "job-priority-default",
1403
0
    "job-priority-supported",
1404
0
    "job-recipient-name",   // IPP PPX
1405
0
    "job-recipient-name-supported", // IPP PPX
1406
0
    "job-retain-until",     // IPP JobExt
1407
0
    "job-retain-until-default",   // IPP JobExt
1408
0
    "job-retain-until-interval",  // IPP JobExt
1409
0
    "job-retain-until=interval-default",// IPP JobExt
1410
0
    "job-retain-until-interval-supported",
1411
          // IPP JobExt
1412
0
    "job-retain-until-supported", // IPP JobExt
1413
0
    "job-retain-until-time",    // IPP JobExt
1414
0
    "job-retain-until-time-supported",  // IPP JobExt
1415
0
    "job-sheet-message",    // IPP JobExt
1416
0
    "job-sheet-message-supported",  // IPP JobExt
1417
0
    "job-sheets",
1418
0
    "job-sheets-col",     // IPP JobExt
1419
0
    "job-sheets-col-default",   // IPP JobExt
1420
0
    "job-sheets-col-supported",   // IPP JobExt
1421
0
    "job-sheets-default",
1422
0
    "job-sheets-supported",
1423
0
    "laminating-sides-supported", // IPP FIN
1424
0
    "laminating-type-supported",  // IPP FIN
1425
0
    "logo-uri-schemes-supported", // IPP FaxOut
1426
0
    "material-amount-units-supported",  // IPP 3D
1427
0
    "material-diameter-supported",  // IPP 3D
1428
0
    "material-purpose-supported", // IPP 3D
1429
0
    "material-rate-supported",    // IPP 3D
1430
0
    "material-rate-units-supported",  // IPP 3D
1431
0
    "material-shell-thickness-supported",
1432
          // IPP 3D
1433
0
    "material-temperature-supported", // IPP 3D
1434
0
    "material-type-supported",    // IPP 3D
1435
0
    "materials-col",      // IPP 3D
1436
0
    "materials-col-database",   // IPP 3D
1437
0
    "materials-col-default",    // IPP 3D
1438
0
    "materials-col-ready",    // IPP 3D
1439
0
    "materials-col-supported",    // IPP 3D
1440
0
    "max-materials-col-supported",  // IPP 3D
1441
0
    "max-page-ranges-supported",
1442
0
    "max-stitching-locations-supported",// IPP FIN
1443
0
    "media",
1444
0
    "media-back-coating-supported", // IPP JobExt
1445
0
    "media-bottom-margin-supported",  // IPP JobExt
1446
0
    "media-col",      // IPP JobExt
1447
0
    "media-col-default",    // IPP JobExt
1448
0
    "media-col-ready",      // IPP JobExt
1449
0
    "media-col-supported",    // IPP JobExt
1450
0
    "media-color-supported",    // IPP JobExt
1451
0
    "media-default",
1452
0
    "media-front-coating-supported",  // IPP JobExt
1453
0
    "media-grain-supported",    // IPP JobExt
1454
0
    "media-hole-count-supported", // IPP JobExt
1455
0
    "media-info-supported",   // IPP JobExt
1456
0
    "media-input-tray-check",   // IPP PPX
1457
0
    "media-input-tray-check-default", // IPP PPX
1458
0
    "media-input-tray-check-supported", // IPP PPX
1459
0
    "media-key-supported",    // IPP JobExt
1460
0
    "media-left-margin-supported",  // IPP JobExt
1461
0
    "media-order-count-supported",  // IPP JobExt
1462
0
    "media-overprint",      // IPP NODRIVER
1463
0
    "media-overprint-distance-supported",
1464
          // IPP NODRIVER
1465
0
    "media-overprint-method-supported", // IPP NODRIVER
1466
0
    "media-overprint-supported",  // IPP NODRIVER
1467
0
    "media-pre-printed-supported",  // IPP JobExt
1468
0
    "media-ready",
1469
0
    "media-recycled-supported",   // IPP JobExt
1470
0
    "media-right-margin-supported", // IPP JobExt
1471
0
    "media-size-supported",   // IPP JobExt
1472
0
    "media-source-supported",   // IPP JobExt
1473
0
    "media-supported",
1474
0
    "media-thickness-supported",  // IPP JobExt
1475
0
    "media-top-margin-supported", // IPP JobExt
1476
0
    "media-type-supported",   // IPP JobExt
1477
0
    "media-weight-metric-supported",  // IPP JobExt
1478
0
    "multiple-document-handling",
1479
0
    "multiple-document-handling-default",
1480
0
    "multiple-document-handling-supported",
1481
0
    "multiple-object-handling",   // IPP 3D
1482
0
    "multiple-object-handling-default", // IPP 3D
1483
0
    "multiple-object-handling-supported",
1484
          // IPP 3D
1485
0
    "number-of-retries",    // IPP FaxOut
1486
0
    "number-of-retries-default",
1487
0
    "number-of-retries-supported",
1488
0
    "number-up",
1489
0
    "number-up-default",
1490
0
    "number-up-supported",
1491
0
    "orientation-requested",
1492
0
    "orientation-requested-default",
1493
0
    "orientation-requested-supported",
1494
0
    "output-bin",
1495
0
    "output-bin-default",
1496
0
    "output-bin-supported",
1497
0
    "output-device",      // IPP JobExt
1498
0
    "output-device-supported",    // IPP JobExt
1499
0
    "output-mode",      // CUPS extension
1500
0
    "output-mode-default",    // CUPS extension
1501
0
    "output-mode-supported",    // CUPS extension
1502
0
    "overrides",
1503
0
    "overrides-supported",
1504
0
    "page-delivery",      // IPP PPX
1505
0
    "page-delivery-default",    // IPP PPX
1506
0
    "page-delivery-supported",    // IPP PPX
1507
0
    "page-ranges",
1508
0
    "page-ranges-supported",
1509
0
    "platform-temperature",   // IPP 3D
1510
0
    "platform-temperature-default", // IPP 3D
1511
0
    "platform-temperature-supported", // IPP 3D
1512
0
    "preferred-attributes-supported", // IPP NODRIVER
1513
0
    "presentation-direction-number-up", // IPP PPX
1514
0
    "presentation-direction-number-up-default",
1515
          // IPP PPX
1516
0
    "presentation-direction-number-up-supported",
1517
          // IPP PPX
1518
0
    "print-accuracy",     // IPP 3D
1519
0
    "print-accuracy-default",   // IPP 3D
1520
0
    "print-accuracy-supported",   // IPP 3D
1521
0
    "print-base",     // IPP 3D
1522
0
    "print-base-default",   // IPP 3D
1523
0
    "print-base-supported",   // IPP 3D
1524
0
    "print-color-mode",     // IPP NODRIVER
1525
0
    "print-color-mode-default",   // IPP NODRIVER
1526
0
    "print-color-mode-supported", // IPP NODRIVER
1527
0
    "print-content-optimize",   // IPP JobExt
1528
0
    "print-content-optimize-default", // IPP JobExt
1529
0
    "print-content-optimize-supported", // IPP JobExt
1530
0
    "print-objects",      // IPP 3D
1531
0
    "print-objects-default",    // IPP 3D
1532
0
    "print-objects-supported",    // IPP 3D
1533
0
    "print-processing-attributes-supported",
1534
          // IPP NODRIVER
1535
0
    "print-quality",
1536
0
    "print-quality-default",
1537
0
    "print-quality-supported",
1538
0
    "print-rendering-intent",   // IPP NODRIVER
1539
0
    "print-rendering-intent-default", // IPP NODRIVER
1540
0
    "print-rendering-intent-supported", // IPP NODRIVER
1541
0
    "print-scaling",      // IPP NODRIVER
1542
0
    "print-scaling-default",    // IPP NODRIVER
1543
0
    "print-scaling-supported",    // IPP NODRIVER
1544
0
    "print-supports",     // IPP 3D
1545
0
    "print-supports-default",   // IPP 3D
1546
0
    "print-supports-supported",   // IPP 3D
1547
0
    "printer-resolution",
1548
0
    "printer-resolution-default",
1549
0
    "printer-resolution-supported",
1550
0
    "proof-copies",     // IPP EPX
1551
0
    "proof-copies-supported",   // IPP EPX
1552
0
    "proof-print",      // IPP EPX
1553
0
    "proof-print-default",    // IPP EPX
1554
0
    "proof-print-supported"   // IPP EPX
1555
0
    "punching-hole-diameter-configured",// IPP FIN
1556
0
    "punching-locations-supported", // IPP FIN
1557
0
    "punching-offset-supported",  // IPP FIN
1558
0
    "punching-reference-edge-supported",// IPP FIN
1559
0
    "retry-interval",     // IPP FaxOut
1560
0
    "retry-interval-default",
1561
0
    "retry-interval-supported",
1562
0
    "retry-timeout",      // IPP FaxOut
1563
0
    "retry-timeout-default",
1564
0
    "retry-timeout-supported",
1565
0
    "separator-sheets",     // IPP PPX
1566
0
    "separator-sheets-default",   // IPP PPX
1567
0
    "separator-sheets-supported", // IPP PPX
1568
0
    "separator-sheets-type-supported",  // IPP PPX
1569
0
    "sides",
1570
0
    "sides-default",
1571
0
    "sides-supported",
1572
0
    "stitching-angle-supported",  // IPP FIN
1573
0
    "stitching-locations-supported",  // IPP FIN
1574
0
    "stitching-method-supported", // IPP FIN
1575
0
    "stitching-offset-supported", // IPP FIN
1576
0
    "stitching-reference-edge-supported",
1577
          // IPP FIN
1578
0
    "x-image-position",     // IPP PPX
1579
0
    "x-image-position-default",   // IPP PPX
1580
0
    "x-image-position-supported", // IPP PPX
1581
0
    "x-image-shift",      // IPP PPX
1582
0
    "x-image-shift-default",    // IPP PPX
1583
0
    "x-image-shift-supported",    // IPP PPX
1584
0
    "x-side1-image-shift",    // IPP PPX
1585
0
    "x-side1-image-shift-default",  // IPP PPX
1586
0
    "x-side1-image-shift-supported",  // IPP PPX
1587
0
    "x-side2-image-shift",    // IPP PPX
1588
0
    "x-side2-image-shift-default",  // IPP PPX
1589
0
    "x-side2-image-shift-supported",  // IPP PPX
1590
0
    "y-image-position",     // IPP PPX
1591
0
    "y-image-position-default",   // IPP PPX
1592
0
    "y-image-position-supported", // IPP PPX
1593
0
    "y-image-shift",      // IPP PPX
1594
0
    "y-image-shift-default",    // IPP PPX
1595
0
    "y-image-shift-supported",    // IPP PPX
1596
0
    "y-side1-image-shift",    // IPP PPX
1597
0
    "y-side1-image-shift-default",  // IPP PPX
1598
0
    "y-side1-image-shift-supported",  // IPP PPX
1599
0
    "y-side2-image-shift",    // IPP PPX
1600
0
    "y-side2-image-shift-default",  // IPP PPX
1601
0
    "y-side2-image-shift-supported" // IPP PPX
1602
0
  };
1603
0
  static const char * const printer_description[] =
1604
0
  {         // printer-description group
1605
0
    "auth-info-required",   // CUPS extension
1606
0
    "chamber-humidity-current",   // IPP 3D
1607
0
    "chamber-temperature-current",  // IPP 3D
1608
0
    "charset-configured",
1609
0
    "charset-supported",
1610
0
    "client-info-supported",    // IPP JobExt
1611
0
    "color-supported",
1612
0
    "compression-supported",
1613
0
    "device-service-count",
1614
0
    "device-uri",     // CUPS extension
1615
0
    "device-uuid",
1616
0
    "document-charset-default",   // IPP JobExt
1617
0
    "document-charset-supported", // IPP JobExt
1618
0
    "document-creation-attributes-supported",
1619
0
    "document-format-default",
1620
0
    "document-format-details-supported",// IPP JobExt
1621
0
    "document-format-preferred",  // AirPrint extension
1622
0
    "document-format-supported",
1623
0
    "document-format-varying-attributes",
1624
0
    "document-natural-language-default",// IPP JobExt
1625
0
    "document-natural-language-supported",
1626
          // IPP JobExt
1627
0
    "document-password-supported",  // IPP NODRIVER
1628
0
    "document-privacy-attributes",  // IPP Privacy Attributes
1629
0
    "document-privacy-scope",   // IPP Privacy Attributes
1630
0
    "generated-natural-language-supported",
1631
0
    "identify-actions-default",   // IPP NODRIVER
1632
0
    "identify-actions-supported", // IPP NODRIVER
1633
0
    "input-source-supported",   // IPP FaxOut
1634
0
    "ipp-features-supported",   // IPP NODRIVER
1635
0
    "ipp-versions-supported",
1636
0
    "ippget-event-life",    // RFC 3995
1637
0
    "job-authorization-uri-supported",  // CUPS extension
1638
0
    "job-constraints-supported",  // IPP NODRIVER
1639
0
    "job-creation-attributes-supported",// IPP JobExt
1640
0
    "job-history-attributes-configured",// IPP JobExt
1641
0
    "job-history-attributes-supported", // IPP JobExt
1642
0
    "job-history-interval-configured",  // IPP JobExt
1643
0
    "job-history-interval-supported", // IPP JobExt
1644
0
    "job-ids-supported",    // IPP JobExt
1645
0
    "job-impressions-supported",
1646
0
    "job-k-limit",      // CUPS extension
1647
0
    "job-k-octets-supported",
1648
0
    "job-mandatory-attributes-supported",
1649
          // IPP JobExt
1650
0
    "job-media-sheets-supported",
1651
0
    "job-page-limit",     // CUPS extension
1652
0
    "job-pages-per-set-supported",  // IPP FIN
1653
0
    "job-password-encryption-supported",// IPP EPX
1654
0
    "job-password-length-supported",  // IPP EPX
1655
0
    "job-password-repertoire-configured",
1656
          // IPP EPX
1657
0
    "job-password-repertoire-supported",// IPP EPX
1658
0
    "job-password-supported",   // IPP EPX
1659
0
    "job-presets-supported",    // IPP NODRIVER
1660
0
    "job-privacy-attributes",   // IPP Privacy Attributes
1661
0
    "job-privacy-scope",    // IPP Privacy Attributes
1662
0
    "job-quota-period",     // CUPS extension
1663
0
    "job-release-action-default", // IPP EPX
1664
0
    "job-release-action-supported", // IPP EPX
1665
0
    "job-resolvers-supported",    // IPP NODRIVER
1666
0
    "job-settable-attributes-supported",// RFC 3380
1667
0
    "job-spooling-supported",   // IPP JobExt
1668
0
    "job-storage-access-supported", // IPP EPX
1669
0
    "job-storage-disposition-supported",// IPP EPX
1670
0
    "job-storage-group-supported",  // IPP EPX
1671
0
    "job-storage-supported",    // IPP EPX
1672
0
    "job-triggers-supported",   // IPP NODRIVER
1673
0
    "jpeg-features-supported",    // IPP NODRIVER
1674
0
    "jpeg-k-octets-supported",    // IPP NODRIVER
1675
0
    "jpeg-x-dimension-supported", // IPP NODRIVER
1676
0
    "jpeg-y-dimension-supported", // IPP NODRIVER
1677
0
    "landscape-orientation-requested-preferred",
1678
          // AirPrint extension
1679
0
    "marker-change-time",   // CUPS extension
1680
0
    "marker-colors",      // CUPS extension
1681
0
    "marker-high-levels",   // CUPS extension
1682
0
    "marker-levels",      // CUPS extension
1683
0
    "marker-low-levels",    // CUPS extension
1684
0
    "marker-message",     // CUPS extension
1685
0
    "marker-names",     // CUPS extension
1686
0
    "marker-types",     // CUPS extension
1687
0
    "max-client-info-supported",  // IPP JobExt
1688
0
    "member-names",     // CUPS extension
1689
0
    "member-uris",      // CUPS extension
1690
0
    "mopria-certified",     // Mopria extension
1691
0
    "multiple-destination-uris-supported",
1692
          // IPP FaxOut
1693
0
    "multiple-document-jobs-supported",
1694
0
    "multiple-operation-time-out",
1695
0
    "multiple-operation-time-out-action",
1696
          // IPP NODRIVER
1697
0
    "natural-language-configured",
1698
0
    "operations-supported",
1699
0
    "output-device-uuid-supported", // IPP INFRA
1700
0
    "pages-per-minute",
1701
0
    "pages-per-minute-color",
1702
0
    "pdf-k-octets-supported",   // CUPS extension
1703
0
    "pdf-features-supported",   // IPP 3D
1704
0
    "pdf-versions-supported",   // CUPS extension
1705
0
    "pdl-override-supported",
1706
0
    "platform-shape",     // IPP 3D
1707
0
    "pkcs7-document-format-supported",  // IPP TRUSTNOONE
1708
0
    "port-monitor",     // CUPS extension
1709
0
    "port-monitor-supported",   // CUPS extension
1710
0
    "preferred-attributes-supported",
1711
0
    "printer-alert",
1712
0
    "printer-alert-description",
1713
0
    "printer-camera-image-uri",   // IPP 3D
1714
0
    "printer-charge-info",
1715
0
    "printer-charge-info-uri",
1716
0
    "printer-commands",     // CUPS extension
1717
0
    "printer-config-change-date-time",
1718
0
    "printer-config-change-time",
1719
0
    "printer-config-changes",   // IPP System
1720
0
    "printer-contact-col",    // IPP System
1721
0
    "printer-current-time",
1722
0
    "printer-detailed-status-messages", // IPP EPX
1723
0
    "printer-device-id",
1724
0
    "printer-dns-sd-name",    // CUPS extension
1725
0
    "printer-driver-installer",
1726
0
    "printer-fax-log-uri",    // IPP FaxOut
1727
0
    "printer-fax-modem-info",   // IPP FaxOut
1728
0
    "printer-fax-modem-name",   // IPP FaxOut
1729
0
    "printer-fax-modem-number",   // IPP FaxOut
1730
0
    "printer-finisher",     // IPP FIN
1731
0
    "printer-finisher-description", // IPP FIN
1732
0
    "printer-finisher-supplies",  // IPP FIN
1733
0
    "printer-finisher-supplies-description",
1734
          // IPP FIN
1735
0
    "printer-firmware-name",    // PWG 5110.1
1736
0
    "printer-firmware-patches",   // PWG 5110.1
1737
0
    "printer-firmware-string-version",  // PWG 5110.1
1738
0
    "printer-firmware-version",   // PWG 5110.1
1739
0
    "printer-geo-location",
1740
0
    "printer-get-attributes-supported",
1741
0
    "printer-icc-profiles",
1742
0
    "printer-icons",
1743
0
    "printer-id",     // IPP System
1744
0
    "printer-info",
1745
0
    "printer-input-tray",   // IPP NODRIVER
1746
0
    "printer-is-accepting-jobs",
1747
0
    "printer-is-shared",    // CUPS extension
1748
0
    "printer-is-temporary",   // CUPS extension
1749
0
    "printer-kind",     // IPP Paid Printing
1750
0
    "printer-location",
1751
0
    "printer-make-and-model",
1752
0
    "printer-mandatory-job-attributes",
1753
0
    "printer-message-date-time",
1754
0
    "printer-message-from-operator",
1755
0
    "printer-message-time",
1756
0
    "printer-more-info",
1757
0
    "printer-more-info-manufacturer",
1758
0
    "printer-name",
1759
0
    "printer-organization",
1760
0
    "printer-organizational-unit",
1761
0
    "printer-output-tray",    // IPP NODRIVER
1762
0
    "printer-pkcs7-public-key",   // IPP TRUSTNOONE
1763
0
    "printer-pkcs7-repertoire-configured",
1764
          // IPP TRUSTNOONE
1765
0
    "printer-pkcs7-repertoire-supported",
1766
          // IPP TRUSTNOONE
1767
0
    "printer-requested-client-type",  // IPP JobExt
1768
0
    "printer-service-type",   // IPP System
1769
0
    "printer-settable-attributes-supported",
1770
          // RFC 3380
1771
0
    "printer-service-contact-col",  // IPP EPX
1772
0
    "printer-state",
1773
0
    "printer-state-change-date-time",
1774
0
    "printer-state-change-time",
1775
0
    "printer-state-message",
1776
0
    "printer-state-reasons",
1777
0
    "printer-storage",      // IPP EPX
1778
0
    "printer-storage-description",  // IPP EPX
1779
0
    "printer-strings-languages-supported",
1780
          // IPP NODRIVER
1781
0
    "printer-strings-uri",    // IPP NODRIVER
1782
0
    "printer-supply",
1783
0
    "printer-supply-description",
1784
0
    "printer-supply-info-uri",
1785
0
    "printer-type",     // CUPS extension
1786
0
    "printer-up-time",
1787
0
    "printer-uri-supported",
1788
0
    "printer-uuid",
1789
0
    "printer-wifi-ssid",    // AirPrint extension
1790
0
    "printer-wifi-state",   // AirPrint extension
1791
0
    "printer-xri-supported",
1792
0
    "proof-copies-supported",   // IPP EPX
1793
0
    "proof-print-copies-supported", // IPP EPX
1794
0
    "pwg-raster-document-resolution-supported",
1795
          // PWG Raster
1796
0
    "pwg-raster-document-sheet-back", // PWG Raster
1797
0
    "pwg-raster-document-type-supported",
1798
          // PWG Raster
1799
0
    "queued-job-count",
1800
0
    "reference-uri-schemes-supported",
1801
0
    "repertoire-supported",
1802
0
    "requesting-user-name-allowed", // CUPS extension
1803
0
    "requesting-user-name-denied",  // CUPS extension
1804
0
    "requesting-user-uri-supported",
1805
0
    "smi2699-auth-print-group",   // PWG ippserver extension
1806
0
    "smi2699-auth-proxy-group",   // PWG ippserver extension
1807
0
    "smi2699-device-command",   // PWG ippserver extension
1808
0
    "smi2699-device-format",    // PWG ippserver extension
1809
0
    "smi2699-device-name",    // PWG ippserver extension
1810
0
    "smi2699-device-uri",   // PWG ippserver extension
1811
0
    "subordinate-printers-supported",
1812
0
    "subscription-privacy-attributes",  // IPP Privacy Attributes
1813
0
    "subscription-privacy-scope", // IPP Privacy Attributes
1814
0
    "trimming-offset-supported",  // IPP FIN
1815
0
    "trimming-reference-edge-supported",// IPP FIN
1816
0
    "trimming-type-supported",    // IPP FIN
1817
0
    "trimming-when-supported",    // IPP FIN
1818
0
    "urf-supported",      // AirPrint
1819
0
    "uri-authentication-supported",
1820
0
    "uri-security-supported",
1821
0
    "which-jobs-supported",   // IPP JobExt
1822
0
    "xri-authentication-supported",
1823
0
    "xri-security-supported",
1824
0
    "xri-uri-scheme-supported"
1825
0
  };
1826
0
  static const char * const resource_description[] =
1827
0
  {         // resource-description group - IPP System
1828
0
    "resource-info",
1829
0
    "resource-name"
1830
0
  };
1831
0
  static const char * const resource_status[] =
1832
0
  {         // resource-status group - IPP System
1833
0
    "date-time-at-canceled",
1834
0
    "date-time-at-creation",
1835
0
    "date-time-at-installed",
1836
0
    "resource-data-uri",
1837
0
    "resource-format",
1838
0
    "resource-id",
1839
0
    "resource-k-octets",
1840
0
    "resource-state",
1841
0
    "resource-state-message",
1842
0
    "resource-state-reasons",
1843
0
    "resource-string-version",
1844
0
    "resource-type",
1845
0
    "resource-use-count",
1846
0
    "resource-uuid",
1847
0
    "resource-version",
1848
0
    "time-at-canceled",
1849
0
    "time-at-creation",
1850
0
    "time-at-installed"
1851
0
  };
1852
0
  static const char * const resource_template[] =
1853
0
  {         // resource-template group - IPP System
1854
0
    "resource-format",
1855
0
    "resource-format-supported",
1856
0
    "resource-info",
1857
0
    "resource-name",
1858
0
    "resource-type",
1859
0
    "resource-type-supported"
1860
0
  };
1861
0
  static const char * const subscription_description[] =
1862
0
  {         // subscription-description group
1863
0
    "notify-job-id",
1864
0
    "notify-lease-expiration-time",
1865
0
    "notify-printer-up-time",
1866
0
    "notify-printer-uri",
1867
0
    "notify-resource-id",   // IPP System
1868
0
    "notify-system-uri",    // IPP System
1869
0
    "notify-sequence-number",
1870
0
    "notify-subscriber-user-name",
1871
0
    "notify-subscriber-user-uri",
1872
0
    "notify-subscription-id",
1873
0
    "notify-subscription-uuid"    // IPP NODRIVER
1874
0
  };
1875
0
  static const char * const subscription_template[] =
1876
0
  {         // subscription-template group
1877
0
    "notify-attributes",
1878
0
    "notify-attributes-supported",
1879
0
    "notify-charset",
1880
0
    "notify-events",
1881
0
    "notify-events-default",
1882
0
    "notify-events-supported",
1883
0
    "notify-lease-duration",
1884
0
    "notify-lease-duration-default",
1885
0
    "notify-lease-duration-supported",
1886
0
    "notify-max-events-supported",
1887
0
    "notify-natural-language",
1888
0
    "notify-pull-method",
1889
0
    "notify-pull-method-supported",
1890
0
    "notify-recipient-uri",
1891
0
    "notify-schemes-supported",
1892
0
    "notify-time-interval",
1893
0
    "notify-user-data"
1894
0
  };
1895
0
  static const char * const system_description[] =
1896
0
  {         // system-description group - IPP System
1897
0
    "charset-configured",
1898
0
    "charset-supported",
1899
0
    "document-format-supported",
1900
0
    "generated-natural-language-supported",
1901
0
    "ipp-features-supported",
1902
0
    "ipp-versions-supported",
1903
0
    "ippget-event-life",
1904
0
    "multiple-document-printers-supported",
1905
0
    "natural-language-configured",
1906
0
    "notify-attributes-supported",
1907
0
    "notify-events-default",
1908
0
    "notify-events-supported",
1909
0
    "notify-lease-duration-default",
1910
0
    "notify-lease-duration-supported",
1911
0
    "notify-max-events-supported",
1912
0
    "notify-pull-method-supported",
1913
0
    "operations-supported",
1914
0
    "power-calendar-policy-col",
1915
0
    "power-event-policy-col",
1916
0
    "power-timeout-policy-col",
1917
0
    "printer-creation-attributes-supported",
1918
0
    "printer-service-type-supported",
1919
0
    "resource-format-supported",
1920
0
    "resource-type-supported",
1921
0
    "resource-settable-attributes-supported",
1922
0
    "smi2699-auth-group-supported", // PWG ippserver extension
1923
0
    "smi2699-device-command-supported", // PWG ippserver extension
1924
0
    "smi2699-device-format-format", // PWG ippserver extension
1925
0
    "smi2699-device-uri-schemes-supported",
1926
          // PWG ippserver extension
1927
0
    "system-contact-col",
1928
0
    "system-current-time",
1929
0
    "system-default-printer-id",
1930
0
    "system-geo-location",
1931
0
    "system-info",
1932
0
    "system-location",
1933
0
    "system-mandatory-printer-attributes",
1934
0
    "system-make-and-model",
1935
0
    "system-message-from-operator",
1936
0
    "system-name",
1937
0
    "system-owner-col",
1938
0
    "system-settable-attributes-supported",
1939
0
    "system-strings-languages-supported",
1940
0
    "system-strings-uri",
1941
0
    "system-xri-supported"
1942
0
  };
1943
0
  static const char * const system_status[] =
1944
0
  {         // system-status group - IPP System
1945
0
    "power-log-col",
1946
0
    "power-state-capabilities-col",
1947
0
    "power-state-counters-col",
1948
0
    "power-state-monitor-col",
1949
0
    "power-state-transitions-col",
1950
0
    "system-config-change-date-time",
1951
0
    "system-config-change-time",
1952
0
    "system-config-changes",
1953
0
    "system-configured-printers",
1954
0
    "system-configured-resources",
1955
0
    "system-firmware-name",
1956
0
    "system-firmware-patches",
1957
0
    "system-firmware-string-version",
1958
0
    "system-firmware-version",
1959
0
    "system-impressions-completed",
1960
0
    "system-impressions-completed-col",
1961
0
    "system-media-sheets-completed",
1962
0
    "system-media-sheets-completed-col",
1963
0
    "system-pages-completed",
1964
0
    "system-pages-completed-col",
1965
0
    "system-resident-application-name",
1966
0
    "system-resident-application-patches",
1967
0
    "system-resident-application-string-version",
1968
0
    "system-resident-application-version",
1969
0
    "system-serial-number",
1970
0
    "system-state",
1971
0
    "system-state-change-date-time",
1972
0
    "system-state-change-time",
1973
0
    "system-state-message",
1974
0
    "system-state-reasons",
1975
0
    "system-time-source-configured",
1976
0
    "system-up-time",
1977
0
    "system-user-application-name",
1978
0
    "system-user-application-patches",
1979
0
    "system-user-application-string-version",
1980
0
    "system-user-application-version",
1981
0
    "system-uuid",
1982
0
    "xri-authentication-supported",
1983
0
    "xri-security-supported",
1984
0
    "xri-uri-scheme-supported"
1985
0
  };
1986
1987
1988
  // Get the requested-attributes attribute...
1989
0
  op = ippGetOperation(request);
1990
1991
0
  if ((requested = ippFindAttribute(request, "requested-attributes", IPP_TAG_KEYWORD)) == NULL)
1992
0
  {
1993
    // The Get-Jobs operation defaults to "job-id" and "job-uri", and
1994
    // Get-Documents defaults to "document-number", while all others default to
1995
    // "all"...
1996
0
    if (op == IPP_OP_GET_JOBS)
1997
0
    {
1998
0
      ra = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, NULL, NULL);
1999
0
      cupsArrayAdd(ra, "job-id");
2000
0
      cupsArrayAdd(ra, "job-uri");
2001
2002
0
      return (ra);
2003
0
    }
2004
0
    else if (op == IPP_OP_GET_DOCUMENTS)
2005
0
    {
2006
0
      ra = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, NULL, NULL);
2007
0
      cupsArrayAdd(ra, "document-number");
2008
2009
0
      return (ra);
2010
0
    }
2011
0
    else
2012
0
    {
2013
0
      return (NULL);
2014
0
    }
2015
0
  }
2016
2017
  // If the attribute contains a single "all" keyword, return NULL...
2018
0
  count = ippGetCount(requested);
2019
0
  if (count == 1 && !strcmp(ippGetString(requested, 0, NULL), "all"))
2020
0
    return (NULL);
2021
2022
  // Create an array using "strcmp" as the comparison function...
2023
0
  ra = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, NULL, NULL);
2024
2025
0
  for (i = 0; i < count; i ++)
2026
0
  {
2027
0
    added = false;
2028
0
    value = ippGetString(requested, i, NULL);
2029
2030
0
    if (!strcmp(value, "document-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_JOB_ATTRIBUTES || op == IPP_OP_GET_JOBS || op == IPP_OP_GET_DOCUMENT_ATTRIBUTES || op == IPP_OP_GET_DOCUMENTS)))
2031
0
    {
2032
0
      for (j = 0; j < (sizeof(document_description) / sizeof(document_description[0])); j ++)
2033
0
        cupsArrayAdd(ra, (void *)document_description[j]);
2034
2035
0
      added = true;
2036
0
    }
2037
2038
0
    if (!strcmp(value, "document-template") || !strcmp(value, "all"))
2039
0
    {
2040
0
      for (j = 0; j < (sizeof(document_template) / sizeof(document_template[0])); j ++)
2041
0
        cupsArrayAdd(ra, (void *)document_template[j]);
2042
2043
0
      added = true;
2044
0
    }
2045
2046
0
    if (!strcmp(value, "job-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_JOB_ATTRIBUTES || op == IPP_OP_GET_JOBS)))
2047
0
    {
2048
0
      for (j = 0; j < (sizeof(job_description) / sizeof(job_description[0])); j ++)
2049
0
        cupsArrayAdd(ra, (void *)job_description[j]);
2050
2051
0
      added = true;
2052
0
    }
2053
2054
0
    if (!strcmp(value, "job-template") || (!strcmp(value, "all") && (op == IPP_OP_GET_JOB_ATTRIBUTES || op == IPP_OP_GET_JOBS || op == IPP_OP_GET_PRINTER_ATTRIBUTES || op == IPP_OP_GET_OUTPUT_DEVICE_ATTRIBUTES)))
2055
0
    {
2056
0
      for (j = 0; j < (sizeof(job_template) / sizeof(job_template[0])); j ++)
2057
0
        cupsArrayAdd(ra, (void *)job_template[j]);
2058
2059
0
      added = true;
2060
0
    }
2061
2062
0
    if (!strcmp(value, "printer-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_PRINTER_ATTRIBUTES || op == IPP_OP_GET_OUTPUT_DEVICE_ATTRIBUTES || op == IPP_OP_GET_PRINTERS || op == IPP_OP_CUPS_GET_DEFAULT || op == IPP_OP_CUPS_GET_PRINTERS || op == IPP_OP_CUPS_GET_CLASSES)))
2063
0
    {
2064
0
      for (j = 0; j < (sizeof(printer_description) / sizeof(printer_description[0])); j ++)
2065
0
        cupsArrayAdd(ra, (void *)printer_description[j]);
2066
2067
0
      added = true;
2068
0
    }
2069
2070
0
    if (!strcmp(value, "resource-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_RESOURCE_ATTRIBUTES || op == IPP_OP_GET_RESOURCES)))
2071
0
    {
2072
0
      for (j = 0; j < (sizeof(resource_description) / sizeof(resource_description[0])); j ++)
2073
0
        cupsArrayAdd(ra, (void *)resource_description[j]);
2074
2075
0
      added = true;
2076
0
    }
2077
2078
0
    if (!strcmp(value, "resource-status") || (!strcmp(value, "all") && (op == IPP_OP_GET_RESOURCE_ATTRIBUTES || op == IPP_OP_GET_RESOURCES)))
2079
0
    {
2080
0
      for (j = 0; j < (sizeof(resource_status) / sizeof(resource_status[0])); j ++)
2081
0
        cupsArrayAdd(ra, (void *)resource_status[j]);
2082
2083
0
      added = true;
2084
0
    }
2085
2086
0
    if (!strcmp(value, "resource-template") || (!strcmp(value, "all") && (op == IPP_OP_GET_RESOURCE_ATTRIBUTES || op == IPP_OP_GET_RESOURCES || op == IPP_OP_GET_SYSTEM_ATTRIBUTES)))
2087
0
    {
2088
0
      for (j = 0; j < (sizeof(resource_template) / sizeof(resource_template[0])); j ++)
2089
0
        cupsArrayAdd(ra, (void *)resource_template[j]);
2090
2091
0
      added = true;
2092
0
    }
2093
2094
0
    if (!strcmp(value, "subscription-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES || op == IPP_OP_GET_SUBSCRIPTIONS)))
2095
0
    {
2096
0
      for (j = 0; j < (sizeof(subscription_description) / sizeof(subscription_description[0])); j ++)
2097
0
        cupsArrayAdd(ra, (void *)subscription_description[j]);
2098
2099
0
      added = true;
2100
0
    }
2101
2102
0
    if (!strcmp(value, "subscription-template") || (!strcmp(value, "all") && (op == IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES || op == IPP_OP_GET_SUBSCRIPTIONS)))
2103
0
    {
2104
0
      for (j = 0; j < (sizeof(subscription_template) / sizeof(subscription_template[0])); j ++)
2105
0
        cupsArrayAdd(ra, (void *)subscription_template[j]);
2106
2107
0
      added = true;
2108
0
    }
2109
2110
0
    if (!strcmp(value, "system-description") || (!strcmp(value, "all") && op == IPP_OP_GET_SYSTEM_ATTRIBUTES))
2111
0
    {
2112
0
      for (j = 0; j < (sizeof(system_description) / sizeof(system_description[0])); j ++)
2113
0
        cupsArrayAdd(ra, (void *)system_description[j]);
2114
2115
0
      added = true;
2116
0
    }
2117
2118
0
    if (!strcmp(value, "system-status") || (!strcmp(value, "all") && op == IPP_OP_GET_SYSTEM_ATTRIBUTES))
2119
0
    {
2120
0
      for (j = 0; j < (sizeof(system_status) / sizeof(system_status[0])); j ++)
2121
0
        cupsArrayAdd(ra, (void *)system_status[j]);
2122
2123
0
      added = true;
2124
0
    }
2125
2126
0
    if (!added)
2127
0
      cupsArrayAdd(ra, (void *)value);
2128
0
  }
2129
2130
0
  return (ra);
2131
0
}
2132
2133
2134
//
2135
// 'ippEnumString()' - Return a string corresponding to the enum value.
2136
//
2137
2138
const char *        // O - Enum string
2139
ippEnumString(const char *attrname, // I - Attribute name
2140
              int        enumvalue) // I - Enum value
2141
0
{
2142
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2143
2144
2145
  // Check for standard enum values...
2146
0
  if (!strcmp(attrname, "document-state") && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_document_states) / sizeof(ipp_document_states[0]))))
2147
0
    return (ipp_document_states[enumvalue - 3]);
2148
0
  else if (!strcmp(attrname, "finishings") || !strcmp(attrname, "finishings-actual") || !strcmp(attrname, "finishings-default") || !strcmp(attrname, "finishings-ready") || !strcmp(attrname, "finishings-supported") || !strcmp(attrname, "job-finishings") || !strcmp(attrname, "job-finishings-default") || !strcmp(attrname, "job-finishings-supported"))
2149
0
  {
2150
0
    if (enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_finishings) / sizeof(ipp_finishings[0]))))
2151
0
      return (ipp_finishings[enumvalue - 3]);
2152
0
    else if (enumvalue >= 0x40000000 && enumvalue < (0x40000000 + (int)(sizeof(ipp_finishings_vendor) / sizeof(ipp_finishings_vendor[0]))))
2153
0
      return (ipp_finishings_vendor[enumvalue - 0x40000000]);
2154
0
  }
2155
0
  else if (!strcmp(attrname, "job-state") && enumvalue >= IPP_JSTATE_PENDING && enumvalue <= IPP_JSTATE_COMPLETED)
2156
0
    return (ipp_job_states[enumvalue - IPP_JSTATE_PENDING]);
2157
0
  else if (!strcmp(attrname, "operations-supported"))
2158
0
    return (ippOpString((ipp_op_t)enumvalue));
2159
0
  else if ((!strcmp(attrname, "orientation-requested") || !strcmp(attrname, "orientation-requested-actual") || !strcmp(attrname, "orientation-requested-default") || !strcmp(attrname, "orientation-requested-supported")) && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_orientation_requesteds) / sizeof(ipp_orientation_requesteds[0]))))
2160
0
    return (ipp_orientation_requesteds[enumvalue - 3]);
2161
0
  else if ((!strcmp(attrname, "print-quality") || !strcmp(attrname, "print-quality-actual") || !strcmp(attrname, "print-quality-default") || !strcmp(attrname, "print-quality-supported")) && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_print_qualities) / sizeof(ipp_print_qualities[0]))))
2162
0
    return (ipp_print_qualities[enumvalue - 3]);
2163
0
  else if (!strcmp(attrname, "printer-state") && enumvalue >= IPP_PSTATE_IDLE && enumvalue <= IPP_PSTATE_STOPPED)
2164
0
    return (ipp_printer_states[enumvalue - IPP_PSTATE_IDLE]);
2165
0
  else if (!strcmp(attrname, "resource-state") && enumvalue >= IPP_RSTATE_PENDING && enumvalue <= IPP_RSTATE_ABORTED)
2166
0
    return (ipp_resource_states[enumvalue - IPP_RSTATE_PENDING]);
2167
0
  else if (!strcmp(attrname, "system-state") && enumvalue >= IPP_SSTATE_IDLE && enumvalue <= IPP_SSTATE_STOPPED)
2168
0
    return (ipp_system_states[enumvalue - IPP_SSTATE_IDLE]);
2169
2170
  // Not a standard enum value, just return the decimal equivalent...
2171
0
  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "%d", enumvalue);
2172
0
  return (cg->ipp_unknown);
2173
0
}
2174
2175
2176
//
2177
// 'ippEnumValue()' - Return the value associated with a given enum string.
2178
//
2179
2180
int         // O - Enum value or `-1` if unknown
2181
ippEnumValue(const char *attrname,  // I - Attribute name
2182
             const char *enumstring)  // I - Enum string
2183
0
{
2184
0
  size_t  i,      // Looping var
2185
0
    num_strings;    // Number of strings to compare
2186
0
  const char * const *strings;    // Strings to compare
2187
2188
2189
  // If the string is just a number, return it...
2190
0
  if (isdigit(*enumstring & 255))
2191
0
    return ((int)strtol(enumstring, NULL, 0));
2192
2193
  // Otherwise look up the string...
2194
0
  if (!strcmp(attrname, "document-state"))
2195
0
  {
2196
0
    num_strings = sizeof(ipp_document_states) / sizeof(ipp_document_states[0]);
2197
0
    strings     = ipp_document_states;
2198
0
  }
2199
0
  else if (!strcmp(attrname, "finishings") ||
2200
0
     !strcmp(attrname, "finishings-actual") ||
2201
0
     !strcmp(attrname, "finishings-default") ||
2202
0
     !strcmp(attrname, "finishings-ready") ||
2203
0
     !strcmp(attrname, "finishings-supported"))
2204
0
  {
2205
0
    for (i = 0; i < (sizeof(ipp_finishings_vendor) / sizeof(ipp_finishings_vendor[0])); i ++)
2206
0
    {
2207
0
      if (!strcmp(enumstring, ipp_finishings_vendor[i]))
2208
0
  return (i + 0x40000000);
2209
0
    }
2210
2211
0
    num_strings = sizeof(ipp_finishings) / sizeof(ipp_finishings[0]);
2212
0
    strings     = ipp_finishings;
2213
0
  }
2214
0
  else if (!strcmp(attrname, "job-state"))
2215
0
  {
2216
0
    num_strings = sizeof(ipp_job_states) / sizeof(ipp_job_states[0]);
2217
0
    strings     = ipp_job_states;
2218
0
  }
2219
0
  else if (!strcmp(attrname, "operations-supported"))
2220
0
  {
2221
0
    return (ippOpValue(enumstring));
2222
0
  }
2223
0
  else if (!strcmp(attrname, "orientation-requested") ||
2224
0
           !strcmp(attrname, "orientation-requested-actual") ||
2225
0
           !strcmp(attrname, "orientation-requested-default") ||
2226
0
           !strcmp(attrname, "orientation-requested-supported"))
2227
0
  {
2228
0
    num_strings = sizeof(ipp_orientation_requesteds) / sizeof(ipp_orientation_requesteds[0]);
2229
0
    strings     = ipp_orientation_requesteds;
2230
0
  }
2231
0
  else if (!strcmp(attrname, "print-quality") ||
2232
0
           !strcmp(attrname, "print-quality-actual") ||
2233
0
           !strcmp(attrname, "print-quality-default") ||
2234
0
           !strcmp(attrname, "print-quality-supported"))
2235
0
  {
2236
0
    num_strings = sizeof(ipp_print_qualities) / sizeof(ipp_print_qualities[0]);
2237
0
    strings     = ipp_print_qualities;
2238
0
  }
2239
0
  else if (!strcmp(attrname, "printer-state"))
2240
0
  {
2241
0
    num_strings = sizeof(ipp_printer_states) / sizeof(ipp_printer_states[0]);
2242
0
    strings     = ipp_printer_states;
2243
0
  }
2244
0
  else if (!strcmp(attrname, "resource-state"))
2245
0
  {
2246
0
    num_strings = sizeof(ipp_resource_states) / sizeof(ipp_resource_states[0]);
2247
0
    strings     = ipp_resource_states;
2248
0
  }
2249
0
  else if (!strcmp(attrname, "system-state"))
2250
0
  {
2251
0
    num_strings = sizeof(ipp_system_states) / sizeof(ipp_system_states[0]);
2252
0
    strings     = ipp_system_states;
2253
0
  }
2254
0
  else
2255
0
  {
2256
0
    return (-1);
2257
0
  }
2258
2259
0
  for (i = 0; i < num_strings; i ++)
2260
0
  {
2261
0
    if (!strcmp(enumstring, strings[i]))
2262
0
      return (i + 3);
2263
0
  }
2264
2265
0
  return (-1);
2266
0
}
2267
2268
2269
//
2270
// 'ippErrorString()' - Return a name for the given status code.
2271
//
2272
2273
const char *        // O - Text string
2274
ippErrorString(ipp_status_t error)  // I - Error status
2275
0
{
2276
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2277
2278
2279
  // See if the error code is a known value...
2280
0
  if (error >= IPP_STATUS_OK && error <= IPP_STATUS_OK_EVENTS_COMPLETE)
2281
0
    return (ipp_status_oks[error]);
2282
0
  else if (error == IPP_STATUS_REDIRECTION_OTHER_SITE)
2283
0
    return ("redirection-other-site");
2284
0
  else if (error == IPP_STATUS_CUPS_SEE_OTHER)
2285
0
    return ("cups-see-other");
2286
0
  else if (error >= IPP_STATUS_ERROR_BAD_REQUEST && error <= IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED)
2287
0
    return (ipp_status_400s[error - IPP_STATUS_ERROR_BAD_REQUEST]);
2288
0
  else if (error >= IPP_STATUS_ERROR_INTERNAL && error <= IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS)
2289
0
    return (ipp_status_500s[error - IPP_STATUS_ERROR_INTERNAL]);
2290
0
  else if (error >= IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED && error <= IPP_STATUS_ERROR_CUPS_OAUTH)
2291
0
    return (ipp_status_1000s[error - IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED]);
2292
2293
  // No, build an "0xxxxx" error string...
2294
0
  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "0x%04x", error);
2295
2296
0
  return (cg->ipp_unknown);
2297
0
}
2298
2299
2300
//
2301
// 'ippErrorValue()' - Return a status code for the given name.
2302
//
2303
2304
ipp_status_t        // O - IPP status code
2305
ippErrorValue(const char *name)   // I - Name
2306
0
{
2307
0
  size_t  i;      // Looping var
2308
2309
2310
0
  for (i = 0; i < (sizeof(ipp_status_oks) / sizeof(ipp_status_oks[0])); i ++)
2311
0
  {
2312
0
    if (!_cups_strcasecmp(name, ipp_status_oks[i]))
2313
0
      return ((ipp_status_t)i);
2314
0
  }
2315
2316
0
  if (!_cups_strcasecmp(name, "redirection-other-site"))
2317
0
    return (IPP_STATUS_REDIRECTION_OTHER_SITE);
2318
2319
0
  if (!_cups_strcasecmp(name, "cups-see-other"))
2320
0
    return (IPP_STATUS_CUPS_SEE_OTHER);
2321
2322
0
  for (i = 0; i < (sizeof(ipp_status_400s) / sizeof(ipp_status_400s[0])); i ++)
2323
0
  {
2324
0
    if (!_cups_strcasecmp(name, ipp_status_400s[i]))
2325
0
      return ((ipp_status_t)(i + 0x400));
2326
0
  }
2327
2328
0
  for (i = 0; i < (sizeof(ipp_status_500s) / sizeof(ipp_status_500s[0])); i ++)
2329
0
  {
2330
0
    if (!_cups_strcasecmp(name, ipp_status_500s[i]))
2331
0
      return ((ipp_status_t)(i + 0x500));
2332
0
  }
2333
2334
0
  for (i = 0; i < (sizeof(ipp_status_1000s) / sizeof(ipp_status_1000s[0])); i ++)
2335
0
  {
2336
0
    if (!_cups_strcasecmp(name, ipp_status_1000s[i]))
2337
0
      return ((ipp_status_t)(i + 0x1000));
2338
0
  }
2339
2340
0
  return ((ipp_status_t)-1);
2341
0
}
2342
2343
2344
//
2345
// 'ippGetPort()' - Return the default IPP port number.
2346
//
2347
2348
int         // O - Port number
2349
ippGetPort(void)
2350
0
{
2351
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2352
2353
2354
0
  DEBUG_puts("ippPort()");
2355
2356
0
  if (!cg->client_conf_loaded)
2357
0
    _cupsSetDefaults();
2358
2359
0
  DEBUG_printf("1ippPort: Returning %d...", cg->ipp_port);
2360
2361
0
  return (cg->ipp_port);
2362
0
}
2363
2364
2365
//
2366
// 'ippOpString()' - Return a name for the given operation id.
2367
//
2368
2369
const char *        // O - Name
2370
ippOpString(ipp_op_t op)    // I - Operation ID
2371
0
{
2372
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2373
2374
2375
  // See if the operation ID is a known value...
2376
0
  if (op >= IPP_OP_PRINT_JOB && op < (ipp_op_t)(sizeof(ipp_std_ops) / sizeof(ipp_std_ops[0])))
2377
0
    return (ipp_std_ops[op]);
2378
0
  else if (op == IPP_OP_PRIVATE)
2379
0
    return ("windows-ext");
2380
0
  else if (op >= IPP_OP_CUPS_GET_DEFAULT && op <= IPP_OP_CUPS_GET_PPD)
2381
0
    return (ipp_cups_ops[op - IPP_OP_CUPS_GET_DEFAULT]);
2382
0
  else if (op >= IPP_OP_CUPS_GET_DOCUMENT && op <= IPP_OP_CUPS_CREATE_LOCAL_PRINTER)
2383
0
    return (ipp_cups_ops2[op - IPP_OP_CUPS_GET_DOCUMENT]);
2384
2385
  // No, build an "0xxxxx" operation string...
2386
0
  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "0x%04x", op);
2387
2388
0
  return (cg->ipp_unknown);
2389
0
}
2390
2391
2392
//
2393
// 'ippOpValue()' - Return an operation id for the given name.
2394
//
2395
2396
ipp_op_t        // O - Operation ID
2397
ippOpValue(const char *name)    // I - Textual name
2398
0
{
2399
0
  size_t  i;      // Looping var
2400
2401
2402
0
  if (!strncmp(name, "0x", 2))
2403
0
    return ((ipp_op_t)strtol(name + 2, NULL, 16));
2404
2405
0
  for (i = 0; i < (sizeof(ipp_std_ops) / sizeof(ipp_std_ops[0])); i ++)
2406
0
  {
2407
0
    if (!_cups_strcasecmp(name, ipp_std_ops[i]))
2408
0
      return ((ipp_op_t)i);
2409
0
  }
2410
2411
0
  if (!_cups_strcasecmp(name, "windows-ext"))
2412
0
    return (IPP_OP_PRIVATE);
2413
2414
0
  for (i = 0; i < (sizeof(ipp_cups_ops) / sizeof(ipp_cups_ops[0])); i ++)
2415
0
  {
2416
0
    if (!_cups_strcasecmp(name, ipp_cups_ops[i]))
2417
0
      return ((ipp_op_t)(i + 0x4001));
2418
0
  }
2419
2420
0
  for (i = 0; i < (sizeof(ipp_cups_ops2) / sizeof(ipp_cups_ops2[0])); i ++)
2421
0
  {
2422
0
    if (!_cups_strcasecmp(name, ipp_cups_ops2[i]))
2423
0
      return ((ipp_op_t)(i + 0x4027));
2424
0
  }
2425
2426
0
  if (!_cups_strcasecmp(name, "Create-Job-Subscription"))
2427
0
    return (IPP_OP_CREATE_JOB_SUBSCRIPTIONS);
2428
2429
0
  if (!_cups_strcasecmp(name, "Create-Printer-Subscription"))
2430
0
    return (IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS);
2431
2432
0
  if (!_cups_strcasecmp(name, "CUPS-Add-Class"))
2433
0
    return (IPP_OP_CUPS_ADD_MODIFY_CLASS);
2434
2435
0
  if (!_cups_strcasecmp(name, "CUPS-Add-Printer"))
2436
0
    return (IPP_OP_CUPS_ADD_MODIFY_PRINTER);
2437
2438
0
  return (IPP_OP_CUPS_INVALID);
2439
0
}
2440
2441
2442
//
2443
// 'ippSetPort()' - Set the default port number.
2444
//
2445
2446
void
2447
ippSetPort(int p)     // I - Port number to use
2448
0
{
2449
0
  DEBUG_printf("ippSetPort(p=%d)", p);
2450
2451
0
  _cupsGlobals()->ipp_port = p;
2452
0
}
2453
2454
2455
//
2456
// 'ippStateString()' - Return the name corresponding to a state value.
2457
//
2458
2459
const char *        // O - State name
2460
ippStateString(ipp_state_t state) // I - State value
2461
0
{
2462
0
  if (state >= IPP_STATE_ERROR && state <= IPP_STATE_DATA)
2463
0
    return (ipp_states[state - IPP_STATE_ERROR]);
2464
0
  else
2465
0
    return ("UNKNOWN");
2466
0
}
2467
2468
2469
//
2470
// 'ippTagString()' - Return the tag name corresponding to a tag value.
2471
//
2472
// The returned names are defined in RFC 8011 and the IANA IPP Registry.
2473
//
2474
2475
const char *        // O - Tag name
2476
ippTagString(ipp_tag_t tag)   // I - Tag value
2477
0
{
2478
0
  tag &= IPP_TAG_CUPS_MASK;
2479
2480
0
  if (tag < (ipp_tag_t)(sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])))
2481
0
    return (ipp_tag_names[tag]);
2482
0
  else
2483
0
    return ("UNKNOWN");
2484
0
}
2485
2486
2487
//
2488
// 'ippTagValue()' - Return the tag value corresponding to a tag name.
2489
//
2490
// The tag names are defined in RFC 8011 and the IANA IPP Registry.
2491
//
2492
2493
ipp_tag_t       // O - Tag value
2494
ippTagValue(const char *name)   // I - Tag name
2495
0
{
2496
0
  size_t  i;      // Looping var
2497
2498
2499
0
  for (i = 0; i < (sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])); i ++)
2500
0
  {
2501
0
    if (!_cups_strcasecmp(name, ipp_tag_names[i]))
2502
0
      return ((ipp_tag_t)i);
2503
0
  }
2504
2505
0
  if (!_cups_strcasecmp(name, "operation"))
2506
0
    return (IPP_TAG_OPERATION);
2507
0
  else if (!_cups_strcasecmp(name, "job"))
2508
0
    return (IPP_TAG_JOB);
2509
0
  else if (!_cups_strcasecmp(name, "printer"))
2510
0
    return (IPP_TAG_PRINTER);
2511
0
  else if (!_cups_strcasecmp(name, "unsupported"))
2512
0
    return (IPP_TAG_UNSUPPORTED_GROUP);
2513
0
  else if (!_cups_strcasecmp(name, "subscription"))
2514
0
    return (IPP_TAG_SUBSCRIPTION);
2515
0
  else if (!_cups_strcasecmp(name, "event"))
2516
0
    return (IPP_TAG_EVENT_NOTIFICATION);
2517
0
  else if (!_cups_strcasecmp(name, "language"))
2518
0
    return (IPP_TAG_LANGUAGE);
2519
0
  else if (!_cups_strcasecmp(name, "mimetype"))
2520
0
    return (IPP_TAG_MIMETYPE);
2521
0
  else if (!_cups_strcasecmp(name, "name"))
2522
0
    return (IPP_TAG_NAME);
2523
0
  else if (!_cups_strcasecmp(name, "text"))
2524
0
    return (IPP_TAG_TEXT);
2525
0
  else if (!_cups_strcasecmp(name, "begCollection"))
2526
0
    return (IPP_TAG_BEGIN_COLLECTION);
2527
0
  else
2528
0
    return (IPP_TAG_ZERO);
2529
0
}
2530
2531
2532
//
2533
// 'ipp_col_string()' - Convert a collection to a string.
2534
//
2535
2536
static size_t       // O - Number of bytes
2537
ipp_col_string(ipp_t  *col,   // I - Collection attribute
2538
               char   *buffer,    // I - Buffer or NULL
2539
               size_t bufsize)    // I - Size of buffer
2540
0
{
2541
0
  char      *bufptr,  // Position in buffer
2542
0
      *bufend,  // End of buffer
2543
0
      prefix = '{', // Prefix character
2544
0
      temp[256];  // Temporary string
2545
0
  ipp_attribute_t *attr;    // Current member attribute
2546
2547
2548
0
  if (!col)
2549
0
  {
2550
0
    if (buffer)
2551
0
      *buffer = '\0';
2552
2553
0
    return (0);
2554
0
  }
2555
2556
0
  bufptr = buffer;
2557
0
  bufend = buffer + bufsize - 1;
2558
2559
0
  for (attr = col->attrs; attr; attr = attr->next)
2560
0
  {
2561
0
    if (!attr->name)
2562
0
      continue;
2563
2564
0
    if (buffer && bufptr < bufend)
2565
0
      *bufptr = prefix;
2566
0
    bufptr ++;
2567
0
    prefix = ' ';
2568
2569
0
    if (buffer && bufptr < bufend)
2570
0
      bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%s=", attr->name);
2571
0
    else
2572
0
      bufptr += strlen(attr->name) + 1;
2573
2574
0
    if (buffer && bufptr < bufend)
2575
0
      bufptr += ippAttributeString(attr, bufptr, (size_t)(bufend - bufptr + 1));
2576
0
    else
2577
0
      bufptr += ippAttributeString(attr, temp, sizeof(temp));
2578
0
  }
2579
2580
0
  if (prefix == '{')
2581
0
  {
2582
0
    if (buffer && bufptr < bufend)
2583
0
      *bufptr = prefix;
2584
0
    bufptr ++;
2585
0
  }
2586
2587
0
  if (buffer && bufptr < bufend)
2588
0
    *bufptr = '}';
2589
0
  bufptr ++;
2590
2591
0
  return ((size_t)(bufptr - buffer));
2592
0
}