--- /var/tmp/portage/usbutils-0.11-r3/work/usbutils-0.11/lsusb.c 2002-08-06 08:35:21.000000000 +0200 +++ /var/tmp/portage/usbutils-0.11-r3/work/usbutils-0.11/lsusb.c 2004-03-02 17:36:58.394072736 +0100 @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef HAVE_LINUX_USBDEVICE_FS_H @@ -76,6 +77,15 @@ static void dump_junk2(unsigned char *, unsigned int); +static int to_me(int x) +{ +#ifndef __BIG_ENDIAN__ + return x; +#else + return (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8); +#endif +} + /* ---------------------------------------------------------------------- */ int lprintf(unsigned int vl, const char *format, ...) @@ -293,7 +303,7 @@ " iSerial %5u %s\n" " bNumConfigurations %5u\n", buf[0], buf[1], buf[3], buf[2], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], - vid, vendor, pid, product, buf[13], buf[12], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); + to_me(vid), vendor, to_me(pid), product, buf[13], buf[12], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); dump_junk(buf, " ", 18); } @@ -1374,7 +1384,7 @@ pid = buf[10] | (buf[11] << 8); get_vendor_string(vendor, sizeof(vendor), vid); get_product_string(product, sizeof(product), vid, pid); - printf("Device: ID %04x:%04x %s %s\n", vid, pid, vendor, product); + printf("Device: ID %04x:%04x %s %s\n", to_me(vid), to_me(pid), vendor, product); dumpdev(buf, fd, flags); status=0; err: @@ -1432,7 +1442,7 @@ get_product_string(product, sizeof(product), vid, pid); if (verblevel > 0) printf("\n"); - printf("Bus %s Device %s: ID %04x:%04x %s %s\n", de->d_name, de2->d_name, vid, pid, vendor, product); + printf("Bus %s Device %s: ID %04x:%04x %s %s\n", de->d_name, de2->d_name, to_me(vid), to_me(pid), vendor, product); if (verblevel > 0) dumpdev(buf, fd, flags); err: