2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1994-09-28 16:58:33 quinn
10 * Revision 1.2 1994/09/27 20:03:52 quinn
11 * Seems relatively bug-free.
13 * Revision 1.1 1994/09/26 17:12:32 quinn
16 * Revision 1.1 1994/09/26 16:07:57 quinn
17 * Most of the functionality in place.
24 extern int is_mbuf_size[3];
26 typedef unsigned int ISAM_P;
29 * Memory buffer. Used to manage records (keys) in memory for
30 * reading and insertion/deletion.
32 typedef struct is_mbuf
36 #define IS_MBUF_TYPE_SMALL 0
37 #define IS_MBUF_TYPE_MEDIUM 1
38 #define IS_MBUF_TYPE_LARGE 2
43 char *data; /* dummy */
47 * Structure describing the virtual image of a disk block.
48 * (these blocks may grow beyond the blocksize during insertion).
50 typedef struct is_mblock
52 int num_records; /* number of records */
53 int diskpos; /* positive if this block is mapped */
54 int nextpos; /* pos of nxt blk. Only valid imm aft. rd. */
55 int bread; /* number of bytes read */
56 int state; /* state of block in rel. to disk block */
57 #define IS_MBSTATE_UNREAD 0 /* block hasn't been read */
58 #define IS_MBSTATE_PARTIAL 1 /* block has been partially read */
59 #define IS_MBSTATE_CLEAN 2 /* block is clean (unmodified) */
60 #define IS_MBSTATE_DIRTY 3 /* block has been modified */
62 is_mbuf *data; /* data contained in block */
64 struct is_mblock *next; /* next diskblock */
67 typedef struct isam_struct *ISAM;
69 * Descriptor for a specific table.
71 typedef struct is_mtable
73 int num_records; /* total number of records */
74 int pos_type; /* blocktype */
75 is_mblock *cur_mblock;
76 is_mblock *data; /* blocks contained in this table */
80 is_mblock *xmalloc_mblock();
81 is_mbuf *xmalloc_mbuf(int type);
82 void xfree_mblock(is_mblock *p);
83 void xfree_mblocks(is_mblock *l);
84 void xfree_mbuf(is_mbuf *p);
85 void xfree_mbufs(is_mbuf *l);
86 void xrelease_mblock(is_mblock *p);
87 void is_m_establish_tab(ISAM is, is_mtable *tab, ISAM_P pos);
88 void is_m_release_tab(is_mtable *tab);
89 void is_m_rewind(is_mtable *tab);
90 void is_m_replace_record(is_mtable *tab, const void *rec);
91 int is_m_write_record(is_mtable *tab, const void *rec);
92 void is_m_unread_record(is_mtable *tab);
93 int is_m_read_record(is_mtable *tab, void *buf);
94 int is_m_seek_record(is_mtable *tab, const void *rec);
95 void is_m_delete_record(is_mtable *tab);
96 int is_m_peek_record(is_mtable *tab, void *rec);
97 int is_m_read_full(is_mtable *tab, is_mblock *mblock);
98 int is_m_num_records(is_mtable *tab);