update.
[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   unsigned char *location;
17 } CHISE_DS;
18
19 CHISE_DS* chise_open_data_source (CHISE_DS_Type type, char *location);
20
21 int chise_ds_close (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 struct CHISE_Attribute_Table
49 {
50   CHISE_DS *ds;
51   DB *db;
52 } CHISE_Attribute_Table;
53
54
55 typedef CHISE_Attribute_Table CHISE_Decoding_Table;
56
57 CHISE_Decoding_Table*
58 chise_ds_open_decoding_table (CHISE_DS *ds, const char *ccs,
59                               DBTYPE real_subtype,
60                               u_int32_t accessmask, int modemask);
61
62 int chise_dt_close (CHISE_Decoding_Table *table);
63
64 CHISE_Char_ID chise_dt_get_char (CHISE_Decoding_Table *table, int code_point);
65
66 int chise_dt_put_char (CHISE_Decoding_Table *table,
67                        int code_point, CHISE_Char_ID cid);
68
69
70 typedef CHISE_Attribute_Table CHISE_Feature_Table;
71
72 CHISE_Feature_Table*
73 chise_ds_open_feature_table (CHISE_DS *ds, const char *feature,
74                              DBTYPE real_subtype,
75                              u_int32_t accessmask, int modemask);
76
77 int chise_ft_close (CHISE_Feature_Table *table);
78
79 int chise_ft_get_value (CHISE_Feature_Table *table,
80                         CHISE_Char_ID cid, CHISE_Value *valdatum);
81
82 void
83 chise_ft_iterate (CHISE_Feature_Table *table,
84                   int (*func) (CHISE_Feature_Table *table,
85                                CHISE_Char_ID cid, CHISE_Value *valdatum));
86
87
88 CHISE_Char_ID chise_decode_char (CHISE_DS *ds, char *ccs, int code_point);
89
90 int chise_get_feature (CHISE_DS *ds, CHISE_Char_ID cid,
91                        char *key, CHISE_Value *valdatum);
92
93
94 CHISE_Attribute_Table*
95 chise_open_attribute_table (CHISE_DS *ds,
96                             const char *encoding, const char *feature,
97                             DBTYPE real_subtype,
98                             u_int32_t accessmask, int modemask);
99
100 int chise_close_attribute_table (CHISE_Attribute_Table *at);
101
102 int chise_get_attribute_table (CHISE_Attribute_Table *at,
103                                char *key, CHISE_Value *valdatum);
104
105 #endif /* !_CHISE_H */