libusb 0.3.4 → 0.4.0

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 (136) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Gemfile +1 -0
  5. data/History.md +10 -0
  6. data/README.md +19 -6
  7. data/Rakefile +1 -1
  8. data/ext/extconf.rb +17 -1
  9. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/AUTHORS +18 -6
  10. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/COPYING +0 -0
  11. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/ChangeLog +58 -1
  12. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/INSTALL +0 -0
  13. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/Makefile.am +6 -1
  14. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/Makefile.in +248 -174
  15. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/NEWS +2 -2
  16. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/PORTING +0 -0
  17. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/README +2 -1
  18. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/TODO +0 -0
  19. data/ext/libusbx-1.0.17/Xcode/common.xcconfig +40 -0
  20. data/ext/libusbx-1.0.17/Xcode/config.h +28 -0
  21. data/ext/libusbx-1.0.17/Xcode/debug.xcconfig +29 -0
  22. data/ext/libusbx-1.0.17/Xcode/libusbx.xcconfig +21 -0
  23. data/ext/libusbx-1.0.17/Xcode/libusbx.xcodeproj/project.pbxproj +864 -0
  24. data/ext/libusbx-1.0.17/Xcode/libusbx_debug.xcconfig +21 -0
  25. data/ext/libusbx-1.0.17/Xcode/libusbx_release.xcconfig +21 -0
  26. data/ext/libusbx-1.0.17/Xcode/release.xcconfig +29 -0
  27. data/ext/libusbx-1.0.17/aclocal.m4 +1112 -0
  28. data/ext/libusbx-1.0.17/android/README +114 -0
  29. data/ext/libusbx-1.0.17/android/config.h +90 -0
  30. data/ext/libusbx-1.0.17/android/jni/Android.mk +23 -0
  31. data/ext/libusbx-1.0.17/android/jni/Application.mk +19 -0
  32. data/ext/libusbx-1.0.17/android/jni/examples.mk +134 -0
  33. data/ext/libusbx-1.0.17/android/jni/libusb.mk +54 -0
  34. data/ext/libusbx-1.0.17/android/jni/tests.mk +56 -0
  35. data/ext/libusbx-1.0.17/compile +347 -0
  36. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/config.guess +164 -130
  37. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/config.h.in +37 -1
  38. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/config.sub +174 -89
  39. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/configure +723 -302
  40. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/configure.ac +71 -20
  41. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/depcomp +345 -185
  42. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/doc/Makefile.am +0 -0
  43. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/doc/Makefile.in +95 -32
  44. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/doc/doxygen.cfg.in +1 -1
  45. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/Makefile.am +5 -4
  46. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/Makefile.in +208 -104
  47. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/dpfp.c +1 -1
  48. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/dpfp_threaded.c +1 -1
  49. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/ezusb.c +188 -8
  50. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/ezusb.h +18 -5
  51. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/fxload.c +90 -64
  52. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/getopt/getopt.c +0 -0
  53. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/getopt/getopt.h +0 -0
  54. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/getopt/getopt1.c +0 -0
  55. data/ext/libusbx-1.0.17/examples/hotplugtest.c +97 -0
  56. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/listdevs.c +12 -4
  57. data/ext/libusbx-1.0.17/examples/sam3u_benchmark.c +193 -0
  58. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/examples/xusb.c +106 -49
  59. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/install-sh +21 -14
  60. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb-1.0.pc.in +1 -1
  61. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/Makefile.am +29 -10
  62. data/ext/libusbx-1.0.17/libusb/Makefile.in +914 -0
  63. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/core.c +378 -87
  64. data/ext/libusbx-1.0.17/libusb/descriptor.c +1199 -0
  65. data/ext/libusbx-1.0.17/libusb/hotplug.c +322 -0
  66. data/ext/libusbx-1.0.17/libusb/hotplug.h +82 -0
  67. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/io.c +182 -62
  68. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/libusb-1.0.def +32 -0
  69. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/libusb-1.0.rc +2 -0
  70. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/libusb.h +481 -32
  71. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/libusbi.h +135 -38
  72. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/darwin_usb.c +591 -496
  73. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/darwin_usb.h +39 -46
  74. data/ext/libusbx-1.0.17/libusb/os/linux_netlink.c +345 -0
  75. data/ext/libusbx-1.0.17/libusb/os/linux_udev.c +306 -0
  76. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/linux_usbfs.c +653 -617
  77. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/linux_usbfs.h +32 -0
  78. data/ext/{libusbx-1.0.14/libusb/os/openbsd_usb.c → libusbx-1.0.17/libusb/os/netbsd_usb.c} +70 -63
  79. data/ext/libusbx-1.0.17/libusb/os/openbsd_usb.c +823 -0
  80. data/ext/libusbx-1.0.17/libusb/os/poll_posix.c +51 -0
  81. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/poll_posix.h +2 -1
  82. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/poll_windows.c +85 -106
  83. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/poll_windows.h +14 -3
  84. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/threads_posix.c +3 -1
  85. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/threads_posix.h +0 -0
  86. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/threads_windows.c +6 -5
  87. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/threads_windows.h +0 -0
  88. data/ext/libusbx-1.0.17/libusb/os/wince_usb.c +1026 -0
  89. data/ext/libusbx-1.0.17/libusb/os/wince_usb.h +131 -0
  90. data/ext/libusbx-1.0.17/libusb/os/windows_common.h +108 -0
  91. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/windows_usb.c +92 -57
  92. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/os/windows_usb.h +2 -63
  93. data/ext/libusbx-1.0.17/libusb/strerror.c +184 -0
  94. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/sync.c +24 -38
  95. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/libusb/version.h +1 -1
  96. data/ext/libusbx-1.0.17/libusb/version_nano.h +1 -0
  97. data/ext/{libusbx-1.0.14 → libusbx-1.0.17}/ltmain.sh +60 -41
  98. data/ext/{libusbx-1.0.14/aclocal.m4 → libusbx-1.0.17/m4/libtool.m4} +229 -1723
  99. data/ext/libusbx-1.0.17/m4/ltoptions.m4 +384 -0
  100. data/ext/libusbx-1.0.17/m4/ltsugar.m4 +123 -0
  101. data/ext/libusbx-1.0.17/m4/ltversion.m4 +23 -0
  102. data/ext/libusbx-1.0.17/m4/lt~obsolete.m4 +98 -0
  103. data/ext/libusbx-1.0.17/missing +215 -0
  104. data/ext/libusbx-1.0.17/tests/Makefile.am +6 -0
  105. data/ext/libusbx-1.0.17/tests/Makefile.in +583 -0
  106. data/ext/libusbx-1.0.17/tests/libusbx_testlib.h +107 -0
  107. data/ext/libusbx-1.0.17/tests/stress.c +160 -0
  108. data/ext/libusbx-1.0.17/tests/testlib.c +276 -0
  109. data/lib/libusb.rb +4 -0
  110. data/lib/libusb/call.rb +43 -1
  111. data/lib/libusb/constants.rb +5 -0
  112. data/lib/libusb/context.rb +100 -0
  113. data/lib/libusb/dev_handle.rb +27 -0
  114. data/lib/libusb/device.rb +10 -4
  115. data/lib/libusb/version_gem.rb +1 -1
  116. data/test/test_libusb_capability.rb +2 -2
  117. data/test/test_libusb_compat.rb +2 -2
  118. data/test/test_libusb_compat_mass_storage.rb +2 -2
  119. data/test/test_libusb_descriptors.rb +4 -2
  120. data/test/test_libusb_event_machine.rb +2 -2
  121. data/test/test_libusb_gc.rb +2 -2
  122. data/test/test_libusb_hotplug.rb +115 -0
  123. data/test/test_libusb_iso_transfer.rb +3 -3
  124. data/test/test_libusb_mass_storage.rb +6 -16
  125. data/test/test_libusb_mass_storage2.rb +26 -3
  126. data/test/test_libusb_structs.rb +2 -2
  127. data/test/test_libusb_threads.rb +2 -2
  128. data/test/test_libusb_version.rb +2 -2
  129. metadata +127 -68
  130. metadata.gz.sig +0 -0
  131. data/ext/libusbx-1.0.14/THANKS +0 -7
  132. data/ext/libusbx-1.0.14/compile +0 -143
  133. data/ext/libusbx-1.0.14/libusb/Makefile.in +0 -721
  134. data/ext/libusbx-1.0.14/libusb/descriptor.c +0 -731
  135. data/ext/libusbx-1.0.14/libusb/version_nano.h +0 -1
  136. data/ext/libusbx-1.0.14/missing +0 -376
