+int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
+ Odr_oid *syntax, char **addinfo)
+{
+#if HAVE_XML2
+ xmlNodePtr ptr;
+
+ ptr = find_target_node(name);
+ if (!ptr)
+ return 0;
+ for(ptr = ptr->children; ptr; ptr = ptr->next)
+ {
+ if (ptr->type == XML_ELEMENT_NODE &&
+ !strcmp((const char *) ptr->name, "syntax"))
+ {
+ int match = 0; // if we match record syntax
+ const char *match_type = 0;
+ const char *match_error = 0;
+ const char *match_marcxml = 0;
+ struct _xmlAttr *attr;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ if (!strcmp((const char *) attr->name, "type") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ match_type = (const char *) attr->children->content;
+ if (!strcmp((const char *) attr->name, "error") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ match_error = (const char *) attr->children->content;
+ if (!strcmp((const char *) attr->name, "marcxml") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ match_marcxml = (const char *) attr->children->content;
+ }
+ if (match_type)
+ {
+ if (!strcmp(match_type, "*"))
+ match = 1;
+ else if (!strcmp(match_type, "none"))
+ {
+ if (syntax == 0)
+ match = 1;
+ }
+ else if (syntax)
+ {
+ int match_oid[OID_SIZE];
+ oid_name_to_oid(CLASS_RECSYN, match_type, match_oid);
+ if (oid_oidcmp(match_oid, syntax) == 0)
+ match = 1;
+ }
+ }
+ if (match)
+ {
+ if (match_marcxml)
+ {
+ return -1;
+ }
+ if (match_error)
+ {
+ if (syntax)
+ {
+ char dotoid_str[100];
+ oid_to_dotstring(syntax, dotoid_str);
+ *addinfo = odr_strdup(odr, dotoid_str);
+ }
+ return atoi(match_error);
+ }
+ return 0;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+#if HAVE_XML2