2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-05-29 08:17:13 quinn
8 * iMoved oid to util to support comstack.
10 * Revision 1.5 1995/05/22 11:30:16 quinn
11 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
13 * Revision 1.4 1995/05/16 08:50:22 quinn
14 * License, documentation, and memory fixes
16 * Revision 1.3 1995/04/11 11:52:02 quinn
17 * Fixed possible buf in proto.c
19 * Revision 1.2 1995/03/29 15:39:38 quinn
20 * Adding some resource control elements, and a null-check to getentbyoid
22 * Revision 1.1 1995/03/27 08:32:12 quinn
29 * More or less protocol-transparent OID database.
30 * We could (and should?) extend this so that the user app can add new
31 * entries to the list at initialization.
36 static int z3950_prefix[] = { 1, 2, 840, 10003, -1 };
37 static int sr_prefix[] = { 1, 0, 10163, -1 };
42 static oident oids[] =
44 /* General definitions */
45 {PROTO_GENERAL, CLASS_TRANSYN, VAL_BER, {2,1,1,-1}, "BER" },
46 {PROTO_GENERAL, CLASS_TRANSYN, VAL_ISO2709, {1,0,2709,1,1,-1},"ISO2709"},
48 /* Z39.50v3 definitions */
49 {PROTO_Z3950, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "Z-APDU" },
50 {PROTO_Z3950, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "Z-BASIC" },
51 {PROTO_Z3950, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
52 {PROTO_Z3950, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
53 {PROTO_Z3950, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
54 {PROTO_Z3950, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
55 {PROTO_Z3950, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
56 {PROTO_Z3950, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
57 {PROTO_Z3950, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
58 {PROTO_Z3950, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
59 {PROTO_Z3950, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
60 {PROTO_Z3950, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
61 {PROTO_Z3950, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
62 {PROTO_Z3950, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
63 {PROTO_Z3950, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
64 {PROTO_Z3950, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
65 {PROTO_Z3950, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
66 {PROTO_Z3950, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
67 {PROTO_Z3950, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
68 {PROTO_Z3950, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
69 {PROTO_Z3950, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
70 {PROTO_Z3950, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
71 {PROTO_Z3950, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
72 {PROTO_Z3950, CLASS_RECSYN, VAL_AUSMARC, {5,20,-1}, "Ausmarc" },
73 {PROTO_Z3950, CLASS_RECSYN, VAL_IBERMARC, {5,21,-1}, "Ibermarc" },
74 {PROTO_Z3950, CLASS_RECSYN, VAL_EXPLAIN, {5,100,-1}, "Explain" },
75 {PROTO_Z3950, CLASS_RECSYN, VAL_SUTRS, {5,101,-1}, "SUTRS" },
76 {PROTO_Z3950, CLASS_RECSYN, VAL_OPAC, {5,102,-1}, "OPAC" },
77 {PROTO_Z3950, CLASS_RECSYN, VAL_SUMMARY, {5,103,-1}, "Summary" },
78 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS0, {5,104,-1}, "GRS-0" },
79 {PROTO_Z3950, CLASS_RECSYN, VAL_GRS1, {5,105,-1}, "GRS-1" },
80 {PROTO_Z3950, CLASS_RECSYN, VAL_EXTENDED, {5,106,-1}, "Extended" },
81 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE1, {7,1,-1}, "Resource-1" },
82 {PROTO_Z3950, CLASS_RESFORM, VAL_RESOURCE2, {7,2,-1}, "Resource-2" },
83 {PROTO_Z3950, CLASS_ACCFORM, VAL_PROMPT1, {8,1,-1}, "Prompt-1" },
84 {PROTO_Z3950, CLASS_ACCFORM, VAL_DES1, {8,2,-1}, "Des-1" },
85 {PROTO_Z3950, CLASS_ACCFORM, VAL_KRB1, {8,3,-1}, "Krb-1" },
86 {PROTO_Z3950, CLASS_EXTSERV, VAL_PRESSET, {9,1,-1}, "Pers. set" },
87 {PROTO_Z3950, CLASS_EXTSERV, VAL_PQUERY, {9,2,-1}, "Pers. query" },
88 {PROTO_Z3950, CLASS_EXTSERV, VAL_PCQUERY, {9,3,-1}, "Per'd query" },
89 {PROTO_Z3950, CLASS_EXTSERV, VAL_ITEMORDER, {9,4,-1}, "Item order" },
90 {PROTO_Z3950, CLASS_EXTSERV, VAL_DBUPDATE, {9,5,-1}, "DB. Update" },
91 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTSPEC,{9,6,-1}, "exp. spec." },
92 {PROTO_Z3950, CLASS_EXTSERV, VAL_EXPORTINV, {9,7,-1}, "exp. inv." },
94 /* SR definitions. Note that some of them aren't defined by the
95 standard (yet), but are borrowed from Z3950v3 */
96 {PROTO_SR, CLASS_ABSYN, VAL_APDU, {2,1,-1}, "SR-APDU" },
97 {PROTO_SR, CLASS_APPCTX, VAL_BASIC_CTX, {1,1,-1}, "SR-BASIC" },
98 {PROTO_SR, CLASS_ATTSET, VAL_BIB1, {3,1,-1}, "Bib-1" },
99 {PROTO_SR, CLASS_ATTSET, VAL_EXP1, {3,2,-1}, "Exp-1" },
100 {PROTO_SR, CLASS_ATTSET, VAL_EXT1, {3,3,-1}, "Ext-1" },
101 {PROTO_SR, CLASS_ATTSET, VAL_CCL1, {3,4,-1}, "CCL-1" },
102 {PROTO_SR, CLASS_ATTSET, VAL_GILS, {3,5,-1}, "GILS" },
103 {PROTO_SR, CLASS_ATTSET, VAL_STAS, {3,6,-1}, "STAS", },
104 {PROTO_SR, CLASS_DIAGSET, VAL_BIB1, {4,1,-1}, "Bib-1" },
105 {PROTO_SR, CLASS_DIAGSET, VAL_DIAG1, {4,2,-1}, "Diag-1" },
106 {PROTO_SR, CLASS_RECSYN, VAL_UNIMARC, {5,1,-1}, "Unimarc" },
107 {PROTO_SR, CLASS_RECSYN, VAL_INTERMARC, {5,2,-1}, "Intermarc" },
108 {PROTO_SR, CLASS_RECSYN, VAL_CCF, {5,3,-1}, "CCF" },
109 {PROTO_SR, CLASS_RECSYN, VAL_USMARC, {5,10,-1}, "USmarc" },
110 {PROTO_SR, CLASS_RECSYN, VAL_UKMARC, {5,11,-1}, "UKmarc" },
111 {PROTO_SR, CLASS_RECSYN, VAL_NORMARC, {5,12,-1}, "Normarc" },
112 {PROTO_SR, CLASS_RECSYN, VAL_LIBRISMARC,{5,13,-1}, "Librismarc" },
113 {PROTO_SR, CLASS_RECSYN, VAL_DANMARC, {5,14,-1}, "Danmarc" },
114 {PROTO_SR, CLASS_RECSYN, VAL_FINMARC, {5,15,-1}, "Finmarc" },
115 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
116 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
117 {PROTO_SR, CLASS_RECSYN, VAL_MAB, {5,16,-1}, "MAB" },
118 {PROTO_SR, CLASS_RECSYN, VAL_CANMARC, {5,17,-1}, "Canmarc" },
119 {PROTO_SR, CLASS_RECSYN, VAL_SBN, {5,18,-1}, "SBN" },
120 {PROTO_SR, CLASS_RECSYN, VAL_PICAMARC, {5,19,-1}, "Picamarc" },
126 void oid_oidcpy(int *t, int *s)
128 while ((*(t++) = *(s++)) > -1);
131 void oid_oidcat(int *t, int *s)
135 while ((*(t++) = *(s++)) > -1);
138 int oid_oidcmp(int *o1, int *o2)
140 while (*o1 == *o2 && *o1 > -1)
153 int oid_oidlen(int *o)
163 static int match_prefix(int *look, int *prefix)
167 for (len = 0; *look == *prefix; look++, prefix++, len++);
168 if (*prefix < 0) /* did we reach the end of the prefix? */
173 struct oident *oid_getentbyoid(int *o)
175 enum oid_proto proto;
179 /* determine protocol type */
182 if ((prelen = match_prefix(o, z3950_prefix)))
184 else if ((prelen = match_prefix(o, sr_prefix)))
187 proto = PROTO_GENERAL;
188 for (p = oids; *p->oidsuffix >= 0; p++)
189 if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
195 * To query, fill out proto, class, and value of the ent parameter.
197 int *oid_getoidbyent(struct oident *ent)
200 static int ret[OID_SIZE];
202 for (p = oids; *p->oidsuffix >= 0; p++)
203 if (ent->proto == p->proto &&
204 ent->class == p->class &&
205 ent->value == p->value)
207 if (ent->proto == PROTO_Z3950)
208 oid_oidcpy(ret, z3950_prefix);
209 else if (ent->proto == PROTO_SR)
210 oid_oidcpy(ret, sr_prefix);
213 oid_oidcat(ret, p->oidsuffix);