18#ifdef FREECIV_HAVE_XML_REGISTRY
20#include <libxml/parser.h>
34struct section_file *xmlfile_load(xmlDoc *sec_doc,
const char *filename)
43 xmlroot = xmlDocGetRootElement(sec_doc);
44 if (xmlroot == NULL || strcmp((
const char *)xmlroot->name,
"Freeciv")) {
46 log_error(
_(
"XML-file has no root node <Freeciv>"));
51 cap = (
char *)xmlGetNsProp(xmlroot, (xmlChar *)
"options", NULL);
54 log_error(
_(
"XML-file has no capabilities defined!"));
60 log_error(
_(
"XML-file has incompatible capabilities."));
61 log_normal(
_(
"Freeciv capabilities: %s"), FCXML_CAPSTR);
74 current = xmlroot->children;
76 while (current != NULL) {
77 if (current->type == XML_ELEMENT_NODE) {
82 sec_node = current->children;
84 while (sec_node != NULL) {
85 if (sec_node->type == XML_ELEMENT_NODE) {
86 xmlNodePtr value_node = sec_node->children;
88 while (value_node != NULL) {
89 if (value_node->type == XML_TEXT_NODE) {
90 const char *content = (
const char *) xmlNodeGetContent(value_node);
91 int len = strlen(content);
98 if (buf[0] ==
'"' && buf[
len - 1] ==
'"') {
104 log_error(
"Cannot parse token \"%s\"", content);
110 value_node = value_node->next;
114 sec_node = sec_node->next;
118 current = current->next;
bool has_capabilities(const char *us, const char *them)
#define log_normal(message,...)
#define log_error(message,...)
struct section_file * secfile_new(bool allow_duplicates)
void secfile_destroy(struct section_file *secfile)
struct section * secfile_section_new(struct section_file *secfile, const char *name)
bool entry_from_token(struct section *psection, const char *name, const char *tok)
struct section_file * secfile