Rename extract_data to extract_iso_data, add extract_data for use by

other transfer types.
This commit is contained in:
Sebastian Zagrodzki
2017-02-10 21:45:26 +01:00
parent 9018981e65
commit 9e50cd8c1c
2 changed files with 26 additions and 1 deletions

View File

@@ -64,7 +64,26 @@ void print_xfer(struct libusb_transfer *xfer) {
}
}
// extract data from a non-isochronous transfer.
int extract_data(struct libusb_transfer *xfer, void *raw, int max, unsigned char *status) {
int i;
unsigned char *in = xfer->buffer;
unsigned char *out = raw;
int len = xfer->actual_length;
if (len > max) {
len = max;
}
memcpy(out, in, len);
if (xfer->status != 0 && *status == 0) {
*status = xfer->status;
}
return len;
}
// extract data from an isochronous transfer. Very similar to extract_data, but
// acquires data from xfer->iso_packet_desc array instead of xfer attributes.
int extract_iso_data(struct libusb_transfer *xfer, void *raw, int max, unsigned char *status) {
int i;
int copied = 0;
unsigned char *in = xfer->buffer;