summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-15 12:35:02 +0000
committerPete Batard <pbatard@gmail.com>2010-01-15 12:35:02 +0000
commitb96e16e75ffc2b3bdd76ec5457d37d092f0a2590 (patch)
tree21ad3867b7e663edf6511c511f2ecb0f0a9a7ba6
parent8981e69c7da1c6b8c9e97510bd5b1dd137e50cdb (diff)
downloadlibusb-b96e16e75ffc2b3bdd76ec5457d37d092f0a2590.tar.gz
r80: workaround for interface macro redefinition on Windows (removes the need for #undef interface in end user sources)
-rw-r--r--examples/xusb.c24
-rw-r--r--libusb/core.c26
-rw-r--r--libusb/descriptor.c46
-rw-r--r--libusb/libusb.h27
-rw-r--r--libusb/libusbi.h6
-rw-r--r--libusb/os/windows_compat.h9
-rw-r--r--libusb/os/windows_usb.c62
-rw-r--r--libusb/os/windows_usb.h12
8 files changed, 106 insertions, 106 deletions
diff --git a/examples/xusb.c b/examples/xusb.c
index 3167d98..4775194 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -36,9 +36,6 @@
#ifdef OS_WINDOWS
#include <windows.h>
#define msleep(msecs) Sleep(msecs)
-#ifdef interface
-#undef interface
-#endif
#else
#include <unistd.h>
#define msleep(msecs) usleep(1000*msecs)
@@ -373,21 +370,21 @@ int test_device(uint16_t vid, uint16_t pid)
nb_ifaces = conf_desc->bNumInterfaces;
printf("num interfaces = %d\n", nb_ifaces);
for (i=0; i<conf_desc->bNumInterfaces; i++) {
- for (j=0; j<conf_desc->interface[i].num_altsetting; j++) {
+ for (j=0; j<conf_desc->usb_interface[i].num_altsetting; j++) {
printf("interface[%d].altsetting[%d]: num endpoints = %d\n",
- i, j, conf_desc->interface[i].altsetting[j].bNumEndpoints);
+ i, j, conf_desc->usb_interface[i].altsetting[j].bNumEndpoints);
printf(" Class.SubClass.Protocol: %02X.%02X.%02X\n",
- conf_desc->interface[i].altsetting[j].bInterfaceClass,
- conf_desc->interface[i].altsetting[j].bInterfaceSubClass,
- conf_desc->interface[i].altsetting[j].bInterfaceProtocol);
- if ( (conf_desc->interface[i].altsetting[j].bInterfaceClass == LIBUSB_CLASS_MASS_STORAGE)
- && ( (conf_desc->interface[i].altsetting[j].bInterfaceSubClass == 0x01)
- || (conf_desc->interface[i].altsetting[j].bInterfaceSubClass == 0x06) ) ) {
+ conf_desc->usb_interface[i].altsetting[j].bInterfaceClass,
+ conf_desc->usb_interface[i].altsetting[j].bInterfaceSubClass,
+ conf_desc->usb_interface[i].altsetting[j].bInterfaceProtocol);
+ if ( (conf_desc->usb_interface[i].altsetting[j].bInterfaceClass == LIBUSB_CLASS_MASS_STORAGE)
+ && ( (conf_desc->usb_interface[i].altsetting[j].bInterfaceSubClass == 0x01)
+ || (conf_desc->usb_interface[i].altsetting[j].bInterfaceSubClass == 0x06) ) ) {
// Mass storage devices that can use basic SCSI commands
test_scsi = -1;
}
- for (k=0; k<conf_desc->interface[i].altsetting[j].bNumEndpoints; k++) {
- endpoint = &conf_desc->interface[i].altsetting[j].endpoint[k];
+ for (k=0; k<conf_desc->usb_interface[i].altsetting[j].bNumEndpoints; k++) {
+ endpoint = &conf_desc->usb_interface[i].altsetting[j].endpoint[k];
printf(" endpoint[%d].address: %02X\n", k, endpoint->bEndpointAddress);
printf(" max packet size: %04X\n", endpoint->wMaxPacketSize);
printf(" polling interval: %02X\n", endpoint->bInterval);
@@ -483,6 +480,7 @@ int main(int argc, char** argv)
test_device(VID, PID);
libusb_exit(NULL);
+
return 0;
}
diff --git a/libusb/core.c b/libusb/core.c
index 1a2fdca..94b22e1 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -689,7 +689,7 @@ static const struct libusb_endpoint_descriptor *find_endpoint(
{
int iface_idx;
for (iface_idx = 0; iface_idx < config->bNumInterfaces; iface_idx++) {
- const struct libusb_interface *iface = &config->interface[iface_idx];
+ const struct libusb_interface *iface = &config->usb_interface[iface_idx];
int altsetting_idx;
for (altsetting_idx = 0; altsetting_idx < iface->num_altsetting;
@@ -1357,7 +1357,7 @@ API_EXPORTED int libusb_reset_device(libusb_device_handle *dev)
* perform I/O.
*
* \param dev a device handle
- * \param interface the interface to check
+ * \param interface_number the interface to check
* \returns 0 if no kernel driver is active
* \returns 1 if a kernel driver is active
* \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
@@ -1365,11 +1365,11 @@ API_EXPORTED int libusb_reset_device(libusb_device_handle *dev)
* \see libusb_detach_kernel_driver()
*/
API_EXPORTED int libusb_kernel_driver_active(libusb_device_handle *dev,
- int interface)
+ int interface_number)
{
- usbi_dbg("interface %d", interface);
+ usbi_dbg("interface %d", interface_number);
if (usbi_backend->kernel_driver_active)
- return usbi_backend->kernel_driver_active(dev, interface);
+ return usbi_backend->kernel_driver_active(dev, interface_number);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -1379,7 +1379,7 @@ API_EXPORTED int libusb_kernel_driver_active(libusb_device_handle *dev,
* able to claim the interface and perform I/O.
*
* \param dev a device handle
- * \param interface the interface to detach the driver from
+ * \param interface_number the interface to detach the driver from
* \returns 0 on success
* \returns LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
* \returns LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
@@ -1388,11 +1388,11 @@ API_EXPORTED int libusb_kernel_driver_active(libusb_device_handle *dev,
* \see libusb_kernel_driver_active()
*/
API_EXPORTED int libusb_detach_kernel_driver(libusb_device_handle *dev,
- int interface)
+ int interface_number)
{
- usbi_dbg("interface %d", interface);
+ usbi_dbg("interface %d", interface_number);
if (usbi_backend->detach_kernel_driver)
- return usbi_backend->detach_kernel_driver(dev, interface);
+ return usbi_backend->detach_kernel_driver(dev, interface_number);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -1402,7 +1402,7 @@ API_EXPORTED int libusb_detach_kernel_driver(libusb_device_handle *dev,
* using libusb_detach_kernel_driver().
*
* \param dev a device handle
- * \param interface the interface to attach the driver from
+ * \param interface_number the interface to attach the driver from
* \returns 0 on success
* \returns LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
* \returns LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
@@ -1413,11 +1413,11 @@ API_EXPORTED int libusb_detach_kernel_driver(libusb_device_handle *dev,
* \see libusb_kernel_driver_active()
*/
API_EXPORTED int libusb_attach_kernel_driver(libusb_device_handle *dev,
- int interface)
+ int interface_number)
{
- usbi_dbg("interface %d", interface);
+ usbi_dbg("interface %d", interface_number);
if (usbi_backend->attach_kernel_driver)
- return usbi_backend->attach_kernel_driver(dev, interface);
+ return usbi_backend->attach_kernel_driver(dev, interface_number);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index 5664934..638ed85 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -154,16 +154,16 @@ static int parse_endpoint(struct libusb_context *ctx,
return parsed;
}
-static void clear_interface(struct libusb_interface *interface)
+static void clear_interface(struct libusb_interface *usb_interface)
{
int i;
int j;
- if (interface->altsetting) {
- for (i = 0; i < interface->num_altsetting; i++) {
+ if (usb_interface->altsetting) {
+ for (i = 0; i < usb_interface->num_altsetting; i++) {
struct libusb_interface_descriptor *ifp =
(struct libusb_interface_descriptor *)
- interface->altsetting + i;
+ usb_interface->altsetting + i;
if (ifp->extra)
free((void *) ifp->extra);
if (ifp->endpoint) {
@@ -173,14 +173,14 @@ static void clear_interface(struct libusb_interface *interface)
free((void *) ifp->endpoint);
}
}
- free((void *) interface->altsetting);
- interface->altsetting = NULL;
+ free((void *) usb_interface->altsetting);
+ usb_interface->altsetting = NULL;
}
}
static int parse_interface(libusb_context *ctx,
- struct libusb_interface *interface, unsigned char *buffer, int size,
+ struct libusb_interface *usb_interface, unsigned char *buffer, int size,
int host_endian)
{
int i;
@@ -192,22 +192,22 @@ static int parse_interface(libusb_context *ctx,
struct libusb_interface_descriptor *ifp;
unsigned char *begin;
- interface->num_altsetting = 0;
+ usb_interface->num_altsetting = 0;
while (size >= INTERFACE_DESC_LENGTH) {
struct libusb_interface_descriptor *altsetting =
- (struct libusb_interface_descriptor *) interface->altsetting;
+ (struct libusb_interface_descriptor *) usb_interface->altsetting;
altsetting = realloc(altsetting,
sizeof(struct libusb_interface_descriptor) *
- (interface->num_altsetting + 1));
+ (usb_interface->num_altsetting + 1));
if (!altsetting) {
r = LIBUSB_ERROR_NO_MEM;
goto err;
}
- interface->altsetting = altsetting;
+ usb_interface->altsetting = altsetting;
- ifp = altsetting + interface->num_altsetting;
- interface->num_altsetting++;
+ ifp = altsetting + usb_interface->num_altsetting;
+ usb_interface->num_altsetting++;
usbi_parse_descriptor(buffer, "bbbbbbbbb", ifp, 0);
ifp->extra = NULL;
ifp->extra_length = 0;
@@ -309,18 +309,18 @@ static int parse_interface(libusb_context *ctx,
return parsed;
err:
- clear_interface(interface);
+ clear_interface(usb_interface);
return r;
}
static void clear_configuration(struct libusb_config_descriptor *config)
{
- if (config->interface) {
+ if (config->usb_interface) {
int i;
for (i = 0; i < config->bNumInterfaces; i++)
clear_interface((struct libusb_interface *)
- config->interface + i);
- free((void *) config->interface);
+ config->usb_interface + i);
+ free((void *) config->usb_interface);
}
if (config->extra)
free((void *) config->extra);
@@ -335,7 +335,7 @@ static int parse_configuration(struct libusb_context *ctx,
int size;
int tmp;
struct usb_descriptor_header header;
- struct libusb_interface *interface;
+ struct libusb_interface *usb_interface;
usbi_parse_descriptor(buffer, "bbwbbbbb", config, host_endian);
size = config->wTotalLength;
@@ -346,12 +346,12 @@ static int parse_configuration(struct libusb_context *ctx,
}
tmp = config->bNumInterfaces * sizeof(struct libusb_interface);
- interface = malloc(tmp);
- config->interface = interface;
- if (!config->interface)
+ usb_interface = malloc(tmp);
+ config->usb_interface = usb_interface;
+ if (!config->usb_interface)
return LIBUSB_ERROR_NO_MEM;
- memset(interface, 0, tmp);
+ memset(usb_interface, 0, tmp);
buffer += config->bLength;
size -= config->bLength;
@@ -405,7 +405,7 @@ static int parse_configuration(struct libusb_context *ctx,
}
}
- r = parse_interface(ctx, interface + i, buffer, size, host_endian);
+ r = parse_interface(ctx, usb_interface + i, buffer, size, host_endian);
if (r < 0)
goto err;
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 46a5006..d345727 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -22,8 +22,7 @@
#define __LIBUSB_H__
#include <stdint.h>
-#if defined(_MSC_VER)
-#define inline __inline
+#ifdef _MSC_VER
#include <time.h>
#else
#include <sys/time.h>
@@ -32,6 +31,15 @@
#include <time.h>
#include <limits.h>
+// Work around for Windows "interface" macro redefinition
+#ifdef _MSC_VER
+#define inline __inline
+#pragma push_macro("interface")
+#endif
+#ifndef interface
+#define interface usb_interface
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -496,7 +504,7 @@ struct libusb_config_descriptor {
/** Array of interfaces supported by this configuration. The length of
* this array is determined by the bNumInterfaces field. */
- const struct libusb_interface *interface;
+ const struct libusb_interface *usb_interface;
/** Extra descriptors. If libusb encounters unknown configuration
* descriptors, it will store them here, should you wish to parse them. */
@@ -800,8 +808,8 @@ void libusb_close(libusb_device_handle *dev_handle);
libusb_device *libusb_get_device(libusb_device_handle *dev_handle);
int libusb_set_configuration(libusb_device_handle *dev, int configuration);
-int libusb_claim_interface(libusb_device_handle *dev, int iface);
-int libusb_release_interface(libusb_device_handle *dev, int iface);
+int libusb_claim_interface(libusb_device_handle *dev, int interface_number);
+int libusb_release_interface(libusb_device_handle *dev, int interface_number);
libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context *ctx,
uint16_t vendor_id, uint16_t product_id);
@@ -811,9 +819,9 @@ int libusb_set_interface_alt_setting(libusb_device_handle *dev,
int libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint);
int libusb_reset_device(libusb_device_handle *dev);
-int libusb_kernel_driver_active(libusb_device_handle *dev, int interface);
-int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface);
-int libusb_attach_kernel_driver(libusb_device_handle *dev, int interface);
+int libusb_kernel_driver_active(libusb_device_handle *dev, int interface_number);
+int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number);
+int libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number);
/* async I/O */
@@ -1237,4 +1245,7 @@ void libusb_set_pollfd_notifiers(libusb_context *ctx,
}
#endif
+#ifdef _MSC_VER
+#pragma pop_macro("interface")
+#endif
#endif
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index 9cdbba5..6d2e661 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -709,7 +709,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*kernel_driver_active)(struct libusb_device_handle *handle,
- int interface);
+ int iface);
/* Detach a kernel driver from an interface. Optional.
*
@@ -725,7 +725,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*detach_kernel_driver)(struct libusb_device_handle *handle,
- int interface);
+ int iface);
/* Attach a kernel driver to an interface. Optional.
*
@@ -742,7 +742,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*attach_kernel_driver)(struct libusb_device_handle *handle,
- int interface);
+ int iface);
/* Destroy a device. Optional.
*
diff --git a/libusb/os/windows_compat.h b/libusb/os/windows_compat.h
index 4ce3645..9159b4e 100644
--- a/libusb/os/windows_compat.h
+++ b/libusb/os/windows_compat.h
@@ -21,15 +21,6 @@
*/
#pragma once
-/*
- * Prevent compilation problems on Windows platforms
- *
- * This is placed in the .h to limit changes required to the core files
- */
-#if defined(interface)
-#undef interface
-#endif
-
#if !defined(ssize_t)
#if defined (_WIN64)
#define ssize_t __int64
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 3ef060a..193408e 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -287,14 +287,14 @@ static void windows_assign_endpoints(struct libusb_device *dev, int iface, int a
const struct libusb_interface_descriptor *if_desc;
if (libusb_get_config_descriptor(dev, 0, &conf_desc) == LIBUSB_SUCCESS) {
- if_desc = &conf_desc->interface[iface].altsetting[altsetting];
- safe_free(priv->interface[iface].endpoint);
- priv->interface[iface].endpoint = malloc(if_desc->bNumEndpoints);
- if (priv->interface[iface].endpoint != NULL) {
- priv->interface[iface].nb_endpoints = if_desc->bNumEndpoints;
+ if_desc = &conf_desc->usb_interface[iface].altsetting[altsetting];
+ safe_free(priv->usb_interface[iface].endpoint);
+ priv->usb_interface[iface].endpoint = malloc(if_desc->bNumEndpoints);
+ if (priv->usb_interface[iface].endpoint != NULL) {
+ priv->usb_interface[iface].nb_endpoints = if_desc->bNumEndpoints;
for (i=0; i<if_desc->bNumEndpoints; i++) {
- priv->interface[iface].endpoint[i] = if_desc->endpoint[i].bEndpointAddress;
- usbi_dbg("(re)assigned endpoint %02X to interface %d", priv->interface[iface].endpoint[i], iface);
+ priv->usb_interface[iface].endpoint[i] = if_desc->endpoint[i].bEndpointAddress;
+ usbi_dbg("(re)assigned endpoint %02X to interface %d", priv->usb_interface[iface].endpoint[i], iface);
}
}
libusb_free_config_descriptor(conf_desc);
@@ -941,18 +941,18 @@ static int set_composite_device(struct libusb_context *ctx, DEVINST devinst, str
for (j=0; j<nb_paths; j++) {
if (safe_strncmp(sanitized_path[j], sanitized_short, strlen(sanitized_short)) == 0) {
- priv->interface[interface_number].path = sanitized_path[j];
+ priv->usb_interface[interface_number].path = sanitized_path[j];
sanitized_path[j] = NULL;
}
}
safe_free(sanitized_short);
- if (priv->interface[interface_number].path == NULL) {
+ if (priv->usb_interface[interface_number].path == NULL) {
usbi_warn(ctx, "could not retrieve full path for interface %d",
interface_number);
continue;
}
- usbi_dbg("interface_path[%d]: %s", interface_number, priv->interface[interface_number].path);
+ usbi_dbg("interface_path[%d]: %s", interface_number, priv->usb_interface[interface_number].path);
found = true;
}
@@ -1077,7 +1077,7 @@ static int set_device_paths(struct libusb_context *ctx, struct discovered_devs *
if (safe_strcmp(priv->driver, "WinUSB") == 0) {
priv->apib = &windows_winusb_backend;
// For non composite, the first interface is the same as the device
- priv->interface[0].path = safe_strdup(priv->path); // needs strdup
+ priv->usb_interface[0].path = safe_strdup(priv->path); // needs strdup
} else if (safe_strcmp(reg_key, "usbccgp") == 0) {
// Composite (multi-interface) devices are identified by their use of
// the USB Common Class Generic Parent driver
@@ -1263,8 +1263,8 @@ static int windows_claim_interface(struct libusb_device_handle *dev_handle, int
if (iface >= USB_MAXINTERFACES)
return LIBUSB_ERROR_INVALID_PARAM;
- safe_free(priv->interface[iface].endpoint);
- priv->interface[iface].nb_endpoints= 0;
+ safe_free(priv->usb_interface[iface].endpoint);
+ priv->usb_interface[iface].nb_endpoints= 0;
r = priv->apib->claim_interface(dev_handle, iface);
@@ -1280,8 +1280,8 @@ static int windows_set_interface_altsetting(struct libusb_device_handle *dev_han
int r = LIBUSB_SUCCESS;
struct windows_device_priv *priv = __device_priv(dev_handle->dev);
- safe_free(priv->interface[iface].endpoint);
- priv->interface[iface].nb_endpoints= 0;
+ safe_free(priv->usb_interface[iface].endpoint);
+ priv->usb_interface[iface].nb_endpoints= 0;
r = priv->apib->set_interface_altsetting(dev_handle, iface, altsetting);
@@ -1734,8 +1734,8 @@ static int winusb_open(struct libusb_device_handle *dev_handle)
// WinUSB requires a seperate handle for each interface
for (i = 0; i < USB_MAXINTERFACES; i++) {
- if (priv->interface[i].path != NULL) {
- file_handle = CreateFileA(priv->interface[i].path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
+ if (priv->usb_interface[i].path != NULL) {
+ file_handle = CreateFileA(priv->usb_interface[i].path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
if (file_handle == INVALID_HANDLE_VALUE) {
usbi_err(ctx, "could not open device %s (interface %d): %s", priv->path, i, windows_error_str(0));
@@ -1846,8 +1846,8 @@ static int winusb_claim_interface(struct libusb_device_handle *dev_handle, int i
// With handle and enpoints set (in parent), we can setup the default
// pipe properties (copied from libusb-win32-v1)
// see http://download.microsoft.com/download/D/1/D/D1DD7745-426B-4CC3-A269-ABBBE427C0EF/DVC-T705_DDC08.pptx
- for (i=0; i<priv->interface[iface].nb_endpoints; i++) {
- endpoint_address = priv->interface[iface].endpoint[i];
+ for (i=0; i<priv->usb_interface[iface].nb_endpoints; i++) {
+ endpoint_address = priv->usb_interface[iface].endpoint[i];
policy = false;
if (!WinUsb_SetPipePolicy(winusb_handle, endpoint_address,
SHORT_PACKET_TERMINATE, sizeof(UCHAR), &policy)) {
@@ -1916,10 +1916,10 @@ static int winusb_interface_by_endpoint(struct windows_device_priv *priv,
continue;
if (handle_priv->interface_handle[i].winusb == 0)
continue;
- if (priv->interface[i].endpoint == NULL)
+ if (priv->usb_interface[i].endpoint == NULL)
continue;
- for (j=0; j<priv->interface[i].nb_endpoints; j++) {
- if (priv->interface[i].endpoint[j] == endpoint_address) {
+ for (j=0; j<priv->usb_interface[i].nb_endpoints; j++) {
+ if (priv->usb_interface[i].endpoint[j] == endpoint_address) {
return i;
}
}
@@ -2176,22 +2176,22 @@ static int winusb_reset_device(struct libusb_device_handle *dev_handle)
}
if ( (winusb_handle != 0) && (winusb_handle != INVALID_HANDLE_VALUE)) {
- for (j=0; j<priv->interface[i].nb_endpoints; j++) {
- usbi_dbg("resetting ep %02X", priv->interface[i].endpoint[j]);
+ for (j=0; j<priv->usb_interface[i].nb_endpoints; j++) {
+ usbi_dbg("resetting ep %02X", priv->usb_interface[i].endpoint[j]);
// TODO: looks like whatever you try here, you can't get an actual reset of the ep
- if (!WinUsb_AbortPipe(winusb_handle, priv->interface[i].endpoint[j])) {
+ if (!WinUsb_AbortPipe(winusb_handle, priv->usb_interface[i].endpoint[j])) {
usbi_err(ctx, "WinUsb_AbortPipe (pipe address %02X) failed: %s",
- priv->interface[i].endpoint[j], windows_error_str(0));
+ priv->usb_interface[i].endpoint[j], windows_error_str(0));
}
// FlushPipe seems to fail on OUT pipes
- if ( (priv->interface[i].endpoint[j] & LIBUSB_ENDPOINT_IN)
- && (!WinUsb_FlushPipe(winusb_handle, priv->interface[i].endpoint[j])) ) {
+ if ( (priv->usb_interface[i].endpoint[j] & LIBUSB_ENDPOINT_IN)
+ && (!WinUsb_FlushPipe(winusb_handle, priv->usb_interface[i].endpoint[j])) ) {
usbi_err(ctx, "WinUsb_FlushPipe (pipe address %02X) failed: %s",
- priv->interface[i].endpoint[j], windows_error_str(0));
+ priv->usb_interface[i].endpoint[j], windows_error_str(0));
}
- if (!WinUsb_ResetPipe(winusb_handle, priv->interface[i].endpoint[j])) {
+ if (!WinUsb_ResetPipe(winusb_handle, priv->usb_interface[i].endpoint[j])) {
usbi_err(ctx, "WinUsb_ResetPipe (pipe address %02X) failed: %s",
- priv->interface[i].endpoint[j], windows_error_str(0));
+ priv->usb_interface[i].endpoint[j], windows_error_str(0));
}
}
}
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index 8c59c7c..692d2d2 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -134,7 +134,7 @@ struct windows_device_priv {
char *path; // each interface has a path as well
int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
uint8_t *endpoint;
- } interface[USB_MAXINTERFACES];
+ } usb_interface[USB_MAXINTERFACES];
char *driver; // driver name (eg WinUSB, USBSTOR, HidUsb, etc)
struct windows_driver_backend const *apib;
uint8_t active_config;
@@ -153,9 +153,9 @@ static inline void windows_device_priv_init(struct windows_device_priv* p) {
p->config_descriptor = NULL;
memset(&(p->dev_descriptor), 0, sizeof(USB_DEVICE_DESCRIPTOR));
for (i=0; i<USB_MAXINTERFACES; i++) {
- p->interface[i].path = NULL;
- p->interface[i].nb_endpoints = 0;
- p->interface[i].endpoint = NULL;
+ p->usb_interface[i].path = NULL;
+ p->usb_interface[i].nb_endpoints = 0;
+ p->usb_interface[i].endpoint = NULL;
}
}
@@ -169,8 +169,8 @@ static inline void windows_device_priv_release(struct windows_device_priv* p, in
}
safe_free(p->config_descriptor);
for (i=0; i<USB_MAXINTERFACES; i++) {
- safe_free(p->interface[i].path);
- safe_free(p->interface[i].endpoint);
+ safe_free(p->usb_interface[i].path);
+ safe_free(p->usb_interface[i].endpoint);
}
}