+ client_send ".ACTION COPY"; # safeq sends this twice
+ client_send ".COPY Mozete kopirati |".credit;
+ client_send ".NOP";
+ client_send ".CREDIT ".credit;
+ } elsif ( $line =~ m/\.COPY (.+)/ ) {
+ # FIXME
+ my $charge = 0;
+ foreach ( split(/,/,$1) ) {
+ die "can't find [$_] in prices=",dump($prices) unless exists $prices->{$_};
+ $charge += $prices->{$_};
+ }
+ warn "CHARGE: $charge\n";
+ $credit -= $charge;
+ $total_charged += $charge;
+ $total_pages++;
+ client_send ".CREDIT ".credit;
+ client_send ".COPY 1"; # I verified that you are allowed to copy 1 page?
+ client_send ".NOP";
+
+ } elsif ( $line =~ m/\.ACTION LIST/ ) {
+ # FIXME
+
+ } elsif ( $line =~ m/\.ACTION PRINT ALL/ ) {
+ # FIXME
+
+ } elsif ( $line =~ m/^\.NOP/ ) {
+ # XXX it's important to sleep, before sending response or
+ # interface on terminal device will be unresponsive
+ $next_nop_t = time() + 5; # NOP every 5s?
+ } elsif ( $line =~ m/^\.END/ ) {
+ client_send ".DONE BLK WAIT";
+ $client_socket->close;
+ } elsif (defined $line) {
+ warn "UNKNOWN: ",dump($line);
+ print "Response>";
+ my $r = <STDIN>;
+ chomp $r;
+ client_send $r;