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