btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / bin / setusbconfig.cpp
blob6f793797d19c29e369a985535297f35cfdb1cae5
1 #include <stdio.h>
2 #include <string.h>
4 #include <USBKit.h>
7 int
8 main(int argc, char *argv[])
10 if (argc < 3) {
11 printf("usage: %s <device> <configuration index>\n", argv[0]);
12 return 1;
15 BUSBDevice device(argv[1]);
16 if (device.InitCheck() != B_OK) {
17 printf("failed to open device %s\n", argv[1]);
18 return 2;
21 uint32 index;
22 if (sscanf(argv[2], "%lu", &index) != 1) {
23 printf("could not parse configuration index\n");
24 return 3;
27 const BUSBConfiguration *config = device.ConfigurationAt(index);
28 if (config == NULL) {
29 printf("couldn't get configuration at %lu\n", index);
30 return 4;
33 status_t result = device.SetConfiguration(config);
34 if (result != B_OK) {
35 printf("failed to set configuration: %s\n", strerror(result));
36 return 5;
39 printf("configuration %lu set on device %s\n", index, argv[1]);
40 return 0;