4 * Internet Printing Protocol support functions for CUPS.
6 * Copyright 2007-2014 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * Include necessary headers...
22 #include "cups-private.h"
29 static const char * const ipp_states
[] =
34 "IPP_STATE_ATTRIBUTE",
37 static const char * const ipp_status_oks
[] = /* "OK" status codes */
38 { /* (name) = abandoned standard value */
40 "successful-ok-ignored-or-substituted-attributes",
41 "successful-ok-conflicting-attributes",
42 "successful-ok-ignored-subscriptions",
43 "(successful-ok-ignored-notifications)",
44 "successful-ok-too-many-events",
45 "(successful-ok-but-cancel-subscription)",
46 "successful-ok-events-complete"
48 * const ipp_status_400s
[] = /* Client errors */
49 { /* (name) = abandoned standard value */
50 "client-error-bad-request",
51 "client-error-forbidden",
52 "client-error-not-authenticated",
53 "client-error-not-authorized",
54 "client-error-not-possible",
55 "client-error-timeout",
56 "client-error-not-found",
58 "client-error-request-entity-too-large",
59 "client-error-request-value-too-long",
60 "client-error-document-format-not-supported",
61 "client-error-attributes-or-values-not-supported",
62 "client-error-uri-scheme-not-supported",
63 "client-error-charset-not-supported",
64 "client-error-conflicting-attributes",
65 "client-error-compression-not-supported",
66 "client-error-compression-error",
67 "client-error-document-format-error",
68 "client-error-document-access-error",
69 "client-error-attributes-not-settable",
70 "client-error-ignored-all-subscriptions",
71 "client-error-too-many-subscriptions",
72 "(client-error-ignored-all-notifications)",
73 "(client-error-client-print-support-file-not-found)",
74 "client-error-document-password-error",
75 "client-error-document-permission-error",
76 "client-error-document-security-error",
77 "client-error-document-unprintable-error",
78 "client-error-account-info-needed",
79 "client-error-account-closed",
80 "client-error-account-limit-reached",
81 "client-error-account-authorization-failed",
82 "client-error-not-fetchable"
84 * const ipp_status_480s
[] = /* Vendor client errors */
103 /* 0x0490 - 0x049F */
116 "cups-error-account-info-needed",
117 "cups-error-account-closed",
118 "cups-error-account-limit-reached",
119 "cups-error-account-authorization-failed"
121 * const ipp_status_500s
[] = /* Server errors */
123 "server-error-internal-error",
124 "server-error-operation-not-supported",
125 "server-error-service-unavailable",
126 "server-error-version-not-supported",
127 "server-error-device-error",
128 "server-error-temporary-error",
129 "server-error-not-accepting-jobs",
131 "server-error-job-canceled",
132 "server-error-multiple-document-jobs-not-supported",
133 "server-error-printer-is-deactivated",
134 "server-error-too-many-jobs",
135 "server-error-too-many-documents"
137 * const ipp_status_1000s
[] = /* CUPS internal */
139 "cups-authentication-canceled",
141 "cups-upgrade-required"
143 static const char * const ipp_std_ops
[] =
145 /* 0x0000 - 0x000f */
155 "Get-Job-Attributes",
157 "Get-Printer-Attributes",
163 /* 0x0010 - 0x001f */
167 "Set-Printer-Attributes",
168 "Set-Job-Attributes",
169 "Get-Printer-Supported-Values",
170 "Create-Printer-Subscriptions",
171 "Create-Job-Subscriptions",
172 "Get-Subscription-Attributes",
174 "Renew-Subscription",
175 "Cancel-Subscription",
177 "(Send-Notifications)",
178 "(Get-Resource-Attributes)",
179 "(Get-Resource-Data)",
181 /* 0x0020 - 0x002f */
183 "(Get-Printer-Support-Files)",
186 "Pause-Printer-After-Current-Job",
188 "Release-Held-New-Jobs",
189 "Deactivate-Printer",
195 "Cancel-Current-Job",
196 "Suspend-Current-Job",
199 /* 0x0030 - 0x003f */
201 "Schedule-Job-After",
204 "Get-Document-Attributes",
207 "Set-Document-Attributes",
214 "Send-Hardcopy-Document",
215 "Acknowledge-Document",
217 /* 0x0040 - 0x004a */
218 "Acknowledge-Identify-Printer",
222 "Get-Output-Device-Attributes",
223 "Update-Active-Jobs",
224 "Deregister-Output-Device",
225 "Update-Document-Status",
227 "Update-Output-Device-Attributes",
228 "Get-Next-Document-Data"
230 * const ipp_cups_ops
[] =
234 "CUPS-Add-Modify-Printer",
235 "CUPS-Delete-Printer",
237 "CUPS-Add-Modify-Class",
245 "CUPS-Authenticate-Job",
248 * const ipp_cups_ops2
[] =
252 * const ipp_tag_names
[] =
253 { /* Value/group tag names */
255 "operation-attributes-tag",
257 "job-attributes-tag", /* 0x02 */
258 "end-of-attributes-tag",
260 "printer-attributes-tag",
262 "unsupported-attributes-tag",
264 "subscription-attributes-tag",
266 "event-notification-attributes-tag",
268 "(resource-attributes-tag)",
270 "document-attributes-tag",
278 "unsupported", /* 0x10 */
279 "default", /* 0x11 */
280 "unknown", /* 0x12 */
281 "no-value", /* 0x13 */
283 "not-settable", /* 0x15 */
284 "delete-attribute", /* 0x16 */
285 "admin-define", /* 0x17 */
295 "integer", /* 0x21 */
296 "boolean", /* 0x22 */
310 "octetString", /* 0x30 */
311 "dateTime", /* 0x31 */
312 "resolution", /* 0x32 */
313 "rangeOfInteger", /* 0x33 */
314 "collection", /* 0x34 */
315 "textWithLanguage", /* 0x35 */
316 "nameWithLanguage", /* 0x36 */
317 "endCollection", /* 0x37 */
327 "textWithoutLanguage",/* 0x41 */
328 "nameWithoutLanguage",/* 0x42 */
330 "keyword", /* 0x44 */
332 "uriScheme", /* 0x46 */
333 "charset", /* 0x47 */
334 "naturalLanguage", /* 0x48 */
335 "mimeMediaType", /* 0x49 */
336 "memberAttrName" /* 0x4a */
338 static const char * const ipp_document_states
[] =
339 { /* document-state-enums */
343 "processing-stopped", /* IPPSIX */
348 * const ipp_finishings
[] =
349 { /* finishings enums */
362 "coat", /* Finishings 2.0 */
363 "laminate", /* Finishings 2.0 */
368 "staple-bottom-left",
370 "staple-bottom-right",
374 "edge-stitch-bottom",
378 "staple-dual-bottom",
379 "staple-triple-left", /* Finishings 2.0 */
380 "staple-triple-top", /* Finishings 2.0 */
381 "staple-triple-right",/* Finishings 2.0 */
382 "staple-triple-bottom",/* Finishings 2.0 */
408 "trim-after-documents",
417 "punch-top-left", /* Finishings 2.0 */
418 "punch-bottom-left", /* Finishings 2.0 */
419 "punch-top-right", /* Finishings 2.0 */
420 "punch-bottom-right", /* Finishings 2.0 */
421 "punch-dual-left", /* Finishings 2.0 */
422 "punch-dual-top", /* Finishings 2.0 */
423 "punch-dual-right", /* Finishings 2.0 */
424 "punch-dual-bottom", /* Finishings 2.0 */
425 "punch-triple-left", /* Finishings 2.0 */
426 "punch-triple-top", /* Finishings 2.0 */
427 "punch-triple-right", /* Finishings 2.0 */
428 "punch-triple-bottom",/* Finishings 2.0 */
429 "punch-quad-left", /* Finishings 2.0 */
430 "punch-quad-top", /* Finishings 2.0 */
431 "punch-quad-right", /* Finishings 2.0 */
432 "punch-quad-bottom", /* Finishings 2.0 */
437 "fold-accordian", /* Finishings 2.0 */
438 "fold-double-gate", /* Finishings 2.0 */
439 "fold-gate", /* Finishings 2.0 */
440 "fold-half", /* Finishings 2.0 */
441 "fold-half-z", /* Finishings 2.0 */
442 "fold-left-gate", /* Finishings 2.0 */
443 "fold-letter", /* Finishings 2.0 */
444 "fold-parallel", /* Finishings 2.0 */
445 "fold-poster", /* Finishings 2.0 */
446 "fold-right-gate", /* Finishings 2.0 */
447 "fold-z" /* Finishings 2.0 */
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/OS X 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/OS X 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",
902 "media-input-tray-check-actual",
904 "media-sheets-completed",
907 "orientation-requested-actual",
909 "output-device-assigned",
911 "page-delivery-actual",
912 "page-order-received-actual",
913 "page-ranges-actual",
916 "pages-completed-current-copy",
917 "presentation-direction-number-up-actual",
918 "print-color-mode-actual",
919 "print-content-optimize-actual",
920 "print-quality-actual",
921 "print-rendering-intent-actual",
922 "print-scaling-actual", /* IPP Paid Printing */
923 "printer-resolution-actual",
925 "separator-sheets-actual",
926 "sheet-completed-copy-number",
930 "time-at-processing",
931 "x-image-position-actual",
932 "x-image-shift-actual",
933 "x-side1-image-shift-actual",
934 "x-side2-image-shift-actual",
935 "y-image-position-actual",
936 "y-image-shift-actual",
937 "y-side1-image-shift-actual",
938 "y-side2-image-shift-actual"
940 static const char * const document_template
[] =
941 { /* document-template group */
946 "cover-back-default",
947 "cover-back-supported",
949 "cover-front-default",
950 "cover-front-supported",
952 "feed-orientation-default",
953 "feed-orientation-supported",
956 "finishings-col-default",
957 "finishings-col-supported",
958 "finishings-default",
959 "finishings-supported",
960 "font-name-requested",
961 "font-name-requested-default",
962 "font-name-requested-supported",
963 "font-size-requested",
964 "font-size-requested-default",
965 "font-size-requested-supported",
967 "force-front-side-default",
968 "force-front-side-supported",
969 "imposition-template",
970 "imposition-template-default",
971 "imposition-template-supported",
972 "insert-after-page-number-supported",
973 "insert-count-supported",
975 "insert-sheet-default",
976 "insert-sheet-supported",
977 "max-stitching-locations-supported",
979 "media-back-coating-supported",
980 "media-bottom-margin-supported",
983 "media-col-supported",
984 "media-color-supported",
986 "media-front-coating-supported",
987 "media-grain-supported",
988 "media-hole-count-supported",
989 "media-info-supported",
990 "media-input-tray-check",
991 "media-input-tray-check-default",
992 "media-input-tray-check-supported",
993 "media-key-supported",
994 "media-left-margin-supported",
995 "media-order-count-supported",
996 "media-pre-printed-supported",
997 "media-recycled-supported",
998 "media-right-margin-supported",
999 "media-size-supported",
1000 "media-source-supported",
1002 "media-thickness-supported",
1003 "media-top-margin-supported",
1004 "media-type-supported",
1005 "media-weight-metric-supported",
1006 "multiple-document-handling",
1007 "multiple-document-handling-default",
1008 "multiple-document-handling-supported",
1010 "number-up-default",
1011 "number-up-supported",
1012 "orientation-requested",
1013 "orientation-requested-default",
1014 "orientation-requested-supported",
1015 "output-mode", /* CUPS extension */
1016 "output-mode-default", /* CUPS extension */
1017 "output-mode-supported", /* CUPS extension */
1019 "overrides-supported",
1021 "page-delivery-default",
1022 "page-delivery-supported",
1023 "page-order-received",
1024 "page-order-received-default",
1025 "page-order-received-supported",
1027 "page-ranges-supported",
1029 "pages-per-subset-supported",
1031 "pdl-init-file-default",
1032 "pdl-init-file-entry-supported",
1033 "pdl-init-file-location-supported",
1034 "pdl-init-file-name-subdirectory-supported",
1035 "pdl-init-file-name-supported",
1036 "pdl-init-file-supported",
1037 "presentation-direction-number-up",
1038 "presentation-direction-number-up-default",
1039 "presentation-direction-number-up-supported",
1041 "print-color-mode-default",
1042 "print-color-mode-supported",
1043 "print-content-optimize",
1044 "print-content-optimize-default",
1045 "print-content-optimize-supported",
1047 "print-quality-default",
1048 "print-quality-supported",
1049 "print-rendering-intent",
1050 "print-rendering-intent-default",
1051 "print-rendering-intent-supported",
1052 "print-scaling", /* IPP Paid Printing */
1053 "print-scaling-default", /* IPP Paid Printing */
1054 "print-scaling-supported", /* IPP Paid Printing */
1055 "printer-resolution",
1056 "printer-resolution-default",
1057 "printer-resolution-supported",
1059 "separator-sheets-default",
1060 "separator-sheets-supported",
1062 "sheet-collate-default",
1063 "sheet-collate-supported",
1067 "stitching-locations-supported",
1068 "stitching-offset-supported",
1070 "x-image-position-default",
1071 "x-image-position-supported",
1073 "x-image-shift-default",
1074 "x-image-shift-supported",
1075 "x-side1-image-shift",
1076 "x-side1-image-shift-default",
1077 "x-side1-image-shift-supported",
1078 "x-side2-image-shift",
1079 "x-side2-image-shift-default",
1080 "x-side2-image-shift-supported",
1082 "y-image-position-default",
1083 "y-image-position-supported",
1085 "y-image-shift-default",
1086 "y-image-shift-supported",
1087 "y-side1-image-shift",
1088 "y-side1-image-shift-default",
1089 "y-side1-image-shift-supported",
1090 "y-side2-image-shift",
1091 "y-side2-image-shift-default",
1092 "y-side2-image-shift-supported"
1094 static const char * const job_description
[] =
1095 { /* job-description group */
1096 "compression-supplied",
1098 "cover-back-actual",
1099 "cover-front-actual",
1100 "current-page-order",
1101 "date-time-at-completed",
1102 "date-time-at-creation",
1103 "date-time-at-processing",
1104 "destination-statuses",
1105 "document-charset-supplied",
1106 "document-digital-signature-supplied",
1107 "document-format-details-supplied",
1108 "document-format-supplied",
1109 "document-message-supplied",
1110 "document-metadata",
1111 "document-name-supplied",
1112 "document-natural-language-supplied",
1113 "document-overrides-actual",
1115 "finishings-actual",
1116 "finishings-col-actual",
1117 "force-front-side-actual",
1118 "imposition-template-actual",
1119 "impressions-completed-current-copy",
1120 "insert-sheet-actual",
1121 "job-account-id-actual",
1122 "job-accounting-sheets-actual",
1123 "job-accounting-user-id-actual",
1124 "job-attribute-fidelity",
1125 "job-charge-info", /* CUPS extension */
1126 "job-collation-type",
1127 "job-collation-type-actual",
1128 "job-copies-actual",
1129 "job-cover-back-actual",
1130 "job-cover-front-actual",
1131 "job-detailed-status-message",
1132 "job-document-access-errors",
1133 "job-error-sheet-actual",
1134 "job-finishings-actual",
1135 "job-finishings-col-actual",
1136 "job-hold-until-actual",
1139 "job-impressions-completed",
1141 "job-k-octets-processed",
1142 "job-mandatory-attributes",
1143 "job-media-progress", /* CUPS extension */
1145 "job-media-sheets-completed",
1146 "job-message-from-operator",
1149 "job-originating-host-name", /* CUPS extension */
1150 "job-originating-user-name",
1151 "job-originating-user-uri",
1153 "job-pages-completed",
1154 "job-pages-completed-current-copy",
1155 "job-printer-state-message", /* CUPS extension */
1156 "job-printer-state-reasons", /* CUPS extension */
1157 "job-printer-up-time",
1159 "job-priority-actual",
1160 "job-save-printer-make-and-model",
1161 "job-sheet-message-actual",
1162 "job-sheets-actual",
1163 "job-sheets-col-actual",
1165 "job-state-message",
1166 "job-state-reasons",
1171 "media-check-input-tray-actual",
1172 "multiple-document-handling-actual",
1173 "number-of-documents",
1174 "number-of-intervening-jobs",
1176 "orientation-requested-actual",
1177 "original-requesting-user-name",
1178 "output-bin-actual",
1179 "output-device-assigned",
1181 "page-delivery-actual",
1182 "page-order-received-actual",
1183 "page-ranges-actual",
1184 "presentation-direction-number-up-actual",
1185 "print-color-mode-actual",
1186 "print-content-optimize-actual",
1187 "print-quality-actual",
1188 "print-rendering-intent-actual",
1189 "print-scaling-actual", /* IPP Paid Printing */
1190 "printer-resolution-actual",
1191 "separator-sheets-actual",
1192 "sheet-collate-actual",
1193 "sheet-completed-copy-number",
1194 "sheet-completed-document-number",
1196 "time-at-completed",
1198 "time-at-processing",
1200 "x-image-position-actual",
1201 "x-image-shift-actual",
1202 "x-side1-image-shift-actual",
1203 "x-side2-image-shift-actual",
1204 "y-image-position-actual",
1205 "y-image-shift-actual",
1206 "y-side1-image-shift-actual",
1207 "y-side2-image-shift-actual"
1209 static const char * const job_template
[] =
1210 { /* job-template group */
1211 "confirmation-sheet-print", /* IPP FaxOut */
1212 "confirmation-sheet-print-default",
1217 "cover-back-default",
1218 "cover-back-supported",
1220 "cover-front-default",
1221 "cover-front-supported",
1222 "cover-sheet-info", /* IPP FaxOut */
1223 "cover-sheet-info-default",
1224 "cover-sheet-info-supported",
1225 "destination-uri-schemes-supported",/* IPP FaxOut */
1226 "destination-uris", /* IPP FaxOut */
1227 "destination-uris-supported",
1229 "feed-orientation-default",
1230 "feed-orientation-supported",
1233 "finishings-col-default",
1234 "finishings-col-supported",
1235 "finishings-default",
1236 "finishings-supported",
1237 "font-name-requested",
1238 "font-name-requested-default",
1239 "font-name-requested-supported",
1240 "font-size-requested",
1241 "font-size-requested-default",
1242 "font-size-requested-supported",
1244 "force-front-side-default",
1245 "force-front-side-supported",
1246 "imposition-template",
1247 "imposition-template-default",
1248 "imposition-template-supported",
1249 "insert-after-page-number-supported",
1250 "insert-count-supported",
1252 "insert-sheet-default",
1253 "insert-sheet-supported",
1255 "job-account-id-default",
1256 "job-account-id-supported",
1257 "job-accounting-sheets"
1258 "job-accounting-sheets-default"
1259 "job-accounting-sheets-supported"
1260 "job-accounting-user-id",
1261 "job-accounting-user-id-default",
1262 "job-accounting-user-id-supported",
1264 "job-copies-default",
1265 "job-copies-supported",
1267 "job-cover-back-default",
1268 "job-cover-back-supported",
1270 "job-cover-front-default",
1271 "job-cover-front-supported",
1272 "job-delay-output-until",
1273 "job-delay-output-until-default",
1274 "job-delay-output-until-supported",
1275 "job-delay-output-until-time",
1276 "job-delay-output-until-time-default",
1277 "job-delay-output-until-time-supported",
1279 "job-error-action-default",
1280 "job-error-action-supported",
1282 "job-error-sheet-default",
1283 "job-error-sheet-supported",
1285 "job-finishings-col",
1286 "job-finishings-col-default",
1287 "job-finishings-col-supported",
1288 "job-finishings-default",
1289 "job-finishings-supported",
1291 "job-hold-until-default",
1292 "job-hold-until-supported",
1293 "job-hold-until-time",
1294 "job-hold-until-time-default",
1295 "job-hold-until-time-supported",
1296 "job-message-to-operator",
1297 "job-message-to-operator-default",
1298 "job-message-to-operator-supported",
1300 "job-phone-number-default",
1301 "job-phone-number-supported",
1303 "job-priority-default",
1304 "job-priority-supported",
1305 "job-recipient-name",
1306 "job-recipient-name-default",
1307 "job-recipient-name-supported",
1308 "job-save-disposition",
1309 "job-save-disposition-default",
1310 "job-save-disposition-supported",
1313 "job-sheets-col-default",
1314 "job-sheets-col-supported",
1315 "job-sheets-default",
1316 "job-sheets-supported",
1317 "logo-uri-schemes-supported",
1318 "max-save-info-supported",
1319 "max-stitching-locations-supported",
1321 "media-back-coating-supported",
1322 "media-bottom-margin-supported",
1324 "media-col-default",
1325 "media-col-supported",
1326 "media-color-supported",
1328 "media-front-coating-supported",
1329 "media-grain-supported",
1330 "media-hole-count-supported",
1331 "media-info-supported",
1332 "media-input-tray-check",
1333 "media-input-tray-check-default",
1334 "media-input-tray-check-supported",
1335 "media-key-supported",
1336 "media-left-margin-supported",
1337 "media-order-count-supported",
1338 "media-pre-printed-supported",
1339 "media-recycled-supported",
1340 "media-right-margin-supported",
1341 "media-size-supported",
1342 "media-source-supported",
1344 "media-thickness-supported",
1345 "media-top-margin-supported",
1346 "media-type-supported",
1347 "media-weight-metric-supported",
1348 "multiple-document-handling",
1349 "multiple-document-handling-default",
1350 "multiple-document-handling-supported",
1351 "number-of-retries", /* IPP FaxOut */
1352 "number-of-retries-default",
1353 "number-of-retries-supported",
1355 "number-up-default",
1356 "number-up-supported",
1357 "orientation-requested",
1358 "orientation-requested-default",
1359 "orientation-requested-supported",
1361 "output-bin-default",
1362 "output-bin-supported",
1364 "output-device-default",
1365 "output-device-supported",
1366 "output-mode", /* CUPS extension */
1367 "output-mode-default", /* CUPS extension */
1368 "output-mode-supported", /* CUPS extension */
1370 "overrides-supported",
1372 "page-delivery-default",
1373 "page-delivery-supported",
1374 "page-order-received",
1375 "page-order-received-default",
1376 "page-order-received-supported",
1378 "page-ranges-supported",
1380 "pages-per-subset-supported",
1382 "pdl-init-file-default",
1383 "pdl-init-file-entry-supported",
1384 "pdl-init-file-location-supported",
1385 "pdl-init-file-name-subdirectory-supported",
1386 "pdl-init-file-name-supported",
1387 "pdl-init-file-supported",
1388 "presentation-direction-number-up",
1389 "presentation-direction-number-up-default",
1390 "presentation-direction-number-up-supported",
1392 "print-color-mode-default",
1393 "print-color-mode-supported",
1394 "print-content-optimize",
1395 "print-content-optimize-default",
1396 "print-content-optimize-supported",
1398 "print-quality-default",
1399 "print-quality-supported",
1400 "print-rendering-intent",
1401 "print-rendering-intent-default",
1402 "print-rendering-intent-supported",
1403 "print-scaling", /* IPP Paid Printing */
1404 "print-scaling-default", /* IPP Paid Printing */
1405 "print-scaling-supported", /* IPP Paid Printing */
1406 "printer-resolution",
1407 "printer-resolution-default",
1408 "printer-resolution-supported",
1410 "proof-print-default",
1411 "proof-print-supported",
1412 "retry-interval", /* IPP FaxOut */
1413 "retry-interval-default",
1414 "retry-interval-supported",
1415 "retry-timeout", /* IPP FaxOut */
1416 "retry-timeout-default",
1417 "retry-timeout-supported",
1418 "save-disposition-supported",
1419 "save-document-format-default",
1420 "save-document-format-supported",
1421 "save-location-default",
1422 "save-location-supported",
1423 "save-name-subdirectory-supported",
1424 "save-name-supported",
1426 "separator-sheets-default",
1427 "separator-sheets-supported",
1429 "sheet-collate-default",
1430 "sheet-collate-supported",
1434 "stitching-locations-supported",
1435 "stitching-offset-supported",
1437 "x-image-position-default",
1438 "x-image-position-supported",
1440 "x-image-shift-default",
1441 "x-image-shift-supported",
1442 "x-side1-image-shift",
1443 "x-side1-image-shift-default",
1444 "x-side1-image-shift-supported",
1445 "x-side2-image-shift",
1446 "x-side2-image-shift-default",
1447 "x-side2-image-shift-supported",
1449 "y-image-position-default",
1450 "y-image-position-supported",
1452 "y-image-shift-default",
1453 "y-image-shift-supported",
1454 "y-side1-image-shift",
1455 "y-side1-image-shift-default",
1456 "y-side1-image-shift-supported",
1457 "y-side2-image-shift",
1458 "y-side2-image-shift-default",
1459 "y-side2-image-shift-supported"
1461 static const char * const printer_description
[] =
1462 { /* printer-description group */
1463 "auth-info-required", /* CUPS extension */
1464 "charset-configured",
1465 "charset-supported",
1467 "compression-supported",
1468 "device-service-count",
1469 "device-uri", /* CUPS extension */
1471 "document-charset-default",
1472 "document-charset-supported",
1473 "document-creation-attributes-supported",
1474 "document-digital-signature-default",
1475 "document-digital-signature-supported",
1476 "document-format-default",
1477 "document-format-details-default",
1478 "document-format-details-supported",
1479 "document-format-supported",
1480 "document-format-varying-attributes",
1481 "document-format-version-default",
1482 "document-format-version-supported",
1483 "document-natural-language-default",
1484 "document-natural-language-supported",
1485 "document-password-supported",
1486 "generated-natural-language-supported",
1487 "identify-actions-default",
1488 "identify-actions-supported",
1489 "input-source-supported",
1490 "ipp-features-supported",
1491 "ipp-versions-supported",
1492 "ippget-event-life",
1493 "job-authorization-uri-supported", /* CUPS extension */
1494 "job-constraints-supported",
1495 "job-creation-attributes-supported",
1496 "job-finishings-col-ready",
1497 "job-finishings-ready",
1498 "job-ids-supported",
1499 "job-impressions-supported",
1500 "job-k-limit", /* CUPS extension */
1501 "job-k-octets-supported",
1502 "job-media-sheets-supported",
1503 "job-page-limit", /* CUPS extension */
1504 "job-password-encryption-supported",
1505 "job-password-supported",
1506 "job-quota-period", /* CUPS extension */
1507 "job-resolvers-supported",
1508 "job-settable-attributes-supported",
1509 "job-spooling-supported",
1510 "jpeg-k-octets-supported", /* CUPS extension */
1511 "jpeg-x-dimension-supported", /* CUPS extension */
1512 "jpeg-y-dimension-supported", /* CUPS extension */
1513 "landscape-orientation-requested-preferred",
1514 /* CUPS extension */
1515 "marker-change-time", /* CUPS extension */
1516 "marker-colors", /* CUPS extension */
1517 "marker-high-levels", /* CUPS extension */
1518 "marker-levels", /* CUPS extension */
1519 "marker-low-levels", /* CUPS extension */
1520 "marker-message", /* CUPS extension */
1521 "marker-names", /* CUPS extension */
1522 "marker-types", /* CUPS extension */
1525 "member-names", /* CUPS extension */
1526 "member-uris", /* CUPS extension */
1527 "multiple-destination-uris-supported",/* IPP FaxOut */
1528 "multiple-document-jobs-supported",
1529 "multiple-operation-time-out",
1530 "multiple-operation-time-out-action",
1531 "natural-language-configured",
1532 "operations-supported",
1534 "pages-per-minute-color",
1535 "pdf-k-octets-supported", /* CUPS extension */
1536 "pdf-versions-supported", /* CUPS extension */
1537 "pdl-override-supported",
1538 "port-monitor", /* CUPS extension */
1539 "port-monitor-supported", /* CUPS extension */
1540 "preferred-attributes-supported",
1542 "printer-alert-description",
1543 "printer-charge-info",
1544 "printer-charge-info-uri",
1545 "printer-commands", /* CUPS extension */
1546 "printer-current-time",
1547 "printer-detailed-status-messages",
1548 "printer-device-id",
1549 "printer-dns-sd-name", /* CUPS extension */
1550 "printer-driver-installer",
1551 "printer-fax-log-uri", /* IPP FaxOut */
1552 "printer-fax-modem-info", /* IPP FaxOut */
1553 "printer-fax-modem-name", /* IPP FaxOut */
1554 "printer-fax-modem-number", /* IPP FaxOut */
1555 "printer-firmware-name", /* PWG 5110.1 */
1556 "printer-firmware-patches", /* PWG 5110.1 */
1557 "printer-firmware-string-version", /* PWG 5110.1 */
1558 "printer-firmware-version", /* PWG 5110.1 */
1559 "printer-geo-location",
1560 "printer-get-attributes-supported",
1561 "printer-icc-profiles",
1564 "printer-input-tray", /* IPP JPS3 */
1565 "printer-is-accepting-jobs",
1566 "printer-is-shared", /* CUPS extension */
1567 "printer-kind", /* IPP Paid Printing */
1569 "printer-make-and-model",
1570 "printer-mandatory-job-attributes",
1571 "printer-message-date-time",
1572 "printer-message-from-operator",
1573 "printer-message-time",
1574 "printer-more-info",
1575 "printer-more-info-manufacturer",
1577 "printer-native-formats",
1578 "printer-organization",
1579 "printer-organizational-unit",
1580 "printer-output-tray", /* IPP JPS3 */
1581 "printer-queue-id", /* CUPS extension */
1582 "printer-settable-attributes-supported",
1584 "printer-state-change-date-time",
1585 "printer-state-change-time",
1586 "printer-state-message",
1587 "printer-state-reasons",
1589 "printer-supply-description",
1590 "printer-supply-info-uri",
1591 "printer-type", /* CUPS extension */
1593 "printer-uri-supported",
1595 "printer-xri-supported",
1596 "pwg-raster-document-resolution-supported",
1597 "pwg-raster-document-sheet-back",
1598 "pwg-raster-document-type-supported",
1600 "reference-uri-schemes-supported",
1601 "repertoire-supported",
1602 "requesting-user-name-allowed", /* CUPS extension */
1603 "requesting-user-name-denied", /* CUPS extension */
1604 "requesting-user-uri-supported",
1605 "subordinate-printers-supported",
1606 "urf-supported", /* CUPS extension */
1607 "uri-authentication-supported",
1608 "uri-security-supported",
1609 "user-defined-value-supported",
1610 "which-jobs-supported",
1611 "xri-authentication-supported",
1612 "xri-security-supported",
1613 "xri-uri-scheme-supported"
1615 static const char * const subscription_description
[] =
1616 { /* subscription-description group */
1618 "notify-lease-expiration-time",
1619 "notify-printer-up-time",
1620 "notify-printer-uri",
1621 "notify-sequence-number",
1622 "notify-subscriber-user-name",
1623 "notify-subscriber-user-uri",
1624 "notify-subscription-id",
1625 "subscriptions-uuid"
1627 static const char * const subscription_template
[] =
1628 { /* subscription-template group */
1629 "notify-attributes",
1630 "notify-attributes-supported",
1633 "notify-events-default",
1634 "notify-events-supported",
1635 "notify-lease-duration",
1636 "notify-lease-duration-default",
1637 "notify-lease-duration-supported",
1638 "notify-max-events-supported",
1639 "notify-natural-language",
1640 "notify-pull-method",
1641 "notify-pull-method-supported",
1642 "notify-recipient-uri",
1643 "notify-schemes-supported",
1644 "notify-time-interval",
1650 * Get the requested-attributes attribute...
1653 if ((requested
= ippFindAttribute(request
, "requested-attributes",
1654 IPP_TAG_KEYWORD
)) == NULL
)
1657 * The Get-Jobs operation defaults to "job-id" and "job-uri", all others
1658 * default to "all"...
1661 if (ippGetOperation(request
) == IPP_OP_GET_JOBS
)
1663 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1664 cupsArrayAdd(ra
, "job-id");
1665 cupsArrayAdd(ra
, "job-uri");
1674 * If the attribute contains a single "all" keyword, return NULL...
1677 count
= ippGetCount(requested
);
1678 if (count
== 1 && !strcmp(ippGetString(requested
, 0, NULL
), "all"))
1682 * Create an array using "strcmp" as the comparison function...
1685 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1687 for (i
= 0; i
< count
; i
++)
1690 value
= ippGetString(requested
, i
, NULL
);
1692 if (!strcmp(value
, "document-description") || !strcmp(value
, "all"))
1695 j
< (int)(sizeof(document_description
) /
1696 sizeof(document_description
[0]));
1698 cupsArrayAdd(ra
, (void *)document_description
[j
]);
1703 if (!strcmp(value
, "document-template") || !strcmp(value
, "all"))
1706 j
< (int)(sizeof(document_template
) / sizeof(document_template
[0]));
1708 cupsArrayAdd(ra
, (void *)document_template
[j
]);
1713 if (!strcmp(value
, "job-description") || !strcmp(value
, "all"))
1716 j
< (int)(sizeof(job_description
) / sizeof(job_description
[0]));
1718 cupsArrayAdd(ra
, (void *)job_description
[j
]);
1723 if (!strcmp(value
, "job-template") || !strcmp(value
, "all"))
1726 j
< (int)(sizeof(job_template
) / sizeof(job_template
[0]));
1728 cupsArrayAdd(ra
, (void *)job_template
[j
]);
1733 if (!strcmp(value
, "printer-description") || !strcmp(value
, "all"))
1736 j
< (int)(sizeof(printer_description
) /
1737 sizeof(printer_description
[0]));
1739 cupsArrayAdd(ra
, (void *)printer_description
[j
]);
1744 if (!strcmp(value
, "subscription-description") || !strcmp(value
, "all"))
1747 j
< (int)(sizeof(subscription_description
) /
1748 sizeof(subscription_description
[0]));
1750 cupsArrayAdd(ra
, (void *)subscription_description
[j
]);
1755 if (!strcmp(value
, "subscription-template") || !strcmp(value
, "all"))
1758 j
< (int)(sizeof(subscription_template
) /
1759 sizeof(subscription_template
[0]));
1761 cupsArrayAdd(ra
, (void *)subscription_template
[j
]);
1767 cupsArrayAdd(ra
, (void *)value
);
1775 * 'ippEnumString()' - Return a string corresponding to the enum value.
1778 const char * /* O - Enum string */
1779 ippEnumString(const char *attrname
, /* I - Attribute name */
1780 int enumvalue
) /* I - Enum value */
1782 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1786 * Check for standard enum values...
1789 if (!strcmp(attrname
, "document-state") &&
1791 enumvalue
< (3 + (int)(sizeof(ipp_document_states
) /
1792 sizeof(ipp_document_states
[0]))))
1793 return (ipp_document_states
[enumvalue
- 3]);
1794 else if (!strcmp(attrname
, "finishings") ||
1795 !strcmp(attrname
, "finishings-actual") ||
1796 !strcmp(attrname
, "finishings-default") ||
1797 !strcmp(attrname
, "finishings-ready") ||
1798 !strcmp(attrname
, "finishings-supported") ||
1799 !strcmp(attrname
, "job-finishings") ||
1800 !strcmp(attrname
, "job-finishings-default") ||
1801 !strcmp(attrname
, "job-finishings-supported"))
1803 if (enumvalue
>= 3 &&
1804 enumvalue
< (3 + (int)(sizeof(ipp_finishings
) /
1805 sizeof(ipp_finishings
[0]))))
1806 return (ipp_finishings
[enumvalue
- 3]);
1807 else if (enumvalue
>= 0x40000000 &&
1808 enumvalue
<= (0x40000000 + (int)(sizeof(ipp_finishings_vendor
) /
1809 sizeof(ipp_finishings_vendor
[0]))))
1810 return (ipp_finishings_vendor
[enumvalue
- 0x40000000]);
1812 else if ((!strcmp(attrname
, "job-collation-type") ||
1813 !strcmp(attrname
, "job-collation-type-actual")) &&
1815 enumvalue
< (3 + (int)(sizeof(ipp_job_collation_types
) /
1816 sizeof(ipp_job_collation_types
[0]))))
1817 return (ipp_job_collation_types
[enumvalue
- 3]);
1818 else if (!strcmp(attrname
, "job-state") &&
1819 enumvalue
>= IPP_JSTATE_PENDING
&& enumvalue
<= IPP_JSTATE_COMPLETED
)
1820 return (ipp_job_states
[enumvalue
- IPP_JSTATE_PENDING
]);
1821 else if (!strcmp(attrname
, "operations-supported"))
1822 return (ippOpString((ipp_op_t
)enumvalue
));
1823 else if ((!strcmp(attrname
, "orientation-requested") ||
1824 !strcmp(attrname
, "orientation-requested-actual") ||
1825 !strcmp(attrname
, "orientation-requested-default") ||
1826 !strcmp(attrname
, "orientation-requested-supported")) &&
1828 enumvalue
< (3 + (int)(sizeof(ipp_orientation_requesteds
) /
1829 sizeof(ipp_orientation_requesteds
[0]))))
1830 return (ipp_orientation_requesteds
[enumvalue
- 3]);
1831 else if ((!strcmp(attrname
, "print-quality") ||
1832 !strcmp(attrname
, "print-quality-actual") ||
1833 !strcmp(attrname
, "print-quality-default") ||
1834 !strcmp(attrname
, "print-quality-supported")) &&
1836 enumvalue
< (3 + (int)(sizeof(ipp_print_qualities
) /
1837 sizeof(ipp_print_qualities
[0]))))
1838 return (ipp_print_qualities
[enumvalue
- 3]);
1839 else if (!strcmp(attrname
, "printer-state") &&
1840 enumvalue
>= IPP_PSTATE_IDLE
&& enumvalue
<= IPP_PSTATE_STOPPED
)
1841 return (ipp_printer_states
[enumvalue
- IPP_PSTATE_IDLE
]);
1844 * Not a standard enum value, just return the decimal equivalent...
1847 snprintf(cg
->ipp_unknown
, sizeof(cg
->ipp_unknown
), "%d", enumvalue
);
1848 return (cg
->ipp_unknown
);
1853 * 'ippEnumValue()' - Return the value associated with a given enum string.
1856 int /* O - Enum value or -1 if unknown */
1857 ippEnumValue(const char *attrname
, /* I - Attribute name */
1858 const char *enumstring
) /* I - Enum string */
1860 int i
, /* Looping var */
1861 num_strings
; /* Number of strings to compare */
1862 const char * const *strings
; /* Strings to compare */
1866 * If the string is just a number, return it...
1869 if (isdigit(*enumstring
& 255))
1870 return ((int)strtol(enumstring
, NULL
, 0));
1873 * Otherwise look up the string...
1876 if (!strcmp(attrname
, "document-state"))
1878 num_strings
= (int)(sizeof(ipp_document_states
) / sizeof(ipp_document_states
[0]));
1879 strings
= ipp_document_states
;
1881 else if (!strcmp(attrname
, "finishings") ||
1882 !strcmp(attrname
, "finishings-actual") ||
1883 !strcmp(attrname
, "finishings-default") ||
1884 !strcmp(attrname
, "finishings-ready") ||
1885 !strcmp(attrname
, "finishings-supported"))
1888 i
< (int)(sizeof(ipp_finishings_vendor
) /
1889 sizeof(ipp_finishings_vendor
[0]));
1891 if (!strcmp(enumstring
, ipp_finishings_vendor
[i
]))
1892 return (i
+ 0x40000000);
1894 num_strings
= (int)(sizeof(ipp_finishings
) / sizeof(ipp_finishings
[0]));
1895 strings
= ipp_finishings
;
1897 else if (!strcmp(attrname
, "job-collation-type") ||
1898 !strcmp(attrname
, "job-collation-type-actual"))
1900 num_strings
= (int)(sizeof(ipp_job_collation_types
) /
1901 sizeof(ipp_job_collation_types
[0]));
1902 strings
= ipp_job_collation_types
;
1904 else if (!strcmp(attrname
, "job-state"))
1906 num_strings
= (int)(sizeof(ipp_job_states
) / sizeof(ipp_job_states
[0]));
1907 strings
= ipp_job_states
;
1909 else if (!strcmp(attrname
, "operations-supported"))
1910 return (ippOpValue(enumstring
));
1911 else if (!strcmp(attrname
, "orientation-requested") ||
1912 !strcmp(attrname
, "orientation-requested-actual") ||
1913 !strcmp(attrname
, "orientation-requested-default") ||
1914 !strcmp(attrname
, "orientation-requested-supported"))
1916 num_strings
= (int)(sizeof(ipp_orientation_requesteds
) /
1917 sizeof(ipp_orientation_requesteds
[0]));
1918 strings
= ipp_orientation_requesteds
;
1920 else if (!strcmp(attrname
, "print-quality") ||
1921 !strcmp(attrname
, "print-quality-actual") ||
1922 !strcmp(attrname
, "print-quality-default") ||
1923 !strcmp(attrname
, "print-quality-supported"))
1925 num_strings
= (int)(sizeof(ipp_print_qualities
) / sizeof(ipp_print_qualities
[0]));
1926 strings
= ipp_print_qualities
;
1928 else if (!strcmp(attrname
, "printer-state"))
1930 num_strings
= (int)(sizeof(ipp_printer_states
) / sizeof(ipp_printer_states
[0]));
1931 strings
= ipp_printer_states
;
1936 for (i
= 0; i
< num_strings
; i
++)
1937 if (!strcmp(enumstring
, strings
[i
]))
1945 * 'ippErrorString()' - Return a name for the given status code.
1948 const char * /* O - Text string */
1949 ippErrorString(ipp_status_t error
) /* I - Error status */
1951 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1955 * See if the error code is a known value...
1958 if (error
>= IPP_STATUS_OK
&& error
<= IPP_STATUS_OK_EVENTS_COMPLETE
)
1959 return (ipp_status_oks
[error
]);
1960 else if (error
== IPP_STATUS_REDIRECTION_OTHER_SITE
)
1961 return ("redirection-other-site");
1962 else if (error
== IPP_STATUS_CUPS_SEE_OTHER
)
1963 return ("cups-see-other");
1964 else if (error
>= IPP_STATUS_ERROR_BAD_REQUEST
&&
1965 error
<= IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED
)
1966 return (ipp_status_400s
[error
- IPP_STATUS_ERROR_BAD_REQUEST
]);
1967 else if (error
>= 0x480 &&
1968 error
<= IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED
)
1969 return (ipp_status_480s
[error
- 0x0480]);
1970 else if (error
>= IPP_STATUS_ERROR_INTERNAL
&&
1971 error
<= IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS
)
1972 return (ipp_status_500s
[error
- IPP_STATUS_ERROR_INTERNAL
]);
1973 else if (error
>= IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
&&
1974 error
<= IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED
)
1975 return (ipp_status_1000s
[error
-
1976 IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
]);
1979 * No, build an "0xxxxx" error string...
1982 sprintf(cg
->ipp_unknown
, "0x%04x", error
);
1984 return (cg
->ipp_unknown
);
1989 * 'ippErrorValue()' - Return a status code for the given name.
1991 * @since CUPS 1.2/OS X 10.5@
1994 ipp_status_t
/* O - IPP status code */
1995 ippErrorValue(const char *name
) /* I - Name */
1997 size_t i
; /* Looping var */
2000 for (i
= 0; i
< (sizeof(ipp_status_oks
) / sizeof(ipp_status_oks
[0])); i
++)
2001 if (!_cups_strcasecmp(name
, ipp_status_oks
[i
]))
2002 return ((ipp_status_t
)i
);
2004 if (!_cups_strcasecmp(name
, "redirection-other-site"))
2005 return (IPP_STATUS_REDIRECTION_OTHER_SITE
);
2007 if (!_cups_strcasecmp(name
, "cups-see-other"))
2008 return (IPP_STATUS_CUPS_SEE_OTHER
);
2010 for (i
= 0; i
< (sizeof(ipp_status_400s
) / sizeof(ipp_status_400s
[0])); i
++)
2011 if (!_cups_strcasecmp(name
, ipp_status_400s
[i
]))
2012 return ((ipp_status_t
)(i
+ 0x400));
2014 for (i
= 0; i
< (sizeof(ipp_status_480s
) / sizeof(ipp_status_480s
[0])); i
++)
2015 if (!_cups_strcasecmp(name
, ipp_status_480s
[i
]))
2016 return ((ipp_status_t
)(i
+ 0x480));
2018 for (i
= 0; i
< (sizeof(ipp_status_500s
) / sizeof(ipp_status_500s
[0])); i
++)
2019 if (!_cups_strcasecmp(name
, ipp_status_500s
[i
]))
2020 return ((ipp_status_t
)(i
+ 0x500));
2022 for (i
= 0; i
< (sizeof(ipp_status_1000s
) / sizeof(ipp_status_1000s
[0])); i
++)
2023 if (!_cups_strcasecmp(name
, ipp_status_1000s
[i
]))
2024 return ((ipp_status_t
)(i
+ 0x1000));
2026 return ((ipp_status_t
)-1);
2031 * 'ippOpString()' - Return a name for the given operation id.
2033 * @since CUPS 1.2/OS X 10.5@
2036 const char * /* O - Name */
2037 ippOpString(ipp_op_t op
) /* I - Operation ID */
2039 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2043 * See if the operation ID is a known value...
2046 if (op
>= IPP_OP_PRINT_JOB
&& op
<= IPP_OP_VALIDATE_DOCUMENT
)
2047 return (ipp_std_ops
[op
]);
2048 else if (op
== IPP_OP_PRIVATE
)
2049 return ("windows-ext");
2050 else if (op
>= IPP_OP_CUPS_GET_DEFAULT
&& op
<= IPP_OP_CUPS_GET_PPD
)
2051 return (ipp_cups_ops
[op
- IPP_OP_CUPS_GET_DEFAULT
]);
2052 else if (op
== IPP_OP_CUPS_GET_DOCUMENT
)
2053 return (ipp_cups_ops2
[0]);
2056 * No, build an "0xxxxx" operation string...
2059 sprintf(cg
->ipp_unknown
, "0x%04x", op
);
2061 return (cg
->ipp_unknown
);
2066 * 'ippOpValue()' - Return an operation id for the given name.
2068 * @since CUPS 1.2/OS X 10.5@
2071 ipp_op_t
/* O - Operation ID */
2072 ippOpValue(const char *name
) /* I - Textual name */
2074 size_t i
; /* Looping var */
2077 if (!strncmp(name
, "0x", 2))
2078 return ((ipp_op_t
)strtol(name
+ 2, NULL
, 16));
2080 for (i
= 0; i
< (sizeof(ipp_std_ops
) / sizeof(ipp_std_ops
[0])); i
++)
2081 if (!_cups_strcasecmp(name
, ipp_std_ops
[i
]))
2082 return ((ipp_op_t
)i
);
2084 if (!_cups_strcasecmp(name
, "windows-ext"))
2085 return (IPP_OP_PRIVATE
);
2087 for (i
= 0; i
< (sizeof(ipp_cups_ops
) / sizeof(ipp_cups_ops
[0])); i
++)
2088 if (!_cups_strcasecmp(name
, ipp_cups_ops
[i
]))
2089 return ((ipp_op_t
)(i
+ 0x4001));
2091 for (i
= 0; i
< (sizeof(ipp_cups_ops2
) / sizeof(ipp_cups_ops2
[0])); i
++)
2092 if (!_cups_strcasecmp(name
, ipp_cups_ops2
[i
]))
2093 return ((ipp_op_t
)(i
+ 0x4027));
2095 if (!_cups_strcasecmp(name
, "Create-Job-Subscription"))
2096 return (IPP_OP_CREATE_JOB_SUBSCRIPTIONS
);
2098 if (!_cups_strcasecmp(name
, "Create-Printer-Subscription"))
2099 return (IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS
);
2101 if (!_cups_strcasecmp(name
, "CUPS-Add-Class"))
2102 return (IPP_OP_CUPS_ADD_MODIFY_CLASS
);
2104 if (!_cups_strcasecmp(name
, "CUPS-Add-Printer"))
2105 return (IPP_OP_CUPS_ADD_MODIFY_PRINTER
);
2107 return (IPP_OP_CUPS_INVALID
);
2112 * 'ippPort()' - Return the default IPP port number.
2115 int /* O - Port number */
2118 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2121 DEBUG_puts("ippPort()");
2126 DEBUG_printf(("1ippPort: Returning %d...", cg
->ipp_port
));
2128 return (cg
->ipp_port
);
2133 * 'ippSetPort()' - Set the default port number.
2137 ippSetPort(int p
) /* I - Port number to use */
2139 DEBUG_printf(("ippSetPort(p=%d)", p
));
2141 _cupsGlobals()->ipp_port
= p
;
2146 * 'ippStateString()' - Return the name corresponding to a state value.
2148 * @since CUPS 2.0/OS 10.10@
2151 const char * /* O - State name */
2152 ippStateString(ipp_state_t state
) /* I - State value */
2154 if (state
>= IPP_STATE_ERROR
&& state
<= IPP_STATE_DATA
)
2155 return (ipp_states
[state
- IPP_STATE_ERROR
]);
2162 * 'ippTagString()' - Return the tag name corresponding to a tag value.
2164 * The returned names are defined in RFC 2911 and 3382.
2166 * @since CUPS 1.4/OS X 10.6@
2169 const char * /* O - Tag name */
2170 ippTagString(ipp_tag_t tag
) /* I - Tag value */
2172 tag
&= IPP_TAG_CUPS_MASK
;
2174 if (tag
< (ipp_tag_t
)(sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])))
2175 return (ipp_tag_names
[tag
]);
2182 * 'ippTagValue()' - Return the tag value corresponding to a tag name.
2184 * The tag names are defined in RFC 2911 and 3382.
2186 * @since CUPS 1.4/OS X 10.6@
2189 ipp_tag_t
/* O - Tag value */
2190 ippTagValue(const char *name
) /* I - Tag name */
2192 size_t i
; /* Looping var */
2195 for (i
= 0; i
< (sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])); i
++)
2196 if (!_cups_strcasecmp(name
, ipp_tag_names
[i
]))
2197 return ((ipp_tag_t
)i
);
2199 if (!_cups_strcasecmp(name
, "operation"))
2200 return (IPP_TAG_OPERATION
);
2201 else if (!_cups_strcasecmp(name
, "job"))
2202 return (IPP_TAG_JOB
);
2203 else if (!_cups_strcasecmp(name
, "printer"))
2204 return (IPP_TAG_PRINTER
);
2205 else if (!_cups_strcasecmp(name
, "unsupported"))
2206 return (IPP_TAG_UNSUPPORTED_GROUP
);
2207 else if (!_cups_strcasecmp(name
, "subscription"))
2208 return (IPP_TAG_SUBSCRIPTION
);
2209 else if (!_cups_strcasecmp(name
, "event"))
2210 return (IPP_TAG_EVENT_NOTIFICATION
);
2211 else if (!_cups_strcasecmp(name
, "language"))
2212 return (IPP_TAG_LANGUAGE
);
2213 else if (!_cups_strcasecmp(name
, "mimetype"))
2214 return (IPP_TAG_MIMETYPE
);
2215 else if (!_cups_strcasecmp(name
, "name"))
2216 return (IPP_TAG_NAME
);
2217 else if (!_cups_strcasecmp(name
, "text"))
2218 return (IPP_TAG_TEXT
);
2219 else if (!_cups_strcasecmp(name
, "begCollection"))
2220 return (IPP_TAG_BEGIN_COLLECTION
);
2222 return (IPP_TAG_ZERO
);
2227 * 'ipp_col_string()' - Convert a collection to a string.
2230 static size_t /* O - Number of bytes */
2231 ipp_col_string(ipp_t
*col
, /* I - Collection attribute */
2232 char *buffer
, /* I - Buffer or NULL */
2233 size_t bufsize
) /* I - Size of buffer */
2235 char *bufptr
, /* Position in buffer */
2236 *bufend
, /* End of buffer */
2237 prefix
= '{', /* Prefix character */
2238 temp
[256]; /* Temporary string */
2239 ipp_attribute_t
*attr
; /* Current member attribute */
2251 bufend
= buffer
+ bufsize
- 1;
2253 for (attr
= col
->attrs
; attr
; attr
= attr
->next
)
2258 if (buffer
&& bufptr
< bufend
)
2263 if (buffer
&& bufptr
< bufend
)
2264 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%s=", attr
->name
);
2266 bufptr
+= strlen(attr
->name
) + 1;
2268 if (buffer
&& bufptr
< bufend
)
2269 bufptr
+= ippAttributeString(attr
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
2271 bufptr
+= ippAttributeString(attr
, temp
, sizeof(temp
));
2276 if (buffer
&& bufptr
< bufend
)
2281 if (buffer
&& bufptr
< bufend
)
2285 return ((size_t)(bufptr
- buffer
));