diff options
author | Peter Stuge <peter@stuge.se> | 2011-09-14 02:30:18 +0200 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2011-09-22 11:26:14 +0200 |
commit | 6904534314cf09323e6e1b00baae7cee2a2cd41e (patch) | |
tree | 31edfa21faa54a6732e31ed33bcf41fd1345ae06 | |
parent | 2dc2fa2a56408e515d25359323b4ea2f1bbec14a (diff) | |
download | libusb-6904534314cf09323e6e1b00baae7cee2a2cd41e.tar.gz |
Add libusb_has_capability() API function
Since it is currently not planned to change the filename of the libusb
DLL file for Windows systems between libusb-1.0 versions it is important
to have this API available starting with the first release that supports
Windows.
Currently there exists only one capability; LIBUSB_CAN_GET_DEVICE_SPEED,
which will always be supported when libusb_has_capability() is available.
-rw-r--r-- | libusb/core.c | 17 | ||||
-rw-r--r-- | libusb/libusb-1.0.def | 2 | ||||
-rw-r--r-- | libusb/libusb.h | 11 |
3 files changed, 30 insertions, 0 deletions
diff --git a/libusb/core.c b/libusb/core.c index 5834bea..efa3f62 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1664,6 +1664,23 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx) free(ctx); } +/** \ingroup misc + * Check if the running library has a given capability. + * + * \param capability the \ref libusb_capability to check for + * \returns 1 if the running library has the capability, 0 otherwise + */ +int API_EXPORTED libusb_has_capability(uint32_t capability) +{ + switch (capability) { + case LIBUSB_CAN_GET_DEVICE_SPEED: + return 1; + default: + break; + } + return 0; +} + void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, const char *function, const char *format, va_list args) { diff --git a/libusb/libusb-1.0.def b/libusb/libusb-1.0.def index 4eef912..54b0622 100644 --- a/libusb/libusb-1.0.def +++ b/libusb/libusb-1.0.def @@ -70,6 +70,8 @@ EXPORTS libusb_handle_events_timeout@8 = libusb_handle_events_timeout libusb_handle_events_timeout_completed libusb_handle_events_timeout_completed@12 = libusb_handle_events_timeout_completed + libusb_has_capability + libusb_has_capability@4 = libusb_has_capability libusb_init libusb_init@4 = libusb_init libusb_interrupt_transfer diff --git a/libusb/libusb.h b/libusb/libusb.h index 3b7f92a..0e9f257 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -885,9 +885,20 @@ struct libusb_transfer { ; }; +/** \ingroup misc + * Capabilities supported by this instance of libusb. Test if the running + * library supports a given capability by calling + * \ref libusb_has_capability(). + */ +enum libusb_capability { + /** The libusb_get_device_speed() API is available. */ + LIBUSB_CAN_GET_DEVICE_SPEED = 0, +}; + 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); +int LIBUSB_CALL libusb_has_capability(uint32_t capability); ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, libusb_device ***list); |