) { print OUT $_; }
- truncate (IN, 0) || die "couldn't truncate $image_tmp: $!";
- close (IN);
- close (OUT) || die "couldn't write $image_jpg: $!";
- if ($DEBUG > 2) { print STDERR "wrote $image_jpg\n"; }
- }
+ } elsif (($rc & 0xff) == 0) {
+ $rc >>= 8;
+ if ($verbose) {
+ print "$progname: subproc exited with status $rc.\n";
}
-
- # Overwrite the map data.
- #
- seek (MAP, 0, 0) || die "couldn't rewind $map_file: $!";
- truncate (MAP, 0) || die "couldn't truncate $map_file: $!";
- print MAP $map;
- }
-
- my $of = select(MAP); $| = 1; select($of); # flush output
- print MAP "";
-
- flock (MAP, LOCK_UN) || die "couldn't unlock $map_file: $!";
- close (MAP) || die "couldn't close $map_file: $!";
-
- if ($DEBUG > 2) { print STDERR "jpeg: closed $map_file\n"; }
-}
-
-
-sub cgi_generate_image {
-
- $SIG{PIPE} = 'IGNORE';
-
- my @urls = get_image_urls ($pastes_per_load);
- my $end_time = time + $image_retrieval_time;
-
- if ($DEBUG > 2) {
- print STDERR "loading $#urls images\n";
- }
-
- foreach (@urls) {
- my ($img, $referer) = m/^([^ ]+) ([^ ]+)/;
- if ($img) {
- cgi_paste_image ($img, $referer);
+ } else {
+ if ($rc & 0x80) {
+ if ($verbose) {
+ print "$progname: subproc dumped core.\n";
+ }
+ $rc &= ~0x80;
}
- last if (time > $end_time);
- }
-}
-
-
-sub cgi_sanity_check {
- my $error = undef;
- foreach (@all_files) {
- if (! -e $_) { $error = "$_ does not exist.\n"; }
- elsif (! -r $_) { $error = "$_ is unreadable.\n"; }
- elsif (! -w $_) { $error = "$_ is unwritable.\n"; }
- last if ($error);
- }
-
- return unless $error;
-
- print "Content-Type: text/html\n";
- print "\n\nError$body_tagError
";
- print POSIX::getcwd() . "/" . $error . "\n";
-
- $_ = join(", ", @all_files);
- s/,([^,]*)$/, and$1/;
-
- print "Each of the files: $_\n";
- print " must exist and be readable and writable by the httpd process\n";
- print "(which probably means they must be globally readable and\n";
- print "writable, since on most systems, CGI scripts run as the\n";
- print "user nobody.)\n
\n";
-
- exit (0);
-}
-
-
-# Write the encapsulating HTML document and associated HTTP headers.
-# This is fast -- it just writes out the wrapper document corresponding
-# to the data currently on disk. It is the loading of the sub-image
-# that does the real work.
-#
-sub cgi_emit_html_document {
-
- cgi_sanity_check;
-
- my $map_file_date;
- my $doc = $html_document;
-
- my $w2 = int ($img_width * $scale);
- my $h2 = int ($img_height * $scale);
- $doc =~ s/%%WIDTH%%/$w2/g;
- $doc =~ s/%%HEIGHT%%/$h2/g;
-
- local *MAP;
- open (MAP, "<$map_file") || die "couldn't open $map_file: $!";
- if ($DEBUG > 2) { print STDERR "html: opened $map_file\n"; }
-
- flock (MAP, LOCK_SH) || die "couldn't lock $map_file: $!";
- seek (MAP, 0, 0) || die "couldn't rewind $map_file: $!";
- if ($DEBUG > 2) { print STDERR "html: locked $map_file\n"; }
-
- $map_file_date = (stat(MAP))[9];
-
- my $map = "