Function rset_open changed its wflag parameter to general flags.
[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.5  1995-10-10 14:00:04  adam
8  * Function rset_open changed its wflag parameter to general flags.
9  *
10  * Revision 1.4  1995/10/06  14:38:06  adam
11  * New result set method: r_score.
12  * Local no (sysno) and score is transferred to retrieveCtrl.
13  *
14  * Revision 1.3  1995/09/08  14:52:42  adam
15  * Work on relevance feedback.
16  *
17  * Revision 1.2  1995/09/07  13:58:43  adam
18  * New parameter: result-set file descriptor (RSFD) to support multiple
19  * positions within the same result-set.
20  * Boolean operators: and, or, not implemented.
21  *
22  * Revision 1.1  1995/09/06  10:35:44  adam
23  * Null set implemented.
24  *
25  */
26
27 #include <stdio.h>
28 #include <rsnull.h>
29 #include <alexutil.h>
30
31 static rset_control *r_create(const struct rset_control *sel, void *parms);
32 static RSFD r_open (rset_control *ct, int flag);
33 static void r_close (RSFD rfd);
34 static void r_delete (rset_control *ct);
35 static void r_rewind (RSFD rfd);
36 static int r_count (rset_control *ct);
37 static int r_read (RSFD rfd, void *buf);
38 static int r_write (RSFD rfd, const void *buf);
39 static int r_score (RSFD rfd, int *score);
40
41 static const rset_control control = 
42 {
43     "NULL set type",
44     0,
45     r_create,
46     r_open,
47     r_close,
48     r_delete,
49     r_rewind,
50     r_count,
51     r_read,
52     r_write,
53     r_score
54 };
55
56 const rset_control *rset_kind_null = &control;
57
58 static rset_control *r_create(const struct rset_control *sel, void *parms)
59 {
60     rset_control *newct;
61
62     newct = xmalloc(sizeof(*newct));
63     memcpy(newct, sel, sizeof(*sel));
64     return newct;
65 }
66
67 static RSFD r_open (rset_control *ct, int flag)
68 {
69     if (flag & RSETF_WRITE)
70     {
71         logf (LOG_FATAL, "NULL set type is read-only");
72         return NULL;
73     }
74     return "";
75 }
76
77 static void r_close (RSFD rfd)
78 {
79 }
80
81 static void r_delete (rset_control *ct)
82 {
83     xfree(ct);
84 }
85
86 static void r_rewind (RSFD rfd)
87 {
88     logf (LOG_DEBUG, "rsnull_rewind");
89 }
90
91 static int r_count (rset_control *ct)
92 {
93     return 0;
94 }
95
96 static int r_read (RSFD rfd, void *buf)
97 {
98     return 0;
99 }
100
101 static int r_write (RSFD rfd, const void *buf)
102 {
103     logf (LOG_FATAL, "NULL set type is read-only");
104     return -1;
105 }
106
107 static int r_score (RSFD rfd, int *score)
108 {
109     *score = -1;
110     return -1;
111 }
112