1 # $Id: zoomtst3.pl,v 1.3 2006-04-07 12:03:27 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 bagel.indexdata.com:210/gils mineral
13 print STDERR "Usage: $0 target1 target2 ... targetN query\n";
14 print STDERR " eg. $0 bagel.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.
48 # No more to be done. Inspect results
49 for (my $i = 0; $i < $n; $i++) {
50 my $tname = $ARGV[$i];
51 my($error, $errmsg, $addinfo, $diagset) = $z[$i]->error_x();
53 print STDERR "$tname error: $errmsg ($error) $addinfo\n";
57 # OK, no major errors. Look at the result count
58 my $size = $r[$i]->size();
59 print "$tname: $size hits\n";
61 # Go through all records at target
62 $size = 10 if $size > 10;
63 for (my $pos = 0; $pos < $size; $pos++) {
64 print "$tname: fetching ", $pos+1, " of $size\n";
65 my $tmp = $r[$i]->record($pos);
67 print "$tname: can't get record ", $pos+1, "\n";
70 my $rec = $tmp->render();
72 print "$tname: can't render record ", $pos+1, "\n";
75 print $pos+1, "\n", $rec, "\n";
80 for (my $i = 0; $i < $n; $i++) {