Coverage Report

Created: 2026-01-09 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cups/cups/ipp-support.c
Line
Count
Source
1
//
2
// Internet Printing Protocol support functions for CUPS.
3
//
4
// Copyright © 2020-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
// @since CUPS 1.6@
608
//
609
610
size_t          // O - Number of bytes less `nul`
611
ippAttributeString(
612
    ipp_attribute_t *attr,    // I - Attribute
613
    char            *buffer,    // I - String buffer or `NULL`
614
    size_t          bufsize)    // I - Size of string buffer
615
0
{
616
0
  int   i;      // Looping var
617
0
  char    *bufptr,    // Pointer into buffer
618
0
    *bufend,    // End of buffer
619
0
    temp[256];    // Temporary string
620
0
  const char  *ptr,     // Pointer into string
621
0
    *end;     // Pointer to end of string
622
0
  _ipp_value_t  *val;     // Current value
623
624
625
  // Range check input...
626
0
  if (!attr || !attr->name)
627
0
  {
628
0
    if (buffer)
629
0
      *buffer = '\0';
630
631
0
    return (0);
632
0
  }
633
634
  // Setup buffer pointers...
635
0
  bufptr = buffer;
636
0
  if (buffer)
637
0
    bufend = buffer + bufsize - 1;
638
0
  else
639
0
    bufend = NULL;
640
641
  // Loop through the values...
642
0
  for (i = attr->num_values, val = attr->values; i > 0; i --, val ++)
643
0
  {
644
0
    if (val > attr->values)
645
0
    {
646
0
      if (buffer && bufptr < bufend)
647
0
        *bufptr++ = ',';
648
0
      else
649
0
        bufptr ++;
650
0
    }
651
652
0
    switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
653
0
    {
654
0
      case IPP_TAG_ENUM :
655
0
          ptr = ippEnumString(attr->name, val->integer);
656
657
0
          if (buffer && bufptr < bufend)
658
0
            cupsCopyString(bufptr, ptr, (size_t)(bufend - bufptr + 1));
659
660
0
          bufptr += strlen(ptr);
661
0
          break;
662
663
0
      case IPP_TAG_INTEGER :
664
0
          if (buffer && bufptr < bufend)
665
0
            bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d", val->integer);
666
0
          else
667
0
            bufptr += snprintf(temp, sizeof(temp), "%d", val->integer);
668
0
          break;
669
670
0
      case IPP_TAG_BOOLEAN :
671
0
          if (buffer && bufptr < bufend)
672
0
            cupsCopyString(bufptr, val->boolean ? "true" : "false", (size_t)(bufend - bufptr + 1));
673
674
0
          bufptr += val->boolean ? 4 : 5;
675
0
          break;
676
677
0
      case IPP_TAG_RANGE :
678
0
          if (buffer && bufptr < bufend)
679
0
            bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d-%d", val->range.lower, val->range.upper);
680
0
          else
681
0
            bufptr += snprintf(temp, sizeof(temp), "%d-%d", val->range.lower, val->range.upper);
682
0
          break;
683
684
0
      case IPP_TAG_RESOLUTION :
685
0
    if (val->resolution.xres == val->resolution.yres)
686
0
    {
687
0
      if (buffer && bufptr < bufend)
688
0
        bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%d%s", val->resolution.xres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
689
0
      else
690
0
        bufptr += snprintf(temp, sizeof(temp), "%d%s", val->resolution.xres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
691
0
    }
692
0
    else if (buffer && bufptr < bufend)
693
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");
694
0
          else
695
0
            bufptr += snprintf(temp, sizeof(temp), "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
696
0
          break;
697
698
0
      case IPP_TAG_DATE :
699
0
          {
700
0
            unsigned year;    // Year
701
702
0
            year = ((unsigned)val->date[0] << 8) | (unsigned)val->date[1];
703
704
0
      if (val->date[9] == 0 && val->date[10] == 0)
705
0
        snprintf(temp, sizeof(temp), "%04u-%02u-%02uT%02u:%02u:%02uZ",
706
0
           year, val->date[2], val->date[3], val->date[4],
707
0
           val->date[5], val->date[6]);
708
0
      else
709
0
        snprintf(temp, sizeof(temp),
710
0
                 "%04u-%02u-%02uT%02u:%02u:%02u%c%02u%02u",
711
0
           year, val->date[2], val->date[3], val->date[4],
712
0
           val->date[5], val->date[6], val->date[8], val->date[9],
713
0
           val->date[10]);
714
715
0
            if (buffer && bufptr < bufend)
716
0
              cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr + 1));
717
718
0
            bufptr += strlen(temp);
719
0
          }
720
0
          break;
721
722
0
      case IPP_TAG_TEXT :
723
0
      case IPP_TAG_NAME :
724
0
      case IPP_TAG_KEYWORD :
725
0
      case IPP_TAG_CHARSET :
726
0
      case IPP_TAG_URI :
727
0
      case IPP_TAG_URISCHEME :
728
0
      case IPP_TAG_MIMETYPE :
729
0
      case IPP_TAG_LANGUAGE :
730
0
      case IPP_TAG_TEXTLANG :
731
0
      case IPP_TAG_NAMELANG :
732
0
    if (!val->string.text)
733
0
      break;
734
735
0
          for (ptr = val->string.text; *ptr; ptr ++)
736
0
          {
737
0
            if (*ptr == '\\' || *ptr == '\"' || *ptr == '[')
738
0
            {
739
0
              if (buffer && bufptr < bufend)
740
0
                *bufptr = '\\';
741
0
              bufptr ++;
742
0
            }
743
744
0
            if (buffer && bufptr < bufend)
745
0
              *bufptr = *ptr;
746
0
            bufptr ++;
747
0
          }
748
749
0
          if (val->string.language)
750
0
          {
751
           /*
752
            * Add "[language]" to end of string...
753
            */
754
755
0
            if (buffer && bufptr < bufend)
756
0
              *bufptr = '[';
757
0
            bufptr ++;
758
759
0
            if (buffer && bufptr < bufend)
760
0
              cupsCopyString(bufptr, val->string.language, (size_t)(bufend - bufptr));
761
0
            bufptr += strlen(val->string.language);
762
763
0
            if (buffer && bufptr < bufend)
764
0
              *bufptr = ']';
765
0
            bufptr ++;
766
0
          }
767
0
          break;
768
769
0
      case IPP_TAG_BEGIN_COLLECTION :
770
0
          if (buffer && bufptr < bufend)
771
0
            bufptr += ipp_col_string(val->collection, bufptr, (size_t)(bufend - bufptr + 1));
772
0
          else
773
0
            bufptr += ipp_col_string(val->collection, NULL, 0);
774
0
          break;
775
776
0
      case IPP_TAG_STRING :
777
0
          for (ptr = val->unknown.data, end = ptr + val->unknown.length;
778
0
               ptr < end; ptr ++)
779
0
          {
780
0
            if (*ptr == '\\' || _cups_isspace(*ptr))
781
0
            {
782
0
              if (buffer && bufptr < bufend)
783
0
                *bufptr = '\\';
784
0
              bufptr ++;
785
786
0
              if (buffer && bufptr < bufend)
787
0
                *bufptr = *ptr;
788
0
              bufptr ++;
789
0
            }
790
0
            else if (!isprint(*ptr & 255))
791
0
            {
792
0
              if (buffer && bufptr < bufend)
793
0
                bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "\\%03o", *ptr & 255);
794
0
              else
795
0
                bufptr += snprintf(temp, sizeof(temp), "\\%03o", *ptr & 255);
796
0
            }
797
0
            else
798
0
            {
799
0
              if (buffer && bufptr < bufend)
800
0
                *bufptr = *ptr;
801
0
              bufptr ++;
802
0
            }
803
0
          }
804
0
          break;
805
806
0
      default :
807
0
          ptr = ippTagString(attr->value_tag);
808
0
          if (buffer && bufptr < bufend)
809
0
            cupsCopyString(bufptr, ptr, (size_t)(bufend - bufptr + 1));
810
0
          bufptr += strlen(ptr);
811
0
          break;
812
0
    }
813
0
  }
814
815
  // Nul-terminate and return...
816
0
  if (buffer && bufptr < bufend)
817
0
    *bufptr = '\0';
818
0
  else if (bufend)
819
0
    *bufend = '\0';
820
821
0
  return ((size_t)(bufptr - buffer));
