xref: /aoo42x/main/sane/inc/sane.h (revision cdf0e10c)
1*cdf0e10cSrcweir /* sane - Scanner Access Now Easy.
2*cdf0e10cSrcweir    Copyright (C) 1997 David Mosberger-Tang and Andreas Beck
3*cdf0e10cSrcweir    This file is part of the SANE package.
4*cdf0e10cSrcweir 
5*cdf0e10cSrcweir    This file is in the public domain.  You may use and modify it as
6*cdf0e10cSrcweir    you see fit, as long as this copyright message is included and
7*cdf0e10cSrcweir    that there is an indication as to what modifications have been
8*cdf0e10cSrcweir    made (if any).
9*cdf0e10cSrcweir 
10*cdf0e10cSrcweir    SANE is distributed in the hope that it will be useful, but WITHOUT
11*cdf0e10cSrcweir    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12*cdf0e10cSrcweir    FITNESS FOR A PARTICULAR PURPOSE.
13*cdf0e10cSrcweir 
14*cdf0e10cSrcweir    This file declares SANE application interface.  See the SANE
15*cdf0e10cSrcweir    standard for a detailed explanation of the interface.  */
16*cdf0e10cSrcweir #ifndef sane_h
17*cdf0e10cSrcweir #define sane_h
18*cdf0e10cSrcweir 
19*cdf0e10cSrcweir #define SANE_CURRENT_MAJOR	0
20*cdf0e10cSrcweir 
21*cdf0e10cSrcweir #define SANE_VERSION_CODE(major, minor, build)	\
22*cdf0e10cSrcweir   (  (((SANE_Word) (major) &   0xff) << 24)	\
23*cdf0e10cSrcweir    | (((SANE_Word) (minor) &   0xff) << 16)	\
24*cdf0e10cSrcweir    | (((SANE_Word) (build) & 0xffff) <<  0))
25*cdf0e10cSrcweir 
26*cdf0e10cSrcweir #define SANE_VERSION_MAJOR(code)	((((SANE_Word)(code)) >> 24) &   0xff)
27*cdf0e10cSrcweir #define SANE_VERSION_MINOR(code)	((((SANE_Word)(code)) >> 16) &   0xff)
28*cdf0e10cSrcweir #define SANE_VERSION_BUILD(code)	((((SANE_Word)(code)) >>  0) & 0xffff)
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #define SANE_FALSE	0
31*cdf0e10cSrcweir #define SANE_TRUE	1
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir typedef unsigned char SANE_Byte;
34*cdf0e10cSrcweir typedef int SANE_Word;
35*cdf0e10cSrcweir typedef SANE_Word SANE_Bool;
36*cdf0e10cSrcweir typedef SANE_Word SANE_Int;
37*cdf0e10cSrcweir typedef char SANE_Char;
38*cdf0e10cSrcweir typedef SANE_Char *SANE_String;
39*cdf0e10cSrcweir typedef const SANE_Char *SANE_String_Const;
40*cdf0e10cSrcweir typedef void *SANE_Handle;
41*cdf0e10cSrcweir typedef SANE_Word SANE_Fixed;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #define SANE_FIXED_SCALE_SHIFT	16
44*cdf0e10cSrcweir #define SANE_FIX(v)	((SANE_Word) ((v) * (1 << SANE_FIXED_SCALE_SHIFT)))
45*cdf0e10cSrcweir #define SANE_UNFIX(v)	((double)(v) / (1 << SANE_FIXED_SCALE_SHIFT))
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir typedef enum
48*cdf0e10cSrcweir   {
49*cdf0e10cSrcweir     SANE_STATUS_GOOD = 0,	/* everything A-OK */
50*cdf0e10cSrcweir     SANE_STATUS_UNSUPPORTED,	/* operation is not supported */
51*cdf0e10cSrcweir     SANE_STATUS_CANCELLED,	/* operation was cancelled */
52*cdf0e10cSrcweir     SANE_STATUS_DEVICE_BUSY,	/* device is busy; try again later */
53*cdf0e10cSrcweir     SANE_STATUS_INVAL,		/* data is invalid (includes no dev at open) */
54*cdf0e10cSrcweir     SANE_STATUS_EOF,		/* no more data available (end-of-file) */
55*cdf0e10cSrcweir     SANE_STATUS_JAMMED,		/* document feeder jammed */
56*cdf0e10cSrcweir     SANE_STATUS_NO_DOCS,	/* document feeder out of documents */
57*cdf0e10cSrcweir     SANE_STATUS_COVER_OPEN,	/* scanner cover is open */
58*cdf0e10cSrcweir     SANE_STATUS_IO_ERROR,	/* error during device I/O */
59*cdf0e10cSrcweir     SANE_STATUS_NO_MEM,		/* out of memory */
60*cdf0e10cSrcweir     SANE_STATUS_ACCESS_DENIED	/* access to resource has been denied */
61*cdf0e10cSrcweir   }
62*cdf0e10cSrcweir SANE_Status;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir typedef enum
65*cdf0e10cSrcweir   {
66*cdf0e10cSrcweir     SANE_TYPE_BOOL = 0,
67*cdf0e10cSrcweir     SANE_TYPE_INT,
68*cdf0e10cSrcweir     SANE_TYPE_FIXED,
69*cdf0e10cSrcweir     SANE_TYPE_STRING,
70*cdf0e10cSrcweir     SANE_TYPE_BUTTON,
71*cdf0e10cSrcweir     SANE_TYPE_GROUP
72*cdf0e10cSrcweir   }
73*cdf0e10cSrcweir SANE_Value_Type;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir typedef enum
76*cdf0e10cSrcweir   {
77*cdf0e10cSrcweir     SANE_UNIT_NONE = 0,		/* the value is unit-less (e.g., # of scans) */
78*cdf0e10cSrcweir     SANE_UNIT_PIXEL,		/* value is number of pixels */
79*cdf0e10cSrcweir     SANE_UNIT_BIT,		/* value is number of bits */
80*cdf0e10cSrcweir     SANE_UNIT_MM,		/* value is millimeters */
81*cdf0e10cSrcweir     SANE_UNIT_DPI,		/* value is resolution in dots/inch */
82*cdf0e10cSrcweir     SANE_UNIT_PERCENT,		/* value is a percentage */
83*cdf0e10cSrcweir     SANE_UNIT_MICROSECOND	/* value is micro seconds */
84*cdf0e10cSrcweir   }
85*cdf0e10cSrcweir SANE_Unit;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir typedef struct
88*cdf0e10cSrcweir   {
89*cdf0e10cSrcweir     SANE_String_Const name;	/* unique device name */
90*cdf0e10cSrcweir     SANE_String_Const vendor;	/* device vendor string */
91*cdf0e10cSrcweir     SANE_String_Const model;	/* device model name */
92*cdf0e10cSrcweir     SANE_String_Const type;	/* device type (e.g., "flatbed scanner") */
93*cdf0e10cSrcweir   }
94*cdf0e10cSrcweir SANE_Device;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir #define SANE_CAP_SOFT_SELECT		(1 << 0)
97*cdf0e10cSrcweir #define SANE_CAP_HARD_SELECT		(1 << 1)
98*cdf0e10cSrcweir #define SANE_CAP_SOFT_DETECT		(1 << 2)
99*cdf0e10cSrcweir #define SANE_CAP_EMULATED		(1 << 3)
100*cdf0e10cSrcweir #define SANE_CAP_AUTOMATIC		(1 << 4)
101*cdf0e10cSrcweir #define SANE_CAP_INACTIVE		(1 << 5)
102*cdf0e10cSrcweir #define SANE_CAP_ADVANCED		(1 << 6)
103*cdf0e10cSrcweir #define SANE_CAP_ALWAYS_SETTABLE	(1 << 7)
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir #define SANE_OPTION_IS_ACTIVE(cap)	(((cap) & SANE_CAP_INACTIVE) == 0)
106*cdf0e10cSrcweir #define SANE_OPTION_IS_SETTABLE(cap)	(((cap) & SANE_CAP_SOFT_SELECT) != 0)
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir #define SANE_INFO_INEXACT		(1 << 0)
109*cdf0e10cSrcweir #define SANE_INFO_RELOAD_OPTIONS	(1 << 1)
110*cdf0e10cSrcweir #define SANE_INFO_RELOAD_PARAMS		(1 << 2)
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir typedef enum
113*cdf0e10cSrcweir   {
114*cdf0e10cSrcweir     SANE_CONSTRAINT_NONE = 0,
115*cdf0e10cSrcweir     SANE_CONSTRAINT_RANGE,
116*cdf0e10cSrcweir     SANE_CONSTRAINT_WORD_LIST,
117*cdf0e10cSrcweir     SANE_CONSTRAINT_STRING_LIST
118*cdf0e10cSrcweir   }
119*cdf0e10cSrcweir SANE_Constraint_Type;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir typedef struct
122*cdf0e10cSrcweir   {
123*cdf0e10cSrcweir     SANE_Word min;		/* minimum (element) value */
124*cdf0e10cSrcweir     SANE_Word max;		/* maximum (element) value */
125*cdf0e10cSrcweir     SANE_Word quant;		/* quantization value (0 if none) */
126*cdf0e10cSrcweir   }
127*cdf0e10cSrcweir SANE_Range;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir typedef struct
130*cdf0e10cSrcweir   {
131*cdf0e10cSrcweir     SANE_String_Const name;	/* name of this option (command-line name) */
132*cdf0e10cSrcweir     SANE_String_Const title;	/* title of this option (single-line) */
133*cdf0e10cSrcweir     SANE_String_Const desc;	/* description of this option (multi-line) */
134*cdf0e10cSrcweir     SANE_Value_Type type;	/* how are values interpreted? */
135*cdf0e10cSrcweir     SANE_Unit unit;		/* what is the (physical) unit? */
136*cdf0e10cSrcweir     SANE_Int size;
137*cdf0e10cSrcweir     SANE_Int cap;		/* capabilities */
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     SANE_Constraint_Type constraint_type;
140*cdf0e10cSrcweir     union
141*cdf0e10cSrcweir       {
142*cdf0e10cSrcweir 	const SANE_String_Const *string_list;	/* NULL-terminated list */
143*cdf0e10cSrcweir 	const SANE_Word *word_list;	/* first element is list-length */
144*cdf0e10cSrcweir 	const SANE_Range *range;
145*cdf0e10cSrcweir       }
146*cdf0e10cSrcweir     constraint;
147*cdf0e10cSrcweir   }
148*cdf0e10cSrcweir SANE_Option_Descriptor;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir typedef enum
151*cdf0e10cSrcweir   {
152*cdf0e10cSrcweir     SANE_ACTION_GET_VALUE = 0,
153*cdf0e10cSrcweir     SANE_ACTION_SET_VALUE,
154*cdf0e10cSrcweir     SANE_ACTION_SET_AUTO
155*cdf0e10cSrcweir   }
156*cdf0e10cSrcweir SANE_Action;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir typedef enum
159*cdf0e10cSrcweir   {
160*cdf0e10cSrcweir     SANE_FRAME_GRAY,		/* band covering human visual range */
161*cdf0e10cSrcweir     SANE_FRAME_RGB,		/* pixel-interleaved red/green/blue bands */
162*cdf0e10cSrcweir     SANE_FRAME_RED,		/* red band only */
163*cdf0e10cSrcweir     SANE_FRAME_GREEN,		/* green band only */
164*cdf0e10cSrcweir     SANE_FRAME_BLUE		/* blue band only */
165*cdf0e10cSrcweir   }
166*cdf0e10cSrcweir SANE_Frame;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir typedef struct
169*cdf0e10cSrcweir   {
170*cdf0e10cSrcweir     SANE_Frame format;
171*cdf0e10cSrcweir     SANE_Bool last_frame;
172*cdf0e10cSrcweir     SANE_Int bytes_per_line;
173*cdf0e10cSrcweir     SANE_Int pixels_per_line;
174*cdf0e10cSrcweir     SANE_Int lines;
175*cdf0e10cSrcweir     SANE_Int depth;
176*cdf0e10cSrcweir   }
177*cdf0e10cSrcweir SANE_Parameters;
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir struct SANE_Auth_Data;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir #define SANE_MAX_USERNAME_LEN	256
182*cdf0e10cSrcweir #define SANE_MAX_PASSWORD_LEN	256
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir typedef void (*SANE_Auth_Callback) (SANE_String_Const resource,
185*cdf0e10cSrcweir 				    SANE_Char username[SANE_MAX_USERNAME_LEN],
186*cdf0e10cSrcweir 				    SANE_Char password[SANE_MAX_PASSWORD_LEN]);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir extern SANE_Status sane_init (SANE_Int * version_code,
189*cdf0e10cSrcweir 			      SANE_Auth_Callback authorize);
190*cdf0e10cSrcweir extern void sane_exit (void);
191*cdf0e10cSrcweir extern SANE_Status sane_get_devices (const SANE_Device *** device_list,
192*cdf0e10cSrcweir 				     SANE_Bool local_only);
193*cdf0e10cSrcweir extern SANE_Status sane_open (SANE_String_Const devicename,
194*cdf0e10cSrcweir 			      SANE_Handle * handle);
195*cdf0e10cSrcweir extern void sane_close (SANE_Handle handle);
196*cdf0e10cSrcweir extern const SANE_Option_Descriptor *
197*cdf0e10cSrcweir   sane_get_option_descriptor (SANE_Handle handle, SANE_Int option);
198*cdf0e10cSrcweir extern SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option,
199*cdf0e10cSrcweir 					SANE_Action action, void *value,
200*cdf0e10cSrcweir 					SANE_Int * info);
201*cdf0e10cSrcweir extern SANE_Status sane_get_parameters (SANE_Handle handle,
202*cdf0e10cSrcweir 					SANE_Parameters * params);
203*cdf0e10cSrcweir extern SANE_Status sane_start (SANE_Handle handle);
204*cdf0e10cSrcweir extern SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data,
205*cdf0e10cSrcweir 			      SANE_Int max_length, SANE_Int * length);
206*cdf0e10cSrcweir extern void sane_cancel (SANE_Handle handle);
207*cdf0e10cSrcweir extern SANE_Status sane_set_io_mode (SANE_Handle handle,
208*cdf0e10cSrcweir 				     SANE_Bool non_blocking);
209*cdf0e10cSrcweir extern SANE_Status sane_get_select_fd (SANE_Handle handle,
210*cdf0e10cSrcweir 				       SANE_Int * fd);
211*cdf0e10cSrcweir extern SANE_String_Const sane_strstatus (SANE_Status status);
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir #endif /* sane_h */
214