Minor.
[idzebra-moved-to-github.git] / include / bfile.h
1 /*
2  * Copyright (C) 1994-1999, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Id: bfile.h,v 1.17 1999-05-12 13:08:06 adam Exp $
7  */
8
9 #ifndef BFILE_H
10 #define BFILE_H
11
12 #include <mfile.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #define bf_blocksize(bf) mf_blocksize(bf->mf)
19
20 typedef struct BFiles_struct *BFiles;
21
22 BFiles bfs_create (const char *spec);
23 void bfs_destroy (BFiles bfiles);
24
25 typedef struct BFile_struct
26 {
27     MFile mf;
28     struct CFile_struct *cf;
29 } *BFile, BFile_struct;
30
31 /* bf_close: closes bfile.
32    returns 0 if successful; non-zero otherwise 
33  */
34 int bf_close (BFile);
35
36 /* bf_open: opens bfile.
37    opens bfile with name 'name' and with 'block_size' as block size.
38    returns bfile handle is successful; NULL otherwise 
39  */
40 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
41
42 /* bf_read: reads bytes from bfile 'bf'.
43    reads 'nbytes' bytes (or whole block if 0) from offset 'offset' from
44    block 'no'. stores contents in buffer 'buf'.
45    returns 1 if whole block could be read; 0 otherwise.
46  */
47 int bf_read (BFile bf, int no, int offset, int nbytes, void *buf);
48
49 /* bf_write: writes bytes to bfile 'bf'.
50    writes 'nbytes' bytes (or whole block if 0) at offset 'offset' to
51    block 'no'. retrieves contents from buffer 'buf'.
52    returns 0 if successful; non-zero otherwise.
53  */
54 int bf_write (BFile bf, int no, int offset, int nbytes, const void *buf);
55
56 /* bf_cache: enables bfile cache if spec is not NULL */
57 void bf_cache (BFiles bfs, const char *spec);
58
59 /* bf_lockDir: specifies locking directory for the cache system */
60 void bf_lockDir (BFiles bfs, const char *lockDir);
61
62 /* bf_commitExists: returns 1 if commit is pending; 0 otherwise */
63 int bf_commitExists (BFiles bfs);
64
65 /* bf_commitExec: executes commit */
66 void bf_commitExec (BFiles bfs);
67
68 /* bf_commitClean: cleans commit files, etc */
69 void bf_commitClean (BFiles bfs, const char *spec);
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif