From affd7e4168d70b94e015b777748b7eca1cd00ec0 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Fri, 4 Nov 1994 13:21:21 +0000 Subject: [PATCH] Working. --- include/rset.h | 44 ++++++++++++++++++--------- include/rsisam.h | 26 ++++++++++++++++ include/rstemp.h | 19 ++++++++++++ rset/Makefile | 7 +++-- rset/rset.c | 34 +++++++++++++++++++++ rset/rsisam.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ rset/rstemp.c | 61 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 261 insertions(+), 17 deletions(-) create mode 100644 include/rsisam.h create mode 100644 include/rstemp.h create mode 100644 rset/rset.c create mode 100644 rset/rsisam.c create mode 100644 rset/rstemp.c diff --git a/include/rset.h b/include/rset.h index 789ae9d..68acc15 100644 --- a/include/rset.h +++ b/include/rset.h @@ -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 * */ @@ -14,27 +17,40 @@ 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 index 0000000..a2364f3 --- /dev/null +++ b/include/rsisam.h @@ -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 +#include + +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 index 0000000..141d163 --- /dev/null +++ b/include/rstemp.h @@ -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 + +extern const rset_control *rset_kind_temp; + +#endif diff --git a/rset/Makefile b/rset/Makefile index ede37d5..2ad74d4 100644 --- a/rset/Makefile +++ b/rset/Makefile @@ -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 index 0000000..667bd1d --- /dev/null +++ b/rset/rset.c @@ -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 + +#include + +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 index 0000000..56a432c --- /dev/null +++ b/rset/rsisam.c @@ -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 +#include + +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 index 0000000..e6e6fe3 --- /dev/null +++ b/rset/rstemp.c @@ -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 + +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() +{} -- 1.7.10.4