1 /* $Id: memory.h,v 1.8 2002-08-02 19:26:56 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
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
32 extern int is_mbuf_size[3];
34 typedef unsigned int ISAM_P;
37 * Memory buffer. Used to manage records (keys) in memory for
38 * reading and insertion/deletion.
40 typedef struct is_mbuf
44 #define IS_MBUF_TYPE_SMALL 0
45 #define IS_MBUF_TYPE_MEDIUM 1
46 #define IS_MBUF_TYPE_LARGE 2
51 char *data; /* dummy */
55 * Structure describing the virtual image of a disk block.
56 * (these blocks may grow beyond the blocksize during insertion).
58 typedef struct is_mblock
60 int num_records; /* number of records */
61 int diskpos; /* positive if this block is mapped */
62 int nextpos; /* pos of nxt blk. Only valid imm aft. rd. */
63 int bread; /* number of bytes read */
64 int state; /* state of block in rel. to disk block */
65 #define IS_MBSTATE_UNREAD 0 /* block hasn't been read */
66 #define IS_MBSTATE_PARTIAL 1 /* block has been partially read */
67 #define IS_MBSTATE_CLEAN 2 /* block is clean (unmodified) */
68 #define IS_MBSTATE_DIRTY 3 /* block has been modified */
70 is_mbuf *data; /* data contained in block */
72 struct is_mblock *next; /* next diskblock */
75 typedef struct isam_struct *ISAM;
77 * Descriptor for a specific table.
79 typedef struct is_mtable
81 int num_records; /* total number of records */
82 int pos_type; /* blocktype */
83 is_mblock *cur_mblock;
85 is_mblock *data; /* blocks contained in this table */
89 is_mblock *xmalloc_mblock();
90 is_mbuf *xmalloc_mbuf(int type);
91 void xfree_mblock(is_mblock *p);
92 void xfree_mblocks(is_mblock *l);
93 void xfree_mbuf(is_mbuf *p);
94 void xfree_mbufs(is_mbuf *l);
95 void xrelease_mblock(is_mblock *p);
96 void is_m_establish_tab(ISAM is, is_mtable *tab, ISAM_P pos);
97 void is_m_release_tab(is_mtable *tab);
98 void is_m_rewind(is_mtable *tab);
99 void is_m_replace_record(is_mtable *tab, const void *rec);
100 int is_m_write_record(is_mtable *tab, const void *rec);
101 void is_m_unread_record(is_mtable *tab);
102 int is_m_read_record(is_mtable *tab, void *buf, int keep);
103 int is_m_seek_record(is_mtable *tab, const void *rec);
104 void is_m_delete_record(is_mtable *tab);
105 int is_m_peek_record(is_mtable *tab, void *rec);
106 int is_m_read_full(is_mtable *tab, is_mblock *mblock);
107 int is_m_num_records(is_mtable *tab);