2 * Side-channel API definitions for CUPS.
4 * Copyright 2007-2012 by Apple Inc.
5 * Copyright 2006 by Easy Software Products.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
10 #ifndef _CUPS_SIDECHANNEL_H_
11 # define _CUPS_SIDECHANNEL_H_
14 * Include necessary headers...
17 # include "versioning.h"
26 # endif /* __cplusplus */
33 #define CUPS_SC_FD 4 /* File descriptor for select/poll */
40 enum cups_sc_bidi_e
/**** Bidirectional capability values ****/
42 CUPS_SC_BIDI_NOT_SUPPORTED
= 0, /* Bidirectional I/O is not supported */
43 CUPS_SC_BIDI_SUPPORTED
= 1 /* Bidirectional I/O is supported */
45 typedef enum cups_sc_bidi_e cups_sc_bidi_t
;
46 /**** Bidirectional capabilities ****/
48 enum cups_sc_command_e
/**** Request command codes ****/
50 CUPS_SC_CMD_NONE
= 0, /* No command @private@ */
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 */
55 CUPS_SC_CMD_GET_STATE
= 5, /* Return the device state */
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@ */
59 CUPS_SC_CMD_MAX
/* End of valid values @private@ */
61 typedef enum cups_sc_command_e cups_sc_command_t
;
62 /**** Request command codes ****/
64 enum cups_sc_connected_e
/**** Connectivity values ****/
66 CUPS_SC_NOT_CONNECTED
= 0, /* Backend is not "connected" to printer */
67 CUPS_SC_CONNECTED
= 1 /* Backend is "connected" to printer */
69 typedef enum cups_sc_connected_e cups_sc_connected_t
;
70 /**** Connectivity values ****/
73 enum cups_sc_state_e
/**** Printer state bits ****/
75 CUPS_SC_STATE_OFFLINE
= 0, /* Device is offline */
76 CUPS_SC_STATE_ONLINE
= 1, /* Device is online */
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 */
84 typedef enum cups_sc_state_e cups_sc_state_t
;
85 /**** Printer state bits ****/
87 enum cups_sc_status_e
/**** Response status codes ****/
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 */
98 typedef enum cups_sc_status_e cups_sc_status_t
;
99 /**** Response status codes ****/
101 typedef void (*cups_sc_walk_func_t
)(const char *oid
, const char *data
,
102 int datalen
, void *context
);
103 /**** SNMP walk callback ****/
110 extern cups_sc_status_t
cupsSideChannelDoRequest(cups_sc_command_t command
,
111 char *data
, int *datalen
,
112 double timeout
) _CUPS_API_1_3
;
113 extern int cupsSideChannelRead(cups_sc_command_t
*command
,
114 cups_sc_status_t
*status
,
115 char *data
, int *datalen
,
116 double timeout
) _CUPS_API_1_3
;
117 extern int cupsSideChannelWrite(cups_sc_command_t command
,
118 cups_sc_status_t status
,
119 const char *data
, int datalen
,
120 double timeout
) _CUPS_API_1_3
;
122 /**** New in CUPS 1.4 ****/
123 extern cups_sc_status_t
cupsSideChannelSNMPGet(const char *oid
, char *data
,
124 int *datalen
, double timeout
)
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
;
133 # endif /* __cplusplus */
135 #endif /* !_CUPS_SIDECHANNEL_H_ */