]>
Commit | Line | Data |
---|---|---|
dec2f757 | 1 | /* |
58ec2a95 | 2 | * "$Id: ipp.h,v 1.8 1999/03/21 02:10:03 mike Exp $" |
dec2f757 | 3 | * |
3a193f5e | 4 | * Internet Printing Protocol definitions for the Common UNIX Printing |
5 | * System (CUPS). | |
dec2f757 | 6 | * |
3a193f5e | 7 | * Copyright 1997-1999 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 | ||
3a193f5e | 33 | # include <cups/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 | ||
3b960317 | 52 | /* |
53 | * Common limits... | |
54 | */ | |
55 | ||
5356dc5a | 56 | # define IPP_MAX_NAME 256 |
3b960317 | 57 | # define IPP_MAX_VALUES 100 |
58 | ||
59 | ||
3a193f5e | 60 | /* |
61 | * Types and structures... | |
62 | */ | |
63 | ||
64 | typedef enum /**** Format tags for attribute formats... ****/ | |
65 | { | |
66 | IPP_TAG_ZERO = 0x00, | |
67 | IPP_TAG_OPERATION, | |
68 | IPP_TAG_JOB, | |
3a193f5e | 69 | IPP_TAG_END, |
50146867 | 70 | IPP_TAG_PRINTER, |
71 | IPP_TAG_EXTENSION, | |
72 | IPP_TAG_UNSUPPORTED = 0x10, | |
73 | IPP_TAG_DEFAULT, | |
74 | IPP_TAG_UNKNOWN, | |
75 | IPP_TAG_NOVALUE, | |
3a193f5e | 76 | IPP_TAG_INTEGER = 0x21, |
77 | IPP_TAG_BOOLEAN, | |
78 | IPP_TAG_ENUM, | |
79 | IPP_TAG_STRING = 0x30, | |
80 | IPP_TAG_DATE, | |
81 | IPP_TAG_RESOLUTION, | |
82 | IPP_TAG_RANGE, | |
83 | IPP_TAG_TEXTLANG, | |
84 | IPP_TAG_NAMELANG, | |
85 | IPP_TAG_TEXT = 0x41, | |
86 | IPP_TAG_NAME, | |
87 | IPP_TAG_KEYWORD, | |
88 | IPP_TAG_URI, | |
89 | IPP_TAG_URISCHEME, | |
90 | IPP_TAG_CHARSET, | |
91 | IPP_TAG_LANGUAGE, | |
92 | IPP_TAG_MIMETYPE | |
93 | } ipp_tag_t; | |
94 | ||
95 | typedef enum /**** Resolution units... ****/ | |
96 | { | |
97 | IPP_RES_PER_INCH = 3, | |
98 | IPP_RES_PER_CM | |
99 | } ipp_res_t; | |
100 | ||
50146867 | 101 | typedef enum /**** Multiple Document Handling ****/ |
102 | { | |
103 | IPP_DOC_SINGLE, | |
104 | IPP_DOC_UNCOLLATED, | |
105 | IPP_DOC_COLLATED, | |
106 | IPP_DOC_SEPARATE | |
107 | } ipp_doc_t; | |
108 | ||
109 | typedef enum /**** Finishings... ****/ | |
110 | { | |
111 | IPP_FINISH_NONE = 3, | |
112 | IPP_FINISH_STAPLE, | |
113 | IPP_FINISH_PUNCH, | |
114 | IPP_FINISH_COVER, | |
115 | IPP_FINISH_BIND | |
116 | } ipp_finish_t; | |
117 | ||
118 | typedef enum /**** Duplex/Sides... ****/ | |
119 | { | |
120 | IPP_SIDES_ONE, | |
121 | IPP_SIDES_TWO_LONG_EDGE, | |
122 | IPP_SIDES_TWO_SHORT_EDGE | |
123 | } ipp_sides_t; | |
124 | ||
125 | typedef enum /**** Orientation... ****/ | |
126 | { | |
127 | IPP_PORTRAIT = 3, /* No rotation */ | |
128 | IPP_LANDSCAPE, /* 90 degrees counter-clockwise */ | |
129 | IPP_REVERSE_LANDSCAPE, /* 90 degrees clockwise */ | |
130 | IPP_REVERSE_PORTRAIT /* 180 degrees */ | |
131 | } ipp_orient_t; | |
132 | ||
133 | typedef enum /**** Qualities... ****/ | |
134 | { | |
135 | IPP_QUALITY_DRAFT = 3, | |
136 | IPP_QUALITY_NORMAL, | |
137 | IPP_QUALITY_HIGH | |
138 | } ipp_quality_t; | |
139 | ||
140 | typedef enum /**** Job States.... */ | |
141 | { | |
142 | IPP_JOB_PENDING = 3, | |
143 | IPP_JOB_HELD, | |
144 | IPP_JOB_PROCESSING, | |
145 | IPP_JOB_STOPPED, | |
146 | IPP_JOB_CANCELED, | |
147 | IPP_JOB_ABORTED, | |
148 | IPP_JOB_COMPLETED | |
3b960317 | 149 | } ipp_jstate_t; |
150 | ||
151 | typedef enum /**** Printer States.... */ | |
152 | { | |
153 | IPP_PRINTER_IDLE = 3, | |
154 | IPP_PRINTER_PROCESSING, | |
155 | IPP_PRINTER_STOPPED | |
156 | } ipp_pstate_t; | |
50146867 | 157 | |
3a193f5e | 158 | typedef enum /**** IPP states... ****/ |
159 | { | |
3b960317 | 160 | IPP_ERROR = -1, /* An error occurred */ |
161 | IPP_IDLE, /* Nothing is happening/request completed */ | |
162 | IPP_HEADER, /* The request header needs to be sent/received */ | |
163 | IPP_ATTRIBUTE, /* One or more attributes need to be sent/received */ | |
164 | IPP_DATA /* IPP request data needs to be sent/received */ | |
3a193f5e | 165 | } ipp_state_t; |
166 | ||
167 | typedef enum /**** IPP operations... ****/ | |
168 | { | |
169 | IPP_PRINT_JOB = 0x0002, | |
170 | IPP_PRINT_URI, | |
171 | IPP_VALIDATE_JOB, | |
172 | IPP_CREATE_JOB, | |
173 | IPP_SEND_DOCUMENT, | |
174 | IPP_SEND_URI, | |
175 | IPP_CANCEL_JOB, | |
176 | IPP_GET_JOB_ATTRIBUTES, | |
177 | IPP_GET_JOBS, | |
178 | IPP_GET_PRINTER_ATTRIBUTES, | |
5356dc5a | 179 | IPP_HOLD_JOB = 0x000c, |
180 | IPP_RELEASE_JOB, | |
181 | IPP_RESTART_JOB, | |
182 | IPP_PAUSE_PRINTER = 0x0010, | |
183 | IPP_RESUME_PRINTER, | |
184 | IPP_PURGE_JOBS, | |
3b960317 | 185 | IPP_PRIVATE = 0x4000, |
5356dc5a | 186 | CUPS_GET_DEFAULT, |
3b960317 | 187 | CUPS_GET_PRINTERS, |
188 | CUPS_ADD_PRINTER, | |
189 | CUPS_DELETE_PRINTER, | |
190 | CUPS_GET_CLASSES, | |
191 | CUPS_ADD_CLASS, | |
192 | CUPS_DELETE_CLASS | |
3a193f5e | 193 | } ipp_op_t; |
194 | ||
195 | typedef enum /**** IPP status codes... ****/ | |
196 | { | |
197 | IPP_OK = 0x0000, | |
198 | IPP_OK_SUBST, | |
199 | IPP_OK_CONFLICT, | |
200 | IPP_BAD_REQUEST = 0x0400, | |
201 | IPP_FORBIDDEN, | |
202 | IPP_NOT_AUTHENTICATED, | |
203 | IPP_NOT_AUTHORIZED, | |
204 | IPP_NOT_POSSIBLE, | |
205 | IPP_TIMEOUT, | |
206 | IPP_NOT_FOUND, | |
207 | IPP_GONE, | |
208 | IPP_REQUEST_ENTITY, | |
209 | IPP_REQUEST_VALUE, | |
210 | IPP_DOCUMENT_FORMAT, | |
211 | IPP_ATTRIBUTES, | |
212 | IPP_URI_SCHEME, | |
213 | IPP_CHARSET, | |
214 | IPP_CONFLICT, | |
215 | IPP_INTERNAL_ERROR = 0x0500, | |
216 | IPP_OPERATION_NOT_SUPPORTED, | |
217 | IPP_SERVICE_UNAVAILABLE, | |
218 | IPP_VERSION_NOT_SUPPORTED, | |
219 | IPP_DEVICE_UNAVAILABLE, | |
220 | IPP_TEMPORARY_ERROR, | |
221 | IPP_NOT_ACCEPTING, | |
222 | IPP_PRINTER_BUSY | |
223 | } ipp_status_t; | |
224 | ||
225 | typedef unsigned char uchar; /**** Unsigned 8-bit integer/character ****/ | |
226 | typedef unsigned short ushort; /**** Unsigned 16-bit integer ****/ | |
227 | typedef unsigned int uint; /**** Unsigned 32-bit integer ****/ | |
228 | ||
50146867 | 229 | typedef union /**** Request Header ****/ |
3a193f5e | 230 | { |
3b960317 | 231 | struct /* Any Header */ |
232 | { | |
233 | uchar version[2]; /* Protocol version number */ | |
234 | int op_status; /* Operation ID or status code*/ | |
235 | int request_id; /* Request ID */ | |
236 | } any; | |
237 | ||
50146867 | 238 | struct /* Operation Header */ |
239 | { | |
240 | uchar version[2]; /* Protocol version number */ | |
241 | ipp_op_t operation_id; /* Operation ID */ | |
242 | int request_id; /* Request ID */ | |
243 | } op; | |
244 | ||
245 | struct /* Status Header */ | |
246 | { | |
247 | uchar version[2]; /* Protocol version number */ | |
248 | ipp_status_t status_code; /* Status code */ | |
249 | int request_id; /* Request ID */ | |
250 | } status; | |
3a193f5e | 251 | } ipp_request_t; |
252 | ||
3a193f5e | 253 | |
254 | typedef union /**** Attribute Value ****/ | |
255 | { | |
50146867 | 256 | int integer; /* Integer/enumerated value */ |
3a193f5e | 257 | |
258 | char boolean; /* Boolean value */ | |
259 | ||
3a193f5e | 260 | uchar date[11]; /* Date/time value */ |
261 | ||
262 | struct | |
263 | { | |
264 | int xres, /* Horizontal resolution */ | |
265 | yres; /* Vertical resolution */ | |
50146867 | 266 | ipp_res_t units; /* Resolution units */ |
3a193f5e | 267 | } resolution; /* Resolution value */ |
268 | ||
269 | struct | |
270 | { | |
271 | int lower, /* Lower value */ | |
272 | upper; /* Upper value */ | |
273 | } range; /* Range of integers value */ | |
274 | ||
275 | struct | |
276 | { | |
277 | char *charset; /* Character set */ | |
58ec2a95 | 278 | char *text; /* String */ |
279 | } string; /* String with language value */ | |
3a193f5e | 280 | } ipp_value_t; |
281 | ||
282 | typedef struct ipp_attribute_s /**** Attribute ****/ | |
283 | { | |
284 | struct ipp_attribute_s *next; | |
285 | /* Next atrtribute in list */ | |
286 | ipp_tag_t group_tag, /* Job/Printer/Operation group tag */ | |
287 | value_tag; /* What type of value is it? */ | |
288 | char *name; /* Name of attribute */ | |
289 | int num_values; /* Number of values */ | |
290 | ipp_value_t values[1]; /* Values */ | |
291 | } ipp_attribute_t; | |
292 | ||
293 | typedef struct /**** Request State ****/ | |
294 | { | |
295 | ipp_state_t state; /* State of request */ | |
296 | ipp_request_t request; /* Request header */ | |
50146867 | 297 | ipp_attribute_t *attrs, /* Attributes */ |
298 | *last, /* Last attribute in list */ | |
299 | *current; /* Current attribute (for read/write) */ | |
3b960317 | 300 | ipp_tag_t curtag; /* Current attribute group tag */ |
3a193f5e | 301 | } ipp_t; |
302 | ||
303 | ||
304 | /* | |
305 | * Prototypes... | |
306 | */ | |
307 | ||
50146867 | 308 | extern time_t ippDateToTime(uchar *date); |
309 | extern ipp_attribute_t *ippAddBoolean(ipp_t *ipp, ipp_tag_t group, char *name, char value); | |
310 | extern ipp_attribute_t *ippAddBooleans(ipp_t *ipp, ipp_tag_t group, char *name, int num_values, char *values); | |
311 | extern ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group, char *name, uchar *value); | |
58ec2a95 | 312 | extern ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, char *name, int value); |
313 | extern ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, char *name, int num_values, int *values); | |
50146867 | 314 | extern ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group, char *name, int lower, int upper); |
5356dc5a | 315 | extern ipp_attribute_t *ippAddRanges(ipp_t *ipp, ipp_tag_t group, char *name, int num_values, int *lower, int *upper); |
50146867 | 316 | extern ipp_attribute_t *ippAddResolution(ipp_t *ipp, ipp_tag_t group, char *name, ipp_res_t units, int xres, int yres); |
5356dc5a | 317 | extern ipp_attribute_t *ippAddResolutions(ipp_t *ipp, ipp_tag_t group, char *name, int num_values, ipp_res_t units, int *xres, int *yres); |
318 | extern ipp_attribute_t *ippAddSeparator(ipp_t *ipp); | |
58ec2a95 | 319 | extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, char *name, char *charset, char *value); |
320 | extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, char *name, int num_values, char *charset, char **values); | |
50146867 | 321 | extern void ippDelete(ipp_t *ipp); |
58ec2a95 | 322 | extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, char *name, ipp_tag_t type); |
50146867 | 323 | extern size_t ippLength(ipp_t *ipp); |
324 | extern ipp_t *ippNew(void); | |
3b960317 | 325 | extern ipp_state_t ippRead(http_t *http, ipp_t *ipp); |
50146867 | 326 | extern uchar *ippTimeToDate(time_t t); |
3b960317 | 327 | extern ipp_state_t ippWrite(http_t *http, ipp_t *ipp); |
4a73831b | 328 | extern int ippPort(void); |
3a193f5e | 329 | |
330 | /* | |
331 | * C++ magic... | |
332 | */ | |
dec2f757 | 333 | |
3a193f5e | 334 | # ifdef __cplusplus |
335 | } | |
336 | # endif /* __cplusplus */ | |
337 | #endif /* !_CUPS_IPP_H_ */ | |
dec2f757 | 338 | |
339 | /* | |
58ec2a95 | 340 | * End of "$Id: ipp.h,v 1.8 1999/03/21 02:10:03 mike Exp $". |
dec2f757 | 341 | */ |