Remove isamd. It's not been in use for a long time and isamb is better
[idzebra-moved-to-github.git] / isamb / tstisamb.c
index 78b65b0..3ea1d92 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: tstisamb.c,v 1.3 2004-06-02 06:39:36 adam Exp $
+/* $Id: tstisamb.c,v 1.8 2004-08-04 08:35:24 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -26,6 +26,18 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <isamb.h>
 #include <assert.h>
 
+static void log_item(int level, const void *b, const char *txt)
+{
+    int x;
+    memcpy(&x, b, sizeof(int));
+    yaz_log(LOG_DEBUG, "%s %d", txt, x);
+}
+
+static void log_pr(const char *txt)
+{
+    yaz_log(LOG_DEBUG, "%s", txt);
+}
+
 int compare_item(const void *a, const void *b)
 {
     int ia, ib;
@@ -35,12 +47,12 @@ int compare_item(const void *a, const void *b)
     return ia - ib;
 }
 
-void *code_start(int mode)
+void *code_start()
 {
     return 0;
 }
 
-void code_item(int mode, void *p, char **dst, char **src)
+void code_item(void *p, char **dst, const char **src)
 {
     memcpy (*dst, *src, sizeof(int));
     (*dst) += sizeof(int);
@@ -50,7 +62,7 @@ void code_item(int mode, void *p, char **dst, char **src)
 void code_reset(void *p)
 {
 }
-void code_stop(int mode, void *p)
+void code_stop(void *p)
 {
 }
 
@@ -84,7 +96,6 @@ void tst_forward(ISAMB isb, int n)
     struct read_info ri;
     int i;
     ISAMB_PP pp;
-    char key_buf[10];
 
     /* insert a number of entries */
     ri.no = 0;
@@ -98,12 +109,12 @@ void tst_forward(ISAMB isb, int n)
     /* read the entries */
     pp = isamb_pp_open (isb, isamc_p);
     
-    for (i = 0; i<ri.max; i++)
+    for (i = 0; i<ri.max; i +=2 )
     {
        int x = -1;
        int xu = i;
        isamb_pp_forward(pp, &x, &xu);
-       if (x != xu)
+       if (x != xu && xu != x+1)
        {
            yaz_log(LOG_WARN, "isamb_pp_forward (1). Got %d (expected %d)",
                    x, xu);
@@ -117,12 +128,12 @@ void tst_forward(ISAMB isb, int n)
     for (i = 0; i<ri.max; i += 100)
     {
        int x = -1;
-       int xuntil = i;
-       isamb_pp_forward(pp, &x, &xuntil);
-       if (x != xuntil)
+       int xu = i;
+       isamb_pp_forward(pp, &x, &xu);
+       if (x != xu && xu != x+1)
        {
            yaz_log(LOG_WARN, "isamb_pp_forward (2). Got %d (expected %d)",
-                   x, xuntil);
+                   x, xu);
            exit(4);
        }
        ri.no++;
@@ -172,13 +183,10 @@ void tst_insert(ISAMB isb, int n)
     }
     isamb_pp_close(pp);
 
+    isamb_dump(isb, isamc_p, log_pr);
     isamb_unlink(isb, isamc_p);
 }
 
-static void log_item(int level, const void *b, const char *txt)
-{
-}
-
 int main(int argc, char **argv)
 {
     BFiles bfs;
@@ -191,10 +199,11 @@ int main(int argc, char **argv)
     /* setup method (attributes) */
     method.compare_item = compare_item;
     method.log_item = log_item;
-    method.code_start = code_start;
-    method.code_item = code_item;
-    method.code_reset = code_reset;
-    method.code_stop = code_stop;
+    method.codec.start = code_start;
+    method.codec.encode = code_item;
+    method.codec.decode = code_item;
+    method.codec.reset = code_reset;
+    method.codec.stop = code_stop;
 
     /* create block system */
     bfs = bfs_create(0, 0);