added five asserts to make sure that the arguments of reclist_insert do exist
[pazpar2-moved-to-github.git] / src / database.c
index ab6fa8b..67e7ea2 100644 (file)
@@ -1,4 +1,4 @@
-/* $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.
@@ -126,7 +126,7 @@ static struct host *find_host(const char *hostport)
 
 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;
@@ -136,12 +136,15 @@ static struct database *load_database(const char *id)
     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);
@@ -324,19 +327,20 @@ static void prepare_yazmarc(void *ignore, struct database *db)
 
             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;
         }
 }