File: driver_name.cpp

package info (click to toggle)
libusb 2%3A0.1.12-13
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,172 kB
  • ctags: 483
  • sloc: sh: 8,374; ansic: 2,626; cpp: 960; makefile: 225
file content (63 lines) | stat: -rw-r--r-- 1,645 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// -*- C++;indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
/*
 * driver_name.cpp
 *
 *  Test suite program for C++ bindings
 */

#include <iostream>
#include <iomanip>
#include <usbpp.h>

using namespace std;

int main(void)
{
	USB::Busses buslist; 

	cout << "bus/device  idVendor/idProduct" << endl;

	//  buslist.init();

	USB::Bus *bus;
	list<USB::Bus *>::const_iterator biter;
	USB::Device *device;
	list<USB::Device *>::const_iterator diter;
	int i, j;
	int retval;
	string driver;

	for (biter = buslist.begin(); biter != buslist.end(); biter++) {
		bus = *biter;

		for (diter = bus->begin(); diter != bus->end(); diter++) {
			device = *diter;

			USB::Configuration *this_Configuration;
			this_Configuration = device->firstConfiguration();
			for (i=0; i < device->numConfigurations(); i++) {
				USB::Interface *this_Interface;
				this_Interface = this_Configuration->firstInterface();
				for (j=0; j < this_Configuration->numInterfaces(); j++) {
					retval = this_Interface->driverName(driver);
					if (0 == retval) {
						cout << bus->directoryName() << "/" 
							 << device->fileName() << "     "
							 << uppercase << hex << setw(4) << setfill('0')
							 << device->idVendor() << "/"
							 << uppercase << hex << setw(4) << setfill('0')
							 << device->idProduct() << "    "
							 << "driver: " << driver << endl;
					} else {
						cout << "fetching driver string failed (" << retval << "): " << usb_strerror() << endl;
						return EXIT_FAILURE;
					}
					this_Interface = this_Configuration->nextInterface();
				}
				this_Configuration = device->nextConfiguration();
			}
		}
	}

	return 0;
}