8a2828b2418b700a4795da773f755bee34ccf8fd
[idzebra-moved-to-github.git] / include / idzebra / dict.h
1 /* $Id: dict.h,v 1.5 2006-05-10 08:13:20 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 /** \file dict.h
24     \brief Zebra dictionary
25     
26     The dictionary is a hash that maps a string to a value.
27     The value is opaque and is defined as a sequence of bytes
28     with a length in the range 0 to 255.
29 */
30
31 #ifndef DICT_H
32 #define DICT_H
33
34 #include <yaz/yconfig.h>
35 #include <idzebra/bfile.h>
36
37 YAZ_BEGIN_CDECL
38
39 /** \var Dict
40  * \brief Dictionary type
41  *
42  * Most dictionary functions operatate on a Dict type (object).
43  */
44 typedef struct Dict_struct *Dict;
45
46 typedef unsigned Dict_ptr;
47 typedef unsigned char Dict_char;
48
49 YAZ_EXPORT 
50 Dict dict_open (BFiles bfs, const char *name, int cache, int rw,
51                       int compact_flag, int page_size);
52
53 YAZ_EXPORT
54 int dict_close (Dict dict);
55
56 YAZ_EXPORT
57 int dict_insert (Dict dict, const char *p, int userlen, void *userinfo);
58
59 YAZ_EXPORT
60 int dict_delete (Dict dict, const char *p);
61
62 YAZ_EXPORT
63 int dict_delete_subtree (Dict dict, const char *p, void *client,
64                                 int (*f)(const char *info, void *client));
65 YAZ_EXPORT
66 char *dict_lookup (Dict dict, const char *p);
67
68 YAZ_EXPORT
69 int dict_lookup_ec (Dict dict, char *p, int range, int (*f)(char *name));
70
71 YAZ_EXPORT
72 int dict_lookup_grep (Dict dict, const char *p, int range, void *client,
73                       int *max_pos, int init_pos,
74                       int (*f)(char *name, const char *info, void *client));
75
76 YAZ_EXPORT
77 int dict_strcmp (const Dict_char *s1, const Dict_char *s2);
78
79 YAZ_EXPORT
80 int dict_strncmp (const Dict_char *s1, const Dict_char *s2, size_t n);
81
82 YAZ_EXPORT
83 int dict_strlen (const Dict_char *s);
84
85 YAZ_EXPORT
86 int dict_scan (Dict dict, char *str, 
87                int *before, int *after, void *client,
88                int (*f)(char *name, const char *info, int pos, void *client));
89
90 YAZ_EXPORT 
91 void dict_grep_cmap (Dict dict, void *vp,
92                      const char **(*cmap)(void *vp,
93                                           const char **from, int len));
94
95 YAZ_EXPORT
96 int dict_copy_compact (BFiles bfs, const char *from, const char *to);
97
98 YAZ_END_CDECL
99    
100 #endif
101 /*
102  * Local variables:
103  * c-basic-offset: 4
104  * indent-tabs-mode: nil
105  * End:
106  * vim: shiftwidth=4 tabstop=8 expandtab
107  */
108