libusb 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.travis.yml +2 -2
  2. data/Gemfile +0 -8
  3. data/History.md +5 -0
  4. data/README.md +6 -6
  5. data/Rakefile +9 -9
  6. data/ext/extconf.rb +1 -1
  7. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/AUTHORS +10 -0
  8. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/COPYING +0 -0
  9. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/ChangeLog +17 -9
  10. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/INSTALL +0 -0
  11. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Makefile.am +0 -0
  12. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Makefile.in +153 -178
  13. data/ext/libusb-1.0.18/NEWS +2 -0
  14. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/PORTING +13 -13
  15. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/README +9 -11
  16. data/ext/libusb-1.0.18/TODO +2 -0
  17. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/common.xcconfig +3 -3
  18. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/config.h +0 -0
  19. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/debug.xcconfig +2 -2
  20. data/ext/{libusbx-1.0.17/Xcode/libusbx.xcconfig → libusb-1.0.18/Xcode/libusb.xcconfig} +2 -2
  21. data/ext/libusb-1.0.18/Xcode/libusb.xcodeproj/project.pbxproj +1 -0
  22. data/ext/{libusbx-1.0.17/Xcode/libusbx_debug.xcconfig → libusb-1.0.18/Xcode/libusb_debug.xcconfig} +3 -3
  23. data/ext/{libusbx-1.0.17/Xcode/libusbx_release.xcconfig → libusb-1.0.18/Xcode/libusb_release.xcconfig} +3 -3
  24. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/release.xcconfig +2 -2
  25. data/ext/{libusbx-1.0.17/m4/libtool.m4 → libusb-1.0.18/aclocal.m4} +1731 -27
  26. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/README +0 -0
  27. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/config.h +1 -10
  28. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/Android.mk +0 -0
  29. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/Application.mk +6 -1
  30. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/examples.mk +0 -0
  31. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/libusb.mk +0 -0
  32. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/tests.mk +0 -0
  33. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/compile +3 -7
  34. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/config.guess +19 -24
  35. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/config.h.in +0 -0
  36. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/config.sub +30 -47
  37. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/configure +118 -172
  38. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/configure.ac +24 -2
  39. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/depcomp +186 -268
  40. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/doc/Makefile.am +1 -1
  41. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/doc/Makefile.in +36 -73
  42. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/doc/doxygen.cfg.in +1 -1
  43. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/Makefile.am +0 -0
  44. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/Makefile.in +68 -132
  45. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/dpfp.c +1 -1
  46. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/dpfp_threaded.c +1 -1
  47. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/ezusb.c +57 -26
  48. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/ezusb.h +0 -0
  49. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/fxload.c +3 -3
  50. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/getopt/getopt.c +0 -0
  51. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/getopt/getopt.h +0 -0
  52. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/getopt/getopt1.c +0 -0
  53. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/hotplugtest.c +9 -2
  54. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/listdevs.c +1 -1
  55. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/sam3u_benchmark.c +0 -0
  56. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/xusb.c +20 -4
  57. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/install-sh +7 -7
  58. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb-1.0.pc.in +1 -1
  59. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/Makefile.am +1 -1
  60. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/Makefile.in +94 -134
  61. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/core.c +95 -74
  62. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/descriptor.c +2 -2
  63. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/hotplug.c +3 -3
  64. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/hotplug.h +1 -1
  65. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/io.c +127 -116
  66. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusb-1.0.def +0 -0
  67. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusb-1.0.rc +1 -1
  68. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusb.h +42 -39
  69. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusbi.h +20 -11
  70. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/darwin_usb.c +20 -16
  71. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/darwin_usb.h +1 -1
  72. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_netlink.c +0 -0
  73. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_udev.c +0 -0
  74. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_usbfs.c +15 -12
  75. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_usbfs.h +0 -0
  76. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/netbsd_usb.c +2 -4
  77. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/openbsd_usb.c +5 -2
  78. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_posix.c +0 -0
  79. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_posix.h +0 -0
  80. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_windows.c +2 -2
  81. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_windows.h +0 -0
  82. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_posix.c +1 -1
  83. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_posix.h +1 -1
  84. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_windows.c +1 -1
  85. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_windows.h +1 -1
  86. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/wince_usb.c +1 -2
  87. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/wince_usb.h +2 -2
  88. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/windows_common.h +1 -1
  89. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/windows_usb.c +53 -33
  90. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/windows_usb.h +6 -1
  91. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/strerror.c +2 -2
  92. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/sync.c +6 -6
  93. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/version.h +1 -1
  94. data/ext/libusb-1.0.18/libusb/version_nano.h +1 -0
  95. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/ltmain.sh +3 -3
  96. data/ext/libusb-1.0.18/missing +331 -0
  97. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/Makefile.am +1 -1
  98. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/Makefile.in +69 -127
  99. data/ext/{libusbx-1.0.17/tests/libusbx_testlib.h → libusb-1.0.18/tests/libusb_testlib.h} +15 -15
  100. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/stress.c +16 -16
  101. data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/testlib.c +21 -20
  102. data/lib/libusb/version_gem.rb +1 -1
  103. data/libusb.gemspec +1 -6
  104. metadata +117 -135
  105. checksums.yaml +0 -7
  106. checksums.yaml.gz.sig +0 -0
  107. data.tar.gz.sig +0 -0
  108. data/ext/libusbx-1.0.17/NEWS +0 -2
  109. data/ext/libusbx-1.0.17/TODO +0 -2
  110. data/ext/libusbx-1.0.17/Xcode/libusbx.xcodeproj/project.pbxproj +0 -864
  111. data/ext/libusbx-1.0.17/aclocal.m4 +0 -1112
  112. data/ext/libusbx-1.0.17/libusb/version_nano.h +0 -1
  113. data/ext/libusbx-1.0.17/m4/ltoptions.m4 +0 -384
  114. data/ext/libusbx-1.0.17/m4/ltsugar.m4 +0 -123
  115. data/ext/libusbx-1.0.17/m4/ltversion.m4 +0 -23
  116. data/ext/libusbx-1.0.17/m4/lt~obsolete.m4 +0 -98
  117. data/ext/libusbx-1.0.17/missing +0 -215
  118. metadata.gz.sig +0 -0
@@ -41,7 +41,7 @@ BEGIN
41
41
  BEGIN
42
42
  BLOCK "040904b0"
43
43
  BEGIN
44
- VALUE "CompanyName", "libusbx.org\0"
44
+ VALUE "CompanyName", "libusb.info\0"
45
45
  VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0"
46
46
  VALUE "FileVersion", LIBUSB_VERSIONSTRING
47
47
  VALUE "InternalName", "libusb\0"
@@ -1,10 +1,10 @@
1
1
  /*
2
- * Public libusbx header file
2
+ * Public libusb header file
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
6
  * Copyright © 2012 Nathan Hjelm <hjelmn@cs.unm.edu>
7
- * For more information, please visit: http://libusbx.org
7
+ * For more information, please visit: http://libusb.info
8
8
  *
9
9
  * This library is free software; you can redistribute it and/or
10
10
  * modify it under the terms of the GNU Lesser General Public
@@ -62,7 +62,7 @@ typedef unsigned __int32 uint32_t;
62
62
  #include <limits.h>
63
63
 
64
64
  /* 'interface' might be defined as a macro on Windows, so we need to
65
- * undefine it so as not to break the current libusbx API, because
65
+ * undefine it so as not to break the current libusb API, because
66
66
  * libusb_config_descriptor has an 'interface' member
67
67
  * As this can be problematic if you include windows.h after libusb.h
68
68
  * in your sources, we force windows.h to be included first. */
@@ -85,14 +85,14 @@ typedef unsigned __int32 uint32_t;
85
85
 
86
86
  /** \def LIBUSB_CALL
87
87
  * \ingroup misc
88
- * libusbx's Windows calling convention.
88
+ * libusb's Windows calling convention.
89
89
  *
90
90
  * Under Windows, the selection of available compilers and configurations
91
91
  * means that, unlike other platforms, there is not <em>one true calling
92
92
  * convention</em> (calling convention: the manner in which parameters are
93
93
  * passed to funcions in the generated assembly code).
94
94
  *
95
- * Matching the Windows API itself, libusbx uses the WINAPI convention (which
95
+ * Matching the Windows API itself, libusb uses the WINAPI convention (which
96
96
  * translates to the <tt>stdcall</tt> convention) and guarantees that the
97
97
  * library is compiled in this way. The public header file also includes
98
98
  * appropriate annotations so that your own software will use the right
@@ -100,7 +100,7 @@ typedef unsigned __int32 uint32_t;
100
100
  * your codebase.
101
101
  *
102
102
  * The one consideration that you must apply in your software is to mark
103
- * all functions which you use as libusbx callbacks with this LIBUSB_CALL
103
+ * all functions which you use as libusb callbacks with this LIBUSB_CALL
104
104
  * annotation, so that they too get compiled for the correct calling
105
105
  * convention.
106
106
  *
@@ -108,7 +108,7 @@ typedef unsigned __int32 uint32_t;
108
108
  * means that you can apply it to your code without worrying about
109
109
  * cross-platform compatibility.
110
110
  */
