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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
/* $TOG: imLcIm.c /main/12 1998/06/16 16:05:15 kaleb $ */
/******************************************************************
Copyright 1992, 1993, 1994 by FUJITSU LIMITED
Copyright 1993 by Digital Equipment Corporation
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of FUJITSU LIMITED and
Digital Equipment Corporation not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission. FUJITSU LIMITED and Digital Equipment Corporation
makes no representations about the suitability of this software for
any purpose. It is provided "as is" without express or implied
warranty.
FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR
ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
Author: Takashi Fujiwara FUJITSU LIMITED
fujiwara@a80.tech.yk.fujitsu.co.jp
Modifier: Franky Ling Digital Equipment Corporation
frankyling@hgrd01.enet.dec.com
******************************************************************/
/* $XFree86: xc/lib/X11/imLcIm.c,v 1.8 2000/12/04 18:49:23 dawes Exp $ */
#include <stdio.h>
/*
#include <X11/Xlib.h>
*/
#include <X11/Xmd.h>
#include <X11/Xatom.h>
#include <X11/Xos.h>
#include "Xlibint.h"
#include "Xlcint.h"
#include "XlcPublic.h"
#include "XlcPubI.h"
#include "Ximint.h"
#include <ctype.h>
Public Bool
_XimCheckIfLocalProcessing(im)
Xim im;
{
FILE *fp;
char *name;
if(strcmp(im->core.im_name, "") == 0) {
name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
if (name != (char *)NULL) {
fp = _XFopenFile (name, "r");
Xfree(name);
if (fp != (FILE *)NULL) {
fclose(fp);
return(True);
}
}
return(False);
} else if(strcmp(im->core.im_name, "local") == 0 ||
strcmp(im->core.im_name, "none" ) == 0 ) {
return(True);
}
return(False);
}
Private void
XimFreeDefaultTree(top)
DefTree *top;
{
if (!top) return;
if (top->succession) XimFreeDefaultTree(top->succession);
if (top->next) XimFreeDefaultTree(top->next);
if (top->mb) Xfree(top->mb);
if (top->wc) Xfree(top->wc);
if (top->utf8) Xfree(top->utf8);
Xfree(top);
}
Public void
_XimLocalIMFree(im)
Xim im;
{
XimFreeDefaultTree(im->private.local.top);
if(im->core.im_resources) {
Xfree(im->core.im_resources);
im->core.im_resources = NULL;
}
if(im->core.ic_resources) {
Xfree(im->core.ic_resources);
im->core.ic_resources = NULL;
}
if(im->core.im_values_list) {
Xfree(im->core.im_values_list);
im->core.im_values_list = NULL;
}
if(im->core.ic_values_list) {
Xfree(im->core.ic_values_list);
im->core.ic_values_list = NULL;
}
if(im->core.styles) {
Xfree(im->core.styles);
im->core.styles = NULL;
}
if(im->core.res_name) {
Xfree(im->core.res_name);
im->core.res_name = NULL;
}
if(im->core.res_class) {
Xfree(im->core.res_class);
im->core.res_class = NULL;
}
if(im->core.im_name) {
Xfree(im->core.im_name);
im->core.im_name = NULL;
}
if (im->private.local.ctom_conv) {
_XlcCloseConverter(im->private.local.ctom_conv);
im->private.local.ctom_conv = NULL;
}
if (im->private.local.ctow_conv) {
_XlcCloseConverter(im->private.local.ctow_conv);
im->private.local.ctow_conv = NULL;
}
if (im->private.local.ctoutf8_conv) {
_XlcCloseConverter(im->private.local.ctoutf8_conv);
im->private.local.ctoutf8_conv = NULL;
}
if (im->private.local.cstomb_conv) {
_XlcCloseConverter(im->private.local.cstomb_conv);
im->private.local.cstomb_conv = NULL;
}
if (im->private.local.cstowc_conv) {
_XlcCloseConverter(im->private.local.cstowc_conv);
im->private.local.cstowc_conv = NULL;
}
if (im->private.local.cstoutf8_conv) {
_XlcCloseConverter(im->private.local.cstoutf8_conv);
im->private.local.cstoutf8_conv = NULL;
}
if (im->private.local.ucstoc_conv) {
_XlcCloseConverter(im->private.local.ucstoc_conv);
im->private.local.ucstoc_conv = NULL;
}
if (im->private.local.ucstoutf8_conv) {
_XlcCloseConverter(im->private.local.ucstoutf8_conv);
im->private.local.ucstoutf8_conv = NULL;
}
return;
}
Private Status
_XimLocalCloseIM(xim)
XIM xim;
{
Xim im = (Xim)xim;
XIC ic;
XIC next;
ic = im->core.ic_chain;
while (ic) {
(*ic->methods->destroy) (ic);
next = ic->core.next;
Xfree ((char *) ic);
ic = next;
}
_XimLocalIMFree(im);
_XimDestroyIMStructureList(im);
return(True);
}
Public char *
_XimLocalGetIMValues(xim, values)
XIM xim;
XIMArg *values;
{
Xim im = (Xim)xim;
XimDefIMValues im_values;
_XimGetCurrentIMValues(im, &im_values);
return(_XimGetIMValueData(im, (XPointer)&im_values, values,
im->core.im_resources, im->core.im_num_resources));
}
Public char *
_XimLocalSetIMValues(xim, values)
XIM xim;
XIMArg *values;
{
Xim im = (Xim)xim;
XimDefIMValues im_values;
char *name = (char *)NULL;
_XimGetCurrentIMValues(im, &im_values);
name = _XimSetIMValueData(im, (XPointer)&im_values, values,
im->core.im_resources, im->core.im_num_resources);
_XimSetCurrentIMValues(im, &im_values);
return(name);
}
Private void
_XimCreateDefaultTree(im)
Xim im;
{
FILE *fp;
char *name;
name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
if (name == (char *)NULL)
return;
fp = _XFopenFile (name, "r");
Xfree(name);
if (fp == (FILE *)NULL)
return;
_XimParseStringFile(fp, &im->private.local.top);
fclose(fp);
}
Private XIMMethodsRec Xim_im_local_methods = {
_XimLocalCloseIM, /* close */
_XimLocalSetIMValues, /* set_values */
_XimLocalGetIMValues, /* get_values */
_XimLocalCreateIC, /* create_ic */
_XimLcctstombs, /* ctstombs */
_XimLcctstowcs, /* ctstowcs */
_XimLcctstoutf8 /* ctstoutf8 */
};
Public Bool
_XimLocalOpenIM(im)
Xim im;
{
XLCd lcd = im->core.lcd;
XlcConv conv;
XimDefIMValues im_values;
XimLocalPrivateRec* private = &im->private.local;
_XimInitialResourceInfo();
if(_XimSetIMResourceList(&im->core.im_resources,
&im->core.im_num_resources) == False) {
goto Open_Error;
}
if(_XimSetICResourceList(&im->core.ic_resources,
&im->core.ic_num_resources) == False) {
goto Open_Error;
}
_XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
_XimGetCurrentIMValues(im, &im_values);
if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
im->core.im_resources, im->core.im_num_resources) == False) {
goto Open_Error;
}
_XimSetCurrentIMValues(im, &im_values);
_XimCreateDefaultTree(im);
if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte)))
goto Open_Error;
private->ctom_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar)))
goto Open_Error;
private->ctow_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNUtf8String)))
goto Open_Error;
private->ctoutf8_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte)))
goto Open_Error;
private->cstomb_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar)))
goto Open_Error;
private->cstowc_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String)))
goto Open_Error;
private->cstoutf8_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar)))
goto Open_Error;
private->ucstoc_conv = conv;
if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String)))
goto Open_Error;
private->ucstoutf8_conv = conv;
im->methods = &Xim_im_local_methods;
private->current_ic = (XIC)NULL;
return(True);
Open_Error :
_XimLocalIMFree(im);
return(False);
}
|