WinCE: Fix race between wince_clock_gettime_threaded() and wince_clock_gettime()
[libusbx.git] / libusb / hotplug.h
blob614ddbcff05a9bf0e7cdd3f87e3d5f512f56afa3
1 /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
2 /*
3 * Hotplug support for libusbx
4 * Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
5 * Copyright © 2012-2013 Peter Stuge <peter@stuge.se>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined(USBI_HOTPLUG_H)
23 #define USBI_HOTPLUG_H
25 #ifndef LIBUSBI_H
26 #include "libusbi.h"
27 #endif
29 /** \ingroup hotplug
30 * The hotplug callback structure. The user populates this structure with
31 * libusb_hotplug_prepare_callback() and then calls libusb_hotplug_register_callback()
32 * to receive notification of hotplug events.
34 struct libusb_hotplug_callback {
35 /** Context this callback is associated with */
36 struct libusb_context *ctx;
38 /** Vendor ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
39 int vendor_id;
41 /** Product ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
42 int product_id;
44 /** Device class to match or LIBUSB_HOTPLUG_MATCH_ANY */
45 int dev_class;
47 /** Hotplug callback flags */
48 libusb_hotplug_flag flags;
50 /** Event(s) that will trigger this callback */
51 libusb_hotplug_event events;
53 /** Callback function to invoke for matching event/device */
54 libusb_hotplug_callback_fn cb;
56 /** Handle for this callback (used to match on deregister) */
57 libusb_hotplug_callback_handle handle;
59 /** User data that will be passed to the callback function */
60 void *user_data;
62 /** Callback is marked for deletion */
63 int needs_free;
65 /** List this callback is registered in (ctx->hotplug_cbs) */
66 struct list_head list;
69 typedef struct libusb_hotplug_callback libusb_hotplug_callback;
71 struct libusb_hotplug_message {
72 libusb_hotplug_event event;
73 struct libusb_device *device;
76 typedef struct libusb_hotplug_message libusb_hotplug_message;
78 void usbi_hotplug_deregister_all(struct libusb_context *ctx);
79 void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
80 libusb_hotplug_event event);
82 #endif