libusb20_be_device_foreach(3)

libusb20_be_device_foreach3

Iterate connected usb devices

Usage

library “libusb”

#include <libusb20.h>

struct libusb20_device *

libusb20_be_device_foreach(struct libusb20_backend *pbe, struct libusb20_device *pdev);

Overview

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);

Releases

36 releases since FreeBSD 8.3-RELEASE; the text changed 27 times.

  1. 8.3
  2. 8.4
  3. 9.0
  4. 9.1
  5. 9.2
  6. 9.3
  7. 10.0
  8. 10.1
  9. 10.2
  10. 10.3
  11. 10.4
  12. 11.0
  13. 11.1
  14. 11.2
  15. 11.3
  16. 11.4
  17. 12.0
  18. 12.1
  19. 12.2
  20. 12.3
  21. 12.4
  22. 13.0–13.2
  23. 13.3–14.3
  24. 14.4
  25. 14.5
  26. 15.0
  27. 15.1
  28. 16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.