+static int check_diagnostic(const xmlNode *ptr, ODR odr,
+ int *error_code, const char **addinfo)
+{
+ if (ptr && ptr->type == XML_ELEMENT_NODE &&
+ !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
+ {
+ struct _xmlAttr *attr;
+ const char *code_str = 0;
+ const char *addinfo_str = 0;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ if (!xmlStrcmp(attr->name, BAD_CAST "code") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ code_str = (const char *) attr->children->content;
+ else if (!xmlStrcmp(attr->name, BAD_CAST "addinfo") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ addinfo_str = (const char *) attr->children->content;
+ else
+ {
+ *error_code = 1;
+ *addinfo = "bad attribute for diagnostic element";
+ return 1;
+ }
+ }
+ if (!code_str)
+ {
+ *error_code = 1;
+ *addinfo = "missing @code for diagnostic element";
+ return 1;
+ }
+ *error_code = atoi(code_str);
+ if (addinfo_str)
+ *addinfo = odr_strdup(odr, addinfo_str);
+ return 1;
+ }
+ else
+ return 0;
+}
+