69a3b5b2c47e7442d5f678f14cc9745adf85149e
[idzebra-moved-to-github.git] / include / bfile.h
1 /*
2  * Copyright (C) 1994-1997, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: bfile.h,v $
7  * Revision 1.15  1997-09-17 12:19:07  adam
8  * Zebra version corresponds to YAZ version 1.4.
9  * Changed Zebra server so that it doesn't depend on global common_resource.
10  *
11  * Revision 1.14  1997/09/05 15:29:58  adam
12  * Changed prototype for chr_map_input - added const.
13  * Added support for C++, headers uses extern "C" for public definitions.
14  *
15  * Revision 1.13  1996/10/29 13:43:07  adam
16  * Added a few comments.
17  *
18  * Revision 1.12  1996/03/26 16:00:44  adam
19  * The directory of the shadow table can be specified by the new
20  * bf_lockDir call.
21  *
22  * Revision 1.11  1995/12/08  16:20:39  adam
23  * New commit utilities - used for 'save' update.
24  *
25  * Revision 1.10  1995/12/01  16:24:33  adam
26  * Commit files use separate meta file area.
27  *
28  * Revision 1.9  1995/12/01  11:37:46  adam
29  * Cached/commit files implemented as meta-files.
30  *
31  * Revision 1.8  1995/11/30  08:33:29  adam
32  * Started work on commit facility.
33  *
34  * Revision 1.7  1995/09/04  12:33:35  adam
35  * Various cleanup. YAZ util used instead.
36  *
37  * Revision 1.6  1994/09/14  13:10:35  quinn
38  * Small changes
39  *
40  * Revision 1.5  1994/08/24  08:45:52  quinn
41  * Using mfile.
42  *
43  * Revision 1.4  1994/08/17  15:38:28  adam
44  * Include of util.h.
45  *
46  * Revision 1.3  1994/08/17  14:09:47  quinn
47  * Small changes
48  *
49  */
50
51 #ifndef BFILE_H
52 #define BFILE_H
53
54 #include <mfile.h>
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 #define bf_blocksize(bf) mf_blocksize(bf->mf)
61
62 typedef struct BFiles_struct *BFiles;
63
64 BFiles bfs_create (const char *spec);
65 void bfs_destroy (BFiles bfiles);
66
67 typedef struct BFile_struct
68 {
69     MFile mf;
70     struct CFile_struct *cf;
71 } *BFile, BFile_struct;
72
73 /* bf_close: closes bfile.
74    returns 0 if successful; non-zero otherwise 
75  */
76 int bf_close (BFile);
77
78 /* bf_open: opens bfile.
79    opens bfile with name 'name' and with 'block_size' as block size.
80    returns bfile handle is successful; NULL otherwise 
81  */
82 BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag);
83
84 /* bf_read: reads bytes from bfile 'bf'.
85    reads 'num' bytes (or whole block if 0) from offset 'offset' from
86    block 'no'. stores contents in buffer 'buf'.
87    returns 1 if whole block could be read; 0 otherwise.
88  */
89 int bf_read (BFile bf, int no, int offset, int num, void *buf);
90
91 /* bf_write: writes bytes to bfile 'bf'.
92    writes 'num' bytes (or whole block if 0) at offset 'offset' to
93    block 'no'. retrieves contents from buffer 'buf'.
94    returns 0 if successful; non-zero otherwise.
95  */
96 int bf_write (BFile bf, int no, int offset, int num, const void *buf);
97
98 /* bf_cache: enables bfile cache if spec is not NULL */
99 void bf_cache (BFiles bfs, const char *spec);
100
101 /* bf_lockDir: specifies locking directory for the cache system */
102 void bf_lockDir (BFiles bfs, const char *lockDir);
103
104 /* bf_commitExists: returns 1 if commit is pending; 0 otherwise */
105 int bf_commitExists (BFiles bfs);
106
107 /* bf_commitExec: executes commit */
108 void bf_commitExec (BFiles bfs);
109
110 /* bf_commitClean: cleans commit files, etc */
111 void bf_commitClean (BFiles bfs, const char *spec);
112
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif