summaryrefslogtreecommitdiffstats
path: root/usr.sbin/usbconfig/dump.c
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2010-01-07 00:50:45 +0000
committerthompsa <thompsa@FreeBSD.org>2010-01-07 00:50:45 +0000
commit8399082d6d51d51e281d46f674bc47cb8cdcc08f (patch)
tree5e7c75c11de880b8d288f02782f128c57659a989 /usr.sbin/usbconfig/dump.c
parent2e14be290b5b8c1dd99a985297642637367d2604 (diff)
downloadFreeBSD-src-8399082d6d51d51e281d46f674bc47cb8cdcc08f.zip
FreeBSD-src-8399082d6d51d51e281d46f674bc47cb8cdcc08f.tar.gz
Sync to p4
- Add new quirks commands and the '-d' option optionally to specify the ugen device. Submitted by: Hans Petter Selasky
Diffstat (limited to 'usr.sbin/usbconfig/dump.c')
-rw-r--r--usr.sbin/usbconfig/dump.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/usr.sbin/usbconfig/dump.c b/usr.sbin/usbconfig/dump.c
index 6dfc6ec..4e527ea 100644
--- a/usr.sbin/usbconfig/dump.c
+++ b/usr.sbin/usbconfig/dump.c
@@ -365,3 +365,40 @@ dump_config(struct libusb20_device *pdev, uint8_t all_cfg)
}
return;
}
+
+void
+dump_string_by_index(struct libusb20_device *pdev, uint8_t str_index)
+{
+ char *pbuf;
+ uint8_t n;
+ uint8_t len;
+
+ pbuf = malloc(256);
+ if (pbuf == NULL)
+ err(1, "out of memory");
+
+ if (str_index == 0) {
+ /* language table */
+ if (libusb20_dev_req_string_sync(pdev,
+ str_index, 0, pbuf, 256)) {
+ printf("STRING_0x%02x = <read error>\n", str_index);
+ } else {
+ printf("STRING_0x%02x = ", str_index);
+ len = (uint8_t)pbuf[0];
+ for (n = 0; n != len; n++) {
+ printf("0x%02x%s", (uint8_t)pbuf[n],
+ (n != (len-1)) ? ", " : "");
+ }
+ printf("\n");
+ }
+ } else {
+ /* ordinary string */
+ if (libusb20_dev_req_string_simple_sync(pdev,
+ str_index, pbuf, 256)) {
+ printf("STRING_0x%02x = <read error>\n", str_index);
+ } else {
+ printf("STRING_0x%02x = <%s>\n", str_index, pbuf);
+ }
+ }
+ free(pbuf);
+}
OpenPOWER on IntegriCloud