# clientname "ypp-sc-tools"
# clientversion 2.1-g2e06a26 [from git-describe --tags HEAD]
# clientfixes "lastpage" [space separated list]
-# deduped.tsv.gz output of ypp-commodities --tsv
+# data filename=deduped.tsv.gz output of ypp-commodities --tsv
use strict (qw(vars));
use POSIX;
}
my $clientname= must_param('clientname',$re_any);
-my $client= $clients{$clientname};
+my $clientinfo= $clients{$clientname};
fail('unknown client') unless defined $client;
-my $clientfixes= must_param('clientfixes', $re_any);
-foreach my $bug (@$client) {
+my $clientfixes= must_param('clientfixes', "^([-0-9a-z ]*)\$");
+my @clientfixes= sort grep { m/./ } split /\s+/, $clientfixes;
+$clientfixes= "@clientfixes";
+foreach my $bug (@$clientinfo) {
fail("client out of date - missing bugfix \`$bug'")
- unless grep { $_ eq $bug } split /\s+/, $clientfixes;
+ unless grep { $_ eq $bug } @clientfixes;
}
my $cversion= must_param('clientversion', "^(\\d[-+._0-9a-zA-Z]+)\$");
}
fail("unknown island") unless $island_found;
+die if $ocean =~ m/\=/;
+die if $island =~ m/\=/;
+
+$datafile= must_param('data',"^(deduped\\.tsv\\.gz)\$");
+$indatafh= upload('data'); fail("data is not a file") unless defined $datafh;
+
+our %done;
+
+my $content= MIME::Entity->build(Type => 'multipart/mixed',
+ Boundary => '=',
+ Charset => 'utf-8');
+
+my $clientspec= "$clientname $clientversion $clientfixes";
+foreach $vn (qw(ocean island
+ clientspec
+ clientname clientversion clientfixes)) {
+
+while (<$datafh>) {
+ !m/\P{IsPrint}/ or die bad_data('nonprinting char(s)');
+ my @v= split /\t/;
+ @v==6 or bad_data('wrong number of fields');
+ my ($commod,$stall) = @v;
+ defined $commods{$commod} or bad_data("unknown commodity \`$commod'");
+ $stall =~ m/^\p{IsUpper}/ or bad_data("stall not capitalised");
+ !exists $done{$commod,$stall} or bad_data("repeated data");
+ $done{$commod,$stall}= 1;
+ foreach my $f (@v[2..5]) {
+ $f =~ m/^(0|[1-9][0-9]{0,5}|\>1000)$/ or bad_data("bad field");
+ ($v % 1) or ($v !~ m/\>/) or bad_data("> in price");
+ }
+}
+
+
+
+
#foreach my $commod (sort keys %commods) {
# print "$commod\n";
#}