2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 2002-04-05 08:46:26 adam
8 * Zebra with full functionality
10 * Revision 1.1 2001/01/16 19:17:18 heikki
22 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
23 static RSFD r_open (RSET ct, int flag);
24 static void r_close (RSFD rfd);
25 static void r_delete (RSET ct);
26 static void r_rewind (RSFD rfd);
27 static int r_count (RSET ct);
28 static int r_read (RSFD rfd, void *buf, int *term_index);
29 static int r_write (RSFD rfd, const void *buf);
31 static const struct rset_control control =
44 const struct rset_control *rset_kind_isamd = &control;
48 struct rset_pp_info *next;
49 struct rset_isamd_info *info;
52 struct rset_isamd_info {
55 struct rset_pp_info *ispt_list;
58 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
60 rset_isamd_parms *pt = (rset_isamd_parms *) parms;
61 struct rset_isamd_info *info;
63 ct->flags |= RSET_FLAG_VOLATILE;
64 info = (struct rset_isamd_info *) xmalloc (sizeof(*info));
67 info->ispt_list = NULL;
68 ct->no_rset_terms = 1;
69 ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms));
70 ct->rset_terms[0] = pt->rset_term;
74 RSFD r_open (RSET ct, int flag)
76 struct rset_isamd_info *info = (struct rset_isamd_info *) ct->buf;
77 struct rset_pp_info *ptinfo;
79 logf (LOG_DEBUG, "risamd_open");
80 if (flag & RSETF_WRITE)
82 logf (LOG_FATAL, "ISAMD set type is read-only");
85 ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo));
86 ptinfo->next = info->ispt_list;
87 info->ispt_list = ptinfo;
88 ptinfo->pt = isamd_pp_open (info->is, info->pos);
90 if (ct->rset_terms[0]->nn < 0)
91 ct->rset_terms[0]->nn = isamd_pp_num (ptinfo->pt);
95 static void r_close (RSFD rfd)
97 struct rset_isamd_info *info = ((struct rset_pp_info*) rfd)->info;
98 struct rset_pp_info **ptinfop;
100 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
103 isamd_pp_close ((*ptinfop)->pt);
104 *ptinfop = (*ptinfop)->next;
108 logf (LOG_FATAL, "r_close but no rfd match!");
112 static void r_delete (RSET ct)
114 struct rset_isamd_info *info = (struct rset_isamd_info *) ct->buf;
116 logf (LOG_DEBUG, "rsisamd_delete");
117 assert (info->ispt_list == NULL);
118 rset_term_destroy (ct->rset_terms[0]);
119 xfree (ct->rset_terms);
123 static void r_rewind (RSFD rfd)
125 logf (LOG_DEBUG, "rsisamd_rewind");
129 static int r_count (RSET ct)
134 static int r_read (RSFD rfd, void *buf, int *term_index)
137 return isamd_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
140 static int r_write (RSFD rfd, const void *buf)
142 logf (LOG_FATAL, "ISAMD set type is read-only");