IDZEBRA  2.2.7
bfile.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 
27 #ifndef BFILE_H
28 #define BFILE_H
29 
30 #include <yaz/yconfig.h>
31 #include <idzebra/util.h>
32 
33 YAZ_BEGIN_CDECL
34 
38 typedef struct BFiles_struct *BFiles;
39 
43 typedef struct BFile_struct *BFile;
44 
50 BFiles bfs_create (const char *spec, const char *base);
51 
58 void bfs_destroy (BFiles bfiles);
59 
63 YAZ_EXPORT
64 void bf_close(BFile bf);
65 
71 YAZ_EXPORT
72 int bf_close2(BFile bf);
73 
82 YAZ_EXPORT
83 BFile bf_open(BFiles bfs, const char *name, int block_size, int wflag);
84 
85 
95 YAZ_EXPORT
96 int bf_read(BFile bf, zint no, int offset, int nbytes, void *buf);
97 
108 YAZ_EXPORT
109 int bf_read2(BFile bf, zint no, int offset, int nbytes, void *buf)
110  ZEBRA_GCC_ATTR((warn_unused_result));
111 
112 
124 YAZ_EXPORT
125 int bf_write(BFile bf, zint no, int offset, int nbytes, const void *buf);
126 
127 
140 YAZ_EXPORT
141 int bf_write2(BFile bf, zint no, int offset, int nbytes, const void *buf)
142  ZEBRA_GCC_ATTR((warn_unused_result));
143 
150 YAZ_EXPORT
151 ZEBRA_RES bf_cache (BFiles bfs, const char *spec);
152 
158 YAZ_EXPORT
159 int bf_commitExists (BFiles bfs);
160 
164 YAZ_EXPORT
165 int bf_commitExec (BFiles bfs) ZEBRA_GCC_ATTR((warn_unused_result));
166 
171 YAZ_EXPORT
172 void bf_commitClean (BFiles bfs, const char *spec);
173 
177 YAZ_EXPORT
178 void bf_reset (BFiles bfs);
179 
180 /* \brief gets statistics about directory in register area
181  \param bfs block files
182  \param no directory number (0=first, 1=second,...)
183  \param directory holds directory name (if found)
184  \param used_bytes used file bytes in directory (if found)
185  \param max_bytes max usage of bytes (if found)
186  \retval 1 no is within range and directory, used, max are set.
187  \retval 0 no is out of range and directory, used, max are unset
188 
189  We are using double, because off_t may have a different size
190  on same platform depending on whether 64-bit is enabled or not.
191  Note that if a register area has unlimited size, that is represented
192  as max_bytes = -1.
193 
194 */
195 YAZ_EXPORT
196 int bfs_register_directory_stat(BFiles bfs, int no, const char **directory,
197  double *used_bytes, double *max_bytes);
198 
199 /* \brief gets statistics about directory in shadow area
200  \param bfs block files
201  \param no directory number (0=first, 1=second,...)
202  \param directory holds directory name (if found)
203  \param used_bytes used file bytes in directory (if found)
204  \param max_bytes max usage of bytes (if found)
205  \retval 1 no is within range and directory, used, max are set.
206  \retval 0 no is out of range and directory, used, max are unset
207 
208  We are using double, because off_t may have a different size
209  on same platform depending on whether 64-bit is enabled or not.
210  Note that if a shadow area has unlimited size, that is represented
211  as max_bytes = -1.
212 */
213 YAZ_EXPORT
214 int bfs_shadow_directory_stat(BFiles bfs, int no, const char **directory,
215  double *used_bytes, double *max_bytes);
216 
217 YAZ_END_CDECL
218 
219 #endif
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 
int bf_read(BFile bf, zint no, int offset, int nbytes, void *buf)
read from block file (may call exit)
Definition: bfile.c:205
struct BFile_struct * BFile
A Block File.
Definition: bfile.h:43
int bf_write2(BFile bf, zint no, int offset, int nbytes, const void *buf) ZEBRA_GCC_ATTR((warn_unused_result))
writes block of bytes to file
Definition: bfile.c:243
int bf_read2(BFile bf, zint no, int offset, int nbytes, void *buf) ZEBRA_GCC_ATTR((warn_unused_result))
read from block file
Definition: bfile.c:216
ZEBRA_RES bf_cache(BFiles bfs, const char *spec)
enables or disables shadow for block files
Definition: bfile.c:95
int bfs_register_directory_stat(BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes)
Definition: bfile.c:338
void bf_close(BFile bf)
closes a Block file (may call exit)
Definition: bfile.c:139
BFile bf_open(BFiles bfs, const char *name, int block_size, int wflag)
opens and returns a Block file handle
Definition: bfile.c:150
int bf_commitExec(BFiles bfs) ZEBRA_GCC_ATTR((warn_unused_result))
Executes commit operation.
Definition: bfile.c:277
int bf_write(BFile bf, zint no, int offset, int nbytes, const void *buf)
writes block of bytes to file (may call exit)
Definition: bfile.c:232
void bf_reset(BFiles bfs)
Removes register and shadow completely.
Definition: bfile.c:268
void bf_commitClean(BFiles bfs, const char *spec)
Cleans shadow files (remove them)
Definition: bfile.c:321
int bf_close2(BFile bf)
closes a Block file
Definition: bfile.c:121
int bfs_shadow_directory_stat(BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes)
Definition: bfile.c:346
BFiles bfs_create(const char *spec, const char *base)
creates a Block files collection
Definition: bfile.c:56
void bfs_destroy(BFiles bfiles)
destroys a block files handle
Definition: bfile.c:73
struct BFiles_struct * BFiles
A collection of BFile(s).
Definition: bfile.h:38
int bf_commitExists(BFiles bfs)
Check if there is content in shadow area (to be committed).
Definition: bfile.c:255
int block_size
Definition: bfile.c:46
long zint
Zebra integer.
Definition: util.h:66
#define ZEBRA_GCC_ATTR(x)
Definition: util.h:41
short ZEBRA_RES
Common return type for Zebra API.
Definition: util.h:80