~ubuntu-branches/ubuntu/saucy/openvpn/saucy-proposed

« back to all changes in this revision

Viewing changes to install-win32/macro.pl

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2013-05-24 17:42:45 UTC
  • mfrom: (1.1.19) (10.2.22 sid)
  • Revision ID: package-import@ubuntu.com-20130524174245-g9y6wlforycufqy5
Tags: 2.3.1-2ubuntu1
* Merge from Debian unstable. Remaining changes:
  - debian/openvpn.init.d:
    + Do not use start-stop-daemon and </dev/null to avoid blocking boot.
    + Show per-VPN result messages.
    + Add "--script-security 2" by default for backwards compatabliity.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
# Simple macro processor.
4
 
 
5
 
# Macros are defined in a control file that follows
6
 
# a simple definition-based grammar as documented in the
7
 
# trans script.  Stdin is then copied to stdout, and any
8
 
# occurrence of @@MACRO@@ is substituted.  Macros can also
9
 
# be specified on the command line.
10
 
 
11
 
die "usage: macro [-O<openquote>] [-C<closequote>] [-Dname=var ...] [control-file ...] " if (@ARGV < 1);
12
 
 
13
 
%Parms = ();
14
 
$open_quote = "@@";
15
 
$close_quote = "@@";
16
 
 
17
 
while ($arg=shift(@ARGV)) {
18
 
  if ($arg =~ /^-/) {
19
 
    if ($arg =~ /^-D(\w+)(?:=(.*))?$/) {
20
 
      $Parms{$1} = $2
21
 
    } elsif ($arg =~ /-O(.*)$/) {
22
 
      $open_quote = $1;
23
 
    } elsif ($arg =~ /-C(.*)$/) {
24
 
      $close_quote = $1;
25
 
    } else {
26
 
      die "unrecognized option: $arg";
27
 
    }
28
 
  } else {
29
 
    open(CONTROL, "< $arg") or die "cannot open $arg";
30
 
    while (<CONTROL>) {
31
 
      if (/^!define\s+(\w+)(?:\s+['"]?(.*?)['"]?)?\s*$/) {
32
 
        $Parms{$1} = $2;
33
 
      }
34
 
    }
35
 
  }
36
 
}
37
 
 
38
 
sub print_symbol_table {
39
 
  foreach my $k (sort (keys(%Parms))) {
40
 
    my $v = $Parms{$k};
41
 
    print "[$k] -> \"$v\"\n";
42
 
  }
43
 
}
44
 
 
45
 
#print_symbol_table ();
46
 
#exit 0;
47
 
 
48
 
while (<STDIN>) {
49
 
  s{
50
 
    \Q$open_quote\E
51
 
    \s*
52
 
    (
53
 
    \w+
54
 
   )
55
 
    \s*
56
 
    \Q$close_quote\E
57
 
  }{
58
 
    $Parms{$1}
59
 
  }xge;
60
 
  print;
61
 
}