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