LibInsane: /build/libinsane/src/libinsane/subprojects/libinsane/include/libinsane/capi.h Source File

| LibInsane 1.0.10 Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library

Loading...
Searching...
No Matches
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
9extern "C" {
10#endif
11
15 struct lis_device_descriptor {
21 char *dev_id;
22
23 char *vendor;
24 char *model;
25 char *type;
26};
27
28
32 enum lis_value_type {
33 LIS_TYPE_BOOL = 0,
34 LIS_TYPE_INTEGER,
35 LIS_TYPE_DOUBLE,
36 LIS_TYPE_STRING,
37 LIS_TYPE_IMAGE_FORMAT
38};
39
40
46 enum lis_img_format {
57 LIS_IMG_FORMAT_RAW_RGB_24 = 0,
58
59 LIS_IMG_FORMAT_GRAYSCALE_8,
60 LIS_IMG_FORMAT_BW_1,
61 LIS_IMG_FORMAT_BMP,
62 LIS_IMG_FORMAT_CIFF,
63 LIS_IMG_FORMAT_EXIF,
64 LIS_IMG_FORMAT_FLASHPIX,
65 LIS_IMG_FORMAT_GIF,
66 LIS_IMG_FORMAT_JPEG,
67 LIS_IMG_FORMAT_PNG,
68 LIS_IMG_FORMAT_ICO,
69 LIS_IMG_FORMAT_JPEG2K,
70 LIS_IMG_FORMAT_JPEG2KX,
71 LIS_IMG_FORMAT_MEMORYBMP, // Windows BMP without header
72 LIS_IMG_FORMAT_PHOTOCD,
73 LIS_IMG_FORMAT_PICT,
74 LIS_IMG_FORMAT_TIFF,
75};
76
77
78 enum lis_unit {
79 LIS_UNIT_NONE = 0,
80 LIS_UNIT_PIXEL,
81 LIS_UNIT_BIT,
82 LIS_UNIT_MM,
83 LIS_UNIT_DPI,
84 LIS_UNIT_PERCENT,
85 LIS_UNIT_MICROSECOND,
86};
87
88
94 union lis_value {
95 int boolean;
96 int integer;
97 double dbl;
98 const char *string;
99 enum lis_img_format format;
100};
101
102
103
104 struct lis_value_range {
105 union lis_value min;
106 union lis_value max;
107 union lis_value interval;
108};
109
110
111 struct lis_value_list {
112 int nb_values;
113 union lis_value *values;
114};
115
116
120 struct lis_option_descriptor {
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
148 int capabilities;
149
153 struct {
154 enum lis_value_type type;
155 enum lis_unit unit;
156 } value;
157
161 struct {
162 enum {
163 LIS_CONSTRAINT_NONE,
164 LIS_CONSTRAINT_RANGE,
165 LIS_CONSTRAINT_LIST,
166 } type;
172 union {
176 struct lis_value_range range;
177
181 struct lis_value_list list;
182 } possible;
183 } constraint;
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
233 struct lis_scan_parameters {
238 enum lis_img_format format;
239
244 int width;
245
250 int height;
251
257 size_t image_size;
258};
259
260
261 struct lis_scan_session {
280 enum lis_error (*get_scan_parameters)(
281 struct lis_scan_session *self,
282 struct lis_scan_parameters *parameters
283 );
284
289 int (*end_of_feed)(struct lis_scan_session *session);
290
296 int (*end_of_page)(struct lis_scan_session *session);
297
321 enum lis_error (*scan_read)(
322 struct lis_scan_session *session, void *out_buffer,
323 size_t *buffer_size
324 );
325
337 void (*cancel)(struct lis_scan_session *session);
338};
339
340
341 enum lis_item_type {
342 LIS_ITEM_DEVICE,
343 LIS_ITEM_FLATBED,
344 LIS_ITEM_ADF,
345 LIS_ITEM_UNIDENTIFIED = -1,
346};
347
348
355 struct lis_item {
356 const char *name;
357 enum lis_item_type type;
358
373 enum lis_error (*get_children)(struct lis_item *self, struct lis_item ***children);
374
385 enum lis_error (*get_options)(
386 struct lis_item *self, struct lis_option_descriptor ***descs
387 );
388
396 enum lis_error (*scan_start)(struct lis_item *self, struct lis_scan_session **session);
397
407 void (*close)(struct lis_item *self);
408};
409
410
411 enum lis_device_locations {
412 LIS_DEVICE_LOCATIONS_ANY = 0,
413 LIS_DEVICE_LOCATIONS_LOCAL_ONLY,
414};
415
416
422 struct lis_api {
423 const char *base_name;
436 void (*cleanup)(struct lis_api *impl);
437
454 enum lis_error (*list_devices)(
455 struct lis_api *impl, enum lis_device_locations locs,
456 struct lis_device_descriptor ***dev_infos
457 );
458
482 enum lis_error (*get_device)(
483 struct lis_api *impl, const char *dev_id, struct lis_item **item
484 );
485};
486
487#ifdef __cplusplus
488}
489#endif
490
491#endif
lis_device_locations
lis_device_locations
Definition capi.h:411
LIS_DEVICE_LOCATIONS_LOCAL_ONLY
@ LIS_DEVICE_LOCATIONS_LOCAL_ONLY
Definition capi.h:413
LIS_DEVICE_LOCATIONS_ANY
@ LIS_DEVICE_LOCATIONS_ANY
Definition capi.h:412
lis_item_type
lis_item_type
Definition capi.h:341
LIS_ITEM_ADF
@ LIS_ITEM_ADF
Definition capi.h:344
LIS_ITEM_FLATBED
@ LIS_ITEM_FLATBED
Definition capi.h:343
LIS_ITEM_UNIDENTIFIED
@ LIS_ITEM_UNIDENTIFIED
Definition capi.h:345
LIS_ITEM_DEVICE
@ LIS_ITEM_DEVICE
Definition capi.h:342
lis_value_type
lis_value_type
Variable type.
Definition capi.h:32
LIS_TYPE_DOUBLE
@ LIS_TYPE_DOUBLE
Definition capi.h:35
LIS_TYPE_BOOL
@ LIS_TYPE_BOOL
Definition capi.h:33
LIS_TYPE_INTEGER
@ LIS_TYPE_INTEGER
Definition capi.h:34
LIS_TYPE_STRING
@ LIS_TYPE_STRING
Definition capi.h:36
LIS_TYPE_IMAGE_FORMAT
@ LIS_TYPE_IMAGE_FORMAT
Definition capi.h:37
lis_unit
lis_unit
Definition capi.h:78
LIS_UNIT_PIXEL
@ LIS_UNIT_PIXEL
Definition capi.h:80
LIS_UNIT_DPI
@ LIS_UNIT_DPI
Definition capi.h:83
LIS_UNIT_PERCENT
@ LIS_UNIT_PERCENT
Definition capi.h:84
LIS_UNIT_MM
@ LIS_UNIT_MM
Definition capi.h:82
LIS_UNIT_BIT
@ LIS_UNIT_BIT
Definition capi.h:81
LIS_UNIT_MICROSECOND
@ LIS_UNIT_MICROSECOND
Definition capi.h:85
LIS_UNIT_NONE
@ LIS_UNIT_NONE
Definition capi.h:79
lis_img_format
lis_img_format
Image format.
Definition capi.h:46
LIS_IMG_FORMAT_CIFF
@ LIS_IMG_FORMAT_CIFF
Definition capi.h:62
LIS_IMG_FORMAT_EXIF
@ LIS_IMG_FORMAT_EXIF
Definition capi.h:63
LIS_IMG_FORMAT_GRAYSCALE_8
@ LIS_IMG_FORMAT_GRAYSCALE_8
Definition capi.h:59
LIS_IMG_FORMAT_BMP
@ LIS_IMG_FORMAT_BMP
Definition capi.h:61
LIS_IMG_FORMAT_GIF
@ LIS_IMG_FORMAT_GIF
Definition capi.h:65
LIS_IMG_FORMAT_JPEG2K
@ LIS_IMG_FORMAT_JPEG2K
Definition capi.h:69
LIS_IMG_FORMAT_TIFF
@ LIS_IMG_FORMAT_TIFF
Definition capi.h:74
LIS_IMG_FORMAT_JPEG2KX
@ LIS_IMG_FORMAT_JPEG2KX
Definition capi.h:70
LIS_IMG_FORMAT_FLASHPIX
@ LIS_IMG_FORMAT_FLASHPIX
Definition capi.h:64
LIS_IMG_FORMAT_ICO
@ LIS_IMG_FORMAT_ICO
Definition capi.h:68
LIS_IMG_FORMAT_JPEG
@ LIS_IMG_FORMAT_JPEG
Definition capi.h:66
LIS_IMG_FORMAT_PNG
@ LIS_IMG_FORMAT_PNG
Definition capi.h:67
LIS_IMG_FORMAT_RAW_RGB_24
@ LIS_IMG_FORMAT_RAW_RGB_24
Raw image, 24bits per pixel.
Definition capi.h:57
LIS_IMG_FORMAT_PICT
@ LIS_IMG_FORMAT_PICT
Definition capi.h:73
LIS_IMG_FORMAT_BW_1
@ LIS_IMG_FORMAT_BW_1
Definition capi.h:60
LIS_IMG_FORMAT_PHOTOCD
@ LIS_IMG_FORMAT_PHOTOCD
Definition capi.h:72
LIS_IMG_FORMAT_MEMORYBMP
@ LIS_IMG_FORMAT_MEMORYBMP
Definition capi.h:71
error.h
lis_error
lis_error
Definition error.h:13
lis_api
LibInsane C API.
Definition capi.h:422
lis_api::base_name
const char * base_name
Definition capi.h:423
lis_api::cleanup
void(* cleanup)(struct lis_api *impl)
cleanup the implementation.
Definition capi.h:436
lis_api::list_devices
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:454
lis_api::get_device
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:482
lis_device_descriptor
Basic informations regarding a scanner.
Definition capi.h:15
lis_device_descriptor::vendor
char * vendor
Definition capi.h:23
lis_device_descriptor::model
char * model
Definition capi.h:24
lis_device_descriptor::dev_id
char * dev_id
Device id to use to identify and access the scanner.
Definition capi.h:21
lis_device_descriptor::type
char * type
Definition capi.h:25
lis_item
Definition capi.h:355
lis_item::close
void(* close)(struct lis_item *self)
Close the access to a scanner.
Definition capi.h:407
lis_item::name
const char * name
Definition capi.h:356
lis_item::type
enum lis_item_type type
Definition capi.h:357
lis_item::scan_start
enum lis_error(* scan_start)(struct lis_item *self, struct lis_scan_session **session)
Starts a scan session.
Definition capi.h:396
lis_item::get_options
enum lis_error(* get_options)(struct lis_item *self, struct lis_option_descriptor ***descs)
Get item's options.
Definition capi.h:385
lis_item::get_children
enum lis_error(* get_children)(struct lis_item *self, struct lis_item ***children)
Get item's children (usually scan sources).
Definition capi.h:373
lis_option_descriptor
Describes a scanner or source option and provides callback to read or change its value.
Definition capi.h:120
lis_option_descriptor::LIS_CONSTRAINT_LIST
@ LIS_CONSTRAINT_LIST
Definition capi.h:165
lis_option_descriptor::constraint
struct lis_option_descriptor::@1 constraint
Restrictions defining the possible values for this option.
lis_option_descriptor::range
struct lis_value_range range
Definition capi.h:176
lis_option_descriptor::title
const char * title
Definition capi.h:122
lis_option_descriptor::possible
union lis_option_descriptor::@1::@4 possible
lis_option_descriptor::unit
enum lis_unit unit
Definition capi.h:155
lis_option_descriptor::list
struct lis_value_list list
Definition capi.h:181
lis_option_descriptor::type
enum lis_value_type type
Definition capi.h:154
lis_option_descriptor::fn
struct lis_option_descriptor::@2 fn
lis_option_descriptor::value
struct lis_option_descriptor::@0 value
Description of the type of values for this option.
lis_option_descriptor::capabilities
int capabilities
Option capabilities.
Definition capi.h:148
lis_option_descriptor::desc
const char * desc
Definition capi.h:123
lis_option_descriptor::name
const char * name
Definition capi.h:121
lis_option_descriptor::LIS_CONSTRAINT_RANGE
@ LIS_CONSTRAINT_RANGE
Definition capi.h:164
lis_option_descriptor::LIS_CONSTRAINT_NONE
@ LIS_CONSTRAINT_NONE
Definition capi.h:163
lis_scan_parameters
Describes what will be returned when scanning.
Definition capi.h:233
lis_scan_parameters::height
int height
Height of the image in pixels.
Definition capi.h:250
lis_scan_parameters::format
enum lis_img_format format
Image format. This value is guaranteed to be true when scanning.
Definition capi.h:238
lis_scan_parameters::image_size
size_t image_size
Estimated image size in bytes. Can be used to pre-allocate memory.
Definition capi.h:257
lis_scan_parameters::width
int width
Width of the image in pixels. This value is guaranteed to be true when scanning.
Definition capi.h:244
lis_scan_session
Definition capi.h:261
lis_scan_session::cancel
void(* cancel)(struct lis_scan_session *session)
Cancel the current scan session.
Definition capi.h:337
lis_scan_session::get_scan_parameters
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:280
lis_scan_session::end_of_feed
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:289
lis_scan_session::scan_read
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:321
lis_scan_session::end_of_page
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:296
lis_value_list
Definition capi.h:111
lis_value_list::values
union lis_value * values
Definition capi.h:113
lis_value_list::nb_values
int nb_values
Definition capi.h:112
lis_value_range
Definition capi.h:104
lis_value_range::max
union lis_value max
Definition capi.h:106
lis_value_range::min
union lis_value min
Definition capi.h:105
lis_value_range::interval
union lis_value interval
Definition capi.h:107
lis_value
Variable.
Definition capi.h:94
lis_value::string
const char * string
Definition capi.h:98
lis_value::integer
int integer
Definition capi.h:96
lis_value::dbl
double dbl
Definition capi.h:97
lis_value::boolean
int boolean
Definition capi.h:95
lis_value::format
enum lis_img_format format
Definition capi.h:99