New set type: bool. Not finished yet.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 6 Sep 1995 13:27:15 +0000 (13:27 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 6 Sep 1995 13:27:15 +0000 (13:27 +0000)
include/rsbool.h [new file with mode: 0644]
rset/Makefile
rset/rsbool.c [new file with mode: 0644]

diff --git a/include/rsbool.h b/include/rsbool.h
new file mode 100644 (file)
index 0000000..2a636ce
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 1994-1995, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rsbool.h,v $
+ * Revision 1.1  1995-09-06 13:27:37  adam
+ * New set type: bool. Not finished yet.
+ *
+ */
+
+#ifndef RSET_BOOL_H
+#define RSET_BOOL_H
+
+#include <rset.h>
+
+extern const rset_control *rset_kind_bool;
+
+typedef struct rset_bool_parms
+{
+    int     key_size;
+    int     op;
+} rset_bool_parms;
+
+#endif
index 362b5d0..7769f03 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.5 1995-09-06 10:35:44 adam Exp $
+# $Id: Makefile,v 1.6 1995-09-06 13:27:15 adam Exp $
 
 SHELL=/bin/sh
 RANLIB=ranlib
@@ -11,7 +11,7 @@ INCLUDE=-I../include -I$(YAZ)/include
 DEFS=$(INCLUDE)
 LIB=../lib/rset.a
 PROG=
-PO=rset.o rstemp.o rsisam.o rsnull.o
+PO=rset.o rstemp.o rsisam.o rsnull.o rsbool.o
 CPP=cc -E
 
 all: $(LIB)
diff --git a/rset/rsbool.c b/rset/rsbool.c
new file mode 100644 (file)
index 0000000..c4aee9c
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 1994-1995, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rsbool.c,v $
+ * Revision 1.1  1995-09-06 13:27:15  adam
+ * New set type: bool. Not finished yet.
+ *
+ */
+
+#include <stdio.h>
+#include <rsbool.h>
+#include <alexutil.h>
+
+static rset_control *r_create(const struct rset_control *sel, void *parms);
+static int r_open (rset_control *ct, int wflag);
+static void r_close (rset_control *ct);
+static void r_delete (rset_control *ct);
+static void r_rewind (rset_control *ct);
+static int r_count (rset_control *ct);
+static int r_read (rset_control *ct, void *buf);
+static int r_write (rset_control *ct, const void *buf);
+
+static const rset_control control = 
+{
+    "BOOL set type",
+    0,
+    r_create,
+    r_open,
+    r_close,
+    r_delete,
+    r_rewind,
+    r_count,
+    r_read,
+    r_write
+};
+
+const rset_control *rset_kind_bool = &control;
+
+struct rset_bool_info {
+    int key_size;
+    int op;
+};
+
+static rset_control *r_create(const struct rset_control *sel, void *parms)
+{
+    rset_control *newct;
+    rset_bool_parms *bool_parms = parms;
+    struct rset_bool_info *info;
+
+    logf (LOG_DEBUG, "rsbool_create(%s)", sel->desc);
+    newct = xmalloc(sizeof(*newct));
+    memcpy(newct, sel, sizeof(*sel));
+    newct->buf = xmalloc (sizeof(struct rset_bool_info));
+    info = (struct rset_bool_info*) newct->buf;
+    info->key_size = bool_parms->key_size;
+    info->op = bool_parms->op;
+    return newct;
+}
+
+static int r_open(rset_control *ct, int wflag)
+{
+    if (wflag)
+    {
+       logf (LOG_FATAL, "bool set type is read-only");
+       return -1;
+    }
+    return 0;
+}
+
+static void r_close(rset_control *ct)
+{
+    /* NOP */
+}
+
+static void r_delete(rset_control *ct)
+{
+    xfree(ct);
+}
+
+static void r_rewind(rset_control *ct)
+{
+    logf (LOG_DEBUG, "rsbool_rewind");
+}
+
+static int r_count (rset_control *ct)
+{
+    return 0;
+}
+
+static int r_read (rset_control *ct, void *buf)
+{
+    return 0;
+}
+
+static int r_write (rset_control *ct, const void *buf)
+{
+    logf (LOG_FATAL, "bool set type is read-only");
+    return -1;
+}