(struct CHISE_DS): Omit definition of members.
[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 CHISE_DS;
14
15 CHISE_DS* chise_open_data_source (CHISE_DS_Type type, char *location);
16
17 int chise_ds_close (CHISE_DS *ds);
18
19
20 typedef int CHISE_Char_ID;
21
22
23 typedef DBT CHISE_Value;
24
25 static inline int
26 chise_value_size (const CHISE_Value *s)
27 {
28   return s->size;
29 }
30
31 static inline char *
32 chise_value_data (const CHISE_Value *s)
33 {
34   return s->data;
35 }
36
37 static inline char *
38 chise_value_to_c_string (const CHISE_Value *s)
39 {
40   return s->data;
41 }
42
43
44 typedef struct CHISE_Attribute_Table
45 {
46   CHISE_DS *ds;
47   DB *db;
48 } CHISE_Attribute_Table;
49
50
51 typedef CHISE_Attribute_Table CHISE_Decoding_Table;
52
53 CHISE_Decoding_Table*
54 chise_ds_open_decoding_table (CHISE_DS *ds, const char *ccs,
55                               DBTYPE real_subtype,
56                               u_int32_t accessmask, int modemask);
57
58 int chise_dt_close (CHISE_Decoding_Table *table);
59
60 CHISE_Char_ID chise_dt_get_char (CHISE_Decoding_Table *table, int code_point);
61
62 int chise_dt_put_char (CHISE_Decoding_Table *table,
63                        int code_point, CHISE_Char_ID cid);
64
65
66 typedef CHISE_Attribute_Table CHISE_Feature_Table;
67
68 CHISE_Feature_Table*
69 chise_ds_open_feature_table (CHISE_DS *ds, const char *feature,
70                              DBTYPE real_subtype,
71                              u_int32_t accessmask, int modemask);
72
73 int chise_ft_close (CHISE_Feature_Table *table);
74
75 int chise_ft_get_value (CHISE_Feature_Table *table,
76                         CHISE_Char_ID cid, CHISE_Value *valdatum);
77
78 void
79 chise_ft_iterate (CHISE_Feature_Table *table,
80                   int (*func) (CHISE_Feature_Table *table,
81                                CHISE_Char_ID cid, CHISE_Value *valdatum));
82
83
84 CHISE_Char_ID chise_decode_char (CHISE_DS *ds, char *ccs, int code_point);
85
86 int chise_get_feature (CHISE_DS *ds, CHISE_Char_ID cid,
87                        char *key, CHISE_Value *valdatum);
88
89
90 CHISE_Attribute_Table*
91 chise_open_attribute_table (CHISE_DS *ds,
92                             const char *encoding, const char *feature,
93                             DBTYPE real_subtype,
94                             u_int32_t accessmask, int modemask);
95
96 int chise_close_attribute_table (CHISE_Attribute_Table *at);
97
98 int chise_get_attribute_table (CHISE_Attribute_Table *at,
99                                char *key, CHISE_Value *valdatum);
100
101 #endif /* !_CHISE_H */