1#!/usr/bin/perl -w 2 3# Creates an USB device list from the description file 4# 5# epson2usb.pl doc/descriptions/epson2.desc 6# 7# Copyright (C) 2010 Tower Technologies 8# Author: Alessandro Zummo <a.zummo@towertech.it> 9# 10# This file is part of the SANE package. 11# 12# This program is free software; you can redistribute it and/or 13# modify it under the terms of the GNU General Public License as 14# published by the Free Software Foundation, version 2. 15 16use strict; 17use warnings; 18 19 my %ids; 20 my @models; 21 my $i = 0; 22 23 while (<>) { 24 25 my $flip = /^:model/ ... /^$/; 26 27 $models[$i]{$1} = $2 28 if /^:(\w+)\s+(.+)/; 29 30 $i++ 31 if $flip =~ /E0$/; 32 } 33 34 foreach my $m (@models) { 35 36 next unless defined $m->{'usbid'}; 37 next if $m->{'status'} eq ':unsupported'; 38 39# print $m->{'model'} , "\n"; 40# print "-", $m->{'usbid'} , "-\n"; 41 42 next unless $m->{'usbid'} =~ /"0x04b8"\s+"(0x[[:xdigit:]]+)"/; 43 44 my $id = $1; 45# print $id, "\n"; 46 47 $m->{'model'} =~ s/;.+$//; 48 $m->{'model'} =~ s/\"//g; 49 $m->{'model'} =~ s/\s+$//; 50 51 push(@{$ids{$id}}, $m->{'model'}); 52 } 53 54 foreach (sort keys %ids) { 55 print ' ', $_, ', /* '; 56 print join(', ', @{$ids{$_}}); 57 print " */\n"; 58 } 59