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
Remove TCL_LIB from all LDADDs except for Tcl filter. We don't anything
[idzebra-moved-to-github.git]
/
index
/
zebraapi.c
diff --git
a/index/zebraapi.c
b/index/zebraapi.c
index
d1a3cce
..
9030da1
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.133 2004-09-27 10:44:49 adam 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);
@@
-157,7
+151,7
@@
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);
if ((res = res_open (configName, def_res, over_res)))
{
if ((res = res_open (configName, def_res, over_res)))
{
@@
-184,11
+178,18
@@
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))
+{
+ recTypeClass_info(zs->record_classes, cd, cb);
+}
void zebra_pidfname(ZebraService zs, char *path)
{
void zebra_pidfname(ZebraService zs, char *path)
{
@@
-238,7
+239,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
+256,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
+269,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;
@@
-410,7
+408,7
@@
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);
+ 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
+435,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
+446,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
+458,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);
@@
-692,7
+689,7
@@
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)
}
int zebra_select_database (ZebraHandle zh, const char *basename)
@@
-812,7
+809,7
@@
int zebra_search_RPN (ZebraHandle zh, ODR o,
while (i--) maxhits *= 10;
}
if (zh->hits > maxhits) { /* too large for yaz to handle */
while (i--) maxhits *= 10;
}
if (zh->hits > maxhits) { /* too large for yaz to handle */
- logf(LOG_LOG,"limiting hits to "ZINT_FORMAT, maxhits);
+ logf(LOG_DEBUG,"limiting hits to "ZINT_FORMAT, maxhits);
*hits=maxhits; /* round it down to two digits, to look like rounded */
}
else
*hits=maxhits; /* round it down to two digits, to look like rounded */
}
else
@@
-1409,7
+1406,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
+1418,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
+1495,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;
}
@@
-1584,7
+1581,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
+1607,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);
}
@@
-1638,7
+1635,7
@@
int zebra_repository_update (ZebraHandle zh, const char *path)
{
ASSERTZH;
zh->errCode=0;
{
ASSERTZH;
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;
}
@@
-1647,7
+1644,7
@@
int zebra_repository_delete (ZebraHandle zh, const char *path)
{
ASSERTZH;
zh->errCode=0;
{
ASSERTZH;
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;
}
@@
-1700,13
+1697,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);
@@
-1751,6
+1748,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);
@@
-1976,7
+1975,7
@@
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);
+ 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);
@@
-2002,7
+2001,7
@@
int zebra_update_record (ZebraHandle zh,
{
int res;
{
int res;
- 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
+2026,7
@@
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);
+ 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);