]>
Commit | Line | Data |
---|---|---|
dec2f757 | 1 | /* |
997fbfa7 | 2 | * "$Id: ipp.h,v 1.45 2002/12/17 18:56:42 swdev Exp $" |
dec2f757 | 3 | * |
3a193f5e | 4 | * Internet Printing Protocol definitions for the Common UNIX Printing |
5 | * System (CUPS). | |
dec2f757 | 6 | * |
997fbfa7 | 7 | * Copyright 1997-2003 by Easy Software Products. |
dec2f757 | 8 | * |
9 | * These coded instructions, statements, and computer programs are the | |
10 | * property of Easy Software Products and are protected by Federal | |
11 | * copyright law. Distribution and use rights are outlined in the file | |
12 | * "LICENSE.txt" which should have been included with this file. If this | |
13 | * file is missing or damaged please contact Easy Software Products | |
14 | * at: | |
15 | * | |
16 | * Attn: CUPS Licensing Information | |
17 | * Easy Software Products | |
58ec2a95 | 18 | * 44141 Airport View Drive, Suite 204 |
dec2f757 | 19 | * Hollywood, Maryland 20636-3111 USA |
20 | * | |
21 | * Voice: (301) 373-9603 | |
22 | * EMail: cups-info@cups.org | |
23 | * WWW: http://www.cups.org | |
34410ef2 | 24 | * |
25 | * This file is subject to the Apple OS-Developed Software exception. | |
dec2f757 | 26 | */ |
27 | ||
3a193f5e | 28 | #ifndef _CUPS_IPP_H_ |
29 | # define _CUPS_IPP_H_ | |
30 | ||
dec2f757 | 31 | /* |
32 | * Include necessary headers... | |
33 | */ | |
34 | ||
183914a3 | 35 | # include "http.h" |
3a193f5e | 36 | |
37 | ||
38 | /* | |
39 | * C++ magic... | |
40 | */ | |
41 | ||
42 | # ifdef __cplusplus | |
43 | extern "C" { | |
44 | # endif /* __cplusplus */ | |
45 | ||
46 | ||
47 | /* | |
48 | * IPP version string... | |
49 | */ | |
50 | ||
91acc14f | 51 | # define IPP_VERSION "\001\001" |
3a193f5e | 52 | |
20c7158b | 53 | /* |
54 | * IPP registered port number... This is the default value - applications | |
55 | * should use the ippPort() function so that you can customize things in | |
56 | * /etc/services if needed! | |
57 | */ | |
58 | ||
59 | # define IPP_PORT 631 | |
3a193f5e | 60 | |
3b960317 | 61 | /* |
62 | * Common limits... | |
63 | */ | |
64 | ||
5356dc5a | 65 | # define IPP_MAX_NAME 256 |
acf4f738 | 66 | # define IPP_MAX_VALUES 10 /* Now just an allocation increment */ |
3b960317 | 67 | |
68 | ||
3a193f5e | 69 | /* |
70 | * Types and structures... | |
71 | */ | |
72 | ||
73 | typedef enum /**** Format tags for attribute formats... ****/ | |
74 | { | |
75 | IPP_TAG_ZERO = 0x00, | |
76 | IPP_TAG_OPERATION, | |
77 | IPP_TAG_JOB, | |
3a193f5e | 78 | IPP_TAG_END, |
50146867 | 79 | IPP_TAG_PRINTER, |
714294b4 | 80 | IPP_TAG_UNSUPPORTED_GROUP, |
d2dd6522 | 81 | IPP_TAG_SUBSCRIPTION, |
82 | IPP_TAG_EVENT_NOTIFICATION, | |
714294b4 | 83 | IPP_TAG_UNSUPPORTED_VALUE = 0x10, |
50146867 | 84 | IPP_TAG_DEFAULT, |
85 | IPP_TAG_UNKNOWN, | |
86 | IPP_TAG_NOVALUE, | |
a3e17a89 | 87 | IPP_TAG_NOTSETTABLE = 0x15, |
88 | IPP_TAG_DELETEATTR, | |
d2dd6522 | 89 | IPP_TAG_ADMINDEFINE, |
3a193f5e | 90 | IPP_TAG_INTEGER = 0x21, |
91 | IPP_TAG_BOOLEAN, | |
92 | IPP_TAG_ENUM, | |
93 | IPP_TAG_STRING = 0x30, | |
94 | IPP_TAG_DATE, | |
95 | IPP_TAG_RESOLUTION, | |
96 | IPP_TAG_RANGE, | |
d2dd6522 | 97 | IPP_TAG_BEGIN_COLLECTION, |
3a193f5e | 98 | IPP_TAG_TEXTLANG, |
99 | IPP_TAG_NAMELANG, | |
d2dd6522 | 100 | IPP_TAG_END_COLLECTION, |
3a193f5e | 101 | IPP_TAG_TEXT = 0x41, |
102 | IPP_TAG_NAME, | |
01bebed4 | 103 | IPP_TAG_KEYWORD = 0x44, |
3a193f5e | 104 | IPP_TAG_URI, |
105 | IPP_TAG_URISCHEME, | |
106 | IPP_TAG_CHARSET, | |
107 | IPP_TAG_LANGUAGE, | |
b6ea8f29 | 108 | IPP_TAG_MIMETYPE, |
d2dd6522 | 109 | IPP_TAG_MEMBERNAME, |
35c8c9b0 | 110 | IPP_TAG_MASK = 0x7fffffff, /* Mask for copied attribute values */ |
111 | IPP_TAG_COPY = -0x7fffffff-1 /* Bitflag for copied attribute values */ | |
3a193f5e | 112 | } ipp_tag_t; |
113 | ||
114 | typedef enum /**** Resolution units... ****/ | |
115 | { | |
116 | IPP_RES_PER_INCH = 3, | |
117 | IPP_RES_PER_CM | |
118 | } ipp_res_t; | |
119 | ||
50146867 | 120 | typedef enum /**** Finishings... ****/ |
121 | { | |
d2dd6522 | 122 | IPP_FINISHINGS_NONE = 3, |
123 | IPP_FINISHINGS_STAPLE, | |
124 | IPP_FINISHINGS_PUNCH, | |
125 | IPP_FINISHINGS_COVER, | |
126 | IPP_FINISHINGS_BIND, | |
127 | IPP_FINISHINGS_SADDLE_STITCH, | |
128 | IPP_FINISHINGS_EDGE_STITCH, | |
129 | IPP_FINISHINGS_FOLD, | |
130 | IPP_FINISHINGS_TRIM, | |
131 | IPP_FINISHINGS_BALE, | |
132 | IPP_FINISHINGS_BOOKLET_MAKER, | |
133 | IPP_FINISHINGS_JOB_OFFSET, | |
134 | IPP_FINISHINGS_STAPLE_TOP_LEFT = 20, | |
135 | IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, | |
136 | IPP_FINISHINGS_STAPLE_TOP_RIGHT, | |
137 | IPP_FINISHINGS_STAPLE_BOTTOM_RIGHT, | |
138 | IPP_FINISHINGS_EDGE_STITCH_LEFT, | |
139 | IPP_FINISHINGS_EDGE_STITCH_TOP, | |
140 | IPP_FINISHINGS_EDGE_STITCH_RIGHT, | |
141 | IPP_FINISHINGS_EDGE_STITCH_BOTTOM, | |
142 | IPP_FINISHINGS_STAPLE_DUAL_LEFT, | |
143 | IPP_FINISHINGS_STAPLE_DUAL_TOP, | |
144 | IPP_FINISHINGS_STAPLE_DUAL_RIGHT, | |
145 | IPP_FINISHINGS_STAPLE_DUAL_BOTTOM, | |
146 | IPP_FINISHINGS_BIND_LEFT = 50, | |
147 | IPP_FINISHINGS_BIND_TOP, | |
148 | IPP_FINISHINGS_BIND_RIGHT, | |
149 | IPP_FINISHINGS_BIND_BOTTOM | |
50146867 | 150 | } ipp_finish_t; |
151 | ||
50146867 | 152 | typedef enum /**** Orientation... ****/ |
153 | { | |
154 | IPP_PORTRAIT = 3, /* No rotation */ | |
155 | IPP_LANDSCAPE, /* 90 degrees counter-clockwise */ | |
156 | IPP_REVERSE_LANDSCAPE, /* 90 degrees clockwise */ | |
157 | IPP_REVERSE_PORTRAIT /* 180 degrees */ | |
158 | } ipp_orient_t; | |
159 | ||
160 | typedef enum /**** Qualities... ****/ | |
161 | { | |
162 | IPP_QUALITY_DRAFT = 3, | |
163 | IPP_QUALITY_NORMAL, | |
164 | IPP_QUALITY_HIGH | |
165 | } ipp_quality_t; | |
166 | ||
167 | typedef enum /**** Job States.... */ | |
168 | { | |
169 | IPP_JOB_PENDING = 3, | |
170 | IPP_JOB_HELD, | |
171 | IPP_JOB_PROCESSING, | |
172 | IPP_JOB_STOPPED, | |
e09246c8 | 173 | IPP_JOB_CANCELLED, |
50146867 | 174 | IPP_JOB_ABORTED, |
175 | IPP_JOB_COMPLETED | |
3b960317 | 176 | } ipp_jstate_t; |
177 | ||
178 | typedef enum /**** Printer States.... */ | |
179 | { | |
180 | IPP_PRINTER_IDLE = 3, | |
181 | IPP_PRINTER_PROCESSING, | |
182 | IPP_PRINTER_STOPPED | |
183 | } ipp_pstate_t; | |
50146867 | 184 | |
3a193f5e | 185 | typedef enum /**** IPP states... ****/ |
186 | { | |
3b960317 | 187 | IPP_ERROR = -1, /* An error occurred */ |
188 | IPP_IDLE, /* Nothing is happening/request completed */ | |
189 | IPP_HEADER, /* The request header needs to be sent/received */ | |
190 | IPP_ATTRIBUTE, /* One or more attributes need to be sent/received */ | |
191 | IPP_DATA /* IPP request data needs to be sent/received */ | |
3a193f5e | 192 | } ipp_state_t; |
193 | ||
194 | typedef enum /**** IPP operations... ****/ | |
195 | { | |
196 | IPP_PRINT_JOB = 0x0002, | |
197 | IPP_PRINT_URI, | |
198 | IPP_VALIDATE_JOB, | |
199 | IPP_CREATE_JOB, | |
200 | IPP_SEND_DOCUMENT, | |
201 | IPP_SEND_URI, | |
202 | IPP_CANCEL_JOB, | |
203 | IPP_GET_JOB_ATTRIBUTES, | |
204 | IPP_GET_JOBS, | |
205 | IPP_GET_PRINTER_ATTRIBUTES, | |
9aebebc3 | 206 | IPP_HOLD_JOB, |
5356dc5a | 207 | IPP_RELEASE_JOB, |
208 | IPP_RESTART_JOB, | |
209 | IPP_PAUSE_PRINTER = 0x0010, | |
210 | IPP_RESUME_PRINTER, | |
211 | IPP_PURGE_JOBS, | |
9cbd98eb | 212 | IPP_SET_PRINTER_ATTRIBUTES, |
213 | IPP_SET_JOB_ATTRIBUTES, | |
214 | IPP_GET_PRINTER_SUPPORTED_VALUES, | |
d2dd6522 | 215 | IPP_CREATE_PRINTER_SUBSCRIPTION, |
216 | IPP_CREATE_JOB_SUBSCRIPTION, | |
217 | IPP_GET_SUBSCRIPTION_ATTRIBUTES, | |
218 | IPP_GET_SUBSCRIPTIONS, | |
219 | IPP_RENEW_SUBSCRIPTION, | |
220 | IPP_CANCEL_SUBSCRIPTION, | |
221 | IPP_GET_NOTIFICATIONS, | |
222 | IPP_SEND_NOTIFICATIONS, | |
223 | IPP_GET_PRINT_SUPPORT_FILES = 0x0021, | |
224 | IPP_ENABLE_PRINTER, | |
225 | IPP_DISABLE_PRINTER, | |
226 | IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB, | |
227 | IPP_HOLD_NEW_JOBS, | |
228 | IPP_RELEASE_HELD_NEW_JOBS, | |
229 | IPP_DEACTIVATE_PRINTER, | |
230 | IPP_ACTIVATE_PRINTER, | |
231 | IPP_RESTART_PRINTER, | |
232 | IPP_SHUTDOWN_PRINTER, | |
233 | IPP_STARTUP_PRINTER, | |
234 | IPP_REPROCESS_JOB, | |
235 | IPP_CANCEL_CURRENT_JOB, | |
236 | IPP_SUSPEND_CURRENT_JOB, | |
237 | IPP_RESUME_JOB, | |
238 | IPP_PROMOTE_JOB, | |
239 | IPP_SCHEDULE_JOB_AFTER, | |
3b960317 | 240 | IPP_PRIVATE = 0x4000, |
5356dc5a | 241 | CUPS_GET_DEFAULT, |
3b960317 | 242 | CUPS_GET_PRINTERS, |
243 | CUPS_ADD_PRINTER, | |
244 | CUPS_DELETE_PRINTER, | |
245 | CUPS_GET_CLASSES, | |
246 | CUPS_ADD_CLASS, | |
d23a857a | 247 | CUPS_DELETE_CLASS, |
248 | CUPS_ACCEPT_JOBS, | |
3270670b | 249 | CUPS_REJECT_JOBS, |
bd84e0d1 | 250 | CUPS_SET_DEFAULT, |
251 | CUPS_GET_DEVICES, | |
a3e17a89 | 252 | CUPS_GET_PPDS, |
d2dd6522 | 253 | CUPS_MOVE_JOB, |
254 | CUPS_ADD_DEVICE, | |
255 | CUPS_DELETE_DEVICE | |
3a193f5e | 256 | } ipp_op_t; |
257 | ||
258 | typedef enum /**** IPP status codes... ****/ | |
259 | { | |
260 | IPP_OK = 0x0000, | |
261 | IPP_OK_SUBST, | |
262 | IPP_OK_CONFLICT, | |
7b1b1c6e | 263 | IPP_OK_IGNORED_SUBSCRIPTIONS, |
264 | IPP_OK_IGNORED_NOTIFICATIONS, | |
265 | IPP_OK_TOO_MANY_EVENTS, | |
266 | IPP_OK_BUT_CANCEL_SUBSCRIPTION, | |
267 | IPP_REDIRECTION_OTHER_SITE = 0x300, | |
3a193f5e | 268 | IPP_BAD_REQUEST = 0x0400, |
269 | IPP_FORBIDDEN, | |
270 | IPP_NOT_AUTHENTICATED, | |
271 | IPP_NOT_AUTHORIZED, | |
272 | IPP_NOT_POSSIBLE, | |
273 | IPP_TIMEOUT, | |
274 | IPP_NOT_FOUND, | |
275 | IPP_GONE, | |
276 | IPP_REQUEST_ENTITY, | |
277 | IPP_REQUEST_VALUE, | |
278 | IPP_DOCUMENT_FORMAT, | |
279 | IPP_ATTRIBUTES, | |
280 | IPP_URI_SCHEME, | |
281 | IPP_CHARSET, | |
cd7ca660 | 282 | IPP_CONFLICT, |
f213de35 | 283 | IPP_COMPRESSION_NOT_SUPPORTED, |
284 | IPP_COMPRESSION_ERROR, | |
285 | IPP_DOCUMENT_FORMAT_ERROR, | |
286 | IPP_DOCUMENT_ACCESS_ERROR, | |
7b1b1c6e | 287 | IPP_ATTRIBUTES_NOT_SETTABLE, |
288 | IPP_IGNORED_ALL_SUBSCRIPTIONS, | |
289 | IPP_TOO_MANY_SUBSCRIPTIONS, | |
290 | IPP_IGNORED_ALL_NOTIFICATIONS, | |
291 | IPP_PRINT_SUPPORT_FILE_NOT_FOUND, | |
292 | ||
3a193f5e | 293 | IPP_INTERNAL_ERROR = 0x0500, |
294 | IPP_OPERATION_NOT_SUPPORTED, | |
295 | IPP_SERVICE_UNAVAILABLE, | |
296 | IPP_VERSION_NOT_SUPPORTED, | |
f213de35 | 297 | IPP_DEVICE_ERROR, |
3a193f5e | 298 | IPP_TEMPORARY_ERROR, |
299 | IPP_NOT_ACCEPTING, | |
f213de35 | 300 | IPP_PRINTER_BUSY, |
501b59e2 | 301 | IPP_ERROR_JOB_CANCELLED, |
7b1b1c6e | 302 | IPP_MULTIPLE_JOBS_NOT_SUPPORTED, |
303 | IPP_PRINTER_IS_DEACTIVATED | |
3a193f5e | 304 | } ipp_status_t; |
305 | ||
7551914d | 306 | typedef unsigned char ipp_uchar_t;/**** Unsigned 8-bit integer/character ****/ |
3a193f5e | 307 | |
50146867 | 308 | typedef union /**** Request Header ****/ |
3a193f5e | 309 | { |
3b960317 | 310 | struct /* Any Header */ |
311 | { | |
7551914d | 312 | ipp_uchar_t version[2]; /* Protocol version number */ |
3b960317 | 313 | int op_status; /* Operation ID or status code*/ |
314 | int request_id; /* Request ID */ | |
315 | } any; | |
316 | ||
50146867 | 317 | struct /* Operation Header */ |
318 | { | |
7551914d | 319 | ipp_uchar_t version[2]; /* Protocol version number */ |
50146867 | 320 | ipp_op_t operation_id; /* Operation ID */ |
321 | int request_id; /* Request ID */ | |
322 | } op; | |
323 | ||
324 | struct /* Status Header */ | |
325 | { | |
7551914d | 326 | ipp_uchar_t version[2]; /* Protocol version number */ |
50146867 | 327 | ipp_status_t status_code; /* Status code */ |
328 | int request_id; /* Request ID */ | |
329 | } status; | |
3a193f5e | 330 | } ipp_request_t; |
331 | ||
3a193f5e | 332 | |
333 | typedef union /**** Attribute Value ****/ | |
334 | { | |
50146867 | 335 | int integer; /* Integer/enumerated value */ |
3a193f5e | 336 | |
337 | char boolean; /* Boolean value */ | |
338 | ||
7551914d | 339 | ipp_uchar_t date[11]; /* Date/time value */ |
3a193f5e | 340 | |
341 | struct | |
342 | { | |
343 | int xres, /* Horizontal resolution */ | |
344 | yres; /* Vertical resolution */ | |
50146867 | 345 | ipp_res_t units; /* Resolution units */ |
3a193f5e | 346 | } resolution; /* Resolution value */ |
347 | ||
348 | struct | |
349 | { | |
350 | int lower, /* Lower value */ | |
351 | upper; /* Upper value */ | |
352 | } range; /* Range of integers value */ | |
353 | ||
354 | struct | |
355 | { | |
356 | char *charset; /* Character set */ | |
58ec2a95 | 357 | char *text; /* String */ |
358 | } string; /* String with language value */ | |
cb1f28d6 | 359 | |
360 | struct | |
361 | { | |
362 | int length; /* Length of attribute */ | |
363 | void *data; /* Data in attribute */ | |
364 | } unknown; /* Unknown attribute type */ | |
3a193f5e | 365 | } ipp_value_t; |
366 | ||
367 | typedef struct ipp_attribute_s /**** Attribute ****/ | |
368 | { | |
acf4f738 | 369 | struct ipp_attribute_s *next; /* Next attribute in list */ |
3a193f5e | 370 | ipp_tag_t group_tag, /* Job/Printer/Operation group tag */ |
371 | value_tag; /* What type of value is it? */ | |
372 | char *name; /* Name of attribute */ | |
373 | int num_values; /* Number of values */ | |
374 | ipp_value_t values[1]; /* Values */ | |
375 | } ipp_attribute_t; | |
376 | ||
377 | typedef struct /**** Request State ****/ | |
378 | { | |
379 | ipp_state_t state; /* State of request */ | |
380 | ipp_request_t request; /* Request header */ | |
50146867 | 381 | ipp_attribute_t *attrs, /* Attributes */ |
382 | *last, /* Last attribute in list */ | |
383 | *current; /* Current attribute (for read/write) */ | |
3b960317 | 384 | ipp_tag_t curtag; /* Current attribute group tag */ |
3a193f5e | 385 | } ipp_t; |
386 | ||
387 | ||
388 | /* | |
389 | * Prototypes... | |
390 | */ | |
391 | ||
063e1ac7 | 392 | extern ipp_attribute_t *ippAddBoolean(ipp_t *ipp, ipp_tag_t group, const char *name, char value); |
393 | extern ipp_attribute_t *ippAddBooleans(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const char *values); | |
3dab5e3b | 394 | extern ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group, const char *name, const ipp_uchar_t *value); |
063e1ac7 | 395 | extern ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int value); |
396 | extern ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const int *values); | |
397 | extern ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group, const char *name, int lower, int upper); | |
398 | extern ipp_attribute_t *ippAddRanges(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const int *lower, const int *upper); | |
399 | extern ipp_attribute_t *ippAddResolution(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_res_t units, int xres, int yres); | |
400 | extern ipp_attribute_t *ippAddResolutions(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, ipp_res_t units, const int *xres, const int *yres); | |
5356dc5a | 401 | extern ipp_attribute_t *ippAddSeparator(ipp_t *ipp); |
063e1ac7 | 402 | extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, const char *charset, const char *value); |
403 | extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const char *charset, const char **values); | |
9aebebc3 | 404 | extern time_t ippDateToTime(const ipp_uchar_t *date); |
50146867 | 405 | extern void ippDelete(ipp_t *ipp); |
9aebebc3 | 406 | extern const char *ippErrorString(ipp_status_t error); |
fbd4fc3f | 407 | extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, const char *name, |
408 | ipp_tag_t type); | |
409 | extern ipp_attribute_t *ippFindNextAttribute(ipp_t *ipp, const char *name, | |
410 | ipp_tag_t type); | |
50146867 | 411 | extern size_t ippLength(ipp_t *ipp); |
412 | extern ipp_t *ippNew(void); | |
3b960317 | 413 | extern ipp_state_t ippRead(http_t *http, ipp_t *ipp); |
063e1ac7 | 414 | extern const ipp_uchar_t *ippTimeToDate(time_t t); |
3b960317 | 415 | extern ipp_state_t ippWrite(http_t *http, ipp_t *ipp); |
4a73831b | 416 | extern int ippPort(void); |
c68b6ae8 | 417 | extern void ippSetPort(int p); |
3a193f5e | 418 | |
e09246c8 | 419 | extern ipp_attribute_t *_ipp_add_attr(ipp_t *, int); |
a3e17a89 | 420 | extern void _ipp_free_attr(ipp_attribute_t *); |
e09246c8 | 421 | |
422 | ||
3a193f5e | 423 | /* |
424 | * C++ magic... | |
425 | */ | |
dec2f757 | 426 | |
3a193f5e | 427 | # ifdef __cplusplus |
428 | } | |
429 | # endif /* __cplusplus */ | |
430 | #endif /* !_CUPS_IPP_H_ */ | |
dec2f757 | 431 | |
432 | /* | |
997fbfa7 | 433 | * End of "$Id: ipp.h,v 1.45 2002/12/17 18:56:42 swdev Exp $". |
dec2f757 | 434 | */ |