X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Fssic.pl;h=e5fa2be81774fa9052bd7ef21e2cb6c923bce75f;hb=e09c119b75cfd9f6e62f50083edf4a812be66134;hp=117864b81bceb95982121cecb9715bc93f10b2a4;hpb=20be67fb7cbd7886caf5ba491812074f5a3be226;p=ssic.git diff --git a/src/ssic.pl b/src/ssic.pl index 117864b..e5fa2be 100644 --- a/src/ssic.pl +++ b/src/ssic.pl @@ -86,16 +86,16 @@ sub version sub warning { - my ($fmt, $args) = @_; + my ($fmt, @args) = @_; - printf("ssic: Warning: " . $fmt, $args); + printf("ssic: Warning: " . $fmt, @args); } sub error { - my ($status, $fmt, $args) = @_; + my ($status, $fmt, @args) = @_; - printf("ssic: Error: " . $fmt, $args); + printf("ssic: Error: " . $fmt, @args); exit($status); } @@ -112,11 +112,31 @@ sub compile error(4, "Input and output files are equal\n"); } - open($input_fh, "<", $input); - open($output_fh, ">", $output); + if ($input eq "-") { + $input_fh = *STDIN; + } else { + if (not open($input_fh, "<", $input)) { + error(4, "%s: %s\n", $input, $!); + } + } + if ($output eq "-") { + $output_fh = *STDOUT; + } else { + if (not open($output_fh, ">", $output)) { + error(4, "%s: %s\n", $output, $!); + } + } + + %ENV = ( + "DOCUMENT_NAME" => $input, + "DOCUMENT_URI" => $input, + ); $CGI::SSI::DEBUG = 0; - $ssi = CGI::SSI->new(); + $ssi = CGI::SSI->new( + "DOCUMENT_NAME" => $input, + "DOCUMENT_URI" => $input, + ); while (($var_name, $var_value) = each(%{$vars})) { $ssi->set($var_name => $var_value);