Improved installation. Updated for inclusion of YAZ header files.
[idzebra-moved-to-github.git] / include / isamh.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 ISAMH_H
16 #define ISAMH_H
17
18 #include <bfile.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 typedef struct ISAMH_s *ISAMH;
25 typedef int ISAMH_P;
26 typedef struct ISAMH_PP_s *ISAMH_PP;
27
28 typedef struct ISAMH_filecat_s {  /* filecategories, mostly block sizes */
29     int bsize;         /* block size */
30     int mblocks;       /* maximum keys before switching to larger sizes */
31 } *ISAMH_filecat;
32
33 typedef struct ISAMH_M_s {
34     ISAMH_filecat filecat;
35
36     int (*compare_item)(const void *a, const void *b);
37
38 #define ISAMH_DECODE 0
39 #define ISAMH_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 } *ISAMH_M;
48
49 typedef struct ISAMH_I_s {  /* encapsulation of input data */
50     int (*read_item)(void *clientData, char **dst, int *insertMode);
51     void *clientData;
52 } *ISAMH_I;
53
54 ISAMH_M isamh_getmethod (void);
55
56 ISAMH isamh_open (BFiles bfs, const char *name, int writeflag, ISAMH_M method);
57 int isamh_close (ISAMH is);
58 ISAMH_P isamh_append (ISAMH is, ISAMH_P pos, ISAMH_I data);
59   /* corresponds to isc_merge */
60   
61   
62 ISAMH_PP isamh_pp_open (ISAMH is, ISAMH_P pos);
63 void isamh_pp_close (ISAMH_PP pp);
64 int isamh_read_item (ISAMH_PP pp, char **dst);
65 int isamh_pp_read (ISAMH_PP pp, void *buf);
66 int isamh_pp_num (ISAMH_PP pp);
67
68 int isamh_block_used (ISAMH is, int type);
69 int isamh_block_size (ISAMH is, int type);
70
71
72 #define isamh_type(x) ((x) & 7)
73 #define isamh_block(x) ((x) >> 3)
74 #define isamh_addr(blk,typ) (((blk)<<3)+(typ))
75
76 void isamh_buildfirstblock(ISAMH_PP pp);
77 void isamh_buildlaterblock(ISAMH_PP pp);
78
79 #ifdef __cplusplus
80 }
81 #endif
82
83 #endif  /* ISAMH_H */
84
85
86 /*
87  * $Log: isamh.h,v $
88  * Revision 1.3  1999-07-06 16:30:20  heikki
89  * IsamH startss to work - at least it builds indexes. Can not search yet...
90  *
91  * Revision 1.2  1999/07/06 09:37:04  heikki
92  * Working on isamh - not ready yet.
93  *
94  * Revision 1.1  1999/06/30 15:06:28  heikki
95  * copied from isamc.h, simplifying
96  *
97  */