822
0
}
823
824
825
//
826
// 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
827
//                               given requested-attributes attribute.
828
//
829
// This function creates a (sorted) CUPS array of attribute names matching the
830
// list of "requested-attribute" values supplied in an IPP request.  All IANA-
831
// registered values are supported in addition to the CUPS IPP extension
832
// attributes.
833
//
834
// The "request" argument specifies the request message that was read from
835
// the client.
836
//
837
// `NULL` is returned if all attributes should be returned.  Otherwise, the
838
// result is a sorted array of attribute names, where
839
// `cupsArrayFind(array, "attribute-name")` will return a non-`NULL` pointer.
840
// The array must be freed using @link cupsArrayDelete@.
841
//
842
// @since CUPS 1.7@
843
//
844
845
cups_array_t *        // O - CUPS array or `NULL` if all
846
ippCreateRequestedArray(ipp_t *request) // I - IPP request
847
0
{
848
0
  size_t    i, j,   // Looping vars
849
0
      count;    // Number of values
850
0
  bool      added;    // Was name added?
851
0
  ipp_op_t    op;   // IPP operation code
852
0
  ipp_attribute_t *requested; // requested-attributes attribute
853
0
  cups_array_t    *ra;    // Requested attributes array
854
0
  const char    *value;   // Current value
855
  // The following lists come from the current IANA IPP registry of attributes
856
0
  static const char * const document_description[] =
857
0
  {         // document-description group
858
0
    "compression",
859
0
    "copies-actual",
860
0
    "cover-back-actual",
861
0
    "cover-front-actual",
862
0
    "current-page-order",
863
0
    "date-time-at-completed",
864
0
    "date-time-at-creation",
865
0
    "date-time-at-processing",
866
0
    "detailed-status-messages",
867
0
    "document-access-errors",
868
0
    "document-charset",
869
0
    "document-format",
870
0
    "document-format-details",    // IPP JobExt
871
0
    "document-format-detected",   // IPP JobExt
872
0
    "document-job-id",
873
0
    "document-job-uri",
874
0
    "document-message",
875
0
    "document-metadata",
876
0
    "document-name",
877
0
    "document-natural-language",
878
0
    "document-number",
879
0
    "document-printer-uri",
880
0
    "document-state",
881
0
    "document-state-message",
882
0
    "document-state-reasons",
883
0
    "document-uri",
884
0
    "document-uuid",      // IPP NODRIVER
885
0
    "errors-count",     // IPP JobExt
886
0
    "finishings-actual",
887
0
    "finishings-col-actual",
888
0
    "force-front-side-actual",
889
0
    "imposition-template-actual",
890
0
    "impressions",
891
0
    "impressions-col",
892
0
    "impressions-completed",
893
0
    "impressions-completed-col",
894
0
    "impressions-completed-current-copy",
895
0
    "insert-sheet-actual",
896
0
    "k-octets",
897
0
    "k-octets-processed",
898
0
    "last-document",
899
0
    "materials-col-actual",   // IPP 3D
900
0
    "media-actual",
901
0
    "media-col-actual",
902
0
    "media-input-tray-check-actual",
903
0
    "media-sheets",
904
0
    "media-sheets-col",
905
0
    "media-sheets-completed",
906
0
    "media-sheets-completed-col",
907
0
    "more-info",
908
0
    "multiple-object-handling-actual",  // IPP 3D
909
0
    "number-up-actual",
910
0
    "orientation-requested-actual",
911
0
    "output-bin-actual",
912
0
    "output-device-assigned",
913
0
    "overrides-actual",
914
0
    "page-delivery-actual",
915
0
    "page-order-received-actual",
916
0
    "page-ranges-actual",
917
0
    "pages",
918
0
    "pages-col",
919
0
    "pages-completed",
920
0
    "pages-completed-col",
921
0
    "pages-completed-current-copy",
922
0
    "platform-temperature-actual",  // IPP 3D
923
0
    "presentation-direction-number-up-actual",
924
0
    "print-accuracy-actual",    // IPP 3D
925
0
    "print-base-actual",    // IPP 3D
926
0
    "print-color-mode-actual",
927
0
    "print-content-optimize-actual",  // IPP JobExt
928
0
    "print-objects-actual",   // IPP 3D
929
0
    "print-quality-actual",
930
0
    "print-rendering-intent-actual",
931
0
    "print-scaling-actual",   // IPP Paid Printing
932
0
    "print-supports-actual",    // IPP 3D
933
0
    "printer-resolution-actual",
934
0
    "printer-up-time",
935
0
    "separator-sheets-actual",
936
0
    "sheet-completed-copy-number",
937
0
    "sides-actual",
938
0
    "time-at-completed",
939
0
    "time-at-creation",
940
0
    "time-at-processing",
941
0
    "warnings-count",     // IPP JobExt
942
0
    "x-image-position-actual",
943
0
    "x-image-shift-actual",
944
0
    "x-side1-image-shift-actual",
945
0
    "x-side2-image-shift-actual",
946
0
    "y-image-position-actual",
947
0
    "y-image-shift-actual",
948
0
    "y-side1-image-shift-actual",
949
0
    "y-side2-image-shift-actual"
950
0
  };
951
0
  static const char * const document_template[] =
952
0
  {         // document-template group
953
0
    "baling-type-supported",    // IPP FIN
954
0
    "baling-when-supported",    // IPP FIN
955
0
    "binding-reference-edge-supported", // IPP FIN
956
0
    "binding-type-supported",   // IPP FIN
957
0
    "chamber-humidity",     // IPP 3D
958
0
    "chamber-humidity-default",   // IPP 3D
959
0
    "chamber-humidity-supported", // IPP 3D
960
0
    "chamber-temperature",    // IPP 3D
961
0
    "chamber-temperature-default",  // IPP 3D
962
0
    "chamber-temperature-supported",  // IPP 3D
963
0
    "coating-sides-supported",    // IPP FIN
964
0
    "coating-type-supported",   // IPP FIN
965
0
    "copies",
966
0
    "copies-default",
967
0
    "copies-supported",
968
0
    "cover-back",     // IPP PPX
969
0
    "cover-back-default",   // IPP PPX
970
0
    "cover-back-supported",   // IPP PPX
971
0
    "cover-front",      // IPP PPX
972
0
    "cover-front-default",    // IPP PPX
973
0
    "cover-front-supported",    // IPP PPX
974
0
    "covering-name-supported",    // IPP FIN
975
0
    "feed-orientation",
976
0
    "feed-orientation-default",
977
0
    "feed-orientation-supported",
978
0
    "finishing-template-supported", // IPP FIN
979
0
    "finishings",
980
0
    "finishings-col",     // IPP FIN
981
0
    "finishings-col-database",    // IPP FIN
982
0
    "finishings-col-default",   // IPP FIN
983
0
    "finishings-col-ready",   // IPP FIN
984
0
    "finishings-col-supported",   // IPP FIN
985
0
    "finishings-default",
986
0
    "finishings-ready",
987
0
    "finishings-supported",
988
0
    "folding-direction-supported",  // IPP FIN
989
0
    "folding-offset-supported",   // IPP FIN
990
0
    "folding-reference-edge-supported", // IPP FIN
991
0
    "force-front-side",     // IPP PPX
992
0
    "force-front-side-default",   // IPP PPX
993
0
    "force-front-side-supported", // IPP PPX
994
0
    "imposition-template",    // IPP PPX
995
0
    "imposition-template-default",  // IPP PPX
996
0
    "imposition-template-supported",  // IPP PPX
997
0
    "insert-count-supported",   // IPP PPX
998
0
    "insert-sheet",     // IPP PPX
999
0
    "insert-sheet-default",   // IPP PPX
1000
0
    "insert-sheet-supported",   // IPP PPX
1001
0
    "laminating-sides-supported", // IPP FIN
1002
0
    "laminating-type-supported",  // IPP FIN
1003
0
    "material-amount-units-supported",  // IPP 3D
1004
0
    "material-diameter-supported",  // IPP 3D
1005
0
    "material-purpose-supported", // IPP 3D
1006
0
    "material-rate-supported",    // IPP 3D
1007
0
    "material-rate-units-supported",  // IPP 3D
1008
0
    "material-shell-thickness-supported",
1009
          // IPP 3D
1010
0
    "material-temperature-supported", // IPP 3D
1011
0
    "material-type-supported",    // IPP 3D
1012
0
    "materials-col",      // IPP 3D
1013
0
    "materials-col-database",   // IPP 3D
1014
0
    "materials-col-default",    // IPP 3D
1015
0
    "materials-col-ready",    // IPP 3D
1016
0
    "materials-col-supported",    // IPP 3D
1017
0
    "max-materials-col-supported",  // IPP 3D
1018
0
    "max-page-ranges-supported",
1019
0
    "max-stitching-locations-supported",// IPP FIN
1020
0
    "media",
1021
0
    "media-back-coating-supported", // IPP JobExt
1022
0
    "media-bottom-margin-supported",  // IPP JobExt
1023
0
    "media-col",      // IPP JobExt
1024
0
    "media-col-default",    // IPP JobExt
1025
0
    "media-col-ready",      // IPP JobExt
1026
0
    "media-col-supported",    // IPP JobExt
1027
0
    "media-color-supported",    // IPP JobExt
1028
0
    "media-default",
1029
0
    "media-front-coating-supported",  // IPP JobExt
1030
0
    "media-grain-supported",    // IPP JobExt
1031
0
    "media-hole-count-supported", // IPP JobExt
1032
0
    "media-info-supported",   // IPP JobExt
1033
0
    "media-input-tray-check",   // IPP PPX
1034
0
    "media-input-tray-check-default", // IPP PPX
1035
0
    "media-input-tray-check-supported", // IPP PPX
1036
0
    "media-key-supported",    // IPP JobExt
1037
0
    "media-left-margin-supported",  // IPP JobExt
1038
0
    "media-order-count-supported",  // IPP JobExt
1039
0
    "media-overprint",      // IPP NODRIVER
1040
0
    "media-overprint-distance-supported",
1041
          // IPP NODRIVER
1042
0
    "media-overprint-method-supported", // IPP NODRIVER
1043
0
    "media-overprint-supported",  // IPP NODRIVER
1044
0
    "media-pre-printed-supported",  // IPP JobExt
1045
0
    "media-ready",
1046
0
    "media-recycled-supported",   // IPP JobExt
1047
0
    "media-right-margin-supported", // IPP JobExt
1048
0
    "media-size-supported",   // IPP JobExt
1049
0
    "media-source-supported",   // IPP JobExt
1050
0
    "media-supported",
1051
0
    "media-thickness-supported",  // IPP JobExt
1052
0
    "media-top-margin-supported", // IPP JobExt
1053
0
    "media-type-supported",   // IPP JobExt
1054
0
    "media-weight-metric-supported",  // IPP JobExt
1055
0
    "multiple-document-handling",
1056
0
    "multiple-document-handling-default",
1057
0
    "multiple-document-handling-supported",
1058
0
    "multiple-object-handling",   // IPP 3D
1059
0
    "multiple-object-handling-default", // IPP 3D
1060
0
    "multiple-object-handling-supported",
1061
          // IPP 3D
1062
0
    "number-up",
1063
0
    "number-up-default",
1064
0
    "number-up-supported",
1065
0
    "orientation-requested",
1066
0
    "orientation-requested-default",
1067
0
    "orientation-requested-supported",
1068
0
    "output-device",      // IPP JobExt
1069
0
    "output-device-supported",    // IPP JobExt
1070
0
    "output-mode",      // CUPS extension
1071
0
    "output-mode-default",    // CUPS extension
1072
0
    "output-mode-supported",    // CUPS extension
1073
0
    "overrides",
1074
0
    "overrides-supported",
1075
0
    "page-delivery",      // IPP PPX
1076
0
    "page-delivery-default",    // IPP PPX
1077
0
    "page-delivery-supported",    // IPP PPX
1078
0
    "page-ranges",
1079
0
    "page-ranges-supported",
1080
0
    "platform-temperature",   // IPP 3D
1081
0
    "platform-temperature-default", // IPP 3D
1082
0
    "platform-temperature-supported", // IPP 3D
1083
0
    "preferred-attributes-supported", // IPP NODRIVER
1084
0
    "presentation-direction-number-up", // IPP PPX
1085
0
    "presentation-direction-number-up-default",
1086
          // IPP PPX
1087
0
    "presentation-direction-number-up-supported",
1088
          // IPP PPX
1089
0
    "print-accuracy",     // IPP 3D
1090
0
    "print-accuracy-default",   // IPP 3D
1091
0
    "print-accuracy-supported",   // IPP 3D
1092
0
    "print-base",     // IPP 3D
1093
0
    "print-base-default",   // IPP 3D
1094
0
    "print-base-supported",   // IPP 3D
1095
0
    "print-color-mode",     // IPP NODRIVER
1096
0
    "print-color-mode-default",   // IPP NODRIVER
1097
0
    "print-color-mode-supported", // IPP NODRIVER
1098
0
    "print-content-optimize",   // IPP JobExt
1099
0
    "print-content-optimize-default", // IPP JobExt
1100
0
    "print-content-optimize-supported", // IPP JobExt
1101
0
    "print-objects",      // IPP 3D
1102
0
    "print-objects-default",    // IPP 3D
1103
0
    "print-objects-supported",    // IPP 3D
1104
0
    "print-processing-attributes-supported",
1105
          // IPP NODRIVER
1106
0
    "print-quality",
1107
0
    "print-quality-default",
1108
0
    "print-quality-supported",
1109
0
    "print-rendering-intent",   // IPP NODRIVER
1110
0
    "print-rendering-intent-default", // IPP NODRIVER
1111
0
    "print-rendering-intent-supported", // IPP NODRIVER
1112
0
    "print-scaling",      // IPP NODRIVER
1113
0
    "print-scaling-default",    // IPP NODRIVER
1114
0
    "print-scaling-supported",    // IPP NODRIVER
1115
0
    "print-supports",     // IPP 3D
1116
0
    "print-supports-default",   // IPP 3D
1117
0
    "print-supports-supported",   // IPP 3D
1118
0
    "printer-resolution",
1119
0
    "printer-resolution-default",
1120
0
    "printer-resolution-supported",
1121
0
    "punching-hole-diameter-configured",// IPP FIN
1122
0
    "punching-locations-supported", // IPP FIN
1123
0
    "punching-offset-supported",  // IPP FIN
1124
0
    "punching-reference-edge-supported",// IPP FIN
1125
0
    "separator-sheets",     // IPP PPX
1126
0
    "separator-sheets-default",   // IPP PPX
1127
0
    "separator-sheets-supported", // IPP PPX
1128
0
    "separator-sheets-type-supported",  // IPP PPX
1129
0
    "sides",
1130
0
    "sides-default",
1131
0
    "sides-supported",
1132
0
    "stitching-angle-supported",  // IPP FIN
1133
0
    "stitching-locations-supported",  // IPP FIN
1134
0
    "stitching-method-supported", // IPP FIN
1135
0
    "stitching-offset-supported", // IPP FIN
1136
0
    "stitching-reference-edge-supported",
1137
          // IPP FIN
1138
0
    "x-image-position",     // IPP PPX
1139
0
    "x-image-position-default",   // IPP PPX
1140
0
    "x-image-position-supported", // IPP PPX
1141
0
    "x-image-shift",      // IPP PPX
1142
0
    "x-image-shift-default",    // IPP PPX
1143
0
    "x-image-shift-supported",    // IPP PPX
1144
0
    "x-side1-image-shift",    // IPP PPX
1145
0
    "x-side1-image-shift-default",  // IPP PPX
1146
0
    "x-side1-image-shift-supported",  // IPP PPX
1147
0
    "x-side2-image-shift",    // IPP PPX
1148
0
    "x-side2-image-shift-default",  // IPP PPX
1149
0
    "x-side2-image-shift-supported",  // IPP PPX
1150
0
    "y-image-position",     // IPP PPX
1151
0
    "y-image-position-default",   // IPP PPX
1152
0
    "y-image-position-supported", // IPP PPX
1153
0
    "y-image-shift",      // IPP PPX
1154
0
    "y-image-shift-default",    // IPP PPX
1155
0
    "y-image-shift-supported",    // IPP PPX
1156
0
    "y-side1-image-shift",    // IPP PPX
1157
0
    "y-side1-image-shift-default",  // IPP PPX
1158
0
    "y-side1-image-shift-supported",  // IPP PPX
1159
0
    "y-side2-image-shift",    // IPP PPX
1160
0
    "y-side2-image-shift-default",  // IPP PPX
1161
0
    "y-side2-image-shift-supported" // IPP PPX
1162
0
  };
1163
0
  static const char * const job_description[] =
1164
0
  {         // job-description group
1165
0
    "chamber-humidity-actual",    // IPP 3D
1166
0
    "chamber-temperature-actual", // IPP 3D
1167
0
    "client-info",      // IPP JobExt
1168
0
    "compression-supplied",
1169
0
    "copies-actual",
1170
0
    "cover-back-actual",
1171
0
    "cover-front-actual",
1172
0
    "current-page-order",
1173
0
    "date-time-at-completed",
1174
0
    "date-time-at-completed-estimated", // IPP PPX
1175
0
    "date-time-at-creation",
1176
0
    "date-time-at-processing",
1177
0
    "date-time-at-processing-estimated",// IPP PPX
1178
0
    "destination-statuses",
1179
0
    "document-charset-supplied",
1180
0
    "document-digital-signature-supplied",
1181
0
    "document-format-details-supplied",
1182
0
    "document-format-supplied",
1183
0
    "document-message-supplied",
1184
0
    "document-metadata",
1185
0
    "document-name-supplied",
1186
0
    "document-natural-language-supplied",
1187
0
    "document-overrides-actual",
1188
0
    "errors-count",
1189
0
    "finishings-actual",
1190
0
    "finishings-col-actual",
1191
0
    "force-front-side-actual",
1192
0
    "imposition-template-actual",
1193
0
    "impressions-completed-current-copy",
1194
0
    "insert-sheet-actual",
1195
0
    "job-account-id-actual",
1196
0
    "job-accounting-sheets-actual",
1197
0
    "job-accounting-user-id-actual",
1198
0
    "job-attribute-fidelity",
1199
0
    "job-charge-info",      // CUPS extension
1200
0
    "job-detailed-status-message",
1201
0
    "job-document-access-errors",
1202
0
    "job-error-sheet-actual",
1203
0
    "job-hold-until-actual",
1204
0
    "job-id",
1205
0
    "job-impressions",
1206
0
    "job-impressions-col",    // IPP JobExt
1207
0
    "job-impressions-completed",
1208
0
    "job-impressions-completed-col",  // IPP JobExt
1209
0
    "job-k-octets",
1210
0
    "job-k-octets-processed",
1211
0
    "job-mandatory-attributes",
1212
0
    "job-media-progress",   // CUPS extension
1213
0
    "job-media-sheets",
1214
0
    "job-media-sheets-col",   // IPP JobExt
1215
0
    "job-media-sheets-completed",
1216
0
    "job-media-sheets-completed-col", // IPP JobExt
1217
0
    "job-message-from-operator",
1218
0
    "job-more-info",
1219
0
    "job-name",
1220
0
    "job-originating-host-name",  // CUPS extension
1221
0
    "job-originating-user-name",
1222
0
    "job-originating-user-uri",   // IPP NODRIVER
1223
0
    "job-pages",      // IPP JobExt
1224
0
    "job-pages-col",      // IPP JobExt
1225
0
    "job-pages-completed",    // IPP JobExt
1226
0
    "job-pages-completed-col",    // IPP JobExt
1227
0
    "job-pages-completed-current-copy",
1228
0
    "job-printer-state-message",  // CUPS extension
1229
0
    "job-printer-state-reasons",  // CUPS extension
1230
0
    "job-printer-up-time",
1231
0
    "job-printer-uri",
1232
0
    "job-priority-actual",
1233
0
    "job-processing-time",    // IPP JobExt
1234
0
    "job-resource-ids",     // IPP System
1235
0
    "job-save-printer-make-and-model",
1236
0
    "job-sheet-message-actual",
1237
0
    "job-sheets-actual",
1238
0
    "job-sheets-col-actual",
1239
0
    "job-state",
1240
0
    "job-state-message",
1241
0
    "job-state-reasons",
1242
0
    "job-storage",      // IPP EPX
1243
0
    "job-uri",
1244
0
    "job-uuid",       // IPP NODRIVER
1245
0
    "materials-col-actual",   // IPP 3D
1246
0
    "media-actual",
1247
0
    "media-col-actual",
1248
0
    "media-check-input-tray-actual",
1249
0
    "multiple-document-handling-actual",
1250
0
    "multiple-object-handling-actual",  // IPP 3D
1251
0
    "number-of-documents",
1252
0
    "number-of-intervening-jobs",
1253
0
    "number-up-actual",
1254
0
    "orientation-requested-actual",
1255
0
    "original-requesting-user-name",
1256
0
    "output-bin-actual",
1257
0
    "output-device-assigned",
1258
0
    "output-device-job-state",    // IPP INFRA
1259
0
    "output-device-job-state-message",  // IPP INFRA
1260
0
    "output-device-job-state-reasons",  // IPP INFRA
1261
0
    "output-device-uuid-assigned",  // IPP INFRA
1262
0
    "overrides-actual",
1263
0
    "page-delivery-actual",
1264
0
    "page-order-received-actual",
1265
0
    "page-ranges-actual",
1266
0
    "parent-job-id",      // IPP EPX
1267
0
    "parent-job-uuid",      // IPP EPX
1268
0
    "platform-temperature-actual",  // IPP 3D
1269
0
    "presentation-direction-number-up-actual",
1270
0
    "print-accuracy-actual",    // IPP 3D
1271
0
    "print-base-actual",    // IPP 3D
1272
0
    "print-color-mode-actual",
1273
0
    "print-content-optimize-actual",
1274
0
    "print-objects-actual",   // IPP 3D
1275
0
    "print-quality-actual",
1276
0
    "print-rendering-intent-actual",
1277
0
    "print-scaling-actual",   // IPP Paid Printing
1278
0
    "print-supports-actual",    // IPP 3D
1279
0
    "printer-resolution-actual",
1280
0
    "separator-sheets-actual",
1281
0
    "sheet-collate-actual",
1282
0
    "sheet-completed-copy-number",
1283
0
    "sheet-completed-document-number",
1284
0
    "sides-actual",
1285
0
    "time-at-completed",
1286
0
    "time-at-completed-estimated",  // IPP PPX
1287
0
    "time-at-creation",
1288
0
    "time-at-processing",
1289
0
    "time-at-processing-estimated", // IPP PPX
1290
0
    "warnings-count",     // IPP JobExt
1291
0
    "x-image-position-actual",
1292
0
    "x-image-shift-actual",
1293
0
    "x-side1-image-shift-actual",
1294
0
    "x-side2-image-shift-actual",
1295
0
    "y-image-position-actual",
1296
0
    "y-image-shift-actual",
1297
0
    "y-side1-image-shift-actual",
1298
0
    "y-side2-image-shift-actual"
1299
0
  };
1300
0
  static const char * const job_template[] =
1301
0
  {         // job-template group
1302
0
    "accuracy-units-supported",   // IPP 3D
1303
0
    "baling-type-supported",    // IPP FIN
1304
0
    "baling-when-supported",    // IPP FIN
1305
0
    "binding-reference-edge-supported", // IPP FIN
1306
0
    "binding-type-supported",   // IPP FIN
1307
0
    "chamber-humidity",     // IPP 3D
1308
0
    "chamber-humidity-default",   // IPP 3D
1309
0
    "chamber-humidity-supported", // IPP 3D
1310
0
    "chamber-temperature",    // IPP 3D
1311
0
    "chamber-temperature-default",  // IPP 3D
1312
0
    "chamber-temperature-supported",  // IPP 3D
1313
0
    "coating-sides-supported",    // IPP FIN
1314
0
    "coating-type-supported",   // IPP FIN
1315
0
    "confirmation-sheet-print",   // IPP FaxOut
1316
0
    "confirmation-sheet-print-default",
1317
0
    "copies",
1318
0
    "copies-default",
1319
0
    "copies-supported",
1320
0
    "cover-back",     // IPP PPX
1321
0
    "cover-back-default",   // IPP PPX
1322
0
    "cover-back-supported",   // IPP PPX
1323
0
    "cover-front",      // IPP PPX
1324
0
    "cover-front-default",    // IPP PPX
1325
0
    "cover-front-supported",    // IPP PPX
1326
0
    "cover-sheet-info",     // IPP FaxOut
1327
0
    "cover-sheet-info-default",   // IPP FaxOut
1328
0
    "cover-sheet-info-supported", // IPP FaxOut
1329
0
    "covering-name-supported",    // IPP FIN
1330
0
    "destination-uri-schemes-supported",// IPP FaxOut
1331
0
    "destination-uris",     // IPP FaxOut
1332
0
    "destination-uris-supported",
1333
0
    "feed-orientation",
1334
0
    "feed-orientation-default",
1335
0
    "feed-orientation-supported",
1336
0
    "finishings",
1337
0
    "finishings-col",     // IPP FIN
1338
0
    "finishings-col-database",    // IPP FIN
1339
0
    "finishings-col-default",   // IPP FIN
1340
0
    "finishings-col-ready",   // IPP FIN
1341
0
    "finishings-col-supported",   // IPP FIN
1342
0
    "finishings-default",
1343
0
    "finishings-ready",
1344
0
    "finishings-supported",
1345
0
    "folding-direction-supported",  // IPP FIN
1346
0
    "folding-offset-supported",   // IPP FIN
1347
0
    "folding-reference-edge-supported", // IPP FIN
1348
0
    "force-front-side",     // IPP PPX
1349
0
    "force-front-side-default",   // IPP PPX
1350
0
    "force-front-side-supported", // IPP PPX
1351
0
    "imposition-template",    // IPP PPX
1352
0
    "imposition-template-default",  // IPP PPX
1353
0
    "imposition-template-supported",  // IPP PPX
1354
0
    "insert-count-supported",   // IPP PPX
1355
0
    "insert-sheet",     // IPP PPX
1356
0
    "insert-sheet-default",   // IPP PPX
1357
0
    "insert-sheet-supported",   // IPP PPX
1358
0
    "job-account-id",     // IPP JobExt
1359
0
    "job-account-id-default",   // IPP JobExt
1360
0
    "job-account-id-supported",   // IPP JobExt
1361
0
    "job-accounting-output-bin-supported",
1362
          // IPP PPX
1363
0
    "job-accounting-sheets",    // IPP PPX
1364
0
    "job-accounting-sheets-default",  // IPP PPX
1365
0
    "job-accounting-sheets-supported",  // IPP PPX
1366
0
    "job-accounting-sheets-type-supported",
1367
          // IPP PPX
1368
0
    "job-accounting-user-id",   // IPP JobExt
1369
0
    "job-accounting-user-id-default", // IPP JobExt
1370
0
    "job-accounting-user-id-supported", // IPP JobExt
1371
0
    "job-cancel-after",     // IPP JobExt
1372
0
    "job-cancel-after-default",   // IPP JobExt
1373
0
    "job-cancel-after-supported", // IPP JobExt
1374
0
    "job-complete-before",    // IPP PPX
1375
0
    "job-complete-before-supported",  // IPP PPX
1376
0
    "job-complete-before-time",   // IPP PPX
1377
0
    "job-complete-before-time-supported",
1378
          // IPP PPX
1379
0
    "job-delay-output-until",   // IPP JobExt
1380
0
    "job-delay-output-until-default", // IPP JobExt
1381
0
    "job-delay-output-until-supported", // IPP JobExt
1382
0
    "job-delay-output-until-time",  // IPP JobExt
1383
0
    "job-delay-output-until-time-default",
1384
          // IPP JobExt
1385
0
    "job-delay-output-until-time-supported",
1386
          // IPP JobExt
1387
0
    "job-error-action",     // IPP NODRIVER
1388
0
    "job-error-action-default",   // IPP NODRIVER
1389
0
    "job-error-action-supported", // IPP NODRIVER
1390
0
    "job-error-sheet",      // IPP PPX
1391
0
    "job-error-sheet-default",    // IPP PPX
1392
0
    "job-error-sheet-supported",  // IPP PPX
1393
0
    "job-error-sheet-type-supported", // IPP PPX
1394
0
    "job-error-sheet-when-supported", // IPP PPX
1395
0
    "job-hold-until",
1396
0
    "job-hold-until-default",
1397
0
    "job-hold-until-supported",
1398
0
    "job-hold-until-time",    // IPP JobExt
1399
0
    "job-hold-until-time-supported",  // IPP JobExt
1400
0
    "job-message-to-operator",    // IPP PPX
1401
0
    "job-message-to-operator-supported",// IPP PPX
1402
0
    "job-phone-number",     // IPP PPX
1403
0
    "job-phone-number-default",   // IPP PPX
1404
0
    "job-phone-number-supported", // IPP PPX
1405
0
    "job-priority",
1406
0
    "job-priority-default",
1407
0
    "job-priority-supported",
1408
0
    "job-recipient-name",   // IPP PPX
1409
0
    "job-recipient-name-supported", // IPP PPX
1410
0
    "job-retain-until",     // IPP JobExt
1411
0
    "job-retain-until-default",   // IPP JobExt
1412
0
    "job-retain-until-interval",  // IPP JobExt
1413
0
    "job-retain-until=interval-default",// IPP JobExt
1414
0
    "job-retain-until-interval-supported",
1415
          // IPP JobExt
1416
0
    "job-retain-until-supported", // IPP JobExt
1417
0
    "job-retain-until-time",    // IPP JobExt
1418
0
    "job-retain-until-time-supported",  // IPP JobExt
1419
0
    "job-sheet-message",    // IPP JobExt
1420
0
    "job-sheet-message-supported",  // IPP JobExt
1421
0
    "job-sheets",
1422
0
    "job-sheets-col",     // IPP JobExt
1423
0
    "job-sheets-col-default",   // IPP JobExt
1424
0
    "job-sheets-col-supported",   // IPP JobExt
1425
0
    "job-sheets-default",
1426
0
    "job-sheets-supported",
1427
0
    "laminating-sides-supported", // IPP FIN
1428
0
    "laminating-type-supported",  // IPP FIN
1429
0
    "logo-uri-schemes-supported", // IPP FaxOut
1430
0
    "material-amount-units-supported",  // IPP 3D
1431
0
    "material-diameter-supported",  // IPP 3D
1432
0
    "material-purpose-supported", // IPP 3D
1433
0
    "material-rate-supported",    // IPP 3D
1434
0
    "material-rate-units-supported",  // IPP 3D
1435
0
    "material-shell-thickness-supported",
1436
          // IPP 3D
1437
0
    "material-temperature-supported", // IPP 3D
1438
0
    "material-type-supported",    // IPP 3D
1439
0
    "materials-col",      // IPP 3D
1440
0
    "materials-col-database",   // IPP 3D
1441
0
    "materials-col-default",    // IPP 3D
1442
0
    "materials-col-ready",    // IPP 3D
1443
0
    "materials-col-supported",    // IPP 3D
1444
0
    "max-materials-col-supported",  // IPP 3D
1445
0
    "max-page-ranges-supported",
1446
0
    "max-stitching-locations-supported",// IPP FIN
1447
0
    "media",
1448
0
    "media-back-coating-supported", // IPP JobExt
1449
0
    "media-bottom-margin-supported",  // IPP JobExt
1450
0
    "media-col",      // IPP JobExt
1451
0
    "media-col-default",    // IPP JobExt
1452
0
    "media-col-ready",      // IPP JobExt
1453
0
    "media-col-supported",    // IPP JobExt
1454
0
    "media-color-supported",    // IPP JobExt
1455
0
    "media-default",
1456
0
    "media-front-coating-supported",  // IPP JobExt
1457
0
    "media-grain-supported",    // IPP JobExt
1458
0
    "media-hole-count-supported", // IPP JobExt
1459
0
    "media-info-supported",   // IPP JobExt
1460
0
    "media-input-tray-check",   // IPP PPX
1461
0
    "media-input-tray-check-default", // IPP PPX
1462
0
    "media-input-tray-check-supported", // IPP PPX
1463
0
    "media-key-supported",    // IPP JobExt
1464
0
    "media-left-margin-supported",  // IPP JobExt
1465
0
    "media-order-count-supported",  // IPP JobExt
1466
0
    "media-overprint",      // IPP NODRIVER
1467
0
    "media-overprint-distance-supported",
1468
          // IPP NODRIVER
1469
0
    "media-overprint-method-supported", // IPP NODRIVER
1470
0
    "media-overprint-supported",  // IPP NODRIVER
1471
0
    "media-pre-printed-supported",  // IPP JobExt
1472
0
    "media-ready",
1473
0
    "media-recycled-supported",   // IPP JobExt
1474
0
    "media-right-margin-supported", // IPP JobExt
1475
0
    "media-size-supported",   // IPP JobExt
1476
0
    "media-source-supported",   // IPP JobExt
1477
0
    "media-supported",
1478
0
    "media-thickness-supported",  // IPP JobExt
1479
0
    "media-top-margin-supported", // IPP JobExt
1480
0
    "media-type-supported",   // IPP JobExt
1481
0
    "media-weight-metric-supported",  // IPP JobExt
1482
0
    "multiple-document-handling",
1483
0
    "multiple-document-handling-default",
1484
0
    "multiple-document-handling-supported",
1485
0
    "multiple-object-handling",   // IPP 3D
1486
0
    "multiple-object-handling-default", // IPP 3D
1487
0
    "multiple-object-handling-supported",
1488
          // IPP 3D
1489
0
    "number-of-retries",    // IPP FaxOut
1490
0
    "number-of-retries-default",
1491
0
    "number-of-retries-supported",
1492
0
    "number-up",
1493
0
    "number-up-default",
1494
0
    "number-up-supported",
1495
0
    "orientation-requested",
1496
0
    "orientation-requested-default",
1497
0
    "orientation-requested-supported",
1498
0
    "output-bin",
1499
0
    "output-bin-default",
1500
0
    "output-bin-supported",
1501
0
    "output-device",      // IPP JobExt
1502
0
    "output-device-supported",    // IPP JobExt
1503
0
    "output-mode",      // CUPS extension
1504
0
    "output-mode-default",    // CUPS extension
1505
0
    "output-mode-supported",    // CUPS extension
1506
0
    "overrides",
1507
0
    "overrides-supported",
1508
0
    "page-delivery",      // IPP PPX
1509
0
    "page-delivery-default",    // IPP PPX
1510
0
    "page-delivery-supported",    // IPP PPX
1511
0
    "page-ranges",
1512
0
    "page-ranges-supported",
1513
0
    "platform-temperature",   // IPP 3D
1514
0
    "platform-temperature-default", // IPP 3D
1515
0
    "platform-temperature-supported", // IPP 3D
1516
0
    "preferred-attributes-supported", // IPP NODRIVER
1517
0
    "presentation-direction-number-up", // IPP PPX
1518
0
    "presentation-direction-number-up-default",
1519
          // IPP PPX
1520
0
    "presentation-direction-number-up-supported",
1521
          // IPP PPX
1522
0
    "print-accuracy",     // IPP 3D
1523
0
    "print-accuracy-default",   // IPP 3D
1524
0
    "print-accuracy-supported",   // IPP 3D
1525
0
    "print-base",     // IPP 3D
1526
0
    "print-base-default",   // IPP 3D
1527
0
    "print-base-supported",   // IPP 3D
1528
0
    "print-color-mode",     // IPP NODRIVER
1529
0
    "print-color-mode-default",   // IPP NODRIVER
1530
0
    "print-color-mode-supported", // IPP NODRIVER
1531
0
    "print-content-optimize",   // IPP JobExt
1532
0
    "print-content-optimize-default", // IPP JobExt
1533
0
    "print-content-optimize-supported", // IPP JobExt
1534
0
    "print-objects",      // IPP 3D
1535
0
    "print-objects-default",    // IPP 3D
1536
0
    "print-objects-supported",    // IPP 3D
1537
0
    "print-processing-attributes-supported",
1538
          // IPP NODRIVER
1539
0
    "print-quality",
1540
0
    "print-quality-default",
1541
0
    "print-quality-supported",
1542
0
    "print-rendering-intent",   // IPP NODRIVER
1543
0
    "print-rendering-intent-default", // IPP NODRIVER
1544
0
    "print-rendering-intent-supported", // IPP NODRIVER
1545
0
    "print-scaling",      // IPP NODRIVER
1546
0
    "print-scaling-default",    // IPP NODRIVER
1547
0
    "print-scaling-supported",    // IPP NODRIVER
1548
0
    "print-supports",     // IPP 3D
1549
0
    "print-supports-default",   // IPP 3D
1550
0
    "print-supports-supported",   // IPP 3D
1551
0
    "printer-resolution",
1552
0
    "printer-resolution-default",
1553
0
    "printer-resolution-supported",
1554
0
    "proof-copies",     // IPP EPX
1555
0
    "proof-copies-supported",   // IPP EPX
1556
0
    "proof-print",      // IPP EPX
1557
0
    "proof-print-default",    // IPP EPX
1558
0
    "proof-print-supported"   // IPP EPX
1559
0
    "punching-hole-diameter-configured",// IPP FIN
1560
0
    "punching-locations-supported", // IPP FIN
1561
0
    "punching-offset-supported",  // IPP FIN
1562
0
    "punching-reference-edge-supported",// IPP FIN
1563
0
    "retry-interval",     // IPP FaxOut
1564
0
    "retry-interval-default",
1565
0
    "retry-interval-supported",
1566
0
    "retry-timeout",      // IPP FaxOut
1567
0
    "retry-timeout-default",
1568
0
    "retry-timeout-supported",
1569
0
    "separator-sheets",     // IPP PPX
1570
0
    "separator-sheets-default",   // IPP PPX
1571
0
    "separator-sheets-supported", // IPP PPX
1572
0
    "separator-sheets-type-supported",  // IPP PPX
1573
0
    "sides",
1574
0
    "sides-default",
1575
0
    "sides-supported",
1576
0
    "stitching-angle-supported",  // IPP FIN
1577
0
    "stitching-locations-supported",  // IPP FIN
1578
0
    "stitching-method-supported", // IPP FIN
1579
0
    "stitching-offset-supported", // IPP FIN
1580
0
    "stitching-reference-edge-supported",
1581
          // IPP FIN
1582
0
    "x-image-position",     // IPP PPX
1583
0
    "x-image-position-default",   // IPP PPX
1584
0
    "x-image-position-supported", // IPP PPX
1585
0
    "x-image-shift",      // IPP PPX
1586
0
    "x-image-shift-default",    // IPP PPX
1587
0
    "x-image-shift-supported",    // IPP PPX
1588
0
    "x-side1-image-shift",    // IPP PPX
1589
0
    "x-side1-image-shift-default",  // IPP PPX
1590
0
    "x-side1-image-shift-supported",  // IPP PPX
1591
0
    "x-side2-image-shift",    // IPP PPX
1592
0
    "x-side2-image-shift-default",  // IPP PPX
1593
0
    "x-side2-image-shift-supported",  // IPP PPX
1594
0
    "y-image-position",     // IPP PPX
1595
0
    "y-image-position-default",   // IPP PPX
1596
0
    "y-image-position-supported", // IPP PPX
1597
0
    "y-image-shift",      // IPP PPX
1598
0
    "y-image-shift-default",    // IPP PPX
1599
0
    "y-image-shift-supported",    // IPP PPX
1600
0
    "y-side1-image-shift",    // IPP PPX
1601
0
    "y-side1-image-shift-default",  // IPP PPX
1602
0
    "y-side1-image-shift-supported",  // IPP PPX
1603
0
    "y-side2-image-shift",    // IPP PPX
1604
0
    "y-side2-image-shift-default",  // IPP PPX
1605
0
    "y-side2-image-shift-supported" // IPP PPX
1606
0
  };
1607
0
  static const char * const printer_description[] =
1608
0
  {         // printer-description group
1609
0
    "auth-info-required",   // CUPS extension
1610
0
    "chamber-humidity-current",   // IPP 3D
1611
0
    "chamber-temperature-current",  // IPP 3D
1612
0
    "charset-configured",
1613
0
    "charset-supported",
1614
0
    "client-info-supported",    // IPP JobExt
1615
0
    "color-supported",
1616
0
    "compression-supported",
1617
0
    "device-service-count",
1618
0
    "device-uri",     // CUPS extension
1619
0
    "device-uuid",
1620
0
    "document-charset-default",   // IPP JobExt
1621
0
    "document-charset-supported", // IPP JobExt
1622
0
    "document-creation-attributes-supported",
1623
0
    "document-format-default",
1624
0
    "document-format-details-supported",// IPP JobExt
1625
0
    "document-format-preferred",  // AirPrint extension
1626
0
    "document-format-supported",
1627
0
    "document-format-varying-attributes",
1628
0
    "document-natural-language-default",// IPP JobExt
1629
0
    "document-natural-language-supported",
1630
          // IPP JobExt
1631
0
    "document-password-supported",  // IPP NODRIVER
1632
0
    "document-privacy-attributes",  // IPP Privacy Attributes
1633
0
    "document-privacy-scope",   // IPP Privacy Attributes
1634
0
    "generated-natural-language-supported",
1635
0
    "identify-actions-default",   // IPP NODRIVER
1636
0
    "identify-actions-supported", // IPP NODRIVER
1637
0
    "input-source-supported",   // IPP FaxOut
1638
0
    "ipp-features-supported",   // IPP NODRIVER
1639
0
    "ipp-versions-supported",
1640
0
    "ippget-event-life",    // RFC 3995
1641
0
    "job-authorization-uri-supported",  // CUPS extension
1642
0
    "job-constraints-supported",  // IPP NODRIVER
1643
0
    "job-creation-attributes-supported",// IPP JobExt
1644
0
    "job-history-attributes-configured",// IPP JobExt
1645
0
    "job-history-attributes-supported", // IPP JobExt
1646
0
    "job-history-interval-configured",  // IPP JobExt
1647
0
    "job-history-interval-supported", // IPP JobExt
1648
0
    "job-ids-supported",    // IPP JobExt
1649
0
    "job-impressions-supported",
1650
0
    "job-k-limit",      // CUPS extension
1651
0
    "job-k-octets-supported",
1652
0
    "job-mandatory-attributes-supported",
1653
          // IPP JobExt
1654
0
    "job-media-sheets-supported",
1655
0
    "job-page-limit",     // CUPS extension
1656
0
    "job-pages-per-set-supported",  // IPP FIN
1657
0
    "job-password-encryption-supported",// IPP EPX
1658
0
    "job-password-length-supported",  // IPP EPX
1659
0
    "job-password-repertoire-configured",
1660
          // IPP EPX
1661
0
    "job-password-repertoire-supported",// IPP EPX
1662
0
    "job-password-supported",   // IPP EPX
1663
0
    "job-presets-supported",    // IPP NODRIVER
1664
0
    "job-privacy-attributes",   // IPP Privacy Attributes
1665
0
    "job-privacy-scope",    // IPP Privacy Attributes
1666
0
    "job-quota-period",     // CUPS extension
1667
0
    "job-release-action-default", // IPP EPX
1668
0
    "job-release-action-supported", // IPP EPX
1669
0
    "job-resolvers-supported",    // IPP NODRIVER
1670
0
    "job-settable-attributes-supported",// RFC 3380
1671
0
    "job-spooling-supported",   // IPP JobExt
1672
0
    "job-storage-access-supported", // IPP EPX
1673
0
    "job-storage-disposition-supported",// IPP EPX
1674
0
    "job-storage-group-supported",  // IPP EPX
1675
0
    "job-storage-supported",    // IPP EPX
1676
0
    "job-triggers-supported",   // IPP NODRIVER
1677
0
    "jpeg-features-supported",    // IPP NODRIVER
1678
0
    "jpeg-k-octets-supported",    // IPP NODRIVER
1679
0
    "jpeg-x-dimension-supported", // IPP NODRIVER
1680
0
    "jpeg-y-dimension-supported", // IPP NODRIVER
1681
0
    "landscape-orientation-requested-preferred",
1682
          // AirPrint extension
1683
0
    "marker-change-time",   // CUPS extension
1684
0
    "marker-colors",      // CUPS extension
1685
0
    "marker-high-levels",   // CUPS extension
1686
0
    "marker-levels",      // CUPS extension
1687
0
    "marker-low-levels",    // CUPS extension
1688
0
    "marker-message",     // CUPS extension
1689
0
    "marker-names",     // CUPS extension
1690
0
    "marker-types",     // CUPS extension
1691
0
    "max-client-info-supported",  // IPP JobExt
1692
0
    "member-names",     // CUPS extension
1693
0
    "member-uris",      // CUPS extension
1694
0
    "mopria-certified",     // Mopria extension
1695
0
    "multiple-destination-uris-supported",
1696
          // IPP FaxOut
1697
0
    "multiple-document-jobs-supported",
1698
0
    "multiple-operation-time-out",
1699
0
    "multiple-operation-time-out-action",
1700
          // IPP NODRIVER
1701
0
    "natural-language-configured",
1702
0
    "operations-supported",
1703
0
    "output-device-uuid-supported", // IPP INFRA
1704
0
    "pages-per-minute",
1705
0
    "pages-per-minute-color",
1706
0
    "pdf-k-octets-supported",   // CUPS extension
1707
0
    "pdf-features-supported",   // IPP 3D
1708
0
    "pdf-versions-supported",   // CUPS extension
1709
0
    "pdl-override-supported",
1710
0
    "platform-shape",     // IPP 3D
1711
0
    "pkcs7-document-format-supported",  // IPP TRUSTNOONE
1712
0
    "port-monitor",     // CUPS extension
1713
0
    "port-monitor-supported",   // CUPS extension
1714
0
    "preferred-attributes-supported",
1715
0
    "printer-alert",
1716
0
    "printer-alert-description",
1717
0
    "printer-camera-image-uri",   // IPP 3D
1718
0
    "printer-charge-info",
1719
0
    "printer-charge-info-uri",
1720
0
    "printer-commands",     // CUPS extension
1721
0
    "printer-config-change-date-time",
1722
0
    "printer-config-change-time",
1723
0
    "printer-config-changes",   // IPP System
1724
0
    "printer-contact-col",    // IPP System
1725
0
    "printer-current-time",
1726
0
    "printer-detailed-status-messages", // IPP EPX
1727
0
    "printer-device-id",
1728
0
    "printer-dns-sd-name",    // CUPS extension
1729
0
    "printer-driver-installer",
1730
0
    "printer-fax-log-uri",    // IPP FaxOut
1731
0
    "printer-fax-modem-info",   // IPP FaxOut
1732
0
    "printer-fax-modem-name",   // IPP FaxOut
1733
0
    "printer-fax-modem-number",   // IPP FaxOut
1734
0
    "printer-finisher",     // IPP FIN
1735
0
    "printer-finisher-description", // IPP FIN
1736
0
    "printer-finisher-supplies",  // IPP FIN
1737
0
    "printer-finisher-supplies-description",
1738
          // IPP FIN
1739
0
    "printer-firmware-name",    // PWG 5110.1
1740
0
    "printer-firmware-patches",   // PWG 5110.1
1741
0
    "printer-firmware-string-version",  // PWG 5110.1
1742
0
    "printer-firmware-version",   // PWG 5110.1
1743
0
    "printer-geo-location",
1744
0
    "printer-get-attributes-supported",
1745
0
    "printer-icc-profiles",
1746
0
    "printer-icons",
1747
0
    "printer-id",     // IPP System
1748
0
    "printer-info",
1749
0
    "printer-input-tray",   // IPP NODRIVER
1750
0
    "printer-is-accepting-jobs",
1751
0
    "printer-is-shared",    // CUPS extension
1752
0
    "printer-is-temporary",   // CUPS extension
1753
0
    "printer-kind",     // IPP Paid Printing
1754
0
    "printer-location",
1755
0
    "printer-make-and-model",
1756
0
    "printer-mandatory-job-attributes",
1757
0
    "printer-message-date-time",
1758
0
    "printer-message-from-operator",
1759
0
    "printer-message-time",
1760
0
    "printer-more-info",
1761
0
    "printer-more-info-manufacturer",
1762
0
    "printer-name",
1763
0
    "printer-organization",
1764
0
    "printer-organizational-unit",
1765
0
    "printer-output-tray",    // IPP NODRIVER
1766
0
    "printer-pkcs7-public-key",   // IPP TRUSTNOONE
1767
0
    "printer-pkcs7-repertoire-configured",
1768
          // IPP TRUSTNOONE
1769
0
    "printer-pkcs7-repertoire-supported",
1770
          // IPP TRUSTNOONE
1771
0
    "printer-requested-client-type",  // IPP JobExt
1772
0
    "printer-service-type",   // IPP System
1773
0
    "printer-settable-attributes-supported",
1774
          // RFC 3380
1775
0
    "printer-service-contact-col",  // IPP EPX
1776
0
    "printer-state",
1777
0
    "printer-state-change-date-time",
1778
0
    "printer-state-change-time",
1779
0
    "printer-state-message",
1780
0
    "printer-state-reasons",
1781
0
    "printer-storage",      // IPP EPX
1782
0
    "printer-storage-description",  // IPP EPX
1783
0
    "printer-strings-languages-supported",
1784
          // IPP NODRIVER
1785
0
    "printer-strings-uri",    // IPP NODRIVER
1786
0
    "printer-supply",
1787
0
    "printer-supply-description",
1788
0
    "printer-supply-info-uri",
1789
0
    "printer-type",     // CUPS extension
1790
0
    "printer-up-time",
1791
0
    "printer-uri-supported",
1792
0
    "printer-uuid",
1793
0
    "printer-wifi-ssid",    // AirPrint extension
1794
0
    "printer-wifi-state",   // AirPrint extension
1795
0
    "printer-xri-supported",
1796
0
    "proof-copies-supported",   // IPP EPX
1797
0
    "proof-print-copies-supported", // IPP EPX
1798
0
    "pwg-raster-document-resolution-supported",
1799
          // PWG Raster
1800
0
    "pwg-raster-document-sheet-back", // PWG Raster
1801
0
    "pwg-raster-document-type-supported",
1802
          // PWG Raster
1803
0
    "queued-job-count",
1804
0
    "reference-uri-schemes-supported",
1805
0
    "repertoire-supported",
1806
0
    "requesting-user-name-allowed", // CUPS extension
1807
0
    "requesting-user-name-denied",  // CUPS extension
1808
0
    "requesting-user-uri-supported",
1809
0
    "smi2699-auth-print-group",   // PWG ippserver extension
1810
0
    "smi2699-auth-proxy-group",   // PWG ippserver extension
1811
0
    "smi2699-device-command",   // PWG ippserver extension
1812
0
    "smi2699-device-format",    // PWG ippserver extension
1813
0
    "smi2699-device-name",    // PWG ippserver extension
1814
0
    "smi2699-device-uri",   // PWG ippserver extension
1815
0
    "subordinate-printers-supported",
1816
0
    "subscription-privacy-attributes",  // IPP Privacy Attributes
1817
0
    "subscription-privacy-scope", // IPP Privacy Attributes
1818
0
    "trimming-offset-supported",  // IPP FIN
1819
0
    "trimming-reference-edge-supported",// IPP FIN
1820
0
    "trimming-type-supported",    // IPP FIN
1821
0
    "trimming-when-supported",    // IPP FIN
1822
0
    "urf-supported",      // AirPrint
1823
0
    "uri-authentication-supported",
1824
0
    "uri-security-supported",
1825
0
    "which-jobs-supported",   // IPP JobExt
1826
0
    "xri-authentication-supported",
1827
0
    "xri-security-supported",
1828
0
    "xri-uri-scheme-supported"
1829
0
  };
1830
0
  static const char * const resource_description[] =
1831
0
  {         // resource-description group - IPP System
1832
0
    "resource-info",
1833
0
    "resource-name"
1834
0
  };
1835
0
  static const char * const resource_status[] =
1836
0
  {         // resource-status group - IPP System
1837
0
    "date-time-at-canceled",
1838
0
    "date-time-at-creation",
1839
0
    "date-time-at-installed",
1840
0
    "resource-data-uri",
1841
0
    "resource-format",
1842
0
    "resource-id",
1843
0
    "resource-k-octets",
1844
0
    "resource-state",
1845
0
    "resource-state-message",
1846
0
    "resource-state-reasons",
1847
0
    "resource-string-version",
1848
0
    "resource-type",
1849
0
    "resource-use-count",
1850
0
    "resource-uuid",
1851
0
    "resource-version",
1852
0
    "time-at-canceled",
1853
0
    "time-at-creation",
1854
0
    "time-at-installed"
1855
0
  };
1856
0
  static const char * const resource_template[] =
1857
0
  {         // resource-template group - IPP System
1858
0
    "resource-format",
1859
0
    "resource-format-supported",
1860
0
    "resource-info",
1861
0
    "resource-name",
1862
0
    "resource-type",
1863
0
    "resource-type-supported"
1864
0
  };
1865
0
  static const char * const subscription_description[] =
1866
0
  {         // subscription-description group
1867
0
    "notify-job-id",
1868
0
    "notify-lease-expiration-time",
1869
0
    "notify-printer-up-time",
1870
0
    "notify-printer-uri",
1871
0
    "notify-resource-id",   // IPP System
1872
0
    "notify-system-uri",    // IPP System
1873
0
    "notify-sequence-number",
1874
0
    "notify-subscriber-user-name",
1875
0
    "notify-subscriber-user-uri",
1876
0
    "notify-subscription-id",
1877
0
    "notify-subscription-uuid"    // IPP NODRIVER
1878
0
  };
1879
0
  static const char * const subscription_template[] =
1880
0
  {         // subscription-template group
1881
0
    "notify-attributes",
1882
0
    "notify-attributes-supported",
1883
0
    "notify-charset",
1884
0
    "notify-events",
1885
0
    "notify-events-default",
1886
0
    "notify-events-supported",
1887
0
    "notify-lease-duration",
1888
0
    "notify-lease-duration-default",
1889
0
    "notify-lease-duration-supported",
1890
0
    "notify-max-events-supported",
1891
0
    "notify-natural-language",
1892
0
    "notify-pull-method",
1893
0
    "notify-pull-method-supported",
1894
0
    "notify-recipient-uri",
1895
0
    "notify-schemes-supported",
1896
0
    "notify-time-interval",
1897
0
    "notify-user-data"
1898
0
  };
1899
0
  static const char * const system_description[] =
1900
0
  {         // system-description group - IPP System
1901
0
    "charset-configured",
1902
0
    "charset-supported",
1903
0
    "document-format-supported",
1904
0
    "generated-natural-language-supported",
1905
0
    "ipp-features-supported",
1906
0
    "ipp-versions-supported",
1907
0
    "ippget-event-life",
1908
0
    "multiple-document-printers-supported",
1909
0
    "natural-language-configured",
1910
0
    "notify-attributes-supported",
1911
0
    "notify-events-default",
1912
0
    "notify-events-supported",
1913
0
    "notify-lease-duration-default",
1914
0
    "notify-lease-duration-supported",
1915
0
    "notify-max-events-supported",
1916
0
    "notify-pull-method-supported",
1917
0
    "operations-supported",
1918
0
    "power-calendar-policy-col",
1919
0
    "power-event-policy-col",
1920
0
    "power-timeout-policy-col",
1921
0
    "printer-creation-attributes-supported",
1922
0
    "printer-service-type-supported",
1923
0
    "resource-format-supported",
1924
0
    "resource-type-supported",
1925
0
    "resource-settable-attributes-supported",
1926
0
    "smi2699-auth-group-supported", // PWG ippserver extension
1927
0
    "smi2699-device-command-supported", // PWG ippserver extension
1928
0
    "smi2699-device-format-format", // PWG ippserver extension
1929
0
    "smi2699-device-uri-schemes-supported",
1930
          // PWG ippserver extension
1931
0
    "system-contact-col",
1932
0
    "system-current-time",
1933
0
    "system-default-printer-id",
1934
0
    "system-geo-location",
1935
0
    "system-info",
1936
0
    "system-location",
1937
0
    "system-mandatory-printer-attributes",
1938
0
    "system-make-and-model",
1939
0
    "system-message-from-operator",
1940
0
    "system-name",
1941
0
    "system-owner-col",
1942
0
    "system-settable-attributes-supported",
1943
0
    "system-strings-languages-supported",
1944
0
    "system-strings-uri",
1945
0
    "system-xri-supported"
1946
0
  };
1947
0
  static const char * const system_status[] =
1948
0
  {         // system-status group - IPP System
1949
0
    "power-log-col",
1950
0
    "power-state-capabilities-col",
1951
0
    "power-state-counters-col",
1952
0
    "power-state-monitor-col",
1953
0
    "power-state-transitions-col",
1954
0
    "system-config-change-date-time",
1955
0
    "system-config-change-time",
1956
0
    "system-config-changes",
1957
0
    "system-configured-printers",
1958
0
    "system-configured-resources",
1959
0
    "system-firmware-name",
1960
0
    "system-firmware-patches",
1961
0
    "system-firmware-string-version",
1962
0
    "system-firmware-version",
1963
0
    "system-impressions-completed",
1964
0
    "system-impressions-completed-col",
1965
0
    "system-media-sheets-completed",
1966
0
    "system-media-sheets-completed-col",
1967
0
    "system-pages-completed",
1968
0
    "system-pages-completed-col",
1969
0
    "system-resident-application-name",
1970
0
    "system-resident-application-patches",
1971
0
    "system-resident-application-string-version",
1972
0
    "system-resident-application-version",
1973
0
    "system-serial-number",
1974
0
    "system-state",
1975
0
    "system-state-change-date-time",
1976
0
    "system-state-change-time",
1977
0
    "system-state-message",
1978
0
    "system-state-reasons",
1979
0
    "system-time-source-configured",
1980
0
    "system-up-time",
1981
0
    "system-user-application-name",
1982
0
    "system-user-application-patches",
1983
0
    "system-user-application-string-version",
1984
0
    "system-user-application-version",
1985
0
    "system-uuid",
1986
0
    "xri-authentication-supported",
1987
0
    "xri-security-supported",
1988
0
    "xri-uri-scheme-supported"
1989
0
  };
1990
1991
1992
  // Get the requested-attributes attribute...
1993
0
  op = ippGetOperation(request);
1994
1995
0
  if ((requested = ippFindAttribute(request, "requested-attributes", IPP_TAG_KEYWORD)) == NULL)
1996
0
  {
1997
    // The Get-Jobs operation defaults to "job-id" and "job-uri", and
1998
    // Get-Documents defaults to "document-number", while all others default to
1999
    // "all"...
2000
0
    if (op == IPP_OP_GET_JOBS)
2001
0
    {
2002
0
      ra = cupsArrayNew(_cupsArrayStrcmp, NULL);
2003
0
      cupsArrayAdd(ra, "job-id");
2004
0
      cupsArrayAdd(ra, "job-uri");
2005
2006
0
      return (ra);
2007
0
    }
2008
0
    else if (op == IPP_OP_GET_DOCUMENTS)
2009
0
    {
2010
0
      ra = cupsArrayNew(_cupsArrayStrcmp, NULL);
2011
0
      cupsArrayAdd(ra, "document-number");
2012
2013
0
      return (ra);
2014
0
    }
2015
0
    else
2016
0
    {
2017
0
      return (NULL);
2018
0
    }
2019
0
  }
2020
2021
  // If the attribute contains a single "all" keyword, return NULL...
2022
0
  count = (size_t)ippGetCount(requested);
2023
0
  if (count == 1 && !strcmp(ippGetString(requested, 0, NULL), "all"))
2024
0
    return (NULL);
2025
2026
  // Create an array using "strcmp" as the comparison function...
2027
0
  ra = cupsArrayNew(_cupsArrayStrcmp, NULL);
2028
2029
0
  for (i = 0; i < count; i ++)
2030
0
  {
2031
0
    added = false;
2032
0
    value = ippGetString(requested, i, NULL);
2033
2034
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)))
2035
0
    {
2036
0
      for (j = 0; j < (sizeof(document_description) / sizeof(document_description[0])); j ++)
2037
0
        cupsArrayAdd(ra, (void *)document_description[j]);
2038
2039
0
      added = true;
2040
0
    }
