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