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