Omit CVS Id. Update copyright year.
[idzebra-moved-to-github.git] / bfile / cfile.h
1 /* This file is part of the Zebra server.
2    Copyright (C) 1995-2008 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20
21
22 #ifndef CFILE_H
23 #define CFILE_H
24
25 #include <yaz/yconfig.h>
26
27 YAZ_BEGIN_CDECL
28
29 #define HASH_BUCKET 15
30
31 struct CFile_ph_bucket {     /* structure on disc */
32     zint no[HASH_BUCKET];    /* block number in original file */
33     zint vno[HASH_BUCKET];   /* block number in shadow file */
34     zint this_bucket;        /* this bucket number */
35     zint next_bucket;        /* next bucket number */
36 };
37
38 struct CFile_hash_bucket {
39     struct CFile_ph_bucket ph;
40     int dirty;
41     struct CFile_hash_bucket *h_next, **h_prev;
42     struct CFile_hash_bucket *lru_next, *lru_prev;
43 };
44
45 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
46
47 #define CFILE_FLAT 1
48
49 typedef struct CFile_struct
50 {
51     struct CFile_head {
52         int state;               /* 1 = hash, 2 = flat */
53         zint next_block;          /* next free block / last block */
54         int block_size;          /* mfile/bfile block size */
55         int hash_size;           /* no of chains in hash table */
56         zint first_bucket;       /* first hash bucket */
57         zint next_bucket;        /* last hash bucket + 1 = first flat bucket */
58         zint flat_bucket;        /* last flat bucket + 1 */
59     } head;
60     MFile block_mf;
61     MFile hash_mf;
62     zint *array;
63     struct CFile_hash_bucket **parray;
64     struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
65     int dirty;
66     zint bucket_in_memory;
67     zint max_bucket_in_memory;
68     char *iobuf;
69     MFile rmf;
70     int  no_hits;
71     int  no_miss;
72     Zebra_mutex mutex;
73 } *CFile;
74
75 int cf_close (CFile cf);
76 CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
77                int wflag, int *firstp);
78 int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf);
79 int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf);
80 int cf_commit (CFile cf) ZEBRA_GCC_ATTR((warn_unused_result));
81
82 YAZ_END_CDECL
83
84 #endif
85 /*
86  * Local variables:
87  * c-basic-offset: 4
88  * indent-tabs-mode: nil
89  * End:
90  * vim: shiftwidth=4 tabstop=8 expandtab
91  */
92