@@ -22,6 +22,8 @@
22
22
 
23
23
  #pragma once
24
24
 
25
+ #include "windows_common.h"
26
+
25
27
  #if defined(_MSC_VER)
26
28
  // disable /W4 MSVC warnings that are benign
27
29
  #pragma warning(disable:4127) // conditional expression is constant
@@ -30,17 +32,6 @@
30
32
  #pragma warning(disable:4201) // nameless struct/union
31
33
  #endif
32
34
 
33
- // Windows API default is uppercase - ugh!
34
- #if !defined(bool)
35
- #define bool BOOL
36
- #endif
37
- #if !defined(true)
38
- #define true TRUE
39
- #endif
40
- #if !defined(false)
41
- #define false FALSE
42
- #endif
43
-
44
35
  // Missing from MSVC6 setupapi.h
45
36
  #if !defined(SPDRP_ADDRESS)
46
37
  #define SPDRP_ADDRESS 28
@@ -57,24 +48,6 @@ extern char *_strdup(const char *strSource);
57
48
  // _beginthreadex is MSVCRT => unavailable for cygwin. Fallback to using CreateThread
58
49
  #define _beginthreadex(a, b, c, d, e, f) CreateThread(a, b, (LPTHREAD_START_ROUTINE)c, d, e, f)
