Mercurial > kinput2.yaz
comparison lib/Xatoklib/if.c @ 0:92745d501b9a
initial import from kinput2-v3.1
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 08 Mar 2010 04:44:30 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:92745d501b9a |
---|---|
1 /* | |
2 * Copyright 1999 Justsystem Corporation, Japan. | |
3 * | |
4 * Permission to use, copy, modify, and distribute this software and its | |
5 * documentation for any purpose and without fee is hereby granted, | |
6 * provided that the above copyright notice appear in all copies and that | |
7 * both that copyright notice and this permission notice appear in | |
8 * supporting documentation, and that the name of Justsystem Corporation | |
9 * not be used in advertising or publicity pertaining to distribution | |
10 * of the software without specific, written prior permission. Justsystem | |
11 * Corporation makes no representations about the suitability of this | |
12 * software for any purpose. It is provided "as is" without express | |
13 * or implied warranty. | |
14 * | |
15 * Author: Atsushi Irisawa | |
16 */ | |
17 | |
18 #ifndef lint | |
19 static char rcsid[] = "$Id: if.c,v 1.3 1999/08/24 09:05:26 ishisone Exp $" ; | |
20 #endif /* !lint */ | |
21 | |
22 #include <stdio.h> | |
23 #include <X11/IntrinsicP.h> | |
24 #include <X11/StringDefs.h> | |
25 #include <X11/Xmu/Atoms.h> | |
26 #include <X11/keysym.h> | |
27 | |
28 #include <Xatoklib.h> | |
29 #include <key_def.h> | |
30 | |
31 /* Page */ | |
32 /* | |
33 * [$B4X?tL>(B] | |
34 * atokModeSet( ) | |
35 * [$BI=Bj(B] | |
36 * $B%b!<%I$N@_Dj(B | |
37 * [$B8F=P7A<0(B] | |
38 * int atokModeSet( _XatokRecPtr acomm, WORD ceCmd, WORD value ) | |
39 * | |
40 * [$B0z?t(B] | |
41 * $B7?(B : $BL>(B $B>N(B : IO : $B@b(B $BL@(B | |
42 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
43 * WORD : ceCmd : i : CE $B%3%^%s%IHV9f(B | |
44 * WORD : value : i : $BCM(B | |
45 * | |
46 * | |
47 * [$BJV$jCM(B] | |
48 * CE$B$N=hM}7k2L(B | |
49 * [$B;HMQ4X?t(B] | |
50 * AtokClntCommunicate( ) | |
51 * [$B5!G=(B] | |
52 * CE$B$N%b!<%I$r9T$J$&(BAPI$B$r8F$S=P$9!#(B | |
53 * value $B$,(BATCEPRVAPI_READCMD $B$N;~$O!"(B | |
54 * $B8=:_$N@_DjCM$NFI$_9~$_$G$"$k!#(B | |
55 */ | |
56 WORD atokModeSet(acomm, ceCmd, value) | |
57 _XatokRecPtr acomm; | |
58 WORD ceCmd; | |
59 WORD value; | |
60 { | |
61 if ( value == ATCEPRVAPI_READCMD ) { | |
62 acomm->NETrqst.AtCEPrvAPIOutinf = ATCEPRVAPI_READCMD ; | |
63 } | |
64 else { | |
65 acomm->NETrqst.AtCEPrvAPIOutinf = value ; | |
66 } | |
67 acomm->NETrqst.ceCmd = ceCmd ; ; | |
68 AtokClntCommunicate( acomm->sock, &acomm->NETrqst, &acomm->NETrslt ) ; | |
69 | |
70 return acomm->NETrslt.header.CEOutinf ; | |
71 } | |
72 | |
73 /* Page */ | |
74 /* | |
75 * [$B4X?tL>(B] | |
76 * atokConnect( ) | |
77 * [$BI=Bj(B] | |
78 * ATOK12X $B%5!<%P$H$N@\B3(B | |
79 * [$B8F=P7A<0(B] | |
80 * int atokConnect( char *server, char *port, char *conf, char *style, | |
81 * _XatokRecPtr acomm ) | |
82 * | |
83 * [$B0z?t(B] | |
84 * $B7?(B : $BL>(B $B>N(B : IO : $B@b(B $BL@(B | |
85 * char : *server : i : ATOK12x $B2TF/%[%9%HL>(B | |
86 * char : *port : i : $B@\B3%5!<%S%9L>(B | |
87 * char : *conf : i : conf $B%U%!%$%kL>(B | |
88 * char : *style : i : style $B%U%!%$%kL>(B | |
89 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
90 * | |
91 * | |
92 * [$BJV$jCM(B] | |
93 * 0 $BL$K~(B : $B@\B3%(%i!<(B | |
94 * $B#00J>e(B :$B@\B3$7$?(BSOCKET$B5-=R;R(B | |
95 * | |
96 * [$B;HMQ4X?t(B] | |
97 * AtokClntConnect( ) | |
98 * XatokBufferConvert( ) | |
99 * [$B5!G=(B] | |
100 * $B?75,$K(B ATO$B#1#2(Bx$B$H$N@\B3$r9T$J$&!#(B | |
101 * $B@\B3$O%W%m%;%9$G#1$D$G$h$$!#(B | |
102 * $B@\B3$,=PMh$?>l9g$K$O!"3F%b!<%I$N8=:_$N@_DjCM$r<hF@$9$k!#(B | |
103 */ | |
104 int atokConnect(server, port, conf, style, acomm) | |
105 char *server; | |
106 char *port; | |
107 char *conf; | |
108 char *style; | |
109 _XatokRecPtr acomm; | |
110 { | |
111 wchar dummy[128] ; | |
112 int status ; | |
113 int sock ; | |
114 | |
115 sock = AtokClntConnect( server, port, conf, style, | |
116 &acomm->NETrqst, &acomm->NETrslt ) ; | |
117 if ( sock < 0 ) { | |
118 return sock ; | |
119 } | |
120 | |
121 /* | |
122 * $B@\B3$K@.8y$7$?$i8=:_$N%b!<%I$r<hF@$9$k!#(B | |
123 *$B%b!<%IJ8;zNs$K4X$7$F$O!"@\B3;~$K%j%?!<%s$5$l$k!#(B | |
124 */ | |
125 XatokBufferConvert( acomm, ( WORD ) -1, &acomm->NETrslt, | |
126 dummy, &status, &status, &status, &status ) ; | |
127 | |
128 acomm->sock = sock ; | |
129 | |
130 /* | |
131 * $B8=:_$N@_DjCM$r<hF@$9$k!#(B | |
132 */ | |
133 acomm->mode.modeKANDSP = atokModeSet( acomm, | |
134 IME_PRV_SETKANDSP, ATCEPRVAPI_READCMD ) ; | |
135 acomm->mode.modeHEN = atokModeSet( acomm, | |
136 IME_PRV_SETHENMODE, ATCEPRVAPI_READCMD ) ; | |
137 acomm->mode.modeGAKU = atokModeSet( acomm, | |
138 IME_PRV_SETGAKUMODE, ATCEPRVAPI_READCMD ) ; | |
139 acomm->mode.modeKOTE = atokModeSet( acomm, | |
140 IME_PRV_SETKOTEMODE, ATCEPRVAPI_READCMD ) ; | |
141 acomm->mode.modeOKURI = atokModeSet( acomm, | |
142 IME_PRV_SETOKURIMODE, ATCEPRVAPI_READCMD ) ; | |
143 acomm->mode.modeROT = atokModeSet( acomm, | |
144 IME_PRV_SETROTMODEF, ATCEPRVAPI_READCMD ) ; | |
145 | |
146 return sock ; | |
147 } | |
148 /* Page */ | |
149 /* | |
150 * [$B4X?tL>(B] | |
151 * atokCEOpen( ) | |
152 * [$BI=Bj(B] | |
153 * CONTEXT$B$N:n@.(B | |
154 * [$B8F=P7A<0(B] | |
155 * int atokCEOpen( int sock, int clntid, _XatokRecPtr acomm ) | |
156 * | |
157 * [$B0z?t(B] | |
158 * $B7?(B : $BL>(B $B>N(B : IO : $B@b(B $BL@(B | |
159 * int : sock : i : ATOK12X $B$H$N@\B3(BSOCKET | |
160 * int : clntid : i : $B%/%i%$%"%s%H(BID | |
161 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
162 * | |
163 * [$BJV$jCM(B] | |
164 * -1 : CONTEXT$B:n@.%(%i!<(B | |
165 * 1 : CONTEXT $B:n@.@.8y(B | |
166 * | |
167 * [$B;HMQ4X?t(B] | |
168 * AtokClntCEOpen( ) | |
169 * XatokBufferConvert( ) | |
170 * [$B5!G=(B] | |
171 * $B4{$K@\B3$5$l$F$$$F!"%/%i%$%"%s%H(BID$B$,3d$jEv$F$i$l$F$$$k(B | |
172 * $B%;%C%7%g%s$KBP$7!"(BATOK12CE $B$H$N(BCONTEXT$B$rDI2C:n@.$9$k!#(B | |
173 */ | |
174 | |
175 int atokCEOpen(sock, clntid, acomm) | |
176 int sock; | |
177 int clntid; | |
178 _XatokRecPtr acomm; | |
179 { | |
180 wchar dummy[128] ; /* BufferConvert $B$N$?$a$N(B TMP */ | |
181 int status ; /* BufferConvert $B$N$?$a$N(B TMP */ | |
182 | |
183 if ( AtokClntCEOpen( sock, clntid, &acomm->NETrqst, &acomm->NETrslt ) < 0 ) { | |
184 return -1 ; | |
185 } | |
186 | |
187 XatokBufferConvert( acomm, ( WORD ) -1, &acomm->NETrslt, | |
188 dummy, &status, &status, &status, &status ) ; | |
189 | |
190 acomm->mode.modeKANDSP = atokModeSet( acomm, | |
191 IME_PRV_SETKANDSP, ATCEPRVAPI_READCMD ) ; | |
192 acomm->mode.modeHEN = atokModeSet( acomm, | |
193 IME_PRV_SETHENMODE, ATCEPRVAPI_READCMD ) ; | |
194 acomm->mode.modeGAKU = atokModeSet( acomm, | |
195 IME_PRV_SETGAKUMODE, ATCEPRVAPI_READCMD ) ; | |
196 acomm->mode.modeKOTE = atokModeSet( acomm, | |
197 IME_PRV_SETKOTEMODE, ATCEPRVAPI_READCMD ) ; | |
198 acomm->mode.modeOKURI = atokModeSet( acomm, | |
199 IME_PRV_SETOKURIMODE, ATCEPRVAPI_READCMD ) ; | |
200 acomm->mode.modeROT = atokModeSet( acomm, | |
201 IME_PRV_SETROTMODEF, ATCEPRVAPI_READCMD ) ; | |
202 | |
203 return 1 ; | |
204 } | |
205 | |
206 | |
207 /* Page */ | |
208 /* | |
209 * [$B4X?tL>(B] | |
210 * atokKanjiOn | |
211 * [$BI=Bj(B] | |
212 * $B4A;z(BON | |
213 * [$B8F=P7A<0(B] | |
214 * int atokKanjiOn( _XatokRecPtr acomm ) | |
215 * [$B0z?t(B] | |
216 * $B7?(B : $BL>(B $B>N(B : IO : $B@b(B $BL@(B | |
217 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
218 * | |
219 * [$BJV$jCM(B] | |
220 * 0 $BL$K~(B : $B%(%i!<(B | |
221 * 0 : OK | |
222 * | |
223 * [$B;HMQ4X?t(B] | |
224 * atokClntCommunicate( ) | |
225 * [$B5!G=(B] | |
226 * CE $B$N%b!<%I$r4A;z(BON$B$H$9$k!#(B | |
227 * | |
228 */ | |
229 int atokKanjiOn(acomm) | |
230 _XatokRecPtr acomm; | |
231 { | |
232 int status ; | |
233 | |
234 acomm->convStatus = M_KEYCONV ; | |
235 acomm->convStatus = acomm->oldStatus ; | |
236 acomm->NETrqst.ceCmd = IME_PRV_KANJION ; | |
237 acomm->curAux = acomm->menuAux ; | |
238 | |
239 status = AtokClntCommunicate( acomm->sock, | |
240 &acomm->NETrqst, &acomm->NETrslt ) ; | |
241 | |
242 return status ; | |
243 } | |
244 | |
245 int atokKanjiOff(acomm) | |
246 _XatokRecPtr acomm; | |
247 { | |
248 int status ; | |
249 | |
250 acomm->oldStatus = acomm->convStatus ; | |
251 acomm->convStatus = M_NOKEYCONV ; | |
252 acomm->NETrqst.ceCmd = IME_PRV_KANJIOFF ; | |
253 acomm->curAux = acomm->menuAux ; | |
254 | |
255 status = AtokClntCommunicate( acomm->sock, | |
256 &acomm->NETrqst, &acomm->NETrslt ) ; | |
257 | |
258 return status ; | |
259 } | |
260 | |
261 /* Page */ | |
262 /* | |
263 * [$B4X?tL>(B] | |
264 * atokWordStyleList( ) | |
265 * [$BI=Bj(B] | |
266 * $BIJ;l%j%9%H$N<hF@(B | |
267 * [$B8F=P7A<0(B] | |
268 * int atokWordStyleList( _XatokRecPtr acomm ) | |
269 * | |
270 * [$B0z?t(B] | |
271 * $B7?(B : $BL>(B $B>N(B : I O : $B@b(B $BL@(B | |
272 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
273 * | |
274 * [$BJV$jCM(B] | |
275 * -1 : $BAw?.%(%i!<(B | |
276 * N : $BIJ;l$N8D?t(B | |
277 * | |
278 * [$B;HMQ4X?t(B] | |
279 * atokClntCommunicate( ) | |
280 * [$B5!G=(B] | |
281 * $B<-=q$KEPO?$9$k$?$a$NIJ;l%j%9%H$r<hF@$9$k!#(B | |
282 * $BIJ;l%j%9%H$O(B S-JIS $B$GAw$i$l$FMh$k!#(Bkinput2 $BFbIt$G$O(B | |
283 * EUC $B$G4IM}$7$F$$$k$?$a!"$3$3$G%3!<%IJQ49$r9T$J$&!#(B | |
284 * $BIJ;l%j%9%H$O!"8uJd%j%9%H$r4IM}$9$k$N$HF1$8%P%C%U%!$G(B | |
285 * $B4IM}$9$k!#$=$N%P%C%U%!$,<hF@$5$l$F$$$J$$>l9g$K$O!"(B | |
286 * $B?7$?$K<hF@$9$k!#(B | |
287 */ | |
288 int atokWordStyleList(acomm) | |
289 _XatokRecPtr acomm; | |
290 { | |
291 int size ; | |
292 int i, j, n ; | |
293 int len ; | |
294 ATOKDEHINSTR *sptr ; | |
295 char euc[BUFSIZ] ; | |
296 | |
297 if ( acomm->hinsiPtr ) { | |
298 goto make_cand ; | |
299 } | |
300 | |
301 acomm->NETrqst.ceCmd = IME_PRV_WORDSYLECOUNT ; | |
302 if ( AtokClntCommunicate( acomm->sock, &acomm->NETrqst, &acomm->NETrslt ) < 0 ) { | |
303 return -1 ; | |
304 } | |
305 | |
306 #ifdef ATOK_DEBUG | |
307 printf( "CHECK %d\n", acomm->NETrslt.header.CEOutinf ) ; | |
308 #endif /* ATOK_DEBUG */ | |
309 acomm->hinsiNum = acomm->NETrslt.header.CEOutinf ; | |
310 acomm->NETrqst.ceCmd = IME_PRV_WORDSTYLELIST ; | |
311 acomm->NETrqst.AtCEIncode = acomm->hinsiNum ; | |
312 #ifdef ATOK_DEBUG | |
313 printf( "\311\312\273\354\301\355\277\364 %d\n"/*=$BIJ;lAm?t(B %d\n=*/, acomm->hinsiNum ) ; | |
314 #endif /* ATOK_DEBUG */ | |
315 AtokClntCommunicate( acomm->sock, &acomm->NETrqst, &acomm->NETrslt ) ; | |
316 | |
317 size = sizeof( ATOKDEHINSTR ) * acomm->hinsiNum ; | |
318 acomm->hinsiPtr = ( ATOKDEHINSTR * )malloc( size ) ; | |
319 sptr = acomm->NETrslt.header.wordPtr ; | |
320 memcpy( acomm->hinsiPtr, sptr, size ) ; | |
321 make_cand: | |
322 size = 0 ; | |
323 /* | |
324 * S-JIS $B$GAw$i$l$F$-$?IJ;l%j%9%H%G!<%?$r(B kinput2$BB&$G07$($k$h$&$K(B | |
325 * EUC $B$KJQ49$9$k!#(B | |
326 */ | |
327 for( i = 0 ; i < acomm->hinsiNum ; i++ ) { | |
328 size += s2e( acomm->hinsiPtr[i].szHinsiStr, | |
329 strlen( acomm->hinsiPtr[i].szHinsiStr ), | |
330 euc, sizeof( euc )) ; | |
331 } | |
332 /* | |
333 * $BIJ;l%j%9%H$r4IM}$9$k%P%C%U%!$O8uJd%j%9%H$r4IM}$9$k%P%C%U%!$H(B | |
334 * $BF1$8NN0h$H$7!"4{$K3NJ]$5$l$F$$$k>l9g$K$O$=$NNN0h$O3NJ]$7$J$$!#(B | |
335 * $B%P%C%U%!$r6&M-=PMh$k$N$O!"8uJd$r=PNOCf$K!"IJ;l%j%9%H$r(B | |
336 * $B=PNO$9$k;v$,$J$$$+$i$G$"$j!"F1;~$K=PNO$9$k;v$,$"$k>l9g$K$O(B | |
337 * $BNN0h$rJL$K$H$k$h$&$K=$@5$9$kI,MW$,$"$k!#(B | |
338 */ | |
339 if ( acomm->kohoSize == 0 ) { | |
340 acomm->kohoStrPtr = ( WCHAR * )malloc( size * sizeof( WCHAR )) ; | |
341 acomm->kohoLenPtr = ( BYTE * )malloc( acomm->hinsiNum * sizeof( BYTE )) ; | |
342 acomm->kohoSfxPtr = ( BYTE * )malloc( acomm->hinsiNum * sizeof( BYTE )) ; | |
343 acomm->kohoSize = acomm->hinsiNum ; | |
344 acomm->kohoStrLen = size ; | |
345 } | |
346 if ( acomm->kohoSize < acomm->hinsiNum ) { | |
347 acomm->kohoLenPtr = ( BYTE * )realloc( acomm->kohoLenPtr, | |
348 acomm->hinsiNum * sizeof( BYTE )) ; | |
349 acomm->kohoSfxPtr = ( BYTE * )realloc( acomm->kohoSfxPtr, | |
350 acomm->hinsiNum * sizeof( BYTE )) ; | |
351 acomm->kohoSize = n ; | |
352 } | |
353 if ( acomm->kohoStrLen < size ) { | |
354 acomm->kohoStrPtr = ( WCHAR * )realloc( acomm->kohoStrPtr, | |
355 size * sizeof( WCHAR )) ; | |
356 acomm->kohoStrLen = size ; | |
357 } | |
358 len = 0 ; | |
359 for( i = 0 ; i < acomm->hinsiNum ; i++ ) { | |
360 n = strlen( acomm->hinsiPtr[i].szHinsiStr ) ; | |
361 n = sjis2ucs( acomm->hinsiPtr[i].szHinsiStr, n, | |
362 &acomm->kohoStrPtr[len], size -len, 0 ) ; | |
363 acomm->kohoLenPtr[i] = n ; | |
364 len += n ; | |
365 } | |
366 acomm->kohoNum2 = acomm->hinsiNum ; | |
367 acomm->kohoPos = 0 ; | |
368 | |
369 return acomm->hinsiNum ; | |
370 } | |
371 | |
372 /* Page */ | |
373 /* | |
374 * [$B4X?tL>(B] | |
375 * atokCandidate( ) | |
376 * [$BI=Bj(B] | |
377 * $B8uJd%j%9%H$N<hF@!?@_Dj(B | |
378 * [$B8F=P7A<0(B] | |
379 * int atokCandidate( _XatokRecPtr acomm, int nbr ) | |
380 * | |
381 * [$B0z?t(B] | |
382 * $B7?(B : $BL>(B $B>N(B : I O : $B@b(B $BL@(B | |
383 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
384 * int : nbr : i : $B@_Dj$9$kHV9f(B | |
385 * | |
386 * [$BJV$jCM(B] | |
387 * 0 $BL$K~(B : $BAw?.%(%i!<(B | |
388 * 0 : OK | |
389 * | |
390 * [$B;HMQ4X?t(B] | |
391 * atokClntCommunicate( ) | |
392 * [$B5!G=(B] | |
393 * $B8uJd%j%9%H$h$j!"8=:_A*Br$5$l$F$$$k8uJdHV9f$r@_Dj$9$k!#(B | |
394 */ | |
395 int atokCandidate(acomm, nbr) | |
396 _XatokRecPtr acomm; | |
397 int nbr; | |
398 { | |
399 int status ; | |
400 /* | |
401 * if $BJ8I,MW$J$7(B | |
402 */ | |
403 if ( nbr != ATCEPRVAPI_READCMD ) { | |
404 acomm->NETrqst.AtCEIncode = nbr ; | |
405 } | |
406 else { | |
407 acomm->NETrqst.AtCEIncode = ATCEPRVAPI_READCMD ; | |
408 } | |
409 acomm->NETrqst.ceCmd = IME_PRV_CANDLIST ; | |
410 | |
411 status = AtokClntCommunicate( acomm->sock, &acomm->NETrqst, &acomm->NETrslt ) ; | |
412 | |
413 return status ; | |
414 } | |
415 | |
416 /* Page */ | |
417 /* | |
418 * [$B4X?tL>(B] | |
419 * atokWordRegister( ) | |
420 * [$BI=Bj(B] | |
421 * $BC18l$NEPO?(B | |
422 * [$B8F=P7A<0(B] | |
423 * atokWordRegister( _XatokRecPtr acomm, wchar *word, | |
424 * int wlen, wchar *yomi, int ylen, int hinshi ) | |
425 * | |
426 * [$B0z?t(B] | |
427 * $B7?(B : $BL>(B $B>N(B : I O : $B@b(B $BL@(B | |
428 * _XatokRecPtr : acomm : i/o : kinput2$BMQJQ49%P%C%U%!(B | |
429 * wchar : *word : i : $BEPO?C18l(B | |
430 * int : wlen : i : $BEPO?C18lD9$5(B | |
431 * wchar : *yomi : i : $BC18l$h$_(B | |
432 * int : ylen : i : $BC18l$h$_$J$,$5(B | |
433 * int : hinshi : i : $BIJ;lHV9f(B | |
434 * | |
435 * | |
436 * [$BJV$jCM(B] | |
437 * -1 : $BAw?.$G$-$J$$!#(B | |
438 * 0 : $B@5>o=*N;(B | |
439 * 1 : $B$3$NFI$_$G$O$3$l0J>eEPO?IT2D(B | |
440 * 2 : $B$3$l0J>eEPO?IT2D(B | |
441 * 3 : $B<-=q@_DjIT@5(B | |
442 * 4 : $BI=5-$KITE,@Z$JJ8;z$r4^$`(B | |
443 * 5 : $BEPO?$G$-$J$$!#(B | |
444 * 6 : $BFI$_$KITE,@Z$JJ8;z$r4^$`(B | |
445 * 7 : $B4{$KEPO?$5$l$F$$$k!#(B | |
446 * | |
447 * [$B;HMQ4X?t(B] | |
448 * atokClntCommunicate( ) | |
449 * wcs2euc( ) | |
450 * euc2ucs( ) | |
451 * [$B5!G=(B] | |
452 * $BC18lEPO?$r9T$J$&!#(B | |
453 * $BC18lI=5-!"$h$_$O(B $B$=$l$>$F(B UCS$B%3!<%I$GEPO?$9$k!#(B | |
454 * kinput2 $B$G4IM}$7$F$$$k;~$O(B | |
455 * $BC18lI=5-$O(B WCHAR, $BFI$_%3!<%I$O(BEUC$B$G$"$k$N$G$=$l$>$l(B | |
456 * UCS $B$X$NJQ49$r0lEY9T$J$&!#(B | |
457 * $BIJ;lHV9f$O!"#1$+$i;O$^$kJ*$G$"$k!#(B | |
458 */ | |
459 | |
460 int atokWordRegister(acomm, word, wlen, yomi, ylen, hinshi) | |
461 _XatokRecPtr acomm; | |
462 wchar *word; | |
463 int wlen; | |
464 wchar *yomi; | |
465 int ylen; | |
466 int hinshi; | |
467 { | |
468 AtokReqPacket *req ; | |
469 unsigned char *eucp ; | |
470 WCHAR *ucs_wp ; /* $BC18l(B UCS $BJ8;zNs(B */ | |
471 WCHAR *ucs_yp ; /* $BFI$_(B UCS $BJ8;zNs(B */ | |
472 unsigned char *sjp ; | |
473 int len ; | |
474 int alen ; | |
475 int i ; | |
476 | |
477 if ( wlen > ylen ) alen = wlen ; | |
478 else alen = ylen ; | |
479 | |
480 acomm->NETrqst.ceCmd = IME_PRV_REGISTERWORDEX ; | |
481 req = &acomm->NETrqst ; | |
482 /* printf( "wlen %d, ylen %d\n", wlen, ylen ) ; */ | |
483 | |
484 eucp = ( unsigned char * )malloc( alen * sizeof( WCHAR ) + 1 ) ; | |
485 sjp = ( unsigned char * )malloc( ylen * sizeof( WCHAR ) + 1 ) ; | |
486 | |
487 /* | |
488 * $BC18lJ8;zNs$r(B WCS -> EUC -> UCS $BJQ49$9$k!#(B | |
489 */ | |
490 bzero( eucp, alen ) ; | |
491 wcs2euc( word, wlen, eucp ) ; | |
492 len = strlen( eucp ) ; | |
493 ucs_wp = ( WCHAR * )malloc(( len + 1 ) * sizeof( WCHAR )) ; | |
494 euc2ucs( eucp, strlen( eucp ), ucs_wp, len, 0x3013 ) ; | |
495 | |
496 #if 0 | |
497 printf( "\303\261\270\354 WCS CODE -> "/*=$BC18l(B WCS CODE -> =*/ ) ; | |
498 for( i = 0 ; i <= wlen ; i++ ) { | |
499 printf( "0x%x ", word[i] ) ; | |
500 } | |
501 printf( "\303\261\270\354 EUC CODE -> "/*=$BC18l(B EUC CODE -> =*/ ) ; | |
502 for( i = 0 ; i <= len ; i++ ) { | |
503 printf( "0x%x ", eucp[i] ) ; | |
504 } | |
505 printf( "\n" ) ; | |
506 printf( "\303\261\270\354 EUC [%s]\n"/*=$BC18l(B EUC [%s]\n=*/, eucp ) ; | |
507 printf( "\303\261\270\354 UCS CODE -> "/*=$BC18l(B UCS CODE -> =*/ ) ; | |
508 for( i = 0 ; i <= wlen ; i++ ) { | |
509 /* printf( "0x%x ", ucs_wp[i] ) ; */ | |
510 } | |
511 printf( "\n" ) ; | |
512 #endif | |
513 | |
514 | |
515 /* | |
516 * $BFI$_J8;zNs$r(B WCS -> EUC -> UCS $BJQ49$9$k!#(B | |
517 */ | |
518 bzero( eucp, alen ) ; | |
519 wcs2euc( yomi, ylen, eucp ) ; | |
520 len = strlen( eucp ) ; | |
521 ucs_yp = ( WCHAR * )malloc(( len + 1 ) * sizeof( WCHAR )) ; | |
522 euc2ucs( eucp, strlen( eucp ), ucs_yp, len, 0x3013 ) ; | |
523 | |
524 #if 0 | |
525 printf( "\306\311\244\337 EUC CODE -->"/*=$BFI$_(B EUC CODE -->=*/ ) ; | |
526 for( i = 0 ; i <= len ; i++ ) { | |
527 printf( "0x%x ", eucp[i] ) ; | |
528 } | |
529 printf( "\n" ) ; | |
530 printf( "\306\311\244\337 EUC [%s]\n"/*=$BFI$_(B EUC [%s]\n=*/, eucp ) ; | |
531 for( i = 0 ; i <= strlen( eucp ) ; i++ ) { | |
532 printf( "0x%0x ", eucp[i] ) ; | |
533 } | |
534 printf( "\n" ) ; | |
535 printf( "\306\311\244\337 UCS CODE -> "/*=$BFI$_(B UCS CODE -> =*/ ) ; | |
536 for( i = 0 ; i <= ylen ; i++ ) { | |
537 printf( "0x%x ", ucs_yp[i] ) ; | |
538 } | |
539 printf( "\n" ) ; | |
540 #endif | |
541 | |
542 /* | |
543 * $BAw?.%Q%i%a!<%?$N:n@.(B | |
544 */ | |
545 req->Kind[0] = T_WCHAR ; | |
546 req->Size[0] = wlen ; | |
547 req->ArgPtr[0] = ucs_wp ; | |
548 | |
549 req->Kind[1] = T_WCHAR ; | |
550 req->Size[1] = ylen ; | |
551 req->ArgPtr[1] = ucs_yp ; | |
552 | |
553 req->Ctr[0] = hinshi ; | |
554 | |
555 AtokClntCommunicate( acomm->sock, &acomm->NETrqst, &acomm->NETrslt ) ; | |
556 | |
557 free( ucs_wp ) ; | |
558 free( ucs_yp ) ; | |
559 free( eucp ) ; | |
560 | |
561 /* printf( "$BEPO?7k2L(B %d\n", acomm->NETrslt.header.CEOutinf ) ; */ | |
562 return acomm->NETrslt.header.CEOutinf ; | |
563 } | |
564 /* End of if.c */ |