8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / print / libipp-core / common / ipp.h
blobc13728e334407f600f220aff6c481374b2690e1f
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 #ifndef _IPP_H
29 #define _IPP_H
31 /* $Id: ipp.h 146 2006-03-24 00:26:54Z njacobs $ */
33 #pragma ident "%Z%%M% %I% %E% SMI"
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #include <stdarg.h>
40 #include <sys/time.h>
41 #include <papi.h>
42 #include <inttypes.h>
45 typedef ssize_t (*ipp_reader_t)(void *fd, void *buffer, size_t buffer_size);
46 typedef ssize_t (*ipp_writer_t)(void *fd, void *buffer, size_t buffer_size);
48 enum {
49 IPP_TYPE_UNKNOWN = 0,
50 IPP_TYPE_REQUEST = 1,
51 IPP_TYPE_RESPONSE = 2
55 * How closely do we conform to the spec when parsing? Do we
56 * a) Stop parsing only when we encounter an error that prevents us from
57 * continuing parsing (a server error or ridiculously malformed request)?
58 * b) Stop parsing when we know the server wouldn't be able to act on the
59 * response correctly, even if we can make sense of some of the data?
60 * c) Jawohl, Mein IPP Spec!
61 * The answer will usually be b, though a will be useful for debugging.
63 enum {
64 IPP_PARSE_CONFORMANCE_RASH = 0,
65 IPP_PARSE_CONFORMANCE_LOOSE = 1,
66 IPP_PARSE_CONFORMANCE_STRICT = 2
70 /* Operation IDs */
71 enum {
72 OPID_MIN = 0x0000, /* 0x0000 */
73 OPID_RESERVED_0000 = 0x0000, /* 0x0000 */
74 OPID_RESERVED_0001, /* 0x0001 */
75 OPID_PRINT_JOB, /* 0x0002 */
76 OPID_PRINT_URI, /* 0x0003 */
77 OPID_VALIDATE_JOB, /* 0x0004 */
78 OPID_CREATE_JOB, /* 0x0005 */
79 OPID_SEND_DOCUMENT, /* 0x0006 */
80 OPID_SEND_URI, /* 0x0007 */
81 OPID_CANCEL_JOB, /* 0x0008 */
82 OPID_GET_JOB_ATTRIBUTES, /* 0x0009 */
83 OPID_GET_JOBS, /* 0x000a */
84 OPID_GET_PRINTER_ATTRIBUTES, /* 0x000b */
85 OPID_HOLD_JOB, /* 0x000c */
86 OPID_RELEASE_JOB, /* 0x000d */
87 OPID_RESTART_JOB, /* 0x000e */
88 OPID_RESERVED_000F, /* 0x000f */
89 OPID_PAUSE_PRINTER, /* 0x0010 */
90 OPID_RESUME_PRINTER, /* 0x0011 */
91 OPID_PURGE_JOBS, /* 0x0012 */
92 OPID_SET_PRINTER_ATTRIBUTES, /* 0x0013 */
93 OPID_SET_JOB_ATTRIBUTES, /* 0x0014 */
94 OPID_GET_PRINTER_SUPPORTED_VALUES, /* 0x0015 */
95 OPID_CREATE_PRINTER_SUBSCRIPTION, /* 0x0016 */
96 OPID_CREATE_JOB_SUBSCRIPTION, /* 0x0017 */
97 OPID_GET_SUBSCRIPTION_ATTRIBUTES, /* 0x0018 */
98 OPID_GET_SUBSCRIPTIONS, /* 0x0019 */
99 OPID_RENEW_SUBSCRIPTION, /* 0x001a */
100 OPID_CANCEL_SUBSCRIPTION, /* 0x001b */
101 OPID_GET_NOTIFICATIONS, /* 0x001c */
102 OPID_SEND_NOTIFICATIONS, /* 0x001d */
103 OPID_GET_RESOURCE_ATTRIBUTES, /* 0x001e */
104 OPID_GET_RESOURCE_DATA, /* 0x001f */
105 OPID_GET_RESOURCES, /* 0x0020 */
106 OPID_GET_PRINT_SUPPORT_FILES, /* 0x0021 */
107 OPID_ENABLE_PRINTER, /* 0x0022 */
108 OPID_DISABLE_PRINTER, /* 0x0023 */
109 OPID_PAUSE_PRINTER_AFTER_CURRENT_JOB, /* 0x0024 */
110 OPID_HOLD_NEW_JOBS, /* 0x0025 */
111 OPID_RELEASE_HELD_NEW_JOBS, /* 0x0026 */
112 OPID_DEACTIVATE_PRINTER, /* 0x0027 */
113 OPID_ACTIVATE_PRINTER, /* 0x0028 */
114 OPID_RESTART_PRINTER, /* 0x0029 */
115 OPID_SHUTDOWN_PRINTER, /* 0x002a */
116 OPID_STARTUP_PRINTER, /* 0x002b */
117 OPID_REPROCESS_JOB, /* 0x002c */
118 OPID_CANCEL_CURRENT_JOB, /* 0x002d */
119 OPID_SUSPEND_CURRENT_JOB, /* 0x002e */
120 OPID_RESUME_JOB, /* 0x002f */
121 OPID_PROMOTE_JOB, /* 0x0030 */
122 OPID_SCHEDULE_JOB_AFTER, /* 0x0031 */
123 OPID_RESERVED_MIN, /* 0x0032 */
124 OPID_RESERVED_0032 = 0x0032, /* 0x0032 */
125 /* ... */
126 OPID_RESERVED_3FFF = 0x3fff, /* 0x3fff */
127 OPID_RESERVED_MAX = 0x3fff, /* 0x3fff */
128 OPID_RESERVED_VENDOR_MIN = 0x4000, /* 0x4000 */
129 OPID_RESERVED_VENDOR_4000 = 0x4000, /* 0x4000 */
130 /* ... */
131 OPID_RESERVED_VENDOR_8FFF = 0x8fff, /* 0x8fff */
132 OPID_RESERVED_VENDOR_MAX = 0x8fff, /* 0x8fff */
133 OPID_MAX = 0x8fff /* 0x8fff */
136 enum {
137 /* Delimiter Tags */
138 DTAG_MIN = 0x00, /* 0x00 */
139 DTAG_RESERVED_DELIMITER_00 = 0x00, /* 0x00 */
140 DTAG_OPERATION_ATTRIBUTES, /* 0x01 */
141 DTAG_JOB_ATTRIBUTES, /* 0x02 */
142 DTAG_END_OF_ATTRIBUTES, /* 0x03 */
143 DTAG_PRINTER_ATTRIBUTES, /* 0x04 */
144 DTAG_UNSUPPORTED_ATTRIBUTES, /* 0x05 */
145 DTAG_SUBSCRIPTION_ATTRIBUTES, /* 0x06 */
146 DTAG_EVENT_NOTIFICATION_ATTRIBUTES, /* 0x07 */
147 DTAG_RESERVED_DELIMITER_08, /* 0x08 */
148 DTAG_RESERVED_DELIMITER_09, /* 0x09 */
149 DTAG_RESERVED_DELIMITER_0A, /* 0x0a */
150 DTAG_RESERVED_DELIMITER_0B, /* 0x0b */
151 DTAG_RESERVED_DELIMITER_0C, /* 0x0c */
152 DTAG_RESERVED_DELIMITER_0D, /* 0x0d */
153 DTAG_RESERVED_DELIMITER_0E, /* 0x0e */
154 DTAG_RESERVED_DELIMITER_0F, /* 0x0f */
155 DTAG_MAX = 0x0f, /* 0x0f */
157 /* Value Tags */
158 VTAG_MIN = 0x10, /* 0x10 */
159 VTAG_UNSUPPORTED = 0x10, /* 0x10 */
160 VTAG_RESERVED_DEFAULT, /* 0x11 */
161 VTAG_UNKNOWN, /* 0x12 */
162 VTAG_NOVALUE, /* 0x13 */
163 VTAG_RESERVED_OOB_14, /* 0x14 */
164 VTAG_NOT_SETTABLE, /* 0x15 */
165 VTAG_DELETE_ATTRIBUTE, /* 0x16 */
166 VTAG_ADMIN_DEFINE, /* 0x17 */
167 VTAG_RESERVED_OOB_18, /* 0x18 */
168 VTAG_RESERVED_OOB_19, /* 0x19 */
169 VTAG_RESERVED_OOB_1A, /* 0x1a */
170 VTAG_RESERVED_OOB_1B, /* 0x1b */
171 VTAG_RESERVED_OOB_1C, /* 0x1c */
172 VTAG_RESERVED_OOB_1D, /* 0x1d */
173 VTAG_RESERVED_OOB_1E, /* 0x1e */
174 VTAG_RESERVED_OOB_1F, /* 0x1f */
175 VTAG_RESERVED_INT_GEN, /* 0x20 */
176 VTAG_INTEGER, /* 0x21 */
177 VTAG_BOOLEAN, /* 0x22 */
178 VTAG_ENUM, /* 0x23 */
179 VTAG_RESERVED_INT_24, /* 0x24 */
180 VTAG_RESERVED_INT_25, /* 0x25 */
181 VTAG_RESERVED_INT_26, /* 0x26 */
182 VTAG_RESERVED_INT_27, /* 0x27 */
183 VTAG_RESERVED_INT_28, /* 0x28 */
184 VTAG_RESERVED_INT_29, /* 0x29 */
185 VTAG_RESERVED_INT_2A, /* 0x2a */
186 VTAG_RESERVED_INT_2B, /* 0x2b */
187 VTAG_RESERVED_INT_2C, /* 0x2c */
188 VTAG_RESERVED_INT_2D, /* 0x2d */
189 VTAG_RESERVED_INT_2E, /* 0x2e */
190 VTAG_RESERVED_INT_2F, /* 0x2f */
191 VTAG_OCTET_STRING, /* 0x30 */
192 VTAG_DATE_TIME, /* 0x31 */
193 VTAG_RESOLUTION, /* 0x32 */
194 VTAG_RANGE_OF_INTEGER, /* 0x33 */
195 VTAG_BEGIN_COLLECTION, /* 0x34 */
196 VTAG_TEXT_WITH_LANGUAGE, /* 0x35 */
197 VTAG_NAME_WITH_LANGUAGE, /* 0x36 */
198 VTAG_END_COLLECTION, /* 0x37 */
199 VTAG_RESERVED_STRING_38, /* 0x38 */
200 VTAG_RESERVED_STRING_39, /* 0x39 */
201 VTAG_RESERVED_STRING_3A, /* 0x3a */
202 VTAG_RESERVED_STRING_3B, /* 0x3b */
203 VTAG_RESERVED_STRING_3C, /* 0x3c */
204 VTAG_RESERVED_STRING_3D, /* 0x3d */
205 VTAG_RESERVED_STRING_3E, /* 0x3e */
206 VTAG_RESERVED_STRING_3F, /* 0x3f */
207 VTAG_RESERVED_CHAR_GEN, /* 0x40 */
208 VTAG_TEXT_WITHOUT_LANGUAGE, /* 0x41 */
209 VTAG_NAME_WITHOUT_LANGUAGE, /* 0x42 */
210 VTAG_RESERVED_43, /* 0x43 */
211 VTAG_KEYWORD, /* 0x44 */
212 VTAG_URI, /* 0x45 */
213 VTAG_URI_SCHEME, /* 0x46 */
214 VTAG_CHARSET, /* 0x47 */
215 VTAG_NATURAL_LANGUAGE, /* 0x48 */
216 VTAG_MIME_MEDIA_TYPE, /* 0x49 */
217 VTAG_MEMBER_ATTR_NAME, /* 0x4a */
218 VTAG_RESERVED_STRING_4B, /* 0x4b */
219 VTAG_RESERVED_STRING_4C, /* 0x4c */
220 VTAG_RESERVED_STRING_4D, /* 0x4d */
221 VTAG_RESERVED_STRING_4E, /* 0x4e */
222 VTAG_RESERVED_STRING_4F, /* 0x4f */
223 VTAG_RESERVED_STRING_50, /* 0x50 */
224 VTAG_RESERVED_STRING_51, /* 0x51 */
225 VTAG_RESERVED_STRING_52, /* 0x52 */
226 VTAG_RESERVED_STRING_53, /* 0x53 */
227 VTAG_RESERVED_STRING_54, /* 0x54 */
228 VTAG_RESERVED_STRING_55, /* 0x55 */
229 VTAG_RESERVED_STRING_56, /* 0x56 */
230 VTAG_RESERVED_STRING_57, /* 0x57 */
231 VTAG_RESERVED_STRING_58, /* 0x58 */
232 VTAG_RESERVED_STRING_59, /* 0x59 */
233 VTAG_RESERVED_STRING_5A, /* 0x5a */
234 VTAG_RESERVED_STRING_5B, /* 0x5b */
235 VTAG_RESERVED_STRING_5C, /* 0x5c */
236 VTAG_RESERVED_STRING_5D, /* 0x5d */
237 VTAG_RESERVED_STRING_5E, /* 0x5e */
238 VTAG_RESERVED_STRING_5F, /* 0x5f */
239 VTAG_RESERVED_MAX = 0x5f, /* 0x5f */
240 VTAG_MAX = 0x5f, /* 0x5f */
241 VTAG_EXTEND = 0x7f /* 0x7f */
244 /* Response codes */
245 enum {
246 IPP_OK_MIN = 0x0000,
247 IPP_OK = 0x0000, /* 0x0000 */
248 IPP_OK_IGNORED_ATTRIBUTES, /* 0x0001 */
249 IPP_OK_CONFLICTING_ATTRIBUTES, /* 0x0002 */
250 IPP_OK_IGNORED_SUBSCRIPTIONS, /* 0x0003 */
251 IPP_OK_IGNORED_NOTIFICATIONS, /* 0x0004 */
252 IPP_OK_TOO_MANY_EVENTS, /* 0x0005 */
253 IPP_OK_BUT_CANCEL_SUBSCRIPTION, /* 0x0006 */
254 IPP_OK_MAX = IPP_OK_BUT_CANCEL_SUBSCRIPTION,
256 IPP_REDIR_MIN = 0x0300,
257 IPP_REDIR_OTHER_SIZE = 0x0300, /* 0x0300 */
258 IPP_REDIR_MAX = 0x0300,
260 IPP_CERR_MIN = 0x0400,
261 IPP_CERR_BAD_REQUEST = 0x0400, /* 0x0400 */
262 IPP_CERR_FORBIDDEN, /* 0x0401 */
263 IPP_CERR_NOT_AUTHENTICATED, /* 0x0402 */
264 IPP_CERR_NOT_AUTHORIZED, /* 0x0403 */
265 IPP_CERR_NOT_POSSIBLE, /* 0x0404 */
266 IPP_CERR_TIMEOUT, /* 0x0405 */
267 IPP_CERR_NOT_FOUND, /* 0x0406 */
268 IPP_CERR_GONE, /* 0x0407 */
269 IPP_CERR_REQUEST_ENTITY, /* 0x0408 */
270 IPP_CERR_REQUEST_VALUE, /* 0x0409 */
271 IPP_CERR_DOCUMENT_FORMAT, /* 0x040a */
272 IPP_CERR_ATTRIBUTES, /* 0x040b */
273 IPP_CERR_URI_SCHEME, /* 0x040c */
274 IPP_CERR_CHARSET, /* 0x040d */
275 IPP_CERR_CONFLICT, /* 0x040e */
276 IPP_CERR_COMPRESSION_NOT_SUPPORTED, /* 0x040f */
277 IPP_CERR_COMPRESSION_ERROR, /* 0x0410 */
278 IPP_CERR_DOCUMENT_FORMAT_ERROR, /* 0x0411 */
279 IPP_CERR_DOCUMENT_ACCESS_ERROR, /* 0x0412 */
280 IPP_CERR_ATTRIBUTES_NOT_SETTABLE, /* 0x0413 */
281 IPP_CERR_IGNORED_ALL_SUBSCRIPTIONS, /* 0x0414 */
282 IPP_CERR_TOO_MANY_SUBSCRIPTIONS, /* 0x0415 */
283 IPP_CERR_IGNORED_ALL_NOTIFICATIONS, /* 0x0416 */
284 IPP_CERR_PRINT_SUPPORT_FILE_NOT_FOUND, /* 0x0417 */
285 IPP_CERR_MAX = IPP_CERR_PRINT_SUPPORT_FILE_NOT_FOUND,
287 IPP_SERR_MIN = 0x0500,
288 IPP_SERR_INTERNAL = 0x0500, /* 0x0500 */
289 IPP_SERR_OPERATION_NOT_SUPPORTED, /* 0x0501 */
290 IPP_SERR_SERVICE_UNAVAILABLE, /* 0x0502 */
291 IPP_SERR_VERSION_NOT_SUPPORTED, /* 0x0503 */
292 IPP_SERR_DEVICE_ERROR, /* 0x0504 */
293 IPP_SERR_TEMPORARY_ERROR, /* 0x0505 */
294 IPP_SERR_NOT_ACCEPTING, /* 0x0506 */
295 IPP_SERR_BUSY, /* 0x0507 */
296 IPP_SERR_CANCELLED, /* 0x0508 */
297 IPP_SERR_MULTIPLE_DOCS_NOT_SUPPORTED, /* 0x0509 */
298 IPP_SERR_PRINTER_IS_DEACTIVATED, /* 0x050a */
299 IPP_SERR_MAX = IPP_SERR_PRINTER_IS_DEACTIVATED
302 /* Job state codes */
303 enum {
304 IPP_JOB_STATE_PENDING = 3,
305 IPP_JOB_STATE_PENDING_HELD = 4,
306 IPP_JOB_STATE_PROCESSING = 5,
307 IPP_JOB_STATE_PROCESSING_STOPPED = 6,
308 IPP_JOB_STATE_CANCELED = 7,
309 IPP_JOB_STATE_ABORTED = 8,
310 IPP_JOB_STATE_COMPLETED = 9
313 /* exported functions */
314 extern papi_status_t ipp_read_message(ipp_reader_t iread, void *fd,
315 papi_attribute_t ***message, char type);
317 extern papi_status_t ipp_write_message(ipp_writer_t iwrite, void *fd,
318 papi_attribute_t **message);
320 /* internal functions shared between modules */
321 extern void ipp_set_status(papi_attribute_t ***message, papi_status_t status,
322 char *format, ...);
323 extern papi_status_t ipp_validate_request(papi_attribute_t **request,
324 papi_attribute_t ***response);
326 extern int ipp_severity(int16_t status);
328 extern int16_t ipp_charset_supported(char *charset);
330 extern void *string_to_ipp_attr_value(int8_t type, char *value);
332 extern char *ipp_uri_to_printer(char *uri);
333 extern void *papi_attribute_to_ipp_attr(int8_t type, papi_attribute_t *attr);
335 extern int8_t name_to_ipp_type(char *name);
336 extern char *job_template[];
337 extern char *job_description[];
338 extern char *printer_description[];
339 extern char *ipp_tag_string(int8_t tag, char *buf, size_t bufsiz);
340 extern size_t min_val_len(int8_t type, char *name);
341 extern size_t max_val_len(int8_t type, char *name);
342 extern int is_keyword(char *value);
344 #ifdef __cplusplus
346 #endif
348 #endif /* _IPP_H */