59
50
  #endif
60
- #define safe_free(p) do {if (p != NULL) {free((void*)p); p = NULL;}} while(0)
61
- #define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
62
- #define safe_min(a, b) min((size_t)(a), (size_t)(b))
63
- #define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \
64
- ((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0)
65
- #define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
66
- #define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1))
67
- #define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
68
- #define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
69
- #define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
70
- #define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
71
- #define safe_strlen(str) ((str==NULL)?0:strlen(str))
72
- #define safe_sprintf _snprintf
73
- #define safe_unref_device(dev) do {if (dev != NULL) {libusb_unref_device(dev); dev = NULL;}} while(0)
74
- #define wchar_to_utf8_ms(wstr, str, strlen) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, strlen, NULL, NULL)
75
- #ifndef ARRAYSIZE
76
- #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
77
- #endif
78
51
 
79
52
  #define MAX_CTRL_BUFFER_LENGTH 4096
80
53
  #define MAX_USB_DEVICES 256
@@ -84,9 +57,6 @@ extern char *_strdup(const char *strSource);
84
57
  #define MAX_GUID_STRING_LENGTH 40
85
58
  #define MAX_PATH_LENGTH 128
86
59
  #define MAX_KEY_LENGTH 256
87
- #define MAX_TIMER_SEMAPHORES 128
88
- #define TIMER_REQUEST_RETRY_MS 100
89
- #define ERR_BUFFER_SIZE 256
90
60
  #define LIST_SEPARATOR ';'
91
61
  #define HTAB_SIZE 1021
92
62
 
@@ -332,37 +302,6 @@ struct driver_lookup {
332
302
  const char* designation; // internal designation (for debug output)
333
303
  };
334
304
 
335
- /*
336
- * API macros - from libusb-win32 1.x
337
- */
338
- #define DLL_DECLARE_PREFIXNAME(api, ret, prefixname, name, args) \
339
- typedef ret (api * __dll_##name##_t)args; \
340
- static __dll_##name##_t prefixname = NULL
341
-
342
- #define DLL_LOAD_PREFIXNAME(dll, prefixname, name, ret_on_failure) \
343
- do { \
344
- HMODULE h = GetModuleHandleA(#dll); \
345
- if (!h) \
346
- h = LoadLibraryA(#dll); \
347
- if (!h) { \
348
- if (ret_on_failure) { return LIBUSB_ERROR_NOT_FOUND; } \
349
- else { break; } \
350
- } \
351
- prefixname = (__dll_##name##_t)GetProcAddress(h, #name); \
352
- if (prefixname) break; \
353
- prefixname = (__dll_##name##_t)GetProcAddress(h, #name "A"); \
354
- if (prefixname) break; \
355
- prefixname = (__dll_##name##_t)GetProcAddress(h, #name "W"); \
356
- if (prefixname) break; \
357
- if(ret_on_failure) \
358
- return LIBUSB_ERROR_NOT_FOUND; \
359
- } while(0)
360
-
361
- #define DLL_DECLARE(api, ret, name, args) DLL_DECLARE_PREFIXNAME(api, ret, name, name, args)
362
- #define DLL_LOAD(dll, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, name, name, ret_on_failure)
363
- #define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args) DLL_DECLARE_PREFIXNAME(api, ret, prefix##name, name, args)
364
- #define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, prefix##name, name, ret_on_failure)
365
-
366
305
  /* OLE32 dependency */
367
306
  DLL_DECLARE_PREFIXED(WINAPI, HRESULT, p, CLSIDFromString, (LPCOLESTR, LPCLSID));
368
307
 
@@ -0,0 +1,184 @@
1
+ /*
2
+ * libusb strerror code
3
+ * Copyright © 2013 Hans de Goede <hdegoede@redhat.com>
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+ #include "config.h"
20
+
21
+ #include <locale.h>
22
+ #include <stdlib.h>
23
+ #include <string.h>
24
+
25
+ #include "libusb.h"
26
+ #include "libusbi.h"
27
+
28
+ #if defined(_MSC_VER)
29
+ #define strncasecmp _strnicmp
30
+ #endif
31
+
32
+ static size_t usbi_locale = 0;
33
+
34
+ /** \ingroup misc
35
+ * How to add a new \ref libusb_strerror() translation:
36
+ * <ol>
37
+ * <li> Download the latest \c strerror.c from:<br>
38
+ * https://raw.github.com/libusbx/libusbx/master/libusb/sterror.c </li>
39
+ * <li> Open the file in an UTF-8 capable editor </li>
40
+ * <li> Add the 2 letter <a href="http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1</a>
41
+ * code for your locale at the end of \c usbi_locale_supported[]<br>
42
+ * Eg. for Chinese, you would add "zh" so that:
43
+ * \code... usbi_locale_supported[] = { "en", "nl", "fr" };\endcode
44
+ * becomes:
45
+ * \code... usbi_locale_supported[] = { "en", "nl", "fr", "zh" };\endcode </li>
46
+ * <li> Copy the <tt>{ / * English (en) * / ... }</tt> section and add it at the end of \c usbi_localized_errors<br>
47
+ * Eg. for Chinese, the last section of \c usbi_localized_errors could look like:
48
+ * \code
49
+ * }, { / * Chinese (zh) * /
50
+ * "Success",
51
+ * ...
52
+ * "Other error",
53
+ * }
54
+ * };\endcode </li>
55
+ * <li> Translate each of the English messages from the section you copied into your language </li>
56
+ * <li> Save the file (in UTF-8 format) and send it to \c libusbx-devel\@lists.sourceforge.net </li>
57
+ * </ol>
58
+ */
59
+
60
+ static const char* usbi_locale_supported[] = { "en", "nl", "fr" };
61
+ static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUSB_ERROR_COUNT] = {
62
+ { /* English (en) */
63
+ "Success",
64
+ "Input/Output Error",
65
+ "Invalid parameter",
66
+ "Access denied (insufficient permissions)",
67
+ "No such device (it may have been disconnected)",
68
+ "Entity not found",
69
+ "Resource busy",
70
+ "Operation timed out",
71
+ "Overflow",
72
+ "Pipe error",
73
+ "System call interrupted (perhaps due to signal)",
74
+ "Insufficient memory",
75
+ "Operation not supported or unimplemented on this platform",
76
+ "Other error",
77
+ }, { /* Dutch (nl) */
78
+ "Gelukt",
79
+ "Invoer-/uitvoerfout",
80
+ "Ongeldig argument",
81
+ "Toegang geweigerd (onvoldoende toegangsrechten)",
82
+ "Apparaat bestaat niet (verbinding met apparaat verbroken?)",
83
+ "Niet gevonden",
84
+ "Apparaat of hulpbron is bezig",
85
+ "Bewerking verlopen",
86
+ "Waarde is te groot",
87
+ "Gebroken pijp",
88
+ "Onderbroken systeemaanroep",
89
+ "Onvoldoende geheugen beschikbaar",
90
+ "Bewerking wordt niet ondersteund",
91
+ "Andere fout",
92
+ }, { /* French (fr) */
93
+ "Succès",
94
+ "Erreur d'entrée/sortie",
95
+ "Paramètre invalide",
96
+ "Accès refusé (permissions insuffisantes)",
97
+ "Périphérique introuvable (peut-être déconnecté)",
98
+ "Elément introuvable",
99
+ "Resource déjà occupée",
100
+ "Operation expirée",
101
+ "Débordement",
102
+ "Erreur de pipe",
103
+ "Appel système abandonné (peut-être à cause d’un signal)",
104
+ "Mémoire insuffisante",
105
+ "Opération non supportée or non implémentée sur cette plateforme",
106
+ "Autre erreur"
107
+ }
108
+ };
109
+
110
+ /** \ingroup misc
111
+ * Set the language, and only the language, not the encoding! used for
112
+ * translatable libusb messages.
113
+ *
114
+ * This takes a locale string in the default setlocale format: lang[-region]
115
+ * or lang[_country_region][.codeset]. Only the lang part of the string is
116
+ * used, and only 2 letter ISO 639-1 codes are accepted for it, such as "de".
117
+ * The optional region, country_region or codeset parts are ignored. This
118
+ * means that functions which return translatable strings will NOT honor the
119
+ * specified encoding.
120
+ * All strings returned are encoded as UTF-8 strings.
121
+ *
122
+ * If libusb_setlocale() is not called, all messages will be in English.
123
+ *
124
+ * The following functions return translatable strings: libusb_strerror().
125
+ * Note that the libusb log messages controlled through libusb_set_debug()
126
+ * are not translated, they are always in English.
127
+ *
128
+ * For POSIX UTF-8 environments if you want libusb to follow the standard
129
+ * locale settings, call libusb_setlocale(setlocale(LC_MESSAGES, NULL)),
130
+ * after your app has done its locale setup.
131
+ *
132
+ * \param locale locale-string in the form of lang[_country_region][.codeset]
133
+ * or lang[-region], where lang is a 2 letter ISO 639-1 code
134
+ * \returns LIBUSB_SUCCESS on success
135
+ * \returns LIBUSB_ERROR_INVALID_PARAM if the locale doesn't meet the requirements
136
+ * \returns LIBUSB_ERROR_NOT_FOUND if the requested language is not supported
137
+ * \returns a LIBUSB_ERROR code on other errors
138
+ */
139
+
140
+ int API_EXPORTED libusb_setlocale(const char *locale)
141
+ {
142
+ size_t i;
143
+
144
+ if ( (locale == NULL) || (strlen(locale) < 2)
145
+ || ((strlen(locale) > 2) && (locale[2] != '-') && (locale[2] != '_') && (locale[2] != '.')) )
146
+ return LIBUSB_ERROR_INVALID_PARAM;
147
+
148
+ for (i=0; i<ARRAYSIZE(usbi_locale_supported); i++) {
149
+ if (strncasecmp(usbi_locale_supported[i], locale, 2) == 0)
150
+ break;
151
+ }
152
+ if (i >= ARRAYSIZE(usbi_locale_supported)) {
153
+ return LIBUSB_ERROR_NOT_FOUND;
154
+ }
155
+
156
+ usbi_locale = i;
157
+
158
+ return LIBUSB_SUCCESS;
159
+ }
160
+
161
+ /** \ingroup misc
162
+ * Returns a constant string with a short description of the given error code,
163
+ * this description is intended for displaying to the end user and will be in
164
+ * the language set by libusb_setlocale().
165
+ *
166
+ * The returned string is encoded in UTF-8.
167
+ *
168
+ * The messages always start with a capital letter and end without any dot.
169
+ * The caller must not free() the returned string.
170
+ *
171
+ * \param errcode the error code whose description is desired
172
+ * \returns a short description of the error code in UTF-8 encoding
173
+ */
174
+ DEFAULT_VISIBILITY const char* LIBUSB_CALL libusb_strerror(enum libusb_error errcode)
175
+ {
176
+ int errcode_index = -errcode;
177
+
178
+ if ((errcode_index < 0) || (errcode_index >= LIBUSB_ERROR_COUNT)) {
179
+ /* "Other Error", which should always be our last message, is returned */
180
+ errcode_index = LIBUSB_ERROR_COUNT - 1;
181
+ }
182
+
183
+ return usbi_localized_errors[usbi_locale][errcode_index];
184
+ }
@@ -17,7 +17,7 @@
17
17
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
  */
19
19
 
20
- #include <config.h>
20
+ #include "config.h"
21
21
  #include <errno.h>
22
22
  #include <stdint.h>
23
23
  #include <stdlib.h>
@@ -33,7 +33,7 @@
33
33
  * may wish to consider using the \ref asyncio "asynchronous I/O API" instead.
34
34
  */
35
35
 
36
- static void LIBUSB_CALL ctrl_transfer_cb(struct libusb_transfer *transfer)
36
+ static void LIBUSB_CALL sync_transfer_cb(struct libusb_transfer *transfer)
37
37
  {
38
38
  int *completed = transfer->user_data;
39
39
  *completed = 1;
@@ -41,6 +41,24 @@ static void LIBUSB_CALL ctrl_transfer_cb(struct libusb_transfer *transfer)
41
41
  /* caller interprets result and frees transfer */
42
42
  }
43
43
 
44
+ static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer)
45
+ {
46
+ int r, *completed = transfer->user_data;
47
+ struct libusb_context *ctx = HANDLE_CTX(transfer->dev_handle);
48
+
49
+ while (!*completed) {
50
+ r = libusb_handle_events_completed(ctx, completed);
51
+ if (r < 0) {
52
+ if (r == LIBUSB_ERROR_INTERRUPTED)
53
+ continue;
54
+ usbi_err(ctx, "libusb_handle_events failed: %s, cancelling transfer and retrying",
55
+ libusb_error_name(r));
56
+ libusb_cancel_transfer(transfer);
57
+ continue;
58
+ }
59
+ }
60
+ }
61
+
44
62
  /** \ingroup syncio
45
63
  * Perform a USB control transfer.
46
64
  *
@@ -93,7 +111,7 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
93
111
  memcpy(buffer + LIBUSB_CONTROL_SETUP_SIZE, data, wLength);
94
112
 
95
113
  libusb_fill_control_transfer(transfer, dev_handle, buffer,
96
- ctrl_transfer_cb, &completed, timeout);
114
+ sync_transfer_cb, &completed, timeout);
97
115
  transfer->flags = LIBUSB_TRANSFER_FREE_BUFFER;
98
116
  r = libusb_submit_transfer(transfer);
99
117
  if (r < 0) {
@@ -101,19 +119,7 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
101
119
  return r;
102
120
  }
103
121
 
104
- while (!completed) {
105
- r = libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed);
106
- if (r < 0) {
107
- if (r == LIBUSB_ERROR_INTERRUPTED)
108
- continue;
109
- libusb_cancel_transfer(transfer);
110
- while (!completed)
111
- if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0)
112
- break;
113
- libusb_free_transfer(transfer);
114
- return r;
115
- }
116
- }
122
+ sync_transfer_wait_for_completion(transfer);
117
123
 
118
124
  if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
119
125
  memcpy(data, libusb_control_transfer_get_data(transfer),
@@ -149,14 +155,6 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
149
155
  return r;
150
156
  }
151
157
 
152
- static void LIBUSB_CALL bulk_transfer_cb(struct libusb_transfer *transfer)
153
- {
154
- int *completed = transfer->user_data;
155
- *completed = 1;
156
- usbi_dbg("actual_length=%d", transfer->actual_length);
157
- /* caller interprets results and frees transfer */
158
- }
159
-
160
158
  static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
161
159
  unsigned char endpoint, unsigned char *buffer, int length,
162
160
  int *transferred, unsigned int timeout, unsigned char type)
@@ -169,7 +167,7 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
169
167
  return LIBUSB_ERROR_NO_MEM;
170
168
 
171
169
  libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer, length,
172
- bulk_transfer_cb, &completed, timeout);
170
+ sync_transfer_cb, &completed, timeout);
173
171
  transfer->type = type;
174
172
 
175
173
  r = libusb_submit_transfer(transfer);
@@ -178,19 +176,7 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
178
176
  return r;
179
177
  }
