diff options
Diffstat (limited to 'lib/libusb/descr.c')
| -rw-r--r-- | lib/libusb/descr.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/libusb/descr.c b/lib/libusb/descr.c index 8904a871cb11..65b60ce78b82 100644 --- a/lib/libusb/descr.c +++ b/lib/libusb/descr.c @@ -1,4 +1,4 @@ -/* $NetBSD: descr.c,v 1.7 1999/10/13 17:48:04 drochner Exp $ */ +/* $NetBSD: descr.c,v 1.9 2000/09/24 02:13:24 augustss Exp $ */ /* * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> @@ -37,7 +37,9 @@ #include <string.h> #include <unistd.h> #include <sys/time.h> +#if defined(__FreeBSD__) #include <sys/ioctl.h> +#endif #include <dev/usb/usb.h> @@ -45,28 +47,34 @@ #include "usbvar.h" report_desc_t -hid_get_report_desc(fd) - int fd; +hid_get_report_desc(int fd) { struct usb_ctl_report_desc rep; - report_desc_t r; rep.size = 0; if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) - return (0); - r = malloc(sizeof *r + rep.size); + return (NULL); + + return hid_use_report_desc(rep.data, (unsigned int)rep.size); +} + +report_desc_t +hid_use_report_desc(unsigned char *data, unsigned int size) +{ + report_desc_t r; + + r = malloc(sizeof(*r) + size); if (r == 0) { errno = ENOMEM; - return (0); + return (NULL); } - r->size = rep.size; - memcpy(r->data, rep.data, (unsigned int)rep.size); + r->size = size; + memcpy(r->data, data, size); return (r); } void -hid_dispose_report_desc(r) - report_desc_t r; +hid_dispose_report_desc(report_desc_t r) { free(r); |
