Remove extraneous and misleading old CVS IDs
[ZOOM-Perl-moved-to-github.git] / lib / Net / Z3950.pm
1 use strict;
2 use warnings;
3 use Net::Z3950::ZOOM;
4
5 our $VERSION = '0.99';  # Supersedes "proper" Net::Z3950 v0.51
6
7
8 # Member naming convention is the same as in ../ZOOM.pm
9
10 # ----------------------------------------------------------------------------
11 # Enumerations are copied from the old Net::Z3950 module.
12 # It's not entirely clear yet which of these we actually need, for for
13 # now I am commenting them all out, and faulting in the ones we need.
14 # ----------------------------------------------------------------------------
15
16 # Define the operation-code enumeration.  The values here are chosen
17 # to be in a distinctive range (i.e. 3950 plus a small integer) so
18 # that if they are misused in another context, they're easy to spot.
19 package Net::Z3950::Op;
20 sub Error    { 3951 }
21 sub Init     { 3952 }
22 sub Search   { 3953 }
23 sub Get      { 3954 }
24 sub DeleteRS { 3955 }
25 sub Scan     { 3956 }
26 package Net::Z3950;
27
28
29 ## Define the record-syntax enumeration.  These values must be kept
30 ## synchronised with the values implied by the oid_value enumeration in
31 ## the header file "yaz/oid.h"
32 #package Net::Z3950::RecordSyntax;
33 #sub UNIMARC    { 16 }
34 #sub INTERMARC  { 17 }
35 #sub CCF        { 18 }
36 #sub USMARC     { 19 }
37 #sub UKMARC     { 20 }
38 #sub NORMARC    { 21 }
39 #sub LIBRISMARC { 22 }
40 #sub DANMARC    { 23 }
41 #sub FINMARC    { 24 }
42 #sub MAB        { 25 }
43 #sub CANMARC    { 26 }
44 #sub SBN        { 27 }
45 #sub PICAMARC   { 28 }
46 #sub AUSMARC    { 29 }
47 #sub IBERMARC   { 30 }
48 #sub CATMARC    { 31 }
49 #sub MALMARC    { 32 }
50 #sub EXPLAIN    { 33 }
51 #sub SUTRS      { 34 }
52 #sub OPAC       { 35 }
53 #sub SUMMARY    { 36 }
54 #sub GRS0       { 37 }
55 #sub GRS1       { 38 }
56 #sub EXTENDED   { 39 }
57 #sub TEXT_HTML  { 70 }
58 #sub XML        { 80 }
59 #sub TEXT_XML   { 80 }
60 #sub APPLICATION_XML { 81 }
61 #
62 #use vars '%map';
63 ## Maps record-syntax name strings to enumeration members
64 #%map = (UNIMARC => UNIMARC,
65 #       INTERMARC => INTERMARC,
66 #       CCF => CCF,
67 #       USMARC => USMARC,
68 #       UKMARC => UKMARC,
69 #       NORMARC => NORMARC,
70 #       LIBRISMARC => LIBRISMARC,
71 #       DANMARC => DANMARC,
72 #       FINMARC => FINMARC,
73 #       MAB => MAB,
74 #       CANMARC => CANMARC,
75 #       SBN => SBN,
76 #       PICAMARC => PICAMARC,
77 #       AUSMARC => AUSMARC,
78 #       IBERMARC => IBERMARC,
79 #       CATMARC => CATMARC,
80 #       MALMARC => MALMARC,
81 #       EXPLAIN => EXPLAIN,
82 #       SUTRS => SUTRS,
83 #       OPAC => OPAC,
84 #       SUMMARY => SUMMARY,
85 #       GRS0 => GRS0,
86 #       GRS1 => GRS1,
87 #       EXTENDED => EXTENDED,
88 #       TEXT_HTML => TEXT_HTML,
89 #       XML => XML,
90 #       TEXT_XML => TEXT_XML,
91 #       APPLICATION_XML => APPLICATION_XML,
92 #       );
93 #package Net::Z3950;
94 #
95 #
96 ## Define the reason-for-decodeAPDU()-failure enumeration.  This must
97 ## be kept synchronised with the values #defined in "yazwrap/yazwrap.h"
98 #package Net::Z3950::Reason;
99 #sub EOF        { 23951 }       # read EOF from connection (server gone)
100 #sub Incomplete { 23952 }       # read bytes, but not yet a whole APDU
101 #sub Malformed  { 23953 }       # couldn't decode APDU (malformed)
102 #sub BadAPDU    { 23954 }       # APDU was well-formed but unrecognised
103 #sub Error      { 23955 }       # some other error (consult errno)
104 #package Net::Z3950;
105 #
106 #
107 ## Define the query-type enumeration.  This must be kept synchronised
108 ## with the values #defined in "yazwrap/yazwrap.h"
109 #package Net::Z3950::QueryType;
110 #sub Prefix  { 39501 }          # Yaz's "@attr"-ish forward-Polish notation
111 #sub CCL     { 39502 }          # Send CCL string to server ``as is''
112 #sub CCL2RPN { 39503 }          # Convert CCL to RPN (type-1) locally
113 #sub CQL     { 39504 }          # Send CQL string to server ``as is''
114 #package Net::Z3950;
115 #
116 #
117 ## Define the result-set-status enumeration, used by the
118 ## `resultSetStatus' field in the Net::Z3950::APDU::SearchResponse
119 ## class in cases where `searchStatus' is false (indicating failure).
120 ## This must be kept synchronised with the ASN.1 for the structure
121 ## described in section 3.2.2.1.11 of the Z39.50 standard itself.
122 #package Net::Z3950::ResultSetStatus;
123 #sub Subset  { 1 }
124 #sub Interim { 2 }
125 #sub None    { 3 }
126 #package Net::Z3950;
127 #
128 #
129 ## Define the present-status enumeration, used by the `presentStatus'
130 ## field in the Net::Z3950::APDU::SearchResponse class in cases where
131 ## `searchStatus' is true (indicating success).  This must be kept
132 ## synchronised with the ASN.1 for the structure described in section
133 ## 3.2.2.1.11 of the Z39.50 standard itself.
134 #package Net::Z3950::PresentStatus;
135 #sub Success  { 0 }
136 #sub Partial1 { 1 }
137 #sub Partial2 { 2 }
138 #sub Partial3 { 3 }
139 #sub Partial4 { 4 }
140 #sub Failure  { 5 }
141 #package Net::Z3950;
142 #
143 #
144 ## Define the scan-status enumeration, used by the `scanStatus'
145 ## field in the Net::Z3950::APDU::ScanResponse class.  This must be
146 ## kept synchronised with the ASN.1 for the structure described in
147 ## section 3.2.8.1.6 of the Z39.50 standard itself.
148 #package Net::Z3950::ScanStatus;
149 #sub Success  { 0 }
150 #sub Partial1 { 1 }
151 #sub Partial2 { 2 }
152 #sub Partial3 { 3 }
153 #sub Partial4 { 4 }
154 #sub Partial5 { 5 }
155 #sub Failure  { 6 }
156 #package Net::Z3950;
157
158 # ----------------------------------------------------------------------------
159
160 package Net::Z3950;
161
162 sub errstr {
163     my($errcode) = @_;
164     # This is not 100% compatible, because it will translate
165     # ZOOM-level errors as well as BIB-1 diagnostic codes.
166     return Net::Z3950::ZOOM::diag_str($errcode)
167 }
168
169 sub opstr {
170     my($op) = @_;
171     return "error" if $op == Net::Z3950::Op::Error;
172     return "init" if $op == Net::Z3950::Op::Init;
173     return "search" if $op == Net::Z3950::Op::Search;
174     return "get" if $op == Net::Z3950::Op::Get;
175     return "deleteRS" if $op == Net::Z3950::Op::DeleteRS;
176     return "scan" if $op == Net::Z3950::Op::Scan;
177     return "unknown op " . $op;
178 }
179
180
181 # ----------------------------------------------------------------------------
182
183 package Net::Z3950::Manager;
184 sub new { Net::Z3950::Connection->new() }
185
186
187 # ----------------------------------------------------------------------------
188
189 package Net::Z3950::Connection;
190
191 sub new {
192     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."
193 }
194
195
196 1;