2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: d1_expout.c,v $
7 * Revision 1.17 1999-11-30 13:47:12 adam
8 * Improved installation. Moved header files to include/yaz.
10 * Revision 1.16 1999/08/27 09:40:32 adam
11 * Renamed logf function to yaz_log. Removed VC++ project files.
13 * Revision 1.15 1998/09/28 12:44:40 adam
14 * Fixed bug in f_integer.
16 * Revision 1.14 1998/06/08 14:26:41 adam
17 * Fixed bug in f_queryTypeDetails.
19 * Revision 1.13 1998/06/05 08:58:48 adam
20 * Fixed un-initialised var in f_rpnCapabilities.
22 * Revision 1.12 1998/05/18 13:07:04 adam
23 * Changed the way attribute sets are handled by the retriaval module.
24 * Extended Explain conversion / schema.
25 * Modified server and client to work with ASN.1 compiled protocol handlers.
27 * Revision 1.11 1998/04/02 08:27:37 adam
28 * Minor change in definition of Z_TargetInfo. Furhter work on Explain
29 * schema - added AttributeDetails.
31 * Revision 1.10 1998/03/31 15:13:20 adam
32 * Development towards compiled ASN.1.
34 * Revision 1.9 1998/03/05 08:07:58 adam
35 * Make data1 to EXPLAIN ignore local tags in root.
37 * Revision 1.8 1998/02/11 11:53:35 adam
38 * Changed code so that it compiles as C++.
40 * Revision 1.7 1997/12/09 16:18:16 adam
41 * Work on EXPLAIN schema. First implementation of sub-schema facility
44 * Revision 1.6 1997/11/24 11:33:56 adam
45 * Using function odr_nullval() instead of global ODR_NULLVAL when
48 * Revision 1.5 1997/11/19 10:30:06 adam
51 * Revision 1.4 1997/11/18 09:51:08 adam
52 * Removed element num_children from data1_node. Minor changes in
55 * Revision 1.3 1997/09/17 12:10:36 adam
58 * Revision 1.2 1995/12/14 16:28:30 quinn
61 * Revision 1.1 1995/12/14 11:09:51 quinn
72 #include <yaz/proto.h>
73 #include <yaz/data1.h>
84 static int is_numeric_tag (ExpHandle *eh, data1_node *c)
86 if (!c || c->which != DATA1N_tag)
88 if (!c->u.tag.element)
90 yaz_log(LOG_WARN, "Tag %s is local", c->u.tag.tag);
93 if (c->u.tag.element->tag->which != DATA1T_numeric)
95 yaz_log(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
98 if (eh->select && !c->u.tag.node_selected)
100 return c->u.tag.element->tag->value.numeric;
103 static int is_data_tag (ExpHandle *eh, data1_node *c)
105 if (!c || c->which != DATA1N_data)
107 if (eh->select && !c->u.tag.node_selected)
112 static int *f_integer(ExpHandle *eh, data1_node *c)
118 if (!is_data_tag (eh, c) || c->u.data.len > 63)
120 r = (int *)odr_malloc(eh->o, sizeof(*r));
121 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
126 static char *f_string(ExpHandle *eh, data1_node *c)
131 if (!is_data_tag (eh, c))
133 r = (char *)odr_malloc(eh->o, c->u.data.len+1);
134 memcpy(r, c->u.data.data, c->u.data.len);
135 r[c->u.data.len] = '\0';
139 static bool_t *f_bool(ExpHandle *eh, data1_node *c)
145 if (!is_data_tag (eh, c) || c->u.data.len > 63)
147 tf = (int *)odr_malloc (eh->o, sizeof(*tf));
148 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
153 static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
157 oid_value value_for_this;
160 if (!is_data_tag (eh, c) || c->u.data.len > 63)
162 sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
163 value_for_this = oid_getvalbyname(oidstr);
164 if (value_for_this == VAL_NONE)
166 Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
174 ident.oclass = oclass;
175 ident.proto = PROTO_Z3950;
176 ident.value = value_for_this;
178 oid_ent_to_oid (&ident, oid_this);
180 return odr_oiddup (eh->o, oid_this);
183 static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
189 static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c)
192 Z_HumanStringUnit *u;
195 if (!is_data_tag (eh, c))
197 r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
199 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
200 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
202 u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
203 memcpy(u->text, c->u.data.data, c->u.data.len);
204 u->text[c->u.data.len] = '\0';
208 static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
210 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
214 res->dateChanged = 0;
216 res->humanStringLanguage = 0;
219 for (c = n->child; c; c = c->next)
221 switch (is_numeric_tag (eh, c))
223 case 601: res->dateAdded = f_string(eh, c); break;
224 case 602: res->dateChanged = f_string(eh, c); break;
225 case 603: res->expiry = f_string(eh, c); break;
226 case 604: res->humanStringLanguage = f_string(eh, c); break;
232 Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
239 for (c = n->child ; c; c = c->next)
240 if (is_numeric_tag (eh, c) == 1000)
244 res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
245 for (c = n->child, i = 0 ; c; c = c->next)
246 if (is_numeric_tag (eh, c) == 1000)
247 res[i++] = f_oid (eh, c, oclass);
251 char **f_string_seq (ExpHandle *eh, data1_node *n, int *num)
258 for (c = n->child ; c; c = c->next)
260 if (is_numeric_tag (eh, c) != 1001)
266 res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
267 for (c = n->child, i = 0 ; c; c = c->next)
269 if (is_numeric_tag (eh, c) != 1001)
271 res[i++] = f_string (eh, c);
276 Z_ProximitySupport *f_proximitySupport (ExpHandle *eh, data1_node *n)
278 Z_ProximitySupport *res = (Z_ProximitySupport *)
279 odr_malloc (eh->o, sizeof(*res));
280 res->anySupport = eh->false_value;
281 res->num_unitsSupported = 0;
282 res->unitsSupported = 0;
286 Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
288 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
289 odr_malloc (eh->o, sizeof(*res));
292 res->num_operators = 0;
293 res->operators = NULL;
294 res->resultSetAsOperandSupported = eh->false_value;
295 res->restrictionOperandSupported = eh->false_value;
296 res->proximity = NULL;
298 for (c = n->child; c; c = c->next)
301 switch (is_numeric_tag(eh, c))
304 for (n = c->child; n; n = n->next)
306 if (is_numeric_tag(eh, n) != 551)
308 (res->num_operators)++;
310 if (res->num_operators)
311 res->operators = (int **)
312 odr_malloc (eh->o, res->num_operators
313 * sizeof(*res->operators));
314 for (n = c->child; n; n = n->next)
316 if (is_numeric_tag(eh, n) != 551)
318 res->operators[i++] = f_integer (eh, n);
322 res->resultSetAsOperandSupported = f_bool (eh, c);
325 res->restrictionOperandSupported = f_bool (eh, c);
328 res->proximity = f_proximitySupport (eh, c);
335 Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
337 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
338 odr_malloc(eh->o, sizeof(*res));
341 res->which = Z_QueryTypeDetails_rpn;
343 for (c = n->child; c; c = c->next)
345 switch (is_numeric_tag(eh, c))
348 res->which = Z_QueryTypeDetails_rpn;
349 res->u.rpn = f_rpnCapabilities (eh, c);
360 static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
362 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
365 res->num_queryTypesSupported = 0;
366 res->queryTypesSupported = 0;
367 res->num_diagnosticsSets = 0;
368 res->diagnosticsSets = 0;
369 res->num_attributeSetIds = 0;
370 res->attributeSetIds = 0;
371 res->num_schemas = 0;
373 res->num_recordSyntaxes = 0;
374 res->recordSyntaxes = 0;
375 res->num_resourceChallenges = 0;
376 res->resourceChallenges = 0;
377 res->restrictedAccess = 0;
379 res->num_variantSets = 0;
380 res->variantSets = 0;
381 res->num_elementSetNames = 0;
382 res->elementSetNames = 0;
383 res->num_unitSystems = 0;
384 res->unitSystems = 0;
386 for (c = n->child; c; c = c->next)
389 switch (is_numeric_tag (eh, c))
392 for (n = c->child; n; n = n->next)
394 if (is_numeric_tag(eh, n) != 518)
396 (res->num_queryTypesSupported)++;
398 if (res->num_queryTypesSupported)
399 res->queryTypesSupported =
400 (Z_QueryTypeDetails **)
401 odr_malloc (eh->o, res->num_queryTypesSupported
402 * sizeof(*res->queryTypesSupported));
403 for (n = c->child; n; n = n->next)
405 if (is_numeric_tag(eh, n) != 518)
407 res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
411 res->diagnosticsSets =
412 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
415 res->attributeSetIds =
416 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
420 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
423 res->recordSyntaxes =
424 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
427 res->resourceChallenges =
428 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
430 case 513: res->restrictedAccess = NULL; break; /* fix */
431 case 514: res->costInfo = NULL; break; /* fix */
434 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
437 res->elementSetNames =
438 f_string_seq (eh, c, &res->num_elementSetNames);
441 res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
448 static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
450 int *r= (int *)odr_malloc(eh->o, sizeof(*r));
455 if (!is_numeric_tag (eh, c))
457 if (c->u.tag.element->tag->value.numeric == 210)
458 *wp = Z_DatabaseInfo_actualNumber;
459 else if (c->u.tag.element->tag->value.numeric == 211)
460 *wp = Z_DatabaseInfo_approxNumber;
463 if (!c->child || c->child->which != DATA1N_data)
465 sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
470 static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
472 Z_ContactInfo *res = (Z_ContactInfo *)
473 odr_malloc (eh->o, sizeof(*res));
477 res->description = 0;
482 for (c = n->child; c; c = c->next)
484 switch (is_numeric_tag (eh, c))
486 case 102: res->name = f_string (eh, c); break;
487 case 113: res->description = f_humstring (eh, c); break;
488 case 127: res->address = f_humstring (eh, c); break;
489 case 128: res->email = f_string (eh, c); break;
490 case 129: res->phone = f_string (eh, c); break;
496 static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
502 for (c = n->child; c; c = c->next)
504 if (!is_numeric_tag (eh, c) != 102)
511 res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
513 res->num_databases = i;
514 res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
516 for (c = n->child; c; c = c->next)
518 if (!is_numeric_tag (eh, c) != 102)
520 res->databases[i++] = f_string (eh, c);
525 static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
527 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
528 odr_malloc (eh->o, sizeof(*res));
531 res->hostAddress = 0;
534 for (c = n->child; c; c = c->next)
536 switch (is_numeric_tag (eh, c))
538 case 121: res->hostAddress = f_string (eh, c); break;
539 case 122: res->port = f_integer (eh, c); break;
545 static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
548 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
549 odr_malloc (eh->o, sizeof(*res));
555 for (c = n->child; c; c = c->next)
557 switch (is_numeric_tag (eh, c))
559 case 124: res->type = f_string (eh, c); break;
560 case 121: res->address = f_string (eh, c); break;
566 static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
569 Z_NetworkAddress **res = NULL;
574 for (c = n->child; c; c = c->next)
576 switch (is_numeric_tag (eh, c))
586 res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
588 for (c = n->child; c; c = c->next)
590 switch (is_numeric_tag (eh, c))
593 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
594 res[i]->which = Z_NetworkAddress_iA;
595 res[i]->u.internetAddress = f_networkAddressIA(eh, c);
599 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
600 res[i]->which = Z_NetworkAddress_other;
601 res[i]->u.other = f_networkAddressOther(eh, c);
609 static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
611 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
615 res->originalCategory = 0;
616 res->description = 0;
618 for (c = n->child; c; c = c->next)
620 switch (is_numeric_tag (eh, c))
622 case 102: res->category = f_string(eh, c); break;
623 case 302: res->originalCategory = f_string(eh, c); break;
624 case 113: res->description = f_humstring(eh, c); break;
625 case 303: res->asn1Module = f_string (eh, c); break;
631 static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
633 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
637 res->num_categories = 0;
638 res->categories = NULL;
640 for (c = n->child; c; c = c->next)
644 switch (is_numeric_tag (eh, c))
646 case 600: res->commonInfo = f_commonInfo(eh, c); break;
648 for (n = c->child; n; n = n->next)
650 if (is_numeric_tag(eh, n) != 301)
652 (res->num_categories)++;
654 if (res->num_categories)
656 (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
657 * sizeof(*res->categories));
658 for (n = c->child; n; n = n->next)
660 if (is_numeric_tag(eh, n) != 301)
662 res->categories[i++] = f_categoryInfo (eh, n);
667 assert (res->num_categories && res->categories);
671 static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
673 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
680 res->namedResultSets = 0;
681 res->multipleDBsearch = 0;
682 res->maxResultSets = 0;
683 res->maxResultSize = 0;
685 res->timeoutInterval = 0;
686 res->welcomeMessage = 0;
687 res->contactInfo = 0;
688 res->description = 0;
689 res->num_nicknames = 0;
692 res->paymentAddr = 0;
694 res->num_dbCombinations = 0;
695 res->dbCombinations = 0;
696 res->num_addresses = 0;
698 res->num_languages = 0;
699 res->languages = NULL;
700 res->commonAccessInfo = 0;
702 for (c = n->child; c; c = c->next)
706 switch (is_numeric_tag (eh, c))
708 case 600: res->commonInfo = f_commonInfo(eh, c); break;
709 case 102: res->name = f_string(eh, c); break;
710 case 103: res->recentNews = f_humstring(eh, c); break;
711 case 104: res->icon = NULL; break; /* fix */
712 case 105: res->namedResultSets = f_bool(eh, c); break;
713 case 106: res->multipleDBsearch = f_bool(eh, c); break;
714 case 107: res->maxResultSets = f_integer(eh, c); break;
715 case 108: res->maxResultSize = f_integer(eh, c); break;
716 case 109: res->maxTerms = f_integer(eh, c); break;
717 case 110: res->timeoutInterval = f_intunit(eh, c); break;
718 case 111: res->welcomeMessage = f_humstring(eh, c); break;
719 case 112: res->contactInfo = f_contactInfo(eh, c); break;
720 case 113: res->description = f_humstring(eh, c); break;
722 res->num_nicknames = 0;
723 for (n = c->child; n; n = n->next)
725 if (is_numeric_tag(eh, n) != 102)
727 (res->num_nicknames)++;
729 if (res->num_nicknames)
731 (char **)odr_malloc (eh->o, res->num_nicknames
732 * sizeof(*res->nicknames));
733 for (n = c->child; n; n = n->next)
735 if (is_numeric_tag(eh, n) != 102)
737 res->nicknames[i++] = f_string (eh, n);
740 case 115: res->usageRest = f_humstring(eh, c); break;
741 case 116: res->paymentAddr = f_humstring(eh, c); break;
742 case 117: res->hours = f_humstring(eh, c); break;
744 res->num_dbCombinations = 0;
745 for (n = c->child; n; n = n->next)
747 if (!is_numeric_tag(eh, n) != 605)
749 (res->num_dbCombinations)++;
751 if (res->num_dbCombinations)
752 res->dbCombinations =
753 (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
754 * sizeof(*res->dbCombinations));
755 for (n = c->child; n; n = n->next)
757 if (!is_numeric_tag(eh, n) != 605)
759 res->dbCombinations[i++] = f_databaseList (eh, n);
764 f_networkAddresses (eh, c, &res->num_addresses);
767 res->num_languages = 0;
768 for (n = c->child; n; n = n->next)
770 if (!is_numeric_tag(eh, n) != 126)
772 (res->num_languages)++;
774 if (res->num_languages)
775 res->languages = (char **)
776 odr_malloc (eh->o, res->num_languages *
777 sizeof(*res->languages));
778 for (n = c->child; n; n = n->next)
780 if (!is_numeric_tag(eh, n) != 126)
782 res->languages[i++] = f_string (eh, n);
785 case 500: res->commonAccessInfo = f_accessInfo(eh, c); break;
788 if (!res->namedResultSets)
789 res->namedResultSets = eh->false_value;
790 if (!res->multipleDBsearch)
791 res->multipleDBsearch = eh->false_value;
795 static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
797 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
802 res->explainDatabase = 0;
803 res->num_nicknames = 0;
808 res->titleString = 0;
809 res->num_keywords = 0;
811 res->description = 0;
812 res->associatedDbs = 0;
814 res->disclaimers = 0;
816 res->u.actualNumber = 0;
817 res->defaultOrder = 0;
818 res->avRecordSize = 0;
819 res->maxRecordSize = 0;
823 res->updateInterval = 0;
825 res->proprietary = 0;
826 res->copyrightText = 0;
827 res->copyrightNotice = 0;
828 res->producerContactInfo = 0;
829 res->supplierContactInfo = 0;
830 res->submissionContactInfo = 0;
833 for (c = n->child; c; c = c->next)
837 switch (is_numeric_tag (eh, c))
839 case 600: res->commonInfo = f_commonInfo(eh, c); break;
840 case 102: res->name = f_string(eh, c); break;
841 case 226: res->explainDatabase = odr_nullval(); break;
843 res->num_nicknames = 0;
844 for (n = c->child; n; n = n->next)
846 if (!is_numeric_tag(eh, n) ||
847 n->u.tag.element->tag->value.numeric != 102)
849 (res->num_nicknames)++;
851 if (res->num_nicknames)
853 (char **)odr_malloc (eh->o, res->num_nicknames
854 * sizeof(*res->nicknames));
855 for (n = c->child; n; n = n->next)
857 if (!is_numeric_tag(eh, n) ||
858 n->u.tag.element->tag->value.numeric != 102)
860 res->nicknames[i++] = f_string (eh, n);
863 case 104: res->icon = 0; break; /* fix */
864 case 201: res->userFee = f_bool(eh, c); break;
865 case 202: res->available = f_bool(eh, c); break;
866 case 203: res->titleString = f_humstring(eh, c); break;
868 res->num_keywords = 0;
869 for (n = c->child; n; n = n->next)
871 if (!is_numeric_tag(eh, n) != 1000)
873 (res->num_keywords)++;
875 if (res->num_keywords)
877 (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
878 * sizeof(*res->keywords));
879 for (n = c->child; n; n = n->next)
881 if (!is_numeric_tag(eh, n) != 1000)
883 res->keywords[i++] = f_humstring (eh, n);
886 case 113: res->description = f_humstring(eh, c); break;
888 res->associatedDbs = f_databaseList (eh, c);
891 res->subDbs = f_databaseList (eh, c);
893 case 207: res->disclaimers = f_humstring(eh, c); break;
894 case 103: res->news = f_humstring(eh, c); break;
895 case 209: res->u.actualNumber =
896 f_recordCount(eh, c, &res->which); break;
897 case 212: res->defaultOrder = f_humstring(eh, c); break;
898 case 213: res->avRecordSize = f_integer(eh, c); break;
899 case 214: res->maxRecordSize = f_integer(eh, c); break;
900 case 215: res->hours = f_humstring(eh, c); break;
901 case 216: res->bestTime = f_humstring(eh, c); break;
902 case 217: res->lastUpdate = f_string(eh, c); break;
903 case 218: res->updateInterval = f_intunit(eh, c); break;
904 case 219: res->coverage = f_humstring(eh, c); break;
905 case 220: res->proprietary = f_bool(eh, c); break;
906 case 221: res->copyrightText = f_humstring(eh, c); break;
907 case 222: res->copyrightNotice = f_humstring(eh, c); break;
908 case 223: res->producerContactInfo = f_contactInfo(eh, c); break;
909 case 224: res->supplierContactInfo = f_contactInfo(eh, c); break;
910 case 225: res->submissionContactInfo = f_contactInfo(eh, c); break;
911 case 500: res->accessInfo = f_accessInfo(eh, c); break;
915 res->userFee = eh->false_value;
917 res->available = eh->true_value;
921 Z_StringOrNumeric *f_stringOrNumeric (ExpHandle *eh, data1_node *n)
923 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
924 odr_malloc (eh->o, sizeof(*res));
926 for (c = n->child; c; c = c->next)
928 switch (is_numeric_tag (eh, c))
931 res->which = Z_StringOrNumeric_string;
932 res->u.string = f_string (eh, c);
935 res->which = Z_StringOrNumeric_numeric;
936 res->u.numeric = f_integer (eh, c);
943 Z_AttributeDescription *f_attributeDescription (
944 ExpHandle *eh, data1_node *n)
946 Z_AttributeDescription *res = (Z_AttributeDescription *)
947 odr_malloc(eh->o, sizeof(*res));
952 res->description = 0;
953 res->attributeValue = 0;
954 res->num_equivalentAttributes = 0;
955 res->equivalentAttributes = 0;
957 for (c = n->child; c; c = c->next)
959 switch (is_numeric_tag (eh, c))
961 case 102: res->name = f_string (eh, c); break;
962 case 113: res->description = f_humstring (eh, c); break;
963 case 710: res->attributeValue = f_stringOrNumeric (eh, c); break;
964 case 752: (res->num_equivalentAttributes++); break;
967 if (res->num_equivalentAttributes)
968 res->equivalentAttributes = (Z_StringOrNumeric **)
969 odr_malloc (eh->o, sizeof(*res->equivalentAttributes) *
970 res->num_equivalentAttributes);
971 for (c = n->child; c; c = c->next)
972 if (is_numeric_tag (eh, c) == 752)
973 res->equivalentAttributes[i++] = f_stringOrNumeric (eh, c);
977 Z_AttributeType *f_attributeType (ExpHandle *eh, data1_node *n)
979 Z_AttributeType *res = (Z_AttributeType *)
980 odr_malloc(eh->o, sizeof(*res));
984 res->description = 0;
985 res->attributeType = 0;
986 res->num_attributeValues = 0;
987 res->attributeValues = 0;
989 for (c = n->child; c; c = c->next)
992 switch (is_numeric_tag (eh, c))
994 case 102: res->name = f_string (eh, c); break;
995 case 113: res->description = f_humstring (eh, c); break;
996 case 704: res->attributeType = f_integer (eh, c); break;
998 for (n = c->child; n; n = n->next)
1000 if (is_numeric_tag(eh, n) != 709)
1002 (res->num_attributeValues)++;
1004 if (res->num_attributeValues)
1005 res->attributeValues = (Z_AttributeDescription **)
1006 odr_malloc (eh->o, res->num_attributeValues
1007 * sizeof(*res->attributeValues));
1008 for (n = c->child; n; n = n->next)
1010 if (is_numeric_tag(eh, n) != 709)
1012 res->attributeValues[i++] = f_attributeDescription (eh, n);
1020 Z_AttributeSetInfo *f_attributeSetInfo (ExpHandle *eh, data1_node *n)
1022 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
1023 odr_malloc(eh->o, sizeof(*res));
1026 res->commonInfo = 0;
1027 res->attributeSet = 0;
1029 res->num_attributes = 0;
1030 res->attributes = 0;
1031 res->description = 0;
1032 for (c = n->child; c; c = c->next)
1035 switch (is_numeric_tag (eh, c))
1037 case 600: res->commonInfo = f_commonInfo (eh, c); break;
1038 case 1000: res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1039 case 102: res->name = f_string (eh, c); break;
1041 for (n = c->child; n; n = n->next)
1043 if (is_numeric_tag(eh, n) != 751)
1045 (res->num_attributes)++;
1047 if (res->num_attributes)
1048 res->attributes = (Z_AttributeType **)
1049 odr_malloc (eh->o, res->num_attributes
1050 * sizeof(*res->attributes));
1051 for (n = c->child; n; n = n->next)
1053 if (is_numeric_tag(eh, n) != 751)
1055 res->attributes[i++] = f_attributeType (eh, n);
1058 case 113: res->description = f_humstring (eh, c); break;
1064 Z_OmittedAttributeInterpretation *f_omittedAttributeInterpretation (
1065 ExpHandle *eh, data1_node *n)
1067 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1068 odr_malloc (eh->o, sizeof(*res));
1071 res->defaultValue = 0;
1072 res->defaultDescription = 0;
1073 for (c = n->child; c; c = c->next)
1075 switch (is_numeric_tag (eh, c))
1078 res->defaultValue = f_stringOrNumeric (eh, c);
1081 res->defaultDescription = f_humstring(eh, c);
1088 Z_AttributeValue *f_attributeValue (ExpHandle *eh, data1_node *n)
1090 Z_AttributeValue *res = (Z_AttributeValue *)
1091 odr_malloc (eh->o, sizeof(*res));
1095 res->description = 0;
1096 res->num_subAttributes = 0;
1097 res->subAttributes = 0;
1098 res->num_superAttributes = 0;
1099 res->superAttributes = 0;
1100 res->partialSupport = 0;
1101 for (c = n->child; c; c = c->next)
1104 switch (is_numeric_tag (eh, c))
1107 res->value = f_stringOrNumeric (eh, c); break;
1109 res->description = f_humstring (eh, c); break;
1111 for (n = c->child; n; n = n->next)
1113 if (is_numeric_tag(eh, n) != 713)
1115 (res->num_subAttributes)++;
1117 if (res->num_subAttributes)
1118 res->subAttributes =
1119 (Z_StringOrNumeric **)
1120 odr_malloc (eh->o, res->num_subAttributes
1121 * sizeof(*res->subAttributes));
1122 for (n = c->child; n; n = n->next)
1124 if (is_numeric_tag(eh, n) != 713)
1126 res->subAttributes[i++] = f_stringOrNumeric (eh, n);
1130 for (n = c->child; n; n = n->next)
1132 if (is_numeric_tag(eh, n) != 715)
1134 (res->num_superAttributes)++;
1136 if (res->num_superAttributes)
1137 res->superAttributes =
1138 (Z_StringOrNumeric **)
1139 odr_malloc (eh->o, res->num_superAttributes
1140 * sizeof(*res->superAttributes));
1141 for (n = c->child; n; n = n->next)
1143 if (is_numeric_tag(eh, n) != 715)
1145 res->superAttributes[i++] = f_stringOrNumeric (eh, n);
1149 res->partialSupport = odr_nullval ();
1156 Z_AttributeTypeDetails *f_attributeTypeDetails (ExpHandle *eh, data1_node *n)
1158 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1159 odr_malloc(eh->o, sizeof(*res));
1161 res->attributeType = 0;
1162 res->defaultIfOmitted = 0;
1163 res->num_attributeValues = 0;
1164 res->attributeValues = 0;
1165 for (c = n->child; c; c = c->next)
1168 switch (is_numeric_tag (eh, c))
1170 case 704: res->attributeType = f_integer (eh, c); break;
1172 res->defaultIfOmitted = f_omittedAttributeInterpretation (eh, c);
1175 for (n = c->child; n; n = n->next)
1177 if (is_numeric_tag(eh, n) != 709)
1179 (res->num_attributeValues)++;
1181 if (res->num_attributeValues)
1182 res->attributeValues =
1183 (Z_AttributeValue **)
1184 odr_malloc (eh->o, res->num_attributeValues
1185 * sizeof(*res->attributeValues));
1186 for (n = c->child; n; n = n->next)
1188 if (is_numeric_tag(eh, n) != 709)
1190 res->attributeValues[i++] = f_attributeValue (eh, n);
1198 Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n)
1200 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1201 odr_malloc(eh->o, sizeof(*res));
1204 res->attributeSet = 0;
1205 res->num_attributesByType = 0;
1206 res->attributesByType = 0;
1207 for (c = n->child; c; c = c->next)
1210 switch (is_numeric_tag (eh, c))
1212 case 1000: res->attributeSet = f_oid(eh, c, CLASS_ATTSET); break;
1214 for (n = c->child; n; n = n->next)
1216 if (is_numeric_tag(eh, n) != 703)
1218 (res->num_attributesByType)++;
1220 if (res->num_attributesByType)
1221 res->attributesByType =
1222 (Z_AttributeTypeDetails **)
1223 odr_malloc (eh->o, res->num_attributesByType
1224 * sizeof(*res->attributesByType));
1225 for (n = c->child; n; n = n->next)
1227 if (is_numeric_tag(eh, n) != 703)
1229 res->attributesByType[i++] = f_attributeTypeDetails (eh, n);
1237 Z_AttributeValueList *f_attributeValueList (ExpHandle *eh, data1_node *n)
1239 Z_AttributeValueList *res = (Z_AttributeValueList *)
1240 odr_malloc (eh->o, sizeof(*res));
1244 res->num_attributes = 0;
1245 res->attributes = 0;
1246 for (c = n->child; c; c = c->next)
1247 if (is_numeric_tag (eh, c) == 710)
1248 (res->num_attributes)++;
1249 if (res->num_attributes)
1251 res->attributes = (Z_StringOrNumeric **)
1252 odr_malloc (eh->o, res->num_attributes * sizeof(*res->attributes));
1254 for (c = n->child; c; c = c->next)
1255 if (is_numeric_tag(eh, c) == 710)
1256 res->attributes[i++] = f_stringOrNumeric (eh, c);
1260 Z_AttributeOccurrence *f_attributeOccurrence (ExpHandle *eh, data1_node *n)
1262 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1263 odr_malloc (eh->o, sizeof(*res));
1266 res->attributeSet = 0;
1267 res->attributeType = 0;
1268 res->mustBeSupplied = 0;
1269 res->which = Z_AttributeOcc_any_or_none;
1270 res->attributeValues.any_or_none = odr_nullval ();
1272 for (c = n->child; c; c = c->next)
1274 switch (is_numeric_tag (eh, c))
1277 res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1279 res->attributeType = f_integer (eh, c); break;
1281 res->mustBeSupplied = odr_nullval (); break;
1283 res->which = Z_AttributeOcc_any_or_none;
1284 res->attributeValues.any_or_none = odr_nullval ();
1287 res->which = Z_AttributeOcc_specific;
1288 res->attributeValues.specific = f_attributeValueList (eh, c);
1295 Z_AttributeCombination *f_attributeCombination (ExpHandle *eh, data1_node *n)
1297 Z_AttributeCombination *res = (Z_AttributeCombination *)
1298 odr_malloc (eh->o, sizeof(*res));
1302 res->num_occurrences = 0;
1303 res->occurrences = 0;
1304 for (c = n->child; c; c = c->next)
1305 if (is_numeric_tag (eh, c) == 719)
1306 (res->num_occurrences)++;
1307 if (res->num_occurrences)
1309 res->occurrences = (Z_AttributeOccurrence **)
1310 odr_malloc (eh->o, res->num_occurrences * sizeof(*res->occurrences));
1312 for (c = n->child; c; c = c->next)
1313 if (is_numeric_tag(eh, c) == 719)
1314 res->occurrences[i++] = f_attributeOccurrence (eh, c);
1315 assert (res->num_occurrences);
1319 Z_AttributeCombinations *f_attributeCombinations (ExpHandle *eh, data1_node *n)
1321 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1322 odr_malloc (eh->o, sizeof(*res));
1324 res->defaultAttributeSet = 0;
1325 res->num_legalCombinations = 0;
1326 res->legalCombinations = 0;
1328 for (c = n->child; c; c = c->next)
1331 switch (is_numeric_tag (eh, c))
1334 res->defaultAttributeSet = f_oid (eh, c, CLASS_ATTSET);
1337 for (n = c->child; n; n = n->next)
1339 if (is_numeric_tag(eh, n) != 718)
1341 (res->num_legalCombinations)++;
1343 if (res->num_legalCombinations)
1344 res->legalCombinations =
1345 (Z_AttributeCombination **)
1346 odr_malloc (eh->o, res->num_legalCombinations
1347 * sizeof(*res->legalCombinations));
1348 for (n = c->child; n; n = n->next)
1350 if (is_numeric_tag(eh, n) != 718)
1352 res->legalCombinations[i++] = f_attributeCombination (eh, n);
1357 assert (res->num_legalCombinations);
1361 Z_AttributeDetails *f_attributeDetails (ExpHandle *eh, data1_node *n)
1363 Z_AttributeDetails *res = (Z_AttributeDetails *)
1364 odr_malloc(eh->o, sizeof(*res));
1367 res->commonInfo = 0;
1368 res->databaseName = 0;
1369 res->num_attributesBySet = 0;
1370 res->attributesBySet = NULL;
1371 res->attributeCombinations = NULL;
1373 for (c = n->child; c; c = c->next)
1376 switch (is_numeric_tag (eh, c))
1378 case 600: res->commonInfo = f_commonInfo(eh, c); break;
1379 case 102: res->databaseName = f_string (eh, c); break;
1381 for (n = c->child; n; n = n->next)
1383 if (is_numeric_tag(eh, n) != 701)
1385 (res->num_attributesBySet)++;
1387 if (res->num_attributesBySet)
1388 res->attributesBySet =
1389 (Z_AttributeSetDetails **)
1390 odr_malloc (eh->o, res->num_attributesBySet
1391 * sizeof(*res->attributesBySet));
1392 for (n = c->child; n; n = n->next)
1394 if (is_numeric_tag(eh, n) != 701)
1396 res->attributesBySet[i++] = f_attributeSetDetails (eh, n);
1400 res->attributeCombinations = f_attributeCombinations (eh, c);
1407 Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
1411 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
1416 eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
1417 *eh.false_value = 0;
1418 eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
1421 assert(n->which == DATA1N_root);
1422 if (strcmp(n->u.root.type, "explain"))
1424 yaz_log(LOG_WARN, "Attempt to convert a non-Explain record");
1427 for (n = n->child; n; n = n->next)
1429 switch (is_numeric_tag (&eh, n))
1432 res->which = Z_Explain_categoryList;
1433 if (!(res->u.categoryList = f_categoryList(&eh, n)))
1437 res->which = Z_Explain_targetInfo;
1438 if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
1442 res->which = Z_Explain_databaseInfo;
1443 if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
1447 res->which = Z_Explain_attributeSetInfo;
1448 if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n)))
1452 res->which = Z_Explain_attributeDetails;
1453 if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))
1458 yaz_log(LOG_WARN, "No category in Explain record");