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