usb 1.7.2 → 1.8.1-libusb.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/.gitmodules +1 -1
  2. package/Readme.md +2 -2
  3. package/binding.gyp +2 -2
  4. package/libusb/.private/pre-commit.sh +7 -1
  5. package/libusb/.travis.yml +49 -0
  6. package/libusb/AUTHORS +44 -3
  7. package/libusb/Brewfile +4 -0
  8. package/libusb/ChangeLog +74 -2
  9. package/libusb/README.md +32 -0
  10. package/libusb/TODO +1 -1
  11. package/libusb/Xcode/common.xcconfig +12 -0
  12. package/libusb/Xcode/config.h +25 -0
  13. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +959 -1
  14. package/libusb/android/README +4 -2
  15. package/libusb/android/config.h +75 -0
  16. package/libusb/appveyor.yml +41 -0
  17. package/libusb/appveyor_cygwin.bat +11 -0
  18. package/libusb/appveyor_minGW.bat +19 -0
  19. package/libusb/autogen.sh +1 -1
  20. package/libusb/bootstrap.sh +3 -16
  21. package/libusb/configure.ac +108 -80
  22. package/libusb/doc/doxygen.cfg.in +1785 -739
  23. package/libusb/examples/Makefile.am +1 -1
  24. package/libusb/examples/dpfp.c +3 -1
  25. package/libusb/examples/dpfp_threaded.c +23 -10
  26. package/libusb/examples/ezusb.c +3 -3
  27. package/libusb/examples/ezusb.h +2 -2
  28. package/libusb/examples/fxload.c +31 -9
  29. package/libusb/examples/hotplugtest.c +35 -7
  30. package/libusb/examples/listdevs.c +3 -1
  31. package/libusb/examples/sam3u_benchmark.c +3 -3
  32. package/libusb/examples/testlibusb.c +277 -0
  33. package/libusb/examples/xusb.c +40 -34
  34. package/libusb/libusb/Makefile.am +49 -23
  35. package/libusb/libusb/core.c +855 -457
  36. package/libusb/libusb/descriptor.c +72 -78
  37. package/libusb/libusb/hotplug.c +122 -76
  38. package/libusb/libusb/hotplug.h +42 -25
  39. package/libusb/libusb/io.c +625 -390
  40. package/libusb/libusb/libusb-1.0.def +12 -0
  41. package/libusb/libusb/libusb.h +218 -150
  42. package/libusb/libusb/libusbi.h +346 -176
  43. package/libusb/libusb/os/darwin_usb.c +604 -319
  44. package/libusb/libusb/os/darwin_usb.h +61 -20
  45. package/libusb/libusb/os/haiku_pollfs.cpp +367 -0
  46. package/libusb/libusb/os/haiku_usb.h +113 -0
  47. package/libusb/libusb/os/haiku_usb_backend.cpp +533 -0
  48. package/libusb/libusb/os/haiku_usb_raw.cpp +267 -0
  49. package/libusb/libusb/os/haiku_usb_raw.h +188 -0
  50. package/libusb/libusb/os/linux_netlink.c +186 -146
  51. package/libusb/libusb/os/linux_udev.c +36 -14
  52. package/libusb/libusb/os/linux_usbfs.c +426 -225
  53. package/libusb/libusb/os/linux_usbfs.h +5 -3
  54. package/libusb/libusb/os/netbsd_usb.c +21 -77
  55. package/libusb/libusb/os/openbsd_usb.c +32 -115
  56. package/libusb/libusb/os/poll_posix.c +38 -5
  57. package/libusb/libusb/os/poll_posix.h +3 -0
  58. package/libusb/libusb/os/poll_windows.c +277 -626
  59. package/libusb/libusb/os/poll_windows.h +11 -44
  60. package/libusb/libusb/os/sunos_usb.c +1695 -0
  61. package/libusb/libusb/os/sunos_usb.h +80 -0
  62. package/libusb/libusb/os/threads_posix.c +24 -26
  63. package/libusb/libusb/os/threads_posix.h +73 -21
  64. package/libusb/libusb/os/threads_windows.c +71 -157
  65. package/libusb/libusb/os/threads_windows.h +68 -44
  66. package/libusb/libusb/os/wince_usb.c +276 -420
  67. package/libusb/libusb/os/wince_usb.h +23 -28
  68. package/libusb/libusb/os/windows_common.h +78 -58
  69. package/libusb/libusb/os/windows_nt_common.c +1010 -0
  70. package/libusb/libusb/os/windows_nt_common.h +110 -0
  71. package/libusb/libusb/os/windows_nt_shared_types.h +147 -0
  72. package/libusb/libusb/os/windows_usbdk.c +830 -0
  73. package/libusb/libusb/os/windows_usbdk.h +103 -0
  74. package/libusb/libusb/os/windows_winusb.c +4391 -0
  75. package/libusb/libusb/os/windows_winusb.h +783 -0
  76. package/libusb/libusb/strerror.c +41 -7
  77. package/libusb/libusb/sync.c +41 -13
  78. package/libusb/libusb/version.h +1 -1
  79. package/libusb/libusb/version_nano.h +1 -1
  80. package/libusb/libusb-1.0.pc.in +1 -1
  81. package/libusb/msvc/appveyor.bat +27 -0
  82. package/libusb/msvc/config.h +5 -4
  83. package/libusb/msvc/ddk_build.cmd +87 -43
  84. package/libusb/msvc/fxload_2010.vcxproj +24 -104
  85. package/libusb/msvc/fxload_2012.vcxproj +24 -107
  86. package/libusb/msvc/fxload_2013.vcxproj +24 -107
  87. package/libusb/msvc/fxload_2015.vcxproj +91 -0
  88. package/libusb/msvc/fxload_2017.vcxproj +114 -0
  89. package/libusb/msvc/fxload_sources +1 -1
  90. package/libusb/msvc/getopt_2010.vcxproj +16 -75
  91. package/libusb/msvc/getopt_2012.vcxproj +16 -79
  92. package/libusb/msvc/getopt_2013.vcxproj +16 -79
  93. package/libusb/msvc/getopt_2015.vcxproj +73 -0
  94. package/libusb/msvc/getopt_2017.vcxproj +98 -0
  95. package/libusb/msvc/getopt_sources +6 -2
  96. package/libusb/msvc/hotplugtest_2010.vcxproj +18 -99
  97. package/libusb/msvc/hotplugtest_2012.vcxproj +18 -102
  98. package/libusb/msvc/hotplugtest_2013.vcxproj +18 -102
  99. package/libusb/msvc/hotplugtest_2015.vcxproj +83 -0
  100. package/libusb/msvc/hotplugtest_2017.vcxproj +106 -0
  101. package/libusb/msvc/hotplugtest_sources +1 -1
  102. package/libusb/msvc/libusb_2005.sln +20 -20
  103. package/libusb/msvc/libusb_2010.sln +57 -46
  104. package/libusb/msvc/libusb_2012.sln +57 -46
  105. package/libusb/msvc/libusb_2013.sln +57 -50
  106. package/libusb/msvc/libusb_2015.sln +59 -52
  107. package/libusb/msvc/libusb_2017.sln +186 -0
  108. package/libusb/msvc/libusb_dll.dsp +2 -2
  109. package/libusb/msvc/libusb_dll_2005.vcproj +30 -2
  110. package/libusb/msvc/libusb_dll_2010.vcxproj +26 -90
  111. package/libusb/msvc/libusb_dll_2012.vcxproj +28 -96
  112. package/libusb/msvc/libusb_dll_2013.vcxproj +28 -96
  113. package/libusb/msvc/libusb_dll_2015.vcxproj +107 -0
  114. package/libusb/msvc/libusb_dll_2017.vcxproj +134 -0
  115. package/libusb/msvc/libusb_dll_wince.vcproj +9 -1
  116. package/libusb/msvc/libusb_sources +10 -5
  117. package/libusb/msvc/libusb_static.dsp +2 -2
  118. package/libusb/msvc/libusb_static_2005.vcproj +32 -4
  119. package/libusb/msvc/libusb_static_2010.vcxproj +24 -83
  120. package/libusb/msvc/libusb_static_2012.vcxproj +25 -87
  121. package/libusb/msvc/libusb_static_2013.vcxproj +25 -87
  122. package/libusb/msvc/libusb_static_2015.vcxproj +98 -0
  123. package/libusb/msvc/libusb_static_2017.vcxproj +117 -0
  124. package/libusb/msvc/libusb_static_wince.vcproj +20 -26
  125. package/libusb/msvc/libusb_wince.sln +88 -88
  126. package/libusb/msvc/listdevs_2010.vcxproj +16 -99
  127. package/libusb/msvc/listdevs_2012.vcxproj +16 -102
  128. package/libusb/msvc/listdevs_2013.vcxproj +16 -102
  129. package/libusb/msvc/listdevs_2015.vcxproj +83 -0
  130. package/libusb/msvc/listdevs_2017.vcxproj +106 -0
  131. package/libusb/msvc/listdevs_sources +2 -1
  132. package/libusb/msvc/stress_2010.vcxproj +20 -101
  133. package/libusb/msvc/stress_2012.vcxproj +20 -104
  134. package/libusb/msvc/stress_2013.vcxproj +20 -104
  135. package/libusb/msvc/stress_2015.vcxproj +87 -0
  136. package/libusb/msvc/stress_2017.vcxproj +110 -0
  137. package/libusb/msvc/stress_sources +21 -0
  138. package/libusb/msvc/testlibusb_2010.vcxproj +82 -0
  139. package/libusb/msvc/testlibusb_2012.vcxproj +83 -0
  140. package/libusb/msvc/testlibusb_2013.vcxproj +83 -0
  141. package/libusb/msvc/testlibusb_2015.vcxproj +83 -0
  142. package/libusb/msvc/testlibusb_2017.vcxproj +106 -0
  143. package/libusb/msvc/testlibusb_sources +20 -0
  144. package/libusb/msvc/xusb_2010.vcxproj +17 -98
  145. package/libusb/msvc/xusb_2012.vcxproj +17 -101
  146. package/libusb/msvc/xusb_2013.vcxproj +17 -101
  147. package/libusb/msvc/xusb_2015.vcxproj +83 -0
  148. package/libusb/msvc/xusb_2017.vcxproj +106 -0
  149. package/libusb/msvc/xusb_sources +1 -1
  150. package/libusb/tests/stress.c +2 -2
  151. package/libusb/tests/testlib.c +0 -4
  152. package/libusb/travis-autogen.sh +39 -0
  153. package/libusb.gypi +13 -2
  154. package/package.json +20 -11
  155. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  156. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  157. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  158. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  159. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  160. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  161. package/prebuilds/linux-ia32/node.napi.node +0 -0
  162. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  163. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  164. package/prebuilds/win32-ia32/node.napi.node +0 -0
  165. package/prebuilds/win32-x64/node.napi.node +0 -0
  166. package/src/device.cc +1 -1
  167. package/usb.js +51 -5
  168. package/.github/workflows/prebuild.yml +0 -49
  169. package/libusb/INSTALL +0 -234
  170. package/libusb/README +0 -28
  171. package/libusb/libusb/os/windows_usb.c +0 -5347
  172. package/libusb/libusb/os/windows_usb.h +0 -971
  173. package/libusb/msvc/fxload_2010.vcxproj.filters +0 -25
  174. package/libusb/msvc/fxload_2012.vcxproj.filters +0 -25
  175. package/libusb/msvc/getopt_2010.vcxproj.filters +0 -26
  176. package/libusb/msvc/getopt_2012.vcxproj.filters +0 -26
  177. package/libusb/msvc/hotplugtest_2010.vcxproj.filters +0 -14
  178. package/libusb/msvc/hotplugtest_2012.vcxproj.filters +0 -14
  179. package/libusb/msvc/libusb_dll_2010.vcxproj.filters +0 -81
  180. package/libusb/msvc/libusb_dll_2012.vcxproj.filters +0 -84
  181. package/libusb/msvc/libusb_static_2010.vcxproj.filters +0 -74
  182. package/libusb/msvc/libusb_static_2012.vcxproj.filters +0 -74
  183. package/libusb/msvc/listdevs_2010.vcxproj.filters +0 -14
  184. package/libusb/msvc/listdevs_2012.vcxproj.filters +0 -14
  185. package/libusb/msvc/stress_2010.vcxproj.filters +0 -25
  186. package/libusb/msvc/stress_2012.vcxproj.filters +0 -25
  187. package/libusb/msvc/xusb_2010.vcxproj.filters +0 -14
  188. package/libusb/msvc/xusb_2012.vcxproj.filters +0 -14
