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 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_Feature_Table CHISE_Feature_Table;
45 typedef CHISE_Feature_Table* CHISE_Feature;
46
47 CHISE_Feature
48 chise_ds_get_feature (CHISE_DS *ds, const unsigned char *feature,
49                       DBTYPE real_subtype,
50                       u_int32_t accessmask, int modemask);
51
52 int chise_char_load_feature_value (CHISE_Char_ID cid,
53                                    CHISE_Feature feature,
54                                    CHISE_Value *valdatum);
55
56 unsigned char*
57 chise_char_gets_feature_value (CHISE_Char_ID cid,
58                                CHISE_Feature feature,
59                                unsigned char *dst, size_t size);
60
61 void
62 chise_char_feature_value_iterate (CHISE_Feature feature,
63                                   int (*func) (CHISE_Char_ID cid,
64                                                CHISE_Feature feature,
65                                                CHISE_Value *valdatum));
66
67 void
68 chise_char_feature_str_iterate (CHISE_Feature feature,
69                                 int (*func) (CHISE_Char_ID cid,
70                                              CHISE_Feature feature,
71                                              unsigned char *str));
72
73
74 CHISE_Feature_Table*
75 chise_ds_open_feature_table (CHISE_DS *ds, const char *feature,
76                              DBTYPE real_subtype,
77                              u_int32_t accessmask, int modemask);
78
79 int chise_ft_close (CHISE_Feature_Table *table);
80
81
82 typedef struct CHISE_CCS_Table CHISE_CCS_Table;
83 typedef CHISE_CCS_Table* CHISE_CCS;
84
85 CHISE_CCS
86 chise_ds_get_ccs (CHISE_DS *ds, const unsigned char *ccs,
87                   DBTYPE real_subtype,
88                   u_int32_t accessmask, int modemask);
89
90 CHISE_Char_ID chise_ccs_decode (CHISE_CCS ccs, int code_point);
91
92 CHISE_CCS_Table*
93 chise_ds_open_ccs_table (CHISE_DS *ds, const char *ccs,
94                          DBTYPE real_subtype,
95                          u_int32_t accessmask, int modemask);
96
97 int chise_ccst_close (CHISE_CCS_Table *table);
98
99 int chise_ccst_put_char (CHISE_CCS_Table *table,
100                          int code_point, CHISE_Char_ID cid);
101
102 #endif /* !_CHISE_H */