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