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