2041
2042
0
    if (!strcmp(value, "document-template") || !strcmp(value, "all"))
2043
0
    {
2044
0
      for (j = 0; j < (sizeof(document_template) / sizeof(document_template[0])); j ++)
2045
0
        cupsArrayAdd(ra, (void *)document_template[j]);
2046
2047
0
      added = true;
2048
0
    }
2049
2050
0
    if (!strcmp(value, "job-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_JOB_ATTRIBUTES || op == IPP_OP_GET_JOBS)))
2051
0
    {
2052
0
      for (j = 0; j < (sizeof(job_description) / sizeof(job_description[0])); j ++)
2053
0
        cupsArrayAdd(ra, (void *)job_description[j]);
2054
2055
0
      added = true;
2056
0
    }
2057
2058
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)))
2059
0
    {
2060
0
      for (j = 0; j < (sizeof(job_template) / sizeof(job_template[0])); j ++)
2061
0
        cupsArrayAdd(ra, (void *)job_template[j]);
2062
2063
0
      added = true;
2064
0
    }
2065
2066
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)))
2067
0
    {
2068
0
      for (j = 0; j < (sizeof(printer_description) / sizeof(printer_description[0])); j ++)
2069
0
        cupsArrayAdd(ra, (void *)printer_description[j]);
2070
2071
0
      added = true;
2072
0
    }
