unsigned int sesid;
struct http_session *s;
struct http_response *rs = c->response;
- struct conf_service *service;
+ struct conf_service *service = 0; /* no service (yet) */
- if (content_type && !yaz_strcmp_del("text/xml", content_type, "; "))
+ if (r->content_len && content_type &&
+ !yaz_strcmp_del("text/xml", content_type, "; "))
{
xmlDoc *doc = xmlParseMemory(r->content_buf, r->content_len);
xmlNode *root_n;
root_n = xmlDocGetRootElement(doc);
service = service_create(c->server, root_n);
xmlFreeDoc(doc);
+ if (!service)
+ {
+ error(rs, PAZPAR2_MALFORMED_SETTING, 0);
+ return;
+ }
}
- else
+
+ if (!service)
{
const char *service_name = http_argbyname(c->request, "service");
service = locate_service(c->server, service_name);
http_send_response(c);
}
+static void apply_local_setting(void *client_data,
+ struct setting *set)
+{
+ struct session *se = (struct session *) client_data;
+
+ session_apply_setting(se, nmem_strdup(se->session_nmem, set->target),
+ nmem_strdup(se->session_nmem, set->name),
+ nmem_strdup(se->session_nmem, set->value));
+}
+
static void cmd_settings(struct http_channel *c)
{
struct http_response *rs = c->response;
struct http_request *rq = c->request;
struct http_session *s = locate_session(rq, rs);
+ const char *content_type = http_lookup_header(rq->headers, "Content-Type");
if (!s)
return;
+ if (rq->content_len && content_type &&
+ !yaz_strcmp_del("text/xml", content_type, "; "))
+ {
+ xmlDoc *doc = xmlParseMemory(rq->content_buf, rq->content_len);
+ xmlNode *root_n;
+ if (!doc)
+ {
+ error(rs, PAZPAR2_MALFORMED_SETTING, 0);
+ return;
+ }
+ root_n = xmlDocGetRootElement(doc);
+
+ settings_read_node_x(root_n, s->psession, apply_local_setting);
+
+ xmlFreeDoc(doc);
+ }
if (process_settings(s->psession, rq, rs) < 0)
return;
rs->payload = "<settings><status>OK</status></settings>";
}
// Read settings from an XML file, calling handler function for each setting
-static void read_settings_node(xmlNode *n,
- struct conf_service *service,
- void (*fun)(struct conf_service *service,
- struct setting *set))
+void settings_read_node_x(xmlNode *n,
+ void *client_data,
+ void (*fun)(void *client_data,
+ struct setting *set))
{
xmlChar *namea, *targeta, *valuea, *usera, *precedencea;
strcpy(valueb, (const char *) valuea);
set.value = valueb;
set.next = 0;
- (*fun)(service, &set);
+ (*fun)(client_data, &set);
}
xmlFree(name);
xmlFree(precedence);
}
static void read_settings_file(const char *path,
- struct conf_service *service,
- void (*fun)(struct conf_service *service,
+ void *client_data,
+ void (*fun)(void *client_data,
struct setting *set))
{
xmlDoc *doc = xmlParseFile(path);
exit(1);
}
n = xmlDocGetRootElement(doc);
- read_settings_node(n, service, fun);
+ settings_read_node_x(n, client_data, fun);
xmlFreeDoc(doc);
}
// Recursively read files or directories, invoking a
// callback for each one
static void read_settings(const char *path,
- struct conf_service *service,
- void (*fun)(struct conf_service *service,
+ void *client_data,
+ void (*fun)(void *client_data,
struct setting *set))
{
DIR *d;
if (*de->d_name == '.' || !strcmp(de->d_name, "CVS"))
continue;
sprintf(tmp, "%s/%s", path, de->d_name);
- read_settings(tmp, service, fun);
+ read_settings(tmp, client_data, fun);
}
closedir(d);
}
else if ((dot = strrchr(path, '.')) && !strcmp(dot + 1, "xml"))
- read_settings_file(path, service, fun);
+ read_settings_file(path, client_data, fun);
}
// Determines if a ZURL is a wildcard, and what kind
// Callback -- updates database records with dictionary entries as appropriate
// This is used in pass 2 to assign name/value pairs to databases
-static void update_databases(struct conf_service *service,
- struct setting *set)
+static void update_databases(void *client_data, struct setting *set)
{
+ struct conf_service *service = (struct conf_service *) client_data;
struct update_database_context context;
context.set = set;
context.service = service;
}
}
-static void prepare_target_dictionary(struct conf_service *service,
- struct setting *set)
+static void prepare_target_dictionary(void *client_data, struct setting *set)
{
+ struct conf_service *service = (struct conf_service *) client_data;
struct setting_dictionary *dictionary = service->dictionary;
int i;
int pass)
{
if (pass == 1)
- read_settings_node(n, service, prepare_target_dictionary);
+ settings_read_node_x(n, service, prepare_target_dictionary);
else
- read_settings_node(n, service, update_databases);
+ settings_read_node_x(n, service, update_databases);
}
/*
int settings_offset_cprefix(struct conf_service *service, const char *name);
void init_settings(struct conf_service *service);
void resolve_databases(struct conf_service *service);
+void settings_read_node_x(xmlNode *n,
+ void *client_data,
+ void (*fun)(void *client_data,
+ struct setting *set));
#endif
+++ /dev/null
-/* This file is part of Pazpar2.
- Copyright (C) 2006-2009 Index Data
-
-Pazpar2 is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-#ifndef UTIL_H
-#define UTIL_H
-
-void die(char *string, char *add);
-
-
-#endif
--- /dev/null
+<show>
+<status>OK</status>
+<activeclients>0</activeclients>
+<merged>9</merged>
+<total>10</total>
+<start>0</start>
+<num>9</num>
+<hit>
+
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date></location>
+<recid>title the computer bible author medium book</recid>
+</hit>
+<hit>
+
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author></location>
+<location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author></location>
+<count>2</count>
+<recid>title how to program a computer author jack collins medium book</recid>
+</hit>
+<hit>
+
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date></location>
+<recid>title a plan for community college computer development author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author></location>
+<recid>title washington metropolitan area rail computer feasibility study author englund carl r medium book</recid>
+</hit>
+<hit>
+
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author></location>
+<recid>title the use of passwords for controlled access to computer resources author wood helen m medium book</recid>
+</hit>
+<hit>
+
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author></location>
+<recid>title the puget sound region author mairs john w medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer science & technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Computer science & technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date></location>
+<recid>title computer science technology author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date></location>
+<recid>title computer processing of dynamic images from an anger scintillation camera author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date></location>
+<recid>title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book</recid>
+</hit>
+</show>
--- /dev/null
+<bytarget><status>OK</status>
+<target><id>z3950.indexdata.com/marc</id>
+<name>Index Data MARC test server</name>
+<hits>10</hits>
+<diagnostic>0</diagnostic>
+<records>10</records>
+<state>Client_Idle</state>
+</target></bytarget>
\ No newline at end of file
-<show>
-<status>OK</status>
-<activeclients>0</activeclients>
-<merged>3</merged>
-<total>3</total>
-<start>0</start>
-<num>3</num>
-<hit>
-
-<md-title>OIL/GAS DRILLING</md-title><location id="z3950.indexdata.com/gils" name="Index Data GILS test server">
-<md-title>OIL/GAS DRILLING</md-title></location>
-<recid>title oil gas drilling author medium book</recid>
-</hit>
-<hit>
-
-<md-title>GROUNDWATER RESOURCE MAPS - COUNTY SERIES</md-title><location id="z3950.indexdata.com/gils" name="Index Data GILS test server">
-<md-title>GROUNDWATER RESOURCE MAPS - COUNTY SERIES</md-title></location>
-<recid>title groundwater resource maps county series author medium book</recid>
-</hit>
-<hit>
-
-<md-title>BIBLIOGRAPHY OF MAINE GEOLOGY</md-title><location id="z3950.indexdata.com/gils" name="Index Data GILS test server">
-<md-title>BIBLIOGRAPHY OF MAINE GEOLOGY</md-title></location>
-<recid>title bibliography of maine geology author medium book</recid>
-</hit>
-</show>
+<init><status>OK</status><session>3</session><protocol>1</protocol></init>
\ No newline at end of file
-<show>
-<status>OK</status>
-<activeclients>0</activeclients>
-<merged>9</merged>
-<total>10</total>
-<start>0</start>
-<num>9</num>
-<hit>
-
-<md-title>The Computer Bible</md-title>
-<md-date>1973-1980</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>The Computer Bible</md-title>
-<md-date>1973-1980</md-date></location>
-<recid>title the computer bible author medium book</recid>
-</hit>
-<hit>
-
-<md-title>How to program a computer</md-title>
-<md-author>Jack Collins</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>How to program a computer</md-title>
-<md-author>Jack Collins</md-author></location>
-<location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>How to program a computer</md-title>
-<md-author>Jack Collins</md-author></location>
-<count>2</count>
-<recid>title how to program a computer author jack collins medium book</recid>
-</hit>
-<hit>
-
-<md-title>A plan for community college computer development</md-title>
-<md-date>1971</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>A plan for community college computer development</md-title>
-<md-date>1971</md-date></location>
-<recid>title a plan for community college computer development author medium book</recid>
-</hit>
-<hit>
-
-<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
-<md-title-remainder>final report</md-title-remainder>
-<md-date>1971</md-date>
-<md-author>Englund, Carl R</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
-<md-title-remainder>final report</md-title-remainder>
-<md-date>1971</md-date>
-<md-author>Englund, Carl R</md-author></location>
-<recid>title washington metropolitan area rail computer feasibility study author englund carl r medium book</recid>
-</hit>
-<hit>
-
-<md-title>The use of passwords for controlled access to computer resources</md-title>
-<md-date>1977</md-date>
-<md-author>Wood, Helen M</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>The use of passwords for controlled access to computer resources</md-title>
-<md-date>1977</md-date>
-<md-author>Wood, Helen M</md-author></location>
-<recid>title the use of passwords for controlled access to computer resources author wood helen m medium book</recid>
-</hit>
-<hit>
-
-<md-title>The Puget Sound Region</md-title>
-<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
-<md-date>1974</md-date>
-<md-author>Mairs, John W</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>The Puget Sound Region</md-title>
-<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
-<md-date>1974</md-date>
-<md-author>Mairs, John W</md-author></location>
-<recid>title the puget sound region author mairs john w medium book</recid>
-</hit>
-<hit>
-
-<md-title>Computer science & technology</md-title>
-<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
-<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>Computer science & technology</md-title>
-<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
-<md-date>1977</md-date></location>
-<recid>title computer science technology author medium book</recid>
-</hit>
-<hit>
-
-<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
-<md-title-remainder>the proceedings of a workshop</md-title-remainder>
-<md-date>1974</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
-<md-title-remainder>the proceedings of a workshop</md-title-remainder>
-<md-date>1974</md-date></location>
-<recid>title computer processing of dynamic images from an anger scintillation camera author medium book</recid>
-</hit>
-<hit>
-
-<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
-<md-title-remainder>proceedings of the workshop</md-title-remainder>
-<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
-<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
-<md-title-remainder>proceedings of the workshop</md-title-remainder>
-<md-date>1977</md-date></location>
-<recid>title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book</recid>
-</hit>
-</show>
+<settings><status>OK</status></settings>
\ No newline at end of file
--- /dev/null
+<show>
+<status>OK</status>
+<activeclients>0</activeclients>
+<merged>9</merged>
+<total>10</total>
+<start>0</start>
+<num>9</num>
+<hit>
+
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date></location>
+<recid>title the computer bible author medium book</recid>
+</hit>
+<hit>
+
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author></location>
+<location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author></location>
+<count>2</count>
+<recid>title how to program a computer author jack collins medium book</recid>
+</hit>
+<hit>
+
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date></location>
+<recid>title a plan for community college computer development author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author></location>
+<recid>title washington metropolitan area rail computer feasibility study author englund carl r medium book</recid>
+</hit>
+<hit>
+
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author></location>
+<recid>title the use of passwords for controlled access to computer resources author wood helen m medium book</recid>
+</hit>
+<hit>
+
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author></location>
+<recid>title the puget sound region author mairs john w medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer science & technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Computer science & technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date></location>
+<recid>title computer science technology author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date></location>
+<recid>title computer processing of dynamic images from an anger scintillation camera author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date></location>
+<recid>title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book</recid>
+</hit>
+</show>
--- /dev/null
+<show>
+<status>OK</status>
+<activeclients>0</activeclients>
+<merged>3</merged>
+<total>3</total>
+<start>0</start>
+<num>3</num>
+<hit>
+
+<md-title>OIL/GAS DRILLING</md-title><location id="z3950.indexdata.com/gils" name="Index Data GILS test server">
+<md-title>OIL/GAS DRILLING</md-title></location>
+<recid>title oil gas drilling author medium book</recid>
+</hit>
+<hit>
+
+<md-title>GROUNDWATER RESOURCE MAPS - COUNTY SERIES</md-title><location id="z3950.indexdata.com/gils" name="Index Data GILS test server">
+<md-title>GROUNDWATER RESOURCE MAPS - COUNTY SERIES</md-title></location>
+<recid>title groundwater resource maps county series author medium book</recid>
+</hit>
+<hit>
+
+<md-title>BIBLIOGRAPHY OF MAINE GEOLOGY</md-title><location id="z3950.indexdata.com/gils" name="Index Data GILS test server">
+<md-title>BIBLIOGRAPHY OF MAINE GEOLOGY</md-title></location>
+<recid>title bibliography of maine geology author medium book</recid>
+</hit>
+</show>
gils_service.xml
http://localhost:9763/search.pz2?command=init
http://localhost:9763/search.pz1?session=2&command=search&query=computer
+gils_service.xml
+http://localhost:9763/search.pz2?command=init&clear=1
+z3950_indexdata_com_marc.xml
+http://localhost:9763/search.pz1?session=3&command=settings
+http://localhost:9763/search.pz1?session=3&command=search&query=computer
2
-http://localhost:9763/search.pz1?session=2&command=show
http://localhost:9763/search.pz1?session=1&command=show
+http://localhost:9763/search.pz1?session=2&command=show
+http://localhost:9763/search.pz1?session=3&command=show
+http://localhost:9763/search.pz1?session=3&command=bytarget