X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM.pm;h=6b2f8c985b12b9c64addf7531872b3324412e1f3;hb=87c72eaf97a3dbf51a93dab782c2909539addc48;hp=0a42e3e9b04310b47d0e364402e6d610f7774afc;hpb=beb0211a4003983bbacbe2b8c1a6f08144ccc39a;p=ZOOM-Perl-moved-to-github.git diff --git a/lib/ZOOM.pm b/lib/ZOOM.pm index 0a42e3e..6b2f8c9 100644 --- a/lib/ZOOM.pm +++ b/lib/ZOOM.pm @@ -1,5 +1,3 @@ -# $Id: ZOOM.pm,v 1.48 2007-05-09 12:03:52 mike Exp $ - use strict; use warnings; use IO::File; @@ -113,6 +111,12 @@ sub diag_str { return Net::Z3950::ZOOM::diag_str($code); } +sub diag_srw_str { + my($code) = @_; + + return Net::Z3950::ZOOM::diag_srw_str($code); +} + sub event_str { return Net::Z3950::ZOOM::event_str(@_); } @@ -141,8 +145,11 @@ sub new { $diagset ||= "ZOOM"; if (uc($diagset) eq "ZOOM" || uc($diagset) eq "BIB-1") { $message ||= ZOOM::diag_str($code); + } elsif (lc($diagset) eq "info:srw/diagnostic/1") { + $message ||= ZOOM::diag_srw_str($code); } else { - # Should fill in messages for other diagsets, too. + # Should fill in messages for any other known diagsets. + $message ||= "(unknown error)"; } return bless { @@ -175,7 +182,9 @@ sub diagset { sub render { my $this = shift(); - my $res = "ZOOM error " . $this->code() . ' "' . $this->message() . '"'; + + my $res = "ZOOM error " . $this->code(); + $res .= ' "' . $this->message() . '"' if $this->message(); $res .= ' (addinfo: "' . $this->addinfo() . '")' if $this->addinfo(); $res .= " from diag-set '" . $this->diagset() . "'" if $this->diagset(); return $res; @@ -569,6 +578,14 @@ sub sortby { or ZOOM::_oops(ZOOM::Error::SORTBY, $sortby); } +sub sortby2 { + my $this = shift(); + my($strategy, $sortby) = @_; + + Net::Z3950::ZOOM::query_sortby2($this->_query(), $strategy, $sortby) == 0 + or ZOOM::_oops(ZOOM::Error::SORTBY, $sortby); +} + sub destroy { my $this = shift(); @@ -887,14 +904,7 @@ sub get { my($type, $args) = @_; $type = "$type;$args" if defined $args; - my $len = 0; - my $string = Net::Z3950::ZOOM::record_get($this->_rec(), $type, $len); - # I don't think we need '$len' at all. ### Probably the Perl-to-C - # glue code should use the value of `len' as well as the opaque - # data-pointer returned, to ensure that the SV contains all of the - # returned data and does not stop at the first NUL character in - # binary data. Carefully check the ZOOM_record_get() documentation. - return $string; + return Net::Z3950::ZOOM::record_get($this->_rec(), $type); } sub clone {