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