2 * Copyright (c) 1995-1997, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.24 1997-09-29 13:19:00 adam
8 * Added function, oid_ent_to_oid, to replace the function
9 * oid_getoidbyent, which is not thread safe.
11 * Revision 1.23 1997/09/09 10:10:19 adam
12 * Another MSV5.0 port. Changed projects to include proper
13 * library/include paths.
14 * Server starts server in test-mode when no options are given.
16 * Revision 1.22 1997/08/29 13:34:58 quinn
17 * Added thesaurus oids
19 * Revision 1.21 1997/08/19 08:46:05 quinn
22 * Revision 1.20 1997/07/28 12:34:43 adam
23 * Added new OID entries (RVDM).
25 * Revision 1.19 1997/05/02 08:39:41 quinn
26 * Support for private OID table added. Thanks to Ronald van der Meer
28 * Revision 1.18 1997/04/30 08:52:12 quinn
31 * Revision 1.17 1996/10/10 12:35:23 quinn
32 * Added Update extended service.
34 * Revision 1.16 1996/10/09 15:55:02 quinn
35 * Added SearchInfoReport
37 * Revision 1.15 1996/10/07 15:29:43 quinn
40 * Revision 1.14 1996/02/20 17:58:28 adam
41 * Added const to oid_getvalbyname.
43 * Revision 1.13 1996/02/20 16:37:33 quinn
44 * Using yaz_matchstr in oid_getvalbyname
46 * Revision 1.12 1996/01/02 08:57:53 quinn
47 * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
49 * Revision 1.11 1995/12/13 16:03:35 quinn
50 * *** empty log message ***
52 * Revision 1.10 1995/11/28 09:30:44 quinn
55 * Revision 1.9 1995/11/13 09:27:53 quinn
56 * Fiddling with the variant stuff.
58 * Revision 1.8 1995/10/12 10:34:56 quinn
61 * Revision 1.7 1995/10/10 16:27:12 quinn
62 * *** empty log message ***
64 * Revision 1.6 1995/09/29 17:12:35 quinn
67 * Revision 1.5 1995/09/29 17:01:51 quinn
70 * Revision 1.4 1995/09/27 15:03:03 quinn
71 * Modified function heads & prototypes.
73 * Revision 1.3 1995/09/12 11:32:06 quinn
74 * Added a looker-upper by name.
76 * Revision 1.2 1995/08/21 09:11:16 quinn
77 * Smallish fixes to suppport new formats.
79 * Revision 1.1 1995/05/29 08:17:13 quinn
80 * iMoved oid to util to support comstack.
82 * Revision 1.5 1995/05/22 11:30:16 quinn
83 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
85 * Revision 1.4 1995/05/16 08:50:22 quinn
86 * License, documentation, and memory fixes
88 * Revision 1.3 1995/04/11 11:52:02 quinn
89 * Fixed possible buf in proto.c
91 * Revision 1.2 1995/03/29 15:39:38 quinn
92 * Adding some resource control elements, and a null-check to getentbyoid
94 * Revision 1.1 1995/03/27 08:32:12 quinn
101 * More or less protocol-transparent OID database.
102 * We could (and should?) extend this so that the user app can add new
103 * entries to the list at initialization.
108 #include <yaz-util.h>
110 static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
111 static int sr_prefix[] = { 1, 0, 10163, -1 };
113 static oident *extoids = NULL;
118 static oident oids[] =
120 /* General definitions */
121 {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1}, "BER" },
122 {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},"ISO2709"},
124 /* Z39.50v3 definitions */
125 {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "Z-APDU" },
127 {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "Z-BASIC" },
129 {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
130 {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
131 {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
132 {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
133 {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS-attset" },
134 {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS-attset" },
135 {PROTO_Z3950, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
136 {PROTO_Z3950, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
137 {PROTO_Z3950, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
138 {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1},"Thesaurus-attset"},
140 {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
141 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
143 {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
144 {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
145 {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
146 {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
147 {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
148 {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
149 {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
150 {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
151 {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
152 {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
153 {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
154 {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
155 {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
156 {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
157 {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
158 {PROTO_Z3950, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Carmarc" },
159 {PROTO_Z3950, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
160 {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
161 {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
162 {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
163 {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
164 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
165 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
166 {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
167 {PROTO_Z3950, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
169 {PROTO_Z3950, CLASS_RECSYN, VAL_ID_SGML, {5,1000,81,1,-1},"ID-SGML" },
171 {PROTO_Z3950, CLASS_RECSYN, VAL_SOIF, {5,1000,81,2,-1},"SOIF" },
173 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
174 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
176 {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
177 {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
178 {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
180 {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
181 {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
182 {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
183 {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
184 {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
185 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
186 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
188 {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1,{10,1,-1}, "searchResult-1"},
190 {PROTO_Z3950, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
192 {PROTO_Z3950, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
194 {PROTO_Z3950, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
195 {PROTO_Z3950, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
196 {PROTO_Z3950, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
197 {PROTO_Z3950, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
198 {PROTO_Z3950, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
200 {PROTO_Z3950, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
201 {PROTO_Z3950, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
202 {PROTO_Z3950, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
203 {PROTO_Z3950, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
204 {PROTO_Z3950, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
205 {PROTO_Z3950, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
206 {PROTO_Z3950, CLASS_TAGSET, VAL_THESAURUS, {14,1000,81,1,-1}, "thesaurus-tagset"},
208 /* SR definitions. Note that some of them aren't defined by the
209 standard (yet), but are borrowed from Z3950v3 */
210 {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
212 {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
214 {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
215 {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
216 {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
217 {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
218 {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
219 {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
220 {PROTO_SR, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
221 {PROTO_SR, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
222 {PROTO_SR, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
224 {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
225 {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
227 {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
228 {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
229 {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
230 {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
231 {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
232 {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
233 {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
234 {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
235 {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
236 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
237 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
238 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
239 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
240 {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
241 {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
242 {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
243 {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
244 {PROTO_SR, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Catmarc" },
245 {PROTO_SR, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
246 {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
247 {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
248 {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
249 {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
250 {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
251 {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
252 {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
253 {PROTO_SR, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
255 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
256 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
258 {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
259 {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
260 {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
262 {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
263 {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
264 {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
265 {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
266 {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
267 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
268 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
270 {PROTO_SR, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
272 {PROTO_SR, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
274 {PROTO_SR, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
275 {PROTO_SR, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
276 {PROTO_SR, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
277 {PROTO_SR, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
278 {PROTO_SR, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
279 {PROTO_Z3950, CLASS_SCHEMA, VAL_THESAURUS, {13,1000,81,1,-1}, "thesaurus-schema"},
281 {PROTO_SR, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
282 {PROTO_SR, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
284 {PROTO_SR, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
285 {PROTO_SR, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
286 {PROTO_SR, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
287 {PROTO_SR, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
294 void oid_oidcpy(int *t, int *s)
296 while ((*(t++) = *(s++)) > -1);
299 void oid_oidcat(int *t, int *s)
303 while ((*(t++) = *(s++)) > -1);
306 int oid_oidcmp(int *o1, int *o2)
308 while (*o1 == *o2 && *o1 > -1)
321 int oid_oidlen(int *o)
331 static int match_prefix(int *look, int *prefix)
335 for (len = 0; *look == *prefix; look++, prefix++, len++);
336 if (*prefix < 0) /* did we reach the end of the prefix? */
341 struct oident *oid_getentbyoid(int *o)
343 enum oid_proto proto;
347 /* determine protocol type */
350 if ((prelen = match_prefix(o, z3950_prefix)) != 0)
352 else if ((prelen = match_prefix(o, sr_prefix)) != 0)
355 proto = PROTO_GENERAL;
356 for (p = oids; *p->oidsuffix >= 0; p++)
357 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
360 for (p = extoids; *p->oidsuffix >= 0; p++)
361 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
368 * To query, fill out proto, class, and value of the ent parameter.
370 int *oid_ent_to_oid(struct oident *ent, int *ret)
374 for (p = oids; *p->oidsuffix >= 0; p++)
375 if (ent->proto == p->proto &&
376 ent->oclass == p->oclass &&
377 ent->value == p->value)
379 if (ent->proto == PROTO_Z3950)
380 oid_oidcpy(ret, z3950_prefix);
381 else if (ent->proto == PROTO_SR)
382 oid_oidcpy(ret, sr_prefix);
385 oid_oidcat(ret, p->oidsuffix);
389 for (p = extoids; *p->oidsuffix >= 0; p++)
390 if (ent->proto == p->proto &&
391 ent->oclass == p->oclass &&
392 ent->value == p->value)
394 if (ent->proto == PROTO_Z3950)
395 oid_oidcpy(ret, z3950_prefix);
396 else if (ent->proto == PROTO_SR)
397 oid_oidcpy(ret, sr_prefix);
400 oid_oidcat(ret, p->oidsuffix);
406 * To query, fill out proto, class, and value of the ent parameter.
408 int *oid_getoidbyent(struct oident *ent)
410 static int ret[OID_SIZE];
412 return oid_ent_to_oid (ent, ret);
415 oid_value oid_getvalbyname(const char *name)
419 for (p = oids; *p->oidsuffix >= 0; p++)
420 if (!yaz_matchstr(p->desc, name))
423 for (p = extoids; *p->oidsuffix >= 0; p++)
424 if (!yaz_matchstr(p->desc, name))
429 void oid_setprivateoids(oident *list)