1 /* $Id: rset.h,v 1.30 2004-08-23 12:38:53 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
35 typedef struct rset *RSET;
39 char *desc; /* text description of set type (for debugging) */
40 void *(*f_create)(RSET ct, const struct rset_control *sel, void *parms);
41 RSFD (*f_open)(RSET ct, int wflag);
42 void (*f_close)(RSFD rfd);
43 void (*f_delete)(RSET ct);
44 void (*f_rewind)(RSFD rfd);
45 int (*f_forward)(RSET ct, RSFD rfd, void *buf,
46 int (*cmpfunc)(const void *p1, const void *p2),
47 const void *untilbuf);
48 void (*f_pos)(RSFD rfd, double *current, double *total);
49 /* returns -1,-1 if pos function not implemented for this type */
50 int (*f_read)(RSFD rfd, void *buf);
51 int (*f_write)(RSFD rfd, const void *buf);
54 int rset_default_forward(RSET ct, RSFD rfd, void *buf,
55 int (*cmpfunc)(const void *p1, const void *p2),
56 const void *untilbuf);
57 void rset_default_pos(RSFD rfd, double *current, double *total);
71 const struct rset_control *control;
79 RSET rset_create(const struct rset_control *sel, void *parms);
82 /* int rset_open(RSET rs, int wflag); */
83 #define rset_open(rs, wflag) (*(rs)->control->f_open)((rs), (wflag))
85 /* void rset_close(RSET rs); */
86 #define rset_close(rs, rfd) (*(rs)->control->f_close)(rfd)
88 void rset_delete(RSET rs);
90 RSET rset_dup (RSET rs);
92 /* void rset_rewind(RSET rs); */
93 #define rset_rewind(rs, rfd) (*(rs)->control->f_rewind)((rfd))
95 /* int rset_forward(RSET rs, void *buf, void *untilbuf); */
96 #define rset_forward(rs, fd, buf, cmpfunc, untilbuf) \
97 (*(rs)->control->f_forward)((rs), (fd), (buf), (cmpfunc), (untilbuf))
99 /* int rset_pos(RSET rs, RSFD fd, double *current, double *total); */
100 #define rset_pos(rs,fd,cur,tot) \
101 (*(rs)->control->f_pos)( (fd),(cur),(tot))
103 /* int rset_read(RSET rs, void *buf); */
104 #define rset_read(rs, fd, buf) (*(rs)->control->f_read)((fd), (buf))
106 /* int rset_write(RSET rs, const void *buf); */
107 #define rset_write(rs, fd, buf) (*(rs)->control->f_write)((fd), (buf))
109 /* int rset_type (RSET) */
110 #define rset_type(rs) ((rs)->control->desc)