@@ -3,7 +3,7 @@
3
3
  * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
4
4
  * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
5
5
  * Copyright © 2012 Pete Batard <pete@akeo.ie>
6
- * Copyright © 2012 Nathan Hjelm <hjelmn@cs.unm.edu>
6
+ * Copyright © 2012-2018 Nathan Hjelm <hjelmn@cs.unm.edu>
7
7
  * For more information, please visit: http://libusb.info
8
8
  *
9
9
  * This library is free software; you can redistribute it and/or
@@ -54,13 +54,19 @@ typedef unsigned __int32 uint32_t;
54
54
  #include <sys/types.h>
55
55
  #endif
56
56
 
57
- #if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
57
+ #if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__HAIKU__)
58
58
  #include <sys/time.h>
59
59
  #endif
60
60
 
61
61
  #include <time.h>
62
62
  #include <limits.h>
63
63
 
64
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
65
+ #define ZERO_SIZED_ARRAY /* [] - valid C99 code */
66
+ #else
67
+ #define ZERO_SIZED_ARRAY 0 /* [0] - non-standard, but usually working code */
68
+ #endif
69
+
64
70
  /* 'interface' might be defined as a macro on Windows, so we need to
65
71
  * undefine it so as not to break the current libusb API, because
66
72
  * libusb_config_descriptor has an 'interface' member
@@ -79,18 +85,20 @@ typedef unsigned __int32 uint32_t;
79
85
  #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
80
86
  #define LIBUSB_DEPRECATED_FOR(f) \
81
87
  __attribute__((deprecated("Use " #f " instead")))
88
+ #elif __GNUC__ >= 3
89
+ #define LIBUSB_DEPRECATED_FOR(f) __attribute__((deprecated))
82
90
  #else
83
91
  #define LIBUSB_DEPRECATED_FOR(f)
84
92
  #endif /* __GNUC__ */
85
93
 
