blob: 6cd6bf5168f82450099fb4b5e2e0dd82ad2d4f81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
* This file is part of MXE.
* See index.html for further information.
*/
#include <stdio.h>
#include <libusb.h>
int main(int argc, char *argv[])
{
int ret;
ssize_t num_devs;
libusb_context *ctx;
libusb_device **devs;
(void)argc;
(void)argv;
ret = libusb_init(&ctx);
if (ret != LIBUSB_SUCCESS) {
printf("Initialization error: %s.\n", libusb_error_name(ret));
return 1;
}
num_devs = libusb_get_device_list(ctx, &devs);
if (num_devs < 0 || !devs) {
printf("Device list error: %s.\n", libusb_error_name(num_devs));
return 2;
}
printf("Found %d USB devices.\n", (int)num_devs);
libusb_free_device_list(devs, 1);
libusb_exit(ctx);
return 0;
}
|