]>
Commit | Line | Data |
---|---|---|
f7deaa1a | 1 | /* |
503b54c9 | 2 | * Side-channel API definitions for CUPS. |
f7deaa1a | 3 | * |
503b54c9 MS |
4 | * Copyright 2007-2012 by Apple Inc. |
5 | * Copyright 2006 by Easy Software Products. | |
f7deaa1a | 6 | * |
e3101897 | 7 | * Licensed under Apache License v2.0. See the file "LICENSE" for more information. |
f7deaa1a | 8 | */ |
9 | ||
10 | #ifndef _CUPS_SIDECHANNEL_H_ | |
11 | # define _CUPS_SIDECHANNEL_H_ | |
12 | ||
2fb76298 MS |
13 | /* |
14 | * Include necessary headers... | |
15 | */ | |
16 | ||
17 | # include "versioning.h" | |
18 | ||
19 | ||
f7deaa1a | 20 | /* |
21 | * C++ magic... | |
22 | */ | |
23 | ||
24 | # ifdef __cplusplus | |
25 | extern "C" { | |
26 | # endif /* __cplusplus */ | |
27 | ||
28 | ||
29 | /* | |
30 | * Constants... | |
31 | */ | |
32 | ||
33 | #define CUPS_SC_FD 4 /* File descriptor for select/poll */ | |
34 | ||
35 | ||
36 | /* | |
37 | * Enumerations... | |
38 | */ | |
39 | ||
79e1d494 | 40 | enum cups_sc_bidi_e /**** Bidirectional capability values ****/ |
f7deaa1a | 41 | { |
42 | CUPS_SC_BIDI_NOT_SUPPORTED = 0, /* Bidirectional I/O is not supported */ | |
43 | CUPS_SC_BIDI_SUPPORTED = 1 /* Bidirectional I/O is supported */ | |
5a738aea MS |
44 | }; |
45 | typedef enum cups_sc_bidi_e cups_sc_bidi_t; | |
46 | /**** Bidirectional capabilities ****/ | |
f7deaa1a | 47 | |
5a738aea | 48 | enum cups_sc_command_e /**** Request command codes ****/ |
f7deaa1a | 49 | { |
18ecb428 | 50 | CUPS_SC_CMD_NONE = 0, /* No command @private@ */ |
f7deaa1a | 51 | CUPS_SC_CMD_SOFT_RESET = 1, /* Do a soft reset */ |
52 | CUPS_SC_CMD_DRAIN_OUTPUT = 2, /* Drain all pending output */ | |
53 | CUPS_SC_CMD_GET_BIDI = 3, /* Return bidirectional capabilities */ | |
54 | CUPS_SC_CMD_GET_DEVICE_ID = 4, /* Return the IEEE-1284 device ID */ | |
20fbc903 | 55 | CUPS_SC_CMD_GET_STATE = 5, /* Return the device state */ |
8072030b MS |
56 | CUPS_SC_CMD_SNMP_GET = 6, /* Query an SNMP OID @since CUPS 1.4/macOS 10.6@ */ |
57 | CUPS_SC_CMD_SNMP_GET_NEXT = 7, /* Query the next SNMP OID @since CUPS 1.4/macOS 10.6@ */ | |
58 | CUPS_SC_CMD_GET_CONNECTED = 8, /* Return whether the backend is "connected" to the printer @since CUPS 1.5/macOS 10.7@ */ | |
f14324a7 | 59 | CUPS_SC_CMD_MAX /* End of valid values @private@ */ |
5a738aea MS |
60 | }; |
61 | typedef enum cups_sc_command_e cups_sc_command_t; | |
62 | /**** Request command codes ****/ | |
f7deaa1a | 63 | |
f14324a7 MS |
64 | enum cups_sc_connected_e /**** Connectivity values ****/ |
65 | { | |
66 | CUPS_SC_NOT_CONNECTED = 0, /* Backend is not "connected" to printer */ | |
67 | CUPS_SC_CONNECTED = 1 /* Backend is "connected" to printer */ | |
68 | }; | |
69 | typedef enum cups_sc_connected_e cups_sc_connected_t; | |
70 | /**** Connectivity values ****/ | |
71 | ||
72 | ||
5a738aea | 73 | enum cups_sc_state_e /**** Printer state bits ****/ |
f7deaa1a | 74 | { |
79e1d494 MS |
75 | CUPS_SC_STATE_OFFLINE = 0, /* Device is offline */ |
76 | CUPS_SC_STATE_ONLINE = 1, /* Device is online */ | |
f7deaa1a | 77 | CUPS_SC_STATE_BUSY = 2, /* Device is busy */ |
78 | CUPS_SC_STATE_ERROR = 4, /* Other error condition */ | |
79 | CUPS_SC_STATE_MEDIA_LOW = 16, /* Paper low condition */ | |
80 | CUPS_SC_STATE_MEDIA_EMPTY = 32, /* Paper out condition */ | |
81 | CUPS_SC_STATE_MARKER_LOW = 64, /* Toner/ink low condition */ | |
82 | CUPS_SC_STATE_MARKER_EMPTY = 128 /* Toner/ink out condition */ | |
5a738aea MS |
83 | }; |
84 | typedef enum cups_sc_state_e cups_sc_state_t; | |
85 | /**** Printer state bits ****/ | |
f7deaa1a | 86 | |
5a738aea | 87 | enum cups_sc_status_e /**** Response status codes ****/ |
f7deaa1a | 88 | { |
89 | CUPS_SC_STATUS_NONE, /* No status */ | |
90 | CUPS_SC_STATUS_OK, /* Operation succeeded */ | |
91 | CUPS_SC_STATUS_IO_ERROR, /* An I/O error occurred */ | |
92 | CUPS_SC_STATUS_TIMEOUT, /* The backend did not respond */ | |
93 | CUPS_SC_STATUS_NO_RESPONSE, /* The device did not respond */ | |
94 | CUPS_SC_STATUS_BAD_MESSAGE, /* The command/response message was invalid */ | |
95 | CUPS_SC_STATUS_TOO_BIG, /* Response too big */ | |
96 | CUPS_SC_STATUS_NOT_IMPLEMENTED /* Command not implemented */ | |
5a738aea MS |
97 | }; |
98 | typedef enum cups_sc_status_e cups_sc_status_t; | |
99 | /**** Response status codes ****/ | |
f7deaa1a | 100 | |
20fbc903 MS |
101 | typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data, |
102 | int datalen, void *context); | |
103 | /**** SNMP walk callback ****/ | |
104 | ||
f7deaa1a | 105 | |
106 | /* | |
107 | * Prototypes... | |
108 | */ | |
109 | ||
110 | extern cups_sc_status_t cupsSideChannelDoRequest(cups_sc_command_t command, | |
111 | char *data, int *datalen, | |
2fb76298 | 112 | double timeout) _CUPS_API_1_3; |
f7deaa1a | 113 | extern int cupsSideChannelRead(cups_sc_command_t *command, |
114 | cups_sc_status_t *status, | |
115 | char *data, int *datalen, | |
2fb76298 | 116 | double timeout) _CUPS_API_1_3; |
f7deaa1a | 117 | extern int cupsSideChannelWrite(cups_sc_command_t command, |
118 | cups_sc_status_t status, | |
119 | const char *data, int datalen, | |
2fb76298 | 120 | double timeout) _CUPS_API_1_3; |
f7deaa1a | 121 | |
20fbc903 MS |
122 | /**** New in CUPS 1.4 ****/ |
123 | extern cups_sc_status_t cupsSideChannelSNMPGet(const char *oid, char *data, | |
124 | int *datalen, double timeout) | |
125 | _CUPS_API_1_4; | |
126 | extern cups_sc_status_t cupsSideChannelSNMPWalk(const char *oid, double timeout, | |
127 | cups_sc_walk_func_t cb, | |
128 | void *context) _CUPS_API_1_4; | |
129 | ||
f7deaa1a | 130 | |
131 | # ifdef __cplusplus | |
132 | } | |
133 | # endif /* __cplusplus */ | |
134 | ||
135 | #endif /* !_CUPS_SIDECHANNEL_H_ */ |