d9112edb81937763e1ebc1b34314d690c94b6e9f
[idzebra-moved-to-github.git] / include / isamd.h
1 /* $Id$
2    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
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 ISAMD_H
24 #define ISAMD_H
25
26 #include <bfile.h>
27
28 YAZ_BEGIN_CDECL
29
30 typedef struct ISAMD_s *ISAMD;
31 typedef int ISAMD_P;
32 typedef struct ISAMD_PP_s *ISAMD_PP;
33
34 typedef struct ISAMD_filecat_s {  /* filecategories, mostly block sizes */
35     int bsize;         /* block size */
36     int mblocks;       /* maximum keys before switching to larger sizes */
37 } *ISAMD_filecat;
38
39 typedef struct ISAMD_M_s {
40     ISAMD_filecat filecat;
41
42     int (*compare_item)(const void *a, const void *b);
43     void (*log_item)(int logmask, const void *p, const char *txt);
44
45 #define ISAMD_DECODE 0
46 #define ISAMD_ENCODE 1
47     void *(*code_start)(int mode);
48     void (*code_stop)(int mode, void *p);
49     void (*code_item)(int mode, void *p, char **dst, const char **src);
50     void (*code_reset)(void *p);
51
52     int max_blocks_mem;
53     int debug;
54 } ISAMD_M;
55
56 typedef struct ISAMD_I_s {  /* encapsulation of input data */
57     int (*read_item)(void *clientData, char **dst, int *insertMode);
58     void *clientData;
59 } *ISAMD_I;
60
61 ISAMD_M *isamd_getmethod (ISAMD_M *me);
62
63 ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M *method);
64 int isamd_close (ISAMD is);
65 /*ISAMD_P isamd_append (ISAMD is, ISAMD_P pos, ISAMD_I data);*/
66 int isamd_append (ISAMD is, char *dictentry, int dictlen, ISAMD_I data);
67
68   
69   
70 /* Shortcut: If the isam is relatively short, we store the */
71 /* whole thing in the dictionary, and allocate no blocks at all! */
72 #define ISAMD_MAX_DICT_LEN 16
73
74 /*ISAMD_PP isamd_pp_open (ISAMD is, const char *dictbuf);*/
75 ISAMD_PP isamd_pp_open (ISAMD is, const char *dictbuf, int dictlen);
76 ISAMD_PP isamd_pp_create (ISAMD is, int cat);
77
78 void isamd_pp_close (ISAMD_PP pp);
79 int isamd_read_item (ISAMD_PP pp, char **dst);
80 int isamd_read_main_item (ISAMD_PP pp, char **dst);
81 int isamd_pp_read (ISAMD_PP pp, void *buf);
82 int isamd_pp_num (ISAMD_PP pp);
83
84 int isamd_block_used (ISAMD is, int type);
85 int isamd_block_size (ISAMD is, int type);
86
87
88 #define isamd_type(x) ((x) & 7)
89 #define isamd_block(x) ((x) >> 3)
90 #define isamd_addr(blk,typ) (((blk)<<3)+(typ))
91
92 void isamd_buildfirstblock(ISAMD_PP pp);
93 void isamd_buildlaterblock(ISAMD_PP pp);
94
95 YAZ_END_CDECL
96
97 #endif  /* ISAMD_H */
98
99
100 /*
101  * $Log: isamd.h,v $
102  * Revision 1.3  1999/08/18 08:33:41  heikki
103  * Fixes
104  *
105  * Revision 1.2  1999/07/14 13:21:34  heikki
106  * Added isam-d files. Compiles (almost) clean. Doesn't work at all
107  *
108  * Revision 1.1  1999/07/14 12:34:43  heikki
109  * Copied from isamh, starting to change things...
110  *
111  *
112  */