Coverage Report

Created: 2023-11-19 06:30

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