Working.
authorSebastian Hammer <quinn@indexdata.com>
Fri, 4 Nov 1994 13:21:21 +0000 (13:21 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Fri, 4 Nov 1994 13:21:21 +0000 (13:21 +0000)
include/rset.h
include/rsisam.h [new file with mode: 0644]
include/rstemp.h [new file with mode: 0644]
rset/Makefile
rset/rset.c [new file with mode: 0644]
rset/rsisam.c [new file with mode: 0644]
rset/rstemp.c [new file with mode: 0644]

index 789ae9d..68acc15 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rset.h,v $
- * Revision 1.1  1994-11-03 14:13:22  quinn
+ * Revision 1.2  1994-11-04 13:21:21  quinn
+ * Working.
+ *
+ * Revision 1.1  1994/11/03  14:13:22  quinn
  * Result set manipulation
  *
  */
 
 typedef struct rset_control
 {
+    char *desc; /* text description of set type (for debugging) */
     char *buf;  /* state data stored by subsystem */
-    int (*f_open)(rset_control *ct, int wflag);
-    void (*f_close)(rset_control *ct *data);
-    void (*f_delete)(rset_control *ct);
-    void (*f_rewind)(rset_control *ct);
-    int (*f_count)(rset_control *ct);
-    int (*f_read)(...);
-    int (*f_write)(...);
+    struct rset_control *(*f_create)(const struct rset_control *sel, void *parms);
+    int (*f_open)(struct rset_control *ct, int wflag);
+    void (*f_close)(struct rset_control *ct);
+    void (*f_delete)(struct rset_control *ct);
+    void (*f_rewind)(struct rset_control *ct);
+    int (*f_count)(struct rset_control *ct);
+    int (*f_read)(struct rset_control *ct, void *buf);
+    int (*f_write)(struct rset_control *ct, const void *buf);
 } rset_control;
 
 typedef struct rset
 {
+    int is_open;
     rset_control *control;
-} rset *RSET;
+} rset, *RSET;
+
+RSET rset_create(const rset_control *sel, void *parms);       /* parameters? */
+
+/* int rset_open(RSET rs, int wflag); */
+#define rset_open(rs, wflag) ((*(rs)->control->f_open)((rs)->control, (wflag)))
+
+/* void rset_close(RSET rs); */
+#define rset_close(rs) ((*(rs)->control->f_close)((rs)->control))
 
-RSET rset_create();       /* parameters? */
-int rset_open(RSET rs, int wflag);
-void rset_close(RSET rs);
 void rset_delete(RSET rs);
-void rset_rewind(RSET rs);
-int rset_count(RSET rs);   /* more parameters? */
+
+/* void rset_rewind(RSET rs); */
+#define rset_rewind(rs, wflag) ((*(rs)->control->f_rewind)((rs)->control))
+
+/* int rset_count(RSET rs); */
+#define rset_count(rs, wflag) ((*(rs)->control->f_count)((rs)->control))
+
 int rset_read(RSET rs, void *buf);   /* change parameters */
 int rset_write(RSET rs, void *buf);  /* change parameters */
 
diff --git a/include/rsisam.h b/include/rsisam.h
new file mode 100644 (file)
index 0000000..a2364f3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rsisam.h,v $
+ * Revision 1.1  1994-11-04 13:21:23  quinn
+ * Working.
+ *
+ */
+
+#ifndef RSET_TEMP_H
+#define RSET_TEMP_H
+
+#include <rset.h>
+#include <isam.h>
+
+extern const rset_control *rset_kind_isam;
+
+typedef struct rset_isam_parms
+{
+    ISAM is;
+    ISAM_P pos;
+} rset_isam_parms;
+
+#endif
diff --git a/include/rstemp.h b/include/rstemp.h
new file mode 100644 (file)
index 0000000..141d163
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rstemp.h,v $
+ * Revision 1.1  1994-11-04 13:21:23  quinn
+ * Working.
+ *
+ */
+
+#ifndef RSET_TEMP_H
+#define RSET_TEMP_H
+
+#include <rset.h>
+
+extern const rset_control *rset_kind_temp;
+
+#endif
index ede37d5..2ad74d4 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.1 1994-11-03 14:13:29 quinn Exp $
+# $Id: Makefile,v 1.2 1994-11-04 13:21:28 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include
@@ -9,7 +9,7 @@ CFLAGS=-g -Wall -pedantic
 DEFS=$(INCLUDE)
 LIB=../lib/rset.a
 PROG=
