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.16 1999-08-27 09:40:32 adam
8 * Renamed logf function to yaz_log. Removed VC++ project files.
10 * Revision 1.15 1998/09/28 12:44:40 adam
11 * Fixed bug in f_integer.
13 * Revision 1.14 1998/06/08 14:26:41 adam
14 * Fixed bug in f_queryTypeDetails.
16 * Revision 1.13 1998/06/05 08:58:48 adam
17 * Fixed un-initialised var in f_rpnCapabilities.
19 * Revision 1.12 1998/05/18 13:07:04 adam
20 * Changed the way attribute sets are handled by the retriaval module.
21 * Extended Explain conversion / schema.
22 * Modified server and client to work with ASN.1 compiled protocol handlers.
24 * Revision 1.11 1998/04/02 08:27:37 adam
25 * Minor change in definition of Z_TargetInfo. Furhter work on Explain
26 * schema - added AttributeDetails.
28 * Revision 1.10 1998/03/31 15:13:20 adam
29 * Development towards compiled ASN.1.
31 * Revision 1.9 1998/03/05 08:07:58 adam
32 * Make data1 to EXPLAIN ignore local tags in root.
34 * Revision 1.8 1998/02/11 11:53:35 adam
35 * Changed code so that it compiles as C++.
37 * Revision 1.7 1997/12/09 16:18:16 adam
38 * Work on EXPLAIN schema. First implementation of sub-schema facility
41 * Revision 1.6 1997/11/24 11:33:56 adam
42 * Using function odr_nullval() instead of global ODR_NULLVAL when
45 * Revision 1.5 1997/11/19 10:30:06 adam
48 * Revision 1.4 1997/11/18 09:51:08 adam
49 * Removed element num_children from data1_node. Minor changes in
52 * Revision 1.3 1997/09/17 12:10:36 adam
55 * Revision 1.2 1995/12/14 16:28:30 quinn
58 * Revision 1.1 1995/12/14 11:09:51 quinn
81 static int is_numeric_tag (ExpHandle *eh, data1_node *c)
83 if (!c || c->which != DATA1N_tag)
85 if (!c->u.tag.element)
87 yaz_log(LOG_WARN, "Tag %s is local", c->u.tag.tag);
90 if (c->u.tag.element->tag->which != DATA1T_numeric)
92 yaz_log(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
95 if (eh->select && !c->u.tag.node_selected)
97 return c->u.tag.element->tag->value.numeric;
100 static int is_data_tag (ExpHandle *eh, data1_node *c)
102 if (!c || c->which != DATA1N_data)
104 if (eh->select && !c->u.tag.node_selected)
109 static int *f_integer(ExpHandle *eh, data1_node *c)
115 if (!is_data_tag (eh, c) || c->u.data.len > 63)
117 r = (int *)odr_malloc(eh->o, sizeof(*r));
118 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
123 static char *f_string(ExpHandle *eh, data1_node *c)
128 if (!is_data_tag (eh, c))
130 r = (char *)odr_malloc(eh->o, c->u.data.len+1);
131 memcpy(r, c->u.data.data, c->u.data.len);
132 r[c->u.data.len] = '\0';
136 static bool_t *f_bool(ExpHandle *eh, data1_node *c)
142 if (!is_data_tag (eh, c) || c->u.data.len > 63)
144 tf = (int *)odr_malloc (eh->o, sizeof(*tf));
145 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
150 static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
154 oid_value value_for_this;
157 if (!is_data_tag (eh, c) || c->u.data.len > 63)
159 sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
160 value_for_this = oid_getvalbyname(oidstr);
161 if (value_for_this == VAL_NONE)
163 Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
171 ident.oclass = oclass;
172 ident.proto = PROTO_Z3950;
173 ident.value = value_for_this;
175 oid_ent_to_oid (&ident, oid_this);
177 return odr_oiddup (eh->o, oid_this);
180 static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
186 static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c)
189 Z_HumanStringUnit *u;
192 if (!is_data_tag (eh, c))
194 r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
196 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
197 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
199 u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
200 memcpy(u->text, c->u.data.data, c->u.data.len);
201 u->text[c->u.data.len] = '\0';
205 static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
207 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
211 res->dateChanged = 0;
213 res->humanStringLanguage = 0;
216 for (c = n->child; c; c = c->next)
218 switch (is_numeric_tag (eh, c))
220 case 601: res->dateAdded = f_string(eh, c); break;
221 case 602: res->dateChanged = f_string(eh, c); break;
222 case 603: res->expiry = f_string(eh, c); break;
223 case 604: res->humanStringLanguage = f_string(eh, c); break;
229 Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
236 for (c = n->child ; c; c = c->next)
237 if (is_numeric_tag (eh, c) == 1000)
241 res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
242 for (c = n->child, i = 0 ; c; c = c->next)
243 if (is_numeric_tag (eh, c) == 1000)
244 res[i++] = f_oid (eh, c, oclass);
248 char **f_string_seq (ExpHandle *eh, data1_node *n, int *num)
255 for (c = n->child ; c; c = c->next)
257 if (is_numeric_tag (eh, c) != 1001)
263 res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
264 for (c = n->child, i = 0 ; c; c = c->next)
266 if (is_numeric_tag (eh, c) != 1001)
268 res[i++] = f_string (eh, c);
273 Z_ProximitySupport *f_proximitySupport (ExpHandle *eh, data1_node *n)
275 Z_ProximitySupport *res = (Z_ProximitySupport *)
276 odr_malloc (eh->o, sizeof(*res));
277 res->anySupport = eh->false_value;
278 res->num_unitsSupported = 0;
279 res->unitsSupported = 0;
283 Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
285 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
286 odr_malloc (eh->o, sizeof(*res));
289 res->num_operators = 0;
290 res->operators = NULL;
291 res->resultSetAsOperandSupported = eh->false_value;
292 res->restrictionOperandSupported = eh->false_value;
293 res->proximity = NULL;
295 for (c = n->child; c; c = c->next)
298 switch (is_numeric_tag(eh, c))
301 for (n = c->child; n; n = n->next)
303 if (is_numeric_tag(eh, n) != 551)
305 (res->num_operators)++;
307 if (res->num_operators)
308 res->operators = (int **)
309 odr_malloc (eh->o, res->num_operators
310 * sizeof(*res->operators));
311 for (n = c->child; n; n = n->next)
313 if (is_numeric_tag(eh, n) != 551)
315 res->operators[i++] = f_integer (eh, n);
319 res->resultSetAsOperandSupported = f_bool (eh, c);
322 res->restrictionOperandSupported = f_bool (eh, c);
325 res->proximity = f_proximitySupport (eh, c);
332 Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
334 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
335 odr_malloc(eh->o, sizeof(*res));
338 res->which = Z_QueryTypeDetails_rpn;
340 for (c = n->child; c; c = c->next)
342 switch (is_numeric_tag(eh, c))
345 res->which = Z_QueryTypeDetails_rpn;
346 res->u.rpn = f_rpnCapabilities (eh, c);
357 static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
359 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
362 res->num_queryTypesSupported = 0;
363 res->queryTypesSupported = 0;
364 res->num_diagnosticsSets = 0;
365 res->diagnosticsSets = 0;
366 res->num_attributeSetIds = 0;
367 res->attributeSetIds = 0;
368 res->num_schemas = 0;
370 res->num_recordSyntaxes = 0;
371 res->recordSyntaxes = 0;
372 res->num_resourceChallenges = 0;
373 res->resourceChallenges = 0;
374 res->restrictedAccess = 0;
376 res->num_variantSets = 0;
377 res->variantSets = 0;
378 res->num_elementSetNames = 0;
379 res->elementSetNames = 0;
380 res->num_unitSystems = 0;
381 res->unitSystems = 0;
383 for (c = n->child; c; c = c->next)
386 switch (is_numeric_tag (eh, c))
389 for (n = c->child; n; n = n->next)
391 if (is_numeric_tag(eh, n) != 518)
393 (res->num_queryTypesSupported)++;
395 if (res->num_queryTypesSupported)
396 res->queryTypesSupported =
397 (Z_QueryTypeDetails **)
398 odr_malloc (eh->o, res->num_queryTypesSupported
399 * sizeof(*res->queryTypesSupported));
400 for (n = c->child; n; n = n->next)
402 if (is_numeric_tag(eh, n) != 518)
404 res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
408 res->diagnosticsSets =
409 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
412 res->attributeSetIds =
413 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
417 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
420 res->recordSyntaxes =
421 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
424 res->resourceChallenges =
425 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
427 case 513: res->restrictedAccess = NULL; break; /* fix */
428 case 514: res->costInfo = NULL; break; /* fix */
431 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
434 res->elementSetNames =
435 f_string_seq (eh, c, &res->num_elementSetNames);
438 res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
445 static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
447 int *r= (int *)odr_malloc(eh->o, sizeof(*r));
452 if (!is_numeric_tag (eh, c))
454 if (c->u.tag.element->tag->value.numeric == 210)
455 *wp = Z_DatabaseInfo_actualNumber;
456 else if (c->u.tag.element->tag->value.numeric == 211)
457 *wp = Z_DatabaseInfo_approxNumber;
460 if (!c->child || c->child->which != DATA1N_data)
462 sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
467 static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
469 Z_ContactInfo *res = (Z_ContactInfo *)
470 odr_malloc (eh->o, sizeof(*res));
474 res->description = 0;
479 for (c = n->child; c; c = c->next)
481 switch (is_numeric_tag (eh, c))
483 case 102: res->name = f_string (eh, c); break;
484 case 113: res->description = f_humstring (eh, c); break;
485 case 127: res->address = f_humstring (eh, c); break;
486 case 128: res->email = f_string (eh, c); break;
487 case 129: res->phone = f_string (eh, c); break;
493 static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
499 for (c = n->child; c; c = c->next)
501 if (!is_numeric_tag (eh, c) != 102)
508 res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
510 res->num_databases = i;
511 res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
513 for (c = n->child; c; c = c->next)
515 if (!is_numeric_tag (eh, c) != 102)
517 res->databases[i++] = f_string (eh, c);
522 static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
524 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
525 odr_malloc (eh->o, sizeof(*res));
528 res->hostAddress = 0;
531 for (c = n->child; c; c = c->next)
533 switch (is_numeric_tag (eh, c))
535 case 121: res->hostAddress = f_string (eh, c); break;
536 case 122: res->port = f_integer (eh, c); break;
542 static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
545 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
546 odr_malloc (eh->o, sizeof(*res));
552 for (c = n->child; c; c = c->next)
554 switch (is_numeric_tag (eh, c))
556 case 124: res->type = f_string (eh, c); break;
557 case 121: res->address = f_string (eh, c); break;
563 static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
566 Z_NetworkAddress **res = NULL;
571 for (c = n->child; c; c = c->next)
573 switch (is_numeric_tag (eh, c))
583 res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
585 for (c = n->child; c; c = c->next)
587 switch (is_numeric_tag (eh, c))
590 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
591 res[i]->which = Z_NetworkAddress_iA;
592 res[i]->u.internetAddress = f_networkAddressIA(eh, c);
596 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
597 res[i]->which = Z_NetworkAddress_other;
598 res[i]->u.other = f_networkAddressOther(eh, c);
606 static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
608 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
612 res->originalCategory = 0;
613 res->description = 0;
615 for (c = n->child; c; c = c->next)
617 switch (is_numeric_tag (eh, c))
619 case 102: res->category = f_string(eh, c); break;
620 case 302: res->originalCategory = f_string(eh, c); break;
621 case 113: res->description = f_humstring(eh, c); break;
622 case 303: res->asn1Module = f_string (eh, c); break;
628 static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
630 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
634 res->num_categories = 0;
635 res->categories = NULL;
637 for (c = n->child; c; c = c->next)
641 switch (is_numeric_tag (eh, c))
643 case 600: res->commonInfo = f_commonInfo(eh, c); break;
645 for (n = c->child; n; n = n->next)
647 if (is_numeric_tag(eh, n) != 301)
649 (res->num_categories)++;
651 if (res->num_categories)
653 (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
654 * sizeof(*res->categories));
655 for (n = c->child; n; n = n->next)
657 if (is_numeric_tag(eh, n) != 301)
659 res->categories[i++] = f_categoryInfo (eh, n);
664 assert (res->num_categories && res->categories);
668 static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
670 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
677 res->namedResultSets = 0;
678 res->multipleDBsearch = 0;
679 res->maxResultSets = 0;
680 res->maxResultSize = 0;
682 res->timeoutInterval = 0;
683 res->welcomeMessage = 0;
684 res->contactInfo = 0;
685 res->description = 0;
686 res->num_nicknames = 0;
689 res->paymentAddr = 0;
691 res->num_dbCombinations = 0;
692 res->dbCombinations = 0;
693 res->num_addresses = 0;
695 res->num_languages = 0;
696 res->languages = NULL;
697 res->commonAccessInfo = 0;
699 for (c = n->child; c; c = c->next)
703 switch (is_numeric_tag (eh, c))
705 case 600: res->commonInfo = f_commonInfo(eh, c); break;
706 case 102: res->name = f_string(eh, c); break;
707 case 103: res->recentNews = f_humstring(eh, c); break;
708 case 104: res->icon = NULL; break; /* fix */
709 case 105: res->namedResultSets = f_bool(eh, c); break;
710 case 106: res->multipleDBsearch = f_bool(eh, c); break;
711 case 107: res->maxResultSets = f_integer(eh, c); break;
712 case 108: res->maxResultSize = f_integer(eh, c); break;
713 case 109: res->maxTerms = f_integer(eh, c); break;
714 case 110: res->timeoutInterval = f_intunit(eh, c); break;
715 case 111: res->welcomeMessage = f_humstring(eh, c); break;
716 case 112: res->contactInfo = f_contactInfo(eh, c); break;
717 case 113: res->description = f_humstring(eh, c); break;
719 res->num_nicknames = 0;
720 for (n = c->child; n; n = n->next)
722 if (is_numeric_tag(eh, n) != 102)
724 (res->num_nicknames)++;
726 if (res->num_nicknames)
728 (char **)odr_malloc (eh->o, res->num_nicknames
729 * sizeof(*res->nicknames));
730 for (n = c->child; n; n = n->next)
732 if (is_numeric_tag(eh, n) != 102)
734 res->nicknames[i++] = f_string (eh, n);
737 case 115: res->usageRest = f_humstring(eh, c); break;
738 case 116: res->paymentAddr = f_humstring(eh, c); break;
739 case 117: res->hours = f_humstring(eh, c); break;
741 res->num_dbCombinations = 0;
742 for (n = c->child; n; n = n->next)
744 if (!is_numeric_tag(eh, n) != 605)
746 (res->num_dbCombinations)++;
748 if (res->num_dbCombinations)
749 res->dbCombinations =
750 (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
751 * sizeof(*res->dbCombinations));
752 for (n = c->child; n; n = n->next)
754 if (!is_numeric_tag(eh, n) != 605)
756 res->dbCombinations[i++] = f_databaseList (eh, n);
761 f_networkAddresses (eh, c, &res->num_addresses);
764 res->num_languages = 0;
765 for (n = c->child; n; n = n->next)
767 if (!is_numeric_tag(eh, n) != 126)
769 (res->num_languages)++;
771 if (res->num_languages)
772 res->languages = (char **)
773 odr_malloc (eh->o, res->num_languages *
774 sizeof(*res->languages));
775 for (n = c->child; n; n = n->next)
777 if (!is_numeric_tag(eh, n) != 126)
779 res->languages[i++] = f_string (eh, n);
782 case 500: res->commonAccessInfo = f_accessInfo(eh, c); break;
785 if (!res->namedResultSets)
786 res->namedResultSets = eh->false_value;
787 if (!res->multipleDBsearch)
788 res->multipleDBsearch = eh->false_value;
792 static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
794 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
799 res->explainDatabase = 0;
800 res->num_nicknames = 0;
805 res->titleString = 0;
806 res->num_keywords = 0;
808 res->description = 0;
809 res->associatedDbs = 0;
811 res->disclaimers = 0;
813 res->u.actualNumber = 0;
814 res->defaultOrder = 0;
815 res->avRecordSize = 0;
816 res->maxRecordSize = 0;
820 res->updateInterval = 0;
822 res->proprietary = 0;
823 res->copyrightText = 0;
824 res->copyrightNotice = 0;
825 res->producerContactInfo = 0;
826 res->supplierContactInfo = 0;
827 res->submissionContactInfo = 0;
830 for (c = n->child; c; c = c->next)
834 switch (is_numeric_tag (eh, c))
836 case 600: res->commonInfo = f_commonInfo(eh, c); break;
837 case 102: res->name = f_string(eh, c); break;
838 case 226: res->explainDatabase = odr_nullval(); break;
840 res->num_nicknames = 0;
841 for (n = c->child; n; n = n->next)
843 if (!is_numeric_tag(eh, n) ||
844 n->u.tag.element->tag->value.numeric != 102)
846 (res->num_nicknames)++;
848 if (res->num_nicknames)
850 (char **)odr_malloc (eh->o, res->num_nicknames
851 * sizeof(*res->nicknames));
852 for (n = c->child; n; n = n->next)
854 if (!is_numeric_tag(eh, n) ||
855 n->u.tag.element->tag->value.numeric != 102)
857 res->nicknames[i++] = f_string (eh, n);
860 case 104: res->icon = 0; break; /* fix */
861 case 201: res->userFee = f_bool(eh, c); break;
862 case 202: res->available = f_bool(eh, c); break;
863 case 203: res->titleString = f_humstring(eh, c); break;
865 res->num_keywords = 0;
866 for (n = c->child; n; n = n->next)
868 if (!is_numeric_tag(eh, n) != 1000)
870 (res->num_keywords)++;
872 if (res->num_keywords)
874 (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
875 * sizeof(*res->keywords));
876 for (n = c->child; n; n = n->next)
878 if (!is_numeric_tag(eh, n) != 1000)
880 res->keywords[i++] = f_humstring (eh, n);
883 case 113: res->description = f_humstring(eh, c); break;
885 res->associatedDbs = f_databaseList (eh, c);
888 res->subDbs = f_databaseList (eh, c);
890 case 207: res->disclaimers = f_humstring(eh, c); break;
891 case 103: res->news = f_humstring(eh, c); break;
892 case 209: res->u.actualNumber =
893 f_recordCount(eh, c, &res->which); break;
894 case 212: res->defaultOrder = f_humstring(eh, c); break;
895 case 213: res->avRecordSize = f_integer(eh, c); break;
896 case 214: res->maxRecordSize = f_integer(eh, c); break;
897 case 215: res->hours = f_humstring(eh, c); break;
898 case 216: res->bestTime = f_humstring(eh, c); break;
899 case 217: res->lastUpdate = f_string(eh, c); break;
900 case 218: res->updateInterval = f_intunit(eh, c); break;
901 case 219: res->coverage = f_humstring(eh, c); break;
902 case 220: res->proprietary = f_bool(eh, c); break;
903 case 221: res->copyrightText = f_humstring(eh, c); break;
904 case 222: res->copyrightNotice = f_humstring(eh, c); break;
905 case 223: res->producerContactInfo = f_contactInfo(eh, c); break;
906 case 224: res->supplierContactInfo = f_contactInfo(eh, c); break;
907 case 225: res->submissionContactInfo = f_contactInfo(eh, c); break;
908 case 500: res->accessInfo = f_accessInfo(eh, c); break;
912 res->userFee = eh->false_value;
914 res->available = eh->true_value;
918 Z_StringOrNumeric *f_stringOrNumeric (ExpHandle *eh, data1_node *n)
920 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
921 odr_malloc (eh->o, sizeof(*res));
923 for (c = n->child; c; c = c->next)
925 switch (is_numeric_tag (eh, c))
928 res->which = Z_StringOrNumeric_string;
929 res->u.string = f_string (eh, c);
932 res->which = Z_StringOrNumeric_numeric;
933 res->u.numeric = f_integer (eh, c);
940 Z_AttributeDescription *f_attributeDescription (
941 ExpHandle *eh, data1_node *n)
943 Z_AttributeDescription *res = (Z_AttributeDescription *)
944 odr_malloc(eh->o, sizeof(*res));
949 res->description = 0;
950 res->attributeValue = 0;
951 res->num_equivalentAttributes = 0;
952 res->equivalentAttributes = 0;
954 for (c = n->child; c; c = c->next)
956 switch (is_numeric_tag (eh, c))
958 case 102: res->name = f_string (eh, c); break;
959 case 113: res->description = f_humstring (eh, c); break;
960 case 710: res->attributeValue = f_stringOrNumeric (eh, c); break;
961 case 752: (res->num_equivalentAttributes++); break;
964 if (res->num_equivalentAttributes)
965 res->equivalentAttributes = (Z_StringOrNumeric **)
966 odr_malloc (eh->o, sizeof(*res->equivalentAttributes) *
967 res->num_equivalentAttributes);
968 for (c = n->child; c; c = c->next)
969 if (is_numeric_tag (eh, c) == 752)
970 res->equivalentAttributes[i++] = f_stringOrNumeric (eh, c);
974 Z_AttributeType *f_attributeType (ExpHandle *eh, data1_node *n)
976 Z_AttributeType *res = (Z_AttributeType *)
977 odr_malloc(eh->o, sizeof(*res));
981 res->description = 0;
982 res->attributeType = 0;
983 res->num_attributeValues = 0;
984 res->attributeValues = 0;
986 for (c = n->child; c; c = c->next)
989 switch (is_numeric_tag (eh, c))
991 case 102: res->name = f_string (eh, c); break;
992 case 113: res->description = f_humstring (eh, c); break;
993 case 704: res->attributeType = f_integer (eh, c); break;
995 for (n = c->child; n; n = n->next)
997 if (is_numeric_tag(eh, n) != 709)
999 (res->num_attributeValues)++;
1001 if (res->num_attributeValues)
1002 res->attributeValues = (Z_AttributeDescription **)
1003 odr_malloc (eh->o, res->num_attributeValues
1004 * sizeof(*res->attributeValues));
1005 for (n = c->child; n; n = n->next)
1007 if (is_numeric_tag(eh, n) != 709)
1009 res->attributeValues[i++] = f_attributeDescription (eh, n);
1017 Z_AttributeSetInfo *f_attributeSetInfo (ExpHandle *eh, data1_node *n)
1019 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
1020 odr_malloc(eh->o, sizeof(*res));
1023 res->commonInfo = 0;
1024 res->attributeSet = 0;
1026 res->num_attributes = 0;
1027 res->attributes = 0;
1028 res->description = 0;
1029 for (c = n->child; c; c = c->next)
1032 switch (is_numeric_tag (eh, c))
1034 case 600: res->commonInfo = f_commonInfo (eh, c); break;
1035 case 1000: res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1036 case 102: res->name = f_string (eh, c); break;
1038 for (n = c->child; n; n = n->next)
1040 if (is_numeric_tag(eh, n) != 751)
1042 (res->num_attributes)++;
1044 if (res->num_attributes)
1045 res->attributes = (Z_AttributeType **)
1046 odr_malloc (eh->o, res->num_attributes
1047 * sizeof(*res->attributes));
1048 for (n = c->child; n; n = n->next)
1050 if (is_numeric_tag(eh, n) != 751)
1052 res->attributes[i++] = f_attributeType (eh, n);
1055 case 113: res->description = f_humstring (eh, c); break;
1061 Z_OmittedAttributeInterpretation *f_omittedAttributeInterpretation (
1062 ExpHandle *eh, data1_node *n)
1064 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1065 odr_malloc (eh->o, sizeof(*res));
1068 res->defaultValue = 0;
1069 res->defaultDescription = 0;
1070 for (c = n->child; c; c = c->next)
1072 switch (is_numeric_tag (eh, c))
1075 res->defaultValue = f_stringOrNumeric (eh, c);
1078 res->defaultDescription = f_humstring(eh, c);
1085 Z_AttributeValue *f_attributeValue (ExpHandle *eh, data1_node *n)
1087 Z_AttributeValue *res = (Z_AttributeValue *)
1088 odr_malloc (eh->o, sizeof(*res));
1092 res->description = 0;
1093 res->num_subAttributes = 0;
1094 res->subAttributes = 0;
1095 res->num_superAttributes = 0;
1096 res->superAttributes = 0;
1097 res->partialSupport = 0;
1098 for (c = n->child; c; c = c->next)
1101 switch (is_numeric_tag (eh, c))
1104 res->value = f_stringOrNumeric (eh, c); break;
1106 res->description = f_humstring (eh, c); break;
1108 for (n = c->child; n; n = n->next)
1110 if (is_numeric_tag(eh, n) != 713)
1112 (res->num_subAttributes)++;
1114 if (res->num_subAttributes)
1115 res->subAttributes =
1116 (Z_StringOrNumeric **)
1117 odr_malloc (eh->o, res->num_subAttributes
1118 * sizeof(*res->subAttributes));
1119 for (n = c->child; n; n = n->next)
1121 if (is_numeric_tag(eh, n) != 713)
1123 res->subAttributes[i++] = f_stringOrNumeric (eh, n);
1127 for (n = c->child; n; n = n->next)
1129 if (is_numeric_tag(eh, n) != 715)
1131 (res->num_superAttributes)++;
1133 if (res->num_superAttributes)
1134 res->superAttributes =
1135 (Z_StringOrNumeric **)
1136 odr_malloc (eh->o, res->num_superAttributes
1137 * sizeof(*res->superAttributes));
1138 for (n = c->child; n; n = n->next)
1140 if (is_numeric_tag(eh, n) != 715)
1142 res->superAttributes[i++] = f_stringOrNumeric (eh, n);
1146 res->partialSupport = odr_nullval ();
1153 Z_AttributeTypeDetails *f_attributeTypeDetails (ExpHandle *eh, data1_node *n)
1155 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1156 odr_malloc(eh->o, sizeof(*res));
1158 res->attributeType = 0;
1159 res->defaultIfOmitted = 0;
1160 res->num_attributeValues = 0;
1161 res->attributeValues = 0;
1162 for (c = n->child; c; c = c->next)
1165 switch (is_numeric_tag (eh, c))
1167 case 704: res->attributeType = f_integer (eh, c); break;
1169 res->defaultIfOmitted = f_omittedAttributeInterpretation (eh, c);
1172 for (n = c->child; n; n = n->next)
1174 if (is_numeric_tag(eh, n) != 709)
1176 (res->num_attributeValues)++;
1178 if (res->num_attributeValues)
1179 res->attributeValues =
1180 (Z_AttributeValue **)
1181 odr_malloc (eh->o, res->num_attributeValues
1182 * sizeof(*res->attributeValues));
1183 for (n = c->child; n; n = n->next)
1185 if (is_numeric_tag(eh, n) != 709)
1187 res->attributeValues[i++] = f_attributeValue (eh, n);
1195 Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n)
1197 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1198 odr_malloc(eh->o, sizeof(*res));
1201 res->attributeSet = 0;
1202 res->num_attributesByType = 0;
1203 res->attributesByType = 0;
1204 for (c = n->child; c; c = c->next)
1207 switch (is_numeric_tag (eh, c))
1209 case 1000: res->attributeSet = f_oid(eh, c, CLASS_ATTSET); break;
1211 for (n = c->child; n; n = n->next)
1213 if (is_numeric_tag(eh, n) != 703)
1215 (res->num_attributesByType)++;
1217 if (res->num_attributesByType)
1218 res->attributesByType =
1219 (Z_AttributeTypeDetails **)
1220 odr_malloc (eh->o, res->num_attributesByType
1221 * sizeof(*res->attributesByType));
1222 for (n = c->child; n; n = n->next)
1224 if (is_numeric_tag(eh, n) != 703)
1226 res->attributesByType[i++] = f_attributeTypeDetails (eh, n);
1234 Z_AttributeValueList *f_attributeValueList (ExpHandle *eh, data1_node *n)
1236 Z_AttributeValueList *res = (Z_AttributeValueList *)
1237 odr_malloc (eh->o, sizeof(*res));
1241 res->num_attributes = 0;
1242 res->attributes = 0;
1243 for (c = n->child; c; c = c->next)
1244 if (is_numeric_tag (eh, c) == 710)
1245 (res->num_attributes)++;
1246 if (res->num_attributes)
1248 res->attributes = (Z_StringOrNumeric **)
1249 odr_malloc (eh->o, res->num_attributes * sizeof(*res->attributes));
1251 for (c = n->child; c; c = c->next)
1252 if (is_numeric_tag(eh, c) == 710)
1253 res->attributes[i++] = f_stringOrNumeric (eh, c);
1257 Z_AttributeOccurrence *f_attributeOccurrence (ExpHandle *eh, data1_node *n)
1259 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1260 odr_malloc (eh->o, sizeof(*res));
1263 res->attributeSet = 0;
1264 res->attributeType = 0;
1265 res->mustBeSupplied = 0;
1266 res->which = Z_AttributeOcc_any_or_none;
1267 res->attributeValues.any_or_none = odr_nullval ();
1269 for (c = n->child; c; c = c->next)
1271 switch (is_numeric_tag (eh, c))
1274 res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1276 res->attributeType = f_integer (eh, c); break;
1278 res->mustBeSupplied = odr_nullval (); break;
1280 res->which = Z_AttributeOcc_any_or_none;
1281 res->attributeValues.any_or_none = odr_nullval ();
1284 res->which = Z_AttributeOcc_specific;
1285 res->attributeValues.specific = f_attributeValueList (eh, c);
1292 Z_AttributeCombination *f_attributeCombination (ExpHandle *eh, data1_node *n)
1294 Z_AttributeCombination *res = (Z_AttributeCombination *)
1295 odr_malloc (eh->o, sizeof(*res));
1299 res->num_occurrences = 0;
1300 res->occurrences = 0;
1301 for (c = n->child; c; c = c->next)
1302 if (is_numeric_tag (eh, c) == 719)
1303 (res->num_occurrences)++;
1304 if (res->num_occurrences)
1306 res->occurrences = (Z_AttributeOccurrence **)
1307 odr_malloc (eh->o, res->num_occurrences * sizeof(*res->occurrences));
1309 for (c = n->child; c; c = c->next)
1310 if (is_numeric_tag(eh, c) == 719)
1311 res->occurrences[i++] = f_attributeOccurrence (eh, c);
1312 assert (res->num_occurrences);
1316 Z_AttributeCombinations *f_attributeCombinations (ExpHandle *eh, data1_node *n)
1318 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1319 odr_malloc (eh->o, sizeof(*res));
1321 res->defaultAttributeSet = 0;
1322 res->num_legalCombinations = 0;
1323 res->legalCombinations = 0;
1325 for (c = n->child; c; c = c->next)
1328 switch (is_numeric_tag (eh, c))
1331 res->defaultAttributeSet = f_oid (eh, c, CLASS_ATTSET);
1334 for (n = c->child; n; n = n->next)
1336 if (is_numeric_tag(eh, n) != 718)
1338 (res->num_legalCombinations)++;
1340 if (res->num_legalCombinations)
1341 res->legalCombinations =
1342 (Z_AttributeCombination **)
1343 odr_malloc (eh->o, res->num_legalCombinations
1344 * sizeof(*res->legalCombinations));
1345 for (n = c->child; n; n = n->next)
1347 if (is_numeric_tag(eh, n) != 718)
1349 res->legalCombinations[i++] = f_attributeCombination (eh, n);
1354 assert (res->num_legalCombinations);
1358 Z_AttributeDetails *f_attributeDetails (ExpHandle *eh, data1_node *n)
1360 Z_AttributeDetails *res = (Z_AttributeDetails *)
1361 odr_malloc(eh->o, sizeof(*res));
1364 res->commonInfo = 0;
1365 res->databaseName = 0;
1366 res->num_attributesBySet = 0;
1367 res->attributesBySet = NULL;
1368 res->attributeCombinations = NULL;
1370 for (c = n->child; c; c = c->next)
1373 switch (is_numeric_tag (eh, c))
1375 case 600: res->commonInfo = f_commonInfo(eh, c); break;
1376 case 102: res->databaseName = f_string (eh, c); break;
1378 for (n = c->child; n; n = n->next)
1380 if (is_numeric_tag(eh, n) != 701)
1382 (res->num_attributesBySet)++;
1384 if (res->num_attributesBySet)
1385 res->attributesBySet =
1386 (Z_AttributeSetDetails **)
1387 odr_malloc (eh->o, res->num_attributesBySet
1388 * sizeof(*res->attributesBySet));
1389 for (n = c->child; n; n = n->next)
1391 if (is_numeric_tag(eh, n) != 701)
1393 res->attributesBySet[i++] = f_attributeSetDetails (eh, n);
1397 res->attributeCombinations = f_attributeCombinations (eh, c);
1404 Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
1408 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
1413 eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
1414 *eh.false_value = 0;
1415 eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
1418 assert(n->which == DATA1N_root);
1419 if (strcmp(n->u.root.type, "explain"))
1421 yaz_log(LOG_WARN, "Attempt to convert a non-Explain record");
1424 for (n = n->child; n; n = n->next)
1426 switch (is_numeric_tag (&eh, n))
1429 res->which = Z_Explain_categoryList;
1430 if (!(res->u.categoryList = f_categoryList(&eh, n)))
1434 res->which = Z_Explain_targetInfo;
1435 if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
1439 res->which = Z_Explain_databaseInfo;
1440 if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
1444 res->which = Z_Explain_attributeSetInfo;
1445 if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n)))
1449 res->which = Z_Explain_attributeDetails;
1450 if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))
1455 yaz_log(LOG_WARN, "No category in Explain record");