summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2008-06-24 23:01:51 -0500
committerDaniel Drake <dsd@gentoo.org>2008-06-26 22:42:59 -0500
commit1df713d622ab4f0b03aad72d903ac7beb8fb3b90 (patch)
tree60d12ab36c2a75dbb80104d956712e6f47c72990 /examples
parent9818151c60a85aea6af24cb0996a92c3726c9864 (diff)
downloadlibusbx-1df713d622ab4f0b03aad72d903ac7beb8fb3b90.tar.gz
Introduce contexts to the API
Suggested by David Zeuthen. This allows multiple libraries in the same process to independently use libusb without interfering.
Diffstat (limited to 'examples')
-rw-r--r--examples/dpfp.c12
-rw-r--r--examples/dpfp_threaded.c12
-rw-r--r--examples/lsusb.c6
3 files changed, 15 insertions, 15 deletions
diff --git a/examples/dpfp.c b/examples/dpfp.c
index 7808184..bd9702a 100644
--- a/examples/dpfp.c
+++ b/examples/dpfp.c
@@ -67,7 +67,7 @@ static int do_exit = 0;
static int find_dpfp_device(void)
{
- devh = libusb_open_device_with_vid_pid(0x05ba, 0x000a);
+ devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a);
return devh ? 0 : -EIO;
}
@@ -347,7 +347,7 @@ static int init_capture(void)
if (r < 0) {
libusb_cancel_transfer(irq_transfer);
while (irq_transfer)
- if (libusb_handle_events() < 0)
+ if (libusb_handle_events(NULL) < 0)
break;
return r;
}
@@ -419,7 +419,7 @@ int main(void)
struct sigaction sigact;
int r = 1;
- r = libusb_init();
+ r = libusb_init(NULL);
if (r < 0) {
fprintf(stderr, "failed to initialise libusb\n");
exit(1);
@@ -464,7 +464,7 @@ int main(void)
sigaction(SIGQUIT, &sigact, NULL);
while (!do_exit) {
- r = libusb_handle_events();
+ r = libusb_handle_events(NULL);
if (r < 0)
goto out_deinit;
}
@@ -484,7 +484,7 @@ int main(void)
}
while (irq_transfer || img_transfer)
- if (libusb_handle_events() < 0)
+ if (libusb_handle_events(NULL) < 0)
break;
if (do_exit == 1)
@@ -501,7 +501,7 @@ out_release:
libusb_release_interface(devh, 0);
out:
libusb_close(devh);
- libusb_exit();
+ libusb_exit(NULL);
return r >= 0 ? r : -r;
}
diff --git a/examples/dpfp_threaded.c b/examples/dpfp_threaded.c
index 2d106d3..59540e3 100644
--- a/examples/dpfp_threaded.c
+++ b/examples/dpfp_threaded.c
@@ -83,7 +83,7 @@ static void *poll_thread_main(void *arg)
while (!do_exit) {
struct timeval tv = { 1, 0 };
- r = libusb_handle_events_timeout(&tv);
+ r = libusb_handle_events_timeout(NULL, &tv);
if (r < 0) {
request_exit(2);
break;
@@ -96,7 +96,7 @@ static void *poll_thread_main(void *arg)
static int find_dpfp_device(void)
{
- devh = libusb_open_device_with_vid_pid(0x05ba, 0x000a);
+ devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a);
return devh ? 0 : -EIO;
}
@@ -374,7 +374,7 @@ static int init_capture(void)
if (r < 0) {
libusb_cancel_transfer(irq_transfer);
while (irq_transfer)
- if (libusb_handle_events() < 0)
+ if (libusb_handle_events(NULL) < 0)
break;
return r;
}
@@ -446,7 +446,7 @@ int main(void)
struct sigaction sigact;
int r = 1;
- r = libusb_init();
+ r = libusb_init(NULL);
if (r < 0) {
fprintf(stderr, "failed to initialise libusb\n");
exit(1);
@@ -522,7 +522,7 @@ int main(void)
}
while (img_transfer || irq_transfer)
- if (libusb_handle_events() < 0)
+ if (libusb_handle_events(NULL) < 0)
break;
if (do_exit == 1)
@@ -539,7 +539,7 @@ out_release:
libusb_release_interface(devh, 0);
out:
libusb_close(devh);
- libusb_exit();
+ libusb_exit(NULL);
return r >= 0 ? r : -r;
}
diff --git a/examples/lsusb.c b/examples/lsusb.c
index 5a83020..7e9f48e 100644
--- a/examples/lsusb.c
+++ b/examples/lsusb.c
@@ -47,18 +47,18 @@ int main(void)
int r;
ssize_t cnt;
- r = libusb_init();
+ r = libusb_init(NULL);
if (r < 0)
return r;
- cnt = libusb_get_device_list(&devs);
+ cnt = libusb_get_device_list(NULL, &devs);
if (cnt < 0)
return (int) cnt;
print_devs(devs);
libusb_free_device_list(devs, 1);
- libusb_exit();
+ libusb_exit(NULL);
return 0;
}