2073
2074
0
    if (!strcmp(value, "resource-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_RESOURCE_ATTRIBUTES || op == IPP_OP_GET_RESOURCES)))
2075
0
    {
2076
0
      for (j = 0; j < (sizeof(resource_description) / sizeof(resource_description[0])); j ++)
2077
0
        cupsArrayAdd(ra, (void *)resource_description[j]);
2078
2079
0
      added = true;
2080
0
    }
2081
2082
0
    if (!strcmp(value, "resource-status") || (!strcmp(value, "all") && (op == IPP_OP_GET_RESOURCE_ATTRIBUTES || op == IPP_OP_GET_RESOURCES)))
2083
0
    {
2084
0
      for (j = 0; j < (sizeof(resource_status) / sizeof(resource_status[0])); j ++)
2085
0
        cupsArrayAdd(ra, (void *)resource_status[j]);
2086
2087
0
      added = true;
2088
0
    }
2089
2090
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)))
2091
0
    {
2092
0
      for (j = 0; j < (sizeof(resource_template) / sizeof(resource_template[0])); j ++)
2093
0
        cupsArrayAdd(ra, (void *)resource_template[j]);
2094
2095
0
      added = true;
2096
0
    }
2097
2098
0
    if (!strcmp(value, "subscription-description") || (!strcmp(value, "all") && (op == IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES || op == IPP_OP_GET_SUBSCRIPTIONS)))
