Added parameter clear=1 for init command which makes the session not use
[pazpar2-moved-to-github.git] / src / database.c
index 2553b7c..9228162 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: database.c,v 1.26 2007-05-11 16:57:42 quinn Exp $
+/* $Id: database.c,v 1.29 2007-06-28 09:36:10 adam Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -107,6 +107,7 @@ static struct database *load_database(const char *id)
     struct host *host;
     char hostport[256];
     char *dbname;
+    struct setting *idset;
 
     yaz_log(YLOG_LOG, "New database: %s", id);
     if (!nmem)
@@ -138,7 +139,18 @@ static struct database *load_database(const char *id)
     db->databases[1] = 0;
     db->errors = 0;
     db->explain = explain;
+
     db->settings = 0;
+
+    db->settings = nmem_malloc(nmem, sizeof(struct settings*) * settings_num());
+    memset(db->settings, 0, sizeof(struct settings*) * settings_num());
+    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 = databases;
     databases = db;
 
@@ -247,8 +259,8 @@ int session_grep_databases(struct session *se, struct database_criterion *cl,
     return i;
 }
 
-int grep_databases(void *context, struct database_criterion *cl,
-        void (*fun)(void *context, struct database *db))
+int predef_grep_databases(void *context, struct database_criterion *cl,
+                          void (*fun)(void *context, struct database *db))
 {
     struct database *p;
     int i = 0;