2 * Copyright (c) 1995-2000, Index Data
3 * See the file LICENSE for details.
6 * Revision 1.43 2000-03-14 09:21:08 ian
7 * Added Admin Extended Service OID
9 * Revision 1.42 2000/02/29 13:44:55 adam
10 * Check for config.h (currently not generated).
12 * Revision 1.41 2000/01/10 15:16:53 adam
13 * Added several OID's.
15 * Revision 1.40 2000/01/06 14:59:13 adam
16 * Added oid_init/oid_exit. Changed oid_exit.
18 * Revision 1.39 1999/12/16 23:36:19 adam
19 * Implemented ILL protocol. Minor updates ASN.1 compiler.
21 * Revision 1.38 1999/11/30 13:47:12 adam
22 * Improved installation. Moved header files to include/yaz.
24 * Revision 1.37 1999/09/13 12:51:15 adam
25 * Added CLIENT IP OID.
27 * Revision 1.36 1999/05/27 13:02:20 adam
28 * Assigned OID for old DB Update (VAL_DBUPDATE0).
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.
34 * Revision 1.34 1999/04/15 09:19:43 adam
35 * Added COOKIE UserInfo OID.
37 * Revision 1.33 1999/04/09 12:16:11 adam
38 * Added OtherInfo private OID proxy.
40 * Revision 1.32 1999/02/18 10:30:46 quinn
41 * Changed ES: Update OID
43 * Revision 1.31 1998/12/03 11:33:05 adam
44 * Added OID's for XML.
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.
49 * Revision 1.29 1998/10/14 13:32:35 adam
50 * Added include of string.h.
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
57 * Revision 1.27 1998/05/18 10:10:02 adam
58 * Added Explain-schema and Explain-tagset to OID database.
60 * Revision 1.26 1998/03/20 14:46:06 adam
61 * Added UNIverse Resource Reports.
63 * Revision 1.25 1998/02/10 15:32:03 adam
64 * Added new Object Identifiers.
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.
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.
75 * Revision 1.22 1997/08/29 13:34:58 quinn
76 * Added thesaurus oids
78 * Revision 1.21 1997/08/19 08:46:05 quinn
81 * Revision 1.20 1997/07/28 12:34:43 adam
82 * Added new OID entries (RVDM).
84 * Revision 1.19 1997/05/02 08:39:41 quinn
85 * Support for private OID table added. Thanks to Ronald van der Meer
87 * Revision 1.18 1997/04/30 08:52:12 quinn
90 * Revision 1.17 1996/10/10 12:35:23 quinn
91 * Added Update extended service.
93 * Revision 1.16 1996/10/09 15:55:02 quinn
94 * Added SearchInfoReport
96 * Revision 1.15 1996/10/07 15:29:43 quinn
99 * Revision 1.14 1996/02/20 17:58:28 adam
100 * Added const to oid_getvalbyname.
102 * Revision 1.13 1996/02/20 16:37:33 quinn
103 * Using yaz_matchstr in oid_getvalbyname
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
108 * Revision 1.11 1995/12/13 16:03:35 quinn
109 * *** empty log message ***
111 * Revision 1.10 1995/11/28 09:30:44 quinn
114 * Revision 1.9 1995/11/13 09:27:53 quinn
115 * Fiddling with the variant stuff.
117 * Revision 1.8 1995/10/12 10:34:56 quinn
120 * Revision 1.7 1995/10/10 16:27:12 quinn
121 * *** empty log message ***
123 * Revision 1.6 1995/09/29 17:12:35 quinn
126 * Revision 1.5 1995/09/29 17:01:51 quinn
129 * Revision 1.4 1995/09/27 15:03:03 quinn
130 * Modified function heads & prototypes.
132 * Revision 1.3 1995/09/12 11:32:06 quinn
133 * Added a looker-upper by name.
135 * Revision 1.2 1995/08/21 09:11:16 quinn
136 * Smallish fixes to suppport new formats.
138 * Revision 1.1 1995/05/29 08:17:13 quinn
139 * iMoved oid to util to support comstack.
141 * Revision 1.5 1995/05/22 11:30:16 quinn
142 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
144 * Revision 1.4 1995/05/16 08:50:22 quinn
145 * License, documentation, and memory fixes
147 * Revision 1.3 1995/04/11 11:52:02 quinn
148 * Fixed possible buf in proto.c
150 * Revision 1.2 1995/03/29 15:39:38 quinn
151 * Adding some resource control elements, and a null-check to getentbyoid
153 * Revision 1.1 1995/03/27 08:32:12 quinn
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.
173 #include <yaz/yaz-util.h>
175 static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
176 static int sr_prefix[] = { 1, 0, 10163, -1 };
179 struct oident oident;
180 struct oident_list *next;
183 static struct oident_list *oident_table = NULL;
184 static int oid_value_dynamic = VAL_DYNAMIC;
185 static int oid_init_flag = 0;
190 static oident oids[] =
192 /* General definitions */
193 {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1},
195 {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},
197 {PROTO_GENERAL, CLASS_GENERAL, VAL_ISO_ILL_1, {1,2,10161,2,1,-1},
199 /* Z39.50v3 definitions */
200 {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1},
202 {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1},
204 {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1},
206 {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1},
208 {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1},
210 {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1},
212 {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1},
214 {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1},
216 {PROTO_Z3950, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1},
217 "Collections-attset"},
218 {PROTO_Z3950, CLASS_ATTSET, VAL_CIMI1, {3,8,-1},
220 {PROTO_Z3950, CLASS_ATTSET, VAL_GEO, {3,9,-1},
223 {PROTO_Z3950, CLASS_ATTSET, VAL_ZBIG, {3,10,-1},
225 {PROTO_Z3950, CLASS_ATTSET, VAL_UTIL, {3,11,-1},
227 {PROTO_Z3950, CLASS_ATTSET, VAL_XD1, {3,12,-1},
229 {PROTO_Z3950, CLASS_ATTSET, VAL_ZTHES, {3,13,-1},
231 {PROTO_Z3950, CLASS_ATTSET, VAL_FIN1, {3,14,-1},
233 {PROTO_Z3950, CLASS_ATTSET, VAL_DAN1, {3,15,-1},
236 {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1},
238 {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1},
240 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1},
242 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG_ES, {4,3,-1},
244 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG_GENERAL, {4,3,-1},
246 {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1},
248 {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1},
250 {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1},
252 {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1},
254 {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1},
256 {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1},
258 {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC, {5,13,-1},
260 {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1},
262 {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1},
264 {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1},
266 {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1},
268 {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1},
270 {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1},
272 {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1},
274 {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1},
276 {PROTO_Z3950, CLASS_RECSYN, VAL_CATMARC, {5,22,-1},
278 {PROTO_Z3950, CLASS_RECSYN, VAL_MALMARC, {5,23,-1},
280 {PROTO_Z3950, CLASS_RECSYN, VAL_JPMARC, {5,24,-1},
282 {PROTO_Z3950, CLASS_RECSYN, VAL_SWEMARC, {5,25,-1},
284 {PROTO_Z3950, CLASS_RECSYN, VAL_SIGLEMARC, {5,26,-1},
286 {PROTO_Z3950, CLASS_RECSYN, VAL_ISDSMARC, {5,27,-1},
288 {PROTO_Z3950, CLASS_RECSYN, VAL_RUSMARC, {5,28,-1},
290 {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1},
292 {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1},
294 {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1},
296 {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1},
298 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1},
300 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1},
302 {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1},
304 {PROTO_Z3950, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1},
306 {PROTO_Z3950, CLASS_RECSYN, VAL_PDF, {5,109,1,-1},
308 {PROTO_Z3950, CLASS_RECSYN, VAL_POSTSCRIPT, {5,109,2,-1},
310 {PROTO_Z3950, CLASS_RECSYN, VAL_HTML, {5,109,3,-1},
312 {PROTO_Z3950, CLASS_RECSYN, VAL_TIFF, {5,109,4,-1},
314 {PROTO_Z3950, CLASS_RECSYN, VAL_GIF, {5,109,5,-1},
316 {PROTO_Z3950, CLASS_RECSYN, VAL_JPEG, {5,109,6,-1},
318 {PROTO_Z3950, CLASS_RECSYN, VAL_PNG, {5,109,7,-1},
320 {PROTO_Z3950, CLASS_RECSYN, VAL_MPEG, {5,109,8,-1},
322 {PROTO_Z3950, CLASS_RECSYN, VAL_SGML, {5,109,9,-1},
325 {PROTO_Z3950, CLASS_RECSYN, VAL_TIFFB, {5,110,1,-1},
327 {PROTO_Z3950, CLASS_RECSYN, VAL_WAV, {5,110,2,-1},
330 {PROTO_Z3950, CLASS_RECSYN, VAL_SQLRS, {5,111,-1},
332 {PROTO_Z3950, CLASS_RECSYN, VAL_SOIF, {5,1000,81,2,-1},
334 {PROTO_Z3950, CLASS_RECSYN, VAL_TEXT_XML, {5,109,10,-1},
336 {PROTO_Z3950, CLASS_RECSYN, VAL_TEXT_XML, {5,109,10,-1},
338 {PROTO_Z3950, CLASS_RECSYN, VAL_APPLICATION_XML, {5,109,11,-1},
340 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1},
342 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1},
344 {PROTO_Z3950, CLASS_RESFORM, VAL_UNIVERSE_REPORT, {7,1000,81,1,-1},
345 "UNIverse-Resource-Report"},
347 {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1},
349 {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1},
351 {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1},
353 {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1},
355 {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1},
357 {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1},
359 {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1},
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},
365 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC, {9,6,-1},
367 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1},
369 {PROTO_Z3950, CLASS_EXTSERV, VAL_ADMINSERVICE, {9,81,1,-1},
371 {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1, {10,1,-1},
373 {PROTO_Z3950, CLASS_USERINFO,VAL_CHARLANG, {10,2,-1},
374 "CharSetandLanguageNegotiation"},
375 {PROTO_Z3950, CLASS_USERINFO,VAL_USERINFO1, {10,3,-1},
377 {PROTO_Z3950, CLASS_USERINFO,VAL_MULTISRCH1, {10,4,-1},
378 "MultipleSearchTerms-1"},
379 {PROTO_Z3950, CLASS_USERINFO,VAL_MULTISRCH2, {10,5,-1},
380 "MultipleSearchTerms-2"},
381 {PROTO_Z3950, CLASS_USERINFO,VAL_DATETIME, {10,6,-1},
383 {PROTO_Z3950, CLASS_USERINFO,VAL_PROXY, {10,1000,81,1,-1},
385 {PROTO_Z3950, CLASS_USERINFO,VAL_COOKIE, {10,1000,81,2,-1},
387 {PROTO_Z3950, CLASS_USERINFO,VAL_CLIENT_IP, {10,1000,81,3,-1},
389 {PROTO_Z3950, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1},
391 {PROTO_Z3950, CLASS_VARSET, VAL_VAR1, {12,1,-1},
393 {PROTO_Z3950, CLASS_SCHEMA, VAL_WAIS, {13,1,-1},
395 {PROTO_Z3950, CLASS_SCHEMA, VAL_GILS, {13,2,-1},
397 {PROTO_Z3950, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1},
398 "Collections-schema"},
399 {PROTO_Z3950, CLASS_SCHEMA, VAL_GEO, {13,4,-1},
401 {PROTO_Z3950, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1},
403 {PROTO_Z3950, CLASS_SCHEMA, VAL_UPDATEES, {13,6,-1},
405 {PROTO_Z3950, CLASS_SCHEMA, VAL_THESAURUS, {13,1000,81,1,-1},
407 {PROTO_Z3950, CLASS_SCHEMA, VAL_EXPLAIN, {13,1000,81,2,-1},
409 {PROTO_Z3950, CLASS_TAGSET, VAL_SETM, {14,1,-1},
411 {PROTO_Z3950, CLASS_TAGSET, VAL_SETG, {14,2,-1},
413 {PROTO_Z3950, CLASS_TAGSET, VAL_STAS, {14,3,-1},
415 {PROTO_Z3950, CLASS_TAGSET, VAL_GILS, {14,4,-1},
417 {PROTO_Z3950, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1},
418 "Collections-tagset"},
419 {PROTO_Z3950, CLASS_TAGSET, VAL_CIMI1, {14,6,-1},
421 {PROTO_Z3950, CLASS_TAGSET, VAL_THESAURUS, {14,1000,81,1,-1},
423 {PROTO_Z3950, CLASS_TAGSET, VAL_EXPLAIN, {14,1000,81,2,-1},
427 /* SR definitions. Note that some of them aren't defined by the
428 standard (yet), but are borrowed from Z3950v3 */
429 {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
431 {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
433 {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
434 {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
435 {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
436 {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
437 {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
438 {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
439 {PROTO_SR, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
440 {PROTO_SR, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
441 {PROTO_SR, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
443 {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
444 {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
446 {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
447 {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
448 {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
449 {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
450 {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
451 {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
452 {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
453 {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
454 {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
455 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
456 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
457 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
458 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
459 {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
460 {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
461 {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
462 {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
463 {PROTO_SR, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Catmarc" },
464 {PROTO_SR, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
465 {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
466 {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
467 {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
468 {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
469 {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
470 {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
471 {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
472 {PROTO_SR, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
474 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
475 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
477 {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
478 {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
479 {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
481 {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
482 {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
483 {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
484 {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
485 {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
486 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
487 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
489 {PROTO_SR, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
491 {PROTO_SR, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
493 {PROTO_SR, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
494 {PROTO_SR, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
495 {PROTO_SR, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
496 {PROTO_SR, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
497 {PROTO_SR, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
499 {PROTO_SR, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
500 {PROTO_SR, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
502 {PROTO_SR, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
503 {PROTO_SR, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
504 {PROTO_SR, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
505 {PROTO_SR, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
507 {PROTO_NOP, CLASS_NOP, VAL_NOP, {-1}, 0 }
512 void oid_oidcpy(int *t, int *s)
514 while ((*(t++) = *(s++)) > -1);
517 void oid_oidcat(int *t, int *s)
521 while ((*(t++) = *(s++)) > -1);
524 int oid_oidcmp(int *o1, int *o2)
526 while (*o1 == *o2 && *o1 > -1)
539 int oid_oidlen(int *o)
549 static int match_prefix(int *look, int *prefix)
553 for (len = 0; *look == *prefix; look++, prefix++, len++);
554 if (*prefix < 0) /* did we reach the end of the prefix? */
559 void oid_transfer (struct oident *oident)
561 while (*oident->oidsuffix >= 0)
563 oid_addent (oident->oidsuffix, oident->proto,
565 oident->desc, oident->value);
574 /* oid_transfer is thread safe, so there's nothing wrong in having
575 two threads calling it simultaniously. On the other hand
576 no thread may exit oid_init before all OID's bave been
577 transferred - which is why checked is set after oid_transfer...
587 struct oident_list *this_p = oident_table;
588 oident_table = oident_table->next;
590 xfree (this_p->oident.desc);
596 static struct oident *oid_getentbyoid_x(int *o)
598 enum oid_proto proto;
600 struct oident_list *ol;
602 /* determine protocol type */
603 if ((prelen = match_prefix(o, z3950_prefix)) != 0)
605 else if ((prelen = match_prefix(o, sr_prefix)) != 0)
608 proto = PROTO_GENERAL;
609 for (ol = oident_table; ol; ol = ol->next)
611 struct oident *p = &ol->oident;
612 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
614 if (p->proto == PROTO_GENERAL && !oid_oidcmp (o, p->oidsuffix))
621 * To query, fill out proto, class, and value of the ent parameter.
623 int *oid_ent_to_oid(struct oident *ent, int *ret)
625 struct oident_list *ol;
628 for (ol = oident_table; ol; ol = ol->next)
630 struct oident *p = &ol->oident;
631 if ((ent->proto == p->proto || p->proto == PROTO_GENERAL) &&
632 (ent->oclass == p->oclass || p->oclass == CLASS_GENERAL) &&
633 ent->value == p->value)
635 if (p->proto == PROTO_Z3950)
636 oid_oidcpy(ret, z3950_prefix);
637 else if (p->proto == PROTO_SR)
638 oid_oidcpy(ret, sr_prefix);
641 oid_oidcat(ret, p->oidsuffix);
651 * To query, fill out proto, class, and value of the ent parameter.
653 int *oid_getoidbyent(struct oident *ent)
655 static int ret[OID_SIZE];
657 return oid_ent_to_oid (ent, ret);
660 struct oident *oid_addent (int *oid, enum oid_proto proto,
661 enum oid_class oclass,
662 const char *desc, int value)
664 struct oident *oident;
666 nmem_critical_enter ();
667 oident = oid_getentbyoid_x (oid);
671 struct oident_list *oident_list;
672 oident_list = (struct oident_list *) xmalloc (sizeof(*oident_list));
673 oident = &oident_list->oident;
674 oident->proto = proto;
675 oident->oclass = oclass;
681 sprintf (desc_str, "%d", *oid);
682 for (i = 1; oid[i] >= 0; i++)
683 sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
686 oident->desc = (char *) xmalloc (strlen(desc)+1);
687 strcpy (oident->desc, desc);
688 if (value == VAL_DYNAMIC)
689 oident->value = (enum oid_value) (++oid_value_dynamic);
691 oident->value = (enum oid_value) value;
692 oid_oidcpy (oident->oidsuffix, oid);
693 oident_list->next = oident_table;
694 oident_table = oident_list;
696 nmem_critical_leave ();
700 struct oident *oid_getentbyoid(int *oid)
702 struct oident *oident;
707 oident = oid_getentbyoid_x (oid);
709 oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL,
714 static oid_value oid_getval_raw(const char *name)
716 int val = 0, i = 0, oid[OID_SIZE];
717 struct oident *oident;
719 while (isdigit (*name))
721 val = val*10 + (*name - '0');
733 oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
735 return oident->value;
738 oid_value oid_getvalbyname(const char *name)
740 struct oident_list *ol;
744 return oid_getval_raw (name);
745 for (ol = oident_table; ol; ol = ol->next)
746 if (!yaz_matchstr(ol->oident.desc, name))
748 return ol->oident.value;
753 void oid_setprivateoids(oident *list)