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