]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/ipp.h
Merge changes from 1.1.x into 1.2 devel.
[thirdparty/cups.git] / cups / ipp.h
CommitLineData
dec2f757 1/*
753453e4 2 * "$Id: ipp.h,v 1.36.2.3 2001/12/26 16:52:12 mike Exp $"
dec2f757 3 *
3a193f5e 4 * Internet Printing Protocol definitions for the Common UNIX Printing
5 * System (CUPS).
dec2f757 6 *
d2935a0f 7 * Copyright 1997-2001 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
dec2f757 24 */
25
3a193f5e 26#ifndef _CUPS_IPP_H_
27# define _CUPS_IPP_H_
28
dec2f757 29/*
30 * Include necessary headers...
31 */
32
183914a3 33# include "http.h"
3a193f5e 34
35
36/*
37 * C++ magic...
38 */
39
40# ifdef __cplusplus
41extern "C" {
42# endif /* __cplusplus */
43
44
45/*
46 * IPP version string...
47 */
48
49# define IPP_VERSION "\001\000"
50
20c7158b 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
3a193f5e 58
3b960317 59/*
60 * Common limits...
61 */
62
5356dc5a 63# define IPP_MAX_NAME 256
753453e4 64# define IPP_MAX_VALUES 10 /* Now just an allocation increment */
3b960317 65
66
3a193f5e 67/*
68 * Types and structures...
69 */
70
71typedef enum /**** Format tags for attribute formats... ****/
72{
73 IPP_TAG_ZERO = 0x00,
74 IPP_TAG_OPERATION,
75 IPP_TAG_JOB,
3a193f5e 76 IPP_TAG_END,
50146867 77 IPP_TAG_PRINTER,
714294b4 78 IPP_TAG_UNSUPPORTED_GROUP,
d2dd6522 79 IPP_TAG_SUBSCRIPTION,
80 IPP_TAG_EVENT_NOTIFICATION,
714294b4 81 IPP_TAG_UNSUPPORTED_VALUE = 0x10,
50146867 82 IPP_TAG_DEFAULT,
83 IPP_TAG_UNKNOWN,
84 IPP_TAG_NOVALUE,
a3e17a89 85 IPP_TAG_NOTSETTABLE = 0x15,
86 IPP_TAG_DELETEATTR,
d2dd6522 87 IPP_TAG_ADMINDEFINE,
3a193f5e 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,
d2dd6522 95 IPP_TAG_BEGIN_COLLECTION,
3a193f5e 96 IPP_TAG_TEXTLANG,
97 IPP_TAG_NAMELANG,
d2dd6522 98 IPP_TAG_END_COLLECTION,
3a193f5e 99 IPP_TAG_TEXT = 0x41,
100 IPP_TAG_NAME,
01bebed4 101 IPP_TAG_KEYWORD = 0x44,
3a193f5e 102 IPP_TAG_URI,
103 IPP_TAG_URISCHEME,
104 IPP_TAG_CHARSET,
105 IPP_TAG_LANGUAGE,
b6ea8f29 106 IPP_TAG_MIMETYPE,
d2dd6522 107 IPP_TAG_MEMBERNAME,
b5cb0608 108 IPP_TAG_MASK = 0x3fffffff, /* Mask for copied attribute values */
109 IPP_TAG_COPY = 0x40000000 /* Bitflag for copied attribute values */
3a193f5e 110} ipp_tag_t;
111
112typedef enum /**** Resolution units... ****/
113{
114 IPP_RES_PER_INCH = 3,
115 IPP_RES_PER_CM
116} ipp_res_t;
117
50146867 118typedef enum /**** Finishings... ****/
119{
d2dd6522 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
50146867 148} ipp_finish_t;
149
50146867 150typedef 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
158typedef enum /**** Qualities... ****/
159{
160 IPP_QUALITY_DRAFT = 3,
161 IPP_QUALITY_NORMAL,
162 IPP_QUALITY_HIGH
163} ipp_quality_t;
164
165typedef enum /**** Job States.... */
166{
167 IPP_JOB_PENDING = 3,
168 IPP_JOB_HELD,
169 IPP_JOB_PROCESSING,
170 IPP_JOB_STOPPED,
e09246c8 171 IPP_JOB_CANCELLED,
50146867 172 IPP_JOB_ABORTED,
173 IPP_JOB_COMPLETED
3b960317 174} ipp_jstate_t;
175
176typedef enum /**** Printer States.... */
177{
178 IPP_PRINTER_IDLE = 3,
179 IPP_PRINTER_PROCESSING,
180 IPP_PRINTER_STOPPED
181} ipp_pstate_t;
50146867 182
3a193f5e 183typedef enum /**** IPP states... ****/
184{
3b960317 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 */
3a193f5e 190} ipp_state_t;
191
192typedef 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,
9aebebc3 204 IPP_HOLD_JOB,
5356dc5a 205 IPP_RELEASE_JOB,
206 IPP_RESTART_JOB,
207 IPP_PAUSE_PRINTER = 0x0010,
208 IPP_RESUME_PRINTER,
209 IPP_PURGE_JOBS,
9cbd98eb 210 IPP_SET_PRINTER_ATTRIBUTES,
211 IPP_SET_JOB_ATTRIBUTES,
212 IPP_GET_PRINTER_SUPPORTED_VALUES,
d2dd6522 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,
3b960317 238 IPP_PRIVATE = 0x4000,
5356dc5a 239 CUPS_GET_DEFAULT,
3b960317 240 CUPS_GET_PRINTERS,
241 CUPS_ADD_PRINTER,
242 CUPS_DELETE_PRINTER,
243 CUPS_GET_CLASSES,
244 CUPS_ADD_CLASS,
d23a857a 245 CUPS_DELETE_CLASS,
246 CUPS_ACCEPT_JOBS,
3270670b 247 CUPS_REJECT_JOBS,
bd84e0d1 248 CUPS_SET_DEFAULT,
249 CUPS_GET_DEVICES,
a3e17a89 250 CUPS_GET_PPDS,
d2dd6522 251 CUPS_MOVE_JOB,
252 CUPS_ADD_DEVICE,
253 CUPS_DELETE_DEVICE
3a193f5e 254} ipp_op_t;
255
256typedef enum /**** IPP status codes... ****/
257{
258 IPP_OK = 0x0000,
259 IPP_OK_SUBST,
260 IPP_OK_CONFLICT,
7b1b1c6e 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,
3a193f5e 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,
cd7ca660 280 IPP_CONFLICT,
f213de35 281 IPP_COMPRESSION_NOT_SUPPORTED,
282 IPP_COMPRESSION_ERROR,
283 IPP_DOCUMENT_FORMAT_ERROR,
284 IPP_DOCUMENT_ACCESS_ERROR,
7b1b1c6e 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
3a193f5e 291 IPP_INTERNAL_ERROR = 0x0500,
292 IPP_OPERATION_NOT_SUPPORTED,
293 IPP_SERVICE_UNAVAILABLE,
294 IPP_VERSION_NOT_SUPPORTED,
f213de35 295 IPP_DEVICE_ERROR,
3a193f5e 296 IPP_TEMPORARY_ERROR,
297 IPP_NOT_ACCEPTING,
f213de35 298 IPP_PRINTER_BUSY,
501b59e2 299 IPP_ERROR_JOB_CANCELLED,
7b1b1c6e 300 IPP_MULTIPLE_JOBS_NOT_SUPPORTED,
301 IPP_PRINTER_IS_DEACTIVATED
3a193f5e 302} ipp_status_t;
303
7551914d 304typedef unsigned char ipp_uchar_t;/**** Unsigned 8-bit integer/character ****/
3a193f5e 305
50146867 306typedef union /**** Request Header ****/
3a193f5e 307{
3b960317 308 struct /* Any Header */
309 {
7551914d 310 ipp_uchar_t version[2]; /* Protocol version number */
3b960317 311 int op_status; /* Operation ID or status code*/
312 int request_id; /* Request ID */
313 } any;
314
50146867 315 struct /* Operation Header */
316 {
7551914d 317 ipp_uchar_t version[2]; /* Protocol version number */
50146867 318 ipp_op_t operation_id; /* Operation ID */
319 int request_id; /* Request ID */
320 } op;
321
322 struct /* Status Header */
323 {
7551914d 324 ipp_uchar_t version[2]; /* Protocol version number */
50146867 325 ipp_status_t status_code; /* Status code */
326 int request_id; /* Request ID */
327 } status;
3a193f5e 328} ipp_request_t;
329
3a193f5e 330
331typedef union /**** Attribute Value ****/
332{
50146867 333 int integer; /* Integer/enumerated value */
3a193f5e 334
335 char boolean; /* Boolean value */
336
7551914d 337 ipp_uchar_t date[11]; /* Date/time value */
3a193f5e 338
339 struct
340 {
341 int xres, /* Horizontal resolution */
342 yres; /* Vertical resolution */
50146867 343 ipp_res_t units; /* Resolution units */
3a193f5e 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 */
58ec2a95 355 char *text; /* String */
356 } string; /* String with language value */
cb1f28d6 357
358 struct
359 {
360 int length; /* Length of attribute */
361 void *data; /* Data in attribute */
362 } unknown; /* Unknown attribute type */
3a193f5e 363} ipp_value_t;
364
365typedef struct ipp_attribute_s /**** Attribute ****/
366{
753453e4 367 struct ipp_attribute_s *next; /* Next attribute in list */
3a193f5e 368 ipp_tag_t group_tag, /* Job/Printer/Operation group tag */
369 value_tag; /* What type of value is it? */
370 char *name; /* Name of attribute */
371 int num_values; /* Number of values */
372 ipp_value_t values[1]; /* Values */
373} ipp_attribute_t;
374
375typedef struct /**** Request State ****/
376{
377 ipp_state_t state; /* State of request */
378 ipp_request_t request; /* Request header */
50146867 379 ipp_attribute_t *attrs, /* Attributes */
380 *last, /* Last attribute in list */
381 *current; /* Current attribute (for read/write) */
3b960317 382 ipp_tag_t curtag; /* Current attribute group tag */
3a193f5e 383} ipp_t;
384
385
386/*
387 * Prototypes...
388 */
389
063e1ac7 390extern ipp_attribute_t *ippAddBoolean(ipp_t *ipp, ipp_tag_t group, const char *name, char value);
391extern ipp_attribute_t *ippAddBooleans(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const char *values);
3dab5e3b 392extern ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group, const char *name, const ipp_uchar_t *value);
063e1ac7 393extern ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int value);
394extern ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const int *values);
395extern ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group, const char *name, int lower, int upper);
396extern ipp_attribute_t *ippAddRanges(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const int *lower, const int *upper);
397extern ipp_attribute_t *ippAddResolution(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_res_t units, int xres, int yres);
398extern 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 399extern ipp_attribute_t *ippAddSeparator(ipp_t *ipp);
063e1ac7 400extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, const char *charset, const char *value);
401extern 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 402extern time_t ippDateToTime(const ipp_uchar_t *date);
50146867 403extern void ippDelete(ipp_t *ipp);
9aebebc3 404extern const char *ippErrorString(ipp_status_t error);
063e1ac7 405extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, const char *name, ipp_tag_t type);
50146867 406extern size_t ippLength(ipp_t *ipp);
407extern ipp_t *ippNew(void);
99de6da0 408extern int ippPort(void);
3b960317 409extern ipp_state_t ippRead(http_t *http, ipp_t *ipp);
99de6da0 410extern ipp_state_t ippReadFile(int fd, ipp_t *ipp);
411extern void ippSetPort(int p);
063e1ac7 412extern const ipp_uchar_t *ippTimeToDate(time_t t);
3b960317 413extern ipp_state_t ippWrite(http_t *http, ipp_t *ipp);
99de6da0 414extern ipp_state_t ippWriteFile(int fd, ipp_t *ipp);
3a193f5e 415
e09246c8 416extern ipp_attribute_t *_ipp_add_attr(ipp_t *, int);
a3e17a89 417extern void _ipp_free_attr(ipp_attribute_t *);
e09246c8 418
419
3a193f5e 420/*
421 * C++ magic...
422 */
dec2f757 423
3a193f5e 424# ifdef __cplusplus
425}
426# endif /* __cplusplus */
427#endif /* !_CUPS_IPP_H_ */
dec2f757 428
429/*
753453e4 430 * End of "$Id: ipp.h,v 1.36.2.3 2001/12/26 16:52:12 mike Exp $".
dec2f757 431 */