Update version to 0.2.0.
[chise/libchise.git] / chise.h
1 #ifndef _CHISE_H
2 #define _CHISE_H
3
4 #include <db.h>
5 #include <errno.h>
6
7 typedef enum CHISE_DS_Type
8 {
9   CHISE_DS_NONE,
10   CHISE_DS_Berkeley_DB
11 } CHISE_DS_Type;
12
13 typedef struct CHISE_DS
14 {
15   CHISE_DS_Type type;
16   char *location;
17 } CHISE_DS;
18
19 int chise_open_data_source (CHISE_DS *ds, CHISE_DS_Type type,
20                             char *location);
21
22 int chise_close_data_source (CHISE_DS *ds);
23
24
25 typedef int CHISE_Char_ID;
26
27
28 typedef DBT CHISE_Value;
29
30 static inline int
31 chise_value_size (const CHISE_Value *s)
32 {
33   return s->size;
34 }
35
36 static inline char *
37 chise_value_data (const CHISE_Value *s)
38 {
39   return s->data;
40 }
41
42 static inline char *
43 chise_value_to_c_string (const CHISE_Value *s)
44 {
45   return s->data;
46 }
47
48
49 typedef struct CHISE_Attribute_Table
50 {
51   DB *dbp;
52 } CHISE_Attribute_Table;
53
54
55 typedef CHISE_Attribute_Table CHISE_Decoding_Table;
56
57 int chise_open_decoding_table (CHISE_Decoding_Table *db,
58                                CHISE_DS *ds, const char *ccs,
59                                DBTYPE real_subtype,
60                                u_int32_t accessmask, int modemask);
61
62 int chise_close_decoding_table (CHISE_Decoding_Table *db);
63
64 CHISE_Char_ID chise_dt_get_char (CHISE_Decoding_Table *db, int code_point);
65
66 int chise_dt_put_char (CHISE_Decoding_Table *db,
67                        int code_point, CHISE_Char_ID cid);
68
69 typedef CHISE_Attribute_Table CHISE_Feature_Table;
70
71 int chise_open_feature_table (CHISE_Feature_Table *db,
72                               CHISE_DS *ds, const char *feature,
73                               DBTYPE real_subtype,
74                               u_int32_t accessmask, int modemask);
75
76 int chise_close_feature_table (CHISE_Feature_Table *db);
77
78 int chise_ft_get_value (CHISE_Feature_Table *db,
79                         CHISE_Char_ID cid, CHISE_Value *valdatum);
80
81 void
82 chise_ft_iterate (CHISE_Feature_Table *dbp,
83                   int (*func) (CHISE_Feature_Table *db,
84                                CHISE_Char_ID cid, CHISE_Value *valdatum));
85
86
87 CHISE_Char_ID chise_decode_char (CHISE_DS *ds, char *ccs, int code_point);
88
89 int chise_get_feature (CHISE_DS *ds, CHISE_Char_ID cid,
90                        char *key, CHISE_Value *valdatum);
91
92
93 int chise_open_attribute_table (CHISE_Attribute_Table *db,
94                                 const char *db_dir,
95                                 const char *encoding, const char *feature,
96                                 DBTYPE real_subtype,
97                                 u_int32_t accessmask, int modemask);
98
99 int chise_close_attribute_table (CHISE_Attribute_Table *db);
100
101 int chise_get_attribute_table (CHISE_Attribute_Table *db,
102                                char *key, CHISE_Value *valdatum);
103
104 #endif /* !_CHISE_H */