X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fdatabase.c;h=92281628553f595eb73b506ec327df09e3cd7402;hb=0ff1a97b2a69905755b9adb24a474d30f1c52150;hp=f43cc75b73ec8fef2c9ac5dc0b6a03803f38a3f8;hpb=78a5114a3d2a330bd7c507c4055af0e94688aef1;p=pazpar2-moved-to-github.git diff --git a/src/database.c b/src/database.c index f43cc75..9228162 100644 --- a/src/database.c +++ b/src/database.c @@ -1,4 +1,4 @@ -/* $Id: database.c,v 1.24 2007-04-22 15:00:56 adam 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. @@ -29,6 +29,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "pazpar2.h" +#include "host.h" #include "config.h" #include "settings.h" #include "http.h" @@ -106,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) @@ -137,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; @@ -235,6 +248,8 @@ int session_grep_databases(struct session *se, struct database_criterion *cl, { if (p->settings && p->settings[PZ_ALLOW] && *p->settings[PZ_ALLOW]->value == '0') continue; + if (!p->settings[PZ_NAME]) + continue; if (database_match_criteria(p->settings, cl)) { (*fun)(se, p); @@ -244,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;