86
94
  /** \def LIBUSB_CALL
87
- * \ingroup misc
95
+ * \ingroup libusb_misc
88
96
  * libusb's Windows calling convention.
89
97
  *
90
98
  * Under Windows, the selection of available compilers and configurations
91
99
  * means that, unlike other platforms, there is not <em>one true calling
92
100
  * convention</em> (calling convention: the manner in which parameters are
93
- * passed to funcions in the generated assembly code).
101
+ * passed to functions in the generated assembly code).
94
102
  *
95
103
  * Matching the Windows API itself, libusb uses the WINAPI convention (which
96
104
  * translates to the <tt>stdcall</tt> convention) and guarantees that the
@@ -122,7 +130,7 @@ typedef unsigned __int32 uint32_t;
122
130
  #endif
123
131
 
124
132
  /** \def LIBUSB_API_VERSION
125
- * \ingroup misc
133
+ * \ingroup libusb_misc
126
134
  * libusb's API version.
127
135
  *
128
136
  * Since version 1.0.13, to help with feature detection, libusb defines
@@ -138,13 +146,10 @@ typedef unsigned __int32 uint32_t;
138
146
  * #endif
139
147
  * \endcode
140
148
  *
141
- * Another feature of LIBUSB_API_VERSION is that it can be used to detect
142
- * whether you are compiling against the libusb or the libusb library.
143
- *
144
149
  * Internally, LIBUSB_API_VERSION is defined as follows:
145
150
  * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
146
151
  */
147
- #define LIBUSB_API_VERSION 0x01000103
152
+ #define LIBUSB_API_VERSION 0x01000107
148
153
 
149
154
  /* The following is kept for compatibility, but will be deprecated in the future */
150
155
  #define LIBUSBX_API_VERSION LIBUSB_API_VERSION