2099
0
    {
2100
0
      for (j = 0; j < (sizeof(subscription_description) / sizeof(subscription_description[0])); j ++)
2101
0
        cupsArrayAdd(ra, (void *)subscription_description[j]);
2102
2103
0
      added = true;
2104
0
    }
2105
2106
0
    if (!strcmp(value, "subscription-template") || (!strcmp(value, "all") && (op == IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES || op == IPP_OP_GET_SUBSCRIPTIONS)))
2107
0
    {
2108
0
      for (j = 0; j < (sizeof(subscription_template) / sizeof(subscription_template[0])); j ++)
2109
0
        cupsArrayAdd(ra, (void *)subscription_template[j]);
2110
2111
0
      added = true;
2112
0
    }
2113
2114
0
    if (!strcmp(value, "system-description") || (!strcmp(value, "all") && op == IPP_OP_GET_SYSTEM_ATTRIBUTES))
2115
0
    {
2116
0
      for (j = 0; j < (sizeof(system_description) / sizeof(system_description[0])); j ++)
2117
0
        cupsArrayAdd(ra, (void *)system_description[j]);
2118
2119
0
      added = true;
2120
0
    }
2121
2122
0
    if (!strcmp(value, "system-status") || (!strcmp(value, "all") && op == IPP_OP_GET_SYSTEM_ATTRIBUTES))
