32 #include <yaz/proto.h>
33 #include <yaz/oid_db.h>
34 #include <yaz/snprintf.h>
50 if (!c->
u.
tag.element)
52 yaz_log(YLOG_WARN,
"Tag %s is local", c->
u.
tag.tag);
57 yaz_log(YLOG_WARN,
"Tag %s is not numeric", c->
u.
tag.tag);
62 return c->
u.
tag.element->tag->value.numeric;
81 sprintf(intbuf,
"%.*s", c->
u.
data.len, c->
u.
data.data);
82 return odr_intdup(eh->
o, atoi(intbuf));
92 r = (
char *)odr_malloc(eh->
o, c->
u.
data.len+1);
94 r[c->
u.
data.len] =
'\0';
106 tf = (
int *)odr_malloc (eh->
o,
sizeof(*tf));
107 sprintf(intbuf,
"%.*s", c->
u.
data.len, c->
u.
data.data);
119 yaz_snprintf(oidstr,
sizeof(oidstr)-1,
122 return yaz_string_to_oid_odr(yaz_oid_std(),
123 CLASS_GENERAL, oidstr, eh->
o);
135 Z_HumanStringUnit *u;
140 r = (Z_HumanString *)odr_malloc(eh->
o,
sizeof(*r));
142 r->strings = (Z_HumanStringUnit **)odr_malloc(eh->
o,
sizeof(Z_HumanStringUnit*));
143 r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->
o,
sizeof(*u));
145 u->text = (
char *)odr_malloc(eh->
o, c->
u.
data.len+1);
146 memcpy(u->text, c->
u.
data.data, c->
u.
data.len);
147 u->text[c->
u.
data.len] =
'\0';
153 Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->
o,
sizeof(*res));
157 res->dateChanged = 0;
159 res->humanStringLanguage = 0;
166 case 601: res->dateAdded =
f_string(eh, c);
break;
167 case 602: res->dateChanged =
f_string(eh, c);
break;
168 case 603: res->expiry =
f_string(eh, c);
break;
169 case 604: res->humanStringLanguage =
f_string(eh, c);
break;
187 res = (Odr_oid **)odr_malloc (eh->
o,
sizeof(*res) * (*num));
188 for (c = n->
child, i = 0 ; c; c = c->
next)
190 res[i++] =
f_oid (eh, c, oclass);
209 res = (
char **)odr_malloc (eh->
o,
sizeof(*res) * (*num));
210 for (c = n->
child, i = 0 ; c; c = c->
next)
221 Z_ProximitySupport *res = (Z_ProximitySupport *)
222 odr_malloc (eh->
o,
sizeof(*res));
224 res->num_unitsSupported = 0;
225 res->unitsSupported = 0;
231 Z_RpnCapabilities *res = (Z_RpnCapabilities *)
232 odr_malloc (eh->
o,
sizeof(*res));
235 res->num_operators = 0;
236 res->operators = NULL;
237 res->resultSetAsOperandSupported = eh->
false_value;
238 res->restrictionOperandSupported = eh->
false_value;
239 res->proximity = NULL;
251 (res->num_operators)++;
253 if (res->num_operators)
254 res->operators = (Odr_int **)
255 odr_malloc (eh->
o, res->num_operators
256 *
sizeof(*res->operators));
265 res->resultSetAsOperandSupported =
f_bool (eh, c);
268 res->restrictionOperandSupported =
f_bool (eh, c);
280 Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
281 odr_malloc(eh->
o,
sizeof(*res));
284 res->
which = Z_QueryTypeDetails_rpn;
291 res->which = Z_QueryTypeDetails_rpn;
305 Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->
o,
sizeof(*res));
308 res->num_queryTypesSupported = 0;
309 res->queryTypesSupported = 0;
310 res->num_diagnosticsSets = 0;
311 res->diagnosticsSets = 0;
312 res->num_attributeSetIds = 0;
313 res->attributeSetIds = 0;
314 res->num_schemas = 0;
316 res->num_recordSyntaxes = 0;
317 res->recordSyntaxes = 0;
318 res->num_resourceChallenges = 0;
319 res->resourceChallenges = 0;
320 res->restrictedAccess = 0;
322 res->num_variantSets = 0;
323 res->variantSets = 0;
324 res->num_elementSetNames = 0;
325 res->elementSetNames = 0;
326 res->num_unitSystems = 0;
327 res->unitSystems = 0;
339 (res->num_queryTypesSupported)++;
341 if (res->num_queryTypesSupported)
342 res->queryTypesSupported =
343 (Z_QueryTypeDetails **)
344 odr_malloc (eh->
o, res->num_queryTypesSupported
345 *
sizeof(*res->queryTypesSupported));
354 res->diagnosticsSets =
355 f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
358 res->attributeSetIds =
359 f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
363 f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
366 res->recordSyntaxes =
367 f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
370 res->resourceChallenges =
371 f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
373 case 513: res->restrictedAccess = NULL;
break;
374 case 514: res->costInfo = NULL;
break;
377 f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
380 res->elementSetNames =
384 res->unitSystems =
f_string_seq (eh, c, &res->num_unitSystems);
399 if (c->
u.
tag.element->tag->value.numeric == 210)
400 *wp = Z_DatabaseInfo_actualNumber;
401 else if (c->
u.
tag.element->tag->value.numeric == 211)
402 *wp = Z_DatabaseInfo_approxNumber;
409 return odr_intdup(eh->
o, atoi(intbuf));
414 Z_ContactInfo *res = (Z_ContactInfo *)
415 odr_malloc (eh->
o,
sizeof(*res));
419 res->description = 0;
428 case 102: res->name =
f_string (eh, c);
break;
429 case 113: res->description =
f_humstring (eh, c);
break;
430 case 127: res->address =
f_humstring (eh, c);
break;
431 case 128: res->email =
f_string (eh, c);
break;
432 case 129: res->phone =
f_string (eh, c);
break;
453 res = (Z_DatabaseList *)odr_malloc (eh->
o,
sizeof(*res));
455 res->num_databases = i;
456 res->databases = (
char **)odr_malloc (eh->
o,
sizeof(*res->databases) * i);
462 res->databases[i++] =
f_string (eh, c);
469 Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
470 odr_malloc (eh->
o,
sizeof(*res));
473 res->hostAddress = 0;
480 case 121: res->hostAddress =
f_string (eh, c);
break;
481 case 122: res->port =
f_integer (eh, c);
break;
490 Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
491 odr_malloc (eh->
o,
sizeof(*res));
501 case 124: res->type =
f_string (eh, c);
break;
502 case 121: res->address =
f_string (eh, c);
break;
511 Z_NetworkAddress **res = NULL;
528 res = (Z_NetworkAddress **) odr_malloc (eh->
o,
sizeof(*res) * (*num));
535 res[i] = (Z_NetworkAddress *) odr_malloc (eh->
o,
sizeof(**res));
536 res[i]->
which = Z_NetworkAddress_iA;
541 res[i] = (Z_NetworkAddress *) odr_malloc (eh->
o,
sizeof(**res));
542 res[i]->which = Z_NetworkAddress_other;
553 Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->
o,
sizeof(*res));
557 res->originalCategory = 0;
558 res->description = 0;
564 case 102: res->category =
f_string(eh, c);
break;
565 case 302: res->originalCategory =
f_string(eh, c);
break;
566 case 113: res->description =
f_humstring(eh, c);
break;
567 case 303: res->asn1Module =
f_string (eh, c);
break;
575 Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->
o,
sizeof(*res));
579 res->num_categories = 0;
580 res->categories = NULL;
594 (res->num_categories)++;
596 if (res->num_categories)
598 (Z_CategoryInfo **)odr_malloc (eh->
o, res->num_categories
599 *
sizeof(*res->categories));
609 assert (res->num_categories && res->categories);
615 Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->
o,
sizeof(*res));
622 res->namedResultSets = 0;
623 res->multipleDBsearch = 0;
624 res->maxResultSets = 0;
625 res->maxResultSize = 0;
627 res->timeoutInterval = 0;
628 res->welcomeMessage = 0;
629 res->contactInfo = 0;
630 res->description = 0;
631 res->num_nicknames = 0;
634 res->paymentAddr = 0;
636 res->num_dbCombinations = 0;
637 res->dbCombinations = 0;
638 res->num_addresses = 0;
640 res->num_languages = 0;
641 res->languages = NULL;
642 res->commonAccessInfo = 0;
651 case 102: res->name =
f_string(eh, c);
break;
652 case 103: res->recentNews =
f_humstring(eh, c);
break;
653 case 104: res->icon = NULL;
break;
654 case 105: res->namedResultSets =
f_bool(eh, c);
break;
655 case 106: res->multipleDBsearch =
f_bool(eh, c);
break;
656 case 107: res->maxResultSets =
f_integer(eh, c);
break;
657 case 108: res->maxResultSize =
f_integer(eh, c);
break;
658 case 109: res->maxTerms =
f_integer(eh, c);
break;
659 case 110: res->timeoutInterval =
f_intunit(eh, c);
break;
660 case 111: res->welcomeMessage =
f_humstring(eh, c);
break;
662 case 113: res->description =
f_humstring(eh, c);
break;
664 res->num_nicknames = 0;
669 (res->num_nicknames)++;
671 if (res->num_nicknames)
673 (
char **)odr_malloc (eh->
o, res->num_nicknames
674 *
sizeof(*res->nicknames));
679 res->nicknames[i++] =
f_string (eh, n);
682 case 115: res->usageRest =
f_humstring(eh, c);
break;
683 case 116: res->paymentAddr =
f_humstring(eh, c);
break;
686 res->num_dbCombinations = 0;
691 (res->num_dbCombinations)++;
693 if (res->num_dbCombinations)
694 res->dbCombinations =
695 (Z_DatabaseList **)odr_malloc (eh->
o, res->num_dbCombinations
696 *
sizeof(*res->dbCombinations));
709 res->num_languages = 0;
714 (res->num_languages)++;
716 if (res->num_languages)
717 res->languages = (
char **)
718 odr_malloc (eh->
o, res->num_languages *
719 sizeof(*res->languages));
724 res->languages[i++] =
f_string (eh, n);
727 case 500: res->commonAccessInfo =
f_accessInfo(eh, c);
break;
730 if (!res->namedResultSets)
732 if (!res->multipleDBsearch)
739 Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->
o,
sizeof(*res));
744 res->explainDatabase = 0;
745 res->num_nicknames = 0;
750 res->titleString = 0;
751 res->num_keywords = 0;
753 res->description = 0;
754 res->associatedDbs = 0;
756 res->disclaimers = 0;
758 res->
u.actualNumber = 0;
759 res->defaultOrder = 0;
760 res->avRecordSize = 0;
761 res->maxRecordSize = 0;
765 res->updateInterval = 0;
767 res->proprietary = 0;
768 res->copyrightText = 0;
769 res->copyrightNotice = 0;
770 res->producerContactInfo = 0;
771 res->supplierContactInfo = 0;
772 res->submissionContactInfo = 0;
782 case 102: res->name =
f_string(eh, c);
break;
783 case 226: res->explainDatabase = odr_nullval();
break;
785 res->num_nicknames = 0;
789 n->
u.
tag.element->tag->value.numeric != 102)
791 (res->num_nicknames)++;
793 if (res->num_nicknames)
795 (
char **)odr_malloc (eh->
o, res->num_nicknames
796 *
sizeof(*res->nicknames));
800 n->
u.
tag.element->tag->value.numeric != 102)
802 res->nicknames[i++] =
f_string (eh, n);
805 case 104: res->icon = 0;
break;
806 case 201: res->userFee =
f_bool(eh, c);
break;
807 case 202: res->available =
f_bool(eh, c);
break;
808 case 203: res->titleString =
f_humstring(eh, c);
break;
810 res->num_keywords = 0;
815 (res->num_keywords)++;
817 if (res->num_keywords)
819 (Z_HumanString **)odr_malloc (eh->
o, res->num_keywords
820 *
sizeof(*res->keywords));
828 case 113: res->description =
f_humstring(eh, c);
break;
835 case 207: res->disclaimers =
f_humstring(eh, c);
break;
837 case 209: res->u.actualNumber =
839 case 212: res->defaultOrder =
f_humstring(eh, c);
break;
840 case 213: res->avRecordSize =
f_integer(eh, c);
break;
841 case 214: res->maxRecordSize =
f_integer(eh, c);
break;
843 case 216: res->bestTime =
f_humstring(eh, c);
break;
844 case 217: res->lastUpdate =
f_string(eh, c);
break;
845 case 218: res->updateInterval =
f_intunit(eh, c);
break;
846 case 219: res->coverage =
f_humstring(eh, c);
break;
847 case 220: res->proprietary =
f_bool(eh, c);
break;
848 case 221: res->copyrightText =
f_humstring(eh, c);
break;
849 case 222: res->copyrightNotice =
f_humstring(eh, c);
break;
850 case 223: res->producerContactInfo =
f_contactInfo(eh, c);
break;
851 case 224: res->supplierContactInfo =
f_contactInfo(eh, c);
break;
852 case 225: res->submissionContactInfo =
f_contactInfo(eh, c);
break;
865 Z_StringOrNumeric *res = (Z_StringOrNumeric *)
866 odr_malloc (eh->
o,
sizeof(*res));
873 res->
which = Z_StringOrNumeric_string;
877 res->which = Z_StringOrNumeric_numeric;
888 Z_AttributeDescription *res = (Z_AttributeDescription *)
889 odr_malloc(eh->
o,
sizeof(*res));
894 res->description = 0;
895 res->attributeValue = 0;
896 res->num_equivalentAttributes = 0;
897 res->equivalentAttributes = 0;
903 case 102: res->name =
f_string (eh, c);
break;
904 case 113: res->description =
f_humstring (eh, c);
break;
906 case 752: (res->num_equivalentAttributes++);
break;
909 if (res->num_equivalentAttributes)
910 res->equivalentAttributes = (Z_StringOrNumeric **)
911 odr_malloc (eh->
o,
sizeof(*res->equivalentAttributes) *
912 res->num_equivalentAttributes);
921 Z_AttributeType *res = (Z_AttributeType *)
922 odr_malloc(eh->
o,
sizeof(*res));
926 res->description = 0;
927 res->attributeType = 0;
928 res->num_attributeValues = 0;
929 res->attributeValues = 0;
936 case 102: res->name =
f_string (eh, c);
break;
937 case 113: res->description =
f_humstring (eh, c);
break;
938 case 704: res->attributeType =
f_integer (eh, c);
break;
944 (res->num_attributeValues)++;
946 if (res->num_attributeValues)
947 res->attributeValues = (Z_AttributeDescription **)
948 odr_malloc (eh->
o, res->num_attributeValues
949 *
sizeof(*res->attributeValues));
964 Z_AttributeSetInfo *res = (Z_AttributeSetInfo *)
965 odr_malloc(eh->
o,
sizeof(*res));
969 res->attributeSet = 0;
971 res->num_attributes = 0;
973 res->description = 0;
979 case 600: res->commonInfo =
f_commonInfo (eh, c);
break;
980 case 1000: res->attributeSet =
f_oid (eh, c, CLASS_ATTSET);
break;
981 case 102: res->name =
f_string (eh, c);
break;
987 (res->num_attributes)++;
989 if (res->num_attributes)
990 res->attributes = (Z_AttributeType **)
991 odr_malloc (eh->
o, res->num_attributes
992 *
sizeof(*res->attributes));
1000 case 113: res->description =
f_humstring (eh, c);
break;
1009 Z_OmittedAttributeInterpretation *res = (Z_OmittedAttributeInterpretation*)
1010 odr_malloc (eh->
o,
sizeof(*res));
1013 res->defaultValue = 0;
1014 res->defaultDescription = 0;
1032 Z_AttributeValue *res = (Z_AttributeValue *)
1033 odr_malloc (eh->
o,
sizeof(*res));
1037 res->description = 0;
1038 res->num_subAttributes = 0;
1039 res->subAttributes = 0;
1040 res->num_superAttributes = 0;
1041 res->superAttributes = 0;
1042 res->partialSupport = 0;
1057 (res->num_subAttributes)++;
1059 if (res->num_subAttributes)
1060 res->subAttributes =
1061 (Z_StringOrNumeric **)
1062 odr_malloc (eh->
o, res->num_subAttributes
1063 *
sizeof(*res->subAttributes));
1076 (res->num_superAttributes)++;
1078 if (res->num_superAttributes)
1079 res->superAttributes =
1080 (Z_StringOrNumeric **)
1081 odr_malloc (eh->
o, res->num_superAttributes
1082 *
sizeof(*res->superAttributes));
1091 res->partialSupport = odr_nullval ();
1100 Z_AttributeTypeDetails *res = (Z_AttributeTypeDetails *)
1101 odr_malloc(eh->
o,
sizeof(*res));
1103 res->attributeType = 0;
1104 res->defaultIfOmitted = 0;
1105 res->num_attributeValues = 0;
1106 res->attributeValues = 0;
1112 case 704: res->attributeType =
f_integer (eh, c);
break;
1121 (res->num_attributeValues)++;
1123 if (res->num_attributeValues)
1124 res->attributeValues =
1125 (Z_AttributeValue **)
1126 odr_malloc (eh->
o, res->num_attributeValues
1127 *
sizeof(*res->attributeValues));
1142 Z_AttributeSetDetails *res = (Z_AttributeSetDetails *)
1143 odr_malloc(eh->
o,
sizeof(*res));
1146 res->attributeSet = 0;
1147 res->num_attributesByType = 0;
1148 res->attributesByType = 0;
1154 case 1000: res->attributeSet =
f_oid(eh, c, CLASS_ATTSET);
break;
1160 (res->num_attributesByType)++;
1162 if (res->num_attributesByType)
1163 res->attributesByType =
1164 (Z_AttributeTypeDetails **)
1165 odr_malloc (eh->
o, res->num_attributesByType
1166 *
sizeof(*res->attributesByType));
1181 Z_AttributeValueList *res = (Z_AttributeValueList *)
1182 odr_malloc (eh->
o,
sizeof(*res));
1186 res->num_attributes = 0;
1190 (res->num_attributes)++;
1191 if (res->num_attributes)
1193 res->attributes = (Z_StringOrNumeric **)
1194 odr_malloc (eh->
o, res->num_attributes *
sizeof(*res->attributes));
1204 Z_AttributeOccurrence *res = (Z_AttributeOccurrence *)
1205 odr_malloc (eh->
o,
sizeof(*res));
1208 res->attributeSet = 0;
1209 res->attributeType = 0;
1210 res->mustBeSupplied = 0;
1211 res->
which = Z_AttributeOcc_any_or_none;
1212 res->attributeValues.any_or_none = odr_nullval ();
1219 res->attributeSet =
f_oid (eh, c, CLASS_ATTSET);
break;
1221 res->attributeType =
f_integer (eh, c);
break;
1223 res->mustBeSupplied = odr_nullval ();
break;
1225 res->which = Z_AttributeOcc_any_or_none;
1226 res->attributeValues.any_or_none = odr_nullval ();
1229 res->which = Z_AttributeOcc_specific;
1239 Z_AttributeCombination *res = (Z_AttributeCombination *)
1240 odr_malloc (eh->
o,
sizeof(*res));
1244 res->num_occurrences = 0;
1245 res->occurrences = 0;
1248 (res->num_occurrences)++;
1249 if (res->num_occurrences)
1251 res->occurrences = (Z_AttributeOccurrence **)
1252 odr_malloc (eh->
o, res->num_occurrences *
sizeof(*res->occurrences));
1257 assert (res->num_occurrences);
1263 Z_AttributeCombinations *res = (Z_AttributeCombinations *)
1264 odr_malloc (eh->
o,
sizeof(*res));
1266 res->defaultAttributeSet = 0;
1267 res->num_legalCombinations = 0;
1268 res->legalCombinations = 0;
1276 res->defaultAttributeSet =
f_oid (eh, c, CLASS_ATTSET);
1283 (res->num_legalCombinations)++;
1285 if (res->num_legalCombinations)
1286 res->legalCombinations =
1287 (Z_AttributeCombination **)
1288 odr_malloc (eh->
o, res->num_legalCombinations
1289 *
sizeof(*res->legalCombinations));
1299 assert (res->num_legalCombinations);
1305 Z_AttributeDetails *res = (Z_AttributeDetails *)
1306 odr_malloc(eh->
o,
sizeof(*res));
1309 res->commonInfo = 0;
1310 res->databaseName = 0;
1311 res->num_attributesBySet = 0;
1312 res->attributesBySet = NULL;
1313 res->attributeCombinations = NULL;
1320 case 600: res->commonInfo =
f_commonInfo(eh, c);
break;
1321 case 102: res->databaseName =
f_string (eh, c);
break;
1327 (res->num_attributesBySet)++;
1329 if (res->num_attributesBySet)
1330 res->attributesBySet =
1331 (Z_AttributeSetDetails **)
1332 odr_malloc (eh->
o, res->num_attributesBySet
1333 *
sizeof(*res->attributesBySet));
1353 Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o,
sizeof(*res));
1364 if (strcmp(n->
u.
root.type,
"explain"))
1366 yaz_log(YLOG_WARN,
"Attempt to convert a non-Explain record");
1374 res->which = Z_Explain_categoryList;
1379 res->which = Z_Explain_targetInfo;
1384 res->which = Z_Explain_databaseInfo;
1389 res->which = Z_Explain_attributeSetInfo;
1394 res->which = Z_Explain_attributeDetails;
1400 yaz_log(YLOG_WARN,
"No category in Explain record");