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