2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.22 1997-08-29 13:34:58 quinn
10 * Revision 1.21 1997/08/19 08:46:05 quinn
13 * Revision 1.20 1997/07/28 12:34:43 adam
14 * Added new OID entries (RVDM).
16 * Revision 1.19 1997/05/02 08:39:41 quinn
17 * Support for private OID table added. Thanks to Ronald van der Meer
19 * Revision 1.18 1997/04/30 08:52:12 quinn
22 * Revision 1.17 1996/10/10 12:35:23 quinn
23 * Added Update extended service.
25 * Revision 1.16 1996/10/09 15:55:02 quinn
26 * Added SearchInfoReport
28 * Revision 1.15 1996/10/07 15:29:43 quinn
31 * Revision 1.14 1996/02/20 17:58:28 adam
32 * Added const to oid_getvalbyname.
34 * Revision 1.13 1996/02/20 16:37:33 quinn
35 * Using yaz_matchstr in oid_getvalbyname
37 * Revision 1.12 1996/01/02 08:57:53 quinn
38 * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
40 * Revision 1.11 1995/12/13 16:03:35 quinn
41 * *** empty log message ***
43 * Revision 1.10 1995/11/28 09:30:44 quinn
46 * Revision 1.9 1995/11/13 09:27:53 quinn
47 * Fiddling with the variant stuff.
49 * Revision 1.8 1995/10/12 10:34:56 quinn
52 * Revision 1.7 1995/10/10 16:27:12 quinn
53 * *** empty log message ***
55 * Revision 1.6 1995/09/29 17:12:35 quinn
58 * Revision 1.5 1995/09/29 17:01:51 quinn
61 * Revision 1.4 1995/09/27 15:03:03 quinn
62 * Modified function heads & prototypes.
64 * Revision 1.3 1995/09/12 11:32:06 quinn
65 * Added a looker-upper by name.
67 * Revision 1.2 1995/08/21 09:11:16 quinn
68 * Smallish fixes to suppport new formats.
70 * Revision 1.1 1995/05/29 08:17:13 quinn
71 * iMoved oid to util to support comstack.
73 * Revision 1.5 1995/05/22 11:30:16 quinn
74 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
76 * Revision 1.4 1995/05/16 08:50:22 quinn
77 * License, documentation, and memory fixes
79 * Revision 1.3 1995/04/11 11:52:02 quinn
80 * Fixed possible buf in proto.c
82 * Revision 1.2 1995/03/29 15:39:38 quinn
83 * Adding some resource control elements, and a null-check to getentbyoid
85 * Revision 1.1 1995/03/27 08:32:12 quinn
92 * More or less protocol-transparent OID database.
93 * We could (and should?) extend this so that the user app can add new
94 * entries to the list at initialization.
100 static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
101 static int sr_prefix[] = { 1, 0, 10163, -1 };
103 static oident *extoids = NULL;
108 static oident oids[] =
110 /* General definitions */
111 {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1}, "BER" },
112 {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},"ISO2709"},
114 /* Z39.50v3 definitions */
115 {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "Z-APDU" },
117 {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "Z-BASIC" },
119 {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
120 {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
121 {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
122 {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
123 {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS-attset" },
124 {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS-attset" },
125 {PROTO_Z3950, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
126 {PROTO_Z3950, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
127 {PROTO_Z3950, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
128 {PROTO_Z3950, CLASS_ATTSET, VAL_THESAURUS, {3,1000,81,1,-1},"Thesaurus-attset"},
130 {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
131 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
133 {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
134 {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
135 {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
136 {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
137 {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
138 {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
139 {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
140 {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
141 {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
142 {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
143 {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
144 {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
145 {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
146 {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
147 {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
148 {PROTO_Z3950, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Carmarc" },
149 {PROTO_Z3950, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
150 {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
151 {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
152 {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
153 {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
154 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
155 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
156 {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
157 {PROTO_Z3950, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
159 {PROTO_Z3950, CLASS_RECSYN, VAL_ID_SGML, {5,1000,81,1,-1},"ID-SGML" },
161 {PROTO_Z3950, CLASS_RECSYN, VAL_SOIF, {5,1000,81,2,-1},"SOIF" },
163 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
164 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
166 {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
167 {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
168 {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
170 {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
171 {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
172 {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
173 {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
174 {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
175 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
176 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
178 {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1,{10,1,-1}, "searchResult-1"},
180 {PROTO_Z3950, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
182 {PROTO_Z3950, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
184 {PROTO_Z3950, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
185 {PROTO_Z3950, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
186 {PROTO_Z3950, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
187 {PROTO_Z3950, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
188 {PROTO_Z3950, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
190 {PROTO_Z3950, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
191 {PROTO_Z3950, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
192 {PROTO_Z3950, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
193 {PROTO_Z3950, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
194 {PROTO_Z3950, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
195 {PROTO_Z3950, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
196 {PROTO_Z3950, CLASS_TAGSET, VAL_THESAURUS, {14,1000,81,1,-1}, "thesaurus-tagset"},
198 /* SR definitions. Note that some of them aren't defined by the
199 standard (yet), but are borrowed from Z3950v3 */
200 {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
202 {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
204 {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
205 {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
206 {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
207 {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
208 {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
209 {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
210 {PROTO_SR, CLASS_ATTSET, VAL_COLLECT1, {3,7,-1}, "Collections-attset"},
211 {PROTO_SR, CLASS_ATTSET, VAL_CIMI1, {3,8,-1}, "CIMI-attset"},
212 {PROTO_SR, CLASS_ATTSET, VAL_GEO, {3,9,-1}, "Geo-attset"},
214 {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
215 {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
217 {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
218 {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
219 {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
220 {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
221 {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
222 {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
223 {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
224 {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
225 {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
226 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
227 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
228 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
229 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
230 {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
231 {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
232 {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
233 {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
234 {PROTO_SR, CLASS_RECSYN, VAL_CATMARC, {5,22,-1}, "Catmarc" },
235 {PROTO_SR, CLASS_RECSYN, VAL_MALMARC, {5,23,-1}, "Malmarc" },
236 {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
237 {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
238 {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
239 {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
240 {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
241 {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
242 {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
243 {PROTO_SR, CLASS_RECSYN, VAL_FRAGMENT, {5,107,-1}, "Fragment" },
245 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
246 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
248 {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
249 {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
250 {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
252 {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
253 {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
254 {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
255 {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
256 {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
257 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
258 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
260 {PROTO_SR, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
262 {PROTO_SR, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
264 {PROTO_SR, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
265 {PROTO_SR, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
266 {PROTO_SR, CLASS_SCHEMA, VAL_COLLECT1, {13,3,-1}, "Collections-schema" },
267 {PROTO_SR, CLASS_SCHEMA, VAL_GEO, {13,4,-1}, "Geo-schema" },
268 {PROTO_SR, CLASS_SCHEMA, VAL_CIMI1, {13,5,-1}, "CIMI-schema" },
269 {PROTO_Z3950, CLASS_SCHEMA, VAL_THESAURUS, {13,1000,81,1,-1}, "thesaurus-schema"},
271 {PROTO_SR, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
272 {PROTO_SR, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
274 {PROTO_SR, CLASS_TAGSET, VAL_STAS, {14,3,-1}, "STAS-tagset" },
275 {PROTO_SR, CLASS_TAGSET, VAL_GILS, {14,4,-1}, "GILS-tagset" },
276 {PROTO_SR, CLASS_TAGSET, VAL_COLLECT1, {14,5,-1}, "Collections-tagset"},
277 {PROTO_SR, CLASS_TAGSET, VAL_CIMI1, {14,6,-1}, "CIMI-tagset" },
284 void oid_oidcpy(int *t, int *s)
286 while ((*(t++) = *(s++)) > -1);
289 void oid_oidcat(int *t, int *s)
293 while ((*(t++) = *(s++)) > -1);
296 int oid_oidcmp(int *o1, int *o2)
298 while (*o1 == *o2 && *o1 > -1)
311 int oid_oidlen(int *o)
321 static int match_prefix(int *look, int *prefix)
325 for (len = 0; *look == *prefix; look++, prefix++, len++);
326 if (*prefix < 0) /* did we reach the end of the prefix? */
331 struct oident *oid_getentbyoid(int *o)
333 enum oid_proto proto;
337 /* determine protocol type */
340 if ((prelen = match_prefix(o, z3950_prefix)) != 0)
342 else if ((prelen = match_prefix(o, sr_prefix)) != 0)
345 proto = PROTO_GENERAL;
346 for (p = oids; *p->oidsuffix >= 0; p++)
347 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
350 for (p = extoids; *p->oidsuffix >= 0; p++)
351 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
357 * To query, fill out proto, class, and value of the ent parameter.
359 int *oid_getoidbyent(struct oident *ent)
362 static int ret[OID_SIZE];
364 for (p = oids; *p->oidsuffix >= 0; p++)
365 if (ent->proto == p->proto &&
366 ent->oclass == p->oclass &&
367 ent->value == p->value)
369 if (ent->proto == PROTO_Z3950)
370 oid_oidcpy(ret, z3950_prefix);
371 else if (ent->proto == PROTO_SR)
372 oid_oidcpy(ret, sr_prefix);
375 oid_oidcat(ret, p->oidsuffix);
379 for (p = extoids; *p->oidsuffix >= 0; p++)
380 if (ent->proto == p->proto &&
381 ent->oclass == p->oclass &&
382 ent->value == p->value)
384 if (ent->proto == PROTO_Z3950)
385 oid_oidcpy(ret, z3950_prefix);
386 else if (ent->proto == PROTO_SR)
387 oid_oidcpy(ret, sr_prefix);
390 oid_oidcat(ret, p->oidsuffix);
396 oid_value oid_getvalbyname(const char *name)
400 for (p = oids; *p->oidsuffix >= 0; p++)
401 if (!yaz_matchstr(p->desc, name))
404 for (p = extoids; *p->oidsuffix >= 0; p++)
405 if (!yaz_matchstr(p->desc, name))
410 void oid_setprivateoids(oident *list)