1 /* $Id: rsisamc.c,v 1.40 2005-05-24 11:35:43 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 #include <idzebra/util.h>
29 static RSFD r_open (RSET ct, int flag);
30 static void r_close (RSFD rfd);
31 static void r_delete (RSET ct);
32 static int r_read (RSFD rfd, void *buf, TERMID *term);
33 static int r_write (RSFD rfd, const void *buf);
34 static void r_pos (RSFD rfd, double *current, double *total);
36 static const struct rset_control control =
54 struct rset_isamc_info {
59 static int log_level = 0;
60 static int log_level_initialized = 0;
62 RSET rsisamc_create(NMEM nmem, struct rset_key_control *kcontrol,
64 ISAMC is, ISAM_P pos, TERMID term)
66 RSET rnew = rset_create_base(&control, nmem, kcontrol, scope, term, 0, 0);
67 struct rset_isamc_info *info;
68 if (!log_level_initialized)
70 log_level = yaz_log_module_level("rsisamc");
71 log_level_initialized = 1;
73 info = (struct rset_isamc_info *) nmem_malloc(rnew->nmem, sizeof(*info));
77 yaz_log(log_level, "create: term=%p", term);
81 static void r_delete (RSET ct)
83 yaz_log(log_level, "rsisamc_delete");
87 RSFD r_open (RSET ct, int flag)
89 struct rset_isamc_info *info = (struct rset_isamc_info *) ct->priv;
91 struct rset_pp_info *ptinfo;
93 yaz_log(log_level, "risamc_open");
94 if (flag & RSETF_WRITE)
96 yaz_log(YLOG_FATAL, "ISAMC set type is read-only");
99 rfd = rfd_create_base(ct);
101 ptinfo = (struct rset_pp_info *)rfd->priv;
103 ptinfo = (struct rset_pp_info *) nmem_malloc (ct->nmem,sizeof(*ptinfo));
105 ptinfo->buf = nmem_malloc (ct->nmem,ct->keycontrol->key_size);
107 ptinfo->pt = isamc_pp_open(info->is, info->pos);
111 static void r_close (RSFD rfd)
113 struct rset_pp_info *p = (struct rset_pp_info *)(rfd->priv);
115 isamc_pp_close(p->pt);
119 static int r_read (RSFD rfd, void *buf, TERMID *term)
121 struct rset_pp_info *p = (struct rset_pp_info *)(rfd->priv);
123 r = isamc_pp_read(p->pt, buf);
125 *term = rfd->rset->term;
126 yaz_log(log_level, "isamc.r_read");
130 static int r_write (RSFD rfd, const void *buf)
132 yaz_log(YLOG_FATAL, "ISAMC set type is read-only");
136 static void r_pos (RSFD rfd, double *current, double *total)
138 *current = -1; /* sorry, not implemented yet */