2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1999-11-30 13:47:11 adam
8 * Improved installation. Moved header files to include/yaz.
10 * Revision 1.4 1999/04/20 09:56:47 adam
11 * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
12 * Modified all encoders/decoders to reflect this change.
14 * Revision 1.3 1998/02/11 11:53:32 adam
15 * Changed code so that it compiles as C++.
17 * Revision 1.2 1998/02/10 15:31:46 adam
18 * Implemented date and time structure. Changed the Update Extended
21 * Revision 1.1 1995/10/12 10:34:37 quinn
27 #include <yaz/proto.h>
29 int z_OccurValues(ODR o, Z_OccurValues **p, int opt, const char *name)
31 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
32 return opt && odr_ok(o);
34 odr_implicit(o, odr_integer, &(*p)->start, ODR_CONTEXT, 1, 0) &&
35 odr_implicit(o, odr_integer, &(*p)->howMany, ODR_CONTEXT, 2, 1) &&
39 int z_Occurrences(ODR o, Z_Occurrences **p, int opt, const char *name)
41 static Odr_arm arm[] =
43 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Occurrences_all,
44 (Odr_fun)odr_null, 0},
45 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Occurrences_last,
46 (Odr_fun)odr_null, 0},
47 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Occurrences_values,
48 (Odr_fun)z_OccurValues, 0},
49 {-1, -1, -1, -1, 0, 0}
52 if (o->direction == ODR_DECODE)
53 *p = (Z_Occurrences *)odr_malloc(o, sizeof(**p));
56 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
59 return opt && odr_ok(o);
62 int z_SpecificTag(ODR o, Z_SpecificTag **p, int opt, const char *name)
64 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
65 return opt && odr_ok(o);
67 odr_implicit(o, odr_oid, &(*p)->schemaId, ODR_CONTEXT, 0, 1) &&
68 odr_implicit(o, odr_integer, &(*p)->tagType, ODR_CONTEXT, 1, 1) &&
69 odr_explicit(o, z_StringOrNumeric, &(*p)->tagValue, ODR_CONTEXT,
71 odr_explicit(o, z_Occurrences, &(*p)->occurrences,
76 int z_ETagUnit(ODR o, Z_ETagUnit **p, int opt, const char *name)
78 static Odr_arm arm[] =
80 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ETagUnit_specificTag,
81 (Odr_fun)z_SpecificTag, 0},
82 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ETagUnit_wildThing,
83 (Odr_fun)z_Occurrences, 0},
84 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_ETagUnit_wildPath,
85 (Odr_fun)odr_null, 0},
89 if (o->direction == ODR_DECODE)
90 *p = (Z_ETagUnit *)odr_malloc(o, sizeof(**p));
93 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
96 return opt && odr_ok(o);
99 int z_ETagPath(ODR o, Z_ETagPath **p, int opt, const char *name)
101 if (o->direction == ODR_DECODE)
102 *p = (Z_ETagPath *)odr_malloc(o, sizeof(**p));
105 if (odr_sequence_of(o, (Odr_fun)z_ETagUnit, &(*p)->tags,
109 return opt && odr_ok(o);
112 int z_SimpleElement(ODR o, Z_SimpleElement **p, int opt, const char *name)
114 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
115 return opt && odr_ok(o);
117 odr_implicit(o, z_ETagPath, &(*p)->path, ODR_CONTEXT, 1, 0) &&
118 odr_implicit(o, z_Variant, &(*p)->variantRequest,
119 ODR_CONTEXT, 2, 1) &&
123 int z_CompoPrimitives(ODR o, Z_CompoPrimitives **p, int opt, const char *name)
125 if (o->direction == ODR_DECODE)
126 *p = (Z_CompoPrimitives *)odr_malloc(o, sizeof(**p));
129 if (odr_sequence_of(o, z_InternationalString, &(*p)->primitives,
130 &(*p)->num_primitives, 0))
133 return opt && odr_ok(o);
136 int z_CompoSpecs(ODR o, Z_CompoSpecs **p, int opt, const char *name)
138 if (o->direction == ODR_DECODE)
139 *p = (Z_CompoSpecs *)odr_malloc(o, sizeof(**p));
142 if (odr_sequence_of(o, (Odr_fun)z_SimpleElement, &(*p)->specs,
143 &(*p)->num_specs, 0))
146 return opt && odr_ok(o);
149 int z_CompositeElement(ODR o, Z_CompositeElement **p, int opt,
152 static Odr_arm arm[] =
154 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_CompoElement_primitives,
155 (Odr_fun)z_CompoPrimitives, 0},
156 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_CompoElement_specs,
157 (Odr_fun)z_CompoSpecs, 0},
158 {-1, -1, -1, -1, 0, 0}
161 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
162 return opt && odr_ok(o);
164 odr_constructed_begin(o, &(*p)->elementList, ODR_CONTEXT, 1, 0) &&
165 odr_choice(o, arm, &(*p)->elementList, &(*p)->which, 0) &&
166 odr_constructed_end(o) &&
167 odr_implicit(o, z_ETagPath, &(*p)->deliveryTag, ODR_CONTEXT, 2, 0) &&
168 odr_implicit(o, z_Variant, &(*p)->variantRequest, ODR_CONTEXT, 3, 1) &&
172 int z_ElementRequest(ODR o, Z_ElementRequest **p, int opt, const char *name)
174 static Odr_arm arm[] =
176 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ERequest_simpleElement,
177 (Odr_fun)z_SimpleElement, 0},
178 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ERequest_compositeElement,
179 (Odr_fun)z_CompositeElement, 0},
180 {-1, -1, -1 -1, 0, 0}
183 if (o->direction == ODR_DECODE)
184 *p = (Z_ElementRequest *)odr_malloc(o, sizeof(**p));
187 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
190 return opt && odr_ok(o);
193 int z_Espec1(ODR o, Z_Espec1 **p, int opt, const char *name)
195 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
196 return opt && odr_ok(o);
198 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
199 (odr_sequence_of(o, z_InternationalString, &(*p)->elementSetNames,
200 &(*p)->num_elementSetNames, 0) || odr_ok(o)) &&
201 odr_implicit(o, odr_oid, &(*p)->defaultVariantSetId,
202 ODR_CONTEXT, 2, 1) &&
203 odr_implicit(o, z_Variant, &(*p)->defaultVariantRequest,
204 ODR_CONTEXT, 3, 1) &&
205 odr_implicit(o, odr_integer, &(*p)->defaultTagType,
206 ODR_CONTEXT, 4, 1) &&
207 odr_implicit_settag(o, ODR_CONTEXT, 5) &&
208 (odr_sequence_of(o, (Odr_fun)z_ElementRequest, &(*p)->elements,
209 &(*p)->num_elements, 0) || odr_ok(o)) &&