2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.20 1999-04-20 09:56:48 adam
8 * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
9 * Modified all encoders/decoders to reflect this change.
11 * Revision 1.19 1998/03/31 15:13:19 adam
12 * Development towards compiled ASN.1.
14 * Revision 1.18 1998/03/31 11:07:44 adam
15 * Furhter work on UNIverse resource report.
16 * Added Extended Services handling in frontend server.
18 * Revision 1.17 1998/03/20 14:46:06 adam
19 * Added UNIverse Resource Reports.
21 * Revision 1.16 1998/02/11 11:53:32 adam
22 * Changed code so that it compiles as C++.
24 * Revision 1.15 1998/02/10 15:31:46 adam
25 * Implemented date and time structure. Changed the Update Extended
28 * Revision 1.14 1998/01/05 09:04:57 adam
29 * Fixed bugs in encoders/decoders - Not operator (!) missing.
31 * Revision 1.13 1997/05/14 06:53:22 adam
34 * Revision 1.12 1997/04/30 08:52:02 quinn
37 * Revision 1.11 1996/10/10 12:35:13 quinn
38 * Added Update extended service.
40 * Revision 1.10 1996/10/09 15:54:55 quinn
41 * Added SearchInfoReport
43 * Revision 1.9 1996/06/10 08:53:36 quinn
44 * Added Summary,OPAC,ResourceReport
46 * Revision 1.8 1996/02/20 12:51:44 quinn
47 * Completed SCAN. Fixed problems with EXTERNAL.
49 * Revision 1.7 1995/10/12 10:34:38 quinn
52 * Revision 1.6 1995/09/29 17:11:55 quinn
55 * Revision 1.5 1995/09/27 15:02:42 quinn
56 * Modified function heads & prototypes.
58 * Revision 1.4 1995/08/29 11:17:16 quinn
59 * *** empty log message ***
61 * Revision 1.3 1995/08/21 09:10:18 quinn
62 * Smallish fixes to suppport new formats.
64 * Revision 1.2 1995/08/17 12:45:00 quinn
65 * Fixed minor problems with GRS-1. Added support in c&s.
67 * Revision 1.1 1995/08/15 13:37:41 quinn
76 * The table below should be moved to the ODR structure itself and
77 * be an image of the association context: To help
78 * map indirect references when they show up.
80 static Z_ext_typeent type_table[] =
82 {VAL_SUTRS, Z_External_sutrs, (Odr_fun) z_SUTRS},
83 {VAL_EXPLAIN, Z_External_explainRecord, (Odr_fun)z_ExplainRecord},
84 {VAL_RESOURCE1, Z_External_resourceReport1, (Odr_fun)z_ResourceReport1},
85 {VAL_RESOURCE2, Z_External_resourceReport2, (Odr_fun)z_ResourceReport2},
86 {VAL_PROMPT1, Z_External_promptObject1, (Odr_fun)z_PromptObject1 },
87 {VAL_GRS1, Z_External_grs1, (Odr_fun)z_GenericRecord},
88 {VAL_EXTENDED, Z_External_extendedService, (Odr_fun)z_TaskPackage},
90 {VAL_ITEMORDER, Z_External_itemOrder, (Odr_fun)z_IOItemOrder},
92 {VAL_ITEMORDER, Z_External_itemOrder, (Odr_fun)z_ItemOrder},
94 {VAL_DIAG1, Z_External_diag1, (Odr_fun)z_DiagnosticFormat},
95 {VAL_ESPEC1, Z_External_espec1, (Odr_fun)z_Espec1},
96 {VAL_SUMMARY, Z_External_summary, (Odr_fun)z_BriefBib},
97 {VAL_OPAC, Z_External_OPAC, (Odr_fun)z_OPACRecord},
98 {VAL_SEARCHRES1, Z_External_searchResult1, (Odr_fun)z_SearchInfoReport},
99 {VAL_DBUPDATE, Z_External_update, (Odr_fun)z_IUUpdate},
100 {VAL_DATETIME, Z_External_dateTime, (Odr_fun)z_DateTime},
101 {VAL_UNIVERSE_REPORT, Z_External_universeReport, (Odr_fun)z_UniverseReport},
105 Z_ext_typeent *z_ext_getentbyref(oid_value val)
109 for (i = type_table; i->dref != VAL_NONE; i++)
115 int z_External(ODR o, Z_External **p, int opt, const char *name)
120 static Odr_arm arm[] =
122 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_single,
123 (Odr_fun)odr_any, 0},
124 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_External_octet,
125 (Odr_fun)odr_octetstring, 0},
126 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_External_arbitrary,
127 (Odr_fun)odr_bitstring, 0},
128 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_sutrs,
129 (Odr_fun)z_SUTRS, 0},
130 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_explainRecord,
131 (Odr_fun)z_ExplainRecord, 0},
132 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport1,
133 (Odr_fun)z_ResourceReport1, 0},
134 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport2,
135 (Odr_fun)z_ResourceReport2, 0},
136 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1,
137 (Odr_fun)z_PromptObject1, 0},
138 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1,
139 (Odr_fun)z_GenericRecord, 0},
140 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService,
141 (Odr_fun)z_TaskPackage, 0},
143 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
144 (Odr_fun)z_IOItemOrder, 0},
146 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
147 (Odr_fun)z_ItemOrder, 0},
149 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_diag1,
150 (Odr_fun)z_DiagnosticFormat, 0},
151 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1,
152 (Odr_fun)z_Espec1, 0},
153 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_summary,
154 (Odr_fun)z_BriefBib, 0},
155 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OPAC,
156 (Odr_fun)z_OPACRecord, 0},
157 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_searchResult1,
158 (Odr_fun)z_SearchInfoReport, 0},
159 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update,
160 (Odr_fun)z_IUUpdate, 0},
161 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_dateTime,
162 (Odr_fun)z_DateTime, 0},
163 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_universeReport,
164 (Odr_fun)z_UniverseReport, 0},
165 {-1, -1, -1, -1, 0, 0}
168 odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
169 if (!odr_sequence_begin(o, p, sizeof(**p), name))
170 return opt && odr_ok(o);
171 if (!(odr_oid(o, &(*p)->direct_reference, 1, 0) &&
172 odr_integer(o, &(*p)->indirect_reference, 1, 0) &&
173 odr_graphicstring(o, &(*p)->descriptor, 1, 0)))
176 * Do we know this beast?
178 if (o->direction == ODR_DECODE && (*p)->direct_reference &&
179 (oid = oid_getentbyoid((*p)->direct_reference)) &&
180 (type = z_ext_getentbyref(oid->value)))
182 int zclass, tag, cons;
185 * We know it. If it's represented as an ASN.1 type, bias the CHOICE.
187 if (!odr_peektag(o, &zclass, &tag, &cons))
188 return opt && odr_ok(o);
189 if (zclass == ODR_CONTEXT && tag == 0 && cons == 1)
190 odr_choice_bias(o, type->what);
193 odr_choice(o, arm, &(*p)->u, &(*p)->which, name) &&