X-Git-Url: http://git.indexdata.com/?p=pazpar2-moved-to-github.git;a=blobdiff_plain;f=src%2Fsettings.c;h=1c52b3005dd2ba42063b38cbb4370555961d24bd;hp=85af04dc73842e98f2a9b3bbe658e3fb6125aac5;hb=HEAD;hpb=194b8961ce560e233440017a65ec1758b3e6b5ec diff --git a/src/settings.c b/src/settings.c index 85af04d..1c52b30 100644 --- a/src/settings.c +++ b/src/settings.c @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include @@ -157,29 +158,6 @@ char *settings_name(struct conf_service *service, int offset) return service->dictionary->dict[offset]; } - -// Apply a session override to a database -void service_apply_setting(struct conf_service *service, char *name, char *value) -{ - struct setting *s; - int offset = settings_create_offset(service, name); - expand_settings_array(&service->settings->settings, &service->settings->num_settings, offset, service->nmem); - for (s = service->settings->settings[offset]; s; s = s->next) - if (!strcmp(s->name, name)) - { - s->value = value; - return; - } - s = nmem_malloc(service->nmem, sizeof(*s)); - s->precedence = 0; - s->target = NULL; - s->name = name; - s->value = value; - s->next = service->settings->settings[offset]; - service->settings->settings[offset] = s; -} - - static int isdir(const char *path) { struct stat st; @@ -199,11 +177,10 @@ int settings_read_node_x(xmlNode *n, struct setting *set)) { int ret_val = 0; /* success */ - char *namea = (char *) xmlGetProp(n, (xmlChar *) "name"); - char *targeta = (char *) xmlGetProp(n, (xmlChar *) "target"); - char *valuea = (char *) xmlGetProp(n, (xmlChar *) "value"); - char *usera = (char *) xmlGetProp(n, (xmlChar *) "user"); - char *precedencea = (char *) xmlGetProp(n, (xmlChar *) "precedence"); + const char *namea = yaz_xml_get_prop(n, "name"); + const char *targeta = yaz_xml_get_prop(n, "target"); + const char *valuea = yaz_xml_get_prop(n, "value"); + const char *precedencea = yaz_xml_get_prop(n, "precedence"); for (n = n->children; n; n = n->next) { @@ -213,11 +190,10 @@ int settings_read_node_x(xmlNode *n, { xmlNode *root = n->children; struct setting set; - char *name = (char *) xmlGetProp(n, (xmlChar *) "name"); - char *target = (char *) xmlGetProp(n, (xmlChar *) "target"); - char *value = (char *) xmlGetProp(n, (xmlChar *) "value"); - char *user = (char *) xmlGetProp(n, (xmlChar *) "user"); - char *precedence = (char *) xmlGetProp(n, (xmlChar *) "precedence"); + const char *name = yaz_xml_get_prop(n, "name"); + const char *target = yaz_xml_get_prop(n, "target"); + const char *value = yaz_xml_get_prop(n, "value"); + const char *precedence = yaz_xml_get_prop(n, "precedence"); xmlChar *buf_out = 0; set.next = 0; @@ -254,7 +230,7 @@ int settings_read_node_x(xmlNode *n, xmlDocSetRootElement(doc, xmlCopyNode(root, 1)); xmlDocDumpMemory(doc, &buf_out, &len_out); /* xmlDocDumpMemory 0-terminates */ - set.value = (char *) buf_out; + set.value = (const char *) buf_out; xmlFreeDoc(doc); } } @@ -271,11 +247,6 @@ int settings_read_node_x(xmlNode *n, ret_val = -1; } xmlFree(buf_out); - xmlFree(name); - xmlFree(precedence); - xmlFree(value); - xmlFree(user); - xmlFree(target); } else { @@ -284,11 +255,6 @@ int settings_read_node_x(xmlNode *n, ret_val = -1; } } - xmlFree(namea); - xmlFree(precedencea); - xmlFree(valuea); - xmlFree(usera); - xmlFree(targeta); return ret_val; }