Changed prototype for chr_map_input - added const.
[idzebra-moved-to-github.git] / include / isam.h
1 /*
2  * Copyright (C) 1994-1997, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: isam.h,v $
7  * Revision 1.12  1997-09-05 15:30:00  adam
8  * Changed prototype for chr_map_input - added const.
9  * Added support for C++, headers uses extern "C" for public definitions.
10  *
11  * Revision 1.11  1996/10/29 13:43:44  adam
12  * Removed definition of SYSNO.
13  *
14  * Revision 1.10  1995/09/06 16:10:57  adam
15  * More work on boolean sets.
16  *
17  * Revision 1.9  1994/09/28  16:58:26  quinn
18  * Small mod.
19  *
20  * Revision 1.8  1994/09/28  12:56:09  quinn
21  * Added access functions (ISPT)
22  *
23  * Revision 1.7  1994/09/28  11:56:13  quinn
24  * Removed const from input to is_merge
25  *
26  * Revision 1.6  1994/09/28  11:29:28  quinn
27  * Added cmp parameter.
28  *
29  * Revision 1.5  1994/09/27  20:03:36  quinn
30  * Seems relatively bug-free.
31  *
32  * Revision 1.4  1994/09/26  17:05:54  quinn
33  * Trivial.
34  *
35  * Revision 1.3  1994/09/26  16:08:42  quinn
36  * Most of the functionality in place.
37  *
38  * Revision 1.2  1994/09/14  13:10:35  quinn
39  * Small changes
40  *
41  * Revision 1.1  1994/09/12  08:02:07  quinn
42  * Not functional yet
43  *
44  */
45
46 #ifndef ISAM_H
47 #define ISAM_H
48
49 #include <bfile.h>
50
51 #include "../isam/memory.h"
52 #include "../isam/physical.h"
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 #define IS_MAX_BLOCKTYPES 4
59 #define IS_MAX_RECORD 512
60 #define IS_DEF_REPACK_PERCENT "30" /* how much relative change before repack */
61
62 /*
63  * Description of a blocktype (part of an isam file)
64  */
65 typedef struct isam_blocktype
66 {
67     BFile bf;                    /* blocked file */
68     int blocksize;
69     int first_block;             /* position of first data block */
70     int max_keys_block;          /* max num of keys per block */
71     int max_keys_block0;         /* max num of keys in first block */
72     int nice_keys_block;         /* nice number of keys per block */
73     int max_keys;                /* max number of keys per table */
74     int freelist;                /* first free block */
75     int top;                     /* first unused block */
76     int index;                   /* placeholder. Always 0. */
77     char *dbuf;                  /* buffer for use in I/O operations */
78 } isam_blocktype;
79
80 /*
81  * Handle to an open isam complex.
82  */
83 typedef struct isam_struct
84 {
85     isam_blocktype types[IS_MAX_BLOCKTYPES]; /* block_types used in this file */
86     int num_types;                /* number of block types used */
87     int writeflag;
88     int keysize;                  /* size of the keys (records) used */
89     int repack;                   /* how many percent to grow before repack */
90     int (*cmp)(const void *k1, const void *k2); /* compare function */
91 } isam_struct;
92
93 typedef struct ispt_struct
94 {
95     struct is_mtable tab;
96     struct ispt_struct *next;      /* freelist */
97 } ispt_struct, *ISPT; 
98
99 #define is_type(x) ((x) & 3)      /* type part of position */
100 #define is_block(x) ((x) >> 2)     /* block # part of position */
101
102 #define is_keysize(is) ((is)->keysize)
103
104 /*
105  * Public Prototypes.
106  *******************************************************************
107  */
108
109 /*
110  * Open isam file.
111  */
112 ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
113     int writeflag, int keysize);
114
115 /*
116  * Close isam file.
117  */
118 int is_close(ISAM is);
119
120 /*
121  * Locate a table of keys in an isam file. The ISPT is an individual
122  * position marker for that table.
123  */
124 ISPT is_position(ISAM is, ISAM_P pos);
125
126 /*
127  * Release ISPT.
128  */
129 void is_pt_free(ISPT ip);
130
131 /*
132  * Read a key from a table.
133  */
134 int is_readkey(ISPT ip, void *buf);
135
136 int is_writekey(ISPT ip, const void *buf);
137
138 int is_numkeys(ISPT ip);
139
140 void is_rewind(ISPT ip);
141
142 ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data);
143
144 #ifdef __cplusplus
145 }
146 #endif
147
148 #endif