Core: Add get_version() call
* Also some formatting/typo improvements
This commit is contained in:
parent
5b82831df2
commit
37dfd16c8c
6 changed files with 44 additions and 19 deletions
|
@ -758,9 +758,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
bool show_help = false;
|
bool show_help = false;
|
||||||
bool debug_mode = false;
|
bool debug_mode = false;
|
||||||
#ifdef HAS_GETVERSION
|
|
||||||
const struct libusb_version* version;
|
const struct libusb_version* version;
|
||||||
#endif
|
|
||||||
int j, r;
|
int j, r;
|
||||||
size_t i, arglen;
|
size_t i, arglen;
|
||||||
unsigned tmp_vid, tmp_pid;
|
unsigned tmp_vid, tmp_pid;
|
||||||
|
@ -859,10 +857,8 @@ int main(int argc, char** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_GETVERSION
|
version = libusb_get_version();
|
||||||
version = libusb_getversion(); */
|
|
||||||
printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
|
printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
|
||||||
#endif
|
|
||||||
r = libusb_init(NULL);
|
r = libusb_init(NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -42,6 +42,8 @@ const struct usbi_os_backend * const usbi_backend = &windows_backend;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct libusb_context *usbi_default_context = NULL;
|
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 int default_context_refcnt = 0;
|
||||||
static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
|
static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
@ -577,7 +579,7 @@ struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
|
||||||
* \param ctx the context to operate on, or NULL for the default context
|
* \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
|
* \param list output location for a list of devices. Must be later freed with
|
||||||
* libusb_free_device_list().
|
* 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.
|
* \ref libusb_error according to errors encountered by the backend.
|
||||||
*/
|
*/
|
||||||
ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
|
ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
|
||||||
|
@ -1760,3 +1762,13 @@ DEFAULT_VISIBILITY const char * LIBUSB_CALL libusb_error_name(int error_code)
|
||||||
}
|
}
|
||||||
return "**UNKNOWN**";
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -62,6 +62,8 @@ EXPORTS
|
||||||
libusb_get_pollfds@4 = libusb_get_pollfds
|
libusb_get_pollfds@4 = libusb_get_pollfds
|
||||||
libusb_get_string_descriptor_ascii
|
libusb_get_string_descriptor_ascii
|
||||||
libusb_get_string_descriptor_ascii@16 = 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
|
||||||
libusb_handle_events@4 = libusb_handle_events
|
libusb_handle_events@4 = libusb_handle_events
|
||||||
libusb_handle_events_completed
|
libusb_handle_events_completed
|
||||||
|
|
|
@ -12,9 +12,13 @@
|
||||||
#define LU_STR(s) #s
|
#define LU_STR(s) #s
|
||||||
#define LU_XSTR(s) LU_STR(s)
|
#define LU_XSTR(s) LU_STR(s)
|
||||||
#if LIBUSB_NANO > 0
|
#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
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,7 +39,6 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904b0"
|
BLOCK "040904b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Comments", "\0"
|
|
||||||
VALUE "CompanyName", "libusbx.org\0"
|
VALUE "CompanyName", "libusbx.org\0"
|
||||||
VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0"
|
VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0"
|
||||||
VALUE "FileVersion", LIBUSB_VERSIONSTRING
|
VALUE "FileVersion", LIBUSB_VERSIONSTRING
|
||||||
|
|
|
@ -638,6 +638,16 @@ struct libusb_context;
|
||||||
struct libusb_device;
|
struct libusb_device;
|
||||||
struct libusb_device_handle;
|
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
|
/** \ingroup lib
|
||||||
* Structure representing a libusbx session. The concept of individual libusbx
|
* Structure representing a libusbx session. The concept of individual libusbx
|
||||||
* sessions allows for your program to use two libraries (or dynamically
|
* sessions allows for your program to use two libraries (or dynamically
|
||||||
|
@ -929,6 +939,7 @@ enum libusb_capability {
|
||||||
int LIBUSB_CALL libusb_init(libusb_context **ctx);
|
int LIBUSB_CALL libusb_init(libusb_context **ctx);
|
||||||
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
|
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
|
||||||
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
|
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);
|
int LIBUSB_CALL libusb_has_capability(uint32_t capability);
|
||||||
const char * LIBUSB_CALL libusb_error_name(int errcode);
|
const char * LIBUSB_CALL libusb_error_name(int errcode);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
/* Inside the libusbx code, mark all public functions as follows:
|
/* Inside the libusbx code, mark all public functions as follows:
|
||||||
* return_type API_EXPORTED function_name(params) { ... }
|
* return_type API_EXPORTED function_name(params) { ... }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue