2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.8 1999-11-30 13:48:04 adam
8 * Improved installation. Updated for inclusion of YAZ header files.
10 * Revision 1.7 1999/05/26 07:49:14 adam
13 * Revision 1.6 1999/02/02 14:51:35 adam
14 * Updated WIN32 code specific sections. Changed header.
16 * Revision 1.5 1998/03/05 08:36:28 adam
17 * New result set model.
19 * Revision 1.4 1997/12/18 10:54:25 adam
20 * New method result set method rs_hits that returns the number of
21 * hits in result-set (if known). The ranked result set returns real
22 * number of hits but only when not combined with other operands.
24 * Revision 1.3 1997/10/31 12:37:01 adam
25 * Code calls xfree() instead of free().
27 * Revision 1.2 1996/11/08 11:15:57 adam
28 * Compressed isam fully supported.
30 * Revision 1.1 1996/10/29 13:41:48 adam
42 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
43 static RSFD r_open (RSET ct, int flag);
44 static void r_close (RSFD rfd);
45 static void r_delete (RSET ct);
46 static void r_rewind (RSFD rfd);
47 static int r_count (RSET ct);
48 static int r_read (RSFD rfd, void *buf, int *term_index);
49 static int r_write (RSFD rfd, const void *buf);
51 static const struct rset_control control =
64 const struct rset_control *rset_kind_isamc = &control;
68 struct rset_pp_info *next;
69 struct rset_isamc_info *info;
72 struct rset_isamc_info {
75 struct rset_pp_info *ispt_list;
78 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
80 rset_isamc_parms *pt = (rset_isamc_parms *) parms;
81 struct rset_isamc_info *info;
83 ct->flags |= RSET_FLAG_VOLATILE;
84 info = (struct rset_isamc_info *) xmalloc (sizeof(*info));
87 info->ispt_list = NULL;
88 ct->no_rset_terms = 1;
89 ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms));
90 ct->rset_terms[0] = pt->rset_term;
94 RSFD r_open (RSET ct, int flag)
96 struct rset_isamc_info *info = (struct rset_isamc_info *) ct->buf;
97 struct rset_pp_info *ptinfo;
99 logf (LOG_DEBUG, "risamc_open");
100 if (flag & RSETF_WRITE)
102 logf (LOG_FATAL, "ISAMC set type is read-only");
105 ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo));
106 ptinfo->next = info->ispt_list;
107 info->ispt_list = ptinfo;
108 ptinfo->pt = isc_pp_open (info->is, info->pos);
110 if (ct->rset_terms[0]->nn < 0)
111 ct->rset_terms[0]->nn = isc_pp_num (ptinfo->pt);
115 static void r_close (RSFD rfd)
117 struct rset_isamc_info *info = ((struct rset_pp_info*) rfd)->info;
118 struct rset_pp_info **ptinfop;
120 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
123 isc_pp_close ((*ptinfop)->pt);
124 *ptinfop = (*ptinfop)->next;
128 logf (LOG_FATAL, "r_close but no rfd match!");
132 static void r_delete (RSET ct)
134 struct rset_isamc_info *info = (struct rset_isamc_info *) ct->buf;
136 logf (LOG_DEBUG, "rsisamc_delete");
137 assert (info->ispt_list == NULL);
138 rset_term_destroy (ct->rset_terms[0]);
139 xfree (ct->rset_terms);
143 static void r_rewind (RSFD rfd)
145 logf (LOG_DEBUG, "rsisamc_rewind");
149 static int r_count (RSET ct)
154 static int r_read (RSFD rfd, void *buf, int *term_index)
157 return isc_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
160 static int r_write (RSFD rfd, const void *buf)
162 logf (LOG_FATAL, "ISAMC set type is read-only");