b557b6a72d9cac2bdadc57e9e542c6f1a6e9e736
[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_nil (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 CONCORD_DS concord_genre_get_data_source (CONCORD_Genre genre);
79
80 int
81 concord_genre_foreach_feature_name (CONCORD_Genre genre,
82                                     int (*func) (CONCORD_Genre genre,
83                                                  unsigned char* name));
84
85
86 typedef struct CONCORD_Feature_Table CONCORD_Feature_Table;
87 typedef CONCORD_Feature_Table* CONCORD_Feature;
88
89 CONCORD_Feature
90 concord_genre_get_feature (CONCORD_Genre genre, const unsigned char* name);
91
92 unsigned char*
93 concord_feature_get_name (CONCORD_Feature feature);
94
95 int concord_feature_setup_db (CONCORD_Feature feature, int writable);
96
97 int concord_feature_sync (CONCORD_Feature feature);
98
99 int
100 concord_stroid_set_feature_str (const unsigned char* object_id,
101                                 CONCORD_Feature feature,
102                                 unsigned char* value);
103
104 int
105 concord_stroid_get_feature_string (const unsigned char* object_id,
106                                    CONCORD_Feature feature,
107                                    CONCORD_String value);
108 CONCORD_Object
109 concord_stroid_get_feature_object (const unsigned char* object_id,
110                                    CONCORD_Feature feature);
111 unsigned char*
112 concord_stroid_gets_feature (const unsigned char* object_id,
113                              CONCORD_Feature feature,
114                              unsigned char* dst, size_t size);
115
116 int
117 concord_feature_foreach_object_string (CONCORD_Feature feature,
118                                        int (*func)
119                                        (CONCORD_String object_id,
120                                         CONCORD_Feature feature,
121                                         CONCORD_String valdatum));
122
123
124 typedef struct CONCORD_INDEX_Table CONCORD_INDEX_Table;
125 typedef CONCORD_INDEX_Table* CONCORD_INDEX;
126
127 CONCORD_INDEX
128 concord_genre_get_index (CONCORD_Genre genre, const unsigned char* name);
129
130 int concord_index_setup_db (CONCORD_INDEX index, int writable);
131
132 int concord_index_sync (CONCORD_INDEX index);
133
134 int concord_index_strid_get_object_string (CONCORD_INDEX index,
135                                            const unsigned char* strid,
136                                            CONCORD_String object_id);
137
138 int concord_index_strid_set_object_str (CONCORD_INDEX index,
139                                         const unsigned char* strid,
140                                         unsigned char* object_id);
141
142 #if 0
143 {
144 #endif
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif /* !_CONCORD_H */