-/* $Id: database.c,v 1.15 2007-04-11 19:55:57 quinn Exp $
+/* $Id: database.c,v 1.18 2007-04-13 00:29:14 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);
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]))
+ if (db->settings[PZ_ENCODING])
+ encoding = db->settings[PZ_ENCODING]->value;
+
+ cm = yaz_iconv_open("utf-8", encoding);
+ if (!cm)
{
- encoding = s->value;
- break;
- }
- if (!(cm = yaz_iconv_open("utf-8", encoding)))
- {
- 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;
}
}