(CONCORD_Genre_Table): Revived as an alias of `COS_Genre_ent'.
[chise/concord.git] / concord.h
1 /* Copyright (C) 2003, 2004, 2005, 2006, 2013 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 #include <cos.h>
31
32 typedef DBT CONCORD_String_Tank;
33 typedef CONCORD_String_Tank* CONCORD_String;
34
35 int CONCORD_String_size (const CONCORD_String s);
36 unsigned char* CONCORD_String_data (const CONCORD_String s);
37
38
39 typedef COS_Object CONCORD_Object;
40
41 typedef enum CONCORD_Backend_Type
42 {
43   CONCORD_Backend_NONE,
44   CONCORD_Backend_Berkeley_DB
45 } CONCORD_Backend_Type;
46
47
48 typedef struct COS_DS_ent COS_DS_ent;
49 typedef COS_DS_ent* COS_DS;
50 typedef COS_DS CONCORD_DS;
51
52 CONCORD_DS
53 concord_open_ds (CONCORD_Backend_Type type, const char* location,
54                  int subtype, int modemask);
55
56 COS_DS concord_open_env (COS_object ds);
57
58 int concord_close_ds (CONCORD_DS ds);
59
60 char* concord_ds_location (CONCORD_DS ds);
61
62 int
63 concord_ds_set_object_failure (CONCORD_DS ds, CONCORD_Object object_nil);
64 int
65 concord_ds_set_read_object_function (CONCORD_DS ds,
66                                      CONCORD_Object (*read_object)
67                                      (const unsigned char* str,
68                                       size_t length));
69
70 int
71 concord_ds_foreach_genre_name (CONCORD_DS ds,
72                                int (*func) (CONCORD_DS ds, char* name));
73
74
75 typedef struct COS_Genre_ent COS_Genre_ent;
76 typedef COS_Genre_ent* COS_Genre;
77 typedef COS_Genre_ent CONCORD_Genre_Table;
78 typedef COS_Genre CONCORD_Genre;
79
80 CONCORD_Genre
81 concord_ds_get_genre (CONCORD_DS ds, const char* name);
82
83 COS_Genre
84 concord_get_genre (COS_object ds, COS_object genre);
85
86 char* concord_genre_get_name (CONCORD_Genre genre);
87
88 CONCORD_DS concord_genre_get_data_source (CONCORD_Genre genre);
89
90 int
91 concord_genre_foreach_feature_name (CONCORD_Genre genre,
92                                     int (*func) (CONCORD_Genre genre,
93                                                  char* name));
94
95
96 typedef struct COS_Feature_ent COS_Feature_ent;
97 typedef COS_Feature_ent* COS_Feature;
98 typedef COS_Feature CONCORD_Feature;
99
100 CONCORD_Feature
101 concord_genre_get_feature (CONCORD_Genre genre, const char* name);
102
103 COS_Feature
104 concord_get_feature (COS_object ds,
105                      COS_object genre, COS_object feature);
106
107 char* concord_feature_get_name (CONCORD_Feature feature);
108
109 CONCORD_Genre concord_feature_get_genre (CONCORD_Feature feature);
110
111 int concord_feature_setup_db (CONCORD_Feature feature, int writable);
112
113 int concord_feature_sync (CONCORD_Feature feature);
114
115 int
116 concord_obj_put_feature_value_str (const char* object_id,
117                                    CONCORD_Feature feature,
118                                    unsigned char* value);
119
120 CONCORD_Object
121 concord_obj_get_feature_value (const char* object_id,
122                                CONCORD_Feature feature);
123 int
124 concord_obj_get_feature_value_string (const char* object_id,
125                                       CONCORD_Feature feature,
126                                       CONCORD_String value);
127 unsigned char*
128 concord_obj_gets_feature_value (const char* object_id,
129                                 CONCORD_Feature feature,
130                                 unsigned char* dst, size_t size);
131
132 COS_object
133 concord_object_get_feature_value (COS_object object, COS_object feature);
134
135 int
136 concord_feature_foreach_obj_string (CONCORD_Feature feature,
137                                     int (*func)
138                                     (CONCORD_String object_id,
139                                      CONCORD_Feature feature,
140                                      CONCORD_String valdatum));
141
142
143 typedef struct COS_Feature_INDEX_ent COS_Feature_INDEX_ent;
144 typedef COS_Feature_INDEX_ent* COS_Feature_INDEX;
145 typedef COS_Feature_INDEX CONCORD_INDEX;
146
147 CONCORD_INDEX
148 concord_genre_get_index (CONCORD_Genre genre, const char* name);
149
150 COS_Feature_INDEX
151 concord_get_feature_index (COS_object ds,
152                            COS_object genre, COS_object feature);
153
154 char* concord_index_get_name (CONCORD_INDEX index);
155
156 CONCORD_Genre concord_index_get_genre (CONCORD_INDEX index);
157
158 int concord_index_setup_db (CONCORD_INDEX index, int writable);
159
160 int concord_index_sync (CONCORD_INDEX index);
161
162 int concord_index_strid_put_obj (CONCORD_INDEX index,
163                                  const char* strid,
164                                  char* object_id);
165
166 int concord_index_strid_get_obj_string (CONCORD_INDEX index,
167                                         const char* strid,
168                                         CONCORD_String object_id);
169
170
171 COS_object
172 concord_decode_object (COS_object ds, COS_object genre,
173                        COS_object feature, COS_object id);
174
175 #if 0
176 {
177 #endif
178 #ifdef __cplusplus
179 }
180 #endif
181
182 #endif /* !_CONCORD_H */