IDZEBRA 2.2.8
rsisams.c
Go to the documentation of this file.
1/* This file is part of the Zebra server.
2 Copyright (C) Index Data
3
4Zebra is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 2, or (at your option) any later
7version.
8
9Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18*/
19
20#if HAVE_CONFIG_H
21#include <config.h>
22#endif
23#include <stdio.h>
24#include <assert.h>
25#include <idzebra/util.h>
26#include <rset.h>
27
28static RSFD r_open (RSET ct, int flag);
29static void r_close (RSFD rfd);
30static void r_delete (RSET ct);
31static int r_read (RSFD rfd, void *buf, TERMID *term);
32static void r_pos (RSFD rfd, double *current, double *total);
33
34static const struct rset_control control =
35{
36 "isams",
39 r_open,
40 r_close,
41 0, /* no forward */
42 r_pos,
43 r_read,
45};
46
47struct rfd_private {
49};
50
51struct rset_private {
53 ISAM_P pos;
54};
55
56
57RSET rsisams_create(NMEM nmem, struct rset_key_control *kcontrol,
58 int scope,
59 ISAMS is, ISAM_P pos, TERMID term)
60{
61 RSET rnew = rset_create_base(&control, nmem, kcontrol, scope, term, 0, 0);
62 struct rset_private *info;
63 info = (struct rset_private *) nmem_malloc(rnew->nmem, sizeof(*info));
64 rnew->priv = info;
65 info->is = is;
66 info->pos = pos;
67 return rnew;
68}
69
70static void r_delete (RSET ct)
71{
72 yaz_log (YLOG_DEBUG, "rsisams_delete");
73}
74
75RSFD r_open (RSET ct, int flag)
76{
77 struct rset_private *info = (struct rset_private *) ct->priv;
78 RSFD rfd;
79 struct rfd_private *ptinfo;
80
81 yaz_log (YLOG_DEBUG, "risams_open");
82 if (flag & RSETF_WRITE)
83 {
84 yaz_log (YLOG_FATAL, "ISAMS set type is read-only");
85 return NULL;
86 }
87 rfd = rfd_create_base(ct);
88 if (rfd->priv)
89 ptinfo = (struct rfd_private *)(rfd->priv);
90 else {
91 ptinfo = (struct rfd_private *) nmem_malloc(ct->nmem,sizeof(*ptinfo));
92 rfd->priv = ptinfo;
93 }
94 ptinfo->pt = isams_pp_open (info->is, info->pos);
95 return rfd;
96}
97
98static void r_close (RSFD rfd)
99{
100 struct rfd_private *ptinfo = (struct rfd_private *)(rfd->priv);
101
102 isams_pp_close (ptinfo->pt);
103}
104
105
106static int r_read (RSFD rfd, void *buf, TERMID *term)
107{
108 struct rfd_private *ptinfo = (struct rfd_private *)(rfd->priv);
109 int rc = isams_pp_read(ptinfo->pt, buf);
110 if (rc && term)
111 *term = rfd->rset->term;
112 return rc;
113}
114
115static void r_pos (RSFD rfd, double *current, double *total)
116{
117 *current=-1; /* sorry, not implemented yet */
118 *total=-1;
119}
120
121
122/*
123 * Local variables:
124 * c-basic-offset: 4
125 * c-file-style: "Stroustrup"
126 * indent-tabs-mode: nil
127 * End:
128 * vim: shiftwidth=4 tabstop=8 expandtab
129 */
130
zint ISAM_P
Definition isamc.h:28
int isams_pp_read(ISAMS_PP pp, void *buf)
Definition isams.c:227
void isams_pp_close(ISAMS_PP pp)
Definition isams.c:215
ISAMS_PP isams_pp_open(ISAMS is, ISAM_P pos)
Definition isams.c:187
RSET rset_create_base(const struct rset_control *sel, NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID term, int no_children, RSET *children)
Common constuctor for RSETs.
Definition rset.c:164
#define RSETF_WRITE
Definition rset.h:200
int rset_no_write(RSFD rfd, const void *buf)
Definition rset.c:431
RSFD rfd_create_base(RSET rs)
Common constuctor for RFDs.
Definition rset.c:43
void rset_get_one_term(RSET ct, TERMID *terms, int maxterms, int *curterm)
is a getterms function for those that don't have any
Definition rset.c:291
static const struct rset_control control
Definition rsisams.c:34
static int r_read(RSFD rfd, void *buf, TERMID *term)
Definition rsisams.c:106
static void r_delete(RSET ct)
Definition rsisams.c:70
RSET rsisams_create(NMEM nmem, struct rset_key_control *kcontrol, int scope, ISAMS is, ISAM_P pos, TERMID term)
Definition rsisams.c:57
static RSFD r_open(RSET ct, int flag)
Definition rsisams.c:75
static void r_pos(RSFD rfd, double *current, double *total)
Definition rsisams.c:115
static void r_close(RSFD rfd)
Definition rsisams.c:98
ISAMB_PP pt
Definition rsisamb.c:64
void * buf
Definition rsisamb.c:65
ISAMS_PP pt
Definition rsisams.c:48
ISAM_P pos
Definition rsisamb.c:70
ISAMB is
Definition rsisamb.c:69
ISAMS is
Definition rsisams.c:52
Definition rset.h:151
TERMID term
Definition rset.h:160
NMEM nmem
Definition rset.h:156
Definition rset.h:73
void * priv
Definition rset.h:75
RSET rset
Definition rset.h:74
const char * scope