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