1 # $Id: Z3950.pm,v 1.2 2007-02-26 15:58:33 mike Exp $
7 our $VERSION = '0.99'; # Supersedes "proper" Net::Z3950 v0.51
10 # Member naming convention is the same as in ../ZOOM.pm
12 # ----------------------------------------------------------------------------
13 # Enumerations are copied from the old Net::Z3950 module.
14 # It's not entirely clear yet which of these we actually need, for for
15 # now I am commenting them all out, and faulting in the ones we need.
16 # ----------------------------------------------------------------------------
18 # Define the operation-code enumeration. The values here are chosen
19 # to be in a distinctive range (i.e. 3950 plus a small integer) so
20 # that if they are misused in another context, they're easy to spot.
21 package Net::Z3950::Op;
31 ## Define the record-syntax enumeration. These values must be kept
32 ## synchronised with the values implied by the oid_value enumeration in
33 ## the header file "yaz/oid.h"
34 #package Net::Z3950::RecordSyntax;
41 #sub LIBRISMARC { 22 }
62 #sub APPLICATION_XML { 81 }
65 ## Maps record-syntax name strings to enumeration members
66 #%map = (UNIMARC => UNIMARC,
67 # INTERMARC => INTERMARC,
72 # LIBRISMARC => LIBRISMARC,
78 # PICAMARC => PICAMARC,
80 # IBERMARC => IBERMARC,
89 # EXTENDED => EXTENDED,
90 # TEXT_HTML => TEXT_HTML,
92 # TEXT_XML => TEXT_XML,
93 # APPLICATION_XML => APPLICATION_XML,
98 ## Define the reason-for-decodeAPDU()-failure enumeration. This must
99 ## be kept synchronised with the values #defined in "yazwrap/yazwrap.h"
100 #package Net::Z3950::Reason;
101 #sub EOF { 23951 } # read EOF from connection (server gone)
102 #sub Incomplete { 23952 } # read bytes, but not yet a whole APDU
103 #sub Malformed { 23953 } # couldn't decode APDU (malformed)
104 #sub BadAPDU { 23954 } # APDU was well-formed but unrecognised
105 #sub Error { 23955 } # some other error (consult errno)
109 ## Define the query-type enumeration. This must be kept synchronised
110 ## with the values #defined in "yazwrap/yazwrap.h"
111 #package Net::Z3950::QueryType;
112 #sub Prefix { 39501 } # Yaz's "@attr"-ish forward-Polish notation
113 #sub CCL { 39502 } # Send CCL string to server ``as is''
114 #sub CCL2RPN { 39503 } # Convert CCL to RPN (type-1) locally
115 #sub CQL { 39504 } # Send CQL string to server ``as is''
119 ## Define the result-set-status enumeration, used by the
120 ## `resultSetStatus' field in the Net::Z3950::APDU::SearchResponse
121 ## class in cases where `searchStatus' is false (indicating failure).
122 ## This must be kept synchronised with the ASN.1 for the structure
123 ## described in section 3.2.2.1.11 of the Z39.50 standard itself.
124 #package Net::Z3950::ResultSetStatus;
131 ## Define the present-status enumeration, used by the `presentStatus'
132 ## field in the Net::Z3950::APDU::SearchResponse class in cases where
133 ## `searchStatus' is true (indicating success). This must be kept
134 ## synchronised with the ASN.1 for the structure described in section
135 ## 3.2.2.1.11 of the Z39.50 standard itself.
136 #package Net::Z3950::PresentStatus;
146 ## Define the scan-status enumeration, used by the `scanStatus'
147 ## field in the Net::Z3950::APDU::ScanResponse class. This must be
148 ## kept synchronised with the ASN.1 for the structure described in
149 ## section 3.2.8.1.6 of the Z39.50 standard itself.
150 #package Net::Z3950::ScanStatus;
160 # ----------------------------------------------------------------------------
166 # This is not 100% compatible, because it will translate
167 # ZOOM-level errors as well as BIB-1 diagnostic codes.
168 return Net::Z3950::ZOOM::diag_str($errcode)
173 return "error" if $op == Net::Z3950::Op::Error;
174 return "init" if $op == Net::Z3950::Op::Init;
175 return "search" if $op == Net::Z3950::Op::Search;
176 return "get" if $op == Net::Z3950::Op::Get;
177 return "deleteRS" if $op == Net::Z3950::Op::DeleteRS;
178 return "scan" if $op == Net::Z3950::Op::Scan;
179 return "unknown op " . $op;
183 # ----------------------------------------------------------------------------
185 package Net::Z3950::Manager;
186 sub new { Net::Z3950::Connection->new() }
189 # ----------------------------------------------------------------------------
191 package Net::Z3950::Connection;
194 die "The Net::Z3950::ZOOM distribution does not yet support the Net::Z3950 'Classic' API. A subsequent version will do so; until then, please continue using Net::Z3950 itself if you need its API."