3 # $Id: test-pod.pl,v 1.4 2006-05-10 13:00:33 mike Exp $
6 # YAZ_LOG=pod perl -I lib test-pod.pl
7 # (at least until the default sync. behaviour of ZOOM-C changes.)
14 my $pod = new ZOOM::Pod("bagel.indexdata.com/gils",
15 "bagel.indexdata.com/marc",
16 #"z3950.loc.gov:7090/Voyager",
19 $pod->option(elementSetName => "b");
20 $pod->callback(ZOOM::Event::RECV_SEARCH, \&completed_search);
21 $pod->callback(ZOOM::Event::RECV_RECORD, \&got_record);
22 $pod->search_pqf("the");
23 my $err = $pod->wait();
24 die "$pod->wait() failed with error $err" if $err;
26 sub completed_search {
27 my($conn, $state, $rs, $event) = @_;
28 print $conn->option("host"), ": found ", $rs->size(), " records\n";
29 $state->{next_to_fetch} = 0;
30 $state->{next_to_show} = 0;
31 request_record($conn, $rs, $state);
36 my($conn, $state, $rs, $event) = @_;
39 # Sanity-checking assertions. These should be impossible
40 my $ns = $state->{next_to_show};
41 my $nf = $state->{next_to_fetch};
43 die "next_to_show > next_to_fetch ($ns > $nf)";
44 } elsif ($ns == $nf) {
45 die "next_to_show == next_to_fetch ($ns)";
49 my $i = $state->{next_to_show}++;
50 my $rec = $rs->record($i);
51 print $conn->option("host"), ": record $i is ", render_record($rec), "\n";
52 request_record($conn, $rs, $state);
57 my($conn, $rs, $state) = @_;
59 my $i = $state->{next_to_fetch}++;
60 my $rec = $rs->records($i, 1, 0);
61 print($conn->option("host"), ": pre-fetch: record $i is ",
62 render_record($rec), "\n");
68 return "undefined" if !defined $rec;
69 return "'" . $rec->render() . "'";