projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Re-estabslished rank-1. Gets same order of results, but slightly different
[idzebra-moved-to-github.git]
/
index
/
zebraapi.c
diff --git
a/index/zebraapi.c
b/index/zebraapi.c
index
d1a3cce
..
e97e27c
100644
(file)
--- a/
index/zebraapi.c
+++ b/
index/zebraapi.c
@@
-1,4
+1,4
@@
-/* $Id: zebraapi.c,v 1.129 2004-09-09 09:07:12 adam Exp $
+/* $Id: zebraapi.c,v 1.137 2004-10-26 15:32:11 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
@@
-43,13
+43,7
@@
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define ASSERTZHRES assert(zh && zh->service && zh->res)
#define ASSERTZS assert(zs)
#define ASSERTZHRES assert(zh && zh->service && zh->res)
#define ASSERTZS assert(zs)
-/* A simple log macro */
-/* don't break with older yazen that lack log_app2 */
-#ifdef LOG_APP2
#define LOG_API LOG_APP2
#define LOG_API LOG_APP2
-#else
-#define LOG_API LOG_DEBUG
-#endif
static Res zebra_open_res (ZebraHandle zh);
static void zebra_close_res (ZebraHandle zh);
static Res zebra_open_res (ZebraHandle zh);
static void zebra_close_res (ZebraHandle zh);
@@
-93,7
+87,6
@@
ZebraHandle zebra_open (ZebraService zs)
{
ZebraHandle zh;
const char *default_encoding;
{
ZebraHandle zh;
const char *default_encoding;
- ASSERTZS;
yaz_log(LOG_API,"zebra_open");
if (!zs)
yaz_log(LOG_API,"zebra_open");
if (!zs)
@@
-157,7
+150,8
@@
ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
{
Res res;
{
Res res;
- yaz_log(LOG_API|LOG_LOG,"zebra_start %s",configName);
+ yaz_log(LOG_API,"zebra_start %s",configName);
+ assert(configName);
if ((res = res_open (configName, def_res, over_res)))
{
if ((res = res_open (configName, def_res, over_res)))
{
@@
-184,14
+178,24
@@
ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
res_get (zh->global_res, "passwd"));
}
zh->path_root = res_get (zh->global_res, "root");
res_get (zh->global_res, "passwd"));
}
zh->path_root = res_get (zh->global_res, "root");
+ zh->nmem = nmem_create();
+ zh->record_classes = recTypeClass_create (zh->global_res, zh->nmem);
return zh;
}
return 0;
}
return zh;
}
return 0;
}
+void zebra_filter_info(ZebraService zs, void *cd,
+ void (*cb)(void *cd, const char *name))
+{
+ ASSERTZS;
+ assert(cb);
+ recTypeClass_info(zs->record_classes, cd, cb);
+}
void zebra_pidfname(ZebraService zs, char *path)
{
void zebra_pidfname(ZebraService zs, char *path)
{
+ ASSERTZS;
zebra_lock_prefix (zs->global_res, path);
strcat(path, "zebrasrv.pid");
}
zebra_lock_prefix (zs->global_res, path);
strcat(path, "zebrasrv.pid");
}
@@
-203,6
+207,8
@@
Dict dict_open_res (BFiles bfs, const char *name, int cache, int rw,
char resource_str[200];
const char *v;
sprintf (resource_str, "dict.%.100s.pagesize", name);
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)
v = res_get(res, resource_str);
if (v)
@@
-238,7
+244,7
@@
struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
assert (res);
assert (res);
- yaz_log (LOG_LOG|LOG_API, "zebra_register_open rw = %d useshadow=%d p=%p,n=%s,rp=%s",
+ yaz_log (LOG_DEBUG, "zebra_register_open rw=%d useshadow=%d p=%p n=%s rp=%s",
rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
reg->dh = data1_createx (DATA1_FLAG_XML);
rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
reg->dh = data1_createx (DATA1_FLAG_XML);
@@
-255,12
+261,11
@@
struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
getcwd(cwd, sizeof(cwd)-1);
profilePath = res_get_def(res, "profilePath", DEFAULT_PROFILE_PATH);
getcwd(cwd, sizeof(cwd)-1);
profilePath = res_get_def(res, "profilePath", DEFAULT_PROFILE_PATH);
- yaz_log(LOG_LOG, "profilePath=%s cwd=%s", profilePath, cwd);
+ yaz_log(LOG_DEBUG, "profilePath=%s cwd=%s", profilePath, cwd);
data1_set_tabpath (reg->dh, profilePath);
data1_set_tabroot (reg->dh, reg_path);
data1_set_tabpath (reg->dh, profilePath);
data1_set_tabroot (reg->dh, reg_path);
- reg->recTypes = recTypes_init (reg->dh);
- recTypes_default_handlers (reg->recTypes);
+ reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
reg->zebra_maps = zebra_maps_open (res, reg_path);
reg->rank_classes = NULL;
reg->zebra_maps = zebra_maps_open (res, reg_path);
reg->rank_classes = NULL;
@@
-269,9
+274,7
@@
struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
reg->keys.buf_max = 0;
reg->keys.buf = 0;
reg->keys.buf_max = 0;
reg->keys.buf = 0;
-#if IT_KEY_NEW
reg->keys.codec_handle = iscz1_start();
reg->keys.codec_handle = iscz1_start();
-#endif
reg->sortKeys.buf = 0;
reg->sortKeys.buf_max = 0;
reg->sortKeys.buf = 0;
reg->sortKeys.buf_max = 0;
@@
-289,8
+292,10
@@
struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
reg->ptr_i=0;
zebraRankInstall (reg, rank1_class);
reg->ptr_i=0;
zebraRankInstall (reg, rank1_class);
+#ifdef SKIPTHIS /* FIXME - those ranks not yet converted to new interface */
zebraRankInstall (reg, rankzv_class);
zebraRankInstall (reg, rankliv_class);
zebraRankInstall (reg, rankzv_class);
zebraRankInstall (reg, rankliv_class);
+#endif
recordCompression = res_get_def (res, "recordCompression", "none");
if (!strcmp (recordCompression, "none"))
recordCompression = res_get_def (res, "recordCompression", "none");
if (!strcmp (recordCompression, "none"))
@@
-410,7
+415,8
@@
int zebra_admin_start (ZebraHandle zh)
static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
{
ASSERTZS;
static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
{
ASSERTZS;
- yaz_log(LOG_LOG|LOG_API, "zebra_register_close p=%p", reg);
+ assert(reg);
+ yaz_log(LOG_DEBUG, "zebra_register_close p=%p", reg);
reg->stop_flag = 0;
zebra_chdir (zs);
if (reg->records)
reg->stop_flag = 0;
zebra_chdir (zs);
if (reg->records)
@@
-437,11
+443,8
@@
static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
xfree (reg->sortKeys.buf);
xfree (reg->keys.buf);
xfree (reg->sortKeys.buf);
xfree (reg->keys.buf);
-#if IT_KEY_NEW
if (reg->keys.codec_handle)
iscz1_stop(reg->keys.codec_handle);
if (reg->keys.codec_handle)
iscz1_stop(reg->keys.codec_handle);
-#endif
-
xfree (reg->key_buf);
xfree (reg->name);
xfree (reg);
xfree (reg->key_buf);
xfree (reg->name);
xfree (reg);
@@
-451,7
+454,7
@@
int zebra_stop(ZebraService zs)
{
if (!zs)
return 0;
{
if (!zs)
return 0;
- yaz_log (LOG_LOG|LOG_API, "zebra_stop");
+ yaz_log (LOG_API, "zebra_stop");
while (zs->sessions)
{
while (zs->sessions)
{
@@
-463,6
+466,8
@@
int zebra_stop(ZebraService zs)
if (zs->passwd_db)
passwd_db_close (zs->passwd_db);
if (zs->passwd_db)
passwd_db_close (zs->passwd_db);
+ recTypeClass_destroy(zs->record_classes);
+ nmem_destroy(zs->nmem);
res_close (zs->global_res);
xfree (zs->configName);
xfree (zs);
res_close (zs->global_res);
xfree (zs->configName);
xfree (zs);
@@
-639,6
+644,10
@@
void map_basenames_func (void *vp, const char *name, const char *value)
struct map_baseinfo *p = (struct map_baseinfo *) vp;
int i, no;
char fromdb[128], todb[8][128];
struct map_baseinfo *p = (struct map_baseinfo *) vp;
int i, no;
char fromdb[128], todb[8][128];
+
+ assert(value);
+ assert(name);
+ assert(vp);
no =
sscanf (value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s",
no =
sscanf (value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s",
@@
-670,6
+679,8
@@
void map_basenames (ZebraHandle zh, ODR stream,
int i;
ASSERTZH;
yaz_log(LOG_API,"map_basenames ");
int i;
ASSERTZH;
yaz_log(LOG_API,"map_basenames ");
+ assert(stream);
+
zh->errCode=0;
info.zh = zh;
zh->errCode=0;
info.zh = zh;
@@
-692,13
+703,14
@@
void map_basenames (ZebraHandle zh, ODR stream,
*num_bases = info.new_num_bases;
*basenames = info.new_basenames;
for (i = 0; i<*num_bases; i++)
*num_bases = info.new_num_bases;
*basenames = info.new_basenames;
for (i = 0; i<*num_bases; i++)
- logf (LOG_LOG, "base %s", (*basenames)[i]);
+ logf (LOG_DEBUG, "base %s", (*basenames)[i]);
}
int zebra_select_database (ZebraHandle zh, const char *basename)
{
ASSERTZH;
yaz_log(LOG_API,"zebra_select_database %s",basename);
}
int zebra_select_database (ZebraHandle zh, const char *basename)
{
ASSERTZH;
yaz_log(LOG_API,"zebra_select_database %s",basename);
+ assert(basename);
zh->errCode=0;
return zebra_select_databases (zh, 1, &basename);
}
zh->errCode=0;
return zebra_select_databases (zh, 1, &basename);
}
@@
-711,6
+723,8
@@
int zebra_select_databases (ZebraHandle zh, int num_bases,
int len = 0;
char *new_reg = 0;
ASSERTZH;
int len = 0;
char *new_reg = 0;
ASSERTZH;
+ assert(basenames);
+
yaz_log(LOG_API,"zebra_select_databases n=%d [0]=%s",
num_bases,basenames[0]);
zh->errCode=0;
yaz_log(LOG_API,"zebra_select_databases n=%d [0]=%s",
num_bases,basenames[0]);
zh->errCode=0;
@@
-788,6
+802,10
@@
int zebra_search_RPN (ZebraHandle zh, ODR o,
const char *max;
zint maxhits;
ASSERTZH;
const char *max;
zint maxhits;
ASSERTZH;
+ assert(o);
+ assert(query);
+ assert(hits);
+ assert(setname);
yaz_log(LOG_API,"zebra_search_rpn");
zh->errCode=0;
zh->hits = 0;
yaz_log(LOG_API,"zebra_search_rpn");
zh->errCode=0;
zh->hits = 0;
@@
-796,7
+814,9
@@
int zebra_search_RPN (ZebraHandle zh, ODR o,
if (zebra_begin_read (zh))
return 1;
if (zebra_begin_read (zh))
return 1;
+#ifdef SKIPTHIS /* FIXME - livcode rank not yet available */
zebra_livcode_transform(zh, query);
zebra_livcode_transform(zh, query);
+#endif
resultSetAddRPN (zh, odr_extract_mem(o), query,
zh->num_basenames, zh->basenames, setname);
resultSetAddRPN (zh, odr_extract_mem(o), query,
zh->num_basenames, zh->basenames, setname);
@@
-807,13
+827,13
@@
int zebra_search_RPN (ZebraHandle zh, ODR o,
maxhits=atoi(max);
else {
int i=0;
maxhits=atoi(max);
else {
int i=0;
- maxhits=INT_MAX;
+ maxhits=INT_MAX; /* properly rounded, to make it look like a limit*/
while (maxhits>100) { maxhits/=10; i++;}
while (i--) maxhits *= 10;
}
if (zh->hits > maxhits) { /* too large for yaz to handle */
while (maxhits>100) { maxhits/=10; i++;}
while (i--) maxhits *= 10;
}
if (zh->hits > maxhits) { /* too large for yaz to handle */
- logf(LOG_LOG,"limiting hits to "ZINT_FORMAT, maxhits);
- *hits=maxhits; /* round it down to two digits, to look like rounded */
+ logf(LOG_DEBUG,"limiting hits to "ZINT_FORMAT, maxhits);
+ *hits=maxhits;
}
else
*hits = zh->hits;
}
else
*hits = zh->hits;
@@
-828,6
+848,11
@@
int zebra_records_retrieve (ZebraHandle zh, ODR stream,
ZebraPosSet poset;
int i, *pos_array, ret = 0;
ASSERTZH;
ZebraPosSet poset;
int i, *pos_array, ret = 0;
ASSERTZH;
+ assert(stream);
+ assert(setname);
+ assert(recs);
+ assert(num_recs>0);
+
yaz_log(LOG_API,"zebra_records_retrieve n=%d",num_recs);
zh->errCode=0;
yaz_log(LOG_API,"zebra_records_retrieve n=%d",num_recs);
zh->errCode=0;
@@
-900,6
+925,12
@@
int zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
int *is_partial)
{
ASSERTZH;
int *is_partial)
{
ASSERTZH;
+ assert(stream);
+ assert(zapt);
+ assert(position);
+ assert(num_entries);
+ assert(is_partial);
+ assert(entries);
yaz_log(LOG_API,"zebra_scan");
zh->errCode=0;
if (zebra_begin_read (zh))
yaz_log(LOG_API,"zebra_scan");
zh->errCode=0;
if (zebra_begin_read (zh))
@@
-921,6
+952,11
@@
int zebra_sort (ZebraHandle zh, ODR stream,
int *sort_status)
{
ASSERTZH;
int *sort_status)
{
ASSERTZH;
+ assert(stream);
+ assert(num_input_setnames>0);
+ assert(input_setnames);
+ assert(sort_sequence);
+ assert(sort_status);
yaz_log(LOG_API,"zebra_sort");
zh->errCode=0;
if (zebra_begin_read (zh))
yaz_log(LOG_API,"zebra_sort");
zh->errCode=0;
if (zebra_begin_read (zh))
@@
-937,6
+973,9
@@
int zebra_deleleResultSet(ZebraHandle zh, int function,
{
int i, status;
ASSERTZH;
{
int i, status;
ASSERTZH;
+ assert(num_setnames>0);
+ assert(setnames);
+ assert(statuses);
yaz_log(LOG_API,"zebra_deleleResultSet n=%d",num_setnames);
zh->errCode=0;
if (zebra_begin_read(zh))
yaz_log(LOG_API,"zebra_deleleResultSet n=%d",num_setnames);
zh->errCode=0;
if (zebra_begin_read(zh))
@@
-1055,6
+1094,7
@@
int zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
Z_NamePlusRecord *npr = segment->segmentRecords[i];
printf ("--------------%d--------------------\n", i);
Z_NamePlusRecord *npr = segment->segmentRecords[i];
printf ("--------------%d--------------------\n", i);
+ /* FIXME - What! printing on stdout ??? */
if (npr->which == Z_NamePlusRecord_intermediateFragment)
{
Z_FragmentSyntax *fragment = npr->u.intermediateFragment;
if (npr->which == Z_NamePlusRecord_intermediateFragment)
{
Z_FragmentSyntax *fragment = npr->u.intermediateFragment;
@@
-1093,6
+1133,9
@@
int zebra_admin_exchange_record (ZebraHandle zh,
char *rinfo = 0;
char recid_z[256];
ASSERTZH;
char *rinfo = 0;
char recid_z[256];
ASSERTZH;
+ assert(action>0 && action <=4);
+ assert(rec_buf);
+
yaz_log(LOG_API,"zebra_admin_exchange_record ac=%d", action);
zh->errCode=0;
yaz_log(LOG_API,"zebra_admin_exchange_record ac=%d", action);
zh->errCode=0;
@@
-1150,6
+1193,7
@@
int delete_w_handle(const char *info, void *handle)
{
ZebraHandle zh = (ZebraHandle) handle;
ISAMC_P pos;
{
ZebraHandle zh = (ZebraHandle) handle;
ISAMC_P pos;
+ ASSERTZH;
if (*info == sizeof(pos))
{
if (*info == sizeof(pos))
{
@@
-1204,7
+1248,8
@@
int zebra_drop_database (ZebraHandle zh, const char *database)
int zebra_create_database (ZebraHandle zh, const char *database)
{
ASSERTZH;
int zebra_create_database (ZebraHandle zh, const char *database)
{
ASSERTZH;
- yaz_log(LOG_API,"zebra_create_database");
+ yaz_log(LOG_API,"zebra_create_database %s",database);
+ assert(database);
zh->errCode=0;
if (zebra_select_database (zh, database))
zh->errCode=0;
if (zebra_select_database (zh, database))
@@
-1231,6
+1276,8
@@
int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
{
WRBUF wrbuf;
ASSERTZH;
{
WRBUF wrbuf;
ASSERTZH;
+ assert(input_str);
+ assert(output_str);
yaz_log(LOG_API,"zebra_string_norm ");
zh->errCode=0;
if (!zh->reg->zebra_maps)
yaz_log(LOG_API,"zebra_string_norm ");
zh->errCode=0;
if (!zh->reg->zebra_maps)
@@
-1249,6
+1296,7
@@
int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
int zebra_set_state (ZebraHandle zh, int val, int seqno)
int zebra_set_state (ZebraHandle zh, int val, int seqno)
+ /* FIXME - zint seqno ?? */
{
char state_fname[256];
char *fname;
{
char state_fname[256];
char *fname;
@@
-1262,7
+1310,7
@@
int zebra_set_state (ZebraHandle zh, int val, int seqno)
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
f = fopen (fname, "w");
fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
f = fopen (fname, "w");
- yaz_log (LOG_DEBUG, "%c %d %ld", val, seqno, p);
+ yaz_log (LOG_DEBUG, "zebra_set_state: %c %d %ld", val, seqno, p);
fprintf (f, "%c %d %ld\n", val, seqno, p);
fclose (f);
xfree (fname);
fprintf (f, "%c %d %ld\n", val, seqno, p);
fclose (f);
xfree (fname);
@@
-1307,6
+1355,7
@@
static void read_res_for_transaction(ZebraHandle zh)
{
const char *group = res_get(zh->res, "group");
const char *v;
{
const char *group = res_get(zh->res, "group");
const char *v;
+ /* FIXME - do we still use groups ?? */
zh->m_group = group;
v = res_get_prefix(zh->res, "followLinks", group, "1");
zh->m_group = group;
v = res_get_prefix(zh->res, "followLinks", group, "1");
@@
-1333,6
+1382,7
@@
static void read_res_for_transaction(ZebraHandle zh)
int zebra_begin_trans (ZebraHandle zh, int rw)
{
int zebra_begin_trans (ZebraHandle zh, int rw)
{
+ ASSERTZH;
if (!zh->res)
{
zh->errCode = 2;
if (!zh->res)
{
zh->errCode = 2;
@@
-1409,7
+1459,7
@@
int zebra_begin_trans (ZebraHandle zh, int rw)
zebra_get_state (zh, &val, &seqno);
if (val == 'c')
{
zebra_get_state (zh, &val, &seqno);
if (val == 'c')
{
- yaz_log (LOG_LOG, "previous transaction didn't finish commit");
+ yaz_log (LOG_WARN, "previous transaction didn't finish commit");
zebra_unlock (zh->lock_shadow);
zebra_unlock (zh->lock_normal);
zebra_commit (zh);
zebra_unlock (zh->lock_shadow);
zebra_unlock (zh->lock_normal);
zebra_commit (zh);
@@
-1421,7
+1471,7
@@
int zebra_begin_trans (ZebraHandle zh, int rw)
{
BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
zh->path_reg);
{
BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
zh->path_reg);
- yaz_log (LOG_LOG, "previous transaction didn't reach commit");
+ yaz_log (LOG_WARN, "previous transaction didn't reach commit");
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
}
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
}
@@
-1498,13
+1548,13
@@
int zebra_begin_trans (ZebraHandle zh, int rw)
dirty = 1;
else if (seqno != zh->reg->seqno)
{
dirty = 1;
else if (seqno != zh->reg->seqno)
{
- yaz_log (LOG_LOG, "reopen seqno cur/old %d/%d",
+ yaz_log (LOG_DEBUG, "reopen seqno cur/old %d/%d",
seqno, zh->reg->seqno);
dirty = 1;
}
else if (zh->reg->last_val != val)
{
seqno, zh->reg->seqno);
dirty = 1;
}
else if (zh->reg->last_val != val)
{
- yaz_log (LOG_LOG, "reopen last cur/old %d/%d",
+ yaz_log (LOG_DEBUG, "reopen last cur/old %d/%d",
val, zh->reg->last_val);
dirty = 1;
}
val, zh->reg->last_val);
dirty = 1;
}
@@
-1541,6
+1591,7
@@
int zebra_begin_trans (ZebraHandle zh, int rw)
int zebra_end_trans (ZebraHandle zh)
{
int zebra_end_trans (ZebraHandle zh)
{
+ ASSERTZH;
ZebraTransactionStatus dummy;
yaz_log(LOG_API,"zebra_end_trans");
return zebra_end_transaction(zh, &dummy);
ZebraTransactionStatus dummy;
yaz_log(LOG_API,"zebra_end_trans");
return zebra_end_transaction(zh, &dummy);
@@
-1553,6
+1604,7
@@
int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
const char *rval;
ASSERTZH;
const char *rval;
ASSERTZH;
+ assert(status);
yaz_log(LOG_API,"zebra_end_transaction");
status->processed = 0;
yaz_log(LOG_API,"zebra_end_transaction");
status->processed = 0;
@@
-1584,7
+1636,7
@@
int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
zh->trans_no--;
zh->trans_w_no = 0;
zh->trans_no--;
zh->trans_w_no = 0;
- yaz_log (LOG_LOG, "zebra_end_trans");
+ yaz_log (LOG_DEBUG, "zebra_end_trans");
rval = res_get (zh->res, "shadow");
zebraExplain_runNumberIncrement (zh->reg->zei, 1);
rval = res_get (zh->res, "shadow");
zebraExplain_runNumberIncrement (zh->reg->zei, 1);
@@
-1610,7
+1662,7
@@
int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
if (val != 'd')
{
BFiles bfs = bfs_create (rval, zh->path_reg);
if (val != 'd')
{
BFiles bfs = bfs_create (rval, zh->path_reg);
- yaz_log (LOG_LOG, "deleting shadow stuff val=%c", val);
+ yaz_log (LOG_DEBUG, "deleting shadow val=%c", val);
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
}
bf_commitClean (bfs, rval);
bfs_destroy (bfs);
}
@@
-1637,8
+1689,9
@@
int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
int zebra_repository_update (ZebraHandle zh, const char *path)
{
ASSERTZH;
int zebra_repository_update (ZebraHandle zh, const char *path)
{
ASSERTZH;
+ assert(path);
zh->errCode=0;
zh->errCode=0;
- logf (LOG_LOG|LOG_API, "updating %s", path);
+ logf (LOG_API, "updating %s", path);
repositoryUpdate (zh, path);
return zh->errCode;
}
repositoryUpdate (zh, path);
return zh->errCode;
}
@@
-1646,8
+1699,9
@@
int zebra_repository_update (ZebraHandle zh, const char *path)
int zebra_repository_delete (ZebraHandle zh, const char *path)
{
ASSERTZH;
int zebra_repository_delete (ZebraHandle zh, const char *path)
{
ASSERTZH;
+ assert(path);
zh->errCode=0;
zh->errCode=0;
- logf (LOG_LOG|LOG_API, "deleting %s", path);
+ logf (LOG_API, "deleting %s", path);
repositoryDelete (zh, path);
return zh->errCode;
}
repositoryDelete (zh, path);
return zh->errCode;
}
@@
-1655,6
+1709,7
@@
int zebra_repository_delete (ZebraHandle zh, const char *path)
int zebra_repository_show (ZebraHandle zh, const char *path)
{
ASSERTZH;
int zebra_repository_show (ZebraHandle zh, const char *path)
{
ASSERTZH;
+ assert(path);
yaz_log(LOG_API,"zebra_repository_show");
zh->errCode=0;
repositoryShow (zh, path);
yaz_log(LOG_API,"zebra_repository_show");
zh->errCode=0;
repositoryShow (zh, path);
@@
-1700,13
+1755,13
@@
static int zebra_commit_ex (ZebraHandle zh, int clean_only)
{
zebra_set_state (zh, 'c', seqno);
{
zebra_set_state (zh, 'c', seqno);
- logf (LOG_LOG, "commit start");
+ logf (LOG_DEBUG, "commit start");
bf_commitExec (bfs);
#ifndef WIN32
sync ();
#endif
}
bf_commitExec (bfs);
#ifndef WIN32
sync ();
#endif
}
- logf (LOG_LOG, "commit clean");
+ logf (LOG_DEBUG, "commit clean");
bf_commitClean (bfs, rval);
seqno++;
zebra_set_state (zh, 'o', seqno);
bf_commitClean (bfs, rval);
seqno++;
zebra_set_state (zh, 'o', seqno);
@@
-1724,12
+1779,14
@@
static int zebra_commit_ex (ZebraHandle zh, int clean_only)
int zebra_clean (ZebraHandle zh)
{
int zebra_clean (ZebraHandle zh)
{
+ ASSERTZH;
yaz_log(LOG_API,"zebra_clean");
return zebra_commit_ex(zh, 1);
}
int zebra_commit (ZebraHandle zh)
{
yaz_log(LOG_API,"zebra_clean");
return zebra_commit_ex(zh, 1);
}
int zebra_commit (ZebraHandle zh)
{
+ ASSERTZH;
yaz_log(LOG_API,"zebra_commit");
return zebra_commit_ex(zh, 0);
}
yaz_log(LOG_API,"zebra_commit");
return zebra_commit_ex(zh, 0);
}
@@
-1751,6
+1808,8
@@
int zebra_init (ZebraHandle zh)
bfs = bfs_create (res_get (zh->service->global_res, "register"),
zh->path_reg);
bfs = bfs_create (res_get (zh->service->global_res, "register"),
zh->path_reg);
+ if (!bfs)
+ return -1;
if (rval && *rval)
bf_cache (bfs, rval);
if (rval && *rval)
bf_cache (bfs, rval);
@@
-1798,6
+1857,7
@@
int zebra_shadow_enable (ZebraHandle zh, int value)
int zebra_record_encoding (ZebraHandle zh, const char *encoding)
{
ASSERTZH;
int zebra_record_encoding (ZebraHandle zh, const char *encoding)
{
ASSERTZH;
+ assert(encoding);
yaz_log(LOG_API,"zebra_record_encoding");
zh->errCode=0;
xfree (zh->record_encoding);
yaz_log(LOG_API,"zebra_record_encoding");
zh->errCode=0;
xfree (zh->record_encoding);
@@
-1831,6
+1891,8
@@
int zebra_record_encoding (ZebraHandle zh, const char *encoding)
int zebra_set_resource(ZebraHandle zh, const char *name, const char *value)
{
ASSERTZH;
int zebra_set_resource(ZebraHandle zh, const char *name, const char *value)
{
ASSERTZH;
+ assert(name);
+ assert(value);
yaz_log(LOG_API,"zebra_set_resource %s:%s",name,value);
zh->errCode=0;
res_set(zh->res, name, value);
yaz_log(LOG_API,"zebra_set_resource %s:%s",name,value);
zh->errCode=0;
res_set(zh->res, name, value);
@@
-1842,6
+1904,8
@@
const char *zebra_get_resource(ZebraHandle zh,
{
const char *v;
ASSERTZH;
{
const char *v;
ASSERTZH;
+ assert(name);
+ assert(defaultvalue);
v= res_get_def( zh->res, name, (char *)defaultvalue);
zh->errCode=0;
yaz_log(LOG_API,"zebra_get_resource %s:%s",name,v);
v= res_get_def( zh->res, name, (char *)defaultvalue);
zh->errCode=0;
yaz_log(LOG_API,"zebra_get_resource %s:%s",name,v);
@@
-1860,12
+1924,14
@@
int zebra_trans_no (ZebraHandle zh)
int zebra_get_shadow_enable (ZebraHandle zh)
{
int zebra_get_shadow_enable (ZebraHandle zh)
{
+ ASSERTZH;
yaz_log(LOG_API,"zebra_get_shadow_enable");
return (zh->shadow_enable);
}
int zebra_set_shadow_enable (ZebraHandle zh, int value)
{
yaz_log(LOG_API,"zebra_get_shadow_enable");
return (zh->shadow_enable);
}
int zebra_set_shadow_enable (ZebraHandle zh, int value)
{
+ ASSERTZH;
yaz_log(LOG_API,"zebra_set_shadow_enable %d",value);
zh->shadow_enable = value;
return 0;
yaz_log(LOG_API,"zebra_set_shadow_enable %d",value);
zh->shadow_enable = value;
return 0;
@@
-1880,6
+1946,12
@@
void api_records_retrieve (ZebraHandle zh, ODR stream,
{
ZebraPosSet poset;
int i, *pos_array;
{
ZebraPosSet poset;
int i, *pos_array;
+ ASSERTZH;
+ assert(stream);
+ assert(setname);
+ assert(comp);
+ assert(recs);
+ assert(num_recs>0);
yaz_log(LOG_API,"api_records_retrieve s=%s n=%d",setname,num_recs);
if (!zh->res)
yaz_log(LOG_API,"api_records_retrieve s=%s n=%d",setname,num_recs);
if (!zh->res)
@@
-1976,7
+2048,10
@@
int zebra_insert_record (ZebraHandle zh,
const char *buf, int buf_size, int force_update)
{
int res;
const char *buf, int buf_size, int force_update)
{
int res;
- yaz_log(LOG_API,"zebra_insert_record sysno=" ZINT_FORMAT, *sysno);
+ ASSERTZH;
+ assert(sysno);
+ assert(buf);
+ yaz_log(LOG_API, "zebra_insert_record sysno=" ZINT_FORMAT, *sysno);
if (buf_size < 1) buf_size = strlen(buf);
if (buf_size < 1) buf_size = strlen(buf);
@@
-2001,8
+2076,11
@@
int zebra_update_record (ZebraHandle zh,
int force_update)
{
int res;
int force_update)
{
int res;
+ ASSERTZH;
+ assert(sysno);
+ assert(buf);
- yaz_log(LOG_API,"zebra_update_record sysno=" ZINT_FORMAT, *sysno);
+ yaz_log(LOG_API, "zebra_update_record sysno=" ZINT_FORMAT, *sysno);
if (buf_size < 1) buf_size = strlen(buf);
if (buf_size < 1) buf_size = strlen(buf);
@@
-2027,7
+2105,10
@@
int zebra_delete_record (ZebraHandle zh,
int force_update)
{
int res;
int force_update)
{
int res;
- yaz_log(LOG_API,"zebra_delete_record sysno=" ZINT_FORMAT, *sysno);
+ ASSERTZH;
+ assert(sysno);
+ assert(buf);
+ yaz_log(LOG_API, "zebra_delete_record sysno=" ZINT_FORMAT, *sysno);
if (buf_size < 1) buf_size = strlen(buf);
if (buf_size < 1) buf_size = strlen(buf);
@@
-2056,6
+2137,9
@@
int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
int res=-1;
Z_RPNQuery *query;
ODR odr = odr_createmem(ODR_ENCODE);
int res=-1;
Z_RPNQuery *query;
ODR odr = odr_createmem(ODR_ENCODE);
+ ASSERTZH;
+ assert(pqf_query);
+ assert(setname);
yaz_log(LOG_API,"zebra_search_PQF s=%s q=%s",setname, pqf_query);
yaz_log(LOG_API,"zebra_search_PQF s=%s q=%s",setname, pqf_query);
@@
-2087,7
+2171,13
@@
int zebra_sort_by_specstr (ZebraHandle zh,
{
int num_input_setnames = 0;
int sort_status = 0;
{
int num_input_setnames = 0;
int sort_status = 0;
- Z_SortKeySpecList *sort_sequence = yaz_sort_spec (stream, sort_spec);
+ Z_SortKeySpecList *sort_sequence;
+ ASSERTZH;
+ assert(stream);
+ assert(sort_spec);
+ assert(output_setname);
+ assert(input_setnames);
+ sort_sequence = yaz_sort_spec (stream, sort_spec);
yaz_log(LOG_API,"sort (FIXME) ");
if (!sort_sequence)
{
yaz_log(LOG_API,"sort (FIXME) ");
if (!sort_sequence)
{