2123
0
    {
2124
0
      for (j = 0; j < (sizeof(system_status) / sizeof(system_status[0])); j ++)
2125
0
        cupsArrayAdd(ra, (void *)system_status[j]);
2126
2127
0
      added = true;
2128
0
    }
2129
2130
0
    if (!added)
2131
0
      cupsArrayAdd(ra, (void *)value);
2132
0
  }
2133
2134
0
  return (ra);
2135
0
}
2136
2137
2138
//
2139
// 'ippEnumString()' - Return a string corresponding to the enum value.
2140
//
2141
2142
const char *        // O - Enum string
2143
ippEnumString(const char *attrname, // I - Attribute name
2144
              int        enumvalue) // I - Enum value
2145
0
{
2146
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2147
2148
2149
  // Check for standard enum values...
2150
0
  if (!strcmp(attrname, "document-state") && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_document_states) / sizeof(ipp_document_states[0]))))
2151
0
    return (ipp_document_states[enumvalue - 3]);
2152
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"))
2153
0
  {
2154
0
    if (enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_finishings) / sizeof(ipp_finishings[0]))))
2155
0
      return (ipp_finishings[enumvalue - 3]);
2156
0
    else if (enumvalue >= 0x40000000 && enumvalue < (0x40000000 + (int)(sizeof(ipp_finishings_vendor) / sizeof(ipp_finishings_vendor[0]))))
