enchant_sys/
lib.rs

1use std::os::raw::{c_char, c_int, c_void};
2
3#[repr(C)]
4#[derive(Debug, Copy, Clone)]
5pub struct EnchantBroker {
6    _unused: [u8; 0],
7}
8
9#[repr(C)]
10#[derive(Debug, Copy, Clone)]
11pub struct EnchantDict {
12    _unused: [u8; 0],
13}
14
15// EnchantBrokerDescribeFn
16// @provider_name: The provider's identifier, such as "hunspell" or "aspell", in UTF8 encoding
17// @provider_desc: A description of the provider, such as "Aspell 0.53" in UTF8 encoding
18// @provider_dll_file: The provider's DLL filename in Glib file encoding (UTF8 on Windows)
19// @user_data: Supplied user data, or %null if you don't care
20//
21// Callback used to enumerate and describe Enchant's various providers
22pub type EnchantBrokerDescribeFn = extern "C" fn(
23    provider_name: *const c_char,
24    provider_desc: *const c_char,
25    provider_dll_file: *const c_char,
26    user_data: *mut c_void,
27);
28
29// EnchantDictDescribeFn
30// @lang_tag: The dictionary's language tag (eg: en_US, de_AT, ...)
31// @provider_name: The provider's name (eg: Aspell) in UTF8 encoding
32// @provider_desc: The provider's description (eg: Aspell 0.50.3) in UTF8 encoding
33// @provider_file: The DLL/SO where this dict's provider was loaded from in Glib file encoding
34// (UTF8 on Windows)
35// @user_data: Supplied user data, or %null if you don't care
36//
37// Callback used to describe an individual dictionary
38pub type EnchantDictDescribeFn = extern "C" fn(
39    lang_tag: *const c_char,
40    provider_name: *const c_char,
41    provider_desc: *const c_char,
42    provider_file: *const c_char,
43    user_data: *mut c_void,
44);
45
46extern "C" {
47    pub fn enchant_get_version() -> *const c_char;
48
49    pub fn enchant_broker_init() -> *mut EnchantBroker;
50    pub fn enchant_broker_free(broker: *mut EnchantBroker);
51
52    pub fn enchant_broker_request_dict(
53        broker: *mut EnchantBroker,
54        tag: *const c_char,
55    ) -> *mut EnchantDict;
56    pub fn enchant_broker_request_pwl_dict(
57        broker: *mut EnchantBroker,
58        pwl: *const c_char,
59    ) -> *mut EnchantDict;
60    pub fn enchant_broker_free_dict(broker: *mut EnchantBroker, dict: *mut EnchantDict);
61    pub fn enchant_broker_dict_exists(broker: *mut EnchantBroker, tag: *const c_char) -> c_int;
62    pub fn enchant_broker_set_ordering(
63        broker: *mut EnchantBroker,
64        tag: *const c_char,
65        ordering: *const c_char,
66    );
67    pub fn enchant_broker_get_error(broker: *mut EnchantBroker) -> *const c_char;
68
69    pub fn enchant_broker_describe(
70        broker: *mut EnchantBroker,
71        f: EnchantBrokerDescribeFn,
72        user_data: *mut c_void,
73    );
74
75    pub fn enchant_dict_check(dict: *mut EnchantDict, word: *const c_char, len: isize) -> c_int;
76    pub fn enchant_dict_suggest(
77        dict: *mut EnchantDict,
78        word: *const c_char,
79        len: isize,
80        out_n_suggs: *mut usize,
81    ) -> *mut *mut c_char;
82    pub fn enchant_dict_add(dict: *mut EnchantDict, word: *const c_char, len: isize);
83    pub fn enchant_dict_add_to_session(dict: *mut EnchantDict, word: *const c_char, len: isize);
84    pub fn enchant_dict_remove(dict: *mut EnchantDict, word: *const c_char, len: isize);
85    pub fn enchant_dict_remove_from_session(
86        dict: *mut EnchantDict,
87        word: *const c_char,
88        len: isize,
89    );
90    pub fn enchant_dict_is_added(dict: *mut EnchantDict, word: *const c_char, len: isize) -> c_int;
91    pub fn enchant_dict_is_removed(
92        dict: *mut EnchantDict,
93        word: *const c_char,
94        len: isize,
95    ) -> c_int;
96
97    pub fn enchant_dict_store_replacement(
98        dict: *mut EnchantDict,
99        mis: *const c_char,
100        mis_len: isize,
101        cor: *const c_char,
102        cor_len: isize,
103    );
104    pub fn enchant_dict_free_string_list(dict: *mut EnchantDict, string_list: *mut *mut c_char);
105
106    pub fn enchant_dict_get_error(dict: *mut EnchantDict) -> *const c_char;
107
108    pub fn enchant_dict_describe(
109        dict: *mut EnchantDict,
110        f: EnchantDictDescribeFn,
111        user_data: *mut c_void,
112    );
113
114    pub fn enchant_broker_list_dicts(
115        broker: *mut EnchantBroker,
116        f: EnchantDictDescribeFn,
117        user_data: *mut c_void,
118    );
119}