summaryrefslogtreecommitdiff
path: root/tools/epson2usb.pl
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-31 17:00:58 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-31 17:00:58 +0200
commitd087d778ffb62e2713cb848540bcc819470365bd (patch)
treed69692a274dd1c7d0672e6bb7155a0fc106f9d49 /tools/epson2usb.pl
parentc8bd2513ecba169cff44c09c8058c36987357b18 (diff)
parent3759ce55ba79b8d3b9d8ed247a252273ee7dade3 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tools/epson2usb.pl')
-rwxr-xr-xtools/epson2usb.pl61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/epson2usb.pl b/tools/epson2usb.pl
new file mode 100755
index 0000000..6d542d7
--- /dev/null
+++ b/tools/epson2usb.pl
@@ -0,0 +1,61 @@
+#!/usr/bin/perl -w
+
+# Creates an USB device list from the description file
+#
+# epson2usb.pl doc/descriptions/epson2.desc
+#
+# Copyright (C) 2010 Tower Technologies
+# Author: Alessandro Zummo <a.zummo@towertech.it>
+#
+# This file is part of the SANE package.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, version 2.
+
+use strict;
+use warnings;
+
+ my %ids;
+ my @models;
+ my $i = 0;
+
+ while (<>) {
+
+ my $flip = /^:model/ ... /^$/;
+
+ $models[$i]{$1} = $2
+ if /^:(\w+)\s+(.+)/;
+
+ $i++
+ if $flip =~ /E0$/;
+ }
+
+ foreach my $m (@models) {
+
+ next unless defined $m->{'usbid'};
+ next if $m->{'status'} eq ':unsupported';
+
+# print $m->{'model'} , "\n";
+# print "-", $m->{'usbid'} , "-\n";
+
+ next unless $m->{'usbid'} =~ /"0x04b8"\s+"(0x[[:xdigit:]]+)"/;
+
+ my $id = $1;
+
+# print $id, "\n";
+
+ $id =~ s/0x0/0x/;
+
+ $m->{'model'} =~ s/;.+$//;
+ $m->{'model'} =~ s/\"//g;
+ $m->{'model'} =~ s/\s+$//;
+
+ push(@{$ids{$id}}, $m->{'model'});
+ }
+
+ foreach (sort keys %ids) {
+ print ' ', $_, ', /* ';
+ print join(', ', @{$ids{$_}});
+ print " */\n";
+ }