Fix log messages
[idzebra-moved-to-github.git] / index / zebraapi.c
index 0633fd0..ae04ebe 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.66 2002-08-05 19:46:01 adam Exp $
+/* $Id: zebraapi.c,v 1.69 2002-08-29 08:47:08 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
    Index Data Aps
 
@@ -102,18 +102,17 @@ ZebraHandle zebra_open (ZebraService zs)
 
     default_encoding = res_get_def(zs->global_res, "encoding", "ISO-8859-1");
     zh->record_encoding = xstrdup (default_encoding);
-#if HAVE_ICONV_H
+
     zh->iconv_to_utf8 =
-        iconv_open ("UTF-8", default_encoding);
-    if (zh->iconv_to_utf8 == (iconv_t)(-1))
+        yaz_iconv_open ("UTF-8", default_encoding);
+    if (zh->iconv_to_utf8 == 0)
         yaz_log (LOG_WARN, "iconv: %s to UTF-8 unsupported",
            default_encoding);
     zh->iconv_from_utf8 =
-        iconv_open (default_encoding, "UTF-8");
-    if (zh->iconv_to_utf8 == (iconv_t)(-1))
+        yaz_iconv_open (default_encoding, "UTF-8");
+    if (zh->iconv_to_utf8 == 0)
         yaz_log (LOG_WARN, "iconv: UTF-8 to %s unsupported",
            default_encoding);
-#endif
 
     zebra_mutex_cond_lock (&zs->session_lock);
 
@@ -131,9 +130,7 @@ ZebraService zebra_start (const char *configName)
 
     yaz_log (LOG_LOG, "zebra_start %s", configName);
 
-    if (!(res = res_open (configName, 0)))
-       yaz_log (LOG_WARN, "Cannot read resources `%s'", configName);
-    else
+    if ((res = res_open (configName, 0)))
     {
         ZebraService zh = xmalloc (sizeof(*zh));
 
@@ -431,12 +428,11 @@ void zebra_close (ZebraHandle zh)
     zebra_close_res (zh);
 
     xfree (zh->record_encoding);
-#if HAVE_ICONV_H
-    if (zh->iconv_to_utf8 != (iconv_t) (-1))
-        iconv_close (zh->iconv_to_utf8);
-    if (zh->iconv_from_utf8 != (iconv_t) (-1))
-        iconv_close (zh->iconv_from_utf8);
-#endif
+
+    if (zh->iconv_to_utf8 != 0)
+        yaz_iconv_close (zh->iconv_to_utf8);
+    if (zh->iconv_from_utf8 != 0)
+        yaz_iconv_close (zh->iconv_from_utf8);
 
     xfree (zh->admin_databaseName);
     zebra_mutex_cond_lock (&zs->session_lock);
@@ -694,6 +690,11 @@ int zebra_select_databases (ZebraHandle zh, int num_bases,
         zh->errCode = 109;
         return -1;
     }
+    if (!zh->lock_normal || !zh->lock_shadow)
+    {
+        zh->errCode = 2;
+       return -1;
+    }
     return 0;
 }
 
@@ -1008,6 +1009,12 @@ int zebra_begin_read (ZebraHandle zh)
         zh->errCode = 109;
         return -1;
     }
+    if (!zh->lock_normal || !zh->lock_shadow)
+    {
+        (zh->trans_no)--;
+        zh->errCode = 2;
+       return -1;
+    }
     zebra_get_state (zh, &val, &seqno);
     if (val == 'd')
         val = 'o';