92e93987d52c205cdd4d7a556928f846fad9df2f
[chise/concord.git] / concord.h
1 /* Copyright (C) 2003,2004,2005 MORIOKA Tomohiko
2    This file is part of the CONCORD Library.
3
4    The CONCORD Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    The CONCORD Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the CONCORD Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 #ifndef _CONCORD_H
20 #define _CONCORD_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 #if 0
26 }
27 #endif
28
29 #include <db.h>
30
31 typedef DBT CONCORD_String_Tank;
32 typedef CONCORD_String_Tank* CONCORD_String;
33
34 int CONCORD_String_size (const CONCORD_String s);
35 unsigned char* CONCORD_String_data (const CONCORD_String s);
36
37
38 typedef void* CONCORD_Object;
39
40 typedef enum CONCORD_Backend_Type
41 {
42   CONCORD_Backend_NONE,
43   CONCORD_Backend_Berkeley_DB
44 } CONCORD_Backend_Type;
45
46
47 typedef struct CONCORD_DS_Table CONCORD_DS_Table;
48 typedef CONCORD_DS_Table* CONCORD_DS;
49
50 CONCORD_DS
51 concord_open_ds (CONCORD_Backend_Type type, const unsigned char* location,
52                  int subtype, int modemask);
53
54 int concord_close_ds (CONCORD_DS ds);
55
56 unsigned char* concord_ds_location (CONCORD_DS ds);
57
58 int
59 concord_ds_set_object_failure (CONCORD_DS ds, CONCORD_Object object_nil);
60 int
61 concord_ds_set_read_object_function (CONCORD_DS ds,
62                                      CONCORD_Object (*read_object)
63                                      (const unsigned char* str,
64                                       size_t length));
65
66 int
67 concord_ds_foreach_genre_name (CONCORD_DS ds,
68                                int (*func) (CONCORD_DS ds,
69                                             unsigned char* name));
70
71
72 typedef struct CONCORD_Genre_Table CONCORD_Genre_Table;
73 typedef CONCORD_Genre_Table* CONCORD_Genre;
74
75 CONCORD_Genre
76 concord_ds_get_genre (CONCORD_DS ds, const unsigned char* name);
77
78 unsigned char* concord_genre_get_name (CONCORD_Genre genre);
79
80 CONCORD_DS concord_genre_get_data_source (CONCORD_Genre genre);
81
82 int
83 concord_genre_foreach_feature_name (CONCORD_Genre genre,
84                                     int (*func) (CONCORD_Genre genre,
85                                                  unsigned char* name));
86
87
88 typedef struct CONCORD_Feature_Table CONCORD_Feature_Table;
89 typedef CONCORD_Feature_Table* CONCORD_Feature;
90
91 CONCORD_Feature
92 concord_genre_get_feature (CONCORD_Genre genre, const unsigned char* name);
93
94 unsigned char*
95 concord_feature_get_name (CONCORD_Feature feature);
96
97 CONCORD_Genre concord_feature_get_genre (CONCORD_Feature feature);
98
99 int concord_feature_setup_db (CONCORD_Feature feature, int writable);
100
101 int concord_feature_sync (CONCORD_Feature feature);
102
103 int
104 concord_obj_put_feature_value_str (const unsigned char* object_id,
105                                    CONCORD_Feature feature,
106                                    unsigned char* value);
107
108 CONCORD_Object
109 concord_obj_get_feature_value (const unsigned char* object_id,
110                                CONCORD_Feature feature);
111 int
112 concord_obj_get_feature_value_string (const unsigned char* object_id,
113                                       CONCORD_Feature feature,
114                                       CONCORD_String value);
115 unsigned char*
116 concord_obj_gets_feature_value (const unsigned char* object_id,
117                                 CONCORD_Feature feature,
118                                 unsigned char* dst, size_t size);
119
120 int
121 concord_feature_foreach_obj_string (CONCORD_Feature feature,
122                                     int (*func)
123                                     (CONCORD_String object_id,
124                                      CONCORD_Feature feature,
125                                      CONCORD_String valdatum));
126
127
128 typedef struct CONCORD_INDEX_Table CONCORD_INDEX_Table;
129 typedef CONCORD_INDEX_Table* CONCORD_INDEX;
130
131 CONCORD_INDEX
132 concord_genre_get_index (CONCORD_Genre genre, const unsigned char* name);
133
134 int concord_index_setup_db (CONCORD_INDEX index, int writable);
135
136 int concord_index_sync (CONCORD_INDEX index);
137
138 int concord_index_strid_put_obj (CONCORD_INDEX index,
139                                  const unsigned char* strid,
140                                  unsigned char* object_id);
141
142 int concord_index_strid_get_obj_string (CONCORD_INDEX index,
143                                         const unsigned char* strid,
144                                         CONCORD_String object_id);
145
146 #if 0
147 {
148 #endif
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif /* !_CONCORD_H */