Back again
[idzebra-moved-to-github.git] / isam / memory.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: memory.h,v $
7  * Revision 1.1  1994-09-26 17:12:32  quinn
8  * Back again
9  *
10  * Revision 1.1  1994/09/26  16:07:57  quinn
11  * Most of the functionality in place.
12  *
13  */
14
15 #ifndef MEMORY_H
16 #define MEMORY_H
17
18 #include <isam.h>
19
20 extern int is_mbuf_size[3];
21
22 /*
23  * Memory buffer. Used to manage records (keys) in memory for
24  * reading and insertion/deletion.
25  */
26 typedef struct is_mbuf
27 {
28     int refcount;
29     int type;
30 #define IS_MBUF_TYPE_SMALL  0
31 #define IS_MBUF_TYPE_MEDIUM 1
32 #define IS_MBUF_TYPE_LARGE  2 
33     int offset;
34     int num;
35     int cur_record;
36     struct is_mbuf *next;
37     char *data;                 /* dummy */
38 } is_mbuf;
39
40 /*
41  * Structure describing the virtual image of a disk block.
42  * (these blocks may grow beyond the blocksize during insertion).
43  */
44 typedef struct is_mblock
45 {
46     int num_records;              /* number of records */
47     int diskpos;                  /* positive if this block is mapped */
48     int nextpos;                  /* pos of nxt blk. Only valid imm aft. rd. */
49     int bread;                    /* number of bytes read */
50     int state;                    /* state of block in rel. to disk block */
51 #define IS_MBSTATE_UNREAD  0          /* block hasn't been read */
52 #define IS_MBSTATE_PARTIAL 1          /* block has been partially read */
53 #define IS_MBSTATE_CLEAN   2          /* block is clean (unmodified) */
54 #define IS_MBSTATE_DIRTY   3          /* block has been modified */
55     is_mbuf *cur_mbuf;
56     is_mbuf *data;                /* data contained in block */
57
58     struct is_mblock *next;       /* next diskblock */
59 } is_mblock;
60
61 /*
62  * Descriptor for a specific table.
63  */
64 typedef struct is_mtable
65 {
66     int num_records;               /* total number of records */
67     int pos_type;                  /* blocktype */
68     is_mblock *cur_mblock;
69     is_mblock *data;               /* blocks contained in this table */
70     ISAM is;
71 } is_mtable;
72
73 is_mblock *xmalloc_mblock();
74 is_mbuf *xmalloc_mbuf(int type);
75 void xfree_mblock(is_mblock *p);
76 void xfree_mbuf(is_mblock *p);
77 void is_m_establish_tab(ISAM is, is_mtable *tab, ISAM_P pos);
78 void is_m_rewind(is_mtable *tab);
79 void is_m_replace_record(is_mtable *tab, const void *rec);
80 int is_m_write_record(is_mtable *tab, const void *rec);
81 void is_m_unread_record(is_mtable *tab);
82 int is_m_read_record(is_mtable *tab, void *buf);
83 int is_m_seek_record(is_mtable *tab, const void *rec);
84 void is_m_delete_record(is_mtable *tab);
85 int is_m_peek_record(is_mtable *tab, void *rec);
86 int is_m_read_full(is_mtable *tab, is_mblock *mblock);
87
88 #endif