Multiple registers (alpha early)
[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.20 2002-04-04 14:14:13 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, const char *base);
23 void bfs_destroy (BFiles bfiles);
24
25 typedef struct BFile_struct
26 {
27     MFile mf;
28     Zebra_lock_rdwr rdwr_lock;
29     struct CFile_struct *cf;
30 } *BFile, BFile_struct;
31
32 /* bf_close: closes bfile.
33    returns 0 if successful; non-zero otherwise 
34  */
35 int bf_close (BFile);
36
37 /* bf_open: opens bfile.
38    opens bfile with name 'name' and with 'block_size' as block size.
39    returns bfile handle is successful; NULL otherwise 
40  */
41 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
42
43 /* bf_read: reads bytes from bfile 'bf'.
44    reads 'nbytes' bytes (or whole block if 0) from offset 'offset' from
45    block 'no'. stores contents in buffer 'buf'.
46    returns 1 if whole block could be read; 0 otherwise.
47  */
48 int bf_read (BFile bf, int no, int offset, int nbytes, void *buf);
49
50 /* bf_write: writes bytes to bfile 'bf'.
51    writes 'nbytes' bytes (or whole block if 0) at offset 'offset' to
52    block 'no'. retrieves contents from buffer 'buf'.
53    returns 0 if successful; non-zero otherwise.
54  */
55 int bf_write (BFile bf, int no, int offset, int nbytes, const void *buf);
56
57 /* bf_cache: enables bfile cache if spec is not NULL */
58 void bf_cache (BFiles bfs, const char *spec);
59
60 /* bf_commitExists: returns 1 if commit is pending; 0 otherwise */
61 int bf_commitExists (BFiles bfs);
62
63 /* bf_commitExec: executes commit */
64 void bf_commitExec (BFiles bfs);
65
66 /* bf_commitClean: cleans commit files, etc */
67 void bf_commitClean (BFiles bfs, const char *spec);
68
69 /* bf_reset: delete register and shadow completely */
70 void bf_reset (BFiles bfs);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif