summaryrefslogtreecommitdiffstats
path: root/generate_usbclass.pl
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-11-22 23:16:03 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-11-22 23:16:03 +0000
commit58a7b19643a0ab2920b01149251e9d0e5b6a9d8e (patch)
tree28a1ca83a2b768fa6408abb33d702560c0e9ed16 /generate_usbclass.pl
parente18a021172c5280ca948eeb69d5df82678350ba1 (diff)
downloadldetect-58a7b19643a0ab2920b01149251e9d0e5b6a9d8e.tar
ldetect-58a7b19643a0ab2920b01149251e9d0e5b6a9d8e.tar.gz
ldetect-58a7b19643a0ab2920b01149251e9d0e5b6a9d8e.tar.bz2
ldetect-58a7b19643a0ab2920b01149251e9d0e5b6a9d8e.tar.xz
ldetect-58a7b19643a0ab2920b01149251e9d0e5b6a9d8e.zip
- don't limitate to CLASS ID's with a Protocol number
- fix bug that made ID's with a-f not appear (\d not very good to parse hexadecimal)
Diffstat (limited to 'generate_usbclass.pl')
-rwxr-xr-xgenerate_usbclass.pl19
1 files changed, 13 insertions, 6 deletions
diff --git a/generate_usbclass.pl b/generate_usbclass.pl
index 50fe13b..ae85164 100755
--- a/generate_usbclass.pl
+++ b/generate_usbclass.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-print q(/* This auto-generated from <usb.h>, don't modify! */
+print q(/* This is auto-generated from </usr/share/usb.ids>, don't modify! */
struct {
unsigned long id;
@@ -10,18 +10,25 @@ struct {
while (<>) {
chomp;
- if (/^C\s+(\d+)\s+(.*)/) {
+ if (/^C\s+([\da-f]+)\s+(.*)/) { #- I want alphanumeric but I can't get this [:alnum:] to work :-(
($cat, $cat_descr) = ($1, $2);
- } elsif (/^\t(\d+)\s+(.*)/ && defined $cat) {
+ } elsif (/^\t([\da-f]+)\s+(.*)/ && defined $cat) {
($sub, $sub_descr) = ($1, $2);
- $sub =~ /^\d\d$/ or die "bad line $.: sub category number badly formatted ($_)\n";
- } elsif (/^\t\t(\d+)\s+(.*)/ && defined $cat) {
- print qq(/* $. */ { 0x$cat$sub$1, "$cat_descr|$sub_descr|$2" },\n);
+ $sub =~ /^[\da-f]{2}$/ or die "bad line $.: sub category number badly formatted ($_)\n";
+ push @without_prot, [ "0x$cat$sub"."00", "/* $. */ { 0x$cat$sub".qq(00, "$cat_descr|$sub_descr" },\n) ];
+ } elsif (/^\t\t([\da-f]+)\s+(.*)/ && defined $cat) {
+ push @everything, qq(/* $. */ { 0x$cat$sub$1, "$cat_descr|$sub_descr|$2" },\n);
} elsif (/^\S/) {
undef $cat;
}
}
+foreach $l (@without_prot) {
+ grep { /{ $l->[0], / } @everything or push @everything, $l->[1];
+}
+
+print sort @everything;
+
print '
};