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