YAZ  5.23.1
z-grs.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-grs.h>
11 
12 int z_GenericRecord(ODR o, Z_GenericRecord **p, int opt, const char *name)
13 {
14  if (!odr_initmember(o, p, sizeof(**p)))
15  return odr_missing(o, opt, name);
16  if (odr_sequence_of(o, (Odr_fun) z_TaggedElement, &(*p)->elements,
17  &(*p)->num_elements, name))
18  return 1;
19  if (o->direction == ODR_DECODE)
20  *p = 0;
21  return odr_missing(o, opt, name);
22 }
23 
24 int z_TaggedElement(ODR o, Z_TaggedElement **p, int opt, const char *name)
25 {
26  if (!odr_sequence_begin(o, p, sizeof(**p), name))
27  return odr_missing(o, opt, name) && odr_ok (o);
28  return
30  &(*p)->tagType, ODR_CONTEXT, 1, 1, "tagType") &&
32  &(*p)->tagValue, ODR_CONTEXT, 2, 0, "tagValue") &&
34  &(*p)->tagOccurrence, ODR_CONTEXT, 3, 1, "tagOccurrence") &&
36  &(*p)->content, ODR_CONTEXT, 4, 0, "content") &&
38  &(*p)->metaData, ODR_CONTEXT, 5, 1, "metaData") &&
40  &(*p)->appliedVariant, ODR_CONTEXT, 6, 1, "appliedVariant") &&
42 }
43 
44 int z_ElementData(ODR o, Z_ElementData **p, int opt, const char *name)
45 {
46  static Odr_arm arm[] = {
47  {-1, -1, -1, Z_ElementData_octets,
48  (Odr_fun) odr_octetstring, "octets"},
49  {-1, -1, -1, Z_ElementData_numeric,
50  (Odr_fun) odr_integer, "numeric"},
51  {-1, -1, -1, Z_ElementData_date,
52  (Odr_fun) odr_generalizedtime, "date"},
53  {-1, -1, -1, Z_ElementData_ext,
54  (Odr_fun) z_External, "ext"},
55  {-1, -1, -1, Z_ElementData_string,
56  (Odr_fun) z_InternationalString, "string"},
57  {-1, -1, -1, Z_ElementData_trueOrFalse,
58  (Odr_fun) odr_bool, "trueOrFalse"},
59  {-1, -1, -1, Z_ElementData_oid,
60  (Odr_fun) odr_oid, "oid"},
62  (Odr_fun) z_IntUnit, "intUnit"},
64  (Odr_fun) odr_null, "elementNotThere"},
66  (Odr_fun) odr_null, "elementEmpty"},
68  (Odr_fun) odr_null, "noDataRequested"},
70  (Odr_fun) z_External, "diagnostic"},
72  (Odr_fun) z_GenericRecord, "subtree"},
73  {-1, -1, -1, -1, (Odr_fun) 0, 0}
74  };
75  if (!odr_initmember(o, p, sizeof(**p)))
76  return odr_missing(o, opt, name);
77  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
78  return 1;
79  if (o->direction == ODR_DECODE)
80  *p = 0;
81  return odr_missing(o, opt, name);
82 }
83 
84 int z_ElementMetaData(ODR o, Z_ElementMetaData **p, int opt, const char *name)
85 {
86  if (!odr_sequence_begin(o, p, sizeof(**p), name))
87  return odr_missing(o, opt, name) && odr_ok (o);
88  return
90  &(*p)->seriesOrder, ODR_CONTEXT, 1, 1, "seriesOrder") &&
92  &(*p)->usageRight, ODR_CONTEXT, 2, 1, "usageRight") &&
94  (odr_sequence_of(o, (Odr_fun) z_HitVector, &(*p)->hits,
95  &(*p)->num_hits, "hits") || odr_ok(o)) &&
97  &(*p)->displayName, ODR_CONTEXT, 4, 1, "displayName") &&
99  (odr_sequence_of(o, (Odr_fun) z_Variant, &(*p)->supportedVariants,
100  &(*p)->num_supportedVariants, "supportedVariants") || odr_ok(o)) &&
102  &(*p)->message, ODR_CONTEXT, 6, 1, "message") &&
104  &(*p)->elementDescriptor, ODR_CONTEXT, 7, 1, "elementDescriptor") &&
106  &(*p)->surrogateFor, ODR_CONTEXT, 8, 1, "surrogateFor") &&
108  &(*p)->surrogateElement, ODR_CONTEXT, 9, 1, "surrogateElement") &&
110  &(*p)->other, ODR_CONTEXT, 99, 1, "other") &&
111  odr_sequence_end(o);
112 }
113 
114 int z_TagPath_s(ODR o, Z_TagPath_s **p, int opt, const char *name)
115 {
116  if (!odr_sequence_begin(o, p, sizeof(**p), name))
117  return odr_missing(o, opt, name) && odr_ok (o);
118  return
120  &(*p)->tagType, ODR_CONTEXT, 1, 1, "tagType") &&
122  &(*p)->tagValue, ODR_CONTEXT, 2, 0, "tagValue") &&
124  &(*p)->tagOccurrence, ODR_CONTEXT, 3, 1, "tagOccurrence") &&
125  odr_sequence_end(o);
126 }
127 
128 int z_TagPath(ODR o, Z_TagPath **p, int opt, const char *name)
129 {
130  if (!odr_initmember(o, p, sizeof(**p)))
131  return odr_missing(o, opt, name);
132  if (odr_sequence_of(o, (Odr_fun) z_TagPath_s, &(*p)->elements,
133  &(*p)->num, name))
134  return 1;
135  if (o->direction == ODR_DECODE)
136  *p = 0;
137  return odr_missing(o, opt, name);
138 }
139 
140 int z_Order(ODR o, Z_Order **p, int opt, const char *name)
141 {
142  if (!odr_sequence_begin(o, p, sizeof(**p), name))
143  return odr_missing(o, opt, name) && odr_ok (o);
144  return
146  &(*p)->ascending, ODR_CONTEXT, 1, 0, "ascending") &&
148  &(*p)->order, ODR_CONTEXT, 2, 0, "order") &&
149  odr_sequence_end(o);
150 }
151 
152 int z_Usage(ODR o, Z_Usage **p, int opt, const char *name)
153 {
154  if (!odr_sequence_begin(o, p, sizeof(**p), name))
155  return odr_missing(o, opt, name) && odr_ok (o);
156  return
158  &(*p)->type, ODR_CONTEXT, 1, 0, "type") &&
160  &(*p)->restriction, ODR_CONTEXT, 2, 1, "restriction") &&
161  odr_sequence_end(o);
162 }
163 
164 int z_HitVector(ODR o, Z_HitVector **p, int opt, const char *name)
165 {
166  if (!odr_sequence_begin(o, p, sizeof(**p), name))
167  return odr_missing(o, opt, name) && odr_ok (o);
168  return
169  z_Term(o, &(*p)->satisfier, 1, "satisfier") &&
171  &(*p)->offsetIntoElement, ODR_CONTEXT, 1, 1, "offsetIntoElement") &&
173  &(*p)->length, ODR_CONTEXT, 2, 1, "length") &&
175  &(*p)->hitRank, ODR_CONTEXT, 3, 1, "hitRank") &&
177  &(*p)->targetToken, ODR_CONTEXT, 4, 1, "targetToken") &&
178  odr_sequence_end(o);
179 }
180 
181 int z_Triple(ODR o, Z_Triple **p, int opt, const char *name)
182 {
183  static Odr_arm arm[] = {
184  {-1, -1, -1, Z_Triple_integer,
185  (Odr_fun) odr_integer, "integer"},
186  {-1, -1, -1, Z_Triple_internationalString,
187  (Odr_fun) z_InternationalString, "internationalString"},
188  {-1, -1, -1, Z_Triple_octetString,
189  (Odr_fun) odr_octetstring, "octetString"},
190  {-1, -1, -1, Z_Triple_objectIdentifier,
191  (Odr_fun) odr_oid, "objectIdentifier"},
192  {-1, -1, -1, Z_Triple_boolean,
193  (Odr_fun) odr_bool, "boolean"},
194  {-1, -1, -1, Z_Triple_null,
195  (Odr_fun) odr_null, "null"},
197  (Odr_fun) z_Unit, "unit"},
199  (Odr_fun) z_IntUnit, "valueAndUnit"},
200  {-1, -1, -1, -1, (Odr_fun) 0, 0}
201  };
202  if (!odr_sequence_begin(o, p, sizeof(**p), name))
203  return odr_missing(o, opt, name) && odr_ok (o);
204  return
206  &(*p)->variantSetId, ODR_CONTEXT, 0, 1, "variantSetId") &&
208  &(*p)->zclass, ODR_CONTEXT, 1, 0, "zclass") &&
210  &(*p)->type, ODR_CONTEXT, 2, 0, "type") &&
211  odr_constructed_begin(o, &(*p)->value, ODR_CONTEXT, 3, "value") &&
212  odr_choice(o, arm, &(*p)->value, &(*p)->which, 0) &&
213  odr_constructed_end(o) &&
214  odr_sequence_end(o);
215 }
216 
217 int z_Variant(ODR o, Z_Variant **p, int opt, const char *name)
218 {
219  if (!odr_sequence_begin(o, p, sizeof(**p), name))
220  return odr_missing(o, opt, name) && odr_ok (o);
221  return
223  &(*p)->globalVariantSetId, ODR_CONTEXT, 1, 1, "globalVariantSetId") &&
225  odr_sequence_of(o, (Odr_fun) z_Triple, &(*p)->triples,
226  &(*p)->num_triples, "triples") &&
227  odr_sequence_end(o);
228 }
#define odr_ok(o)
Definition: odr.h:215
ASN.1 Module RecordSyntax-generic.
int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt, const char *name)
Definition: z-core.c:1603
Definition: z-grs.h:131
Definition: z-grs.h:126
#define odr_explicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:195
#define Z_Triple_boolean
Definition: z-grs.h:165
int z_ElementData(ODR o, Z_ElementData **p, int opt, const char *name)
Definition: z-grs.c:44
int z_ElementMetaData(ODR o, Z_ElementMetaData **p, int opt, const char *name)
Definition: z-grs.c:84
#define odr_implicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:192
int odr_sequence_begin(ODR o, void *p, int size, const char *name)
Definition: odr_seq.c:15
#define Z_Triple_valueAndUnit
Definition: z-grs.h:168
char * name
Definition: initopt.c:18
#define Z_Triple_null
Definition: z-grs.h:166
int z_TagPath(ODR o, Z_TagPath **p, int opt, const char *name)
Definition: z-grs.c:128
#define Z_Triple_octetString
Definition: z-grs.h:163
#define Z_ElementData_subtree
Definition: z-grs.h:96
int z_External(ODR o, Z_External **p, int opt, const char *name)
codec for BER EXTERNAL
Definition: prt-ext.c:95
int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag, const char *name)
Definition: odr_cons.c:24
int z_TagPath_s(ODR o, Z_TagPath_s **p, int opt, const char *name)
Definition: z-grs.c:114
int odr_initmember(ODR o, void *p, int size)
Definition: odr_tag.c:44
#define Z_ElementData_ext
Definition: z-grs.h:87
int direction
Definition: odr.h:126
int z_TaggedElement(ODR o, Z_TaggedElement **p, int opt, const char *name)
Definition: z-grs.c:24
#define Z_ElementData_trueOrFalse
Definition: z-grs.h:89
int odr_integer(ODR o, Odr_int **p, int opt, const char *name)
Definition: odr_int.c:19
int odr_bool(ODR o, Odr_bool **p, int opt, const char *name)
Definition: odr_bool.c:21
#define Z_ElementData_date
Definition: z-grs.h:86
#define Z_Triple_integer
Definition: z-grs.h:161
int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, const char *name)
Definition: odr_choice.c:17
#define Z_Triple_internationalString
Definition: z-grs.h:162
int z_Usage(ODR o, Z_Usage **p, int opt, const char *name)
Definition: z-grs.c:152
#define Z_Triple_unit
Definition: z-grs.h:167
#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(* Odr_fun)(ODR, char **, int, const char *)
Definition: odr.h:135
int which
Definition: odr.h:142
Definition: odr.h:137
int z_Order(ODR o, Z_Order **p, int opt, const char *name)
Definition: z-grs.c:140
int z_Variant(ODR o, Z_Variant **p, int opt, const char *name)
Definition: z-grs.c:217
#define Z_ElementData_oid
Definition: z-grs.h:90
int odr_null(ODR o, Odr_null **p, int opt, const char *name)
Definition: odr_null.c:19
int z_Triple(ODR o, Z_Triple **p, int opt, const char *name)
Definition: z-grs.c:181
int odr_missing(ODR o, int opt, const char *name)
Definition: odr_util.c:82
int z_HitVector(ODR o, Z_HitVector **p, int opt, const char *name)
Definition: z-grs.c:164
#define Z_ElementData_octets
Definition: z-grs.h:84
Definition: odr.h:124
#define Z_ElementData_noDataRequested
Definition: z-grs.h:94
int odr_sequence_end(ODR o)
Definition: odr_seq.c:61
#define Z_Triple_objectIdentifier
Definition: z-grs.h:164
int z_Unit(ODR o, Z_Unit **p, int opt, const char *name)
Definition: z-core.c:1582
#define Z_ElementData_elementEmpty
Definition: z-grs.h:93
int opt
Definition: initopt.c:19
#define Z_ElementData_numeric
Definition: z-grs.h:85
#define Z_ElementData_intUnit
Definition: z-grs.h:91
#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_InternationalString(ODR o, Z_InternationalString **p, int opt, const char *name)
Definition: z-core.c:1598
#define Z_ElementData_elementNotThere
Definition: z-grs.h:92
int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name)
Definition: odr_oct.c:19
#define Z_ElementData_string
Definition: z-grs.h:88
int z_Term(ODR o, Z_Term **p, int opt, const char *name)
Definition: z-core.c:329
#define Z_ElementData_diagnostic
Definition: z-grs.h:95
int odr_generalizedtime(ODR o, char **p, int opt, const char *name)
Definition: odr_use.c:63
int odr_constructed_end(ODR o)
Definition: odr_cons.c:148
#define ODR_CONTEXT
Definition: odr.h:67
int z_IntUnit(ODR o, Z_IntUnit **p, int opt, const char *name)
Definition: z-core.c:1570
#define ODR_DECODE
Definition: odr.h:95
int odr_implicit_settag(ODR o, int zclass, int tag)
Definition: odr_tag.c:32
int z_GenericRecord(ODR o, Z_GenericRecord **p, int opt, const char *name)
Definition: z-grs.c:12