summaryrefslogtreecommitdiffstats
path: root/generate_usbclass.pl
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-12-16 18:22:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-12-16 18:22:32 +0000
commit1f8893a6cd761f9ef87d4cb9c8d8baecf17b4352 (patch)
tree9db1d895d506145757dff083c0f75ec3252d30f2 /generate_usbclass.pl
parent9f8ce02a3814161d80ae8430282eeb58ae75cbb8 (diff)
downloadldetect-1f8893a6cd761f9ef87d4cb9c8d8baecf17b4352.tar
ldetect-1f8893a6cd761f9ef87d4cb9c8d8baecf17b4352.tar.gz
ldetect-1f8893a6cd761f9ef87d4cb9c8d8baecf17b4352.tar.bz2
ldetect-1f8893a6cd761f9ef87d4cb9c8d8baecf17b4352.tar.xz
ldetect-1f8893a6cd761f9ef87d4cb9c8d8baecf17b4352.zip
now detect usb
Diffstat (limited to 'generate_usbclass.pl')
-rwxr-xr-xgenerate_usbclass.pl35
1 files changed, 35 insertions, 0 deletions
diff --git a/generate_usbclass.pl b/generate_usbclass.pl
new file mode 100755
index 0000000..a503e85
--- /dev/null
+++ b/generate_usbclass.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+print q(/* This auto-generated from <usb.h>, don't modify! */
+
+struct {
+ unsigned short id;
+ const char *name;
+} usbclasses[] = {
+);
+
+while (<>) {
+ chomp;
+ if (/^C\s+(\d+)\s+(.*)/) {
+ ($cat, $descr) = ($1, $2);
+ } elsif (/^\t\t(\d+)\s+(.*)/ && defined $cat) {
+ print qq( { 0x$cat$1, "$descr|$2" },\n);
+ } elsif (/^\S/) {
+ undef $cat;
+ }
+}
+
+print '
+};
+
+int nb_usbclasses = sizeof(usbclasses) / sizeof(*usbclasses);
+
+extern const char *usb_class2text(unsigned short class) {
+ int i;
+ for (i = 0; i < nb_usbclasses; i++)
+ if (usbclasses[i].id == class) return usbclasses[i].name;
+
+ return "";
+}
+
+';