180
178
 
181
- while (!completed) {
182
- r = libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed);
183
- if (r < 0) {
184
- if (r == LIBUSB_ERROR_INTERRUPTED)
185
- continue;
186
- libusb_cancel_transfer(transfer);
187
- while (!completed)
188
- if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0)
189
- break;
190
- libusb_free_transfer(transfer);
191
- return r;
192
- }
193
- }
179
+ sync_transfer_wait_for_completion(transfer);
194
180
 
195
181
  *transferred = transfer->actual_length;
196
182
  switch (transfer->status) {
@@ -7,7 +7,7 @@
7
7
  #define LIBUSB_MINOR 0
8
8
  #endif
9
9
  #ifndef LIBUSB_MICRO
10
- #define LIBUSB_MICRO 14
10
+ #define LIBUSB_MICRO 17
11
11
  #endif
12
12
  #ifndef LIBUSB_NANO
13
13
  #define LIBUSB_NANO 0
@@ -0,0 +1 @@
1
+ #define LIBUSB_NANO 10830
@@ -1,9 +1,9 @@
1
1
 
2
- # libtool (GNU libtool) 2.4
2
+ # libtool (GNU libtool) 2.4.2
3
3
  # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4
4
 
5
5
  # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6
- # 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6
+ # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7
7
  # This is free software; see the source for copying conditions. There is NO
8
8
  # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
9
 
@@ -41,6 +41,7 @@
41
41
  # --quiet, --silent don't print informational messages
42
42
  # --no-quiet, --no-silent
43
43
  # print informational messages (default)
44
+ # --no-warn don't display warning messages
44
45
  # --tag=TAG use configuration variables from tag TAG
45
46
  # -v, --verbose print more informational messages than default
46
47
  # --no-verbose don't print the extra informational messages
@@ -69,7 +70,7 @@
69
70
  # compiler: $LTCC
70
71
  # compiler flags: $LTCFLAGS
71
72
  # linker: $LD (gnu? $with_gnu_ld)
72
- # $progname: (GNU libtool) 2.4
73
+ # $progname: (GNU libtool) 2.4.2
73
74
  # automake: $automake_version
74
75
  # autoconf: $autoconf_version
75
76
  #
@@ -79,9 +80,9 @@
79
80
 
80
81
  PROGRAM=libtool
81
82
  PACKAGE=libtool
82
- VERSION=2.4
83
+ VERSION=2.4.2
83
84
  TIMESTAMP=""
84
- package_revision=1.3293
85
+ package_revision=1.3337
85
86
 
86
87
  # Be Bourne compatible
87
88
  if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
@@ -136,15 +137,10 @@ progpath="$0"
136
137
 
137
138
  : ${CP="cp -f"}
138
139
  test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139
- : ${EGREP="grep -E"}
140
- : ${FGREP="grep -F"}
141
- : ${GREP="grep"}
142
- : ${LN_S="ln -s"}
143
140
  : ${MAKE="make"}
144
141
  : ${MKDIR="mkdir"}
145
142
  : ${MV="mv -f"}
146
143
  : ${RM="rm -f"}
147
- : ${SED="sed"}
148
144
  : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
149
145
  : ${Xsed="$SED -e 1s/^X//"}
150
146
 
@@ -387,7 +383,7 @@ case $progpath in
387
383
  ;;
388
384
  *)
