Removed the VOLATILE flag from rsets
[idzebra-moved-to-github.git] / include / rset.h
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
3    Index Data Aps
4
5 This file is part of the Zebra server.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.
21 */
22
23
24
25 #ifndef RSET_H
26 #define RSET_H
27
28 #include <stdlib.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 typedef void *RSFD;
34
35 typedef struct rset *RSET;
36
37 struct rset_control
38 {
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);
52 };
53
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);
58
59 /*
60 struct rset_term {
61     char *name;
62     zint nn;
63     char *flags;
64     zint count;
65     int  type;
66 };
67 */
68
69 typedef struct rset
70 {
71     const struct rset_control *control;
72     int  count;
73     void *buf;
74 } rset;
75
76 #define RSETF_READ       0
77 #define RSETF_WRITE      1
78
79 RSET rset_create(const struct rset_control *sel, void *parms); 
80 /* parameters? */
81
82 /* int rset_open(RSET rs, int wflag); */
83 #define rset_open(rs, wflag) (*(rs)->control->f_open)((rs), (wflag))
84
85 /* void rset_close(RSET rs); */
86 #define rset_close(rs, rfd) (*(rs)->control->f_close)(rfd)
87
88 void rset_delete(RSET rs);
89
90 RSET rset_dup (RSET rs);
91
92 /* void rset_rewind(RSET rs); */
93 #define rset_rewind(rs, rfd) (*(rs)->control->f_rewind)((rfd))
94
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))
98
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))
102
103 /* int rset_read(RSET rs, void *buf); */
104 #define rset_read(rs, fd, buf) (*(rs)->control->f_read)((fd), (buf))
105
106 /* int rset_write(RSET rs, const void *buf); */
107 #define rset_write(rs, fd, buf) (*(rs)->control->f_write)((fd), (buf))
108
109 /* int rset_type (RSET) */
110 #define rset_type(rs) ((rs)->control->desc)
111
112
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif