IDZEBRA  2.1.2
isam.h
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
53 #ifndef ISAM_H
54 #define ISAM_H
55 
56 #include <idzebra/bfile.h>
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 
69 struct key_control {
71  int key_size;
72 
76  int scope;
77 
80  int (*cmp) (const void *p1, const void *p2);
81 
83  void (*key_logdump_txt) (int logmask, const void *p, const char *txt);
84 
87  zint (*getseq)(const void *p);
88 
91 };
92 
93 typedef struct key_control KEY_CONTROL;
94 
96  /* FIXME - in zrpn.c, time being. Needs to be moved out */
97 
98 
102  int (*read_item)(void *clientData, char **dst, int *insertMode);
103  void *clientData;
104 };
105 
106 typedef struct isam_data_stram ISAM_DATA_STREAM;
107 
108 
110 typedef zint ISAM_POS;
111 
113 typedef struct ISAM_s *ISAM;
114 
116 typedef struct ISAM_CUR_s *ISAM_CUR;
117 
119 struct isam_conrol {
121  char *desc;
123  const char *def_filename;
124 
125  /* there is an isam_open function, but it is not part of this */
126  /* dynamic table, as it is what provides this table */
127 
129  void (*f_close)(ISAM i);
130 
133  ISAM_POS (*f_put)(ISAM is, ISAM_POS pos, const void *buf);
134 
137  int (*f_del)(ISAM is, ISAM_POS pos, const void *buf);
138 
141  int (*f_get)(ISAM is, ISAM_POS pos, void *buf );
142 
144  ISAM_POS (*f_merge)(ISAM is, ISAM_POS pos, ISAM_DATA_STREAM *data);
145 
147  ISAM_CUR (*f_cur_open)(ISAM is, ISAM_POS pos);
148 
150  int (*f_read)(ISAM_CUR cur, void *buf);
151 
153  int (*f_forward)(ISAM_CUR cur, void *buf, const void *untilbuf);
154 
156  void (*f_pos)(ISAM_CUR cur, double *current, double *total);
157 
159  void (*f_cur_close)(ISAM_CUR cur);
160 
162  int (*f_unlink)(ISAM is, ISAM_POS pos);
163 
164 };
165 
167 struct ISAM_s {
168  const struct isam_control *ictrl; /* the functions */
169  const KEY_CONTROL *kctrl; /* all about the keys stored in the isam */
170  BFiles bfs; /* The underlying block file system */
171  void *priv; /* various types of ISAMs hand their private parts here */
172 };
173 
175 struct ISAM_CUR {
176  ISAM is;
177  void *priv;
178 };
179 
180 
181 
183 ISAM isam_open (BFiles bfs,
184  const char *isamtype, /* usually "b" */
185  const char *filename, /* optional, use default from control ?? */
186  int flags, /* FIXME - define read/write, and some special ones */
187  const KEY_CONTROL *key_control);
188 
189 
192 #define isam_close(is) (*(is)->ictrl->f_close)(is)
193 
194 #define isam_puf(is,pos,buf) (*(is)->ictrl->f_put)((is),(pos)(buf))
195 
196 #define isam_del(is,pos,buf) (*(is)->ictrl->f_del)((is),(pos)(buf))
197 
198 #define isam_get(is,pos,buf) (*(is)->ictrl->f_get)((is),(pos)(buf))
199 
200 #define isam_merge(is,pos,data) (*(is)->ictrl->f_merge)((is),(pos)(data))
201 
202 #define isam_cur_open(is,pos) (*(is)->ictrl->f_cur_open)((is),(pos))
203 
204 #define isam_read(cur,buf) (*(is)->ictrl->f_read)((cur),(buf))
205 
206 #define isam_forward(cur,buf,untilbuf) (*(is)->ictrl->f_forward)((cur),(buf)(untilbuf))
207 
208 #define isam_pos(cur,current,total) (*(is)->ictrl->f_pos)((cur),(current),(total))
209 
210 #define isam_cur_close(cur) (*(is)->ictrl->f_cur_close)(cur)
211 
212 #define isam_unlink(is,pos) (*(is)->ictrl->f_unlink)((is),(pos))
213 
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* ISAM_H */
220 /*
221  * Local variables:
222  * c-basic-offset: 4
223  * c-file-style: "Stroustrup"
224  * indent-tabs-mode: nil
225  * End:
226  * vim: shiftwidth=4 tabstop=8 expandtab
227  */
228 
const KEY_CONTROL * kctrl
Definition: isam.h:169
void * clientData
Definition: isam.h:103
void * priv
Definition: isam.h:171
Zebra Block File Layer.
int(* cmp)(const void *p1, const void *p2)
Definition: isam.h:80
void * priv
Definition: isam.h:177
const struct isam_control * ictrl
Definition: isam.h:168
int key_size
Definition: isam.h:71
zint ISAM_POS
Definition: isam.h:110
ISAM_CODEC * codec
Definition: isam.h:90
ISAM isam_open(BFiles bfs, const char *isamtype, const char *filename, int flags, const KEY_CONTROL *key_control)
int scope
Definition: isam.h:76
const KEY_CONTROL * default_key_control()
long zint
Zebra integer.
Definition: util.h:66
const char * def_filename
Definition: isam.h:123
BFiles bfs
Definition: isam.h:170
struct ISAM_CUR_s * ISAM_CUR
Definition: isam.h:116
zint(* getseq)(const void *p)
Definition: isam.h:87
char * desc
Definition: isam.h:121
void(* key_logdump_txt)(int logmask, const void *p, const char *txt)
Definition: isam.h:83
Definition: isam.h:167
struct ISAM_s * ISAM
Definition: isam.h:113
struct isam_data_stram ISAM_DATA_STREAM
Definition: isam.h:106
ISAM is
Definition: isam.h:176