3 # $Id: test-pod.pl,v 1.7 2006-05-10 15:55:19 mike Exp $
6 # YAZ_LOG=pod perl -I lib test-pod.pl "bagel.indexdata.com/gils" "bagel.indexdata.com/marc"
14 printf STDERR "Usage: $0 <target1> [<target2> ...]\n";
18 ZOOM::Log::mask_str("appl");
19 my $pod = new ZOOM::Pod(@ARGV);
20 $pod->option(elementSetName => "b");
21 $pod->callback(ZOOM::Event::RECV_SEARCH, \&completed_search);
22 $pod->callback(ZOOM::Event::RECV_RECORD, \&got_record);
23 #$pod->callback(exception => \&exception_thrown);
24 $pod->search_pqf("the");
25 my $err = $pod->wait();
26 die "$pod->wait() failed with error $err" if $err;
28 sub completed_search {
29 my($conn, $state, $rs, $event) = @_;
30 print $conn->option("host"), ": found ", $rs->size(), " records\n";
31 $state->{next_to_fetch} = 0;
32 $state->{next_to_show} = 0;
33 request_records($conn, $rs, $state, 2);
38 my($conn, $state, $rs, $event) = @_;
41 # Sanity-checking assertions. These should be impossible
42 my $ns = $state->{next_to_show};
43 my $nf = $state->{next_to_fetch};
45 die "next_to_show > next_to_fetch ($ns > $nf)";
46 } elsif ($ns == $nf) {
47 die "next_to_show == next_to_fetch ($ns)";
51 my $i = $state->{next_to_show}++;
52 my $rec = $rs->record($i);
53 print $conn->option("host"), ": record $i is ", render_record($rec), "\n";
54 request_records($conn, $rs, $state, 3)
55 if $i == $state->{next_to_fetch}-1;
60 sub exception_thrown {
61 my($conn, $state, $rs, $exception) = @_;
62 print "Uh-oh! $exception\n";
67 my($conn, $rs, $state, $count) = @_;
69 my $i = $state->{next_to_fetch};
70 ZOOM::Log::log("appl", "requesting $count records from $i");
71 $rs->records($i, $count, 0);
72 $state->{next_to_fetch} += $count;
78 return "undefined" if !defined $rec;
79 return "'" . $rec->render() . "'";