111
- /* LIBUSB_CALL must be defined on both definition and declaration of libusbx
111
+ /* LIBUSB_CALL must be defined on both definition and declaration of libusb
112
112
  * functions. You'd think that declaration would be enough, but cygwin will
113
113
  * complain about conflicting types unless both are marked this way.
114
114
  * The placement of this macro is important too; it must appear after the
@@ -121,36 +121,39 @@ typedef unsigned __int32 uint32_t;
121
121
  #define LIBUSB_CALL
122
122
  #endif
123
123
 
124
- /** \def LIBUSBX_API_VERSION
124
+ /** \def LIBUSB_API_VERSION
125
125
  * \ingroup misc
126
- * libusbx's API version.
126
+ * libusb's API version.
127
127
  *
128
- * Since version 1.0.13, to help with feature detection, libusbx defines
129
- * a LIBUSBX_API_VERSION macro that gets increased every time there is a
128
+ * Since version 1.0.13, to help with feature detection, libusb defines
129
+ * a LIBUSB_API_VERSION macro that gets increased every time there is a
130
130
  * significant change to the API, such as the introduction of a new call,
131
131
  * the definition of a new macro/enum member, or any other element that
132
- * libusbx applications may want to detect at compilation time.
132
+ * libusb applications may want to detect at compilation time.
133
133
  *
134
134
  * The macro is typically used in an application as follows:
135
135
  * \code
136
- * #if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x01001234)
137
- * // Use one of the newer features from the libusbx API
136
+ * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
137
+ * // Use one of the newer features from the libusb API
138
138
  * #endif
139
139
  * \endcode
140
140
  *
141
- * Another feature of LIBUSBX_API_VERSION is that it can be used to detect
142
- * whether you are compiling against the libusb or the libusbx library.
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
143
  *
144
- * Internally, LIBUSBX_API_VERSION is defined as follows:
145
- * (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental)
144
+ * Internally, LIBUSB_API_VERSION is defined as follows:
145
+ * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
146
146
  */
147
- #define LIBUSBX_API_VERSION 0x01000102
147
+ #define LIBUSB_API_VERSION 0x01000102
148
+
149
+ /* The following is kept for compatibility, but will be deprecated in the future */
150
+ #define LIBUSBX_API_VERSION LIBUSB_API_VERSION
148
151
 
149
152
  #ifdef __cplusplus
150
153
  extern "C" {
151
154
  #endif
152
155
 
153
- /** \fn libusb_cpu_to_le16
156
+ /**
154
157
  * \ingroup misc
155
158
  * Convert a 16-bit value from host-endian to little-endian format. On
156
159
  * little endian systems, this function does nothing. On big endian systems,
@@ -562,7 +565,7 @@ struct libusb_endpoint_descriptor {
562
565
  /** For audio devices only: the address if the synch endpoint */
563
566
  uint8_t bSynchAddress;
564
567
 
565
- /** Extra descriptors. If libusbx encounters unknown endpoint descriptors,
568
+ /** Extra descriptors. If libusb encounters unknown endpoint descriptors,
566
569
  * it will store them here, should you wish to parse them. */
567
570
  const unsigned char *extra;
568
571
 
@@ -612,7 +615,7 @@ struct libusb_interface_descriptor {
612
615
  * by the bNumEndpoints field. */
613
616
  const struct libusb_endpoint_descriptor *endpoint;
614
617
 
615
- /** Extra descriptors. If libusbx encounters unknown interface descriptors,
618
+ /** Extra descriptors. If libusb encounters unknown interface descriptors,
616
619
  * it will store them here, should you wish to parse them. */
617
620
  const unsigned char *extra;
618
621
 
@@ -670,7 +673,7 @@ struct libusb_config_descriptor {
670
673
  * this array is determined by the bNumInterfaces field. */
671
674
  const struct libusb_interface *interface;
672
675
 
673
- /** Extra descriptors. If libusbx encounters unknown configuration
676
+ /** Extra descriptors. If libusb encounters unknown configuration
674
677
  * descriptors, it will store them here, should you wish to parse them. */
675
678
  const unsigned char *extra;
676
679
 
@@ -889,7 +892,7 @@ struct libusb_control_setup {
889
892
 
890
893
  #define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
891
894
 
892
- /* libusbx */
895
+ /* libusb */
893
896
 
894
897
  struct libusb_context;
895
898
  struct libusb_device;
@@ -897,7 +900,7 @@ struct libusb_device_handle;
897
900
  struct libusb_hotplug_callback;
898
901
 
899
902
  /** \ingroup lib
900
- * Structure providing the version of the libusbx runtime
903
+ * Structure providing the version of the libusb runtime
901
904
  */
902
905
  struct libusb_version {
903
906
  /** Library major version. */
@@ -920,16 +923,16 @@ struct libusb_version {
920
923
  };
921
924
 
922
925
  /** \ingroup lib
923
- * Structure representing a libusbx session. The concept of individual libusbx
926
+ * Structure representing a libusb session. The concept of individual libusb
924
927
  * sessions allows for your program to use two libraries (or dynamically
925
928
  * load two modules) which both independently use libusb. This will prevent
926
- * interference between the individual libusbx users - for example
929
+ * interference between the individual libusb users - for example
927
930
  * libusb_set_debug() will not affect the other user of the library, and
928
931
  * libusb_exit() will not destroy resources that the other user is still
929
932
  * using.
930
933
  *
931
934
  * Sessions are created by libusb_init() and destroyed through libusb_exit().
932
- * If your application is guaranteed to only ever include a single libusbx
935
+ * If your application is guaranteed to only ever include a single libusb
933
936
  * user (i.e. you), you do not have to worry about contexts: pass NULL in
934
937
  * every function call where a context is required. The default context
935
938
  * will be used.
@@ -1042,7 +1045,7 @@ enum libusb_bos_type {
1042
1045
  };
1043
1046
 
1044
1047
  /** \ingroup misc
1045
- * Error codes. Most libusbx functions return 0 on success or one of these
1048
+ * Error codes. Most libusb functions return 0 on success or one of these
1046
1049
  * codes on failure.
1047
1050
  * You can call libusb_error_name() to retrieve a string representation of an
1048
1051
  * error code or libusb_strerror() to get an end-user suitable description of
@@ -1188,7 +1191,7 @@ struct libusb_transfer;
1188
1191
  * Asynchronous transfer callback function type. When submitting asynchronous
1189
1192
  * transfers, you pass a pointer to a callback function of this type via the
1190
1193
  * \ref libusb_transfer::callback "callback" member of the libusb_transfer
1191
- * structure. libusbx will call this function later, when the transfer has
1194
+ * structure. libusb will call this function later, when the transfer has
1192
1195
  * completed or failed. See \ref asyncio for more information.
1193
1196
  * \param transfer The libusb_transfer struct the callback function is being
1194
1197
  * notified about.
@@ -1271,7 +1274,7 @@ enum libusb_capability {
1271
1274
  LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
1272
1275
  /** The library can access HID devices without requiring user intervention.
1273
1276
  * Note that before being able to actually access an HID device, you may
1274
- * still have to call additional libusbx functions such as
1277
+ * still have to call additional libusb functions such as
1275
1278
  * \ref libusb_detach_kernel_driver(). */
1276
1279
  LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
1277
1280
  /** The library supports detaching of the default USB driver, using
@@ -1829,7 +1832,7 @@ void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
1829
1832
  * per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
1830
1833
  * on an already deregisted callback.
1831
1834
  *
1832
- * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
1835
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1833
1836
  *
1834
1837
  * For more information, see \ref hotplug.
1835
1838
  */
@@ -1837,7 +1840,7 @@ typedef int libusb_hotplug_callback_handle;
1837
1840
 
1838
1841
  /** \ingroup hotplug
1839
1842
  *
1840
- * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
1843
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1841
1844
  *
1842
1845
  * Flags for hotplug events */
1843
1846
  typedef enum {
@@ -1847,7 +1850,7 @@ typedef enum {
1847
1850
 
1848
1851
  /** \ingroup hotplug
1849
1852
  *
1850
- * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
1853
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1851
1854
  *
1852
1855
  * Hotplug events */
1853
1856
  typedef enum {
@@ -1871,13 +1874,13 @@ typedef enum {
1871
1874
  * This callback may be called by an internal event thread and as such it is
1872
1875
  * recommended the callback do minimal processing before returning.
1873
1876
  *
1874
- * libusbx will call this function later, when a matching event had happened on
1877
+ * libusb will call this function later, when a matching event had happened on
1875
1878
  * a matching device. See \ref hotplug for more information.
1876
1879
  *
1877
1880
  * It is safe to call either libusb_hotplug_register_callback() or
1878
1881
  * libusb_hotplug_deregister_callback() from within a callback function.
1879
1882
  *
1880
- * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
1883
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1881
1884
  *
1882
1885
  * \param ctx context of this notification
1883
1886
  * \param device libusb_device this event occurred on
@@ -1901,7 +1904,7 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
1901
1904
  *
1902
1905
  * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
1903
1906
  * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
1904
- * already plugged into the machine. Note that libusbx modifies its internal
1907
+ * already plugged into the machine. Note that libusb modifies its internal
1905
1908
  * device list from a separate thread, while calling hotplug callbacks from
1906
1909
  * libusb_handle_events(), so it is possible for a device to already be present
1907
1910
  * on, or removed from, its internal device list, while the hotplug callbacks
@@ -1911,7 +1914,7 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
1911
1914
  * from libusb_handle_events(); and/or your callback may be called for the
1912
1915
  * removal of a device for which an arrived call was never made.
1913
1916
  *
1914
- * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
1917
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1915
1918
  *
1916
1919
  * \param[in] ctx context to register this callback with
1917
1920
  * \param[in] events bitwise or of events that will trigger this callback. See \ref
@@ -1940,7 +1943,7 @@ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
1940
1943
  * Deregister a callback from a libusb_context. This function is safe to call from within
1941
1944
  * a hotplug callback.
1942
1945
  *
1943
- * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
1946
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1944
1947
  *
1945
1948
  * \param[in] ctx context this callback is registered with
1946
1949
  * \param[in] handle the handle of the callback to deregister
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Internal header for libusbx
2
+ * Internal header for libusb
3
3
  * Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
4
4
  * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
5
5
  *
@@ -39,11 +39,11 @@
39
39
  #include "libusb.h"
40
40
  #include "version.h"
41
41
 
42
- /* Inside the libusbx code, mark all public functions as follows:
42
+ /* Inside the libusb code, mark all public functions as follows:
43
43
  * return_type API_EXPORTED function_name(params) { ... }
44
44
  * But if the function returns a pointer, mark it as follows:
45
45
  * DEFAULT_VISIBILITY return_type * LIBUSB_CALL function_name(params) { ... }
46
- * In the libusbx public header, mark all declarations as:
46
+ * In the libusb public header, mark all declarations as:
47
47
  * return_type LIBUSB_CALL function_name(params);
48
48
  */
49
49
  #define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY
@@ -149,6 +149,15 @@ static inline void *usbi_reallocf(void *ptr, size_t size)
149
149
 
150
150
  #define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
151
151
 
152
+ /* Some platforms don't have this define */
153
+ #ifndef TIMESPEC_TO_TIMEVAL
154
+ #define TIMESPEC_TO_TIMEVAL(tv, ts) \
155
+ do { \
156
+ (tv)->tv_sec = (ts)->tv_sec; \
157
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
158
+ } while (0)
159
+ #endif
160
+
152
161
  void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
153
162
  const char *function, const char *format, ...);
154
163
 
@@ -503,7 +512,7 @@ struct usbi_os_backend {
503
512
  * to determine specific capabilities of the system, allocate required
504
513
  * data structures for later, etc.
505
514
  *
506
- * This function is called when a libusbx user initializes the library
515
+ * This function is called when a libusb user initializes the library
507
516
  * prior to use.
508
517
  *
509
518
  * Return 0 on success, or a LIBUSB_ERROR code on failure.
@@ -533,9 +542,9 @@ struct usbi_os_backend {
533
542
  * but that is an unlikely case.
534
543
  *
535
544
  * After computing a session ID for a device, call
536
- * usbi_get_device_by_session_id(). This function checks if libusbx already
537
- * knows about the device, and if so, it provides you with a libusb_device
538
- * structure for it.
545
+ * usbi_get_device_by_session_id(). This function checks if libusb already
546
+ * knows about the device, and if so, it provides you with a reference
547
+ * to a libusb_device structure for it.
539
548
  *
540
549
  * If usbi_get_device_by_session_id() returns NULL, it is time to allocate
541
550
  * a new device structure for the device. Call usbi_alloc_device() to
@@ -594,7 +603,7 @@ struct usbi_os_backend {
594
603
  *
595
604
  * Your backend should allocate any internal resources required for I/O
596
605
  * and other operations so that those operations can happen (hopefully)
597
- * without hiccup. This is also a good place to inform libusbx that it
606
+ * without hiccup. This is also a good place to inform libusb that it
598
607
  * should monitor certain file descriptors related to this device -
599
608
  * see the usbi_add_pollfd() function.
600
609
  *
@@ -618,7 +627,7 @@ struct usbi_os_backend {
618
627
  /* Close a device such that the handle cannot be used again. Your backend
619
628
  * should destroy any resources that were allocated in the open path.
620
629
  * This may also be a good place to call usbi_remove_pollfd() to inform
621
- * libusbx of any file descriptors associated with this device that should
630
+ * libusb of any file descriptors associated with this device that should
622
631
  * no longer be monitored.
623
632
  *
624
633
  * This function is called when the user closes a device handle.
@@ -719,7 +728,7 @@ struct usbi_os_backend {
719
728
  *
720
729
  * If you cannot retrieve this from cache, either do not implement this
721
730
  * function, or return LIBUSB_ERROR_NOT_SUPPORTED. This will cause
722
- * libusbx to retrieve the information through a standard control transfer.
731
+ * libusb to retrieve the information through a standard control transfer.
723
732
  *
724
733
  * This function must be non-blocking.
725
734
  * Return:
@@ -918,7 +927,7 @@ struct usbi_os_backend {
918
927
  * all private data from the transfer as if you were just about to report
919
928
  * completion or cancellation.
920
929
  *
921
- * This function might seem a bit out of place. It is used when libusbx
930
+ * This function might seem a bit out of place. It is used when libusb
922
931
  * detects a disconnected device - it calls this function for all pending
923
932
  * transfers before reporting completion (with the disconnect code) to
924
933
  * the user. Maybe we can improve upon this internal interface in future.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C; indent-tabs-mode:nil -*- */
2
2
  /*
3
- * darwin backend for libusbx 1.0
3
+ * darwin backend for libusb 1.0
4
4
  * Copyright © 2008-2013 Nathan Hjelm <hjelmn@users.sourceforge.net>
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -71,6 +71,7 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
71
71
 
72
72
  #if defined(ENABLE_LOGGING)
73
73
  static const char *darwin_error_str (int result) {
74
+ static char string_buffer[50];
74
75
  switch (result) {
75
76
  case kIOReturnSuccess:
76
77
  return "no error";
@@ -103,7 +104,8 @@ static const char *darwin_error_str (int result) {
103
104
  case kIOUSBHighSpeedSplitError:
104
105
  return "high speed split error";
105
106
  default:
106
- return "unknown error";
107
+ snprintf(string_buffer, sizeof(string_buffer), "unknown error (0x%x)", result);
108
+ return string_buffer;
107
109
  }
108
110
  }
109
111
  #endif
@@ -293,6 +295,7 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
293
295
  /* signal the core that this device has been disconnected. the core will tear down this device
294
296
  when the reference count reaches 0 */
295
297
  usbi_disconnect_device(dev);
298
+ libusb_unref_device(dev);
296
299
  }
297
300
  }
298
301
 
@@ -747,7 +750,7 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
747
750
  (void) get_ioregistry_value_number (service, CFSTR("sessionID"), kCFNumberSInt64Type, &sessionID);
748
751
  (void) get_ioregistry_value_number (service, CFSTR("PortNum"), kCFNumberSInt8Type, &port);
749
752
 
750
- usbi_dbg("finding cached device for sessionID 0x\n" PRIx64, sessionID);
753
+ usbi_dbg("finding cached device for sessionID 0x%" PRIx64, sessionID);
751
754
 
752
755
  result = IORegistryEntryGetParentEntry (service, kIOUSBPlane, &parent);
753
756
 
@@ -761,7 +764,7 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
761
764
  *cached_out = NULL;
762
765
 
763
766
  list_for_each_entry(new_device, &darwin_cached_devices, list, struct darwin_cached_device) {
764
- usbi_dbg("matching sessionID 0x%x against cached device with sessionID 0x%x", sessionID, new_device->session);
767
+ usbi_dbg("matching sessionID 0x%" PRIx64 " against cached device with sessionID 0x%" PRIx64, sessionID, new_device->session);
765
768
  if (new_device->session == sessionID) {
766
769
  usbi_dbg("using cached device for device");
767
770
  *cached_out = new_device;
@@ -772,7 +775,7 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
772
775
  if (*cached_out)
773
776
  break;
774
777
 
775
- usbi_dbg("caching new device with sessionID 0x%x\n", sessionID);
778
+ usbi_dbg("caching new device with sessionID 0x%" PRIx64, sessionID);
776
779
 
777
780
  device = darwin_device_from_service (service);
778
781
  if (!device) {
@@ -842,7 +845,7 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
842
845
  if (ret)
843
846
  break;
844
847
 
845
- usbi_dbg ("allocating new device in context %p for with session 0x%08x",
848
+ usbi_dbg ("allocating new device in context %p for with session 0x%" PRIx64,
846
849
  ctx, cached_device->session);
847
850
 
848
851
  dev = usbi_alloc_device(ctx, (unsigned long) cached_device->session);
@@ -864,11 +867,6 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
864
867
  dev->bus_number = cached_device->location >> 24;
865
868
  dev->device_address = cached_device->address;
866
869
 
867
- /* need to add a reference to the parent device */
868
- if (dev->parent_dev) {
869
- libusb_ref_device(dev->parent_dev);
870
- }
871
-
872
870
  (*(priv->dev->device))->GetDeviceSpeed (priv->dev->device, &devSpeed);
873
871
 
874
872
  switch (devSpeed) {
@@ -1433,7 +1431,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
1433
1431
 
1434
1432
  IOReturn ret;
1435
1433
  uint8_t transferType;
1436
- /* None of the values below are used in libusbx for bulk transfers */
1434
+ /* None of the values below are used in libusb for bulk transfers */
1437
1435
  uint8_t direction, number, interval, pipeRef, iface;
1438
1436
  uint16_t maxPacketSize;
1439
1437
 
@@ -1447,8 +1445,14 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
1447
1445
 
1448
1446
  cInterface = &priv->interfaces[iface];
1449
1447
 
1450
- (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
1451
- &transferType, &maxPacketSize, &interval);
1448
+ ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
1449
+ &transferType, &maxPacketSize, &interval);
1450
+
1451
+ if (ret) {
1452
+ usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out",
1453
+ darwin_error_str(ret), ret);
1454
+ return darwin_to_libusb (ret);
1455
+ }
1452
1456
 
1453
1457
  if (0 != (transfer->length % maxPacketSize)) {
1454
1458
  /* do not need a zero packet */
@@ -1511,7 +1515,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
1511
1515
  return LIBUSB_ERROR_NO_MEM;
1512
1516
  }
1513
1517
 
1514
- /* copy the frame list from the libusbx descriptor (the structures differ only is member order) */
1518
+ /* copy the frame list from the libusb descriptor (the structures differ only is member order) */
1515
1519
  for (i = 0 ; i < transfer->num_iso_packets ; i++)
1516
1520
  tpriv->isoc_framelist[i].frReqCount = transfer->iso_packet_desc[i].length;
1517
1521
 
@@ -1592,7 +1596,7 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
1592
1596
  tpriv->req.wValue = OSSwapLittleToHostInt16 (setup->wValue);
1593
1597
  tpriv->req.wIndex = OSSwapLittleToHostInt16 (setup->wIndex);
1594
1598
  tpriv->req.wLength = OSSwapLittleToHostInt16 (setup->wLength);
1595
- /* data is stored after the libusbx control block */
1599
+ /* data is stored after the libusb control block */
1596
1600
  tpriv->req.pData = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
1597
1601
  tpriv->req.completionTimeout = transfer->timeout;
1598
1602
  tpriv->req.noDataTimeout = transfer->timeout;