source: trunk/gsdl/packages/yaz/asn/prt-esp.c@ 1343

Last change on this file since 1343 was 1343, checked in by johnmcp, 24 years ago

Added the YAZ toolkit source to the packages directory (for z39.50 stuff)

  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/*
2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
5 *
6 * $Log$
7 * Revision 1.1 2000/08/03 03:09:49 johnmcp
8 * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
9 *
10 * Revision 1.5 1999/11/30 13:47:11 adam
11 * Improved installation. Moved header files to include/yaz.
12 *
13 * Revision 1.4 1999/04/20 09:56:47 adam
14 * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
15 * Modified all encoders/decoders to reflect this change.
16 *
17 * Revision 1.3 1998/02/11 11:53:32 adam
18 * Changed code so that it compiles as C++.
19 *
20 * Revision 1.2 1998/02/10 15:31:46 adam
21 * Implemented date and time structure. Changed the Update Extended
22 * Service.
23 *
24 * Revision 1.1 1995/10/12 10:34:37 quinn
25 * Added Espec-1.
26 *
27 *
28 */
29
30#include <yaz/proto.h>
31
32int z_OccurValues(ODR o, Z_OccurValues **p, int opt, const char *name)
33{
34 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
35 return opt && odr_ok(o);
36 return
37 odr_implicit(o, odr_integer, &(*p)->start, ODR_CONTEXT, 1, 0) &&
38 odr_implicit(o, odr_integer, &(*p)->howMany, ODR_CONTEXT, 2, 1) &&
39 odr_sequence_end(o);
40}
41
42int z_Occurrences(ODR o, Z_Occurrences **p, int opt, const char *name)
43{
44 static Odr_arm arm[] =
45 {
46 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Occurrences_all,
47 (Odr_fun)odr_null, 0},
48 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Occurrences_last,
49 (Odr_fun)odr_null, 0},
50 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Occurrences_values,
51 (Odr_fun)z_OccurValues, 0},
52 {-1, -1, -1, -1, 0, 0}
53 };
54
55 if (o->direction == ODR_DECODE)
56 *p = (Z_Occurrences *)odr_malloc(o, sizeof(**p));
57 else if (!*p)
58 return opt;
59 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
60 return 1;
61 *p = 0;
62 return opt && odr_ok(o);
63}
64
65int z_SpecificTag(ODR o, Z_SpecificTag **p, int opt, const char *name)
66{
67 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
68 return opt && odr_ok(o);
69 return
70 odr_implicit(o, odr_oid, &(*p)->schemaId, ODR_CONTEXT, 0, 1) &&
71 odr_implicit(o, odr_integer, &(*p)->tagType, ODR_CONTEXT, 1, 1) &&
72 odr_explicit(o, z_StringOrNumeric, &(*p)->tagValue, ODR_CONTEXT,
73 2, 0) &&
74 odr_explicit(o, z_Occurrences, &(*p)->occurrences,
75 ODR_CONTEXT, 3, 1) &&
76 odr_sequence_end(o);
77}
78
79int z_ETagUnit(ODR o, Z_ETagUnit **p, int opt, const char *name)
80{
81 static Odr_arm arm[] =
82 {
83 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ETagUnit_specificTag,
84 (Odr_fun)z_SpecificTag, 0},
85 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ETagUnit_wildThing,
86 (Odr_fun)z_Occurrences, 0},
87 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_ETagUnit_wildPath,
88 (Odr_fun)odr_null, 0},
89 {-1, -1, -1 -1, 0, 0}
90 };
91
92 if (o->direction == ODR_DECODE)
93 *p = (Z_ETagUnit *)odr_malloc(o, sizeof(**p));
94 else if (!*p)
95 return opt;
96 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
97 return 1;
98 *p = 0;
99 return opt && odr_ok(o);
100}
101
102int z_ETagPath(ODR o, Z_ETagPath **p, int opt, const char *name)
103{
104 if (o->direction == ODR_DECODE)
105 *p = (Z_ETagPath *)odr_malloc(o, sizeof(**p));
106 else if (!*p)
107 return opt;
108 if (odr_sequence_of(o, (Odr_fun)z_ETagUnit, &(*p)->tags,
109 &(*p)->num_tags, 0))
110 return 1;
111 *p = 0;
112 return opt && odr_ok(o);
113}
114
115int z_SimpleElement(ODR o, Z_SimpleElement **p, int opt, const char *name)
116{
117 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
118 return opt && odr_ok(o);
119 return
120 odr_implicit(o, z_ETagPath, &(*p)->path, ODR_CONTEXT, 1, 0) &&
121 odr_implicit(o, z_Variant, &(*p)->variantRequest,
122 ODR_CONTEXT, 2, 1) &&
123 odr_sequence_end(o);
124}
125
126int z_CompoPrimitives(ODR o, Z_CompoPrimitives **p, int opt, const char *name)
127{
128 if (o->direction == ODR_DECODE)
129 *p = (Z_CompoPrimitives *)odr_malloc(o, sizeof(**p));
130 else if (!*p)
131 return opt;
132 if (odr_sequence_of(o, z_InternationalString, &(*p)->primitives,
133 &(*p)->num_primitives, 0))
134 return 1;
135 *p = 0;
136 return opt && odr_ok(o);
137}
138
139int z_CompoSpecs(ODR o, Z_CompoSpecs **p, int opt, const char *name)
140{
141 if (o->direction == ODR_DECODE)
142 *p = (Z_CompoSpecs *)odr_malloc(o, sizeof(**p));
143 else if (!*p)
144 return opt;
145 if (odr_sequence_of(o, (Odr_fun)z_SimpleElement, &(*p)->specs,
146 &(*p)->num_specs, 0))
147 return 1;
148 *p = 0;
149 return opt && odr_ok(o);
150}
151
152int z_CompositeElement(ODR o, Z_CompositeElement **p, int opt,
153 const char *name)
154{
155 static Odr_arm arm[] =
156 {
157 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_CompoElement_primitives,
158 (Odr_fun)z_CompoPrimitives, 0},
159 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_CompoElement_specs,
160 (Odr_fun)z_CompoSpecs, 0},
161 {-1, -1, -1, -1, 0, 0}
162 };
163
164 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
165 return opt && odr_ok(o);
166 return
167 odr_constructed_begin(o, &(*p)->elementList, ODR_CONTEXT, 1, 0) &&
168 odr_choice(o, arm, &(*p)->elementList, &(*p)->which, 0) &&
169 odr_constructed_end(o) &&
170 odr_implicit(o, z_ETagPath, &(*p)->deliveryTag, ODR_CONTEXT, 2, 0) &&
171 odr_implicit(o, z_Variant, &(*p)->variantRequest, ODR_CONTEXT, 3, 1) &&
172 odr_sequence_end(o);
173}
174
175int z_ElementRequest(ODR o, Z_ElementRequest **p, int opt, const char *name)
176{
177 static Odr_arm arm[] =
178 {
179 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ERequest_simpleElement,
180 (Odr_fun)z_SimpleElement, 0},
181 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ERequest_compositeElement,
182 (Odr_fun)z_CompositeElement, 0},
183 {-1, -1, -1 -1, 0, 0}
184 };
185
186 if (o->direction == ODR_DECODE)
187 *p = (Z_ElementRequest *)odr_malloc(o, sizeof(**p));
188 else if (!*p)
189 return opt;
190 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
191 return 1;
192 *p = 0;
193 return opt && odr_ok(o);
194}
195
196int z_Espec1(ODR o, Z_Espec1 **p, int opt, const char *name)
197{
198 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
199 return opt && odr_ok(o);
200 return
201 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
202 (odr_sequence_of(o, z_InternationalString, &(*p)->elementSetNames,
203 &(*p)->num_elementSetNames, 0) || odr_ok(o)) &&
204 odr_implicit(o, odr_oid, &(*p)->defaultVariantSetId,
205 ODR_CONTEXT, 2, 1) &&
206 odr_implicit(o, z_Variant, &(*p)->defaultVariantRequest,
207 ODR_CONTEXT, 3, 1) &&
208 odr_implicit(o, odr_integer, &(*p)->defaultTagType,
209 ODR_CONTEXT, 4, 1) &&
210 odr_implicit_settag(o, ODR_CONTEXT, 5) &&
211 (odr_sequence_of(o, (Odr_fun)z_ElementRequest, &(*p)->elements,
212 &(*p)->num_elements, 0) || odr_ok(o)) &&
213 odr_sequence_end(o);
214}
Note: See TracBrowser for help on using the repository browser.