1 /* $Id: rsisams.c,v 1.8 2004-08-20 14:44:46 heikki Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
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
30 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
31 static RSFD r_open (RSET ct, int flag);
32 static void r_close (RSFD rfd);
33 static void r_delete (RSET ct);
34 static void r_rewind (RSFD rfd);
35 static int r_read (RSFD rfd, void *buf);
36 static int r_write (RSFD rfd, const void *buf);
38 static const struct rset_control control =
52 const struct rset_control *rset_kind_isams = &control;
56 struct rset_pp_info *next;
57 struct rset_isams_info *info;
60 struct rset_isams_info {
63 struct rset_pp_info *ispt_list;
66 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
68 rset_isams_parms *pt = (struct rset_isams_parms *) parms;
69 struct rset_isams_info *info;
71 ct->flags |= RSET_FLAG_VOLATILE;
72 info = (struct rset_isams_info *) xmalloc (sizeof(*info));
75 info->ispt_list = NULL;
79 RSFD r_open (RSET ct, int flag)
81 struct rset_isams_info *info = (struct rset_isams_info *) ct->buf;
82 struct rset_pp_info *ptinfo;
84 logf (LOG_DEBUG, "risams_open");
85 if (flag & RSETF_WRITE)
87 logf (LOG_FATAL, "ISAMS set type is read-only");
90 ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo));
91 ptinfo->next = info->ispt_list;
92 info->ispt_list = ptinfo;
93 ptinfo->pt = isams_pp_open (info->is, info->pos);
98 static void r_close (RSFD rfd)
100 struct rset_isams_info *info = ((struct rset_pp_info*) rfd)->info;
101 struct rset_pp_info **ptinfop;
103 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
106 isams_pp_close ((*ptinfop)->pt);
107 *ptinfop = (*ptinfop)->next;
111 logf (LOG_FATAL, "r_close but no rfd match!");
115 static void r_delete (RSET ct)
117 struct rset_isams_info *info = (struct rset_isams_info *) ct->buf;
119 logf (LOG_DEBUG, "rsisams_delete");
120 assert (info->ispt_list == NULL);
124 static void r_rewind (RSFD rfd)
126 logf (LOG_DEBUG, "rsisams_rewind");
131 static int r_read (RSFD rfd, void *buf)
133 return isams_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
136 static int r_write (RSFD rfd, const void *buf)
138 logf (LOG_FATAL, "ISAMS set type is read-only");