@@ -154,7 +159,7 @@ extern "C" {
154
159
  #endif
155
160
 
156
161
  /**
157
- * \ingroup misc
162
+ * \ingroup libusb_misc
158
163
  * Convert a 16-bit value from host-endian to little-endian format. On
159
164
  * little endian systems, this function does nothing. On big endian systems,
160
165
  * the bytes are swapped.
@@ -173,7 +178,7 @@ static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
173
178
  }
174
179
 
175
180
  /** \def libusb_le16_to_cpu
176
- * \ingroup misc
181
+ * \ingroup libusb_misc
177
182
  * Convert a 16-bit value from little-endian to host-endian format. On
178
183
  * little endian systems, this function does nothing. On big endian systems,
179
184
  * the bytes are swapped.
@@ -184,7 +189,7 @@ static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
184
189
 
185
190
  /* standard USB stuff */
186
191
 
187
- /** \ingroup desc
192
+ /** \ingroup libusb_desc
188
193
  * Device and/or Interface Class codes */
189
194
  enum libusb_class_code {
190
195
  /** In the context of a \ref libusb_device_descriptor "device descriptor",
@@ -246,7 +251,7 @@ enum libusb_class_code {
246
251
  LIBUSB_CLASS_VENDOR_SPEC = 0xff
247
252
  };
248
253
 
249
- /** \ingroup desc
254
+ /** \ingroup libusb_desc
250
255
  * Descriptor types as defined by the USB specification. */
251
256
  enum libusb_descriptor_type {
252
257
  /** Device descriptor. See libusb_device_descriptor. */
@@ -314,7 +319,7 @@ enum libusb_descriptor_type {
314
319
  #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
315
320
  #define LIBUSB_ENDPOINT_DIR_MASK 0x80
316
321
 
317
- /** \ingroup desc
322
+ /** \ingroup libusb_desc
318
323
  * Endpoint direction. Values for bit 7 of the
319
324
  * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme.
320
325
  */
@@ -328,7 +333,7 @@ enum libusb_endpoint_direction {
328
333
 
329
334
  #define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
330
335
 
331
- /** \ingroup desc
336
+ /** \ingroup libusb_desc
332
337
  * Endpoint transfer type. Values for bits 0:1 of the
333
338
  * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
334
339
  */
@@ -349,7 +354,7 @@ enum libusb_transfer_type {
349
354
  LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
350
355
  };
351
356
 
352
- /** \ingroup misc
357
+ /** \ingroup libusb_misc
353
358
  * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */
354
359
  enum libusb_standard_request {
355
360
  /** Request status of the specific recipient */
@@ -397,7 +402,7 @@ enum libusb_standard_request {
397
402
  LIBUSB_SET_ISOCH_DELAY = 0x31,
398
403
  };
399
404
 
400
- /** \ingroup misc
405
+ /** \ingroup libusb_misc
401
406
  * Request type bits of the
402
407
  * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
403
408
  * transfers. */
@@ -415,7 +420,7 @@ enum libusb_request_type {
415
420
  LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
416
421
  };
417
422
 
418
- /** \ingroup misc
423
+ /** \ingroup libusb_misc
419
424
  * Recipient bits of the
420
425
  * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
421
426
  * transfers. Values 4 through 31 are reserved. */
@@ -435,7 +440,7 @@ enum libusb_request_recipient {
435
440
 
436
441
  #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
437
442
 
438
- /** \ingroup desc
443
+ /** \ingroup libusb_desc
439
444
  * Synchronization type for isochronous endpoints. Values for bits 2:3 of the
440
445
  * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
441
446
  * libusb_endpoint_descriptor.
@@ -456,7 +461,7 @@ enum libusb_iso_sync_type {
456
461
 
457
462
  #define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
458
463
 
459
- /** \ingroup desc
464
+ /** \ingroup libusb_desc
460
465
  * Usage type for isochronous endpoints. Values for bits 4:5 of the
461
466
  * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
462
467
  * libusb_endpoint_descriptor.
@@ -472,7 +477,7 @@ enum libusb_iso_usage_type {
472
477
  LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
473
478
  };
474
479
 
475
- /** \ingroup desc
480
+ /** \ingroup libusb_desc
476
481
  * A structure representing the standard USB device descriptor. This
477
482
  * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
478
483
  * All multiple-byte fields are represented in host-endian format.
@@ -526,7 +531,7 @@ struct libusb_device_descriptor {
526
531
  uint8_t bNumConfigurations;
527
532
  };
528
533
 
529
- /** \ingroup desc
534
+ /** \ingroup libusb_desc
530
535
  * A structure representing the standard USB endpoint descriptor. This
531
536
  * descriptor is documented in section 9.6.6 of the USB 3.0 specification.
532
537
  * All multiple-byte fields are represented in host-endian format.
@@ -572,11 +577,11 @@ struct libusb_endpoint_descriptor {
572
577
  * it will store them here, should you wish to parse them. */
573
578
  const unsigned char *extra;
574
579
 
575
- /** Length of the extra descriptors, in bytes. */
580
+ /** Length of the extra descriptors, in bytes. Must be non-negative. */
576
581
  int extra_length;
577
582
  };
578
583
 
579
- /** \ingroup desc
584
+ /** \ingroup libusb_desc
580
585
  * A structure representing the standard USB interface descriptor. This
581
586
  * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
582
587
  * All multiple-byte fields are represented in host-endian format.
@@ -622,11 +627,11 @@ struct libusb_interface_descriptor {
622
627
  * it will store them here, should you wish to parse them. */
623
628
  const unsigned char *extra;
624
629
 
625
- /** Length of the extra descriptors, in bytes. */
630
+ /** Length of the extra descriptors, in bytes. Must be non-negative. */
626
631
  int extra_length;
627
632
  };
628
633
 
629
- /** \ingroup desc
634
+ /** \ingroup libusb_desc
630
635
  * A collection of alternate settings for a particular USB interface.
631
636
  */
632
637
  struct libusb_interface {
@@ -634,11 +639,12 @@ struct libusb_interface {
634
639
  * by the num_altsetting field. */
635
640
  const struct libusb_interface_descriptor *altsetting;
636
641
 
637
- /** The number of alternate settings that belong to this interface */
642
+ /** The number of alternate settings that belong to this interface.
643
+ * Must be non-negative. */
638
644
  int num_altsetting;
639
645
  };
640
646
 
641
- /** \ingroup desc
647
+ /** \ingroup libusb_desc
642
648
  * A structure representing the standard USB configuration descriptor. This
643
649
  * descriptor is documented in section 9.6.3 of the USB 3.0 specification.
644
650
  * All multiple-byte fields are represented in host-endian format.
@@ -668,8 +674,9 @@ struct libusb_config_descriptor {
668
674
  uint8_t bmAttributes;
669
675
 
670
676
  /** Maximum power consumption of the USB device from this bus in this
671
- * configuration when the device is fully opreation. Expressed in units
672
- * of 2 mA. */
677
+ * configuration when the device is fully operation. Expressed in units
678
+ * of 2 mA when the device is operating in high-speed mode and in units
679
+ * of 8 mA when the device is operating in super-speed mode. */
673
680
  uint8_t MaxPower;
674
681
 
675
682
  /** Array of interfaces supported by this configuration. The length of
@@ -680,11 +687,11 @@ struct libusb_config_descriptor {
680
687
  * descriptors, it will store them here, should you wish to parse them. */
681
688
  const unsigned char *extra;
682
689
 
683
- /** Length of the extra descriptors, in bytes. */
690
+ /** Length of the extra descriptors, in bytes. Must be non-negative. */
684
691
  int extra_length;
685
692
  };
686
693
 
687
- /** \ingroup desc
694
+ /** \ingroup libusb_desc
688
695
  * A structure representing the superspeed endpoint companion
689
696
  * descriptor. This descriptor is documented in section 9.6.7 of
690
697
  * the USB 3.0 specification. All multiple-byte fields are represented in
@@ -702,7 +709,7 @@ struct libusb_ss_endpoint_companion_descriptor {
702
709
 
703
710
 
704
711
  /** The maximum number of packets the endpoint can send or
705
- * recieve as part of a burst. */
712
+ * receive as part of a burst. */
706
713
  uint8_t bMaxBurst;
707
714
 
708
715
  /** In bulk EP: bits 4:0 represents the maximum number of
@@ -716,7 +723,7 @@ struct libusb_ss_endpoint_companion_descriptor {
716
723
  uint16_t wBytesPerInterval;
717
724
  };
718
725
 
719
- /** \ingroup desc
726
+ /** \ingroup libusb_desc
720
727
  * A generic representation of a BOS Device Capability descriptor. It is
721
728
  * advised to check bDevCapabilityType and call the matching
722
729
  * libusb_get_*_descriptor function to get a structure fully matching the type.
@@ -731,16 +738,10 @@ struct libusb_bos_dev_capability_descriptor {
731
738
  /** Device Capability type */
732
739
  uint8_t bDevCapabilityType;
733
740
  /** Device Capability data (bLength - 3 bytes) */
734
- uint8_t dev_capability_data
735
- #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
736
- [] /* valid C99 code */
737
- #else
738
- [0] /* non-standard, but usually working code */
739
- #endif
740
- ;
741
+ uint8_t dev_capability_data[ZERO_SIZED_ARRAY];
741
742
  };
742
743
 
743
- /** \ingroup desc
744
+ /** \ingroup libusb_desc
744
745
  * A structure representing the Binary Device Object Store (BOS) descriptor.
745
746
  * This descriptor is documented in section 9.6.2 of the USB 3.0 specification.
746
747
  * All multiple-byte fields are represented in host-endian format.
@@ -762,16 +763,10 @@ struct libusb_bos_descriptor {
762
763
  uint8_t bNumDeviceCaps;
763
764
 
764
765
  /** bNumDeviceCap Device Capability Descriptors */
765
- struct libusb_bos_dev_capability_descriptor *dev_capability
766
- #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
767
- [] /* valid C99 code */
768
- #else
769
- [0] /* non-standard, but usually working code */
770
- #endif
771
- ;
766
+ struct libusb_bos_dev_capability_descriptor *dev_capability[ZERO_SIZED_ARRAY];
772
767
  };
773
768
 
774
- /** \ingroup desc
769
+ /** \ingroup libusb_desc
775
770
  * A structure representing the USB 2.0 Extension descriptor
776
771
  * This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification.
777
772
  * All multiple-byte fields are represented in host-endian format.
@@ -797,7 +792,7 @@ struct libusb_usb_2_0_extension_descriptor {
797
792
  uint32_t bmAttributes;
798
793
  };
799
794
 
800
- /** \ingroup desc
795
+ /** \ingroup libusb_desc
801
796
  * A structure representing the SuperSpeed USB Device Capability descriptor
802
797
  * This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification.
803
798
  * All multiple-byte fields are represented in host-endian format.
@@ -839,7 +834,7 @@ struct libusb_ss_usb_device_capability_descriptor {
839
834
  uint16_t bU2DevExitLat;
840
835
  };
841
836
 
842
- /** \ingroup desc
837
+ /** \ingroup libusb_desc
843
838
  * A structure representing the Container ID descriptor.
844
839
  * This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification.
845
840
  * All multiple-byte fields, except UUIDs, are represented in host-endian format.
@@ -865,7 +860,7 @@ struct libusb_container_id_descriptor {
865
860
  uint8_t ContainerID[16];
866
861
  };
867
862
 
868
- /** \ingroup asyncio
863
+ /** \ingroup libusb_asyncio
869
864
  * Setup packet for control transfers. */
870
865
  struct libusb_control_setup {
871
866
  /** Request type. Bits 0:4 determine recipient, see
@@ -900,9 +895,8 @@ struct libusb_control_setup {
900
895
  struct libusb_context;
901
896
  struct libusb_device;
902
897
  struct libusb_device_handle;
903
- struct libusb_hotplug_callback;
904
898
 
905
- /** \ingroup lib
899
+ /** \ingroup libusb_lib
906
900
  * Structure providing the version of the libusb runtime
907
901
  */
908
902
  struct libusb_version {
@@ -925,12 +919,12 @@ struct libusb_version {
925
919
  const char* describe;
926
920
  };
927
921
 
928
- /** \ingroup lib
922
+ /** \ingroup libusb_lib
929
923
  * Structure representing a libusb session. The concept of individual libusb
930
924
  * sessions allows for your program to use two libraries (or dynamically
931
925
  * load two modules) which both independently use libusb. This will prevent
932
926
  * interference between the individual libusb users - for example
933
- * libusb_set_debug() will not affect the other user of the library, and
927
+ * libusb_set_option() will not affect the other user of the library, and
934
928
  * libusb_exit() will not destroy resources that the other user is still
935
929
  * using.
936
930
  *
@@ -940,11 +934,11 @@ struct libusb_version {
940
934
  * every function call where a context is required. The default context
941
935
  * will be used.
942
936
  *
943
- * For more information, see \ref contexts.
937
+ * For more information, see \ref libusb_contexts.
944
938
  */
945
939
  typedef struct libusb_context libusb_context;
946
940
 
947
- /** \ingroup dev
941
+ /** \ingroup libusb_dev
948
942
  * Structure representing a USB device detected on the system. This is an
949
943
  * opaque type for which you are only ever provided with a pointer, usually
950
944
  * originating from libusb_get_device_list().
@@ -962,7 +956,7 @@ typedef struct libusb_context libusb_context;
962
956
  typedef struct libusb_device libusb_device;
963
957
 
964
958
 
965
- /** \ingroup dev
959
+ /** \ingroup libusb_dev
966
960
  * Structure representing a handle on a USB device. This is an opaque type for
967
961
  * which you are only ever provided with a pointer, usually originating from
968
962
  * libusb_open().
@@ -972,7 +966,7 @@ typedef struct libusb_device libusb_device;
972
966
  */
973
967
  typedef struct libusb_device_handle libusb_device_handle;
974
968
 
975
- /** \ingroup dev
969
+ /** \ingroup libusb_dev
976
970
  * Speed codes. Indicates the speed at which the device is operating.
977
971
  */
978
972
  enum libusb_speed {
@@ -990,9 +984,12 @@ enum libusb_speed {
990
984
 
991
985
  /** The device is operating at super speed (5000MBit/s). */
992
986
  LIBUSB_SPEED_SUPER = 4,
987
+
988
+ /** The device is operating at super speed plus (10000MBit/s). */
989
+ LIBUSB_SPEED_SUPER_PLUS = 5,
993
990
  };
994
991
 
995
- /** \ingroup dev
992
+ /** \ingroup libusb_dev
996
993
  * Supported speeds (wSpeedSupported) bitfield. Indicates what
997
994
  * speeds the device supports.
998
995
  */
@@ -1010,7 +1007,7 @@ enum libusb_supported_speed {
1010
1007
  LIBUSB_SUPER_SPEED_OPERATION = 8,
1011
1008
  };
1012
1009
 
1013
- /** \ingroup dev
1010
+ /** \ingroup libusb_dev
1014
1011
  * Masks for the bits of the
1015
1012
  * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
1016
1013
  * of the USB 2.0 Extension descriptor.
@@ -1020,7 +1017,7 @@ enum libusb_usb_2_0_extension_attributes {
1020
1017
  LIBUSB_BM_LPM_SUPPORT = 2,
1021
1018
  };
1022
1019
 
1023
- /** \ingroup dev
1020
+ /** \ingroup libusb_dev
1024
1021
  * Masks for the bits of the
1025
1022
  * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
1026
1023
  * field of the SuperSpeed USB Device Capability descriptor.
@@ -1030,7 +1027,7 @@ enum libusb_ss_usb_device_capability_attributes {
1030
1027
  LIBUSB_BM_LTM_SUPPORT = 2,
1031
1028
  };
1032
1029
 
1033
- /** \ingroup dev
1030
+ /** \ingroup libusb_dev
1034
1031
  * USB capability types
1035
1032
  */
1036
1033
  enum libusb_bos_type {
@@ -1047,7 +1044,7 @@ enum libusb_bos_type {
1047
1044
  LIBUSB_BT_CONTAINER_ID = 4,
1048
1045
  };
1049
1046
 
1050
- /** \ingroup misc
1047
+ /** \ingroup libusb_misc
1051
1048
  * Error codes. Most libusb functions return 0 on success or one of these
1052
1049
  * codes on failure.
1053
1050
  * You can call libusb_error_name() to retrieve a string representation of an
@@ -1104,7 +1101,7 @@ enum libusb_error {
1104
1101
  /* Total number of error codes in enum libusb_error */
1105
1102
  #define LIBUSB_ERROR_COUNT 14
1106
1103
 
1107
- /** \ingroup asyncio
1104
+ /** \ingroup libusb_asyncio
1108
1105
  * Transfer status codes */
1109
1106
  enum libusb_transfer_status {
1110
1107
  /** Transfer completed without error. Note that this does not indicate
@@ -1134,20 +1131,23 @@ enum libusb_transfer_status {
1134
1131
  when adding new status codes here. */
1135
1132
  };
1136
1133
 
1137
- /** \ingroup asyncio
1134
+ /** \ingroup libusb_asyncio
1138
1135
  * libusb_transfer.flags values */
1139
1136
  enum libusb_transfer_flags {
1140
1137
  /** Report short frames as errors */
1141
- LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0,
1138
+ LIBUSB_TRANSFER_SHORT_NOT_OK = 1U << 0,
1142
1139
 
1143
- /** Automatically free() transfer buffer during libusb_free_transfer() */
1144
- LIBUSB_TRANSFER_FREE_BUFFER = 1<<1,
1140
+ /** Automatically free() transfer buffer during libusb_free_transfer().
1141
+ * Note that buffers allocated with libusb_dev_mem_alloc() should not
1142
+ * be attempted freed in this way, since free() is not an appropriate
1143
+ * way to release such memory. */
1144
+ LIBUSB_TRANSFER_FREE_BUFFER = 1U << 1,
1145
1145
 
1146
1146
  /** Automatically call libusb_free_transfer() after callback returns.
1147
1147
  * If this flag is set, it is illegal to call libusb_free_transfer()
1148
1148
  * from your transfer callback, as this will result in a double-free
1149
1149
  * when this flag is acted upon. */
1150
- LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2,
1150
+ LIBUSB_TRANSFER_FREE_TRANSFER = 1U << 2,
1151
1151
 
1152
1152
  /** Terminate transfers that are a multiple of the endpoint's
1153
1153
  * wMaxPacketSize with an extra zero length packet. This is useful
@@ -1172,10 +1172,10 @@ enum libusb_transfer_flags {
1172
1172
  *
1173
1173
  * Available since libusb-1.0.9.
1174
1174
  */
1175
- LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 << 3,
1175
+ LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1U << 3,
1176
1176
  };
1177
1177
 
1178
- /** \ingroup asyncio
1178
+ /** \ingroup libusb_asyncio
1179
1179
  * Isochronous packet descriptor. */
1180
1180
  struct libusb_iso_packet_descriptor {
1181
1181
  /** Length of data to request in this packet */
@@ -1190,18 +1190,18 @@ struct libusb_iso_packet_descriptor {
1190
1190
 
1191
1191
  struct libusb_transfer;
1192
1192
 
1193
- /** \ingroup asyncio
1193
+ /** \ingroup libusb_asyncio
1194
1194
  * Asynchronous transfer callback function type. When submitting asynchronous
1195
1195
  * transfers, you pass a pointer to a callback function of this type via the
1196
1196
  * \ref libusb_transfer::callback "callback" member of the libusb_transfer
1197
1197
  * structure. libusb will call this function later, when the transfer has
1198
- * completed or failed. See \ref asyncio for more information.
1198
+ * completed or failed. See \ref libusb_asyncio for more information.
1199
1199
  * \param transfer The libusb_transfer struct the callback function is being
1200
1200
  * notified about.
1201
1201
  */
1202
1202
  typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
1203
1203
 
1204
- /** \ingroup asyncio
1204
+ /** \ingroup libusb_asyncio
1205
1205
  * The generic USB transfer structure. The user populates this structure and
1206
1206
  * then submits it in order to request a transfer. After the transfer has
1207
1207
  * completed, the library populates the transfer with the results and passes
@@ -1220,7 +1220,7 @@ struct libusb_transfer {
1220
1220
  /** Type of the endpoint from \ref libusb_transfer_type */
1221
1221
  unsigned char type;
1222
1222
 
1223
- /** Timeout for this transfer in millseconds. A value of 0 indicates no
1223
+ /** Timeout for this transfer in milliseconds. A value of 0 indicates no
1224
1224
  * timeout. */
1225
1225
  unsigned int timeout;
1226
1226
 
@@ -1233,7 +1233,7 @@ struct libusb_transfer {
1233
1233
  * to determine if errors occurred. */
1234
1234
  enum libusb_transfer_status status;
1235
1235
 
1236
- /** Length of the data buffer */
1236
+ /** Length of the data buffer. Must be non-negative. */
1237
1237
  int length;
1238
1238
 
1239
1239
  /** Actual length of data that was transferred. Read-only, and only for
@@ -1252,20 +1252,14 @@ struct libusb_transfer {
1252
1252
  unsigned char *buffer;
1253
1253
 
1254
1254
  /** Number of isochronous packets. Only used for I/O with isochronous
1255
- * endpoints. */
1255
+ * endpoints. Must be non-negative. */
1256
1256
  int num_iso_packets;
1257
1257
 
1258
1258
  /** Isochronous packet descriptors, for isochronous transfers only. */
1259
- struct libusb_iso_packet_descriptor iso_packet_desc
1260
- #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1261
- [] /* valid C99 code */
1262
- #else
1263
- [0] /* non-standard, but usually working code */
1264
- #endif
1265
- ;
1259
+ struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY];
1266
1260
  };
1267
1261
 
1268
- /** \ingroup misc
1262
+ /** \ingroup libusb_misc
1269
1263
  * Capabilities supported by an instance of libusb on the current running
1270
1264
  * platform. Test if the loaded library supports a given capability by calling
1271
1265
  * \ref libusb_has_capability().
@@ -1285,27 +1279,51 @@ enum libusb_capability {
1285
1279
  LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
1286
1280
  };
1287
1281
 
1288
- /** \ingroup lib
1282
+ /** \ingroup libusb_lib
1289
1283
  * Log message levels.
1290
1284
  * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
1291
1285
  * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
1292
1286
  * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
1293
- * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
1294
- * and error messages are printed to stderr
1295
- * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
1296
- * warnings and errors to stderr
1287
+ * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stderr
1288
+ * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stderr
1297
1289
  */
1298
1290
  enum libusb_log_level {
1299
1291
  LIBUSB_LOG_LEVEL_NONE = 0,
1300
- LIBUSB_LOG_LEVEL_ERROR,
1301
- LIBUSB_LOG_LEVEL_WARNING,
1302
- LIBUSB_LOG_LEVEL_INFO,
1303
- LIBUSB_LOG_LEVEL_DEBUG,
1292
+ LIBUSB_LOG_LEVEL_ERROR = 1,
1293
+ LIBUSB_LOG_LEVEL_WARNING = 2,
1294
+ LIBUSB_LOG_LEVEL_INFO = 3,
1295
+ LIBUSB_LOG_LEVEL_DEBUG = 4,
1296
+ };
1297
+
1298
+ /** \ingroup libusb_lib
1299
+ * Log callback mode.
1300
+ * \see libusb_set_log_cb()
1301
+ */
1302
+ enum libusb_log_cb_mode {
1303
+
1304
+ /** Callback function handling all log mesages. */
1305
+ LIBUSB_LOG_CB_GLOBAL = 1 << 0,
1306
+
1307
+ /** Callback function handling context related log mesages. */
1308
+ LIBUSB_LOG_CB_CONTEXT = 1 << 1
1304
1309
  };
1305
1310
 
1311
+ /** \ingroup libusb_lib
1312
+ * Callback function for handling log messages.
1313
+ * \param ctx the context which is related to the log message, or NULL if it
1314
+ * is a global log message
1315
+ * \param level the log level, see \ref libusb_log_level for a description
1316
+ * \param str the log message
1317
+ * \see libusb_set_log_cb()
1318
+ */
1319
+ typedef void (LIBUSB_CALL *libusb_log_cb)(libusb_context *ctx,
1320
+ enum libusb_log_level level, const char *str);
1321
+
1306
1322
  int LIBUSB_CALL libusb_init(libusb_context **ctx);
1307
1323
  void LIBUSB_CALL libusb_exit(libusb_context *ctx);
1324
+ LIBUSB_DEPRECATED_FOR(libusb_set_option)
1308
1325
  void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
1326
+ void LIBUSB_CALL libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode);
1309
1327
  const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
1310
1328
  int LIBUSB_CALL libusb_has_capability(uint32_t capability);
1311
1329
  const char * LIBUSB_CALL libusb_error_name(int errcode);
@@ -1337,7 +1355,7 @@ int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
1337
1355
  struct libusb_ss_endpoint_companion_descriptor **ep_comp);
1338
1356
  void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
1339
1357
  struct libusb_ss_endpoint_companion_descriptor *ep_comp);
1340
- int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *handle,
1358
+ int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
1341
1359
  struct libusb_bos_descriptor **bos);
1342
1360
  void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
1343
1361
  int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
@@ -1370,43 +1388,49 @@ int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
1370
1388
  int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
1371
1389
  unsigned char endpoint);
1372
1390
 
1373
- int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **handle);
1391
+ int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
1392
+ int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle);
1374
1393
  void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
1375
1394
  libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
1376
1395
 
1377
- int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev,
1396
+ int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev_handle,
1378
1397
  int configuration);
