Character set negotiation updates
[idzebra-moved-to-github.git] / rset / rsnull.c
1 /*
2  * Copyright (C) 1994-1999, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: rsnull.c,v $
7  * Revision 1.14  2002-07-25 13:06:44  adam
8  * Character set negotiation updates
9  *
10  * Revision 1.13  2002/03/21 10:25:42  adam
11  * use lockDir. Fixes for searchResult for null/sort sets
12  *
13  * Revision 1.12  1999/05/26 07:49:14  adam
14  * C++ compilation.
15  *
16  * Revision 1.11  1999/02/02 14:51:36  adam
17  * Updated WIN32 code specific sections. Changed header.
18  *
19  * Revision 1.10  1998/03/05 08:36:28  adam
20  * New result set model.
21  *
22  * Revision 1.9  1997/12/18 10:54:25  adam
23  * New method result set method rs_hits that returns the number of
24  * hits in result-set (if known). The ranked result set returns real
25  * number of hits but only when not combined with other operands.
26  *
27  * Revision 1.8  1996/10/29 13:55:24  adam
28  * Include of zebrautl.h instead of alexutil.h.
29  *
30  * Revision 1.7  1995/12/11 09:15:25  adam
31  * New set types: sand/sor/snot - ranked versions of and/or/not in
32  * ranked/semi-ranked result sets.
33  * Note: the snot not finished yet.
34  * New rset member: flag.
35  * Bug fix: r_delete in rsrel.c did free bad memory block.
36  *
37  * Revision 1.6  1995/10/12  12:41:57  adam
38  * Private info (buf) moved from struct rset_control to struct rset.
39  * Bug fixes in relevance.
40  *
41  * Revision 1.5  1995/10/10  14:00:04  adam
42  * Function rset_open changed its wflag parameter to general flags.
43  *
44  * Revision 1.4  1995/10/06  14:38:06  adam
45  * New result set method: r_score.
46  * Local no (sysno) and score is transferred to retrieveCtrl.
47  *
48  * Revision 1.3  1995/09/08  14:52:42  adam
49  * Work on relevance feedback.
50  *
51  * Revision 1.2  1995/09/07  13:58:43  adam
52  * New parameter: result-set file descriptor (RSFD) to support multiple
53  * positions within the same result-set.
54  * Boolean operators: and, or, not implemented.
55  *
56  * Revision 1.1  1995/09/06  10:35:44  adam
57  * Null set implemented.
58  *
59  */
60
61 #include <stdio.h>
62 #include <rsnull.h>
63 #include <zebrautl.h>
64
65 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
66 static RSFD r_open (RSET ct, int flag);
67 static void r_close (RSFD rfd);
68 static void r_delete (RSET ct);
69 static void r_rewind (RSFD rfd);
70 static int r_count (RSET ct);
71 static int r_read (RSFD rfd, void *buf, int *term_index);
72 static int r_write (RSFD rfd, const void *buf);
73
74 static const struct rset_control control = 
75 {
76     "null",
77     r_create,
78     r_open,
79     r_close,
80     r_delete,
81     r_rewind,
82     r_count,
83     r_read,
84     r_write,
85 };
86
87 const struct rset_control *rset_kind_null = &control;
88
89 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
90 {
91     rset_null_parms *null_parms = (rset_null_parms *) parms;
92
93     ct->no_rset_terms = 1;
94     ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms));
95     if (parms && null_parms->rset_term)
96         ct->rset_terms[0] = null_parms->rset_term;
97     else
98         ct->rset_terms[0] = rset_term_create ("term", -1, "rank-0",
99                                               0);
100     ct->rset_terms[0]->nn = 0;
101
102     return NULL;
103 }
104
105 static RSFD r_open (RSET ct, int flag)
106 {
107     if (flag & RSETF_WRITE)
108     {
109         logf (LOG_FATAL, "NULL set type is read-only");
110         return NULL;
111     }
112     return "";
113 }
114
115 static void r_close (RSFD rfd)
116 {
117 }
118
119 static void r_delete (RSET ct)
120 {
121     rset_term_destroy (ct->rset_terms[0]);
122     xfree (ct->rset_terms);
123 }
124
125 static void r_rewind (RSFD rfd)
126 {
127     logf (LOG_DEBUG, "rsnull_rewind");
128 }
129
130 static int r_count (RSET ct)
131 {
132     return 0;
133 }
134
135 static int r_read (RSFD rfd, void *buf, int *term_index)
136 {
137     *term_index = -1;
138     return 0;
139 }
140
141 static int r_write (RSFD rfd, const void *buf)
142 {
143     logf (LOG_FATAL, "NULL set type is read-only");
144     return -1;
145 }
146