2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.9 1994-09-28 16:58:26 quinn
10 * Revision 1.8 1994/09/28 12:56:09 quinn
11 * Added access functions (ISPT)
13 * Revision 1.7 1994/09/28 11:56:13 quinn
14 * Removed const from input to is_merge
16 * Revision 1.6 1994/09/28 11:29:28 quinn
17 * Added cmp parameter.
19 * Revision 1.5 1994/09/27 20:03:36 quinn
20 * Seems relatively bug-free.
22 * Revision 1.4 1994/09/26 17:05:54 quinn
25 * Revision 1.3 1994/09/26 16:08:42 quinn
26 * Most of the functionality in place.
28 * Revision 1.2 1994/09/14 13:10:35 quinn
31 * Revision 1.1 1994/09/12 08:02:07 quinn
41 #include "../isam/memory.h"
42 #include "../isam/physical.h"
44 #define IS_MAX_BLOCKTYPES 4
45 #define IS_MAX_RECORD 512
46 #define IS_DEF_REPACK_PERCENT "30" /* how much relative change before repack */
48 typedef unsigned int SYSNO; /* should be somewhere else */
51 * Description of a blocktype (part of an isam file)
53 typedef struct isam_blocktype
55 BFile bf; /* blocked file */
57 int first_block; /* position of first data block */
58 int max_keys_block; /* max num of keys per block */
59 int max_keys_block0; /* max num of keys in first block */
60 int nice_keys_block; /* nice number of keys per block */
61 int max_keys; /* max number of keys per table */
62 int freelist; /* first free block */
63 int top; /* first unused block */
64 int index; /* placeholder. Always 0. */
65 char *dbuf; /* buffer for use in I/O operations */
69 * Handle to an open isam complex.
71 typedef struct isam_struct
73 isam_blocktype types[IS_MAX_BLOCKTYPES]; /* block_types used in this file */
74 int num_types; /* number of block types used */
76 int keysize; /* size of the keys (records) used */
77 int repack; /* how many percent to grow before repack */
78 int (*cmp)(const void *k1, const void *k2); /* compare function */
81 typedef struct ispt_struct
84 struct ispt_struct *next; /* freelist */
87 #define is_type(x) ((x) & 3) /* type part of position */
88 #define is_block(x) ((x) >> 2) /* block # part of position */
90 #define is_keysize(is) ((is)->keysize)
94 *******************************************************************
100 ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
106 int is_close(ISAM is);
109 * Locate a table of keys in an isam file. The ISPT is an individual
110 * position marker for that table.
112 ISPT is_position(ISAM is, ISAM_P pos);
117 void is_pt_free(ISPT ip);
120 * Read a key from a table.
122 int is_readkey(ISPT ip, void *buf);
124 int is_writekey(ISPT ip, const void *buf);
126 int is_numkeys(ISPT ip);
128 void is_rewind(ISPT ip);
130 ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data);