78
80
N_("Anthy private dictionary"),
81
struct _anthy_dic_api {
82
void (*util_init) (void);
83
void (*util_set_personality) (char *);
84
const char *(*util_get_anthydir) (void);
86
void (*priv_dic_delete) (void);
87
int (*priv_dic_select_first_entry) (void);
88
int (*priv_dic_select_next_entry) (void);
89
int (*priv_dic_select_entry) (char *);
91
char *(*priv_dic_get_index) (char *, int);
92
int (*priv_dic_get_freq) (void);
93
char *(*priv_dic_get_wtype) (char *, int);
94
char *(*priv_dic_get_word) (char *, int);
96
int (*priv_dic_add_entry) (char *, char *, char *, int);
98
static struct _anthy_dic_api anthy_dic_api;
99
static void *anthy_dic_lib;
102
#define ANTHYDIC_DYLIB "libanthydic.0.dylib"
104
#define ANTHYDIC_DYLIB "libanthydic.so.0"
109
anthy_dic_lib = dlopen(ANTHYDIC_DYLIB, RTLD_GLOBAL |RTLD_NOW);
110
if (anthy_dic_lib == NULL) {
114
anthy_dic_api.util_init = dlsym(anthy_dic_lib, "anthy_dic_util_init");
115
anthy_dic_api.util_set_personality = dlsym(anthy_dic_lib, "anthy_dic_util_set_personality");
116
anthy_dic_api.util_get_anthydir = dlsym(anthy_dic_lib, "anthy_dic_util_get_anthydir");
118
anthy_dic_api.priv_dic_delete = dlsym(anthy_dic_lib, "anthy_priv_dic_delete");
119
anthy_dic_api.priv_dic_select_first_entry = dlsym(anthy_dic_lib, "anthy_priv_dic_select_first_entry");
120
anthy_dic_api.priv_dic_select_next_entry = dlsym(anthy_dic_lib, "anthy_priv_dic_select_next_entry");
121
anthy_dic_api.priv_dic_select_entry = dlsym(anthy_dic_lib, "anthy_priv_dic_select_entry");
123
anthy_dic_api.priv_dic_get_index = dlsym(anthy_dic_lib, "anthy_priv_dic_get_index");
124
anthy_dic_api.priv_dic_get_freq = dlsym(anthy_dic_lib, "anthy_priv_dic_get_freq");
125
anthy_dic_api.priv_dic_get_wtype = dlsym(anthy_dic_lib, "anthy_priv_dic_get_wtype");
126
anthy_dic_api.priv_dic_get_word = dlsym(anthy_dic_lib, "anthy_priv_dic_get_word");
128
anthy_dic_api.priv_dic_add_entry = dlsym(anthy_dic_lib, "anthy_priv_dic_add_entry");
130
if (!anthy_dic_api.util_init && !anthy_dic_api.util_set_personality
131
&& !anthy_dic_api.util_get_anthydir && !anthy_dic_api.priv_dic_delete
132
&& !anthy_dic_api.priv_dic_select_first_entry
133
&& !anthy_dic_api.priv_dic_select_next_entry
134
&& !anthy_dic_api.priv_dic_select_entry
135
&& !anthy_dic_api.priv_dic_get_index
136
&& !anthy_dic_api.priv_dic_get_freq
137
&& !anthy_dic_api.priv_dic_get_wtype
138
&& !anthy_dic_api.priv_dic_get_word
139
&& !anthy_dic_api.priv_dic_add_entry) {
140
dlclose(anthy_dic_lib);
147
84
dict_anthy_init(void)
149
if (get_anthydic_api() == -1)
151
anthy_dic_api.util_init();
86
anthy_dic_util_init();
156
91
dict_anthy_exit(void)
159
return dlclose(anthy_dic_lib);
93
anthy_dic_util_quit();
165
98
dict_anthy_read_priv_dic_list(uim_word **head)
167
char phon[100], desc[100], cclass_code[100];
170
if (anthy_dic_api.priv_dic_select_first_entry() == -1) {
176
if (anthy_dic_api.priv_dic_get_index(phon, sizeof(phon))
177
&& anthy_dic_api.priv_dic_get_wtype(cclass_code, sizeof(cclass_code))
178
&& anthy_dic_api.priv_dic_get_word(desc, sizeof(desc))) {
180
char *cclass_desc = NULL;
182
for (pos = 0; pos < NR_POS; pos++) {
183
cclass_desc = find_desc_from_code(cclass_code, pos);
184
if (cclass_desc) break;
187
word_append(head, WORD_TYPE_ANTHY,
189
phon, desc, cclass_desc,
190
anthy_dic_api.priv_dic_get_freq(),
193
ret = anthy_dic_api.priv_dic_select_next_entry();
100
char phon[100], desc[100], cclass_native[100];
103
if (anthy_priv_dic_select_first_entry() == -1) {
109
if (anthy_priv_dic_get_index(phon, sizeof(phon))
110
&& anthy_priv_dic_get_wtype(cclass_native,
111
sizeof(cclass_native))
112
&& anthy_priv_dic_get_word(desc, sizeof(desc))) {
114
const char *cclass_code = NULL;
116
for (pos = 0; pos < NR_POS; pos++) {
117
cclass_code = find_desc_from_code_with_type(cclass_native, pos);
122
word_append(head, WORD_TYPE_ANTHY, "EUC-JP",
123
phon, desc, cclass_code, cclass_native,
124
anthy_priv_dic_get_freq(),
127
ret = anthy_priv_dic_select_next_entry();
199
133
dict_anthy_add_priv_dic_with_flags(char *phon, char *desc,
200
134
char *cclass_code, int freq)
202
if ((strlen(phon) == 0) ||
203
(strlen(desc) == 0) ||
204
(strlen(cclass_code) == 0)) {
136
if ((strlen(phon) == 0) || (strlen(desc) == 0) ||
137
(strlen(cclass_code) == 0)) {
208
return anthy_dic_api.priv_dic_add_entry(phon, desc,
141
return anthy_priv_dic_add_entry(phon, desc, cclass_code, freq);
213
145
dict_anthy_delete_priv_dic(char *phon, char *desc, char *cclass_code)
215
return anthy_dic_api.priv_dic_add_entry(phon, desc,
147
return anthy_priv_dic_add_entry(phon, desc, cclass_code, 0);
219
150
static uim_dict *