First version of ISAMS.
[idzebra-moved-to-github.git] / bfile / cfile.h
1 /*
2  * Copyright (C) 1995-1999, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Id: cfile.h,v 1.11 1999-05-12 13:08:06 adam Exp $
7  */
8
9 #ifndef CFILE_H
10 #define CFILE_H
11
12 #define HASH_BUCKET 15
13
14 struct CFile_ph_bucket {     /* structure on disc */
15     int no[HASH_BUCKET];     /* block number in original file */
16     int vno[HASH_BUCKET];    /* block number in shadow file */
17     int this_bucket;         /* this bucket number */
18     int next_bucket;         /* next bucket number */
19 };
20
21 struct CFile_hash_bucket {
22     struct CFile_ph_bucket ph;
23     int dirty;
24     struct CFile_hash_bucket *h_next, **h_prev;
25     struct CFile_hash_bucket *lru_next, *lru_prev;
26 };
27
28 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
29
30 #define CFILE_FLAT 1
31
32 typedef struct CFile_struct
33 {
34     struct CFile_head {
35         int state;               /* 1 = hash, 2 = flat */
36         int next_block;          /* next free block / last block */
37         int block_size;          /* mfile/bfile block size */
38         int hash_size;           /* no of chains in hash table */
39         int first_bucket;        /* first hash bucket */
40         int next_bucket;         /* last hash bucket + 1 = first flat bucket */
41         int flat_bucket;         /* last flat bucket + 1 */
42     } head;
43     MFile block_mf;
44     MFile hash_mf;
45     int *array;
46     struct CFile_hash_bucket **parray;
47     struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
48     int dirty;
49     int bucket_in_memory;
50     int max_bucket_in_memory;
51     char *iobuf;
52     MFile rmf;
53     int  no_hits;
54     int  no_miss;
55 } *CFile;
56
57 int cf_close (CFile cf);
58 CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
59                int wflag, int *firstp);
60 int cf_read (CFile cf, int no, int offset, int nbytes, void *buf);
61 int cf_write (CFile cf, int no, int offset, int nbytes, const void *buf);
62 void cf_unlink (CFile cf);
63 void cf_commit (CFile cf);
64
65 #endif