15 $SIG{'__WARN__'} = \&warning;
17 if (not getopts('o:hV', \%opts)) {
21 if (exists($opts{'h'})) {
25 if (exists($opts{'V'})) {
31 error(4, "No input files\n");
33 if (exists($opts{'o'})) {
35 error(4, "Cannot specify -o with multiple files\n");
37 compile($ARGV[0], $opts{'o'});
41 $output =~ s/\.[^.]+$/.html/;
42 compile($input, $output);
51 printf($fh "Usage: %s [-o <output>] <input> ...\n", $0);
60 print(" -o <output> Place the output into <output>\n");
61 print(" -h Display this information\n");
62 print(" -V Display compiler version information\n");
69 print("ssic 0.1.0\n");
70 print("Copyright (C) 2013 Patrick \"P. J.\" McDermott\n");
71 print("License GPLv3+: GNU GPL version 3 or later " .
72 "<http://gnu.org/licenses/gpl.html>.\n");
73 print("This is free software: you are free to change and " .
74 "redistribute it.\n");
75 print("There is NO WARRANTY, to the extent permitted by law.\n");
80 my ($fmt, $args) = @_;
82 printf("ssic: Warning: " . $fmt, $args);
87 my ($status, $fmt, $args) = @_;
89 printf("ssic: Error: " . $fmt, $args);
95 my ($input, $output) = @_;
100 if ($input eq $output) {
101 error(4, "Input and output files are equal\n");
104 open($input_fh, "<", $input);
105 open($output_fh, ">", $output);
107 $CGI::SSI::DEBUG = 0;
108 $ssi = CGI::SSI->new();
110 print($output_fh $ssi->process(<$input_fh>));