bfile header created.
[idzebra-moved-to-github.git] / include / bfile.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: bfile.h,v $
7  * Revision 1.1  1994-08-16 16:16:02  adam
8  * bfile header created.
9  *
10  */
11
12 #ifndef BFILE_H
13 #define BFILE_H
14 struct BFile_block
15 {
16     struct BFile_block *h_next, **h_prev;
17     struct BFile_block *lru_next, *lru_prev;
18     void *data;
19     int dirty;
20     int no;
21 };
22
23 typedef struct BFile_struct
24 {
25     int fd;
26     int block_size;
27     int cache;
28     struct BFile_block *all_blocks;
29     struct BFile_block *free_list;
30     struct BFile_block **hash_array;
31
32     struct BFile_block *lru_back, *lru_front;
33     int hash_size;
34     void *all_data;
35
36     int  hits;
37     int  misses;
38 } *BFile;
39
40 int bf_close (BFile);
41 BFile bf_open (const char *name, int block_size, int cache);
42 BFile bf_open_w (const char *name, int block_size, int cache);
43 int bf_read (BFile bf, int no, void *buf);
44 int bf_write (BFile bf, int no, const void *buf);
45
46 int bf_readp (BFile bf, int no, void **bufp);
47 int bf_newp (BFile bf, int no, void **bufp);
48 int bf_touch (BFile bf, int no);
49 void bf_flush_blocks (BFile bf, int no_to_flush);
50
51 void *xmalloc_f (size_t size);
52 #define xmalloc(x) xmalloc_f(x)
53
54 extern char *prog;
55
56 #endif