Coverage Report

Created: 2025-07-18 07:04

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