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.13 1998-06-05 08:58:48 adam
8 * Fixed un-initialised var in f_rpnCapabilities.
10 * Revision 1.12 1998/05/18 13:07:04 adam
11 * Changed the way attribute sets are handled by the retriaval module.
12 * Extended Explain conversion / schema.
13 * Modified server and client to work with ASN.1 compiled protocol handlers.
15 * Revision 1.11 1998/04/02 08:27:37 adam
16 * Minor change in definition of Z_TargetInfo. Furhter work on Explain
17 * schema - added AttributeDetails.
19 * Revision 1.10 1998/03/31 15:13:20 adam
20 * Development towards compiled ASN.1.
22 * Revision 1.9 1998/03/05 08:07:58 adam
23 * Make data1 to EXPLAIN ignore local tags in root.
25 * Revision 1.8 1998/02/11 11:53:35 adam
26 * Changed code so that it compiles as C++.
28 * Revision 1.7 1997/12/09 16:18:16 adam
29 * Work on EXPLAIN schema. First implementation of sub-schema facility
32 * Revision 1.6 1997/11/24 11:33:56 adam
33 * Using function odr_nullval() instead of global ODR_NULLVAL when
36 * Revision 1.5 1997/11/19 10:30:06 adam
39 * Revision 1.4 1997/11/18 09:51:08 adam
40 * Removed element num_children from data1_node. Minor changes in
43 * Revision 1.3 1997/09/17 12:10:36 adam
46 * Revision 1.2 1995/12/14 16:28:30 quinn
49 * Revision 1.1 1995/12/14 11:09:51 quinn
72 static int is_numeric_tag (ExpHandle *eh, data1_node *c)
74 if (!c || c->which != DATA1N_tag)
76 if (!c->u.tag.element)
78 logf(LOG_WARN, "Tag %s is local", c->u.tag.tag);
81 if (c->u.tag.element->tag->which != DATA1T_numeric)
83 logf(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
86 if (eh->select && !c->u.tag.node_selected)
88 return c->u.tag.element->tag->value.numeric;
91 static int is_data_tag (ExpHandle *eh, data1_node *c)
93 if (!c || c->which != DATA1N_data)
95 if (eh->select && !c->u.tag.node_selected)
100 static int *f_integer(ExpHandle *eh, data1_node *c)
106 if (!is_data_tag (eh, c) || c->u.data.len > 63)
108 r = (int *)odr_malloc(eh->o, sizeof(*r));
109 sprintf(intbuf, "%.*s", 63, c->u.data.data);
114 static char *f_string(ExpHandle *eh, data1_node *c)
119 if (!is_data_tag (eh, c))
121 r = (char *)odr_malloc(eh->o, c->u.data.len+1);
122 memcpy(r, c->u.data.data, c->u.data.len);
123 r[c->u.data.len] = '\0';
127 static bool_t *f_bool(ExpHandle *eh, data1_node *c)
133 if (!is_data_tag (eh, c) || c->u.data.len > 63)
135 tf = (int *)odr_malloc (eh->o, sizeof(*tf));
136 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
141 static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
145 oid_value value_for_this;
148 if (!is_data_tag (eh, c) || c->u.data.len > 63)
150 sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
151 value_for_this = oid_getvalbyname(oidstr);
152 if (value_for_this == VAL_NONE)
154 Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
162 ident.oclass = oclass;
163 ident.proto = PROTO_Z3950;
164 ident.value = value_for_this;
166 oid_ent_to_oid (&ident, oid_this);
168 return odr_oiddup (eh->o, oid_this);
171 static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
177 static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c)
180 Z_HumanStringUnit *u;
183 if (!is_data_tag (eh, c))
185 r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
187 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
188 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
190 u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
191 memcpy(u->text, c->u.data.data, c->u.data.len);
192 u->text[c->u.data.len] = '\0';
196 static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
198 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
202 res->dateChanged = 0;
204 res->humanStringLanguage = 0;
207 for (c = n->child; c; c = c->next)
209 switch (is_numeric_tag (eh, c))
211 case 601: res->dateAdded = f_string(eh, c); break;
212 case 602: res->dateChanged = f_string(eh, c); break;
213 case 603: res->expiry = f_string(eh, c); break;
214 case 604: res->humanStringLanguage = f_string(eh, c); break;
220 Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
227 for (c = n->child ; c; c = c->next)
228 if (is_numeric_tag (eh, c) == 1000)
232 res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
233 for (c = n->child, i = 0 ; c; c = c->next)
234 if (is_numeric_tag (eh, c) == 1000)
235 res[i++] = f_oid (eh, c, oclass);
239 char **f_string_seq (ExpHandle *eh, data1_node *n, int *num)
246 for (c = n->child ; c; c = c->next)
248 if (is_numeric_tag (eh, c) != 1001)
254 res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
255 for (c = n->child, i = 0 ; c; c = c->next)
257 if (is_numeric_tag (eh, c) != 1001)
259 res[i++] = f_string (eh, c);
264 Z_ProximitySupport *f_proximitySupport (ExpHandle *eh, data1_node *n)
266 Z_ProximitySupport *res = (Z_ProximitySupport *)
267 odr_malloc (eh->o, sizeof(*res));
268 res->anySupport = eh->false_value;
269 res->num_unitsSupported = 0;
270 res->unitsSupported = 0;
274 Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
276 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
277 odr_malloc (eh->o, sizeof(*res));
280 res->num_operators = 0;
281 res->operators = NULL;
282 res->resultSetAsOperandSupported = eh->false_value;
283 res->restrictionOperandSupported = eh->false_value;
284 res->proximity = NULL;
286 for (c = n->child; n; c = c->next)
289 switch (is_numeric_tag(eh, c))
292 for (n = c->child; n; n = n->next)
294 if (is_numeric_tag(eh, n) != 551)
296 (res->num_operators)++;
298 if (res->num_operators)
299 res->operators = (int **)
300 odr_malloc (eh->o, res->num_operators
301 * sizeof(*res->operators));
302 for (n = c->child; n; n = n->next)
304 if (is_numeric_tag(eh, n) != 551)
306 res->operators[i++] = f_integer (eh, n);
310 res->resultSetAsOperandSupported = f_bool (eh, c);
313 res->restrictionOperandSupported = f_bool (eh, c);
316 res->proximity = f_proximitySupport (eh, c);
323 Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
325 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
326 odr_malloc(eh->o, sizeof(*res));
329 res->which = Z_QueryTypeDetails_rpn;
331 for (c = n->child; c; c = c->next)
333 switch (is_numeric_tag(eh, n))
336 res->which = Z_QueryTypeDetails_rpn;
337 res->u.rpn = f_rpnCapabilities (eh, c);
348 static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
350 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
353 res->num_queryTypesSupported = 0;
354 res->queryTypesSupported = 0;
355 res->num_diagnosticsSets = 0;
356 res->diagnosticsSets = 0;
357 res->num_attributeSetIds = 0;
358 res->attributeSetIds = 0;
359 res->num_schemas = 0;
361 res->num_recordSyntaxes = 0;
362 res->recordSyntaxes = 0;
363 res->num_resourceChallenges = 0;
364 res->resourceChallenges = 0;
365 res->restrictedAccess = 0;
367 res->num_variantSets = 0;
368 res->variantSets = 0;
369 res->num_elementSetNames = 0;
370 res->elementSetNames = 0;
371 res->num_unitSystems = 0;
372 res->unitSystems = 0;
374 for (c = n->child; c; c = c->next)
377 switch (is_numeric_tag (eh, c))
380 for (n = c->child; n; n = n->next)
382 if (is_numeric_tag(eh, n) != 518)
384 (res->num_queryTypesSupported)++;
386 if (res->num_queryTypesSupported)
387 res->queryTypesSupported =
388 (Z_QueryTypeDetails **)
389 odr_malloc (eh->o, res->num_queryTypesSupported
390 * sizeof(*res->queryTypesSupported));
391 for (n = c->child; n; n = n->next)
393 if (is_numeric_tag(eh, n) != 518)
395 res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
399 res->diagnosticsSets =
400 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
403 res->attributeSetIds =
404 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
408 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
411 res->recordSyntaxes =
412 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
415 res->resourceChallenges =
416 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
418 case 513: res->restrictedAccess = NULL; break; /* fix */
419 case 514: res->costInfo = NULL; break; /* fix */
422 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
425 res->elementSetNames =
426 f_string_seq (eh, c, &res->num_elementSetNames);
429 res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
436 static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
438 int *r= (int *)odr_malloc(eh->o, sizeof(*r));
443 if (!is_numeric_tag (eh, c))
445 if (c->u.tag.element->tag->value.numeric == 210)
446 *wp = Z_DatabaseInfo_actualNumber;
447 else if (c->u.tag.element->tag->value.numeric == 211)
448 *wp = Z_DatabaseInfo_approxNumber;
451 if (!c->child || c->child->which != DATA1N_data)
453 sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
458 static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
460 Z_ContactInfo *res = (Z_ContactInfo *)
461 odr_malloc (eh->o, sizeof(*res));
465 res->description = 0;
470 for (c = n->child; c; c = c->next)
472 switch (is_numeric_tag (eh, c))
474 case 102: res->name = f_string (eh, c); break;
475 case 113: res->description = f_humstring (eh, c); break;
476 case 127: res->address = f_humstring (eh, c); break;
477 case 128: res->email = f_string (eh, c); break;
478 case 129: res->phone = f_string (eh, c); break;
484 static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
490 for (c = n->child; c; c = c->next)
492 if (!is_numeric_tag (eh, c) != 102)
499 res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
501 res->num_databases = i;
502 res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
504 for (c = n->child; c; c = c->next)
506 if (!is_numeric_tag (eh, c) != 102)
508 res->databases[i++] = f_string (eh, c);
513 static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
515 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
516 odr_malloc (eh->o, sizeof(*res));
519 res->hostAddress = 0;
522 for (c = n->child; c; c = c->next)
524 switch (is_numeric_tag (eh, c))
526 case 121: res->hostAddress = f_string (eh, c); break;
527 case 122: res->port = f_integer (eh, c); break;
533 static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
536 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
537 odr_malloc (eh->o, sizeof(*res));
543 for (c = n->child; c; c = c->next)
545 switch (is_numeric_tag (eh, c))
547 case 124: res->type = f_string (eh, c); break;
548 case 121: res->address = f_string (eh, c); break;
554 static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
557 Z_NetworkAddress **res = NULL;
562 for (c = n->child; c; c = c->next)
564 switch (is_numeric_tag (eh, c))
574 res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
576 for (c = n->child; c; c = c->next)
578 switch (is_numeric_tag (eh, c))
581 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
582 res[i]->which = Z_NetworkAddress_iA;
583 res[i]->u.internetAddress = f_networkAddressIA(eh, c);
587 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
588 res[i]->which = Z_NetworkAddress_other;
589 res[i]->u.other = f_networkAddressOther(eh, c);
597 static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
599 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
603 res->originalCategory = 0;
604 res->description = 0;
606 for (c = n->child; c; c = c->next)
608 switch (is_numeric_tag (eh, c))
610 case 102: res->category = f_string(eh, c); break;
611 case 302: res->originalCategory = f_string(eh, c); break;
612 case 113: res->description = f_humstring(eh, c); break;
613 case 303: res->asn1Module = f_string (eh, c); break;
619 static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
621 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
625 res->num_categories = 0;
626 res->categories = NULL;
628 for (c = n->child; c; c = c->next)
632 switch (is_numeric_tag (eh, c))
634 case 600: res->commonInfo = f_commonInfo(eh, c); break;
636 for (n = c->child; n; n = n->next)
638 if (is_numeric_tag(eh, n) != 301)
640 (res->num_categories)++;
642 if (res->num_categories)
644 (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
645 * sizeof(*res->categories));
646 for (n = c->child; n; n = n->next)
648 if (is_numeric_tag(eh, n) != 301)
650 res->categories[i++] = f_categoryInfo (eh, n);
655 assert (res->num_categories && res->categories);
659 static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
661 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
668 res->namedResultSets = 0;
669 res->multipleDBsearch = 0;
670 res->maxResultSets = 0;
671 res->maxResultSize = 0;
673 res->timeoutInterval = 0;
674 res->welcomeMessage = 0;
675 res->contactInfo = 0;
676 res->description = 0;
677 res->num_nicknames = 0;
680 res->paymentAddr = 0;
682 res->num_dbCombinations = 0;
683 res->dbCombinations = 0;
684 res->num_addresses = 0;
686 res->num_languages = 0;
687 res->languages = NULL;
688 res->commonAccessInfo = 0;
690 for (c = n->child; c; c = c->next)
694 switch (is_numeric_tag (eh, c))
696 case 600: res->commonInfo = f_commonInfo(eh, c); break;
697 case 102: res->name = f_string(eh, c); break;
698 case 103: res->recentNews = f_humstring(eh, c); break;
699 case 104: res->icon = NULL; break; /* fix */
700 case 105: res->namedResultSets = f_bool(eh, c); break;
701 case 106: res->multipleDBsearch = f_bool(eh, c); break;
702 case 107: res->maxResultSets = f_integer(eh, c); break;
703 case 108: res->maxResultSize = f_integer(eh, c); break;
704 case 109: res->maxTerms = f_integer(eh, c); break;
705 case 110: res->timeoutInterval = f_intunit(eh, c); break;
706 case 111: res->welcomeMessage = f_humstring(eh, c); break;
707 case 112: res->contactInfo = f_contactInfo(eh, c); break;
708 case 113: res->description = f_humstring(eh, c); break;
710 res->num_nicknames = 0;
711 for (n = c->child; n; n = n->next)
713 if (is_numeric_tag(eh, n) != 102)
715 (res->num_nicknames)++;
717 if (res->num_nicknames)
719 (char **)odr_malloc (eh->o, res->num_nicknames
720 * sizeof(*res->nicknames));
721 for (n = c->child; n; n = n->next)
723 if (is_numeric_tag(eh, n) != 102)
725 res->nicknames[i++] = f_string (eh, n);
728 case 115: res->usageRest = f_humstring(eh, c); break;
729 case 116: res->paymentAddr = f_humstring(eh, c); break;
730 case 117: res->hours = f_humstring(eh, c); break;
732 res->num_dbCombinations = 0;
733 for (n = c->child; n; n = n->next)
735 if (!is_numeric_tag(eh, n) != 605)
737 (res->num_dbCombinations)++;
739 if (res->num_dbCombinations)
740 res->dbCombinations =
741 (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
742 * sizeof(*res->dbCombinations));
743 for (n = c->child; n; n = n->next)
745 if (!is_numeric_tag(eh, n) != 605)
747 res->dbCombinations[i++] = f_databaseList (eh, n);
752 f_networkAddresses (eh, c, &res->num_addresses);
755 res->num_languages = 0;
756 for (n = c->child; n; n = n->next)
758 if (!is_numeric_tag(eh, n) != 126)
760 (res->num_languages)++;
762 if (res->num_languages)
763 res->languages = (char **)
764 odr_malloc (eh->o, res->num_languages *
765 sizeof(*res->languages));
766 for (n = c->child; n; n = n->next)
768 if (!is_numeric_tag(eh, n) != 126)
770 res->languages[i++] = f_string (eh, n);
773 case 500: res->commonAccessInfo = f_accessInfo(eh, c); break;
776 if (!res->namedResultSets)
777 res->namedResultSets = eh->false_value;
778 if (!res->multipleDBsearch)
779 res->multipleDBsearch = eh->false_value;
783 static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
785 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
790 res->explainDatabase = 0;
791 res->num_nicknames = 0;
796 res->titleString = 0;
797 res->num_keywords = 0;
799 res->description = 0;
800 res->associatedDbs = 0;
802 res->disclaimers = 0;
804 res->u.actualNumber = 0;
805 res->defaultOrder = 0;
806 res->avRecordSize = 0;
807 res->maxRecordSize = 0;
811 res->updateInterval = 0;
813 res->proprietary = 0;
814 res->copyrightText = 0;
815 res->copyrightNotice = 0;
816 res->producerContactInfo = 0;
817 res->supplierContactInfo = 0;
818 res->submissionContactInfo = 0;
821 for (c = n->child; c; c = c->next)
825 switch (is_numeric_tag (eh, c))
827 case 600: res->commonInfo = f_commonInfo(eh, c); break;
828 case 102: res->name = f_string(eh, c); break;
829 case 226: res->explainDatabase = odr_nullval(); break;
831 res->num_nicknames = 0;
832 for (n = c->child; n; n = n->next)
834 if (!is_numeric_tag(eh, n) ||
835 n->u.tag.element->tag->value.numeric != 102)
837 (res->num_nicknames)++;
839 if (res->num_nicknames)
841 (char **)odr_malloc (eh->o, res->num_nicknames
842 * sizeof(*res->nicknames));
843 for (n = c->child; n; n = n->next)
845 if (!is_numeric_tag(eh, n) ||
846 n->u.tag.element->tag->value.numeric != 102)
848 res->nicknames[i++] = f_string (eh, n);
851 case 104: res->icon = 0; break; /* fix */
852 case 201: res->userFee = f_bool(eh, c); break;
853 case 202: res->available = f_bool(eh, c); break;
854 case 203: res->titleString = f_humstring(eh, c); break;
856 res->num_keywords = 0;
857 for (n = c->child; n; n = n->next)
859 if (!is_numeric_tag(eh, n) != 1000)
861 (res->num_keywords)++;
863 if (res->num_keywords)
865 (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
866 * sizeof(*res->keywords));
867 for (n = c->child; n; n = n->next)
869 if (!is_numeric_tag(eh, n) != 1000)
871 res->keywords[i++] = f_humstring (eh, n);
874 case 113: res->description = f_humstring(eh, c); break;
876 res->associatedDbs = f_databaseList (eh, c);
879 res->subDbs = f_databaseList (eh, c);
881 case 207: res->disclaimers = f_humstring(eh, c); break;
882 case 103: res->news = f_humstring(eh, c); break;
883 case 209: res->u.actualNumber =
884 f_recordCount(eh, c, &res->which); break;
885 case 212: res->defaultOrder = f_humstring(eh, c); break;
886 case 213: res->avRecordSize = f_integer(eh, c); break;
887 case 214: res->maxRecordSize = f_integer(eh, c); break;
888 case 215: res->hours = f_humstring(eh, c); break;
889 case 216: res->bestTime = f_humstring(eh, c); break;
890 case 217: res->lastUpdate = f_string(eh, c); break;
891 case 218: res->updateInterval = f_intunit(eh, c); break;
892 case 219: res->coverage = f_humstring(eh, c); break;
893 case 220: res->proprietary = f_bool(eh, c); break;
894 case 221: res->copyrightText = f_humstring(eh, c); break;
895 case 222: res->copyrightNotice = f_humstring(eh, c); break;
896 case 223: res->producerContactInfo = f_contactInfo(eh, c); break;
897 case 224: res->supplierContactInfo = f_contactInfo(eh, c); break;
898 case 225: res->submissionContactInfo = f_contactInfo(eh, c); break;
899 case 500: res->accessInfo = f_accessInfo(eh, c); break;
903 res->userFee = eh->false_value;
905 res->available = eh->true_value;
909 Z_StringOrNumeric *f_stringOrNumeric (ExpHandle *eh, data1_node *n)
911 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
912 odr_malloc (eh->o, sizeof(*res));
914 for (c = n->child; c; c = c->next)
916 switch (is_numeric_tag (eh, c))
919 res->which = Z_StringOrNumeric_string;
920 res->u.string = f_string (eh, c);
923 res->which = Z_StringOrNumeric_numeric;
924 res->u.numeric = f_integer (eh, c);
931 Z_AttributeDescription *f_attributeDescription (
932 ExpHandle *eh, data1_node *n)
934 Z_AttributeDescription *res = (Z_AttributeDescription *)
935 odr_malloc(eh->o, sizeof(*res));
940 res->description = 0;
941 res->attributeValue = 0;
942 res->num_equivalentAttributes = 0;
943 res->equivalentAttributes = 0;
945 for (c = n->child; c; c = c->next)
947 switch (is_numeric_tag (eh, c))
949 case 102: res->name = f_string (eh, c); break;
950 case 113: res->description = f_humstring (eh, c); break;
951 case 710: res->attributeValue = f_stringOrNumeric (eh, c); break;
952 case 752: (res->num_equivalentAttributes++); break;
955 if (res->num_equivalentAttributes)
956 res->equivalentAttributes = (Z_StringOrNumeric **)
957 odr_malloc (eh->o, sizeof(*res->equivalentAttributes) *
958 res->num_equivalentAttributes);
959 for (c = n->child; c; c = c->next)
960 if (is_numeric_tag (eh, c) == 752)
961 res->equivalentAttributes[i++] = f_stringOrNumeric (eh, c);
965 Z_AttributeType *f_attributeType (ExpHandle *eh, data1_node *n)
967 Z_AttributeType *res = (Z_AttributeType *)
968 odr_malloc(eh->o, sizeof(*res));
972 res->description = 0;
973 res->attributeType = 0;
974 res->num_attributeValues = 0;
975 res->attributeValues = 0;
977 for (c = n->child; c; c = c->next)
980 switch (is_numeric_tag (eh, c))
982 case 102: res->name = f_string (eh, c); break;
983 case 113: res->description = f_humstring (eh, c); break;
984 case 704: res->attributeType = f_integer (eh, c); break;
986 for (n = c->child; n; n = n->next)
988 if (is_numeric_tag(eh, n) != 709)
990 (res->num_attributeValues)++;
992 if (res->num_attributeValues)
993 res->attributeValues = (Z_AttributeDescription **)
994 odr_malloc (eh->o, res->num_attributeValues
995 * sizeof(*res->attributeValues));
996 for (n = c->child; n; n = n->next)
998 if (is_numeric_tag(eh, n) != 709)
1000 res->attributeValues[i++] = f_attributeDescription (eh, n);
1008 Z_AttributeSetInfo *f_attributeSetInfo (ExpHandle *eh, data1_node *n)
1010 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
1011 odr_malloc(eh->o, sizeof(*res));
1014 res->commonInfo = 0;
1015 res->attributeSet = 0;
1017 res->num_attributes = 0;
1018 res->attributes = 0;
1019 res->description = 0;
1020 for (c = n->child; c; c = c->next)
1023 switch (is_numeric_tag (eh, c))
1025 case 600: res->commonInfo = f_commonInfo (eh, c); break;
1026 case 1000: res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1027 case 102: res->name = f_string (eh, c); break;
1029 for (n = c->child; n; n = n->next)
1031 if (is_numeric_tag(eh, n) != 751)
1033 (res->num_attributes)++;
1035 if (res->num_attributes)
1036 res->attributes = (Z_AttributeType **)
1037 odr_malloc (eh->o, res->num_attributes
1038 * sizeof(*res->attributes));
1039 for (n = c->child; n; n = n->next)
1041 if (is_numeric_tag(eh, n) != 751)
1043 res->attributes[i++] = f_attributeType (eh, n);
1046 case 113: res->description = f_humstring (eh, c); break;
1052 Z_OmittedAttributeInterpretation *f_omittedAttributeInterpretation (
1053 ExpHandle *eh, data1_node *n)
1055 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1056 odr_malloc (eh->o, sizeof(*res));
1059 res->defaultValue = 0;
1060 res->defaultDescription = 0;
1061 for (c = n->child; c; c = c->next)
1063 switch (is_numeric_tag (eh, c))
1066 res->defaultValue = f_stringOrNumeric (eh, c);
1069 res->defaultDescription = f_humstring(eh, c);
1076 Z_AttributeValue *f_attributeValue (ExpHandle *eh, data1_node *n)
1078 Z_AttributeValue *res = (Z_AttributeValue *)
1079 odr_malloc (eh->o, sizeof(*res));
1083 res->description = 0;
1084 res->num_subAttributes = 0;
1085 res->subAttributes = 0;
1086 res->num_superAttributes = 0;
1087 res->superAttributes = 0;
1088 res->partialSupport = 0;
1089 for (c = n->child; c; c = c->next)
1092 switch (is_numeric_tag (eh, c))
1095 res->value = f_stringOrNumeric (eh, c); break;
1097 res->description = f_humstring (eh, c); break;
1099 for (n = c->child; n; n = n->next)
1101 if (is_numeric_tag(eh, n) != 713)
1103 (res->num_subAttributes)++;
1105 if (res->num_subAttributes)
1106 res->subAttributes =
1107 (Z_StringOrNumeric **)
1108 odr_malloc (eh->o, res->num_subAttributes
1109 * sizeof(*res->subAttributes));
1110 for (n = c->child; n; n = n->next)
1112 if (is_numeric_tag(eh, n) != 713)
1114 res->subAttributes[i++] = f_stringOrNumeric (eh, n);
1118 for (n = c->child; n; n = n->next)
1120 if (is_numeric_tag(eh, n) != 715)
1122 (res->num_superAttributes)++;
1124 if (res->num_superAttributes)
1125 res->superAttributes =
1126 (Z_StringOrNumeric **)
1127 odr_malloc (eh->o, res->num_superAttributes
1128 * sizeof(*res->superAttributes));
1129 for (n = c->child; n; n = n->next)
1131 if (is_numeric_tag(eh, n) != 715)
1133 res->superAttributes[i++] = f_stringOrNumeric (eh, n);
1137 res->partialSupport = odr_nullval ();
1144 Z_AttributeTypeDetails *f_attributeTypeDetails (ExpHandle *eh, data1_node *n)
1146 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1147 odr_malloc(eh->o, sizeof(*res));
1149 res->attributeType = 0;
1150 res->defaultIfOmitted = 0;
1151 res->num_attributeValues = 0;
1152 res->attributeValues = 0;
1153 for (c = n->child; c; c = c->next)
1156 switch (is_numeric_tag (eh, c))
1158 case 704: res->attributeType = f_integer (eh, c); break;
1160 res->defaultIfOmitted = f_omittedAttributeInterpretation (eh, c);
1163 for (n = c->child; n; n = n->next)
1165 if (is_numeric_tag(eh, n) != 709)
1167 (res->num_attributeValues)++;
1169 if (res->num_attributeValues)
1170 res->attributeValues =
1171 (Z_AttributeValue **)
1172 odr_malloc (eh->o, res->num_attributeValues
1173 * sizeof(*res->attributeValues));
1174 for (n = c->child; n; n = n->next)
1176 if (is_numeric_tag(eh, n) != 709)
1178 res->attributeValues[i++] = f_attributeValue (eh, n);
1186 Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n)
1188 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1189 odr_malloc(eh->o, sizeof(*res));
1192 res->attributeSet = 0;
1193 res->num_attributesByType = 0;
1194 res->attributesByType = 0;
1195 for (c = n->child; c; c = c->next)
1198 switch (is_numeric_tag (eh, c))
1200 case 1000: res->attributeSet = f_oid(eh, c, CLASS_ATTSET); break;
1202 for (n = c->child; n; n = n->next)
1204 if (is_numeric_tag(eh, n) != 703)
1206 (res->num_attributesByType)++;
1208 if (res->num_attributesByType)
1209 res->attributesByType =
1210 (Z_AttributeTypeDetails **)
1211 odr_malloc (eh->o, res->num_attributesByType
1212 * sizeof(*res->attributesByType));
1213 for (n = c->child; n; n = n->next)
1215 if (is_numeric_tag(eh, n) != 703)
1217 res->attributesByType[i++] = f_attributeTypeDetails (eh, n);
1225 Z_AttributeValueList *f_attributeValueList (ExpHandle *eh, data1_node *n)
1227 Z_AttributeValueList *res = (Z_AttributeValueList *)
1228 odr_malloc (eh->o, sizeof(*res));
1232 res->num_attributes = 0;
1233 res->attributes = 0;
1234 for (c = n->child; c; c = c->next)
1235 if (is_numeric_tag (eh, c) == 710)
1236 (res->num_attributes)++;
1237 if (res->num_attributes)
1239 res->attributes = (Z_StringOrNumeric **)
1240 odr_malloc (eh->o, res->num_attributes * sizeof(*res->attributes));
1242 for (c = n->child; c; c = c->next)
1243 if (is_numeric_tag(eh, c) == 710)
1244 res->attributes[i++] = f_stringOrNumeric (eh, c);
1248 Z_AttributeOccurrence *f_attributeOccurrence (ExpHandle *eh, data1_node *n)
1250 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1251 odr_malloc (eh->o, sizeof(*res));
1254 res->attributeSet = 0;
1255 res->attributeType = 0;
1256 res->mustBeSupplied = 0;
1257 res->which = Z_AttributeOcc_any_or_none;
1258 res->attributeValues.any_or_none = odr_nullval ();
1260 for (c = n->child; c; c = c->next)
1262 switch (is_numeric_tag (eh, c))
1265 res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1267 res->attributeType = f_integer (eh, c); break;
1269 res->mustBeSupplied = odr_nullval (); break;
1271 res->which = Z_AttributeOcc_any_or_none;
1272 res->attributeValues.any_or_none = odr_nullval ();
1275 res->which = Z_AttributeOcc_specific;
1276 res->attributeValues.specific = f_attributeValueList (eh, c);
1283 Z_AttributeCombination *f_attributeCombination (ExpHandle *eh, data1_node *n)
1285 Z_AttributeCombination *res = (Z_AttributeCombination *)
1286 odr_malloc (eh->o, sizeof(*res));
1290 res->num_occurrences = 0;
1291 res->occurrences = 0;
1292 for (c = n->child; c; c = c->next)
1293 if (is_numeric_tag (eh, c) == 719)
1294 (res->num_occurrences)++;
1295 if (res->num_occurrences)
1297 res->occurrences = (Z_AttributeOccurrence **)
1298 odr_malloc (eh->o, res->num_occurrences * sizeof(*res->occurrences));
1300 for (c = n->child; c; c = c->next)
1301 if (is_numeric_tag(eh, c) == 719)
1302 res->occurrences[i++] = f_attributeOccurrence (eh, c);
1303 assert (res->num_occurrences);
1307 Z_AttributeCombinations *f_attributeCombinations (ExpHandle *eh, data1_node *n)
1309 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1310 odr_malloc (eh->o, sizeof(*res));
1312 res->defaultAttributeSet = 0;
1313 res->num_legalCombinations = 0;
1314 res->legalCombinations = 0;
1316 for (c = n->child; c; c = c->next)
1319 switch (is_numeric_tag (eh, c))
1322 res->defaultAttributeSet = f_oid (eh, c, CLASS_ATTSET);
1325 for (n = c->child; n; n = n->next)
1327 if (is_numeric_tag(eh, n) != 718)
1329 (res->num_legalCombinations)++;
1331 if (res->num_legalCombinations)
1332 res->legalCombinations =
1333 (Z_AttributeCombination **)
1334 odr_malloc (eh->o, res->num_legalCombinations
1335 * sizeof(*res->legalCombinations));
1336 for (n = c->child; n; n = n->next)
1338 if (is_numeric_tag(eh, n) != 718)
1340 res->legalCombinations[i++] = f_attributeCombination (eh, n);
1345 assert (res->num_legalCombinations);
1349 Z_AttributeDetails *f_attributeDetails (ExpHandle *eh, data1_node *n)
1351 Z_AttributeDetails *res = (Z_AttributeDetails *)
1352 odr_malloc(eh->o, sizeof(*res));
1355 res->commonInfo = 0;
1356 res->databaseName = 0;
1357 res->num_attributesBySet = 0;
1358 res->attributesBySet = NULL;
1359 res->attributeCombinations = NULL;
1361 for (c = n->child; c; c = c->next)
1364 switch (is_numeric_tag (eh, c))
1366 case 600: res->commonInfo = f_commonInfo(eh, c); break;
1367 case 102: res->databaseName = f_string (eh, c); break;
1369 for (n = c->child; n; n = n->next)
1371 if (is_numeric_tag(eh, n) != 701)
1373 (res->num_attributesBySet)++;
1375 if (res->num_attributesBySet)
1376 res->attributesBySet =
1377 (Z_AttributeSetDetails **)
1378 odr_malloc (eh->o, res->num_attributesBySet
1379 * sizeof(*res->attributesBySet));
1380 for (n = c->child; n; n = n->next)
1382 if (is_numeric_tag(eh, n) != 701)
1384 res->attributesBySet[i++] = f_attributeSetDetails (eh, n);
1388 res->attributeCombinations = f_attributeCombinations (eh, c);
1395 Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
1399 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
1404 eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
1405 *eh.false_value = 0;
1406 eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
1409 assert(n->which == DATA1N_root);
1410 if (strcmp(n->u.root.type, "explain"))
1412 logf(LOG_WARN, "Attempt to convert a non-Explain record");
1415 for (n = n->child; n; n = n->next)
1417 switch (is_numeric_tag (&eh, n))
1420 res->which = Z_Explain_categoryList;
1421 if (!(res->u.categoryList = f_categoryList(&eh, n)))
1425 res->which = Z_Explain_targetInfo;
1426 if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
1430 res->which = Z_Explain_databaseInfo;
1431 if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
1435 res->which = Z_Explain_attributeSetInfo;
1436 if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n)))
1440 res->which = Z_Explain_attributeDetails;
1441 if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))
1446 logf(LOG_WARN, "No category in Explain record");