3 # USAGE: $0 </path/to/libgphoto2/camlibs/ptp2>
8 # Extracts USB devices from libgphoto2
9 # This is then parsed by make-usb.py to make epan/dissectors/usb.c
11 # (c)2013 Max Baker <max@warped.org>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; either version 2
16 # of the License, or (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 my $path = shift @ARGV || '.';
29 $re_hex = '0x[0-9a-f]+';
31 parse_file
("$path/library.c",1);
32 parse_file
("$path/music-players.h",0);
34 open (O
,"> tools/usb-ptp-extract-models.txt") or die $!;
36 foreach my $vendor (sort {hex($a) <=> hex($b)} keys %devices) {
37 my $p = $devices{$vendor};
38 foreach my $product (sort {hex($a) <=> hex($b)} keys %$p) {
39 my $pd = $product; $pd =~ s/^0x//i;
40 my $v = $vendor; $v =~ s/^0x//i;
41 # { 0xeb1ae355, "KWorld DVB-T 355U Digital TV Dongle" },
42 #printf " { 0x%s%s, \"%s\" },\n",$v, $pd, $p->{$product};
44 printf O
"%s%s %s\n", $v, $pd, $p->{$product};
58 open (H
,"<$file") or die "Could not find $file. $!";
62 # Look for models[] line as start
68 # Look for }; as the end
69 $start = 0 if /^\s*};/;
86 my ($model, $vendor, $product, $manif);
88 # {"Nikon:DSC D90 (PTP mode)", 0x04b0, 0x0421, PTP_CAP|PTP_CAP_PREVIEW},
95 ($model, $vendor, $product) = ($1,$2,$3);
99 # { "Creative
", 0x041e, "ZEN X
-Fi
3", 0x4169,
100 # { "TrekStor
", 0x0402, "i
.Beat Sweez FM
", 0x0611,
107 ($manif, $vendor, $model, $product) = ($1,$2,$3,$4);
108 $model = "$manif $model";
111 next unless defined $vendor;
116 #print "$vendor $product $model\n";
117 $devices{$vendor}->{$product}=$model;