2 * Copyright (c) 1995-1998, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: d1_expout.c,v $
7 * Revision 1.14 1998-06-08 14:26:41 adam
8 * Fixed bug in f_queryTypeDetails.
10 * Revision 1.13 1998/06/05 08:58:48 adam
11 * Fixed un-initialised var in f_rpnCapabilities.
13 * Revision 1.12 1998/05/18 13:07:04 adam
14 * Changed the way attribute sets are handled by the retriaval module.
15 * Extended Explain conversion / schema.
16 * Modified server and client to work with ASN.1 compiled protocol handlers.
18 * Revision 1.11 1998/04/02 08:27:37 adam
19 * Minor change in definition of Z_TargetInfo. Furhter work on Explain
20 * schema - added AttributeDetails.
22 * Revision 1.10 1998/03/31 15:13:20 adam
23 * Development towards compiled ASN.1.
25 * Revision 1.9 1998/03/05 08:07:58 adam
26 * Make data1 to EXPLAIN ignore local tags in root.
28 * Revision 1.8 1998/02/11 11:53:35 adam
29 * Changed code so that it compiles as C++.
31 * Revision 1.7 1997/12/09 16:18:16 adam
32 * Work on EXPLAIN schema. First implementation of sub-schema facility
35 * Revision 1.6 1997/11/24 11:33:56 adam
36 * Using function odr_nullval() instead of global ODR_NULLVAL when
39 * Revision 1.5 1997/11/19 10:30:06 adam
42 * Revision 1.4 1997/11/18 09:51:08 adam
43 * Removed element num_children from data1_node. Minor changes in
46 * Revision 1.3 1997/09/17 12:10:36 adam
49 * Revision 1.2 1995/12/14 16:28:30 quinn
52 * Revision 1.1 1995/12/14 11:09:51 quinn
75 static int is_numeric_tag (ExpHandle *eh, data1_node *c)
77 if (!c || c->which != DATA1N_tag)
79 if (!c->u.tag.element)
81 logf(LOG_WARN, "Tag %s is local", c->u.tag.tag);
84 if (c->u.tag.element->tag->which != DATA1T_numeric)
86 logf(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
89 if (eh->select && !c->u.tag.node_selected)
91 return c->u.tag.element->tag->value.numeric;
94 static int is_data_tag (ExpHandle *eh, data1_node *c)
96 if (!c || c->which != DATA1N_data)
98 if (eh->select && !c->u.tag.node_selected)
103 static int *f_integer(ExpHandle *eh, data1_node *c)
109 if (!is_data_tag (eh, c) || c->u.data.len > 63)
111 r = (int *)odr_malloc(eh->o, sizeof(*r));
112 sprintf(intbuf, "%.*s", 63, c->u.data.data);
117 static char *f_string(ExpHandle *eh, data1_node *c)
122 if (!is_data_tag (eh, c))
124 r = (char *)odr_malloc(eh->o, c->u.data.len+1);
125 memcpy(r, c->u.data.data, c->u.data.len);
126 r[c->u.data.len] = '\0';
130 static bool_t *f_bool(ExpHandle *eh, data1_node *c)
136 if (!is_data_tag (eh, c) || c->u.data.len > 63)
138 tf = (int *)odr_malloc (eh->o, sizeof(*tf));
139 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
144 static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
148 oid_value value_for_this;
151 if (!is_data_tag (eh, c) || c->u.data.len > 63)
153 sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
154 value_for_this = oid_getvalbyname(oidstr);
155 if (value_for_this == VAL_NONE)
157 Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
165 ident.oclass = oclass;
166 ident.proto = PROTO_Z3950;
167 ident.value = value_for_this;
169 oid_ent_to_oid (&ident, oid_this);
171 return odr_oiddup (eh->o, oid_this);
174 static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
180 static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c)
183 Z_HumanStringUnit *u;
186 if (!is_data_tag (eh, c))
188 r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
190 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
191 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
193 u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
194 memcpy(u->text, c->u.data.data, c->u.data.len);
195 u->text[c->u.data.len] = '\0';
199 static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
201 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
205 res->dateChanged = 0;
207 res->humanStringLanguage = 0;
210 for (c = n->child; c; c = c->next)
212 switch (is_numeric_tag (eh, c))
214 case 601: res->dateAdded = f_string(eh, c); break;
215 case 602: res->dateChanged = f_string(eh, c); break;
216 case 603: res->expiry = f_string(eh, c); break;
217 case 604: res->humanStringLanguage = f_string(eh, c); break;
223 Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
230 for (c = n->child ; c; c = c->next)
231 if (is_numeric_tag (eh, c) == 1000)
235 res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
236 for (c = n->child, i = 0 ; c; c = c->next)
237 if (is_numeric_tag (eh, c) == 1000)
238 res[i++] = f_oid (eh, c, oclass);
242 char **f_string_seq (ExpHandle *eh, data1_node *n, int *num)
249 for (c = n->child ; c; c = c->next)
251 if (is_numeric_tag (eh, c) != 1001)
257 res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
258 for (c = n->child, i = 0 ; c; c = c->next)
260 if (is_numeric_tag (eh, c) != 1001)
262 res[i++] = f_string (eh, c);
267 Z_ProximitySupport *f_proximitySupport (ExpHandle *eh, data1_node *n)
269 Z_ProximitySupport *res = (Z_ProximitySupport *)
270 odr_malloc (eh->o, sizeof(*res));
271 res->anySupport = eh->false_value;
272 res->num_unitsSupported = 0;
273 res->unitsSupported = 0;
277 Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
279 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
280 odr_malloc (eh->o, sizeof(*res));
283 res->num_operators = 0;
284 res->operators = NULL;
285 res->resultSetAsOperandSupported = eh->false_value;
286 res->restrictionOperandSupported = eh->false_value;
287 res->proximity = NULL;
289 for (c = n->child; c; c = c->next)
292 switch (is_numeric_tag(eh, c))
295 for (n = c->child; n; n = n->next)
297 if (is_numeric_tag(eh, n) != 551)
299 (res->num_operators)++;
301 if (res->num_operators)
302 res->operators = (int **)
303 odr_malloc (eh->o, res->num_operators
304 * sizeof(*res->operators));
305 for (n = c->child; n; n = n->next)
307 if (is_numeric_tag(eh, n) != 551)
309 res->operators[i++] = f_integer (eh, n);
313 res->resultSetAsOperandSupported = f_bool (eh, c);
316 res->restrictionOperandSupported = f_bool (eh, c);
319 res->proximity = f_proximitySupport (eh, c);
326 Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
328 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
329 odr_malloc(eh->o, sizeof(*res));
332 res->which = Z_QueryTypeDetails_rpn;
334 for (c = n->child; c; c = c->next)
336 switch (is_numeric_tag(eh, c))
339 res->which = Z_QueryTypeDetails_rpn;
340 res->u.rpn = f_rpnCapabilities (eh, c);
351 static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
353 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
356 res->num_queryTypesSupported = 0;
357 res->queryTypesSupported = 0;
358 res->num_diagnosticsSets = 0;
359 res->diagnosticsSets = 0;
360 res->num_attributeSetIds = 0;
361 res->attributeSetIds = 0;
362 res->num_schemas = 0;
364 res->num_recordSyntaxes = 0;
365 res->recordSyntaxes = 0;
366 res->num_resourceChallenges = 0;
367 res->resourceChallenges = 0;
368 res->restrictedAccess = 0;
370 res->num_variantSets = 0;
371 res->variantSets = 0;
372 res->num_elementSetNames = 0;
373 res->elementSetNames = 0;
374 res->num_unitSystems = 0;
375 res->unitSystems = 0;
377 for (c = n->child; c; c = c->next)
380 switch (is_numeric_tag (eh, c))
383 for (n = c->child; n; n = n->next)
385 if (is_numeric_tag(eh, n) != 518)
387 (res->num_queryTypesSupported)++;
389 if (res->num_queryTypesSupported)
390 res->queryTypesSupported =
391 (Z_QueryTypeDetails **)
392 odr_malloc (eh->o, res->num_queryTypesSupported
393 * sizeof(*res->queryTypesSupported));
394 for (n = c->child; n; n = n->next)
396 if (is_numeric_tag(eh, n) != 518)
398 res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
402 res->diagnosticsSets =
403 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
406 res->attributeSetIds =
407 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
411 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
414 res->recordSyntaxes =
415 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
418 res->resourceChallenges =
419 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
421 case 513: res->restrictedAccess = NULL; break; /* fix */
422 case 514: res->costInfo = NULL; break; /* fix */
425 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
428 res->elementSetNames =
429 f_string_seq (eh, c, &res->num_elementSetNames);
432 res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
439 static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
441 int *r= (int *)odr_malloc(eh->o, sizeof(*r));
446 if (!is_numeric_tag (eh, c))
448 if (c->u.tag.element->tag->value.numeric == 210)
449 *wp = Z_DatabaseInfo_actualNumber;
450 else if (c->u.tag.element->tag->value.numeric == 211)
451 *wp = Z_DatabaseInfo_approxNumber;
454 if (!c->child || c->child->which != DATA1N_data)
456 sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
461 static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
463 Z_ContactInfo *res = (Z_ContactInfo *)
464 odr_malloc (eh->o, sizeof(*res));
468 res->description = 0;
473 for (c = n->child; c; c = c->next)
475 switch (is_numeric_tag (eh, c))
477 case 102: res->name = f_string (eh, c); break;
478 case 113: res->description = f_humstring (eh, c); break;
479 case 127: res->address = f_humstring (eh, c); break;
480 case 128: res->email = f_string (eh, c); break;
481 case 129: res->phone = f_string (eh, c); break;
487 static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
493 for (c = n->child; c; c = c->next)
495 if (!is_numeric_tag (eh, c) != 102)
502 res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
504 res->num_databases = i;
505 res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
507 for (c = n->child; c; c = c->next)
509 if (!is_numeric_tag (eh, c) != 102)
511 res->databases[i++] = f_string (eh, c);
516 static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
518 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
519 odr_malloc (eh->o, sizeof(*res));
522 res->hostAddress = 0;
525 for (c = n->child; c; c = c->next)
527 switch (is_numeric_tag (eh, c))
529 case 121: res->hostAddress = f_string (eh, c); break;
530 case 122: res->port = f_integer (eh, c); break;
536 static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
539 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
540 odr_malloc (eh->o, sizeof(*res));
546 for (c = n->child; c; c = c->next)
548 switch (is_numeric_tag (eh, c))
550 case 124: res->type = f_string (eh, c); break;
551 case 121: res->address = f_string (eh, c); break;
557 static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
560 Z_NetworkAddress **res = NULL;
565 for (c = n->child; c; c = c->next)
567 switch (is_numeric_tag (eh, c))
577 res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
579 for (c = n->child; c; c = c->next)
581 switch (is_numeric_tag (eh, c))
584 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
585 res[i]->which = Z_NetworkAddress_iA;
586 res[i]->u.internetAddress = f_networkAddressIA(eh, c);
590 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
591 res[i]->which = Z_NetworkAddress_other;
592 res[i]->u.other = f_networkAddressOther(eh, c);
600 static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
602 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
606 res->originalCategory = 0;
607 res->description = 0;
609 for (c = n->child; c; c = c->next)
611 switch (is_numeric_tag (eh, c))
613 case 102: res->category = f_string(eh, c); break;
614 case 302: res->originalCategory = f_string(eh, c); break;
615 case 113: res->description = f_humstring(eh, c); break;
616 case 303: res->asn1Module = f_string (eh, c); break;
622 static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
624 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
628 res->num_categories = 0;
629 res->categories = NULL;
631 for (c = n->child; c; c = c->next)
635 switch (is_numeric_tag (eh, c))
637 case 600: res->commonInfo = f_commonInfo(eh, c); break;
639 for (n = c->child; n; n = n->next)
641 if (is_numeric_tag(eh, n) != 301)
643 (res->num_categories)++;
645 if (res->num_categories)
647 (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
648 * sizeof(*res->categories));
649 for (n = c->child; n; n = n->next)
651 if (is_numeric_tag(eh, n) != 301)
653 res->categories[i++] = f_categoryInfo (eh, n);
658 assert (res->num_categories && res->categories);
662 static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
664 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
671 res->namedResultSets = 0;
672 res->multipleDBsearch = 0;
673 res->maxResultSets = 0;
674 res->maxResultSize = 0;
676 res->timeoutInterval = 0;
677 res->welcomeMessage = 0;
678 res->contactInfo = 0;
679 res->description = 0;
680 res->num_nicknames = 0;
683 res->paymentAddr = 0;
685 res->num_dbCombinations = 0;
686 res->dbCombinations = 0;
687 res->num_addresses = 0;
689 res->num_languages = 0;
690 res->languages = NULL;
691 res->commonAccessInfo = 0;
693 for (c = n->child; c; c = c->next)
697 switch (is_numeric_tag (eh, c))
699 case 600: res->commonInfo = f_commonInfo(eh, c); break;
700 case 102: res->name = f_string(eh, c); break;
701 case 103: res->recentNews = f_humstring(eh, c); break;
702 case 104: res->icon = NULL; break; /* fix */
703 case 105: res->namedResultSets = f_bool(eh, c); break;
704 case 106: res->multipleDBsearch = f_bool(eh, c); break;
705 case 107: res->maxResultSets = f_integer(eh, c); break;
706 case 108: res->maxResultSize = f_integer(eh, c); break;
707 case 109: res->maxTerms = f_integer(eh, c); break;
708 case 110: res->timeoutInterval = f_intunit(eh, c); break;
709 case 111: res->welcomeMessage = f_humstring(eh, c); break;
710 case 112: res->contactInfo = f_contactInfo(eh, c); break;
711 case 113: res->description = f_humstring(eh, c); break;
713 res->num_nicknames = 0;
714 for (n = c->child; n; n = n->next)
716 if (is_numeric_tag(eh, n) != 102)
718 (res->num_nicknames)++;
720 if (res->num_nicknames)
722 (char **)odr_malloc (eh->o, res->num_nicknames
723 * sizeof(*res->nicknames));
724 for (n = c->child; n; n = n->next)
726 if (is_numeric_tag(eh, n) != 102)
728 res->nicknames[i++] = f_string (eh, n);
731 case 115: res->usageRest = f_humstring(eh, c); break;
732 case 116: res->paymentAddr = f_humstring(eh, c); break;
733 case 117: res->hours = f_humstring(eh, c); break;
735 res->num_dbCombinations = 0;
736 for (n = c->child; n; n = n->next)
738 if (!is_numeric_tag(eh, n) != 605)
740 (res->num_dbCombinations)++;
742 if (res->num_dbCombinations)
743 res->dbCombinations =
744 (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
745 * sizeof(*res->dbCombinations));
746 for (n = c->child; n; n = n->next)
748 if (!is_numeric_tag(eh, n) != 605)
750 res->dbCombinations[i++] = f_databaseList (eh, n);
755 f_networkAddresses (eh, c, &res->num_addresses);
758 res->num_languages = 0;
759 for (n = c->child; n; n = n->next)
761 if (!is_numeric_tag(eh, n) != 126)
763 (res->num_languages)++;
765 if (res->num_languages)
766 res->languages = (char **)
767 odr_malloc (eh->o, res->num_languages *
768 sizeof(*res->languages));
769 for (n = c->child; n; n = n->next)
771 if (!is_numeric_tag(eh, n) != 126)
773 res->languages[i++] = f_string (eh, n);
776 case 500: res->commonAccessInfo = f_accessInfo(eh, c); break;
779 if (!res->namedResultSets)
780 res->namedResultSets = eh->false_value;
781 if (!res->multipleDBsearch)
782 res->multipleDBsearch = eh->false_value;
786 static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
788 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
793 res->explainDatabase = 0;
794 res->num_nicknames = 0;
799 res->titleString = 0;
800 res->num_keywords = 0;
802 res->description = 0;
803 res->associatedDbs = 0;
805 res->disclaimers = 0;
807 res->u.actualNumber = 0;
808 res->defaultOrder = 0;
809 res->avRecordSize = 0;
810 res->maxRecordSize = 0;
814 res->updateInterval = 0;
816 res->proprietary = 0;
817 res->copyrightText = 0;
818 res->copyrightNotice = 0;
819 res->producerContactInfo = 0;
820 res->supplierContactInfo = 0;
821 res->submissionContactInfo = 0;
824 for (c = n->child; c; c = c->next)
828 switch (is_numeric_tag (eh, c))
830 case 600: res->commonInfo = f_commonInfo(eh, c); break;
831 case 102: res->name = f_string(eh, c); break;
832 case 226: res->explainDatabase = odr_nullval(); break;
834 res->num_nicknames = 0;
835 for (n = c->child; n; n = n->next)
837 if (!is_numeric_tag(eh, n) ||
838 n->u.tag.element->tag->value.numeric != 102)
840 (res->num_nicknames)++;
842 if (res->num_nicknames)
844 (char **)odr_malloc (eh->o, res->num_nicknames
845 * sizeof(*res->nicknames));
846 for (n = c->child; n; n = n->next)
848 if (!is_numeric_tag(eh, n) ||
849 n->u.tag.element->tag->value.numeric != 102)
851 res->nicknames[i++] = f_string (eh, n);
854 case 104: res->icon = 0; break; /* fix */
855 case 201: res->userFee = f_bool(eh, c); break;
856 case 202: res->available = f_bool(eh, c); break;
857 case 203: res->titleString = f_humstring(eh, c); break;
859 res->num_keywords = 0;
860 for (n = c->child; n; n = n->next)
862 if (!is_numeric_tag(eh, n) != 1000)
864 (res->num_keywords)++;
866 if (res->num_keywords)
868 (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
869 * sizeof(*res->keywords));
870 for (n = c->child; n; n = n->next)
872 if (!is_numeric_tag(eh, n) != 1000)
874 res->keywords[i++] = f_humstring (eh, n);
877 case 113: res->description = f_humstring(eh, c); break;
879 res->associatedDbs = f_databaseList (eh, c);
882 res->subDbs = f_databaseList (eh, c);
884 case 207: res->disclaimers = f_humstring(eh, c); break;
885 case 103: res->news = f_humstring(eh, c); break;
886 case 209: res->u.actualNumber =
887 f_recordCount(eh, c, &res->which); break;
888 case 212: res->defaultOrder = f_humstring(eh, c); break;
889 case 213: res->avRecordSize = f_integer(eh, c); break;
890 case 214: res->maxRecordSize = f_integer(eh, c); break;
891 case 215: res->hours = f_humstring(eh, c); break;
892 case 216: res->bestTime = f_humstring(eh, c); break;
893 case 217: res->lastUpdate = f_string(eh, c); break;
894 case 218: res->updateInterval = f_intunit(eh, c); break;
895 case 219: res->coverage = f_humstring(eh, c); break;
896 case 220: res->proprietary = f_bool(eh, c); break;
897 case 221: res->copyrightText = f_humstring(eh, c); break;
898 case 222: res->copyrightNotice = f_humstring(eh, c); break;
899 case 223: res->producerContactInfo = f_contactInfo(eh, c); break;
900 case 224: res->supplierContactInfo = f_contactInfo(eh, c); break;
901 case 225: res->submissionContactInfo = f_contactInfo(eh, c); break;
902 case 500: res->accessInfo = f_accessInfo(eh, c); break;
906 res->userFee = eh->false_value;
908 res->available = eh->true_value;
912 Z_StringOrNumeric *f_stringOrNumeric (ExpHandle *eh, data1_node *n)
914 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
915 odr_malloc (eh->o, sizeof(*res));
917 for (c = n->child; c; c = c->next)
919 switch (is_numeric_tag (eh, c))
922 res->which = Z_StringOrNumeric_string;
923 res->u.string = f_string (eh, c);
926 res->which = Z_StringOrNumeric_numeric;
927 res->u.numeric = f_integer (eh, c);
934 Z_AttributeDescription *f_attributeDescription (
935 ExpHandle *eh, data1_node *n)
937 Z_AttributeDescription *res = (Z_AttributeDescription *)
938 odr_malloc(eh->o, sizeof(*res));
943 res->description = 0;
944 res->attributeValue = 0;
945 res->num_equivalentAttributes = 0;
946 res->equivalentAttributes = 0;
948 for (c = n->child; c; c = c->next)
950 switch (is_numeric_tag (eh, c))
952 case 102: res->name = f_string (eh, c); break;
953 case 113: res->description = f_humstring (eh, c); break;
954 case 710: res->attributeValue = f_stringOrNumeric (eh, c); break;
955 case 752: (res->num_equivalentAttributes++); break;
958 if (res->num_equivalentAttributes)
959 res->equivalentAttributes = (Z_StringOrNumeric **)
960 odr_malloc (eh->o, sizeof(*res->equivalentAttributes) *
961 res->num_equivalentAttributes);
962 for (c = n->child; c; c = c->next)
963 if (is_numeric_tag (eh, c) == 752)
964 res->equivalentAttributes[i++] = f_stringOrNumeric (eh, c);
968 Z_AttributeType *f_attributeType (ExpHandle *eh, data1_node *n)
970 Z_AttributeType *res = (Z_AttributeType *)
971 odr_malloc(eh->o, sizeof(*res));
975 res->description = 0;
976 res->attributeType = 0;
977 res->num_attributeValues = 0;
978 res->attributeValues = 0;
980 for (c = n->child; c; c = c->next)
983 switch (is_numeric_tag (eh, c))
985 case 102: res->name = f_string (eh, c); break;
986 case 113: res->description = f_humstring (eh, c); break;
987 case 704: res->attributeType = f_integer (eh, c); break;
989 for (n = c->child; n; n = n->next)
991 if (is_numeric_tag(eh, n) != 709)
993 (res->num_attributeValues)++;
995 if (res->num_attributeValues)
996 res->attributeValues = (Z_AttributeDescription **)
997 odr_malloc (eh->o, res->num_attributeValues
998 * sizeof(*res->attributeValues));
999 for (n = c->child; n; n = n->next)
1001 if (is_numeric_tag(eh, n) != 709)
1003 res->attributeValues[i++] = f_attributeDescription (eh, n);
1011 Z_AttributeSetInfo *f_attributeSetInfo (ExpHandle *eh, data1_node *n)
1013 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
1014 odr_malloc(eh->o, sizeof(*res));
1017 res->commonInfo = 0;
1018 res->attributeSet = 0;
1020 res->num_attributes = 0;
1021 res->attributes = 0;
1022 res->description = 0;
1023 for (c = n->child; c; c = c->next)
1026 switch (is_numeric_tag (eh, c))
1028 case 600: res->commonInfo = f_commonInfo (eh, c); break;
1029 case 1000: res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1030 case 102: res->name = f_string (eh, c); break;
1032 for (n = c->child; n; n = n->next)
1034 if (is_numeric_tag(eh, n) != 751)
1036 (res->num_attributes)++;
1038 if (res->num_attributes)
1039 res->attributes = (Z_AttributeType **)
1040 odr_malloc (eh->o, res->num_attributes
1041 * sizeof(*res->attributes));
1042 for (n = c->child; n; n = n->next)
1044 if (is_numeric_tag(eh, n) != 751)
1046 res->attributes[i++] = f_attributeType (eh, n);
1049 case 113: res->description = f_humstring (eh, c); break;
1055 Z_OmittedAttributeInterpretation *f_omittedAttributeInterpretation (
1056 ExpHandle *eh, data1_node *n)
1058 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1059 odr_malloc (eh->o, sizeof(*res));
1062 res->defaultValue = 0;
1063 res->defaultDescription = 0;
1064 for (c = n->child; c; c = c->next)
1066 switch (is_numeric_tag (eh, c))
1069 res->defaultValue = f_stringOrNumeric (eh, c);
1072 res->defaultDescription = f_humstring(eh, c);
1079 Z_AttributeValue *f_attributeValue (ExpHandle *eh, data1_node *n)
1081 Z_AttributeValue *res = (Z_AttributeValue *)
1082 odr_malloc (eh->o, sizeof(*res));
1086 res->description = 0;
1087 res->num_subAttributes = 0;
1088 res->subAttributes = 0;
1089 res->num_superAttributes = 0;
1090 res->superAttributes = 0;
1091 res->partialSupport = 0;
1092 for (c = n->child; c; c = c->next)
1095 switch (is_numeric_tag (eh, c))
1098 res->value = f_stringOrNumeric (eh, c); break;
1100 res->description = f_humstring (eh, c); break;
1102 for (n = c->child; n; n = n->next)
1104 if (is_numeric_tag(eh, n) != 713)
1106 (res->num_subAttributes)++;
1108 if (res->num_subAttributes)
1109 res->subAttributes =
1110 (Z_StringOrNumeric **)
1111 odr_malloc (eh->o, res->num_subAttributes
1112 * sizeof(*res->subAttributes));
1113 for (n = c->child; n; n = n->next)
1115 if (is_numeric_tag(eh, n) != 713)
1117 res->subAttributes[i++] = f_stringOrNumeric (eh, n);
1121 for (n = c->child; n; n = n->next)
1123 if (is_numeric_tag(eh, n) != 715)
1125 (res->num_superAttributes)++;
1127 if (res->num_superAttributes)
1128 res->superAttributes =
1129 (Z_StringOrNumeric **)
1130 odr_malloc (eh->o, res->num_superAttributes
1131 * sizeof(*res->superAttributes));
1132 for (n = c->child; n; n = n->next)
1134 if (is_numeric_tag(eh, n) != 715)
1136 res->superAttributes[i++] = f_stringOrNumeric (eh, n);
1140 res->partialSupport = odr_nullval ();
1147 Z_AttributeTypeDetails *f_attributeTypeDetails (ExpHandle *eh, data1_node *n)
1149 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1150 odr_malloc(eh->o, sizeof(*res));
1152 res->attributeType = 0;
1153 res->defaultIfOmitted = 0;
1154 res->num_attributeValues = 0;
1155 res->attributeValues = 0;
1156 for (c = n->child; c; c = c->next)
1159 switch (is_numeric_tag (eh, c))
1161 case 704: res->attributeType = f_integer (eh, c); break;
1163 res->defaultIfOmitted = f_omittedAttributeInterpretation (eh, c);
1166 for (n = c->child; n; n = n->next)
1168 if (is_numeric_tag(eh, n) != 709)
1170 (res->num_attributeValues)++;
1172 if (res->num_attributeValues)
1173 res->attributeValues =
1174 (Z_AttributeValue **)
1175 odr_malloc (eh->o, res->num_attributeValues
1176 * sizeof(*res->attributeValues));
1177 for (n = c->child; n; n = n->next)
1179 if (is_numeric_tag(eh, n) != 709)
1181 res->attributeValues[i++] = f_attributeValue (eh, n);
1189 Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n)
1191 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1192 odr_malloc(eh->o, sizeof(*res));
1195 res->attributeSet = 0;
1196 res->num_attributesByType = 0;
1197 res->attributesByType = 0;
1198 for (c = n->child; c; c = c->next)
1201 switch (is_numeric_tag (eh, c))
1203 case 1000: res->attributeSet = f_oid(eh, c, CLASS_ATTSET); break;
1205 for (n = c->child; n; n = n->next)
1207 if (is_numeric_tag(eh, n) != 703)
1209 (res->num_attributesByType)++;
1211 if (res->num_attributesByType)
1212 res->attributesByType =
1213 (Z_AttributeTypeDetails **)
1214 odr_malloc (eh->o, res->num_attributesByType
1215 * sizeof(*res->attributesByType));
1216 for (n = c->child; n; n = n->next)
1218 if (is_numeric_tag(eh, n) != 703)
1220 res->attributesByType[i++] = f_attributeTypeDetails (eh, n);
1228 Z_AttributeValueList *f_attributeValueList (ExpHandle *eh, data1_node *n)
1230 Z_AttributeValueList *res = (Z_AttributeValueList *)
1231 odr_malloc (eh->o, sizeof(*res));
1235 res->num_attributes = 0;
1236 res->attributes = 0;
1237 for (c = n->child; c; c = c->next)
1238 if (is_numeric_tag (eh, c) == 710)
1239 (res->num_attributes)++;
1240 if (res->num_attributes)
1242 res->attributes = (Z_StringOrNumeric **)
1243 odr_malloc (eh->o, res->num_attributes * sizeof(*res->attributes));
1245 for (c = n->child; c; c = c->next)
1246 if (is_numeric_tag(eh, c) == 710)
1247 res->attributes[i++] = f_stringOrNumeric (eh, c);
1251 Z_AttributeOccurrence *f_attributeOccurrence (ExpHandle *eh, data1_node *n)
1253 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1254 odr_malloc (eh->o, sizeof(*res));
1257 res->attributeSet = 0;
1258 res->attributeType = 0;
1259 res->mustBeSupplied = 0;
1260 res->which = Z_AttributeOcc_any_or_none;
1261 res->attributeValues.any_or_none = odr_nullval ();
1263 for (c = n->child; c; c = c->next)
1265 switch (is_numeric_tag (eh, c))
1268 res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1270 res->attributeType = f_integer (eh, c); break;
1272 res->mustBeSupplied = odr_nullval (); break;
1274 res->which = Z_AttributeOcc_any_or_none;
1275 res->attributeValues.any_or_none = odr_nullval ();
1278 res->which = Z_AttributeOcc_specific;
1279 res->attributeValues.specific = f_attributeValueList (eh, c);
1286 Z_AttributeCombination *f_attributeCombination (ExpHandle *eh, data1_node *n)
1288 Z_AttributeCombination *res = (Z_AttributeCombination *)
1289 odr_malloc (eh->o, sizeof(*res));
1293 res->num_occurrences = 0;
1294 res->occurrences = 0;
1295 for (c = n->child; c; c = c->next)
1296 if (is_numeric_tag (eh, c) == 719)
1297 (res->num_occurrences)++;
1298 if (res->num_occurrences)
1300 res->occurrences = (Z_AttributeOccurrence **)
1301 odr_malloc (eh->o, res->num_occurrences * sizeof(*res->occurrences));
1303 for (c = n->child; c; c = c->next)
1304 if (is_numeric_tag(eh, c) == 719)
1305 res->occurrences[i++] = f_attributeOccurrence (eh, c);
1306 assert (res->num_occurrences);
1310 Z_AttributeCombinations *f_attributeCombinations (ExpHandle *eh, data1_node *n)
1312 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1313 odr_malloc (eh->o, sizeof(*res));
1315 res->defaultAttributeSet = 0;
1316 res->num_legalCombinations = 0;
1317 res->legalCombinations = 0;
1319 for (c = n->child; c; c = c->next)
1322 switch (is_numeric_tag (eh, c))
1325 res->defaultAttributeSet = f_oid (eh, c, CLASS_ATTSET);
1328 for (n = c->child; n; n = n->next)
1330 if (is_numeric_tag(eh, n) != 718)
1332 (res->num_legalCombinations)++;
1334 if (res->num_legalCombinations)
1335 res->legalCombinations =
1336 (Z_AttributeCombination **)
1337 odr_malloc (eh->o, res->num_legalCombinations
1338 * sizeof(*res->legalCombinations));
1339 for (n = c->child; n; n = n->next)
1341 if (is_numeric_tag(eh, n) != 718)
1343 res->legalCombinations[i++] = f_attributeCombination (eh, n);
1348 assert (res->num_legalCombinations);
1352 Z_AttributeDetails *f_attributeDetails (ExpHandle *eh, data1_node *n)
1354 Z_AttributeDetails *res = (Z_AttributeDetails *)
1355 odr_malloc(eh->o, sizeof(*res));
1358 res->commonInfo = 0;
1359 res->databaseName = 0;
1360 res->num_attributesBySet = 0;
1361 res->attributesBySet = NULL;
1362 res->attributeCombinations = NULL;
1364 for (c = n->child; c; c = c->next)
1367 switch (is_numeric_tag (eh, c))
1369 case 600: res->commonInfo = f_commonInfo(eh, c); break;
1370 case 102: res->databaseName = f_string (eh, c); break;
1372 for (n = c->child; n; n = n->next)
1374 if (is_numeric_tag(eh, n) != 701)
1376 (res->num_attributesBySet)++;
1378 if (res->num_attributesBySet)
1379 res->attributesBySet =
1380 (Z_AttributeSetDetails **)
1381 odr_malloc (eh->o, res->num_attributesBySet
1382 * sizeof(*res->attributesBySet));
1383 for (n = c->child; n; n = n->next)
1385 if (is_numeric_tag(eh, n) != 701)
1387 res->attributesBySet[i++] = f_attributeSetDetails (eh, n);
1391 res->attributeCombinations = f_attributeCombinations (eh, c);
1398 Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
1402 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
1407 eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
1408 *eh.false_value = 0;
1409 eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
1412 assert(n->which == DATA1N_root);
1413 if (strcmp(n->u.root.type, "explain"))
1415 logf(LOG_WARN, "Attempt to convert a non-Explain record");
1418 for (n = n->child; n; n = n->next)
1420 switch (is_numeric_tag (&eh, n))
1423 res->which = Z_Explain_categoryList;
1424 if (!(res->u.categoryList = f_categoryList(&eh, n)))
1428 res->which = Z_Explain_targetInfo;
1429 if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
1433 res->which = Z_Explain_databaseInfo;
1434 if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
1438 res->which = Z_Explain_attributeSetInfo;
1439 if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n)))
1443 res->which = Z_Explain_attributeDetails;
1444 if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))
1449 logf(LOG_WARN, "No category in Explain record");