389
385
  save_IFS="$IFS"
390
- IFS=:
386
+ IFS=${PATH_SEPARATOR-:}
391
387
  for progdir in $PATH; do
392
388
  IFS="$save_IFS"
393
389
  test -x "$progdir/$progname" && break
@@ -771,8 +767,8 @@ func_help ()
771
767
  s*\$LTCFLAGS*'"$LTCFLAGS"'*
772
768
  s*\$LD*'"$LD"'*
773
769
  s/\$with_gnu_ld/'"$with_gnu_ld"'/
774
- s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
775
- s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
770
+ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771
+ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
776
772
  p
777
773
  d
778
774
  }
@@ -1052,6 +1048,7 @@ opt_finish=false
1052
1048
  opt_help=false
1053
1049
  opt_help_all=false
1054
1050
  opt_silent=:
1051
+ opt_warning=:
1055
1052
  opt_verbose=:
1056
1053
  opt_silent=false
1057
1054
  opt_verbose=false
@@ -1118,6 +1115,10 @@ esac
1118
1115
  ;;
1119
1116
  --no-silent|--no-quiet)
1120
1117
  opt_silent=false
1118
+ func_append preserve_args " $opt"
1119
+ ;;
1120
+ --no-warning|--no-warn)
1121
+ opt_warning=false
1121
1122
  func_append preserve_args " $opt"
