-# $Id: Net-Z3950-ZOOM.t,v 1.3 2005-10-11 11:44:48 mike Exp $
+# $Id: Net-Z3950-ZOOM.t,v 1.4 2005-10-11 15:48:15 mike Exp $
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Net-Z3950-ZOOM.t'
my $errcode;
my($errmsg, $addinfo) = ("dummy", "dummy");
-my $conn = Net::Z3950::ZOOM::ZOOM_connection_new($host, $port);
-$errcode = Net::Z3950::ZOOM::ZOOM_connection_error($conn, $errmsg, $addinfo);
+my $conn = Net::Z3950::ZOOM::connection_new($host, $port);
+$errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
if ($errcode != 0) {
die("Can't connect to host '$host', port '$port': ",
"errcode='$errcode', errmsg='$errmsg', addinfo='$addinfo'");
}
-my $query = '@attr 1=4 taylor';
-my $rs = Net::Z3950::ZOOM::ZOOM_connection_search_pqf($conn, $query);
-$errcode = Net::Z3950::ZOOM::ZOOM_connection_error($conn, $errmsg, $addinfo);
+Net::Z3950::ZOOM::connection_option_set($conn,
+ preferredRecordSyntax => "usmarc");
+
+my $query = '@attr 1=4 minerals';
+my $rs = Net::Z3950::ZOOM::connection_search_pqf($conn, $query);
+$errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
if ($errcode != 0) {
die("Can't search for '$query': ",
"errcode='$errcode', errmsg='$errmsg', addinfo='$addinfo'");
}
-print STDERR "Result count: ", Net::Z3950::ZOOM::ZOOM_resultset_size($rs), "\n";
-Net::Z3950::ZOOM::ZOOM_resultset_destroy($rs);
-Net::Z3950::ZOOM::ZOOM_connection_destroy($conn);
+my $n = Net::Z3950::ZOOM::resultset_size($rs);
+print STDERR "Result count: $n\n";
+
+for (my $i = 0; $i < $n; $i++) {
+ my $rec = Net::Z3950::ZOOM::resultset_record($rs, $i);
+ my $len = 0;
+ my $data = Net::Z3950::ZOOM::record_get($rec, "render", $len);
+ print STDERR "=== record ", $i+1, " of $n ===\n", $data;
+ my $raw = Net::Z3950::ZOOM::record_get($rec, "raw", $len);
+ print STDERR "--- raw version ---\n", $raw;
+}
+
+Net::Z3950::ZOOM::resultset_destroy($rs);
+Net::Z3950::ZOOM::connection_destroy($conn);