1/* Copyright 1992 NEC Corporation, Tokyo, Japan.
2 *
3 * Permission to use, copy, modify, distribute and sell this software
4 * and its documentation for any purpose is hereby granted without
5 * fee, provided that the above copyright notice appear in all copies
6 * and that both that copyright notice and this permission notice
7 * appear in supporting documentation, and that the name of NEC
8 * Corporation not be used in advertising or publicity pertaining to
9 * distribution of the software without specific, written prior
10 * permission.  NEC Corporation makes no representations about the
11 * suitability of this software for any purpose.  It is provided "as
12 * is" without express or implied warranty.
13 *
14 * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
16 * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 */
22
23/************************************************************************/
24/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997
25/************************************************************************/
26
27
28#if !defined(lint) && !defined(__CODECENTER__)
29static char rcs_id[] = "@(#) 102.1 $Id: ulhinshi.c 14875 2005-11-12 21:25:31Z bonefish $";
30#endif
31
32#include <errno.h>
33#include "canna.h"
34#include "RK.h"
35#include "RKintern.h"
36
37#ifndef NO_EXTEND_MENU
38#ifdef luna88k
39extern int errno;
40#endif
41
42static void WSprintf(WCHAR_T *to_buf, WCHAR_T *x1, WCHAR_T *x2, WCHAR_T *from_buf);
43static void EWStrcpy(WCHAR_T *buf, char *xxxx);
44static int EWStrcmp(WCHAR_T *buf, char *xxxx);
45static int EWStrncmp(WCHAR_T *buf, char *xxxx, int len);
46static int uuTHinshiYNQuitCatch(uiContext d, int retval, mode_context env);
47static int uuTHinshi2YesCatch(uiContext d, int retval, mode_context env);
48static int uuTHinshi2NoCatch(uiContext d, int retval, mode_context env);
49static int uuTHinshi1YesCatch(uiContext d, int retval, mode_context env);
50static int uuTHinshi1NoCatch(uiContext d, int retval, mode_context env);
51static int uuTHinshiQYesCatch(uiContext d, int retval, mode_context env);
52static int uuTHinshiQNoCatch(uiContext d, int retval, mode_context env);
53static int makeHinshi(uiContext d);
54static int tourokuYes(uiContext d);
55static int tourokuNo(uiContext d);
56static void makeDoushi(uiContext d);
57static int uuTDicExitCatch(uiContext d, int retval, mode_context env);
58static int uuTDicQuitCatch(uiContext d, int retval, mode_context env);
59static int tangoTouroku(uiContext d);
60
61static char *e_message[] = {
62//#ifndef WIN
63#ifdef WIN
64  /*0*/"¤µ¤é¤ËºÙ¤«¤¤ÉÊ»ìʬ¤±¤Î¤¿¤á¤Î¼ÁÌä¤ò¤·¤Æ¤âÎɤ¤¤Ç¤¹¤«?(y/n)",
65  /*1*/"ÆɤߤȸõÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£",
66  /*2*/"ÆɤߤȸõÊä¤Î ³èÍѤ¬°ã¤¤¤Þ¤¹¡£ÆþÎϤ·¤Ê¤ª¤·¤Æ¤¯¤À¤µ¤¤¡£",
67  /*3*/"ÆɤߤȸõÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) Áᤤ",
68  /*4*/"ÆɤߤȸõÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) ÀŤ«¤À",
69  /*5*/"¡Ö",
70  /*6*/"¤¹¤ë¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)",
71  /*7*/"¤Ê¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)",
72  /*8*/"¡×¤Ï¿Í̾¤Ç¤¹¤«?(y/n)",
73  /*9*/"¡×¤ÏÃÏ̾¤Ç¤¹¤«?(y/n)",
74  /*10*/"¤Ê¤¤¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)",
75  /*11*/"¡×¤Ï̾»ì¤È¤·¤Æ»È¤¤¤Þ¤¹¤«?(y/n)",
76  /*12*/"¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)",
77  /*13*/"¤È¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)",
78#ifdef STANDALONE
79  /*14*/"¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó",
80#else
81  /*14*/"¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó",
82#endif
83  /*15*/"ñ¸ìÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿",
84  /*16*/"¡Ø",
85  /*17*/"¡Ù",
86  /*18*/"¡Ê",
87  /*19*/"¡Ë¤òÅÐÏ¿¤·¤Þ¤·¤¿",
88  /*20*/"ñ¸ìÅÐÏ¿¤Ë¼ºÇÔ¤·¤Þ¤·¤¿",
89#else
90  /*0*/"\244\265\244\351\244\313\272\331\244\253\244\244\311\312\273\354\312\254\244\261\244\316\244\277\244\341\244\316\274\301\314\344\244\362\244\267\244\306\244\342\316\311\244\244\244\307\244\271\244\253?(y/n)",
91       /* ¤µ¤é¤ËºÙ¤«¤¤ÉÊ»ìʬ¤±¤Î¤¿¤á¤Î¼ÁÌä¤ò¤·¤Æ¤âÎɤ¤¤Ç¤¹¤« */
92
93  /*1*/"\306\311\244\337\244\310\270\365\312\344\244\362\40\275\252\273\337\267\301\244\307\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244\241\243",
94       /* ÆɤߤȸõÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£*/
95
96  /*2*/"\306\311\244\337\244\310\270\365\312\344\244\316\40\263\350\315\321\244\254\260\343\244\244\244\336\244\271\241\243\306\376\316\317\244\267\244\312\244\252\244\267\244\306\244\257\244\300\244\265\244\244\241\243",
97       /* ÆɤߤȸõÊä¤Î ³èÍѤ¬°ã¤¤¤Þ¤¹¡£ÆþÎϤ·¤Ê¤ª¤·¤Æ¤¯¤À¤µ¤¤¡£*/
98
99  /*3*/"\306\311\244\337\244\310\270\365\312\344\244\362\40\275\252\273\337\267\301\244\307\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244\241\243\316\343) \301\341\244\244",
100       /* ÆɤߤȸõÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) Áᤤ */
101
102  /*4*/"\306\311\244\337\244\310\270\365\312\344\244\362\40\275\252\273\337\267\301\244\307\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244\241\243\316\343) \300\305\244\253\244\300",
103       /* ÆɤߤȸõÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) ÀŤ«¤À */
104
105  /*5*/"\241\326",  /* ¡Ö */
106
107  /*6*/"\244\271\244\353\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)",
108       /* ¤¹¤ë¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */
109
110  /*7*/"\244\312\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)",
111       /* ¤Ê¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */
112
113  /*8*/"\241\327\244\317\277\315\314\276\244\307\244\271\244\253?(y/n)",
114       /* ¡×¤Ï¿Í̾¤Ç¤¹¤« */
115
116  /*9*/"\241\327\244\317\303\317\314\276\244\307\244\271\244\253?(y/n)",
117       /* ¡×¤ÏÃÏ̾¤Ç¤¹¤« */
118
119  /*10*/"\244\312\244\244\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)",
120       /* ¤Ê¤¤¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */
121
122  /*11*/"\241\327\244\317\314\276\273\354\244\310\244\267\244\306\273\310\244\244\244\336\244\271\244\253?(y/n)",
123       /* ¡×¤Ï̾»ì¤È¤·¤Æ»È¤¤¤Þ¤¹¤« */
124
125  /*12*/"\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)",
126       /* ¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */
127
128  /*13*/"\244\310\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)",
129       /* ¤È¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */
130
131#ifdef STANDALONE
132  /*14*/"\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363",
133       /* ¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó */
134#else
135  /*14*/"\244\253\244\312\264\301\273\372\312\321\264\271\245\265\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336\244\273\244\363",
136       /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó */
137#endif
138
139  /*15*/"\303\261\270\354\305\320\317\277\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277",
140       /* ñ¸ìÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
141
142  /*16*/"\241\330", /* ¡Ø */
143
144  /*17*/"\241\331", /* ¡Ù */
145
146  /*18*/"\241\312", /* ¡Ê */
147
148  /*19*/"\241\313\244\362\305\320\317\277\244\267\244\336\244\267\244\277",
149       /* ¡Ë¤òÅÐÏ¿¤·¤Þ¤·¤¿ */
150
151  /*20*/"\303\261\270\354\305\320\317\277\244\313\274\272\307\324\244\267\244\336\244\267\244\277",
152       /* ñ¸ìÅÐÏ¿¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */
153#endif
154};
155
156#define message_num (sizeof(e_message) / sizeof(char *))
157static WCHAR_T *message[message_num];
158
159#ifdef WIN
160static char sgyouA[] = "¤«¤¬¤µ¤¿¤Ê¤Ð¤Þ¤é¤ï";
161static char sgyouI[] = "¤­¤®¤·¤Á¤Ë¤Ó¤ß¤ê¤¤";
162static char sgyouU[] = "¤¯¤°¤¹¤Ä¤Ì¤Ö¤à¤ë¤¦";
163#else
164static char sgyouA[] = "\244\253\244\254\244\265\244\277\244\312\244\320\244\336\244\351\244\357";
165                       /* ¤«¤¬¤µ¤¿¤Ê¤Ð¤Þ¤é¤ï */
166
167static char sgyouI[] = "\244\255\244\256\244\267\244\301\244\313\244\323\244\337\244\352\244\244";
168                       /* ¤­¤®¤·¤Á¤Ë¤Ó¤ß¤ê¤¤ */
169
170static char sgyouU[] = "\244\257\244\260\244\271\244\304\244\314\244\326\244\340\244\353\244\246";
171                       /* ¤¯¤°¤¹¤Ä¤Ì¤Ö¤à¤ë¤¦ */
172#endif
173
174
175#define KAGYOU 0
176#define GAGYOU 1
177#define SAGYOU 2
178#define TAGYOU 3
179#define NAGYOU 4
180#define BAGYOU 5
181#define MAGYOU 6
182#define RAGYOU 7
183#define WAGYOU 8
184
185
186static WCHAR_T *gyouA;
187static WCHAR_T *gyouI;
188static WCHAR_T *gyouU;
189
190/* Á´¤Æ¤Î¥á¥Ã¥»¡¼¥¸¤ò"unsigned char"¤«¤é"WCHAR_T"¤ËÊÑ´¹¤¹¤ë */
191int
192initHinshiMessage(void)
193{
194  int i;
195
196  for(i = 0; i < message_num; i++) {
197    message[i] = WString(e_message[i]);
198    if(!message[i]) {
199      return(-1);
200    }
201  }
202  return 0;
203}
204
205/* WSprintf(to_buf, x1, x2, from_buf)
206   :WSprintf(to_buf,"x1%sx2",from_buf);
207 */
208static void
209WSprintf(WCHAR_T *to_buf, WCHAR_T *x1, WCHAR_T *x2, WCHAR_T *from_buf)
210{
211    WStrcpy(to_buf, x1);
212    WStrcat(to_buf, from_buf);
213    WStrcat(to_buf, x2);
214}
215#endif /* NO_EXTEND_MENU */
216
217#ifndef WIN
218void
219EWStrcat(WCHAR_T *buf, char *xxxx)
220{
221  WCHAR_T x[1024];
222
223  MBstowcs(x, xxxx, 1024);
224  WStrcat(buf, x);
225}
226#endif
227
228#ifndef NO_EXTEND_MENU
229static void
230EWStrcpy(WCHAR_T *buf, char *xxxx)
231{
232  WCHAR_T x[1024];
233  int len;
234
235  len = MBstowcs(x, xxxx, 1024);
236  WStrncpy(buf, x, len);
237  buf[len] = (WCHAR_T)0;
238}
239
240static int
241EWStrcmp(WCHAR_T *buf, char *xxxx)
242{
243  WCHAR_T x[1024];
244
245  MBstowcs(x, xxxx, 1024);
246  return(WStrncmp(buf, x, WStrlen(x)));
247}
248
249static int
250EWStrncmp(WCHAR_T *buf, char *xxxx, int len)
251/* ARGSUSED */
252{
253  WCHAR_T x[1024];
254
255  MBstowcs(x, xxxx, 1024);
256  return(WStrncmp(buf, x, WStrlen(x)));
257}
258
259int
260initGyouTable(void)
261{
262  gyouA = WString(sgyouA);
263  gyouI = WString(sgyouI);
264  gyouU = WString(sgyouU);
265
266  if (!gyouA || !gyouI || !gyouU) {
267    return NG;
268  }
269  return 0;
270}
271
272
273/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
274 * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò ¡ÁYes/No ¶¦ÄÌ Quit¡Á                                   *
275 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
276
277static
278int uuTHinshiYNQuitCatch(uiContext d, int retval, mode_context env)
279/* ARGSUSED */
280{
281  popCallback(d);
282
283  return(dicTourokuHinshi(d));
284}
285
286/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
287 * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò ¡ÁYes/No Â裲Ãʳ¬ ¶¦ÄÌ¥³¡¼¥ë¥Ð¥Ã¥¯¡Á                   *
288 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
289
290static
291int uuTHinshi2YesCatch(uiContext d, int retval, mode_context env)
292/* ARGSUSED */
293{
294  tourokuContext tc;
295
296  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
297
298  tourokuYes(d);   /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */
299
300  tc = (tourokuContext)d->modec;
301
302  if (!tc->qbuf[0]) {
303    if (tc->hcode[0]) {
304      /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */
305      return(dicTourokuDictionary(d, (int(*)(...))uuTDicExitCatch, (int(*)(...))uuTDicQuitCatch));
306    }
307  }
308  return(retval);
309}
310
311static
312int uuTHinshi2NoCatch(uiContext d, int retval, mode_context env)
313/* ARGSUSED */
314{
315  tourokuContext tc;
316
317  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
318
319  tourokuNo(d);   /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */
320
321  tc = (tourokuContext)d->modec;
322
323  if (!tc->qbuf[0]) {
324    if (tc->hcode[0]) {
325      /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */
326      return(dicTourokuDictionary(d, (int(*)(...))uuTDicExitCatch, (int(*)(...))uuTDicQuitCatch));
327    }
328  }
329
330  return(retval);
331}
332
333/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
334 * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò ¡ÁYes/No Â裱Ãʳ¬ ¥³¡¼¥ë¥Ð¥Ã¥¯¡Á                       *
335 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
336
337static
338int uuTHinshi1YesCatch(uiContext d, int retval, mode_context env)
339/* ARGSUSED */
340{
341  tourokuContext tc;
342  coreContext ync;
343
344  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
345
346  tourokuYes(d);   /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */
347
348  tc = (tourokuContext)d->modec;
349
350  if(tc->qbuf[0]) {
351    /* ¼ÁÌ䤹¤ë */
352    makeGLineMessage(d, tc->qbuf, WStrlen(tc->qbuf));
353    if((retval = getYesNoContext(d,
354		 NO_CALLBACK, uuTHinshi2YesCatch,
355		 uuTHinshiYNQuitCatch, uuTHinshi2NoCatch)) == NG) {
356      defineEnd(d);
357      return(GLineNGReturnTK(d));
358    }
359    ync = (coreContext)d->modec;
360    ync->majorMode = CANNA_MODE_ExtendMode;
361    ync->minorMode = CANNA_MODE_TourokuHinshiMode;
362  } else if(tc->hcode[0]) {
363    /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */
364    return(dicTourokuDictionary(d, (int(*)(...))uuTDicExitCatch, (int(*)(...))uuTDicQuitCatch));
365  }
366
367  return(retval);
368}
369
370static
371int uuTHinshi1NoCatch(uiContext d, int retval, mode_context env)
372/* ARGSUSED */
373{
374  tourokuContext tc;
375  coreContext ync;
376
377  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
378
379  tourokuNo(d);   /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */
380
381  tc = (tourokuContext)d->modec;
382
383  if(tc->qbuf[0]) {
384    /* ¼ÁÌ䤹¤ë */
385    makeGLineMessage(d, tc->qbuf, WStrlen(tc->qbuf));
386    if((retval = getYesNoContext(d,
387		 NO_CALLBACK, uuTHinshi2YesCatch,
388		 uuTHinshiYNQuitCatch, uuTHinshi2NoCatch)) == NG) {
389      defineEnd(d);
390      return(GLineNGReturnTK(d));
391    }
392    ync = (coreContext)d->modec;
393    ync->majorMode = CANNA_MODE_ExtendMode;
394    ync->minorMode = CANNA_MODE_TourokuHinshiMode;
395  } else if(tc->hcode[0]) {
396    /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */
397    return(dicTourokuDictionary(d, (int(*)(...))uuTDicExitCatch, (int(*)(...))uuTDicQuitCatch));
398  }
399
400  return(retval);
401}
402
403/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
404 * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìʬ¤±¤¹¤ë¡©                                                  *
405 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
406
407static
408int uuTHinshiQYesCatch(uiContext d, int retval, mode_context env)
409/* ARGSUSED */
410{
411  tourokuContext tc;
412  coreContext ync;
413
414  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
415
416  tc = (tourokuContext)d->modec;
417
418  makeGLineMessage(d, tc->qbuf, WStrlen(tc->qbuf)); /* ¼ÁÌä */
419  if((retval = getYesNoContext(d,
420	 NO_CALLBACK, uuTHinshi1YesCatch,
421	 uuTHinshiYNQuitCatch, uuTHinshi1NoCatch)) == NG) {
422    defineEnd(d);
423    return(GLineNGReturnTK(d));
424  }
425  ync = (coreContext)d->modec;
426  ync->majorMode = CANNA_MODE_ExtendMode;
427  ync->minorMode = CANNA_MODE_TourokuHinshiMode;
428
429  return(retval);
430}
431
432static
433int uuTHinshiQNoCatch(uiContext d, int retval, mode_context env)
434/* ARGSUSED */
435{
436  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
437
438  return(dicTourokuDictionary(d, (int(*)(...))uuTDicExitCatch, (int(*)(...))uuTDicQuitCatch));
439}
440
441/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
442 * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò                                                        *
443 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
444
445static int makeHinshi();
446
447int dicTourokuHinshiDelivery(uiContext d)
448{
449  tourokuContext tc = (tourokuContext)d->modec;
450  coreContext ync;
451  int retval = 0;
452
453  makeHinshi(d); /* Éʻ졢¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¡¢¼ÁÌä¤ò¥»¥Ã¥È¤·¤Æ¤¯¤ë */
454
455#if defined(DEBUG) && !defined(WIN)
456  if(iroha_debug) {
457    printf("tc->genbuf=%s, tc->qbuf=%s, tc->hcode=%s\n", tc->genbuf, tc->qbuf,
458	   tc->hcode);
459  }
460#endif
461  if(tc->genbuf[0]) {
462    /* ÆþÎϤµ¤ì¤¿¥Ç¡¼¥¿¤Ë¸í¤ê¤¬¤¢¤Ã¤¿¤Î¤Ç¡¢
463       ¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤·¤ÆÆɤßÆþÎϤËÌá¤ë */
464    clearYomi(d);
465    return(dicTourokuTango(d, uuTTangoQuitCatch));
466  } else if(tc->qbuf[0] && cannaconf.grammaticalQuestion) {
467    /* ºÙ¤«¤¤ÉÊ»ìʬ¤±¤Î¤¿¤á¤Î¼ÁÌä¤ò¤¹¤ë */
468    WStrcpy(d->genbuf, message[0]);
469    if((retval = getYesNoContext(d,
470		 NO_CALLBACK, uuTHinshiQYesCatch,
471		 uuTHinshiYNQuitCatch, uuTHinshiQNoCatch)) == NG) {
472      defineEnd(d);
473      return(GLineNGReturnTK(d));
474    }
475    makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf));
476    ync = (coreContext)d->modec;
477    ync->majorMode = CANNA_MODE_ExtendMode;
478    ync->minorMode = CANNA_MODE_TourokuHinshiMode;
479    return(retval);
480  } else if(tc->hcode[0]) {
481    /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */
482    return(dicTourokuDictionary(d, (int(*)(...))uuTDicExitCatch, (int(*)(...))uuTDicQuitCatch));
483  }
484  return 0;
485}
486
487/*
488 * ÁªÂò¤µ¤ì¤¿Éʻ줫¤é¼¡¤ÎÆ°ºî¤ò¹Ô¤¦
489 *
490 * tc->hcode	ÉÊ»ì
491 * tc->qbuf	¼ÁÌä
492 * tc->genbuf	¥¨¥é¡¼
493 */
494static int
495makeHinshi(uiContext d)
496{
497  tourokuContext tc = (tourokuContext)d->modec;
498  int tlen, ylen, yomi_katsuyou;
499  WCHAR_T tmpbuf[256];
500
501  tc->hcode[0] = 0;
502  tc->qbuf[0] = 0;
503  tc->genbuf[0] = 0;
504
505  tlen = tc->tango_len;
506  ylen = tc->yomi_len;
507
508  switch(tc->curHinshi) {
509  case MEISHI:
510    EWStrcpy(tc->hcode, "#T35");
511    tc->katsuyou = 0;
512    WSprintf(tc->qbuf, message[5], message[6], tc->tango_buffer);
513    break;
514
515  case KOYUMEISHI:
516    EWStrcpy(tc->hcode, "#KK");
517    WSprintf(tc->qbuf, message[5], message[8], tc->tango_buffer);
518    break;
519
520  case DOSHI:
521
522    /* ÆþÎϤ¬½ª»ß·Á¤«¡© */
523    tc->katsuyou = 0;
524    while (tc->katsuyou < GOBISUU &&
525	   tc->tango_buffer[tlen - 1] != gyouU[tc->katsuyou]) {
526      tc->katsuyou++;
527    }
528    yomi_katsuyou = 0;
529    while (yomi_katsuyou < GOBISUU &&
530	   tc->yomi_buffer[ylen - 1] != gyouU[yomi_katsuyou]) {
531      yomi_katsuyou++;
532    }
533    if((tc->katsuyou == GOBISUU) || (yomi_katsuyou == GOBISUU)){
534      WStrcpy(tc->genbuf, message[1]);
535      return(0);
536    }
537    if(tc->katsuyou != yomi_katsuyou){
538      WStrcpy(tc->genbuf, message[2]);
539      return(0);
540    }
541
542    makeDoushi(d);  /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */
543    if (tc->katsuyou == RAGYOU) {
544      tc->curHinshi = RAGYODOSHI;
545      /* ̤Á³·Á¤ò¤Ä¤¯¤ë */
546      WStrncpy(tmpbuf, tc->tango_buffer, tlen-1);
547      tmpbuf[tlen - 1] = gyouA[tc->katsuyou];
548      tmpbuf[tlen] = (WCHAR_T)0;
549      WSprintf(tc->qbuf, message[5], message[10], tmpbuf);
550    }
551    else {
552      tc->curHinshi = GODAN;
553      WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1);
554      tmpbuf[tlen - 1] = gyouI[tc->katsuyou];
555      tmpbuf[tlen] = (WCHAR_T)'\0';
556      WSprintf(tc->qbuf, message[5], message[11], tmpbuf);
557    }
558    break;
559
560  case KEIYOSHI:
561    tc->katsuyou = 1;
562    if(tlen >= 1 && ylen >= 1 &&
563       ((EWStrncmp(tc->tango_buffer+tlen-1, "\244\244", 1) != 0) ||
564	(EWStrncmp(tc->yomi_buffer+ylen-1, "\244\244", 1) != 0))) {
565                                           /* ¤¤ */
566      WStrcpy(tc->genbuf, message[3]);
567      return(0);
568    }
569
570    EWStrcpy(tc->hcode, "#KY"); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */
571    WStrncpy(tmpbuf, tc->tango_buffer, tlen-1);
572    tmpbuf[tlen-1] = 0;
573    WSprintf(tc->qbuf, message[5], message[11], tmpbuf);
574    break;
575
576  case KEIYODOSHI:
577    tc->katsuyou = 1;
578    if(tlen >= 1 && ylen >= 1 &&
579       ((EWStrncmp(tc->tango_buffer+tlen-1, "\244\300", 1)) ||
580	(EWStrncmp(tc->yomi_buffer+ylen-1, "\244\300", 1)))) {
581                                           /* ¤À */
582      WStrcpy(tc->genbuf, message[4]);
583      return(0);
584    }
585    EWStrcpy(tc->hcode, "#T05"); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */
586    WStrncpy(tmpbuf, tc->tango_buffer, tlen-1);
587    tmpbuf[tlen-1] = 0;
588    WSprintf(tc->qbuf, message[5], message[6], tmpbuf);
589    break;
590
591  case FUKUSHI:
592    EWStrcpy(tc->hcode, "#F14"); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */
593    tc->katsuyou = 0;
594    WSprintf(tc->qbuf, message[5], message[6], tc->tango_buffer);
595    break;
596
597  case TANKANJI:
598    EWStrcpy(tc->hcode, "#KJ");
599    break;
600
601  case SUSHI:
602    EWStrcpy(tc->hcode, "#NN");
603    break;
604
605  case RENTAISHI:
606    EWStrcpy(tc->hcode, "#RT");
607    break;
608
609  case SETSUZOKUSHI:  /* Àܳ»ì¡¦´¶Æ°»ì */
610    EWStrcpy(tc->hcode, "#CJ");
611    break;
612
613  case SAHENMEISHI:
614  case MEISHIN:
615    tc->katsuyou = 0;
616    WSprintf(tc->qbuf, message[5], message[7], tc->tango_buffer);
617    break;
618
619  case JINMEI:
620  case KOYUMEISHIN:
621    WSprintf(tc->qbuf, message[5], message[9], tc->tango_buffer);
622    break;
623
624  case RAGYOGODAN:
625    WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1);
626    tmpbuf[tlen - 1] = gyouI[tc->katsuyou];
627    tmpbuf[tlen] = (WCHAR_T)'\0';
628    WSprintf(tc->qbuf, message[5], message[11], tmpbuf);
629    break;
630
631  case KAMISHIMO:
632    WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1);
633    tmpbuf[tlen - 1] = (WCHAR_T)'\0';
634    WSprintf(tc->qbuf, message[5], message[11], tmpbuf);
635    break;
636
637  case KEIYODOSHIY:
638  case KEIYODOSHIN:
639    WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1);
640    tmpbuf[tlen - 1] = 0;
641    WSprintf(tc->qbuf, message[5], message[11], tmpbuf);
642    break;
643
644  case FUKUSHIY:
645  case FUKUSHIN:
646    WSprintf(tc->qbuf, message[5], message[13], tc->tango_buffer);
647    break;
648  }
649
650  return(0);
651}
652
653static
654int tourokuYes(uiContext d)
655{
656  tourokuContext tc = (tourokuContext)d->modec;
657
658  tc->hcode[0] = 0;
659  tc->qbuf[0] = 0;
660  tc->genbuf[0] = 0;
661
662  switch(tc->curHinshi) {
663  case MEISHI:
664    tc->curHinshi = SAHENMEISHI;
665    makeHinshi(d);
666    break;
667
668  case KOYUMEISHI:
669    tc->curHinshi = JINMEI;
670    makeHinshi(d);
671    break;
672
673  case GODAN:  /* ¥é¹Ô°Ê³°¤Î¸ÞÃʳèÍÑÆ°»ì */
674    makeDoushi(d);
675    EWStrcat(tc->hcode, "r");              /* ½ñ¤¯¡¢µÞ¤°¡¢°Ü¤¹ */
676    break;
677
678  case RAGYODOSHI:
679    tc->curHinshi = RAGYOGODAN;
680    makeHinshi(d);
681    break;
682
683  case KEIYOSHI:
684    EWStrcpy(tc->hcode, "#KYT");           /* ¤­¤¤¤í¤¤ */
685    break;
686
687  case KEIYODOSHI:
688    tc->curHinshi = KEIYODOSHIY;
689    makeHinshi(d);
690    break;
691
692  case FUKUSHI:
693    tc->curHinshi = FUKUSHIY;
694    makeHinshi(d);
695    break;
696
697  case MEISHIN:
698    EWStrcpy(tc->hcode, "#T15");          /* ¿§¡¹¡¢¶¯ÎÏ */
699    break;
700
701  case SAHENMEISHI:
702    EWStrcpy(tc->hcode, "#T10");          /* °Â¿´¡¢Éⵤ */
703    break;
704
705  case KOYUMEISHIN:
706    EWStrcpy(tc->hcode, "#CN");	          /* Åìµþ */
707    break;
708
709  case JINMEI:
710    EWStrcpy(tc->hcode, "#JCN");          /* Ê¡Åç */
711    break;
712
713  case RAGYOGODAN:
714    EWStrcpy(tc->hcode, "#R5r");          /* ¼Õ¤ë */
715    break;
716
717  case KAMISHIMO:
718    EWStrcpy(tc->hcode, "#KSr");          /* À¸¤­¤ë¡¢Í¤±¤ë */
719    break;
720
721  case KEIYODOSHIY:
722    EWStrcpy(tc->hcode, "#T10");          /* ´Ø¿´¤À */
723    break;
724
725  case KEIYODOSHIN:
726    EWStrcpy(tc->hcode, "#T15");          /* °Õ³°¤À¡¢²Äǽ¤À */
727    break;
728
729  case FUKUSHIY:
730    EWStrcpy(tc->hcode, "#F04");          /* ¤Õ¤Ã¤¯¤é */
731    break;
732
733  case FUKUSHIN:
734    EWStrcpy(tc->hcode, "#F06");          /* ÆÍÁ³ */
735    break;
736  }
737
738  return(0);
739}
740
741static
742int tourokuNo(uiContext d)
743{
744  tourokuContext tc = (tourokuContext)d->modec;
745  int ylen;
746
747  tc->hcode[0] = 0;
748  tc->qbuf[0] = 0;
749  tc->genbuf[0] = 0;
750
751  switch( tc->curHinshi ) {
752  case MEISHI:
753    tc->curHinshi = MEISHIN;
754    makeHinshi(d);
755    break;
756
757  case KOYUMEISHI:
758    tc->curHinshi = KOYUMEISHIN;
759    makeHinshi(d);
760    break;
761
762  case GODAN:  /* ¥é¹Ô°Ê³°¤Î¸ÞÃʳèÍÑÆ°»ì */
763    makeDoushi(d);
764    break;
765
766  case RAGYODOSHI:
767    ylen = tc->yomi_len;
768    if (ylen >= 2 && !(EWStrcmp(tc->yomi_buffer + ylen - 2, "\244\257\244\353"))) {   /* ¤¯¤ë */
769      EWStrcpy(tc->hcode, "#KX");         /* Íè¤ë */
770    }
771    else if (ylen >=2 && !(EWStrcmp(tc->yomi_buffer + ylen - 2, "\244\271\244\353"))) { /* ¤¹¤ë */
772      EWStrcpy(tc->hcode, "#SX");         /* ¤¹¤ë */
773    }
774    else if (ylen >=2 && !(EWStrcmp(tc->yomi_buffer + ylen - 2, "\244\272\244\353"))) {  /* ¤º¤ë */
775      EWStrcpy(tc->hcode, "#ZX");         /* ½à¤º¤ë */
776    }
777    else {
778      tc->curHinshi = KAMISHIMO;
779      makeHinshi(d);
780    }
781    break;
782
783  case KEIYOSHI:
784    EWStrcpy(tc->hcode, "#KY");           /* Èþ¤·¤¤¡¢Áᤤ */
785    break;
786
787  case KEIYODOSHI:
788    tc->curHinshi = KEIYODOSHIN;
789    makeHinshi(d);
790    break;
791
792  case FUKUSHI:
793    tc->curHinshi = FUKUSHIN;
794    makeHinshi(d);
795    break;
796
797  case MEISHIN:
798    EWStrcpy(tc->hcode, "#T35");          /* »³¡¢¿å */
799    break;
800
801  case SAHENMEISHI:
802    EWStrcpy(tc->hcode, "#T30");          /* ÅØÎÏ¡¢¸¡ºº */
803    break;
804
805  case KOYUMEISHIN:
806    EWStrcpy(tc->hcode, "#KK");           /* ÆüËÜÅŵ¤ */
807    break;
808
809  case JINMEI:
810    EWStrcpy(tc->hcode, "#JN");           /* »°´È */
811    break;
812
813  case RAGYOGODAN:
814    EWStrcpy(tc->hcode, "#R5");           /* °ÒÄ¥¤ë */
815    break;
816
817  case KAMISHIMO:
818    EWStrcpy(tc->hcode, "#KS");           /* ¹ß¤ê¤ë¡¢Í¿¤¨¤ë */
819    break;
820
821  case KEIYODOSHIY:
822    EWStrcpy(tc->hcode, "#T13");          /* ¿¹²¤Æ¤À */
823    break;
824
825  case KEIYODOSHIN:
826    EWStrcpy(tc->hcode, "#T18");          /* ÊØÍø¤À¡¢ÀŤ«¤À */
827    break;
828
829  case FUKUSHIY:
830    EWStrcpy(tc->hcode, "#F12");          /* ¤½¤Ã¤È */
831    break;
832
833  case FUKUSHIN:
834    EWStrcpy(tc->hcode, "#F14");          /* Ë°¤¯¤Þ¤Ç */
835    break;
836  }
837  return(0);
838}
839
840static void
841makeDoushi(uiContext d)
842{
843  tourokuContext tc = (tourokuContext)d->modec;
844
845    switch(tc->katsuyou){
846    case  KAGYOU:
847      EWStrcpy( tc->hcode, "#K5" );     /* ÃÖ¤¯ */
848      break;
849    case  GAGYOU:
850      EWStrcpy( tc->hcode, "#G5" );     /* ¶Ä¤° */
851      break;
852    case  SAGYOU:
853      EWStrcpy( tc->hcode, "#S5" );     /* ÊÖ¤¹ */
854      break;
855    case  TAGYOU:
856      EWStrcpy( tc->hcode, "#T5" );     /* Àä¤Ä */
857      break;
858    case  NAGYOU:
859      EWStrcpy( tc->hcode, "#N5" );     /* »à¤Ì */
860      break;
861    case  BAGYOU:
862      EWStrcpy( tc->hcode, "#B5" );     /* ž¤Ö */
863      break;
864    case  MAGYOU:
865      EWStrcpy( tc->hcode, "#M5" );     /* ½»¤à */
866      break;
867    case  RAGYOU:
868      EWStrcpy( tc->hcode, "#R5" );     /* °ÒÄ¥¤ë */
869      break;
870    case  WAGYOU:
871      EWStrcpy( tc->hcode, "#W5" );     /* ¸À¤¦ */
872      break;
873    }
874}
875
876/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
877 * ¼­½ñ¤Î°ìÍ÷                                                                *
878 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
879
880static
881int uuTDicExitCatch(uiContext d, int retval, mode_context env)
882/* ARGSUSED */
883{
884  forichiranContext fc;
885  int cur;
886  tourokuContext tc;
887
888  d->nbytes = 0;
889
890  popCallback(d); /* °ìÍ÷¤ò pop */
891
892  fc = (forichiranContext)d->modec;
893  cur = fc->curIkouho;
894
895  popForIchiranMode(d);
896  popCallback(d);
897
898  tc = (tourokuContext)d->modec;
899
900  tc->workDic = cur;
901
902  return(tangoTouroku(d));
903}
904
905static
906int uuTDicQuitCatch(uiContext d, int retval, mode_context env)
907/* ARGSUSED */
908{
909  popCallback(d); /* °ìÍ÷¤ò pop */
910
911  popForIchiranMode(d);
912  popCallback(d);
913
914  return(dicTourokuHinshi(d));
915}
916
917int dicTourokuDictionary(uiContext d, int (*exitfunc )(...), int (*quitfunc )(...))
918{
919  tourokuContext tc = (tourokuContext)d->modec;
920  forichiranContext fc;
921  ichiranContext ic;
922  WCHAR_T **work;
923  unsigned inhibit = 0;
924  int retval, upnelem = 0;
925
926  retval = d->nbytes = 0;
927  d->status = 0;
928
929  for(work = tc->udic; *work; work++)
930    upnelem++;
931
932  if((retval = getForIchiranContext(d)) == NG) {
933    freeDic(tc);
934    defineEnd(d);
935    return(GLineNGReturnTK(d));
936  }
937  fc = (forichiranContext)d->modec;
938
939  /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */
940
941  fc->allkouho = tc->udic;
942
943  fc->curIkouho = 0;
944  if (!cannaconf.HexkeySelect)
945    inhibit |= ((unsigned char)NUMBERING | (unsigned char)CHARINSERT);
946  else
947    inhibit |= (unsigned char)CHARINSERT;
948
949   if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, upnelem,
950		 BANGOMAX, inhibit, 0, WITHOUT_LIST_CALLBACK,
951		 NO_CALLBACK,(int(*)(_uiContext*, int, _coreContextRec*))exitfunc, (int(*)(_uiContext*, int, _coreContextRec*))quitfunc, uiUtilIchiranTooSmall))
952                 == NG) {
953    if(fc->allkouho)
954      free(fc->allkouho);
955    popForIchiranMode(d);
956    popCallback(d);
957    defineEnd(d);
958    return(GLineNGReturnTK(d));
959  }
960
961  ic = (ichiranContext)d->modec;
962  ic->majorMode = CANNA_MODE_ExtendMode;
963  ic->minorMode = CANNA_MODE_TourokuDicMode;
964  currentModeInfo(d);
965
966  /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */
967  if(ic->tooSmall) {
968    d->status = AUX_CALLBACK;
969    return(retval);
970  }
971
972  makeGlineStatus(d);
973  /* d->status = ICHIRAN_EVERYTIME; */
974
975  return(retval);
976}
977
978/*
979 * ñ¸ìÅÐÏ¿¤ò¹Ô¤¦
980 */
981static
982int tangoTouroku(uiContext d)
983{
984  tourokuContext tc = (tourokuContext)d->modec;
985  WCHAR_T ktmpbuf[256];
986  WCHAR_T ttmpbuf[256];
987  WCHAR_T line[ROMEBUFSIZE], line2[ROMEBUFSIZE];
988  WCHAR_T xxxx[1024];
989  char dicname[1024];
990  extern int defaultContext;
991  int linecnt;
992
993  defineEnd(d);
994  if(tc->katsuyou || (EWStrncmp(tc->hcode, "#K5", 3) == 0)) {
995    WStrncpy(ttmpbuf, tc->tango_buffer, tc->tango_len - 1);
996    ttmpbuf[tc->tango_len - 1] = (WCHAR_T)0;
997    WStrncpy(ktmpbuf, tc->yomi_buffer, tc->yomi_len - 1);
998    ktmpbuf[tc->yomi_len - 1] = 0;
999  } else {
1000    WStrcpy(ttmpbuf, tc->tango_buffer);
1001    WStrcpy(ktmpbuf, tc->yomi_buffer);
1002  }
1003
1004  /* ¼­½ñ½ñ¤­¹þ¤ßÍѤΰì¹Ô¤òºî¤ë */
1005  WStraddbcpy(line, ktmpbuf, ROMEBUFSIZE);
1006  linecnt = WStrlen(line);
1007  line[linecnt] = (WCHAR_T)' ';
1008  linecnt++;
1009  WStrcpy(line + linecnt, tc->hcode);
1010  linecnt += WStrlen(tc->hcode);
1011  line[linecnt] = (WCHAR_T)' ';
1012  linecnt++;
1013  WStraddbcpy(line + linecnt, ttmpbuf, ROMEBUFSIZE - linecnt);
1014
1015  if(defaultContext == -1) {
1016    if((KanjiInit() < 0) || (defaultContext == -1)) {
1017      jrKanjiError = (char *)e_message[14];
1018      freeAndPopTouroku(d);
1019      return(GLineNGReturn(d));
1020    }
1021  }
1022  /* ¼­½ñ¤ËÅÐÏ¿¤¹¤ë */
1023  WCstombs(dicname, tc->udic[tc->workDic], sizeof(dicname));
1024
1025  if (RkwDefineDic(defaultContext, dicname, line) != 0) {
1026    /* Éʻ줬 #JCN ¤Î¤È¤­¤Ï¡¢ÅÐÏ¿¤Ë¼ºÇÔ¤·¤¿¤é¡¢#JN ¤È #CN ¤ÇÅÐÏ¿¤¹¤ë */
1027    if (EWStrncmp(tc->hcode, "#JCN", 4) == 0) {
1028      WCHAR_T xxx[3];
1029
1030      /* ¤Þ¤º #JN ¤ÇÅÐÏ¿¤¹¤ë */
1031      EWStrcpy(xxx, "#JN");
1032      WStraddbcpy(line, ktmpbuf, ROMEBUFSIZE);
1033      EWStrcat(line, " ");
1034      WStrcat(line, xxx);
1035      EWStrcat(line, " ");
1036      linecnt = WStrlen(line);
1037      WStraddbcpy(line + linecnt, ttmpbuf, ROMEBUFSIZE - linecnt);
1038
1039      if (RkwDefineDic(defaultContext, dicname, line) == 0) {
1040        /* #JN ¤ÇÅÐÏ¿¤Ç¤­¤¿¤È¤­¡¢¼¡¤Ë #CN ¤ÇÅÐÏ¿¤¹¤ë */
1041        EWStrcpy(xxx, "#CN");
1042        WStraddbcpy(line2, ktmpbuf, ROMEBUFSIZE);
1043        EWStrcat(line2, " ");
1044        WStrcat(line2, xxx);
1045        EWStrcat(line2, " ");
1046        linecnt = WStrlen(line2);
1047        WStraddbcpy(line2 + linecnt, ttmpbuf, ROMEBUFSIZE - linecnt);
1048
1049        if (RkwDefineDic(defaultContext, dicname, line2) == 0) {
1050          goto success;
1051        }
1052
1053        /* #CN ¤ÇÅÐÏ¿¤Ç¤­¤Ê¤«¤Ã¤¿¤È¤­¡¢#JN ¤òºï½ü¤¹¤ë */
1054        if (RkwDeleteDic(defaultContext, dicname, line) == NG) {
1055          /* #JN ¤¬ºï½ü¤Ç¤­¤Ê¤«¤Ã¤¿¤é¡¢"¼ºÇÔ¤·¤Þ¤·¤¿" */
1056          if (errno == EPIPE)
1057            jrKanjiPipeError();
1058          WStrcpy(d->genbuf, message[20]);
1059          goto close;
1060        }
1061      }
1062    }
1063    /* #JCN °Ê³°¤Î¤È¤­
1064       #JN ¤¬ÅÐÏ¿¤Ç¤­¤Ê¤«¤Ã¤¿¤È¤­
1065       #CN ¤¬ÅÐÏ¿¤Ç¤­¤º¡¢#JN ¤¬ºï½ü¤Ç¤­¤¿¤È¤­ */
1066    if (errno == EPIPE)
1067      jrKanjiPipeError();
1068    WStrcpy(d->genbuf, message[15]);
1069    goto close;
1070  }
1071
1072 success:
1073  if (cannaconf.auto_sync) {
1074    RkwSync(defaultContext, dicname);
1075  }
1076  /* ÅÐÏ¿¤Î´°Î»¤òɽ¼¨¤¹¤ë */
1077  WSprintf(d->genbuf, message[16], message[17], tc->tango_buffer);
1078  WSprintf(xxxx, message[18], message[19], tc->yomi_buffer);
1079  WStrcat(d->genbuf, xxxx);
1080
1081 close:
1082  makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf));
1083
1084  freeAndPopTouroku(d);
1085  currentModeInfo(d);
1086
1087  return(0); /* ñ¸ìÅÐÏ¿´°Î» */
1088}
1089#endif /* NO_EXTEND_MENU */
1090