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