X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=isamb%2Ftstisamb.c;h=5adb3e88a94576e1326c25b2990a131143784c90;hb=fdbaae03ebe22fb5ede3b0e857fe7691e1d55b28;hp=5f471cdcf069321b479582000b19e91c20dd0e13;hpb=e184d932ecfafa617833b4d45e123faa87969af1;p=idzebra-moved-to-github.git diff --git a/isamb/tstisamb.c b/isamb/tstisamb.c index 5f471cd..5adb3e8 100644 --- a/isamb/tstisamb.c +++ b/isamb/tstisamb.c @@ -1,6 +1,6 @@ -/* $Id: tstisamb.c,v 1.9 2004-08-23 13:06:46 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 - Index Data Aps +/* $Id: tstisamb.c,v 1.19 2005-03-21 17:20:54 adam Exp $ + Copyright (C) 1995-2005 + Index Data ApS This file is part of the Zebra server. @@ -20,22 +20,23 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include -#include #include -#include +#include +#include #include 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); + yaz_log(YLOG_DEBUG, "%s %d", txt, x); } static void log_pr(const char *txt) { - yaz_log(LOG_DEBUG, "%s", txt); + yaz_log(YLOG_DEBUG, "%s", txt); } int compare_item(const void *a, const void *b) @@ -44,7 +45,11 @@ int compare_item(const void *a, const void *b) memcpy(&ia, a, sizeof(int)); memcpy(&ib, b, sizeof(int)); - return ia - ib; + if (ia > ib) + return 1; + if (ia < ib) + return -1; + return 0; } void *code_start() @@ -84,18 +89,19 @@ int code_read(void *vp, char **dst, int *insertMode) memcpy (*dst, &x, sizeof(int)); (*dst)+=sizeof(int); - ri->no += ri->step; + ri->no = ri->no + ri->step; *insertMode = ri->insertMode; return 1; } -void tst_forward(ISAMB isb, int n) +void tst_insert(ISAMB isb, int n) { ISAMC_I isamc_i; ISAMC_P isamc_p; struct read_info ri; - int i; ISAMB_PP pp; + char key_buf[10]; + int nerrs = 0; /* insert a number of entries */ ri.no = 0; @@ -109,49 +115,71 @@ void tst_forward(ISAMB isb, int n) isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i); /* read the entries */ - pp = isamb_pp_open (isb, isamc_p); - - for (i = 0; i