1122
1123
  ;;
1123
1124
  --no-verbose)
@@ -2059,7 +2060,7 @@ func_mode_compile ()
2059
2060
  *.[cCFSifmso] | \
2060
2061
  *.ada | *.adb | *.ads | *.asm | \
2061
2062
  *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2062
- *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
2063
+ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2063
2064
  func_xform "$libobj"
2064
2065
  libobj=$func_xform_result
2065
2066
  ;;
@@ -3201,11 +3202,13 @@ func_mode_install ()
3201
3202
 
3202
3203
  # Set up the ranlib parameters.
3203
3204
  oldlib="$destdir/$name"
3205
+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206
+ tool_oldlib=$func_to_tool_file_result
3204
3207
 
3205
3208
  func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3206
3209
 
3207
3210
  if test -n "$stripme" && test -n "$old_striplib"; then
3208
- func_show_eval "$old_striplib $oldlib" 'exit $?'
3211
+ func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3209
3212
  fi
3210
3213
 
3211
3214
  # Do each command in the postinstall commands.
@@ -3470,7 +3473,7 @@ static const void *lt_preloaded_setup() {
3470
3473
  # linked before any other PIC object. But we must not use
3471
3474
  # pic_flag when linking with -static. The problem exists in
3472
3475
  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3473
- *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3476
+ *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3474
3477
  pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3475
3478
  *-*-hpux*)
