NAME
libusb20_be_device_foreach – iterate connected USB devices
SYNOPSIS
library “libusb”
#include <libusb20.h>
struct libusb20_device *
libusb20_be_device_foreach(struct libusb20_backend *pbe, struct libusb20_device *pdev);
DESCRIPTION
The libusb20_be_device_foreach function iterates connected USB devices, one device at a time. A backend pointer for pbe may be obtained by calling libusb20_be_alloc_default(3). The starting value of pdev is NULL. Calling libusb20_be_device_foreach again with pdev set to the return value of the previous call yields the next device. To begin interacting with a USB device, pass the pointer in a call to libusb20_dev_open(3).
RETURN VALUES
libusb20_be_device_foreach returns NULL for end of list. Otherwise this is a pointer to the next device.
EXAMPLES
#include <libusb20.h>
struct libusb20_backend *be = libusb20_be_alloc_default(NULL);
struct libusb20_device *device = NULL;
while ( (device = libusb20_be_device_foreach(be, device)) != NULL ) {
if (libusb20_dev_open(device, 0) == LIBUSB20_SUCCESS) {
/* do something */
libusb20_dev_close(device);
}
}
libusb20_be_free(be);
SEE ALSO
libusb20(3), libusb20_be_alloc_default(3), libusb20_be_free(3), libusb20_dev_open(3)