summaryrefslogtreecommitdiff
path: root/src/chinese/chinese_provider.c
blob: faf5e16e749bd5feb9a82e8f7684aa7fe47e6d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* enchant
 * Copyright (C) 2003,2004 Dom Lachowicz
 *               2006-2007 Harri Pitkänen <hatapitk@iki.fi>
 *               2006 Anssi Hannula <anssi.hannula@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02110-1301, USA.
 *
 * In addition, as a special exception, Dom Lachowicz
 * gives permission to link the code of this program with
 * non-LGPL Spelling Provider libraries (eg: a MSFT Office
 * spell checker backend) and distribute linked combinations including
 * the two.  You must obey the GNU Lesser General Public License in all
 * respects for all of the code used other than said providers.  If you modify
 * this file, you may extend this exception to your version of the
 * file, but you are not obligated to do so.  If you do not wish to
 * do so, delete this exception statement from your version.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <glib.h>

#include "enchant.h"
#include "enchant-provider.h"

/**
 * ChineseLib is a Chinese spell checker. More information will be add later
 *
 * http://chenxiajian1985.blogspot.com
 */
// to deal with Chinese-Class Language (Chinse, Janpansee, Korean...)
ENCHANT_PLUGIN_DECLARE("Chinese")

static int
chinese_dict_check (EnchantDict * me, const char *const word, size_t len)
{
	int result=-1;
	int chinese_handle;
    chinese_handle = (long) me->user_data;
	//call for library
	return result;
}

static char **
chinese_dict_suggest (EnchantDict * me, const char *const word,
		     size_t len, size_t * out_n_suggs)
{
	char **sugg_arr,**result;
	int chinese_handle,index=0;

	chinese_handle = (long) me->user_data;
	//call for library
	for (*out_n_suggs = 0; (*out_n_suggs)<strlen(sugg_arr); (*out_n_suggs)++)
	{
        if(sugg_arr[*out_n_suggs]!= NULL)
		{
			result[index++]=sugg_arr[*out_n_suggs];
		}    
	}
	return result;
}

static char *
chinese_dict_hyphenate (EnchantDict * me, const char *const word)
{
	char*result=0;
	int chinese_handle;
    chinese_handle = (long) me->user_data;
    //call for library
	return result;	
}

static EnchantDict *
chinese_provider_request_dict (EnchantProvider * me, const char *const tag)
{
	EnchantDict *dict;
	const char * chinese_error;
	int chinese_handle;

	if (chinese_error) {
		//enchant_provider_set_error(me, chinese_error);
		return NULL;
	}

	dict = g_new0 (EnchantDict, 1);
	dict->user_data = (void *)(long) chinese_handle;
	dict->check = chinese_dict_check;
	dict->suggest = chinese_dict_suggest;
	// Chinese don't need hyphenate
	//dict->hyphenate = chinese_dict_hyphenate;

	return dict;
}

static void
chinese_provider_dispose_dict (EnchantProvider * me, EnchantDict * dict)
{
	g_free (dict);
}

static int
chinese_provider_dictionary_exists (struct str_enchant_provider * me,
                                   const char *const tag)
{
	int chinese_handle;
    return 0;
}


static char **
chinese_provider_list_dicts (EnchantProvider * me, 
			    size_t * out_n_dicts)
{
	char ** out_list = NULL;
	int chinese_handle;
	*out_n_dicts = 0;

	return out_list;
}

static void
chinese_provider_free_string_list (EnchantProvider * me, char **str_list)
{
	g_strfreev (str_list);
}

static void
chinese_provider_dispose (EnchantProvider * me)
{
	g_free (me);
}

static const char *
chinese_provider_identify (EnchantProvider * me)
{
	return "Chinese";
}

static const char *
chinese_provider_describe (EnchantProvider * me)
{
	return "Chinese Provider";
}

#ifdef __cplusplus
extern "C" {
#endif

ENCHANT_MODULE_EXPORT (EnchantProvider *) 
	     init_enchant_provider (void);

EnchantProvider *
init_enchant_provider (void)
{
	EnchantProvider *provider;

	provider = g_new0 (EnchantProvider, 1);
	provider->dispose = chinese_provider_dispose;
	provider->request_dict = chinese_provider_request_dict;
	provider->dispose_dict = chinese_provider_dispose_dict;
	provider->dictionary_exists = chinese_provider_dictionary_exists;
	provider->identify = chinese_provider_identify;
	provider->describe = chinese_provider_describe;
	provider->list_dicts = chinese_provider_list_dicts;
	provider->free_string_list = chinese_provider_free_string_list;

	return provider;
}

#ifdef __cplusplus
}
#endif