summaryrefslogtreecommitdiff
path: root/libusb/descriptor.c
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-14 00:58:30 +0000
committerPete Batard <pbatard@gmail.com>2010-01-14 00:58:30 +0000
commitaa118f2c0215b910eda914392a5585c434a92288 (patch)
tree789d87c82cf8002d5559143733b00996b5ad879c /libusb/descriptor.c
parented8c467fcab8861d67d926a1b5bf33c84b74f247 (diff)
downloadlibusb-aa118f2c0215b910eda914392a5585c434a92288.tar.gz
svn r4: revert back to using interface for variable names as in master branch
Diffstat (limited to 'libusb/descriptor.c')
-rw-r--r--libusb/descriptor.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index dea0bce..00849f6 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -22,6 +22,11 @@
#include <stdlib.h>
#include <string.h>
+/* Prevent compilation problems on Windows platforms */
+#ifdef interface
+#undef interface
+#endif
+
#include "libusbi.h"
#define DESC_HEADER_LENGTH 2
@@ -154,16 +159,16 @@ static int parse_endpoint(struct libusb_context *ctx,
return parsed;
}
-static void clear_interface(struct libusb_interface *iface)
+static void clear_interface(struct libusb_interface *interface)
{
int i;
int j;
- if (iface->altsetting) {
- for (i = 0; i < iface->num_altsetting; i++) {
+ if (interface->altsetting) {
+ for (i = 0; i < interface->num_altsetting; i++) {
struct libusb_interface_descriptor *ifp =
(struct libusb_interface_descriptor *)
- iface->altsetting + i;
+ interface->altsetting + i;
if (ifp->extra)
free((void *) ifp->extra);
if (ifp->endpoint) {
@@ -173,14 +178,14 @@ static void clear_interface(struct libusb_interface *iface)
free((void *) ifp->endpoint);
}
}
- free((void *) iface->altsetting);
- iface->altsetting = NULL;
+ free((void *) interface->altsetting);
+ interface->altsetting = NULL;
}
}
static int parse_interface(libusb_context *ctx,
- struct libusb_interface *iface, unsigned char *buffer, int size,
+ struct libusb_interface *interface, unsigned char *buffer, int size,
int host_endian)
{
int i;
@@ -192,22 +197,22 @@ static int parse_interface(libusb_context *ctx,
struct libusb_interface_descriptor *ifp;
unsigned char *begin;
- iface->num_altsetting = 0;
+ interface->num_altsetting = 0;
while (size >= INTERFACE_DESC_LENGTH) {
struct libusb_interface_descriptor *altsetting =
- (struct libusb_interface_descriptor *) iface->altsetting;
+ (struct libusb_interface_descriptor *) interface->altsetting;
altsetting = realloc(altsetting,
sizeof(struct libusb_interface_descriptor) *
- (iface->num_altsetting + 1));
+ (interface->num_altsetting + 1));
if (!altsetting) {
r = LIBUSB_ERROR_NO_MEM;
goto err;
}
- iface->altsetting = altsetting;
+ interface->altsetting = altsetting;
- ifp = altsetting + iface->num_altsetting;
- iface->num_altsetting++;
+ ifp = altsetting + interface->num_altsetting;
+ interface->num_altsetting++;
usbi_parse_descriptor(buffer, "bbbbbbbbb", ifp, 0);
ifp->extra = NULL;
ifp->extra_length = 0;
@@ -309,18 +314,18 @@ static int parse_interface(libusb_context *ctx,
return parsed;
err:
- clear_interface(iface);
+ clear_interface(interface);
return r;
}
static void clear_configuration(struct libusb_config_descriptor *config)
{
- if (config->iface) {
+ if (config->interface) {
int i;
for (i = 0; i < config->bNumInterfaces; i++)
clear_interface((struct libusb_interface *)
- config->iface + i);
- free((void *) config->iface);
+ config->interface + i);
+ free((void *) config->interface);
}
if (config->extra)
free((void *) config->extra);
@@ -335,7 +340,7 @@ static int parse_configuration(struct libusb_context *ctx,
int size;
int tmp;
struct usb_descriptor_header header;
- struct libusb_interface *iface;
+ struct libusb_interface *interface;
usbi_parse_descriptor(buffer, "bbwbbbbb", config, host_endian);
size = config->wTotalLength;
@@ -346,12 +351,12 @@ static int parse_configuration(struct libusb_context *ctx,
}
tmp = config->bNumInterfaces * sizeof(struct libusb_interface);
- iface = malloc(tmp);
- config->iface = iface;
- if (!config->iface)
+ interface = malloc(tmp);
+ config->interface = interface;
+ if (!config->interface)
return LIBUSB_ERROR_NO_MEM;
- memset(iface, 0, tmp);
+ memset(interface, 0, tmp);
buffer += config->bLength;
size -= config->bLength;
@@ -405,7 +410,7 @@ static int parse_configuration(struct libusb_context *ctx,
}
}
- r = parse_interface(ctx, iface + i, buffer, size, host_endian);
+ r = parse_interface(ctx, interface + i, buffer, size, host_endian);
if (r < 0)
goto err;