1379
- int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev,
1398
+ int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev_handle,
1380
1399
  int interface_number);
1381
- int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev,
1400
+ int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev_handle,
1382
1401
  int interface_number);
1383
1402
 
1384
1403
  libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
1385
1404
  libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
1386
1405
 
1387
- int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev,
1406
+ int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev_handle,
1388
1407
  int interface_number, int alternate_setting);
1389
- int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
1408
+ int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev_handle,
1390
1409
  unsigned char endpoint);
1391
- int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);
1410
+ int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev_handle);
1392
1411
 
1393
- int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev,
1412
+ int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev_handle,
1394
1413
  uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
1395
- int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev,
1414
+ int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev_handle,
1396
1415
  unsigned char *endpoints, int num_endpoints);
1397
1416
 
1398
- int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
1417
+ unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handle,
1418
+ size_t length);
1419
+ int LIBUSB_CALL libusb_dev_mem_free(libusb_device_handle *dev_handle,
1420
+ unsigned char *buffer, size_t length);
1421
+
1422
+ int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev_handle,
1399
1423
  int interface_number);
1400
- int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
1424
+ int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
1401
1425
  int interface_number);
1402
- int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev,
1426
+ int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev_handle,
1403
1427
  int interface_number);
1404
1428
  int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
1405
- libusb_device_handle *dev, int enable);
1429
+ libusb_device_handle *dev_handle, int enable);
1406
1430
 
1407
1431
  /* async I/O */
1408
1432
 
1409
- /** \ingroup asyncio
1433
+ /** \ingroup libusb_asyncio
1410
1434
  * Get the data section of a control transfer. This convenience function is here
1411
1435
  * to remind you that the data does not start until 8 bytes into the actual
1412
1436
  * buffer, as the setup packet comes first.
@@ -1424,7 +1448,7 @@ static inline unsigned char *libusb_control_transfer_get_data(
1424
1448
  return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
1425
1449
  }
1426
1450
 
1427
- /** \ingroup asyncio
1451
+ /** \ingroup libusb_asyncio
1428
1452
  * Get the control setup packet of a control transfer. This convenience
1429
1453
  * function is here to remind you that the control setup occupies the first
1430
1454
  * 8 bytes of the transfer data buffer.
@@ -1442,7 +1466,7 @@ static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
1442
1466
  return (struct libusb_control_setup *)(void *) transfer->buffer;
1443
1467
  }
1444
1468
 
1445
- /** \ingroup asyncio
1469
+ /** \ingroup libusb_asyncio
1446
1470
  * Helper function to populate the setup packet (first 8 bytes of the data
1447
1471
  * buffer) for a control transfer. The wIndex, wValue and wLength values should
1448
1472
  * be given in host-endian byte order.
@@ -1486,7 +1510,7 @@ void LIBUSB_CALL libusb_transfer_set_stream_id(
1486
1510
  uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
1487
1511
  struct libusb_transfer *transfer);
1488
1512
 
1489
- /** \ingroup asyncio
1513
+ /** \ingroup libusb_asyncio
1490
1514
  * Helper function to populate the required \ref libusb_transfer fields
1491
1515
  * for a control transfer.
1492
1516
  *
@@ -1532,7 +1556,7 @@ static inline void libusb_fill_control_transfer(
1532
1556
  transfer->callback = callback;
1533
1557
  }
1534
1558
 
1535
- /** \ingroup asyncio
1559
+ /** \ingroup libusb_asyncio
1536
1560
  * Helper function to populate the required \ref libusb_transfer fields
1537
1561
  * for a bulk transfer.
1538
1562
  *
@@ -1560,7 +1584,7 @@ static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
1560
1584
  transfer->callback = callback;
1561
1585
  }
1562
1586
 
1563
- /** \ingroup asyncio
1587
+ /** \ingroup libusb_asyncio
1564
1588
  * Helper function to populate the required \ref libusb_transfer fields
1565
1589
  * for a bulk transfer using bulk streams.
1566
1590
  *
@@ -1588,7 +1612,7 @@ static inline void libusb_fill_bulk_stream_transfer(
1588
1612
  libusb_transfer_set_stream_id(transfer, stream_id);
1589
1613
  }
1590
1614
 
1591
- /** \ingroup asyncio
1615
+ /** \ingroup libusb_asyncio
1592
1616
  * Helper function to populate the required \ref libusb_transfer fields
1593
1617
  * for an interrupt transfer.
1594
1618
  *
@@ -1616,7 +1640,7 @@ static inline void libusb_fill_interrupt_transfer(
1616
1640
  transfer->callback = callback;
1617
1641
  }
1618
1642
 
1619
- /** \ingroup asyncio
1643
+ /** \ingroup libusb_asyncio
1620
1644
  * Helper function to populate the required \ref libusb_transfer fields
1621
1645
  * for an isochronous transfer.
1622
1646
  *
@@ -1646,7 +1670,7 @@ static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
1646
1670
  transfer->callback = callback;
1647
1671
  }
1648
1672
 
1649
- /** \ingroup asyncio
1673
+ /** \ingroup libusb_asyncio
1650
1674
  * Convenience function to set the length of all packets in an isochronous
1651
1675
  * transfer, based on the num_iso_packets field in the transfer structure.
1652
1676
  *
@@ -1662,7 +1686,7 @@ static inline void libusb_set_iso_packet_lengths(
1662
1686
  transfer->iso_packet_desc[i].length = length;
1663
1687
  }
1664
1688
 
1665
- /** \ingroup asyncio
1689
+ /** \ingroup libusb_asyncio
1666
1690
  * Convenience function to locate the position of an isochronous packet
1667
1691
  * within the buffer of an isochronous transfer.
1668
1692
  *
@@ -1701,7 +1725,7 @@ static inline unsigned char *libusb_get_iso_packet_buffer(
1701
1725
  return transfer->buffer + offset;
1702
1726
  }
1703
1727
 
1704
- /** \ingroup asyncio
1728
+ /** \ingroup libusb_asyncio
1705
1729
  * Convenience function to locate the position of an isochronous packet
1706
1730
  * within the buffer of an isochronous transfer, for transfers where each
1707
1731
  * packet is of identical size.
@@ -1752,33 +1776,33 @@ int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
1752
1776
  unsigned char endpoint, unsigned char *data, int length,
1753
1777
  int *actual_length, unsigned int timeout);
1754
1778
 
1755
- /** \ingroup desc
1779
+ /** \ingroup libusb_desc
1756
1780
  * Retrieve a descriptor from the default control pipe.
1757
1781
  * This is a convenience function which formulates the appropriate control
1758
1782
  * message to retrieve the descriptor.
1759
1783
  *
1760
- * \param dev a device handle
1784
+ * \param dev_handle a device handle
1761
1785
  * \param desc_type the descriptor type, see \ref libusb_descriptor_type
1762
1786
  * \param desc_index the index of the descriptor to retrieve
1763
1787
  * \param data output buffer for descriptor
1764
1788
  * \param length size of data buffer
1765
1789
  * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
1766
1790
  */
