Work on flat shadow (not finished yet).
[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.6  1996-02-07 10:08:45  adam
8  * Work on flat shadow (not finished yet).
9  *
10  * Revision 1.5  1995/12/15  12:36:52  adam
11  * Moved hash file information to union.
12  * Renamed commit files.
13  *
14  * Revision 1.4  1995/12/11  09:03:54  adam
15  * New function: cf_unlink.
16  * New member of commit file head: state (0) deleted, (1) hash file.
17  *
18  * Revision 1.3  1995/12/01  16:24:29  adam
19  * Commit files use separate meta file area.
20  *
21  * Revision 1.2  1995/12/01  11:37:23  adam
22  * Cached/commit files implemented as meta-files.
23  *
24  * Revision 1.1  1995/11/30  08:33:12  adam
25  * Started work on commit facility.
26  *
27  */
28
29 #ifndef CFILE_H
30 #define CFILE_H
31
32 #define HASH_BUCKET 63
33
34 struct CFile_hash_bucket {
35     struct CFile_ph_bucket {
36         int no[HASH_BUCKET];
37         int vno[HASH_BUCKET];
38         int this_bucket;
39         int next_bucket;
40     } ph;
41     int dirty;
42     struct CFile_hash_bucket *h_next, **h_prev;
43     struct CFile_hash_bucket *lru_next, *lru_prev;
44 };
45
46 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
47
48 #define CFILE_FLAT 1
49
50 typedef struct CFile_struct
51 {
52     struct CFile_head {
53         int state;
54         int next_block;
55         int block_size;
56         int hash_size;
57         int next_bucket;
58     } head;
59     MFile block_mf;
60     MFile hash_mf;
61     int *array;
62     struct CFile_hash_bucket **parray;
63     struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
64     int dirty;
65     int bucket_in_memory;
66     int max_bucket_in_memory;
67     char *iobuf;
68     MFile rmf;
69 } *CFile;
70
71 int cf_close (CFile cf);
72 CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
73                int wflag, int *firstp);
74 int cf_read (CFile cf, int no, int offset, int num, void *buf);
75 int cf_write (CFile cf, int no, int offset, int num, const void *buf);
76 void cf_unlink (CFile cf);
77 void cf_commit (CFile cf);
78
79 #endif