-/* $Id: database.c,v 1.23 2007-04-21 12:00:54 adam Exp $
+/* $Id: database.c,v 1.28 2007-05-25 03:58:04 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
#include <sys/stat.h>
#include "pazpar2.h"
+#include "host.h"
#include "config.h"
#include "settings.h"
#include "http.h"
struct host *host;
char hostport[256];
char *dbname;
+ struct setting *idset;
yaz_log(YLOG_LOG, "New database: %s", id);
if (!nmem)
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;
return load_database(id);
}
-// This whole session_grep database thing should be moved to pazpar2.c
+// This whole session_grep database thing should be moved elsewhere
int match_zurl(const char *zurl, const char *pattern)
{
{
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);
return i;
}
-// This function will most likely vanish when a proper target profile mechanism is
-// introduced.
-void load_simpletargets(const char *fn)
-{
- FILE *f = fopen(fn, "r");
- char line[256];
-
- if (!f)
- {
- yaz_log(YLOG_WARN|YLOG_ERRNO, "open %s", fn);
- exit(1);
- }
-
- while (fgets(line, 255, f))
- {
- char *url;
- char *name;
- struct database *db;
-
- if (strncmp(line, "target ", 7))
- continue;
- line[strlen(line) - 1] = '\0';
-
- if ((name = strchr(line, ';')))
- *(name++) = '\0';
-
- url = line + 7;
-
- if (!(db = find_database(url, 0)))
- yaz_log(YLOG_WARN, "Unable to load database %s", url);
- }
- fclose(f);
-}
-
-
/*
* Local variables:
* c-basic-offset: 4