3476
3479
  pic_flag_for_symtable=" $pic_flag" ;;
@@ -3982,14 +3985,17 @@ func_exec_program_core ()
3982
3985
  # launches target application with the remaining arguments.
3983
3986
  func_exec_program ()
3984
3987
  {
3985
- for lt_wr_arg
3986
- do
3987
- case \$lt_wr_arg in
3988
- --lt-*) ;;
3989
- *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3990
- esac
3991
- shift
3992
- done
3988
+ case \" \$* \" in
3989
+ *\\ --lt-*)
3990
+ for lt_wr_arg
3991
+ do
3992
+ case \$lt_wr_arg in
3993
+ --lt-*) ;;
3994
+ *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995
+ esac
3996
+ shift
3997
+ done ;;
3998
+ esac
3993
3999
  func_exec_program_core \${1+\"\$@\"}
3994
4000
  }
3995
4001
 
@@ -5057,9 +5063,15 @@ void lt_dump_script (FILE* f)
5057
5063
  {
5058
5064
  EOF
5059
5065
  func_emit_wrapper yes |
5060
- $SED -e 's/\([\\"]\)/\\\1/g' \
5061
- -e 's/^/ fputs ("/' -e 's/$/\\n", f);/'
5062
-
5066
+ $SED -n -e '
5067
+ s/^\(.\{79\}\)\(..*\)/\1\
5068
+ \2/
5069
+ h
5070
+ s/\([\\"]\)/\\\1/g
5071
+ s/$/\\n/
5072
+ s/\([^\n]*\).*/ fputs ("\1", f);/p
5073
+ g
5074
+ D'
5063
5075
  cat <<"EOF"
5064
5076
  }
5065
5077
  EOF
@@ -5643,7 +5655,8 @@ func_mode_link ()
5643
5655
  continue
5644
5656
  ;;
5645
5657
 
5646
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5658
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659
+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5647
5660
  func_append compiler_flags " $arg"
5648
5661
  func_append compile_command " $arg"
5649
5662
  func_append finalize_command " $arg"
@@ -6147,7 +6160,8 @@ func_mode_link ()
6147
6160
  lib=
6148
6161
  found=no
6149
6162
  case $deplib in
6150
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
6163
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6164
+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6151
6165
  if test "$linkmode,$pass" = "prog,link"; then
6152
6166
  compile_deplibs="$deplib $compile_deplibs"
6153
6167
  finalize_deplibs="$deplib $finalize_deplibs"
@@ -6499,7 +6513,7 @@ func_mode_link ()
6499
6513
  # Find the relevant object directory and library name.
6500
6514
  if test "X$installed" = Xyes; then
6501
6515
  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6502
- #func_warning "library \`$lib' was moved."
6516
+ func_warning "library \`$lib' was moved."
6503
6517
  dir="$ladir"
6504
6518
  absdir="$abs_ladir"
6505
6519
  libdir="$abs_ladir"
@@ -6831,7 +6845,7 @@ func_mode_link ()
6831
6845
  test "$hardcode_direct_absolute" = no; then
6832
6846
  add="$dir/$linklib"
6833
6847
  elif test "$hardcode_minus_L" = yes; then
6834
- add_dir="-L$dir"
6848
+ add_dir="-L$absdir"
6835
6849
  # Try looking first in the location we're being installed to.
6836
6850
  if test -n "$inst_prefix_dir"; then
6837
6851
  case $libdir in
@@ -7066,8 +7080,8 @@ func_mode_link ()
7066
7080
  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7067
7081
  test -z "$libdir" && \
7068
7082
  func_fatal_error "\`$deplib' is not a valid libtool archive"
7069
- #test "$absdir" != "$libdir" && \
7070
- # func_warning "\`$deplib' seems to be moved"
7083
+ test "$absdir" != "$libdir" && \
7084
+ func_warning "\`$deplib' seems to be moved"
7071
7085
 
7072
7086
  path="-L$absdir"
7073
7087
  fi
@@ -7316,6 +7330,7 @@ func_mode_link ()
7316
7330
  # which has an extra 1 added just for fun
7317
7331
  #
7318
7332
  case $version_type in
7333
+ # correct linux to gnu/linux during the next big refactor
7319
7334
  darwin|linux|osf|windows|none)
7320
7335
  func_arith $number_major + $number_minor
7321
7336
  current=$func_arith_result
@@ -7432,7 +7447,7 @@ func_mode_link ()
7432
7447
  versuffix="$major.$revision"
7433
7448
  ;;
7434
7449
 
7435
- linux)
7450
+ linux) # correct to gnu/linux during the next big refactor
7436
7451
  func_arith $current - $age
7437
7452
  major=.$func_arith_result
7438
7453
  versuffix="$major.$age.$revision"
@@ -8020,6 +8035,11 @@ EOF
8020
8035
 
8021
8036
  # Test again, we may have decided not to build it any more
8022
8037
  if test "$build_libtool_libs" = yes; then
8038
+ # Remove ${wl} instances when linking with ld.
8039
+ # FIXME: should test the right _cmds variable.
8040
+ case $archive_cmds in
8041
+ *\$LD\ *) wl= ;;
8042
+ esac
8023
8043
  if test "$hardcode_into_libs" = yes; then
8024
8044
  # Hardcode the library paths
8025
8045
  hardcode_libdirs=
@@ -8050,7 +8070,7 @@ EOF
8050
8070
  elif test -n "$runpath_var"; then
8051
8071
  case "$perm_rpath " in
8052
8072
  *" $libdir "*) ;;
8053
- *) func_apped perm_rpath " $libdir" ;;
8073
+ *) func_append perm_rpath " $libdir" ;;
8054
8074
  esac
8055
8075
  fi
8056
8076
  done
@@ -8058,11 +8078,7 @@ EOF
8058
8078
  if test -n "$hardcode_libdir_separator" &&
8059
8079
  test -n "$hardcode_libdirs"; then
8060
8080
  libdir="$hardcode_libdirs"
8061
- if test -n "$hardcode_libdir_flag_spec_ld"; then
8062
- eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
8063
- else
8064
- eval dep_rpath=\"$hardcode_libdir_flag_spec\"
8065
- fi
8081
+ eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8066
8082
  fi
8067
8083
  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8068
8084
  # We should set the runpath_var.
@@ -9152,6 +9168,8 @@ EOF
9152
9168
  esac
9153
9169
  done
9154
9170
  fi
9171
+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9172
+ tool_oldlib=$func_to_tool_file_result
9155
9173
  eval cmds=\"$old_archive_cmds\"
9156
9174
 
9157
9175
  func_len " $cmds"
@@ -9261,7 +9279,8 @@ EOF
9261
9279
  *.la)
9262
9280
  func_basename "$deplib"
9263
9281
  name="$func_basename_result"
9264
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
9282
+ func_resolve_sysroot "$deplib"
9283
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9265
9284
  test -z "$libdir" && \
9266
9285
  func_fatal_error "\`$deplib' is not a valid libtool archive"
9267
9286
  func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"