1/*
2 * Internal header for libusb-compat-0.1
3 * Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
4 * Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef __LIBUSB_USBI_H__
22#define __LIBUSB_USBI_H__
23
24/* Some quick and generic macros for the simple kind of lists we use */
25#define LIST_ADD(begin, ent) \
26	do { \
27	  if (begin) { \
28	    ent->next = begin; \
29	    ent->next->prev = ent; \
30	  } else \
31	    ent->next = NULL; \
32	  ent->prev = NULL; \
33	  begin = ent; \
34	} while(0)
35
36#define LIST_DEL(begin, ent) \
37	do { \
38	  if (ent->prev) \
39	    ent->prev->next = ent->next; \
40	  else \
41	    begin = ent->next; \
42	  if (ent->next) \
43	    ent->next->prev = ent->prev; \
44	  ent->prev = NULL; \
45	  ent->next = NULL; \
46	} while (0)
47
48struct usb_dev_handle {
49	libusb_device_handle *handle;
50	struct usb_device *device;
51
52	/* libusb-0.1 is buggy w.r.t. interface claiming. it allows you to claim
53	 * multiple interfaces but only tracks the most recently claimed one,
54	 * which is used for usb_set_altinterface(). we clone the buggy behaviour
55	 * here. */
56	int last_claimed_interface;
57};
58
59#endif
60
61