-/* $Id: rsnull.c,v 1.15 2002-08-02 19:26:57 adam Exp $
+/* $Id: rsnull.c,v 1.22 2004-08-24 14:25:16 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#include <stdio.h>
-#include <rsnull.h>
+#include <assert.h>
#include <zebrautl.h>
+#include <rsnull.h>
+
+/* FIXME - Use the nmem instead of xmalloc all the way through */
-static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
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 void r_pos (RSFD rfd, double *current, double *total);
+static int r_read (RSFD rfd, void *buf);
static int r_write (RSFD rfd, const void *buf);
static const struct rset_control control =
{
"null",
- r_create,
r_open,
r_close,
r_delete,
r_rewind,
- r_count,
+ rset_default_forward,
+ r_pos,
r_read,
r_write,
};
const struct rset_control *rset_kind_null = &control;
-static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
+RSET rsnull_create(NMEM nmem )
{
- rset_null_parms *null_parms = (rset_null_parms *) parms;
-
- ct->no_rset_terms = 1;
- ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms));
- if (parms && null_parms->rset_term)
- ct->rset_terms[0] = null_parms->rset_term;
- else
- ct->rset_terms[0] = rset_term_create ("term", -1, "rank-0",
- 0);
- ct->rset_terms[0]->nn = 0;
+ RSET rnew=rset_create_base(&control, nmem);
+ rnew->priv=NULL;
+ return rnew;
+}
+#if 0
+static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
+{
return NULL;
}
+#endif
static RSFD r_open (RSET ct, int flag)
{
if (flag & RSETF_WRITE)
{
- logf (LOG_FATAL, "NULL set type is read-only");
- return NULL;
+ logf (LOG_FATAL, "NULL set type is read-only");
+ return NULL;
}
return "";
}
static void r_delete (RSET ct)
{
- rset_term_destroy (ct->rset_terms[0]);
- xfree (ct->rset_terms);
}
static void r_rewind (RSFD rfd)
logf (LOG_DEBUG, "rsnull_rewind");
}
-static int r_count (RSET ct)
+static void r_pos (RSFD rfd, double *current, double *total)
{
- return 0;
+ assert(rfd);
+ assert(current);
+ assert(total);
+ *total=0;
+ *current=0;
}
-static int r_read (RSFD rfd, void *buf, int *term_index)
+static int r_read (RSFD rfd, void *buf)
{
- *term_index = -1;
return 0;
}