1 /* -*- coding: iso-2022-jp -*-
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Copyright (C) 1995 Sun Microsystems, Inc.
5 This file is part of XEmacs.
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Synched up with: Mule 2.3. Not in FSF. */
24 /* Jserver Interface for Mule
25 Coded by Yutaka Ishikawa at ETL (yisikawa@etl.go.jp)
26 Satoru Tomura at ETL (tomura@etl.go.jp)
27 Modified for Wnn4 library by
28 Toshiaki Shingu (shingu@cpr.canon.co.jp)
29 Hiroshi Kuribayashi (kuri@nff.ncl.omron.co.jp) */
32 * Functions defined in this file are
33 * (wnn-server-open wnn-host-name login-name)
34 * wnn-host-name: STRING or NIL
38 * jserver
\e$B$H@\B3$7!"%5!<%P!<FbIt$K@5JQ49!?5UJQ49#2$D$N4D6-$r
\e(B
39 *
\e$B:n$k!#%(%i!<$N;~$O
\e(B nil
\e$B$rJV$9!#
\e(B
44 * jserver
\e$B$H$N@\B3$r@Z$k!#<-=q!"IQEY$O%;!<%V$5$l$J$$!#
\e(B
46 * (wnn-server-dict-add dict-file-name hindo-file-name priority
47 * dict-file-mode hindo-file-mode pw1 pw2)
48 * dict-file-name: STRING
49 * hindo-file-name: STRING or NULL-STRING
51 * dict-file-mode: BOOLEAN
52 * hindo-file-mode: BOOLEAN
56 *
\e$B<-=q%U%!%$%kL>!"IQEY%U%!%$%kL>!"M%@hEY!"<-=q%U%!%$%k%b!<%I
\e(B
57 *
\e$BIQEY%U%!%$%k%b!<%I$G;XDj$7$?<-=q$r%P%C%U%!$KDI2C$9$k!#
\e(B
58 * pw1, pw2
\e$B$O<-=q%U%!%$%k!"IQEY%U%!%$%k$N%Q%9%o!<%I!#
\e(B
60 * (wnn-server-dict-delete dic-no)
62 * RETURNS:
\e$B%(%i!<$N;~
\e(B nil
63 * DESCRIPTION: dic-no
\e$B$N<-=qHV9f$N<-=q$r!"%P%C%U%!$+$i
\e(B
66 * (wnn-server-dict-list)
67 * RETURNS: ((dic-no1 file-name1 comment1 word-no1 nice1)
68 * (dic-no2 file-name2 comment2 word-no2 nice2)...)
69 * DESCRIPTION:
\e$B%P%C%U%!>e$N<-=q$N%j%9%H$rF@$k!#
\e(B
71 * (wnn-server-dict-comment dic-no comment)
72 * RETURNS:
\e$B%(%i!<$N;~
\e(B nil
73 * DESCRIPTION: dic-no
\e$B$N<-=q$K%3%a%s%H$r$D$1$k!#
\e(B
75 * (wnn-server-set-rev rev)
77 * rev
\e$B$,
\e(B nil
\e$B$N;~$O@5JQ49!"$=$l0J30$N;~$O5UJQ49
\e(B
79 * (wnn-server-henkan-begin henkan-string)
80 * henkan-string: STRING
81 * RETURNS: bunsetu-suu
83 *
\e$B2>L>4A;zJQ49$r$7!"Bh0l8uJd$NJ8@a?t$rJV$9!#
\e(B
85 * (wnn-server-zenkouho bunsetu-no dai)
90 *
\e$BJ8@aHV9f$G;XDj$5$l$?J8@a$NA48uJd$r$H$j$@$7
\e(B
91 *
\e$B!"8=:_$N%*%U%;%C%H$rJV$9!#
\e(B
93 * (wnn-server-get-zenkouho offset)
96 * RETURNS: list of zenkouho
98 *
\e$B%*%U%;%C%H$G;XDj$5$l$?8uJd$rF@$k!#
\e(B
100 * (wnn-server-zenkouho-bun)
103 *
\e$BA48uJd$rI=<($7$F$$$kJ8@aHV9f$rF@$k!#
\e(B
105 * (wnn-server-zenkouho-suu)
108 *
\e$BA48uJd$rI=<($7$F$$$kJ8@a$NA48uJd?t$rF@$k!#
\e(B
110 * (wnn-server-dai-top bun-no)
114 *
\e$BJ8@a$,BgJ8@a$N@hF,$J$i
\e(B t
116 * (wnn-server-dai-end bun-no)
120 *
\e$B<!$NBgJ8@a$NJ8@aHV9f$rF@$k!#
\e(B
122 * (wnn-server-henkan-kakutei kouho-no dai)
127 *
\e$B8uJdHV9f$G<($5$l$?8uJd$rA*Br$9$k!#
\e(B
128 * (wnn-server-zenkouho)
\e$B$r8F$s$F$+$i$G$J$$$H$$$1$J$$!#
\e(B
130 * (wnn-server-bunsetu-henkou bunsetu-no bunsetu-length dai)
131 * bunsetu-no: INTEGER
132 * bunsetu-length: INTEGER
136 *
\e$BJ8@a$ND9$5$rJQ99$9$k!#
\e(B
138 * (wnn-bunsetu-kouho-inspect bunsetu-no)
139 * bunsetu-no: INTEGER
140 * RETURNS: (kanji yomi jisho-no serial-no hinsi hindo
141 * ima hyoka daihyoka kangovect)
143 *
\e$BJ8@a$N?'!9$J>pJs$rJQ49%P%C%U%!$+$i$H$j=P$9!#
\e(B
145 * (wnn-server-henkan-quit)
148 *
\e$B2?$b$7$J$$!#
\e(B
150 * (wnn-server-bunsetu-kanji bun-no)
151 * RETURNS: (bunsetu-kanji length)
154 * (wnn-server-bunsetu-yomi bun-no)
155 * RETURNS: (bunsetu-yomi length)
158 * (wnn-server-bunsetu-suu)
159 * RETURNS: bunsetu-suu
162 * (wnn-server-hindo-update &optional bunsetu-no)
163 * bunsetu-no: INTEGER
166 *
\e$BIQEY>pJs$r99?7$9$k!#
\e(B
168 * (wnn-server-word-add dic-no tango yomi comment hinsi)
176 *
\e$B<-=q$KC18l$rEPO?$9$k!#
\e(B
178 * (wnn-server-word-delete dic-no entry)
183 *
\e$B<-=q$+$i%(%s%H%jHV9f$G<($5$l$kC18l$r:o=|$9$k!#
\e(B
185 * (wnn-server-word-use dic-no entry)
190 *
\e$B<-=q$+$i%(%s%H%jHV9f$G<($5$l$kC18l$NM-8z!?L58z$r%H%0%k$9$k!#
\e(B
192 * (wnn-server-word-info dic-no entry)
195 * RETURNS: (yomi kanji comment hindo hinsi)
197 *
\e$B<-=q$+$i%(%s%H%jHV9f$G<($5$l$kC18l$N>pJs$rF@$k!#
\e(B
199 * (wnn-server-word-hindo-set dic-no entry hindo)
205 *
\e$B<-=q$+$i%(%s%H%jHV9f$G<($5$l$kC18l$NIQEY$r@_Dj$9$k!#
\e(B
207 * (wnn-server-word-search yomi)
209 * RETURNS: a LIST of dict-joho
211 *
\e$BA4$F$N<-=q$+$iC18l8!:w$r9T$J$&!#
\e(B
213 * (wnn-server-dict-save)
216 *
\e$BA4$F$N<-=q$HIQEY%U%!%$%k$r%;!<%V$9$k!#
\e(B
218 * (wnn-server-get-param)
219 * RETURNS: (n nsho p1 p2 p3 ... p15)
220 * DESCRIPTION:
\e$BJQ49%Q%i%a!<%?$rF@$k!#
\e(B
222 * (wnn-server-set-param n sho p1 ... p15)
223 * RETURNS:
\e$B%(%i!<$N;~
\e(B nil
224 * DESCRIPTION:
\e$BJQ49%Q%i%a!<%?$r@_Dj$9$k!#
\e(B
226 * (wnn-server-get-msg error-no)
227 * RETURNS:
\e$B%(%i!<%a225;!<%8
\e(B
228 * DESCRIPTION:
\e$B%(%i!<HV9f$+$i%a%C%;!<%8$rF@$k!#
\e(B
230 * (wnn-server-fuzokugo-set fname)
231 * RETURNS:
\e$B%(%i!<$N;~
\e(B nil
232 * DESCRIPTION:
\e$B%P%C%U%!$KImB08l%U%!%$%k$rFI$_9~$`!#
\e(B
234 * (wnn-server-fuzokugo-get)
235 * RETURNS:
\e$B%U%!%$%kL>
\e(B
236 * DESCRIPTION:
\e$B%P%C%U%!$NImB08l%U%!%$%kL>$rF@$k!#
\e(B
238 * (wnn-server-isconnect)
239 * RETURNS:
\e$B%3%M%/%H$7$F$l$P
\e(B t,
\e$B$7$F$J$1$l$P
\e(B nil
240 * DESCRIPTION:
\e$B%5!<%P$H7Q$C$F$$$k$+D4$Y$k!#
\e(B
242 * (wnn-server-hinsi-dicts hinsi-no)
243 * RETURNS: (dic-no1 dic-no2 ...)
244 * DESCRIPTION: hinsi-no
\e$B$NIJ;l$,EPO?$G$-$k<-=q$N%j%9%H$rF@$k!#
\e(B
245 * hinsi-no = -1
\e$B$N$H$-$K$O!"EPO?2DG=$JA4<-=q$rF@$k!#
\e(B
247 * (wnn-server-hinsi-list dic-no name)
248 * RETURNS: (name1 name2 ... )
249 * DESCRIPTION: dic-no
\e$B$N<-=q$G!"IJ;l%N!<%I$KB0$9$k
\e(B
250 *
\e$BIJ;l%N!<%I!JL>!K$N%j%9%H$rF@$k!#
\e(B
251 *
\e$BIJ;lL>$rM?$($?;~$O!"#0$rJV$9!#
\e(B
253 * (wnn-server-hinsi-name hinsi-no)
254 * RETURNS: hinsi-name
255 * DESCRIPTION:
\e$BIJ;lHV9f$+$iL>A0$r<h$k!#
\e(B
257 * (wnn-server-hinsi-number hinsi-name)
259 * DESCRIPTION:
\e$BIJ;lL>$rIJ;lHV9f$KJQ49$9$k!#
\e(B
261 * (wnn-server-version)
262 * RETURNS: version ID(int)
273 #include "wnn/commonhd.h"
274 #include "character.h"
275 #include "wnn/jllib.h"
276 #include "wnn/cplib.h"
278 /* UCHAR
\e$B$,Fs=EDj5A$5$l$k$N$G
\e(B */
281 #define EGG_TIMEOUT 5
283 #define WNNSERVER_J 0
284 #define WNNSERVER_C 1
285 #define WNNSERVER_T 2
286 #define WNNSERVER_K 3
288 int check_wnn_server_type (void);
289 void w2m (w_char *wp, unsigned char *mp, unsigned char lb);
290 void m2w (unsigned char *mp, w_char *wp);
291 void w2y (w_char *w);
292 void c2m (unsigned char *cp, unsigned char *mp, unsigned char lb);
293 static void puts2 (char *s);
294 static int dai_end (int no, int server);
295 static int yes_or_no (unsigned char *s);
297 /* Why doesn't wnn have a prototype for these? */
298 typedef unsigned int letter;
299 int cwnn_yincod_pzy(w_char *, w_char, int);
300 int cwnn_pzy_yincod(letter *, letter *, int);
302 static struct wnn_buf *wnnfns_buf[NSERVER];
303 static struct wnn_env *wnnfns_env_norm[NSERVER];
304 static struct wnn_env *wnnfns_env_rev[NSERVER];
305 static int wnnfns_norm;
306 static unsigned char lb_wnn_server_type[NSERVER] =
307 {LEADING_BYTE_JAPANESE_JISX0208, LEADING_BYTE_CHINESE_GB2312, LEADING_BYTE_THAI_TIS620, LEADING_BYTE_KOREAN_KSC5601};
309 /* Lisp Variables and Constants Definition */
310 Lisp_Object Qjserver;
311 Lisp_Object Qcserver;
312 /*Lisp_Object Qtserver;*/
313 Lisp_Object Qkserver;
314 Lisp_Object Qwnn_no_uniq;
315 Lisp_Object Qwnn_uniq;
316 Lisp_Object Qwnn_uniq_kanji;
317 Lisp_Object Qwnn_n, Qwnn_nsho, Qwnn_hindo, Qwnn_len, Qwnn_jiri, Qwnn_flag;
318 Lisp_Object Qwnn_jisho, Qwnn_sbn, Qwnn_dbn_len, Qwnn_sbn_cnt, Qwnn_suuji;
319 Lisp_Object Qwnn_kana, Qwnn_eisuu, Qwnn_kigou, Qwnn_toji_kakko, Qwnn_fuzokogo, Qwnn_kaikakko;
320 Lisp_Object Vwnn_server_type;
321 Lisp_Object Vcwnn_zhuyin;
322 Lisp_Object Vwnnenv_sticky;
323 Lisp_Object Vwnn_uniq_level;
326 /* Lisp functions definition */
328 DEFUN ("wnn-server-open", Fwnn_open, 2, 2, 0, /*
329 Connect to jserver of host HNAME, make an environment with
330 login name LNAME in the server.
331 Return nil if error occurs.
340 CHECK_STRING (lname);
342 snum = check_wnn_server_type ();
353 strcpy (langname, "zh_TW");
363 size = XSTRING_LENGTH (lname) > 1024 ? 1026 : XSTRING_LENGTH (lname) + 2;
364 envname = alloca (size);
365 strncpy (envname, (char *) XSTRING_DATA (lname), size-2);
366 envname[size-2] = '\0';
367 if (NILP (hname)) hostname = "";
370 CHECK_STRING (hname);
371 size = XSTRING_LENGTH(hname) > 1024 ? 1025 : XSTRING_LENGTH(hname) + 1;
373 hostname = alloca (size);
374 strncpy (hostname, (char *) XSTRING_DATA (hname), size-1);
375 hostname[size-1] = '\0';
377 CHECK_STRING (lname);
378 /* 97/4/16 jhod@po.iijnet.or.jp
379 * libwnn uses SIGALRM, so we need to stop and start interrupts.
382 if (!(wnnfns_buf[snum] = jl_open_lang (envname, hostname, langname,
383 0, 0, 0, EGG_TIMEOUT)))
388 if (!jl_isconnect (wnnfns_buf[snum]))
393 wnnfns_env_norm[snum] = jl_env_get (wnnfns_buf[snum]);
394 /* if (Vwnnenv_sticky == Qt) jl_env_sticky_e (wnnfns_env_norm[snum]);
395 else jl_env_un_sticky_e (wnnfns_env_norm[snum]);*/
396 strcat (envname, "R");
397 if (!(wnnfns_env_rev[snum] = jl_connect_lang (envname, hostname, langname,
398 0, 0, 0, EGG_TIMEOUT)))
403 /* if (Vwnnenv_sticky == Qt) jl_env_sticky_e (wnnfns_env_rev[snum]);
404 else jl_env_un_sticky_e (wnnfns_env_rev[snum]);*/
410 DEFUN ("wnn-server-close", Fwnn_close, 0, 0, 0, /*
411 Close the connection to jserver, Dictionary and frequency files
417 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
418 if (!wnnfns_buf[snum]) return Qnil;
419 if (wnnfns_env_norm[snum])
421 if (NILP (Vwnnenv_sticky)) jl_env_un_sticky_e (wnnfns_env_norm[snum]);
422 else jl_env_sticky_e (wnnfns_env_norm[snum]);
423 jl_disconnect (wnnfns_env_norm[snum]);
425 if (wnnfns_env_rev[snum])
427 if (NILP (Vwnnenv_sticky)) jl_env_un_sticky_e (wnnfns_env_rev[snum]);
428 else jl_env_sticky_e (wnnfns_env_rev[snum]);
429 jl_disconnect (wnnfns_env_rev[snum]);
431 jl_env_set (wnnfns_buf[snum], 0);
432 jl_close (wnnfns_buf[snum]);
433 wnnfns_buf[snum] = (struct wnn_buf *) 0;
434 wnnfns_env_norm[snum] = wnnfns_env_rev[snum] = (struct wnn_env *) 0;
438 DEFUN ("wnn-server-dict-add", Fwnn_dict_add, 5, MANY, 0, /*
439 Add dictionary specified by DICT-FILE-NAME, FREQ-FILE-NAME,
440 PRIORITY, DICT-FILE-MODE, FREQ-FILE-MODE.
441 Specify password files of dictionary and frequency, PW1 and PW2, if needed.
443 (int nargs, Lisp_Object *args))
447 CHECK_STRING (args[0]);
448 CHECK_STRING (args[1]);
450 if (! NILP (args[5])) CHECK_STRING (args[5]);
451 if (! NILP (args[6])) CHECK_STRING (args[6]);
452 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
453 if (!wnnfns_buf[snum]) return Qnil;
455 gcpro1.nvars = nargs;
456 if (jl_dic_add (wnnfns_buf[snum],
457 XSTRING_DATA (args[0]),
458 XSTRING_DATA (args[1]),
459 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV,
461 NILP (args[3]) ? WNN_DIC_RDONLY : WNN_DIC_RW,
462 NILP (args[4]) ? WNN_DIC_RDONLY : WNN_DIC_RW,
463 NILP (args[5]) ? 0 : XSTRING_DATA (args[5]),
464 NILP (args[6]) ? 0 : XSTRING_DATA (args[6]),
475 DEFUN ("wnn-server-dict-delete", Fwnn_dict_delete, 1, 1, 0, /*
476 Remove dictionary specified by DIC-NUMBER from buffer.
483 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
485 if (!wnnfns_buf[snum]) return Qnil;
486 if (jl_dic_delete (wnnfns_buf[snum], no) < 0) return Qnil;
490 DEFUN ("wnn-server-dict-list", Fwnn_dict_list, 0, 0, 0, /*
491 Return information of dictionaries.
495 WNN_DIC_INFO *dicinfo;
497 unsigned char comment[1024];
502 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
503 lb = lb_wnn_server_type[snum];
504 if (!wnnfns_buf[snum]) return Qnil;
506 if((cnt = jl_fi_dic_list (wnnfns_buf[snum], 0x3f, &dicinfo)) < 0)
509 if((cnt = jl_dic_list (wnnfns_buf[snum], &dicinfo)) < 0) return Qnil;
512 for (i = 0, dicinfo += cnt; i < cnt; i++)
515 w2m (dicinfo->comment, comment, lb);
516 /* #### The following has not been Mule-ized!!
517 fname and comment must be ASCII strings! */
519 Fcons (Fcons (make_int (dicinfo->dic_no),
520 list4 (make_string ((Bufbyte *) (dicinfo->fname),
521 strlen (dicinfo->fname)),
522 make_string (comment, strlen ((char *) comment)),
523 make_int (dicinfo->gosuu),
524 make_int (dicinfo->nice))), val);
529 DEFUN ("wnn-server-dict-comment", Fwnn_dict_comment, 2, 2, 0, /*
530 Set comment to dictionary specified by DIC-NUMBER.
531 Comment string COMMENT.
538 CHECK_STRING (comment);
539 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
540 if (!wnnfns_buf[snum]) return Qnil;
541 m2w (XSTRING_DATA (comment), wbuf);
542 if (jl_dic_comment_set (wnnfns_buf[snum], XINT (dicno), wbuf) < 0)
548 DEFUN ("wnn-server-set-rev", Fwnn_set_rev, 1, 1, 0, /*
549 Switch the translation mode to normal if T, or reverse if NIL.
554 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
557 if ((!wnnfns_buf[snum]) || (!wnnfns_env_norm[snum])) return Qnil;
558 jl_env_set (wnnfns_buf[snum], wnnfns_env_norm[snum]);
563 if ((!wnnfns_buf[snum]) || (!wnnfns_env_rev[snum])) return Qnil;
564 jl_env_set (wnnfns_buf[snum], wnnfns_env_rev[snum]);
570 DEFUN ("wnn-server-henkan-begin", Fwnn_begin_henkan, 1, 1, 0, /*
571 Translate YOMI string to kanji. Retuen the number of bunsetsu.
578 CHECK_STRING (hstring);
579 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
580 if (!wnnfns_buf[snum]) return Qnil;
581 m2w (XSTRING_DATA (hstring), wbuf);
582 if (snum == WNNSERVER_C)
586 if ((cnt = jl_fi_ren_conv (wnnfns_buf[snum], wbuf, 0, -1, WNN_USE_MAE)) < 0)
589 if ((cnt = jl_ren_conv (wnnfns_buf[snum], wbuf, 0, -1, WNN_USE_MAE)) < 0)
592 return make_int (cnt);
595 DEFUN ("wnn-server-zenkouho", Fwnn_zenkouho, 2, 2, 0, /*
596 Get zenkouho at BUNSETSU-NUMBER. Second argument DAI is t.
597 if dai-bunsetsu, NIL if sho-bunsetsu. Return the current offset of zenkouho.
605 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
606 if (!wnnfns_buf[snum]) return Qnil;
608 if (EQ(Vwnn_uniq_level, Qwnn_no_uniq)) uniq_level = WNN_NO_UNIQ;
609 else if (EQ(Vwnn_uniq_level, Qwnn_uniq)) uniq_level = WNN_UNIQ;
610 else uniq_level = WNN_UNIQ_KNJ;
613 if ((offset = jl_zenkouho (wnnfns_buf[snum],no,WNN_USE_MAE,
619 if ((offset = jl_zenkouho_dai (wnnfns_buf[snum], no, dai_end (no, snum),
620 WNN_USE_MAE, uniq_level)) < 0)
623 return make_int (offset);
627 DEFUN ("wnn-server-get-zenkouho", Fwnn_get_zenkouho, 1, 1, 0, /*
628 Get kanji string of KOUHO-NUMBER.
632 unsigned char kanji_buf[256];
637 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
638 lb = lb_wnn_server_type[snum];
639 if (!wnnfns_buf[snum]) return Qnil;
640 jl_get_zenkouho_kanji (wnnfns_buf[snum], XINT (kouhoNo), wbuf);
641 w2m (wbuf, kanji_buf, lb);
642 return make_string (kanji_buf, strlen ((char *) kanji_buf));
645 DEFUN ("wnn-server-zenkouho-bun", Fwnn_zenkouho_bun, 0, 0, 0, /*
651 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
652 return make_int (jl_zenkouho_bun (wnnfns_buf[snum]));
655 DEFUN ("wnn-server-zenkouho-suu", Fwnn_zenkouho_suu, 0, 0, 0, /*
656 Return the number of zen kouho.
661 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
662 return make_int (jl_zenkouho_suu (wnnfns_buf[snum]));
665 DEFUN ("wnn-server-dai-top", Fwnn_dai_top, 1, 1, 0, /*
666 Return t if bunsetsu BUN-NUMBER is dai-bunsetsu.
672 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
673 if (!wnnfns_buf[snum]) return Qnil;
674 if (jl_dai_top (wnnfns_buf[snum], XINT (bunNo)) == 1) return Qt;
678 DEFUN ("wnn-server-dai-end", Fwnn_dai_end, 1, 1, 0, /*
679 Return the bunsetu number of the next dai-bunsetsu after BUN-NUMBER.
685 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
686 if (!wnnfns_buf[snum]) return Qnil;
687 return make_int (dai_end (XINT (bunNo), snum));
690 DEFUN ("wnn-server-henkan-kakutei", Fwnn_kakutei, 2, 2, 0, /*
691 Set candidate with OFFSET, DAI. DAI is T if dai-bunsetsu.
697 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
698 if (!wnnfns_buf[snum]) return Qnil;
701 if (jl_set_jikouho (wnnfns_buf[snum], XINT (offset)) < 0) return Qnil;
705 if (jl_set_jikouho_dai (wnnfns_buf[snum], XINT (offset)) < 0)
711 DEFUN ("wnn-server-bunsetu-henkou", Fwnn_bunsetu_henkou, 3, 3, 0, /*
712 Change length of BUN-NUMBER bunsetu to LEN. DAI is T if dai-bunsetsu.
720 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
721 if (!wnnfns_buf[snum]) return Qnil;
724 if ((cnt = jl_fi_nobi_conv (wnnfns_buf[snum], no, XINT(len), -1, WNN_USE_MAE,
725 NILP (dai) ? WNN_SHO : WNN_DAI)) < 0)
728 if ((cnt = jl_nobi_conv (wnnfns_buf[snum], no, XINT(len), -1, WNN_USE_MAE,
729 NILP (dai) ? WNN_SHO : WNN_DAI)) < 0)
732 return make_int (cnt);
735 DEFUN ("wnn-server-inspect", Fwnn_inspect, 1, 1, 0, /*
736 Get bunsetsu information specified by BUN-NUMBER.
741 unsigned char cbuf[512];
743 int bun_no, yomilen, jirilen, i;
747 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
748 lb = lb_wnn_server_type[snum];
749 if (!wnnfns_buf[snum]) return Qnil;
750 bun_no = XINT (bunNo);
752 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->kangovect), val);
753 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->daihyoka), val);
754 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->hyoka), val);
755 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->ima), val);
756 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->hindo), val);
757 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->hinsi), val);
758 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->entry), val);
759 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->dic_no), val);
760 yomilen = jl_get_yomi (wnnfns_buf[snum], bun_no, bun_no + 1, wbuf);
761 jirilen = wnnfns_buf[snum]->bun[bun_no]->jirilen;
762 for (i = yomilen; i >= jirilen; i--) wbuf[i+1] = wbuf[i];
764 w2m (wbuf, cbuf, lb);
765 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val);
766 jl_get_kanji (wnnfns_buf[snum], bun_no, bun_no + 1, wbuf);
767 w2m (wbuf, cbuf, lb);
768 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val);
773 DEFUN ("wnn-server-henkan-quit", Fwnn_quit_henkan, 0, 0, 0, /*
779 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
780 if (!wnnfns_buf[snum]) return Qnil;
784 DEFUN ("wnn-server-bunsetu-kanji", Fwnn_bunsetu_kanji, 1, 1, 0, /*
785 Get the pair of kanji and length of bunsetsu specified by BUN-NUMBER.
790 unsigned char kanji_buf[256];
796 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
797 lb = lb_wnn_server_type[snum];
798 if (!wnnfns_buf[snum]) return Qnil;
800 kanji_len = jl_get_kanji (wnnfns_buf[snum], no, no + 1, wbuf);
801 w2m (wbuf, kanji_buf, lb);
802 return Fcons (make_string (kanji_buf, strlen ((char *) kanji_buf)),
803 make_int (kanji_len));
806 DEFUN ("wnn-server-bunsetu-yomi", Fwnn_bunsetu_yomi, 1, 1, 0, /*
807 Get the pair of yomi and length of bunsetsu specified by BUN-NUMBER.
812 unsigned char yomi_buf[256];
818 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
819 lb = lb_wnn_server_type[snum];
820 if (!wnnfns_buf[snum]) return Qnil;
822 yomi_len = jl_get_yomi (wnnfns_buf[snum], no, no + 1, wbuf);
823 w2m (wbuf, yomi_buf, lb);
824 return Fcons (make_string (yomi_buf, strlen ((char *) yomi_buf)),
825 make_int (yomi_len));
828 DEFUN ("wnn-server-bunsetu-suu", Fwnn_bunsetu_suu, 0, 0, 0, /*
829 Get the number of bunsetsu.
834 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
835 if (!wnnfns_buf[snum]) return Qnil;
836 return make_int (jl_bun_suu (wnnfns_buf[snum]));
839 DEFUN ("wnn-server-hindo-update", Fwnn_hindo_update, 0, 1, 0, /*
840 Update frequency of bunsetsu specified by NUM-NUMBER.
846 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
847 if (NILP (bunNo)) no = -1;
853 if (!wnnfns_buf[snum]) return Qnil;
855 if (jl_optimize_fi (wnnfns_buf[snum], 0, no) < 0) return Qnil;
857 if (jl_update_hindo (wnnfns_buf[snum], 0, no) < 0) return Qnil;
863 DEFUN ("wnn-server-word-add", Fwnn_word_toroku, 5, 5, 0, /*
864 Add a word to dictionary. Arguments are
865 DIC-NUMBER, KANJI, YOMI, COMMENT, HINSI-NUMBER.
867 (dicno, kanji, yomi, comment, hinsi))
869 w_char yomi_buf[256], kanji_buf[256], comment_buf[256];
872 CHECK_STRING (kanji);
874 CHECK_STRING (comment);
876 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
877 if (!wnnfns_buf[snum]) return Qnil;
878 m2w (XSTRING_DATA (yomi), yomi_buf);
879 if (snum == WNNSERVER_C)
881 m2w (XSTRING_DATA (kanji), kanji_buf);
882 m2w (XSTRING_DATA (comment), comment_buf);
883 if (jl_word_add (wnnfns_buf[snum], XINT (dicno), yomi_buf, kanji_buf,
884 comment_buf, XINT (hinsi), 0) < 0)
890 DEFUN ("wnn-server-word-delete", Fwnn_word_sakujo, 2, 2, 0, /*
891 Delete a word from dictionary, specified by DIC-NUMBER, SERIAL-NUMBER.
898 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
899 if (!wnnfns_buf[snum]) return Qnil;
900 if (jl_word_delete (wnnfns_buf[snum], XINT (no), XINT (serial)) < 0)
906 DEFUN ("wnn-server-word-use", Fwnn_word_use, 2, 2, 0, /*
907 Toggle on/off word, specified by DIC-NUMBER and SERIAL-NUMBER.
914 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
915 if (!wnnfns_buf[snum]) return Qnil;
916 if (jl_word_use (wnnfns_buf[snum], XINT (no), XINT (serial)) < 0)
921 DEFUN ("wnn-server-word-info", Fwnn_word_info, 2, 2, 0, /*
922 Return list of yomi, kanji, comment, hindo, hinshi.
927 struct wnn_jdata *info_buf;
928 unsigned char cbuf[512];
933 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
934 lb = lb_wnn_server_type[snum];
935 if (!wnnfns_buf[snum]) return Qnil;
936 if ((info_buf = jl_word_info (wnnfns_buf[snum],
937 XINT (no), XINT (serial))) != NULL)
944 val = Fcons (make_int (info_buf->hinshi), val);
945 val = Fcons (make_int (info_buf->hindo), val);
946 w2m (info_buf->com, cbuf, lb);
947 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val);
948 w2m (info_buf->kanji, cbuf, lb);
949 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val);
950 w2m (info_buf->yomi, cbuf, lb);
951 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val);
956 DEFUN ("wnn-server-word-hindo-set", Fwnn_hindo_set, 3, 3, 0, /*
957 Set frequency to arbitrary value. Specified by DIC-NUMBER,
958 SERIAL-NUMBER, FREQUENCY.
966 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
967 if (!wnnfns_buf[snum]) return Qnil;
968 if (js_hindo_set (jl_env_get (wnnfns_buf[snum]),
978 DEFUN ("wnn-server-word-search", Fwnn_dict_search, 1, 1, 0, /*
979 Search a word YOMI from buffer.
980 Return list of (kanji hinshi freq dic_no serial).
985 struct wnn_jdata *wordinfo;
988 unsigned char kanji_buf[256];
992 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
993 lb = lb_wnn_server_type[snum];
994 if (!wnnfns_buf[snum]) return Qnil;
995 m2w (XSTRING_DATA (yomi), wbuf);
996 if (snum == WNNSERVER_C)
998 if ((count = jl_word_search_by_env (wnnfns_buf[snum],
999 wbuf, &wordinfo)) < 0)
1002 for (i = 0, wordinfo += count; i < count; i++)
1005 w2m (wordinfo->kanji, kanji_buf, lb);
1006 val = Fcons (Fcons (make_string (kanji_buf, strlen ((char *) kanji_buf)),
1007 list4 (make_int (wordinfo->hinshi),
1008 make_int (wordinfo->hindo),
1009 make_int (wordinfo->dic_no),
1010 make_int (wordinfo->serial))),
1016 DEFUN ("wnn-server-dict-save", Fwnn_dict_save, 0, 0, 0, /*
1017 Save all dictionaries and frequency files.
1022 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1023 if (!wnnfns_buf[snum]) return Qnil;
1024 if (jl_dic_save_all (wnnfns_buf[snum]) < 0) return Qnil;
1028 DEFUN ("wnn-server-get-param", Fwnn_get_param, 0, 0, 0, /*
1029 Returns (n nsho hindo len jiri flag jisho sbn dbn_len sbn_cnt
1030 suuji kana eisuu kigou toji_kakko fuzokogo kaikakko)
1034 struct wnn_param param;
1036 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1037 if (!wnnfns_buf[snum]) return Qnil;
1038 if (jl_param_get (wnnfns_buf[snum], ¶m) < 0) return Qnil;
1039 return Fcons (make_int (param.n),
1040 Fcons (make_int (param.nsho),
1041 Fcons (make_int (param.p1),
1042 Fcons (make_int (param.p2),
1043 Fcons (make_int (param.p3),
1044 Fcons (make_int (param.p4),
1045 Fcons (make_int (param.p5),
1046 Fcons (make_int (param.p6),
1047 Fcons (make_int (param.p7),
1048 Fcons (make_int (param.p8),
1049 Fcons (make_int (param.p9),
1050 Fcons (make_int (param.p10),
1051 Fcons (make_int (param.p11),
1052 Fcons (make_int (param.p12),
1053 Fcons (make_int (param.p13),
1054 Fcons (make_int (param.p14),
1055 Fcons (make_int (param.p15),Qnil)))))))))))))))));
1058 DEFUN ("wnn-server-set-param", Fwnn_set_param, 1, 1, 0, /*
1059 Set parameters using an alist, where the CAR contains one of
1060 wnn_n, wnn_nsho, wnn_hindo, wnn_len, wnn_jiri, wnn_flag,
1061 wnn_jisho, wnn_sbn, wnn_dbn_len, wnn_sbn_cnt, wnn_suuji,
1062 wnn_kana, wnn_eisuu, wnn_kigou, wnn_toji_kakko, wnn_fuzokogo,
1063 or wnn_kaikakko and the CDR contains the value.
1068 struct wnn_param param;
1071 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1072 if (!wnnfns_buf[snum]) return Qnil;
1073 rc = jl_param_get (wnnfns_buf[snum], ¶m);
1074 if (rc < 0) return Qnil;
1077 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, val, Vsetvalues_alist)
1081 setval = XINT (val);
1082 if (EQ (key, Qwnn_n)) param.n = setval;
1083 else if (EQ (key, Qwnn_nsho)) param.nsho = setval;
1084 else if (EQ (key, Qwnn_hindo)) param.p1 = setval;
1085 else if (EQ (key, Qwnn_len)) param.p2 = setval;
1086 else if (EQ (key, Qwnn_jiri)) param.p3 = setval;
1087 else if (EQ (key, Qwnn_flag)) param.p4 = setval;
1088 else if (EQ (key, Qwnn_jisho)) param.p5 = setval;
1089 else if (EQ (key, Qwnn_sbn)) param.p6 = setval;
1090 else if (EQ (key, Qwnn_dbn_len)) param.p7 = setval;
1091 else if (EQ (key, Qwnn_sbn_cnt)) param.p8 = setval;
1092 else if (EQ (key, Qwnn_suuji)) param.p9 = setval;
1093 else if (EQ (key, Qwnn_kana)) param.p10 = setval;
1094 else if (EQ (key, Qwnn_eisuu)) param.p11 = setval;
1095 else if (EQ (key, Qwnn_kigou)) param.p12 = setval;
1096 else if (EQ (key, Qwnn_toji_kakko)) param.p13 = setval;
1097 else if (EQ (key, Qwnn_fuzokogo)) param.p14 = setval;
1098 else if (EQ (key, Qwnn_kaikakko)) param.p15 = setval;
1101 signal_simple_error ("Invalid wnn keyword", key);
1108 printf("wnn_n = %d\n",param.n);
1109 printf("wnn_nsho = %d\n",param.nsho);
1110 printf("wnn_hindo = %d\n",param.p1);
1111 printf("wnn_len = %d\n",param.p2);
1112 printf("wnn_jiri = %d\n",param.p3);
1113 printf("wnn_flag = %d\n",param.p4);
1114 printf("wnn_jisho = %d\n",param.p5);
1115 printf("wnn_sbn = %d\n",param.p6);
1116 printf("wnn_dbn_len = %d\n",param.p7);
1117 printf("wnn_sbn_cnt = %d\n",param.p8);
1118 printf("wnn_suuji = %d\n",param.p9);
1119 printf("wnn_kana = %d\n",param.p10);
1120 printf("wnn_eisuu = %d\n",param.p11);
1121 printf("wnn_kigou = %d\n",param.p12);
1122 printf("wnn_toji_kakko = %d\n",param.p13);
1123 printf("wnn_fuzokogo = %d\n",param.p14);
1124 printf("wnn_kaikakko = %d\n",param.p15);
1127 rc = jl_param_set (wnnfns_buf[snum], ¶m);
1128 if (rc < 0) return Qnil;
1132 DEFUN ("wnn-server-get-msg", Fwnn_get_msg, 0, 0, 0, /*
1133 Get message string from wnn_perror.
1137 unsigned char mbuf[256];
1142 /* CHECK_INT (errno);*/
1143 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1144 lb = lb_wnn_server_type[snum];
1148 strcpy (langname, "ja_JP");
1151 strcpy (langname, "zh_CN");
1155 strcpy (langname, "zh_TW");
1159 strcpy (langname, "ko_KR");
1162 if (!wnnfns_buf[snum]) return Qnil;
1163 /* msgp = msg_get (wnn_msg_cat, XINT (errno), 0, 0);*/
1164 msgp = wnn_perror_lang (langname);
1165 c2m ((unsigned char *) msgp, mbuf, lb);
1166 return make_string (mbuf, strlen ((char *) mbuf));
1170 DEFUN ("wnn-server-fuzokugo-set", Fwnn_fuzokugo_set, 1, 1, 0, /*
1176 CHECK_STRING (file);
1177 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1178 if (!wnnfns_buf[snum]) return Qnil;
1179 if (jl_fuzokugo_set (wnnfns_buf[snum], XSTRING_DATA (file)) < 0)
1184 DEFUN ("wnn-server-fuzokugo-get", Fwnn_fuzokugo_get, 0, 0, 0, /*
1191 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1192 if (!wnnfns_buf[snum]) return Qnil;
1193 if (jl_fuzokugo_get (wnnfns_buf[snum], fname) < 0) return Qnil;
1194 return make_string ((Bufbyte *) fname, strlen (fname));
1198 DEFUN ("wnn-server-isconnect", Fwnn_isconnect, 0, 0, 0, /*
1204 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1205 if (!wnnfns_buf[snum]) return Qnil;
1206 if (jl_isconnect (wnnfns_buf[snum])) return Qt;
1210 DEFUN ("wnn-server-hinsi-dicts", Fwnn_hinsi_dicts, 1, 1, 0, /*
1220 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1221 if (!wnnfns_buf[snum]) return Qnil;
1222 if ((cnt = jl_hinsi_dicts (wnnfns_buf[snum], XINT (hinsi), &area)) < 0)
1225 for (area += cnt; cnt > 0; cnt--)
1228 val = Fcons (make_int (*area), val);
1233 DEFUN ("wnn-server-hinsi-list", Fwnn_hinsi_list, 2, 2, 0, /*
1242 unsigned char cbuf[512];
1246 CHECK_STRING (name);
1247 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1248 lb = lb_wnn_server_type[snum];
1249 if (!wnnfns_buf[snum]) return Qnil;
1250 m2w (XSTRING_DATA (name), wbuf);
1251 if ((cnt = jl_hinsi_list (wnnfns_buf[snum], XINT (dicno), wbuf, &area)) < 0)
1253 if (cnt == 0) return make_int (0);
1255 for (area += cnt; cnt > 0; cnt--)
1258 w2m (*area, cbuf, lb);
1259 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val);
1264 DEFUN ("wnn-server-hinsi-name", Fwnn_hinsi_name, 1, 1, 0, /*
1269 unsigned char name[256];
1274 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1275 lb = lb_wnn_server_type[snum];
1276 if (!wnnfns_buf[snum]) return Qnil;
1277 if ((wname = jl_hinsi_name (wnnfns_buf[snum], XINT (no))) == 0) return Qnil;
1278 w2m (wname, name, lb);
1279 return make_string (name, strlen ((char *) name));
1282 DEFUN ("wnn-server-fisys-dict-add", Fwnn_fisys_dict_add, 3, MANY, 0, /*
1283 Add dictionary specified by FISYS-DICT-FILE-NAME, FISYS-FREQ-FILE-NAME,
1284 FISYS-FREQ-FILE-MODE.
1285 Specify password files of dictionary and frequency, PW1 and PW2, if needed.
1287 (int nargs, Lisp_Object *args))
1289 struct gcpro gcpro1;
1291 CHECK_STRING (args[0]);
1292 CHECK_STRING (args[1]);
1293 if (! NILP (args[3])) CHECK_STRING (args[3]);
1294 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1295 if(!wnnfns_buf[snum]) return Qnil;
1297 gcpro1.nvars = nargs;
1298 if(jl_fi_dic_add(wnnfns_buf[snum],
1299 XSTRING_DATA (args[0]),
1300 XSTRING_DATA (args[1]),
1303 NILP (args[2]) ? WNN_DIC_RDONLY : WNN_DIC_RW,
1305 NILP (args[3]) ? 0 : XSTRING_DATA (args[3]),
1315 DEFUN ("wnn-server-fiusr-dict-add", Fwnn_fiusr_dict_add, 4, MANY, 0, /*
1316 Add dictionary specified by FIUSR-DICT-FILE-NAME, FIUSR-FREQ-FILE-NAME,
1317 FIUSR-DICT-FILE-MODE, FIUSR-FREQ-FILE-MODE.
1318 Specify password files of dictionary and frequency, PW1 and PW2, if needed.
1320 (int nargs, Lisp_Object *args))
1322 struct gcpro gcpro1;
1324 CHECK_STRING (args[0]);
1325 CHECK_STRING (args[1]);
1326 if (! NILP (args[4])) CHECK_STRING (args[4]);
1327 if (! NILP (args[5])) CHECK_STRING (args[5]);
1328 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1329 if(!wnnfns_buf[snum]) return Qnil;
1331 gcpro1.nvars = nargs;
1332 if(jl_fi_dic_add(wnnfns_buf[snum],
1333 XSTRING_DATA (args[0]),
1334 XSTRING_DATA (args[1]),
1336 NILP (args[2]) ? WNN_DIC_RDONLY : WNN_DIC_RW,
1337 NILP (args[3]) ? WNN_DIC_RDONLY : WNN_DIC_RW,
1338 NILP (args[4]) ? 0 : XSTRING_DATA (args[4]),
1339 NILP (args[5]) ? 0 : XSTRING_DATA (args[5]),
1349 DEFUN ("wnn-server-notrans-dict-add", Fwnn_notrans_dict_add, 3, MANY, 0, /*
1350 Add dictionary specified by NOTRANS-DICT-FILE-NAME, PRIORITY, DICT-FILE-MODE.
1351 Specify password files of dictionary and frequency PW1 if needed.
1353 (int nargs, Lisp_Object *args))
1355 struct gcpro gcpro1;
1358 struct wnn_env *cur_env;
1359 unsigned long vmask = 0;
1360 struct wnn_henkan_env henv;
1361 CHECK_STRING (args[0]);
1362 CHECK_INT (args[1]);
1363 if (! NILP (args[3])) CHECK_STRING (args[3]);
1364 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1365 if(!wnnfns_buf[snum]) return Qnil;
1367 gcpro1.nvars = nargs;
1369 cur_env = wnnfns_env_norm[snum];
1371 cur_env = wnnfns_env_rev[snum];
1372 dic_no = js_get_autolearning_dic(cur_env, WNN_MUHENKAN_LEARNING);
1373 if (dic_no == WNN_NO_LEARNING) {
1374 if((dic_no = jl_dic_add(wnnfns_buf[snum],
1375 XSTRING_DATA (args[0]),
1377 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV,
1379 WNN_DIC_RW, WNN_DIC_RW,
1380 NILP (args[3]) ? 0 : XSTRING_DATA (args[3]),
1387 js_set_autolearning_dic(cur_env, WNN_MUHENKAN_LEARNING, dic_no);
1389 if(!js_is_loaded_temporary_dic(cur_env)) {
1390 if(js_temporary_dic_add(cur_env,
1391 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV) < 0) {
1396 vmask |= WNN_ENV_MUHENKAN_LEARN_MASK;
1397 henv.muhenkan_flag = NILP (args[2]) ? WNN_DIC_RDONLY : WNN_DIC_RW;
1398 if(jl_set_henkan_env(wnnfns_buf[snum],
1408 DEFUN ("wnn-server-bmodify-dict-add", Fwnn_bmodify_dict_add, 3, MANY, 0, /*
1409 Add dictionary specified by BMODIFY-DICT-FILE-NAME, PRIORITY, DICT-FILE-MODE.
1410 Specify password files of dictionary and frequency PW1 if needed.
1412 (int nargs, Lisp_Object *args))
1414 struct gcpro gcpro1;
1417 struct wnn_env *cur_env;
1418 unsigned long vmask = 0;
1419 struct wnn_henkan_env henv;
1420 CHECK_STRING (args[0]);
1421 CHECK_INT (args[1]);
1422 if (! NILP (args[3])) CHECK_STRING (args[3]);
1423 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1424 if(!wnnfns_buf[snum]) return Qnil;
1426 gcpro1.nvars = nargs;
1428 cur_env = wnnfns_env_norm[snum];
1430 cur_env = wnnfns_env_rev[snum];
1431 dic_no = js_get_autolearning_dic(cur_env, WNN_BUNSETSUGIRI_LEARNING);
1432 if (dic_no == WNN_NO_LEARNING) {
1433 if((dic_no = jl_dic_add(wnnfns_buf[snum],
1434 XSTRING_DATA (args[0]),
1436 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV,
1438 WNN_DIC_RW, WNN_DIC_RW,
1439 NILP (args[3]) ? 0 : XSTRING_DATA (args[3]),
1446 js_set_autolearning_dic(cur_env, WNN_BUNSETSUGIRI_LEARNING, dic_no);
1448 if(!js_is_loaded_temporary_dic(cur_env)) {
1449 if(js_temporary_dic_add(cur_env,
1450 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV) < 0) {
1455 vmask |= WNN_ENV_BUNSETSUGIRI_LEARN_MASK;
1456 henv.bunsetsugiri_flag = NILP (args[2]) ? WNN_DIC_RDONLY : WNN_DIC_RW;
1457 if(jl_set_henkan_env(wnnfns_buf[snum],
1467 DEFUN ("wnn-server-set-last-is-first", Fwnn_last_is_first, 1, 1, 0, /*
1473 unsigned long vmask = 0;
1474 struct wnn_henkan_env henv;
1475 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1476 if(!wnnfns_buf[snum]) return Qnil;
1477 vmask |= WNN_ENV_LAST_IS_FIRST_MASK;
1478 henv.last_is_first_flag = NILP (mode) ? False : True;
1479 if(jl_set_henkan_env(wnnfns_buf[snum],
1481 &henv) < 0) return Qnil;
1485 DEFUN ("wnn-server-set-complex-conv-mode", Fwnn_complex_conv, 1, 1, 0, /*
1491 unsigned long vmask = 0;
1492 struct wnn_henkan_env henv;
1493 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1494 if(!wnnfns_buf[snum]) return Qnil;
1495 vmask |= WNN_ENV_COMPLEX_CONV_MASK;
1496 henv.complex_flag = NILP (mode) ? False : True;
1497 if(jl_set_henkan_env(wnnfns_buf[snum],
1499 &henv) < 0) return Qnil;
1503 DEFUN ("wnn-server-set-okuri-learn-mode", Fwnn_okuri_learn, 1, 1, 0, /*
1509 unsigned long vmask = 0;
1510 struct wnn_henkan_env henv;
1511 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1512 if(!wnnfns_buf[snum]) return Qnil;
1513 vmask |= WNN_ENV_OKURI_LEARN_MASK;
1514 henv.okuri_learn_flag = NILP (mode) ? False : True;
1515 if(jl_set_henkan_env(wnnfns_buf[snum],
1517 &henv) < 0) return Qnil;
1521 DEFUN ("wnn-server-set-okuri-flag", Fwnn_okuri_flag, 1, 1, 0, /*
1527 unsigned long vmask = 0;
1528 struct wnn_henkan_env henv;
1530 mode = XINT (lmode);
1531 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1532 if(!wnnfns_buf[snum]) return Qnil;
1533 if(mode != WNN_OKURI_REGULATION &&
1534 mode != WNN_OKURI_NO &&
1535 mode != WNN_OKURI_YES)
1538 henv.okuri_flag = mode;
1539 vmask |= WNN_ENV_OKURI_MASK;
1540 if(jl_set_henkan_env(wnnfns_buf[snum],
1542 &henv) < 0) return Qnil;
1546 DEFUN ("wnn-server-set-prefix-learn-mode", Fwnn_prefix_learn, 1, 1, 0, /*
1552 unsigned long vmask = 0;
1553 struct wnn_henkan_env henv;
1554 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1555 if(!wnnfns_buf[snum]) return Qnil;
1556 vmask |= WNN_ENV_PREFIX_LEARN_MASK;
1557 henv.prefix_learn_flag = NILP (mode) ? False : True;
1558 if(jl_set_henkan_env(wnnfns_buf[snum],
1560 &henv) < 0) return Qnil;
1564 DEFUN ("wnn-server-set-prefix-flag", Fwnn_prefix_flag, 1, 1, 0, /*
1570 unsigned long vmask = 0;
1571 struct wnn_henkan_env henv;
1573 mode = XINT (lmode);
1574 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1575 if(!wnnfns_buf[snum]) return Qnil;
1576 if(mode != WNN_KANA_KOUHO && mode != WNN_KANJI_KOUHO)
1579 henv.prefix_flag = mode;
1580 vmask |= WNN_ENV_PREFIX_MASK;
1581 if(jl_set_henkan_env(wnnfns_buf[snum],
1583 &henv) < 0) return Qnil;
1587 DEFUN ("wnn-server-set-suffix-learn-mode", Fwnn_suffix_learn, 1, 1, 0, /*
1593 unsigned long vmask = 0;
1594 struct wnn_henkan_env henv;
1595 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1596 if(!wnnfns_buf[snum]) return Qnil;
1597 vmask |= WNN_ENV_SUFFIX_LEARN_MASK;
1598 henv.suffix_learn_flag = NILP (mode) ? False : True;
1599 if(jl_set_henkan_env(wnnfns_buf[snum],
1601 &henv) < 0) return Qnil;
1605 DEFUN ("wnn-server-set-common-learn-mode", Fwnn_common_learn, 1, 1, 0, /*
1611 unsigned long vmask = 0;
1612 struct wnn_henkan_env henv;
1613 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1614 if(!wnnfns_buf[snum]) return Qnil;
1615 vmask |= WNN_ENV_COMMON_LAERN_MASK;
1616 henv.common_learn_flag = NILP (mode) ? False : True;
1617 if(jl_set_henkan_env(wnnfns_buf[snum],
1619 &henv) < 0) return Qnil;
1623 DEFUN ("wnn-server-set-freq-func-mode", Fwnn_freq_func, 1, 1, 0, /*
1629 unsigned long vmask = 0;
1630 struct wnn_henkan_env henv;
1632 mode = XINT (lmode);
1633 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1634 if(!wnnfns_buf[snum]) return Qnil;
1635 if(mode != 0 && mode != 1 && mode != 2 && mode != 3 && mode != 4)
1638 henv.freq_func_flag = mode;
1639 vmask |= WNN_ENV_FREQ_FUNC_MASK;
1640 if(jl_set_henkan_env(wnnfns_buf[snum],
1642 &henv) < 0) return Qnil;
1646 DEFUN ("wnn-server-set-numeric-mode", Fwnn_numeric, 1, 1, 0, /*
1652 unsigned long vmask = 0;
1653 struct wnn_henkan_env henv;
1655 mode = XINT (lmode);
1656 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1657 if(!wnnfns_buf[snum]) return Qnil;
1658 if(mode != WNN_NUM_KANSUUJI &&
1659 mode != WNN_NUM_KANOLD &&
1660 mode != WNN_NUM_HANCAN &&
1661 mode != WNN_NUM_ZENCAN &&
1662 mode != WNN_NUM_HAN &&
1663 mode != WNN_NUM_ZEN &&
1664 mode != WNN_NUM_KAN)
1667 henv.numeric_flag = mode;
1668 vmask |= WNN_ENV_NUMERIC_MASK;
1669 if(jl_set_henkan_env(wnnfns_buf[snum],
1671 &henv) < 0) return Qnil;
1675 DEFUN ("wnn-server-set-alphabet-mode", Fwnn_alphabet, 1, 1, 0, /*
1681 unsigned long vmask = 0;
1682 struct wnn_henkan_env henv;
1684 mode = XINT (lmode);
1685 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1686 if(!wnnfns_buf[snum]) return Qnil;
1687 if(mode != WNN_ALP_HAN && mode != WNN_ALP_ZEN)
1690 henv.alphabet_flag = mode;
1691 vmask |= WNN_ENV_ALPHABET_MASK;
1692 if(jl_set_henkan_env(wnnfns_buf[snum],
1694 &henv) < 0) return Qnil;
1698 DEFUN ("wnn-server-set-symbol-mode", Fwnn_symbol, 1, 1, 0, /*
1704 unsigned long vmask = 0;
1705 struct wnn_henkan_env henv;
1707 mode = XINT (lmode);
1708 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1709 if(!wnnfns_buf[snum]) return Qnil;
1710 if(mode != WNN_KIG_HAN && mode != WNN_KIG_JIS && mode != WNN_KIG_ASC)
1713 henv.symbol_flag = mode;
1714 vmask |= WNN_ENV_SYMBOL_MASK;
1715 if(jl_set_henkan_env(wnnfns_buf[snum],
1717 &henv) < 0) return Qnil;
1721 DEFUN ("wnn-server-set-yuragi-mode", Fwnn_yuragi, 1, 1, 0, /*
1727 unsigned long vmask = 0;
1728 struct wnn_henkan_env henv;
1729 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1730 if(!wnnfns_buf[snum]) return Qnil;
1731 vmask |= WNN_ENV_YURAGI_MASK;
1732 henv.yuragi_flag = NILP (mode) ? False : True;
1733 if(jl_set_henkan_env(wnnfns_buf[snum],
1735 &henv) < 0) return Qnil;
1739 DEFUN ("wnn-reset-previous-info", Fwnn_reset_prev, 0, 0, 0, /*
1745 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1746 if(!wnnfns_buf[snum]) return Qnil;
1747 if(jl_reset_prev_bun(wnnfns_buf[snum]) < 0) return Qnil;
1752 DEFUN ("wnn-server-version", Fwnn_version, 0, 0, 0, /*
1753 Returns Wnn server version ID.
1760 struct wnn_env *cur_env;
1761 if ((snum = check_wnn_server_type()) == -1) return Qnil;
1762 if(!wnnfns_buf[snum]) return Qnil;
1764 cur_env = wnnfns_env_norm[snum];
1766 cur_env = wnnfns_env_rev[snum];
1767 if(js_version (cur_env->js_id,&serv,&libv) < 0) return Qnil;
1768 return make_int (serv);
1771 DEFUN ("wnn-server-hinsi-number", Fwnn_hinsi_number, 1, 1, 0, /*
1779 CHECK_STRING (name);
1780 if ((snum = check_wnn_server_type ()) == -1) return Qnil;
1781 if (!wnnfns_buf[snum]) return Qnil;
1782 m2w (XSTRING_DATA (name), w_buf);
1783 if ((no = jl_hinsi_number (wnnfns_buf[snum], w_buf)) < 0) return Qnil;
1784 return make_int (no);
1788 syms_of_mule_wnn (void)
1790 DEFSUBR (Fwnn_open);
1791 DEFSUBR (Fwnn_close);
1792 DEFSUBR (Fwnn_dict_add);
1793 DEFSUBR (Fwnn_dict_delete);
1794 DEFSUBR (Fwnn_dict_list);
1795 DEFSUBR (Fwnn_dict_comment);
1796 DEFSUBR (Fwnn_set_rev);
1797 DEFSUBR (Fwnn_begin_henkan);
1798 DEFSUBR (Fwnn_zenkouho);
1799 DEFSUBR (Fwnn_get_zenkouho);
1800 DEFSUBR (Fwnn_zenkouho_bun);
1801 DEFSUBR (Fwnn_zenkouho_suu);
1802 DEFSUBR (Fwnn_dai_top);
1803 DEFSUBR (Fwnn_dai_end);
1804 DEFSUBR (Fwnn_kakutei);
1805 DEFSUBR (Fwnn_bunsetu_henkou);
1806 DEFSUBR (Fwnn_inspect);
1807 DEFSUBR (Fwnn_quit_henkan);
1808 DEFSUBR (Fwnn_bunsetu_kanji);
1809 DEFSUBR (Fwnn_bunsetu_yomi);
1810 DEFSUBR (Fwnn_bunsetu_suu);
1811 DEFSUBR (Fwnn_hindo_update);
1812 DEFSUBR (Fwnn_word_toroku);
1813 DEFSUBR (Fwnn_word_sakujo);
1814 DEFSUBR (Fwnn_word_use);
1815 DEFSUBR (Fwnn_word_info);
1816 DEFSUBR (Fwnn_hindo_set);
1817 DEFSUBR (Fwnn_dict_search);
1818 DEFSUBR (Fwnn_dict_save);
1819 DEFSUBR (Fwnn_get_param);
1820 DEFSUBR (Fwnn_set_param);
1821 DEFSUBR (Fwnn_get_msg);
1822 DEFSUBR (Fwnn_fuzokugo_set);
1823 DEFSUBR (Fwnn_fuzokugo_get);
1824 DEFSUBR (Fwnn_isconnect);
1825 DEFSUBR (Fwnn_hinsi_dicts);
1826 DEFSUBR (Fwnn_hinsi_list);
1827 DEFSUBR (Fwnn_hinsi_name);
1828 DEFSUBR (Fwnn_hinsi_number);
1830 DEFSUBR (Fwnn_fisys_dict_add);
1831 DEFSUBR (Fwnn_fiusr_dict_add);
1832 DEFSUBR (Fwnn_notrans_dict_add);
1833 DEFSUBR (Fwnn_bmodify_dict_add);
1834 DEFSUBR (Fwnn_last_is_first);
1835 DEFSUBR (Fwnn_complex_conv);
1836 DEFSUBR (Fwnn_okuri_learn);
1837 DEFSUBR (Fwnn_okuri_flag);
1838 DEFSUBR (Fwnn_prefix_learn);
1839 DEFSUBR (Fwnn_prefix_flag);
1840 DEFSUBR (Fwnn_suffix_learn);
1841 DEFSUBR (Fwnn_common_learn);
1842 DEFSUBR (Fwnn_freq_func);
1843 DEFSUBR (Fwnn_numeric);
1844 DEFSUBR (Fwnn_alphabet);
1845 DEFSUBR (Fwnn_symbol);
1846 DEFSUBR (Fwnn_yuragi);
1847 DEFSUBR (Fwnn_reset_prev);
1849 DEFSUBR (Fwnn_version);
1851 defsymbol (&Qjserver, "jserver");
1852 defsymbol (&Qcserver, "cserver");
1853 /* defsymbol (&Qtserver, "tserver"); */
1854 defsymbol (&Qkserver, "kserver");
1856 defsymbol (&Qwnn_no_uniq, "wnn-no-uniq");
1857 defsymbol (&Qwnn_uniq, "wnn-uniq");
1858 defsymbol (&Qwnn_uniq_kanji, "wnn-uniq-kanji");
1859 defsymbol (&Qwnn_n, "wnn_n");
1860 defsymbol (&Qwnn_nsho, "wnn_nsho");
1861 defsymbol (&Qwnn_hindo, "wnn_hindo");
1862 defsymbol (&Qwnn_len, "wnn_len");
1863 defsymbol (&Qwnn_jiri, "wnn_jiri");
1864 defsymbol (&Qwnn_flag, "wnn_flag");
1865 defsymbol (&Qwnn_jisho, "wnn_jisho");
1866 defsymbol (&Qwnn_sbn, "wnn_sbn");
1867 defsymbol (&Qwnn_dbn_len, "wnn_dbn_len");
1868 defsymbol (&Qwnn_sbn_cnt, "wnn_sbn_cnt");
1869 defsymbol (&Qwnn_suuji, "wnn_suuji");
1870 defsymbol (&Qwnn_kana, "wnn_kana");
1871 defsymbol (&Qwnn_eisuu, "wnn_eisuu");
1872 defsymbol (&Qwnn_kigou, "wnn_kigou");
1873 defsymbol (&Qwnn_toji_kakko, "wnn_toji_kakko");
1874 defsymbol (&Qwnn_fuzokogo, "wnn_fuzokogo");
1875 defsymbol (&Qwnn_kaikakko, "wnn_kaikakko");
1879 reinit_vars_of_mule_wnn (void)
1883 for (i = 0; i < NSERVER; i++)
1885 wnnfns_buf[i] = (struct wnn_buf *) 0;
1886 wnnfns_env_norm[i] = (struct wnn_env *) 0;
1887 wnnfns_env_rev[i] = (struct wnn_env *) 0;
1892 vars_of_mule_wnn (void)
1894 reinit_vars_of_mule_wnn ();
1896 DEFVAR_INT ("lb-sisheng", &lb_sisheng /*
1897 Leading character for Sisheng.
1899 DEFVAR_LISP ("wnn-server-type", &Vwnn_server_type /*
1900 *jserver, cserver ..
1902 DEFVAR_LISP ("cwnn-zhuyin", &Vcwnn_zhuyin /*
1905 DEFVAR_LISP ("wnnenv-sticky", &Vwnnenv_sticky /*
1906 *If non-nil, make environment sticky
1908 DEFVAR_LISP ("wnn-uniq-level", &Vwnn_uniq_level /*
1912 Vwnn_server_type = Qjserver;
1913 Vcwnn_zhuyin = Qnil;
1914 Vwnnenv_sticky = Qnil;
1916 Vwnn_uniq_level = Qwnn_uniq;
1918 Fprovide(intern("wnn"));
1922 w2m (w_char *wp, unsigned char *mp, unsigned char lb)
1928 while ((wc = *wp++) != 0)
1930 switch (wc & 0x8080)
1933 if (EQ(Vwnn_server_type, Qcserver))
1935 len = cwnn_yincod_pzy (pzy, wc,
1939 for (i = 0; i < len; i++)
1943 *mp++ = PRE_LEADING_BYTE_PRIVATE_1; /* #### Not sure about this one... */
1951 *mp++ = LEADING_BYTE_KATAKANA_JISX0201;
1952 *mp++ = (wc & 0xff);
1957 *mp++ = (wc & 0xff00) >> 8;
1958 *mp++ = wc & 0x00ff;
1961 if (lb == LEADING_BYTE_JAPANESE_JISX0208)
1962 *mp++ = LEADING_BYTE_JAPANESE_JISX0212;
1963 else if (lb == LEADING_BYTE_CHINESE_BIG5_1)
1964 *mp++ = LEADING_BYTE_CHINESE_BIG5_2;
1967 *mp++ = (wc & 0xff00) >> 8;
1968 *mp++ = (wc & 0x00ff) | 0x80;
1971 *mp++ = wc & 0x00ff;
1979 m2w (unsigned char *mp, w_char *wp)
1983 while ((ch = *mp++) != 0)
1985 if (BUFBYTE_LEADING_BYTE_P (ch))
1989 case LEADING_BYTE_KATAKANA_JISX0201:
1990 *wp++ = *mp++; break;
1991 case LEADING_BYTE_LATIN_JISX0201:
1992 *wp++ = *mp++ & 0x7F; break;
1993 case LEADING_BYTE_JAPANESE_JISX0208_1978:
1994 case LEADING_BYTE_CHINESE_GB2312:
1995 case LEADING_BYTE_JAPANESE_JISX0208:
1996 case LEADING_BYTE_KOREAN_KSC5601:
1997 /* case LEADING_BYTE_TW: */
1999 *wp++ = (ch << 8) | *mp++;
2001 case LEADING_BYTE_JAPANESE_JISX0212:
2003 *wp++ = (ch << 8) | (*mp++ & 0x7f);
2005 case PRE_LEADING_BYTE_PRIVATE_1: /* #### Not sure about this one... */
2007 if (ch == lb_sisheng)
2008 *wp++ = 0x8e80 | *mp++;
2012 default: /* ignore this character */
2013 mp += REP_BYTES_BY_FIRST_BYTE(ch) - 1;
2027 letter pbuf[5000], ybuf[5000];
2041 len = cwnn_pzy_yincod (ybuf, pbuf,
2042 NILP (Vcwnn_zhuyin) ? CWNN_PINYIN : CWNN_ZHUYIN);
2049 if (*pin == 0 || len == 0)
2057 c2m (unsigned char *cp, unsigned char *mp, unsigned char lb)
2060 while ((ch = *cp) != 0)
2073 dai_end (int no, int server)
2075 for (no++; no < jl_bun_suu (wnnfns_buf[server])
2076 && !jl_dai_top (wnnfns_buf[server], no); no++);
2081 yes_or_no (unsigned char *s)
2083 unsigned char mbuf[512];
2087 if ((snum = check_wnn_server_type ()) == -1) return 0;
2088 lb = lb_wnn_server_type[snum];
2089 /* if no message found, create file without query */
2090 /* if (wnn_msg_cat->msg_bd == 0) return 1;*/
2091 if (*s == 0) return 1;
2093 /* truncate "(Y/N)" */
2094 for (len = 0; (mbuf[len]) && (len < 512); len++);
2095 for (; (mbuf[len] != '(') && (len > 0); len--);
2097 Lisp_Object yes, str;
2098 struct gcpro gcpro1;
2100 str = make_string (mbuf, len);
2102 yes = call1(Qyes_or_no_p, str);
2104 if (NILP (yes)) return 0;
2112 #if 0 /* jhod: We don't really need this echoed... */
2114 Lisp_Object args[1];
2117 extern Lisp_Object Fmessage ();
2119 if ((snum = check_wnn_server_type ()) == -1) return;
2120 lb = lb_wnn_server_type[snum];
2122 args[0] = make_string (mbuf, strlen (mbuf));
2131 check_wnn_server_type (void)
2133 if (EQ(Vwnn_server_type, Qjserver))
2137 else if (EQ(Vwnn_server_type, Qcserver))
2141 /* else if (Vwnn_server_type == Qtserver)
2145 else if (EQ(Vwnn_server_type, Qkserver))