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.12 1998-05-18 13:07:04 adam
8 * Changed the way attribute sets are handled by the retriaval module.
9 * Extended Explain conversion / schema.
10 * Modified server and client to work with ASN.1 compiled protocol handlers.
12 * Revision 1.11 1998/04/02 08:27:37 adam
13 * Minor change in definition of Z_TargetInfo. Furhter work on Explain
14 * schema - added AttributeDetails.
16 * Revision 1.10 1998/03/31 15:13:20 adam
17 * Development towards compiled ASN.1.
19 * Revision 1.9 1998/03/05 08:07:58 adam
20 * Make data1 to EXPLAIN ignore local tags in root.
22 * Revision 1.8 1998/02/11 11:53:35 adam
23 * Changed code so that it compiles as C++.
25 * Revision 1.7 1997/12/09 16:18:16 adam
26 * Work on EXPLAIN schema. First implementation of sub-schema facility
29 * Revision 1.6 1997/11/24 11:33:56 adam
30 * Using function odr_nullval() instead of global ODR_NULLVAL when
33 * Revision 1.5 1997/11/19 10:30:06 adam
36 * Revision 1.4 1997/11/18 09:51:08 adam
37 * Removed element num_children from data1_node. Minor changes in
40 * Revision 1.3 1997/09/17 12:10:36 adam
43 * Revision 1.2 1995/12/14 16:28:30 quinn
46 * Revision 1.1 1995/12/14 11:09:51 quinn
69 static int is_numeric_tag (ExpHandle *eh, data1_node *c)
71 if (!c || c->which != DATA1N_tag)
73 if (!c->u.tag.element)
75 logf(LOG_WARN, "Tag %s is local", c->u.tag.tag);
78 if (c->u.tag.element->tag->which != DATA1T_numeric)
80 logf(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
83 if (eh->select && !c->u.tag.node_selected)
85 return c->u.tag.element->tag->value.numeric;
88 static int is_data_tag (ExpHandle *eh, data1_node *c)
90 if (!c || c->which != DATA1N_data)
92 if (eh->select && !c->u.tag.node_selected)
97 static int *f_integer(ExpHandle *eh, data1_node *c)
103 if (!is_data_tag (eh, c) || c->u.data.len > 63)
105 r = (int *)odr_malloc(eh->o, sizeof(*r));
106 sprintf(intbuf, "%.*s", 63, c->u.data.data);
111 static char *f_string(ExpHandle *eh, data1_node *c)
116 if (!is_data_tag (eh, c))
118 r = (char *)odr_malloc(eh->o, c->u.data.len+1);
119 memcpy(r, c->u.data.data, c->u.data.len);
120 r[c->u.data.len] = '\0';
124 static bool_t *f_bool(ExpHandle *eh, data1_node *c)
130 if (!is_data_tag (eh, c) || c->u.data.len > 63)
132 tf = (int *)odr_malloc (eh->o, sizeof(*tf));
133 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
138 static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
142 oid_value value_for_this;
145 if (!is_data_tag (eh, c) || c->u.data.len > 63)
147 sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
148 value_for_this = oid_getvalbyname(oidstr);
149 if (value_for_this == VAL_NONE)
151 Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
159 ident.oclass = oclass;
160 ident.proto = PROTO_Z3950;
161 ident.value = value_for_this;
163 oid_ent_to_oid (&ident, oid_this);
165 return odr_oiddup (eh->o, oid_this);
168 static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
174 static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c)
177 Z_HumanStringUnit *u;
180 if (!is_data_tag (eh, c))
182 r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
184 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
185 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
187 u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
188 memcpy(u->text, c->u.data.data, c->u.data.len);
189 u->text[c->u.data.len] = '\0';
193 static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
195 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
199 res->dateChanged = 0;
201 res->humanStringLanguage = 0;
204 for (c = n->child; c; c = c->next)
206 switch (is_numeric_tag (eh, c))
208 case 601: res->dateAdded = f_string(eh, c); break;
209 case 602: res->dateChanged = f_string(eh, c); break;
210 case 603: res->expiry = f_string(eh, c); break;
211 case 604: res->humanStringLanguage = f_string(eh, c); break;
217 Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
224 for (c = n->child ; c; c = c->next)
225 if (is_numeric_tag (eh, c) == 1000)
229 res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
230 for (c = n->child, i = 0 ; c; c = c->next)
231 if (is_numeric_tag (eh, c) == 1000)
232 res[i++] = f_oid (eh, c, oclass);
236 char **f_string_seq (ExpHandle *eh, data1_node *n, int *num)
243 for (c = n->child ; c; c = c->next)
245 if (is_numeric_tag (eh, c) != 1001)
251 res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
252 for (c = n->child, i = 0 ; c; c = c->next)
254 if (is_numeric_tag (eh, c) != 1001)
256 res[i++] = f_string (eh, c);
261 Z_ProximitySupport *f_proximitySupport (ExpHandle *eh, data1_node *n)
263 Z_ProximitySupport *res = (Z_ProximitySupport *)
264 odr_malloc (eh->o, sizeof(*res));
265 res->anySupport = eh->false_value;
266 res->num_unitsSupported = 0;
267 res->unitsSupported = 0;
271 Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
273 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
274 odr_malloc (eh->o, sizeof(*res));
277 res->num_operators = 0;
278 res->operators = NULL;
279 res->resultSetAsOperandSupported = eh->false_value;
280 res->restrictionOperandSupported = eh->false_value;
281 res->proximity = NULL;
283 for (c = n->child; n; c = c->next)
286 switch (is_numeric_tag(eh, c))
289 for (n = c->child; n; n = n->next)
291 if (is_numeric_tag(eh, n) != 551)
293 (res->num_operators)++;
295 if (res->num_operators)
296 res->operators = (int **)
297 odr_malloc (eh->o, res->num_operators
298 * sizeof(*res->operators));
299 for (n = c->child; n; n = n->next)
301 if (is_numeric_tag(eh, n) != 551)
303 res->operators[i++] = f_integer (eh, n);
307 res->resultSetAsOperandSupported = f_bool (eh, c);
310 res->restrictionOperandSupported = f_bool (eh, c);
313 res->proximity = f_proximitySupport (eh, c);
320 Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
322 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
323 odr_malloc(eh->o, sizeof(*res));
326 res->which = Z_QueryTypeDetails_rpn;
328 for (c = n->child; c; c = c->next)
330 switch (is_numeric_tag(eh, n))
333 res->which = Z_QueryTypeDetails_rpn;
334 res->u.rpn = f_rpnCapabilities (eh, c);
345 static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
347 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
350 res->num_queryTypesSupported = 0;
351 res->queryTypesSupported = 0;
352 res->num_diagnosticsSets = 0;
353 res->diagnosticsSets = 0;
354 res->num_attributeSetIds = 0;
355 res->attributeSetIds = 0;
356 res->num_schemas = 0;
358 res->num_recordSyntaxes = 0;
359 res->recordSyntaxes = 0;
360 res->num_resourceChallenges = 0;
361 res->resourceChallenges = 0;
362 res->restrictedAccess = 0;
364 res->num_variantSets = 0;
365 res->variantSets = 0;
366 res->num_elementSetNames = 0;
367 res->elementSetNames = 0;
368 res->num_unitSystems = 0;
369 res->unitSystems = 0;
371 for (c = n->child; c; c = c->next)
374 switch (is_numeric_tag (eh, c))
377 for (n = c->child; n; n = n->next)
379 if (is_numeric_tag(eh, n) != 518)
381 (res->num_queryTypesSupported)++;
383 if (res->num_queryTypesSupported)
384 res->queryTypesSupported =
385 (Z_QueryTypeDetails **)
386 odr_malloc (eh->o, res->num_queryTypesSupported
387 * sizeof(*res->queryTypesSupported));
388 for (n = c->child; n; n = n->next)
390 if (is_numeric_tag(eh, n) != 518)
392 res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
396 res->diagnosticsSets =
397 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
400 res->attributeSetIds =
401 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
405 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
408 res->recordSyntaxes =
409 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
412 res->resourceChallenges =
413 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
415 case 513: res->restrictedAccess = NULL; break; /* fix */
416 case 514: res->costInfo = NULL; break; /* fix */
419 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
422 res->elementSetNames =
423 f_string_seq (eh, c, &res->num_elementSetNames);
426 res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
433 static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
435 int *r= (int *)odr_malloc(eh->o, sizeof(*r));
440 if (!is_numeric_tag (eh, c))
442 if (c->u.tag.element->tag->value.numeric == 210)
443 *wp = Z_DatabaseInfo_actualNumber;
444 else if (c->u.tag.element->tag->value.numeric == 211)
445 *wp = Z_DatabaseInfo_approxNumber;
448 if (!c->child || c->child->which != DATA1N_data)
450 sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
455 static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
457 Z_ContactInfo *res = (Z_ContactInfo *)
458 odr_malloc (eh->o, sizeof(*res));
462 res->description = 0;
467 for (c = n->child; c; c = c->next)
469 switch (is_numeric_tag (eh, c))
471 case 102: res->name = f_string (eh, c); break;
472 case 113: res->description = f_humstring (eh, c); break;
473 case 127: res->address = f_humstring (eh, c); break;
474 case 128: res->email = f_string (eh, c); break;
475 case 129: res->phone = f_string (eh, c); break;
481 static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
487 for (c = n->child; c; c = c->next)
489 if (!is_numeric_tag (eh, c) != 102)
496 res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
498 res->num_databases = i;
499 res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
501 for (c = n->child; c; c = c->next)
503 if (!is_numeric_tag (eh, c) != 102)
505 res->databases[i++] = f_string (eh, c);
510 static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
512 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
513 odr_malloc (eh->o, sizeof(*res));
516 res->hostAddress = 0;
519 for (c = n->child; c; c = c->next)
521 switch (is_numeric_tag (eh, c))
523 case 121: res->hostAddress = f_string (eh, c); break;
524 case 122: res->port = f_integer (eh, c); break;
530 static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
533 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
534 odr_malloc (eh->o, sizeof(*res));
540 for (c = n->child; c; c = c->next)
542 switch (is_numeric_tag (eh, c))
544 case 124: res->type = f_string (eh, c); break;
545 case 121: res->address = f_string (eh, c); break;
551 static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
554 Z_NetworkAddress **res = NULL;
559 for (c = n->child; c; c = c->next)
561 switch (is_numeric_tag (eh, c))
571 res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
573 for (c = n->child; c; c = c->next)
575 switch (is_numeric_tag (eh, c))
578 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
579 res[i]->which = Z_NetworkAddress_iA;
580 res[i]->u.internetAddress = f_networkAddressIA(eh, c);
584 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
585 res[i]->which = Z_NetworkAddress_other;
586 res[i]->u.other = f_networkAddressOther(eh, c);
594 static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
596 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
600 res->originalCategory = 0;
601 res->description = 0;
603 for (c = n->child; c; c = c->next)
605 switch (is_numeric_tag (eh, c))
607 case 102: res->category = f_string(eh, c); break;
608 case 302: res->originalCategory = f_string(eh, c); break;
609 case 113: res->description = f_humstring(eh, c); break;
610 case 303: res->asn1Module = f_string (eh, c); break;
616 static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
618 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
622 res->num_categories = 0;
623 res->categories = NULL;
625 for (c = n->child; c; c = c->next)
629 switch (is_numeric_tag (eh, c))
631 case 600: res->commonInfo = f_commonInfo(eh, c); break;
633 for (n = c->child; n; n = n->next)
635 if (is_numeric_tag(eh, n) != 301)
637 (res->num_categories)++;
639 if (res->num_categories)
641 (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
642 * sizeof(*res->categories));
643 for (n = c->child; n; n = n->next)
645 if (is_numeric_tag(eh, n) != 301)
647 res->categories[i++] = f_categoryInfo (eh, n);
652 assert (res->num_categories && res->categories);
656 static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
658 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
665 res->namedResultSets = 0;
666 res->multipleDBsearch = 0;
667 res->maxResultSets = 0;
668 res->maxResultSize = 0;
670 res->timeoutInterval = 0;
671 res->welcomeMessage = 0;
672 res->contactInfo = 0;
673 res->description = 0;
674 res->num_nicknames = 0;
677 res->paymentAddr = 0;
679 res->num_dbCombinations = 0;
680 res->dbCombinations = 0;
681 res->num_addresses = 0;
683 res->num_languages = 0;
684 res->languages = NULL;
685 res->commonAccessInfo = 0;
687 for (c = n->child; c; c = c->next)
691 switch (is_numeric_tag (eh, c))
693 case 600: res->commonInfo = f_commonInfo(eh, c); break;
694 case 102: res->name = f_string(eh, c); break;
695 case 103: res->recentNews = f_humstring(eh, c); break;
696 case 104: res->icon = NULL; break; /* fix */
697 case 105: res->namedResultSets = f_bool(eh, c); break;
698 case 106: res->multipleDBsearch = f_bool(eh, c); break;
699 case 107: res->maxResultSets = f_integer(eh, c); break;
700 case 108: res->maxResultSize = f_integer(eh, c); break;
701 case 109: res->maxTerms = f_integer(eh, c); break;
702 case 110: res->timeoutInterval = f_intunit(eh, c); break;
703 case 111: res->welcomeMessage = f_humstring(eh, c); break;
704 case 112: res->contactInfo = f_contactInfo(eh, c); break;
705 case 113: res->description = f_humstring(eh, c); break;
707 res->num_nicknames = 0;
708 for (n = c->child; n; n = n->next)
710 if (is_numeric_tag(eh, n) != 102)
712 (res->num_nicknames)++;
714 if (res->num_nicknames)
716 (char **)odr_malloc (eh->o, res->num_nicknames
717 * sizeof(*res->nicknames));
718 for (n = c->child; n; n = n->next)
720 if (is_numeric_tag(eh, n) != 102)
722 res->nicknames[i++] = f_string (eh, n);
725 case 115: res->usageRest = f_humstring(eh, c); break;
726 case 116: res->paymentAddr = f_humstring(eh, c); break;
727 case 117: res->hours = f_humstring(eh, c); break;
729 res->num_dbCombinations = 0;
730 for (n = c->child; n; n = n->next)
732 if (!is_numeric_tag(eh, n) != 605)
734 (res->num_dbCombinations)++;
736 if (res->num_dbCombinations)
737 res->dbCombinations =
738 (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
739 * sizeof(*res->dbCombinations));
740 for (n = c->child; n; n = n->next)
742 if (!is_numeric_tag(eh, n) != 605)
744 res->dbCombinations[i++] = f_databaseList (eh, n);
749 f_networkAddresses (eh, c, &res->num_addresses);
752 res->num_languages = 0;
753 for (n = c->child; n; n = n->next)
755 if (!is_numeric_tag(eh, n) != 126)
757 (res->num_languages)++;
759 if (res->num_languages)
760 res->languages = (char **)
761 odr_malloc (eh->o, res->num_languages *
762 sizeof(*res->languages));
763 for (n = c->child; n; n = n->next)
765 if (!is_numeric_tag(eh, n) != 126)
767 res->languages[i++] = f_string (eh, n);
770 case 500: res->commonAccessInfo = f_accessInfo(eh, c); break;
773 if (!res->namedResultSets)
774 res->namedResultSets = eh->false_value;
775 if (!res->multipleDBsearch)
776 res->multipleDBsearch = eh->false_value;
780 static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
782 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
787 res->explainDatabase = 0;
788 res->num_nicknames = 0;
793 res->titleString = 0;
794 res->num_keywords = 0;
796 res->description = 0;
797 res->associatedDbs = 0;
799 res->disclaimers = 0;
801 res->u.actualNumber = 0;
802 res->defaultOrder = 0;
803 res->avRecordSize = 0;
804 res->maxRecordSize = 0;
808 res->updateInterval = 0;
810 res->proprietary = 0;
811 res->copyrightText = 0;
812 res->copyrightNotice = 0;
813 res->producerContactInfo = 0;
814 res->supplierContactInfo = 0;
815 res->submissionContactInfo = 0;
818 for (c = n->child; c; c = c->next)
822 switch (is_numeric_tag (eh, c))
824 case 600: res->commonInfo = f_commonInfo(eh, c); break;
825 case 102: res->name = f_string(eh, c); break;
826 case 226: res->explainDatabase = odr_nullval(); break;
828 res->num_nicknames = 0;
829 for (n = c->child; n; n = n->next)
831 if (!is_numeric_tag(eh, n) ||
832 n->u.tag.element->tag->value.numeric != 102)
834 (res->num_nicknames)++;
836 if (res->num_nicknames)
838 (char **)odr_malloc (eh->o, res->num_nicknames
839 * sizeof(*res->nicknames));
840 for (n = c->child; n; n = n->next)
842 if (!is_numeric_tag(eh, n) ||
843 n->u.tag.element->tag->value.numeric != 102)
845 res->nicknames[i++] = f_string (eh, n);
848 case 104: res->icon = 0; break; /* fix */
849 case 201: res->userFee = f_bool(eh, c); break;
850 case 202: res->available = f_bool(eh, c); break;
851 case 203: res->titleString = f_humstring(eh, c); break;
853 res->num_keywords = 0;
854 for (n = c->child; n; n = n->next)
856 if (!is_numeric_tag(eh, n) != 1000)
858 (res->num_keywords)++;
860 if (res->num_keywords)
862 (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
863 * sizeof(*res->keywords));
864 for (n = c->child; n; n = n->next)
866 if (!is_numeric_tag(eh, n) != 1000)
868 res->keywords[i++] = f_humstring (eh, n);
871 case 113: res->description = f_humstring(eh, c); break;
873 res->associatedDbs = f_databaseList (eh, c);
876 res->subDbs = f_databaseList (eh, c);
878 case 207: res->disclaimers = f_humstring(eh, c); break;
879 case 103: res->news = f_humstring(eh, c); break;
880 case 209: res->u.actualNumber =
881 f_recordCount(eh, c, &res->which); break;
882 case 212: res->defaultOrder = f_humstring(eh, c); break;
883 case 213: res->avRecordSize = f_integer(eh, c); break;
884 case 214: res->maxRecordSize = f_integer(eh, c); break;
885 case 215: res->hours = f_humstring(eh, c); break;
886 case 216: res->bestTime = f_humstring(eh, c); break;
887 case 217: res->lastUpdate = f_string(eh, c); break;
888 case 218: res->updateInterval = f_intunit(eh, c); break;
889 case 219: res->coverage = f_humstring(eh, c); break;
890 case 220: res->proprietary = f_bool(eh, c); break;
891 case 221: res->copyrightText = f_humstring(eh, c); break;
892 case 222: res->copyrightNotice = f_humstring(eh, c); break;
893 case 223: res->producerContactInfo = f_contactInfo(eh, c); break;
894 case 224: res->supplierContactInfo = f_contactInfo(eh, c); break;
895 case 225: res->submissionContactInfo = f_contactInfo(eh, c); break;
896 case 500: res->accessInfo = f_accessInfo(eh, c); break;
900 res->userFee = eh->false_value;
902 res->available = eh->true_value;
906 Z_StringOrNumeric *f_stringOrNumeric (ExpHandle *eh, data1_node *n)
908 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
909 odr_malloc (eh->o, sizeof(*res));
911 for (c = n->child; c; c = c->next)
913 switch (is_numeric_tag (eh, c))
916 res->which = Z_StringOrNumeric_string;
917 res->u.string = f_string (eh, c);
920 res->which = Z_StringOrNumeric_numeric;
921 res->u.numeric = f_integer (eh, c);
928 Z_AttributeDescription *f_attributeDescription (
929 ExpHandle *eh, data1_node *n)
931 Z_AttributeDescription *res = (Z_AttributeDescription *)
932 odr_malloc(eh->o, sizeof(*res));
937 res->description = 0;
938 res->attributeValue = 0;
939 res->num_equivalentAttributes = 0;
940 res->equivalentAttributes = 0;
942 for (c = n->child; c; c = c->next)
944 switch (is_numeric_tag (eh, c))
946 case 102: res->name = f_string (eh, c); break;
947 case 113: res->description = f_humstring (eh, c); break;
948 case 710: res->attributeValue = f_stringOrNumeric (eh, c); break;
949 case 752: (res->num_equivalentAttributes++); break;
952 if (res->num_equivalentAttributes)
953 res->equivalentAttributes = (Z_StringOrNumeric **)
954 odr_malloc (eh->o, sizeof(*res->equivalentAttributes) *
955 res->num_equivalentAttributes);
956 for (c = n->child; c; c = c->next)
957 if (is_numeric_tag (eh, c) == 752)
958 res->equivalentAttributes[i++] = f_stringOrNumeric (eh, c);
962 Z_AttributeType *f_attributeType (ExpHandle *eh, data1_node *n)
964 Z_AttributeType *res = (Z_AttributeType *)
965 odr_malloc(eh->o, sizeof(*res));
969 res->description = 0;
970 res->attributeType = 0;
971 res->num_attributeValues = 0;
972 res->attributeValues = 0;
974 for (c = n->child; c; c = c->next)
977 switch (is_numeric_tag (eh, c))
979 case 102: res->name = f_string (eh, c); break;
980 case 113: res->description = f_humstring (eh, c); break;
981 case 704: res->attributeType = f_integer (eh, c); break;
983 for (n = c->child; n; n = n->next)
985 if (is_numeric_tag(eh, n) != 709)
987 (res->num_attributeValues)++;
989 if (res->num_attributeValues)
990 res->attributeValues = (Z_AttributeDescription **)
991 odr_malloc (eh->o, res->num_attributeValues
992 * sizeof(*res->attributeValues));
993 for (n = c->child; n; n = n->next)
995 if (is_numeric_tag(eh, n) != 709)
997 res->attributeValues[i++] = f_attributeDescription (eh, n);
1005 Z_AttributeSetInfo *f_attributeSetInfo (ExpHandle *eh, data1_node *n)
1007 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
1008 odr_malloc(eh->o, sizeof(*res));
1011 res->commonInfo = 0;
1012 res->attributeSet = 0;
1014 res->num_attributes = 0;
1015 res->attributes = 0;
1016 res->description = 0;
1017 for (c = n->child; c; c = c->next)
1020 switch (is_numeric_tag (eh, c))
1022 case 600: res->commonInfo = f_commonInfo (eh, c); break;
1023 case 1000: res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1024 case 102: res->name = f_string (eh, c); break;
1026 for (n = c->child; n; n = n->next)
1028 if (is_numeric_tag(eh, n) != 751)
1030 (res->num_attributes)++;
1032 if (res->num_attributes)
1033 res->attributes = (Z_AttributeType **)
1034 odr_malloc (eh->o, res->num_attributes
1035 * sizeof(*res->attributes));
1036 for (n = c->child; n; n = n->next)
1038 if (is_numeric_tag(eh, n) != 751)
1040 res->attributes[i++] = f_attributeType (eh, n);
1043 case 113: res->description = f_humstring (eh, c); break;
1049 Z_OmittedAttributeInterpretation *f_omittedAttributeInterpretation (
1050 ExpHandle *eh, data1_node *n)
1052 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1053 odr_malloc (eh->o, sizeof(*res));
1056 res->defaultValue = 0;
1057 res->defaultDescription = 0;
1058 for (c = n->child; c; c = c->next)
1060 switch (is_numeric_tag (eh, c))
1063 res->defaultValue = f_stringOrNumeric (eh, c);
1066 res->defaultDescription = f_humstring(eh, c);
1073 Z_AttributeValue *f_attributeValue (ExpHandle *eh, data1_node *n)
1075 Z_AttributeValue *res = (Z_AttributeValue *)
1076 odr_malloc (eh->o, sizeof(*res));
1080 res->description = 0;
1081 res->num_subAttributes = 0;
1082 res->subAttributes = 0;
1083 res->num_superAttributes = 0;
1084 res->superAttributes = 0;
1085 res->partialSupport = 0;
1086 for (c = n->child; c; c = c->next)
1089 switch (is_numeric_tag (eh, c))
1092 res->value = f_stringOrNumeric (eh, c); break;
1094 res->description = f_humstring (eh, c); break;
1096 for (n = c->child; n; n = n->next)
1098 if (is_numeric_tag(eh, n) != 713)
1100 (res->num_subAttributes)++;
1102 if (res->num_subAttributes)
1103 res->subAttributes =
1104 (Z_StringOrNumeric **)
1105 odr_malloc (eh->o, res->num_subAttributes
1106 * sizeof(*res->subAttributes));
1107 for (n = c->child; n; n = n->next)
1109 if (is_numeric_tag(eh, n) != 713)
1111 res->subAttributes[i++] = f_stringOrNumeric (eh, n);
1115 for (n = c->child; n; n = n->next)
1117 if (is_numeric_tag(eh, n) != 715)
1119 (res->num_superAttributes)++;
1121 if (res->num_superAttributes)
1122 res->superAttributes =
1123 (Z_StringOrNumeric **)
1124 odr_malloc (eh->o, res->num_superAttributes
1125 * sizeof(*res->superAttributes));
1126 for (n = c->child; n; n = n->next)
1128 if (is_numeric_tag(eh, n) != 715)
1130 res->superAttributes[i++] = f_stringOrNumeric (eh, n);
1134 res->partialSupport = odr_nullval ();
1141 Z_AttributeTypeDetails *f_attributeTypeDetails (ExpHandle *eh, data1_node *n)
1143 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1144 odr_malloc(eh->o, sizeof(*res));
1146 res->attributeType = 0;
1147 res->defaultIfOmitted = 0;
1148 res->num_attributeValues = 0;
1149 res->attributeValues = 0;
1150 for (c = n->child; c; c = c->next)
1153 switch (is_numeric_tag (eh, c))
1155 case 704: res->attributeType = f_integer (eh, c); break;
1157 res->defaultIfOmitted = f_omittedAttributeInterpretation (eh, c);
1160 for (n = c->child; n; n = n->next)
1162 if (is_numeric_tag(eh, n) != 709)
1164 (res->num_attributeValues)++;
1166 if (res->num_attributeValues)
1167 res->attributeValues =
1168 (Z_AttributeValue **)
1169 odr_malloc (eh->o, res->num_attributeValues
1170 * sizeof(*res->attributeValues));
1171 for (n = c->child; n; n = n->next)
1173 if (is_numeric_tag(eh, n) != 709)
1175 res->attributeValues[i++] = f_attributeValue (eh, n);
1183 Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n)
1185 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1186 odr_malloc(eh->o, sizeof(*res));
1189 res->attributeSet = 0;
1190 res->num_attributesByType = 0;
1191 res->attributesByType = 0;
1192 for (c = n->child; c; c = c->next)
1195 switch (is_numeric_tag (eh, c))
1197 case 1000: res->attributeSet = f_oid(eh, c, CLASS_ATTSET); break;
1199 for (n = c->child; n; n = n->next)
1201 if (is_numeric_tag(eh, n) != 703)
1203 (res->num_attributesByType)++;
1205 if (res->num_attributesByType)
1206 res->attributesByType =
1207 (Z_AttributeTypeDetails **)
1208 odr_malloc (eh->o, res->num_attributesByType
1209 * sizeof(*res->attributesByType));
1210 for (n = c->child; n; n = n->next)
1212 if (is_numeric_tag(eh, n) != 703)
1214 res->attributesByType[i++] = f_attributeTypeDetails (eh, n);
1222 Z_AttributeValueList *f_attributeValueList (ExpHandle *eh, data1_node *n)
1224 Z_AttributeValueList *res = (Z_AttributeValueList *)
1225 odr_malloc (eh->o, sizeof(*res));
1229 res->num_attributes = 0;
1230 res->attributes = 0;
1231 for (c = n->child; c; c = c->next)
1232 if (is_numeric_tag (eh, c) == 710)
1233 (res->num_attributes)++;
1234 if (res->num_attributes)
1236 res->attributes = (Z_StringOrNumeric **)
1237 odr_malloc (eh->o, res->num_attributes * sizeof(*res->attributes));
1239 for (c = n->child; c; c = c->next)
1240 if (is_numeric_tag(eh, c) == 710)
1241 res->attributes[i++] = f_stringOrNumeric (eh, c);
1245 Z_AttributeOccurrence *f_attributeOccurrence (ExpHandle *eh, data1_node *n)
1247 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1248 odr_malloc (eh->o, sizeof(*res));
1251 res->attributeSet = 0;
1252 res->attributeType = 0;
1253 res->mustBeSupplied = 0;
1254 res->which = Z_AttributeOcc_any_or_none;
1255 res->attributeValues.any_or_none = odr_nullval ();
1257 for (c = n->child; c; c = c->next)
1259 switch (is_numeric_tag (eh, c))
1262 res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1264 res->attributeType = f_integer (eh, c); break;
1266 res->mustBeSupplied = odr_nullval (); break;
1268 res->which = Z_AttributeOcc_any_or_none;
1269 res->attributeValues.any_or_none = odr_nullval ();
1272 res->which = Z_AttributeOcc_specific;
1273 res->attributeValues.specific = f_attributeValueList (eh, c);
1280 Z_AttributeCombination *f_attributeCombination (ExpHandle *eh, data1_node *n)
1282 Z_AttributeCombination *res = (Z_AttributeCombination *)
1283 odr_malloc (eh->o, sizeof(*res));
1287 res->num_occurrences = 0;
1288 res->occurrences = 0;
1289 for (c = n->child; c; c = c->next)
1290 if (is_numeric_tag (eh, c) == 719)
1291 (res->num_occurrences)++;
1292 if (res->num_occurrences)
1294 res->occurrences = (Z_AttributeOccurrence **)
1295 odr_malloc (eh->o, res->num_occurrences * sizeof(*res->occurrences));
1297 for (c = n->child; c; c = c->next)
1298 if (is_numeric_tag(eh, c) == 719)
1299 res->occurrences[i++] = f_attributeOccurrence (eh, c);
1300 assert (res->num_occurrences);
1304 Z_AttributeCombinations *f_attributeCombinations (ExpHandle *eh, data1_node *n)
1306 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1307 odr_malloc (eh->o, sizeof(*res));
1309 res->defaultAttributeSet = 0;
1310 res->num_legalCombinations = 0;
1311 res->legalCombinations = 0;
1313 for (c = n->child; c; c = c->next)
1316 switch (is_numeric_tag (eh, c))
1319 res->defaultAttributeSet = f_oid (eh, c, CLASS_ATTSET);
1322 for (n = c->child; n; n = n->next)
1324 if (is_numeric_tag(eh, n) != 718)
1326 (res->num_legalCombinations)++;
1328 if (res->num_legalCombinations)
1329 res->legalCombinations =
1330 (Z_AttributeCombination **)
1331 odr_malloc (eh->o, res->num_legalCombinations
1332 * sizeof(*res->legalCombinations));
1333 for (n = c->child; n; n = n->next)
1335 if (is_numeric_tag(eh, n) != 718)
1337 res->legalCombinations[i++] = f_attributeCombination (eh, n);
1342 assert (res->num_legalCombinations);
1346 Z_AttributeDetails *f_attributeDetails (ExpHandle *eh, data1_node *n)
1348 Z_AttributeDetails *res = (Z_AttributeDetails *)
1349 odr_malloc(eh->o, sizeof(*res));
1352 res->commonInfo = 0;
1353 res->databaseName = 0;
1354 res->num_attributesBySet = 0;
1355 res->attributesBySet = NULL;
1356 res->attributeCombinations = NULL;
1358 for (c = n->child; c; c = c->next)
1361 switch (is_numeric_tag (eh, c))
1363 case 600: res->commonInfo = f_commonInfo(eh, c); break;
1364 case 102: res->databaseName = f_string (eh, c); break;
1366 for (n = c->child; n; n = n->next)
1368 if (is_numeric_tag(eh, n) != 701)
1370 (res->num_attributesBySet)++;
1372 if (res->num_attributesBySet)
1373 res->attributesBySet =
1374 (Z_AttributeSetDetails **)
1375 odr_malloc (eh->o, res->num_attributesBySet
1376 * sizeof(*res->attributesBySet));
1377 for (n = c->child; n; n = n->next)
1379 if (is_numeric_tag(eh, n) != 701)
1381 res->attributesBySet[i++] = f_attributeSetDetails (eh, n);
1385 res->attributeCombinations = f_attributeCombinations (eh, c);
1392 Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
1396 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
1401 eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
1402 *eh.false_value = 0;
1403 eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
1406 assert(n->which == DATA1N_root);
1407 if (strcmp(n->u.root.type, "explain"))
1409 logf(LOG_WARN, "Attempt to convert a non-Explain record");
1412 for (n = n->child; n; n = n->next)
1414 switch (is_numeric_tag (&eh, n))
1417 res->which = Z_Explain_categoryList;
1418 if (!(res->u.categoryList = f_categoryList(&eh, n)))
1422 res->which = Z_Explain_targetInfo;
1423 if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
1427 res->which = Z_Explain_databaseInfo;
1428 if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
1432 res->which = Z_Explain_attributeSetInfo;
1433 if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n)))
1437 res->which = Z_Explain_attributeDetails;
1438 if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))
1443 logf(LOG_WARN, "No category in Explain record");