(chise_open_data_source): Add new arguments `subtype' and `modemask'.
[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*
16 chise_open_data_source (CHISE_DS_Type type, char *location,
17                         DBTYPE subtype, int modemask);
18
19 int chise_ds_close (CHISE_DS *ds);
20
21
22 typedef int CHISE_Char_ID;
23
24
25 typedef DBT CHISE_Value;
26
27 static inline int
28 chise_value_size (const CHISE_Value *s)
29 {
30   return s->size;
31 }
32
33 static inline char *
34 chise_value_data (const CHISE_Value *s)
35 {
36   return s->data;
37 }
38
39 static inline char *
40 chise_value_to_c_string (const CHISE_Value *s)
41 {
42   return s->data;
43 }
44
45
46 typedef struct CHISE_Feature_Table CHISE_Feature_Table;
47 typedef CHISE_Feature_Table* CHISE_Feature;
48
49 CHISE_Feature
50 chise_ds_get_feature (CHISE_DS *ds, const unsigned char *feature);
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 int
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 #if 0
68 int
69 chise_char_feature_str_iterate (CHISE_Feature feature,
70                                 int (*func) (CHISE_Char_ID cid,
71                                              CHISE_Feature feature,
72                                              unsigned char *str));
73 #endif
74
75 #if 1
76 CHISE_Feature_Table*
77 chise_ds_open_feature_table (CHISE_DS *ds, const char *feature);
78
79 int chise_ft_close (CHISE_Feature_Table *table);
80 #endif
81
82
83 typedef struct CHISE_CCS_Table CHISE_CCS_Table;
84 typedef CHISE_CCS_Table* CHISE_CCS;
85
86 CHISE_CCS
87 chise_ds_get_ccs (CHISE_DS *ds, const unsigned char *ccs);
88
89 CHISE_Char_ID chise_ccs_decode (CHISE_CCS ccs, int code_point);
90
91 int chise_ccs_set_decoded_char (CHISE_CCS ccs,
92                                 int code_point, CHISE_Char_ID cid);
93
94 int chise_ccs_sync (CHISE_CCS ccs);
95
96 #if 0
97 CHISE_CCS_Table*
98 chise_ds_open_ccs_table (CHISE_DS *ds, const char *ccs);
99
100 int chise_ccst_close (CHISE_CCS_Table *table);
101 #endif
102
103 #endif /* !_CHISE_H */