From 70ba74c9bbf739fbe82d1bc2b0fb64a547c0c9e0 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Tue, 3 Aug 2004 14:54:41 +0000 Subject: [PATCH] Added framework for the pos calls. rsisamb and rsnull have a real one, the rest rely on a global dummy. Not tested much yet, as it is never called. --- include/isamb.h | 4 +++- include/rset.h | 7 +++++-- isamb/isamb.c | 4 +--- isamb/tstisamb.c | 3 +-- rset/rsbetween.c | 11 ++--------- rset/rsbool.c | 16 +++++----------- rset/rset.c | 13 ++++++++++++- rset/rsisam.c | 5 ++--- rset/rsisamb.c | 16 ++++++++-------- rset/rsisamc.c | 11 ++--------- rset/rsisamd.c | 11 ++--------- rset/rsisams.c | 11 ++--------- rset/rsm_or.c | 13 +++---------- rset/rsnull.c | 17 ++++++++++------- rset/rsprox.c | 11 ++--------- rset/rstemp.c | 4 ++-- 16 files changed, 62 insertions(+), 95 deletions(-) diff --git a/include/isamb.h b/include/isamb.h index a41e598..5a599bd 100644 --- a/include/isamb.h +++ b/include/isamb.h @@ -1,4 +1,4 @@ -/* $Id: isamb.h,v 1.9 2004-06-02 12:30:32 adam Exp $ +/* $Id: isamb.h,v 1.10 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -42,6 +42,8 @@ int isamb_pp_read (ISAMB_PP pp, void *buf); int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf); +void isamb_pp_pos (ISAMB_PP pp, int *current, int *total); + void isamb_pp_close (ISAMB_PP pp); int isamb_unlink (ISAMB b, ISAMC_P pos); diff --git a/include/rset.h b/include/rset.h index 7883d04..e6bd856 100644 --- a/include/rset.h +++ b/include/rset.h @@ -1,4 +1,4 @@ -/* $Id: rset.h,v 1.22 2004-08-03 12:15:44 heikki Exp $ +/* $Id: rset.h,v 1.23 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -46,7 +46,9 @@ struct rset_control int (*f_forward)(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf); -/* int (*f_count)(RSET ct); */ /* FIXME - remove this and add pos */ + void (*f_pos)(RSFD rfd, int *current, int *total); + /* FIXME - Should be 64-bit ints !*/ + /* returns -1,-1 if pos function not implemented for this type */ int (*f_read)(RSFD rfd, void *buf, int *term_index); int (*f_write)(RSFD rfd, const void *buf); }; @@ -54,6 +56,7 @@ struct rset_control int rset_default_forward(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf); +void rset_default_pos(RSFD rfd, int *current, int *total); struct rset_term { char *name; diff --git a/isamb/isamb.c b/isamb/isamb.c index ed3acfd..2ee7cb1 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,4 +1,4 @@ -/* $Id: isamb.c,v 1.46 2004-06-16 20:34:25 adam Exp $ +/* $Id: isamb.c,v 1.47 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -117,8 +117,6 @@ struct ISAMB_PP_s { struct ISAMB_block **block; }; -void isamb_pp_pos( ISAMB_PP pp, int *current, int *total ); - /* FIXME - this should be in a header file */ #if ISAMB_PTR_CODEC static void encode_ptr (char **dst, unsigned pos) diff --git a/isamb/tstisamb.c b/isamb/tstisamb.c index 08ff71e..253bc1f 100644 --- a/isamb/tstisamb.c +++ b/isamb/tstisamb.c @@ -1,4 +1,4 @@ -/* $Id: tstisamb.c,v 1.6 2004-06-03 00:24:12 adam Exp $ +/* $Id: tstisamb.c,v 1.7 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -96,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; diff --git a/rset/rsbetween.c b/rset/rsbetween.c index 14fd6e0..e04c746 100644 --- a/rset/rsbetween.c +++ b/rset/rsbetween.c @@ -1,4 +1,4 @@ -/* $Id: rsbetween.c,v 1.14 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsbetween.c,v 1.15 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -48,7 +48,6 @@ static void r_rewind_between (RSFD rfd); static int r_forward_between(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf); -/* static int r_count_between (RSET ct); */ static int r_read_between (RSFD rfd, void *buf, int *term_index); static int r_write_between (RSFD rfd, const void *buf); @@ -61,7 +60,7 @@ static const struct rset_control control_between = r_delete_between, r_rewind_between, r_forward_between, /* rset_default_forward, */ - /* r_count_between, */ + rset_default_pos, r_read_between, r_write_between, }; @@ -305,12 +304,6 @@ static int r_forward_between(RSET ct, RSFD rfd, void *buf, int *term_index, return rc; } -/* -static int r_count_between (RSET ct) -{ - return 0; -} -*/ diff --git a/rset/rsbool.c b/rset/rsbool.c index 73620c0..380ef6a 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -1,4 +1,4 @@ -/* $Id: rsbool.c,v 1.31 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsbool.c,v 1.32 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -40,7 +40,7 @@ static void r_rewind (RSFD rfd); static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf); -/* static int r_count (RSET ct); */ +/* static void r_pos (RSFD rfd, int *current, int *total); */ static int r_read_and (RSFD rfd, void *buf, int *term_index); static int r_read_or (RSFD rfd, void *buf, int *term_index); static int r_read_not (RSFD rfd, void *buf, int *term_index); @@ -55,7 +55,7 @@ static const struct rset_control control_and = r_delete, r_rewind, r_forward, /* rset_default_forward, */ - /* r_count, */ + rset_default_pos, r_read_and, r_write, }; @@ -73,7 +73,7 @@ static const struct rset_control control_or = #else rset_default_forward, #endif - /* r_count, */ + rset_default_pos, r_read_or, r_write, }; @@ -87,7 +87,7 @@ static const struct rset_control control_not = r_delete, r_rewind, r_forward, - /* r_count, */ + rset_default_pos, r_read_not, r_write, }; @@ -257,12 +257,6 @@ static int r_forward (RSET ct, RSFD rfd, void *buf, int *term_index, return rc; } -/* -static int r_count (RSET ct) -{ - return 0; -} -*/ /* 1,1 1,3 diff --git a/rset/rset.c b/rset/rset.c index e798148..2f4896e 100644 --- a/rset/rset.c +++ b/rset/rset.c @@ -1,4 +1,4 @@ -/* $Id: rset.c,v 1.20 2004-01-30 11:43:41 heikki Exp $ +/* $Id: rset.c,v 1.21 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -25,6 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include #include #include <../index/index.h> /* for log_keydump. Debugging only */ @@ -64,6 +65,16 @@ RSET rset_dup (RSET rs) return rs; } +void rset_default_pos (RSFD rfd, int *current, int *total) +{ /* FIXME - This function should not be needed, only while */ + /* coding the pos functions. */ + assert(rfd); + assert(current); + assert(total); + *current=-1; /* signal that pos is not implemented */ + *total=-1; +} /* rset_default_pos */ + int rset_default_forward(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf) diff --git a/rset/rsisam.c b/rset/rsisam.c index e89f7e8..d8f7225 100644 --- a/rset/rsisam.c +++ b/rset/rsisam.c @@ -1,4 +1,4 @@ -/* $Id: rsisam.c,v 1.25 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsisam.c,v 1.26 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -31,7 +31,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -44,7 +43,7 @@ static const struct rset_control control = r_delete, r_rewind, rset_default_forward, - /* r_count, */ + rset_default_pos, r_read, r_write, }; diff --git a/rset/rsisamb.c b/rset/rsisamb.c index 68600ed..bac75e9 100644 --- a/rset/rsisamb.c +++ b/rset/rsisamb.c @@ -1,4 +1,4 @@ -/* $Id: rsisamb.c,v 1.9 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsisamb.c,v 1.10 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -39,7 +39,7 @@ static void r_rewind (RSFD rfd); static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf); -/* static int r_count (RSET ct);*/ +static void r_pos (RSFD rfd, int *current, int *total); static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -52,7 +52,7 @@ static const struct rset_control control = r_delete, r_rewind, r_forward, /* rset_default_forward, */ - /* r_count, */ + r_pos, r_read, r_write, }; @@ -156,7 +156,7 @@ static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf) { - int i; /*!*/ + int i; struct rset_pp_info *pinfo = (struct rset_pp_info *) rfd; #if RSET_DEBUG logf (LOG_DEBUG, "rset_rsisamb_forward starting '%s' (ct=%p rfd=%p)", @@ -172,12 +172,12 @@ static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index, return i; } -/* -static int r_count (RSET ct) +static void r_pos (RSFD rfd, int *current, int *total) { - return 0; + struct rset_pp_info *pinfo = (struct rset_pp_info *) rfd; + assert(rfd); + isamb_pp_pos(pinfo->pt, current, total); } -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rsisamc.c b/rset/rsisamc.c index 99c6bf8..d9f85db 100644 --- a/rset/rsisamc.c +++ b/rset/rsisamc.c @@ -1,4 +1,4 @@ -/* $Id: rsisamc.c,v 1.15 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsisamc.c,v 1.16 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -34,7 +34,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -47,7 +46,7 @@ static const struct rset_control control = r_delete, r_rewind, rset_default_forward, - /*r_count, */ + rset_default_pos, r_read, r_write, }; @@ -146,12 +145,6 @@ static void r_rewind (RSFD rfd) logf (LOG_DEBUG, "rsisamc_rewind"); abort (); } -/* -static int r_count (RSET ct) -{ - return 0; -} -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rsisamd.c b/rset/rsisamd.c index 74295a8..8506716 100644 --- a/rset/rsisamd.c +++ b/rset/rsisamd.c @@ -1,4 +1,4 @@ -/* $Id: rsisamd.c,v 1.7 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsisamd.c,v 1.8 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -34,7 +34,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -47,7 +46,7 @@ static const struct rset_control control = r_delete, r_rewind, rset_default_forward, - /* r_count, */ + rset_default_pos, r_read, r_write, }; @@ -141,12 +140,6 @@ static void r_rewind (RSFD rfd) abort (); } -/* -static int r_count (RSET ct) -{ - return 0; -} -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rsisams.c b/rset/rsisams.c index 9b2dd2b..30f3cd7 100644 --- a/rset/rsisams.c +++ b/rset/rsisams.c @@ -1,4 +1,4 @@ -/* $Id: rsisams.c,v 1.5 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsisams.c,v 1.6 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -32,7 +32,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -45,7 +44,7 @@ static const struct rset_control control = r_delete, r_rewind, rset_default_forward, - /* r_count, */ + rset_default_pos, r_read, r_write, }; @@ -135,12 +134,6 @@ static void r_rewind (RSFD rfd) abort (); } -/* -static int r_count (RSET ct) -{ - return 0; -} -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rsm_or.c b/rset/rsm_or.c index 0e4cd98..0569d83 100644 --- a/rset/rsm_or.c +++ b/rset/rsm_or.c @@ -1,4 +1,4 @@ -/* $Id: rsm_or.c,v 1.15 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsm_or.c,v 1.16 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -38,7 +38,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -50,8 +49,8 @@ static const struct rset_control control = r_close, r_delete, r_rewind, - rset_default_forward, - /* r_count, */ + rset_default_forward, /* FIXME */ + rset_default_pos, /* FIXME */ r_read, r_write, }; @@ -297,12 +296,6 @@ static void r_rewind (RSFD rfd) { } -/* -static int r_count (RSET ct) -{ - return 0; -} -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rsnull.c b/rset/rsnull.c index 895a244..e2bf398 100644 --- a/rset/rsnull.c +++ b/rset/rsnull.c @@ -1,4 +1,4 @@ -/* $Id: rsnull.c,v 1.17 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsnull.c,v 1.18 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -23,6 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include +#include #include #include @@ -31,7 +32,7 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ +static void r_pos (RSFD rfd, int *current, int *total); static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -44,7 +45,7 @@ static const struct rset_control control = r_delete, r_rewind, rset_default_forward, - /* r_count, */ + r_pos, r_read, r_write, }; @@ -92,12 +93,14 @@ static void r_rewind (RSFD rfd) logf (LOG_DEBUG, "rsnull_rewind"); } -/* -static int r_count (RSET ct) +static void r_pos (RSFD rfd, int *current, int *total) { - return 0; + assert(rfd); + assert(current); + assert(total); + *total=0; + *current=0; } -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rsprox.c b/rset/rsprox.c index 6a43203..9090495 100644 --- a/rset/rsprox.c +++ b/rset/rsprox.c @@ -1,4 +1,4 @@ -/* $Id: rsprox.c,v 1.4 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rsprox.c,v 1.5 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -40,7 +40,6 @@ static void r_rewind (RSFD rfd); static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index, int (*cmpfunc)(const void *p1, const void *p2), const void *untilbuf); -/* static int r_count (RSET ct); */ static int r_read (RSFD rfd, void *buf, int *term_index); static int r_write (RSFD rfd, const void *buf); @@ -53,7 +52,7 @@ static const struct rset_control control_prox = r_delete, r_rewind, r_forward, - /* r_count, */ + rset_default_pos, r_read, r_write, }; @@ -370,12 +369,6 @@ static int r_forward (RSET ct, RSFD rfd, void *buf, int *term_index, return 0; } -/* -static int r_count (RSET ct) -{ - return 0; -} -*/ static int r_read (RSFD rfd, void *buf, int *term_index) { diff --git a/rset/rstemp.c b/rset/rstemp.c index e2a49e1..f3fc8de 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -1,4 +1,4 @@ -/* $Id: rstemp.c,v 1.37 2004-08-03 12:15:45 heikki Exp $ +/* $Id: rstemp.c,v 1.38 2004-08-03 14:54:41 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -52,7 +52,7 @@ static const struct rset_control control = r_delete, r_rewind, rset_default_forward, - /* r_count, */ + rset_default_pos, r_read, r_write, }; -- 1.7.10.4