1 /* @file plustek-pp_types.h
2  * @brief some typedefs and error codes
3  *
4  * Copyright (C) 2000-2013 Gerhard Jaeger <gerhard@gjaeger.de>
5  *
6  * History:
7  * 0.30 - initial version
8  * 0.31 - no changes
9  * 0.32 - added _VAR_NOT_USED()
10  * 0.33 - no changes
11  * 0.34 - no changes
12  * 0.35 - no changes
13  * 0.36 - added _E_ABORT and _E_VERSION
14  * 0.37 - moved _MAX_DEVICES to plustek_scan.h
15  *        added pChar and TabDef
16  * 0.38 - comment change for _E_NOSUPP
17  *        added RGBByteDef, RGBWordDef and RGBULongDef
18  *        replaced AllPointer by DataPointer
19  *        replaced AllType by DataType
20  *        added _LOBYTE and _HIBYTE stuff
21  *        added _E_NO_ASIC and _E_NORESOURCE
22  * 0.39 - no changes
23  * 0.40 - moved _VAR_NOT_USED and TabDef to plustek-share.h
24  * 0.41 - no changes
25  * 0.42 - moved errorcodes to plustek-share.h
26  * 0.43 - no changes
27  * 0.44 - define Long and ULong types to use int32_t, so
28  *        the code should still work on 64 bit machines
29  * .
30  * <hr>
31  * This file is part of the SANE package.
32  *
33  * This program is free software; you can redistribute it and/or
34  * modify it under the terms of the GNU General Public License as
35  * published by the Free Software Foundation; either version 2 of the
36  * License, or (at your option) any later version.
37  *
38  * This program is distributed in the hope that it will be useful, but
39  * WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
41  * General Public License for more details.
42  *
43  * You should have received a copy of the GNU General Public License
44  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
45  *
46  * As a special exception, the authors of SANE give permission for
47  * additional uses of the libraries contained in this release of SANE.
48  *
49  * The exception is that, if you link a SANE library with other files
50  * to produce an executable, this does not by itself cause the
51  * resulting executable to be covered by the GNU General Public
52  * License.  Your use of that executable is in no way restricted on
53  * account of linking the SANE library code into it.
54  *
55  * This exception does not, however, invalidate any other reasons why
56  * the executable file might be covered by the GNU General Public
57  * License.
58  *
59  * If you submit changes to SANE to the maintainers to be included in
60  * a subsequent release, you agree by submitting the changes that
61  * those changes may be distributed with this exception intact.
62  *
63  * If you write modifications of your own for SANE, it is your choice
64  * whether to permit this exception to apply to your modifications.
65  * If you do not wish that, delete this exception notice.
66  * <hr>
67  */
68 #ifndef __DRV_TYPES_H__
69 #define __DRV_TYPES_H__
70 
71 /* define some useful types */
72 typedef int 			Bool;
73 typedef char 			Char;
74 typedef char 		   *pChar;
75 typedef unsigned char 	UChar;
76 typedef UChar 		   *pUChar;
77 typedef unsigned char   Byte;
78 typedef Byte 		   *pByte;
79 
80 typedef short 			Short;
81 typedef unsigned short	UShort;
82 typedef UShort 		   *pUShort;
83 
84 typedef unsigned int	UInt;
85 typedef UInt		   *pUInt;
86 
87 /* these definitions will fail for 64 bit machines! */
88 #if 0
89 typedef long 		  	Long;
90 typedef long  		   *pLong;
91 typedef unsigned long 	ULong;
92 #endif
93 
94 typedef int32_t		  	Long;
95 typedef int32_t 	   *pLong;
96 typedef uint32_t	 	ULong;
97 typedef ULong 		   *pULong;
98 
99 typedef void 		   *pVoid;
100 
101 /*
102  * the boolean values
103  */
104 #ifndef _TRUE
105 #	define _TRUE    1
106 #endif
107 #ifndef _FALSE
108 #	define _FALSE   0
109 #endif
110 
111 #define _LOWORD(x)	((UShort)(x & 0xffff))
112 #define _HIWORD(x)	((UShort)(x >> 16))
113 #define _LOBYTE(x)  ((Byte)((x) & 0xFF))
114 #define _HIBYTE(x)  ((Byte)((x) >> 8))
115 
116 /*
117  * some useful things...
118  */
119 typedef struct
120 {
121 	Byte b1st;
122 	Byte b2nd;
123 } WordVal, *pWordVal;
124 
125 typedef struct
126 {
127     WordVal w1st;
128     WordVal w2nd;
129 } DWordVal, *pDWordVal;
130 
131 /* useful for RGB-values */
132 typedef struct {
133 	Byte Red;
134 	Byte Green;
135 	Byte Blue;
136 } RGBByteDef, *pRGBByteDef;
137 
138 typedef struct {
139 	UShort Red;
140 	UShort Green;
141 	UShort Blue;
142 } RGBUShortDef, *pRGBUShortDef;
143 
144 typedef struct {
145 
146     union {
147         pUChar  bp;
148         pUShort usp;
149         pULong  ulp;
150     } red;
151     union {
152         pUChar  bp;
153         pUShort usp;
154         pULong  ulp;
155     } green;
156     union {
157         pUChar  bp;
158         pUShort usp;
159         pULong  ulp;
160     } blue;
161 
162 } RBGPtrDef;
163 
164 typedef struct {
165 	ULong Red;
166 	ULong Green;
167 	ULong Blue;
168 } RGBULongDef, *pRGBULongDef;
169 
170 typedef union {
171 	pUChar	       pb;
172 	pUShort	       pw;
173 	pULong	       pdw;
174     pRGBByteDef    pbrgb;
175     pRGBUShortDef  pusrgb;
176     pRGBULongDef   pulrgb;
177 } DataPointer, *pDataPointer;
178 
179 typedef union {
180 	WordVal	 wOverlap;
181 	DWordVal dwOverlap;
182 	ULong	 dwValue;
183 	UShort	 wValue;
184 	Byte	 bValue;
185 } DataType, *pDataType;
186 
187 #endif /* guard __DRV_TYPES_H__ */
188 
189 /* END PLUSTEK-PP_TYPES.H ...................................................*/
190