forked from nemequ/vala-extra-vapis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sane-backends.vapi
271 lines (229 loc) · 7.63 KB
/
sane-backends.vapi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
Copyright (C) 2015 Robin Hellen
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
[CCode(cheader_filename="sane/sane.h", cprefix="SANE_", lower_case_cprefix="sane_")]
namespace Sane
{
[CCode (cprefix="SANE_STATUS_", has_type_id = false)]
public enum Status
{
GOOD,
UNSUPPORTED,
CANCELLED,
DEVICE_BUSY,
INVAL,
EOF,
JAMMED,
NO_DOCS,
COVER_OPEN,
IO_ERROR,
NO_MEM,
ACCESS_DENIED;
[CCode(cname="sane_strstatus")]
public unowned StringConst to_string();
}
[SimpleType]
[IntegerType(rank = 6)] // basically defined to be a 32-bit type of some sort, undefined interpretation.
[CCode(has_type_id = false)]
public struct Word {}
[SimpleType]
[IntegerType(rank = 6)] // defined to be a type that can hold from -2^31 to (2^31 - 1), equivalent to gint32
[CCode(has_type_id = false)]
public struct Int {}
[SimpleType]
[IntegerType(rank = 6)] // defined to be a type that can hold from -2^31 to (2^31 - 1), equivalent to gint32
[CCode(has_type_id = false)]
public struct Fixed
{
[CCode(cname="SANE_FIX")]
public static Fixed from_double(double d);
[CCode(cname="SANE_UNFIX")]
public double to_double();
[CCode(cname="SANE_FIXED_SCALE_SHIFT")]
public static int scale_shift;
}
[SimpleType]
[IntegerType(rank = 2)] // defined to be a type that can hold from 0 to (255), equivalent to gchar
[CCode(has_type_id = false)]
public struct Byte {}
[SimpleType]
[IntegerType(rank = 2)] // defined to be a type that can hold from 0 to (255), equivalent to gchar
[CCode(has_type_id = false)]
public struct Char {}
[CCode(has_type_id = false)]
[Compact]
public class String : string{}
[CCode(has_type_id = false)]
public enum Bool
{
[CCode(cname="SANE_FALSE")]
FALSE,
[CCode(cname="SANE_TRUE")]
TRUE
}
[CCode(cname="const SANE_Char", has_type_id = false)]
[PointerType]
public class StringConst : string {}
[CCode(cname="SANE_Device", has_copy_function = false, has_destroy_function = false, has_type_id = false)]
public struct Device
{
public unowned StringConst name;
public unowned StringConst vendor;
public unowned StringConst model;
public unowned StringConst type;
}
[CCode(cname="SANE_Option_Descriptor", has_type_id = false, ref_function = "", unref_function = "")]
[SimpleType]
public class OptionDescriptor
{
public unowned StringConst name;
public unowned StringConst title;
public unowned StringConst desc;
public ValueType type;
public Unit unit;
public Int size;
public Capability cap;
public ConstraintType constraint_type;
[CCode(array_null_terminated = true, cname="constraint.string_list")]
public unowned StringConst[] string_list;
[CCode(array_length = false, cname="constraint.word_list")] // Array length is first element of the array
public unowned Word[] word_list;
[CCode(cname="constraint.range")]
public Range range;
}
[CCode(has_type_id = false)]
public struct Range
{
Word min;
Word max;
Word quant;
}
[CCode(has_type_id = false)]
public struct Parameters
{
Frame format;
Bool last_frame;
Int bytes_per_line;
Int pixels_per_line;
Int lines;
Int depth;
}
[CCode(cname="SANE_Value_Type", cprefix="SANE_TYPE_", has_type_id = false)]
public enum ValueType
{
BOOL,
INT,
FIXED,
STRING,
BUTTON,
GROUP
}
[CCode(cprefix="SANE_UNIT_", has_type_id = false)]
public enum Unit
{
NONE,
PIXEL,
BIT,
MM,
DPI,
PERCENT,
MICROSECOND
}
[CCode(cname="SANE_Constraint_Type", cprefix="SANE_CONSTRAINT_", has_type_id = false)]
public enum ConstraintType
{
NONE,
RANGE,
WORD_LIST,
STRING_LIST
}
[CCode(cprefix="SANE_ACTION_", has_type_id = false)]
public enum Action
{
GET_VALUE,
SET_VALUE,
SET_AUTO
}
[CCode(cprefix="SANE_FRAME_", has_type_id = false)]
public enum Frame
{
GRAY,
RGB,
RED,
GREEN,
BLUE
}
[CCode(cname="SANE_Int", cprefix="SANE_INFO_", has_type_id = false)]
[Flags]
public enum Info
{
INEXACT,
RELOAD_OPTIONS,
RELOAD_PARAMS
}
[CCode(cname="SANE_Int", cprefix="SANE_CAP_", has_type_id = false)]
[Flags]
public enum Capability
{
SOFT_SELECT,
HARD_SELECT,
SOFT_DETECT,
EMULATED,
AUTOMATIC,
INACTIVE,
ADVANCED;
[CCode(cname="SANE_OPTION_IS_ACTIVE")]
public Bool is_active();
[CCode(cname="SANE_OPTION_IS_SETTABLE")]
public Bool is_settable();
}
[CCode(cname = "void", has_construct_function = false, has_type_id = false, ref_function = "", unref_function = "")]
public class Handle
{
[CCode(cname="sane_open")]
public static Status open(StringConst name, out Handle h);
[CCode(cname="sane_close")]
[DestroysInstance]
public void close();
[CCode(cname="sane_get_option_descriptor")]
public unowned OptionDescriptor get_option_descriptor(Int n);
[CCode(cname="sane_control_option")]
public Status control_option(Int n, Action a, void *v, out Int i);
[CCode(cname="sane_get_parameters")]
public Status get_parameters(out Parameters p);
[CCode(cname="sane_start")]
public Status start();
[CCode(cname="sane_read")]
public Status read([CCode(array_length_pos = 1.1)]Byte[] buf, out Int len);
[CCode(cname="sane_cancel")]
public void cancel();
[CCode(cname="sane_set_io_mode")]
public Status set_io_mode(Bool m);
[CCode(cname="sane_get_select_fd")]
public Status get_select_fd(out Int fd);
}
[CCode(cname="SANE_Authorization_Callback", has_target = false)]
public delegate void AuthorizationCallback(
StringConst resource,
[CCode(array_length_cexpr="SANE_MAX_USERNAME_LEN")]Char username[],
[CCode(array_length_cexpr="SANE_MAX_PASSWORD_LEN")]Char password[]
);
public Status init(out Int version_code, AuthorizationCallback? authorize);
public void exit();
public Status get_devices([CCode(array_null_terminated = true, array_length = false)]out unowned Device?[] device_list, Bool local_only);
}