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"
83 * const ipp_status_480s
[] = /* Vendor client errors */
102 /* 0x0490 - 0x049F */
115 "cups-error-account-info-needed",
116 "cups-error-account-closed",
117 "cups-error-account-limit-reached",
118 "cups-error-account-authorization-failed"
120 * const ipp_status_500s
[] = /* Server errors */
122 "server-error-internal-error",
123 "server-error-operation-not-supported",
124 "server-error-service-unavailable",
125 "server-error-version-not-supported",
126 "server-error-device-error",
127 "server-error-temporary-error",
128 "server-error-not-accepting-jobs",
130 "server-error-job-canceled",
131 "server-error-multiple-document-jobs-not-supported",
132 "server-error-printer-is-deactivated",
133 "server-error-too-many-jobs",
134 "server-error-too-many-documents"
136 * const ipp_status_1000s
[] = /* CUPS internal */
138 "cups-authentication-canceled",
140 "cups-upgrade-required"
142 static const char * const ipp_std_ops
[] =
144 /* 0x0000 - 0x000f */
154 "Get-Job-Attributes",
156 "Get-Printer-Attributes",
162 /* 0x0010 - 0x001f */
166 "Set-Printer-Attributes",
167 "Set-Job-Attributes",
168 "Get-Printer-Supported-Values",
169 "Create-Printer-Subscriptions",
170 "Create-Job-Subscriptions",
171 "Get-Subscription-Attributes",
173 "Renew-Subscription",
174 "Cancel-Subscription",
176 "(Send-Notifications)",
177 "(Get-Resource-Attributes)",
178 "(Get-Resource-Data)",
180 /* 0x0020 - 0x002f */
182 "(Get-Printer-Support-Files)",
185 "Pause-Printer-After-Current-Job",
187 "Release-Held-New-Jobs",
188 "Deactivate-Printer",
194 "Cancel-Current-Job",
195 "Suspend-Current-Job",
198 /* 0x0030 - 0x003f */
200 "Schedule-Job-After",
203 "Get-Document-Attributes",
206 "Set-Document-Attributes",
213 "Send-Hardcopy-Document",
214 "Acknowledge-Document",
216 /* 0x0040 - 0x004a */
217 "Acknowledge-Identify-Printer",
221 "Get-Output-Device-Attributes",
222 "Update-Active-Jobs",
223 "Deregister-Output-Device",
224 "Update-Document-Status",
226 "Update-Output-Device-Attributes",
227 "Get-Next-Document-Data"
229 * const ipp_cups_ops
[] =
233 "CUPS-Add-Modify-Printer",
234 "CUPS-Delete-Printer",
236 "CUPS-Add-Modify-Class",
244 "CUPS-Authenticate-Job",
247 * const ipp_cups_ops2
[] =
251 * const ipp_tag_names
[] =
252 { /* Value/group tag names */
254 "operation-attributes-tag",
256 "job-attributes-tag", /* 0x02 */
257 "end-of-attributes-tag",
259 "printer-attributes-tag",
261 "unsupported-attributes-tag",
263 "subscription-attributes-tag",
265 "event-notification-attributes-tag",
267 "(resource-attributes-tag)",
269 "document-attributes-tag",
277 "unsupported", /* 0x10 */
278 "default", /* 0x11 */
279 "unknown", /* 0x12 */
280 "no-value", /* 0x13 */
282 "not-settable", /* 0x15 */
283 "delete-attribute", /* 0x16 */
284 "admin-define", /* 0x17 */
294 "integer", /* 0x21 */
295 "boolean", /* 0x22 */
309 "octetString", /* 0x30 */
310 "dateTime", /* 0x31 */
311 "resolution", /* 0x32 */
312 "rangeOfInteger", /* 0x33 */
313 "collection", /* 0x34 */
314 "textWithLanguage", /* 0x35 */
315 "nameWithLanguage", /* 0x36 */
316 "endCollection", /* 0x37 */
326 "textWithoutLanguage",/* 0x41 */
327 "nameWithoutLanguage",/* 0x42 */
329 "keyword", /* 0x44 */
331 "uriScheme", /* 0x46 */
332 "charset", /* 0x47 */
333 "naturalLanguage", /* 0x48 */
334 "mimeMediaType", /* 0x49 */
335 "memberAttrName" /* 0x4a */
337 static const char * const ipp_document_states
[] =
338 { /* document-state-enums */
342 "processing-stopped", /* IPPSIX */
347 * const ipp_finishings
[] =
348 { /* finishings enums */
361 "coat", /* Finishings 2.0 */
362 "laminate", /* Finishings 2.0 */
367 "staple-bottom-left",
369 "staple-bottom-right",
373 "edge-stitch-bottom",
377 "staple-dual-bottom",
378 "staple-triple-left", /* Finishings 2.0 */
379 "staple-triple-top", /* Finishings 2.0 */
380 "staple-triple-right",/* Finishings 2.0 */
381 "staple-triple-bottom",/* Finishings 2.0 */
407 "trim-after-documents",
416 "punch-top-left", /* Finishings 2.0 */
417 "punch-bottom-left", /* Finishings 2.0 */
418 "punch-top-right", /* Finishings 2.0 */
419 "punch-bottom-right", /* Finishings 2.0 */
420 "punch-dual-left", /* Finishings 2.0 */
421 "punch-dual-top", /* Finishings 2.0 */
422 "punch-dual-right", /* Finishings 2.0 */
423 "punch-dual-bottom", /* Finishings 2.0 */
424 "punch-triple-left", /* Finishings 2.0 */
425 "punch-triple-top", /* Finishings 2.0 */
426 "punch-triple-right", /* Finishings 2.0 */
427 "punch-triple-bottom",/* Finishings 2.0 */
428 "punch-quad-left", /* Finishings 2.0 */
429 "punch-quad-top", /* Finishings 2.0 */
430 "punch-quad-right", /* Finishings 2.0 */
431 "punch-quad-bottom", /* Finishings 2.0 */
436 "fold-accordian", /* Finishings 2.0 */
437 "fold-double-gate", /* Finishings 2.0 */
438 "fold-gate", /* Finishings 2.0 */
439 "fold-half", /* Finishings 2.0 */
440 "fold-half-z", /* Finishings 2.0 */
441 "fold-left-gate", /* Finishings 2.0 */
442 "fold-letter", /* Finishings 2.0 */
443 "fold-parallel", /* Finishings 2.0 */
444 "fold-poster", /* Finishings 2.0 */
445 "fold-right-gate", /* Finishings 2.0 */
446 "fold-z" /* Finishings 2.0 */
448 * const ipp_finishings_vendor
[] =
450 /* 0x40000000 to 0x4000000F */
467 /* 0x40000010 to 0x4000001F */
484 /* 0x40000020 to 0x4000002F */
501 /* 0x40000030 to 0x4000003F */
518 /* 0x40000040 - 0x4000004F */
525 "cups-punch-top-left",
526 "cups-punch-bottom-left",
527 "cups-punch-top-right",
528 "cups-punch-bottom-right",
529 "cups-punch-dual-left",
530 "cups-punch-dual-top",
531 "cups-punch-dual-right",
532 "cups-punch-dual-bottom",
533 "cups-punch-triple-left",
534 "cups-punch-triple-top",
535 /* 0x40000050 - 0x4000005F */
536 "cups-punch-triple-right",
537 "cups-punch-triple-bottom",
538 "cups-punch-quad-left",
539 "cups-punch-quad-top",
540 "cups-punch-quad-right",
541 "cups-punch-quad-bottom",
546 "cups-fold-accordian",
547 "cups-fold-double-gate",
551 "cups-fold-left-gate",
552 /* 0x40000060 - 0x40000064 */
554 "cups-fold-parallel",
556 "cups-fold-right-gate",
559 * const ipp_job_collation_types
[] =
560 { /* job-collation-type enums */
562 "collated-documents",
563 "uncollated-documents"
565 * const ipp_job_states
[] =
566 { /* job-state enums */
570 "processing-stopped",
575 * const ipp_orientation_requesteds
[] =
576 { /* orientation-requested enums */
583 * const ipp_print_qualities
[] =
584 { /* print-quality enums */
589 * const ipp_printer_states
[] =
590 { /* printer-state enums */
601 static size_t ipp_col_string(ipp_t
*col
, char *buffer
, size_t bufsize
);
605 * 'ippAttributeString()' - Convert the attribute's value to a string.
607 * Returns the number of bytes that would be written, not including the
608 * trailing nul. The buffer pointer can be NULL to get the required length,
609 * just like (v)snprintf.
611 * @since CUPS 1.6/OS X 10.8@
614 size_t /* O - Number of bytes less nul */
616 ipp_attribute_t
*attr
, /* I - Attribute */
617 char *buffer
, /* I - String buffer or NULL */
618 size_t bufsize
) /* I - Size of string buffer */
620 int i
; /* Looping var */
621 char *bufptr
, /* Pointer into buffer */
622 *bufend
, /* End of buffer */
623 temp
[256]; /* Temporary string */
624 const char *ptr
, /* Pointer into string */
625 *end
; /* Pointer to end of string */
626 _ipp_value_t
*val
; /* Current value */
629 if (!attr
|| !attr
->name
)
639 bufend
= buffer
+ bufsize
- 1;
643 for (i
= attr
->num_values
, val
= attr
->values
; i
> 0; i
--, val
++)
645 if (val
> attr
->values
)
647 if (buffer
&& bufptr
< bufend
)
653 switch (attr
->value_tag
& ~IPP_TAG_CUPS_CONST
)
656 ptr
= ippEnumString(attr
->name
, val
->integer
);
658 if (buffer
&& bufptr
< bufend
)
659 strlcpy(bufptr
, ptr
, (size_t)(bufend
- bufptr
+ 1));
661 bufptr
+= strlen(ptr
);
664 case IPP_TAG_INTEGER
:
665 if (buffer
&& bufptr
< bufend
)
666 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d", val
->integer
);
668 bufptr
+= snprintf(temp
, sizeof(temp
), "%d", val
->integer
);
671 case IPP_TAG_BOOLEAN
:
672 if (buffer
&& bufptr
< bufend
)
673 strlcpy(bufptr
, val
->boolean
? "true" : "false", (size_t)(bufend
- bufptr
+ 1));
675 bufptr
+= val
->boolean
? 4 : 5;
679 if (buffer
&& bufptr
< bufend
)
680 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d-%d", val
->range
.lower
, val
->range
.upper
);
682 bufptr
+= snprintf(temp
, sizeof(temp
), "%d-%d", val
->range
.lower
, val
->range
.upper
);
685 case IPP_TAG_RESOLUTION
:
686 if (val
->resolution
.xres
== val
->resolution
.yres
)
688 if (buffer
&& bufptr
< bufend
)
689 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%d%s", val
->resolution
.xres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
691 bufptr
+= snprintf(temp
, sizeof(temp
), "%d%s", val
->resolution
.xres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
693 else if (buffer
&& bufptr
< bufend
)
694 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");
696 bufptr
+= snprintf(temp
, sizeof(temp
), "%dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
, val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
701 unsigned year
; /* Year */
703 year
= ((unsigned)val
->date
[0] << 8) + (unsigned)val
->date
[1];
705 if (val
->date
[9] == 0 && val
->date
[10] == 0)
706 snprintf(temp
, sizeof(temp
), "%04u-%02u-%02uT%02u:%02u:%02uZ",
707 year
, val
->date
[2], val
->date
[3], val
->date
[4],
708 val
->date
[5], val
->date
[6]);
710 snprintf(temp
, sizeof(temp
),
711 "%04u-%02u-%02uT%02u:%02u:%02u%c%02u%02u",
712 year
, val
->date
[2], val
->date
[3], val
->date
[4],
713 val
->date
[5], val
->date
[6], val
->date
[8], val
->date
[9],
716 if (buffer
&& bufptr
< bufend
)
717 strlcpy(bufptr
, temp
, (size_t)(bufend
- bufptr
+ 1));
719 bufptr
+= strlen(temp
);
725 case IPP_TAG_KEYWORD
:
726 case IPP_TAG_CHARSET
:
728 case IPP_TAG_URISCHEME
:
729 case IPP_TAG_MIMETYPE
:
730 case IPP_TAG_LANGUAGE
:
731 case IPP_TAG_TEXTLANG
:
732 case IPP_TAG_NAMELANG
:
733 if (!val
->string
.text
)
736 for (ptr
= val
->string
.text
; *ptr
; ptr
++)
738 if (*ptr
== '\\' || *ptr
== '\"' || *ptr
== '[')
740 if (buffer
&& bufptr
< bufend
)
745 if (buffer
&& bufptr
< bufend
)
750 if (val
->string
.language
)
753 * Add "[language]" to end of string...
756 if (buffer
&& bufptr
< bufend
)
760 if (buffer
&& bufptr
< bufend
)
761 strlcpy(bufptr
, val
->string
.language
, (size_t)(bufend
- bufptr
));
762 bufptr
+= strlen(val
->string
.language
);
764 if (buffer
&& bufptr
< bufend
)
770 case IPP_TAG_BEGIN_COLLECTION
:
771 if (buffer
&& bufptr
< bufend
)
772 bufptr
+= ipp_col_string(val
->collection
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
774 bufptr
+= ipp_col_string(val
->collection
, NULL
, 0);
777 case IPP_TAG_STRING
:
778 for (ptr
= val
->unknown
.data
, end
= ptr
+ val
->unknown
.length
;
781 if (*ptr
== '\\' || _cups_isspace(*ptr
))
783 if (buffer
&& bufptr
< bufend
)
787 if (buffer
&& bufptr
< bufend
)
791 else if (!isprint(*ptr
& 255))
793 if (buffer
&& bufptr
< bufend
)
794 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "\\%03o", *ptr
& 255);
796 bufptr
+= snprintf(temp
, sizeof(temp
), "\\%03o", *ptr
& 255);
800 if (buffer
&& bufptr
< bufend
)
808 ptr
= ippTagString(attr
->value_tag
);
809 if (buffer
&& bufptr
< bufend
)
810 strlcpy(bufptr
, ptr
, (size_t)(bufend
- bufptr
+ 1));
811 bufptr
+= strlen(ptr
);
816 if (buffer
&& bufptr
< bufend
)
821 return ((size_t)(bufptr
- buffer
));
826 * 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
827 * given requested-attributes attribute.
829 * This function creates a (sorted) CUPS array of attribute names matching the
830 * list of "requested-attribute" values supplied in an IPP request. All IANA-
831 * registered values are supported in addition to the CUPS IPP extension
834 * The @code request@ parameter specifies the request message that was read from
837 * @code NULL@ is returned if all attributes should be returned. Otherwise, the
838 * result is a sorted array of attribute names, where @code cupsArrayFind(array,
839 * "attribute-name")@ will return a non-NULL pointer. The array must be freed
840 * using the @code cupsArrayDelete@ function.
842 * @since CUPS 1.7/OS X 10.9@
845 cups_array_t
* /* O - CUPS array or @code NULL@ if all */
846 ippCreateRequestedArray(ipp_t
*request
) /* I - IPP request */
848 int i
, j
, /* Looping vars */
849 count
, /* Number of values */
850 added
; /* Was name added? */
851 ipp_attribute_t
*requested
; /* requested-attributes attribute */
852 cups_array_t
*ra
; /* Requested attributes array */
853 const char *value
; /* Current value */
854 /* The following lists come from the current IANA IPP registry of attributes */
855 static const char * const document_description
[] =
856 { /* document-description group */
860 "cover-front-actual",
861 "current-page-order",
862 "date-time-at-completed",
863 "date-time-at-creation",
864 "date-time-at-processing",
865 "detailed-status-messages",
866 "document-access-errors",
868 "document-digital-signature",
870 "document-format-details",
871 "document-format-detected",
872 "document-format-version",
873 "document-format-version-detected",
879 "document-natural-language",
881 "document-printer-uri",
883 "document-state-message",
884 "document-state-reasons",
889 "finishings-col-actual",
890 "force-front-side-actual",
891 "imposition-template-actual",
893 "impressions-completed",
894 "impressions-completed-current-copy",
895 "insert-sheet-actual",
897 "k-octets-processed",
901 "media-input-tray-check-actual",
903 "media-sheets-completed",
906 "orientation-requested-actual",
908 "output-device-assigned",
910 "page-delivery-actual",
911 "page-order-received-actual",
912 "page-ranges-actual",
915 "pages-completed-current-copy",
916 "presentation-direction-number-up-actual",
917 "print-color-mode-actual",
918 "print-content-optimize-actual",
919 "print-quality-actual",
920 "print-rendering-intent-actual",
921 "print-scaling-actual", /* IPP Paid Printing */
922 "printer-resolution-actual",
924 "separator-sheets-actual",
925 "sheet-completed-copy-number",
929 "time-at-processing",
930 "x-image-position-actual",
931 "x-image-shift-actual",
932 "x-side1-image-shift-actual",
933 "x-side2-image-shift-actual",
934 "y-image-position-actual",
935 "y-image-shift-actual",
936 "y-side1-image-shift-actual",
937 "y-side2-image-shift-actual"
939 static const char * const document_template
[] =
940 { /* document-template group */
945 "cover-back-default",
946 "cover-back-supported",
948 "cover-front-default",
949 "cover-front-supported",
951 "feed-orientation-default",
952 "feed-orientation-supported",
955 "finishings-col-default",
956 "finishings-col-supported",
957 "finishings-default",
958 "finishings-supported",
959 "font-name-requested",
960 "font-name-requested-default",
961 "font-name-requested-supported",
962 "font-size-requested",
963 "font-size-requested-default",
964 "font-size-requested-supported",
966 "force-front-side-default",
967 "force-front-side-supported",
968 "imposition-template",
969 "imposition-template-default",
970 "imposition-template-supported",
971 "insert-after-page-number-supported",
972 "insert-count-supported",
974 "insert-sheet-default",
975 "insert-sheet-supported",
976 "max-stitching-locations-supported",
978 "media-back-coating-supported",
979 "media-bottom-margin-supported",
982 "media-col-supported",
983 "media-color-supported",
985 "media-front-coating-supported",
986 "media-grain-supported",
987 "media-hole-count-supported",
988 "media-info-supported",
989 "media-input-tray-check",
990 "media-input-tray-check-default",
991 "media-input-tray-check-supported",
992 "media-key-supported",
993 "media-left-margin-supported",
994 "media-order-count-supported",
995 "media-pre-printed-supported",
996 "media-recycled-supported",
997 "media-right-margin-supported",
998 "media-size-supported",
999 "media-source-supported",
1001 "media-thickness-supported",
1002 "media-top-margin-supported",
1003 "media-type-supported",
1004 "media-weight-metric-supported",
1005 "multiple-document-handling",
1006 "multiple-document-handling-default",
1007 "multiple-document-handling-supported",
1009 "number-up-default",
1010 "number-up-supported",
1011 "orientation-requested",
1012 "orientation-requested-default",
1013 "orientation-requested-supported",
1014 "output-mode", /* CUPS extension */
1015 "output-mode-default", /* CUPS extension */
1016 "output-mode-supported", /* CUPS extension */
1018 "overrides-supported",
1020 "page-delivery-default",
1021 "page-delivery-supported",
1022 "page-order-received",
1023 "page-order-received-default",
1024 "page-order-received-supported",
1026 "page-ranges-supported",
1028 "pages-per-subset-supported",
1030 "pdl-init-file-default",
1031 "pdl-init-file-entry-supported",
1032 "pdl-init-file-location-supported",
1033 "pdl-init-file-name-subdirectory-supported",
1034 "pdl-init-file-name-supported",
1035 "pdl-init-file-supported",
1036 "presentation-direction-number-up",
1037 "presentation-direction-number-up-default",
1038 "presentation-direction-number-up-supported",
1040 "print-color-mode-default",
1041 "print-color-mode-supported",
1042 "print-content-optimize",
1043 "print-content-optimize-default",
1044 "print-content-optimize-supported",
1046 "print-quality-default",
1047 "print-quality-supported",
1048 "print-rendering-intent",
1049 "print-rendering-intent-default",
1050 "print-rendering-intent-supported",
1051 "print-scaling", /* IPP Paid Printing */
1052 "print-scaling-default", /* IPP Paid Printing */
1053 "print-scaling-supported", /* IPP Paid Printing */
1054 "printer-resolution",
1055 "printer-resolution-default",
1056 "printer-resolution-supported",
1058 "separator-sheets-default",
1059 "separator-sheets-supported",
1061 "sheet-collate-default",
1062 "sheet-collate-supported",
1066 "stitching-locations-supported",
1067 "stitching-offset-supported",
1069 "x-image-position-default",
1070 "x-image-position-supported",
1072 "x-image-shift-default",
1073 "x-image-shift-supported",
1074 "x-side1-image-shift",
1075 "x-side1-image-shift-default",
1076 "x-side1-image-shift-supported",
1077 "x-side2-image-shift",
1078 "x-side2-image-shift-default",
1079 "x-side2-image-shift-supported",
1081 "y-image-position-default",
1082 "y-image-position-supported",
1084 "y-image-shift-default",
1085 "y-image-shift-supported",
1086 "y-side1-image-shift",
1087 "y-side1-image-shift-default",
1088 "y-side1-image-shift-supported",
1089 "y-side2-image-shift",
1090 "y-side2-image-shift-default",
1091 "y-side2-image-shift-supported"
1093 static const char * const job_description
[] =
1094 { /* job-description group */
1095 "compression-supplied",
1097 "cover-back-actual",
1098 "cover-front-actual",
1099 "current-page-order",
1100 "date-time-at-completed",
1101 "date-time-at-creation",
1102 "date-time-at-processing",
1103 "destination-statuses",
1104 "document-charset-supplied",
1105 "document-digital-signature-supplied",
1106 "document-format-details-supplied",
1107 "document-format-supplied",
1108 "document-message-supplied",
1109 "document-metadata",
1110 "document-name-supplied",
1111 "document-natural-language-supplied",
1112 "document-overrides-actual",
1114 "finishings-actual",
1115 "finishings-col-actual",
1116 "force-front-side-actual",
1117 "imposition-template-actual",
1118 "impressions-completed-current-copy",
1119 "insert-sheet-actual",
1120 "job-account-id-actual",
1121 "job-accounting-sheets-actual",
1122 "job-accounting-user-id-actual",
1123 "job-attribute-fidelity",
1124 "job-charge-info", /* CUPS extension */
1125 "job-collation-type",
1126 "job-collation-type-actual",
1127 "job-copies-actual",
1128 "job-cover-back-actual",
1129 "job-cover-front-actual",
1130 "job-detailed-status-message",
1131 "job-document-access-errors",
1132 "job-error-sheet-actual",
1133 "job-finishings-actual",
1134 "job-finishings-col-actual",
1135 "job-hold-until-actual",
1138 "job-impressions-completed",
1140 "job-k-octets-processed",
1141 "job-mandatory-attributes",
1142 "job-media-progress", /* CUPS extension */
1144 "job-media-sheets-completed",
1145 "job-message-from-operator",
1148 "job-originating-host-name", /* CUPS extension */
1149 "job-originating-user-name",
1150 "job-originating-user-uri",
1152 "job-pages-completed",
1153 "job-pages-completed-current-copy",
1154 "job-printer-state-message", /* CUPS extension */
1155 "job-printer-state-reasons", /* CUPS extension */
1156 "job-printer-up-time",
1158 "job-priority-actual",
1159 "job-save-printer-make-and-model",
1160 "job-sheet-message-actual",
1161 "job-sheets-actual",
1162 "job-sheets-col-actual",
1164 "job-state-message",
1165 "job-state-reasons",
1170 "media-check-input-tray-actual",
1171 "multiple-document-handling-actual",
1172 "number-of-documents",
1173 "number-of-intervening-jobs",
1175 "orientation-requested-actual",
1176 "original-requesting-user-name",
1177 "output-bin-actual",
1178 "output-device-assigned",
1180 "page-delivery-actual",
1181 "page-order-received-actual",
1182 "page-ranges-actual",
1183 "presentation-direction-number-up-actual",
1184 "print-color-mode-actual",
1185 "print-content-optimize-actual",
1186 "print-quality-actual",
1187 "print-rendering-intent-actual",
1188 "print-scaling-actual", /* IPP Paid Printing */
1189 "printer-resolution-actual",
1190 "separator-sheets-actual",
1191 "sheet-collate-actual",
1192 "sheet-completed-copy-number",
1193 "sheet-completed-document-number",
1195 "time-at-completed",
1197 "time-at-processing",
1199 "x-image-position-actual",
1200 "x-image-shift-actual",
1201 "x-side1-image-shift-actual",
1202 "x-side2-image-shift-actual",
1203 "y-image-position-actual",
1204 "y-image-shift-actual",
1205 "y-side1-image-shift-actual",
1206 "y-side2-image-shift-actual"
1208 static const char * const job_template
[] =
1209 { /* job-template group */
1210 "confirmation-sheet-print", /* IPP FaxOut */
1211 "confirmation-sheet-print-default",
1216 "cover-back-default",
1217 "cover-back-supported",
1219 "cover-front-default",
1220 "cover-front-supported",
1221 "cover-sheet-info", /* IPP FaxOut */
1222 "cover-sheet-info-default",
1223 "cover-sheet-info-supported",
1224 "destination-uri-schemes-supported",/* IPP FaxOut */
1225 "destination-uris", /* IPP FaxOut */
1226 "destination-uris-supported",
1228 "feed-orientation-default",
1229 "feed-orientation-supported",
1232 "finishings-col-default",
1233 "finishings-col-supported",
1234 "finishings-default",
1235 "finishings-supported",
1236 "font-name-requested",
1237 "font-name-requested-default",
1238 "font-name-requested-supported",
1239 "font-size-requested",
1240 "font-size-requested-default",
1241 "font-size-requested-supported",
1243 "force-front-side-default",
1244 "force-front-side-supported",
1245 "imposition-template",
1246 "imposition-template-default",
1247 "imposition-template-supported",
1248 "insert-after-page-number-supported",
1249 "insert-count-supported",
1251 "insert-sheet-default",
1252 "insert-sheet-supported",
1254 "job-account-id-default",
1255 "job-account-id-supported",
1256 "job-accounting-sheets"
1257 "job-accounting-sheets-default"
1258 "job-accounting-sheets-supported"
1259 "job-accounting-user-id",
1260 "job-accounting-user-id-default",
1261 "job-accounting-user-id-supported",
1263 "job-copies-default",
1264 "job-copies-supported",
1266 "job-cover-back-default",
1267 "job-cover-back-supported",
1269 "job-cover-front-default",
1270 "job-cover-front-supported",
1271 "job-delay-output-until",
1272 "job-delay-output-until-default",
1273 "job-delay-output-until-supported",
1274 "job-delay-output-until-time",
1275 "job-delay-output-until-time-default",
1276 "job-delay-output-until-time-supported",
1278 "job-error-action-default",
1279 "job-error-action-supported",
1281 "job-error-sheet-default",
1282 "job-error-sheet-supported",
1284 "job-finishings-col",
1285 "job-finishings-col-default",
1286 "job-finishings-col-supported",
1287 "job-finishings-default",
1288 "job-finishings-supported",
1290 "job-hold-until-default",
1291 "job-hold-until-supported",
1292 "job-hold-until-time",
1293 "job-hold-until-time-default",
1294 "job-hold-until-time-supported",
1295 "job-message-to-operator",
1296 "job-message-to-operator-default",
1297 "job-message-to-operator-supported",
1299 "job-phone-number-default",
1300 "job-phone-number-supported",
1302 "job-priority-default",
1303 "job-priority-supported",
1304 "job-recipient-name",
1305 "job-recipient-name-default",
1306 "job-recipient-name-supported",
1307 "job-save-disposition",
1308 "job-save-disposition-default",
1309 "job-save-disposition-supported",
1312 "job-sheets-col-default",
1313 "job-sheets-col-supported",
1314 "job-sheets-default",
1315 "job-sheets-supported",
1316 "logo-uri-schemes-supported",
1317 "max-save-info-supported",
1318 "max-stitching-locations-supported",
1320 "media-back-coating-supported",
1321 "media-bottom-margin-supported",
1323 "media-col-default",
1324 "media-col-supported",
1325 "media-color-supported",
1327 "media-front-coating-supported",
1328 "media-grain-supported",
1329 "media-hole-count-supported",
1330 "media-info-supported",
1331 "media-input-tray-check",
1332 "media-input-tray-check-default",
1333 "media-input-tray-check-supported",
1334 "media-key-supported",
1335 "media-left-margin-supported",
1336 "media-order-count-supported",
1337 "media-pre-printed-supported",
1338 "media-recycled-supported",
1339 "media-right-margin-supported",
1340 "media-size-supported",
1341 "media-source-supported",
1343 "media-thickness-supported",
1344 "media-top-margin-supported",
1345 "media-type-supported",
1346 "media-weight-metric-supported",
1347 "multiple-document-handling",
1348 "multiple-document-handling-default",
1349 "multiple-document-handling-supported",
1350 "number-of-retries", /* IPP FaxOut */
1351 "number-of-retries-default",
1352 "number-of-retries-supported",
1354 "number-up-default",
1355 "number-up-supported",
1356 "orientation-requested",
1357 "orientation-requested-default",
1358 "orientation-requested-supported",
1360 "output-bin-default",
1361 "output-bin-supported",
1363 "output-device-default",
1364 "output-device-supported",
1365 "output-mode", /* CUPS extension */
1366 "output-mode-default", /* CUPS extension */
1367 "output-mode-supported", /* CUPS extension */
1369 "overrides-supported",
1371 "page-delivery-default",
1372 "page-delivery-supported",
1373 "page-order-received",
1374 "page-order-received-default",
1375 "page-order-received-supported",
1377 "page-ranges-supported",
1379 "pages-per-subset-supported",
1381 "pdl-init-file-default",
1382 "pdl-init-file-entry-supported",
1383 "pdl-init-file-location-supported",
1384 "pdl-init-file-name-subdirectory-supported",
1385 "pdl-init-file-name-supported",
1386 "pdl-init-file-supported",
1387 "presentation-direction-number-up",
1388 "presentation-direction-number-up-default",
1389 "presentation-direction-number-up-supported",
1391 "print-color-mode-default",
1392 "print-color-mode-supported",
1393 "print-content-optimize",
1394 "print-content-optimize-default",
1395 "print-content-optimize-supported",
1397 "print-quality-default",
1398 "print-quality-supported",
1399 "print-rendering-intent",
1400 "print-rendering-intent-default",
1401 "print-rendering-intent-supported",
1402 "print-scaling", /* IPP Paid Printing */
1403 "print-scaling-default", /* IPP Paid Printing */
1404 "print-scaling-supported", /* IPP Paid Printing */
1405 "printer-resolution",
1406 "printer-resolution-default",
1407 "printer-resolution-supported",
1409 "proof-print-default",
1410 "proof-print-supported",
1411 "retry-interval", /* IPP FaxOut */
1412 "retry-interval-default",
1413 "retry-interval-supported",
1414 "retry-timeout", /* IPP FaxOut */
1415 "retry-timeout-default",
1416 "retry-timeout-supported",
1417 "save-disposition-supported",
1418 "save-document-format-default",
1419 "save-document-format-supported",
1420 "save-location-default",
1421 "save-location-supported",
1422 "save-name-subdirectory-supported",
1423 "save-name-supported",
1425 "separator-sheets-default",
1426 "separator-sheets-supported",
1428 "sheet-collate-default",
1429 "sheet-collate-supported",
1433 "stitching-locations-supported",
1434 "stitching-offset-supported",
1436 "x-image-position-default",
1437 "x-image-position-supported",
1439 "x-image-shift-default",
1440 "x-image-shift-supported",
1441 "x-side1-image-shift",
1442 "x-side1-image-shift-default",
1443 "x-side1-image-shift-supported",
1444 "x-side2-image-shift",
1445 "x-side2-image-shift-default",
1446 "x-side2-image-shift-supported",
1448 "y-image-position-default",
1449 "y-image-position-supported",
1451 "y-image-shift-default",
1452 "y-image-shift-supported",
1453 "y-side1-image-shift",
1454 "y-side1-image-shift-default",
1455 "y-side1-image-shift-supported",
1456 "y-side2-image-shift",
1457 "y-side2-image-shift-default",
1458 "y-side2-image-shift-supported"
1460 static const char * const printer_description
[] =
1461 { /* printer-description group */
1462 "auth-info-required", /* CUPS extension */
1463 "charset-configured",
1464 "charset-supported",
1466 "compression-supported",
1467 "device-service-count",
1468 "device-uri", /* CUPS extension */
1470 "document-charset-default",
1471 "document-charset-supported",
1472 "document-creation-attributes-supported",
1473 "document-digital-signature-default",
1474 "document-digital-signature-supported",
1475 "document-format-default",
1476 "document-format-details-default",
1477 "document-format-details-supported",
1478 "document-format-supported",
1479 "document-format-varying-attributes",
1480 "document-format-version-default",
1481 "document-format-version-supported",
1482 "document-natural-language-default",
1483 "document-natural-language-supported",
1484 "document-password-supported",
1485 "generated-natural-language-supported",
1486 "identify-actions-default",
1487 "identify-actions-supported",
1488 "input-source-supported",
1489 "ipp-features-supported",
1490 "ipp-versions-supported",
1491 "ippget-event-life",
1492 "job-authorization-uri-supported", /* CUPS extension */
1493 "job-constraints-supported",
1494 "job-creation-attributes-supported",
1495 "job-finishings-col-ready",
1496 "job-finishings-ready",
1497 "job-ids-supported",
1498 "job-impressions-supported",
1499 "job-k-limit", /* CUPS extension */
1500 "job-k-octets-supported",
1501 "job-media-sheets-supported",
1502 "job-page-limit", /* CUPS extension */
1503 "job-password-encryption-supported",
1504 "job-password-supported",
1505 "job-quota-period", /* CUPS extension */
1506 "job-resolvers-supported",
1507 "job-settable-attributes-supported",
1508 "job-spooling-supported",
1509 "jpeg-k-octets-supported", /* CUPS extension */
1510 "jpeg-x-dimension-supported", /* CUPS extension */
1511 "jpeg-y-dimension-supported", /* CUPS extension */
1512 "landscape-orientation-requested-preferred",
1513 /* CUPS extension */
1514 "marker-change-time", /* CUPS extension */
1515 "marker-colors", /* CUPS extension */
1516 "marker-high-levels", /* CUPS extension */
1517 "marker-levels", /* CUPS extension */
1518 "marker-low-levels", /* CUPS extension */
1519 "marker-message", /* CUPS extension */
1520 "marker-names", /* CUPS extension */
1521 "marker-types", /* CUPS extension */
1524 "member-names", /* CUPS extension */
1525 "member-uris", /* CUPS extension */
1526 "multiple-destination-uris-supported",/* IPP FaxOut */
1527 "multiple-document-jobs-supported",
1528 "multiple-operation-time-out",
1529 "multiple-operation-time-out-action",
1530 "natural-language-configured",
1531 "operations-supported",
1533 "pages-per-minute-color",
1534 "pdf-k-octets-supported", /* CUPS extension */
1535 "pdf-versions-supported", /* CUPS extension */
1536 "pdl-override-supported",
1537 "port-monitor", /* CUPS extension */
1538 "port-monitor-supported", /* CUPS extension */
1539 "preferred-attributes-supported",
1541 "printer-alert-description",
1542 "printer-charge-info",
1543 "printer-charge-info-uri",
1544 "printer-commands", /* CUPS extension */
1545 "printer-current-time",
1546 "printer-detailed-status-messages",
1547 "printer-device-id",
1548 "printer-dns-sd-name", /* CUPS extension */
1549 "printer-driver-installer",
1550 "printer-fax-log-uri", /* IPP FaxOut */
1551 "printer-fax-modem-info", /* IPP FaxOut */
1552 "printer-fax-modem-name", /* IPP FaxOut */
1553 "printer-fax-modem-number", /* IPP FaxOut */
1554 "printer-firmware-name", /* PWG 5110.1 */
1555 "printer-firmware-patches", /* PWG 5110.1 */
1556 "printer-firmware-string-version", /* PWG 5110.1 */
1557 "printer-firmware-version", /* PWG 5110.1 */
1558 "printer-geo-location",
1559 "printer-get-attributes-supported",
1560 "printer-icc-profiles",
1563 "printer-input-tray", /* IPP JPS3 */
1564 "printer-is-accepting-jobs",
1565 "printer-is-shared", /* CUPS extension */
1566 "printer-kind", /* IPP Paid Printing */
1568 "printer-make-and-model",
1569 "printer-mandatory-job-attributes",
1570 "printer-message-date-time",
1571 "printer-message-from-operator",
1572 "printer-message-time",
1573 "printer-more-info",
1574 "printer-more-info-manufacturer",
1576 "printer-native-formats",
1577 "printer-organization",
1578 "printer-organizational-unit",
1579 "printer-output-tray", /* IPP JPS3 */
1580 "printer-settable-attributes-supported",
1582 "printer-state-change-date-time",
1583 "printer-state-change-time",
1584 "printer-state-message",
1585 "printer-state-reasons",
1587 "printer-supply-description",
1588 "printer-supply-info-uri",
1589 "printer-type", /* CUPS extension */
1591 "printer-uri-supported",
1593 "printer-xri-supported",
1594 "pwg-raster-document-resolution-supported",
1595 "pwg-raster-document-sheet-back",
1596 "pwg-raster-document-type-supported",
1598 "reference-uri-schemes-supported",
1599 "repertoire-supported",
1600 "requesting-user-name-allowed", /* CUPS extension */
1601 "requesting-user-name-denied", /* CUPS extension */
1602 "requesting-user-uri-supported",
1603 "subordinate-printers-supported",
1604 "urf-supported", /* CUPS extension */
1605 "uri-authentication-supported",
1606 "uri-security-supported",
1607 "user-defined-value-supported",
1608 "which-jobs-supported",
1609 "xri-authentication-supported",
1610 "xri-security-supported",
1611 "xri-uri-scheme-supported"
1613 static const char * const subscription_description
[] =
1614 { /* subscription-description group */
1616 "notify-lease-expiration-time",
1617 "notify-printer-up-time",
1618 "notify-printer-uri",
1619 "notify-sequence-number",
1620 "notify-subscriber-user-name",
1621 "notify-subscriber-user-uri",
1622 "notify-subscription-id",
1623 "subscriptions-uuid"
1625 static const char * const subscription_template
[] =
1626 { /* subscription-template group */
1627 "notify-attributes",
1628 "notify-attributes-supported",
1631 "notify-events-default",
1632 "notify-events-supported",
1633 "notify-lease-duration",
1634 "notify-lease-duration-default",
1635 "notify-lease-duration-supported",
1636 "notify-max-events-supported",
1637 "notify-natural-language",
1638 "notify-pull-method",
1639 "notify-pull-method-supported",
1640 "notify-recipient-uri",
1641 "notify-schemes-supported",
1642 "notify-time-interval",
1648 * Get the requested-attributes attribute...
1651 if ((requested
= ippFindAttribute(request
, "requested-attributes",
1652 IPP_TAG_KEYWORD
)) == NULL
)
1655 * The Get-Jobs operation defaults to "job-id" and "job-uri", all others
1656 * default to "all"...
1659 if (ippGetOperation(request
) == IPP_OP_GET_JOBS
)
1661 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1662 cupsArrayAdd(ra
, "job-id");
1663 cupsArrayAdd(ra
, "job-uri");
1672 * If the attribute contains a single "all" keyword, return NULL...
1675 count
= ippGetCount(requested
);
1676 if (count
== 1 && !strcmp(ippGetString(requested
, 0, NULL
), "all"))
1680 * Create an array using "strcmp" as the comparison function...
1683 ra
= cupsArrayNew((cups_array_func_t
)strcmp
, NULL
);
1685 for (i
= 0; i
< count
; i
++)
1688 value
= ippGetString(requested
, i
, NULL
);
1690 if (!strcmp(value
, "document-description") || !strcmp(value
, "all"))
1693 j
< (int)(sizeof(document_description
) /
1694 sizeof(document_description
[0]));
1696 cupsArrayAdd(ra
, (void *)document_description
[j
]);
1701 if (!strcmp(value
, "document-template") || !strcmp(value
, "all"))
1704 j
< (int)(sizeof(document_template
) / sizeof(document_template
[0]));
1706 cupsArrayAdd(ra
, (void *)document_template
[j
]);
1711 if (!strcmp(value
, "job-description") || !strcmp(value
, "all"))
1714 j
< (int)(sizeof(job_description
) / sizeof(job_description
[0]));
1716 cupsArrayAdd(ra
, (void *)job_description
[j
]);
1721 if (!strcmp(value
, "job-template") || !strcmp(value
, "all"))
1724 j
< (int)(sizeof(job_template
) / sizeof(job_template
[0]));
1726 cupsArrayAdd(ra
, (void *)job_template
[j
]);
1731 if (!strcmp(value
, "printer-description") || !strcmp(value
, "all"))
1734 j
< (int)(sizeof(printer_description
) /
1735 sizeof(printer_description
[0]));
1737 cupsArrayAdd(ra
, (void *)printer_description
[j
]);
1742 if (!strcmp(value
, "subscription-description") || !strcmp(value
, "all"))
1745 j
< (int)(sizeof(subscription_description
) /
1746 sizeof(subscription_description
[0]));
1748 cupsArrayAdd(ra
, (void *)subscription_description
[j
]);
1753 if (!strcmp(value
, "subscription-template") || !strcmp(value
, "all"))
1756 j
< (int)(sizeof(subscription_template
) /
1757 sizeof(subscription_template
[0]));
1759 cupsArrayAdd(ra
, (void *)subscription_template
[j
]);
1765 cupsArrayAdd(ra
, (void *)value
);
1773 * 'ippEnumString()' - Return a string corresponding to the enum value.
1776 const char * /* O - Enum string */
1777 ippEnumString(const char *attrname
, /* I - Attribute name */
1778 int enumvalue
) /* I - Enum value */
1780 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1784 * Check for standard enum values...
1787 if (!strcmp(attrname
, "document-state") &&
1789 enumvalue
< (3 + (int)(sizeof(ipp_document_states
) /
1790 sizeof(ipp_document_states
[0]))))
1791 return (ipp_document_states
[enumvalue
- 3]);
1792 else if (!strcmp(attrname
, "finishings") ||
1793 !strcmp(attrname
, "finishings-actual") ||
1794 !strcmp(attrname
, "finishings-default") ||
1795 !strcmp(attrname
, "finishings-ready") ||
1796 !strcmp(attrname
, "finishings-supported") ||
1797 !strcmp(attrname
, "job-finishings") ||
1798 !strcmp(attrname
, "job-finishings-default") ||
1799 !strcmp(attrname
, "job-finishings-supported"))
1801 if (enumvalue
>= 3 &&
1802 enumvalue
< (3 + (int)(sizeof(ipp_finishings
) /
1803 sizeof(ipp_finishings
[0]))))
1804 return (ipp_finishings
[enumvalue
- 3]);
1805 else if (enumvalue
>= 0x40000000 &&
1806 enumvalue
<= (0x40000000 + (int)(sizeof(ipp_finishings_vendor
) /
1807 sizeof(ipp_finishings_vendor
[0]))))
1808 return (ipp_finishings_vendor
[enumvalue
- 0x40000000]);
1810 else if ((!strcmp(attrname
, "job-collation-type") ||
1811 !strcmp(attrname
, "job-collation-type-actual")) &&
1813 enumvalue
< (3 + (int)(sizeof(ipp_job_collation_types
) /
1814 sizeof(ipp_job_collation_types
[0]))))
1815 return (ipp_job_collation_types
[enumvalue
- 3]);
1816 else if (!strcmp(attrname
, "job-state") &&
1817 enumvalue
>= IPP_JSTATE_PENDING
&& enumvalue
<= IPP_JSTATE_COMPLETED
)
1818 return (ipp_job_states
[enumvalue
- IPP_JSTATE_PENDING
]);
1819 else if (!strcmp(attrname
, "operations-supported"))
1820 return (ippOpString((ipp_op_t
)enumvalue
));
1821 else if ((!strcmp(attrname
, "orientation-requested") ||
1822 !strcmp(attrname
, "orientation-requested-actual") ||
1823 !strcmp(attrname
, "orientation-requested-default") ||
1824 !strcmp(attrname
, "orientation-requested-supported")) &&
1826 enumvalue
< (3 + (int)(sizeof(ipp_orientation_requesteds
) /
1827 sizeof(ipp_orientation_requesteds
[0]))))
1828 return (ipp_orientation_requesteds
[enumvalue
- 3]);
1829 else if ((!strcmp(attrname
, "print-quality") ||
1830 !strcmp(attrname
, "print-quality-actual") ||
1831 !strcmp(attrname
, "print-quality-default") ||
1832 !strcmp(attrname
, "print-quality-supported")) &&
1834 enumvalue
< (3 + (int)(sizeof(ipp_print_qualities
) /
1835 sizeof(ipp_print_qualities
[0]))))
1836 return (ipp_print_qualities
[enumvalue
- 3]);
1837 else if (!strcmp(attrname
, "printer-state") &&
1838 enumvalue
>= IPP_PSTATE_IDLE
&& enumvalue
<= IPP_PSTATE_STOPPED
)
1839 return (ipp_printer_states
[enumvalue
- IPP_PSTATE_IDLE
]);
1842 * Not a standard enum value, just return the decimal equivalent...
1845 snprintf(cg
->ipp_unknown
, sizeof(cg
->ipp_unknown
), "%d", enumvalue
);
1846 return (cg
->ipp_unknown
);
1851 * 'ippEnumValue()' - Return the value associated with a given enum string.
1854 int /* O - Enum value or -1 if unknown */
1855 ippEnumValue(const char *attrname
, /* I - Attribute name */
1856 const char *enumstring
) /* I - Enum string */
1858 int i
, /* Looping var */
1859 num_strings
; /* Number of strings to compare */
1860 const char * const *strings
; /* Strings to compare */
1864 * If the string is just a number, return it...
1867 if (isdigit(*enumstring
& 255))
1868 return ((int)strtol(enumstring
, NULL
, 0));
1871 * Otherwise look up the string...
1874 if (!strcmp(attrname
, "document-state"))
1876 num_strings
= (int)(sizeof(ipp_document_states
) / sizeof(ipp_document_states
[0]));
1877 strings
= ipp_document_states
;
1879 else if (!strcmp(attrname
, "finishings") ||
1880 !strcmp(attrname
, "finishings-actual") ||
1881 !strcmp(attrname
, "finishings-default") ||
1882 !strcmp(attrname
, "finishings-ready") ||
1883 !strcmp(attrname
, "finishings-supported"))
1886 i
< (int)(sizeof(ipp_finishings_vendor
) /
1887 sizeof(ipp_finishings_vendor
[0]));
1889 if (!strcmp(enumstring
, ipp_finishings_vendor
[i
]))
1890 return (i
+ 0x40000000);
1892 num_strings
= (int)(sizeof(ipp_finishings
) / sizeof(ipp_finishings
[0]));
1893 strings
= ipp_finishings
;
1895 else if (!strcmp(attrname
, "job-collation-type") ||
1896 !strcmp(attrname
, "job-collation-type-actual"))
1898 num_strings
= (int)(sizeof(ipp_job_collation_types
) /
1899 sizeof(ipp_job_collation_types
[0]));
1900 strings
= ipp_job_collation_types
;
1902 else if (!strcmp(attrname
, "job-state"))
1904 num_strings
= (int)(sizeof(ipp_job_states
) / sizeof(ipp_job_states
[0]));
1905 strings
= ipp_job_states
;
1907 else if (!strcmp(attrname
, "operations-supported"))
1908 return (ippOpValue(enumstring
));
1909 else if (!strcmp(attrname
, "orientation-requested") ||
1910 !strcmp(attrname
, "orientation-requested-actual") ||
1911 !strcmp(attrname
, "orientation-requested-default") ||
1912 !strcmp(attrname
, "orientation-requested-supported"))
1914 num_strings
= (int)(sizeof(ipp_orientation_requesteds
) /
1915 sizeof(ipp_orientation_requesteds
[0]));
1916 strings
= ipp_orientation_requesteds
;
1918 else if (!strcmp(attrname
, "print-quality") ||
1919 !strcmp(attrname
, "print-quality-actual") ||
1920 !strcmp(attrname
, "print-quality-default") ||
1921 !strcmp(attrname
, "print-quality-supported"))
1923 num_strings
= (int)(sizeof(ipp_print_qualities
) / sizeof(ipp_print_qualities
[0]));
1924 strings
= ipp_print_qualities
;
1926 else if (!strcmp(attrname
, "printer-state"))
1928 num_strings
= (int)(sizeof(ipp_printer_states
) / sizeof(ipp_printer_states
[0]));
1929 strings
= ipp_printer_states
;
1934 for (i
= 0; i
< num_strings
; i
++)
1935 if (!strcmp(enumstring
, strings
[i
]))
1943 * 'ippErrorString()' - Return a name for the given status code.
1946 const char * /* O - Text string */
1947 ippErrorString(ipp_status_t error
) /* I - Error status */
1949 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
1953 * See if the error code is a known value...
1956 if (error
>= IPP_STATUS_OK
&& error
<= IPP_STATUS_OK_EVENTS_COMPLETE
)
1957 return (ipp_status_oks
[error
]);
1958 else if (error
== IPP_STATUS_REDIRECTION_OTHER_SITE
)
1959 return ("redirection-other-site");
1960 else if (error
== IPP_STATUS_CUPS_SEE_OTHER
)
1961 return ("cups-see-other");
1962 else if (error
>= IPP_STATUS_ERROR_BAD_REQUEST
&&
1963 error
<= IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED
)
1964 return (ipp_status_400s
[error
- IPP_STATUS_ERROR_BAD_REQUEST
]);
1965 else if (error
>= 0x480 &&
1966 error
<= IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED
)
1967 return (ipp_status_480s
[error
- 0x0480]);
1968 else if (error
>= IPP_STATUS_ERROR_INTERNAL
&&
1969 error
<= IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS
)
1970 return (ipp_status_500s
[error
- IPP_STATUS_ERROR_INTERNAL
]);
1971 else if (error
>= IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
&&
1972 error
<= IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED
)
1973 return (ipp_status_1000s
[error
-
1974 IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
]);
1977 * No, build an "0xxxxx" error string...
1980 sprintf(cg
->ipp_unknown
, "0x%04x", error
);
1982 return (cg
->ipp_unknown
);
1987 * 'ippErrorValue()' - Return a status code for the given name.
1989 * @since CUPS 1.2/OS X 10.5@
1992 ipp_status_t
/* O - IPP status code */
1993 ippErrorValue(const char *name
) /* I - Name */
1995 size_t i
; /* Looping var */
1998 for (i
= 0; i
< (sizeof(ipp_status_oks
) / sizeof(ipp_status_oks
[0])); i
++)
1999 if (!_cups_strcasecmp(name
, ipp_status_oks
[i
]))
2000 return ((ipp_status_t
)i
);
2002 if (!_cups_strcasecmp(name
, "redirection-other-site"))
2003 return (IPP_STATUS_REDIRECTION_OTHER_SITE
);
2005 if (!_cups_strcasecmp(name
, "cups-see-other"))
2006 return (IPP_STATUS_CUPS_SEE_OTHER
);
2008 for (i
= 0; i
< (sizeof(ipp_status_400s
) / sizeof(ipp_status_400s
[0])); i
++)
2009 if (!_cups_strcasecmp(name
, ipp_status_400s
[i
]))
2010 return ((ipp_status_t
)(i
+ 0x400));
2012 for (i
= 0; i
< (sizeof(ipp_status_480s
) / sizeof(ipp_status_480s
[0])); i
++)
2013 if (!_cups_strcasecmp(name
, ipp_status_480s
[i
]))
2014 return ((ipp_status_t
)(i
+ 0x480));
2016 for (i
= 0; i
< (sizeof(ipp_status_500s
) / sizeof(ipp_status_500s
[0])); i
++)
2017 if (!_cups_strcasecmp(name
, ipp_status_500s
[i
]))
2018 return ((ipp_status_t
)(i
+ 0x500));
2020 for (i
= 0; i
< (sizeof(ipp_status_1000s
) / sizeof(ipp_status_1000s
[0])); i
++)
2021 if (!_cups_strcasecmp(name
, ipp_status_1000s
[i
]))
2022 return ((ipp_status_t
)(i
+ 0x1000));
2024 return ((ipp_status_t
)-1);
2029 * 'ippOpString()' - Return a name for the given operation id.
2031 * @since CUPS 1.2/OS X 10.5@
2034 const char * /* O - Name */
2035 ippOpString(ipp_op_t op
) /* I - Operation ID */
2037 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2041 * See if the operation ID is a known value...
2044 if (op
>= IPP_OP_PRINT_JOB
&& op
<= IPP_OP_VALIDATE_DOCUMENT
)
2045 return (ipp_std_ops
[op
]);
2046 else if (op
== IPP_OP_PRIVATE
)
2047 return ("windows-ext");
2048 else if (op
>= IPP_OP_CUPS_GET_DEFAULT
&& op
<= IPP_OP_CUPS_GET_PPD
)
2049 return (ipp_cups_ops
[op
- IPP_OP_CUPS_GET_DEFAULT
]);
2050 else if (op
== IPP_OP_CUPS_GET_DOCUMENT
)
2051 return (ipp_cups_ops2
[0]);
2054 * No, build an "0xxxxx" operation string...
2057 sprintf(cg
->ipp_unknown
, "0x%04x", op
);
2059 return (cg
->ipp_unknown
);
2064 * 'ippOpValue()' - Return an operation id for the given name.
2066 * @since CUPS 1.2/OS X 10.5@
2069 ipp_op_t
/* O - Operation ID */
2070 ippOpValue(const char *name
) /* I - Textual name */
2072 size_t i
; /* Looping var */
2075 if (!strncmp(name
, "0x", 2))
2076 return ((ipp_op_t
)strtol(name
+ 2, NULL
, 16));
2078 for (i
= 0; i
< (sizeof(ipp_std_ops
) / sizeof(ipp_std_ops
[0])); i
++)
2079 if (!_cups_strcasecmp(name
, ipp_std_ops
[i
]))
2080 return ((ipp_op_t
)i
);
2082 if (!_cups_strcasecmp(name
, "windows-ext"))
2083 return (IPP_OP_PRIVATE
);
2085 for (i
= 0; i
< (sizeof(ipp_cups_ops
) / sizeof(ipp_cups_ops
[0])); i
++)
2086 if (!_cups_strcasecmp(name
, ipp_cups_ops
[i
]))
2087 return ((ipp_op_t
)(i
+ 0x4001));
2089 for (i
= 0; i
< (sizeof(ipp_cups_ops2
) / sizeof(ipp_cups_ops2
[0])); i
++)
2090 if (!_cups_strcasecmp(name
, ipp_cups_ops2
[i
]))
2091 return ((ipp_op_t
)(i
+ 0x4027));
2093 if (!_cups_strcasecmp(name
, "Create-Job-Subscription"))
2094 return (IPP_OP_CREATE_JOB_SUBSCRIPTIONS
);
2096 if (!_cups_strcasecmp(name
, "Create-Printer-Subscription"))
2097 return (IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS
);
2099 if (!_cups_strcasecmp(name
, "CUPS-Add-Class"))
2100 return (IPP_OP_CUPS_ADD_MODIFY_CLASS
);
2102 if (!_cups_strcasecmp(name
, "CUPS-Add-Printer"))
2103 return (IPP_OP_CUPS_ADD_MODIFY_PRINTER
);
2105 return (IPP_OP_CUPS_INVALID
);
2110 * 'ippPort()' - Return the default IPP port number.
2113 int /* O - Port number */
2116 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
2119 DEBUG_puts("ippPort()");
2124 DEBUG_printf(("1ippPort: Returning %d...", cg
->ipp_port
));
2126 return (cg
->ipp_port
);
2131 * 'ippSetPort()' - Set the default port number.
2135 ippSetPort(int p
) /* I - Port number to use */
2137 DEBUG_printf(("ippSetPort(p=%d)", p
));
2139 _cupsGlobals()->ipp_port
= p
;
2144 * 'ippStateString()' - Return the name corresponding to a state value.
2146 * @since CUPS 2.0/OS 10.10@
2149 const char * /* O - State name */
2150 ippStateString(ipp_state_t state
) /* I - State value */
2152 if (state
>= IPP_STATE_ERROR
&& state
<= IPP_STATE_DATA
)
2153 return (ipp_states
[state
- IPP_STATE_ERROR
]);
2160 * 'ippTagString()' - Return the tag name corresponding to a tag value.
2162 * The returned names are defined in RFC 2911 and 3382.
2164 * @since CUPS 1.4/OS X 10.6@
2167 const char * /* O - Tag name */
2168 ippTagString(ipp_tag_t tag
) /* I - Tag value */
2170 tag
&= IPP_TAG_CUPS_MASK
;
2172 if (tag
< (ipp_tag_t
)(sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])))
2173 return (ipp_tag_names
[tag
]);
2180 * 'ippTagValue()' - Return the tag value corresponding to a tag name.
2182 * The tag names are defined in RFC 2911 and 3382.
2184 * @since CUPS 1.4/OS X 10.6@
2187 ipp_tag_t
/* O - Tag value */
2188 ippTagValue(const char *name
) /* I - Tag name */
2190 size_t i
; /* Looping var */
2193 for (i
= 0; i
< (sizeof(ipp_tag_names
) / sizeof(ipp_tag_names
[0])); i
++)
2194 if (!_cups_strcasecmp(name
, ipp_tag_names
[i
]))
2195 return ((ipp_tag_t
)i
);
2197 if (!_cups_strcasecmp(name
, "operation"))
2198 return (IPP_TAG_OPERATION
);
2199 else if (!_cups_strcasecmp(name
, "job"))
2200 return (IPP_TAG_JOB
);
2201 else if (!_cups_strcasecmp(name
, "printer"))
2202 return (IPP_TAG_PRINTER
);
2203 else if (!_cups_strcasecmp(name
, "unsupported"))
2204 return (IPP_TAG_UNSUPPORTED_GROUP
);
2205 else if (!_cups_strcasecmp(name
, "subscription"))
2206 return (IPP_TAG_SUBSCRIPTION
);
2207 else if (!_cups_strcasecmp(name
, "event"))
2208 return (IPP_TAG_EVENT_NOTIFICATION
);
2209 else if (!_cups_strcasecmp(name
, "language"))
2210 return (IPP_TAG_LANGUAGE
);
2211 else if (!_cups_strcasecmp(name
, "mimetype"))
2212 return (IPP_TAG_MIMETYPE
);
2213 else if (!_cups_strcasecmp(name
, "name"))
2214 return (IPP_TAG_NAME
);
2215 else if (!_cups_strcasecmp(name
, "text"))
2216 return (IPP_TAG_TEXT
);
2217 else if (!_cups_strcasecmp(name
, "begCollection"))
2218 return (IPP_TAG_BEGIN_COLLECTION
);
2220 return (IPP_TAG_ZERO
);
2225 * 'ipp_col_string()' - Convert a collection to a string.
2228 static size_t /* O - Number of bytes */
2229 ipp_col_string(ipp_t
*col
, /* I - Collection attribute */
2230 char *buffer
, /* I - Buffer or NULL */
2231 size_t bufsize
) /* I - Size of buffer */
2233 char *bufptr
, /* Position in buffer */
2234 *bufend
, /* End of buffer */
2235 prefix
= '{', /* Prefix character */
2236 temp
[256]; /* Temporary string */
2237 ipp_attribute_t
*attr
; /* Current member attribute */
2249 bufend
= buffer
+ bufsize
- 1;
2251 for (attr
= col
->attrs
; attr
; attr
= attr
->next
)
2256 if (buffer
&& bufptr
< bufend
)
2261 if (buffer
&& bufptr
< bufend
)
2262 bufptr
+= snprintf(bufptr
, (size_t)(bufend
- bufptr
+ 1), "%s=", attr
->name
);
2264 bufptr
+= strlen(attr
->name
) + 1;
2266 if (buffer
&& bufptr
< bufend
)
2267 bufptr
+= ippAttributeString(attr
, bufptr
, (size_t)(bufend
- bufptr
+ 1));
2269 bufptr
+= ippAttributeString(attr
, temp
, sizeof(temp
));
2274 if (buffer
&& bufptr
< bufend
)
2279 if (buffer
&& bufptr
< bufend
)
2283 return ((size_t)(bufptr
- buffer
));