1 /*
2  *  MXBT.H
3  *
4  *  Written by Paul Edwards and released to the public domain.
5  *
6  *  See MXBT.C for more details.
7  */
8 
9 #ifndef __MXBT_H__
10 #define __MXBT_H__
11 
12 struct mxbt_ctlrec
13 {
14     /*
15      *  I have commented out the below, and read it in separately, so
16      *  as to minimize alignment problems.  The definition of this
17      *  file format is now "The control record consists of two parts, a
18      *  short integer followed by the following structure, stored in
19      *  native format.  The index and leaf records remain in native
20      *  format".
21      */
22 
23     /* unsigned short recsize; */
24     long indexStart;
25     long rootStart;
26     long lastBlock;
27     long firstLeaf;
28     long lastLeaf;
29     long freeList;
30     unsigned short levels;
31     unsigned short xor;
32 };
33 
34 struct mxbt_leafrec
35 {
36     long recType;
37     long prev;
38     long next;
39     short keyCount;
40     unsigned short keyStart;
41     struct
42     {
43         unsigned short offset;
44         unsigned short len;
45         long value;
46     }
47     keys[1];
48 };
49 
50 struct mxbt_indexrec
51 {
52     long recType;
53     long prev;
54     long next;
55     short keyCount;
56     unsigned short keyStart;
57     struct
58     {
59         unsigned short offset;
60         unsigned short len;
61         long value;
62         long lower;
63     }
64     keys[1];
65 };
66 
67 typedef struct
68 {
69     int error;
70     FILE *fp;
71     long value;
72     int (*compareF) (void *testKey, void *searchKey, int len);
73     void *searchK;
74     union
75     {
76         char intbuf[512];
77         long x;
78     }
79     myunion;
80     char *buf;
81     struct mxbt_ctlrec control;
82     struct mxbt_indexrec *index;
83     struct mxbt_leafrec *leaf;
84     unsigned short recSize;
85     long recordNum;
86 }
87 MXBT;
88 
89 long mxbtOneSearch(MXBT * mxbt, char *indexFile, void *searchKey, int (*compare) (void *testKey, void *searchKey, int len));
90 
91 #endif
92