New parameter: result-set file descriptor (RSFD) to support multiple
[idzebra-moved-to-github.git] / rset / rsnull.c
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: rsnull.c,v $
7  * Revision 1.2  1995-09-07 13:58:43  adam
8  * New parameter: result-set file descriptor (RSFD) to support multiple
9  * positions within the same result-set.
10  * Boolean operators: and, or, not implemented.
11  *
12  * Revision 1.1  1995/09/06  10:35:44  adam
13  * Null set implemented.
14  *
15  */
16
17 #include <stdio.h>
18 #include <rsnull.h>
19 #include <alexutil.h>
20
21 static rset_control *r_create(const struct rset_control *sel, void *parms);
22 static RSFD r_open (rset_control *ct, int wflag);
23 static void r_close (RSFD rfd);
24 static void r_delete (rset_control *ct);
25 static void r_rewind (RSFD rfd);
26 static int r_count (rset_control *ct);
27 static int r_read (RSFD rfd, void *buf);
28 static int r_write (RSFD rfd, const void *buf);
29
30 static const rset_control control = 
31 {
32     "NULL set type",
33     0,
34     r_create,
35     r_open,
36     r_close,
37     r_delete,
38     r_rewind,
39     r_count,
40     r_read,
41     r_write
42 };
43
44 const rset_control *rset_kind_null = &control;
45
46 static rset_control *r_create(const struct rset_control *sel, void *parms)
47 {
48     rset_control *newct;
49
50     logf (LOG_DEBUG, "rsnull_create(%s)", sel->desc);
51     newct = xmalloc(sizeof(*newct));
52     memcpy(newct, sel, sizeof(*sel));
53     return newct;
54 }
55
56 static RSFD r_open (rset_control *ct, int wflag)
57 {
58     if (wflag)
59     {
60         logf (LOG_FATAL, "NULL set type is read-only");
61         return NULL;
62     }
63     return "";
64 }
65
66 static void r_close (RSFD rfd)
67 {
68 }
69
70 static void r_delete (rset_control *ct)
71 {
72     xfree(ct);
73 }
74
75 static void r_rewind (RSFD rfd)
76 {
77     logf (LOG_DEBUG, "rsnull_rewind");
78 }
79
80 static int r_count (rset_control *ct)
81 {
82     return 0;
83 }
84
85 static int r_read (RSFD rfd, void *buf)
86 {
87     return 0;
88 }
89
90 static int r_write (RSFD rfd, const void *buf)
91 {
92     logf (LOG_FATAL, "NULL set type is read-only");
93     return -1;
94 }