X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=pctb%2Fyppsc-parsedb-updatereceiver;h=5d5585ef38bdc4324337c77d2dddb5e2efbc0573;hb=e9fe421133870b68103e6cfcf1a1e06058edf032;hp=17ba86888c6f83ad782f99f1759adff37f2d1cd2;hpb=8afdc8c88ffd4cfb9b28945c877884968bd08a96;p=ypp-sc-tools.db-test.git diff --git a/pctb/yppsc-parsedb-updatereceiver b/pctb/yppsc-parsedb-updatereceiver index 17ba868..5d5585e 100755 --- a/pctb/yppsc-parsedb-updatereceiver +++ b/pctb/yppsc-parsedb-updatereceiver @@ -22,14 +22,15 @@ $CGI::POST_MAX= 65536; $CGI::DISABLE_UPLOADS= 1; use CGI qw/:standard -private_tempfiles/; - +use IO::Pipe; +use IO::Handle; #---------- pixmaps ---------- -sub parseentryin_pixmap ($) { +sub parseentryin__pixmap ($) { my ($entry_in) = @_; $entry_in =~ - m/^(\w+ \- \w[-+'"#! 0-9a-z]*\w)\nP3\n([1-9]\d{1,3}) ([1-9]\d{1,3})\n255\n/s or die; # ']); + m/^(\w+ \- \w[-+'"#! 0-9a-z]*)\nP3\n([1-9]\d{1,3}) ([1-9]\d{1,3})\n255\n/s or die; # ']); my ($def,$w,$h)= ($1, $2+0, $3+0); my @d= grep { m/./ } split /\s+/, $'; @d == $w*$h*3 or die "$d[0]|$d[1]|...|$d[$#d-1]|$d[$#d] ?"; @@ -49,9 +50,17 @@ sub parseentryin_pixmap ($) { $ppm .= "\n"; } - ppmtopgm | pnmscale -width 79 | pnmnorm -bpercent 40 -wpercent 10 | pgmtopbm -threshold + my $summary= pipeval($ppm, + 'ppmtopgm', + 'pnmscale -width 79', + 'pnmnorm -bpercent 40 -wpercent 10', + 'pgmtopbm -threshold', + 'pbmtoascii' + ); + print STDERR ">$summary<\n"; + - writer(); + if (!$lastpipe) { + print $pipe $val or die $!; + exit 0; + } else { + open STDIN, '<&', $lastpipe or die $!; + open STDOUT, '>&', $pipe or die $!; + close $lastpipe or die $!; + close $pipe or die $!; + exec $cmd; die $!; + } + } + $pipe->reader(); + if ($lastpipe) { close $lastpipe or die $!; } + $lastpipe= $pipe; + push @pids, $pid; + } + + $!=0; { local ($/)=undef; $val= <$lastpipe>; } + defined $val or die $!; + $lastpipe->error and die $!; close $lastpipe or die $!; + + foreach my $cmd ('(paste)', @cmds) { + my $pid= shift @pids; + waitpid($pid,0) == $pid or die "$pid $? $!"; + $?==0 or $?==13 or die "$cmd $?"; +print STDERR "OK $cmd\n"; + } + return $val; +} + #---------- main program ---------- my $path= path_info(); @@ -75,7 +128,7 @@ if ($path =~ /(pixmap|char)/) { die "$path ?"; } -my ($ctx,$def,$entry)= ${"parseentryin__$kind"}($entry_in); +my ($ctx,$def,$entry)= &{"parseentryin__$kind"}($entry_in); my $summary= <