YAZ  5.23.1
z-espec1.c
Go to the documentation of this file.
1 
6 #if HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9 
10 #include <yaz/z-espec1.h>
11 
12 int z_Espec1(ODR o, Z_Espec1 **p, int opt, const char *name)
13 {
14  if (!odr_sequence_begin(o, p, sizeof(**p), name))
15  return odr_missing(o, opt, name) && odr_ok (o);
16  return
18  (odr_sequence_of(o, (Odr_fun) z_InternationalString, &(*p)->elementSetNames,
19  &(*p)->num_elementSetNames, "elementSetNames") || odr_ok(o)) &&
21  &(*p)->defaultVariantSetId, ODR_CONTEXT, 2, 1, "defaultVariantSetId") &&
23  &(*p)->defaultVariantRequest, ODR_CONTEXT, 3, 1, "defaultVariantRequest") &&
25  &(*p)->defaultTagType, ODR_CONTEXT, 4, 1, "defaultTagType") &&
27  (odr_sequence_of(o, (Odr_fun) z_ElementRequest, &(*p)->elements,
28  &(*p)->num_elements, "elements") || odr_ok(o)) &&
30 }
31 
33 {
34  if (!odr_initmember(o, p, sizeof(**p)))
35  return odr_missing(o, opt, name);
36  if (odr_sequence_of(o, (Odr_fun) z_InternationalString, &(*p)->elements,
37  &(*p)->num, name))
38  return 1;
39  if (o->direction == ODR_DECODE)
40  *p = 0;
41  return odr_missing(o, opt, name);
42 }
43 
45 {
46  if (!odr_initmember(o, p, sizeof(**p)))
47  return odr_missing(o, opt, name);
48  if (odr_sequence_of(o, (Odr_fun) z_SimpleElement, &(*p)->elements,
49  &(*p)->num, name))
50  return 1;
51  if (o->direction == ODR_DECODE)
52  *p = 0;
53  return odr_missing(o, opt, name);
54 }
55 
57 {
58  static Odr_arm arm[] = {
63  {-1, -1, -1, -1, (Odr_fun) 0, 0}
64  };
65  if (!odr_sequence_begin(o, p, sizeof(**p), name))
66  return odr_missing(o, opt, name) && odr_ok (o);
67  return
68  odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1, "elementList") &&
69  odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
72  &(*p)->deliveryTag, ODR_CONTEXT, 2, 0, "deliveryTag") &&
74  &(*p)->variantRequest, ODR_CONTEXT, 3, 1, "variantRequest") &&
76 }
77 
78 int z_ElementRequest(ODR o, Z_ElementRequest **p, int opt, const char *name)
79 {
80  static Odr_arm arm[] = {
82  (Odr_fun) z_SimpleElement, "simpleElement"},
84  (Odr_fun) z_ElementRequestCompositeElement, "compositeElement"},
85  {-1, -1, -1, -1, (Odr_fun) 0, 0}
86  };
87  if (!odr_initmember(o, p, sizeof(**p)))
88  return odr_missing(o, opt, name);
89  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
90  return 1;
91  if (o->direction == ODR_DECODE)
92  *p = 0;
93  return odr_missing(o, opt, name);
94 }
95 
96 int z_SimpleElement(ODR o, Z_SimpleElement **p, int opt, const char *name)
97 {
98  if (!odr_sequence_begin(o, p, sizeof(**p), name))
99  return odr_missing(o, opt, name) && odr_ok (o);
100  return
102  &(*p)->path, ODR_CONTEXT, 1, 0, "path") &&
104  &(*p)->variantRequest, ODR_CONTEXT, 2, 1, "variantRequest") &&
105  odr_sequence_end(o);
106 }
107 
108 int z_SpecificTag(ODR o, Z_SpecificTag **p, int opt, const char *name)
109 {
110  if (!odr_sequence_begin(o, p, sizeof(**p), name))
111  return odr_missing(o, opt, name) && odr_ok (o);
112  return
114  &(*p)->tagType, ODR_CONTEXT, 1, 1, "tagType") &&
116  &(*p)->tagValue, ODR_CONTEXT, 2, 0, "tagValue") &&
118  &(*p)->occurrences, ODR_CONTEXT, 3, 1, "occurrences") &&
119  odr_sequence_end(o);
120 }
121 
122 int z_ETagUnit(ODR o, Z_ETagUnit **p, int opt, const char *name)
123 {
124  static Odr_arm arm[] = {
126  (Odr_fun) z_SpecificTag, "specificTag"},
128  (Odr_fun) z_Occurrences, "wildThing"},
130  (Odr_fun) odr_null, "wildPath"},
131  {-1, -1, -1, -1, (Odr_fun) 0, 0}
132  };
133  if (!odr_initmember(o, p, sizeof(**p)))
134  return odr_missing(o, opt, name);
135  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
136  return 1;
137  if (o->direction == ODR_DECODE)
138  *p = 0;
139  return odr_missing(o, opt, name);
140 }
141 
142 int z_ETagPath(ODR o, Z_ETagPath **p, int opt, const char *name)
143 {
144  if (!odr_initmember(o, p, sizeof(**p)))
145  return odr_missing(o, opt, name);
146  if (odr_sequence_of(o, (Odr_fun) z_ETagUnit, &(*p)->tags,
147  &(*p)->num_tags, name))
148  return 1;
149  if (o->direction == ODR_DECODE)
150  *p = 0;
151  return odr_missing(o, opt, name);
152 }
153 
154 int z_OccurValues(ODR o, Z_OccurValues **p, int opt, const char *name)
155 {
156  if (!odr_sequence_begin(o, p, sizeof(**p), name))
157  return odr_missing(o, opt, name) && odr_ok (o);
158  return
160  &(*p)->start, ODR_CONTEXT, 1, 0, "start") &&
162  &(*p)->howMany, ODR_CONTEXT, 2, 1, "howMany") &&
163  odr_sequence_end(o);
164 }
165 
166 int z_Occurrences(ODR o, Z_Occurrences **p, int opt, const char *name)
167 {
168  static Odr_arm arm[] = {
170  (Odr_fun) odr_null, "all"},
172  (Odr_fun) odr_null, "last"},
174  (Odr_fun) z_OccurValues, "values"},
175  {-1, -1, -1, -1, (Odr_fun) 0, 0}
176  };
177  if (!odr_initmember(o, p, sizeof(**p)))
178  return odr_missing(o, opt, name);
179  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
180  return 1;
181  if (o->direction == ODR_DECODE)
182  *p = 0;
183  return odr_missing(o, opt, name);
184 }
#define Z_ETagUnit_specificTag
Definition: z-espec1.h:114
#define odr_ok(o)
Definition: odr.h:215
int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt, const char *name)
Definition: z-core.c:1603
#define odr_explicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:195
#define Z_ERequest_simpleElement
Definition: z-espec1.h:92
#define Z_ETagUnit_wildPath
Definition: z-espec1.h:116
#define Z_ERequest_compositeElement
Definition: z-espec1.h:93
int z_ElementRequestCompositeElementSpecs(ODR o, Z_ElementRequestCompositeElementSpecs **p, int opt, const char *name)
Definition: z-espec1.c:44
int z_OccurValues(ODR o, Z_OccurValues **p, int opt, const char *name)
Definition: z-espec1.c:154
#define odr_implicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:192
int z_ETagPath(ODR o, Z_ETagPath **p, int opt, const char *name)
Definition: z-espec1.c:142
int odr_sequence_begin(ODR o, void *p, int size, const char *name)
Definition: odr_seq.c:15
int z_Espec1(ODR o, Z_Espec1 **p, int opt, const char *name)
Definition: z-espec1.c:12
char * name
Definition: initopt.c:18
int z_ElementRequestCompositeElementPrimitives(ODR o, Z_ElementRequestCompositeElementPrimitives **p, int opt, const char *name)
Definition: z-espec1.c:32
int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag, const char *name)
Definition: odr_cons.c:24
int z_SimpleElement(ODR o, Z_SimpleElement **p, int opt, const char *name)
Definition: z-espec1.c:96
int odr_initmember(ODR o, void *p, int size)
Definition: odr_tag.c:44
#define Z_Occurrences_all
Definition: z-espec1.h:136
int direction
Definition: odr.h:126
#define Z_ETagUnit_wildThing
Definition: z-espec1.h:115
int odr_integer(ODR o, Odr_int **p, int opt, const char *name)
Definition: odr_int.c:19
int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, const char *name)
Definition: odr_choice.c:17
#define ODR_EXPLICIT
Definition: odr.h:60
int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num, const char *name)
Definition: odr_seq.c:134
int z_ETagUnit(ODR o, Z_ETagUnit **p, int opt, const char *name)
Definition: z-espec1.c:122
int(* Odr_fun)(ODR, char **, int, const char *)
Definition: odr.h:135
ASN.1 Module ElementSpecificationFormat-eSpec-1.
int which
Definition: odr.h:142
Definition: odr.h:137
#define Z_Occurrences_last
Definition: z-espec1.h:137
int z_Variant(ODR o, Z_Variant **p, int opt, const char *name)
Definition: z-grs.c:217
int odr_null(ODR o, Odr_null **p, int opt, const char *name)
Definition: odr_null.c:19
int odr_missing(ODR o, int opt, const char *name)
Definition: odr_util.c:82
Definition: odr.h:124
int odr_sequence_end(ODR o)
Definition: odr_seq.c:61
int opt
Definition: initopt.c:19
#define ODR_IMPLICIT
Definition: odr.h:59
int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
Definition: odr_oid.c:20
int z_ElementRequest(ODR o, Z_ElementRequest **p, int opt, const char *name)
Definition: z-espec1.c:78
int z_InternationalString(ODR o, Z_InternationalString **p, int opt, const char *name)
Definition: z-core.c:1598
int z_Occurrences(ODR o, Z_Occurrences **p, int opt, const char *name)
Definition: z-espec1.c:166
int z_ElementRequestCompositeElement(ODR o, Z_ElementRequestCompositeElement **p, int opt, const char *name)
Definition: z-espec1.c:56
#define Z_Occurrences_values
Definition: z-espec1.h:138
int odr_constructed_end(ODR o)
Definition: odr_cons.c:148
#define ODR_CONTEXT
Definition: odr.h:67
#define Z_ElementRequestCompositeElement_primitives
Definition: z-espec1.h:80
int z_SpecificTag(ODR o, Z_SpecificTag **p, int opt, const char *name)
Definition: z-espec1.c:108
#define ODR_DECODE
Definition: odr.h:95
int odr_implicit_settag(ODR o, int zclass, int tag)
Definition: odr_tag.c:32
#define Z_ElementRequestCompositeElement_specs
Definition: z-espec1.h:81