2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.23 1997-09-09 10:10:19 adam
8 * Another MSV5.0 port. Changed projects to include proper
9 * library/include paths.
10 * Server starts server in test-mode when no options are given.
12 * Revision 1.22 1997/08/29 13:34:58 quinn
13 * Added thesaurus oids
15 * Revision 1.21 1997/08/19 08:46:05 quinn
18 * Revision 1.20 1997/07/28 12:34:43 adam
19 * Added new OID entries (RVDM).
21 * Revision 1.19 1997/05/02 08:39:41 quinn
22 * Support for private OID table added. Thanks to Ronald van der Meer
24 * Revision 1.18 1997/04/30 08:52:12 quinn
27 * Revision 1.17 1996/10/10 12:35:23 quinn
28 * Added Update extended service.
30 * Revision 1.16 1996/10/09 15:55:02 quinn
31 * Added SearchInfoReport
33 * Revision 1.15 1996/10/07 15:29:43 quinn
36 * Revision 1.14 1996/02/20 17:58:28 adam
37 * Added const to oid_getvalbyname.
39 * Revision 1.13 1996/02/20 16:37:33 quinn
40 * Using yaz_matchstr in oid_getvalbyname
42 * Revision 1.12 1996/01/02 08:57:53 quinn
43 * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
45 * Revision 1.11 1995/12/13 16:03:35 quinn
46 * *** empty log message ***
48 * Revision 1.10 1995/11/28 09:30:44 quinn
51 * Revision 1.9 1995/11/13 09:27:53 quinn
52 * Fiddling with the variant stuff.
54 * Revision 1.8 1995/10/12 10:34:56 quinn
57 * Revision 1.7 1995/10/10 16:27:12 quinn
58 * *** empty log message ***
60 * Revision 1.6 1995/09/29 17:12:35 quinn
63 * Revision 1.5 1995/09/29 17:01:51 quinn
66 * Revision 1.4 1995/09/27 15:03:03 quinn
67 * Modified function heads & prototypes.
69 * Revision 1.3 1995/09/12 11:32:06 quinn
70 * Added a looker-upper by name.
72 * Revision 1.2 1995/08/21 09:11:16 quinn
73 * Smallish fixes to suppport new formats.
75 * Revision 1.1 1995/05/29 08:17:13 quinn
76 * iMoved oid to util to support comstack.
78 * Revision 1.5 1995/05/22 11:30:16 quinn
79 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
81 * Revision 1.4 1995/05/16 08:50:22 quinn
82 * License, documentation, and memory fixes
84 * Revision 1.3 1995/04/11 11:52:02 quinn
85 * Fixed possible buf in proto.c
87 * Revision 1.2 1995/03/29 15:39:38 quinn
88 * Adding some resource control elements, and a null-check to getentbyoid
90 * Revision 1.1 1995/03/27 08:32:12 quinn
97 * More or less protocol-transparent OID database.
98 * We could (and should?) extend this so that the user app can add new
99 * entries to the list at initialization.
104 #include <yaz-util.h>
106 static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
107 static int sr_prefix[] = { 1, 0, 10163, -1 };
109 static oident *extoids = NULL;
114 static oident oids[] =
116 /* General definitions */
117 {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1}, "BER" },
118 {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},"ISO2709"},
120 /* Z39.50v3 definitions */
121 {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "Z-APDU" },
123 {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "Z-BASIC" },
125 {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
126 {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
127 {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
128 {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
129 {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS-attset" },
130 {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS-attset" },
131 {PROTO_Z3950, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
132 {PROTO_Z3950, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
133 {PROTO_Z3950, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
134 {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1},"Thesaurus-attset"},
136 {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
137 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
139 {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
140 {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
141 {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
142 {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
143 {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
144 {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
145 {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
146 {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
147 {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
148 {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
149 {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
150 {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
151 {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
152 {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
153 {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
154 {PROTO_Z3950, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Carmarc" },
155 {PROTO_Z3950, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
156 {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
157 {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
158 {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
159 {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
160 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
161 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
162 {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
163 {PROTO_Z3950, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
165 {PROTO_Z3950, CLASS_RECSYN, VAL_ID_SGML, {5,1000,81,1,-1},"ID-SGML" },
167 {PROTO_Z3950, CLASS_RECSYN, VAL_SOIF, {5,1000,81,2,-1},"SOIF" },
169 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
170 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
172 {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
173 {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
174 {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
176 {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
177 {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
178 {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
179 {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
180 {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
181 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
182 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
184 {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1,{10,1,-1}, "searchResult-1"},
186 {PROTO_Z3950, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
188 {PROTO_Z3950, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
190 {PROTO_Z3950, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
191 {PROTO_Z3950, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
192 {PROTO_Z3950, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
193 {PROTO_Z3950, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
194 {PROTO_Z3950, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
196 {PROTO_Z3950, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
197 {PROTO_Z3950, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
198 {PROTO_Z3950, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
199 {PROTO_Z3950, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
200 {PROTO_Z3950, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
201 {PROTO_Z3950, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
202 {PROTO_Z3950, CLASS_TAGSET, VAL_THESAURUS, {14,1000,81,1,-1}, "thesaurus-tagset"},
204 /* SR definitions. Note that some of them aren't defined by the
205 standard (yet), but are borrowed from Z3950v3 */
206 {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
208 {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
210 {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
211 {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
212 {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
213 {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
214 {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
215 {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
216 {PROTO_SR, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
217 {PROTO_SR, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
218 {PROTO_SR, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
220 {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
221 {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
223 {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
224 {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
225 {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
226 {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
227 {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
228 {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
229 {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
230 {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
231 {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
232 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
233 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
234 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
235 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
236 {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
237 {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
238 {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
239 {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
240 {PROTO_SR, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Catmarc" },
241 {PROTO_SR, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
242 {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
243 {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
244 {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
245 {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
246 {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
247 {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
248 {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
249 {PROTO_SR, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
251 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
252 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
254 {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
255 {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
256 {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
258 {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
259 {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
260 {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
261 {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
262 {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
263 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
264 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
266 {PROTO_SR, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
268 {PROTO_SR, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
270 {PROTO_SR, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
271 {PROTO_SR, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
272 {PROTO_SR, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
273 {PROTO_SR, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
274 {PROTO_SR, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
275 {PROTO_Z3950, CLASS_SCHEMA, VAL_THESAURUS, {13,1000,81,1,-1}, "thesaurus-schema"},
277 {PROTO_SR, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
278 {PROTO_SR, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
280 {PROTO_SR, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
281 {PROTO_SR, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
282 {PROTO_SR, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
283 {PROTO_SR, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
290 void oid_oidcpy(int *t, int *s)
292 while ((*(t++) = *(s++)) > -1);
295 void oid_oidcat(int *t, int *s)
299 while ((*(t++) = *(s++)) > -1);
302 int oid_oidcmp(int *o1, int *o2)
304 while (*o1 == *o2 && *o1 > -1)
317 int oid_oidlen(int *o)
327 static int match_prefix(int *look, int *prefix)
331 for (len = 0; *look == *prefix; look++, prefix++, len++);
332 if (*prefix < 0) /* did we reach the end of the prefix? */
337 struct oident *oid_getentbyoid(int *o)
339 enum oid_proto proto;
343 /* determine protocol type */
346 if ((prelen = match_prefix(o, z3950_prefix)) != 0)
348 else if ((prelen = match_prefix(o, sr_prefix)) != 0)
351 proto = PROTO_GENERAL;
352 for (p = oids; *p->oidsuffix >= 0; p++)
353 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
356 for (p = extoids; *p->oidsuffix >= 0; p++)
357 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
363 * To query, fill out proto, class, and value of the ent parameter.
365 int *oid_getoidbyent(struct oident *ent)
368 static int ret[OID_SIZE];
370 for (p = oids; *p->oidsuffix >= 0; p++)
371 if (ent->proto == p->proto &&
372 ent->oclass == p->oclass &&
373 ent->value == p->value)
375 if (ent->proto == PROTO_Z3950)
376 oid_oidcpy(ret, z3950_prefix);
377 else if (ent->proto == PROTO_SR)
378 oid_oidcpy(ret, sr_prefix);
381 oid_oidcat(ret, p->oidsuffix);
385 for (p = extoids; *p->oidsuffix >= 0; p++)
386 if (ent->proto == p->proto &&
387 ent->oclass == p->oclass &&
388 ent->value == p->value)
390 if (ent->proto == PROTO_Z3950)
391 oid_oidcpy(ret, z3950_prefix);
392 else if (ent->proto == PROTO_SR)
393 oid_oidcpy(ret, sr_prefix);
396 oid_oidcat(ret, p->oidsuffix);
402 oid_value oid_getvalbyname(const char *name)
406 for (p = oids; *p->oidsuffix >= 0; p++)
407 if (!yaz_matchstr(p->desc, name))
410 for (p = extoids; *p->oidsuffix >= 0; p++)
411 if (!yaz_matchstr(p->desc, name))
416 void oid_setprivateoids(oident *list)