2157
0
      return (ipp_finishings_vendor[enumvalue - 0x40000000]);
2158
0
  }
2159
0
  else if (!strcmp(attrname, "job-state") && enumvalue >= IPP_JSTATE_PENDING && enumvalue <= IPP_JSTATE_COMPLETED)
2160
0
    return (ipp_job_states[enumvalue - IPP_JSTATE_PENDING]);
2161
0
  else if (!strcmp(attrname, "operations-supported"))
2162
0
    return (ippOpString((ipp_op_t)enumvalue));
2163
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]))))
2164
0
    return (ipp_orientation_requesteds[enumvalue - 3]);
2165
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]))))
2166
0
    return (ipp_print_qualities[enumvalue - 3]);
2167
0
  else if (!strcmp(attrname, "printer-state") && enumvalue >= IPP_PSTATE_IDLE && enumvalue <= IPP_PSTATE_STOPPED)
2168
0
    return (ipp_printer_states[enumvalue - IPP_PSTATE_IDLE]);
2169
0
  else if (!strcmp(attrname, "resource-state") && enumvalue >= IPP_RSTATE_PENDING && enumvalue <= IPP_RSTATE_ABORTED)
2170
0
    return (ipp_resource_states[enumvalue - IPP_RSTATE_PENDING]);
2171
0
  else if (!strcmp(attrname, "system-state") && enumvalue >= IPP_SSTATE_IDLE && enumvalue <= IPP_SSTATE_STOPPED)
2172
0
    return (ipp_system_states[enumvalue - IPP_SSTATE_IDLE]);
2173
2174
  // Not a standard enum value, just return the decimal equivalent...
2175
0
  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "%d", enumvalue);
2176
0
  return (cg->ipp_unknown);
2177
0
}
2178
2179
2180
//
2181
// 'ippEnumValue()' - Return the value associated with a given enum string.
2182
//
2183
2184
int         // O - Enum value or `-1` if unknown
2185
ippEnumValue(const char *attrname,  // I - Attribute name
2186
             const char *enumstring)  // I - Enum string
2187
0
{
2188
0
  size_t  i,      // Looping var
2189
0
    num_strings;    // Number of strings to compare
2190
0
  const char * const *strings;    // Strings to compare
2191
2192
2193
  // If the string is just a number, return it...
2194
0
  if (isdigit(*enumstring & 255))
2195
0
    return ((int)strtol(enumstring, NULL, 0));
2196
2197
  // Otherwise look up the string...
2198
0
  if (!strcmp(attrname, "document-state"))
2199
0
  {
2200
0
    num_strings = sizeof(ipp_document_states) / sizeof(ipp_document_states[0]);
2201
0
    strings     = ipp_document_states;
2202
0
  }
2203
0
  else if (!strcmp(attrname, "finishings") ||
2204
0
     !strcmp(attrname, "finishings-actual") ||
2205
0
     !strcmp(attrname, "finishings-default") ||
2206
0
     !strcmp(attrname, "finishings-ready") ||
2207
0
     !strcmp(attrname, "finishings-supported"))
2208
0
  {
2209
0
    for (i = 0; i < (sizeof(ipp_finishings_vendor) / sizeof(ipp_finishings_vendor[0])); i ++)
2210
0
    {
2211
0
      if (!strcmp(enumstring, ipp_finishings_vendor[i]))
2212
0
  return (i + 0x40000000);
2213
0
    }
2214
2215
0
    num_strings = sizeof(ipp_finishings) / sizeof(ipp_finishings[0]);
2216
0
    strings     = ipp_finishings;
2217
0
  }
2218
0
  else if (!strcmp(attrname, "job-state"))
2219
0
  {
2220
0
    num_strings = sizeof(ipp_job_states) / sizeof(ipp_job_states[0]);
2221
0
    strings     = ipp_job_states;
2222
0
  }
2223
0
  else if (!strcmp(attrname, "operations-supported"))
2224
0
  {
2225
0
    return (ippOpValue(enumstring));
2226
0
  }
2227
0
  else if (!strcmp(attrname, "orientation-requested") ||
2228
0
           !strcmp(attrname, "orientation-requested-actual") ||
2229
0
           !strcmp(attrname, "orientation-requested-default") ||
2230
0
           !strcmp(attrname, "orientation-requested-supported"))
2231
0
  {
2232
0
    num_strings = sizeof(ipp_orientation_requesteds) / sizeof(ipp_orientation_requesteds[0]);
2233
0
    strings     = ipp_orientation_requesteds;
2234
0
  }
2235
0
  else if (!strcmp(attrname, "print-quality") ||
2236
0
           !strcmp(attrname, "print-quality-actual") ||
2237
0
           !strcmp(attrname, "print-quality-default") ||
2238
0
           !strcmp(attrname, "print-quality-supported"))
2239
0
  {
2240
0
    num_strings = sizeof(ipp_print_qualities) / sizeof(ipp_print_qualities[0]);
2241
0
    strings     = ipp_print_qualities;
2242
0
  }
2243
0
  else if (!strcmp(attrname, "printer-state"))
2244
0
  {
2245
0
    num_strings = sizeof(ipp_printer_states) / sizeof(ipp_printer_states[0]);
2246
0
    strings     = ipp_printer_states;
2247
0
  }
2248
0
  else if (!strcmp(attrname, "resource-state"))
2249
0
  {
2250
0
    num_strings = sizeof(ipp_resource_states) / sizeof(ipp_resource_states[0]);
2251
0
    strings     = ipp_resource_states;
2252
0
  }
2253
0
  else if (!strcmp(attrname, "system-state"))
2254
0
  {
2255
0
    num_strings = sizeof(ipp_system_states) / sizeof(ipp_system_states[0]);
2256
0
    strings     = ipp_system_states;
2257
0
  }
2258
0
  else
2259
0
  {
2260
0
    return (-1);
2261
0
  }
2262
2263
0
  for (i = 0; i < num_strings; i ++)
2264
0
  {
2265
0
    if (!strcmp(enumstring, strings[i]))
2266
0
      return (i + 3);
2267
0
  }
2268
2269
0
  return (-1);
2270
0
}
2271
2272
2273
//
2274
// 'ippErrorString()' - Return a name for the given status code.
2275
//
2276
2277
const char *        // O - Text string
2278
ippErrorString(ipp_status_t error)  // I - Error status
2279
0
{
2280
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2281
2282
2283
  // See if the error code is a known value...
2284
0
  if (error >= IPP_STATUS_OK && error <= IPP_STATUS_OK_EVENTS_COMPLETE)
2285
0
    return (ipp_status_oks[error]);
2286
0
  else if (error == IPP_STATUS_REDIRECTION_OTHER_SITE)
2287
0
    return ("redirection-other-site");
2288
0
  else if (error == IPP_STATUS_CUPS_SEE_OTHER)
2289
0
    return ("cups-see-other");
2290
0
  else if (error >= IPP_STATUS_ERROR_BAD_REQUEST && error <= IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED)
2291
0
    return (ipp_status_400s[error - IPP_STATUS_ERROR_BAD_REQUEST]);
2292
0
  else if (error >= IPP_STATUS_ERROR_INTERNAL && error <= IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS)
2293
0
    return (ipp_status_500s[error - IPP_STATUS_ERROR_INTERNAL]);
2294
0
  else if (error >= IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED && error <= IPP_STATUS_ERROR_CUPS_OAUTH)
2295
0
    return (ipp_status_1000s[error - IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED]);
2296
2297
  // No, build an "0xxxxx" error string...
2298
0
  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "0x%04x", error);
2299
2300
0
  return (cg->ipp_unknown);
