LibInsane  1.0.10
Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library
capi.h
Go to the documentation of this file.
1 #ifndef __LIBINSANE_CAPI_H
2 #define __LIBINSANE_CAPI_H
3 
4 #include <stdlib.h>
5 
6 #include "error.h"
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
21  char *dev_id;
22 
23  char *vendor;
24  char *model;
25  char *type;
26 };
27 
28 
38 };
39 
40 
58 
71  LIS_IMG_FORMAT_MEMORYBMP, // Windows BMP without header
75 };
76 
77 
78 enum lis_unit {
86 };
87 
88 
94 union lis_value {
95  int boolean;
96  int integer;
97  double dbl;
98  const char *string;
100 };
101 
102 
103 
105  union lis_value min;
106  union lis_value max;
107  union lis_value interval;
108 };
109 
110 
114 };
115 
116 
121  const char *name;
122  const char *title;
123  const char *desc;
125 #define LIS_CAP_EMULATED (1<<0)
126 #define LIS_CAP_AUTOMATIC (1<<1)
127 #define LIS_CAP_HW_SELECT (1<<2)
128 #define LIS_CAP_SW_SELECT (1<<3)
129  /* TODO(Jflesch): Sane provides SANE_CAP_SOFT_DETECT ? oO */
133 #define LIS_CAP_INACTIVE (1<<4)
134 
135 #define LIS_OPT_IS_READABLE(opt_desc) (!((opt_desc)->capabilities & LIS_CAP_INACTIVE))
136 #define LIS_OPT_IS_WRITABLE(opt_desc) ((opt_desc)->capabilities & LIS_CAP_SW_SELECT)
137 
149 
153  struct {
154  enum lis_value_type type;
155  enum lis_unit unit;
156  } value;
157 
161  struct {
162  enum {
166  } type;
172  union {
176  struct lis_value_range range;
177 
181  struct lis_value_list list;
184 
185  struct {
204  enum lis_error (*get_value)(struct lis_option_descriptor *self,
205  union lis_value *value);
206 
207 #define LIS_SET_FLAG_INEXACT (1<<0)
208 #define LIS_SET_FLAG_MUST_RELOAD_OPTIONS (1<<1)
209 #define LIS_SET_FLAG_MUST_RELOAD_PARAMS (1<<2)
225  enum lis_error (*set_value)(struct lis_option_descriptor *self,
226  union lis_value value, int *set_flags);
227  } fn;
228 };
229 
238  enum lis_img_format format;
239 
244  int width;
245 
250  int height;
251 
257  size_t image_size;
258 };
259 
260 
282  struct lis_scan_session *self,
283  struct lis_scan_parameters *parameters
284  );
285 
290  int (*end_of_feed)(struct lis_scan_session *session);
291 
297  int (*end_of_page)(struct lis_scan_session *session);
298 
322  enum lis_error (*scan_read)(
323  struct lis_scan_session *session, void *out_buffer,
324  size_t *buffer_size
325  );
326 
338  void (*cancel)(struct lis_scan_session *session);
339 };
340 
341 
347 };
348 
349 
356 struct lis_item {
357  const char *name;
358  enum lis_item_type type;
359 
374  enum lis_error (*get_children)(struct lis_item *self, struct lis_item ***children);
375 
386  enum lis_error (*get_options)(
387  struct lis_item *self, struct lis_option_descriptor ***descs
388  );
389 
397  enum lis_error (*scan_start)(struct lis_item *self, struct lis_scan_session **session);
398 
408  void (*close)(struct lis_item *self);
409 };
410 
411 
415 };
416 
417 
423 struct lis_api {
424  const char *base_name;
437  void (*cleanup)(struct lis_api *impl);
438 
455  enum lis_error (*list_devices)(
456  struct lis_api *impl, enum lis_device_locations locs,
457  struct lis_device_descriptor ***dev_infos
458  );
459 
483  enum lis_error (*get_device)(
484  struct lis_api *impl, const char *dev_id, struct lis_item **item
485  );
486 };
487 
488 #ifdef __cplusplus
489 }
490 #endif
491 
492 #endif
lis_device_locations
Definition: capi.h:412
@ LIS_DEVICE_LOCATIONS_LOCAL_ONLY
Definition: capi.h:414
@ LIS_DEVICE_LOCATIONS_ANY
Definition: capi.h:413
lis_item_type
Definition: capi.h:342
@ LIS_ITEM_ADF
Definition: capi.h:345
@ LIS_ITEM_FLATBED
Definition: capi.h:344
@ LIS_ITEM_UNIDENTIFIED
Definition: capi.h:346
@ LIS_ITEM_DEVICE
Definition: capi.h:343
lis_value_type
Variable type.
Definition: capi.h:32
@ LIS_TYPE_DOUBLE
Definition: capi.h:35
@ LIS_TYPE_BOOL
Definition: capi.h:33
@ LIS_TYPE_INTEGER
Definition: capi.h:34
@ LIS_TYPE_STRING
Definition: capi.h:36
@ LIS_TYPE_IMAGE_FORMAT
Definition: capi.h:37
lis_unit
Definition: capi.h:78
@ LIS_UNIT_PIXEL
Definition: capi.h:80
@ LIS_UNIT_DPI
Definition: capi.h:83
@ LIS_UNIT_PERCENT
Definition: capi.h:84
@ LIS_UNIT_MM
Definition: capi.h:82
@ LIS_UNIT_BIT
Definition: capi.h:81
@ LIS_UNIT_MICROSECOND
Definition: capi.h:85
@ LIS_UNIT_NONE
Definition: capi.h:79
lis_img_format
Image format.
Definition: capi.h:46
@ LIS_IMG_FORMAT_CIFF
Definition: capi.h:62
@ LIS_IMG_FORMAT_EXIF
Definition: capi.h:63
@ LIS_IMG_FORMAT_GRAYSCALE_8
Definition: capi.h:59
@ LIS_IMG_FORMAT_BMP
Definition: capi.h:61
@ LIS_IMG_FORMAT_GIF
Definition: capi.h:65
@ LIS_IMG_FORMAT_JPEG2K
Definition: capi.h:69
@ LIS_IMG_FORMAT_TIFF
Definition: capi.h:74
@ LIS_IMG_FORMAT_JPEG2KX
Definition: capi.h:70
@ LIS_IMG_FORMAT_FLASHPIX
Definition: capi.h:64
@ LIS_IMG_FORMAT_ICO
Definition: capi.h:68
@ LIS_IMG_FORMAT_JPEG
Definition: capi.h:66
@ LIS_IMG_FORMAT_PNG
Definition: capi.h:67
@ LIS_IMG_FORMAT_RAW_RGB_24
Raw image, 24bits per pixel.
Definition: capi.h:57
@ LIS_IMG_FORMAT_PICT
Definition: capi.h:73
@ LIS_IMG_FORMAT_BW_1
Definition: capi.h:60
@ LIS_IMG_FORMAT_PHOTOCD
Definition: capi.h:72
@ LIS_IMG_FORMAT_MEMORYBMP
Definition: capi.h:71
lis_error
Definition: error.h:13
LibInsane C API.
Definition: capi.h:423
const char * base_name
Definition: capi.h:424
void(* cleanup)(struct lis_api *impl)
cleanup the implementation.
Definition: capi.h:437
enum lis_error(* list_devices)(struct lis_api *impl, enum lis_device_locations locs, struct lis_device_descriptor ***dev_infos)
Look for paper eaters.
Definition: capi.h:455
enum lis_error(* get_device)(struct lis_api *impl, const char *dev_id, struct lis_item **item)
Open the access to a device.
Definition: capi.h:483
Basic informations regarding a scanner.
Definition: capi.h:15
char * dev_id
Device id to use to identify and access the scanner.
Definition: capi.h:21
Definition: capi.h:356
void(* close)(struct lis_item *self)
Close the access to a scanner.
Definition: capi.h:408
const char * name
Definition: capi.h:357
enum lis_item_type type
Definition: capi.h:358
enum lis_error(* scan_start)(struct lis_item *self, struct lis_scan_session **session)
Starts a scan session.
Definition: capi.h:397
enum lis_error(* get_options)(struct lis_item *self, struct lis_option_descriptor ***descs)
Get item's options.
Definition: capi.h:386
enum lis_error(* get_children)(struct lis_item *self, struct lis_item ***children)
Get item's children (usually scan sources).
Definition: capi.h:374
Describes a scanner or source option and provides callback to read or change its value.
Definition: capi.h:120
struct lis_option_descriptor::@1 constraint
Restrictions defining the possible values for this option.
struct lis_value_range range
Definition: capi.h:176
const char * title
Definition: capi.h:122
union lis_option_descriptor::@1::@4 possible
enum lis_unit unit
Definition: capi.h:155
struct lis_value_list list
Definition: capi.h:181
enum lis_value_type type
Definition: capi.h:154
struct lis_option_descriptor::@2 fn
struct lis_option_descriptor::@0 value
Description of the type of values for this option.
enum lis_error(* set_value)(struct lis_option_descriptor *self, union lis_value value, int *set_flags)
set the option value.
Definition: capi.h:225
int capabilities
Option capabilities.
Definition: capi.h:148
const char * desc
Definition: capi.h:123
const char * name
Definition: capi.h:121
enum lis_error(* get_value)(struct lis_option_descriptor *self, union lis_value *value)
return the option value.
Definition: capi.h:204
Describes what will be returned when scanning.
Definition: capi.h:233
int height
Height of the image in pixels.
Definition: capi.h:250
enum lis_img_format format
Image format. This value is guaranteed to be true when scanning.
Definition: capi.h:238
size_t image_size
Estimated image size in bytes. Can be used to pre-allocate memory.
Definition: capi.h:257
int width
Width of the image in pixels. This value is guaranteed to be true when scanning.
Definition: capi.h:244
void(* cancel)(struct lis_scan_session *session)
Cancel the current scan session.
Definition: capi.h:338
enum lis_error(* get_scan_parameters)(struct lis_scan_session *self, struct lis_scan_parameters *parameters)
Returns a description of what will be returned when scanning.
Definition: capi.h:281
int(* end_of_feed)(struct lis_scan_session *session)
Indicates if we have reached the end of the feed. Should be called at least each time end_of_page ret...
Definition: capi.h:290
enum lis_error(* scan_read)(struct lis_scan_session *session, void *out_buffer, size_t *buffer_size)
Read a chunk of the scanned image.
Definition: capi.h:322
int(* end_of_page)(struct lis_scan_session *session)
Indicates if we have reached the end of the page being currently scanned. Should be called before eac...
Definition: capi.h:297
union lis_value * values
Definition: capi.h:113
int nb_values
Definition: capi.h:112
union lis_value max
Definition: capi.h:106
union lis_value min
Definition: capi.h:105
union lis_value interval
Definition: capi.h:107
Variable.
Definition: capi.h:94
const char * string
Definition: capi.h:98
int integer
Definition: capi.h:96
double dbl
Definition: capi.h:97
int boolean
Definition: capi.h:95
enum lis_img_format format
Definition: capi.h:99