1 /* $Id: rset.h,v 1.28 2004-08-06 12:55:01 adam 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;
36 typedef struct rset_term *RSET_TERM;
40 char *desc; /* text description of set type (for debugging) */
41 void *(*f_create)(RSET ct, const struct rset_control *sel, void *parms);
42 RSFD (*f_open)(RSET ct, int wflag);
43 void (*f_close)(RSFD rfd);
44 void (*f_delete)(RSET ct);
45 void (*f_rewind)(RSFD rfd);
46 int (*f_forward)(RSET ct, RSFD rfd, void *buf, int *term_index,
47 int (*cmpfunc)(const void *p1, const void *p2),
48 const void *untilbuf);
49 void (*f_pos)(RSFD rfd, double *current, double *total);
50 /* returns -1,-1 if pos function not implemented for this type */
51 int (*f_read)(RSFD rfd, void *buf, int *term_index);
52 int (*f_write)(RSFD rfd, const void *buf);
55 int rset_default_forward(RSET ct, RSFD rfd, void *buf, int *term_index,
56 int (*cmpfunc)(const void *p1, const void *p2),
57 const void *untilbuf);
58 void rset_default_pos(RSFD rfd, double *current, double *total);
70 const struct rset_control *control;
74 RSET_TERM *rset_terms;
78 RSET_TERM rset_term_create (const char *name, int length, const char *flags,
80 void rset_term_destroy (RSET_TERM t);
81 RSET_TERM rset_term_dup (RSET_TERM t);
86 RSET rset_create(const struct rset_control *sel, void *parms);
89 /* int rset_open(RSET rs, int wflag); */
90 #define rset_open(rs, wflag) (*(rs)->control->f_open)((rs), (wflag))
92 /* void rset_close(RSET rs); */
93 #define rset_close(rs, rfd) (*(rs)->control->f_close)(rfd)
95 void rset_delete(RSET rs);
97 RSET rset_dup (RSET rs);
99 /* void rset_rewind(RSET rs); */
100 #define rset_rewind(rs, rfd) (*(rs)->control->f_rewind)((rfd))
102 /* int rset_forward(RSET rs, void *buf, int *indx, void *untilbuf); */
103 #define rset_forward(rs, fd, buf, indx, cmpfunc, untilbuf) \
104 (*(rs)->control->f_forward)((rs), (fd), (buf), (indx), (cmpfunc), (untilbuf))
106 /* int rset_pos(RSET rs, RSFD fd, double *current, double *total); */
107 #define rset_pos(rs,fd,cur,tot) \
108 (*(rs)->control->f_pos)( (fd),(cur),(tot))
110 /* int rset_read(RSET rs, void *buf, int *indx); */
111 #define rset_read(rs, fd, buf, indx) (*(rs)->control->f_read)((fd), (buf), indx)
113 /* int rset_write(RSET rs, const void *buf); */
114 #define rset_write(rs, fd, buf) (*(rs)->control->f_write)((fd), (buf))
116 /* int rset_type (RSET) */
117 #define rset_type(rs) ((rs)->control->desc)
119 #define RSET_FLAG_VOLATILE 1
121 #define rset_is_volatile(rs) ((rs)->flags & RSET_FLAG_VOLATILE)