2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.19 1997-05-02 08:39:41 quinn
8 * Support for private OID table added. Thanks to Ronald van der Meer
10 * Revision 1.18 1997/04/30 08:52:12 quinn
13 * Revision 1.17 1996/10/10 12:35:23 quinn
14 * Added Update extended service.
16 * Revision 1.16 1996/10/09 15:55:02 quinn
17 * Added SearchInfoReport
19 * Revision 1.15 1996/10/07 15:29:43 quinn
22 * Revision 1.14 1996/02/20 17:58:28 adam
23 * Added const to oid_getvalbyname.
25 * Revision 1.13 1996/02/20 16:37:33 quinn
26 * Using yaz_matchstr in oid_getvalbyname
28 * Revision 1.12 1996/01/02 08:57:53 quinn
29 * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
31 * Revision 1.11 1995/12/13 16:03:35 quinn
32 * *** empty log message ***
34 * Revision 1.10 1995/11/28 09:30:44 quinn
37 * Revision 1.9 1995/11/13 09:27:53 quinn
38 * Fiddling with the variant stuff.
40 * Revision 1.8 1995/10/12 10:34:56 quinn
43 * Revision 1.7 1995/10/10 16:27:12 quinn
44 * *** empty log message ***
46 * Revision 1.6 1995/09/29 17:12:35 quinn
49 * Revision 1.5 1995/09/29 17:01:51 quinn
52 * Revision 1.4 1995/09/27 15:03:03 quinn
53 * Modified function heads & prototypes.
55 * Revision 1.3 1995/09/12 11:32:06 quinn
56 * Added a looker-upper by name.
58 * Revision 1.2 1995/08/21 09:11:16 quinn
59 * Smallish fixes to suppport new formats.
61 * Revision 1.1 1995/05/29 08:17:13 quinn
62 * iMoved oid to util to support comstack.
64 * Revision 1.5 1995/05/22 11:30:16 quinn
65 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
67 * Revision 1.4 1995/05/16 08:50:22 quinn
68 * License, documentation, and memory fixes
70 * Revision 1.3 1995/04/11 11:52:02 quinn
71 * Fixed possible buf in proto.c
73 * Revision 1.2 1995/03/29 15:39:38 quinn
74 * Adding some resource control elements, and a null-check to getentbyoid
76 * Revision 1.1 1995/03/27 08:32:12 quinn
83 * More or less protocol-transparent OID database.
84 * We could (and should?) extend this so that the user app can add new
85 * entries to the list at initialization.
91 static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
92 static int sr_prefix[] = { 1, 0, 10163, -1 };
94 static oident *extoids = NULL;
99 static oident oids[] =
101 /* General definitions */
102 {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1}, "BER" },
103 {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},"ISO2709"},
105 /* Z39.50v3 definitions */
106 {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "Z-APDU" },
107 {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "Z-BASIC" },
108 {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
109 {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
110 {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
111 {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
112 {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS-attset" },
113 {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS-attset" },
114 {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
115 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
116 {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
117 {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
118 {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
119 {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
120 {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
121 {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
122 {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
123 {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
124 {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
125 {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
126 {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
127 {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
128 {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
129 {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
130 {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
131 {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
132 {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
133 {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
134 {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
135 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
136 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
137 {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
139 {PROTO_Z3950, CLASS_RECSYN, VAL_ID_SGML, {5,1000,81,1,-1},"ID-SGML" },
141 {PROTO_Z3950, CLASS_RECSYN, VAL_SOIF, {5,1000,81,2,-1},"SOIF" },
142 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
143 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
144 {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
145 {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
146 {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
147 {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
148 {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
149 {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
150 {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
151 {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
152 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
153 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
155 {PROTO_Z3950, CLASS_USERINFO,VAL_SEARCHRES1,{10,1,-1}, "searchResult-1"},
157 {PROTO_Z3950, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
158 {PROTO_Z3950, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
160 {PROTO_Z3950, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
161 {PROTO_Z3950, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
163 {PROTO_Z3950, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
164 {PROTO_Z3950, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
166 {PROTO_Z3950, CLASS_TAGSET, VAL_GILS, {14,3,-1}, "GILS-tagset" },
169 /* SR definitions. Note that some of them aren't defined by the
170 standard (yet), but are borrowed from Z3950v3 */
171 {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
172 {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
173 {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
174 {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
175 {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
176 {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
177 {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
178 {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
179 {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
180 {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
181 {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
182 {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
183 {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
184 {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
185 {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
186 {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
187 {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
188 {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
189 {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
190 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
191 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
192 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
193 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
194 {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
195 {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
196 {PROTO_SR, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
197 {PROTO_SR, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
198 {PROTO_SR, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
199 {PROTO_SR, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
200 {PROTO_SR, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
201 {PROTO_SR, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
202 {PROTO_SR, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
203 {PROTO_SR, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
204 {PROTO_SR, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
205 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
206 {PROTO_SR, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
207 {PROTO_SR, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
208 {PROTO_SR, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
209 {PROTO_SR, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
210 {PROTO_SR, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
211 {PROTO_SR, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
212 {PROTO_SR, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
213 {PROTO_SR, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
214 {PROTO_SR, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
215 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
216 {PROTO_SR, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
217 {PROTO_SR, CLASS_ELEMSPEC,VAL_ESPEC1, {11,1,-1}, "Espec-1" },
218 {PROTO_SR, CLASS_VARSET, VAL_VAR1, {12,1,-1}, "Variant-1" },
220 {PROTO_SR, CLASS_SCHEMA, VAL_WAIS, {13,1,-1}, "WAIS-schema" },
221 {PROTO_SR, CLASS_SCHEMA, VAL_GILS, {13,2,-1}, "GILS-schema" },
223 {PROTO_SR, CLASS_TAGSET, VAL_SETM, {14,1,-1}, "TagsetM" },
224 {PROTO_SR, CLASS_TAGSET, VAL_SETG, {14,2,-1}, "TagsetG" },
226 {PROTO_SR, CLASS_TAGSET, VAL_GILS, {14,3,-1}, "GILS-tagset" },
234 void oid_oidcpy(int *t, int *s)
236 while ((*(t++) = *(s++)) > -1);
239 void oid_oidcat(int *t, int *s)
243 while ((*(t++) = *(s++)) > -1);
246 int oid_oidcmp(int *o1, int *o2)
248 while (*o1 == *o2 && *o1 > -1)
261 int oid_oidlen(int *o)
271 static int match_prefix(int *look, int *prefix)
275 for (len = 0; *look == *prefix; look++, prefix++, len++);
276 if (*prefix < 0) /* did we reach the end of the prefix? */
281 struct oident *oid_getentbyoid(int *o)
283 enum oid_proto proto;
287 /* determine protocol type */
290 if ((prelen = match_prefix(o, z3950_prefix)) != 0)
292 else if ((prelen = match_prefix(o, sr_prefix)) != 0)
295 proto = PROTO_GENERAL;
296 for (p = oids; *p->oidsuffix >= 0; p++)
297 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
300 for (p = extoids; *p->oidsuffix >= 0; p++)
301 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
307 * To query, fill out proto, class, and value of the ent parameter.
309 int *oid_getoidbyent(struct oident *ent)
312 static int ret[OID_SIZE];
314 for (p = oids; *p->oidsuffix >= 0; p++)
315 if (ent->proto == p->proto &&
316 ent->oclass == p->oclass &&
317 ent->value == p->value)
319 if (ent->proto == PROTO_Z3950)
320 oid_oidcpy(ret, z3950_prefix);
321 else if (ent->proto == PROTO_SR)
322 oid_oidcpy(ret, sr_prefix);
325 oid_oidcat(ret, p->oidsuffix);
329 for (p = extoids; *p->oidsuffix >= 0; p++)
330 if (ent->proto == p->proto &&
331 ent->oclass == p->oclass &&
332 ent->value == p->value)
334 if (ent->proto == PROTO_Z3950)
335 oid_oidcpy(ret, z3950_prefix);
336 else if (ent->proto == PROTO_SR)
337 oid_oidcpy(ret, sr_prefix);
340 oid_oidcat(ret, p->oidsuffix);
346 oid_value oid_getvalbyname(const char *name)
350 for (p = oids; *p->oidsuffix >= 0; p++)
351 if (!yaz_matchstr(p->desc, name))
354 for (p = extoids; *p->oidsuffix >= 0; p++)
355 if (!yaz_matchstr(p->desc, name))
360 void oid_setprivateoids(oident *list)