* 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 */
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
# 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
DEFS=$(INCLUDE)
LIB=../lib/rset.a
PROG=
-PO=
+PO=rset.o rstemp.o rsisam.o
CPP=cc -E
all: $(PROG) $(LIB)
$(LIB): $(PO)
- ar aq $(LIB) $(PO)
+ rm -f $(LIB)
+ ar qc $(LIB) $(PO)
ranlib $(LIB)
.c.o:
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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()
+{}