Exemple #1
0
static void print_devs(libusb_device **devs)
{
	libusb_device *dev;
	int i = 0;
	int err;
	char path_to_usbids[] = "./usb.ids";
	const char *str;

	err = names_init(path_to_usbids);
	if (err != 0) {
	    printf("open %s failed\n", path_to_usbids);
	}

	while ((dev = devs[i++]) != NULL) {
		struct libusb_device_descriptor desc;
		int r = libusb_get_device_descriptor(dev, &desc);
		if (r < 0) {
			fprintf(stderr, "failed to get device descriptor");
			return;
		}

		printf("Bus %03d Device %03d: ID %04x:%04x %s",
		        libusb_get_bus_number(dev), libusb_get_device_address(dev),
			desc.idVendor, desc.idProduct,
			names_vendor(desc.idVendor));
		
		if ((str = names_product(desc.idVendor, desc.idProduct)) != NULL) {
		    printf(" %s", str);
		}
		printf("\n");
	}
	
	names_exit();
}
Exemple #2
0
int get_vendor_string(char *buf, size_t size, u_int16_t vid)
{
        const char *cp;

        if (size < 1)
                return 0;
        *buf = 0;
        if (!(cp = names_vendor(vid)))
                return 0;
        return snprintf(buf, size, "%s", cp);
}
Exemple #3
0
void usbip_product_name(char *buff, size_t size, uint16_t vendor, uint16_t product)
{
	const char *prod, *vend;

	prod = names_product(vendor, product);
	if(!prod)
		prod = "unknown product";


	vend = names_vendor(vendor);
	if(!vend)
		vend = "unknown vendor";

	snprintf(buff, size, "%s : %s (%04x:%04x)", vend, prod, vendor, product);
}