| @ | @g; # simplify... $result =~ s@ NOWRAP(>[^\s]+?)@$1@g; # if no spaces, don't need nowrap $output_lines++; return $result; } sub convert_color($) { my ($str) = @_; $str =~ s/\e\[.*?[a-zA-Z]//g; if ($str =~ /( |
\n"; my $ss = ($any_styles ? $stylesheet : ""); $_ = $doc_head; s/%%STYLESHEET%%/$ss/; $output = $_ . $output; return $output; } # This is the main loop when we seem to have been invoked as a CGI script. # sub do_cgi() { error (400, "malformed URL") if ($ENV{PATH_INFO} || $ENV{QUERY_STRING}); if ($ENV{REQUEST_METHOD} eq 'GET') { # # GET means this is the top-level invocation: just display the HTML # for the form in which the user can paste an IRC log. # print STDOUT "Content-Type: text/html\n\n"; print STDOUT ("\n" . "
\n" . "\n"; $err =~ s/&/&/g; $err =~ s/</g; $err =~ s/>/>/g; print "$err\n
\n";
exit (0);
} else {
print STDERR "$progname: $err\n";
exit 1;
}
}
sub usage() {
print STDERR "usage: $progname [--verbose] [--strip] [--no-color]\n" .
" [input-chat-log] [output-html-file]\n";
exit 1;
}
sub main() {
my $in = undef;
my $out = undef;
if (defined ($ENV{REQUEST_URI})) {
return do_cgi();
}
while ($_ = $ARGV[0]) {
shift @ARGV;
if ($_ eq "--verbose") { $verbose++; }
elsif ($_ eq "--strip") { $strip_noise++; }
elsif ($_ eq "--no-time") { $strip_timestamps++; }
elsif ($_ eq "--no-color") { $colorize_p = 0; $separators_p = 1; }
elsif (m/^-v+$/) { $verbose += length($_)-1; }
elsif (m/^-./) { usage; }
elsif (!defined($in)) { $in = $_; }
elsif (!defined($out)) { $out = $_; }
else { usage; }
}
$in = "-" unless $in;
$out = "-" unless $out;
local *IN;
local *OUT;
open (IN, "<$in") || die "$progname: unable to read $in: $!\n";
open (OUT, ">$out") || die "$progname: unable to write $out: $!\n";
$in = "stdin" if $in eq "-";
$out = "stdout" if $out eq "-";
if ($verbose) {
print STDERR "$progname: converting $in to $out...\n";
}
my $body = '';
$body .= $_ while (