1767
- static inline int libusb_get_descriptor(libusb_device_handle *dev,
1791
+ static inline int libusb_get_descriptor(libusb_device_handle *dev_handle,
1768
1792
  uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
1769
1793
  {
1770
- return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
1794
+ return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
1771
1795
  LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
1772
1796
  0, data, (uint16_t) length, 1000);
1773
1797
  }
1774
1798
 
1775
- /** \ingroup desc
1799
+ /** \ingroup libusb_desc
1776
1800
  * Retrieve a descriptor from a device.
1777
1801
  * This is a convenience function which formulates the appropriate control
1778
1802
  * message to retrieve the descriptor. The string returned is Unicode, as
1779
1803
  * detailed in the USB specifications.
1780
1804
  *
1781
- * \param dev a device handle
1805
+ * \param dev_handle a device handle
1782
1806
  * \param desc_index the index of the descriptor to retrieve
1783
1807
  * \param langid the language ID for the string descriptor
1784
1808
  * \param data output buffer for descriptor
@@ -1786,15 +1810,15 @@ static inline int libusb_get_descriptor(libusb_device_handle *dev,
1786
1810
  * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
1787
1811
  * \see libusb_get_string_descriptor_ascii()
1788
1812
  */
1789
- static inline int libusb_get_string_descriptor(libusb_device_handle *dev,
1813
+ static inline int libusb_get_string_descriptor(libusb_device_handle *dev_handle,
1790
1814
  uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
1791
1815
  {
1792
- return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
1816
+ return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
1793
1817
  LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
1794
1818
  langid, data, (uint16_t) length, 1000);
1795
1819
  }
1796
1820
 
1797
- int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
1821
+ int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
1798
1822
  uint8_t desc_index, unsigned char *data, int length);
1799
1823
 
1800
1824
  /* polling and timeouts */
@@ -1804,6 +1828,7 @@ void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
1804
1828
  void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
1805
1829
  int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
1806
1830
  int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
1831
+ void LIBUSB_CALL libusb_interrupt_event_handler(libusb_context *ctx);
1807
1832
  void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
1808
1833
  void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
1809
1834
  int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
@@ -1820,7 +1845,7 @@ int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
1820
1845
  int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
1821
1846
  struct timeval *tv);
1822
1847
 
1823
- /** \ingroup poll
1848
+ /** \ingroup libusb_poll
1824
1849
  * File descriptor for polling
1825
1850
  */
