mirror of
https://github.com/BishopFox/theos-jailed.git
synced 2026-11-07 10:25:57 -10:00
From: Dustin L. Howett <[email protected]> git-svn-id: http://svn.howett.net/svn/theos/trunk@642 4410221e-0ddf-4ce3-99c0-2db6c0dbc727
49 lines
1022 B
Perl
Executable File
49 lines
1022 B
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
use FindBin;
|
|
use lib "$FindBin::Bin/lib";
|
|
|
|
use NIC::NICBase;
|
|
|
|
use Module::Load::Conditional 'can_load';
|
|
|
|
$nicfile = $ARGV[0] if($ARGV[0]);
|
|
$outputdir = $ARGV[1];
|
|
if(!$nicfile || !$outputdir) {
|
|
exitWithError("Syntax: $0 nicfile outputdir");
|
|
}
|
|
|
|
### LOAD THE NICFILE! ###
|
|
open(my $nichandle, "<", $nicfile);
|
|
my $line = <$nichandle>;
|
|
my $nicversion = 1;
|
|
if($line =~ /^nic (\w+)$/) {
|
|
$nicversion = $1;
|
|
} elsif($nicfile =~ /\.tar$/) {
|
|
$nicversion = "Tar";
|
|
}
|
|
seek($nichandle, 0, 0);
|
|
|
|
my $NICPackage = "NIC$nicversion";
|
|
exitWithError("I don't understand NIC version $nicversion!") if(!can_load(modules => {"NIC::Formats::$NICPackage" => undef}));
|
|
|
|
{
|
|
no warnings 'redefine';
|
|
sub NIC::NICBase::_meetsConstraints { return 1; }
|
|
}
|
|
|
|
my $NIC = "NIC::Formats::$NICPackage"->new($nichandle);
|
|
$NIC->addConstraint("package");
|
|
close($nichandle);
|
|
### YAY! ###
|
|
|
|
$NIC->build($outputdir);
|
|
$NIC->dumpPreamble("pre.NIC");
|
|
|
|
sub exitWithError {
|
|
my $error = shift;
|
|
print STDERR "[error] ", $error, $/;
|
|
exit 1;
|
|
}
|