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
[] =
251 "CUPS-Create-Local-Printer"
253 * const ipp_tag_names
[] =
254 { /* Value/group tag names */
256 "operation-attributes-tag",
258 "job-attributes-tag", /* 0x02 */
259 "end-of-attributes-tag",
261 "printer-attributes-tag",
263 "unsupported-attributes-tag",
265 "subscription-attributes-tag",
267 "event-notification-attributes-tag",
269 "(resource-attributes-tag)",
271 "document-attributes-tag",
279 "unsupported", /* 0x10 */
280 "default", /* 0x11 */
281 "unknown", /* 0x12 */
282 "no-value", /* 0x13 */
284 "not-settable", /* 0x15 */
285 "delete-attribute", /* 0x16 */
286 "admin-define", /* 0x17 */
296 "integer", /* 0x21 */
297 "boolean", /* 0x22 */
311 "octetString", /* 0x30 */
312 "dateTime", /* 0x31 */
313 "resolution", /* 0x32 */
314 "rangeOfInteger", /* 0x33 */
315 "collection", /* 0x34 */
316 "textWithLanguage", /* 0x35 */
317 "nameWithLanguage", /* 0x36 */
318 "endCollection", /* 0x37 */
328 "textWithoutLanguage",/* 0x41 */
329 "nameWithoutLanguage",/* 0x42 */
331 "keyword", /* 0x44 */
333 "uriScheme", /* 0x46 */
334 "charset", /* 0x47 */
335 "naturalLanguage", /* 0x48 */
336 "mimeMediaType", /* 0x49 */
337 "memberAttrName" /* 0x4a */
339 static const char * const ipp_document_states
[] =
340 { /* document-state-enums */
344 "processing-stopped", /* IPPSIX */
349 * const ipp_finishings
[] =
350 { /* finishings enums */
363 "coat", /* Finishings 2.0 */
364 "laminate", /* Finishings 2.0 */
369 "staple-bottom-left",
371 "staple-bottom-right",
375 "edge-stitch-bottom",
379 "staple-dual-bottom",
380 "staple-triple-left", /* Finishings 2.0 */
381 "staple-triple-top", /* Finishings 2.0 */
382 "staple-triple-right",/* Finishings 2.0 */
383 "staple-triple-bottom",/* Finishings 2.0 */
409 "trim-after-documents",
418 "punch-top-left", /* Finishings 2.0 */
419 "punch-bottom-left", /* Finishings 2.0 */
420 "punch-top-right", /* Finishings 2.0 */
421 "punch-bottom-right", /* Finishings 2.0 */
422 "punch-dual-left", /* Finishings 2.0 */
423 "punch-dual-top", /* Finishings 2.0 */
424 "punch-dual-right", /* Finishings 2.0 */
425 "punch-dual-bottom", /* Finishings 2.0 */
426 "punch-triple-left", /* Finishings 2.0 */
427 "punch-triple-top", /* Finishings 2.0 */
428 "punch-triple-right", /* Finishings 2.0 */
429 "punch-triple-bottom",/* Finishings 2.0 */
430 "punch-quad-left", /* Finishings 2.0 */
431 "punch-quad-top", /* Finishings 2.0 */
432 "punch-quad-right", /* Finishings 2.0 */
433 "punch-quad-bottom", /* Finishings 2.0 */
438 "fold-accordian", /* Finishings 2.0 */
439 "fold-double-gate", /* Finishings 2.0 */
440 "fold-gate", /* Finishings 2.0 */
441 "fold-half", /* Finishings 2.0 */
442 "fold-half-z", /* Finishings 2.0 */
443 "fold-left-gate", /* Finishings 2.0 */
444 "fold-letter", /* Finishings 2.0 */
445 "fold-parallel", /* Finishings 2.0 */
446 "fold-poster", /* Finishings 2.0 */
447 "fold-right-gate", /* Finishings 2.0 */
448 "fold-z" /* Finishings 2.0 */
450 * const ipp_finishings_vendor
[] =
452 /* 0x40000000 to 0x4000000F */
469 /* 0x40000010 to 0x4000001F */
486 /* 0x40000020 to 0x4000002F */
503 /* 0x40000030 to 0x4000003F */
520 /* 0x40000040 - 0x4000004F */
527 "cups-punch-top-left",
528 "cups-punch-bottom-left",
529 "cups-punch-top-right",
530 "cups-punch-bottom-right",
531 "cups-punch-dual-left",
532 "cups-punch-dual-top",
533 "cups-punch-dual-right",
534 "cups-punch-dual-bottom",
535 "cups-punch-triple-left",
536 "cups-punch-triple-top",
537 /* 0x40000050 - 0x4000005F */
538 "cups-punch-triple-right",
539 "cups-punch-triple-bottom",
540 "cups-punch-quad-left",
541 "cups-punch-quad-top",
542 "cups-punch-quad-right",
543 "cups-punch-quad-bottom",
548 "cups-fold-accordian",
549 "cups-fold-double-gate",
553 "cups-fold-left-gate",
554 /* 0x40000060 - 0x40000064 */
556 "cups-fold-parallel",
558 "cups-fold-right-gate",
561 * const ipp_job_collation_types
[] =
562 { /* job-collation-type enums */
564 "collated-documents",
565 "uncollated-documents"
567 * const ipp_job_states
[] =
568 { /* job-state enums */
572 "processing-stopped",
577 * const ipp_orientation_requesteds
[] =
578 { /* orientation-requested enums */
585 * const ipp_print_qualities
[] =
586 { /* print-quality enums */
591 * const ipp_printer_states
[] =
592 { /* printer-state enums */
603 static size_t ipp_col_string(ipp_t
*col
, char *buffer
, size_t bufsize
);
607 * 'ippAttributeString()' - Convert the attribute's value to a string.
609 * Returns the number of bytes that would be written, not including the
610 * trailing nul. The buffer pointer can be NULL to get the required length,
611 * just like (v)snprintf.
613 * @since CUPS 1.6/OS X 10.8@
616 size_t /* O - Number of bytes less nul */
618 ipp_attribute_t
*attr
, /* I - Attribute */
619 char *buffer
, /* I - String buffer or NULL */
620 size_t bufsize
) /* I - Size of string buffer */
622 int i
; /* Looping var */
623 char *bufptr
, /* Pointer into buffer */
624 *bufend
, /* End of buffer */
625 temp
[256]; /* Temporary string */
626 const char *ptr
, /* Pointer into string */
627 *end
; /* Pointer to end of string */
628 _ipp_value_t
*val
; /* Current value */
631 if (!attr
|| !attr
->name
)
641 bufend
= buffer
+ bufsize
- 1;
645 for (i
= attr
->num_values
, val
= attr
->values
; i
> 0; i
--, val
++)
647 if (val
> attr
->values
)
649 if (buffer
&& bufptr
< bufend
)
655 switch (attr
->value_tag
& ~IPP_TAG_CUPS_CONST
)
658 ptr
= ippEnumString(attr
->name
, val
->integer
);
660 if (buffer
&& bufptr
< bufend
)
661 strlcpy(bufptr
, ptr
, (size_t)(bufend
- bufptr
+ 1));
663 bufptr
+= strlen(ptr
);
666 case IPP_TAG_INTEGER
:
667 if (buffer
&& bufptr
< bufend
)
668 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d", val
->integer
);
670 bufptr
+= snprintf(temp
, sizeof(temp
), "%d", val
->integer
);
673 case IPP_TAG_BOOLEAN
:
674 if (buffer
&& bufptr
< bufend
)
675 strlcpy(bufptr
, val
->boolean
? "true" : "false", (size_t)(bufend
- bufptr
+ 1));
677 bufptr
+= val
->boolean
? 4 : 5;
681 if (buffer
&& bufptr
< bufend
)
682 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d-%d", val
->range
.lower
, val
->range
.upper
);
684 bufptr
+= snprintf(temp
, sizeof(temp
), "%d-%d", val
->range
.lower
, val
->range
.upper
);
687 case IPP_TAG_RESOLUTION
:
688 if (val
->resolution
.xres
== val
->resolution
.yres
)
690 if (buffer
&& bufptr
< bufend
)
691 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d%s", val
->resolution
.xres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
693 bufptr
+= snprintf(temp
, sizeof(temp
), "%d%s", val
->resolution
.xres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
695 else if (buffer
&& bufptr
< bufend
)
696 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");
698 bufptr
+= snprintf(temp
, sizeof(temp
), "%dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
703 unsigned year
; /* Year */
705 year
= ((unsigned)val
->date
[0] << 8) + (unsigned)val
->date
[1];
707 if (val
->date
[9] == 0 && val
->date
[10] == 0)
708 snprintf(temp
, sizeof(temp
), "%04u-%02u-%02uT%02u:%02u:%02uZ",
709 year
, val
->date
[2], val
->date
[3], val
->date
[4],
710 val
->date
[5], val
->date
[6]);
712 snprintf(temp
, sizeof(temp
),
713 "%04u-%02u-%02uT%02u:%02u:%02u%c%02u%02u",
714 year
, val
->date
[2], val
->date
[3], val
->date
[4],
715 val
->date
[5], val
->date
[6], val
->date
[8], val
->date
[9],
718 if (buffer
&& bufptr
< bufend
)
719 strlcpy(bufptr
, temp
, (size_t)(bufend
- bufptr
+ 1));
721 bufptr
+= strlen(temp
);
727 case IPP_TAG_KEYWORD
:
728 case IPP_TAG_CHARSET
:
730 case IPP_TAG_URISCHEME
:
731 case IPP_TAG_MIMETYPE
:
732 case IPP_TAG_LANGUAGE
:
733 case IPP_TAG_TEXTLANG
:
734 case IPP_TAG_NAMELANG
:
735 if (!val
->string
.text
)
738 for (ptr
= val
->string
.text
; *ptr
; ptr
++)
740 if (*ptr
== '\\' || *ptr
== '\"' || *ptr
== '[')
742 if (buffer
&& bufptr
< bufend
)
747 if (buffer
&& bufptr
< bufend
)
752 if (val
->string
.language
)
755 * Add "[language]" to end of string...
758 if (buffer
&& bufptr
< bufend
)
762 if (buffer
&& bufptr
< bufend
)
763 strlcpy(bufptr
, val
->string
.language
, (size_t)(bufend
- bufptr
));
764 bufptr
+= strlen(val
->string
.language
);
766 if (buffer
&& bufptr
< bufend
)
772 case IPP_TAG_BEGIN_COLLECTION
:
773 if (buffer
&& bufptr
< bufend
)
774 bufptr
+= ipp_col_string(val
->collection
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
776 bufptr
+= ipp_col_string(val
->collection
, NULL
, 0);
779 case IPP_TAG_STRING
:
780 for (ptr
= val
->unknown
.data
, end
= ptr
+ val
->unknown
.length
;
783 if (*ptr
== '\\' || _cups_isspace(*ptr
))
785 if (buffer
&& bufptr
< bufend
)
789 if (buffer
&& bufptr
< bufend
)
793 else if (!isprint(*ptr
& 255))
795 if (buffer
&& bufptr
< bufend
)
796 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "\\%03o", *ptr
& 255);
798 bufptr
+= snprintf(temp
, sizeof(temp
), "\\%03o", *ptr
& 255);
802 if (buffer
&& bufptr
< bufend
)
810 ptr
= ippTagString(attr
->value_tag
);
811 if (buffer
&& bufptr
< bufend
)
812 strlcpy(bufptr
, ptr
, (size_t)(bufend
- bufptr
+ 1));
813 bufptr
+= strlen(ptr
);
818 if (buffer
&& bufptr
< bufend
)
823 return ((size_t)(bufptr
- buffer
));
828 * 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
829 * given requested-attributes attribute.
831 * This function creates a (sorted) CUPS array of attribute names matching the
832 * list of "requested-attribute" values supplied in an IPP request. All IANA-
833 * registered values are supported in addition to the CUPS IPP extension
836 * The @code request@ parameter specifies the request message that was read from
839 * @code NULL@ is returned if all attributes should be returned. Otherwise, the
840 * result is a sorted array of attribute names, where @code cupsArrayFind(array,
841 * "attribute-name")@ will return a non-NULL pointer. The array must be freed
842 * using the @code cupsArrayDelete@ function.
844 * @since CUPS 1.7/OS X 10.9@
847 cups_array_t
* /* O - CUPS array or @code NULL@ if all */
848 ippCreateRequestedArray(ipp_t
*request
) /* I - IPP request */
850 int i
, j
, /* Looping vars */
851 count
, /* Number of values */
852 added
; /* Was name added? */
853 ipp_attribute_t
*requested
; /* requested-attributes attribute */
854 cups_array_t
*ra
; /* Requested attributes array */
855 const char *value
; /* Current value */
856 /* The following lists come from the current IANA IPP registry of attributes */
857 static const char * const document_description
[] =
858 { /* document-description group */
862 "cover-front-actual",
863 "current-page-order",
864 "date-time-at-completed",
865 "date-time-at-creation",
866 "date-time-at-processing",
867 "detailed-status-messages",
868 "document-access-errors",
870 "document-digital-signature",
872 "document-format-details",
873 "document-format-detected",
874 "document-format-version",
875 "document-format-version-detected",
881 "document-natural-language",
883 "document-printer-uri",
885 "document-state-message",
886 "document-state-reasons",
891 "finishings-col-actual",
892 "force-front-side-actual",
893 "imposition-template-actual",
895 "impressions-completed",
896 "impressions-completed-current-copy",
897 "insert-sheet-actual",
899 "k-octets-processed",
903 "media-input-tray-check-actual",
905 "media-sheets-completed",
908 "orientation-requested-actual",
910 "output-device-assigned",
912 "page-delivery-actual",
913 "page-order-received-actual",
914 "page-ranges-actual",
917 "pages-completed-current-copy",
918 "presentation-direction-number-up-actual",
919 "print-color-mode-actual",
920 "print-content-optimize-actual",
921 "print-quality-actual",
922 "print-rendering-intent-actual",
923 "print-scaling-actual", /* IPP Paid Printing */
924 "printer-resolution-actual",
926 "separator-sheets-actual",
927 "sheet-completed-copy-number",
931 "time-at-processing",
932 "x-image-position-actual",
933 "x-image-shift-actual",
934 "x-side1-image-shift-actual",
935 "x-side2-image-shift-actual",
936 "y-image-position-actual",
937 "y-image-shift-actual",
938 "y-side1-image-shift-actual",
939 "y-side2-image-shift-actual"
941 static const char * const document_template
[] =
942 { /* document-template group */
947 "cover-back-default",
948 "cover-back-supported",
950 "cover-front-default",
951 "cover-front-supported",
953 "feed-orientation-default",
954 "feed-orientation-supported",
957 "finishings-col-default",
958 "finishings-col-supported",
959 "finishings-default",
960 "finishings-supported",
961 "font-name-requested",
962 "font-name-requested-default",
963 "font-name-requested-supported",
964 "font-size-requested",
965 "font-size-requested-default",
966 "font-size-requested-supported",
968 "force-front-side-default",
969 "force-front-side-supported",
970 "imposition-template",
971 "imposition-template-default",
972 "imposition-template-supported",
973 "insert-after-page-number-supported",
974 "insert-count-supported",
976 "insert-sheet-default",
977 "insert-sheet-supported",
978 "max-stitching-locations-supported",
980 "media-back-coating-supported",
981 "media-bottom-margin-supported",
984 "media-col-supported",
985 "media-color-supported",
987 "media-front-coating-supported",
988 "media-grain-supported",
989 "media-hole-count-supported",
990 "media-info-supported",
991 "media-input-tray-check",
992 "media-input-tray-check-default",
993 "media-input-tray-check-supported",
994 "media-key-supported",
995 "media-left-margin-supported",
996 "media-order-count-supported",
997 "media-pre-printed-supported",
998 "media-recycled-supported",
999 "media-right-margin-supported",
1000 "media-size-supported",
1001 "media-source-supported",
1003 "media-thickness-supported",
1004 "media-top-margin-supported",
1005 "media-type-supported",
1006 "media-weight-metric-supported",
1007 "multiple-document-handling",
1008 "multiple-document-handling-default",
1009 "multiple-document-handling-supported",
1011 "number-up-default",
1012 "number-up-supported",
1013 "orientation-requested",
1014 "orientation-requested-default",
1015 "orientation-requested-supported",
1016 "output-mode", /* CUPS extension */
1017 "output-mode-default", /* CUPS extension */
1018 "output-mode-supported", /* CUPS extension */
1020 "overrides-supported",
1022 "page-delivery-default",
1023 "page-delivery-supported",
1024 "page-order-received",
1025 "page-order-received-default",
1026 "page-order-received-supported",
1028 "page-ranges-supported",
1030 "pages-per-subset-supported",
1032 "pdl-init-file-default",
1033 "pdl-init-file-entry-supported",
1034 "pdl-init-file-location-supported",
1035 "pdl-init-file-name-subdirectory-supported",
1036 "pdl-init-file-name-supported",
1037 "pdl-init-file-supported",
1038 "presentation-direction-number-up",
1039 "presentation-direction-number-up-default",
1040 "presentation-direction-number-up-supported",
1042 "print-color-mode-default",
1043 "print-color-mode-supported",
1044 "print-content-optimize",
1045 "print-content-optimize-default",
1046 "print-content-optimize-supported",
1048 "print-quality-default",
1049 "print-quality-supported",
1050 "print-rendering-intent",
1051 "print-rendering-intent-default",
1052 "print-rendering-intent-supported",
1053 "print-scaling", /* IPP Paid Printing */
1054 "print-scaling-default", /* IPP Paid Printing */
1055 "print-scaling-supported", /* IPP Paid Printing */
1056 "printer-resolution",
1057 "printer-resolution-default",
1058 "printer-resolution-supported",
1060 "separator-sheets-default",
1061 "separator-sheets-supported",
1063 "sheet-collate-default",
1064 "sheet-collate-supported",
1068 "stitching-locations-supported",
1069 "stitching-offset-supported",
1071 "x-image-position-default",
1072 "x-image-position-supported",
1074 "x-image-shift-default",
1075 "x-image-shift-supported",
1076 "x-side1-image-shift",
1077 "x-side1-image-shift-default",
1078 "x-side1-image-shift-supported",
1079 "x-side2-image-shift",
1080 "x-side2-image-shift-default",
1081 "x-side2-image-shift-supported",
1083 "y-image-position-default",
1084 "y-image-position-supported",
1086 "y-image-shift-default",
1087 "y-image-shift-supported",
1088 "y-side1-image-shift",
1089 "y-side1-image-shift-default",
1090 "y-side1-image-shift-supported",
1091 "y-side2-image-shift",
1092 "y-side2-image-shift-default",
1093 "y-side2-image-shift-supported"
1095 static const char * const job_description
[] =
1096 { /* job-description group */
1097 "compression-supplied",
1099 "cover-back-actual",
1100 "cover-front-actual",
1101 "current-page-order",
1102 "date-time-at-completed",
1103 "date-time-at-creation",
1104 "date-time-at-processing",
1105 "destination-statuses",
1106 "document-charset-supplied",
1107 "document-digital-signature-supplied",
1108 "document-format-details-supplied",
1109 "document-format-supplied",
1110 "document-message-supplied",
1111 "document-metadata",
1112 "document-name-supplied",
1113 "document-natural-language-supplied",
1114 "document-overrides-actual",
1116 "finishings-actual",
1117 "finishings-col-actual",
1118 "force-front-side-actual",
1119 "imposition-template-actual",
1120 "impressions-completed-current-copy",
1121 "insert-sheet-actual",
1122 "job-account-id-actual",
1123 "job-accounting-sheets-actual",
1124 "job-accounting-user-id-actual",
1125 "job-attribute-fidelity",
1126 "job-charge-info", /* CUPS extension */
1127 "job-collation-type",
1128 "job-collation-type-actual",
1129 "job-copies-actual",
1130 "job-cover-back-actual",
1131 "job-cover-front-actual",
1132 "job-detailed-status-message",
1133 "job-document-access-errors",
1134 "job-error-sheet-actual",
1135 "job-finishings-actual",
1136 "job-finishings-col-actual",
1137 "job-hold-until-actual",
1140 "job-impressions-completed",
1142 "job-k-octets-processed",
1143 "job-mandatory-attributes",
1144 "job-media-progress", /* CUPS extension */
1146 "job-media-sheets-completed",
1147 "job-message-from-operator",
1150 "job-originating-host-name", /* CUPS extension */
1151 "job-originating-user-name",
1152 "job-originating-user-uri",
1154 "job-pages-completed",
1155 "job-pages-completed-current-copy",
1156 "job-printer-state-message", /* CUPS extension */
1157 "job-printer-state-reasons", /* CUPS extension */
1158 "job-printer-up-time",
1160 "job-priority-actual",
1161 "job-save-printer-make-and-model",
1162 "job-sheet-message-actual",
1163 "job-sheets-actual",
1164 "job-sheets-col-actual",
1166 "job-state-message",
1167 "job-state-reasons",
1172 "media-check-input-tray-actual",
1173 "multiple-document-handling-actual",
1174 "number-of-documents",
1175 "number-of-intervening-jobs",
1177 "orientation-requested-actual",
1178 "original-requesting-user-name",
1179 "output-bin-actual",
1180 "output-device-assigned",
1182 "page-delivery-actual",
1183 "page-order-received-actual",
1184 "page-ranges-actual",
1185 "presentation-direction-number-up-actual",
1186 "print-color-mode-actual",
1187 "print-content-optimize-actual",
1188 "print-quality-actual",
1189 "print-rendering-intent-actual",
1190 "print-scaling-actual", /* IPP Paid Printing */
1191 "printer-resolution-actual",
1192 "separator-sheets-actual",
1193 "sheet-collate-actual",
1194 "sheet-completed-copy-number",
1195 "sheet-completed-document-number",
1197 "time-at-completed",
1199 "time-at-processing",
1201 "x-image-position-actual",
1202 "x-image-shift-actual",
1203 "x-side1-image-shift-actual",
1204 "x-side2-image-shift-actual",
1205 "y-image-position-actual",
1206 "y-image-shift-actual",
1207 "y-side1-image-shift-actual",
1208 "y-side2-image-shift-actual"
1210 static const char * const job_template
[] =
1211 { /* job-template group */
1212 "confirmation-sheet-print", /* IPP FaxOut */
1213 "confirmation-sheet-print-default",
1218 "cover-back-default",
1219 "cover-back-supported",
1221 "cover-front-default",
1222 "cover-front-supported",
1223 "cover-sheet-info", /* IPP FaxOut */
1224 "cover-sheet-info-default",
1225 "cover-sheet-info-supported",
1226 "destination-uri-schemes-supported",/* IPP FaxOut */
1227 "destination-uris", /* IPP FaxOut */
1228 "destination-uris-supported",
1230 "feed-orientation-default",
1231 "feed-orientation-supported",
1234 "finishings-col-default",
1235 "finishings-col-supported",
1236 "finishings-default",
1237 "finishings-supported",
1238 "font-name-requested",
1239 "font-name-requested-default",
1240 "font-name-requested-supported",
1241 "font-size-requested",
1242 "font-size-requested-default",
1243 "font-size-requested-supported",
1245 "force-front-side-default",
1246 "force-front-side-supported",
1247 "imposition-template",
1248 "imposition-template-default",
1249 "imposition-template-supported",
1250 "insert-after-page-number-supported",
1251 "insert-count-supported",
1253 "insert-sheet-default",
1254 "insert-sheet-supported",
1256 "job-account-id-default",
1257 "job-account-id-supported",
1258 "job-accounting-sheets"
1259 "job-accounting-sheets-default"
1260 "job-accounting-sheets-supported"
1261 "job-accounting-user-id",
1262 "job-accounting-user-id-default",
1263 "job-accounting-user-id-supported",
1265 "job-copies-default",
1266 "job-copies-supported",
1268 "job-cover-back-default",
1269 "job-cover-back-supported",
1271 "job-cover-front-default",
1272 "job-cover-front-supported",
1273 "job-delay-output-until",
1274 "job-delay-output-until-default",
1275 "job-delay-output-until-supported",
1276 "job-delay-output-until-time",
1277 "job-delay-output-until-time-default",
1278 "job-delay-output-until-time-supported",
1280 "job-error-action-default",
1281 "job-error-action-supported",
1283 "job-error-sheet-default",
1284 "job-error-sheet-supported",
1286 "job-finishings-col",
1287 "job-finishings-col-default",
1288 "job-finishings-col-supported",
1289 "job-finishings-default",
1290 "job-finishings-supported",
1292 "job-hold-until-default",
1293 "job-hold-until-supported",
1294 "job-hold-until-time",
1295 "job-hold-until-time-default",
1296 "job-hold-until-time-supported",
1297 "job-message-to-operator",
1298 "job-message-to-operator-default",
1299 "job-message-to-operator-supported",
1301 "job-phone-number-default",
1302 "job-phone-number-supported",
1304 "job-priority-default",
1305 "job-priority-supported",
1306 "job-recipient-name",
1307 "job-recipient-name-default",
1308 "job-recipient-name-supported",
1309 "job-save-disposition",
1310 "job-save-disposition-default",
1311 "job-save-disposition-supported",
1314 "job-sheets-col-default",
1315 "job-sheets-col-supported",
1316 "job-sheets-default",
1317 "job-sheets-supported",
1318 "logo-uri-schemes-supported",
1319 "max-save-info-supported",
1320 "max-stitching-locations-supported",
1322 "media-back-coating-supported",
1323 "media-bottom-margin-supported",
1325 "media-col-default",
1326 "media-col-supported",
1327 "media-color-supported",
1329 "media-front-coating-supported",
1330 "media-grain-supported",
1331 "media-hole-count-supported",
1332 "media-info-supported",
1333 "media-input-tray-check",
1334 "media-input-tray-check-default",
1335 "media-input-tray-check-supported",
1336 "media-key-supported",
1337 "media-left-margin-supported",
1338 "media-order-count-supported",
1339 "media-pre-printed-supported",
1340 "media-recycled-supported",
1341 "media-right-margin-supported",
1342 "media-size-supported",
1343 "media-source-supported",
1345 "media-thickness-supported",
1346 "media-top-margin-supported",
1347 "media-type-supported",
1348 "media-weight-metric-supported",
1349 "multiple-document-handling",
1350 "multiple-document-handling-default",
1351 "multiple-document-handling-supported",
1352 "number-of-retries", /* IPP FaxOut */
1353 "number-of-retries-default",
1354 "number-of-retries-supported",
1356 "number-up-default",
1357 "number-up-supported",
1358 "orientation-requested",
1359 "orientation-requested-default",
1360 "orientation-requested-supported",
1362 "output-bin-default",
1363 "output-bin-supported",
1365 "output-device-default",
1366 "output-device-supported",
1367 "output-mode", /* CUPS extension */
1368 "output-mode-default", /* CUPS extension */
1369 "output-mode-supported", /* CUPS extension */
1371 "overrides-supported",
1373 "page-delivery-default",
1374 "page-delivery-supported",
1375 "page-order-received",
1376 "page-order-received-default",
1377 "page-order-received-supported",
1379 "page-ranges-supported",
1381 "pages-per-subset-supported",
1383 "pdl-init-file-default",
1384 "pdl-init-file-entry-supported",
1385 "pdl-init-file-location-supported",
1386 "pdl-init-file-name-subdirectory-supported",
1387 "pdl-init-file-name-supported",
1388 "pdl-init-file-supported",
1389 "presentation-direction-number-up",
1390 "presentation-direction-number-up-default",
1391 "presentation-direction-number-up-supported",
1393 "print-color-mode-default",
1394 "print-color-mode-supported",
1395 "print-content-optimize",
1396 "print-content-optimize-default",
1397 "print-content-optimize-supported",
1399 "print-quality-default",
1400 "print-quality-supported",
1401 "print-rendering-intent",
1402 "print-rendering-intent-default",
1403 "print-rendering-intent-supported",
1404 "print-scaling", /* IPP Paid Printing */
1405 "print-scaling-default", /* IPP Paid Printing */
1406 "print-scaling-supported", /* IPP Paid Printing */
1407 "printer-resolution",
1408 "printer-resolution-default",
1409 "printer-resolution-supported",
1411 "proof-print-default",
1412 "proof-print-supported",
1413 "retry-interval", /* IPP FaxOut */
1414 "retry-interval-default",
1415 "retry-interval-supported",
1416 "retry-timeout", /* IPP FaxOut */
1417 "retry-timeout-default",
1418 "retry-timeout-supported",
1419 "save-disposition-supported",
1420 "save-document-format-default",
1421 "save-document-format-supported",
1422 "save-location-default",
1423 "save-location-supported",
1424 "save-name-subdirectory-supported",
1425 "save-name-supported",
1427 "separator-sheets-default",
1428 "separator-sheets-supported",
1430 "sheet-collate-default",
1431 "sheet-collate-supported",
1435 "stitching-locations-supported",
1436 "stitching-offset-supported",
1438 "x-image-position-default",
1439 "x-image-position-supported",
1441 "x-image-shift-default",
1442 "x-image-shift-supported",
1443 "x-side1-image-shift",
1444 "x-side1-image-shift-default",
1445 "x-side1-image-shift-supported",
1446 "x-side2-image-shift",
1447 "x-side2-image-shift-default",
1448 "x-side2-image-shift-supported",
1450 "y-image-position-default",
1451 "y-image-position-supported",
1453 "y-image-shift-default",
1454 "y-image-shift-supported",
1455 "y-side1-image-shift",
1456 "y-side1-image-shift-default",
1457 "y-side1-image-shift-supported",
1458 "y-side2-image-shift",
1459 "y-side2-image-shift-default",
1460 "y-side2-image-shift-supported"
1462 static const char * const printer_description
[] =
1463 { /* printer-description group */
1464 "auth-info-required", /* CUPS extension */
1465 "charset-configured",
1466 "charset-supported",
1468 "compression-supported",
1469 "device-service-count",
1470 "device-uri", /* CUPS extension */
1472 "document-charset-default",
1473 "document-charset-supported",
1474 "document-creation-attributes-supported",
1475 "document-digital-signature-default",
1476 "document-digital-signature-supported",
1477 "document-format-default",
1478 "document-format-details-default",
1479 "document-format-details-supported",
1480 "document-format-supported",
1481 "document-format-varying-attributes",
1482 "document-format-version-default",
1483 "document-format-version-supported",
1484 "document-natural-language-default",
1485 "document-natural-language-supported",
1486 "document-password-supported",
1487 "generated-natural-language-supported",
1488 "identify-actions-default",
1489 "identify-actions-supported",
1490 "input-source-supported",
1491 "ipp-features-supported",
1492 "ipp-versions-supported",
1493 "ippget-event-life",
1494 "job-authorization-uri-supported", /* CUPS extension */
1495 "job-constraints-supported",
1496 "job-creation-attributes-supported",
1497 "job-finishings-col-ready",
1498 "job-finishings-ready",
1499 "job-ids-supported",
1500 "job-impressions-supported",
1501 "job-k-limit", /* CUPS extension */
1502 "job-k-octets-supported",
1503 "job-media-sheets-supported",
1504 "job-page-limit", /* CUPS extension */
1505 "job-password-encryption-supported",
1506 "job-password-supported",
1507 "job-quota-period", /* CUPS extension */
1508 "job-resolvers-supported",
1509 "job-settable-attributes-supported",
1510 "job-spooling-supported",
1511 "jpeg-k-octets-supported", /* CUPS extension */
1512 "jpeg-x-dimension-supported", /* CUPS extension */
1513 "jpeg-y-dimension-supported", /* CUPS extension */
1514 "landscape-orientation-requested-preferred",
1515 /* CUPS extension */
1516 "marker-change-time", /* CUPS extension */
1517 "marker-colors", /* CUPS extension */
1518 "marker-high-levels", /* CUPS extension */
1519 "marker-levels", /* CUPS extension */
1520 "marker-low-levels", /* CUPS extension */
1521 "marker-message", /* CUPS extension */
1522 "marker-names", /* CUPS extension */
1523 "marker-types", /* CUPS extension */
1526 "member-names", /* CUPS extension */
1527 "member-uris", /* CUPS extension */
1528 "multiple-destination-uris-supported",/* IPP FaxOut */
1529 "multiple-document-jobs-supported",
1530 "multiple-operation-time-out",
1531 "multiple-operation-time-out-action",
1532 "natural-language-configured",
1533 "operations-supported",
1535 "pages-per-minute-color",
1536 "pdf-k-octets-supported", /* CUPS extension */
1537 "pdf-versions-supported", /* CUPS extension */
1538 "pdl-override-supported",
1539 "port-monitor", /* CUPS extension */
1540 "port-monitor-supported", /* CUPS extension */
1541 "preferred-attributes-supported",
1543 "printer-alert-description",
1544 "printer-charge-info",
1545 "printer-charge-info-uri",
1546 "printer-commands", /* CUPS extension */
1547 "printer-current-time",
1548 "printer-detailed-status-messages",
1549 "printer-device-id",
1550 "printer-dns-sd-name", /* CUPS extension */
1551 "printer-driver-installer",
1552 "printer-fax-log-uri", /* IPP FaxOut */
1553 "printer-fax-modem-info", /* IPP FaxOut */
1554 "printer-fax-modem-name", /* IPP FaxOut */
1555 "printer-fax-modem-number", /* IPP FaxOut */
1556 "printer-firmware-name", /* PWG 5110.1 */
1557 "printer-firmware-patches", /* PWG 5110.1 */
1558 "printer-firmware-string-version", /* PWG 5110.1 */
1559 "printer-firmware-version", /* PWG 5110.1 */
1560 "printer-geo-location",
1561 "printer-get-attributes-supported",
1562 "printer-icc-profiles",
1565 "printer-input-tray", /* IPP JPS3 */
1566 "printer-is-accepting-jobs",
1567 "printer-is-shared", /* CUPS extension */
1568 "printer-is-temporary", /* CUPS extension */
1569 "printer-kind", /* IPP Paid Printing */
1571 "printer-make-and-model",
1572 "printer-mandatory-job-attributes",
1573 "printer-message-date-time",
1574 "printer-message-from-operator",
1575 "printer-message-time",
1576 "printer-more-info",
1577 "printer-more-info-manufacturer",
1579 "printer-native-formats",
1580 "printer-organization",
1581 "printer-organizational-unit",
1582 "printer-output-tray", /* IPP JPS3 */
1583 "printer-queue-id", /* CUPS extension */
1584 "printer-settable-attributes-supported",
1586 "printer-state-change-date-time",
1587 "printer-state-change-time",
1588 "printer-state-message",
1589 "printer-state-reasons",
1591 "printer-supply-description",
1592 "printer-supply-info-uri",
1593 "printer-type", /* CUPS extension */
1595 "printer-uri-supported",
1597 "printer-xri-supported",
1598 "pwg-raster-document-resolution-supported",
1599 "pwg-raster-document-sheet-back",
1600 "pwg-raster-document-type-supported",
1602 "reference-uri-schemes-supported",
1603 "repertoire-supported",
1604 "requesting-user-name-allowed", /* CUPS extension */
1605 "requesting-user-name-denied", /* CUPS extension */
1606 "requesting-user-uri-supported",
1607 "subordinate-printers-supported",
1608 "urf-supported", /* CUPS extension */
1609 "uri-authentication-supported",
1610 "uri-security-supported",
1611 "user-defined-value-supported",
1612 "which-jobs-supported",
1613 "xri-authentication-supported",
1614 "xri-security-supported",
1615 "xri-uri-scheme-supported"
1617 static const char * const subscription_description
[] =
1618 { /* subscription-description group */
1620 "notify-lease-expiration-time",
1621 "notify-printer-up-time",
1622 "notify-printer-uri",
1623 "notify-sequence-number",
1624 "notify-subscriber-user-name",
1625 "notify-subscriber-user-uri",
1626 "notify-subscription-id",
1627 "subscriptions-uuid"
1629 static const char * const subscription_template
[] =
1630 { /* subscription-template group */
1631 "notify-attributes",
1632 "notify-attributes-supported",
1635 "notify-events-default",
1636 "notify-events-supported",
1637 "notify-lease-duration",
1638 "notify-lease-duration-default",
1639 "notify-lease-duration-supported",
1640 "notify-max-events-supported",
1641 "notify-natural-language",
1642 "notify-pull-method",
1643 "notify-pull-method-supported",
1644 "notify-recipient-uri",
1645 "notify-schemes-supported",
1646 "notify-time-interval",
1652 * Get the requested-attributes attribute...
1655 if ((requested
= ippFindAttribute(request
, "requested-attributes",
1656 IPP_TAG_KEYWORD
)) == NULL
)
1659 * The Get-Jobs operation defaults to "job-id" and "job-uri", all others
1660 * default to "all"...
1663 if (ippGetOperation(request
) == IPP_OP_GET_JOBS
)
1665 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1666 cupsArrayAdd(ra
, "job-id");
1667 cupsArrayAdd(ra
, "job-uri");
1676 * If the attribute contains a single "all" keyword, return NULL...
1679 count
= ippGetCount(requested
);
1680 if (count
== 1 && !strcmp(ippGetString(requested
, 0, NULL
), "all"))
1684 * Create an array using "strcmp" as the comparison function...
1687 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1689 for (i
= 0; i
< count
; i
++)
1692 value
= ippGetString(requested
, i
, NULL
);
1694 if (!strcmp(value
, "document-description") || !strcmp(value
, "all"))
1697 j
< (int)(sizeof(document_description
) /
1698 sizeof(document_description
[0]));
1700 cupsArrayAdd(ra
, (void *)document_description
[j
]);
1705 if (!strcmp(value
, "document-template") || !strcmp(value
, "all"))
1708 j
< (int)(sizeof(document_template
) / sizeof(document_template
[0]));
1710 cupsArrayAdd(ra
, (void *)document_template
[j
]);
1715 if (!strcmp(value
, "job-description") || !strcmp(value
, "all"))
1718 j
< (int)(sizeof(job_description
) / sizeof(job_description
[0]));
1720 cupsArrayAdd(ra
, (void *)job_description
[j
]);
1725 if (!strcmp(value
, "job-template") || !strcmp(value
, "all"))
1728 j
< (int)(sizeof(job_template
) / sizeof(job_template
[0]));
1730 cupsArrayAdd(ra
, (void *)job_template
[j
]);
1735 if (!strcmp(value
, "printer-description") || !strcmp(value
, "all"))
1738 j
< (int)(sizeof(printer_description
) /
1739 sizeof(printer_description
[0]));
1741 cupsArrayAdd(ra
, (void *)printer_description
[j
]);
1746 if (!strcmp(value
, "subscription-description") || !strcmp(value
, "all"))
1749 j
< (int)(sizeof(subscription_description
) /
1750 sizeof(subscription_description
[0]));
1752 cupsArrayAdd(ra
, (void *)subscription_description
[j
]);
1757 if (!strcmp(value
, "subscription-template") || !strcmp(value
, "all"))
1760 j
< (int)(sizeof(subscription_template
) /
1761 sizeof(subscription_template
[0]));
1763 cupsArrayAdd(ra
, (void *)subscription_template
[j
]);
1769 cupsArrayAdd(ra
, (void *)value
);
1777 * 'ippEnumString()' - Return a string corresponding to the enum value.
1780 const char * /* O - Enum string */
1781 ippEnumString(const char *attrname
, /* I - Attribute name */
1782 int enumvalue
) /* I - Enum value */
1784 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1788 * Check for standard enum values...
1791 if (!strcmp(attrname
, "document-state") &&
1793 enumvalue
< (3 + (int)(sizeof(ipp_document_states
) /
1794 sizeof(ipp_document_states
[0]))))
1795 return (ipp_document_states
[enumvalue
- 3]);
1796 else if (!strcmp(attrname
, "finishings") ||
1797 !strcmp(attrname
, "finishings-actual") ||
1798 !strcmp(attrname
, "finishings-default") ||
1799 !strcmp(attrname
, "finishings-ready") ||
1800 !strcmp(attrname
, "finishings-supported") ||
1801 !strcmp(attrname
, "job-finishings") ||
1802 !strcmp(attrname
, "job-finishings-default") ||
1803 !strcmp(attrname
, "job-finishings-supported"))
1805 if (enumvalue
>= 3 &&
1806 enumvalue
< (3 + (int)(sizeof(ipp_finishings
) /
1807 sizeof(ipp_finishings
[0]))))
1808 return (ipp_finishings
[enumvalue
- 3]);
1809 else if (enumvalue
>= 0x40000000 &&
1810 enumvalue
<= (0x40000000 + (int)(sizeof(ipp_finishings_vendor
) /
1811 sizeof(ipp_finishings_vendor
[0]))))
1812 return (ipp_finishings_vendor
[enumvalue
- 0x40000000]);
1814 else if ((!strcmp(attrname
, "job-collation-type") ||
1815 !strcmp(attrname
, "job-collation-type-actual")) &&
1817 enumvalue
< (3 + (int)(sizeof(ipp_job_collation_types
) /
1818 sizeof(ipp_job_collation_types
[0]))))
1819 return (ipp_job_collation_types
[enumvalue
- 3]);
1820 else if (!strcmp(attrname
, "job-state") &&
1821 enumvalue
>= IPP_JSTATE_PENDING
&& enumvalue
<= IPP_JSTATE_COMPLETED
)
1822 return (ipp_job_states
[enumvalue
- IPP_JSTATE_PENDING
]);
1823 else if (!strcmp(attrname
, "operations-supported"))
1824 return (ippOpString((ipp_op_t
)enumvalue
));
1825 else if ((!strcmp(attrname
, "orientation-requested") ||
1826 !strcmp(attrname
, "orientation-requested-actual") ||
1827 !strcmp(attrname
, "orientation-requested-default") ||
1828 !strcmp(attrname
, "orientation-requested-supported")) &&
1830 enumvalue
< (3 + (int)(sizeof(ipp_orientation_requesteds
) /
1831 sizeof(ipp_orientation_requesteds
[0]))))
1832 return (ipp_orientation_requesteds
[enumvalue
- 3]);
1833 else if ((!strcmp(attrname
, "print-quality") ||
1834 !strcmp(attrname
, "print-quality-actual") ||
1835 !strcmp(attrname
, "print-quality-default") ||
1836 !strcmp(attrname
, "print-quality-supported")) &&
1838 enumvalue
< (3 + (int)(sizeof(ipp_print_qualities
) /
1839 sizeof(ipp_print_qualities
[0]))))
1840 return (ipp_print_qualities
[enumvalue
- 3]);
1841 else if (!strcmp(attrname
, "printer-state") &&
1842 enumvalue
>= IPP_PSTATE_IDLE
&& enumvalue
<= IPP_PSTATE_STOPPED
)
1843 return (ipp_printer_states
[enumvalue
- IPP_PSTATE_IDLE
]);
1846 * Not a standard enum value, just return the decimal equivalent...
1849 snprintf(cg
->ipp_unknown
, sizeof(cg
->ipp_unknown
), "%d", enumvalue
);
1850 return (cg
->ipp_unknown
);
1855 * 'ippEnumValue()' - Return the value associated with a given enum string.
1858 int /* O - Enum value or -1 if unknown */
1859 ippEnumValue(const char *attrname
, /* I - Attribute name */
1860 const char *enumstring
) /* I - Enum string */
1862 int i
, /* Looping var */
1863 num_strings
; /* Number of strings to compare */
1864 const char * const *strings
; /* Strings to compare */
1868 * If the string is just a number, return it...
1871 if (isdigit(*enumstring
& 255))
1872 return ((int)strtol(enumstring
, NULL
, 0));
1875 * Otherwise look up the string...
1878 if (!strcmp(attrname
, "document-state"))
1880 num_strings
= (int)(sizeof(ipp_document_states
) / sizeof(ipp_document_states
[0]));
1881 strings
= ipp_document_states
;
1883 else if (!strcmp(attrname
, "finishings") ||
1884 !strcmp(attrname
, "finishings-actual") ||
1885 !strcmp(attrname
, "finishings-default") ||
1886 !strcmp(attrname
, "finishings-ready") ||
1887 !strcmp(attrname
, "finishings-supported"))
1890 i
< (int)(sizeof(ipp_finishings_vendor
) /
1891 sizeof(ipp_finishings_vendor
[0]));
1893 if (!strcmp(enumstring
, ipp_finishings_vendor
[i
]))
1894 return (i
+ 0x40000000);
1896 num_strings
= (int)(sizeof(ipp_finishings
) / sizeof(ipp_finishings
[0]));
1897 strings
= ipp_finishings
;
1899 else if (!strcmp(attrname
, "job-collation-type") ||
1900 !strcmp(attrname
, "job-collation-type-actual"))
1902 num_strings
= (int)(sizeof(ipp_job_collation_types
) /
1903 sizeof(ipp_job_collation_types
[0]));
1904 strings
= ipp_job_collation_types
;
1906 else if (!strcmp(attrname
, "job-state"))
1908 num_strings
= (int)(sizeof(ipp_job_states
) / sizeof(ipp_job_states
[0]));
1909 strings
= ipp_job_states
;
1911 else if (!strcmp(attrname
, "operations-supported"))
1912 return (ippOpValue(enumstring
));
1913 else if (!strcmp(attrname
, "orientation-requested") ||
1914 !strcmp(attrname
, "orientation-requested-actual") ||
1915 !strcmp(attrname
, "orientation-requested-default") ||
1916 !strcmp(attrname
, "orientation-requested-supported"))
1918 num_strings
= (int)(sizeof(ipp_orientation_requesteds
) /
1919 sizeof(ipp_orientation_requesteds
[0]));
1920 strings
= ipp_orientation_requesteds
;
1922 else if (!strcmp(attrname
, "print-quality") ||
1923 !strcmp(attrname
, "print-quality-actual") ||
1924 !strcmp(attrname
, "print-quality-default") ||
1925 !strcmp(attrname
, "print-quality-supported"))
1927 num_strings
= (int)(sizeof(ipp_print_qualities
) / sizeof(ipp_print_qualities
[0]));
1928 strings
= ipp_print_qualities
;
1930 else if (!strcmp(attrname
, "printer-state"))
1932 num_strings
= (int)(sizeof(ipp_printer_states
) / sizeof(ipp_printer_states
[0]));
1933 strings
= ipp_printer_states
;
1938 for (i
= 0; i
< num_strings
; i
++)
1939 if (!strcmp(enumstring
, strings
[i
]))
1947 * 'ippErrorString()' - Return a name for the given status code.
1950 const char * /* O - Text string */
1951 ippErrorString(ipp_status_t error
) /* I - Error status */
1953 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1957 * See if the error code is a known value...
1960 if (error
>= IPP_STATUS_OK
&& error
<= IPP_STATUS_OK_EVENTS_COMPLETE
)
1961 return (ipp_status_oks
[error
]);
1962 else if (error
== IPP_STATUS_REDIRECTION_OTHER_SITE
)
1963 return ("redirection-other-site");
1964 else if (error
== IPP_STATUS_CUPS_SEE_OTHER
)
1965 return ("cups-see-other");
1966 else if (error
>= IPP_STATUS_ERROR_BAD_REQUEST
&&
1967 error
<= IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED
)
1968 return (ipp_status_400s
[error
- IPP_STATUS_ERROR_BAD_REQUEST
]);
1969 else if (error
>= 0x480 &&
1970 error
<= IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED
)
1971 return (ipp_status_480s
[error
- 0x0480]);
1972 else if (error
>= IPP_STATUS_ERROR_INTERNAL
&&
1973 error
<= IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS
)
1974 return (ipp_status_500s
[error
- IPP_STATUS_ERROR_INTERNAL
]);
1975 else if (error
>= IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
&&
1976 error
<= IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED
)
1977 return (ipp_status_1000s
[error
-
1978 IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
]);
1981 * No, build an "0xxxxx" error string...
1984 sprintf(cg
->ipp_unknown
, "0x%04x", error
);
1986 return (cg
->ipp_unknown
);
1991 * 'ippErrorValue()' - Return a status code for the given name.
1993 * @since CUPS 1.2/OS X 10.5@
1996 ipp_status_t
/* O - IPP status code */
1997 ippErrorValue(const char *name
) /* I - Name */
1999 size_t i
; /* Looping var */
2002 for (i
= 0; i
< (sizeof(ipp_status_oks
) / sizeof(ipp_status_oks
[0])); i
++)
2003 if (!_cups_strcasecmp(name
, ipp_status_oks
[i
]))
2004 return ((ipp_status_t
)i
);
2006 if (!_cups_strcasecmp(name
, "redirection-other-site"))
2007 return (IPP_STATUS_REDIRECTION_OTHER_SITE
);
2009 if (!_cups_strcasecmp(name
, "cups-see-other"))
2010 return (IPP_STATUS_CUPS_SEE_OTHER
);
2012 for (i
= 0; i
< (sizeof(ipp_status_400s
) / sizeof(ipp_status_400s
[0])); i
++)
2013 if (!_cups_strcasecmp(name
, ipp_status_400s
[i
]))
2014 return ((ipp_status_t
)(i
+ 0x400));
2016 for (i
= 0; i
< (sizeof(ipp_status_480s
) / sizeof(ipp_status_480s
[0])); i
++)
2017 if (!_cups_strcasecmp(name
, ipp_status_480s
[i
]))
2018 return ((ipp_status_t
)(i
+ 0x480));
2020 for (i
= 0; i
< (sizeof(ipp_status_500s
) / sizeof(ipp_status_500s
[0])); i
++)
2021 if (!_cups_strcasecmp(name
, ipp_status_500s
[i
]))
2022 return ((ipp_status_t
)(i
+ 0x500));
2024 for (i
= 0; i
< (sizeof(ipp_status_1000s
) / sizeof(ipp_status_1000s
[0])); i
++)
2025 if (!_cups_strcasecmp(name
, ipp_status_1000s
[i
]))
2026 return ((ipp_status_t
)(i
+ 0x1000));
2028 return ((ipp_status_t
)-1);
2033 * 'ippOpString()' - Return a name for the given operation id.
2035 * @since CUPS 1.2/OS X 10.5@
2038 const char * /* O - Name */
2039 ippOpString(ipp_op_t op
) /* I - Operation ID */
2041 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2045 * See if the operation ID is a known value...
2048 if (op
>= IPP_OP_PRINT_JOB
&& op
<= IPP_OP_VALIDATE_DOCUMENT
)
2049 return (ipp_std_ops
[op
]);
2050 else if (op
== IPP_OP_PRIVATE
)
2051 return ("windows-ext");
2052 else if (op
>= IPP_OP_CUPS_GET_DEFAULT
&& op
<= IPP_OP_CUPS_GET_PPD
)
2053 return (ipp_cups_ops
[op
- IPP_OP_CUPS_GET_DEFAULT
]);
2054 else if (op
== IPP_OP_CUPS_GET_DOCUMENT
)
2055 return (ipp_cups_ops2
[0]);
2058 * No, build an "0xxxxx" operation string...
2061 sprintf(cg
->ipp_unknown
, "0x%04x", op
);
2063 return (cg
->ipp_unknown
);
2068 * 'ippOpValue()' - Return an operation id for the given name.
2070 * @since CUPS 1.2/OS X 10.5@
2073 ipp_op_t
/* O - Operation ID */
2074 ippOpValue(const char *name
) /* I - Textual name */
2076 size_t i
; /* Looping var */
2079 if (!strncmp(name
, "0x", 2))
2080 return ((ipp_op_t
)strtol(name
+ 2, NULL
, 16));
2082 for (i
= 0; i
< (sizeof(ipp_std_ops
) / sizeof(ipp_std_ops
[0])); i
++)
2083 if (!_cups_strcasecmp(name
, ipp_std_ops
[i
]))
2084 return ((ipp_op_t
)i
);
2086 if (!_cups_strcasecmp(name
, "windows-ext"))
2087 return (IPP_OP_PRIVATE
);
2089 for (i
= 0; i
< (sizeof(ipp_cups_ops
) / sizeof(ipp_cups_ops
[0])); i
++)
2090 if (!_cups_strcasecmp(name
, ipp_cups_ops
[i
]))
2091 return ((ipp_op_t
)(i
+ 0x4001));
2093 for (i
= 0; i
< (sizeof(ipp_cups_ops2
) / sizeof(ipp_cups_ops2
[0])); i
++)
2094 if (!_cups_strcasecmp(name
, ipp_cups_ops2
[i
]))
2095 return ((ipp_op_t
)(i
+ 0x4027));
2097 if (!_cups_strcasecmp(name
, "Create-Job-Subscription"))
2098 return (IPP_OP_CREATE_JOB_SUBSCRIPTIONS
);
2100 if (!_cups_strcasecmp(name
, "Create-Printer-Subscription"))
2101 return (IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS
);
2103 if (!_cups_strcasecmp(name
, "CUPS-Add-Class"))
2104 return (IPP_OP_CUPS_ADD_MODIFY_CLASS
);
2106 if (!_cups_strcasecmp(name
, "CUPS-Add-Printer"))
2107 return (IPP_OP_CUPS_ADD_MODIFY_PRINTER
);
2109 return (IPP_OP_CUPS_INVALID
);
2114 * 'ippPort()' - Return the default IPP port number.
2117 int /* O - Port number */
2120 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2123 DEBUG_puts("ippPort()");
2128 DEBUG_printf(("1ippPort: Returning %d...", cg
->ipp_port
));
2130 return (cg
->ipp_port
);
2135 * 'ippSetPort()' - Set the default port number.
2139 ippSetPort(int p
) /* I - Port number to use */
2141 DEBUG_printf(("ippSetPort(p=%d)", p
));
2143 _cupsGlobals()->ipp_port
= p
;
2148 * 'ippStateString()' - Return the name corresponding to a state value.
2150 * @since CUPS 2.0/OS 10.10@
2153 const char * /* O - State name */
2154 ippStateString(ipp_state_t state
) /* I - State value */
2156 if (state
>= IPP_STATE_ERROR
&& state
<= IPP_STATE_DATA
)
2157 return (ipp_states
[state
- IPP_STATE_ERROR
]);
2164 * 'ippTagString()' - Return the tag name corresponding to a tag value.
2166 * The returned names are defined in RFC 2911 and 3382.
2168 * @since CUPS 1.4/OS X 10.6@
2171 const char * /* O - Tag name */
2172 ippTagString(ipp_tag_t tag
) /* I - Tag value */
2174 tag
&= IPP_TAG_CUPS_MASK
;
2176 if (tag
< (ipp_tag_t
)(sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])))
2177 return (ipp_tag_names
[tag
]);
2184 * 'ippTagValue()' - Return the tag value corresponding to a tag name.
2186 * The tag names are defined in RFC 2911 and 3382.
2188 * @since CUPS 1.4/OS X 10.6@
2191 ipp_tag_t
/* O - Tag value */
2192 ippTagValue(const char *name
) /* I - Tag name */
2194 size_t i
; /* Looping var */
2197 for (i
= 0; i
< (sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])); i
++)
2198 if (!_cups_strcasecmp(name
, ipp_tag_names
[i
]))
2199 return ((ipp_tag_t
)i
);
2201 if (!_cups_strcasecmp(name
, "operation"))
2202 return (IPP_TAG_OPERATION
);
2203 else if (!_cups_strcasecmp(name
, "job"))
2204 return (IPP_TAG_JOB
);
2205 else if (!_cups_strcasecmp(name
, "printer"))
2206 return (IPP_TAG_PRINTER
);
2207 else if (!_cups_strcasecmp(name
, "unsupported"))
2208 return (IPP_TAG_UNSUPPORTED_GROUP
);
2209 else if (!_cups_strcasecmp(name
, "subscription"))
2210 return (IPP_TAG_SUBSCRIPTION
);
2211 else if (!_cups_strcasecmp(name
, "event"))
2212 return (IPP_TAG_EVENT_NOTIFICATION
);
2213 else if (!_cups_strcasecmp(name
, "language"))
2214 return (IPP_TAG_LANGUAGE
);
2215 else if (!_cups_strcasecmp(name
, "mimetype"))
2216 return (IPP_TAG_MIMETYPE
);
2217 else if (!_cups_strcasecmp(name
, "name"))
2218 return (IPP_TAG_NAME
);
2219 else if (!_cups_strcasecmp(name
, "text"))
2220 return (IPP_TAG_TEXT
);
2221 else if (!_cups_strcasecmp(name
, "begCollection"))
2222 return (IPP_TAG_BEGIN_COLLECTION
);
2224 return (IPP_TAG_ZERO
);
2229 * 'ipp_col_string()' - Convert a collection to a string.
2232 static size_t /* O - Number of bytes */
2233 ipp_col_string(ipp_t
*col
, /* I - Collection attribute */
2234 char *buffer
, /* I - Buffer or NULL */
2235 size_t bufsize
) /* I - Size of buffer */
2237 char *bufptr
, /* Position in buffer */
2238 *bufend
, /* End of buffer */
2239 prefix
= '{', /* Prefix character */
2240 temp
[256]; /* Temporary string */
2241 ipp_attribute_t
*attr
; /* Current member attribute */
2253 bufend
= buffer
+ bufsize
- 1;
2255 for (attr
= col
->attrs
; attr
; attr
= attr
->next
)
2260 if (buffer
&& bufptr
< bufend
)
2265 if (buffer
&& bufptr
< bufend
)
2266 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%s=", attr
->name
);
2268 bufptr
+= strlen(attr
->name
) + 1;
2270 if (buffer
&& bufptr
< bufend
)
2271 bufptr
+= ippAttributeString(attr
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
2273 bufptr
+= ippAttributeString(attr
, temp
, sizeof(temp
));
2278 if (buffer
&& bufptr
< bufend
)
2283 if (buffer
&& bufptr
< bufend
)
2287 return ((size_t)(bufptr
- buffer
));