#!/usr/bin/perl -w # # This script is invoked when the YPP SC PCTB client phones home to # provide updated character set OCR data or updated screenshot pixmap # interpretation (island name) data. # # The client will also phone home anyway to fetch the latest parsedb # before # # This allows me (the operator of the SC server) to: # - review the choices made by the user # - if they are correct, incorporate them in the next client version # - if they are wrong, incorporate fixes of them, or contradictions of them, # in # The information reported # The SC PCTB client does this so that use strict (qw(vars)); $CGI::POST_MAX= 65536; $CGI::DISABLE_UPLOADS= 1; use CGI qw/:standard -private_tempfiles/; #---------- pixmaps ---------- 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; # ']); 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] ?"; map { m/\D/ and die "$& ?"; $_ += 0; $_ >= 0 or die "$_ ?"; $_ <= 255 or die "$_ ?"; } @d; my $ppm= "P3\n$w $h\n255\n"; my $di=0; for (my $y=0; $y<$h; $y++) { for (my $x=0; $x<$w; $x++, $di+=3) { #print STDERR ">$x,$y,$di,",scalar(@d),"<\n"; $ppm .= sprintf " %3d %3d %3d", @d[$di..$di+2]; } $ppm .= "\n"; } ppmtopgm | pnmscale -width 79 | pnmnorm -bpercent 40 -wpercent 10 | pgmtopbm -threshold