1 /* $Id: cfile.h,v 1.17 2005-01-15 19:38:17 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
28 #include <yaz/yconfig.h>
32 #define HASH_BUCKET 15
34 struct CFile_ph_bucket { /* structure on disc */
35 zint no[HASH_BUCKET]; /* block number in original file */
36 zint vno[HASH_BUCKET]; /* block number in shadow file */
37 zint this_bucket; /* this bucket number */
38 zint next_bucket; /* next bucket number */
41 struct CFile_hash_bucket {
42 struct CFile_ph_bucket ph;
44 struct CFile_hash_bucket *h_next, **h_prev;
45 struct CFile_hash_bucket *lru_next, *lru_prev;
48 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
52 typedef struct CFile_struct
55 int state; /* 1 = hash, 2 = flat */
56 zint next_block; /* next free block / last block */
57 int block_size; /* mfile/bfile block size */
58 int hash_size; /* no of chains in hash table */
59 zint first_bucket; /* first hash bucket */
60 zint next_bucket; /* last hash bucket + 1 = first flat bucket */
61 zint flat_bucket; /* last flat bucket + 1 */
66 struct CFile_hash_bucket **parray;
67 struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
69 zint bucket_in_memory;
70 zint max_bucket_in_memory;
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, zint no, int offset, int nbytes, void *buf);
82 int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf);
83 void cf_unlink (CFile cf);
84 void cf_commit (CFile cf);