-PO=
+PO=rset.o rstemp.o rsisam.o
 CPP=cc -E
 
 all: $(PROG) $(LIB)
@@ -19,7 +19,8 @@ $(PROG): $(PROG).o
 
 
 $(LIB): $(PO)
-       ar aq $(LIB) $(PO)
+       rm -f $(LIB)
+       ar qc $(LIB) $(PO)
        ranlib $(LIB)
 
 .c.o:
diff --git a/rset/rset.c b/rset/rset.c
new file mode 100644 (file)
index 0000000..667bd1d
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rset.c,v $
+ * Revision 1.1  1994-11-04 13:21:28  quinn
+ * Working.
+ *
+ */
+
+/* TODO: mem management */
+
+#include <util.h>
+
+#include <rset.h>
+
+RSET rset_create(const rset_control *sel, void *parms)
+{
+    RSET new;
+
+    new = xmalloc(sizeof(*new));     /* make dynamic alloc scheme */
+    if (!(new->control = (*sel->f_create)(sel, parms)))
+       return 0;
+    return new;
+}
+
+void rset_delete(RSET rs)
+{
+    if (rs->is_open)
+       rset_close(rs);
+    (*rs->control->f_delete)(rs->control);
+    xfree(rs);
+}
diff --git a/rset/rsisam.c b/rset/rsisam.c
new file mode 100644 (file)
index 0000000..56a432c
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rsisam.c,v $
+ * Revision 1.1  1994-11-04 13:21:29  quinn
+ * Working.
+ *
+ */
+
+/* TODO: Memory management */
+
+#include <rsisam.h>
+#include <util.h>
+
+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();
+static int r_write();
+
+static const rset_control control = 
+{
+    "ISAM set type",
+    0,
+    r_create,
+    r_open,
+    r_close,
+    r_delete,
+    r_rewind,
+    r_count,
+    r_read,
+    r_write
+};
+
+const rset_control *rset_kind_isam = &control;
+
+rset_control *r_create(const struct rset_control *sel, void *parms)
+{
+    rset_control *newct;
+    rset_isam_parms *pt = parms;
+
+    newct = xmalloc(sizeof(*newct));
+    if (!(newct->buf = (char*) is_position(pt->is, pt->pos)))
+       return 0;
+    return newct;
+}
+
+static int r_open(rset_control *ct, int wflag)
+{
+    r_rewind(ct);
+    return 0;
+}
+
+static void r_close(rset_control *ct)
+{
+    /* NOP */
+}
+
+static void r_delete(rset_control *ct)
+{
+    is_pt_free((ISPT) ct->buf);
+    xfree(ct);
+}
+
+static void r_rewind(rset_control *ct)
+{
+    is_rewind((ISPT) ct->buf);
+}
+
+static int r_count(rset_control *ct)
+{return 0;}
+
+static int r_read(rset_control *ct, void *buf)
+{
+    return is_readkey((ISPT) ct->buf, buf);
+}
+
+static int r_write(rset_control *ct, const void *buf)
+{
+    log(LOG_FATAL, "ISAM set type is read-only");
+    return -1;
+}
diff --git a/rset/rstemp.c b/rset/rstemp.c
new file mode 100644 (file)
index 0000000..e6e6fe3
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: rstemp.c,v $
+ * Revision 1.1  1994-11-04 13:21:30  quinn
+ * Working.
+ *
+ */
+
+#include <rstemp.h>
+
+struct rset_control *r_create(const struct rset_control *sel, void *parms);
+static int r_open(struct rset_control *ct, int wflag);
+static void r_close(struct rset_control *ct);
+static void r_delete(struct rset_control *ct);
+static void r_rewind(struct rset_control *ct);
+static int r_count(struct rset_control *ct);
+static int r_read();
+static int r_write();
+
+static const rset_control control = 
+{
+    "Temporary set",
+    0,
+    r_create,
+    r_open,
+    r_close,
+    r_delete,
+    r_rewind,
+    r_count,
+    r_read,
+    r_write
+};
+
+const rset_control *rset_kind_temp = &control;
+
+struct rset_control *r_create(const struct rset_control *sel, void *parms)
+{}
+
+static int r_open(struct rset_control *ct, int wflag)
+{}
+
+static void r_close(struct rset_control *ct)
+{}
+
+static void r_delete(struct rset_control *ct)
+{}
+
+static void r_rewind(struct rset_control *ct)
+{}
+
+static int r_count(struct rset_control *ct)
+{}
+
+static int r_read()
+{}
+
+static int r_write()
+{}