f958f7a60b003e471b348b005420b02d37e089ef
[idzebra-moved-to-github.git] / include / idzebra / isamc.h
1 /* This file is part of the Zebra server.
2    Copyright (C) 1995-2008 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #ifndef ISAMC_H
21 #define ISAMC_H
22
23 #include <idzebra/isam-codec.h>
24 #include <idzebra/bfile.h>
25
26 YAZ_BEGIN_CDECL
27
28 typedef zint ISAM_P;
29
30 typedef struct ISAMC_s *ISAMC;
31 typedef struct ISAMC_PP_s *ISAMC_PP;
32
33 typedef struct ISAMC_filecat_s {
34     int bsize;         /* block size */
35     int ifill;         /* initial fill */
36     int mfill;         /* minimum fill */
37     int mblocks;       /* maximum blocks */
38 } *ISAMC_filecat;
39
40 typedef struct ISAMC_M_s {
41     ISAMC_filecat filecat;
42
43     int (*compare_item)(const void *a, const void *b);
44     void (*log_item)(int logmask, const void *p, const char *txt);
45
46     ISAM_CODEC codec;
47
48     int max_blocks_mem;
49     int debug;
50 } ISAMC_M;
51
52 typedef struct ISAMC_I_s {
53     int (*read_item)(void *clientData, char **dst, int *insertMode);
54     void *clientData;
55 } ISAMC_I;
56
57 YAZ_EXPORT
58 void isamc_getmethod(ISAMC_M *m);
59
60 YAZ_EXPORT
61 ISAMC isamc_open(BFiles bfs, const char *name, int writeflag,
62                   ISAMC_M *method);
63 YAZ_EXPORT
64 int isamc_close(ISAMC is);
65
66 YAZ_EXPORT
67 void isamc_merge(ISAMC is, ISAM_P *pos, ISAMC_I *data);
68
69 YAZ_EXPORT
70 ISAMC_PP isamc_pp_open(ISAMC is, ISAM_P pos);
71
72 YAZ_EXPORT
73 void isamc_pp_close(ISAMC_PP pp);
74
75 YAZ_EXPORT
76 int isamc_read_item(ISAMC_PP pp, char **dst);
77
78 YAZ_EXPORT
79 int isamc_pp_read(ISAMC_PP pp, void *buf);
80
81 YAZ_EXPORT
82 zint isamc_pp_num(ISAMC_PP pp);
83
84 YAZ_EXPORT
85 zint isamc_block_used(ISAMC is, int type);
86
87 YAZ_EXPORT
88 int isamc_block_size(ISAMC is, int type);
89
90 #define isamc_type(x) ((x) & 7)
91 #define isamc_block(x) ((x) >> 3)
92
93 YAZ_END_CDECL
94
95 #endif
96 /*
97  * Local variables:
98  * c-basic-offset: 4
99  * indent-tabs-mode: nil
100  * End:
101  * vim: shiftwidth=4 tabstop=8 expandtab
102  */
103