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