-/* $Id: database.c,v 1.15 2007-04-11 19:55:57 quinn Exp $
+/* $Id: database.c,v 1.19 2007-04-18 12:41:38 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
static struct database *load_database(const char *id)
{
- xmlDoc *doc = get_explain_xml(id);
+ xmlDoc *doc = 0;
struct zr_explain *explain = 0;
struct database *db;
struct host *host;
yaz_log(YLOG_LOG, "New database: %s", id);
if (!nmem)
nmem = nmem_create();
- if (doc)
+
+ if (config && config->targetprofiles
+ && (doc = get_explain_xml(id)))
{
explain = zr_read_xml(nmem, xmlDocGetRootElement(doc));
if (!explain)
return 0;
}
+
if (strlen(id) > 255)
return 0;
strcpy(hostport, id);
if (offset == PZ_ID)
{
if (match_zurl(settings[offset]->value, v->value))
- return 1;
- else
- return 0;
+ break;
}
else
{
if (!strcmp(settings[offset]->value, v->value))
- return 1;
- else
- return 0;
+ break;
}
}
- return 0;
+ if (v)
+ return 1;
+ else
+ return 0;
}
int database_match_criteria(struct setting **settings, struct database_criterion *cl)
db->yaz_marc = yaz_marc_create();
yaz_marc_subfield_str(db->yaz_marc, "\t");
+
// See if a native encoding is specified
- if ((s = db->settings[PZ_ENCODING]))
- {
- encoding = s->value;
- break;
- }
- if (!(cm = yaz_iconv_open("utf-8", encoding)))
+ if (db->settings[PZ_ENCODING])
+ encoding = db->settings[PZ_ENCODING]->value;
+
+ cm = yaz_iconv_open("utf-8", encoding);
+ if (!cm)
{
- yaz_log(YLOG_FATAL, "Unable to map from %s to UTF-8", encoding);
+ yaz_log(YLOG_FATAL,
+ "Unable to map from %s to UTF-8 for target %s",
+ encoding, db->url);
exit(1);
}
yaz_marc_iconv(db->yaz_marc, cm);
- break;
}
}