X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=sc-emulator.pl;h=9bdf08a1af0260b5cc8915e0a087d58536b764ee;hb=0f3fe0ba73f34e3cb7a069a43a3e07b0cd1bda93;hp=e614cec30d83c8023064151e579bec2710302157;hpb=584943f3bddc78b99d264b03ff01f4d87d430e6a;p=Biblio-SIP2.git diff --git a/sc-emulator.pl b/sc-emulator.pl index e614cec..9bdf08a 100755 --- a/sc-emulator.pl +++ b/sc-emulator.pl @@ -5,26 +5,31 @@ use strict; use IO::Socket::INET; use autodie; -use Data::Dump qw(dump); our $user = 'sip2-user'; our $password = 'sip2-paasswd'; +our $patron = 200000000042; +our $barcode = 1301132799; +our $loc = 'FFZG'; require 'config.pl' if -e 'config.pl'; +use SIP2; + our $sock = IO::Socket::INET->new( '10.60.0.251:6001' ); + sub sip2 { my ( $send, $patt ) = @_; - warn ">>>> ", dump($send), "\n"; + SIP2::dump_message '>>>>', $send; print $sock "$send\r\n"; $sock->flush; # local $/ = "\r"; my $in = <$sock>; - warn "<<<< ", dump($in), "\n"; - die unless $in =~ $patt; + SIP2::dump_message '<<<<', $in; + die "expected $patt" unless $in =~ $patt; } # login @@ -33,3 +38,12 @@ sip2 "9300CN$user|CO$password|" => qr/^941/; # SC Status sip2 "9900302.00" => qr/^98/; +# Patron Information +sip2 "6300020091214 085452 AO$loc|AA$patron|AC$password|" => qr/^64/; + +# Checkout +sip2 "11YN20091214 124436 AO$loc|AA$patron|AB$barcode|AC$password|BON|BIN|" => qw/12/; + +# Checkin +sip2 "09N20091214 08142820091214 081428AP|AO$loc|AB$barcode|AC|BIN|" => qr/^10/; +