Cached/commit files implemented as meta-files.
[idzebra-moved-to-github.git] / bfile / cfile.h
1 /*
2  * Copyright (C) 1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: cfile.h,v $
7  * Revision 1.2  1995-12-01 11:37:23  adam
8  * Cached/commit files implemented as meta-files.
9  *
10  * Revision 1.1  1995/11/30  08:33:12  adam
11  * Started work on commit facility.
12  *
13  */
14
15 #ifndef CFILE_H
16 #define CFILE_H
17
18 #define HASH_BUCKET 63
19
20 struct CFile_hash_bucket {
21     struct CFile_ph_bucket {
22         int no[HASH_BUCKET];
23         int vno[HASH_BUCKET];
24         int this_bucket;
25         int next_bucket;
26     } ph;
27     int dirty;
28     struct CFile_hash_bucket *h_next, **h_prev;
29     struct CFile_hash_bucket *lru_next, *lru_prev;
30 };
31
32 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
33
34 typedef struct CFile_struct
35 {
36     struct CFile_head {
37         int hash_size;
38         int next_bucket;
39         int next_block;
40         int block_size;
41     } head;
42     MFile block_mf;
43     MFile hash_mf;
44     int *array;
45     struct CFile_hash_bucket **parray;
46     struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
47     int dirty;
48     int bucket_in_memory;
49     int max_bucket_in_memory;
50     char *iobuf;
51     MFile rmf;
52 } *CFile;
53
54 int cf_close (CFile cf);
55 CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
56                int *firstp);
57 int cf_read (CFile cf, int no, int offset, int num, void *buf);
58 int cf_write (CFile cf, int no, int offset, int num, const void *buf);
59 void cf_commit (CFile cf);
60
61 #endif