1 | /*
|
---|
2 | * Copyright (c) 1995-2000, Index Data
|
---|
3 | * See the file LICENSE for details.
|
---|
4 | *
|
---|
5 | * $Log$
|
---|
6 | * Revision 1.1 2000/08/03 03:12:09 johnmcp
|
---|
7 | * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
|
---|
8 | *
|
---|
9 | * Revision 1.42 2000/02/29 13:44:55 adam
|
---|
10 | * Check for config.h (currently not generated).
|
---|
11 | *
|
---|
12 | * Revision 1.41 2000/01/10 15:16:53 adam
|
---|
13 | * Added several OID's.
|
---|
14 | *
|
---|
15 | * Revision 1.40 2000/01/06 14:59:13 adam
|
---|
16 | * Added oid_init/oid_exit. Changed oid_exit.
|
---|
17 | *
|
---|
18 | * Revision 1.39 1999/12/16 23:36:19 adam
|
---|
19 | * Implemented ILL protocol. Minor updates ASN.1 compiler.
|
---|
20 | *
|
---|
21 | * Revision 1.38 1999/11/30 13:47:12 adam
|
---|
22 | * Improved installation. Moved header files to include/yaz.
|
---|
23 | *
|
---|
24 | * Revision 1.37 1999/09/13 12:51:15 adam
|
---|
25 | * Added CLIENT IP OID.
|
---|
26 | *
|
---|
27 | * Revision 1.36 1999/05/27 13:02:20 adam
|
---|
28 | * Assigned OID for old DB Update (VAL_DBUPDATE0).
|
---|
29 | *
|
---|
30 | * Revision 1.35 1999/04/20 09:56:49 adam
|
---|
31 | * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
|
---|
32 | * Modified all encoders/decoders to reflect this change.
|
---|
33 | *
|
---|
34 | * Revision 1.34 1999/04/15 09:19:43 adam
|
---|
35 | * Added COOKIE UserInfo OID.
|
---|
36 | *
|
---|
37 | * Revision 1.33 1999/04/09 12:16:11 adam
|
---|
38 | * Added OtherInfo private OID proxy.
|
---|
39 | *
|
---|
40 | * Revision 1.32 1999/02/18 10:30:46 quinn
|
---|
41 | * Changed ES: Update OID
|
---|
42 | *
|
---|
43 | * Revision 1.31 1998/12/03 11:33:05 adam
|
---|
44 | * Added OID's for XML.
|
---|
45 | *
|
---|
46 | * Revision 1.30 1998/10/18 07:48:56 adam
|
---|
47 | * Fixed oid_getentbyoid so that it returns NULL when parsed oid is NULL.
|
---|
48 | *
|
---|
49 | * Revision 1.29 1998/10/14 13:32:35 adam
|
---|
50 | * Added include of string.h.
|
---|
51 | *
|
---|
52 | * Revision 1.28 1998/10/13 16:01:53 adam
|
---|
53 | * Implemented support for dynamic object identifiers.
|
---|
54 | * Function oid_getvalbyname now accepts raw OID's as well as traditional
|
---|
55 | * names.
|
---|
56 | *
|
---|
57 | * Revision 1.27 1998/05/18 10:10:02 adam
|
---|
58 | * Added Explain-schema and Explain-tagset to OID database.
|
---|
59 | *
|
---|
60 | * Revision 1.26 1998/03/20 14:46:06 adam
|
---|
61 | * Added UNIverse Resource Reports.
|
---|
62 | *
|
---|
63 | * Revision 1.25 1998/02/10 15:32:03 adam
|
---|
64 | * Added new Object Identifiers.
|
---|
65 | *
|
---|
66 | * Revision 1.24 1997/09/29 13:19:00 adam
|
---|
67 | * Added function, oid_ent_to_oid, to replace the function
|
---|
68 | * oid_getoidbyent, which is not thread safe.
|
---|
69 | *
|
---|
70 | * Revision 1.23 1997/09/09 10:10:19 adam
|
---|
71 | * Another MSV5.0 port. Changed projects to include proper
|
---|
72 | * library/include paths.
|
---|
73 | * Server starts server in test-mode when no options are given.
|
---|
74 | *
|
---|
75 | * Revision 1.22 1997/08/29 13:34:58 quinn
|
---|
76 | * Added thesaurus oids
|
---|
77 | *
|
---|
78 | * Revision 1.21 1997/08/19 08:46:05 quinn
|
---|
79 | * Added Thesaurus OID
|
---|
80 | *
|
---|
81 | * Revision 1.20 1997/07/28 12:34:43 adam
|
---|
82 | * Added new OID entries (RVDM).
|
---|
83 | *
|
---|
84 | * Revision 1.19 1997/05/02 08:39:41 quinn
|
---|
85 | * Support for private OID table added. Thanks to Ronald van der Meer
|
---|
86 | *
|
---|
87 | * Revision 1.18 1997/04/30 08:52:12 quinn
|
---|
88 | * Null
|
---|
89 | *
|
---|
90 | * Revision 1.17 1996/10/10 12:35:23 quinn
|
---|
91 | * Added Update extended service.
|
---|
92 | *
|
---|
93 | * Revision 1.16 1996/10/09 15:55:02 quinn
|
---|
94 | * Added SearchInfoReport
|
---|
95 | *
|
---|
96 | * Revision 1.15 1996/10/07 15:29:43 quinn
|
---|
97 | * Added SOIF support
|
---|
98 | *
|
---|
99 | * Revision 1.14 1996/02/20 17:58:28 adam
|
---|
100 | * Added const to oid_getvalbyname.
|
---|
101 | *
|
---|
102 | * Revision 1.13 1996/02/20 16:37:33 quinn
|
---|
103 | * Using yaz_matchstr in oid_getvalbyname
|
---|
104 | *
|
---|
105 | * Revision 1.12 1996/01/02 08:57:53 quinn
|
---|
106 | * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
|
---|
107 | *
|
---|
108 | * Revision 1.11 1995/12/13 16:03:35 quinn
|
---|
109 | * *** empty log message ***
|
---|
110 | *
|
---|
111 | * Revision 1.10 1995/11/28 09:30:44 quinn
|
---|
112 | * Work.
|
---|
113 | *
|
---|
114 | * Revision 1.9 1995/11/13 09:27:53 quinn
|
---|
115 | * Fiddling with the variant stuff.
|
---|
116 | *
|
---|
117 | * Revision 1.8 1995/10/12 10:34:56 quinn
|
---|
118 | * Added Espec-1.
|
---|
119 | *
|
---|
120 | * Revision 1.7 1995/10/10 16:27:12 quinn
|
---|
121 | * *** empty log message ***
|
---|
122 | *
|
---|
123 | * Revision 1.6 1995/09/29 17:12:35 quinn
|
---|
124 | * Smallish
|
---|
125 | *
|
---|
126 | * Revision 1.5 1995/09/29 17:01:51 quinn
|
---|
127 | * More Windows work
|
---|
128 | *
|
---|
129 | * Revision 1.4 1995/09/27 15:03:03 quinn
|
---|
130 | * Modified function heads & prototypes.
|
---|
131 | *
|
---|
132 | * Revision 1.3 1995/09/12 11:32:06 quinn
|
---|
133 | * Added a looker-upper by name.
|
---|
134 | *
|
---|
135 | * Revision 1.2 1995/08/21 09:11:16 quinn
|
---|
136 | * Smallish fixes to suppport new formats.
|
---|
137 | *
|
---|
138 | * Revision 1.1 1995/05/29 08:17:13 quinn
|
---|
139 | * iMoved oid to util to support comstack.
|
---|
140 | *
|
---|
141 | * Revision 1.5 1995/05/22 11:30:16 quinn
|
---|
142 | * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
|
---|
143 | *
|
---|
144 | * Revision 1.4 1995/05/16 08:50:22 quinn
|
---|
145 | * License, documentation, and memory fixes
|
---|
146 | *
|
---|
147 | * Revision 1.3 1995/04/11 11:52:02 quinn
|
---|
148 | * Fixed possible buf in proto.c
|
---|
149 | *
|
---|
150 | * Revision 1.2 1995/03/29 15:39:38 quinn
|
---|
151 | * Adding some resource control elements, and a null-check to getentbyoid
|
---|
152 | *
|
---|
153 | * Revision 1.1 1995/03/27 08:32:12 quinn
|
---|
154 | * Added OID database
|
---|
155 | *
|
---|
156 | *
|
---|
157 | */
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * More or less protocol-transparent OID database.
|
---|
161 | * We could (and should?) extend this so that the user app can add new
|
---|
162 | * entries to the list at initialization.
|
---|
163 | */
|
---|
164 | #if HAVE_CONFIG_H
|
---|
165 | #include <config.h>
|
---|
166 | #endif
|
---|
167 |
|
---|
168 | #include <stdlib.h>
|
---|
169 | #include <string.h>
|
---|
170 | #include <ctype.h>
|
---|
171 |
|
---|
172 | #include <yaz/oid.h>
|
---|
173 | #include <yaz/yaz-util.h>
|
---|
174 |
|
---|
175 | static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
|
---|
176 | static int sr_prefix[] = { 1, 0, 10163, -1 };
|
---|
177 |
|
---|
178 | struct oident_list {
|
---|
179 | struct oident oident;
|
---|
180 | struct oident_list *next;
|
---|
181 | };
|
---|
182 |
|
---|
183 | static struct oident_list *oident_table = NULL;
|
---|
184 | static int oid_value_dynamic = VAL_DYNAMIC;
|
---|
185 | static int oid_init_flag = 0;
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * OID database
|
---|
189 | */
|
---|
190 | static oident oids[] =
|
---|
191 | {
|
---|
192 | /* General definitions */
|
---|
193 | {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1},
|
---|
194 | "BER" },
|
---|
195 | {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},
|
---|
196 | "ISO2709"},
|
---|
197 | {PROTO_GENERAL, CLASS_GENERAL, VAL_ISO_ILL_1, {1,2,10161,2,1,-1},
|
---|
198 | "ISOILL-1"},
|
---|
199 | /* Z39.50v3 definitions */
|
---|
200 | {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1},
|
---|
201 | "Z-APDU"},
|
---|
202 | {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1},
|
---|
203 | "Z-BASIC"},
|
---|
204 | {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1},
|
---|
205 | "Bib-1"},
|
---|
206 | {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1},
|
---|
207 | "Exp-1"},
|
---|
208 | {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1},
|
---|
209 | "Ext-1"},
|
---|
210 | {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1},
|
---|
211 | "CCL-1"},
|
---|
212 | {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1},
|
---|
213 | "GILS-attset"},
|
---|
214 | {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1},
|
---|
215 | "STAS-attset"},
|
---|
216 | {PROTO_Z3950, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1},
|
---|
217 | "Collections-attset"},
|
---|
218 | {PROTO_Z3950, CLASS_ATTSET, VAL_CIMI1, {3,8,-1},
|
---|
219 | "CIMI-attset"},
|
---|
220 | {PROTO_Z3950, CLASS_ATTSET, VAL_GEO, {3,9,-1},
|
---|
221 | "Geo-attset"},
|
---|
222 |
|
---|
223 | {PROTO_Z3950, CLASS_ATTSET, VAL_ZBIG, {3,10,-1},
|
---|
224 | "ZBIG"},
|
---|
225 | {PROTO_Z3950, CLASS_ATTSET, VAL_UTIL, {3,11,-1},
|
---|
226 | "Util"},
|
---|
227 | {PROTO_Z3950, CLASS_ATTSET, VAL_XD1, {3,12,-1},
|
---|
228 | "XD-1"},
|
---|
229 | {PROTO_Z3950, CLASS_ATTSET, VAL_ZTHES, {3,13,-1},
|
---|
230 | "Zthes"},
|
---|
231 | {PROTO_Z3950, CLASS_ATTSET, VAL_FIN1, {3,14,-1},
|
---|
232 | "Fin-1"},
|
---|
233 | {PROTO_Z3950, CLASS_ATTSET, VAL_DAN1, {3,15,-1},
|
---|
234 | "Dan-1"},
|
---|
235 |
|
---|
236 | {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1},
|
---|
237 | "Thesaurus-attset"},
|
---|
238 | {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1},
|
---|
239 | "Bib-1"},
|
---|
240 | {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1},
|
---|
241 | "Diag-1"},
|
---|
242 | {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG_ES, {4,3,-1},
|
---|
243 | "Diag-ES"},
|
---|
244 | {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG_GENERAL, {4,3,-1},
|
---|
245 | "Diag-General"},
|
---|
246 | {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1},
|
---|
247 | "Unimarc"},
|
---|
248 | {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1},
|
---|
249 | "Intermarc"},
|
---|
250 | {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1},
|
---|
251 | "CCF"},
|
---|
252 | {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1},
|
---|
253 | "USmarc"},
|
---|
254 | {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1},
|
---|
255 | "UKmarc"},
|
---|
256 | {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1},
|
---|
257 | "Normarc"},
|
---|
258 | {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC, {5,13,-1},
|
---|
259 | "Librismarc"},
|
---|
260 | {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1},
|
---|
261 | "Danmarc"},
|
---|
262 | {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1},
|
---|
263 | "Finmarc"},
|
---|
264 | {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1},
|
---|
265 | "MAB"},
|
---|
266 | {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1},
|
---|
267 | "Canmarc"},
|
---|
268 | {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1},
|
---|
269 | "SBN"},
|
---|
270 | {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1},
|
---|
271 | "Picamarc"},
|
---|
272 | {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1},
|
---|
273 | "Ausmarc"},
|
---|
274 | {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1},
|
---|
275 | "Ibermarc"},
|
---|
276 | {PROTO_Z3950, CLASS_RECSYN, VAL_CATMARC, {5,22,-1},
|
---|
277 | "Carmarc"},
|
---|
278 | {PROTO_Z3950, CLASS_RECSYN, VAL_MALMARC, {5,23,-1},
|
---|
279 | "Malmarc"},
|
---|
280 | {PROTO_Z3950, CLASS_RECSYN, VAL_JPMARC, {5,24,-1},
|
---|
281 | "JPmarc"},
|
---|
282 | {PROTO_Z3950, CLASS_RECSYN, VAL_SWEMARC, {5,25,-1},
|
---|
283 | "SWEmarc"},
|
---|
284 | {PROTO_Z3950, CLASS_RECSYN, VAL_SIGLEMARC, {5,26,-1},
|
---|
285 | "SIGLEmarc"},
|
---|
286 | {PROTO_Z3950, CLASS_RECSYN, VAL_ISDSMARC, {5,27,-1},
|
---|
287 | "ISDSmarc"},
|
---|
288 | {PROTO_Z3950, CLASS_RECSYN, VAL_RUSMARC, {5,28,-1},
|
---|
289 | "RUSmarc"},
|
---|
290 | {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1},
|
---|
291 | "Explain"},
|
---|
292 | {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1},
|
---|
293 | "SUTRS"},
|
---|
294 | {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1},
|
---|
295 | "OPAC"},
|
---|
296 | {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1},
|
---|
297 | "Summary"},
|
---|
298 | {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1},
|
---|
299 | "GRS-0"},
|
---|
300 | {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1},
|
---|
301 | "GRS-1"},
|
---|
302 | {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1},
|
---|
303 | "Extended"},
|
---|
304 | {PROTO_Z3950, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1},
|
---|
305 | "Fragment"},
|
---|
306 | {PROTO_Z3950, CLASS_RECSYN, VAL_PDF, {5,109,1,-1},
|
---|
307 | "pdf"},
|
---|
308 | {PROTO_Z3950, CLASS_RECSYN, VAL_POSTSCRIPT, {5,109,2,-1},
|
---|
309 | "postscript"},
|
---|
310 | {PROTO_Z3950, CLASS_RECSYN, VAL_HTML, {5,109,3,-1},
|
---|
311 | "html"},
|
---|
312 | {PROTO_Z3950, CLASS_RECSYN, VAL_TIFF, {5,109,4,-1},
|
---|
313 | "tiff"},
|
---|
314 | {PROTO_Z3950, CLASS_RECSYN, VAL_GIF, {5,109,5,-1},
|
---|
315 | "gif"},
|
---|
316 | {PROTO_Z3950, CLASS_RECSYN, VAL_JPEG, {5,109,6,-1},
|
---|
317 | "jpeg"},
|
---|
318 | {PROTO_Z3950, CLASS_RECSYN, VAL_PNG, {5,109,7,-1},
|
---|
319 | "png"},
|
---|
320 | {PROTO_Z3950, CLASS_RECSYN, VAL_MPEG, {5,109,8,-1},
|
---|
321 | "mpeg"},
|
---|
322 | {PROTO_Z3950, CLASS_RECSYN, VAL_SGML, {5,109,9,-1},
|
---|
323 | "sgml"},
|
---|
324 |
|
---|
325 | {PROTO_Z3950, CLASS_RECSYN, VAL_TIFFB, {5,110,1,-1},
|
---|
326 | "tiff-b"},
|
---|
327 | {PROTO_Z3950, CLASS_RECSYN, VAL_WAV, {5,110,2,-1},
|
---|
328 | "wav"},
|
---|
329 |
|
---|
330 | {PROTO_Z3950, CLASS_RECSYN, VAL_SQLRS, {5,111,-1},
|
---|
331 | "SQL-RS"},
|
---|
332 | {PROTO_Z3950, CLASS_RECSYN, VAL_SOIF, {5,1000,81,2,-1},
|
---|
333 | "SOIF" },
|
---|
334 | {PROTO_Z3950, CLASS_RECSYN, VAL_TEXT_XML, {5,109,10,-1},
|
---|
335 | "text-XML" },
|
---|
336 | {PROTO_Z3950, CLASS_RECSYN, VAL_TEXT_XML, {5,109,10,-1},
|
---|
337 | "XML" },
|
---|
338 | {PROTO_Z3950, CLASS_RECSYN, VAL_APPLICATION_XML, {5,109,11,-1},
|
---|
339 | "application-XML" },
|
---|
340 | {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1},
|
---|
341 | "Resource-1"},
|
---|
342 | {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1},
|
---|
343 | "Resource-2"},
|
---|
344 | {PROTO_Z3950, CLASS_RESFORM, VAL_UNIVERSE_REPORT, {7,1000,81,1,-1},
|
---|
345 | "UNIverse-Resource-Report"},
|
---|
346 |
|
---|
347 | {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1},
|
---|
348 | "Prompt-1"},
|
---|
349 | {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1},
|
---|
350 | "Des-1"},
|
---|
351 | {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1},
|
---|
352 | "Krb-1"},
|
---|
353 | {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1},
|
---|
354 | "Pers. set"},
|
---|
355 | {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1},
|
---|
356 | "Pers. query"},
|
---|
357 | {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1},
|
---|
358 | "Per'd query"},
|
---|
359 | {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1},
|
---|
360 | "Item order"},
|
---|
361 | {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE0, {9,5,1,-1},
|
---|
362 | "DB. Update (old version)"},
|
---|
363 | {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,1,1,-1},
|
---|
364 | "DB. Update"},
|
---|
365 | {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC, {9,6,-1},
|
---|
366 | "exp. spec."},
|
---|
367 | {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1},
|
---|
368 | "exp. inv."},
|
---|
369 |
|
---|
370 | {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1, {10,1,-1},
|
---|
371 | "searchResult-1"},
|
---|
372 | {PROTO_Z3950, CLASS_USERINFO,VAL_CHARLANG, {10,2,-1},
|
---|
373 | "CharSetandLanguageNegotiation"},
|
---|
374 | {PROTO_Z3950, CLASS_USERINFO,VAL_USERINFO1, {10,3,-1},
|
---|
375 | "UserInfo-1"},
|
---|
376 | {PROTO_Z3950, CLASS_USERINFO,VAL_MULTISRCH1, {10,4,-1},
|
---|
377 | "MultipleSearchTerms-1"},
|
---|
378 | {PROTO_Z3950, CLASS_USERINFO,VAL_MULTISRCH2, {10,5,-1},
|
---|
379 | "MultipleSearchTerms-2"},
|
---|
380 | {PROTO_Z3950, CLASS_USERINFO,VAL_DATETIME, {10,6,-1},
|
---|
381 | "DateTime"},
|
---|
382 | {PROTO_Z3950, CLASS_USERINFO,VAL_PROXY, {10,1000,81,1,-1},
|
---|
383 | "Proxy" },
|
---|
384 | {PROTO_Z3950, CLASS_USERINFO,VAL_COOKIE, {10,1000,81,2,-1},
|
---|
385 | "Cookie" },
|
---|
386 | {PROTO_Z3950, CLASS_USERINFO,VAL_CLIENT_IP, {10,1000,81,3,-1},
|
---|
387 | "Client-IP" },
|
---|
388 | {PROTO_Z3950, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1},
|
---|
389 | "Espec-1"},
|
---|
390 | {PROTO_Z3950, CLASS_VARSET, VAL_VAR1, {12,1,-1},
|
---|
391 | "Variant-1"},
|
---|
392 | {PROTO_Z3950, CLASS_SCHEMA, VAL_WAIS, {13,1,-1},
|
---|
393 | "WAIS-schema"},
|
---|
394 | {PROTO_Z3950, CLASS_SCHEMA, VAL_GILS, {13,2,-1},
|
---|
395 | "GILS-schema"},
|
---|
396 | {PROTO_Z3950, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1},
|
---|
397 | "Collections-schema"},
|
---|
398 | {PROTO_Z3950, CLASS_SCHEMA, VAL_GEO, {13,4,-1},
|
---|
399 | "Geo-schema"},
|
---|
400 | {PROTO_Z3950, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1},
|
---|
401 | "CIMI-schema"},
|
---|
402 | {PROTO_Z3950, CLASS_SCHEMA, VAL_UPDATEES, {13,6,-1},
|
---|
403 | "Update ES"},
|
---|
404 | {PROTO_Z3950, CLASS_SCHEMA, VAL_THESAURUS, {13,1000,81,1,-1},
|
---|
405 | "thesaurus-schema"},
|
---|
406 | {PROTO_Z3950, CLASS_SCHEMA, VAL_EXPLAIN, {13,1000,81,2,-1},
|
---|
407 | "Explain-schema"},
|
---|
408 | {PROTO_Z3950, CLASS_TAGSET, VAL_SETM, {14,1,-1},
|
---|
409 | "TagsetM"},
|
---|
410 | {PROTO_Z3950, CLASS_TAGSET, VAL_SETG, {14,2,-1},
|
---|
411 | "TagsetG"},
|
---|
412 | {PROTO_Z3950, CLASS_TAGSET, VAL_STAS, {14,3,-1},
|
---|
413 | "STAS-tagset"},
|
---|
414 | {PROTO_Z3950, CLASS_TAGSET, VAL_GILS, {14,4,-1},
|
---|
415 | "GILS-tagset"},
|
---|
416 | {PROTO_Z3950, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1},
|
---|
417 | "Collections-tagset"},
|
---|
418 | {PROTO_Z3950, CLASS_TAGSET, VAL_CIMI1, {14,6,-1},
|
---|
419 | "CIMI-tagset"},
|
---|
420 | {PROTO_Z3950, CLASS_TAGSET, VAL_THESAURUS, {14,1000,81,1,-1},
|
---|
421 | "thesaurus-tagset"},
|
---|
422 | {PROTO_Z3950, CLASS_TAGSET, VAL_EXPLAIN, {14,1000,81,2,-1},
|
---|
423 | "Explain-tagset"},
|
---|
424 |
|
---|
425 |
|
---|
426 | /* SR definitions. Note that some of them aren't defined by the
|
---|
427 | standard (yet), but are borrowed from Z3950v3 */
|
---|
428 | {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
|
---|
429 |
|
---|
430 | {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
|
---|
431 |
|
---|
432 | {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
|
---|
433 | {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
|
---|
434 | {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
|
---|
435 | {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
|
---|
436 | {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
|
---|
437 | {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
|
---|
438 | {PROTO_SR, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
|
---|
439 | {PROTO_SR, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
|
---|
440 | {PROTO_SR, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
|
---|
441 |
|
---|
442 | {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
|
---|
443 | {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
|
---|
444 |
|
---|
445 | {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
|
---|
446 | {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
|
---|
447 | {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
|
---|
448 | {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
|
---|
449 | {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
|
---|
450 | {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
|
---|
451 | {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
|
---|
452 | {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
|
---|
453 | {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
|
---|
454 | {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
|
---|
455 | {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
|
---|
456 | {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
|
---|
457 | {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
|
---|
458 | {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
|
---|
459 | {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
|
---|
460 | {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
|
---|
461 | {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
|
---|
462 | {PROTO_SR, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Catmarc" },
|
---|
463 | {PROTO_SR, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
|
---|
464 | {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
|
---|
465 | {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
|
---|
466 | {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
|
---|
467 | {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
|
---|
468 | {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
|
---|
469 | {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
|
---|
470 | {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
|
---|
471 | {PROTO_SR, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
|
---|
472 |
|
---|
473 | {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
|
---|
474 | {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
|
---|
475 |
|
---|
476 | {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
|
---|
477 | {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
|
---|
478 | {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
|
---|
479 |
|
---|
480 | {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
|
---|
481 | {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
|
---|
482 | {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
|
---|
483 | {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
|
---|
484 | {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
|
---|
485 | {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
|
---|
486 | {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
|
---|
487 |
|
---|
488 | {PROTO_SR, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
|
---|
489 |
|
---|
490 | {PROTO_SR, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
|
---|
491 |
|
---|
492 | {PROTO_SR, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
|
---|
493 | {PROTO_SR, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
|
---|
494 | {PROTO_SR, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
|
---|
495 | {PROTO_SR, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
|
---|
496 | {PROTO_SR, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
|
---|
497 |
|
---|
498 | {PROTO_SR, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
|
---|
499 | {PROTO_SR, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
|
---|
500 |
|
---|
501 | {PROTO_SR, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
|
---|
502 | {PROTO_SR, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
|
---|
503 | {PROTO_SR, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
|
---|
504 | {PROTO_SR, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
|
---|
505 |
|
---|
506 | {PROTO_NOP, CLASS_NOP, VAL_NOP, {-1}, 0 }
|
---|
507 | };
|
---|
508 |
|
---|
509 | /* OID utilities */
|
---|
510 |
|
---|
511 | void oid_oidcpy(int *t, int *s)
|
---|
512 | {
|
---|
513 | while ((*(t++) = *(s++)) > -1);
|
---|
514 | }
|
---|
515 |
|
---|
516 | void oid_oidcat(int *t, int *s)
|
---|
517 | {
|
---|
518 | while (*t > -1)
|
---|
519 | t++;
|
---|
520 | while ((*(t++) = *(s++)) > -1);
|
---|
521 | }
|
---|
522 |
|
---|
523 | int oid_oidcmp(int *o1, int *o2)
|
---|
524 | {
|
---|
525 | while (*o1 == *o2 && *o1 > -1)
|
---|
526 | {
|
---|
527 | o1++;
|
---|
528 | o2++;
|
---|
529 | }
|
---|
530 | if (*o1 == *o2)
|
---|
531 | return 0;
|
---|
532 | else if (*o1 > *o2)
|
---|
533 | return 1;
|
---|
534 | else
|
---|
535 | return -1;
|
---|
536 | }
|
---|
537 |
|
---|
538 | int oid_oidlen(int *o)
|
---|
539 | {
|
---|
540 | int len = 0;
|
---|
541 |
|
---|
542 | while (*(o++) >= 0)
|
---|
543 | len++;
|
---|
544 | return len;
|
---|
545 | }
|
---|
546 |
|
---|
547 |
|
---|
548 | static int match_prefix(int *look, int *prefix)
|
---|
549 | {
|
---|
550 | int len;
|
---|
551 |
|
---|
552 | for (len = 0; *look == *prefix; look++, prefix++, len++);
|
---|
553 | if (*prefix < 0) /* did we reach the end of the prefix? */
|
---|
554 | return len;
|
---|
555 | return 0;
|
---|
556 | }
|
---|
557 |
|
---|
558 | void oid_transfer (struct oident *oident)
|
---|
559 | {
|
---|
560 | while (*oident->oidsuffix >= 0)
|
---|
561 | {
|
---|
562 | oid_addent (oident->oidsuffix, oident->proto,
|
---|
563 | oident->oclass,
|
---|
564 | oident->desc, oident->value);
|
---|
565 | oident++;
|
---|
566 | }
|
---|
567 | }
|
---|
568 |
|
---|
569 | void oid_init (void)
|
---|
570 | {
|
---|
571 | if (oid_init_flag)
|
---|
572 | return;
|
---|
573 | /* oid_transfer is thread safe, so there's nothing wrong in having
|
---|
574 | two threads calling it simultaniously. On the other hand
|
---|
575 | no thread may exit oid_init before all OID's bave been
|
---|
576 | transferred - which is why checked is set after oid_transfer...
|
---|
577 | */
|
---|
578 | oid_transfer (oids);
|
---|
579 | oid_init_flag = 1;
|
---|
580 | }
|
---|
581 |
|
---|
582 | void oid_exit (void)
|
---|
583 | {
|
---|
584 | while (oident_table)
|
---|
585 | {
|
---|
586 | struct oident_list *this_p = oident_table;
|
---|
587 | oident_table = oident_table->next;
|
---|
588 |
|
---|
589 | xfree (this_p->oident.desc);
|
---|
590 | xfree (this_p);
|
---|
591 | }
|
---|
592 | oid_init_flag = 0;
|
---|
593 | }
|
---|
594 |
|
---|
595 | static struct oident *oid_getentbyoid_x(int *o)
|
---|
596 | {
|
---|
597 | enum oid_proto proto;
|
---|
598 | int prelen;
|
---|
599 | struct oident_list *ol;
|
---|
600 |
|
---|
601 | /* determine protocol type */
|
---|
602 | if ((prelen = match_prefix(o, z3950_prefix)) != 0)
|
---|
603 | proto = PROTO_Z3950;
|
---|
604 | else if ((prelen = match_prefix(o, sr_prefix)) != 0)
|
---|
605 | proto = PROTO_SR;
|
---|
606 | else
|
---|
607 | proto = PROTO_GENERAL;
|
---|
608 | for (ol = oident_table; ol; ol = ol->next)
|
---|
609 | {
|
---|
610 | struct oident *p = &ol->oident;
|
---|
611 | if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
|
---|
612 | return p;
|
---|
613 | if (p->proto == PROTO_GENERAL && !oid_oidcmp (o, p->oidsuffix))
|
---|
614 | return p;
|
---|
615 | }
|
---|
616 | return 0;
|
---|
617 | }
|
---|
618 |
|
---|
619 | /*
|
---|
620 | * To query, fill out proto, class, and value of the ent parameter.
|
---|
621 | */
|
---|
622 | int *oid_ent_to_oid(struct oident *ent, int *ret)
|
---|
623 | {
|
---|
624 | struct oident_list *ol;
|
---|
625 |
|
---|
626 | oid_init ();
|
---|
627 | for (ol = oident_table; ol; ol = ol->next)
|
---|
628 | {
|
---|
629 | struct oident *p = &ol->oident;
|
---|
630 | if ((ent->proto == p->proto || p->proto == PROTO_GENERAL) &&
|
---|
631 | (ent->oclass == p->oclass || p->oclass == CLASS_GENERAL) &&
|
---|
632 | ent->value == p->value)
|
---|
633 | {
|
---|
634 | if (p->proto == PROTO_Z3950)
|
---|
635 | oid_oidcpy(ret, z3950_prefix);
|
---|
636 | else if (p->proto == PROTO_SR)
|
---|
637 | oid_oidcpy(ret, sr_prefix);
|
---|
638 | else
|
---|
639 | ret[0] = -1;
|
---|
640 | oid_oidcat(ret, p->oidsuffix);
|
---|
641 | ent->desc = p->desc;
|
---|
642 | return ret;
|
---|
643 | }
|
---|
644 | }
|
---|
645 | ret[0] = -1;
|
---|
646 | return 0;
|
---|
647 | }
|
---|
648 |
|
---|
649 | /*
|
---|
650 | * To query, fill out proto, class, and value of the ent parameter.
|
---|
651 | */
|
---|
652 | int *oid_getoidbyent(struct oident *ent)
|
---|
653 | {
|
---|
654 | static int ret[OID_SIZE];
|
---|
655 |
|
---|
656 | return oid_ent_to_oid (ent, ret);
|
---|
657 | }
|
---|
658 |
|
---|
659 | struct oident *oid_addent (int *oid, enum oid_proto proto,
|
---|
660 | enum oid_class oclass,
|
---|
661 | const char *desc, int value)
|
---|
662 | {
|
---|
663 | struct oident *oident;
|
---|
664 |
|
---|
665 | nmem_critical_enter ();
|
---|
666 | oident = oid_getentbyoid_x (oid);
|
---|
667 | if (!oident)
|
---|
668 | {
|
---|
669 | char desc_str[200];
|
---|
670 | struct oident_list *oident_list;
|
---|
671 | oident_list = (struct oident_list *) xmalloc (sizeof(*oident_list));
|
---|
672 | oident = &oident_list->oident;
|
---|
673 | oident->proto = proto;
|
---|
674 | oident->oclass = oclass;
|
---|
675 |
|
---|
676 | if (!desc)
|
---|
677 | {
|
---|
678 | int i;
|
---|
679 |
|
---|
680 | sprintf (desc_str, "%d", *oid);
|
---|
681 | for (i = 1; oid[i] >= 0; i++)
|
---|
682 | sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
|
---|
683 | desc = desc_str;
|
---|
684 | }
|
---|
685 | oident->desc = (char *) xmalloc (strlen(desc)+1);
|
---|
686 | strcpy (oident->desc, desc);
|
---|
687 | if (value == VAL_DYNAMIC)
|
---|
688 | oident->value = (enum oid_value) (++oid_value_dynamic);
|
---|
689 | else
|
---|
690 | oident->value = (enum oid_value) value;
|
---|
691 | oid_oidcpy (oident->oidsuffix, oid);
|
---|
692 | oident_list->next = oident_table;
|
---|
693 | oident_table = oident_list;
|
---|
694 | }
|
---|
695 | nmem_critical_leave ();
|
---|
696 | return oident;
|
---|
697 | }
|
---|
698 |
|
---|
699 | struct oident *oid_getentbyoid(int *oid)
|
---|
700 | {
|
---|
701 | struct oident *oident;
|
---|
702 |
|
---|
703 | if (!oid)
|
---|
704 | return 0;
|
---|
705 | oid_init ();
|
---|
706 | oident = oid_getentbyoid_x (oid);
|
---|
707 | if (!oident)
|
---|
708 | oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL,
|
---|
709 | NULL, VAL_DYNAMIC);
|
---|
710 | return oident;
|
---|
711 | }
|
---|
712 |
|
---|
713 | static oid_value oid_getval_raw(const char *name)
|
---|
714 | {
|
---|
715 | int val = 0, i = 0, oid[OID_SIZE];
|
---|
716 | struct oident *oident;
|
---|
717 |
|
---|
718 | while (isdigit (*name))
|
---|
719 | {
|
---|
720 | val = val*10 + (*name - '0');
|
---|
721 | name++;
|
---|
722 | if (*name == '.')
|
---|
723 | {
|
---|
724 | if (i < OID_SIZE-1)
|
---|
725 | oid[i++] = val;
|
---|
726 | val = 0;
|
---|
727 | name++;
|
---|
728 | }
|
---|
729 | }
|
---|
730 | oid[i] = val;
|
---|
731 | oid[i+1] = -1;
|
---|
732 | oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
|
---|
733 | VAL_DYNAMIC);
|
---|
734 | return oident->value;
|
---|
735 | }
|
---|
736 |
|
---|
737 | oid_value oid_getvalbyname(const char *name)
|
---|
738 | {
|
---|
739 | struct oident_list *ol;
|
---|
740 |
|
---|
741 | oid_init ();
|
---|
742 | if (isdigit (*name))
|
---|
743 | return oid_getval_raw (name);
|
---|
744 | for (ol = oident_table; ol; ol = ol->next)
|
---|
745 | if (!yaz_matchstr(ol->oident.desc, name))
|
---|
746 | {
|
---|
747 | return ol->oident.value;
|
---|
748 | }
|
---|
749 | return VAL_NONE;
|
---|
750 | }
|
---|
751 |
|
---|
752 | void oid_setprivateoids(oident *list)
|
---|
753 | {
|
---|
754 | oid_transfer (list);
|
---|
755 | }
|
---|