-/* $Id: rset.c,v 1.19 2004-01-22 11:27:22 adam Exp $
+/* $Id: rset.c,v 1.21.2.1 2006-08-14 10:39:20 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
#include <stdio.h>
#include <string.h>
#include <zebrautl.h>
+#include <assert.h>
#include <rset.h>
+#include <../index/index.h> /* for log_keydump. Debugging only */
RSET rset_create(const struct rset_control *sel, void *parms)
{
return rs;
}
-int rset_default_forward(RSFD rfd, void *buf, const void *untilbuf)
+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)
{
- logf (LOG_FATAL, "rset_default-forward not yet implemented");
- return 0;
+ int more=1;
+ int cmp=2;
+ logf (LOG_DEBUG, "rset_default_forward starting '%s' (ct=%p rfd=%p)",
+ ct->control->desc, ct,rfd);
+ key_logdump(LOG_DEBUG, untilbuf);
+ while ( (cmp==2) && (more))
+ {
+ logf (LOG_DEBUG, "rset_default_forward looping m=%d c=%d",more,cmp);
+ more=rset_read(ct, rfd, buf, term_index);
+ if (more)
+ cmp=(*cmpfunc)(untilbuf,buf);
+ if (more)
+ key_logdump(LOG_DEBUG,buf);
+ }
+ logf (LOG_DEBUG, "rset_default_forward exiting m=%d c=%d",more,cmp);
+
+ return more;
}
RSET_TERM *rset_terms(RSET rs, int *no)