2 * Internet Printing Protocol support functions for CUPS.
4 * Copyright 2007-2014 by Apple Inc.
5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * missing or damaged, see the license at "http://www.cups.org/".
13 * This file is subject to the Apple OS-Developed Software exception.
17 * Include necessary headers...
20 #include "cups-private.h"
27 static const char * const ipp_states
[] =
32 "IPP_STATE_ATTRIBUTE",
35 static const char * const ipp_status_oks
[] = /* "OK" status codes */
36 { /* (name) = abandoned standard value */
38 "successful-ok-ignored-or-substituted-attributes",
39 "successful-ok-conflicting-attributes",
40 "successful-ok-ignored-subscriptions",
41 "(successful-ok-ignored-notifications)",
42 "successful-ok-too-many-events",
43 "(successful-ok-but-cancel-subscription)",
44 "successful-ok-events-complete"
46 * const ipp_status_400s
[] = /* Client errors */
47 { /* (name) = abandoned standard value */
48 "client-error-bad-request",
49 "client-error-forbidden",
50 "client-error-not-authenticated",
51 "client-error-not-authorized",
52 "client-error-not-possible",
53 "client-error-timeout",
54 "client-error-not-found",
56 "client-error-request-entity-too-large",
57 "client-error-request-value-too-long",
58 "client-error-document-format-not-supported",
59 "client-error-attributes-or-values-not-supported",
60 "client-error-uri-scheme-not-supported",
61 "client-error-charset-not-supported",
62 "client-error-conflicting-attributes",
63 "client-error-compression-not-supported",
64 "client-error-compression-error",
65 "client-error-document-format-error",
66 "client-error-document-access-error",
67 "client-error-attributes-not-settable",
68 "client-error-ignored-all-subscriptions",
69 "client-error-too-many-subscriptions",
70 "(client-error-ignored-all-notifications)",
71 "(client-error-client-print-support-file-not-found)",
72 "client-error-document-password-error",
73 "client-error-document-permission-error",
74 "client-error-document-security-error",
75 "client-error-document-unprintable-error",
76 "client-error-account-info-needed",
77 "client-error-account-closed",
78 "client-error-account-limit-reached",
79 "client-error-account-authorization-failed",
80 "client-error-not-fetchable"
82 * const ipp_status_480s
[] = /* Vendor client errors */
101 /* 0x0490 - 0x049F */
114 "cups-error-account-info-needed",
115 "cups-error-account-closed",
116 "cups-error-account-limit-reached",
117 "cups-error-account-authorization-failed"
119 * const ipp_status_500s
[] = /* Server errors */
121 "server-error-internal-error",
122 "server-error-operation-not-supported",
123 "server-error-service-unavailable",
124 "server-error-version-not-supported",
125 "server-error-device-error",
126 "server-error-temporary-error",
127 "server-error-not-accepting-jobs",
129 "server-error-job-canceled",
130 "server-error-multiple-document-jobs-not-supported",
131 "server-error-printer-is-deactivated",
132 "server-error-too-many-jobs",
133 "server-error-too-many-documents"
135 * const ipp_status_1000s
[] = /* CUPS internal */
137 "cups-authentication-canceled",
139 "cups-upgrade-required"
141 static const char * const ipp_std_ops
[] =
143 /* 0x0000 - 0x000f */
153 "Get-Job-Attributes",
155 "Get-Printer-Attributes",
161 /* 0x0010 - 0x001f */
165 "Set-Printer-Attributes",
166 "Set-Job-Attributes",
167 "Get-Printer-Supported-Values",
168 "Create-Printer-Subscriptions",
169 "Create-Job-Subscriptions",
170 "Get-Subscription-Attributes",
172 "Renew-Subscription",
173 "Cancel-Subscription",
175 "(Send-Notifications)",
176 "(Get-Resource-Attributes)",
177 "(Get-Resource-Data)",
179 /* 0x0020 - 0x002f */
181 "(Get-Printer-Support-Files)",
184 "Pause-Printer-After-Current-Job",
186 "Release-Held-New-Jobs",
187 "Deactivate-Printer",
193 "Cancel-Current-Job",
194 "Suspend-Current-Job",
197 /* 0x0030 - 0x003f */
199 "Schedule-Job-After",
202 "Get-Document-Attributes",
205 "Set-Document-Attributes",
212 "Add-Document-Images",
213 "Acknowledge-Document",
215 /* 0x0040 - 0x004a */
216 "Acknowledge-Identify-Printer",
220 "Get-Output-Device-Attributes",
221 "Update-Active-Jobs",
222 "Deregister-Output-Device",
223 "Update-Document-Status",
225 "Update-Output-Device-Attributes",
226 "Get-Next-Document-Data"
228 * const ipp_cups_ops
[] =
232 "CUPS-Add-Modify-Printer",
233 "CUPS-Delete-Printer",
235 "CUPS-Add-Modify-Class",
243 "CUPS-Authenticate-Job",
246 * const ipp_cups_ops2
[] =
249 "CUPS-Create-Local-Printer"
251 * const ipp_tag_names
[] =
252 { /* Value/group tag names */
254 "operation-attributes-tag",
256 "job-attributes-tag", /* 0x02 */
257 "end-of-attributes-tag",
259 "printer-attributes-tag",
261 "unsupported-attributes-tag",
263 "subscription-attributes-tag",
265 "event-notification-attributes-tag",
267 "(resource-attributes-tag)",
269 "document-attributes-tag",
277 "unsupported", /* 0x10 */
278 "default", /* 0x11 */
279 "unknown", /* 0x12 */
280 "no-value", /* 0x13 */
282 "not-settable", /* 0x15 */
283 "delete-attribute", /* 0x16 */
284 "admin-define", /* 0x17 */
294 "integer", /* 0x21 */
295 "boolean", /* 0x22 */
309 "octetString", /* 0x30 */
310 "dateTime", /* 0x31 */
311 "resolution", /* 0x32 */
312 "rangeOfInteger", /* 0x33 */
313 "collection", /* 0x34 */
314 "textWithLanguage", /* 0x35 */
315 "nameWithLanguage", /* 0x36 */
316 "endCollection", /* 0x37 */
326 "textWithoutLanguage",/* 0x41 */
327 "nameWithoutLanguage",/* 0x42 */
329 "keyword", /* 0x44 */
331 "uriScheme", /* 0x46 */
332 "charset", /* 0x47 */
333 "naturalLanguage", /* 0x48 */
334 "mimeMediaType", /* 0x49 */
335 "memberAttrName" /* 0x4a */
337 static const char * const ipp_document_states
[] =
338 { /* document-state-enums */
342 "processing-stopped", /* IPPSIX */
347 * const ipp_finishings
[] =
348 { /* finishings enums */
361 "coat", /* Finishings 2.0 */
362 "laminate", /* Finishings 2.0 */
367 "staple-bottom-left",
369 "staple-bottom-right",
373 "edge-stitch-bottom",
377 "staple-dual-bottom",
378 "staple-triple-left", /* Finishings 2.0 */
379 "staple-triple-top", /* Finishings 2.0 */
380 "staple-triple-right",/* Finishings 2.0 */
381 "staple-triple-bottom",/* Finishings 2.0 */
407 "trim-after-documents",
416 "punch-top-left", /* Finishings 2.0 */
417 "punch-bottom-left", /* Finishings 2.0 */
418 "punch-top-right", /* Finishings 2.0 */
419 "punch-bottom-right", /* Finishings 2.0 */
420 "punch-dual-left", /* Finishings 2.0 */
421 "punch-dual-top", /* Finishings 2.0 */
422 "punch-dual-right", /* Finishings 2.0 */
423 "punch-dual-bottom", /* Finishings 2.0 */
424 "punch-triple-left", /* Finishings 2.0 */
425 "punch-triple-top", /* Finishings 2.0 */
426 "punch-triple-right", /* Finishings 2.0 */
427 "punch-triple-bottom",/* Finishings 2.0 */
428 "punch-quad-left", /* Finishings 2.0 */
429 "punch-quad-top", /* Finishings 2.0 */
430 "punch-quad-right", /* Finishings 2.0 */
431 "punch-quad-bottom", /* Finishings 2.0 */
432 "punch-multiple-left",/* Finishings 2.1/Canon */
433 "punch-multiple-top", /* Finishings 2.1/Canon */
434 "punch-multiple-right",/* Finishings 2.1/Canon */
435 "punch-multiple-bottom",/* Finishings 2.1/Canon */
436 "fold-accordian", /* Finishings 2.0 */
437 "fold-double-gate", /* Finishings 2.0 */
438 "fold-gate", /* Finishings 2.0 */
439 "fold-half", /* Finishings 2.0 */
440 "fold-half-z", /* Finishings 2.0 */
441 "fold-left-gate", /* Finishings 2.0 */
442 "fold-letter", /* Finishings 2.0 */
443 "fold-parallel", /* Finishings 2.0 */
444 "fold-poster", /* Finishings 2.0 */
445 "fold-right-gate", /* Finishings 2.0 */
446 "fold-z", /* Finishings 2.0 */
447 "fold-engineering-z" /* Finishings 2.1 */
449 * const ipp_finishings_vendor
[] =
451 /* 0x40000000 to 0x4000000F */
468 /* 0x40000010 to 0x4000001F */
485 /* 0x40000020 to 0x4000002F */
502 /* 0x40000030 to 0x4000003F */
519 /* 0x40000040 - 0x4000004F */
526 "cups-punch-top-left",
527 "cups-punch-bottom-left",
528 "cups-punch-top-right",
529 "cups-punch-bottom-right",
530 "cups-punch-dual-left",
531 "cups-punch-dual-top",
532 "cups-punch-dual-right",
533 "cups-punch-dual-bottom",
534 "cups-punch-triple-left",
535 "cups-punch-triple-top",
536 /* 0x40000050 - 0x4000005F */
537 "cups-punch-triple-right",
538 "cups-punch-triple-bottom",
539 "cups-punch-quad-left",
540 "cups-punch-quad-top",
541 "cups-punch-quad-right",
542 "cups-punch-quad-bottom",
547 "cups-fold-accordian",
548 "cups-fold-double-gate",
552 "cups-fold-left-gate",
553 /* 0x40000060 - 0x40000064 */
555 "cups-fold-parallel",
557 "cups-fold-right-gate",
560 * const ipp_job_collation_types
[] =
561 { /* job-collation-type enums */
563 "collated-documents",
564 "uncollated-documents"
566 * const ipp_job_states
[] =
567 { /* job-state enums */
571 "processing-stopped",
576 * const ipp_orientation_requesteds
[] =
577 { /* orientation-requested enums */
584 * const ipp_print_qualities
[] =
585 { /* print-quality enums */
590 * const ipp_printer_states
[] =
591 { /* printer-state enums */
602 static size_t ipp_col_string(ipp_t
*col
, char *buffer
, size_t bufsize
);
606 * 'ippAttributeString()' - Convert the attribute's value to a string.
608 * Returns the number of bytes that would be written, not including the
609 * trailing nul. The buffer pointer can be NULL to get the required length,
610 * just like (v)snprintf.
612 * @since CUPS 1.6/macOS 10.8@
615 size_t /* O - Number of bytes less nul */
617 ipp_attribute_t
*attr
, /* I - Attribute */
618 char *buffer
, /* I - String buffer or NULL */
619 size_t bufsize
) /* I - Size of string buffer */
621 int i
; /* Looping var */
622 char *bufptr
, /* Pointer into buffer */
623 *bufend
, /* End of buffer */
624 temp
[256]; /* Temporary string */
625 const char *ptr
, /* Pointer into string */
626 *end
; /* Pointer to end of string */
627 _ipp_value_t
*val
; /* Current value */
630 if (!attr
|| !attr
->name
)
640 bufend
= buffer
+ bufsize
- 1;
644 for (i
= attr
->num_values
, val
= attr
->values
; i
> 0; i
--, val
++)
646 if (val
> attr
->values
)
648 if (buffer
&& bufptr
< bufend
)
654 switch (attr
->value_tag
& ~IPP_TAG_CUPS_CONST
)
657 ptr
= ippEnumString(attr
->name
, val
->integer
);
659 if (buffer
&& bufptr
< bufend
)
660 strlcpy(bufptr
, ptr
, (size_t)(bufend
- bufptr
+ 1));
662 bufptr
+= strlen(ptr
);
665 case IPP_TAG_INTEGER
:
666 if (buffer
&& bufptr
< bufend
)
667 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d", val
->integer
);
669 bufptr
+= snprintf(temp
, sizeof(temp
), "%d", val
->integer
);
672 case IPP_TAG_BOOLEAN
:
673 if (buffer
&& bufptr
< bufend
)
674 strlcpy(bufptr
, val
->boolean
? "true" : "false", (size_t)(bufend
- bufptr
+ 1));
676 bufptr
+= val
->boolean
? 4 : 5;
680 if (buffer
&& bufptr
< bufend
)
681 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d-%d", val
->range
.lower
, val
->range
.upper
);
683 bufptr
+= snprintf(temp
, sizeof(temp
), "%d-%d", val
->range
.lower
, val
->range
.upper
);
686 case IPP_TAG_RESOLUTION
:
687 if (val
->resolution
.xres
== val
->resolution
.yres
)
689 if (buffer
&& bufptr
< bufend
)
690 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d%s", val
->resolution
.xres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
692 bufptr
+= snprintf(temp
, sizeof(temp
), "%d%s", val
->resolution
.xres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
694 else if (buffer
&& bufptr
< bufend
)
695 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
697 bufptr
+= snprintf(temp
, sizeof(temp
), "%dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
702 unsigned year
; /* Year */
704 year
= ((unsigned)val
->date
[0] << 8) + (unsigned)val
->date
[1];
706 if (val
->date
[9] == 0 && val
->date
[10] == 0)
707 snprintf(temp
, sizeof(temp
), "%04u-%02u-%02uT%02u:%02u:%02uZ",
708 year
, val
->date
[2], val
->date
[3], val
->date
[4],
709 val
->date
[5], val
->date
[6]);
711 snprintf(temp
, sizeof(temp
),
712 "%04u-%02u-%02uT%02u:%02u:%02u%c%02u%02u",
713 year
, val
->date
[2], val
->date
[3], val
->date
[4],
714 val
->date
[5], val
->date
[6], val
->date
[8], val
->date
[9],
717 if (buffer
&& bufptr
< bufend
)
718 strlcpy(bufptr
, temp
, (size_t)(bufend
- bufptr
+ 1));
720 bufptr
+= strlen(temp
);
726 case IPP_TAG_KEYWORD
:
727 case IPP_TAG_CHARSET
:
729 case IPP_TAG_URISCHEME
:
730 case IPP_TAG_MIMETYPE
:
731 case IPP_TAG_LANGUAGE
:
732 case IPP_TAG_TEXTLANG
:
733 case IPP_TAG_NAMELANG
:
734 if (!val
->string
.text
)
737 for (ptr
= val
->string
.text
; *ptr
; ptr
++)
739 if (*ptr
== '\\' || *ptr
== '\"' || *ptr
== '[')
741 if (buffer
&& bufptr
< bufend
)
746 if (buffer
&& bufptr
< bufend
)
751 if (val
->string
.language
)
754 * Add "[language]" to end of string...
757 if (buffer
&& bufptr
< bufend
)
761 if (buffer
&& bufptr
< bufend
)
762 strlcpy(bufptr
, val
->string
.language
, (size_t)(bufend
- bufptr
));
763 bufptr
+= strlen(val
->string
.language
);
765 if (buffer
&& bufptr
< bufend
)
771 case IPP_TAG_BEGIN_COLLECTION
:
772 if (buffer
&& bufptr
< bufend
)
773 bufptr
+= ipp_col_string(val
->collection
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
775 bufptr
+= ipp_col_string(val
->collection
, NULL
, 0);
778 case IPP_TAG_STRING
:
779 for (ptr
= val
->unknown
.data
, end
= ptr
+ val
->unknown
.length
;
782 if (*ptr
== '\\' || _cups_isspace(*ptr
))
784 if (buffer
&& bufptr
< bufend
)
788 if (buffer
&& bufptr
< bufend
)
792 else if (!isprint(*ptr
& 255))
794 if (buffer
&& bufptr
< bufend
)
795 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "\\%03o", *ptr
& 255);
797 bufptr
+= snprintf(temp
, sizeof(temp
), "\\%03o", *ptr
& 255);
801 if (buffer
&& bufptr
< bufend
)
809 ptr
= ippTagString(attr
->value_tag
);
810 if (buffer
&& bufptr
< bufend
)
811 strlcpy(bufptr
, ptr
, (size_t)(bufend
- bufptr
+ 1));
812 bufptr
+= strlen(ptr
);
817 if (buffer
&& bufptr
< bufend
)
822 return ((size_t)(bufptr
- buffer
));
827 * 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
828 * given requested-attributes attribute.
830 * This function creates a (sorted) CUPS array of attribute names matching the
831 * list of "requested-attribute" values supplied in an IPP request. All IANA-
832 * registered values are supported in addition to the CUPS IPP extension
835 * The @code request@ parameter specifies the request message that was read from
838 * @code NULL@ is returned if all attributes should be returned. Otherwise, the
839 * result is a sorted array of attribute names, where @code cupsArrayFind(array,
840 * "attribute-name")@ will return a non-NULL pointer. The array must be freed
841 * using the @code cupsArrayDelete@ function.
843 * @since CUPS 1.7/macOS 10.9@
846 cups_array_t
* /* O - CUPS array or @code NULL@ if all */
847 ippCreateRequestedArray(ipp_t
*request
) /* I - IPP request */
849 int i
, j
, /* Looping vars */
850 count
, /* Number of values */
851 added
; /* Was name added? */
852 ipp_attribute_t
*requested
; /* requested-attributes attribute */
853 cups_array_t
*ra
; /* Requested attributes array */
854 const char *value
; /* Current value */
855 /* The following lists come from the current IANA IPP registry of attributes */
856 static const char * const document_description
[] =
857 { /* document-description group */
861 "cover-front-actual",
862 "current-page-order",
863 "date-time-at-completed",
864 "date-time-at-creation",
865 "date-time-at-processing",
866 "detailed-status-messages",
867 "document-access-errors",
869 "document-digital-signature",
871 "document-format-details",
872 "document-format-detected",
873 "document-format-version",
874 "document-format-version-detected",
880 "document-natural-language",
882 "document-printer-uri",
884 "document-state-message",
885 "document-state-reasons",
890 "finishings-col-actual",
891 "force-front-side-actual",
892 "imposition-template-actual",
894 "impressions-completed",
895 "impressions-completed-current-copy",
896 "insert-sheet-actual",
898 "k-octets-processed",
900 "materials-col-actual", /* IPP 3D */
903 "media-input-tray-check-actual",
905 "media-sheets-completed",
907 "multiple-object-handling-actual", /* IPP 3D */
909 "orientation-requested-actual",
911 "output-device-assigned",
913 "page-delivery-actual",
914 "page-order-received-actual",
915 "page-ranges-actual",
918 "pages-completed-current-copy",
919 "platform-temperature-actual", /* IPP 3D */
920 "presentation-direction-number-up-actual",
921 "print-accuracy-actual", /* IPP 3D */
922 "print-base-actual", /* IPP 3D */
923 "print-color-mode-actual",
924 "print-content-optimize-actual",
925 "print-objects-actual", /* IPP 3D */
926 "print-quality-actual",
927 "print-rendering-intent-actual",
928 "print-scaling-actual", /* IPP Paid Printing */
929 "print-supports-actual", /* IPP 3D */
930 "printer-resolution-actual",
932 "separator-sheets-actual",
933 "sheet-completed-copy-number",
937 "time-at-processing",
938 "x-image-position-actual",
939 "x-image-shift-actual",
940 "x-side1-image-shift-actual",
941 "x-side2-image-shift-actual",
942 "y-image-position-actual",
943 "y-image-shift-actual",
944 "y-side1-image-shift-actual",
945 "y-side2-image-shift-actual"
947 static const char * const document_template
[] =
948 { /* document-template group */
953 "cover-back-default",
954 "cover-back-supported",
956 "cover-front-default",
957 "cover-front-supported",
959 "feed-orientation-default",
960 "feed-orientation-supported",
963 "finishings-col-default",
964 "finishings-col-supported",
965 "finishings-default",
966 "finishings-supported",
967 "font-name-requested",
968 "font-name-requested-default",
969 "font-name-requested-supported",
970 "font-size-requested",
971 "font-size-requested-default",
972 "font-size-requested-supported",
974 "force-front-side-default",
975 "force-front-side-supported",
976 "imposition-template",
977 "imposition-template-default",
978 "imposition-template-supported",
979 "insert-after-page-number-supported",
980 "insert-count-supported",
982 "insert-sheet-default",
983 "insert-sheet-supported",
984 "material-amount-units-supported", /* IPP 3D */
985 "material-diameter-supported", /* IPP 3D */
986 "material-purpose-supported", /* IPP 3D */
987 "material-rate-supported", /* IPP 3D */
988 "material-rate-units-supported", /* IPP 3D */
989 "material-shell-thickness-supported",/* IPP 3D */
990 "material-temperature-supported", /* IPP 3D */
991 "material-type-supported", /* IPP 3D */
992 "materials-col", /* IPP 3D */
993 "materials-col-database", /* IPP 3D */
994 "materials-col-default", /* IPP 3D */
995 "materials-col-ready", /* IPP 3D */
996 "materials-col-supported", /* IPP 3D */
997 "max-materials-col-supported", /* IPP 3D */
998 "max-stitching-locations-supported",
1000 "media-back-coating-supported",
1001 "media-bottom-margin-supported",
1003 "media-col-default",
1004 "media-col-supported",
1005 "media-color-supported",
1007 "media-front-coating-supported",
1008 "media-grain-supported",
1009 "media-hole-count-supported",
1010 "media-info-supported",
1011 "media-input-tray-check",
1012 "media-input-tray-check-default",
1013 "media-input-tray-check-supported",
1014 "media-key-supported",
1015 "media-left-margin-supported",
1016 "media-order-count-supported",
1017 "media-pre-printed-supported",
1018 "media-recycled-supported",
1019 "media-right-margin-supported",
1020 "media-size-supported",
1021 "media-source-supported",
1023 "media-thickness-supported",
1024 "media-top-margin-supported",
1025 "media-type-supported",
1026 "media-weight-metric-supported",
1027 "multiple-document-handling",
1028 "multiple-document-handling-default",
1029 "multiple-document-handling-supported",
1030 "multiple-object-handling", /* IPP 3D */
1031 "multiple-object-handling-default", /* IPP 3D */
1032 "multiple-object-handling-supported",/* IPP 3D */
1034 "number-up-default",
1035 "number-up-supported",
1036 "orientation-requested",
1037 "orientation-requested-default",
1038 "orientation-requested-supported",
1039 "output-mode", /* CUPS extension */
1040 "output-mode-default", /* CUPS extension */
1041 "output-mode-supported", /* CUPS extension */
1043 "overrides-supported",
1045 "page-delivery-default",
1046 "page-delivery-supported",
1047 "page-order-received",
1048 "page-order-received-default",
1049 "page-order-received-supported",
1051 "page-ranges-supported",
1053 "pages-per-subset-supported",
1055 "pdl-init-file-default",
1056 "pdl-init-file-entry-supported",
1057 "pdl-init-file-location-supported",
1058 "pdl-init-file-name-subdirectory-supported",
1059 "pdl-init-file-name-supported",
1060 "pdl-init-file-supported",
1061 "platform-temperature", /* IPP 3D */
1062 "platform-temperature-default", /* IPP 3D */
1063 "platform-temperature-supported", /* IPP 3D */
1064 "presentation-direction-number-up",
1065 "presentation-direction-number-up-default",
1066 "presentation-direction-number-up-supported",
1067 "print-accuracy", /* IPP 3D */
1068 "print-accuracy-default", /* IPP 3D */
1069 "print-accuracy-supported", /* IPP 3D */
1070 "print-base", /* IPP 3D */
1071 "print-base-default", /* IPP 3D */
1072 "print-base-supported", /* IPP 3D */
1074 "print-color-mode-default",
1075 "print-color-mode-supported",
1076 "print-content-optimize",
1077 "print-content-optimize-default",
1078 "print-content-optimize-supported",
1079 "print-objects", /* IPP 3D */
1080 "print-objects-default", /* IPP 3D */
1081 "print-objects-supported", /* IPP 3D */
1083 "print-quality-default",
1084 "print-quality-supported",
1085 "print-rendering-intent",
1086 "print-rendering-intent-default",
1087 "print-rendering-intent-supported",
1088 "print-scaling", /* IPP Paid Printing */
1089 "print-scaling-default", /* IPP Paid Printing */
1090 "print-scaling-supported", /* IPP Paid Printing */
1091 "print-supports", /* IPP 3D */
1092 "print-supports-default", /* IPP 3D */
1093 "print-supports-supported", /* IPP 3D */
1094 "printer-resolution",
1095 "printer-resolution-default",
1096 "printer-resolution-supported",
1098 "separator-sheets-default",
1099 "separator-sheets-supported",
1101 "sheet-collate-default",
1102 "sheet-collate-supported",
1106 "stitching-locations-supported",
1107 "stitching-offset-supported",
1109 "x-image-position-default",
1110 "x-image-position-supported",
1112 "x-image-shift-default",
1113 "x-image-shift-supported",
1114 "x-side1-image-shift",
1115 "x-side1-image-shift-default",
1116 "x-side1-image-shift-supported",
1117 "x-side2-image-shift",
1118 "x-side2-image-shift-default",
1119 "x-side2-image-shift-supported",
1121 "y-image-position-default",
1122 "y-image-position-supported",
1124 "y-image-shift-default",
1125 "y-image-shift-supported",
1126 "y-side1-image-shift",
1127 "y-side1-image-shift-default",
1128 "y-side1-image-shift-supported",
1129 "y-side2-image-shift",
1130 "y-side2-image-shift-default",
1131 "y-side2-image-shift-supported"
1133 static const char * const job_description
[] =
1134 { /* job-description group */
1135 "compression-supplied",
1137 "cover-back-actual",
1138 "cover-front-actual",
1139 "current-page-order",
1140 "date-time-at-completed",
1141 "date-time-at-creation",
1142 "date-time-at-processing",
1143 "destination-statuses",
1144 "document-charset-supplied",
1145 "document-digital-signature-supplied",
1146 "document-format-details-supplied",
1147 "document-format-supplied",
1148 "document-message-supplied",
1149 "document-metadata",
1150 "document-name-supplied",
1151 "document-natural-language-supplied",
1152 "document-overrides-actual",
1154 "finishings-actual",
1155 "finishings-col-actual",
1156 "force-front-side-actual",
1157 "imposition-template-actual",
1158 "impressions-completed-current-copy",
1159 "insert-sheet-actual",
1160 "job-account-id-actual",
1161 "job-accounting-sheets-actual",
1162 "job-accounting-user-id-actual",
1163 "job-attribute-fidelity",
1164 "job-charge-info", /* CUPS extension */
1165 "job-collation-type",
1166 "job-collation-type-actual",
1167 "job-copies-actual",
1168 "job-cover-back-actual",
1169 "job-cover-front-actual",
1170 "job-detailed-status-message",
1171 "job-document-access-errors",
1172 "job-error-sheet-actual",
1173 "job-finishings-actual",
1174 "job-finishings-col-actual",
1175 "job-hold-until-actual",
1178 "job-impressions-completed",
1180 "job-k-octets-processed",
1181 "job-mandatory-attributes",
1182 "job-media-progress", /* CUPS extension */
1184 "job-media-sheets-completed",
1185 "job-message-from-operator",
1188 "job-originating-host-name", /* CUPS extension */
1189 "job-originating-user-name",
1190 "job-originating-user-uri",
1192 "job-pages-completed",
1193 "job-pages-completed-current-copy",
1194 "job-printer-state-message", /* CUPS extension */
1195 "job-printer-state-reasons", /* CUPS extension */
1196 "job-printer-up-time",
1198 "job-priority-actual",
1199 "job-save-printer-make-and-model",
1200 "job-sheet-message-actual",
1201 "job-sheets-actual",
1202 "job-sheets-col-actual",
1204 "job-state-message",
1205 "job-state-reasons",
1208 "materials-col-actual", /* IPP 3D */
1211 "media-check-input-tray-actual",
1212 "multiple-document-handling-actual",
1213 "multiple-object-handling-actual", /* IPP 3D */
1214 "number-of-documents",
1215 "number-of-intervening-jobs",
1217 "orientation-requested-actual",
1218 "original-requesting-user-name",
1219 "output-bin-actual",
1220 "output-device-assigned",
1222 "page-delivery-actual",
1223 "page-order-received-actual",
1224 "page-ranges-actual",
1225 "platform-temperature-actual", /* IPP 3D */
1226 "presentation-direction-number-up-actual",
1227 "print-accuracy-actual", /* IPP 3D */
1228 "print-base-actual", /* IPP 3D */
1229 "print-color-mode-actual",
1230 "print-content-optimize-actual",
1231 "print-objects-actual", /* IPP 3D */
1232 "print-quality-actual",
1233 "print-rendering-intent-actual",
1234 "print-scaling-actual", /* IPP Paid Printing */
1235 "print-supports-actual", /* IPP 3D */
1236 "printer-resolution-actual",
1237 "separator-sheets-actual",
1238 "sheet-collate-actual",
1239 "sheet-completed-copy-number",
1240 "sheet-completed-document-number",
1242 "time-at-completed",
1244 "time-at-processing",
1246 "x-image-position-actual",
1247 "x-image-shift-actual",
1248 "x-side1-image-shift-actual",
1249 "x-side2-image-shift-actual",
1250 "y-image-position-actual",
1251 "y-image-shift-actual",
1252 "y-side1-image-shift-actual",
1253 "y-side2-image-shift-actual"
1255 static const char * const job_template
[] =
1256 { /* job-template group */
1257 "accuracy-units-supported", /* IPP 3D */
1258 "confirmation-sheet-print", /* IPP FaxOut */
1259 "confirmation-sheet-print-default",
1264 "cover-back-default",
1265 "cover-back-supported",
1267 "cover-front-default",
1268 "cover-front-supported",
1269 "cover-sheet-info", /* IPP FaxOut */
1270 "cover-sheet-info-default",
1271 "cover-sheet-info-supported",
1272 "destination-uri-schemes-supported",/* IPP FaxOut */
1273 "destination-uris", /* IPP FaxOut */
1274 "destination-uris-supported",
1276 "feed-orientation-default",
1277 "feed-orientation-supported",
1280 "finishings-col-default",
1281 "finishings-col-supported",
1282 "finishings-default",
1283 "finishings-supported",
1284 "font-name-requested",
1285 "font-name-requested-default",
1286 "font-name-requested-supported",
1287 "font-size-requested",
1288 "font-size-requested-default",
1289 "font-size-requested-supported",
1291 "force-front-side-default",
1292 "force-front-side-supported",
1293 "imposition-template",
1294 "imposition-template-default",
1295 "imposition-template-supported",
1296 "insert-after-page-number-supported",
1297 "insert-count-supported",
1299 "insert-sheet-default",
1300 "insert-sheet-supported",
1302 "job-account-id-default",
1303 "job-account-id-supported",
1304 "job-accounting-sheets"
1305 "job-accounting-sheets-default"
1306 "job-accounting-sheets-supported"
1307 "job-accounting-user-id",
1308 "job-accounting-user-id-default",
1309 "job-accounting-user-id-supported",
1311 "job-copies-default",
1312 "job-copies-supported",
1314 "job-cover-back-default",
1315 "job-cover-back-supported",
1317 "job-cover-front-default",
1318 "job-cover-front-supported",
1319 "job-delay-output-until",
1320 "job-delay-output-until-default",
1321 "job-delay-output-until-supported",
1322 "job-delay-output-until-time",
1323 "job-delay-output-until-time-default",
1324 "job-delay-output-until-time-supported",
1326 "job-error-action-default",
1327 "job-error-action-supported",
1329 "job-error-sheet-default",
1330 "job-error-sheet-supported",
1332 "job-finishings-col",
1333 "job-finishings-col-default",
1334 "job-finishings-col-supported",
1335 "job-finishings-default",
1336 "job-finishings-supported",
1338 "job-hold-until-default",
1339 "job-hold-until-supported",
1340 "job-hold-until-time",
1341 "job-hold-until-time-default",
1342 "job-hold-until-time-supported",
1343 "job-message-to-operator",
1344 "job-message-to-operator-default",
1345 "job-message-to-operator-supported",
1347 "job-phone-number-default",
1348 "job-phone-number-supported",
1350 "job-priority-default",
1351 "job-priority-supported",
1352 "job-recipient-name",
1353 "job-recipient-name-default",
1354 "job-recipient-name-supported",
1355 "job-save-disposition",
1356 "job-save-disposition-default",
1357 "job-save-disposition-supported",
1360 "job-sheets-col-default",
1361 "job-sheets-col-supported",
1362 "job-sheets-default",
1363 "job-sheets-supported",
1364 "logo-uri-schemes-supported",
1365 "material-amount-units-supported", /* IPP 3D */
1366 "material-diameter-supported", /* IPP 3D */
1367 "material-purpose-supported", /* IPP 3D */
1368 "material-rate-supported", /* IPP 3D */
1369 "material-rate-units-supported", /* IPP 3D */
1370 "material-shell-thickness-supported",/* IPP 3D */
1371 "material-temperature-supported", /* IPP 3D */
1372 "material-type-supported", /* IPP 3D */
1373 "materials-col", /* IPP 3D */
1374 "materials-col-database", /* IPP 3D */
1375 "materials-col-default", /* IPP 3D */
1376 "materials-col-ready", /* IPP 3D */
1377 "materials-col-supported", /* IPP 3D */
1378 "max-materials-col-supported", /* IPP 3D */
1379 "max-save-info-supported",
1380 "max-stitching-locations-supported",
1382 "media-back-coating-supported",
1383 "media-bottom-margin-supported",
1385 "media-col-default",
1386 "media-col-supported",
1387 "media-color-supported",
1389 "media-front-coating-supported",
1390 "media-grain-supported",
1391 "media-hole-count-supported",
1392 "media-info-supported",
1393 "media-input-tray-check",
1394 "media-input-tray-check-default",
1395 "media-input-tray-check-supported",
1396 "media-key-supported",
1397 "media-left-margin-supported",
1398 "media-order-count-supported",
1399 "media-pre-printed-supported",
1400 "media-recycled-supported",
1401 "media-right-margin-supported",
1402 "media-size-supported",
1403 "media-source-supported",
1405 "media-thickness-supported",
1406 "media-top-margin-supported",
1407 "media-type-supported",
1408 "media-weight-metric-supported",
1409 "multiple-document-handling",
1410 "multiple-document-handling-default",
1411 "multiple-document-handling-supported",
1412 "multiple-object-handling", /* IPP 3D */
1413 "multiple-object-handling-default", /* IPP 3D */
1414 "multiple-object-handling-supported",/* IPP 3D */
1415 "number-of-retries", /* IPP FaxOut */
1416 "number-of-retries-default",
1417 "number-of-retries-supported",
1419 "number-up-default",
1420 "number-up-supported",
1421 "orientation-requested",
1422 "orientation-requested-default",
1423 "orientation-requested-supported",
1425 "output-bin-default",
1426 "output-bin-supported",
1428 "output-device-default",
1429 "output-device-supported",
1430 "output-mode", /* CUPS extension */
1431 "output-mode-default", /* CUPS extension */
1432 "output-mode-supported", /* CUPS extension */
1434 "overrides-supported",
1436 "page-delivery-default",
1437 "page-delivery-supported",
1438 "page-order-received",
1439 "page-order-received-default",
1440 "page-order-received-supported",
1442 "page-ranges-supported",
1444 "pages-per-subset-supported",
1446 "pdl-init-file-default",
1447 "pdl-init-file-entry-supported",
1448 "pdl-init-file-location-supported",
1449 "pdl-init-file-name-subdirectory-supported",
1450 "pdl-init-file-name-supported",
1451 "pdl-init-file-supported",
1452 "platform-temperature", /* IPP 3D */
1453 "platform-temperature-default", /* IPP 3D */
1454 "platform-temperature-supported", /* IPP 3D */
1455 "presentation-direction-number-up",
1456 "presentation-direction-number-up-default",
1457 "presentation-direction-number-up-supported",
1458 "print-accuracy", /* IPP 3D */
1459 "print-accuracy-default", /* IPP 3D */
1460 "print-accuracy-supported", /* IPP 3D */
1461 "print-base", /* IPP 3D */
1462 "print-base-default", /* IPP 3D */
1463 "print-base-supported", /* IPP 3D */
1465 "print-color-mode-default",
1466 "print-color-mode-supported",
1467 "print-content-optimize",
1468 "print-content-optimize-default",
1469 "print-content-optimize-supported",
1470 "print-objects", /* IPP 3D */
1471 "print-objects-default", /* IPP 3D */
1472 "print-objects-supported", /* IPP 3D */
1474 "print-quality-default",
1475 "print-quality-supported",
1476 "print-rendering-intent",
1477 "print-rendering-intent-default",
1478 "print-rendering-intent-supported",
1479 "print-scaling", /* IPP Paid Printing */
1480 "print-scaling-default", /* IPP Paid Printing */
1481 "print-scaling-supported", /* IPP Paid Printing */
1482 "print-supports", /* IPP 3D */
1483 "print-supports-default", /* IPP 3D */
1484 "print-supports-supported", /* IPP 3D */
1485 "printer-resolution",
1486 "printer-resolution-default",
1487 "printer-resolution-supported",
1489 "proof-print-default",
1490 "proof-print-supported",
1491 "retry-interval", /* IPP FaxOut */
1492 "retry-interval-default",
1493 "retry-interval-supported",
1494 "retry-timeout", /* IPP FaxOut */
1495 "retry-timeout-default",
1496 "retry-timeout-supported",
1497 "save-disposition-supported",
1498 "save-document-format-default",
1499 "save-document-format-supported",
1500 "save-location-default",
1501 "save-location-supported",
1502 "save-name-subdirectory-supported",
1503 "save-name-supported",
1505 "separator-sheets-default",
1506 "separator-sheets-supported",
1508 "sheet-collate-default",
1509 "sheet-collate-supported",
1513 "stitching-locations-supported",
1514 "stitching-offset-supported",
1516 "x-image-position-default",
1517 "x-image-position-supported",
1519 "x-image-shift-default",
1520 "x-image-shift-supported",
1521 "x-side1-image-shift",
1522 "x-side1-image-shift-default",
1523 "x-side1-image-shift-supported",
1524 "x-side2-image-shift",
1525 "x-side2-image-shift-default",
1526 "x-side2-image-shift-supported",
1528 "y-image-position-default",
1529 "y-image-position-supported",
1531 "y-image-shift-default",
1532 "y-image-shift-supported",
1533 "y-side1-image-shift",
1534 "y-side1-image-shift-default",
1535 "y-side1-image-shift-supported",
1536 "y-side2-image-shift",
1537 "y-side2-image-shift-default",
1538 "y-side2-image-shift-supported"
1540 static const char * const printer_description
[] =
1541 { /* printer-description group */
1542 "auth-info-required", /* CUPS extension */
1543 "charset-configured",
1544 "charset-supported",
1546 "compression-supported",
1547 "device-service-count",
1548 "device-uri", /* CUPS extension */
1550 "document-charset-default",
1551 "document-charset-supported",
1552 "document-creation-attributes-supported",
1553 "document-digital-signature-default",
1554 "document-digital-signature-supported",
1555 "document-format-default",
1556 "document-format-details-default",
1557 "document-format-details-supported",
1558 "document-format-supported",
1559 "document-format-varying-attributes",
1560 "document-format-version-default",
1561 "document-format-version-supported",
1562 "document-natural-language-default",
1563 "document-natural-language-supported",
1564 "document-password-supported",
1565 "generated-natural-language-supported",
1566 "identify-actions-default",
1567 "identify-actions-supported",
1568 "input-source-supported",
1569 "ipp-features-supported",
1570 "ipp-versions-supported",
1571 "ippget-event-life",
1572 "job-authorization-uri-supported", /* CUPS extension */
1573 "job-constraints-supported",
1574 "job-creation-attributes-supported",
1575 "job-finishings-col-ready",
1576 "job-finishings-ready",
1577 "job-ids-supported",
1578 "job-impressions-supported",
1579 "job-k-limit", /* CUPS extension */
1580 "job-k-octets-supported",
1581 "job-media-sheets-supported",
1582 "job-page-limit", /* CUPS extension */
1583 "job-password-encryption-supported",
1584 "job-password-supported",
1585 "job-quota-period", /* CUPS extension */
1586 "job-resolvers-supported",
1587 "job-settable-attributes-supported",
1588 "job-spooling-supported",
1589 "jpeg-k-octets-supported", /* CUPS extension */
1590 "jpeg-x-dimension-supported", /* CUPS extension */
1591 "jpeg-y-dimension-supported", /* CUPS extension */
1592 "landscape-orientation-requested-preferred",
1593 /* CUPS extension */
1594 "marker-change-time", /* CUPS extension */
1595 "marker-colors", /* CUPS extension */
1596 "marker-high-levels", /* CUPS extension */
1597 "marker-levels", /* CUPS extension */
1598 "marker-low-levels", /* CUPS extension */
1599 "marker-message", /* CUPS extension */
1600 "marker-names", /* CUPS extension */
1601 "marker-types", /* CUPS extension */
1604 "member-names", /* CUPS extension */
1605 "member-uris", /* CUPS extension */
1606 "multiple-destination-uris-supported",/* IPP FaxOut */
1607 "multiple-document-jobs-supported",
1608 "multiple-operation-time-out",
1609 "multiple-operation-time-out-action",
1610 "natural-language-configured",
1611 "operations-supported",
1613 "pages-per-minute-color",
1614 "pdf-k-octets-supported", /* CUPS extension */
1615 "pdf-features-supported", /* IPP 3D */
1616 "pdf-versions-supported", /* CUPS extension */
1617 "pdl-override-supported",
1618 "port-monitor", /* CUPS extension */
1619 "port-monitor-supported", /* CUPS extension */
1620 "preferred-attributes-supported",
1622 "printer-alert-description",
1623 "printer-charge-info",
1624 "printer-charge-info-uri",
1625 "printer-commands", /* CUPS extension */
1626 "printer-current-time",
1627 "printer-detailed-status-messages",
1628 "printer-device-id",
1629 "printer-dns-sd-name", /* CUPS extension */
1630 "printer-driver-installer",
1631 "printer-fax-log-uri", /* IPP FaxOut */
1632 "printer-fax-modem-info", /* IPP FaxOut */
1633 "printer-fax-modem-name", /* IPP FaxOut */
1634 "printer-fax-modem-number", /* IPP FaxOut */
1635 "printer-firmware-name", /* PWG 5110.1 */
1636 "printer-firmware-patches", /* PWG 5110.1 */
1637 "printer-firmware-string-version", /* PWG 5110.1 */
1638 "printer-firmware-version", /* PWG 5110.1 */
1639 "printer-geo-location",
1640 "printer-get-attributes-supported",
1641 "printer-icc-profiles",
1643 "printer-id", /* CUPS extension */
1645 "printer-input-tray", /* IPP JPS3 */
1646 "printer-is-accepting-jobs",
1647 "printer-is-shared", /* CUPS extension */
1648 "printer-is-temporary", /* CUPS extension */
1649 "printer-kind", /* IPP Paid Printing */
1651 "printer-make-and-model",
1652 "printer-mandatory-job-attributes",
1653 "printer-message-date-time",
1654 "printer-message-from-operator",
1655 "printer-message-time",
1656 "printer-more-info",
1657 "printer-more-info-manufacturer",
1659 "printer-native-formats",
1660 "printer-organization",
1661 "printer-organizational-unit",
1662 "printer-output-tray", /* IPP JPS3 */
1663 "printer-queue-id", /* CUPS extension */
1664 "printer-settable-attributes-supported",
1666 "printer-state-change-date-time",
1667 "printer-state-change-time",
1668 "printer-state-message",
1669 "printer-state-reasons",
1671 "printer-supply-description",
1672 "printer-supply-info-uri",
1673 "printer-type", /* CUPS extension */
1675 "printer-uri-supported",
1677 "printer-xri-supported",
1678 "pwg-raster-document-resolution-supported",
1679 "pwg-raster-document-sheet-back",
1680 "pwg-raster-document-type-supported",
1682 "reference-uri-schemes-supported",
1683 "repertoire-supported",
1684 "requesting-user-name-allowed", /* CUPS extension */
1685 "requesting-user-name-denied", /* CUPS extension */
1686 "requesting-user-uri-supported",
1687 "subordinate-printers-supported",
1688 "urf-supported", /* CUPS extension */
1689 "uri-authentication-supported",
1690 "uri-security-supported",
1691 "user-defined-value-supported",
1692 "which-jobs-supported",
1693 "xri-authentication-supported",
1694 "xri-security-supported",
1695 "xri-uri-scheme-supported"
1697 static const char * const subscription_description
[] =
1698 { /* subscription-description group */
1700 "notify-lease-expiration-time",
1701 "notify-printer-up-time",
1702 "notify-printer-uri",
1703 "notify-sequence-number",
1704 "notify-subscriber-user-name",
1705 "notify-subscriber-user-uri",
1706 "notify-subscription-id",
1707 "subscriptions-uuid"
1709 static const char * const subscription_template
[] =
1710 { /* subscription-template group */
1711 "notify-attributes",
1712 "notify-attributes-supported",
1715 "notify-events-default",
1716 "notify-events-supported",
1717 "notify-lease-duration",
1718 "notify-lease-duration-default",
1719 "notify-lease-duration-supported",
1720 "notify-max-events-supported",
1721 "notify-natural-language",
1722 "notify-pull-method",
1723 "notify-pull-method-supported",
1724 "notify-recipient-uri",
1725 "notify-schemes-supported",
1726 "notify-time-interval",
1732 * Get the requested-attributes attribute...
1735 if ((requested
= ippFindAttribute(request
, "requested-attributes",
1736 IPP_TAG_KEYWORD
)) == NULL
)
1739 * The Get-Jobs operation defaults to "job-id" and "job-uri", all others
1740 * default to "all"...
1743 if (ippGetOperation(request
) == IPP_OP_GET_JOBS
)
1745 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1746 cupsArrayAdd(ra
, "job-id");
1747 cupsArrayAdd(ra
, "job-uri");
1756 * If the attribute contains a single "all" keyword, return NULL...
1759 count
= ippGetCount(requested
);
1760 if (count
== 1 && !strcmp(ippGetString(requested
, 0, NULL
), "all"))
1764 * Create an array using "strcmp" as the comparison function...
1767 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1769 for (i
= 0; i
< count
; i
++)
1772 value
= ippGetString(requested
, i
, NULL
);
1774 if (!strcmp(value
, "document-description") || !strcmp(value
, "all"))
1777 j
< (int)(sizeof(document_description
) /
1778 sizeof(document_description
[0]));
1780 cupsArrayAdd(ra
, (void *)document_description
[j
]);
1785 if (!strcmp(value
, "document-template") || !strcmp(value
, "all"))
1788 j
< (int)(sizeof(document_template
) / sizeof(document_template
[0]));
1790 cupsArrayAdd(ra
, (void *)document_template
[j
]);
1795 if (!strcmp(value
, "job-description") || !strcmp(value
, "all"))
1798 j
< (int)(sizeof(job_description
) / sizeof(job_description
[0]));
1800 cupsArrayAdd(ra
, (void *)job_description
[j
]);
1805 if (!strcmp(value
, "job-template") || !strcmp(value
, "all"))
1808 j
< (int)(sizeof(job_template
) / sizeof(job_template
[0]));
1810 cupsArrayAdd(ra
, (void *)job_template
[j
]);
1815 if (!strcmp(value
, "printer-description") || !strcmp(value
, "all"))
1818 j
< (int)(sizeof(printer_description
) /
1819 sizeof(printer_description
[0]));
1821 cupsArrayAdd(ra
, (void *)printer_description
[j
]);
1826 if (!strcmp(value
, "subscription-description") || !strcmp(value
, "all"))
1829 j
< (int)(sizeof(subscription_description
) /
1830 sizeof(subscription_description
[0]));
1832 cupsArrayAdd(ra
, (void *)subscription_description
[j
]);
1837 if (!strcmp(value
, "subscription-template") || !strcmp(value
, "all"))
1840 j
< (int)(sizeof(subscription_template
) /
1841 sizeof(subscription_template
[0]));
1843 cupsArrayAdd(ra
, (void *)subscription_template
[j
]);
1849 cupsArrayAdd(ra
, (void *)value
);
1857 * 'ippEnumString()' - Return a string corresponding to the enum value.
1860 const char * /* O - Enum string */
1861 ippEnumString(const char *attrname
, /* I - Attribute name */
1862 int enumvalue
) /* I - Enum value */
1864 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1868 * Check for standard enum values...
1871 if (!strcmp(attrname
, "document-state") &&
1873 enumvalue
< (3 + (int)(sizeof(ipp_document_states
) /
1874 sizeof(ipp_document_states
[0]))))
1875 return (ipp_document_states
[enumvalue
- 3]);
1876 else if (!strcmp(attrname
, "finishings") ||
1877 !strcmp(attrname
, "finishings-actual") ||
1878 !strcmp(attrname
, "finishings-default") ||
1879 !strcmp(attrname
, "finishings-ready") ||
1880 !strcmp(attrname
, "finishings-supported") ||
1881 !strcmp(attrname
, "job-finishings") ||
1882 !strcmp(attrname
, "job-finishings-default") ||
1883 !strcmp(attrname
, "job-finishings-supported"))
1885 if (enumvalue
>= 3 &&
1886 enumvalue
< (3 + (int)(sizeof(ipp_finishings
) /
1887 sizeof(ipp_finishings
[0]))))
1888 return (ipp_finishings
[enumvalue
- 3]);
1889 else if (enumvalue
>= 0x40000000 &&
1890 enumvalue
<= (0x40000000 + (int)(sizeof(ipp_finishings_vendor
) /
1891 sizeof(ipp_finishings_vendor
[0]))))
1892 return (ipp_finishings_vendor
[enumvalue
- 0x40000000]);
1894 else if ((!strcmp(attrname
, "job-collation-type") ||
1895 !strcmp(attrname
, "job-collation-type-actual")) &&
1897 enumvalue
< (3 + (int)(sizeof(ipp_job_collation_types
) /
1898 sizeof(ipp_job_collation_types
[0]))))
1899 return (ipp_job_collation_types
[enumvalue
- 3]);
1900 else if (!strcmp(attrname
, "job-state") &&
1901 enumvalue
>= IPP_JSTATE_PENDING
&& enumvalue
<= IPP_JSTATE_COMPLETED
)
1902 return (ipp_job_states
[enumvalue
- IPP_JSTATE_PENDING
]);
1903 else if (!strcmp(attrname
, "operations-supported"))
1904 return (ippOpString((ipp_op_t
)enumvalue
));
1905 else if ((!strcmp(attrname
, "orientation-requested") ||
1906 !strcmp(attrname
, "orientation-requested-actual") ||
1907 !strcmp(attrname
, "orientation-requested-default") ||
1908 !strcmp(attrname
, "orientation-requested-supported")) &&
1910 enumvalue
< (3 + (int)(sizeof(ipp_orientation_requesteds
) /
1911 sizeof(ipp_orientation_requesteds
[0]))))
1912 return (ipp_orientation_requesteds
[enumvalue
- 3]);
1913 else if ((!strcmp(attrname
, "print-quality") ||
1914 !strcmp(attrname
, "print-quality-actual") ||
1915 !strcmp(attrname
, "print-quality-default") ||
1916 !strcmp(attrname
, "print-quality-supported")) &&
1918 enumvalue
< (3 + (int)(sizeof(ipp_print_qualities
) /
1919 sizeof(ipp_print_qualities
[0]))))
1920 return (ipp_print_qualities
[enumvalue
- 3]);
1921 else if (!strcmp(attrname
, "printer-state") &&
1922 enumvalue
>= IPP_PSTATE_IDLE
&& enumvalue
<= IPP_PSTATE_STOPPED
)
1923 return (ipp_printer_states
[enumvalue
- IPP_PSTATE_IDLE
]);
1926 * Not a standard enum value, just return the decimal equivalent...
1929 snprintf(cg
->ipp_unknown
, sizeof(cg
->ipp_unknown
), "%d", enumvalue
);
1930 return (cg
->ipp_unknown
);
1935 * 'ippEnumValue()' - Return the value associated with a given enum string.
1938 int /* O - Enum value or -1 if unknown */
1939 ippEnumValue(const char *attrname
, /* I - Attribute name */
1940 const char *enumstring
) /* I - Enum string */
1942 int i
, /* Looping var */
1943 num_strings
; /* Number of strings to compare */
1944 const char * const *strings
; /* Strings to compare */
1948 * If the string is just a number, return it...
1951 if (isdigit(*enumstring
& 255))
1952 return ((int)strtol(enumstring
, NULL
, 0));
1955 * Otherwise look up the string...
1958 if (!strcmp(attrname
, "document-state"))
1960 num_strings
= (int)(sizeof(ipp_document_states
) / sizeof(ipp_document_states
[0]));
1961 strings
= ipp_document_states
;
1963 else if (!strcmp(attrname
, "finishings") ||
1964 !strcmp(attrname
, "finishings-actual") ||
1965 !strcmp(attrname
, "finishings-default") ||
1966 !strcmp(attrname
, "finishings-ready") ||
1967 !strcmp(attrname
, "finishings-supported"))
1970 i
< (int)(sizeof(ipp_finishings_vendor
) /
1971 sizeof(ipp_finishings_vendor
[0]));
1973 if (!strcmp(enumstring
, ipp_finishings_vendor
[i
]))
1974 return (i
+ 0x40000000);
1976 num_strings
= (int)(sizeof(ipp_finishings
) / sizeof(ipp_finishings
[0]));
1977 strings
= ipp_finishings
;
1979 else if (!strcmp(attrname
, "job-collation-type") ||
1980 !strcmp(attrname
, "job-collation-type-actual"))
1982 num_strings
= (int)(sizeof(ipp_job_collation_types
) /
1983 sizeof(ipp_job_collation_types
[0]));
1984 strings
= ipp_job_collation_types
;
1986 else if (!strcmp(attrname
, "job-state"))
1988 num_strings
= (int)(sizeof(ipp_job_states
) / sizeof(ipp_job_states
[0]));
1989 strings
= ipp_job_states
;
1991 else if (!strcmp(attrname
, "operations-supported"))
1992 return (ippOpValue(enumstring
));
1993 else if (!strcmp(attrname
, "orientation-requested") ||
1994 !strcmp(attrname
, "orientation-requested-actual") ||
1995 !strcmp(attrname
, "orientation-requested-default") ||
1996 !strcmp(attrname
, "orientation-requested-supported"))
1998 num_strings
= (int)(sizeof(ipp_orientation_requesteds
) /
1999 sizeof(ipp_orientation_requesteds
[0]));
2000 strings
= ipp_orientation_requesteds
;
2002 else if (!strcmp(attrname
, "print-quality") ||
2003 !strcmp(attrname
, "print-quality-actual") ||
2004 !strcmp(attrname
, "print-quality-default") ||
2005 !strcmp(attrname
, "print-quality-supported"))
2007 num_strings
= (int)(sizeof(ipp_print_qualities
) / sizeof(ipp_print_qualities
[0]));
2008 strings
= ipp_print_qualities
;
2010 else if (!strcmp(attrname
, "printer-state"))
2012 num_strings
= (int)(sizeof(ipp_printer_states
) / sizeof(ipp_printer_states
[0]));
2013 strings
= ipp_printer_states
;
2018 for (i
= 0; i
< num_strings
; i
++)
2019 if (!strcmp(enumstring
, strings
[i
]))
2027 * 'ippErrorString()' - Return a name for the given status code.
2030 const char * /* O - Text string */
2031 ippErrorString(ipp_status_t error
) /* I - Error status */
2033 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2037 * See if the error code is a known value...
2040 if (error
>= IPP_STATUS_OK
&& error
<= IPP_STATUS_OK_EVENTS_COMPLETE
)
2041 return (ipp_status_oks
[error
]);
2042 else if (error
== IPP_STATUS_REDIRECTION_OTHER_SITE
)
2043 return ("redirection-other-site");
2044 else if (error
== IPP_STATUS_CUPS_SEE_OTHER
)
2045 return ("cups-see-other");
2046 else if (error
>= IPP_STATUS_ERROR_BAD_REQUEST
&&
2047 error
<= IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED
)
2048 return (ipp_status_400s
[error
- IPP_STATUS_ERROR_BAD_REQUEST
]);
2049 else if (error
>= 0x480 &&
2050 error
<= IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED
)
2051 return (ipp_status_480s
[error
- 0x0480]);
2052 else if (error
>= IPP_STATUS_ERROR_INTERNAL
&&
2053 error
<= IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS
)
2054 return (ipp_status_500s
[error
- IPP_STATUS_ERROR_INTERNAL
]);
2055 else if (error
>= IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
&&
2056 error
<= IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED
)
2057 return (ipp_status_1000s
[error
-
2058 IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
]);
2061 * No, build an "0xxxxx" error string...
2064 sprintf(cg
->ipp_unknown
, "0x%04x", error
);
2066 return (cg
->ipp_unknown
);
2071 * 'ippErrorValue()' - Return a status code for the given name.
2073 * @since CUPS 1.2/macOS 10.5@
2076 ipp_status_t
/* O - IPP status code */
2077 ippErrorValue(const char *name
) /* I - Name */
2079 size_t i
; /* Looping var */
2082 for (i
= 0; i
< (sizeof(ipp_status_oks
) / sizeof(ipp_status_oks
[0])); i
++)
2083 if (!_cups_strcasecmp(name
, ipp_status_oks
[i
]))
2084 return ((ipp_status_t
)i
);
2086 if (!_cups_strcasecmp(name
, "redirection-other-site"))
2087 return (IPP_STATUS_REDIRECTION_OTHER_SITE
);
2089 if (!_cups_strcasecmp(name
, "cups-see-other"))
2090 return (IPP_STATUS_CUPS_SEE_OTHER
);
2092 for (i
= 0; i
< (sizeof(ipp_status_400s
) / sizeof(ipp_status_400s
[0])); i
++)
2093 if (!_cups_strcasecmp(name
, ipp_status_400s
[i
]))
2094 return ((ipp_status_t
)(i
+ 0x400));
2096 for (i
= 0; i
< (sizeof(ipp_status_480s
) / sizeof(ipp_status_480s
[0])); i
++)
2097 if (!_cups_strcasecmp(name
, ipp_status_480s
[i
]))
2098 return ((ipp_status_t
)(i
+ 0x480));
2100 for (i
= 0; i
< (sizeof(ipp_status_500s
) / sizeof(ipp_status_500s
[0])); i
++)
2101 if (!_cups_strcasecmp(name
, ipp_status_500s
[i
]))
2102 return ((ipp_status_t
)(i
+ 0x500));
2104 for (i
= 0; i
< (sizeof(ipp_status_1000s
) / sizeof(ipp_status_1000s
[0])); i
++)
2105 if (!_cups_strcasecmp(name
, ipp_status_1000s
[i
]))
2106 return ((ipp_status_t
)(i
+ 0x1000));
2108 return ((ipp_status_t
)-1);
2113 * 'ippOpString()' - Return a name for the given operation id.
2115 * @since CUPS 1.2/macOS 10.5@
2118 const char * /* O - Name */
2119 ippOpString(ipp_op_t op
) /* I - Operation ID */
2121 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2125 * See if the operation ID is a known value...
2128 if (op
>= IPP_OP_PRINT_JOB
&& op
< (ipp_op_t
)(sizeof(ipp_std_ops
) / sizeof(ipp_std_ops
[0])))
2129 return (ipp_std_ops
[op
]);
2130 else if (op
== IPP_OP_PRIVATE
)
2131 return ("windows-ext");
2132 else if (op
>= IPP_OP_CUPS_GET_DEFAULT
&& op
<= IPP_OP_CUPS_GET_PPD
)
2133 return (ipp_cups_ops
[op
- IPP_OP_CUPS_GET_DEFAULT
]);
2134 else if (op
>= IPP_OP_CUPS_GET_DOCUMENT
&& op
<= IPP_OP_CUPS_CREATE_LOCAL_PRINTER
)
2135 return (ipp_cups_ops2
[op
- IPP_OP_CUPS_GET_DOCUMENT
]);
2138 * No, build an "0xxxxx" operation string...
2141 sprintf(cg
->ipp_unknown
, "0x%04x", op
);
2143 return (cg
->ipp_unknown
);
2148 * 'ippOpValue()' - Return an operation id for the given name.
2150 * @since CUPS 1.2/macOS 10.5@
2153 ipp_op_t
/* O - Operation ID */
2154 ippOpValue(const char *name
) /* I - Textual name */
2156 size_t i
; /* Looping var */
2159 if (!strncmp(name
, "0x", 2))
2160 return ((ipp_op_t
)strtol(name
+ 2, NULL
, 16));
2162 for (i
= 0; i
< (sizeof(ipp_std_ops
) / sizeof(ipp_std_ops
[0])); i
++)
2163 if (!_cups_strcasecmp(name
, ipp_std_ops
[i
]))
2164 return ((ipp_op_t
)i
);
2166 if (!_cups_strcasecmp(name
, "windows-ext"))
2167 return (IPP_OP_PRIVATE
);
2169 for (i
= 0; i
< (sizeof(ipp_cups_ops
) / sizeof(ipp_cups_ops
[0])); i
++)
2170 if (!_cups_strcasecmp(name
, ipp_cups_ops
[i
]))
2171 return ((ipp_op_t
)(i
+ 0x4001));
2173 for (i
= 0; i
< (sizeof(ipp_cups_ops2
) / sizeof(ipp_cups_ops2
[0])); i
++)
2174 if (!_cups_strcasecmp(name
, ipp_cups_ops2
[i
]))
2175 return ((ipp_op_t
)(i
+ 0x4027));
2177 if (!_cups_strcasecmp(name
, "Create-Job-Subscription"))
2178 return (IPP_OP_CREATE_JOB_SUBSCRIPTIONS
);
2180 if (!_cups_strcasecmp(name
, "Create-Printer-Subscription"))
2181 return (IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS
);
2183 if (!_cups_strcasecmp(name
, "CUPS-Add-Class"))
2184 return (IPP_OP_CUPS_ADD_MODIFY_CLASS
);
2186 if (!_cups_strcasecmp(name
, "CUPS-Add-Printer"))
2187 return (IPP_OP_CUPS_ADD_MODIFY_PRINTER
);
2189 return (IPP_OP_CUPS_INVALID
);
2194 * 'ippPort()' - Return the default IPP port number.
2197 int /* O - Port number */
2200 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2203 DEBUG_puts("ippPort()");
2208 DEBUG_printf(("1ippPort: Returning %d...", cg
->ipp_port
));
2210 return (cg
->ipp_port
);
2215 * 'ippSetPort()' - Set the default port number.
2219 ippSetPort(int p
) /* I - Port number to use */
2221 DEBUG_printf(("ippSetPort(p=%d)", p
));
2223 _cupsGlobals()->ipp_port
= p
;
2228 * 'ippStateString()' - Return the name corresponding to a state value.
2230 * @since CUPS 2.0/OS 10.10@
2233 const char * /* O - State name */
2234 ippStateString(ipp_state_t state
) /* I - State value */
2236 if (state
>= IPP_STATE_ERROR
&& state
<= IPP_STATE_DATA
)
2237 return (ipp_states
[state
- IPP_STATE_ERROR
]);
2244 * 'ippTagString()' - Return the tag name corresponding to a tag value.
2246 * The returned names are defined in RFC 2911 and 3382.
2248 * @since CUPS 1.4/macOS 10.6@
2251 const char * /* O - Tag name */
2252 ippTagString(ipp_tag_t tag
) /* I - Tag value */
2254 tag
&= IPP_TAG_CUPS_MASK
;
2256 if (tag
< (ipp_tag_t
)(sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])))
2257 return (ipp_tag_names
[tag
]);
2264 * 'ippTagValue()' - Return the tag value corresponding to a tag name.
2266 * The tag names are defined in RFC 2911 and 3382.
2268 * @since CUPS 1.4/macOS 10.6@
2271 ipp_tag_t
/* O - Tag value */
2272 ippTagValue(const char *name
) /* I - Tag name */
2274 size_t i
; /* Looping var */
2277 for (i
= 0; i
< (sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])); i
++)
2278 if (!_cups_strcasecmp(name
, ipp_tag_names
[i
]))
2279 return ((ipp_tag_t
)i
);
2281 if (!_cups_strcasecmp(name
, "operation"))
2282 return (IPP_TAG_OPERATION
);
2283 else if (!_cups_strcasecmp(name
, "job"))
2284 return (IPP_TAG_JOB
);
2285 else if (!_cups_strcasecmp(name
, "printer"))
2286 return (IPP_TAG_PRINTER
);
2287 else if (!_cups_strcasecmp(name
, "unsupported"))
2288 return (IPP_TAG_UNSUPPORTED_GROUP
);
2289 else if (!_cups_strcasecmp(name
, "subscription"))
2290 return (IPP_TAG_SUBSCRIPTION
);
2291 else if (!_cups_strcasecmp(name
, "event"))
2292 return (IPP_TAG_EVENT_NOTIFICATION
);
2293 else if (!_cups_strcasecmp(name
, "language"))
2294 return (IPP_TAG_LANGUAGE
);
2295 else if (!_cups_strcasecmp(name
, "mimetype"))
2296 return (IPP_TAG_MIMETYPE
);
2297 else if (!_cups_strcasecmp(name
, "name"))
2298 return (IPP_TAG_NAME
);
2299 else if (!_cups_strcasecmp(name
, "text"))
2300 return (IPP_TAG_TEXT
);
2301 else if (!_cups_strcasecmp(name
, "begCollection"))
2302 return (IPP_TAG_BEGIN_COLLECTION
);
2304 return (IPP_TAG_ZERO
);
2309 * 'ipp_col_string()' - Convert a collection to a string.
2312 static size_t /* O - Number of bytes */
2313 ipp_col_string(ipp_t
*col
, /* I - Collection attribute */
2314 char *buffer
, /* I - Buffer or NULL */
2315 size_t bufsize
) /* I - Size of buffer */
2317 char *bufptr
, /* Position in buffer */
2318 *bufend
, /* End of buffer */
2319 prefix
= '{', /* Prefix character */
2320 temp
[256]; /* Temporary string */
2321 ipp_attribute_t
*attr
; /* Current member attribute */
2333 bufend
= buffer
+ bufsize
- 1;
2335 for (attr
= col
->attrs
; attr
; attr
= attr
->next
)
2340 if (buffer
&& bufptr
< bufend
)
2345 if (buffer
&& bufptr
< bufend
)
2346 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%s=", attr
->name
);
2348 bufptr
+= strlen(attr
->name
) + 1;
2350 if (buffer
&& bufptr
< bufend
)
2351 bufptr
+= ippAttributeString(attr
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
2353 bufptr
+= ippAttributeString(attr
, temp
, sizeof(temp
));
2358 if (buffer
&& bufptr
< bufend
)
2363 if (buffer
&& bufptr
< bufend
)
2367 return ((size_t)(bufptr
- buffer
));