From 42b0747acfaaf94e94fd6c20b4cd97e10ded0ae0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 6 Sep 1995 16:10:57 +0000 Subject: [PATCH] More work on boolean sets. --- include/isam.h | 7 +++++-- include/rsbool.h | 8 +++++++- include/rset.h | 11 +++++++---- rset/rsbool.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- rset/rset.c | 7 +++++-- rset/rsisam.c | 7 +++++-- rset/rstemp.c | 7 +++++-- 7 files changed, 77 insertions(+), 17 deletions(-) diff --git a/include/isam.h b/include/isam.h index 2051bf5..e38edc1 100644 --- a/include/isam.h +++ b/include/isam.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isam.h,v $ - * Revision 1.9 1994-09-28 16:58:26 quinn + * Revision 1.10 1995-09-06 16:10:57 adam + * More work on boolean sets. + * + * Revision 1.9 1994/09/28 16:58:26 quinn * Small mod. * * Revision 1.8 1994/09/28 12:56:09 quinn @@ -98,7 +101,7 @@ typedef struct ispt_struct * Open isam file. */ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2), - int writeflag); + int writeflag, int keysize); /* * Close isam file. diff --git a/include/rsbool.h b/include/rsbool.h index 2a636ce..03dccc1 100644 --- a/include/rsbool.h +++ b/include/rsbool.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsbool.h,v $ - * Revision 1.1 1995-09-06 13:27:37 adam + * Revision 1.2 1995-09-06 16:10:57 adam + * More work on boolean sets. + * + * Revision 1.1 1995/09/06 13:27:37 adam * New set type: bool. Not finished yet. * */ @@ -20,6 +23,9 @@ typedef struct rset_bool_parms { int key_size; int op; + RSET rset_l; + RSET rset_r; + int (*cmp)(const void *p1, const void *p2); } rset_bool_parms; #endif diff --git a/include/rset.h b/include/rset.h index 69496a3..b370071 100644 --- a/include/rset.h +++ b/include/rset.h @@ -1,10 +1,13 @@ /* - * Copyright (C) 1994, Index Data I/S + * Copyright (C) 1994-1995, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: rset.h,v $ - * Revision 1.5 1995-09-04 15:20:13 adam + * Revision 1.6 1995-09-06 16:10:58 adam + * More work on boolean sets. + * + * Revision 1.5 1995/09/04 15:20:13 adam * More work on temp sets. is_open member removed. * * Revision 1.4 1995/09/04 09:09:52 adam @@ -57,10 +60,10 @@ RSET rset_create(const rset_control *sel, void *parms); /* parameters? */ void rset_delete(RSET rs); /* void rset_rewind(RSET rs); */ -#define rset_rewind(rs, wflag) ((*(rs)->control->f_rewind)((rs)->control)) +#define rset_rewind(rs) ((*(rs)->control->f_rewind)((rs)->control)) /* int rset_count(RSET rs); */ -#define rset_count(rs, wflag) ((*(rs)->control->f_count)((rs)->control)) +#define rset_count(rs) ((*(rs)->control->f_count)((rs)->control)) /* int rset_read(RSET rs, void *buf); */ #define rset_read(rs, buf) ((*(rs)->control->f_read)((rs)->control, (buf))) diff --git a/rset/rsbool.c b/rset/rsbool.c index c4aee9c..d1bddb8 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsbool.c,v $ - * Revision 1.1 1995-09-06 13:27:15 adam + * Revision 1.2 1995-09-06 16:11:55 adam + * More work on boolean sets. + * + * Revision 1.1 1995/09/06 13:27:15 adam * New set type: bool. Not finished yet. * */ @@ -41,6 +44,13 @@ const rset_control *rset_kind_bool = &control; struct rset_bool_info { int key_size; int op; + RSET rset_l; + RSET rset_r; + int more_l; + int more_r; + void *buf_l; + void *buf_r; + int (*cmp)(const void *p1, const void *p2); }; static rset_control *r_create(const struct rset_control *sel, void *parms) @@ -51,37 +61,62 @@ static rset_control *r_create(const struct rset_control *sel, void *parms) logf (LOG_DEBUG, "rsbool_create(%s)", sel->desc); newct = xmalloc(sizeof(*newct)); - memcpy(newct, sel, sizeof(*sel)); + 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; + info->rset_l = bool_parms->rset_l; + info->rset_r = bool_parms->rset_r; + info->cmp = bool_parms->cmp; + info->buf_l = xmalloc (info->key_size); + info->buf_r = xmalloc (info->key_size); return newct; } static int r_open(rset_control *ct, int wflag) { + struct rset_bool_info *info = ct->buf; + if (wflag) { logf (LOG_FATAL, "bool set type is read-only"); return -1; } + rset_open (info->rset_l, wflag); + rset_open (info->rset_r, wflag); + info->more_l = rset_read (info->rset_l, info->buf_l); + info->more_r = rset_read (info->rset_r, info->buf_r); return 0; } static void r_close(rset_control *ct) { - /* NOP */ + struct rset_bool_info *info = ct->buf; + + rset_close (info->rset_l); + rset_close (info->rset_r); } static void r_delete(rset_control *ct) { - xfree(ct); + struct rset_bool_info *info = ct->buf; + + rset_delete (info->rset_l); + rset_delete (info->rset_r); + xfree (info->buf_l); + xfree (info->buf_r); + xfree (ct->buf); + xfree (ct); } static void r_rewind(rset_control *ct) { + struct rset_bool_info *info = ct->buf; + logf (LOG_DEBUG, "rsbool_rewind"); + rset_rewind (info->rset_l); + rset_rewind (info->rset_r); } static int r_count (rset_control *ct) @@ -91,6 +126,10 @@ static int r_count (rset_control *ct) static int r_read (rset_control *ct, void *buf) { + struct rset_bool_info *info = ct->buf; + + if (!info->more_l && !info->more_r) + return 0; return 0; } diff --git a/rset/rset.c b/rset/rset.c index 2b5e57f..0a2f92a 100644 --- a/rset/rset.c +++ b/rset/rset.c @@ -1,10 +1,13 @@ /* - * Copyright (C) 1994, Index Data I/S + * Copyright (C) 1994-1995, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: rset.c,v $ - * Revision 1.3 1995-09-04 15:20:39 adam + * Revision 1.4 1995-09-06 16:11:56 adam + * More work on boolean sets. + * + * Revision 1.3 1995/09/04 15:20:39 adam * More work on temp sets. is_open member removed. * * Revision 1.2 1995/09/04 12:33:56 adam diff --git a/rset/rsisam.c b/rset/rsisam.c index c194bf7..e9f7958 100644 --- a/rset/rsisam.c +++ b/rset/rsisam.c @@ -1,10 +1,13 @@ /* - * Copyright (C) 1994, Index Data I/S + * Copyright (C) 1994-1995, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: rsisam.c,v $ - * Revision 1.7 1995-09-06 10:35:44 adam + * Revision 1.8 1995-09-06 16:11:56 adam + * More work on boolean sets. + * + * Revision 1.7 1995/09/06 10:35:44 adam * Null set implemented. * * Revision 1.6 1995/09/05 11:43:24 adam diff --git a/rset/rstemp.c b/rset/rstemp.c index d02cce5..10412c4 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -1,10 +1,13 @@ /* - * Copyright (C) 1994, Index Data I/S + * Copyright (C) 1994-1995, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: rstemp.c,v $ - * Revision 1.5 1995-09-05 16:36:59 adam + * Revision 1.6 1995-09-06 16:11:56 adam + * More work on boolean sets. + * + * Revision 1.5 1995/09/05 16:36:59 adam * Minor changes. * * Revision 1.4 1995/09/05 11:43:24 adam -- 1.7.10.4