2301
0
}
2302
2303
2304
//
2305
// 'ippErrorValue()' - Return a status code for the given name.
2306
//
2307
// @since CUPS 1.2@
2308
//
2309
2310
ipp_status_t        // O - IPP status code
2311
ippErrorValue(const char *name)   // I - Name
2312
0
{
2313
0
  size_t  i;      // Looping var
2314
2315
2316
0
  for (i = 0; i < (sizeof(ipp_status_oks) / sizeof(ipp_status_oks[0])); i ++)
2317
0
  {
2318
0
    if (!_cups_strcasecmp(name, ipp_status_oks[i]))
2319
0
      return ((ipp_status_t)i);
2320
0
  }
2321
2322
0
  if (!_cups_strcasecmp(name, "redirection-other-site"))
2323
0
    return (IPP_STATUS_REDIRECTION_OTHER_SITE);
2324
2325
0
  if (!_cups_strcasecmp(name, "cups-see-other"))
2326
0
    return (IPP_STATUS_CUPS_SEE_OTHER);
2327
2328
0
  for (i = 0; i < (sizeof(ipp_status_400s) / sizeof(ipp_status_400s[0])); i ++)
2329
0
  {
2330
0
    if (!_cups_strcasecmp(name, ipp_status_400s[i]))
2331
0
      return ((ipp_status_t)(i + 0x400));
2332
0
  }
2333
2334
0
  for (i = 0; i < (sizeof(ipp_status_500s) / sizeof(ipp_status_500s[0])); i ++)
2335
0
  {
2336
0
    if (!_cups_strcasecmp(name, ipp_status_500s[i]))
2337
0
      return ((ipp_status_t)(i + 0x500));
2338
0
  }
2339
2340
0
  for (i = 0; i < (sizeof(ipp_status_1000s) / sizeof(ipp_status_1000s[0])); i ++)
2341
0
  {
2342
0
    if (!_cups_strcasecmp(name, ipp_status_1000s[i]))
2343
0
      return ((ipp_status_t)(i + 0x1000));
2344
0
  }
2345
2346
0
  return ((ipp_status_t)-1);
2347
0
}
2348
2349
2350
//
2351
// 'ippGetPort()' - Return the default IPP port number.
2352
//
2353
// @since CUPS 2.5@
2354
//
2355
2356
int         // O - Port number
2357
ippGetPort(void)
2358
0
{
2359
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2360
2361
2362
0
  DEBUG_puts("ippPort()");
2363
2364
0
  if (!cg->client_conf_loaded)
2365
0
    _cupsSetDefaults();
2366
2367
0
  DEBUG_printf("1ippPort: Returning %d...", cg->ipp_port);
2368
2369
0
  return (cg->ipp_port);
2370
0
}
2371
2372
2373
//
2374
// 'ippOpString()' - Return a name for the given operation id.
2375
//
2376
// @since CUPS 1.2@
2377
//
2378
2379
const char *        // O - Name
2380
ippOpString(ipp_op_t op)    // I - Operation ID
2381
0
{
2382
0
  _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
2383
2384
2385
  // See if the operation ID is a known value...
2386
0
  if (op >= IPP_OP_PRINT_JOB && op < (ipp_op_t)(sizeof(ipp_std_ops) / sizeof(ipp_std_ops[0])))
2387
0
    return (ipp_std_ops[op]);
2388
0
  else if (op == IPP_OP_PRIVATE)
2389
0
    return ("windows-ext");
2390
0
  else if (op >= IPP_OP_CUPS_GET_DEFAULT && op <= IPP_OP_CUPS_GET_PPD)
2391
0
    return (ipp_cups_ops[op - IPP_OP_CUPS_GET_DEFAULT]);
2392
0
  else if (op >= IPP_OP_CUPS_GET_DOCUMENT && op <= IPP_OP_CUPS_CREATE_LOCAL_PRINTER)
2393
0
    return (ipp_cups_ops2[op - IPP_OP_CUPS_GET_DOCUMENT]);
2394
2395
  // No, build an "0xxxxx" operation string...
2396
0
  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "0x%04x", op);
2397
2398
0
  return (cg->ipp_unknown);
2399
0
}
2400
2401
2402
//
2403
// 'ippOpValue()' - Return an operation id for the given name.
2404
//
2405
// @since CUPS 1.2@
2406
//
2407
2408
ipp_op_t        // O - Operation ID
2409
ippOpValue(const char *name)    // I - Textual name
2410
0
{
2411
0
  size_t  i;      // Looping var
2412
2413
2414
0
  if (!strncmp(name, "0x", 2))
2415
0
    return ((ipp_op_t)strtol(name + 2, NULL, 16));
2416
2417
0
  for (i = 0; i < (sizeof(ipp_std_ops) / sizeof(ipp_std_ops[0])); i ++)
2418
0
  {
2419
0
    if (!_cups_strcasecmp(name, ipp_std_ops[i]))
2420
0
      return ((ipp_op_t)i);
2421
0
  }
2422
2423
0
  if (!_cups_strcasecmp(name, "windows-ext"))
2424
0
    return (IPP_OP_PRIVATE);
2425
2426
0
  for (i = 0; i < (sizeof(ipp_cups_ops) / sizeof(ipp_cups_ops[0])); i ++)
2427
0
  {
2428
0
    if (!_cups_strcasecmp(name, ipp_cups_ops[i]))
2429
0
      return ((ipp_op_t)(i + 0x4001));
2430
0
  }
2431
2432
0
  for (i = 0; i < (sizeof(ipp_cups_ops2) / sizeof(ipp_cups_ops2[0])); i ++)
2433
0
  {
2434
0
    if (!_cups_strcasecmp(name, ipp_cups_ops2[i]))
2435
0
      return ((ipp_op_t)(i + 0x4027));
2436
0
  }
2437
2438
0
  if (!_cups_strcasecmp(name, "Create-Job-Subscription"))
2439
0
    return (IPP_OP_CREATE_JOB_SUBSCRIPTIONS);
2440
2441
0
  if (!_cups_strcasecmp(name, "Create-Printer-Subscription"))
2442
0
    return (IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS);
2443
2444
0
  if (!_cups_strcasecmp(name, "CUPS-Add-Class"))
2445
0
    return (IPP_OP_CUPS_ADD_MODIFY_CLASS);
2446
2447
0
  if (!_cups_strcasecmp(name, "CUPS-Add-Printer"))
2448
0
    return (IPP_OP_CUPS_ADD_MODIFY_PRINTER);
2449
2450
0
  return (IPP_OP_CUPS_INVALID);
2451
0
}
2452
2453
2454
//
2455
// 'ippPort()' - Return the default IPP port number.
2456
//
2457
// @deprecated@ @exclude all@
2458
//
2459
2460
int         // O - Port number
2461
ippPort(void)
2462
0
{
2463
0
  return (ippGetPort());
2464
0
}
2465
2466
2467
//
2468
// 'ippSetPort()' - Set the default port number.
2469
//
2470
2471
void
2472
ippSetPort(int p)     // I - Port number to use
2473
0
{
2474
0
  DEBUG_printf("ippSetPort(p=%d)", p);
2475
2476
0
  _cupsGlobals()->ipp_port = p;
2477
0
}
2478
2479
2480
//
2481
// 'ippStateString()' - Return the name corresponding to a state value.
2482
//
2483
// @since CUPS 2.0/OS 10.10@
2484
//
2485
2486
const char *        // O - State name
2487
ippStateString(ipp_state_t state) // I - State value
2488
0
{
2489
0
  if (state >= IPP_STATE_ERROR && state <= IPP_STATE_DATA)
2490
0
    return (ipp_states[state - IPP_STATE_ERROR]);
2491
0
  else
2492
0
    return ("UNKNOWN");
2493
0
}
2494
2495
2496
//
2497
// 'ippTagString()' - Return the tag name corresponding to a tag value.
2498
//
2499
// The returned names are defined in RFC 8011 and the IANA IPP Registry.
2500
//
2501
// @since CUPS 1.4@
2502
//
2503
2504
const char *        // O - Tag name
2505
ippTagString(ipp_tag_t tag)   // I - Tag value
2506
0
{
2507
0
  tag &= IPP_TAG_CUPS_MASK;
2508
2509
0
  if (tag < (ipp_tag_t)(sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])))
2510
0
    return (ipp_tag_names[tag]);
2511
0
  else
2512
0
    return ("UNKNOWN");
2513
0
}
2514
2515
2516
//
2517
// 'ippTagValue()' - Return the tag value corresponding to a tag name.
2518
//
2519
// The tag names are defined in RFC 8011 and the IANA IPP Registry.
2520
//
2521
// @since CUPS 1.4@
2522
//
2523
2524
ipp_tag_t       // O - Tag value
2525
ippTagValue(const char *name)   // I - Tag name
2526
0
{
2527
0
  size_t  i;      // Looping var
2528
2529
2530
0
  for (i = 0; i < (sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])); i ++)
2531
0
  {
2532
0
    if (!_cups_strcasecmp(name, ipp_tag_names[i]))
2533
0
      return ((ipp_tag_t)i);
2534
0
  }
2535
2536
0
  if (!_cups_strcasecmp(name, "operation"))
2537
0
    return (IPP_TAG_OPERATION);
2538
0
  else if (!_cups_strcasecmp(name, "job"))
2539
0
    return (IPP_TAG_JOB);
2540
0
  else if (!_cups_strcasecmp(name, "printer"))
2541
0
    return (IPP_TAG_PRINTER);
2542
0
  else if (!_cups_strcasecmp(name, "unsupported"))
2543
0
    return (IPP_TAG_UNSUPPORTED_GROUP);
2544
0
  else if (!_cups_strcasecmp(name, "subscription"))
2545
0
    return (IPP_TAG_SUBSCRIPTION);
2546
0
  else if (!_cups_strcasecmp(name, "event"))
2547
0
    return (IPP_TAG_EVENT_NOTIFICATION);
2548
0
  else if (!_cups_strcasecmp(name, "language"))
2549
0
    return (IPP_TAG_LANGUAGE);
2550
0
  else if (!_cups_strcasecmp(name, "mimetype"))
2551
0
    return (IPP_TAG_MIMETYPE);
2552
0
  else if (!_cups_strcasecmp(name, "name"))
2553
0
    return (IPP_TAG_NAME);
2554
0
  else if (!_cups_strcasecmp(name, "text"))
2555
0
    return (IPP_TAG_TEXT);
2556
0
  else if (!_cups_strcasecmp(name, "begCollection"))
2557
0
    return (IPP_TAG_BEGIN_COLLECTION);
2558
0
  else
2559
0
    return (IPP_TAG_ZERO);
2560
0
}
2561
2562
2563
//
2564
// 'ipp_col_string()' - Convert a collection to a string.
2565
//
2566
2567
static size_t       // O - Number of bytes
2568
ipp_col_string(ipp_t  *col,   // I - Collection attribute
2569
               char   *buffer,    // I - Buffer or NULL
2570
               size_t bufsize)    // I - Size of buffer
2571
0
{
2572
0
  char      *bufptr,  // Position in buffer
2573
0
      *bufend,  // End of buffer
2574
0
      prefix = '{', // Prefix character
2575
0
      temp[256];  // Temporary string
2576
0
  ipp_attribute_t *attr;    // Current member attribute
2577
2578
2579
0
  if (!col)
2580
0
  {
2581
0
    if (buffer)
2582
0
      *buffer = '\0';
2583
2584
0
    return (0);
2585
0
  }
2586
2587
0
  bufptr = buffer;
2588
0
  bufend = buffer + bufsize - 1;
2589
2590
0
  for (attr = col->attrs; attr; attr = attr->next)
2591
0
  {
2592
0
    if (!attr->name)
2593
0
      continue;
2594
2595
0
    if (buffer && bufptr < bufend)
2596
0
      *bufptr = prefix;
2597
0
    bufptr ++;
2598
0
    prefix = ' ';
2599
2600
0
    if (buffer && bufptr < bufend)
2601
0
      bufptr += snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%s=", attr->name);
2602
0
    else
2603
0
      bufptr += strlen(attr->name) + 1;
2604
2605
0
    if (buffer && bufptr < bufend)
2606
0
      bufptr += ippAttributeString(attr, bufptr, (size_t)(bufend - bufptr + 1));
2607
0
    else
2608
0
      bufptr += ippAttributeString(attr, temp, sizeof(temp));
2609
0
  }
2610
2611
0
  if (prefix == '{')
2612
0
  {
2613
0
    if (buffer && bufptr < bufend)
2614
0
      *bufptr = prefix;
2615
0
    bufptr ++;
2616
0
  }
2617
2618
0
  if (buffer && bufptr < bufend)
2619
0
    *bufptr = '}';
2620
0
  bufptr ++;
2621
2622
0
  return ((size_t)(bufptr - buffer));
2623
0
}