mirror of
https://github.com/OpenVPN/openvpn.git
synced 2025-05-09 13:41:06 +08:00

unix and windows versions. Reworked the Windows build scripting system, with settings (other than version #) specified in settings.in. Moved the native scripting grammar as defined by trans.pl away from NSIS and to something more generic. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1867 e7ae566f-a301-0410-adde-c780ea21d3b5
53 lines
1.1 KiB
Perl
53 lines
1.1 KiB
Perl
#!/usr/bin/perl
|
|
|
|
# Simple macro processor.
|
|
|
|
# Macros are defined in a control file that follows
|
|
# a simple definition-based grammar as documented in the
|
|
# trans script. Stdin is then copied to stdout, and any
|
|
# occurrence of @@MACRO@@ is substituted. Macros can also
|
|
# be specified on the command line.
|
|
|
|
die "usage: macro [-O<openquote>] [-C<closequote>] [-Dname=var ...] [control-file ...] " if (@ARGV < 1);
|
|
|
|
%Parms = ();
|
|
$open_quote = "@@";
|
|
$close_quote = "@@";
|
|
|
|
while ($arg=shift(@ARGV)) {
|
|
if ($arg =~ /^-/) {
|
|
if ($arg =~ /^-D(\w+)=(.*)$/) {
|
|
$Parms{$1} = $2
|
|
} elsif ($arg =~ /-O(.*)$/) {
|
|
$open_quote = $1;
|
|
} elsif ($arg =~ /-C(.*)$/) {
|
|
$close_quote = $1;
|
|
} else {
|
|
die "unrecognized option: $arg";
|
|
}
|
|
} else {
|
|
open(CONTROL, "< $arg") or die "cannot open $arg";
|
|
while (<CONTROL>) {
|
|
chomp;
|
|
if (/^define\s+(\w+)\s+['"]?(.+?)['"]?\s*$/) {
|
|
$Parms{$1} = $2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
while (<STDIN>) {
|
|
s{
|
|
\Q$open_quote\E
|
|
\s*
|
|
(
|
|
\w+
|
|
)
|
|
\s*
|
|
\Q$close_quote\E
|
|
}{
|
|
$Parms{$1}
|
|
}xge;
|
|
print;
|
|
}
|