dump.c (874108aed99d76099ff9eb6c8d830479a504c1ad) | dump.c (cf109686d0a89f698ba59a65d3199bdfc151f88a) |
---|---|
1/* $FreeBSD$ */ 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 351 unchanged lines hidden (view full) --- 360 printf("\n"); 361 } 362 } 363 printf("\n"); 364 free(pcfg); 365 } 366 return; 367} | 1/* $FreeBSD$ */ 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 351 unchanged lines hidden (view full) --- 360 printf("\n"); 361 } 362 } 363 printf("\n"); 364 free(pcfg); 365 } 366 return; 367} |
368 369void 370dump_string_by_index(struct libusb20_device *pdev, uint8_t str_index) 371{ 372 char *pbuf; 373 uint8_t n; 374 uint8_t len; 375 376 pbuf = malloc(256); 377 if (pbuf == NULL) 378 err(1, "out of memory"); 379 380 if (str_index == 0) { 381 /* language table */ 382 if (libusb20_dev_req_string_sync(pdev, 383 str_index, 0, pbuf, 256)) { 384 printf("STRING_0x%02x = <read error>\n", str_index); 385 } else { 386 printf("STRING_0x%02x = ", str_index); 387 len = (uint8_t)pbuf[0]; 388 for (n = 0; n != len; n++) { 389 printf("0x%02x%s", (uint8_t)pbuf[n], 390 (n != (len-1)) ? ", " : ""); 391 } 392 printf("\n"); 393 } 394 } else { 395 /* ordinary string */ 396 if (libusb20_dev_req_string_simple_sync(pdev, 397 str_index, pbuf, 256)) { 398 printf("STRING_0x%02x = <read error>\n", str_index); 399 } else { 400 printf("STRING_0x%02x = <%s>\n", str_index, pbuf); 401 } 402 } 403 free(pbuf); 404} |
|