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.15 1998-09-28 12:44:40 adam
8 * Fixed bug in f_integer.
10 * Revision 1.14 1998/06/08 14:26:41 adam
11 * Fixed bug in f_queryTypeDetails.
13 * Revision 1.13 1998/06/05 08:58:48 adam
14 * Fixed un-initialised var in f_rpnCapabilities.
16 * Revision 1.12 1998/05/18 13:07:04 adam
17 * Changed the way attribute sets are handled by the retriaval module.
18 * Extended Explain conversion / schema.
19 * Modified server and client to work with ASN.1 compiled protocol handlers.
21 * Revision 1.11 1998/04/02 08:27:37 adam
22 * Minor change in definition of Z_TargetInfo. Furhter work on Explain
23 * schema - added AttributeDetails.
25 * Revision 1.10 1998/03/31 15:13:20 adam
26 * Development towards compiled ASN.1.
28 * Revision 1.9 1998/03/05 08:07:58 adam
29 * Make data1 to EXPLAIN ignore local tags in root.
31 * Revision 1.8 1998/02/11 11:53:35 adam
32 * Changed code so that it compiles as C++.
34 * Revision 1.7 1997/12/09 16:18:16 adam
35 * Work on EXPLAIN schema. First implementation of sub-schema facility
38 * Revision 1.6 1997/11/24 11:33:56 adam
39 * Using function odr_nullval() instead of global ODR_NULLVAL when
42 * Revision 1.5 1997/11/19 10:30:06 adam
45 * Revision 1.4 1997/11/18 09:51:08 adam
46 * Removed element num_children from data1_node. Minor changes in
49 * Revision 1.3 1997/09/17 12:10:36 adam
52 * Revision 1.2 1995/12/14 16:28:30 quinn
55 * Revision 1.1 1995/12/14 11:09:51 quinn
78 static int is_numeric_tag (ExpHandle *eh, data1_node *c)
80 if (!c || c->which != DATA1N_tag)
82 if (!c->u.tag.element)
84 logf(LOG_WARN, "Tag %s is local", c->u.tag.tag);
87 if (c->u.tag.element->tag->which != DATA1T_numeric)
89 logf(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
92 if (eh->select && !c->u.tag.node_selected)
94 return c->u.tag.element->tag->value.numeric;
97 static int is_data_tag (ExpHandle *eh, data1_node *c)
99 if (!c || c->which != DATA1N_data)
101 if (eh->select && !c->u.tag.node_selected)
106 static int *f_integer(ExpHandle *eh, data1_node *c)
112 if (!is_data_tag (eh, c) || c->u.data.len > 63)
114 r = (int *)odr_malloc(eh->o, sizeof(*r));
115 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
120 static char *f_string(ExpHandle *eh, data1_node *c)
125 if (!is_data_tag (eh, c))
127 r = (char *)odr_malloc(eh->o, c->u.data.len+1);
128 memcpy(r, c->u.data.data, c->u.data.len);
129 r[c->u.data.len] = '\0';
133 static bool_t *f_bool(ExpHandle *eh, data1_node *c)
139 if (!is_data_tag (eh, c) || c->u.data.len > 63)
141 tf = (int *)odr_malloc (eh->o, sizeof(*tf));
142 sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
147 static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
151 oid_value value_for_this;
154 if (!is_data_tag (eh, c) || c->u.data.len > 63)
156 sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
157 value_for_this = oid_getvalbyname(oidstr);
158 if (value_for_this == VAL_NONE)
160 Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
168 ident.oclass = oclass;
169 ident.proto = PROTO_Z3950;
170 ident.value = value_for_this;
172 oid_ent_to_oid (&ident, oid_this);
174 return odr_oiddup (eh->o, oid_this);
177 static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
183 static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c)
186 Z_HumanStringUnit *u;
189 if (!is_data_tag (eh, c))
191 r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
193 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
194 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
196 u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
197 memcpy(u->text, c->u.data.data, c->u.data.len);
198 u->text[c->u.data.len] = '\0';
202 static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
204 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
208 res->dateChanged = 0;
210 res->humanStringLanguage = 0;
213 for (c = n->child; c; c = c->next)
215 switch (is_numeric_tag (eh, c))
217 case 601: res->dateAdded = f_string(eh, c); break;
218 case 602: res->dateChanged = f_string(eh, c); break;
219 case 603: res->expiry = f_string(eh, c); break;
220 case 604: res->humanStringLanguage = f_string(eh, c); break;
226 Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
233 for (c = n->child ; c; c = c->next)
234 if (is_numeric_tag (eh, c) == 1000)
238 res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
239 for (c = n->child, i = 0 ; c; c = c->next)
240 if (is_numeric_tag (eh, c) == 1000)
241 res[i++] = f_oid (eh, c, oclass);
245 char **f_string_seq (ExpHandle *eh, data1_node *n, int *num)
252 for (c = n->child ; c; c = c->next)
254 if (is_numeric_tag (eh, c) != 1001)
260 res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
261 for (c = n->child, i = 0 ; c; c = c->next)
263 if (is_numeric_tag (eh, c) != 1001)
265 res[i++] = f_string (eh, c);
270 Z_ProximitySupport *f_proximitySupport (ExpHandle *eh, data1_node *n)
272 Z_ProximitySupport *res = (Z_ProximitySupport *)
273 odr_malloc (eh->o, sizeof(*res));
274 res->anySupport = eh->false_value;
275 res->num_unitsSupported = 0;
276 res->unitsSupported = 0;
280 Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
282 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
283 odr_malloc (eh->o, sizeof(*res));
286 res->num_operators = 0;
287 res->operators = NULL;
288 res->resultSetAsOperandSupported = eh->false_value;
289 res->restrictionOperandSupported = eh->false_value;
290 res->proximity = NULL;
292 for (c = n->child; c; c = c->next)
295 switch (is_numeric_tag(eh, c))
298 for (n = c->child; n; n = n->next)
300 if (is_numeric_tag(eh, n) != 551)
302 (res->num_operators)++;
304 if (res->num_operators)
305 res->operators = (int **)
306 odr_malloc (eh->o, res->num_operators
307 * sizeof(*res->operators));
308 for (n = c->child; n; n = n->next)
310 if (is_numeric_tag(eh, n) != 551)
312 res->operators[i++] = f_integer (eh, n);
316 res->resultSetAsOperandSupported = f_bool (eh, c);
319 res->restrictionOperandSupported = f_bool (eh, c);
322 res->proximity = f_proximitySupport (eh, c);
329 Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
331 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
332 odr_malloc(eh->o, sizeof(*res));
335 res->which = Z_QueryTypeDetails_rpn;
337 for (c = n->child; c; c = c->next)
339 switch (is_numeric_tag(eh, c))
342 res->which = Z_QueryTypeDetails_rpn;
343 res->u.rpn = f_rpnCapabilities (eh, c);
354 static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
356 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
359 res->num_queryTypesSupported = 0;
360 res->queryTypesSupported = 0;
361 res->num_diagnosticsSets = 0;
362 res->diagnosticsSets = 0;
363 res->num_attributeSetIds = 0;
364 res->attributeSetIds = 0;
365 res->num_schemas = 0;
367 res->num_recordSyntaxes = 0;
368 res->recordSyntaxes = 0;
369 res->num_resourceChallenges = 0;
370 res->resourceChallenges = 0;
371 res->restrictedAccess = 0;
373 res->num_variantSets = 0;
374 res->variantSets = 0;
375 res->num_elementSetNames = 0;
376 res->elementSetNames = 0;
377 res->num_unitSystems = 0;
378 res->unitSystems = 0;
380 for (c = n->child; c; c = c->next)
383 switch (is_numeric_tag (eh, c))
386 for (n = c->child; n; n = n->next)
388 if (is_numeric_tag(eh, n) != 518)
390 (res->num_queryTypesSupported)++;
392 if (res->num_queryTypesSupported)
393 res->queryTypesSupported =
394 (Z_QueryTypeDetails **)
395 odr_malloc (eh->o, res->num_queryTypesSupported
396 * sizeof(*res->queryTypesSupported));
397 for (n = c->child; n; n = n->next)
399 if (is_numeric_tag(eh, n) != 518)
401 res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
405 res->diagnosticsSets =
406 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
409 res->attributeSetIds =
410 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
414 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
417 res->recordSyntaxes =
418 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
421 res->resourceChallenges =
422 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
424 case 513: res->restrictedAccess = NULL; break; /* fix */
425 case 514: res->costInfo = NULL; break; /* fix */
428 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
431 res->elementSetNames =
432 f_string_seq (eh, c, &res->num_elementSetNames);
435 res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
442 static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
444 int *r= (int *)odr_malloc(eh->o, sizeof(*r));
449 if (!is_numeric_tag (eh, c))
451 if (c->u.tag.element->tag->value.numeric == 210)
452 *wp = Z_DatabaseInfo_actualNumber;
453 else if (c->u.tag.element->tag->value.numeric == 211)
454 *wp = Z_DatabaseInfo_approxNumber;
457 if (!c->child || c->child->which != DATA1N_data)
459 sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
464 static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
466 Z_ContactInfo *res = (Z_ContactInfo *)
467 odr_malloc (eh->o, sizeof(*res));
471 res->description = 0;
476 for (c = n->child; c; c = c->next)
478 switch (is_numeric_tag (eh, c))
480 case 102: res->name = f_string (eh, c); break;
481 case 113: res->description = f_humstring (eh, c); break;
482 case 127: res->address = f_humstring (eh, c); break;
483 case 128: res->email = f_string (eh, c); break;
484 case 129: res->phone = f_string (eh, c); break;
490 static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
496 for (c = n->child; c; c = c->next)
498 if (!is_numeric_tag (eh, c) != 102)
505 res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
507 res->num_databases = i;
508 res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
510 for (c = n->child; c; c = c->next)
512 if (!is_numeric_tag (eh, c) != 102)
514 res->databases[i++] = f_string (eh, c);
519 static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
521 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
522 odr_malloc (eh->o, sizeof(*res));
525 res->hostAddress = 0;
528 for (c = n->child; c; c = c->next)
530 switch (is_numeric_tag (eh, c))
532 case 121: res->hostAddress = f_string (eh, c); break;
533 case 122: res->port = f_integer (eh, c); break;
539 static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
542 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
543 odr_malloc (eh->o, sizeof(*res));
549 for (c = n->child; c; c = c->next)
551 switch (is_numeric_tag (eh, c))
553 case 124: res->type = f_string (eh, c); break;
554 case 121: res->address = f_string (eh, c); break;
560 static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
563 Z_NetworkAddress **res = NULL;
568 for (c = n->child; c; c = c->next)
570 switch (is_numeric_tag (eh, c))
580 res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
582 for (c = n->child; c; c = c->next)
584 switch (is_numeric_tag (eh, c))
587 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
588 res[i]->which = Z_NetworkAddress_iA;
589 res[i]->u.internetAddress = f_networkAddressIA(eh, c);
593 res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
594 res[i]->which = Z_NetworkAddress_other;
595 res[i]->u.other = f_networkAddressOther(eh, c);
603 static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
605 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
609 res->originalCategory = 0;
610 res->description = 0;
612 for (c = n->child; c; c = c->next)
614 switch (is_numeric_tag (eh, c))
616 case 102: res->category = f_string(eh, c); break;
617 case 302: res->originalCategory = f_string(eh, c); break;
618 case 113: res->description = f_humstring(eh, c); break;
619 case 303: res->asn1Module = f_string (eh, c); break;
625 static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
627 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
631 res->num_categories = 0;
632 res->categories = NULL;
634 for (c = n->child; c; c = c->next)
638 switch (is_numeric_tag (eh, c))
640 case 600: res->commonInfo = f_commonInfo(eh, c); break;
642 for (n = c->child; n; n = n->next)
644 if (is_numeric_tag(eh, n) != 301)
646 (res->num_categories)++;
648 if (res->num_categories)
650 (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
651 * sizeof(*res->categories));
652 for (n = c->child; n; n = n->next)
654 if (is_numeric_tag(eh, n) != 301)
656 res->categories[i++] = f_categoryInfo (eh, n);
661 assert (res->num_categories && res->categories);
665 static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
667 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
674 res->namedResultSets = 0;
675 res->multipleDBsearch = 0;
676 res->maxResultSets = 0;
677 res->maxResultSize = 0;
679 res->timeoutInterval = 0;
680 res->welcomeMessage = 0;
681 res->contactInfo = 0;
682 res->description = 0;
683 res->num_nicknames = 0;
686 res->paymentAddr = 0;
688 res->num_dbCombinations = 0;
689 res->dbCombinations = 0;
690 res->num_addresses = 0;
692 res->num_languages = 0;
693 res->languages = NULL;
694 res->commonAccessInfo = 0;
696 for (c = n->child; c; c = c->next)
700 switch (is_numeric_tag (eh, c))
702 case 600: res->commonInfo = f_commonInfo(eh, c); break;
703 case 102: res->name = f_string(eh, c); break;
704 case 103: res->recentNews = f_humstring(eh, c); break;
705 case 104: res->icon = NULL; break; /* fix */
706 case 105: res->namedResultSets = f_bool(eh, c); break;
707 case 106: res->multipleDBsearch = f_bool(eh, c); break;
708 case 107: res->maxResultSets = f_integer(eh, c); break;
709 case 108: res->maxResultSize = f_integer(eh, c); break;
710 case 109: res->maxTerms = f_integer(eh, c); break;
711 case 110: res->timeoutInterval = f_intunit(eh, c); break;
712 case 111: res->welcomeMessage = f_humstring(eh, c); break;
713 case 112: res->contactInfo = f_contactInfo(eh, c); break;
714 case 113: res->description = f_humstring(eh, c); break;
716 res->num_nicknames = 0;
717 for (n = c->child; n; n = n->next)
719 if (is_numeric_tag(eh, n) != 102)
721 (res->num_nicknames)++;
723 if (res->num_nicknames)
725 (char **)odr_malloc (eh->o, res->num_nicknames
726 * sizeof(*res->nicknames));
727 for (n = c->child; n; n = n->next)
729 if (is_numeric_tag(eh, n) != 102)
731 res->nicknames[i++] = f_string (eh, n);
734 case 115: res->usageRest = f_humstring(eh, c); break;
735 case 116: res->paymentAddr = f_humstring(eh, c); break;
736 case 117: res->hours = f_humstring(eh, c); break;
738 res->num_dbCombinations = 0;
739 for (n = c->child; n; n = n->next)
741 if (!is_numeric_tag(eh, n) != 605)
743 (res->num_dbCombinations)++;
745 if (res->num_dbCombinations)
746 res->dbCombinations =
747 (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
748 * sizeof(*res->dbCombinations));
749 for (n = c->child; n; n = n->next)
751 if (!is_numeric_tag(eh, n) != 605)
753 res->dbCombinations[i++] = f_databaseList (eh, n);
758 f_networkAddresses (eh, c, &res->num_addresses);
761 res->num_languages = 0;
762 for (n = c->child; n; n = n->next)
764 if (!is_numeric_tag(eh, n) != 126)
766 (res->num_languages)++;
768 if (res->num_languages)
769 res->languages = (char **)
770 odr_malloc (eh->o, res->num_languages *
771 sizeof(*res->languages));
772 for (n = c->child; n; n = n->next)
774 if (!is_numeric_tag(eh, n) != 126)
776 res->languages[i++] = f_string (eh, n);
779 case 500: res->commonAccessInfo = f_accessInfo(eh, c); break;
782 if (!res->namedResultSets)
783 res->namedResultSets = eh->false_value;
784 if (!res->multipleDBsearch)
785 res->multipleDBsearch = eh->false_value;
789 static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
791 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
796 res->explainDatabase = 0;
797 res->num_nicknames = 0;
802 res->titleString = 0;
803 res->num_keywords = 0;
805 res->description = 0;
806 res->associatedDbs = 0;
808 res->disclaimers = 0;
810 res->u.actualNumber = 0;
811 res->defaultOrder = 0;
812 res->avRecordSize = 0;
813 res->maxRecordSize = 0;
817 res->updateInterval = 0;
819 res->proprietary = 0;
820 res->copyrightText = 0;
821 res->copyrightNotice = 0;
822 res->producerContactInfo = 0;
823 res->supplierContactInfo = 0;
824 res->submissionContactInfo = 0;
827 for (c = n->child; c; c = c->next)
831 switch (is_numeric_tag (eh, c))
833 case 600: res->commonInfo = f_commonInfo(eh, c); break;
834 case 102: res->name = f_string(eh, c); break;
835 case 226: res->explainDatabase = odr_nullval(); break;
837 res->num_nicknames = 0;
838 for (n = c->child; n; n = n->next)
840 if (!is_numeric_tag(eh, n) ||
841 n->u.tag.element->tag->value.numeric != 102)
843 (res->num_nicknames)++;
845 if (res->num_nicknames)
847 (char **)odr_malloc (eh->o, res->num_nicknames
848 * sizeof(*res->nicknames));
849 for (n = c->child; n; n = n->next)
851 if (!is_numeric_tag(eh, n) ||
852 n->u.tag.element->tag->value.numeric != 102)
854 res->nicknames[i++] = f_string (eh, n);
857 case 104: res->icon = 0; break; /* fix */
858 case 201: res->userFee = f_bool(eh, c); break;
859 case 202: res->available = f_bool(eh, c); break;
860 case 203: res->titleString = f_humstring(eh, c); break;
862 res->num_keywords = 0;
863 for (n = c->child; n; n = n->next)
865 if (!is_numeric_tag(eh, n) != 1000)
867 (res->num_keywords)++;
869 if (res->num_keywords)
871 (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
872 * sizeof(*res->keywords));
873 for (n = c->child; n; n = n->next)
875 if (!is_numeric_tag(eh, n) != 1000)
877 res->keywords[i++] = f_humstring (eh, n);
880 case 113: res->description = f_humstring(eh, c); break;
882 res->associatedDbs = f_databaseList (eh, c);
885 res->subDbs = f_databaseList (eh, c);
887 case 207: res->disclaimers = f_humstring(eh, c); break;
888 case 103: res->news = f_humstring(eh, c); break;
889 case 209: res->u.actualNumber =
890 f_recordCount(eh, c, &res->which); break;
891 case 212: res->defaultOrder = f_humstring(eh, c); break;
892 case 213: res->avRecordSize = f_integer(eh, c); break;
893 case 214: res->maxRecordSize = f_integer(eh, c); break;
894 case 215: res->hours = f_humstring(eh, c); break;
895 case 216: res->bestTime = f_humstring(eh, c); break;
896 case 217: res->lastUpdate = f_string(eh, c); break;
897 case 218: res->updateInterval = f_intunit(eh, c); break;
898 case 219: res->coverage = f_humstring(eh, c); break;
899 case 220: res->proprietary = f_bool(eh, c); break;
900 case 221: res->copyrightText = f_humstring(eh, c); break;
901 case 222: res->copyrightNotice = f_humstring(eh, c); break;
902 case 223: res->producerContactInfo = f_contactInfo(eh, c); break;
903 case 224: res->supplierContactInfo = f_contactInfo(eh, c); break;
904 case 225: res->submissionContactInfo = f_contactInfo(eh, c); break;
905 case 500: res->accessInfo = f_accessInfo(eh, c); break;
909 res->userFee = eh->false_value;
911 res->available = eh->true_value;
915 Z_StringOrNumeric *f_stringOrNumeric (ExpHandle *eh, data1_node *n)
917 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
918 odr_malloc (eh->o, sizeof(*res));
920 for (c = n->child; c; c = c->next)
922 switch (is_numeric_tag (eh, c))
925 res->which = Z_StringOrNumeric_string;
926 res->u.string = f_string (eh, c);
929 res->which = Z_StringOrNumeric_numeric;
930 res->u.numeric = f_integer (eh, c);
937 Z_AttributeDescription *f_attributeDescription (
938 ExpHandle *eh, data1_node *n)
940 Z_AttributeDescription *res = (Z_AttributeDescription *)
941 odr_malloc(eh->o, sizeof(*res));
946 res->description = 0;
947 res->attributeValue = 0;
948 res->num_equivalentAttributes = 0;
949 res->equivalentAttributes = 0;
951 for (c = n->child; c; c = c->next)
953 switch (is_numeric_tag (eh, c))
955 case 102: res->name = f_string (eh, c); break;
956 case 113: res->description = f_humstring (eh, c); break;
957 case 710: res->attributeValue = f_stringOrNumeric (eh, c); break;
958 case 752: (res->num_equivalentAttributes++); break;
961 if (res->num_equivalentAttributes)
962 res->equivalentAttributes = (Z_StringOrNumeric **)
963 odr_malloc (eh->o, sizeof(*res->equivalentAttributes) *
964 res->num_equivalentAttributes);
965 for (c = n->child; c; c = c->next)
966 if (is_numeric_tag (eh, c) == 752)
967 res->equivalentAttributes[i++] = f_stringOrNumeric (eh, c);
971 Z_AttributeType *f_attributeType (ExpHandle *eh, data1_node *n)
973 Z_AttributeType *res = (Z_AttributeType *)
974 odr_malloc(eh->o, sizeof(*res));
978 res->description = 0;
979 res->attributeType = 0;
980 res->num_attributeValues = 0;
981 res->attributeValues = 0;
983 for (c = n->child; c; c = c->next)
986 switch (is_numeric_tag (eh, c))
988 case 102: res->name = f_string (eh, c); break;
989 case 113: res->description = f_humstring (eh, c); break;
990 case 704: res->attributeType = f_integer (eh, c); break;
992 for (n = c->child; n; n = n->next)
994 if (is_numeric_tag(eh, n) != 709)
996 (res->num_attributeValues)++;
998 if (res->num_attributeValues)
999 res->attributeValues = (Z_AttributeDescription **)
1000 odr_malloc (eh->o, res->num_attributeValues
1001 * sizeof(*res->attributeValues));
1002 for (n = c->child; n; n = n->next)
1004 if (is_numeric_tag(eh, n) != 709)
1006 res->attributeValues[i++] = f_attributeDescription (eh, n);
1014 Z_AttributeSetInfo *f_attributeSetInfo (ExpHandle *eh, data1_node *n)
1016 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
1017 odr_malloc(eh->o, sizeof(*res));
1020 res->commonInfo = 0;
1021 res->attributeSet = 0;
1023 res->num_attributes = 0;
1024 res->attributes = 0;
1025 res->description = 0;
1026 for (c = n->child; c; c = c->next)
1029 switch (is_numeric_tag (eh, c))
1031 case 600: res->commonInfo = f_commonInfo (eh, c); break;
1032 case 1000: res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1033 case 102: res->name = f_string (eh, c); break;
1035 for (n = c->child; n; n = n->next)
1037 if (is_numeric_tag(eh, n) != 751)
1039 (res->num_attributes)++;
1041 if (res->num_attributes)
1042 res->attributes = (Z_AttributeType **)
1043 odr_malloc (eh->o, res->num_attributes
1044 * sizeof(*res->attributes));
1045 for (n = c->child; n; n = n->next)
1047 if (is_numeric_tag(eh, n) != 751)
1049 res->attributes[i++] = f_attributeType (eh, n);
1052 case 113: res->description = f_humstring (eh, c); break;
1058 Z_OmittedAttributeInterpretation *f_omittedAttributeInterpretation (
1059 ExpHandle *eh, data1_node *n)
1061 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1062 odr_malloc (eh->o, sizeof(*res));
1065 res->defaultValue = 0;
1066 res->defaultDescription = 0;
1067 for (c = n->child; c; c = c->next)
1069 switch (is_numeric_tag (eh, c))
1072 res->defaultValue = f_stringOrNumeric (eh, c);
1075 res->defaultDescription = f_humstring(eh, c);
1082 Z_AttributeValue *f_attributeValue (ExpHandle *eh, data1_node *n)
1084 Z_AttributeValue *res = (Z_AttributeValue *)
1085 odr_malloc (eh->o, sizeof(*res));
1089 res->description = 0;
1090 res->num_subAttributes = 0;
1091 res->subAttributes = 0;
1092 res->num_superAttributes = 0;
1093 res->superAttributes = 0;
1094 res->partialSupport = 0;
1095 for (c = n->child; c; c = c->next)
1098 switch (is_numeric_tag (eh, c))
1101 res->value = f_stringOrNumeric (eh, c); break;
1103 res->description = f_humstring (eh, c); break;
1105 for (n = c->child; n; n = n->next)
1107 if (is_numeric_tag(eh, n) != 713)
1109 (res->num_subAttributes)++;
1111 if (res->num_subAttributes)
1112 res->subAttributes =
1113 (Z_StringOrNumeric **)
1114 odr_malloc (eh->o, res->num_subAttributes
1115 * sizeof(*res->subAttributes));
1116 for (n = c->child; n; n = n->next)
1118 if (is_numeric_tag(eh, n) != 713)
1120 res->subAttributes[i++] = f_stringOrNumeric (eh, n);
1124 for (n = c->child; n; n = n->next)
1126 if (is_numeric_tag(eh, n) != 715)
1128 (res->num_superAttributes)++;
1130 if (res->num_superAttributes)
1131 res->superAttributes =
1132 (Z_StringOrNumeric **)
1133 odr_malloc (eh->o, res->num_superAttributes
1134 * sizeof(*res->superAttributes));
1135 for (n = c->child; n; n = n->next)
1137 if (is_numeric_tag(eh, n) != 715)
1139 res->superAttributes[i++] = f_stringOrNumeric (eh, n);
1143 res->partialSupport = odr_nullval ();
1150 Z_AttributeTypeDetails *f_attributeTypeDetails (ExpHandle *eh, data1_node *n)
1152 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1153 odr_malloc(eh->o, sizeof(*res));
1155 res->attributeType = 0;
1156 res->defaultIfOmitted = 0;
1157 res->num_attributeValues = 0;
1158 res->attributeValues = 0;
1159 for (c = n->child; c; c = c->next)
1162 switch (is_numeric_tag (eh, c))
1164 case 704: res->attributeType = f_integer (eh, c); break;
1166 res->defaultIfOmitted = f_omittedAttributeInterpretation (eh, c);
1169 for (n = c->child; n; n = n->next)
1171 if (is_numeric_tag(eh, n) != 709)
1173 (res->num_attributeValues)++;
1175 if (res->num_attributeValues)
1176 res->attributeValues =
1177 (Z_AttributeValue **)
1178 odr_malloc (eh->o, res->num_attributeValues
1179 * sizeof(*res->attributeValues));
1180 for (n = c->child; n; n = n->next)
1182 if (is_numeric_tag(eh, n) != 709)
1184 res->attributeValues[i++] = f_attributeValue (eh, n);
1192 Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n)
1194 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1195 odr_malloc(eh->o, sizeof(*res));
1198 res->attributeSet = 0;
1199 res->num_attributesByType = 0;
1200 res->attributesByType = 0;
1201 for (c = n->child; c; c = c->next)
1204 switch (is_numeric_tag (eh, c))
1206 case 1000: res->attributeSet = f_oid(eh, c, CLASS_ATTSET); break;
1208 for (n = c->child; n; n = n->next)
1210 if (is_numeric_tag(eh, n) != 703)
1212 (res->num_attributesByType)++;
1214 if (res->num_attributesByType)
1215 res->attributesByType =
1216 (Z_AttributeTypeDetails **)
1217 odr_malloc (eh->o, res->num_attributesByType
1218 * sizeof(*res->attributesByType));
1219 for (n = c->child; n; n = n->next)
1221 if (is_numeric_tag(eh, n) != 703)
1223 res->attributesByType[i++] = f_attributeTypeDetails (eh, n);
1231 Z_AttributeValueList *f_attributeValueList (ExpHandle *eh, data1_node *n)
1233 Z_AttributeValueList *res = (Z_AttributeValueList *)
1234 odr_malloc (eh->o, sizeof(*res));
1238 res->num_attributes = 0;
1239 res->attributes = 0;
1240 for (c = n->child; c; c = c->next)
1241 if (is_numeric_tag (eh, c) == 710)
1242 (res->num_attributes)++;
1243 if (res->num_attributes)
1245 res->attributes = (Z_StringOrNumeric **)
1246 odr_malloc (eh->o, res->num_attributes * sizeof(*res->attributes));
1248 for (c = n->child; c; c = c->next)
1249 if (is_numeric_tag(eh, c) == 710)
1250 res->attributes[i++] = f_stringOrNumeric (eh, c);
1254 Z_AttributeOccurrence *f_attributeOccurrence (ExpHandle *eh, data1_node *n)
1256 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1257 odr_malloc (eh->o, sizeof(*res));
1260 res->attributeSet = 0;
1261 res->attributeType = 0;
1262 res->mustBeSupplied = 0;
1263 res->which = Z_AttributeOcc_any_or_none;
1264 res->attributeValues.any_or_none = odr_nullval ();
1266 for (c = n->child; c; c = c->next)
1268 switch (is_numeric_tag (eh, c))
1271 res->attributeSet = f_oid (eh, c, CLASS_ATTSET); break;
1273 res->attributeType = f_integer (eh, c); break;
1275 res->mustBeSupplied = odr_nullval (); break;
1277 res->which = Z_AttributeOcc_any_or_none;
1278 res->attributeValues.any_or_none = odr_nullval ();
1281 res->which = Z_AttributeOcc_specific;
1282 res->attributeValues.specific = f_attributeValueList (eh, c);
1289 Z_AttributeCombination *f_attributeCombination (ExpHandle *eh, data1_node *n)
1291 Z_AttributeCombination *res = (Z_AttributeCombination *)
1292 odr_malloc (eh->o, sizeof(*res));
1296 res->num_occurrences = 0;
1297 res->occurrences = 0;
1298 for (c = n->child; c; c = c->next)
1299 if (is_numeric_tag (eh, c) == 719)
1300 (res->num_occurrences)++;
1301 if (res->num_occurrences)
1303 res->occurrences = (Z_AttributeOccurrence **)
1304 odr_malloc (eh->o, res->num_occurrences * sizeof(*res->occurrences));
1306 for (c = n->child; c; c = c->next)
1307 if (is_numeric_tag(eh, c) == 719)
1308 res->occurrences[i++] = f_attributeOccurrence (eh, c);
1309 assert (res->num_occurrences);
1313 Z_AttributeCombinations *f_attributeCombinations (ExpHandle *eh, data1_node *n)
1315 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1316 odr_malloc (eh->o, sizeof(*res));
1318 res->defaultAttributeSet = 0;
1319 res->num_legalCombinations = 0;
1320 res->legalCombinations = 0;
1322 for (c = n->child; c; c = c->next)
1325 switch (is_numeric_tag (eh, c))
1328 res->defaultAttributeSet = f_oid (eh, c, CLASS_ATTSET);
1331 for (n = c->child; n; n = n->next)
1333 if (is_numeric_tag(eh, n) != 718)
1335 (res->num_legalCombinations)++;
1337 if (res->num_legalCombinations)
1338 res->legalCombinations =
1339 (Z_AttributeCombination **)
1340 odr_malloc (eh->o, res->num_legalCombinations
1341 * sizeof(*res->legalCombinations));
1342 for (n = c->child; n; n = n->next)
1344 if (is_numeric_tag(eh, n) != 718)
1346 res->legalCombinations[i++] = f_attributeCombination (eh, n);
1351 assert (res->num_legalCombinations);
1355 Z_AttributeDetails *f_attributeDetails (ExpHandle *eh, data1_node *n)
1357 Z_AttributeDetails *res = (Z_AttributeDetails *)
1358 odr_malloc(eh->o, sizeof(*res));
1361 res->commonInfo = 0;
1362 res->databaseName = 0;
1363 res->num_attributesBySet = 0;
1364 res->attributesBySet = NULL;
1365 res->attributeCombinations = NULL;
1367 for (c = n->child; c; c = c->next)
1370 switch (is_numeric_tag (eh, c))
1372 case 600: res->commonInfo = f_commonInfo(eh, c); break;
1373 case 102: res->databaseName = f_string (eh, c); break;
1375 for (n = c->child; n; n = n->next)
1377 if (is_numeric_tag(eh, n) != 701)
1379 (res->num_attributesBySet)++;
1381 if (res->num_attributesBySet)
1382 res->attributesBySet =
1383 (Z_AttributeSetDetails **)
1384 odr_malloc (eh->o, res->num_attributesBySet
1385 * sizeof(*res->attributesBySet));
1386 for (n = c->child; n; n = n->next)
1388 if (is_numeric_tag(eh, n) != 701)
1390 res->attributesBySet[i++] = f_attributeSetDetails (eh, n);
1394 res->attributeCombinations = f_attributeCombinations (eh, c);
1401 Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
1405 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
1410 eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
1411 *eh.false_value = 0;
1412 eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
1415 assert(n->which == DATA1N_root);
1416 if (strcmp(n->u.root.type, "explain"))
1418 logf(LOG_WARN, "Attempt to convert a non-Explain record");
1421 for (n = n->child; n; n = n->next)
1423 switch (is_numeric_tag (&eh, n))
1426 res->which = Z_Explain_categoryList;
1427 if (!(res->u.categoryList = f_categoryList(&eh, n)))
1431 res->which = Z_Explain_targetInfo;
1432 if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
1436 res->which = Z_Explain_databaseInfo;
1437 if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
1441 res->which = Z_Explain_attributeSetInfo;
1442 if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n)))
1446 res->which = Z_Explain_attributeDetails;
1447 if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))
1452 logf(LOG_WARN, "No category in Explain record");