1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <idzebra/util.h>
26 static RSFD r_open (RSET ct, int flag);
27 static void r_close (RSFD rfd);
28 static void r_delete (RSET ct);
29 static int r_read (RSFD rfd, void *buf, TERMID *term);
30 static int r_write (RSFD rfd, const void *buf);
31 static void r_pos (RSFD rfd, double *current, double *total);
33 static const struct rset_control control =
51 struct rset_isamc_info {
56 static int log_level = 0;
57 static int log_level_initialized = 0;
59 RSET rsisamc_create(NMEM nmem, struct rset_key_control *kcontrol,
61 ISAMC is, ISAM_P pos, TERMID term)
63 RSET rnew = rset_create_base(&control, nmem, kcontrol, scope, term, 0, 0);
64 struct rset_isamc_info *info;
65 if (!log_level_initialized)
67 log_level = yaz_log_module_level("rsisamc");
68 log_level_initialized = 1;
70 info = (struct rset_isamc_info *) nmem_malloc(rnew->nmem, sizeof(*info));
74 yaz_log(log_level, "create: term=%p", term);
78 static void r_delete (RSET ct)
80 yaz_log(log_level, "rsisamc_delete");
84 RSFD r_open (RSET ct, int flag)
86 struct rset_isamc_info *info = (struct rset_isamc_info *) ct->priv;
88 struct rset_pp_info *ptinfo;
90 yaz_log(log_level, "risamc_open");
91 if (flag & RSETF_WRITE)
93 yaz_log(YLOG_FATAL, "ISAMC set type is read-only");
96 rfd = rfd_create_base(ct);
98 ptinfo = (struct rset_pp_info *)rfd->priv;
100 ptinfo = (struct rset_pp_info *) nmem_malloc (ct->nmem,sizeof(*ptinfo));
102 ptinfo->buf = nmem_malloc (ct->nmem,ct->keycontrol->key_size);
104 ptinfo->pt = isamc_pp_open(info->is, info->pos);
108 static void r_close (RSFD rfd)
110 struct rset_pp_info *p = (struct rset_pp_info *)(rfd->priv);
112 isamc_pp_close(p->pt);
116 static int r_read (RSFD rfd, void *buf, TERMID *term)
118 struct rset_pp_info *p = (struct rset_pp_info *)(rfd->priv);
120 r = isamc_pp_read(p->pt, buf);
122 *term = rfd->rset->term;
123 yaz_log(log_level, "isamc.r_read");
127 static int r_write (RSFD rfd, const void *buf)
129 yaz_log(YLOG_FATAL, "ISAMC set type is read-only");
133 static void r_pos (RSFD rfd, double *current, double *total)
135 *current = -1; /* sorry, not implemented yet */
144 * c-file-style: "Stroustrup"
145 * indent-tabs-mode: nil
147 * vim: shiftwidth=4 tabstop=8 expandtab