2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1999-04-20 09:56:47 adam
8 * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
9 * Modified all encoders/decoders to reflect this change.
11 * Revision 1.3 1998/02/11 11:53:32 adam
12 * Changed code so that it compiles as C++.
14 * Revision 1.2 1998/02/10 15:31:46 adam
15 * Implemented date and time structure. Changed the Update Extended
18 * Revision 1.1 1995/10/12 10:34:37 quinn
26 int z_OccurValues(ODR o, Z_OccurValues **p, int opt, const char *name)
28 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
29 return opt && odr_ok(o);
31 odr_implicit(o, odr_integer, &(*p)->start, ODR_CONTEXT, 1, 0) &&
32 odr_implicit(o, odr_integer, &(*p)->howMany, ODR_CONTEXT, 2, 1) &&
36 int z_Occurrences(ODR o, Z_Occurrences **p, int opt, const char *name)
38 static Odr_arm arm[] =
40 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Occurrences_all,
41 (Odr_fun)odr_null, 0},
42 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Occurrences_last,
43 (Odr_fun)odr_null, 0},
44 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Occurrences_values,
45 (Odr_fun)z_OccurValues, 0},
46 {-1, -1, -1, -1, 0, 0}
49 if (o->direction == ODR_DECODE)
50 *p = (Z_Occurrences *)odr_malloc(o, sizeof(**p));
53 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
56 return opt && odr_ok(o);
59 int z_SpecificTag(ODR o, Z_SpecificTag **p, int opt, const char *name)
61 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
62 return opt && odr_ok(o);
64 odr_implicit(o, odr_oid, &(*p)->schemaId, ODR_CONTEXT, 0, 1) &&
65 odr_implicit(o, odr_integer, &(*p)->tagType, ODR_CONTEXT, 1, 1) &&
66 odr_explicit(o, z_StringOrNumeric, &(*p)->tagValue, ODR_CONTEXT,
68 odr_explicit(o, z_Occurrences, &(*p)->occurrences,
73 int z_ETagUnit(ODR o, Z_ETagUnit **p, int opt, const char *name)
75 static Odr_arm arm[] =
77 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ETagUnit_specificTag,
78 (Odr_fun)z_SpecificTag, 0},
79 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ETagUnit_wildThing,
80 (Odr_fun)z_Occurrences, 0},
81 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_ETagUnit_wildPath,
82 (Odr_fun)odr_null, 0},
86 if (o->direction == ODR_DECODE)
87 *p = (Z_ETagUnit *)odr_malloc(o, sizeof(**p));
90 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
93 return opt && odr_ok(o);
96 int z_ETagPath(ODR o, Z_ETagPath **p, int opt, const char *name)
98 if (o->direction == ODR_DECODE)
99 *p = (Z_ETagPath *)odr_malloc(o, sizeof(**p));
102 if (odr_sequence_of(o, (Odr_fun)z_ETagUnit, &(*p)->tags,
106 return opt && odr_ok(o);
109 int z_SimpleElement(ODR o, Z_SimpleElement **p, int opt, const char *name)
111 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
112 return opt && odr_ok(o);
114 odr_implicit(o, z_ETagPath, &(*p)->path, ODR_CONTEXT, 1, 0) &&
115 odr_implicit(o, z_Variant, &(*p)->variantRequest,
116 ODR_CONTEXT, 2, 1) &&
120 int z_CompoPrimitives(ODR o, Z_CompoPrimitives **p, int opt, const char *name)
122 if (o->direction == ODR_DECODE)
123 *p = (Z_CompoPrimitives *)odr_malloc(o, sizeof(**p));
126 if (odr_sequence_of(o, z_InternationalString, &(*p)->primitives,
127 &(*p)->num_primitives, 0))
130 return opt && odr_ok(o);
133 int z_CompoSpecs(ODR o, Z_CompoSpecs **p, int opt, const char *name)
135 if (o->direction == ODR_DECODE)
136 *p = (Z_CompoSpecs *)odr_malloc(o, sizeof(**p));
139 if (odr_sequence_of(o, (Odr_fun)z_SimpleElement, &(*p)->specs,
140 &(*p)->num_specs, 0))
143 return opt && odr_ok(o);
146 int z_CompositeElement(ODR o, Z_CompositeElement **p, int opt,
149 static Odr_arm arm[] =
151 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_CompoElement_primitives,
152 (Odr_fun)z_CompoPrimitives, 0},
153 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_CompoElement_specs,
154 (Odr_fun)z_CompoSpecs, 0},
155 {-1, -1, -1, -1, 0, 0}
158 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
159 return opt && odr_ok(o);
161 odr_constructed_begin(o, &(*p)->elementList, ODR_CONTEXT, 1, 0) &&
162 odr_choice(o, arm, &(*p)->elementList, &(*p)->which, 0) &&
163 odr_constructed_end(o) &&
164 odr_implicit(o, z_ETagPath, &(*p)->deliveryTag, ODR_CONTEXT, 2, 0) &&
165 odr_implicit(o, z_Variant, &(*p)->variantRequest, ODR_CONTEXT, 3, 1) &&
169 int z_ElementRequest(ODR o, Z_ElementRequest **p, int opt, const char *name)
171 static Odr_arm arm[] =
173 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ERequest_simpleElement,
174 (Odr_fun)z_SimpleElement, 0},
175 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ERequest_compositeElement,
176 (Odr_fun)z_CompositeElement, 0},
177 {-1, -1, -1 -1, 0, 0}
180 if (o->direction == ODR_DECODE)
181 *p = (Z_ElementRequest *)odr_malloc(o, sizeof(**p));
184 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
187 return opt && odr_ok(o);
190 int z_Espec1(ODR o, Z_Espec1 **p, int opt, const char *name)
192 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
193 return opt && odr_ok(o);
195 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
196 (odr_sequence_of(o, z_InternationalString, &(*p)->elementSetNames,
197 &(*p)->num_elementSetNames, 0) || odr_ok(o)) &&
198 odr_implicit(o, odr_oid, &(*p)->defaultVariantSetId,
199 ODR_CONTEXT, 2, 1) &&
200 odr_implicit(o, z_Variant, &(*p)->defaultVariantRequest,
201 ODR_CONTEXT, 3, 1) &&
202 odr_implicit(o, odr_integer, &(*p)->defaultTagType,
203 ODR_CONTEXT, 4, 1) &&
204 odr_implicit_settag(o, ODR_CONTEXT, 5) &&
205 (odr_sequence_of(o, (Odr_fun)z_ElementRequest, &(*p)->elements,
206 &(*p)->num_elements, 0) || odr_ok(o)) &&