9 # Member naming convention: hash-element names which begin with an
10 # underscore represent underlying ZOOM-C object descriptors; those
11 # which lack them represent Perl's ZOOM objects. (The same convention
12 # is used in naming local variables where appropriate.)
14 # So, for example, the ZOOM::Connection class has an {_conn} element,
15 # which is a pointer to the ZOOM-C Connection object; but the
16 # ZOOM::ResultSet class has a {conn} element, which is a reference to
17 # the Perl-level Connection object by which it was created. (It may
18 # be that we find we have no need for these references, but for now
21 # To get at the underlying ZOOM-C connection object of a result-set
22 # (if you ever needed to do such a thing, which you probably don't)
23 # you'd use $rs->{conn}->_conn().
25 # ----------------------------------------------------------------------------
27 # The "Error" package contains constants returned as error-codes.
29 sub NONE { Net::Z3950::ZOOM::ERROR_NONE }
30 sub CONNECT { Net::Z3950::ZOOM::ERROR_CONNECT }
31 sub MEMORY { Net::Z3950::ZOOM::ERROR_MEMORY }
32 sub ENCODE { Net::Z3950::ZOOM::ERROR_ENCODE }
33 sub DECODE { Net::Z3950::ZOOM::ERROR_DECODE }
34 sub CONNECTION_LOST { Net::Z3950::ZOOM::ERROR_CONNECTION_LOST }
35 sub ZINIT { Net::Z3950::ZOOM::ERROR_INIT }
36 sub INTERNAL { Net::Z3950::ZOOM::ERROR_INTERNAL }
37 sub TIMEOUT { Net::Z3950::ZOOM::ERROR_TIMEOUT }
38 sub UNSUPPORTED_PROTOCOL { Net::Z3950::ZOOM::ERROR_UNSUPPORTED_PROTOCOL }
39 sub UNSUPPORTED_QUERY { Net::Z3950::ZOOM::ERROR_UNSUPPORTED_QUERY }
40 sub INVALID_QUERY { Net::Z3950::ZOOM::ERROR_INVALID_QUERY }
41 sub CQL_PARSE { Net::Z3950::ZOOM::ERROR_CQL_PARSE }
42 sub CQL_TRANSFORM { Net::Z3950::ZOOM::ERROR_CQL_TRANSFORM }
43 sub CCL_CONFIG { Net::Z3950::ZOOM::ERROR_CCL_CONFIG }
44 sub CCL_PARSE { Net::Z3950::ZOOM::ERROR_CCL_PARSE }
45 # The following are added specifically for this OO interface
46 sub CREATE_QUERY { 20001 }
47 sub QUERY_CQL { 20002 }
48 sub QUERY_PQF { 20003 }
52 sub SCANTERM { 20007 }
53 sub LOGLEVEL { 20008 }
55 # Separate space for CCL errors. Great.
56 package ZOOM::CCL::Error;
57 sub OK { Net::Z3950::ZOOM::CCL_ERR_OK }
58 sub TERM_EXPECTED { Net::Z3950::ZOOM::CCL_ERR_TERM_EXPECTED }
59 sub RP_EXPECTED { Net::Z3950::ZOOM::CCL_ERR_RP_EXPECTED }
60 sub SETNAME_EXPECTED { Net::Z3950::ZOOM::CCL_ERR_SETNAME_EXPECTED }
61 sub OP_EXPECTED { Net::Z3950::ZOOM::CCL_ERR_OP_EXPECTED }
62 sub BAD_RP { Net::Z3950::ZOOM::CCL_ERR_BAD_RP }
63 sub UNKNOWN_QUAL { Net::Z3950::ZOOM::CCL_ERR_UNKNOWN_QUAL }
64 sub DOUBLE_QUAL { Net::Z3950::ZOOM::CCL_ERR_DOUBLE_QUAL }
65 sub EQ_EXPECTED { Net::Z3950::ZOOM::CCL_ERR_EQ_EXPECTED }
66 sub BAD_RELATION { Net::Z3950::ZOOM::CCL_ERR_BAD_RELATION }
67 sub TRUNC_NOT_LEFT { Net::Z3950::ZOOM::CCL_ERR_TRUNC_NOT_LEFT }
68 sub TRUNC_NOT_BOTH { Net::Z3950::ZOOM::CCL_ERR_TRUNC_NOT_BOTH }
69 sub TRUNC_NOT_RIGHT { Net::Z3950::ZOOM::CCL_ERR_TRUNC_NOT_RIGHT }
71 # The "Event" package contains constants returned by last_event()
73 sub NONE { Net::Z3950::ZOOM::EVENT_NONE }
74 sub CONNECT { Net::Z3950::ZOOM::EVENT_CONNECT }
75 sub SEND_DATA { Net::Z3950::ZOOM::EVENT_SEND_DATA }
76 sub RECV_DATA { Net::Z3950::ZOOM::EVENT_RECV_DATA }
77 sub TIMEOUT { Net::Z3950::ZOOM::EVENT_TIMEOUT }
78 sub UNKNOWN { Net::Z3950::ZOOM::EVENT_UNKNOWN }
79 sub SEND_APDU { Net::Z3950::ZOOM::EVENT_SEND_APDU }
80 sub RECV_APDU { Net::Z3950::ZOOM::EVENT_RECV_APDU }
81 sub RECV_RECORD { Net::Z3950::ZOOM::EVENT_RECV_RECORD }
82 sub RECV_SEARCH { Net::Z3950::ZOOM::EVENT_RECV_SEARCH }
83 sub ZEND { Net::Z3950::ZOOM::EVENT_END }
85 # ----------------------------------------------------------------------------
92 # Special cases for error specific to the OO layer
93 if ($code == ZOOM::Error::CREATE_QUERY) {
94 return "can't create query object";
95 } elsif ($code == ZOOM::Error::QUERY_CQL) {
96 return "can't set CQL query";
97 } elsif ($code == ZOOM::Error::QUERY_PQF) {
98 return "can't set prefix query";
99 } elsif ($code == ZOOM::Error::SORTBY) {
100 return "can't set sort-specification";
101 } elsif ($code == ZOOM::Error::CLONE) {
102 return "can't clone record";
103 } elsif ($code == ZOOM::Error::PACKAGE) {
104 return "can't create package";
105 } elsif ($code == ZOOM::Error::SCANTERM) {
106 return "can't retrieve term from scan-set";
107 } elsif ($code == ZOOM::Error::LOGLEVEL) {
108 return "unregistered log-level";
111 return Net::Z3950::ZOOM::diag_str($code);
117 return Net::Z3950::ZOOM::diag_srw_str($code);
121 return Net::Z3950::ZOOM::event_str(@_);
127 my @_connsref = map { $_->_conn() } @$connsref;
128 return Net::Z3950::ZOOM::event(\@_connsref);
132 my($code, $addinfo, $diagset) = @_;
134 die new ZOOM::Exception($code, undef, $addinfo, $diagset);
137 # ----------------------------------------------------------------------------
139 package ZOOM::Exception;
143 my($code, $message, $addinfo, $diagset) = @_;
146 if (uc($diagset) eq "ZOOM" || uc($diagset) eq "BIB-1") {
147 $message ||= ZOOM::diag_str($code);
148 } elsif (lc($diagset) eq "info:srw/diagnostic/1") {
149 $message ||= ZOOM::diag_srw_str($code);
151 # Should fill in messages for any other known diagsets.
152 $message ||= "(unknown error)";
165 return $this->{code};
170 return $this->{message};
175 return $this->{addinfo};
180 return $this->{diagset};
186 my $res = "ZOOM error " . $this->code();
187 $res .= ' "' . $this->message() . '"' if $this->message();
188 $res .= ' (addinfo: "' . $this->addinfo() . '")' if $this->addinfo();
189 $res .= " from diag-set '" . $this->diagset() . "'" if $this->diagset();
193 # This means that untrapped exceptions render nicely.
194 use overload '""' => \&render;
196 # ----------------------------------------------------------------------------
198 package ZOOM::Options;
206 $opts = Net::Z3950::ZOOM::options_create();
208 $opts = Net::Z3950::ZOOM::options_create_with_parent($p1->_opts());
210 $opts = Net::Z3950::ZOOM::options_create_with_parent2($p1->_opts(),
213 die "can't make $class object with more than 2 parents";
221 # PRIVATE to this class and ZOOM::Connection::create() and
222 # ZOOM::Connection::package()
227 my $_opts = $this->{_opts};
228 die "{_opts} undefined: has this Options block been destroy()ed?"
236 my($key, $value) = @_;
238 my $oldval = Net::Z3950::ZOOM::options_get($this->_opts(), $key);
239 Net::Z3950::ZOOM::options_set($this->_opts(), $key, $value)
247 my($key, $value) = @_;
250 my $oldval = Net::Z3950::ZOOM::options_getl($this->_opts(),
252 Net::Z3950::ZOOM::options_setl($this->_opts(), $key,
253 $value, length($value))
259 # This is a bit stupid, since the scalar values that Perl returns from
260 # option() can be used as a boolean; but it's just possible that some
261 # applications will rely on ZOOM_options_get_bool()'s idiosyncratic
262 # interpretation of what constitutes truth.
266 my($key, $default) = @_;
268 return Net::Z3950::ZOOM::options_get_bool($this->_opts(), $key, $default);
271 # .. and the next two are even more stupid
274 my($key, $default) = @_;
276 return Net::Z3950::ZOOM::options_get_int($this->_opts(), $key, $default);
281 my($key, $value) = @_;
283 Net::Z3950::ZOOM::options_set_int($this->_opts(), $key, $value);
286 # ### Feel guilty. Feel very, very guilty. I've not been able to
287 # get the callback memory-management right in "ZOOM.xs", with
288 # the result that the values of $function and $udata passed into
289 # this function, which are on the stack, have sometimes been
290 # freed by the time they're used by __ZOOM_option_callback(),
291 # with hilarious results. To avoid this, I copy the values into
292 # module-scoped globals, and pass _those_ into the extension
293 # function. To avoid overwriting those globals by subsequent
294 # calls, I keep all the old ones, pushed onto the @_function and
295 # @_udata arrays, which means that THIS FUNCTION LEAKS MEMORY
296 # LIKE IT'S GOING OUT OF FASHION. Not nice. One day, I should
297 # fix this, but for now there's more important fish to fry.
299 my(@_function, @_udata);
302 my($function, $udata) = @_;
304 push @_function, $function;
305 push @_udata, $udata;
306 Net::Z3950::ZOOM::options_set_callback($o1->_opts(),
307 $_function[-1], $_udata[-1]);
313 Net::Z3950::ZOOM::options_destroy($this->_opts());
314 $this->{_opts} = undef;
318 # ----------------------------------------------------------------------------
320 package ZOOM::Connection;
324 my($host, $port, @options) = @_;
326 my $conn = $class->create(@options);
327 $conn->{host} = $host;
328 $conn->{port} = $port;
330 Net::Z3950::ZOOM::connection_connect($conn->_conn(), $host, $port || 0);
336 # PRIVATE to this class, to ZOOM::event() and to ZOOM::Query::CQL2RPN::new()
340 my $_conn = $this->{_conn};
341 die "{_conn} undefined: has this Connection been destroy()ed?"
349 my($always_die_on_error) = @_;
351 my($errcode, $errmsg, $addinfo, $diagset) = (undef, "x", "x", "x");
352 $errcode = Net::Z3950::ZOOM::connection_error_x($this->_conn(), $errmsg,
355 my $exception = new ZOOM::Exception($errcode, $errmsg, $addinfo,
357 if (!$this->option("async") || $always_die_on_error) {
358 ZOOM::Log::log("zoom_check", "throwing error $exception");
361 ZOOM::Log::log("zoom_check", "not reporting error $exception");
366 # This wrapper for _check() is called only from outside the ZOOM
367 # module, and therefore only in situations where an asynchronous
368 # application is actively asking for an exception to be thrown if an
369 # error has been detected. So it passed always_die_on_error=1 to the
370 # underlying _check() method.
374 return $this->_check(1);
383 $_opts = $_[0]->_opts();
385 $_opts = Net::Z3950::ZOOM::options_create();
386 while (@options >= 2) {
387 my $key = shift(@options);
388 my $val = shift(@options);
389 Net::Z3950::ZOOM::options_set($_opts, $key, $val);
392 die "Odd number of options specified"
396 my $_conn = Net::Z3950::ZOOM::connection_create($_opts);
408 my($errcode, $errmsg, $addinfo, $diagset) = (undef, "dummy", "dummy", "d");
409 $errcode = Net::Z3950::ZOOM::connection_error_x($this->_conn(), $errmsg,
411 return wantarray() ? ($errcode, $errmsg, $addinfo, $diagset) : $errcode;
417 my($errcode, $errmsg, $addinfo, $diagset) = $this->error_x();
418 return undef if $errcode == 0;
419 return new ZOOM::Exception($errcode, $errmsg, $addinfo, $diagset);
424 return Net::Z3950::ZOOM::connection_errcode($this->_conn());
429 return Net::Z3950::ZOOM::connection_errmsg($this->_conn());
434 return Net::Z3950::ZOOM::connection_addinfo($this->_conn());
439 return Net::Z3950::ZOOM::connection_diagset($this->_conn());
444 my($host, $port) = @_;
446 $port = 0 if !defined $port;
447 Net::Z3950::ZOOM::connection_connect($this->_conn(), $host, $port);
454 my($key, $value) = @_;
456 my $oldval = Net::Z3950::ZOOM::connection_option_get($this->_conn(), $key);
457 Net::Z3950::ZOOM::connection_option_set($this->_conn(), $key, $value)
465 my($key, $value) = @_;
468 my $oldval = Net::Z3950::ZOOM::connection_option_getl($this->_conn(),
470 Net::Z3950::ZOOM::connection_option_setl($this->_conn(), $key,
471 $value, length($value))
481 my $_rs = Net::Z3950::ZOOM::connection_search($this->_conn(),
484 return _new ZOOM::ResultSet($this, $query, $_rs);
491 my $_rs = Net::Z3950::ZOOM::connection_search_pqf($this->_conn(), $pqf);
493 return _new ZOOM::ResultSet($this, $pqf, $_rs);
500 my $_ss = Net::Z3950::ZOOM::connection_scan($this->_conn(), $startterm);
502 return _new ZOOM::ScanSet($this, $startterm, $_ss);
509 my $_ss = Net::Z3950::ZOOM::connection_scan1($this->_conn(),
512 return _new ZOOM::ScanSet($this, $query, $_ss);
519 my $_o = defined $options ? $options->_opts() :
520 Net::Z3950::ZOOM::options_create();
521 my $_p = Net::Z3950::ZOOM::connection_package($this->_conn(), $_o)
522 or ZOOM::_oops(ZOOM::Error::PACKAGE);
524 return _new ZOOM::Package($this, $options, $_p);
530 return Net::Z3950::ZOOM::connection_last_event($this->_conn());
536 return Net::Z3950::ZOOM::connection_is_idle($this->_conn());
542 return Net::Z3950::ZOOM::connection_peek_event($this->_conn());
548 Net::Z3950::ZOOM::connection_destroy($this->_conn());
549 $this->{_conn} = undef;
553 # ----------------------------------------------------------------------------
559 die "You can't create $class objects: it's a virtual base class";
562 # PRIVATE to this class and ZOOM::Connection::search()
566 my $_query = $this->{_query};
567 die "{_query} undefined: has this Query been destroy()ed?"
577 Net::Z3950::ZOOM::query_sortby($this->_query(), $sortby) == 0
578 or ZOOM::_oops(ZOOM::Error::SORTBY, $sortby);
584 Net::Z3950::ZOOM::query_destroy($this->_query());
585 $this->{_query} = undef;
589 package ZOOM::Query::CQL;
590 our @ISA = qw(ZOOM::Query);
596 my $q = Net::Z3950::ZOOM::query_create()
597 or ZOOM::_oops(ZOOM::Error::CREATE_QUERY);
598 Net::Z3950::ZOOM::query_cql($q, $string) == 0
599 or ZOOM::_oops(ZOOM::Error::QUERY_CQL, $string);
607 package ZOOM::Query::CQL2RPN;
608 our @ISA = qw(ZOOM::Query);
612 my($string, $conn) = @_;
614 my $q = Net::Z3950::ZOOM::query_create()
615 or ZOOM::_oops(ZOOM::Error::CREATE_QUERY);
616 # check() throws the exception we want; but we only want it on failure!
617 Net::Z3950::ZOOM::query_cql2rpn($q, $string, $conn->_conn()) == 0
626 # We have to work around the retarded ZOOM_query_ccl2rpn() API
627 package ZOOM::Query::CCL2RPN;
628 our @ISA = qw(ZOOM::Query);
632 my($string, $conn) = @_;
634 my $q = Net::Z3950::ZOOM::query_create()
635 or ZOOM::_oops(ZOOM::Error::CREATE_QUERY);
637 my $config = $conn->option("cclqual");
638 if (!defined $config) {
639 my $cclfile = $conn->option("cclfile")
640 or ZOOM::_oops(ZOOM::Error::CCL_CONFIG,
641 "no 'cclqual' or 'cclfile' specified");
642 my $fh = new IO::File("<$cclfile")
643 or ZOOM::_oops(ZOOM::Error::CCL_CONFIG,
644 "can't open cclfile '$cclfile': $!");
645 $config = join("", <$fh>);
649 my($ccl_errcode, $ccl_errstr, $ccl_errpos) = (0, "", 0);
650 if (Net::Z3950::ZOOM::query_ccl2rpn($q, $string, $config,
651 $ccl_errcode, $ccl_errstr,
653 # We have no use for $ccl_errcode or $ccl_errpos
654 ZOOM::_oops(ZOOM::Error::CCL_PARSE, $ccl_errstr);
663 package ZOOM::Query::PQF;
664 our @ISA = qw(ZOOM::Query);
670 my $q = Net::Z3950::ZOOM::query_create()
671 or ZOOM::_oops(ZOOM::Error::CREATE_QUERY);
672 Net::Z3950::ZOOM::query_prefix($q, $string) == 0
673 or ZOOM::_oops(ZOOM::Error::QUERY_PQF, $string);
681 # ----------------------------------------------------------------------------
683 package ZOOM::ResultSet;
687 die "You can't create $class objects directly";
690 # PRIVATE to ZOOM::Connection::search() and ZOOM::Connection::search_pqf()
693 my($conn, $query, $_rs) = @_;
697 query => $query, # This is not currently used, which is
698 # just as well since it could be
699 # either a string (when the RS is
700 # created with search_pqf()) or a
701 # ZOOM::Query object (when it's
702 # created with search())
707 # PRIVATE to this class
711 my $_rs = $this->{_rs};
712 die "{_rs} undefined: has this ResultSet been destroy()ed?"
720 my($key, $value) = @_;
722 my $oldval = Net::Z3950::ZOOM::resultset_option_get($this->_rs(), $key);
723 Net::Z3950::ZOOM::resultset_option_set($this->_rs(), $key, $value)
732 return Net::Z3950::ZOOM::resultset_size($this->_rs());
739 my $_rec = Net::Z3950::ZOOM::resultset_record($this->_rs(), $which);
740 $this->{conn}->_check();
742 # Even if no error has occurred, I think record() might
743 # legitimately return undef if we're running in asynchronous mode
744 # and the record just hasn't been retrieved yet. This goes double
745 # for record_immediate().
746 return undef if !defined $_rec;
748 # For some reason, I have to use the explicit "->" syntax in order
749 # to invoke the ZOOM::Record constructor here, even though I don't
750 # have to do the same for _new ZOOM::ResultSet above. Weird.
751 return ZOOM::Record->_new($this, $which, $_rec);
754 sub record_immediate {
758 my $_rec = Net::Z3950::ZOOM::resultset_record_immediate($this->_rs(),
760 $this->{conn}->_check();
761 # The record might legitimately not be there yet
762 return undef if !defined $_rec;
764 return ZOOM::Record->_new($this, $which, $_rec);
770 Net::Z3950::ZOOM::resultset_cache_reset($this->_rs());
775 my($start, $count, $return_records) = @_;
777 # If the request is out of range, ZOOM-C will currently (as of YAZ
778 # 2.1.38) no-op: it understandably refuses to build and send a
779 # known-bad APDU, but it doesn't set a diagnostic as it ought. So
780 # for now, we do it here. It would be more polite to stash the
781 # error-code in the ZOOM-C connection object for subsequent
782 # discovery (which is what ZOOM-C will presumably do itself when
783 # it's fixed) but since there is no API that allows us to do that,
784 # we just have to throw the exception right now. That's probably
785 # OK for synchronous applications, but not really for
787 my $size = $this->size();
788 if ($start + $count-1 >= $size) {
789 # BIB-1 diagnostic 13 is "Present request out-of-range"
790 ZOOM::_oops(13, undef, "BIB-1");
793 my $raw = Net::Z3950::ZOOM::resultset_records($this->_rs(), $start, $count,
795 # By design, $raw may be undefined (if $return_records is true)
796 return undef if !defined $raw;
798 # We need to package up the returned records in ZOOM::Record objects
800 for my $i (0 .. @$raw-1) {
801 my $_rec = $raw->[$i];
802 if (!defined $_rec) {
805 push @res, ZOOM::Record->_new($this, $start+$i, $_rec);
814 my($sort_type, $sort_spec) = @_;
816 return Net::Z3950::ZOOM::resultset_sort1($this->_rs(),
817 $sort_type, $sort_spec);
823 Net::Z3950::ZOOM::resultset_destroy($this->_rs());
824 $this->{_rs} = undef;
828 # ----------------------------------------------------------------------------
830 package ZOOM::Record;
834 die "You can't create $class objects directly";
837 # PRIVATE to ZOOM::ResultSet::record(),
838 # ZOOM::ResultSet::record_immediate(), ZOOM::ResultSet::records() and
839 # ZOOM::Record::clone()
843 my($rs, $which, $_rec) = @_;
852 # PRIVATE to this class
856 my $_rec = $this->{_rec};
857 die "{_rec} undefined: has this Record been destroy()ed?"
866 my($errcode, $errmsg, $addinfo, $diagset) = (undef, "dummy", "dummy", "d");
867 $errcode = Net::Z3950::ZOOM::record_error($this->_rec(), $errmsg,
870 return wantarray() ? ($errcode, $errmsg, $addinfo, $diagset) : $errcode;
876 my($errcode, $errmsg, $addinfo, $diagset) = $this->error();
877 return undef if $errcode == 0;
878 return new ZOOM::Exception($errcode, $errmsg, $addinfo, $diagset);
885 return $this->get("render", @_);
891 return $this->get("raw", @_);
896 my($type, $args) = @_;
898 $type = "$type;$args" if defined $args;
899 return Net::Z3950::ZOOM::record_get($this->_rec(), $type);
905 my $raw = Net::Z3950::ZOOM::record_clone($this->_rec())
906 or ZOOM::_oops(ZOOM::Error::CLONE);
908 # Arg 1 (rs) is undefined as the new record doesn't belong to an RS
909 return _new ZOOM::Record(undef, undef, $raw);
915 Net::Z3950::ZOOM::record_destroy($this->_rec());
916 $this->{_rec} = undef;
920 # ----------------------------------------------------------------------------
922 package ZOOM::ScanSet;
926 die "You can't create $class objects directly";
929 # PRIVATE to ZOOM::Connection::scan(),
932 my($conn, $startterm, $_ss) = @_;
936 startterm => $startterm,# This is not currently used, which is
937 # just as well since it could be
938 # either a string (when the SS is
939 # created with scan()) or a
940 # ZOOM::Query object (when it's
941 # created with scan1())
946 # PRIVATE to this class
950 my $_ss = $this->{_ss};
951 die "{_ss} undefined: has this ScanSet been destroy()ed?"
959 my($key, $value) = @_;
961 my $oldval = Net::Z3950::ZOOM::scanset_option_get($this->_ss(), $key);
962 Net::Z3950::ZOOM::scanset_option_set($this->_ss(), $key, $value)
971 return Net::Z3950::ZOOM::scanset_size($this->_ss());
978 my($occ, $len) = (0, 0);
979 my $term = Net::Z3950::ZOOM::scanset_term($this->_ss(), $which,
981 or ZOOM::_oops(ZOOM::Error::SCANTERM);
983 die "length of term '$term' differs from returned len=$len"
984 if length($term) != $len;
986 return ($term, $occ);
993 my($occ, $len) = (0, 0);
994 my $term = Net::Z3950::ZOOM::scanset_display_term($this->_ss(), $which,
996 or ZOOM::_oops(ZOOM::Error::SCANTERM);
998 die "length of display term '$term' differs from returned len=$len"
999 if length($term) != $len;
1001 return ($term, $occ);
1007 Net::Z3950::ZOOM::scanset_destroy($this->_ss());
1008 $this->{_ss} = undef;
1012 # ----------------------------------------------------------------------------
1014 package ZOOM::Package;
1017 my $class = shift();
1018 die "You can't create $class objects directly";
1021 # PRIVATE to ZOOM::Connection::package(),
1023 my $class = shift();
1024 my($conn, $options, $_p) = @_;
1028 options => $options,
1033 # PRIVATE to this class
1037 my $_p = $this->{_p};
1038 die "{_p} undefined: has this Package been destroy()ed?"
1046 my($key, $value) = @_;
1048 my $oldval = Net::Z3950::ZOOM::package_option_get($this->_p(), $key);
1049 Net::Z3950::ZOOM::package_option_set($this->_p(), $key, $value)
1059 Net::Z3950::ZOOM::package_send($this->_p(), $type);
1060 $this->{conn}->_check();
1066 Net::Z3950::ZOOM::package_destroy($this->_p());
1067 $this->{_p} = undef;
1071 # There follows trivial support for YAZ logging. This is wired out
1072 # into the Net::Z3950::ZOOM package, and we here provide wrapper
1073 # functions -- nothing more than aliases, really -- in the ZOOM::Log
1074 # package. There really is no point in inventing an OO interface.
1076 # Passing @_ directly to the underlying Net::Z3950::ZOOM::* functions
1077 # doesn't work, for reasons that I can't begin to fathom, and that
1078 # don't particularly interest me. Unpacking into scalars and passing
1079 # those _does_ work, so that's what we do.
1083 sub mask_str { my($a) = @_; Net::Z3950::ZOOM::yaz_log_mask_str($a); }
1084 sub module_level { my($a) = @_; Net::Z3950::ZOOM::yaz_log_module_level($a); }
1085 sub init { my($a, $b, $c) = @_;
1086 Net::Z3950::ZOOM::yaz_log_init($a, $b, $c) }
1087 sub init_file { my($a) = @_; Net::Z3950::ZOOM::yaz_log_init_file($a) }
1088 sub init_level { my($a) = @_; Net::Z3950::ZOOM::yaz_log_init_level($a) }
1089 sub init_prefix { my($a) = @_; Net::Z3950::ZOOM::yaz_log_init_prefix($a) }
1090 sub time_format { my($a) = @_; Net::Z3950::ZOOM::yaz_log_time_format($a) }
1091 sub init_max_size { my($a) = @_; Net::Z3950::ZOOM::yaz_log_init_max_size($a) }
1094 my($level, @message) = @_;
1096 if ($level !~ /^(0x)?\d+$/) {
1097 # Assuming its log-level name, we look it up.
1098 my $num = module_level($level);
1099 ZOOM::_oops(ZOOM::Error::LOGLEVEL, $level)
1104 Net::Z3950::ZOOM::yaz_log($level, join("", @message));
1107 BEGIN { ZOOM::Log::mask_str("zoom_check"); }