1e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* 2e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * libusb-0.1 example program 3e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * Copyright (C) 2008 Daniel Drake <dsd@gentoo.org> 4e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * 5e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * This library is free software; you can redistribute it and/or 6e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * modify it under the terms of the GNU Lesser General Public 7e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * License as published by the Free Software Foundation; either 8e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * version 2.1 of the License, or (at your option) any later version. 9e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * 10e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * This library is distributed in the hope that it will be useful, 11e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * but WITHOUT ANY WARRANTY; without even the implied warranty of 12e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * Lesser General Public License for more details. 14e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * 15e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * You should have received a copy of the GNU Lesser General Public 16e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * License along with this library; if not, write to the Free Software 17e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev */ 19e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev 20e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <stdio.h> 21e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <usb.h> 22e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev 23e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint main(void) 24e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{ 25e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev struct usb_bus *busses; 26e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev struct usb_bus *bus; 27e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev 28e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev usb_init(); 29e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev usb_find_busses(); 30e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev usb_find_devices(); 31e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev 32e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev busses = usb_get_busses(); 33e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev for (bus = busses; bus; bus = bus->next) { 34e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev struct usb_device *dev; 35e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev for (dev = bus->devices; dev; dev = dev->next) { 36e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev printf("%04x:%04x\n", 37e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev dev->descriptor.idVendor, dev->descriptor.idProduct); 38e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev } 39e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev } 40e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev 41e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev return 0; 42e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev} 43e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev 44