Fixed but in cf_commit_flat.
[idzebra-moved-to-github.git] / bfile / cfile.h
1 /*
2  * Copyright (C) 1995-1998, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: cfile.h,v $
7  * Revision 1.9  1998-08-07 15:07:15  adam
8  * Fixed but in cf_commit_flat.
9  *
10  * Revision 1.8  1996/04/18 16:02:56  adam
11  * Changed logging a bit.
12  * Removed warning message when commiting flat shadow files.
13  *
14  * Revision 1.7  1996/02/07  14:03:48  adam
15  * Work on flat indexed shadow files.
16  *
17  * Revision 1.6  1996/02/07  10:08:45  adam
18  * Work on flat shadow (not finished yet).
19  *
20  * Revision 1.5  1995/12/15  12:36:52  adam
21  * Moved hash file information to union.
22  * Renamed commit files.
23  *
24  * Revision 1.4  1995/12/11  09:03:54  adam
25  * New function: cf_unlink.
26  * New member of commit file head: state (0) deleted, (1) hash file.
27  *
28  * Revision 1.3  1995/12/01  16:24:29  adam
29  * Commit files use separate meta file area.
30  *
31  * Revision 1.2  1995/12/01  11:37:23  adam
32  * Cached/commit files implemented as meta-files.
33  *
34  * Revision 1.1  1995/11/30  08:33:12  adam
35  * Started work on commit facility.
36  *
37  */
38
39 #ifndef CFILE_H
40 #define CFILE_H
41
42 #define HASH_BUCKET 15
43
44 struct CFile_hash_bucket {
45     struct CFile_ph_bucket {     /* structure on disc */
46         int no[HASH_BUCKET];     /* block number in original file */
47         int vno[HASH_BUCKET];    /* block number in shadow file */
48         int this_bucket;         /* this bucket number */
49         int next_bucket;         /* next bucket number */
50     } ph;
51     int dirty;
52     struct CFile_hash_bucket *h_next, **h_prev;
53     struct CFile_hash_bucket *lru_next, *lru_prev;
54 };
55
56 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
57
58 #define CFILE_FLAT 1
59
60 typedef struct CFile_struct
61 {
62     struct CFile_head {
63         int state;               /* 1 = hash, 2 = flat */
64         int next_block;          /* next free block / last block */
65         int block_size;          /* mfile/bfile block size */
66         int hash_size;           /* no of chains in hash table */
67         int first_bucket;        /* first hash bucket */
68         int next_bucket;         /* last hash bucket + 1 = first flat bucket */
69         int flat_bucket;         /* last flat bucket + 1 */
70     } head;
71     MFile block_mf;
72     MFile hash_mf;
73     int *array;
74     struct CFile_hash_bucket **parray;
75     struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
76     int dirty;
77     int bucket_in_memory;
78     int max_bucket_in_memory;
79     char *iobuf;
80     MFile rmf;
81     int  no_hits;
82     int  no_miss;
83 } *CFile;
84
85 int cf_close (CFile cf);
86 CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
87                int wflag, int *firstp);
88 int cf_read (CFile cf, int no, int offset, int num, void *buf);
89 int cf_write (CFile cf, int no, int offset, int num, const void *buf);
90 void cf_unlink (CFile cf);
91 void cf_commit (CFile cf);
92
93 #endif