topin.pl
568 Bytes
#!/usr/bin/perl -w
$in = $ARGV[0];
open(IN, "strings --bytes=2 $in |") || die "open failed $in: $!";
$a=0;
while(<IN>) {
chomp;
s/\s*//;
next if (length $_ < 2);
next if (/[^A-Z:0-9[\]_]/);
if ($a eq 0) {
$name=$_;
$a = 1;
} else {
$a = 0;
if ($_ ne "IN" && $_ ne "INPUT" && $_ ne "OUT" && $_ ne "OUTPUT" && $_ ne "BIDIR") {
printf "unknown type: %-20s\t%s\n", $name, $_;
exit(1);
}
$_ = "OUT" if ($_ eq "OUTPUT");
$_ = "IN" if ($_ eq "INPUT");
$_ = "INOUT" if ($_ eq "BIDIR");
printf "%-20s\t%s\n", $name, $_;
}
}