* Compacted some of the code and inlined the DumpRoster implementation into the

class as it's so little code.
* No need to allocate the roster on the heap.
* Add /dev/bus/usb to the device location to make it more clear.
* Add the device location to the non-verbose output as well.
* Put the manufacturer and product strings into quotes to make it clearer that
  those are just strings. Avoids just blank output when a device doesn't provide
  those strings.
* Remove trailing whitespace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29187 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-02-12 23:05:57 +00:00
parent f7de06baf3
commit 576cd2495d
+22 -34
View File
@@ -95,8 +95,15 @@ DumpConfiguration(const BUSBConfiguration *configuration)
static void static void
DumpInfo(BUSBDevice &device, bool verbose) DumpInfo(BUSBDevice &device, bool verbose)
{ {
if (verbose) { if (!verbose) {
printf("[Device %s]\n", device.Location()); printf("%04x:%04x /dev/bus/usb%s \"%s\" \"%s\" ver. %04x\n",
device.VendorID(), device.ProductID(), device.Location(),
device.ManufacturerString(), device.ProductString(),
device.Version());
return;
}
printf("[Device /dev/bus/usb%s]\n", device.Location());
printf(" Class .................. 0x%02x\n", device.Class()); printf(" Class .................. 0x%02x\n", device.Class());
printf(" Subclass ............... 0x%02x\n", device.Subclass()); printf(" Subclass ............... 0x%02x\n", device.Subclass());
printf(" Protocol ............... 0x%02x\n", device.Protocol()); printf(" Protocol ............... 0x%02x\n", device.Protocol());
@@ -113,48 +120,30 @@ DumpInfo(BUSBDevice &device, bool verbose)
printf(" [Configuration %lu]\n", i); printf(" [Configuration %lu]\n", i);
DumpConfiguration(device.ConfigurationAt(i)); DumpConfiguration(device.ConfigurationAt(i));
} }
} else {
printf("%04x:%04x %s %s (version %04x)\n", device.VendorID(), device.ProductID(), device.ManufacturerString(), device.ProductString(), device.Version());
}
} }
class DumpRoster : public BUSBRoster
{ class DumpRoster : public BUSBRoster {
public: public:
DumpRoster(bool verbose); DumpRoster(bool verbose)
~DumpRoster(); : fVerbose(verbose)
virtual status_t DeviceAdded(BUSBDevice *device);
virtual void DeviceRemoved(BUSBDevice *device);
private:
bool fVerbose;
};
DumpRoster::DumpRoster(bool verbose)
: BUSBRoster(),
fVerbose(verbose)
{ {
} }
virtual status_t DeviceAdded(BUSBDevice *device)
DumpRoster::~DumpRoster()
{
}
status_t
DumpRoster::DeviceAdded(BUSBDevice *device)
{ {
DumpInfo(*device, fVerbose); DumpInfo(*device, fVerbose);
return B_OK; return B_OK;
} }
void virtual void DeviceRemoved(BUSBDevice *device)
DumpRoster::DeviceRemoved(BUSBDevice *)
{ {
} }
private:
bool fVerbose;
};
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
@@ -186,10 +175,9 @@ main(int argc, char *argv[])
return 0; return 0;
} }
} else { } else {
DumpRoster *roster = new DumpRoster(verbose); DumpRoster roster(verbose);
roster->Start(); roster.Start();
roster->Stop(); roster.Stop();
delete roster;
} }
return 0; return 0;