2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1995-09-06 16:11:55 adam
8 * More work on boolean sets.
10 * Revision 1.1 1995/09/06 13:27:15 adam
11 * New set type: bool. Not finished yet.
19 static rset_control *r_create(const struct rset_control *sel, void *parms);
20 static int r_open (rset_control *ct, int wflag);
21 static void r_close (rset_control *ct);
22 static void r_delete (rset_control *ct);
23 static void r_rewind (rset_control *ct);
24 static int r_count (rset_control *ct);
25 static int r_read (rset_control *ct, void *buf);
26 static int r_write (rset_control *ct, const void *buf);
28 static const rset_control control =
42 const rset_control *rset_kind_bool = &control;
44 struct rset_bool_info {
53 int (*cmp)(const void *p1, const void *p2);
56 static rset_control *r_create(const struct rset_control *sel, void *parms)
59 rset_bool_parms *bool_parms = parms;
60 struct rset_bool_info *info;
62 logf (LOG_DEBUG, "rsbool_create(%s)", sel->desc);
63 newct = xmalloc(sizeof(*newct));
64 memcpy (newct, sel, sizeof(*sel));
65 newct->buf = xmalloc (sizeof(struct rset_bool_info));
66 info = (struct rset_bool_info*) newct->buf;
67 info->key_size = bool_parms->key_size;
68 info->op = bool_parms->op;
69 info->rset_l = bool_parms->rset_l;
70 info->rset_r = bool_parms->rset_r;
71 info->cmp = bool_parms->cmp;
72 info->buf_l = xmalloc (info->key_size);
73 info->buf_r = xmalloc (info->key_size);
77 static int r_open(rset_control *ct, int wflag)
79 struct rset_bool_info *info = ct->buf;
83 logf (LOG_FATAL, "bool set type is read-only");
86 rset_open (info->rset_l, wflag);
87 rset_open (info->rset_r, wflag);
88 info->more_l = rset_read (info->rset_l, info->buf_l);
89 info->more_r = rset_read (info->rset_r, info->buf_r);
93 static void r_close(rset_control *ct)
95 struct rset_bool_info *info = ct->buf;
97 rset_close (info->rset_l);
98 rset_close (info->rset_r);
101 static void r_delete(rset_control *ct)
103 struct rset_bool_info *info = ct->buf;
105 rset_delete (info->rset_l);
106 rset_delete (info->rset_r);
113 static void r_rewind(rset_control *ct)
115 struct rset_bool_info *info = ct->buf;
117 logf (LOG_DEBUG, "rsbool_rewind");
118 rset_rewind (info->rset_l);
119 rset_rewind (info->rset_r);
122 static int r_count (rset_control *ct)
127 static int r_read (rset_control *ct, void *buf)
129 struct rset_bool_info *info = ct->buf;
131 if (!info->more_l && !info->more_r)
136 static int r_write (rset_control *ct, const void *buf)
138 logf (LOG_FATAL, "bool set type is read-only");