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