Minor.
[idzebra-moved-to-github.git] / include / isamd.h
1 /*
2  * Copyright (c) 1995-1997, Index Data.
3  * See the file LICENSE for details.
4  *
5  * IsamH is a simple ISAM that can only append to the end of the list.
6  * It will need a clean-up process occasionally...  Code stolen from
7  * isamc...
8  * 
9  * Heikki Levanto
10  *
11  * Detailed log at the end of the file
12  *
13  */
14
15 #ifndef ISAMD_H
16 #define ISAMD_H
17
18 #include <bfile.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 typedef struct ISAMD_s *ISAMD;
25 typedef int ISAMD_P;
26 typedef struct ISAMD_PP_s *ISAMD_PP;
27
28 typedef struct ISAMD_filecat_s {  /* filecategories, mostly block sizes */
29     int bsize;         /* block size */
30     int mblocks;       /* maximum keys before switching to larger sizes */
31 } *ISAMD_filecat;
32
33 typedef struct ISAMD_M_s {
34     ISAMD_filecat filecat;
35
36     int (*compare_item)(const void *a, const void *b);
37
38 #define ISAMD_DECODE 0
39 #define ISAMD_ENCODE 1
40     void *(*code_start)(int mode);
41     void (*code_stop)(int mode, void *p);
42     void (*code_item)(int mode, void *p, char **dst, char **src);
43     void (*code_reset)(void *p);
44
45     int max_blocks_mem;
46     int debug;
47 } *ISAMD_M;
48
49 typedef struct ISAMD_I_s {  /* encapsulation of input data */
50     int (*read_item)(void *clientData, char **dst, int *insertMode);
51     void *clientData;
52 } *ISAMD_I;
53
54 ISAMD_M isamd_getmethod (ISAMD_M me);
55
56 ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method);
57 int isamd_close (ISAMD is);
58 ISAMD_P isamd_append (ISAMD is, ISAMD_P pos, ISAMD_I data);
59   /* corresponds to isc_merge */
60   
61   
62 ISAMD_PP isamd_pp_open (ISAMD is, ISAMD_P pos);
63 void isamd_pp_close (ISAMD_PP pp);
64 int isamd_read_item (ISAMD_PP pp, char **dst);
65 int isamd_read_main_item (ISAMD_PP pp, char **dst);
66 int isamd_pp_read (ISAMD_PP pp, void *buf);
67 int isamd_pp_num (ISAMD_PP pp);
68
69 int isamd_block_used (ISAMD is, int type);
70 int isamd_block_size (ISAMD is, int type);
71
72
73 #define isamd_type(x) ((x) & 7)
74 #define isamd_block(x) ((x) >> 3)
75 #define isamd_addr(blk,typ) (((blk)<<3)+(typ))
76
77 void isamd_buildfirstblock(ISAMD_PP pp);
78 void isamd_buildlaterblock(ISAMD_PP pp);
79
80
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif  /* ISAMD_H */
87
88
89 /*
90  * $Log: isamd.h,v $
91  * Revision 1.3  1999/08/18 08:33:41  heikki
92  * Fixes
93  *
94  * Revision 1.2  1999/07/14 13:21:34  heikki
95  * Added isam-d files. Compiles (almost) clean. Doesn't work at all
96  *
97  * Revision 1.1  1999/07/14 12:34:43  heikki
98  * Copied from isamh, starting to change things...
99  *
100  *
101  */