1826
1851
  struct libusb_pollfd {
@@ -1834,7 +1859,7 @@ struct libusb_pollfd {
1834
1859
  short events;
1835
1860
  };
1836
1861
 
1837
- /** \ingroup poll
1862
+ /** \ingroup libusb_poll
1838
1863
  * Callback function, invoked when a new file descriptor should be added
1839
1864
  * to the set of file descriptors monitored for events.
1840
1865
  * \param fd the new file descriptor
@@ -1847,7 +1872,7 @@ struct libusb_pollfd {
1847
1872
  typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
1848
1873
  void *user_data);
1849
1874
 
1850
- /** \ingroup poll
1875
+ /** \ingroup libusb_poll
1851
1876
  * Callback function, invoked when a file descriptor should be removed from
1852
1877
  * the set of file descriptors being monitored for events. After returning
1853
1878
  * from this callback, do not use that file descriptor again.
@@ -1860,11 +1885,12 @@ typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
1860
1885
 
1861
1886
  const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
1862
1887
  libusb_context *ctx);
1888
+ void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
1863
1889
  void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
1864
1890
  libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
1865
1891
  void *user_data);
1866
1892
 
1867
- /** \ingroup hotplug
1893
+ /** \ingroup libusb_hotplug
1868
1894
  * Callback handle.
1869
1895
  *
1870
1896
  * Callbacks handles are generated by libusb_hotplug_register_callback()
@@ -1874,40 +1900,43 @@ void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
1874
1900
  *
1875
1901
  * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1876
1902
  *
1877
- * For more information, see \ref hotplug.
1903
+ * For more information, see \ref libusb_hotplug.
1878
1904
  */
1879
1905
  typedef int libusb_hotplug_callback_handle;
1880
1906
 
1881
- /** \ingroup hotplug
1907
+ /** \ingroup libusb_hotplug
1882
1908
  *
1883
1909
  * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1884
1910
  *
1885
1911
  * Flags for hotplug events */
1886
1912
  typedef enum {
1913
+ /** Default value when not using any flags. */
1914
+ LIBUSB_HOTPLUG_NO_FLAGS = 0U,
1915
+
1887
1916
  /** Arm the callback and fire it for all matching currently attached devices. */
1888
- LIBUSB_HOTPLUG_ENUMERATE = 1,
1917
+ LIBUSB_HOTPLUG_ENUMERATE = 1U << 0,
1889
1918
  } libusb_hotplug_flag;
1890
1919
 
1891
- /** \ingroup hotplug
1920
+ /** \ingroup libusb_hotplug
1892
1921
  *
1893
1922
  * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1894
1923
  *
1895
1924
  * Hotplug events */
1896
1925
  typedef enum {
1897
1926
  /** A device has been plugged in and is ready to use */
1898
- LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01,
1927
+ LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01U,
1899
1928
 
1900
1929
  /** A device has left and is no longer available.
1901
1930
  * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
1902
1931
  * It is safe to call libusb_get_device_descriptor on a device that has left */
1903
- LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02,
1932
+ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02U,
1904
1933
  } libusb_hotplug_event;
1905
1934
 
1906
- /** \ingroup hotplug
1935
+ /** \ingroup libusb_hotplug
1907
1936
  * Wildcard matching for hotplug events */
1908
1937
  #define LIBUSB_HOTPLUG_MATCH_ANY -1
1909
1938
 
1910
- /** \ingroup hotplug
1939
+ /** \ingroup libusb_hotplug
1911
1940
  * Hotplug callback function type. When requesting hotplug event notifications,
1912
1941
  * you pass a pointer to a callback function of this type.
1913
1942
  *
@@ -1915,7 +1944,7 @@ typedef enum {
1915
1944
  * recommended the callback do minimal processing before returning.
1916
1945
  *
1917
1946
  * libusb will call this function later, when a matching event had happened on
1918
- * a matching device. See \ref hotplug for more information.
1947
+ * a matching device. See \ref libusb_hotplug for more information.
1919
1948
  *
1920
1949
  * It is safe to call either libusb_hotplug_register_callback() or
1921
1950
  * libusb_hotplug_deregister_callback() from within a callback function.
@@ -1934,7 +1963,7 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
1934
1963
  libusb_hotplug_event event,
1935
1964
  void *user_data);
1936
1965
 
1937
- /** \ingroup hotplug
1966
+ /** \ingroup libusb_hotplug
1938
1967
  * Register a hotplug callback function
1939
1968
  *
1940
1969
  * Register a callback with the libusb_context. The callback will fire
@@ -1965,7 +1994,7 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
1965
1994
  * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
1966
1995
  * \param[in] cb_fn the function to be invoked on a matching event/device
1967
1996
  * \param[in] user_data user data to pass to the callback function
1968
- * \param[out] handle pointer to store the handle of the allocated callback (can be NULL)
1997
+ * \param[out] callback_handle pointer to store the handle of the allocated callback (can be NULL)
1969
1998
  * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
1970
1999
  */
1971
2000
  int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
@@ -1975,9 +2004,9 @@ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
1975
2004
  int dev_class,
1976
2005
  libusb_hotplug_callback_fn cb_fn,
1977
2006
  void *user_data,
1978
- libusb_hotplug_callback_handle *handle);
2007
+ libusb_hotplug_callback_handle *callback_handle);
1979
2008
 
1980
- /** \ingroup hotplug
2009
+ /** \ingroup libusb_hotplug
1981
2010
  * Deregisters a hotplug callback.
1982
2011
  *
1983
2012
  * Deregister a callback from a libusb_context. This function is safe to call from within
@@ -1986,10 +2015,49 @@ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
1986
2015
  * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1987
2016
  *
1988
2017
  * \param[in] ctx context this callback is registered with
1989
- * \param[in] handle the handle of the callback to deregister
2018
+ * \param[in] callback_handle the handle of the callback to deregister
1990
2019
  */
1991
2020
  void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
1992
- libusb_hotplug_callback_handle handle);
2021
+ libusb_hotplug_callback_handle callback_handle);
2022
+
2023
+ /** \ingroup libusb_lib
2024
+ * Available option values for libusb_set_option().
2025
+ */
2026
+ enum libusb_option {
2027
+ /** Set the log message verbosity.
2028
+ *
2029
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
2030
+ * printed. If you choose to increase the message verbosity level, ensure
2031
+ * that your application does not close the stderr file descriptor.
2032
+ *
2033
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
2034
+ * with its message logging and most of the time, will only log messages that
2035
+ * explain error conditions and other oddities. This will help you debug
2036
+ * your software.
2037
+ *
2038
+ * If the LIBUSB_DEBUG environment variable was set when libusb was
2039
+ * initialized, this function does nothing: the message verbosity is fixed
2040
+ * to the value in the environment variable.
2041
+ *
2042
+ * If libusb was compiled without any message logging, this function does
2043
+ * nothing: you'll never get any messages.
2044
+ *
2045
+ * If libusb was compiled with verbose debug message logging, this function
2046
+ * does nothing: you'll always get messages from all levels.
2047
+ */
2048
+ LIBUSB_OPTION_LOG_LEVEL,
2049
+
2050
+ /** Use the UsbDk backend for a specific context, if available.
2051
+ *
2052
+ * This option should be set immediately after calling libusb_init(), otherwise
2053
+ * unspecified behavior may occur.
2054
+ *
2055
+ * Only valid on Windows.
2056
+ */
2057
+ LIBUSB_OPTION_USE_USBDK,
2058
+ };
2059
+
2060
+ int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
1993
2061
 
1994
2062
  #ifdef __cplusplus
1995
2063
  }