resolve_database(db);
}
-static struct database *load_database(const char *id,
- struct conf_service *service)
+struct database *new_database(const char *id, NMEM nmem)
{
- xmlDoc *doc = 0;
- struct zr_explain *explain = 0;
struct database *db;
char hostport[256];
char *dbname;
struct setting *idset;
- if (service->targetprofiles
- && (doc = get_explain_xml(service->targetprofiles, id)))
- {
- explain = zr_read_xml(service->nmem, xmlDocGetRootElement(doc));
- if (!explain)
- return 0;
- }
-
if (strlen(id) > 255)
return 0;
strcpy(hostport, id);
*(dbname++) = '\0';
else
dbname = "";
- db = nmem_malloc(service->nmem, sizeof(*db));
+ db = nmem_malloc(nmem, sizeof(*db));
memset(db, 0, sizeof(*db));
db->host = 0;
- db->url = nmem_strdup(service->nmem, id);
- db->databases = nmem_malloc(service->nmem, 2 * sizeof(char *));
- db->databases[0] = nmem_strdup(service->nmem, dbname);
+ db->url = nmem_strdup(nmem, id);
+ db->databases = nmem_malloc(nmem, 2 * sizeof(char *));
+ db->databases[0] = nmem_strdup(nmem, dbname);
db->databases[1] = 0;
db->errors = 0;
- db->explain = explain;
+ db->explain = 0;
- db->num_settings = settings_num(service);
- db->settings = nmem_malloc(service->nmem, sizeof(struct settings*) *
+ db->num_settings = PZ_NEGOTIATION_CHARSET+1;
+ db->settings = nmem_malloc(nmem, sizeof(struct settings*) *
db->num_settings);
memset(db->settings, 0, sizeof(struct settings*) * db->num_settings);
- idset = nmem_malloc(service->nmem, sizeof(*idset));
+ idset = nmem_malloc(nmem, sizeof(*idset));
idset->precedence = 0;
idset->name = "pz:id";
idset->target = idset->value = db->url;
idset->next = 0;
db->settings[PZ_ID] = idset;
+ db->next = 0;
+
+ return db;
+}
+static struct database *load_database(const char *id,
+ struct conf_service *service)
+{
+ struct database *db;
+ struct zr_explain *explain = 0;
+ xmlDoc *doc = 0;
+
+ if (service->targetprofiles
+ && (doc = get_explain_xml(service->targetprofiles, id)))
+ {
+ explain = zr_read_xml(service->nmem, xmlDocGetRootElement(doc));
+ if (!explain)
+ return 0;
+ }
+ db = new_database(id, service->nmem);
+ db->explain = explain;
db->next = service->databases;
service->databases = db;
void (*fun)(void *context, struct database *db));
int match_zurl(const char *zurl, const char *pattern);
int resolve_database(struct database *db);
-
+struct database *new_database(const char *id, NMEM nmem);
#endif
{
http_sessions_t hs = xmalloc(sizeof(*hs));
hs->session_list = 0;
+ hs->mutex = 0;
yaz_mutex_create(&hs->mutex);
return hs;
}
// Will be extended to take into account user associated with session
const char *session_setting_oneval(struct session_database *db, int offset)
{
- if (!db->settings[offset])
+ if (offset >= db->num_settings || !db->settings[offset])
return "";
return db->settings[offset]->value;
}
sizeof(struct settings *) * db->num_settings);
new->num_settings = db->num_settings;
for (i = 0; i < db->num_settings; i++)
- new->settings[i] = db->settings[i];
+ {
+ struct setting *setting = db->settings[i];
+ new->settings[i] = setting;
+ }
new->next = se->databases;
se->databases = new;
}
static struct session_database *load_session_database(struct session *se,
char *id)
{
- struct database *db = find_database(id, se->service);
+ struct database *db = new_database(id, se->session_nmem);
resolve_database(db);
session_init_databases_fun((void*) se, db);
+
// New sdb is head of se->databases list
return se->databases;
}
http://localhost:9763/search.pz2?session=4&command=settings&pz:name%5Bz3950.indexdata.com%2Fgils%5D=gils&pz:requestsyntax%5Bz3950.indexdata.com%2Fgils%5D=usmarc&pz:nativesyntax%5Bz3950.indexdata.com%2Fgils%5D=iso2709&pz:xslt%5Bz3950.indexdata.com%2Fgils%5D=marc21.mmap
http://localhost:9763/search.pz2?session=4&command=search&query=computer
2 http://localhost:9763/search.pz2?session=4&command=show&block=1
-http://localhost:9763/search.pz2?command=init&clear=1
+http://localhost:9763/search.pz2?command=init
http://localhost:9763/search.pz2?session=5&command=settings&pz:name%5Bz3950.indexdata.com%2Fmarc%5D=marc&pz:requestsyntax%5Bz3950.indexdata.com%2Fmarc%5D=usmarc&pz:nativesyntax%5Bz3950.indexdata.com%2Fmarc%5D=iso2709&pz:xslt%5Bz3950.indexdata.com%2Fmarc%5D=marc21.xsl&pz:recordfilter%5Bz3950.indexdata.com%2Fmarc%5D=date
http://localhost:9763/search.pz2?session=5&command=search&query=computer&filter=pz%3Aid%3Dz3950.indexdata.com%2Fmarc
2 http://localhost:9763/search.pz2?session=5&command=show&block=1
<?xml version="1.0" encoding="UTF-8"?>
<bytarget><status>OK</status>
<target><id>z3950.indexdata.com/marc</id>
-<name>Target name</name>
+<name>1</name>
<hits>0</hits>
<diagnostic>0</diagnostic>
<records>0</records>
<state>Client_Idle</state>
<settings>
-<set name="pz:elements" value="F"/><set name="pz:elements" value="F"/>
-<set name="pz:requestsyntax" value="marc21"/>
-<set name="pz:cclmap:term" value="u=1016"/><set name="pz:cclmap:term" value="u=host_wildcard"/>
+<set name="pz:elements" value="F"/>
+<set name="pz:cclmap:term" value="u=1016"/>
<set name="pz:id" value="z3950.indexdata.com/marc"/>
-<set name="pz:name" value="Target name"/>
-<set name="category" value="1"/>
+<set name="pz:name" value="1"/>
</settings>
</target></bytarget>
\ No newline at end of file
http://localhost:9763/search.pz2?command=init&clear=1
http://localhost:9763/search.pz2?session=1&command=settings&category%5Bz3950.indexdata.com%2Fmarc%5D=1
http://localhost:9763/search.pz2?session=1&command=search&query=water
-http://localhost:9763/search.pz2?session=2&command=settings&category%5Bz3950.indexdata.com%2Fmarc%5D=1&pz:cclmap:term%5Bz3950.indexdata.com%2Fmarc%5D=u%3D1016&pz:elements%5Bz3950.indexdata.com%2Fmarc%5D=F
+http://localhost:9763/search.pz2?session=2&command=settings&pz:name%5Bz3950.indexdata.com%2Fmarc%5D=1&pz:cclmap:term%5Bz3950.indexdata.com%2Fmarc%5D=u%3D1016&pz:elements%5Bz3950.indexdata.com%2Fmarc%5D=F
http://localhost:9763/search.pz2?session=2&command=search&query=water
2 http://localhost:9763/search.pz2?session=1&command=bytarget&settings=1
http://localhost:9763/search.pz2?session=2&command=bytarget&settings=1