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: uldelete.c 14875 2005-11-12 21:25:31Z bonefish $";
30#endif
31
32
33#if !defined(NO_EXTEND_MENU) && !defined(WIN)
34#include	<errno.h>
35#include 	"canna.h"
36#include "RK.h"
37#include "RKintern.h"
38
39static int uuSYomiEveryTimeCatch(uiContext d, int retval, mode_context env);
40static int uuSYomiExitCatch(uiContext d, int retval, mode_context env);
41static int uuSYomiQuitCatch(uiContext d, int retval, mode_context env);
42static int dicSakujoYomi(uiContext d);
43static int acDicSakujoYomi(uiContext d, int dn, mode_context dm);
44static int acDicSakujoDictionary(uiContext d, int dn, mode_context dm);
45static WCHAR_T **getMountDicName(uiContext d, int *num_return);
46static void CloseDeleteContext(tourokuContext tc);
47static int getEffectDic(tourokuContext tc);
48static int uuSTangoExitCatch(uiContext d, int retval, mode_context env);
49static int uuSTangoQuitCatch(uiContext d, int retval, mode_context env);
50static int dicSakujoBgnBun(uiContext d, RkStat *st);
51static int dicSakujoEndBun(uiContext d);
52static int dicSakujoTango(uiContext d);
53static int getDeleteDic(mountContext mc);
54static int uuSDicExitCatch(uiContext d, int retval, mode_context env);
55static int uuSDicQuitCatch(uiContext d, int retval, mode_context env);
56static int dicSakujoDictionary(uiContext d);
57static int uuSDeleteYesCatch(uiContext d, int retval, mode_context env);
58static int uuSDeleteQuitCatch(uiContext d, int retval, mode_context env);
59static int uuSDeleteNoCatch(uiContext d, int retval, mode_context env);
60static int dicSakujoDo(uiContext d);
61
62extern int RkwGetServerVersion (int *, int *);
63extern int RkwChmodDic (int, char *, int);
64
65static int dicSakujoYomi (uiContext),
66           dicSakujoEndBun (uiContext),
67           dicSakujoTango (uiContext),
68           dicSakujoDictionary (uiContext),
69           dicSakujoDo (uiContext);
70
71void
72freeWorkDic3(tourokuContext tc)
73{
74  if (tc->workDic3) {
75    free(tc->workDic3);
76    tc->workDic3 = (deldicinfo *)0;
77  }
78}
79
80void
81freeWorkDic(tourokuContext tc)
82{
83  if (tc->workDic2) {
84    free(tc->workDic2);
85    tc->workDic2 = (deldicinfo *)0;
86  }
87  freeWorkDic3(tc);
88}
89
90void
91freeDic(tourokuContext tc)
92{
93  if (tc->udic) {
94    WCHAR_T **p = tc->udic;
95
96    for ( ; *p; p++) {
97      WSfree(*p);
98    }
99    free(tc->udic);
100  }
101  freeWorkDic(tc);
102}
103
104void
105freeAndPopTouroku(uiContext d)
106{
107  tourokuContext tc = (tourokuContext)d->modec;
108
109  freeDic(tc);
110  popTourokuMode(d);
111  popCallback(d);
112}
113
114/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
115 * ñ¸ìºï½ü¤ÎÆɤߤÎÆþÎÏ                                                      *
116 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
117static
118int uuSYomiEveryTimeCatch(uiContext d, int retval, mode_context env)
119/* ARGSUSED */
120{
121  int len, echoLen, revPos;
122  WCHAR_T tmpbuf[ROMEBUFSIZE];
123
124  retval = 0;
125  if((echoLen = d->kanji_status_return->length) < 0)
126    return(retval);
127
128  if (echoLen == 0) {
129    d->kanji_status_return->revPos = 0;
130    d->kanji_status_return->revLen = 0;
131  }
132
133  /* ¼è¤ê¤¢¤¨¤º echoStr ¤¬ d->genbuf ¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç copy ¤·¤Æ¤ª¤¯ */
134  WStrncpy(tmpbuf, d->kanji_status_return->echoStr, echoLen);
135
136  revPos = MBstowcs(d->genbuf, "\306\311\244\337?[", ROMEBUFSIZE);
137				/* ÆÉ¤ß */
138  WStrncpy(d->genbuf + revPos, tmpbuf, echoLen);
139  *(d->genbuf + revPos + echoLen) = (WCHAR_T) ']';
140  len = revPos + echoLen + 1;
141  *(d->genbuf + len) = (WCHAR_T) '\0';
142  d->kanji_status_return->gline.line = d->genbuf;
143  d->kanji_status_return->gline.length = len;
144  if (d->kanji_status_return->revLen) {
145    d->kanji_status_return->gline.revPos =
146      d->kanji_status_return->revPos + revPos;
147    d->kanji_status_return->gline.revLen = d->kanji_status_return->revLen;
148  }
149  else { /* ȿžÎΰ褬¤Ê¤¤¾ì¹ç */
150    d->kanji_status_return->gline.revPos = len - 1;
151    d->kanji_status_return->gline.revLen = 1;
152  }
153  d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo);
154  d->kanji_status_return->info |= KanjiGLineInfo;
155  echostrClear(d);
156  checkGLineLen(d);
157
158  return retval;
159}
160
161static
162int uuSYomiExitCatch(uiContext d, int retval, mode_context env)
163/* ARGSUSED */
164{
165  tourokuContext tc;
166
167  popCallback(d); /* Æɤߤò pop */
168
169  tc = (tourokuContext)d->modec;
170
171  WStrncpy(tc->yomi_buffer, d->buffer_return, retval);
172  tc->yomi_buffer[retval] = (WCHAR_T)'\0';
173  tc->yomi_len = WStrlen(tc->yomi_buffer);
174
175  return dicSakujoTango(d);
176}
177
178static
179int uuSYomiQuitCatch(uiContext d, int retval, mode_context env)
180/* ARGSUSED */
181{
182  popCallback(d); /* Æɤߤò pop */
183
184  clearYomi(d);
185
186  freeAndPopTouroku(d);
187  GlineClear(d);
188  currentModeInfo(d);
189
190  return prevMenuIfExist(d);
191}
192
193static
194int dicSakujoYomi(uiContext d)
195{
196  yomiContext yc;
197
198  d->status = 0;
199
200  yc = GetKanjiString(d, (WCHAR_T *)NULL, 0,
201	       CANNA_NOTHING_RESTRICTED,
202	       (int)CANNA_YOMI_CHGMODE_INHIBITTED,
203	       (int)CANNA_YOMI_END_IF_KAKUTEI,
204	       (CANNA_YOMI_INHIBIT_HENKAN | CANNA_YOMI_INHIBIT_ASHEX |
205	       CANNA_YOMI_INHIBIT_ASBUSHU),
206	       uuSYomiEveryTimeCatch, uuSYomiExitCatch,
207	       uuSYomiQuitCatch);
208  if (yc == (yomiContext)0) {
209    deleteEnd(d);
210    return NoMoreMemory();
211  }
212  yc->majorMode = CANNA_MODE_ExtendMode;
213  yc->minorMode = CANNA_MODE_DeleteDicMode;
214  currentModeInfo(d);
215
216  return 0;
217}
218
219static
220int acDicSakujoYomi(uiContext d, int dn, mode_context dm)
221/* ARGSUSED */
222{
223  popCallback(d);
224  return dicSakujoYomi(d);
225}
226
227static
228int acDicSakujoDictionary(uiContext d, int dn, mode_context dm)
229/* ARGSUSED */
230{
231  popCallback(d);
232  return dicSakujoDictionary(d);
233}
234
235/*
236 * ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤«¤é WRITE ¸¢¤Î¤¢¤ë¤â¤Î¤ò¼è¤ê½Ð¤¹
237 */
238static
239WCHAR_T **
240getMountDicName(uiContext d, int *num_return)
241/* ARGSUSED */
242{
243  int nmmdic, check, majv, minv;
244  struct dicname *p;
245  WCHAR_T **tourokup, **tp;
246  extern int defaultContext;
247
248  if (defaultContext < 0) {
249    if ((KanjiInit() < 0) || (defaultContext < 0)) {
250#ifdef STANDALONE
251#ifndef WIN
252      jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó";
253#else
254      jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363";
255#endif
256#else
257#ifndef WIN
258      jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó";
259#else
260      jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\245\265"
261	"\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336"
262	"\244\273\244\363";    /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó */
263#endif
264#endif /* STANDALONE */
265      return 0;
266    }
267  }
268
269  /* ¥µ¡¼¥Ð¤Î Version ¤Ë¤è¤Ã¤Æ¼è¤ê½Ð¤¹¼­½ñ¤òʬ¤±¤ë */
270  RkwGetServerVersion(&majv, &minv);
271
272  if (canna_version(majv, minv) < canna_version(3, 2)) {
273    /* Version3.2 ¤è¤êÁ°¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */
274    for (nmmdic = 0, p = kanjidicnames; p; p = p->next) {
275      if (p->dicflag == DIC_MOUNTED && p->dictype == DIC_USER) {
276        nmmdic++;
277      }
278    }
279  }
280  else {
281    /* Version3.2 °Ê¹ß¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */
282    for (nmmdic = 0, p = kanjidicnames ; p ; p = p->next) {
283      if (p->dicflag == DIC_MOUNTED) {
284        check = RkwChmodDic(defaultContext, p->name, 0);
285        if (check >= 0 && (check & RK_ENABLE_WRITE)) {
286          nmmdic++;
287        }
288      }
289    }
290  }
291
292  /* return BUFFER ¤Î alloc */
293  if ((tourokup = (WCHAR_T **)calloc(nmmdic + 1, sizeof(WCHAR_T *)))
294                                                  == (WCHAR_T **)NULL) {
295    /* + 1 ¤Ê¤Î¤ÏÂǤÁ»ß¤á¥Þ¡¼¥¯¤ò¤¤¤ì¤ë¤¿¤á */
296    jrKanjiError = "malloc (getMountDicName) \244\307\244\255\244\336\244\273"
297	"\244\363\244\307\244\267\244\277";
298                       /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
299    return 0;
300  }
301
302  if (canna_version(majv, minv) < canna_version(3, 2)) {
303    /* Version3.2 ¤è¤êÁ°¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */
304    for (tp = tourokup + nmmdic, p = kanjidicnames ; p ; p = p->next) {
305      if (p->dicflag == DIC_MOUNTED && p->dictype == DIC_USER) {
306        *--tp = WString(p->name);
307      }
308    }
309  }
310  else {
311    /* Version3.2 °Ê¹ß¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */
312    for (tp = tourokup + nmmdic, p = kanjidicnames ; p ; p = p->next) {
313      if (p->dicflag == DIC_MOUNTED) {
314        check = RkwChmodDic(defaultContext, p->name, 0);
315        if (check >= 0 && (check & RK_ENABLE_WRITE)) {
316          *--tp = WString(p->name);
317        }
318      }
319    }
320  }
321  tourokup[nmmdic] = (WCHAR_T *)0;
322  *num_return = nmmdic;
323
324  return tourokup;
325}
326
327int dicSakujo(uiContext d)
328{
329  WCHAR_T **mp, **p;
330  tourokuContext tc;
331  int num;
332  yomiContext yc = (yomiContext)d->modec;
333
334  if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) {
335    return NothingChangedWithBeep(d);
336  }
337  d->status = 0;
338
339  /* ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤Ç WRITE ¸¢¤Î¤¢¤ë¤â¤Î¤ò¼è¤Ã¤Æ¤¯¤ë */
340  if ((mp = getMountDicName(d, &num)) != 0) {
341    if (getTourokuContext(d) != NG) {
342      tc = (tourokuContext)d->modec;
343
344      tc->udic = mp;
345      if(!*mp) {
346        makeGLineMessageFromString(d, "\303\261\270\354\272\357\275\374"
347	"\262\304\307\275\244\312\274\255\275\361\244\254\302\270\272\337"
348	"\244\267\244\336\244\273\244\363");
349			/* ñ¸ìºï½ü²Äǽ¤Ê¼­½ñ¤¬Â¸ºß¤·¤Þ¤»¤ó */
350
351        freeAndPopTouroku(d);
352        deleteEnd(d);
353        currentModeInfo(d);
354        return 0;
355      }
356      tc->nudic = num;
357      return dicSakujoYomi(d);
358    }
359    for ( p = mp; *p; p++) {
360      WSfree(*p);
361    }
362    free(mp);
363  }
364  deleteEnd(d);
365  return GLineNGReturn(d);
366}
367
368/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
369 * ñ¸ìºï½ü¤Îñ¸ì¤ÎÆþÎÏ                                                      *
370 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
371
372static void
373CloseDeleteContext(tourokuContext tc)
374{
375  if(tc->delContext >= 0) {
376    if (RkwCloseContext(tc->delContext) < 0) {
377      if (errno == EPIPE) {
378	jrKanjiPipeError();
379      }
380    }
381  }
382#ifdef DEBUG
383  else
384    printf("ERROR: delContext < 0\n");
385#endif
386}
387
388/*
389 * »ØÄꤵ¤ì¤¿Ã±¸ì¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤ò¼è¤ê½Ð¤¹
390 */
391static
392int getEffectDic(tourokuContext tc)
393{
394  int workContext, currentkouho, nbunsetsu, nelem = tc->nudic;
395  WCHAR_T **mdic, **cands, **work;
396  char dicname[1024], tmpbuf[64];
397  RkLex lex[5];
398  deldicinfo *dic;
399
400  dic = (deldicinfo *)malloc((nelem + 1) * sizeof(deldicinfo));
401  if (dic == (deldicinfo *)NULL) {
402#ifndef WIN
403    jrKanjiError = "malloc (getEffectDic) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿";
404#else
405    jrKanjiError = "malloc (getEffectDic) \244\307\244\255\244\336\244\273"
406	"\244\363\244\307\244\267\244\277";
407#endif
408    return NG;
409  }
410  tc->workDic2 = dic;
411
412  if ((workContext = RkwCreateContext()) == NG) {
413    if (errno == EPIPE) {
414      jrKanjiPipeError();
415    }
416#ifndef WIN
417    jrKanjiError = "¼­½ñ¸¡º÷ÍÑ¥³¥ó¥Æ¥¯¥¹¥È¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿";
418#else
419    jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\245\263\245\363"
420	"\245\306\245\257\245\271\245\310\244\362\272\356\300\256\244\307"
421	"\244\255\244\336\244\273\244\363\244\307\244\267\244\277";
422#endif
423    return NG;
424  }
425
426#ifdef STANDALONE
427  if ((RkwSetDicPath(workContext, "iroha")) == NG) {
428#ifndef WIN
429    jrKanjiError = "¼­½ñ¥Ç¥£¥ì¥¯¥È¥ê¤òÀßÄê¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿";
430#else
431    jrKanjiError = "\274\255\275\361\245\307\245\243\245\354\245\257\245\310\245\352\244\362\300\337\304\352\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277";
432#endif
433    CloseDeleteContext(tc);
434    return NG;
435  }
436#endif /* STANDALONE */
437
438  for (mdic = tc->udic; *mdic; mdic++) {
439    WCstombs(dicname, *mdic, sizeof(dicname));
440    if (RkwMountDic(workContext, dicname, 0) == NG) {
441      if (errno == EPIPE) {
442        jrKanjiPipeError();
443      }
444      jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\245\263\245\363"
445	"\245\306\245\257\245\271\245\310\244\313\274\255\275\361\244\362"
446	"\245\336\245\246\245\363\245\310\244\307\244\255\244\336\244\273"
447	"\244\363\244\307\244\267\244\277";
448              /* ¼­½ñ¸¡º÷ÍÑ¥³¥ó¥Æ¥¯¥¹¥È¤Ë¼­½ñ¤ò¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
449      RkwCloseContext(workContext);
450      return NG;
451    }
452
453    nbunsetsu = RkwBgnBun(workContext, tc->yomi_buffer, tc->yomi_len, 0);
454    if (nbunsetsu == 1) {
455      if ((cands = getIchiranList(workContext, &nelem, &currentkouho)) != 0) {
456        work = cands;
457        while (*work) {
458          if (WStrcmp(*work, tc->tango_buffer) == 0) {
459            dic->name = *mdic;
460            if (RkwXfer(workContext, currentkouho) == NG) {
461              if (errno == EPIPE)
462                jrKanjiPipeError();
463              jrKanjiError = "\245\253\245\354\245\363\245\310\270\365\312\344"
464			     "\244\362\274\350\244\352\275\320\244\273\244\336"
465			     "\244\273\244\363\244\307\244\267\244\277";
466               /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */
467              freeGetIchiranList(cands);
468              RkwEndBun(workContext, 0);
469              RkwUnmountDic(workContext, dicname);
470              RkwCloseContext(workContext);
471              return NG;
472            }
473            if (RkwGetLex(workContext, lex, 5) <= 0) {
474              if (errno == EPIPE)
475                jrKanjiPipeError();
476              jrKanjiError = "\267\301\302\326\301\307\276\360\312\363\244\362"
477		"\274\350\244\352\275\320\244\273\244\336\244\273\244\363"
478		"\244\307\244\267\244\277";
479                /* ·ÁÂÖÁǾðÊó¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */
480              freeGetIchiranList(cands);
481              RkwEndBun(workContext, 0);
482              RkwUnmountDic(workContext, dicname);
483              RkwCloseContext(workContext);
484              return NG;
485            }
486            sprintf((char *)tmpbuf, "#%d#%d", lex[0].rownum, lex[0].colnum);
487            MBstowcs(dic->hcode, tmpbuf, 16);
488            dic++;
489            break;
490          }
491          work++;
492        }
493        freeGetIchiranList(cands);
494      }
495    }
496
497    if (RkwEndBun(workContext, 0) == NG) {
498      if (errno == EPIPE) {
499        jrKanjiPipeError();
500      }
501      jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316"
502	"\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267"
503	"\244\277";
504       /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */
505      RkwUnmountDic(workContext, dicname);
506      RkwCloseContext(workContext);
507      return NG;
508    }
509
510    if (RkwUnmountDic(workContext, dicname) == NG) {
511      if (errno == EPIPE) {
512        jrKanjiPipeError();
513      }
514      jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\244\316\274\255"
515	"\275\361\244\362\245\242\245\363\245\336\245\246\245\363\245\310"
516	"\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277";
517       /* ¼­½ñ¸¡º÷ÍѤμ­½ñ¤ò¥¢¥ó¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
518      RkwCloseContext(workContext);
519      return NG;
520    }
521  }
522
523  if (RkwCloseContext(workContext) < 0) {
524    if (errno == EPIPE) {
525      jrKanjiPipeError();
526    }
527    jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\244\316\245\263"
528	"\245\363\245\306\245\257\245\271\245\310\244\362\245\257\245\355"
529	"\241\274\245\272\244\307\244\255\244\336\244\273\244\363\244\307"
530	"\244\267\244\277";
531     /* ¼­½ñ¸¡º÷ÍѤΥ³¥ó¥Æ¥¯¥¹¥È¤ò¥¯¥í¡¼¥º¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
532    return NG;
533  }
534
535  dic->name = (WCHAR_T *)0;
536  tc->nworkDic2 = dic - tc->workDic2;
537  return 0;
538}
539
540static
541int uuSTangoExitCatch(uiContext d, int retval, mode_context env)
542/* ARGSUSED */
543{
544  forichiranContext fc;
545  tourokuContext tc;
546
547  popCallback(d); /* °ìÍ÷¤ò pop */
548
549  fc = (forichiranContext)d->modec;
550  freeGetIchiranList(fc->allkouho);
551
552  popForIchiranMode(d);
553  popCallback(d);
554
555  tc = (tourokuContext)d->modec;
556  WStrcpy(tc->tango_buffer, d->buffer_return);
557  tc->tango_buffer[d->nbytes] = 0;
558  tc->tango_len = d->nbytes;
559
560  d->nbytes = 0;
561
562  if (getEffectDic(tc) == NG) {
563    freeDic(tc);
564    deleteEnd(d);
565    return GLineNGReturnTK(d);
566  }
567
568  return dicSakujoDictionary(d);
569}
570
571static
572int uuSTangoQuitCatch(uiContext d, int retval, mode_context env)
573/* ARGSUSED */
574{
575  forichiranContext fc;
576
577  popCallback(d); /* °ìÍ÷¤ò pop */
578
579  fc = (forichiranContext)d->modec;
580  freeGetIchiranList(fc->allkouho);
581
582  popForIchiranMode(d);
583  popCallback(d);
584
585  clearYomi(d);
586  return dicSakujoYomi(d);
587}
588
589/*
590 * Æɤߤò»ØÄꤵ¤ì¤¿¼­½ñ¤«¤éÊÑ´¹¤¹¤ë
591 */
592static
593int dicSakujoBgnBun(uiContext d, RkStat *st)
594{
595  tourokuContext tc = (tourokuContext)d->modec;
596  int nbunsetsu;
597  char dicname[1024];
598  WCHAR_T **mdic;
599
600  if(!tc) {
601#if !defined(DEBUG) && !defined(WIN)
602    printf("tc = NULL\n");
603#endif
604  }
605  if(!tc->udic) {
606#if !defined(DEBUG) && !defined(WIN)
607    printf("tc->udic = NULL\n");
608#endif
609  }
610
611  if((tc->delContext = RkwCreateContext())== NG) {
612    if (errno == EPIPE) {
613      jrKanjiPipeError();
614    }
615    jrKanjiError = "\303\261\270\354\272\357\275\374\315\321\244\316\245\263"
616	"\245\363\245\306\245\257\245\271\245\310\244\362\272\356\300\256"
617	"\244\307\244\255\244\336\244\273\244\363";
618     /* ñ¸ìºï½üÍѤΥ³¥ó¥Æ¥¯¥¹¥È¤òºîÀ®¤Ç¤­¤Þ¤»¤ó */
619    return(NG);
620  }
621
622#ifdef STANDALONE
623  if ((RkwSetDicPath(tc->delContext, "iroha")) == NG) {
624#ifndef WIN
625    jrKanjiError = "¼­½ñ¥Ç¥£¥ì¥¯¥È¥ê¤òÀßÄê¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿";
626#else
627    jrKanjiError = "\274\255\275\361\245\307\245\243\245\354\245\257\245\310\245\352\244\362\300\337\304\352\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277";
628#endif
629    CloseDeleteContext(tc);
630    return NG;
631  }
632#endif /* STANDALONE */
633
634  for (mdic = tc->udic; *mdic; mdic++) {
635    WCstombs(dicname, *mdic, sizeof(dicname));
636    if (RkwMountDic(tc->delContext, dicname, 0) == NG) {
637      if (errno == EPIPE) {
638        jrKanjiPipeError();
639      }
640      jrKanjiError = "\303\261\270\354\272\357\275\374\315\321\244\316\274"
641	"\255\275\361\244\362\245\336\245\246\245\363\245\310\244\307\244"
642	"\255\244\336\244\273\244\363\244\307\244\267\244\277";
643        /* ñ¸ìºï½üÍѤμ­½ñ¤ò¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
644      CloseDeleteContext(tc);
645      return(NG);
646    }
647  }
648
649  if((nbunsetsu = RkwBgnBun(tc->delContext, tc->yomi_buffer, tc->yomi_len, 0))
650	== -1) {
651    if (errno == EPIPE) {
652      jrKanjiPipeError();
653    }
654    jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\313"
655	"\274\272\307\324\244\267\244\336\244\267\244\277";
656      /* ¤«¤Ê´Á»úÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */
657    CloseDeleteContext(tc);
658    return(NG);
659  }
660
661  if(RkwGetStat(tc->delContext, st) == -1) {
662    RkwEndBun(tc->delContext, 0); /* 0:³Ø½¬¤·¤Ê¤¤ */
663    if(errno == EPIPE)
664      jrKanjiPipeError();
665    jrKanjiError = "\245\271\245\306\245\244\245\277\245\271\244\362\274\350"
666	"\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267"
667	"\244\277";
668               /* ¥¹¥Æ¥¤¥¿¥¹¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */
669    /* ¥¢¥ó¥Þ¥¦¥ó¥È¤·¤Æ¤Ê¤¤ */
670    CloseDeleteContext(tc);
671    return(NG);
672  }
673
674  return(nbunsetsu);
675}
676
677static
678int dicSakujoEndBun(uiContext d)
679{
680  tourokuContext tc = (tourokuContext)d->modec;
681
682  if(RkwEndBun(tc->delContext, 0) == -1) {	/* 0:³Ø½¬¤·¤Ê¤¤ */
683    if(errno == EPIPE)
684      jrKanjiPipeError();
685    jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316"
686	"\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267"
687	"\244\277";
688       /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */
689    return(NG);
690  }
691
692  return(0);
693}
694
695static
696int dicSakujoTango(uiContext d)
697{
698  tourokuContext tc = (tourokuContext)d->modec;
699  forichiranContext fc;
700  ichiranContext ic;
701  WCHAR_T **allDelCands;
702  BYTE inhibit = 0;
703  int nbunsetsu, nelem, currentkouho, retval = 0;
704  RkStat st;
705
706  if(tc->yomi_len < 1) {
707    return canna_alert(d, "\306\311\244\337\244\362\306\376\316\317\244\267"
708	"\244\306\244\257\244\300\244\265\244\244", acDicSakujoYomi);
709		/* ÆɤߤòÆþÎϤ·¤Æ¤¯¤À¤µ¤¤ */
710  }
711
712  if((nbunsetsu = dicSakujoBgnBun(d, &st)) == NG) {
713    freeDic(tc);
714    deleteEnd(d);
715    return(GLineNGReturnTK(d));
716  }
717  if((nbunsetsu != 1) || (st.maxcand == 0)) {
718    /* ¸õÊ䤬¤Ê¤¤ */
719    if(dicSakujoEndBun(d) == NG) {
720      freeDic(tc);
721      CloseDeleteContext(tc);
722      deleteEnd(d);
723      return(GLineNGReturnTK(d));
724    }
725
726    makeGLineMessageFromString(d, "\244\263\244\316\306\311\244\337\244\307"
727	"\305\320\317\277\244\265\244\354\244\277\303\261\270\354\244\317"
728	"\302\270\272\337\244\267\244\336\244\273\244\363");
729         /* ¤³¤ÎÆɤߤÇÅÐÏ¿¤µ¤ì¤¿Ã±¸ì¤Ï¸ºß¤·¤Þ¤»¤ó */
730    CloseDeleteContext(tc);
731    freeAndPopTouroku(d);
732    deleteEnd(d);
733    currentModeInfo(d);
734    return(0);
735  }
736
737  /* ¤¹¤Ù¤Æ¤Î¸õÊä¤ò¼è¤ê½Ð¤¹ */
738  if((allDelCands =
739      getIchiranList(tc->delContext, &nelem, &currentkouho)) == 0) {
740    freeDic(tc);
741    dicSakujoEndBun(d);
742    CloseDeleteContext(tc);
743    deleteEnd(d);
744    return(GLineNGReturnTK(d));
745  }
746
747  if (dicSakujoEndBun(d) == NG) {
748    freeDic(tc);
749    CloseDeleteContext(tc);
750    deleteEnd(d);
751    return GLineNGReturnTK(d);
752  }
753  CloseDeleteContext(tc);
754
755  if(getForIchiranContext(d) == NG) {
756    freeDic(tc);
757    freeGetIchiranList(allDelCands);
758    deleteEnd(d);
759    return(GLineNGReturnTK(d));
760  }
761
762  fc = (forichiranContext)d->modec;
763  fc->allkouho = allDelCands;
764
765  if (!cannaconf.HexkeySelect)
766    inhibit |= ((BYTE)NUMBERING | (BYTE)CHARINSERT);
767  else
768    inhibit |= (BYTE)CHARINSERT;
769
770  fc->curIkouho = currentkouho;	/* ¸½ºß¤Î¥«¥ì¥ó¥È¸õÊäÈÖ¹æ¤òÊݸ¤¹¤ë */
771  currentkouho = 0;	/* ¥«¥ì¥ó¥È¸õÊ䤫¤é²¿ÈÖÌܤò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë¤« */
772
773  /* ¸õÊä°ìÍ÷¤Ë°Ü¹Ô¤¹¤ë */
774  if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, nelem, BANGOMAX,
775               inhibit, currentkouho, WITHOUT_LIST_CALLBACK,
776	       NO_CALLBACK, uuSTangoExitCatch,
777	       uuSTangoQuitCatch, uiUtilIchiranTooSmall)) == NG) {
778    freeDic(tc);
779    freeGetIchiranList(fc->allkouho);
780    deleteEnd(d);
781    return(GLineNGReturnTK(d));
782  }
783
784  ic = (ichiranContext)d->modec;
785  ic->majorMode = CANNA_MODE_ExtendMode;
786  ic->minorMode = CANNA_MODE_DeleteDicMode;
787  currentModeInfo(d);
788
789  if(ic->tooSmall) {
790    d->status = AUX_CALLBACK;
791    return(retval);
792  }
793
794  makeGlineStatus(d);
795  /* d->status = EVERYTIME_CALLBACK; */
796
797  return(retval);
798}
799
800/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
801 * ñ¸ìºï½ü¤Î¼­½ñ°ìÍ÷                                                        *
802 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
803
804static
805int getDeleteDic(mountContext mc)
806{
807  tourokuContext tc = (tourokuContext)mc->next;
808  int i, num = 0;
809  deldicinfo *dic, *srcp;
810
811  /* ¤Þ¤º¡¢Ã±¸ìºï½ü¤¹¤ë¼­½ñ¤Î¿ô¤ò¿ô¤¨¤ë */
812  for (i = 0; mc->mountList[i]; i++) {
813    if (mc->mountOldStatus[i] != mc->mountNewStatus[i]) {
814      num++;
815    }
816  }
817
818  dic = (deldicinfo *)malloc((num + 1) * sizeof(deldicinfo));
819  if (dic != (deldicinfo *)NULL) {
820    tc->workDic3 = dic;
821
822    /* ¤É¤Î¼­½ñ¤«¤éñ¸ì¤òºï½ü¤¹¤ë¤« */
823    srcp = tc->workDic2;
824    for (i = 0; mc->mountList[i]; i++, srcp++) {
825      if (mc->mountOldStatus[i] != mc->mountNewStatus[i]) {
826        *dic++ = *srcp;
827      }
828    }
829    dic->name = (WCHAR_T *)0;
830    tc->nworkDic3 = dic - tc->workDic3;
831    return 0;
832  }
833  jrKanjiError ="malloc (uuSDicExitCatch) \244\307\244\255\244\336\244\273"
834	"\244\363\244\307\244\267\244\277";
835                 /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
836  return NG;
837}
838
839
840static
841int uuSDicExitCatch(uiContext d, int retval, mode_context env)
842/* ARGSUSED */
843{
844  mountContext mc;
845  tourokuContext tc;
846
847  d->nbytes = 0;
848
849  popCallback(d); /* °ìÍ÷¤ò pop */
850
851  mc = (mountContext)d->modec;
852
853  if (getDeleteDic(mc) == NG) {
854    popMountMode(d);
855    popCallback(d);
856    tc = (tourokuContext)d->modec;
857    freeDic(tc);
858    deleteEnd(d);
859    return GLineNGReturnTK(d);
860  }
861
862  popMountMode(d);
863  popCallback(d);
864
865  tc = (tourokuContext)d->modec;
866  /* ¼­½ñ¤¬ÁªÂò¤µ¤ì¤Ê¤«¤Ã¤¿¤È¤­¤Ï¡¢¥á¥Ã¥»¡¼¥¸¤ò½Ð¤·¡¢
867     ²¿¤«¤Î¥­¡¼¤¬ÆþÎϤµ¤ì¤¿¤é¡¢ ¼­½ñÁªÂò¤ËÌá¤ë¡£     */
868  if (tc->nworkDic3 == 0) {
869    return canna_alert(d, "\274\255\275\361\244\362\301\252\302\362\244\267"
870	"\244\306\244\257\244\300\244\265\244\244", acDicSakujoDictionary);
871		/* ¼­½ñ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤ */
872  }
873
874  return dicSakujoDo(d);
875}
876
877static
878int uuSDicQuitCatch(uiContext d, int retval, mode_context env)
879/* ARGSUSED */
880{
881  popCallback(d); /* °ìÍ÷¤ò pop */
882
883  popMountMode(d);
884  popCallback(d);
885
886  freeWorkDic((tourokuContext)d->modec);
887  return dicSakujoTango(d);
888}
889
890static
891int dicSakujoDictionary(uiContext d)
892{
893  tourokuContext tc = (tourokuContext)d->modec;
894  mountContext mc;
895  ichiranContext ic;
896  deldicinfo *work;
897  BYTE inhibit = 0;
898  int retval, i, upnelem = tc->nworkDic2;
899  char *dicLbuf, **dicLp, *wptr;
900  BYTE *soldp, *snewp;
901  WCHAR_T *xxxx[100];
902
903  retval = d->nbytes = 0;
904  d->status = 0;
905
906  if (upnelem == 1) {
907    work
908      = (deldicinfo *)malloc((1 /* upnelem(==1) */ + 1) * sizeof(deldicinfo));
909    if (work != (deldicinfo *)NULL) {
910      tc->workDic3 = work;
911      *work++ = *tc->workDic2; /* ¹½Â¤ÂΤÎÂåÆþ */
912      work->name = (WCHAR_T *)0;
913      tc->nworkDic3 = 1; /* work - tc->workDic3 == 1 */
914      return dicSakujoDo(d);
915    }
916    jrKanjiError = "malloc (dicSakujoDictionary) \244\307\244\255\244\336"
917	"\244\273\244\363\244\307\244\267\244\277";
918                 /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
919    freeDic(tc);
920    deleteEnd(d);
921    return GLineNGReturnTK(d);
922  }
923
924  if ((dicLbuf = (char *)malloc(ROMEBUFSIZE)) != (char *)NULL) {
925    if ((dicLp = (char **)calloc(upnelem + 1, sizeof(char *)))
926                                               != (char **)NULL) {
927      wptr = dicLbuf;
928      for (work = tc->workDic2; work->name; work++) {
929        i = WCstombs(wptr, work->name, ROMEBUFSIZE);
930        wptr += i;
931        *wptr++ = '\0';
932      }
933      for (wptr = dicLbuf, i = 0; i < upnelem ; i++) {
934        dicLp[i] = wptr;
935        while (*wptr++)
936          /* EMPTY */
937          ;
938      }
939      dicLp[i] = (char *)NULL;
940
941      /* ¸½ºß¤Î¾õÂ֤Ϥ¹¤Ù¤Æ off ¤Ë¤·¤Æ¤ª¤¯ */
942      if ((soldp = (BYTE *)calloc(upnelem + 1, sizeof(BYTE)))
943                                               != (BYTE *)NULL) {
944        if ((snewp = (BYTE *)calloc(upnelem + 1, sizeof(BYTE)))
945                                                 != (BYTE *)NULL) {
946          if ((retval = getMountContext(d)) != NG) {
947            mc = (mountContext)d->modec;
948            mc->mountOldStatus = soldp;
949            mc->mountNewStatus = snewp;
950            mc->mountList = dicLp;
951
952            /* selectOnOff ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */
953
954            mc->curIkouho = 0;
955            if (!cannaconf.HexkeySelect)
956              inhibit |= ((BYTE)NUMBERING | (BYTE)CHARINSERT);
957            else
958              inhibit |= (BYTE)CHARINSERT;
959
960            retval = setWStrings(xxxx, mc->mountList, 0);
961            if (retval == NG) {
962              popMountMode(d);
963              popCallback(d);
964              deleteEnd(d);
965              return GLineNGReturnTK(d);
966            }
967            if ((retval = selectOnOff(d, xxxx, &mc->curIkouho, upnelem,
968		            BANGOMAX, 0, mc->mountOldStatus,
969		            (int(*)(...))NO_CALLBACK, (int(*)(...))uuSDicExitCatch,
970                            (int(*)(...))uuSDicQuitCatch,
971							(int(*)(...))uiUtilIchiranTooSmall)) == NG) {
972              popMountMode(d);
973              popCallback(d);
974              deleteEnd(d);
975              return GLineNGReturnTK(d);
976            }
977
978            ic = (ichiranContext)d->modec;
979            ic->majorMode = CANNA_MODE_ExtendMode;
980            ic->minorMode = CANNA_MODE_DeleteDicMode;
981            currentModeInfo(d);
982
983            /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */
984            if (ic->tooSmall) {
985              jrKanjiError = "\274\255\275\361\260\354\315\367\315\321\244\316"
986		"\311\375\244\254\266\271\244\244\244\316\244\307\274\255"
987		"\275\361\244\316\301\252\302\362\244\254\244\307\244\255"
988		"\244\336\244\273\244\363";
989                /* ¼­½ñ°ìÍ÷ÍѤÎÉý¤¬¶¹¤¤¤Î¤Ç¼­½ñ¤ÎÁªÂò¤¬¤Ç¤­¤Þ¤»¤ó */
990              ichiranFin(d);
991              popCallback(d); /* OnOff ¤ò¥Ý¥Ã¥× */
992              popMountMode(d);
993              popCallback(d);
994              currentModeInfo(d);
995              freeDic(tc);
996              deleteEnd(d);
997              return GLineNGReturnTK(d);
998            }
999
1000            makeGlineStatus(d);
1001            /* d->status = ICHIRAN_EVERYTIME; */
1002
1003            return(retval);
1004          }
1005          free(snewp);
1006        }
1007        free(soldp);
1008      }
1009      free(dicLp);
1010    }
1011    free(dicLbuf);
1012  }
1013  jrKanjiError = "malloc (dicSakujoDictionary) \244\307\244\255\244\336"
1014	"\244\273\244\363\244\307\244\267\244\277";
1015     /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
1016  freeDic(tc);
1017  deleteEnd(d);
1018  return GLineNGReturnTK(d);
1019}
1020
1021/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1022 * ñ¸ìºï½ü                                                                  *
1023 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1024
1025static
1026int uuSDeleteYesCatch(uiContext d, int retval, mode_context env)
1027/* ARGSUSED */
1028{
1029  tourokuContext tc;
1030  char dicname[1024];
1031  deldicinfo *dic;
1032  int bufcnt, l;
1033  extern int defaultContext;
1034
1035  deleteEnd(d);
1036  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
1037
1038  tc = (tourokuContext)d->modec;
1039
1040  if(defaultContext == -1) {
1041    if((KanjiInit() < 0) || (defaultContext == -1)) {
1042#ifdef STANDALONE
1043#ifndef WIN
1044      jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó";
1045#else
1046      jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363";
1047#endif
1048#else
1049#ifndef WIN
1050      jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó";
1051#else
1052      jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\245\265"
1053	"\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336"
1054	"\244\273\244\363";
1055#endif
1056#endif
1057      freeAndPopTouroku(d);
1058      return(GLineNGReturn(d));
1059    }
1060  }
1061
1062  /* ¼­½ñ¤«¤éñ¸ì¤òºï½ü¤¹¤ë */
1063  /* ñ¸ìºï½üÍѤΰì¹Ô¤òºî¤ë(³Æ¼­½ñ¶¦ÄÌ) */
1064  WStraddbcpy(d->genbuf, tc->yomi_buffer, ROMEBUFSIZE);
1065  l = WStrlen(tc->yomi_buffer);
1066  d->genbuf[l] = (WCHAR_T)' ';
1067  l += 1;
1068  for (dic = tc->workDic3; dic->name; dic++) {
1069    /* ñ¸ìºï½üÍѤΰì¹Ô¤òºî¤ë(³Æ¼­½ñ¸ÇÍ­) */
1070    WStrcpy(d->genbuf + l, dic->hcode);
1071    bufcnt = l + WStrlen(dic->hcode);
1072    d->genbuf[bufcnt] = (WCHAR_T)' ';
1073    bufcnt += 1;
1074    WStraddbcpy(d->genbuf + bufcnt, tc->tango_buffer,
1075                                                 ROMEBUFSIZE - bufcnt);
1076
1077    WCstombs(dicname, dic->name, sizeof(dicname));
1078    if (RkwDeleteDic(defaultContext, dicname, d->genbuf) == NG) {
1079      if (errno == EPIPE)
1080        jrKanjiPipeError();
1081      MBstowcs(d->genbuf, "\303\261\270\354\272\357\275\374\244\307\244\255"
1082	"\244\336\244\273\244\363\244\307\244\267\244\277", 512);
1083		/* ñ¸ìºï½ü¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */
1084      goto close;
1085    }
1086    if (cannaconf.auto_sync) {
1087      RkwSync(defaultContext, dicname);
1088    }
1089  }
1090
1091  /* ºï½ü¤Î´°Î»¤òɽ¼¨¤¹¤ë */
1092  l = MBstowcs(d->genbuf, "\241\330", ROMEBUFSIZE);
1093			/* ¡Ø */
1094  WStrcpy(d->genbuf + l, tc->tango_buffer);
1095  l += WStrlen(tc->tango_buffer);
1096  l += MBstowcs(d->genbuf + l, "\241\331(", ROMEBUFSIZE - l);
1097				/* ¡Ù */
1098  WStrcpy(d->genbuf + l, tc->yomi_buffer);
1099  l += WStrlen(tc->yomi_buffer);
1100  l += MBstowcs(d->genbuf + l, ")\244\362\274\255\275\361 ", ROMEBUFSIZE - l);
1101			/* ¤ò¼­½ñ */
1102  dic = tc->workDic3;
1103  WStrcpy(d->genbuf + l, dic->name);
1104  l += WStrlen(dic->name);
1105  for (dic++; dic->name; dic++) {
1106    l += MBstowcs(d->genbuf + l, " \244\310 ", ROMEBUFSIZE - l);
1107				/* ¤È */
1108    WStrcpy(d->genbuf + l, dic->name);
1109    l += WStrlen(dic->name);
1110  }
1111  l += MBstowcs(d->genbuf + l, " \244\253\244\351\272\357\275\374\244\267"
1112	"\244\336\244\267\244\277", ROMEBUFSIZE - l);
1113			/* ¤«¤éºï½ü¤·¤Þ¤·¤¿ */
1114
1115 close:
1116  makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf));
1117
1118  freeAndPopTouroku(d);
1119
1120  currentModeInfo(d);
1121
1122  return(0);
1123}
1124
1125static
1126int uuSDeleteQuitCatch(uiContext d, int retval, mode_context env)
1127/* ARGSUSED */
1128{
1129  tourokuContext tc = (tourokuContext)env;
1130
1131  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
1132
1133  if (tc->nworkDic2 == 1) {
1134    freeWorkDic(tc);
1135    return dicSakujoTango(d);
1136  }
1137  freeWorkDic3(tc);
1138  return dicSakujoDictionary(d);
1139}
1140
1141static
1142int uuSDeleteNoCatch(uiContext d, int retval, mode_context env)
1143/* ARGSUSED */
1144{
1145  popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */
1146
1147  freeAndPopTouroku(d);
1148  deleteEnd(d);
1149  currentModeInfo(d);
1150
1151  GlineClear(d);
1152
1153  return(retval);
1154}
1155
1156static
1157int dicSakujoDo(uiContext d)
1158{
1159  tourokuContext tc = (tourokuContext)d->modec;
1160  int l;
1161  deldicinfo *dic;
1162
1163  l = MBstowcs(d->genbuf, "\241\330", ROMEBUFSIZE);
1164			/* ¡Ø */
1165  WStrcpy(d->genbuf + l, tc->tango_buffer);
1166  l += WStrlen(tc->tango_buffer);
1167  l += MBstowcs(d->genbuf + l, "\241\331(", ROMEBUFSIZE - l);
1168				/* ¡Ù */
1169  WStrcpy(d->genbuf + l, tc->yomi_buffer);
1170  l += WStrlen(tc->yomi_buffer);
1171  l += MBstowcs(d->genbuf + l, ")\244\362\274\255\275\361 ", ROMEBUFSIZE - l);
1172			/* ¤ò¼­½ñ */
1173  dic = tc->workDic3;
1174  WStrcpy(d->genbuf + l, dic->name);
1175  l += WStrlen(dic->name);
1176  for (dic++; dic->name; dic++) {
1177    l += MBstowcs(d->genbuf + l, " \244\310¤È ", ROMEBUFSIZE - l);
1178				/* ¤È */
1179    WStrcpy(d->genbuf + l, dic->name);
1180    l += WStrlen(dic->name);
1181  }
1182  l += MBstowcs(d->genbuf + l, " \244\253\244\351\272\357\275\374\244\267"
1183	"\244\336\244\271\244\253?(y/n)", ROMEBUFSIZE - l);
1184		/* ¤«¤éºï½ü¤·¤Þ¤¹¤« */
1185  if (getYesNoContext(d,
1186	     NO_CALLBACK, uuSDeleteYesCatch,
1187	     uuSDeleteQuitCatch, uuSDeleteNoCatch) == NG) {
1188    freeDic(tc);
1189    deleteEnd(d);
1190    return(GLineNGReturnTK(d));
1191  }
1192  makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf));
1193
1194  return(0);
1195}
1196#endif /* !NO_EXTEND_MENU && !WIN */
1197