New set type: bool. Not finished yet.
[idzebra-moved-to-github.git] / rset / rsbool.c
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: rsbool.c,v $
7  * Revision 1.1  1995-09-06 13:27:15  adam
8  * New set type: bool. Not finished yet.
9  *
10  */
11
12 #include <stdio.h>
13 #include <rsbool.h>
14 #include <alexutil.h>
15
16 static rset_control *r_create(const struct rset_control *sel, void *parms);
17 static int r_open (rset_control *ct, int wflag);
18 static void r_close (rset_control *ct);
19 static void r_delete (rset_control *ct);
20 static void r_rewind (rset_control *ct);
21 static int r_count (rset_control *ct);
22 static int r_read (rset_control *ct, void *buf);
23 static int r_write (rset_control *ct, const void *buf);
24
25 static const rset_control control = 
26 {
27     "BOOL set type",
28     0,
29     r_create,
30     r_open,
31     r_close,
32     r_delete,
33     r_rewind,
34     r_count,
35     r_read,
36     r_write
37 };
38
39 const rset_control *rset_kind_bool = &control;
40
41 struct rset_bool_info {
42     int key_size;
43     int op;
44 };
45
46 static rset_control *r_create(const struct rset_control *sel, void *parms)
47 {
48     rset_control *newct;
49     rset_bool_parms *bool_parms = parms;
50     struct rset_bool_info *info;
51
52     logf (LOG_DEBUG, "rsbool_create(%s)", sel->desc);
53     newct = xmalloc(sizeof(*newct));
54     memcpy(newct, sel, sizeof(*sel));
55     newct->buf = xmalloc (sizeof(struct rset_bool_info));
56     info = (struct rset_bool_info*) newct->buf;
57     info->key_size = bool_parms->key_size;
58     info->op = bool_parms->op;
59     return newct;
60 }
61
62 static int r_open(rset_control *ct, int wflag)
63 {
64     if (wflag)
65     {
66         logf (LOG_FATAL, "bool set type is read-only");
67         return -1;
68     }
69     return 0;
70 }
71
72 static void r_close(rset_control *ct)
73 {
74     /* NOP */
75 }
76
77 static void r_delete(rset_control *ct)
78 {
79     xfree(ct);
80 }
81
82 static void r_rewind(rset_control *ct)
83 {
84     logf (LOG_DEBUG, "rsbool_rewind");
85 }
86
87 static int r_count (rset_control *ct)
88 {
89     return 0;
90 }
91
92 static int r_read (rset_control *ct, void *buf)
93 {
94     return 0;
95 }
96
97 static int r_write (rset_control *ct, const void *buf)
98 {
99     logf (LOG_FATAL, "bool set type is read-only");
100     return -1;
101 }