1 # $Id: zoomtst3.pl,v 1.6 2006-11-02 17:48:26 mike Exp $
3 # See ../README for a description of this program.
4 # perl -I../../blib/lib -I../../blib/arch zoomtst3.pl <t1> [...] <tN> <query>
6 # perl -I../../blib/lib -I../../blib/arch zoomtst3.pl z3950.loc.gov:7090/Voyager z3950.indexdata.com:210/gils endeavor.flo.org:7090/Voyager mineral
13 print STDERR "Usage: $0 target1 target2 ... targetN query\n";
14 print STDERR " eg. $0 z3950.indexdata.dk/gils localhost:9999 fish\n";
19 my(@z, @r); # connections, result sets
20 my $o = new ZOOM::Options();
21 $o->option(async => 1);
23 # Get first 10 records of result set (using piggyback)
24 $o->option(count => 10);
26 # Preferred record syntax
27 $o->option(preferredRecordSyntax => "usmarc");
28 $o->option(elementSetName => "F");
30 # Connect to all targets: options are the same for all of them
31 for (my $i = 0; $i < $n; $i++) {
32 $z[$i] = create ZOOM::Connection($o);
33 $z[$i]->connect($ARGV[$i]);
37 for (my $i = 0; $i < $n; $i++) {
38 $r[$i] = $z[$i]->search_pqf($ARGV[-1]);
41 # Network I/O. Pass number of connections and array of connections
42 while ((my $i = ZOOM::event(\@z)) != 0) {
43 my $ev = $z[$i-1]->last_event();
44 print("connection ", $i-1, ": event $ev (", ZOOM::event_str($ev), ")\n");
45 # It would be nice to display results as they come in, but the
46 # ability to do so is dependent on the END event, which was
47 # introduced only in YAZ 2.1.17. If you have a sufficiently new
48 # YAZ, please use the alternative "async.pl", which is similar to
49 # this program except in its asynchronous display.
52 # No more to be done. Inspect results
53 for (my $i = 0; $i < $n; $i++) {
54 my $tname = $ARGV[$i];
55 my($error, $errmsg, $addinfo, $diagset) = $z[$i]->error_x();
57 print STDERR "$tname error: $errmsg ($error) $addinfo\n";
61 # OK, no major errors. Look at the result count
62 my $size = $r[$i]->size();
63 print "$tname: $size hits\n";
65 # Go through all records at target
66 $size = 10 if $size > 10;
67 for (my $pos = 0; $pos < $size; $pos++) {
68 print "$tname: fetching ", $pos+1, " of $size\n";
69 my $tmp = $r[$i]->record($pos);
71 print "$tname: can't get record ", $pos+1, "\n";
74 my $rec = $tmp->render();
76 print "$tname: can't render record ", $pos+1, "\n";
79 print $pos+1, "\n", $rec, "\n";
84 for (my $i = 0; $i < $n; $i++) {