IDZEBRA  2.1.2
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 
81 YAZ_EXPORT
82 int bf_xclose(BFile bf, int version, const char *more_info);
83 
92 YAZ_EXPORT
93 BFile bf_open(BFiles bfs, const char *name, int block_size, int wflag);
94 
104 YAZ_EXPORT
105 BFile bf_xopen(BFiles bfs, const char *name, int block_size, int wflag,
106  const char *magic, int *read_version,
107  const char **more_info);
108 
118 YAZ_EXPORT
119 int bf_read(BFile bf, zint no, int offset, int nbytes, void *buf);
120 
131 YAZ_EXPORT
132 int bf_read2(BFile bf, zint no, int offset, int nbytes, void *buf)
133  ZEBRA_GCC_ATTR((warn_unused_result));
134 
135 
147 YAZ_EXPORT
148 int bf_write(BFile bf, zint no, int offset, int nbytes, const void *buf);
149 
150 
163 YAZ_EXPORT
164 int bf_write2(BFile bf, zint no, int offset, int nbytes, const void *buf)
165  ZEBRA_GCC_ATTR((warn_unused_result));
166 
173 YAZ_EXPORT
174 ZEBRA_RES bf_cache (BFiles bfs, const char *spec);
175 
181 YAZ_EXPORT
182 int bf_commitExists (BFiles bfs);
183 
187 YAZ_EXPORT
188 int bf_commitExec (BFiles bfs) ZEBRA_GCC_ATTR((warn_unused_result));
189 
194 YAZ_EXPORT
195 void bf_commitClean (BFiles bfs, const char *spec);
196 
200 YAZ_EXPORT
201 void bf_reset (BFiles bfs);
202 
208 YAZ_EXPORT
209 int bf_alloc(BFile bf, int no, zint *blocks);
210 
216 YAZ_EXPORT
217 int bf_free(BFile bf, int no, const zint *blocks);
218 
219 
220 /* \brief gets statistics about directory in register area
221  \param bfs block files
222  \param no directory number (0=first, 1=second,...)
223  \param directory holds directory name (if found)
224  \param used_bytes used file bytes in directory (if found)
225  \param max_bytes max usage of bytes (if found)
226  \retval 1 no is within range and directory, used, max are set.
227  \retval 0 no is out of range and directory, used, max are unset
228 
229  We are using double, because off_t may have a different size
230  on same platform depending on whether 64-bit is enabled or not.
231  Note that if a register area has unlimited size, that is represented
232  as max_bytes = -1.
233 
234 */
235 YAZ_EXPORT
236 int bfs_register_directory_stat(BFiles bfs, int no, const char **directory,
237  double *used_bytes, double *max_bytes);
238 
239 /* \brief gets statistics about directory in shadow area
240  \param bfs block files
241  \param no directory number (0=first, 1=second,...)
242  \param directory holds directory name (if found)
243  \param used_bytes used file bytes in directory (if found)
244  \param max_bytes max usage of bytes (if found)
245  \retval 1 no is within range and directory, used, max are set.
246  \retval 0 no is out of range and directory, used, max are unset
247 
248  We are using double, because off_t may have a different size
249  on same platform depending on whether 64-bit is enabled or not.
250  Note that if a shadow area has unlimited size, that is represented
251  as max_bytes = -1.
252 */
253 YAZ_EXPORT
254 int bfs_shadow_directory_stat(BFiles bfs, int no, const char **directory,
255  double *used_bytes, double *max_bytes);
256 
257 YAZ_END_CDECL
258 
259 #endif
260 /*
261  * Local variables:
262  * c-basic-offset: 4
263  * c-file-style: "Stroustrup"
264  * indent-tabs-mode: nil
265  * End:
266  * vim: shiftwidth=4 tabstop=8 expandtab
267  */
268 
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:330
struct BFile_struct * BFile
A Block File.
Definition: bfile.h:43
int bf_free(BFile bf, int no, const zint *blocks)
Releases one or more blocks in an extended block file.
Definition: bfile.c:480
#define ZEBRA_GCC_ATTR(x)
Definition: util.h:41
void bf_commitClean(BFiles bfs, const char *spec)
Cleans shadow files (remove them)
Definition: bfile.c:435
int bf_xclose(BFile bf, int version, const char *more_info)
closes an extended Block file handle..
Definition: bfile.c:239
BFiles bfs_create(const char *spec, const char *base)
creates a Block files collection
Definition: bfile.c:63
void bf_reset(BFiles bfs)
Removes register and shadow completely.
Definition: bfile.c:382
int bf_commitExists(BFiles bfs)
Check if there is content in shadow area (to be committed).
Definition: bfile.c:369
void bf_close(BFile bf)
closes a Block file (may call exit)
Definition: bfile.c:151
ZEBRA_RES bf_cache(BFiles bfs, const char *spec)
enables or disables shadow for block files
Definition: bfile.c:105
int bf_read(BFile bf, zint no, int offset, int nbytes, void *buf)
read from block file (may call exit)
Definition: bfile.c:319
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:357
void bfs_destroy(BFiles bfiles)
destroys a block files handle
Definition: bfile.c:80
char * magic
Definition: bfile.c:52
int bfs_shadow_directory_stat(BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes)
Definition: bfile.c:505
int bf_alloc(BFile bf, int no, zint *blocks)
Allocates one or more blocks in an extended block file.
Definition: bfile.c:452
long zint
Zebra integer.
Definition: util.h:66
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:346
short ZEBRA_RES
Common return type for Zebra API.
Definition: util.h:80
int bfs_register_directory_stat(BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes)
Definition: bfile.c:497
int block_size
Definition: bfile.c:47
BFile bf_xopen(BFiles bfs, const char *name, int block_size, int wflag, const char *magic, int *read_version, const char **more_info)
opens and returns an extended Block file handle
Definition: bfile.c:162
int bf_close2(BFile bf)
closes a Block file
Definition: bfile.c:131
BFile bf_open(BFiles bfs, const char *name, int block_size, int wflag)
opens and returns a Block file handle
Definition: bfile.c:261
struct BFiles_struct * BFiles
A collection of BFile(s).
Definition: bfile.h:38
int bf_commitExec(BFiles bfs) ZEBRA_GCC_ATTR((warn_unused_result))
Executes commit operation.
Definition: bfile.c:391