diff options
author | hselasky <hselasky@FreeBSD.org> | 2012-05-07 14:07:13 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2012-05-07 14:07:13 +0000 |
commit | 2463f208a26e08825bafd69986312adc7c264f8d (patch) | |
tree | f9b26a5908fe6698ac82d4ad205a847d599d8dc9 /lib/libusb/libusb10_desc.c | |
parent | 4b07a79925078e4a03c602b68c047474d719e2c4 (diff) | |
download | FreeBSD-src-2463f208a26e08825bafd69986312adc7c264f8d.zip FreeBSD-src-2463f208a26e08825bafd69986312adc7c264f8d.tar.gz |
Add missing LibUSB 1.0 API function: libusb_get_string_descriptor().
Reported by: Xiaofan Chen
Diffstat (limited to 'lib/libusb/libusb10_desc.c')
-rw-r--r-- | lib/libusb/libusb10_desc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c index 8e39bab..11e201f 100644 --- a/lib/libusb/libusb10_desc.c +++ b/lib/libusb/libusb10_desc.c @@ -294,6 +294,25 @@ libusb_free_config_descriptor(struct libusb_config_descriptor *config) } int +libusb_get_string_descriptor(libusb_device_handle *pdev, + uint8_t desc_index, uint16_t langid, unsigned char *data, + int length) +{ + if (pdev == NULL || data == NULL || length < 1) + return (LIBUSB_ERROR_INVALID_PARAM); + + if (length > 65535) + length = 65535; + + /* put some default data into the destination buffer */ + data[0] = 0; + + return (libusb_control_transfer(pdev, LIBUSB_ENDPOINT_IN, + LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc_index, + langid, data, length, 1000)); +} + +int libusb_get_string_descriptor_ascii(libusb_device_handle *pdev, uint8_t desc_index, unsigned char *data, int length) { |