create_Info_plist.pl [plain text]
use warnings;
use strict;
use Getopt::Long;
my (@manuf, @product, @name);
my ($manuf, $product, $name);
my $target = "libccid.so";
my $version = "1.0.0";
my $class = "<key>CFBundleName</key>
<string>CCIDCLASSDRIVER</string>";
my $noclass = 0;
GetOptions(
"target=s" => \$target,
"version=s" => \$version,
"no-class" => \$noclass);
if (${
print "usage: $0 supported_readers.txt Info.plist
--target=$target
--version=$version\n";
exit;
}
open IN, "< $ARGV[0]" or die "Can't open $ARGV[0]: $!";
while (<IN>)
{
next if (m/^ next if (m/^$/);
chomp;
($manuf, $product, $name) = split /:/;
push @manuf, $manuf;
push @product, $product;
$name =~ s/&/&/g;
push @name, $name
}
close IN;
map { $_ = "\t\t<string>$_</string>\n" } @manuf;
map { $_ = "\t\t<string>$_</string>\n" } @product;
map { $_ = "\t\t<string>$_</string>\n" } @name;
open IN, "< $ARGV[1]" or die "Can't open $ARGV[1]: $!";
while (<IN>)
{
if (m/MAGIC_VENDOR/)
{
print @manuf;
next;
}
if (m/MAGIC_PRODUCT/)
{
print @product;
next;
}
if (m/MAGIC_FRIENDLYNAME/)
{
print @name;
next;
}
if (m/MAGIC_TARGET/)
{
s/MAGIC_TARGET/$target/;
print;
next;
}
if (m/MAGIC_VERSION/)
{
s/MAGIC_VERSION/$version/;
print;
next;
}
if (m/MAGIC_CLASS/)
{
next if ($noclass);
s/MAGIC_CLASS/$class/;
print;
next;
}
print;
}
close IN;