eeb04e07bb5288713bc24c2946f32a6c06c42e6f
[idzebra-moved-to-github.git] / include / isamg.h
1 /*
2  * Copyright (c) 1995-2000, Index Data.
3  * See the file LICENSE for details.
4  *
5  * ISAM-G  - Generic interface to all our ISAM types
6  *
7  * Heikki Levanto
8  *
9  * Detailed log at the end of the file
10  *
11  */
12
13 #ifndef ISAMG_H
14 #define ISAMG_H
15
16 /* #include <bfile.h> */
17
18 YAZ_BEGIN_CDECL
19
20 typedef struct ISAMG_s *ISAMG;
21 typedef int ISAMG_P;
22 typedef struct ISAMG_PP_s *ISAMG_PP;
23
24 #ifdef SKIPTHIS
25 /* File categories etc are no business of users of ISAM-G (or what?) */
26 typedef struct ISAMG_filecat_s {  /* filecategories, mostly block sizes */
27     int bsize;         /* block size */
28     int mblocks;       /* maximum keys before switching to larger sizes */
29 } *ISAMG_filecat;
30 #endif 
31
32
33 #ifdef SKIPTHIS
34 /* The (delta?)encoding will be encapsulated so deep in the isams that */
35 /* nobody needs to see it here... If different encodings needed, make */
36 /* new isam types! */
37
38 typedef struct ISAMG_M_s {
39     ISAMG_filecat filecat;
40
41     int (*compare_item)(const void *a, const void *b);
42
43 #define ISAMG_DECODE 0
44 #define ISAMG_ENCODE 1
45     void *(*code_start)(int mode);
46     void (*code_stop)(int mode, void *p);
47     void (*code_item)(int mode, void *p, char **dst, char **src);
48     void (*code_reset)(void *p);
49
50     int max_blocks_mem;
51     int debug;
52 } *ISAMG_M;
53 #endif
54
55 #ifdef SKIPTHIS
56 /* Is this needed? Shouldn't they all be using the same encapsulation */
57
58 typedef struct ISAMG_I_s {  /* encapsulation of input data */
59     int (*read_item)(void *clientData, char **dst, int *insertMode);
60     void *clientData;
61 } *ISAMG_I;
62 #endif
63
64 #ifdef SKIPTHIS 
65 ISAMG_M isamg_getmethod (ISAMG_M me);
66 /* Does anyone really need this method thing ?? */
67 #endif
68
69 ISAMG isamg_open (BFiles bfs, int writeflag, char *isam_type_name, Res res);
70
71 int isamg_close (ISAMG is);
72
73 ISAMG_P isamg_append (ISAMG is, ISAMG_P pos, ISAMG_I data);
74 /* This may be difficult to generalize! */
75   
76   
77 ISAMG_PP isamg_pp_open (ISAMG is, ISAMG_P pos);
78 void isamg_pp_close (ISAMG_PP pp);
79 /* int isamg_read_item (ISAMG_PP pp, char **dst);      */
80 /* int isamg_read_main_item (ISAMG_PP pp, char **dst); */
81 int isamg_pp_read (ISAMG_PP pp, void *buf);
82 int isamg_pp_num (ISAMG_PP pp);
83
84 #ifdef SKIPTHIS
85 /* all internal stuff */
86 int isamg_block_used (ISAMG is, int type);
87 int isamg_block_size (ISAMG is, int type);
88
89
90 #define isamg_type(x) ((x) & 7)
91 #define isamg_block(x) ((x) >> 3)
92 #define isamg_addr(blk,typ) (((blk)<<3)+(typ))
93
94 void isamg_buildfirstblock(ISAMG_PP pp);
95 void isamg_buildlaterblock(ISAMG_PP pp);
96 #endif
97
98 YAZ_END_CDECL
99
100 #endif  /* ISAMG_H */
101
102
103 /*
104  * $Log: isamg.h,v $
105  * Revision 1.1  2001-01-16 19:05:11  heikki
106  * Started to add isamg
107  *
108  *
109  *
110  */