From: Adam Dickmeiss Date: Tue, 1 Feb 2011 12:06:21 +0000 (+0000) Subject: Beginnings of zebra_register_check X-Git-Tag: v2.0.46~17 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=16853a7593f10680ea8d6895aa0720b9af3779e6;p=idzebra-moved-to-github.git Beginnings of zebra_register_check --- diff --git a/include/idzebra/api.h b/include/idzebra/api.h index 4b9df81..82bf7ce 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -510,6 +510,9 @@ ZEBRA_RES zebra_set_break_handler(ZebraHandle zh, int (*f)(void *client_data), void *client_data); +YAZ_EXPORT +ZEBRA_RES zebra_register_check(ZebraHandle zh); + YAZ_END_CDECL /** \mainpage Zebra diff --git a/index/zebraapi.c b/index/zebraapi.c index ff18046..420861f 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -2194,6 +2194,33 @@ ZEBRA_RES zebra_compact(ZebraHandle zh) return ZEBRA_OK; } +ZEBRA_RES zebra_register_check(ZebraHandle zh) +{ + ZEBRA_RES res = ZEBRA_FAIL; + if (zebra_begin_read(zh) == ZEBRA_OK) + { + zint no_records = 0; + if (zh->reg) + { + Record rec = rec_get_root(zh->reg->records); + + while (rec) + { + Record r1; + + r1 = rec_get_next(zh->reg->records, rec); + rec_free(&rec); + rec = r1; + no_records++; + } + res = ZEBRA_OK; + } + zebra_end_read(zh); + yaz_log(YLOG_LOG, ZINT_FORMAT " records scanned", no_records); + } + return res; +} + void zebra_result(ZebraHandle zh, int *code, char **addinfo) { yaz_log(log_level, "zebra_result"); diff --git a/index/zebraidx.c b/index/zebraidx.c index a521e73..c411901 100644 --- a/index/zebraidx.c +++ b/index/zebraidx.c @@ -177,6 +177,11 @@ int main(int argc, char **argv) { show_filters(zs); } + else if (!strcmp(arg, "check")) + { + if (zebra_register_check(zh) != ZEBRA_OK) + yaz_log(YLOG_WARN, "register check failed"); + } else { yaz_log(YLOG_FATAL, "unknown command: %s", arg);