28 #include <yaz/proto.h>
32 #define D1_VARIANTARRAY 20
35 int select, ODR o,
int *len,
40 Z_ElementMetaData *r = (Z_ElementMetaData *)odr_malloc(o,
sizeof(*r));
47 r->num_supportedVariants = 0;
48 r->supportedVariants = 0;
50 r->elementDescriptor = 0;
52 r->surrogateElement = 0;
66 Z_Variant *v = (Z_Variant *)odr_malloc(o,
sizeof(*v));
69 v->globalVariantSetId = 0;
71 v->triples = (Z_Triple **)odr_malloc(o,
sizeof(Z_Triple*) * num);
77 for (p = n, num--; p && num >= 0; p = p->
parent, num--)
82 t = v->triples[num] = (Z_Triple *)odr_malloc(o,
sizeof(*t));
84 t->zclass = odr_intdup(o, p->
u.
variant.type->zclass->zclass);
85 t->type = odr_intdup(o, p->
u.
variant.type->type);
90 t->which = Z_Triple_internationalString;
91 t->value.internationalString =
95 yaz_log(YLOG_WARN,
"Unable to handle value for variant %s",
114 if (!m->supportedVariants)
115 m->supportedVariants = (Z_Variant **)odr_malloc(o,
sizeof(Z_Variant*) *
119 yaz_log(YLOG_WARN,
"Too many variants (D1_VARIANTARRAY==%d)",
124 if (!(m->supportedVariants[m->num_supportedVariants++] =
148 *len = n->
u.
data.len;
150 for (i = 0; i<*len; i++)
157 return n->
u.
data.data + i;
174 int select,
int leaf,
178 Z_ElementData *res = (Z_ElementData *)odr_malloc(o,
sizeof(*res));
182 res->which = Z_ElementData_elementNotThere;
183 res->u.elementNotThere = odr_nullval();
188 int toget = n->
u.
data.len;
192 switch (n->
u.
data.what)
195 res->which = Z_ElementData_numeric;
196 res->u.numeric = odr_intdup(o, atoi_n(cp, toget));
201 res->which = Z_ElementData_string;
202 res->u.string = (
char *)odr_malloc(o, toget+1);
204 memcpy(res->u.string, cp, toget);
205 res->u.string[toget] =
'\0';
209 res->which = Z_ElementData_oid;
212 memcpy (str, cp, toget);
214 res->u.oid = odr_getoidbystr(o, str);
215 *len += oid_oidlen(res->u.oid) *
sizeof(int);
218 yaz_log(YLOG_WARN,
"Can't handle datatype.");
224 res->which = Z_ElementData_subtree;
237 int i = n->
u.
data.len;
253 Z_TaggedElement *res = (Z_TaggedElement *)odr_malloc(o,
sizeof(*res));
260 if (n->
u.
tag.element)
261 tag = n->
u.
tag.element->tag;
294 yaz_log(YLOG_WARN,
"Bad data.");
299 res->tagValue = (Z_StringOrNumeric *)odr_malloc(o,
sizeof(Z_StringOrNumeric));
302 res->tagValue->which = Z_StringOrNumeric_numeric;
303 res->tagValue->u.numeric = odr_intdup(o, tag->
value.
numeric);
310 tagstr = n->
u.
tag.tag;
315 res->tagValue->which = Z_StringOrNumeric_string;
316 res->tagValue->u.string = odr_strdup(o, tagstr);
318 res->tagOccurrence = 0;
319 res->appliedVariant = 0;
340 res->content = (Z_ElementData *)odr_malloc(o,
sizeof(*res->content));
341 res->content->which = Z_ElementData_noDataRequested;
342 res->content->u.noDataRequested = odr_nullval();
345 o, len, wellknown_tag)))
352 int select, ODR o,
int *len,
355 Z_GenericRecord *res = (Z_GenericRecord *)odr_malloc(o,
sizeof(*res));
357 int num_children = 0;
362 res->elements = (Z_TaggedElement **)
363 odr_malloc(o,
sizeof(Z_TaggedElement *) * num_children);
364 res->num_elements = 0;
369 if ((res->elements[res->num_elements] =
377 int select, ODR o,
int *len)
385 if (n->
root->u.root.absyn &&
390 yaz_log(YLOG_WARN,
"Unable to locate tag for 'wellKnown'");
391 wellknown_tag = odr_malloc(o,
sizeof(*wellknown_tag));
394 wellknown_tag->
next = 0;
395 wellknown_tag->
tagset = odr_malloc(o,
sizeof(*wellknown_tag->
tagset));
static char * get_data(data1_node *n, int *len)
static int traverse_triples(data1_node *n, int level, Z_ElementMetaData *m, ODR o)
static int is_empty_data(data1_node *n)
static Z_ElementData * nodetoelementdata(data1_handle dh, data1_node *n, int select, int leaf, ODR o, int *len, data1_tag *wellknown_tag)
static Z_TaggedElement * nodetotaggedelement(data1_handle dh, data1_node *n, int select, ODR o, int *len, data1_tag *wellknown_tag)
static Z_Variant * make_variant(data1_node *n, int num, ODR o)
static Z_GenericRecord * data1_nodetogr_r(data1_handle dh, data1_node *n, int select, ODR o, int *len, data1_tag *wellknown_tag)
Z_GenericRecord * data1_nodetogr(data1_handle dh, data1_node *n, int select, ODR o, int *len)
static Z_ElementMetaData * get_ElementMetaData(ODR o)
data1_tag * data1_gettagbyname(data1_handle dh, data1_tagset *s, const char *name)
data1_node * data1_get_root_tag(data1_handle dh, data1_node *n)
struct data1_node::@2::@3 root
struct data1_node * parent
struct data1_node * child
struct data1_node::@2::@6 variant
struct data1_tagset * tagset
union data1_tag::@1 value