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