(concord_open_ds): Use <char*> instead of <unsigned char*> for
[chise/concord.git] / concord.h
1 /* Copyright (C) 2003,2004,2005,2006 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 char* location,
52                  int subtype, int modemask);
53
54 int concord_close_ds (CONCORD_DS ds);
55
56 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, char* name));
69
70
71 typedef struct CONCORD_Genre_Table CONCORD_Genre_Table;
72 typedef CONCORD_Genre_Table* CONCORD_Genre;
73
74 CONCORD_Genre
75 concord_ds_get_genre (CONCORD_DS ds, const char* name);
76
77 char* concord_genre_get_name (CONCORD_Genre genre);
78
79 CONCORD_DS concord_genre_get_data_source (CONCORD_Genre genre);
80
81 int
82 concord_genre_foreach_feature_name (CONCORD_Genre genre,
83                                     int (*func) (CONCORD_Genre genre,
84                                                  char* name));
85
86
87 typedef struct CONCORD_Feature_Table CONCORD_Feature_Table;
88 typedef CONCORD_Feature_Table* CONCORD_Feature;
89
90 CONCORD_Feature
91 concord_genre_get_feature (CONCORD_Genre genre, const char* name);
92
93 char* concord_feature_get_name (CONCORD_Feature feature);
94
95 CONCORD_Genre concord_feature_get_genre (CONCORD_Feature feature);
96
97 int concord_feature_setup_db (CONCORD_Feature feature, int writable);
98
99 int concord_feature_sync (CONCORD_Feature feature);
100
101 int
102 concord_obj_put_feature_value_str (const char* object_id,
103                                    CONCORD_Feature feature,
104                                    unsigned char* value);
105
106 CONCORD_Object
107 concord_obj_get_feature_value (const char* object_id,
108                                CONCORD_Feature feature);
109 int
110 concord_obj_get_feature_value_string (const char* object_id,
111                                       CONCORD_Feature feature,
112                                       CONCORD_String value);
113 unsigned char*
114 concord_obj_gets_feature_value (const char* object_id,
115                                 CONCORD_Feature feature,
116                                 unsigned char* dst, size_t size);
117
118 int
119 concord_feature_foreach_obj_string (CONCORD_Feature feature,
120                                     int (*func)
121                                     (CONCORD_String object_id,
122                                      CONCORD_Feature feature,
123                                      CONCORD_String valdatum));
124
125
126 typedef struct CONCORD_INDEX_Table CONCORD_INDEX_Table;
127 typedef CONCORD_INDEX_Table* CONCORD_INDEX;
128
129 CONCORD_INDEX
130 concord_genre_get_index (CONCORD_Genre genre, const char* name);
131
132 int concord_index_setup_db (CONCORD_INDEX index, int writable);
133
134 int concord_index_sync (CONCORD_INDEX index);
135
136 int concord_index_strid_put_obj (CONCORD_INDEX index,
137                                  const char* strid,
138                                  char* object_id);
139
140 int concord_index_strid_get_obj_string (CONCORD_INDEX index,
141                                         const char* strid,
142                                         CONCORD_String object_id);
143
144 #if 0
145 {
146 #endif
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif /* !_CONCORD_H */