* Copyright (C) 1995-2002, Index Data
* All rights reserved.
*
- * $Id: zebraapi.c,v 1.60 2002-05-07 11:05:19 adam Exp $
+ * $Id: zebraapi.c,v 1.63 2002-07-25 13:06:43 adam Exp $
*/
#include <assert.h>
ZebraHandle zebra_open (ZebraService zs)
{
ZebraHandle zh;
+ const char *default_encoding;
if (!zs)
return 0;
zh->shadow_enable = 1;
+ 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_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_log (LOG_WARN, "iconv: UTF-8 to %s unsupported",
+ default_encoding);
+#endif
+
zebra_mutex_cond_lock (&zs->session_lock);
zh->next = zs->sessions;
struct ISAMC_M_s isamc_m;
if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
- rw, key_isamc_m(res, &isamc_m))))
+ rw, key_isamc_m(res, &isamc_m), 0)))
+ {
+ logf (LOG_WARN, "isamb_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "bc", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+
+ if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
+ rw, key_isamc_m(res, &isamc_m), 1)))
+ {
+ logf (LOG_WARN, "isamb_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "null", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+
+ if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
+ rw, key_isamc_m(res, &isamc_m), -1)))
{
logf (LOG_WARN, "isamb_open");
return 0;
zebra_register_close (zh->service, zh->reg);
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
+
xfree (zh->admin_databaseName);
zebra_mutex_cond_lock (&zs->session_lock);
zebra_lock_destroy (zh->lock_normal);
zh->errString = odr_strdup (stream, setname);
return;
}
+
+ zh->errCode = 0;
if (zebra_begin_read (zh))
return;
zebra_set_state (zh, 'c', seqno);
logf (LOG_LOG, "commit start");
-#ifndef WIN32
- sleep (2);
-#endif
bf_commitExec (bfs);
#ifndef WIN32
sync ();
zh->shadow_enable = value;
}
+int zebra_record_encoding (ZebraHandle zh, const char *encoding)
+{
+ xfree (zh->record_encoding);
+ zh->record_encoding = xstrdup (encoding);
+ return 0;
+}