-/* $Id: zebraapi.c,v 1.166 2005-05-09 10:04:30 adam Exp $
+/* $Id: zebraapi.c,v 1.179 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#include <io.h>
#include <process.h>
#include <direct.h>
-#else
+#endif
+#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <charmap.h>
#include <idzebra/api.h>
+#define DEFAULT_APPROX_LIMIT 2000000000
+
/* simple asserts to validate the most essential input args */
#define ASSERTZH assert(zh && zh->service)
#define ASSERTZHRES assert(zh && zh->service && zh->res)
{
ASSERTZH;
yaz_log(log_level, "zebra_flush_reg");
- zh->errCode = 0;
+ zebra_clearError(zh);
zebraExplain_flush (zh->reg->zei, zh);
extract_flushWriteKeys (zh, 1 /* final */);
zh->num_basenames = 0;
zh->basenames = 0;
+ zh->approx_limit = DEFAULT_APPROX_LIMIT;
zh->trans_no = 0;
zh->trans_w_no = 0;
zh->store_data_buf = 0;
- zh->m_limit = zebra_limit_create(0, 0);
+ zh->m_limit = zebra_limit_create(1, 0);
+
+ zh->nmem_error = nmem_create();
return zh;
}
log_level_initialized = 1;
}
- yaz_log(log_level, "zebra_start %s",configName);
+ yaz_log(YLOG_LOG, "zebra_start %s %s",configName, ZEBRAVER);
assert(configName);
if ((res = res_open (configName, def_res, over_res)))
{
+ const char *passwd_plain = 0;
+ const char *passwd_encrypt = 0;
ZebraService zh = xmalloc(sizeof(*zh));
yaz_log (YLOG_DEBUG, "Read resources `%s'", configName);
zebra_chdir (zh);
zebra_mutex_cond_init (&zh->session_lock);
- if (!res_get (zh->global_res, "passwd"))
+ passwd_plain = res_get (zh->global_res, "passwd");
+ passwd_encrypt = res_get (zh->global_res, "passwd.c");
+
+ if (!passwd_plain && !passwd_encrypt)
zh->passwd_db = NULL;
else
{
- zh->passwd_db = passwd_db_open ();
+ zh->passwd_db = passwd_db_open();
if (!zh->passwd_db)
yaz_log (YLOG_WARN|YLOG_ERRNO, "passwd_db_open failed");
else
- passwd_db_file (zh->passwd_db,
- res_get (zh->global_res, "passwd"));
+ {
+ if (passwd_plain)
+ passwd_db_file_plain(zh->passwd_db, passwd_plain);
+ if (passwd_encrypt)
+ passwd_db_file_crypt(zh->passwd_db, passwd_encrypt);
+ }
}
zh->path_root = res_get (zh->global_res, "root");
zh->nmem = nmem_create();
{
int page_size = 4096;
char resource_str[200];
- const char *v;
sprintf (resource_str, "dict.%.100s.pagesize", name);
assert(bfs);
assert(name);
- v = res_get(res, resource_str);
- if (v)
- {
- page_size = atoi(v);
+ if (res_get_int(res, resource_str, &page_size) == ZEBRA_OK)
yaz_log(YLOG_LOG, "Using custom dictionary page size %d for %s",
page_size, name);
- }
return dict_open(bfs, name, cache, rw, compact_flag, page_size);
}
-
static
struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
int rw, int useshadow, Res res,
reg->dh = data1_createx (DATA1_FLAG_XML);
if (!reg->dh)
+ {
+ xfree(reg);
return 0;
+ }
reg->bfs = bfs_create (res_get (res, "register"), reg_path);
if (!reg->bfs)
{
data1_destroy(reg->dh);
+ xfree(reg);
return 0;
}
if (useshadow)
- bf_cache (reg->bfs, res_get (res, "shadow"));
+ {
+ if (bf_cache (reg->bfs, res_get (res, "shadow")) == ZEBRA_FAIL)
+ {
+ bfs_destroy(reg->bfs);
+ data1_destroy(reg->dh);
+ xfree(reg);
+ return 0;
+ }
+ }
getcwd(cwd, sizeof(cwd)-1);
profilePath = res_get_def(res, "profilePath", DEFAULT_PROFILE_PATH);
reg->sortKeys.buf = 0;
reg->sortKeys.buf_max = 0;
+#if NATTR
+ reg->sortKeys.codec_handle = iscz1_start();
+#endif
reg->records = 0;
reg->dict = 0;
{
ASSERTZH;
yaz_log(log_level, "zebra_admin_shutdown");
- zh->errCode = 0;
+ zebra_clearError(zh);
zebra_mutex_cond_lock (&zh->service->session_lock);
zh->service->stop_flag = 1;
ZebraService zs;
ASSERTZH;
yaz_log(log_level, "zebra_admin_start");
- zh->errCode = 0;
+ zebra_clearError(zh);
zs = zh->service;
zebra_mutex_cond_lock (&zs->session_lock);
zebra_mutex_cond_unlock (&zs->session_lock);
xfree(reg->keys.buf);
if (reg->keys.codec_handle)
iscz1_stop(reg->keys.codec_handle);
+#if NATTR
+ if (reg->sortKeys.codec_handle)
+ iscz1_stop(reg->sortKeys.codec_handle);
+#endif
xfree(reg->key_buf);
xfree(reg->name);
xfree(reg);
zebra_limit_destroy(zh->m_limit);
+ nmem_destroy(zh->nmem_error);
+
xfree(zh->path_reg);
xfree(zh);
return ZEBRA_OK;
zebra_close_res(zh);
}
}
+ if (zh->res)
+ {
+ int approx = 0;
+ if (res_get_int(zh->res, "estimatehits", &approx) == ZEBRA_OK)
+ zebra_set_approx_limit(zh, approx);
+ }
}
void map_basenames_func (void *vp, const char *name, const char *value)
yaz_log(log_level, "map_basenames ");
assert(stream);
- zh->errCode = 0;
-
info.zh = zh;
info.num_bases = *num_bases;
ASSERTZH;
yaz_log(log_level, "zebra_select_database %s",basename);
assert(basename);
- zh->errCode = 0;
return zebra_select_databases (zh, 1, &basename);
}
return ZEBRA_OK;
}
+ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit)
+{
+ if (approx_limit == 0)
+ approx_limit = DEFAULT_APPROX_LIMIT;
+ zh->approx_limit = approx_limit;
+ return ZEBRA_OK;
+}
+
ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
const char *setname, zint *hits)
{
assert(hits);
assert(setname);
yaz_log(log_level, "zebra_search_rpn");
- zh->errCode = 0;
+ zebra_clearError(zh);
zh->hits = 0;
*hits = 0;
return r;
}
-ZEBRA_RES zebra_records_retrieve (ZebraHandle zh, ODR stream,
- const char *setname,
- Z_RecordComposition *comp,
- oid_value input_format, int num_recs,
- ZebraRetrievalRecord *recs)
+ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream,
+ const char *setname,
+ Z_RecordComposition *comp,
+ oid_value input_format, int num_recs,
+ ZebraRetrievalRecord *recs)
{
ZebraMetaRecord *poset;
int i;
assert(num_recs>0);
yaz_log(log_level, "zebra_records_retrieve n=%d", num_recs);
- zh->errCode = 0;
+ zebra_clearError(zh);
if (!zh->res)
{
- zh->errCode = YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST;
- zh->errString = odr_strdup(stream, setname);
+ zebra_setError(zh, YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
+ setname);
return ZEBRA_FAIL;
}
- zh->errCode = 0;
-
if (zebra_begin_read (zh) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (!poset)
{
yaz_log (YLOG_DEBUG, "zebraPosSetCreate error");
- zh->errCode = YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST;
- zh->errString = nmem_strdup (stream->mem, setname);
+ zebra_setError(zh, YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
+ setname);
ret = ZEBRA_FAIL;
}
else
{
char *buf;
int len;
+ zebra_snippets *hit_snippet = zebra_snippets_create();
+
+ zebra_snippets_hit_vector(zh, setname, poset[i].sysno,
+ hit_snippet);
+
recs[i].errCode =
zebra_record_fetch(zh, poset[i].sysno, poset[i].score,
+ hit_snippet,
stream, input_format, comp,
&recs[i].format, &buf, &len,
&recs[i].base, &recs[i].errString);
+
recs[i].len = len;
if (len > 0)
{
recs[i].buf = buf;
recs[i].score = poset[i].score;
recs[i].sysno = poset[i].sysno;
+ zebra_snippets_destroy(hit_snippet);
}
else
{
- char num_str[20];
-
- sprintf (num_str, ZINT_FORMAT, pos_array[i]);
- zh->errCode = YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE;
- zh->errString = odr_strdup (stream, num_str);
- ret = ZEBRA_FAIL;
- break;
+ /* only need to set it once */
+ if (pos_array[i] < zh->approx_limit && ret == ZEBRA_OK)
+ {
+ zebra_setError_zint(zh,
+ YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE,
+ pos_array[i]);
+ ret = ZEBRA_FAIL;
+ break;
+ }
+ recs[i].buf = 0; /* no record and no error issued */
+ recs[i].len = 0;
+ recs[i].errCode = 0;
+ recs[i].format = VAL_NONE;
+ recs[i].sysno = 0;
}
}
zebra_meta_records_destroy(zh, poset, num_recs);
return res;
}
-ZEBRA_RES zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
- oid_value attributeset,
- int *position,
- int *num_entries, ZebraScanEntry **entries,
- int *is_partial)
+ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
+ oid_value attributeset,
+ int *position,
+ int *num_entries, ZebraScanEntry **entries,
+ int *is_partial)
{
ZEBRA_RES res;
ASSERTZH;
assert(is_partial);
assert(entries);
yaz_log(log_level, "zebra_scan");
- zh->errCode = 0;
+ zebra_clearError(zh);
if (zebra_begin_read (zh) == ZEBRA_FAIL)
{
*entries = 0;
Z_SortKeySpecList *sort_sequence,
int *sort_status)
{
+ ZEBRA_RES res;
ASSERTZH;
assert(stream);
assert(num_input_setnames>0);
assert(sort_sequence);
assert(sort_status);
yaz_log(log_level, "zebra_sort");
- zh->errCode = 0;
- if (zebra_begin_read (zh) == ZEBRA_FAIL)
+ zebra_clearError(zh);
+ if (zebra_begin_read(zh) == ZEBRA_FAIL)
return ZEBRA_FAIL;
- resultSetSort (zh, stream->mem, num_input_setnames, input_setnames,
- output_setname, sort_sequence, sort_status);
- return zebra_end_read(zh);
+ res = resultSetSort(zh, stream->mem, num_input_setnames, input_setnames,
+ output_setname, sort_sequence, sort_status);
+ zebra_end_read(zh);
+ return res;
}
int zebra_deleteResultSet(ZebraHandle zh, int function,
ASSERTZH;
assert(statuses);
yaz_log(log_level, "zebra_deleteResultSet n=%d",num_setnames);
- zh->errCode = 0;
+ zebra_clearError(zh);;
if (zebra_begin_read(zh))
return Z_DeleteStatus_systemProblemAtTarget;
switch (function)
const char *zebra_errString (ZebraHandle zh)
{
- const char *e="";
+ const char *e = 0;
if (zh)
e= diagbib1_str (zh->errCode);
yaz_log(log_level, "zebra_errString: %s",e);
char *zebra_errAdd (ZebraHandle zh)
{
- char *a="";
+ char *a = 0;
if (zh)
a= zh->errString;
yaz_log(log_level, "zebra_errAdd: %s",a);
ZebraService zs;
ASSERTZH;
- zh->errCode = 0;
+ zebra_clearError(zh);
zs= zh->service;
sprintf(u, "perm.%.30s", user ? user : "anonymous");
ASSERTZH;
yaz_log(log_level, "zebra_admin_import_begin db=%s rt=%s",
database, record_type);
- zh->errCode = 0;
+ zebra_clearError(zh);
if (zebra_select_database(zh, database) == ZEBRA_FAIL)
return ZEBRA_FAIL;
return zebra_begin_trans(zh, 1);
{
ASSERTZH;
yaz_log(log_level, "zebra_admin_import_end");
- zh->errCode = 0;
+ zebra_clearError(zh);
return zebra_end_trans(zh);
}
int i;
ASSERTZH;
yaz_log(log_level, "zebra_admin_import_segment");
- zh->errCode = 0;
+ zebra_clearError(zh);
for (i = 0; i<segment->num_segmentRecords; i++)
{
Z_NamePlusRecord *npr = segment->segmentRecords[i];
assert(rec_buf);
yaz_log(log_level, "zebra_admin_exchange_record ac=%d", action);
- zh->errCode = 0;
+ zebra_clearError(zh);
if (!recid_buf || recid_len <= 0 || recid_len >= sizeof(recid_z))
return ZEBRA_FAIL;
return 0;
}
-ZEBRA_RES zebra_drop_database (ZebraHandle zh, const char *database)
+ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db)
{
ZEBRA_RES ret = ZEBRA_OK;
ASSERTZH;
- yaz_log(log_level, "zebra_drop_database");
- zh->errCode = 0;
+ yaz_log(log_level, "zebra_drop_database %s", db);
+ zebra_clearError(zh);
- if (zebra_select_database (zh, database) == ZEBRA_FAIL)
+ if (zebra_select_database (zh, db) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (zebra_begin_trans (zh, 1) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (zh->reg->isamb)
{
- zebraExplain_curDatabase (zh->reg->zei, database);
+ zebraExplain_curDatabase (zh->reg->zei, db);
zebraExplain_trav_ord(zh->reg->zei, zh, delete_SU_handle);
zebraExplain_removeDatabase(zh->reg->zei, zh);
return ret;
}
-ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *database)
+ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db)
{
ASSERTZH;
- yaz_log(log_level, "zebra_create_database %s", database);
- assert(database);
- zh->errCode = 0;
+ yaz_log(log_level, "zebra_create_database %s", db);
+ assert(db);
+ zebra_clearError(zh);
- if (zebra_select_database (zh, database) == ZEBRA_FAIL)
+ if (zebra_select_database (zh, db) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (zebra_begin_trans (zh, 1))
return ZEBRA_FAIL;
/* announce database */
- if (zebraExplain_newDatabase (zh->reg->zei, database, 0
+ if (zebraExplain_newDatabase (zh->reg->zei, db, 0
/* explainDatabase */))
{
zebra_end_trans (zh);
- zh->errCode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED;
- zh->errString = "database already exist";
+ zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, db);
return ZEBRA_FAIL;
}
return zebra_end_trans (zh);
assert(input_str);
assert(output_str);
yaz_log(log_level, "zebra_string_norm ");
- zh->errCode = 0;
+ zebra_clearError(zh);
if (!zh->reg->zebra_maps)
return -1;
wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
FILE *f;
ASSERTZH;
yaz_log(log_level, "zebra_set_state v=%d seq=%d", val, seqno);
- zh->errCode = 0;
+ zebra_clearError(zh);
sprintf (state_fname, "state.%s.LCK", zh->reg_name);
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
ASSERTZH;
yaz_log(log_level, "zebra_get_state ");
- zh->errCode = 0;
+ zebra_clearError(zh);
sprintf (state_fname, "state.%s.LCK", zh->reg_name);
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
f = fopen (fname, "r");
zebra_select_default_database(zh);
if (!zh->res)
{
- zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
- zh->errString = "zebra_begin_trans: no database selected";
+ zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR,
+ "zebra_begin_trans: no database selected");
return ZEBRA_FAIL;
}
ASSERTZHRES;
{
if (rw && !strchr(zh->user_perm, 'w'))
{
- zh->errCode =
- YAZ_BIB1_ES_PERMISSION_DENIED_ON_ES_CANNOT_MODIFY_OR_DELETE;
- zh->errString = 0;
+ zebra_setError(
+ zh,
+ YAZ_BIB1_ES_PERMISSION_DENIED_ON_ES_CANNOT_MODIFY_OR_DELETE,
+ 0);
return ZEBRA_FAIL;
}
}
}
if (zh->trans_no != 1)
{
- zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
- zh->errString = "zebra_begin_trans: write trans not allowed within read trans";
+ zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR,
+ "zebra_begin_trans: no write trans within read");
return ZEBRA_FAIL;
}
if (zh->reg)
}
zh->trans_w_no = zh->trans_no;
- zh->errCode = 0;
+ zebra_clearError(zh);
zh->records_inserted = 0;
zh->records_updated = 0;
zh->trans_no--;
zh->trans_w_no = 0;
- zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
- zh->errString = "zebra_begin_trans: cannot open register";
- yaz_log(YLOG_FATAL, zh->errString);
+ zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR,
+ "zebra_begin_trans: cannot open register");
+ yaz_log(YLOG_FATAL, "%s", zh->errString);
return ZEBRA_FAIL;
}
}
zebra_flush_reg (zh);
return ZEBRA_OK;
}
- zh->errCode = 0;
+ zebra_clearError(zh);
#if HAVE_SYS_TIMES_H
times (&zh->tms1);
#endif
if (!zh->res || !zh->reg)
{
- zh->errCode = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
- zh->errString = "zebra_end_trans: no open transaction";
+ zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR,
+ "zebra_end_trans: no open transaction");
return ZEBRA_FAIL;
}
if (zh->trans_no != zh->trans_w_no)
{
ASSERTZH;
assert(path);
- zh->errCode = 0;
+ zebra_clearError(zh);
yaz_log (log_level, "updating %s", path);
repositoryUpdate (zh, path);
return zh->errCode;
{
ASSERTZH;
assert(path);
- zh->errCode = 0;
+ zebra_clearError(zh);
yaz_log (log_level, "deleting %s", path);
repositoryDelete (zh, path);
return zh->errCode;
ASSERTZH;
assert(path);
yaz_log(log_level, "zebra_repository_show");
- zh->errCode = 0;
+ zebra_clearError(zh);
repositoryShow (zh, path);
return zh->errCode;
}
const char *rval;
BFiles bfs;
ASSERTZH;
- zh->errCode = 0;
+ zebra_clearError(zh);
zebra_select_default_database(zh);
if (!zh->res)
BFiles bfs = 0;
ASSERTZH;
yaz_log(log_level, "zebra_init");
- zh->errCode = 0;
+ zebra_clearError(zh);
zebra_select_default_database(zh);
if (!zh->res)
{
- zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
+ zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR,
+ "cannot select default database");
return ZEBRA_FAIL;
}
rval = res_get (zh->res, "shadow");
bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
if (!bfs)
+ {
+ zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, "bfs_create");
return ZEBRA_FAIL;
+ }
if (rval && *rval)
bf_cache (bfs, rval);
BFiles bfs;
ASSERTZH;
yaz_log(log_level, "zebra_compact");
- zh->errCode = 0;
+ zebra_clearError(zh);
if (!zh->res)
{
zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE;
{
ASSERTZH;
yaz_log(log_level, "zebra_shadow_enable");
- zh->errCode = 0;
+ zebra_clearError(zh);
zh->shadow_enable = value;
}
ASSERTZH;
assert(encoding);
yaz_log(log_level, "zebra_octet_term_encoding");
- zh->errCode = 0;
+ zebra_clearError(zh);
if (zh->iconv_to_utf8 != 0)
yaz_iconv_close(zh->iconv_to_utf8);
{
ASSERTZH;
yaz_log(log_level, "zebra_record_encoding");
- zh->errCode = 0;
+ zebra_clearError(zh);
xfree(zh->record_encoding);
zh->record_encoding = 0;
if (encoding)
assert(name);
assert(value);
yaz_log(log_level, "zebra_set_resource %s:%s", name, value);
- zh->errCode = 0;
+ zebra_clearError(zh);
res_set(zh->res, name, value);
}
assert(name);
assert(defaultvalue);
v = res_get_def (zh->res, name, (char *)defaultvalue);
- zh->errCode = 0;
+ zebra_clearError(zh);
yaz_log(log_level, "zebra_get_resource %s:%s", name, v);
return v;
}
*/
ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
- const char *setname, zint *numhits)
+ const char *setname, zint *hits)
{
- zint hits = 0;
+ zint lhits = 0;
ZEBRA_RES res = ZEBRA_OK;
Z_RPNQuery *query;
ODR odr = odr_createmem(ODR_ENCODE);
res = ZEBRA_FAIL;
}
else
- res = zebra_search_RPN(zh, odr, query, setname, &hits);
+ res = zebra_search_RPN(zh, odr, query, setname, &lhits);
odr_destroy(odr);
- yaz_log(log_level, "Hits: " ZINT_FORMAT, hits);
+ yaz_log(log_level, "Hits: " ZINT_FORMAT, lhits);
- if (numhits)
- *numhits = hits;
+ if (hits)
+ *hits = lhits;
return res;
}
/* ---------------------------------------------------------------------------
Set limit for search/scan
*/
-ZEBRA_RES zebra_set_limit(ZebraHandle zh, int exclude_flag, zint *ids)
+ZEBRA_RES zebra_set_limit(ZebraHandle zh, int complement_flag, zint *ids)
{
ASSERTZH;
zebra_limit_destroy(zh->m_limit);
- zh->m_limit = zebra_limit_create(exclude_flag, ids);
+ zh->m_limit = zebra_limit_create(complement_flag, ids);
return ZEBRA_OK;
}
+
+/*
+ Set Error code + addinfo
+*/
+void zebra_setError(ZebraHandle zh, int code, const char *addinfo)
+{
+ zh->errCode = code;
+ nmem_reset(zh->nmem_error);
+ zh->errString = addinfo ? nmem_strdup(zh->nmem_error, addinfo) : 0;
+}
+
+void zebra_setError_zint(ZebraHandle zh, int code, zint i)
+{
+ char vstr[60];
+ sprintf(vstr, ZINT_FORMAT, i);
+
+ zh->errCode = code;
+ nmem_reset(zh->nmem_error);
+ zh->errString = nmem_strdup(zh->nmem_error, vstr);
+}
+