tests: Add various regression "codegen" tests to increase coverage
[vala-gnome.git] / vapi / libusb-1.0.vapi
blob780900a03de736e4d3a484439c4646fb8b163481
1 [CCode (cprefix = "libusb_", cheader_filename = "libusb.h")]
2 namespace LibUSB {
3         [CCode (cname = "enum libusb_class_code", cprefix = "LIBUSB_CLASS_", has_type_id = false)]
4         public enum ClassCode {
5                 PER_INTERFACE,
6                 AUDIO,
7                 COMM,
8                 HID,
9                 PRINTER,
10                 PTP,
11                 MASS_STORAGE,
12                 HUB,
13                 DATA,
14                 VENDOR_SPEC
15         }
17         [CCode (cname = "enum libusb_descriptor_type", cprefix = "LIBUSB_DT_", has_type_id = false)]
18         public enum DescriptorType {
19                 DEVICE,
20                 CONFIG,
21                 STRING,
22                 INTERFACE,
23                 ENDPOINT,
24                 HID,
25                 REPORT,
26                 PHYSICAL,
27                 HUB
28         }
30         [CCode (cprefix = "LIBUSB_DT_")]
31         namespace DescriptorTypeSize {
32                 public const int DEVICE_SIZE;
33                 public const int CONFIG_SIZE;
34                 public const int INTERFACE_SIZE;
35                 public const int ENDPOINT_SIZE;
36                 public const int ENDPOINT_AUDIO_SIZE;
37                 public const int HUB_NONVAR_SIZE;
38         }
40         namespace EndpointMask {
41                 [CCode (cname = "LIBUSB_ENDPOINT_ADDRESS_MASK")]
42                 public const int ADDRESS;
43                 [CCode (cname = "LIBUSB_ENDPOINT_DIR_MASK")]
44                 public const int DIR;
45                 [CCode (cname = "LIBUSB_ENDPOINT_DIR_MASK")]
46                 public const int DIRECTION;
47         }
49         [CCode (cname = "enum libusb_endpoint_direction", cprefix = "LIBUSB_ENDPOINT_", has_type_id = false)]
50         public enum EndpointDirection {
51                 IN,
52                 OUT,
53                 [CCode (cname = "LIBUSB_ENDPOINT_DIR_MASK")]
54                 MASK
55         }
57         [CCode (cname = "enum libusb_transfer_type", cprefix = "LIBUSB_TRANSFER_TYPE_", has_type_id = false)]
58         public enum TransferType {
59                 CONTROL,
60                 ISOCHRONOUS,
61                 BULK,
62                 INTERRUPT
63         }
65         [CCode (cname = "enum libusb_standard_request", cprefix = "LIBUSB_REQUEST_", has_type_id = false)]
66         public enum StandardRequest {
67                 GET_STATUS,
68                 CLEAR_FEATURE,
69                 SET_FEATURE,
70                 SET_ADDRESS,
71                 GET_DESCRIPTOR,
72                 SET_DESCRIPTOR,
73                 GET_CONFIGURATION,
74                 GET_INTERFACE,
75                 SET_INTERFACE,
76                 SYNCH_FRAME
77         }
79         [CCode (cname = "enum libusb_request_type", cprefix = "LIBUSB_REQUEST_TYPE_", has_type_id = false)]
80         public enum RequestType {
81                 STANDARD,
82                 CLASS,
83                 VENDOR,
84                 RESERVED
85         }
87         [CCode (cname = "enum libusb_request_recipient", cprefix = "LIBUSB_RECIPIENT_", has_type_id = false)]
88         public enum RequestRecipient {
89                 DEVICE,
90                 INTERFACE,
91                 ENDPOINT,
92                 OTHER
93         }
95         [CCode (cname = "enum libusb_iso_sync_type", cprefix = "LIBUSB_ISO_SYNC_TYPE_", has_type_id = false)]
96         public enum IsoSyncType {
97                 NONE,
98                 ASYNC,
99                 ADAPTIVE,
100                 SYNC,
101                 MASK
102         }
104         [CCode (cname = "enum libusb_iso_usage_type", cprefix = "LIBUSB_ISO_USAGE_TYPE_", has_type_id = false)]
105         public enum IsoUsageType {
106                 DATA,
107                 FEEDBACK,
108                 IMPLICIT,
109                 MASK
110         }
112         [CCode (cname = "enum libusb_error", cprefix = "LIBUSB_ERROR_", has_type_id = false)]
113         public enum Error {
114                 [CCode (cname = "LIBUSB_SUCCESS")]
115                 SUCCESS,
116                 IO,
117                 INVALID_PARAM,
118                 ACCESS,
119                 NO_DEVICE,
120                 NOT_FOUND,
121                 BUSY,
122                 TIMEOUT,
123                 OVERFLOW,
124                 PIPE,
125                 INTERRUPTED,
126                 NO_MEM,
127                 NOT_SUPPORTED,
128                 OTHER
129         }
131         [CCode (cname = "enum libusb_transfer_flags", cprefix = "LIBUSB_TRANSFER_", has_type_id = false)]
132         public enum TransferFlags {
133                 SHORT_NOT_OK,
134                 FREE_BUFFER,
135                 FREE_TRANSFER
136         }
138         [CCode (cname = "struct libusb_device_descriptor", has_type_id = false)]
139         public struct DeviceDescriptor {
140                 public uint8 bLength;
141                 public uint8 bDescriptorType;
142                 public uint16 bcdUSB;
143                 public uint8 bDeviceClass;
144                 public uint8 bDeviceSubClass;
145                 public uint8 bDeviceProtocol;
146                 public uint8 bMaxPacketSize0;
147                 public uint16 idVendor;
148                 public uint16 idProduct;
149                 public uint16 bcdDevice;
150                 public uint8 iManufacturer;
151                 public uint8 iProduct;
152                 public uint8 iSerialNumber;
153                 public uint8 bNumConfigurations;
155                 [CCode (cname = "libusb_get_device_descriptor", instance_pos = -1)]
156                 public DeviceDescriptor (Device device);
157         }
159         [CCode (cname = "struct libusb_endpoint_descriptor", cprefix = "libusb_", has_type_id = false)]
160         public struct EndpointDescriptor {
161                 public uint8 bLength;
162                 public uint8 bDescriptorType;
163                 public uint8 bEndpointAddress;
164                 public uint8 bmAttributes;
165                 public uint16 wMaxPacketSize;
166                 public uint8 bInterval;
167                 public uint8 bRefresh;
168                 public uint8 bSynchAddress;
169                 [CCode (array_length_cname = "extra_length")]
170                 public uint8[] extra;
171         }
173         [CCode (cname = "struct libusb_interface_descriptor", has_type_id = false)]
174         public struct InterfaceDescriptor {
175                 public uint8 bLength;
176                 public uint8 bDescriptorType;
177                 public uint8 bInterfaceNumber;
178                 public uint8 bAlternateSetting;
179                 public uint8 bNumEndpoints;
180                 public uint8 bInterfaceClass;
181                 public uint8 bInterfaceSubClass;
182                 public uint8 bInterfaceProtocol;
183                 public uint8 iInterface;
184                 [CCode (array_length_cname = "bNumEndpoints", array_length_type = "uint8_t")]
185                 public EndpointDescriptor[] endpoint;
186                 [CCode (array_length_cname = "extra_length")]
187                 public uint8[] extra;
188         }
190         [CCode (cname = "struct libusb_interface", has_type_id = false)]
191         public struct Interface {
192                 [CCode (array_length_cname = "num_altsetting")]
193                 public InterfaceDescriptor[] altsetting;
194         }
196         [Compact, CCode (cname = "struct libusb_config_descriptor", free_function = "libusb_free_config_descriptor")]
197         public class ConfigDescriptor {
198                 public uint8 bLength;
199                 public uint8 bDescriptorType;
200                 public uint16 wTotalLength;
201                 public uint8 bNumInterfaces;
202                 public uint8 bConfigurationValue;
203                 public uint8 iConfiguration;
204                 public uint8 bmAttributes;
205                 public uint8 MaxPower;
206                 [CCode (array_length_cname = "bNumInterfaces")]
207                 public Interface[] @interface;
208                 [CCode (array_length_cname = "extra_length")]
209                 public uint8[] extra;
210         }
213         [Compact, CCode (cname = "libusb_device_handle", cprefix = "libusb_", free_function = "libusb_close")]
214         public class DeviceHandle {
215                 [CCode (cname = "_vala_libusb_device_handle_new")]
216                 public DeviceHandle (Device device) {
217                         DeviceHandle handle;
218                         device.open(out handle);
219                 }
221                 [CCode (cname = "libusb_open_device_with_vid_pid")]
222                 public DeviceHandle.from_vid_pid (Context? context, uint16 vendor_id, uint16 product_id);
223                 public unowned Device get_device ();
224                 public int get_configuration (out int config);
225                 public int set_configuration (int configuration);
226                 public int claim_interface (int interface_number);
227                 public int release_interface (int interface_number);
228                 public int set_interface_alt_setting (int interface_number, int alternate_setting);
229                 public int clear_halt (uchar endpoint);
230                 [CCode (cname = "libusb_reset_device")]
231                 public int reset ();
232                 public int kernel_driver_active (int @interface);
233                 public int detach_kernel_driver (int @interface);
234                 public int attach_kernel_driver (int @interface);
236                 public int get_string_descriptor_ascii (uint8 desc_index, uint8[] data);
237                 public int get_descriptor (uint8 desc_type, uint8 desc_index, uint8[] data);
238                 public int get_string_descriptor (uint desc_index, uint16 langid, uint8[] data);
240                 public int control_transfer (uint8 bmRequestType, uint8 bRequest, uint16 wValue, uint16 wIndex, [CCode (array_length = false)] uint8[] data, uint16 wLength, uint timeout);
241                 public int bulk_transfer (uint8 endpoint, uint8[] data, out int transferred, uint timeout);
242                 public int interrupt_transfer (uint8 endpoint, uint8[] data, out int transferred, uint timeout);
243         }
245         [Compact, CCode (cname = "libusb_device", cprefix = "libusb_", ref_function = "libusb_ref_device", unref_function = "libusb_unref_device")]
246         public class Device {
247                 public uint8 get_bus_number ();
248                 public uint8 get_device_address ();
249                 public int get_max_packet_size (uint8 endpoint);
250                 public int open (out DeviceHandle handle);
252                 public int get_active_config_descriptor (out ConfigDescriptor config);
253                 public int get_config_descriptor (uint8 config_index, out ConfigDescriptor config);
254                 public int get_config_descriptor_by_value (uint8 ConfigurationValue, out ConfigDescriptor config);
255                 public int get_device_descriptor (out DeviceDescriptor desc);
256         }
258         [Compact, CCode (cname = "libusb_context", cprefix = "libusb_", free_function = "libusb_exit")]
259         public class Context {
260                 protected Context ();
261                 public static int init (out Context context);
262                 public void set_debug (int level);
263                 public ssize_t get_device_list ([CCode (array_length = false)] out Device[] list);
264                 public DeviceHandle open_device_with_vid_pid (uint16 vendor_id, uint16 product_id);
266                 public int try_lock_events ();
267                 public void lock_events ();
268                 public void unlock_events ();
269                 public int event_handling_ok ();
270                 public int event_handler_active ();
271                 public void lock_event_waiters ();
272                 public void unlock_event_waiters ();
273                 public int wait_for_event (Posix.timeval tv);
274                 public int handle_events_timeout (Posix.timeval tv);
275                 public int handle_events ();
276                 public int handle_events_locked (Posix.timeval tv);
277                 public int get_next_timeout (out Posix.timeval tv);
278                 public void set_pollfd_notifiers (pollfd_added_cb added_cb, pollfd_removed_cb removed_cb, void* user_data);
279                 [CCode (array_length = false)]
280                 public unowned PollFD[] get_pollfds ();
281         }
283         public static uint16 le16_to_cpu (uint16 n);
284         public static uint16 cpu_to_le16 (uint16 n);
285         [CCode (cname = "malloc", cheader_filename = "stdlib.h")]
286         private static void* malloc (ulong n_bytes);
288         [Compact, CCode (cname = "struct libusb_control_setup")]
289         public class ControlSetup {
290                 public uint8 bmRequestType;
291                 public int8 bRequest;
292                 public uint16 wValue;
293                 public uint16 wIndex;
294                 public uint16 wLength;
295         }
297         [CCode (cname = "enum libusb_transfer_status", cprefix = "LIBUSB_TRANSFER_", has_type_id = false)]
298         public enum TransferStatus {
299                 COMPLETED,
300                 ERROR,
301                 TIMED_OUT,
302                 CANCELLED,
303                 STALL,
304                 NO_DEVICE,
305                 OVERFLOW
306         }
308         [CCode (cname = "struct libusb_iso_packet_descriptor", has_type_id = false)]
309         public struct IsoPacketDescriptor {
310                 public uint length;
311                 public uint actual_length;
312                 public TransferStatus status;
313         }
315         [CCode (has_target = false)]
316         public delegate void transfer_cb_fn (Transfer transfer);
318         [Compact, CCode (cname = "struct libusb_transfer", cprefix = "libusb_", free_function = "libusb_free_transfer")]
319         public class Transfer {
320                 public DeviceHandle dev_handle;
321                 public uint8 flags;
322                 public uint8 endpoint;
323                 public uint8 type;
324                 public uint timeout;
325                 public TransferStatus status;
326                 public int length;
327                 public int actual_length;
328                 public transfer_cb_fn @callback;
329                 public void* user_data;
330                 [CCode (array_length_cname = "length")]
331                 public uint8[] buffer;
332                 public int num_iso_packets;
333                 [CCode (array_length = false)]
334                 public IsoPacketDescriptor[] iso_packet_desc;
336                 [CCode (cname = "libusb_alloc_transfer")]
337                 public Transfer (int iso_packets = 0);
338                 [CCode (cname = "libusb_submit_transfer")]
339                 public int submit ();
340                 [CCode (cname = "libusb_cancel_transfer")]
341                 public int cancel ();
342                 [CCode (cname = "libusb_contrel_transfer_get_data", array_length = false)]
343                 public unowned char[] control_get_data ();
344                 [CCode (cname = "libusb_control_transfer_get_setup")]
345                 public unowned ControlSetup control_get_setup ();
347                 public static void fill_control_setup ([CCode (array_length = false)] uint8[] buffer, uint8 bmRequestType, uint8 bRequest, uint16 wValue, uint16 wIndex, uint16 wLength);
348                 public void fill_control_transfer (DeviceHandle dev_handle, [CCode (array_length = false)] uint8[] buffer, transfer_cb_fn @callback, void* user_data, uint timeout);
349                 public void fill_bulk_transfer (DeviceHandle dev_handle, uint8 endpoint, uint8[] buffer, transfer_cb_fn @callback, void* user_data, uint timeout);
350                 public void fill_interrupt_transfer (DeviceHandle dev_handle, uint8 endpoint, uint8[] buffer, transfer_cb_fn @callback, void* user_data, uint timeout);
351                 public void fill_iso_transfer (DeviceHandle dev_handle, uint8 endpoint, uint8[] buffer, int num_iso_packets, transfer_cb_fn @callback, void* user_data, uint timeout);
352                 public void set_packet_lengths (uint length);
353                 [CCode (array_length = false)]
354                 public unowned uint8[] get_iso_packet_buffer (uint packet);
355                 [CCode (array_length = false)]
356                 public unowned uint8[] get_iso_packet_buffer_simple (int packet);
357         }
359         [CCode (has_target = false)]
360         public delegate void pollfd_added_cb (int fd, short events, void* user_data);
361         [CCode (has_target = false)]
362         public delegate void pollfd_removed_cb (int fd, void* user_data);
364         [Compact, CCode (cname = "struct libusb_pollfd")]
365         public class PollFD {
366                 public int fd;
367                 public short events;
368         }