15 $SIG{'__WARN__'} = \&warning;
17 Getopt::Long::Configure("no_ignore_case", "bundling", "gnu_compat",
19 if (not GetOptions(\%opts,
29 if (exists($opts{'h'})) {
33 if (exists($opts{'V'})) {
39 error(4, "No input files\n");
41 if (exists($opts{'o'})) {
43 error(4, "Cannot specify -o with multiple files\n");
45 compile($ARGV[0], $opts{'o'}, $opts{'D'});
49 $output =~ s/\.[^.]+$/.html/;
50 compile($input, $output, $opts{'D'});
59 printf($fh "Usage: %s [-o <output>] <input> ...\n", $0);
68 print(" -D <name>=<value> Set the variable <name> to <value>\n");
69 print(" -o <output> Place the output into <output>\n");
70 print(" -h, --help Display this information\n");
71 print(" -V, --version Display compiler version information\n");
78 print("ssic 0.1.0\n");
79 print("Copyright (C) 2013 Patrick \"P. J.\" McDermott\n");
80 print("License GPLv3+: GNU GPL version 3 or later " .
81 "<http://gnu.org/licenses/gpl.html>.\n");
82 print("This is free software: you are free to change and " .
83 "redistribute it.\n");
84 print("There is NO WARRANTY, to the extent permitted by law.\n");
89 my ($fmt, $args) = @_;
91 printf("ssic: Warning: " . $fmt, $args);
96 my ($status, $fmt, $args) = @_;
98 printf("ssic: Error: " . $fmt, $args);
104 my ($input, $output, $vars) = @_;
111 if ($input eq $output) {
112 error(4, "Input and output files are equal\n");
115 open($input_fh, "<", $input);
116 open($output_fh, ">", $output);
118 $CGI::SSI::DEBUG = 0;
119 $ssi = CGI::SSI->new();
121 while (($var_name, $var_value) = each(%{$vars})) {
122 $ssi->set($var_name => $var_value);
125 print($output_fh $ssi->process(<$input_fh>));