1 /*****************************************************************************\
\r
2 CommonDefinitions.h : common header
\r
4 Copyright (c) 1996 - 2009, Hewlett-Packard Co.
\r
7 Redistribution and use in source and binary forms, with or without
\r
8 modification, are permitted provided that the following conditions
\r
10 1. Redistributions of source code must retain the above copyright
\r
11 notice, this list of conditions and the following disclaimer.
\r
12 2. Redistributions in binary form must reproduce the above copyright
\r
13 notice, this list of conditions and the following disclaimer in the
\r
14 documentation and/or other materials provided with the distribution.
\r
15 3. Neither the name of Hewlett-Packard nor the names of its
\r
16 contributors may be used to endorse or promote products derived
\r
17 from this software without specific prior written permission.
\r
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
\r
20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
21 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
\r
22 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
\r
24 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
\r
25 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
30 Author: Naga Samrat Chowdary Narla,
\r
31 \*****************************************************************************/
\r
33 #ifndef COMMON_DEFINITIONS_H
\r
34 #define COMMON_DEFINITIONS_H
\r
37 #include <inttypes.h>
\r
39 //#include <machine/types.h>
\r
41 #include <sys/stat.h>
\r
42 #include <cups/cups.h>
\r
43 #include <cups/raster.h>
\r
51 #include <sys/timeb.h>
\r
59 #define SAVE_PCL_FILE 2
\r
60 #define SAVE_INPUT_RASTERS 4
\r
61 #define SEND_TO_PRINTER_ALSO 8
\r
63 #define MAX_COLORTYPE 2
\r
64 #define NUMBER_PLANES 3
\r
66 #define ASSERT assert
\r
68 #define _STRINGIZE(x) #x
\r
69 #define STRINGIZE(x) _STRINGIZE(x)
\r
71 #define dbglog(args...) {syslog(LOG_ERR, __FILE__ " " STRINGIZE(__LINE__) ": " args); \
\r
72 fprintf(stderr, __FILE__ " " STRINGIZE(__LINE__) ": " args);}
\r
75 typedef unsigned char BYTE;
\r
78 #define ABS(x) ( ((x)<0) ? -(x) : (x) )
\r
82 #define MIN(a,b) (((a)>=(b))?(b):(a))
\r
86 #define MAX(a,b) (((a)<=(b))?(b):(a))
\r
89 #ifdef APDK_LITTLE_ENDIAN
\r
90 #define GetRed(x) (((x >> 16) & 0x0FF))
\r
91 #define GetGreen(x) (((x >> 8) & 0x0FF))
\r
92 #define GetBlue(x) ((x & 0x0FF))
\r
94 #define GetRed(x) (((x >> 24) & 0x0FF))
\r
95 #define GetGreen(x) (((x >> 16) & 0x0FF))
\r
96 #define GetBlue(x) (((x >> 8) & 0x0FF))
\r
107 #define HIBYTE(sVar) (BYTE) ((sVar & 0xFF00) >> 8)
\r
108 #define LOBYTE(sVar) (BYTE) ((sVar & 0x00FF))
\r
110 #define LOWORD(l) ((unsigned short) (l))
\r
114 #define HIWORD(l) ((unsigned short) (((uint32_t) (l) >> 16) & 0xFFFF))
\r
117 #define PCL_BUFFER_SIZE 10000
\r
119 typedef unsigned short UInt16;
\r
120 typedef unsigned long UInt32;
\r
121 typedef unsigned char UChar;
\r
122 typedef unsigned int Int16;
\r
123 typedef long Int32;
\r
125 typedef struct RASTERDATA
\r
127 int rastersize[MAX_COLORTYPE];
\r
128 BYTE *rasterdata[MAX_COLORTYPE];
\r
131 const int MAXCOLORDEPTH = 3;
\r
133 const int MAXCOLORPLANES = 6; // current max anticipated, 6 for 690 photopen
\r
135 const int MAXCOLORROWS = 2; // multiple of high-to-low for mixed-resolution cases
\r
137 enum HALFTONING_ALGORITHM
\r
144 * values of DRIVER_ERROR
\r
145 * Values < 0 are warnings
\r
151 // general or system errors
\r
152 NO_ERROR = 0x00, //!< everything okay
\r
153 JOB_CANCELED = 0x01, //!< CANCEL chosen by user
\r
154 SYSTEM_ERROR = 0x02, //!< something bad that should not have happened
\r
155 ALLOCMEM_ERROR = 0x03, //!< failed to allocate memory
\r
156 NO_PRINTER_SELECTED = 0x04, //!< indicates improper calling sequence or unidi
\r
157 INDEX_OUT_OF_RANGE = 0x05, //!< what it says
\r
158 ILLEGAL_RESOLUTION = 0x06, //!< tried to set resolution at unacceptable value
\r
159 NULL_POINTER = 0x07, //!< supplied ptr was null
\r
160 MISSING_PENS = 0x08, //!< one or more printhead/pen missing
\r
163 // (items either absent from current build, or just bad index from client code)
\r
164 UNSUPPORTED_PRINTER = 0x10, //!< selected printer-type unsupported in build
\r
165 UNSUPPORTED_PEN = 0x11, //!< selected pen-type unsupported
\r
166 GRAPHICS_UNSUPPORTED = 0x13, //!< no graphics allowed in current build
\r
167 ILLEGAL_COORDS = 0x15, //!< bad (x,y) passed to TextOut
\r
168 BAD_INPUT_WIDTH = 0x18, //!< inputwidth is 0 and
\r
169 OUTPUTWIDTH_EXCEEDS_PAGEWIDTH = 0x19, //!< inputwidth exceeds printable width
\r
170 UNSUPPORTED_PRINTMODE = 0x19, //!< requested printmode not available
\r
173 IO_ERROR = 0x20, //!< I/O error communicating with printer
\r
174 BAD_DEVICE_ID = 0x21, //!< bad or garbled device id from printer
\r
175 CONTINUE_FROM_BLOCK = 0x22, //!< continue from blocked state for printers with no buttons
\r
178 PLUGIN_LIBRARY_MISSING = 0x30, //!< a required plugin (dynamic) library is missing
\r
181 // convention is that values < 0 can be ignored (at user's peril)
\r
182 WARN_MODE_MISMATCH = -1, //!< printmode selection incompatible with pen, tray, etc.
\r
183 WARN_DUPLEX = -2, //!< duplexer installed; our driver can't use it
\r
184 WARN_LOW_INK_BOTH_PENS= -3, //!< sensor says pens below threshold
\r
185 WARN_LOW_INK_BLACK = -4, //!< sensor says black pen below threshold
\r
186 WARN_LOW_INK_COLOR = -5, //!< sensor says color pen below threshold
\r
188 WARN_LOW_INK_PHOTO = -10, //!< sensor says photo pen below threshold
\r
189 WARN_LOW_INK_GREY = -11, //!< sensor says grey pen below threshold
\r
190 WARN_LOW_INK_BLACK_PHOTO = -12, //!< sensor says black and photo pens below threshold
\r
191 WARN_LOW_INK_COLOR_PHOTO = -13, //!< sensor says color and photo pens below threshold
\r
192 WARN_LOW_INK_GREY_PHOTO = -14, //!< sensor says grey and photo pens below threshold
\r
193 WARN_LOW_INK_COLOR_GREY = -15, //!< sensor says color and grey pens below threshold
\r
194 WARN_LOW_INK_COLOR_GREY_PHOTO = -16, //!< sensor says color, photo, and grey pens below threshold
\r
195 WARN_LOW_INK_COLOR_BLACK_PHOTO = -17, //!< sensor says color, photo, and black pens below threshold
\r
196 WARN_LOW_INK_CYAN = -18, //!< sensor says cyan ink below threshold
\r
197 WARN_LOW_INK_MAGENTA = -19, //!< sensor says magenta ink below threshold
\r
198 WARN_LOW_INK_YELLOW = -20, //!< sensor says yellow ink below threshold
\r
199 WARN_LOW_INK_MULTIPLE_PENS = - 21, //!< sensor says more than one pen below threshold
\r
200 WARN_ILLEGAL_PAPERSIZE = -8, //!< papersize illegal for given hardware
\r
201 ILLEGAL_PAPERSIZE = -8,
\r
202 WARN_INVALID_MEDIA_SOURCE = -9, //!< media source tray is invalid
\r
204 eCreate_Thread_Error = 128 //! Thread error creating the error....
\r
205 } DRIVER_ERROR; //DRIVER_ERROR
\r
220 // used to encourage consistent ordering of color planes
\r
227 #define kWhite 0x00FFFFFE
\r
235 #define RANDSEED 77
\r
238 * ZJStream related definitions
\r
241 typedef uint32_t DWORD;
\r
242 typedef unsigned short WORD;
\r
262 /* 0x00*/ ZJI_PAGECOUNT,
\r
263 /* 0x01*/ ZJI_DMCOLLATE,
\r
264 /* 0x02*/ ZJI_DMDUPLEX,
\r
266 /* 0x03*/ ZJI_DMPAPER,
\r
267 /* 0x04*/ ZJI_DMCOPIES,
\r
268 /* 0x05*/ ZJI_DMDEFAULTSOURCE,
\r
269 /* 0x06*/ ZJI_DMMEDIATYPE,
\r
270 /* 0x07*/ ZJI_NBIE,
\r
271 /* 0x08*/ ZJI_RESOLUTION_X,
\r
272 /* 0x09*/ ZJI_RESOLUTION_Y,
\r
273 /* 0x0A */ ZJI_OFFSET_X,
\r
274 /* 0x0B */ ZJI_OFFSET_Y,
\r
275 /* 0x0C */ ZJI_RASTER_X,
\r
276 /* 0x0D */ ZJI_RASTER_Y,
\r
278 /* 0x0E */ ZJI_COLLATE,
\r
279 /* 0x0F */ ZJI_QUANTITY,
\r
281 /* 0x10 */ ZJI_VIDEO_BPP,
\r
282 /* 0x11 */ ZJI_VIDEO_X,
\r
283 /* 0x12 */ ZJI_VIDEO_Y,
\r
284 /* 0x13 */ ZJI_INTERLACE,
\r
285 /* 0x14 */ ZJI_PLANE,
\r
286 /* 0x15 */ ZJI_PALETTE,
\r
288 /* 0x16 */ ZJI_RET,
\r
289 /* 0x17 */ ZJI_TONER_SAVE,
\r
291 /* 0x18 */ ZJI_MEDIA_SIZE_X,
\r
292 /* 0x19 */ ZJI_MEDIA_SIZE_Y,
\r
293 /* 0x1A */ ZJI_MEDIA_SIZE_UNITS,
\r
295 /* 0x1B */ ZJI_CHROMATIC,
\r
297 /* 0x63 */ ZJI_PAD = 99,
\r
299 /* 0x64 */ ZJI_PROMPT,
\r
301 /* 0x65 */ ZJI_BITMAP_TYPE,
\r
302 /* 0x66 */ ZJI_ENCODING_DATA,
\r
303 /* 0x67 */ ZJI_END_PLANE,
\r
305 /* 0x68 */ ZJI_BITMAP_PIXELS,
\r
306 /* 0x69 */ ZJI_BITMAP_LINES,
\r
307 /* 0x6A */ ZJI_BITMAP_BPP,
\r
308 /* 0x6B */ ZJI_BITMAP_STRIDE,
\r
330 // very frequently used fragments made into macros for readability
\r
331 #define CERRCHECK if (constructor_error != NO_ERROR) {dbglog("CERRCHECK fired\n"); return;}
\r
332 #define ERRCHECK if (err != NO_ERROR) {dbglog("ERRCHECK fired\n"); return err;}
\r
333 #define NEWCHECK(x) if (x==NULL) return ALLOCMEM_ERROR;
\r
334 #define CNEWCHECK(x) if (x==NULL) { constructor_error=ALLOCMEM_ERROR; return; }
\r
336 #define CUSTOM_MEDIA_SIZE 101
\r
338 #define EVENT_PRINT_FAILED_MISSING_PLUGIN 502
\r
341 COLORTYPE_COLOR, // 0
\r
342 COLORTYPE_BLACK, // 1
\r
346 typedef struct ColorMap_s
\r
350 unsigned char *ulMap3;
\r
355 COMPRESS_MODE0 = 0,
\r
356 COMPRESS_MODE2 = 2,
\r
357 COMPRESS_MODE9 = 9,
\r
358 COMPRESS_MODE_AUTO = 10,
\r
359 COMPRESS_MODE_JPEG = 11,
\r
360 COMPRESS_MODE_LJ = 12,
\r
361 COMPRESS_MODE_GRAFIT = 16
\r
364 enum COMPRESSOR_TYPE
\r
366 COMPRESSOR_JPEG_QUICKCONNECT,
\r
367 COMPRESSOR_JPEG_JETREADY,
\r
371 const int QTABLE_SIZE = 64;
\r
372 // jpeglib.h declares these as UINT16, which is defined as unsigned short in jmorecfg.h
\r
373 typedef struct QTableInfo_s
\r
375 DWORD qtable0[QTABLE_SIZE];
\r
376 DWORD qtable1[QTABLE_SIZE];
\r
377 DWORD qtable2[QTABLE_SIZE];
\r
378 unsigned int qFactor;
\r
381 typedef struct PrintMode_s
\r
384 // The resolutions can be different for different planes
\r
385 unsigned int ResolutionX[MAXCOLORPLANES];
\r
386 unsigned int ResolutionY[MAXCOLORPLANES];
\r
388 unsigned int ColorDepth[MAXCOLORPLANES];
\r
389 unsigned int dyeCount; // number of inks in the pen(s)
\r
391 HALFTONING_ALGORITHM eHT;
\r
395 unsigned int BaseResX,BaseResY;
\r
398 const unsigned char* BlackFEDTable;
\r
399 const unsigned char* ColorFEDTable;
\r
404 const char *printer_platform_name;
\r
405 PrintMode *print_modes;
\r
409 typedef struct QualityAttributes_s
\r
414 unsigned int horizontal_resolution;
\r
415 unsigned int vertical_resolution;
\r
416 unsigned int actual_vertical_resolution;
\r
417 char print_mode_name[32];
\r
418 } QualityAttributes;
\r
420 typedef struct MediaAttributes_s
\r
423 int physical_width;
\r
424 int physical_height;
\r
425 int printable_width;
\r
426 int printable_height;
\r
427 int printable_start_x;
\r
428 int printable_start_y;
\r
429 int horizontal_overspray;
\r
430 int vertical_overspray;
\r
431 int left_overspray;
\r
435 typedef struct JobAttributes_s
\r
439 DUPLEXMODE e_duplex_mode;
\r
440 int print_borderless;
\r
443 QualityAttributes quality_attributes;
\r
444 MediaAttributes media_attributes;
\r
448 char job_title[128];
\r
449 char user_name[32];
\r
450 char host_name[32];
\r
451 char domain_name[32];
\r
453 char driver_version[32];
\r
454 char driver_name[128];
\r
455 char printer_name[160];
\r
456 char job_start_time[32];
\r
458 char printer_platform[32];
\r
459 char printer_language[32];
\r
460 int integer_values[16];
\r
461 int printer_platform_version;
\r
462 int pre_process_raster;
\r
465 #endif // COMMON_DEFINITIONS_H
\r