2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1999-05-26 07:49:14 adam
10 * Revision 1.1 1999/05/12 15:24:25 adam
11 * First version of ISAMS.
20 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
21 static RSFD r_open (RSET ct, int flag);
22 static void r_close (RSFD rfd);
23 static void r_delete (RSET ct);
24 static void r_rewind (RSFD rfd);
25 static int r_count (RSET ct);
26 static int r_read (RSFD rfd, void *buf, int *term_index);
27 static int r_write (RSFD rfd, const void *buf);
29 static const struct rset_control control =
42 const struct rset_control *rset_kind_isams = &control;
46 struct rset_pp_info *next;
47 struct rset_isams_info *info;
50 struct rset_isams_info {
53 struct rset_pp_info *ispt_list;
56 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
58 rset_isams_parms *pt = (struct rset_isams_parms *) parms;
59 struct rset_isams_info *info;
61 ct->flags |= RSET_FLAG_VOLATILE;
62 info = (struct rset_isams_info *) xmalloc (sizeof(*info));
65 info->ispt_list = NULL;
66 ct->no_rset_terms = 1;
67 ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms));
68 ct->rset_terms[0] = pt->rset_term;
72 RSFD r_open (RSET ct, int flag)
74 struct rset_isams_info *info = (struct rset_isams_info *) ct->buf;
75 struct rset_pp_info *ptinfo;
77 logf (LOG_DEBUG, "risams_open");
78 if (flag & RSETF_WRITE)
80 logf (LOG_FATAL, "ISAMS set type is read-only");
83 ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo));
84 ptinfo->next = info->ispt_list;
85 info->ispt_list = ptinfo;
86 ptinfo->pt = isams_pp_open (info->is, info->pos);
88 if (ct->rset_terms[0]->nn < 0)
89 ct->rset_terms[0]->nn = isams_pp_num (ptinfo->pt);
93 static void r_close (RSFD rfd)
95 struct rset_isams_info *info = ((struct rset_pp_info*) rfd)->info;
96 struct rset_pp_info **ptinfop;
98 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
101 isams_pp_close ((*ptinfop)->pt);
102 *ptinfop = (*ptinfop)->next;
106 logf (LOG_FATAL, "r_close but no rfd match!");
110 static void r_delete (RSET ct)
112 struct rset_isams_info *info = (struct rset_isams_info *) ct->buf;
114 logf (LOG_DEBUG, "rsisams_delete");
115 assert (info->ispt_list == NULL);
116 rset_term_destroy (ct->rset_terms[0]);
117 xfree (ct->rset_terms);
121 static void r_rewind (RSFD rfd)
123 logf (LOG_DEBUG, "rsisams_rewind");
127 static int r_count (RSET ct)
132 static int r_read (RSFD rfd, void *buf, int *term_index)
135 return isams_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
138 static int r_write (RSFD rfd, const void *buf)
140 logf (LOG_FATAL, "ISAMS set type is read-only");