~ubuntu-branches/ubuntu/raring/hplip/raring-proposed

« back to all changes in this revision

Viewing changes to .pc/hplip-syslog-fix-debug-messages-to-error.dpatch/prnt/hpcups/CommonDefinitions.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-26 11:20:39 UTC
  • mfrom: (1.5.6) (31.1.3 precise)
  • Revision ID: package-import@ubuntu.com-20120526112039-bevxczegxnbyr5m7
Tags: 3.12.4-1
* New upstream release
* Switch to source/format 3.0 (quilt) - drop dpatch
* Refreshed debian/patches
* dh_autoreconf debian/autogen.sh & set local-options single-debian-patch
* Update to debian/compat -> 9
* Fix "hardened build flags" patch from Moritz - thanks (Closes: #667828)
* Fix "duplex descriptor uninitialized" patch from Matej (Closes: #583273)
* Fix "please migrate to kde-runtime" patch from Pino (Closes: #666544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************\
 
2
  CommonDefinitions.h : common header
 
3
 
 
4
  Copyright (c) 1996 - 2009, Hewlett-Packard Co.
 
5
  All rights reserved.
 
6
 
 
7
  Redistribution and use in source and binary forms, with or without
 
8
  modification, are permitted provided that the following conditions
 
9
  are met:
 
10
  1. Redistributions of source code must retain the above copyright
 
11
     notice, this list of conditions and the following disclaimer.
 
12
  2. Redistributions in binary form must reproduce the above copyright
 
13
     notice, this list of conditions and the following disclaimer in the
 
14
     documentation and/or other materials provided with the distribution.
 
15
  3. Neither the name of Hewlett-Packard nor the names of its
 
16
     contributors may be used to endorse or promote products derived
 
17
     from this software without specific prior written permission.
 
18
 
 
19
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
 
20
  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
21
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 
22
  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 
24
  TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 
25
  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 
26
  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
28
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 
 
30
  Author: Naga Samrat Chowdary Narla,
 
31
\*****************************************************************************/
 
32
 
 
33
#ifndef COMMON_DEFINITIONS_H
 
34
#define COMMON_DEFINITIONS_H
 
35
 
 
36
#include <stdio.h>
 
37
#include <inttypes.h>
 
38
#include <stdint.h>
 
39
//#include <machine/types.h>
 
40
#include <fcntl.h>
 
41
#include <sys/stat.h>
 
42
#include <cups/cups.h>
 
43
#include <cups/raster.h>
 
44
#include <stdarg.h>
 
45
#include <stdio.h>
 
46
#include <stdlib.h>
 
47
#include <string.h>
 
48
#include <syslog.h>
 
49
#include <assert.h>
 
50
#include <time.h>
 
51
#include <sys/timeb.h>
 
52
#include <string.h>
 
53
 
 
54
#ifndef _GNU_SOURCE
 
55
#define _GNU_SOURCE
 
56
#endif
 
57
 
 
58
#define BASIC_LOG          1
 
59
#define SAVE_PCL_FILE      2
 
60
#define SAVE_INPUT_RASTERS 4
 
61
#define SEND_TO_PRINTER_ALSO    8
 
62
 
 
63
#define MAX_COLORTYPE 2
 
64
#define NUMBER_PLANES 3
 
65
 
 
66
#define ASSERT assert
 
67
 
 
68
#define _STRINGIZE(x) #x
 
69
#define STRINGIZE(x) _STRINGIZE(x)
 
70
 
 
71
#define dbglog(args...) {syslog(LOG_ERR, __FILE__ " " STRINGIZE(__LINE__) ": " args); \
 
72
fprintf(stderr, __FILE__ " " STRINGIZE(__LINE__) ": " args);}
 
73
 
 
74
 
 
75
typedef unsigned char     BYTE;
 
76
 
 
77
#ifndef ABS
 
78
    #define ABS(x)      ( ((x)<0) ? -(x) : (x) )
 
79
#endif
 
80
 
 
81
#ifndef MIN
 
82
    #define MIN(a,b)    (((a)>=(b))?(b):(a))
 
83
#endif
 
84
 
 
85
#ifndef MAX
 
86
    #define MAX(a,b)    (((a)<=(b))?(b):(a))
 
87
#endif
 
88
 
 
89
#ifdef APDK_LITTLE_ENDIAN
 
90
    #define GetRed(x) (((x >> 16) & 0x0FF))
 
91
    #define GetGreen(x) (((x >> 8) & 0x0FF))
 
92
    #define GetBlue(x) ((x & 0x0FF))
 
93
 #else
 
94
    #define GetRed(x) (((x >> 24) & 0x0FF))
 
95
    #define GetGreen(x) (((x >> 16) & 0x0FF))
 
96
    #define GetBlue(x) (((x >> 8) & 0x0FF))
 
97
 #endif
 
98
 
 
99
#ifdef BLACK_PEN
 
100
    #undef BLACK_PEN
 
101
#endif
 
102
 
 
103
#ifdef NO_ERROR
 
104
    #undef NO_ERROR
 
105
#endif
 
106
 
 
107
#define HIBYTE(sVar) (BYTE) ((sVar & 0xFF00) >> 8)
 
108
#define LOBYTE(sVar) (BYTE) ((sVar & 0x00FF))
 
109
#ifndef LOWORD
 
110
    #define LOWORD(l)   ((unsigned short) (l))
 
111
#endif
 
112
 
 
113
#ifndef HIWORD
 
114
    #define HIWORD(l)   ((unsigned short) (((uint32_t) (l) >> 16) & 0xFFFF))
 
115
#endif
 
116
 
 
117
#define PCL_BUFFER_SIZE    10000
 
118
 
 
119
typedef unsigned short  UInt16;
 
120
typedef unsigned long   UInt32;
 
121
typedef unsigned char   UChar;
 
122
typedef unsigned int    Int16;
 
123
typedef long     Int32;
 
124
 
 
125
typedef struct RASTERDATA
 
126
{
 
127
    int      rastersize[MAX_COLORTYPE];
 
128
    BYTE     *rasterdata[MAX_COLORTYPE];
 
129
} RASTERDATA;
 
130
 
 
131
const int MAXCOLORDEPTH = 3;
 
132
 
 
133
const int MAXCOLORPLANES = 6;   // current max anticipated, 6 for 690 photopen
 
134
 
 
135
const int MAXCOLORROWS = 2;     // multiple of high-to-low for mixed-resolution cases
 
136
 
 
137
enum HALFTONING_ALGORITHM
 
138
{
 
139
    FED,
 
140
    MATRIX
 
141
};
 
142
 
 
143
/*
 
144
 *  values of DRIVER_ERROR
 
145
 *  Values < 0 are warnings
 
146
 */
 
147
 
 
148
typedef enum
 
149
{
 
150
 
 
151
// general or system errors
 
152
    NO_ERROR             =  0x00,    //!< everything okay
 
153
    JOB_CANCELED         =  0x01,    //!< CANCEL chosen by user
 
154
    SYSTEM_ERROR         =  0x02,    //!< something bad that should not have happened
 
155
    ALLOCMEM_ERROR       =  0x03,    //!< failed to allocate memory
 
156
    NO_PRINTER_SELECTED  =  0x04,    //!< indicates improper calling sequence or unidi
 
157
    INDEX_OUT_OF_RANGE   =  0x05,    //!< what it says
 
158
    ILLEGAL_RESOLUTION   =  0x06,    //!< tried to set resolution at unacceptable value
 
159
    NULL_POINTER         =  0x07,    //!< supplied ptr was null
 
160
    MISSING_PENS         =  0x08,    //!< one or more printhead/pen missing
 
161
 
 
162
// build-related
 
163
// (items either absent from current build, or just bad index from client code)
 
164
    UNSUPPORTED_PRINTER  =  0x10,    //!< selected printer-type unsupported in build
 
165
    UNSUPPORTED_PEN      =  0x11,    //!< selected pen-type unsupported
 
166
    GRAPHICS_UNSUPPORTED =  0x13,    //!< no graphics allowed in current build
 
167
    ILLEGAL_COORDS       =  0x15,    //!< bad (x,y) passed to TextOut
 
168
    BAD_INPUT_WIDTH      =  0x18,    //!< inputwidth is 0 and
 
169
    OUTPUTWIDTH_EXCEEDS_PAGEWIDTH = 0x19, //!< inputwidth exceeds printable width
 
170
    UNSUPPORTED_PRINTMODE = 0x19,    //!< requested printmode not available
 
171
 
 
172
// I/O related
 
173
    IO_ERROR             =  0x20,    //!< I/O error communicating with printer
 
174
    BAD_DEVICE_ID        =  0x21,    //!< bad or garbled device id from printer
 
175
    CONTINUE_FROM_BLOCK  =  0x22,    //!< continue from blocked state for printers with no buttons
 
176
 
 
177
//  Runtime related
 
178
    PLUGIN_LIBRARY_MISSING = 0x30,   //!< a required plugin (dynamic) library is missing
 
179
 
 
180
// WARNINGS
 
181
// convention is that values < 0 can be ignored (at user's peril)
 
182
    WARN_MODE_MISMATCH    =  -1,     //!< printmode selection incompatible with pen, tray, etc.
 
183
    WARN_DUPLEX           =  -2,     //!< duplexer installed; our driver can't use it
 
184
    WARN_LOW_INK_BOTH_PENS=  -3,     //!< sensor says pens below threshold
 
185
    WARN_LOW_INK_BLACK    =  -4,     //!< sensor says black pen below threshold
 
186
    WARN_LOW_INK_COLOR    =  -5,     //!< sensor says color pen below threshold
 
187
 
 
188
    WARN_LOW_INK_PHOTO    =  -10,    //!< sensor says photo pen below threshold
 
189
    WARN_LOW_INK_GREY     =  -11,    //!< sensor says grey pen below threshold
 
190
    WARN_LOW_INK_BLACK_PHOTO =  -12,     //!< sensor says black and photo pens below threshold
 
191
    WARN_LOW_INK_COLOR_PHOTO =  -13,     //!< sensor says color and photo pens below threshold
 
192
    WARN_LOW_INK_GREY_PHOTO  =  -14,     //!< sensor says grey and photo pens below threshold
 
193
    WARN_LOW_INK_COLOR_GREY  =  -15,     //!< sensor says color and grey pens below threshold
 
194
    WARN_LOW_INK_COLOR_GREY_PHOTO  =  -16,     //!< sensor says color, photo, and grey pens below threshold
 
195
    WARN_LOW_INK_COLOR_BLACK_PHOTO  =  -17,     //!< sensor says color, photo, and black pens below threshold
 
196
    WARN_LOW_INK_CYAN               = -18,      //!< sensor says cyan ink below threshold
 
197
    WARN_LOW_INK_MAGENTA            = -19,      //!< sensor says magenta ink below threshold
 
198
    WARN_LOW_INK_YELLOW             = -20,      //!< sensor says yellow ink below threshold
 
199
    WARN_LOW_INK_MULTIPLE_PENS      = - 21,     //!< sensor says more than one pen below threshold
 
200
    WARN_ILLEGAL_PAPERSIZE = -8,     //!< papersize illegal for given hardware
 
201
    ILLEGAL_PAPERSIZE      = -8, 
 
202
    WARN_INVALID_MEDIA_SOURCE = -9,   //!< media source tray is invalid
 
203
    
 
204
    eCreate_Thread_Error = 128   //! Thread error creating the error....
 
205
} DRIVER_ERROR; //DRIVER_ERROR
 
206
 
 
207
enum DUPLEXMODE
 
208
{
 
209
    DUPLEXMODE_NONE,
 
210
    DUPLEXMODE_BOOK,
 
211
    DUPLEXMODE_TABLET
 
212
};
 
213
 
 
214
enum ENDIAN_TYPE
 
215
{
 
216
    LITTLEENDIAN,
 
217
    BIGENDIAN
 
218
};
 
219
 
 
220
// used to encourage consistent ordering of color planes
 
221
#define PLANE_K   0
 
222
#define PLANE_C   1
 
223
#define PLANE_M   2
 
224
#define PLANE_Y   3
 
225
#define Clight    4
 
226
#define Mlight    5
 
227
#define kWhite    0x00FFFFFE
 
228
 
 
229
#define K         0
 
230
#define C         1
 
231
#define M         2
 
232
#define Y         3
 
233
#define Clight    4
 
234
#define Mlight    5
 
235
#define RANDSEED  77
 
236
 
 
237
/*
 
238
 *  ZJStream related definitions
 
239
 */
 
240
 
 
241
typedef uint32_t          DWORD;
 
242
typedef unsigned short    WORD;
 
243
typedef enum
 
244
{
 
245
    ZJT_START_DOC,
 
246
    ZJT_END_DOC,
 
247
    ZJT_START_PAGE,
 
248
    ZJT_END_PAGE,
 
249
    ZJT_JBIG_BIH,
 
250
    ZJT_JBIG_HID,
 
251
    ZJT_END_JBIG,
 
252
    ZJT_SIGNATURE,
 
253
    ZJT_RAW_IMAGE,
 
254
    ZJT_START_PLANE,
 
255
    ZJT_END_PLANE,
 
256
    ZJT_PAUSE,
 
257
    ZJT_BITMAP
 
258
} CHUNK_TYPE;
 
259
 
 
260
typedef enum
 
261
{
 
262
/* 0x00*/    ZJI_PAGECOUNT,
 
263
/* 0x01*/    ZJI_DMCOLLATE,
 
264
/* 0x02*/    ZJI_DMDUPLEX,
 
265
 
 
266
/* 0x03*/    ZJI_DMPAPER,
 
267
/* 0x04*/    ZJI_DMCOPIES,
 
268
/* 0x05*/    ZJI_DMDEFAULTSOURCE,
 
269
/* 0x06*/    ZJI_DMMEDIATYPE,
 
270
/* 0x07*/    ZJI_NBIE,
 
271
/* 0x08*/    ZJI_RESOLUTION_X,
 
272
/* 0x09*/    ZJI_RESOLUTION_Y,
 
273
/* 0x0A */    ZJI_OFFSET_X,
 
274
/* 0x0B */    ZJI_OFFSET_Y,
 
275
/* 0x0C */    ZJI_RASTER_X,
 
276
/* 0x0D */    ZJI_RASTER_Y,
 
277
 
 
278
/* 0x0E */    ZJI_COLLATE,
 
279
/* 0x0F */    ZJI_QUANTITY,
 
280
 
 
281
/* 0x10 */    ZJI_VIDEO_BPP,
 
282
/* 0x11 */    ZJI_VIDEO_X,
 
283
/* 0x12 */    ZJI_VIDEO_Y,
 
284
/* 0x13 */    ZJI_INTERLACE,
 
285
/* 0x14 */    ZJI_PLANE,
 
286
/* 0x15 */    ZJI_PALETTE,
 
287
 
 
288
/* 0x16 */    ZJI_RET,
 
289
/* 0x17 */    ZJI_TONER_SAVE,
 
290
 
 
291
/* 0x18 */    ZJI_MEDIA_SIZE_X,
 
292
/* 0x19 */    ZJI_MEDIA_SIZE_Y,
 
293
/* 0x1A */    ZJI_MEDIA_SIZE_UNITS,
 
294
 
 
295
/* 0x1B */    ZJI_CHROMATIC,
 
296
 
 
297
/* 0x63 */    ZJI_PAD = 99,
 
298
 
 
299
/* 0x64 */    ZJI_PROMPT,
 
300
 
 
301
/* 0x65 */    ZJI_BITMAP_TYPE,
 
302
/* 0x66 */    ZJI_ENCODING_DATA,
 
303
/* 0x67 */    ZJI_END_PLANE,
 
304
 
 
305
/* 0x68 */    ZJI_BITMAP_PIXELS,
 
306
/* 0x69 */    ZJI_BITMAP_LINES,
 
307
/* 0x6A */    ZJI_BITMAP_BPP,
 
308
/* 0x6B */    ZJI_BITMAP_STRIDE,
 
309
 
 
310
} ZJ_ITEM;
 
311
 
 
312
typedef enum
 
313
{
 
314
    RET_OFF = 0,
 
315
    RET_ON,
 
316
    RET_AUTO,
 
317
    RET_LIGHT,
 
318
    RET_MEDIUM,
 
319
    RET_DARK
 
320
} RET_VALUE;
 
321
 
 
322
typedef enum
 
323
{
 
324
    ZJIT_UINT32 = 1,
 
325
    ZJIT_INT32,
 
326
    ZJIT_STRING,
 
327
    ZJIT_BYTELUT
 
328
} CHUNK_ITEM_TYPE;
 
329
 
 
330
// very frequently used fragments made into macros for readability
 
331
#define CERRCHECK if (constructor_error != NO_ERROR) {dbglog("CERRCHECK fired\n"); return;}
 
332
#define ERRCHECK if (err != NO_ERROR) {dbglog("ERRCHECK fired\n"); return err;}
 
333
#define NEWCHECK(x) if (x==NULL) return ALLOCMEM_ERROR;
 
334
#define CNEWCHECK(x) if (x==NULL) { constructor_error=ALLOCMEM_ERROR; return; }
 
335
 
 
336
#define CUSTOM_MEDIA_SIZE 101
 
337
 
 
338
#define EVENT_PRINT_FAILED_MISSING_PLUGIN 502
 
339
enum COLORTYPE
 
340
{
 
341
    COLORTYPE_COLOR,       // 0
 
342
    COLORTYPE_BLACK,       // 1
 
343
    COLORTYPE_BOTH
 
344
};
 
345
 
 
346
typedef struct ColorMap_s
 
347
{
 
348
    uint32_t *ulMap1;
 
349
    uint32_t *ulMap2;
 
350
    unsigned char *ulMap3;
 
351
} ColorMap;
 
352
 
 
353
enum COMPRESS_MODE
 
354
{
 
355
    COMPRESS_MODE0       = 0,
 
356
    COMPRESS_MODE2       = 2, 
 
357
    COMPRESS_MODE9       = 9,
 
358
    COMPRESS_MODE_AUTO   = 10,
 
359
    COMPRESS_MODE_JPEG   = 11,
 
360
    COMPRESS_MODE_LJ     = 12,
 
361
    COMPRESS_MODE_GRAFIT = 16
 
362
};
 
363
 
 
364
enum COMPRESSOR_TYPE
 
365
{
 
366
    COMPRESSOR_JPEG_QUICKCONNECT,
 
367
    COMPRESSOR_JPEG_JETREADY,
 
368
    COMPRESSOR_TAOS
 
369
};
 
370
 
 
371
const int QTABLE_SIZE =  64;
 
372
//  jpeglib.h declares these as UINT16, which is defined as unsigned short in jmorecfg.h
 
373
typedef struct QTableInfo_s
 
374
{
 
375
    DWORD qtable0[QTABLE_SIZE];
 
376
    DWORD qtable1[QTABLE_SIZE];
 
377
    DWORD qtable2[QTABLE_SIZE];
 
378
    unsigned int   qFactor;
 
379
} QTableInfo;
 
380
 
 
381
typedef struct PrintMode_s
 
382
{
 
383
    const char    *name;
 
384
// The resolutions can be different for different planes
 
385
    unsigned int ResolutionX[MAXCOLORPLANES];
 
386
    unsigned int ResolutionY[MAXCOLORPLANES];
 
387
 
 
388
    unsigned int ColorDepth[MAXCOLORPLANES];
 
389
    unsigned int dyeCount;      // number of inks in the pen(s)
 
390
 
 
391
    HALFTONING_ALGORITHM eHT;
 
392
 
 
393
    ColorMap cmap;
 
394
 
 
395
    unsigned int BaseResX,BaseResY;
 
396
    bool     MixedRes;
 
397
 
 
398
    const unsigned char* BlackFEDTable;
 
399
    const unsigned char* ColorFEDTable;
 
400
} PrintMode;
 
401
 
 
402
typedef struct
 
403
{
 
404
    const char   *printer_platform_name;
 
405
    PrintMode    *print_modes;
 
406
    int          count;
 
407
} PrintModeTable;
 
408
 
 
409
typedef struct QualityAttributes_s
 
410
{
 
411
    int             media_type;
 
412
    int             media_subtype;
 
413
    int             print_quality;
 
414
    unsigned int    horizontal_resolution;
 
415
    unsigned int    vertical_resolution;
 
416
    unsigned int    actual_vertical_resolution;
 
417
    char            print_mode_name[32];
 
418
} QualityAttributes;
 
419
 
 
420
typedef struct MediaAttributes_s
 
421
{
 
422
    int        pcl_id;
 
423
    int        physical_width;
 
424
    int        physical_height;
 
425
    int        printable_width;
 
426
    int        printable_height;
 
427
    int        printable_start_x;
 
428
    int        printable_start_y;
 
429
    int        horizontal_overspray;
 
430
    int        vertical_overspray;
 
431
    int        left_overspray; 
 
432
    int        top_overspray;
 
433
} MediaAttributes;
 
434
 
 
435
typedef struct JobAttributes_s
 
436
{
 
437
    int                media_source;
 
438
    int                color_mode;
 
439
    DUPLEXMODE         e_duplex_mode;
 
440
    int                print_borderless;
 
441
    int                krgb_mode;
 
442
    int                mech_offset;
 
443
    QualityAttributes  quality_attributes;
 
444
    MediaAttributes    media_attributes;
 
445
    int                job_id;
 
446
    int                page_order;
 
447
    int                total_pages;
 
448
    char               job_title[128];
 
449
    char               user_name[32];
 
450
    char               host_name[32];
 
451
    char               domain_name[32];
 
452
    char               os_name[160];
 
453
    char               driver_version[32];
 
454
    char               driver_name[128];
 
455
    char               printer_name[160];
 
456
    char               job_start_time[32];
 
457
    char               uuid[64];
 
458
    char               printer_platform[32];
 
459
    char               printer_language[32];
 
460
    int                integer_values[16];
 
461
    int                printer_platform_version;
 
462
    int                pre_process_raster;
 
463
} JobAttributes;
 
464
 
 
465
#endif // COMMON_DEFINITIONS_H
 
466