Beginnings of zebra_register_check
authorAdam Dickmeiss <adam@lenny32bit.(none)>
Tue, 1 Feb 2011 12:06:21 +0000 (12:06 +0000)
committerAdam Dickmeiss <adam@lenny32bit.(none)>
Tue, 1 Feb 2011 12:06:21 +0000 (12:06 +0000)
include/idzebra/api.h
index/zebraapi.c
index/zebraidx.c

index 4b9df81..82bf7ce 100644 (file)
@@ -510,6 +510,9 @@ ZEBRA_RES zebra_set_break_handler(ZebraHandle zh,
                                   int (*f)(void *client_data),
                                   void *client_data);
 
                                   int (*f)(void *client_data),
                                   void *client_data);
 
+YAZ_EXPORT
+ZEBRA_RES zebra_register_check(ZebraHandle zh);
+
 YAZ_END_CDECL                                
 
 /** \mainpage Zebra
 YAZ_END_CDECL                                
 
 /** \mainpage Zebra
index ff18046..420861f 100644 (file)
@@ -2194,6 +2194,33 @@ ZEBRA_RES zebra_compact(ZebraHandle zh)
     return ZEBRA_OK;
 }
 
     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");
 void zebra_result(ZebraHandle zh, int *code, char **addinfo)
 {
     yaz_log(log_level, "zebra_result");
index a521e73..c411901 100644 (file)
@@ -177,6 +177,11 @@ int main(int argc, char **argv)
                 {
                     show_filters(zs);
                 }
                 {
                     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);
                 else
                 {
                     yaz_log(YLOG_FATAL, "unknown command: %s", arg);