cvsdist 3c9f1bd
--- usbutils-0.11/names.c.hidcc	2002-06-17 11:13:47.000000000 +0200
cvsdist 3c9f1bd
+++ usbutils-0.11/names.c	2004-09-01 10:53:12.716443518 +0200
cvsdist 3c9f1bd
@@ -116,6 +116,7 @@
cvsdist 3c9f1bd
 static struct genericstrtable *physdess[HASHSZ] = { NULL, };
cvsdist 3c9f1bd
 static struct genericstrtable *hutus[HASHSZ] = { NULL, };
cvsdist 3c9f1bd
 static struct genericstrtable *langids[HASHSZ] = { NULL, };
cvsdist 3c9f1bd
+static struct genericstrtable *countrycodes[HASHSZ] = { NULL, };
cvsdist 3c9f1bd
 
cvsdist 3c9f1bd
 /* ---------------------------------------------------------------------- */
cvsdist 3c9f1bd
 
cvsdist 3c9f1bd
@@ -164,6 +165,11 @@
cvsdist 3c9f1bd
 	return names_genericstrtable(biass, b);
cvsdist 3c9f1bd
 }
cvsdist 3c9f1bd
 
cvsdist 3c9f1bd
+const char *names_countrycode(unsigned int countrycode)
cvsdist 3c9f1bd
+{
cvsdist 3c9f1bd
+	return names_genericstrtable(countrycodes, countrycode);
cvsdist 3c9f1bd
+}
cvsdist 3c9f1bd
+
cvsdist 3c9f1bd
 const char *names_vendor(u_int16_t vendorid)
cvsdist 3c9f1bd
 {
cvsdist 3c9f1bd
 	struct vendor *v;
cvsdist 3c9f1bd
@@ -402,6 +408,11 @@
cvsdist 3c9f1bd
 	return new_genericstrtable(biass, name, b);
cvsdist 3c9f1bd
 }
cvsdist 3c9f1bd
 
cvsdist 3c9f1bd
+static int new_countrycode(const char *name, unsigned int countrycode)
cvsdist 3c9f1bd
+{
cvsdist 3c9f1bd
+	return new_genericstrtable(countrycodes, name, countrycode);
cvsdist 3c9f1bd
+}
cvsdist 3c9f1bd
+
cvsdist 3c9f1bd
 /* ---------------------------------------------------------------------- */
cvsdist 3c9f1bd
 
cvsdist 3c9f1bd
 #define DBG(x) 
cvsdist 3c9f1bd
@@ -553,6 +564,27 @@
cvsdist 3c9f1bd
 			DBG(printf("line %5u audio terminal type %02x %s\n", linectr, u, cp));
cvsdist 3c9f1bd
 			continue;
cvsdist 3c9f1bd
 		}
cvsdist 3c9f1bd
+		if (buf[0] == 'H' && buf[1] == 'C' && buf[2] == 'C' && isspace(buf[3])) {
cvsdist 3c9f1bd
+			/* HID Descriptor bCountryCode */
cvsdist 3c9f1bd
+                        cp =  buf+3;
cvsdist 3c9f1bd
+                        while (isspace(*cp))
cvsdist 3c9f1bd
+                                cp++;
cvsdist 3c9f1bd
+                        if (!isxdigit(*cp)) {
cvsdist 3c9f1bd
+                                fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
cvsdist 3c9f1bd
+                                continue;
cvsdist 3c9f1bd
+                        }
cvsdist 3c9f1bd
+                        u = strtoul(cp, &cp, 10);
cvsdist 3c9f1bd
+                        while (isspace(*cp))
cvsdist 3c9f1bd
+                                cp++;
cvsdist 3c9f1bd
+                        if (!*cp) {
cvsdist 3c9f1bd
+                                fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
cvsdist 3c9f1bd
+                                continue;
cvsdist 3c9f1bd
+                        }
cvsdist 3c9f1bd
+                        if (new_countrycode(cp, u))
cvsdist 3c9f1bd
+                                fprintf(stderr, "Duplicate HID country code at line %u country %02u %s\n", linectr, u, cp);
cvsdist 3c9f1bd
+                        DBG(printf("line %5u keyboard country code %02u %s\n", linectr, u, cp));
cvsdist 3c9f1bd
+                        continue;
cvsdist 3c9f1bd
+		}
cvsdist 3c9f1bd
 		if (isxdigit(*cp)) {
cvsdist 3c9f1bd
 			/* vendor */
cvsdist 3c9f1bd
 			u = strtoul(cp, &cp, 16);
cvsdist 3c9f1bd
--- usbutils-0.11/names.h.hidcc	2000-11-06 16:00:06.000000000 +0100
cvsdist 3c9f1bd
+++ usbutils-0.11/names.h	2004-09-01 10:53:14.097253193 +0200
cvsdist 3c9f1bd
@@ -44,6 +44,7 @@
cvsdist 3c9f1bd
 extern const char *names_langid(u_int16_t langid);
cvsdist 3c9f1bd
 extern const char *names_physdes(u_int8_t ph);
cvsdist 3c9f1bd
 extern const char *names_bias(u_int8_t b);
cvsdist 3c9f1bd
+extern const char *names_countrycode(unsigned int countrycode);
cvsdist 3c9f1bd
 extern int names_init(char *n);
cvsdist 3c9f1bd
 
cvsdist 3c9f1bd
 /* ---------------------------------------------------------------------- */
cvsdist 3c9f1bd
--- usbutils-0.11/lsusb.c.hidcc	2004-08-30 17:57:04.000000000 +0200
cvsdist 3c9f1bd
+++ usbutils-0.11/lsusb.c	2004-09-01 11:03:48.208861173 +0200
cvsdist 3c9f1bd
@@ -1205,9 +1205,9 @@
cvsdist 3c9f1bd
 	       "          bLength             %5u\n"
cvsdist 3c9f1bd
 	       "          bDescriptorType     %5u\n"
cvsdist 3c9f1bd
 	       "          bcdHID              %2x.%02x\n"
cvsdist 3c9f1bd
-	       "          bCountryCode        %5u\n"
cvsdist 3c9f1bd
+	       "          bCountryCode        %5u %s\n"
cvsdist 3c9f1bd
 	       "          bNumDescriptors     %5u\n",
cvsdist 3c9f1bd
-	       buf[0], buf[1], buf[3], buf[2], buf[4], buf[5]);
cvsdist 3c9f1bd
+	       buf[0], buf[1], buf[3], buf[2], buf[4], names_countrycode(buf[4]) ? : "Unknown", buf[5]);
cvsdist 3c9f1bd
 	for (i = 0; i < buf[5]; i++)
cvsdist 3c9f1bd
 		printf("          bDescriptorType     %5u %s\n"
cvsdist 3c9f1bd
 		       "          wDescriptorLength   %5u\n",