{
bool show_help = false;
bool debug_mode = false;
-#ifdef HAS_GETVERSION
const struct libusb_version* version;
-#endif
int j, r;
size_t i, arglen;
unsigned tmp_vid, tmp_pid;
return 0;
}
-#ifdef HAS_GETVERSION
- version = libusb_getversion(); */
+ version = libusb_get_version();
printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
-#endif
r = libusb_init(NULL);
if (r < 0)
return r;
#endif
struct libusb_context *usbi_default_context = NULL;
+const struct libusb_version libusb_version_internal =
+ { LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO};
static int default_context_refcnt = 0;
static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
* \param ctx the context to operate on, or NULL for the default context
* \param list output location for a list of devices. Must be later freed with
* libusb_free_device_list().
- * \returns The number of devices in the outputted list, or any
+ * \returns the number of devices in the outputted list, or any
* \ref libusb_error according to errors encountered by the backend.
*/
ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
}
return "**UNKNOWN**";
}
+
+/** \ingroup misc
+ * Fills a libusb_version struct with the full version (major, minor,
+ * micro, nano) of this library
+ */
+DEFAULT_VISIBILITY
+const struct libusb_version * LIBUSB_CALL libusb_get_version(void)
+{
+ return &libusb_version_internal;
+}
libusb_get_pollfds@4 = libusb_get_pollfds
libusb_get_string_descriptor_ascii
libusb_get_string_descriptor_ascii@16 = libusb_get_string_descriptor_ascii
+ libusb_get_version
+ libusb_get_version@0 = libusb_get_version
libusb_handle_events
libusb_handle_events@4 = libusb_handle_events
libusb_handle_events_completed
#define LU_STR(s) #s
#define LU_XSTR(s) LU_STR(s)
#if LIBUSB_NANO > 0
-#define LIBUSB_VERSIONSTRING LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." LU_XSTR(LIBUSB_MICRO) "." LU_XSTR(LIBUSB_NANO) LIBUSB_RC "\0"
+#define LIBUSB_VERSIONSTRING \
+ LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \
+ LU_XSTR(LIBUSB_MICRO) "." LU_XSTR(LIBUSB_NANO) LIBUSB_RC "\0"
#else
-#define LIBUSB_VERSIONSTRING LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." LU_XSTR(LIBUSB_MICRO) LIBUSB_RC "\0"
+#define LIBUSB_VERSIONSTRING \
+ LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \
+ LU_XSTR(LIBUSB_MICRO) LIBUSB_RC "\0"
#endif
#endif
BEGIN
BLOCK "040904b0"
BEGIN
- VALUE "Comments", "\0"
VALUE "CompanyName", "libusbx.org\0"
VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0"
VALUE "FileVersion", LIBUSB_VERSIONSTRING
struct libusb_device_handle;
/** \ingroup lib
+ * Structure providing the version of libusbx currently in use
+ */
+struct libusb_version {
+ uint16_t major;
+ uint16_t minor;
+ uint16_t micro;
+ uint16_t nano;
+};
+
+/** \ingroup lib
* Structure representing a libusbx session. The concept of individual libusbx
* sessions allows for your program to use two libraries (or dynamically
* load two modules) which both independently use libusb. This will prevent
* Speed codes. Indicates the speed at which the device is operating.
*/
enum libusb_speed {
- /** The OS doesn't report or know the device speed. */
- LIBUSB_SPEED_UNKNOWN = 0,
+ /** The OS doesn't report or know the device speed. */
+ LIBUSB_SPEED_UNKNOWN = 0,
- /** The device is operating at low speed (1.5MBit/s). */
- LIBUSB_SPEED_LOW = 1,
+ /** The device is operating at low speed (1.5MBit/s). */
+ LIBUSB_SPEED_LOW = 1,
- /** The device is operating at full speed (12MBit/s). */
- LIBUSB_SPEED_FULL = 2,
+ /** The device is operating at full speed (12MBit/s). */
+ LIBUSB_SPEED_FULL = 2,
- /** The device is operating at high speed (480MBit/s). */
- LIBUSB_SPEED_HIGH = 3,
+ /** The device is operating at high speed (480MBit/s). */
+ LIBUSB_SPEED_HIGH = 3,
- /** The device is operating at super speed (5000MBit/s). */
- LIBUSB_SPEED_SUPER = 4,
+ /** The device is operating at super speed (5000MBit/s). */
+ LIBUSB_SPEED_SUPER = 4,
};
/** \ingroup misc
int LIBUSB_CALL libusb_init(libusb_context **ctx);
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
+const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
int LIBUSB_CALL libusb_has_capability(uint32_t capability);
const char * LIBUSB_CALL libusb_error_name(int errcode);
#endif
#include <libusb.h>
+#include "version.h"
/* Inside the libusbx code, mark all public functions as follows:
* return_type API_EXPORTED function_name(params) { ... }