]>
| Commit | Line | Data |
|---|---|---|
| ed486911 | 1 | /* |
| 7e86f2f6 | 2 | * Backend support definitions for CUPS. |
| ed486911 | 3 | * |
| 0813a2ce MS |
4 | * Copyright © 2021 by OpenPrinting |
| 5 | * Copyright © 2007-2021 by Apple Inc. | |
| 53f8d64f | 6 | * Copyright © 1997-2007 by Easy Software Products, all rights reserved. |
| ed486911 | 7 | * |
| 53f8d64f MS |
8 | * Licensed under Apache License v2.0. See the file "LICENSE" for more |
| 9 | * information. | |
| ed486911 | 10 | */ |
| 11 | ||
| 12 | #ifndef _CUPS_BACKEND_PRIVATE_H_ | |
| 13 | # define _CUPS_BACKEND_PRIVATE_H_ | |
| 14 | ||
| 15 | ||
| 16 | /* | |
| 17 | * Include necessary headers. | |
| 18 | */ | |
| 19 | ||
| cc754834 MS |
20 | # include <cups/cups-private.h> |
| 21 | # include <cups/snmp-private.h> | |
| ed486911 | 22 | # include <cups/backend.h> |
| f7deaa1a | 23 | # include <cups/sidechannel.h> |
| ed486911 | 24 | # include <signal.h> |
| 25 | ||
| ef55b745 MS |
26 | # ifdef __linux |
| 27 | # include <sys/ioctl.h> | |
| 28 | # include <linux/lp.h> | |
| 29 | # define IOCNR_GET_DEVICE_ID 1 | |
| 30 | # define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len) | |
| 31 | # include <linux/parport.h> | |
| 32 | # include <linux/ppdev.h> | |
| 33 | # include <unistd.h> | |
| 34 | # include <fcntl.h> | |
| 35 | # endif /* __linux */ | |
| 36 | ||
| 37 | # ifdef __sun | |
| 38 | # ifdef __sparc | |
| 39 | # include <sys/ecppio.h> | |
| 40 | # else | |
| 41 | # include <sys/ioccom.h> | |
| 42 | # include <sys/ecppsys.h> | |
| 43 | # endif /* __sparc */ | |
| 44 | # endif /* __sun */ | |
| 45 | ||
| ed486911 | 46 | |
| 47 | /* | |
| 48 | * C++ magic... | |
| 49 | */ | |
| 50 | ||
| d09495fa | 51 | # ifdef __cplusplus |
| ed486911 | 52 | extern "C" { |
| d09495fa | 53 | # endif /* __cplusplus */ |
| ed486911 | 54 | |
| 55 | ||
| 0813a2ce MS |
56 | /* |
| 57 | * Log messages in backend signal handlers or other places where stdio cannot | |
| 58 | * be used... | |
| 59 | */ | |
| 60 | ||
| 61 | # define backendMessage(msg) {const char *s = msg; write(2, s, strlen(s));} | |
| 62 | ||
| 63 | ||
| 91c84a35 MS |
64 | /* |
| 65 | * OID constants... | |
| 66 | */ | |
| 67 | ||
| 7a14d768 | 68 | /* Host MIB */ |
| 91c84a35 MS |
69 | #define CUPS_OID_mib2 1,3,6,1,2,1 |
| 70 | ||
| 749b1e90 MS |
71 | #define CUPS_OID_system CUPS_OID_mib2,1 |
| 72 | #define CUPS_OID_sysLocation CUPS_OID_system,6 | |
| 73 | ||
| 91c84a35 MS |
74 | #define CUPS_OID_host CUPS_OID_mib2,25 |
| 75 | ||
| 76 | #define CUPS_OID_hrSystem CUPS_OID_host,1 | |
| 77 | ||
| 78 | #define CUPS_OID_hrStorage CUPS_OID_host,2 | |
| 79 | ||
| 80 | #define CUPS_OID_hrDevice CUPS_OID_host,3 | |
| 81 | #define CUPS_OID_hrDeviceTable CUPS_OID_hrDevice,2 | |
| 82 | #define CUPS_OID_hrDeviceEntry CUPS_OID_hrDeviceTable,1 | |
| 83 | #define CUPS_OID_hrDeviceIndex CUPS_OID_hrDeviceEntry,1 | |
| 84 | #define CUPS_OID_hrDeviceType CUPS_OID_hrDeviceEntry,2 | |
| 85 | #define CUPS_OID_hrDeviceDescr CUPS_OID_hrDeviceEntry,3 | |
| 86 | ||
| 87 | #define CUPS_OID_hrPrinterTable CUPS_OID_hrDevice,5 | |
| 88 | #define CUPS_OID_hrPrinterEntry CUPS_OID_hrPrinterTable,1 | |
| 89 | #define CUPS_OID_hrPrinterStatus CUPS_OID_hrPrinterEntry,1 | |
| 90 | #define CUPS_OID_hrPrinterDetectedErrorState CUPS_OID_hrPrinterEntry,2 | |
| 91 | ||
| 7a14d768 | 92 | /* Printer MIB */ |
| 91c84a35 MS |
93 | #define CUPS_OID_printmib CUPS_OID_mib2,43 |
| 94 | ||
| 95 | #define CUPS_OID_prtGeneral CUPS_OID_printmib,5 | |
| 96 | #define CUPS_OID_prtGeneralTable CUPS_OID_prtGeneral,1 | |
| 97 | #define CUPS_OID_prtGeneralEntry CUPS_OID_prtGeneralTable,1 | |
| 68b10830 | 98 | #define CUPS_OID_prtGeneralCurrentLocalization CUPS_OID_prtGeneralEntry,2 |
| 91c84a35 MS |
99 | #define CUPS_OID_prtGeneralPrinterName CUPS_OID_prtGeneralEntry,16 |
| 100 | #define CUPS_OID_prtGeneralSerialNumber CUPS_OID_prtGeneralEntry,17 | |
| 101 | ||
| 102 | #define CUPS_OID_prtCover CUPS_OID_printmib,6 | |
| 103 | #define CUPS_OID_prtCoverTable CUPS_OID_prtCover,1 | |
| 104 | #define CUPS_OID_prtCoverEntry CUPS_OID_prtCoverTable,1 | |
| 105 | #define CUPS_OID_prtCoverDescription CUPS_OID_prtCoverEntry,2 | |
| 106 | #define CUPS_OID_prtCoverStatus CUPS_OID_prtCoverEntry,3 | |
| 107 | ||
| 68b10830 MS |
108 | #define CUPS_OID_prtLocalization CUPS_OID_printmib,7 |
| 109 | #define CUPS_OID_prtLocalizationTable CUPS_OID_prtLocalization,1 | |
| 110 | #define CUPS_OID_prtLocalizationEntry CUPS_OID_prtLocalizationTable,1 | |
| 111 | #define CUPS_OID_prtLocalizationCharacterSet CUPS_OID_prtLocalizationEntry,4 | |
| 112 | ||
| 91c84a35 MS |
113 | #define CUPS_OID_prtMarker CUPS_OID_printmib,10 |
| 114 | #define CUPS_OID_prtMarkerTable CUPS_OID_prtMarker,2 | |
| 115 | #define CUPS_OID_prtMarkerEntry CUPS_OID_prtMarkerTable,1 | |
| 116 | #define CUPS_OID_prtMarkerLifeCount CUPS_OID_prtMarkerEntry,4 | |
| 117 | ||
| 118 | #define CUPS_OID_prtMarkerSupplies CUPS_OID_printmib,11 | |
| 119 | #define CUPS_OID_prtMarkerSuppliesTable CUPS_OID_prtMarkerSupplies,1 | |
| 120 | #define CUPS_OID_prtMarkerSuppliesEntry CUPS_OID_prtMarkerSuppliesTable,1 | |
| 121 | #define CUPS_OID_prtMarkerSuppliesIndex CUPS_OID_prtMarkerSuppliesEntry,1 | |
| 122 | #define CUPS_OID_prtMarkerSuppliesMarkerIndex CUPS_OID_prtMarkerSuppliesEntry,2 | |
| 123 | #define CUPS_OID_prtMarkerSuppliesColorantIndex CUPS_OID_prtMarkerSuppliesEntry,3 | |
| 124 | #define CUPS_OID_prtMarkerSuppliesClass CUPS_OID_prtMarkerSuppliesEntry,4 | |
| 125 | #define CUPS_OID_prtMarkerSuppliesType CUPS_OID_prtMarkerSuppliesEntry,5 | |
| 126 | #define CUPS_OID_prtMarkerSuppliesDescription CUPS_OID_prtMarkerSuppliesEntry,6 | |
| 127 | #define CUPS_OID_prtMarkerSuppliesSupplyUnit CUPS_OID_prtMarkerSuppliesEntry,7 | |
| 568fa3fa MS |
128 | #define CUPS_OID_prtMarkerSuppliesMaxCapacity CUPS_OID_prtMarkerSuppliesEntry,8 |
| 129 | #define CUPS_OID_prtMarkerSuppliesLevel CUPS_OID_prtMarkerSuppliesEntry,9 | |
| 91c84a35 MS |
130 | |
| 131 | #define CUPS_OID_prtMarkerColorant CUPS_OID_printmib,12 | |
| 132 | #define CUPS_OID_prtMarkerColorantTable CUPS_OID_prtMarkerColorant,1 | |
| 133 | #define CUPS_OID_prtMarkerColorantEntry CUPS_OID_prtMarkerColorantTable,1 | |
| 134 | #define CUPS_OID_prtMarkerColorantIndex CUPS_OID_prtMarkerColorantEntry,1 | |
| 135 | #define CUPS_OID_prtMarkerColorantMarkerIndex CUPS_OID_prtMarkerColorantEntry,2 | |
| 136 | #define CUPS_OID_prtMarkerColorantRole CUPS_OID_prtMarkerColorantEntry,3 | |
| 137 | #define CUPS_OID_prtMarkerColorantValue CUPS_OID_prtMarkerColorantEntry,4 | |
| 138 | #define CUPS_OID_prtMarkerColorantTonality CUPS_OID_prtMarkerColorantEntry,5 | |
| 139 | ||
| 140 | #define CUPS_OID_prtInterpreter CUPS_OID_printmib,15 | |
| 141 | #define CUPS_OID_prtInterpreterTable CUPS_OID_prtInterpreter,1 | |
| 142 | #define CUPS_OID_prtInterpreterEntry CUPS_OID_prtInterpreterTable,1 | |
| 143 | #define CUPS_OID_prtInterpreterLangFamily CUPS_OID_prtInterpreterEntry,2 | |
| 144 | #define CUPS_OID_prtInterpreterLangLevel CUPS_OID_prtInterpreterEntry,3 | |
| 145 | ||
| 7a14d768 MS |
146 | /* Printer Port Monitor MIB */ |
| 147 | #define CUPS_OID_enterprises 1,3,6,1,4,1 | |
| 148 | #define CUPS_OID_pwg CUPS_OID_enterprises,2699,1 | |
| 149 | #define CUPS_OID_ppmMIB CUPS_OID_pwg,2 | |
| 150 | #define CUPS_OID_ppmMIBObjects CUPS_OID_ppmMIB,1 | |
| 151 | ||
| 152 | #define CUPS_OID_ppmGeneral CUPS_OID_ppmMIBObjects,1 | |
| 153 | ||
| 154 | #define CUPS_OID_ppmPrinter CUPS_OID_ppmMIBObjects,2 | |
| 155 | #define CUPS_OID_ppmPrinterTable CUPS_OID_ppmPrinter,1 | |
| 156 | #define CUPS_OID_ppmPrinterEntry CUPS_OID_ppmPrinterTable,1 | |
| 157 | #define CUPS_OID_ppmPrinterIndex CUPS_OID_ppmPrinterEntry,1 | |
| 158 | #define CUPS_OID_ppmPrinterName CUPS_OID_ppmPrinterEntry,2 | |
| 159 | #define CUPS_OID_ppmPrinterIEEE1284DeviceId CUPS_OID_ppmPrinterEntry,3 | |
| 160 | #define CUPS_OID_ppmPrinterNumberOfPorts CUPS_OID_ppmPrinterEntry,4 | |
| 161 | #define CUPS_OID_ppmPrinterPreferredPortIndex CUPS_OID_ppmPrinterEntry,5 | |
| 162 | #define CUPS_OID_ppmPrinterHrDeviceIndex CUPS_OID_ppmPrinterEntry,6 | |
| 163 | #define CUPS_OID_ppmPrinterSnmpCommunityName CUPS_OID_ppmPrinterEntry,7 | |
| 164 | #define CUPS_OID_ppmPrinterSnmpQueryEnabled CUPS_OID_ppmPrinterEntry,8 | |
| 165 | ||
| 166 | #define CUPS_OID_ppmPort CUPS_OID_ppmMIBObjects,3 | |
| 167 | #define CUPS_OID_ppmPortTable CUPS_OID_ppmPort,1 | |
| 168 | #define CUPS_OID_ppmPortEntry CUPS_OID_ppmPortTable,1 | |
| 169 | #define CUPS_OID_ppmPortIndex CUPS_OID_ppmPortEntry,1 | |
| 170 | #define CUPS_OID_ppmPortEnabled CUPS_OID_ppmPortEntry,2 | |
| 171 | #define CUPS_OID_ppmPortName CUPS_OID_ppmPortEntry,3 | |
| 172 | #define CUPS_OID_ppmPortServiceNameOrURI CUPS_OID_ppmPortEntry,4 | |
| 173 | #define CUPS_OID_ppmPortProtocolType CUPS_OID_ppmPortEntry,5 | |
| 174 | #define CUPS_OID_ppmPortProtocolTargetPort CUPS_OID_ppmPortEntry,6 | |
| 175 | #define CUPS_OID_ppmPortProtocolAltSourceEnabled CUPS_OID_ppmPortEntry,7 | |
| 176 | #define CUPS_OID_ppmPortPrtChannelIndex CUPS_OID_ppmPortEntry,8 | |
| 177 | #define CUPS_OID_ppmPortLprByteCountEnabled CUPS_OID_ppmPortEntry,9 | |
| 178 | ||
| 91c84a35 MS |
179 | |
| 180 | /* | |
| 181 | * State constants... | |
| 182 | */ | |
| 183 | ||
| 184 | #define CUPS_TC_other 1 | |
| 185 | #define CUPS_TC_unknown 2 | |
| 186 | ||
| 187 | #define CUPS_TC_idle 3 | |
| 188 | #define CUPS_TC_printing 4 | |
| 189 | #define CUPS_TC_warmup 5 | |
| 190 | ||
| 191 | /* These come from the hrPrinterDetectedErrorState OCTET-STRING */ | |
| 192 | #define CUPS_TC_lowPaper 0x8000 | |
| 193 | #define CUPS_TC_noPaper 0x4000 | |
| 194 | #define CUPS_TC_lowToner 0x2000 | |
| 195 | #define CUPS_TC_noToner 0x1000 | |
| 196 | #define CUPS_TC_doorOpen 0x0800 | |
| 197 | #define CUPS_TC_jammed 0x0400 | |
| 198 | #define CUPS_TC_offline 0x0200 | |
| 199 | #define CUPS_TC_serviceRequested 0x0100 | |
| 200 | #define CUPS_TC_inputTrayMissing 0x0080 | |
| 201 | #define CUPS_TC_outputTrayMissing 0x0040 | |
| 202 | #define CUPS_TC_markerSupplyMissing 0x0020 | |
| 203 | #define CUPS_TC_outputNearFull 0x0010 | |
| 204 | #define CUPS_TC_outputFull 0x0008 | |
| 205 | #define CUPS_TC_inputTrayEmpty 0x0004 | |
| 206 | #define CUPS_TC_overduePreventMaint 0x0002 | |
| 207 | ||
| 208 | #define CUPS_TC_prtCoverStatus_coverOpen 3 | |
| 209 | #define CUPS_TC_prtCoverStatus_coverClosed 4 | |
| 210 | #define CUPS_TC_prtCoverStatus_interlockOpen 5 | |
| 211 | #define CUPS_TC_prtCoverStatus_interlockClosed 6 | |
| 212 | ||
| 213 | #define CUPS_TC_langPCL 3 | |
| 214 | #define CUPS_TC_langHPGL 4 | |
| 215 | #define CUPS_TC_langPJL 5 | |
| 216 | #define CUPS_TC_langPS 6 | |
| 217 | #define CUPS_TC_langEscapeP 9 | |
| 218 | #define CUPS_TC_langCCITT 26 | |
| 219 | #define CUPS_TC_langLIPS 39 | |
| 220 | #define CUPS_TC_langTIFF 40 | |
| 221 | #define CUPS_TC_langPCLXL 47 | |
| 222 | #define CUPS_TC_langPDF 54 | |
| 223 | #define CUPS_TC_langJPEG 61 | |
| 224 | ||
| 5a738aea MS |
225 | #define CUPS_TC_supplyThatIsConsumed 3 |
| 226 | #define CUPS_TC_receptacleThatIsFilled 4 | |
| 227 | ||
| 228 | #define CUPS_TC_process 3 | |
| 229 | #define CUPS_TC_spot 4 | |
| 230 | ||
| 91c84a35 MS |
231 | #define CUPS_TC_toner 3 |
| 232 | #define CUPS_TC_wasteToner 4 | |
| 233 | #define CUPS_TC_ink 5 | |
| 234 | #define CUPS_TC_inkCartridge 6 | |
| 235 | #define CUPS_TC_inkRibbon 7 | |
| 236 | #define CUPS_TC_wasteInk 8 | |
| 237 | #define CUPS_TC_opc 9 | |
| 238 | #define CUPS_TC_developer 10 | |
| 239 | #define CUPS_TC_fuserOil 11 | |
| 240 | #define CUPS_TC_solidWax 12 | |
| 241 | #define CUPS_TC_ribbonWax 13 | |
| 242 | #define CUPS_TC_wasteWax 14 | |
| 243 | #define CUPS_TC_fuser 15 | |
| 244 | #define CUPS_TC_coronaWire 16 | |
| 245 | #define CUPS_TC_fuserOilWick 17 | |
| 246 | #define CUPS_TC_cleanerUnit 18 | |
| 247 | #define CUPS_TC_fuserCleaningPad 19 | |
| 248 | #define CUPS_TC_transferUnit 20 | |
| 249 | #define CUPS_TC_tonerCartridge 21 | |
| 250 | #define CUPS_TC_fuserOiler 22 | |
| 251 | #define CUPS_TC_water 23 | |
| 252 | #define CUPS_TC_wasteWater 24 | |
| 253 | #define CUPS_TC_glueWaterAdditive 25 | |
| 254 | #define CUPS_TC_wastePaper 26 | |
| 255 | #define CUPS_TC_bindingSupply 27 | |
| 256 | #define CUPS_TC_bandingSupply 28 | |
| 257 | #define CUPS_TC_stitchingWire 29 | |
| 258 | #define CUPS_TC_shrinkWrap 30 | |
| 259 | #define CUPS_TC_paperWrap 31 | |
| 260 | #define CUPS_TC_staples 32 | |
| 261 | #define CUPS_TC_inserts 33 | |
| 262 | #define CUPS_TC_covers 34 | |
| 263 | ||
| 82cc1f9a MS |
264 | #define CUPS_TC_tenThousandthsOfInches 3 |
| 265 | #define CUPS_TC_micrometers 4 | |
| 266 | #define CUPS_TC_impressions 7 | |
| 267 | #define CUPS_TC_sheets 8 | |
| 268 | #define CUPS_TC_hours 11 | |
| 269 | #define CUPS_TC_thousandthsOfOunces 12 | |
| 270 | #define CUPS_TC_tenthsOfGrams 13 | |
| d6b36f7f | 271 | #define CUPS_TC_hundredthsOfFluidOunces 14 |
| 82cc1f9a MS |
272 | #define CUPS_TC_tenthsOfMilliliters 15 |
| 273 | #define CUPS_TC_feet 16 | |
| 274 | #define CUPS_TC_meters 17 | |
| 275 | #define CUPS_TC_items 18 | |
| 276 | #define CUPS_TC_percent 19 | |
| 277 | ||
| 68b10830 MS |
278 | /* These come from RFC 3808 to define character sets we support */ |
| 279 | /* Also see http://www.iana.org/assignments/character-sets */ | |
| 280 | #define CUPS_TC_csASCII 3 | |
| 281 | #define CUPS_TC_csISOLatin1 4 | |
| 282 | #define CUPS_TC_csShiftJIS 17 | |
| 283 | #define CUPS_TC_csUTF8 106 | |
| 284 | #define CUPS_TC_csUnicode 1000 /* UCS2 BE */ | |
| 285 | #define CUPS_TC_csUCS4 1001 /* UCS4 BE */ | |
| 286 | #define CUPS_TC_csUnicodeASCII 1002 | |
| 287 | #define CUPS_TC_csUnicodeLatin1 1003 | |
| 288 | #define CUPS_TC_csUTF16BE 1013 | |
| 289 | #define CUPS_TC_csUTF16LE 1014 | |
| 290 | #define CUPS_TC_csUTF32 1017 | |
| 291 | #define CUPS_TC_csUTF32BE 1018 | |
| 292 | #define CUPS_TC_csUTF32LE 1019 | |
| a2326b5b | 293 | #define CUPS_TC_csWindows31J 2024 |
| 68b10830 | 294 | |
| 91c84a35 | 295 | |
| c8fef167 MS |
296 | /* |
| 297 | * Types... | |
| 298 | */ | |
| 299 | ||
| 300 | typedef int (*_cups_sccb_t)(int print_fd, int device_fd, int snmp_fd, | |
| 301 | http_addr_t *addr, int use_bc); | |
| 302 | ||
| 303 | ||
| ed486911 | 304 | /* |
| 305 | * Prototypes... | |
| 306 | */ | |
| 307 | ||
| 7a14d768 MS |
308 | extern void backendCheckSideChannel(int snmp_fd, http_addr_t *addr); |
| 309 | extern int backendDrainOutput(int print_fd, int device_fd); | |
| 310 | extern int backendGetDeviceID(int fd, char *device_id, | |
| 311 | int device_id_size, | |
| 312 | char *make_model, | |
| 313 | int make_model_size, | |
| 314 | const char *scheme, char *uri, | |
| 315 | int uri_size); | |
| 316 | extern int backendGetMakeModel(const char *device_id, | |
| 317 | char *make_model, | |
| 7e86f2f6 | 318 | size_t make_model_size); |
| f5cffc18 | 319 | extern http_addrlist_t *backendLookup(const char *hostname, int port, int *cancel); |
| 18ecb428 | 320 | extern int backendNetworkSideCB(int print_fd, int device_fd, |
| 7a14d768 MS |
321 | int snmp_fd, http_addr_t *addr, |
| 322 | int use_bc); | |
| 7a14d768 | 323 | extern ssize_t backendRunLoop(int print_fd, int device_fd, int snmp_fd, |
| c8fef167 MS |
324 | http_addr_t *addr, int use_bc, |
| 325 | int update_state, _cups_sccb_t side_cb); | |
| 7a14d768 MS |
326 | extern int backendSNMPSupplies(int snmp_fd, http_addr_t *addr, |
| 327 | int *page_count, | |
| 328 | int *printer_state); | |
| c8fef167 | 329 | extern int backendWaitLoop(int snmp_fd, http_addr_t *addr, |
| f14324a7 | 330 | int use_bc, _cups_sccb_t side_cb); |
| c8fef167 | 331 | |
| d09495fa | 332 | # ifdef __cplusplus |
| ed486911 | 333 | } |
| d09495fa | 334 | # endif /* __cplusplus */ |
| ed486911 | 335 | #endif /* !_CUPS_BACKEND_PRIVATE_H_ */ |