Bump year. Change Aps->ApS
[idzebra-moved-to-github.git] / rset / rsnull.c
index e2bf398..f073744 100644 (file)
@@ -1,6 +1,6 @@
-/* $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
+/* $Id: rsnull.c,v 1.31 2005-01-15 19:38:35 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
 
 This file is part of the Zebra server.
 
@@ -24,26 +24,24 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <stdio.h>
 #include <assert.h>
-#include <rsnull.h>
 #include <zebrautl.h>
+#include <rset.h>
+
 
-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 void r_pos (RSFD rfd, int *current, int *total);
-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, TERMID *term);
 static int r_write (RSFD rfd, const void *buf);
 
 static const struct rset_control control = 
 {
     "null",
-    r_create,
+    r_delete,
+    rset_get_no_terms,
     r_open,
     r_close,
-    r_delete,
-    r_rewind,
     rset_default_forward,
     r_pos,
     r_read,
@@ -52,48 +50,37 @@ static const struct rset_control control =
 
 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, const struct key_control *kcontrol )
 {
-    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;
-
-    return NULL;
+    RSET rnew=rset_create_base(&control, nmem, kcontrol,0,0);
+    rnew->priv=NULL;
+    return rnew;
 }
 
 static RSFD r_open (RSET ct, int flag)
 {
+    RSFD rfd;
     if (flag & RSETF_WRITE)
     {
-       logf (LOG_FATAL, "NULL set type is read-only");
-       return NULL;
+        yaz_log (YLOG_FATAL, "NULL set type is read-only");
+        return NULL;
     }
-    return "";
+    rfd=rfd_create_base(ct);
+    rfd->priv=NULL; 
+    return rfd;
 }
 
 static void r_close (RSFD rfd)
 {
+    rfd_delete_base(rfd);
 }
 
 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 void r_pos (RSFD rfd, int *current, int *total)
+static void r_pos (RSFD rfd, double *current, double *total)
 {
     assert(rfd);
     assert(current);
@@ -102,15 +89,16 @@ static void r_pos (RSFD rfd, int *current, int *total)
     *current=0;
 }
 
-static int r_read (RSFD rfd, void *buf, int *term_index)
+static int r_read (RSFD rfd, void *buf, TERMID *term)
 {
-    *term_index = -1;
+    if (term)
+        *term=0; /* NULL */
     return 0;
 }
 
 static int r_write (RSFD rfd, const void *buf)
 {
-    logf (LOG_FATAL, "NULL set type is read-only");
+    yaz_log (YLOG_FATAL, "NULL set type is read-only");
     return -1;
 }