Mercurial > hg > xemacs-beta
annotate src/mule-wnnfns.c @ 5198:bc3ede8f29a8
fix spacing in some files
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-04-09 Ben Wing <ben@xemacs.org>
* fileio.c (check_writable):
* fileio.c (Fdo_auto_save):
* redisplay-xlike-inc.c (separate_textual_runs_nomule):
* redisplay-xlike-inc.c (separate_textual_runs_xft_nomule):
* redisplay-xlike-inc.c (separate_textual_runs_xft_mule):
* redisplay-xlike-inc.c (separate_textual_runs_mule):
* redisplay-xlike-inc.c (XLIKE_output_string):
* redisplay-xlike-inc.c (XLIKE_output_vertical_divider):
* redisplay.c (create_text_block):
* redisplay.c (regenerate_window):
* redisplay.c (redisplay_window):
* redisplay.c (redisplay_device):
* redisplay.c (window_line_number):
* redisplay.c (point_would_be_visible):
* redisplay.c (compute_display_line_dynarr_usage):
* specifier.c (prune_specifiers):
* specifier.c (finalize_specifier):
* specifier.c (make_magic_specifier):
* specifier.c (charset_matches_specifier_tag_set_p):
* specifier.c (Fdefine_specifier_tag):
* specifier.c (setup_device_initial_specifier_tags):
* specifier.c (bodily_specifier):
* specifier.c (add_spec_to_ghost_specifier):
* specifier.c (remove_ghost_specifier):
* specifier.c (set_specifier_fallback):
* specifier.c (specifier_instance_from_inst_list):
* specifier.c (set_specifier_caching):
Fix coding style to correspond to GNU standard.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 09 Apr 2010 23:38:02 -0500 |
parents | c0934cef10c6 |
children | 70ed8a0d8da8 |
rev | line source |
---|---|
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
1 /* -*- coding: utf-8 -*- |
428 | 2 Copyright (C) 1995 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Sun Microsystems, Inc. | |
4 | |
5 This file is part of XEmacs. | |
6 | |
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 | |
10 later version. | |
11 | |
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 | |
15 for more details. | |
16 | |
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. */ | |
21 | |
22 /* Synched up with: Mule 2.3. Not in FSF. */ | |
23 | |
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) */ | |
30 | |
31 /* | |
32 * Functions defined in this file are | |
33 * (wnn-server-open wnn-host-name login-name) | |
34 * wnn-host-name: STRING or NIL | |
35 * login-name: STRING | |
36 * RETURNS: BOOLEAN | |
37 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
38 * jserver と接続し、サーバー内部に正変換/逆変換2つの環境を |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
39 * 作る。エラーの時は nil を返す。 |
428 | 40 * |
41 * (wnn-server-close) | |
42 * RETURNS: BOOLEAN | |
43 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
44 * jserver との接続を切る。辞書、頻度はセーブされない。 |
428 | 45 * |
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 | |
50 * priority: INTEGER | |
51 * dict-file-mode: BOOLEAN | |
52 * hindo-file-mode: BOOLEAN | |
53 * pw1: STRING or NIL | |
54 * pw2: STRING or NIL | |
55 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
56 * 辞書ファイル名、頻度ファイル名、優先度、辞書ファイルモード |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
57 * 頻度ファイルモードで指定した辞書をバッファに追加する。 |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
58 * pw1, pw2 は辞書ファイル、頻度ファイルのパスワード。 |
428 | 59 * |
60 * (wnn-server-dict-delete dic-no) | |
61 * dic-no: INTEGER | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
62 * RETURNS: エラーの時 nil |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
63 * DESCRIPTION: dic-no の辞書番号の辞書を、バッファから |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
64 * 削除する。 |
428 | 65 * |
66 * (wnn-server-dict-list) | |
67 * RETURNS: ((dic-no1 file-name1 comment1 word-no1 nice1) | |
68 * (dic-no2 file-name2 comment2 word-no2 nice2)...) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
69 * DESCRIPTION: バッファ上の辞書のリストを得る。 |
428 | 70 * |
71 * (wnn-server-dict-comment dic-no comment) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
72 * RETURNS: エラーの時 nil |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
73 * DESCRIPTION: dic-no の辞書にコメントをつける。 |
428 | 74 * |
75 * (wnn-server-set-rev rev) | |
76 * rev: BOOLEAN | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
77 * rev が nil の時は正変換、それ以外の時は逆変換 |
428 | 78 * |
79 * (wnn-server-henkan-begin henkan-string) | |
80 * henkan-string: STRING | |
81 * RETURNS: bunsetu-suu | |
82 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
83 * 仮名漢字変換をし、第一候補の文節数を返す。 |
428 | 84 * |
85 * (wnn-server-zenkouho bunsetu-no dai) | |
86 * bunsetu-no: INTEGER | |
87 * dai: BOOLEAN | |
88 * RETURNS: offset | |
89 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
90 * 文節番号で指定された文節の全候補をとりだし |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
91 * 、現在のオフセットを返す。 |
428 | 92 * |
93 * (wnn-server-get-zenkouho offset) | |
94 * bunsetu-no: INTEGER | |
95 * dai: BOOLEAN | |
96 * RETURNS: list of zenkouho | |
97 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
98 * オフセットで指定された候補を得る。 |
428 | 99 * |
100 * (wnn-server-zenkouho-bun) | |
101 * RETURNS: INTEGER | |
102 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
103 * 全候補を表示している文節番号を得る。 |
428 | 104 * |
105 * (wnn-server-zenkouho-suu) | |
106 * RETURNS: INTEGER | |
107 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
108 * 全候補を表示している文節の全候補数を得る。 |
428 | 109 * |
110 * (wnn-server-dai-top bun-no) | |
111 * bun-no: INTEGER | |
112 * RETURNS: BOOLEAN | |
113 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
114 * 文節が大文節の先頭なら t |
428 | 115 * |
116 * (wnn-server-dai-end bun-no) | |
117 * bun-no: INTEGER | |
118 * RETURNS: INTEGER | |
119 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
120 * 次の大文節の文節番号を得る。 |
428 | 121 * |
122 * (wnn-server-henkan-kakutei kouho-no dai) | |
123 * kouho-no: INTEGER | |
124 * dai: BOOLEAN | |
125 * RETURNS: BOOLEAN | |
126 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
127 * 候補番号で示された候補を選択する。 |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
128 * (wnn-server-zenkouho) を呼んてからでないといけない。 |
428 | 129 * |
130 * (wnn-server-bunsetu-henkou bunsetu-no bunsetu-length dai) | |
131 * bunsetu-no: INTEGER | |
132 * bunsetu-length: INTEGER | |
133 * dai: BOOLEAN | |
134 * RETURNS: | |
135 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
136 * 文節の長さを変更する。 |
428 | 137 * |
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) | |
142 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
143 * 文節の色々な情報を変換バッファからとり出す。 |
428 | 144 * |
145 * (wnn-server-henkan-quit) | |
146 * RETURNS: BOOLEAN | |
147 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
148 * 何もしない。 |
428 | 149 * |
150 * (wnn-server-bunsetu-kanji bun-no) | |
151 * RETURNS: (bunsetu-kanji length) | |
152 * DESCRIPTION: | |
153 * | |
154 * (wnn-server-bunsetu-yomi bun-no) | |
155 * RETURNS: (bunsetu-yomi length) | |
156 * DESCRIPTION: | |
157 * | |
158 * (wnn-server-bunsetu-suu) | |
159 * RETURNS: bunsetu-suu | |
160 * DESCRIPTION: | |
161 * | |
162 * (wnn-server-hindo-update &optional bunsetu-no) | |
163 * bunsetu-no: INTEGER | |
164 * RETURNS: BOOLEAN | |
165 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
166 * 頻度情報を更新する。 |
428 | 167 * |
168 * (wnn-server-word-add dic-no tango yomi comment hinsi) | |
169 * dic-no: INTEGER | |
170 * tango: STRING | |
171 * yoni: STRING | |
172 * comment: STRING | |
173 * hinsi: INTEGER | |
174 * RETURNS: BOOLEAN | |
175 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
176 * 辞書に単語を登録する。 |
428 | 177 * |
178 * (wnn-server-word-delete dic-no entry) | |
179 * dic-no: INTEGER | |
180 * entry: INTEGER | |
181 * RETURNS: BOOLEAN | |
182 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
183 * 辞書からエントリ番号で示される単語を削除する。 |
428 | 184 * |
185 * (wnn-server-word-use dic-no entry) | |
186 * dic-no: INTEGER | |
187 * entry: INTEGER | |
188 * RETURNS: BOOLEAN | |
189 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
190 * 辞書からエントリ番号で示される単語の有効/無効をトグルする。 |
428 | 191 * |
192 * (wnn-server-word-info dic-no entry) | |
193 * dic-no: INTEGER | |
194 * entry: INTEGER | |
195 * RETURNS: (yomi kanji comment hindo hinsi) | |
196 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
197 * 辞書からエントリ番号で示される単語の情報を得る。 |
428 | 198 * |
199 * (wnn-server-word-hindo-set dic-no entry hindo) | |
200 * dic-no: INTEGER | |
201 * entry: INTEGER | |
202 * hindo: INTEGER | |
203 * RETURNS: BOOLEAN | |
204 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
205 * 辞書からエントリ番号で示される単語の頻度を設定する。 |
428 | 206 * |
207 * (wnn-server-word-search yomi) | |
208 * yomi: STRING | |
209 * RETURNS: a LIST of dict-joho | |
210 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
211 * 全ての辞書から単語検索を行なう。 |
428 | 212 * |
213 * (wnn-server-dict-save) | |
214 * RETURNS: BOOLEAN | |
215 * DESCRIPTION: | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
216 * 全ての辞書と頻度ファイルをセーブする。 |
428 | 217 * |
218 * (wnn-server-get-param) | |
219 * RETURNS: (n nsho p1 p2 p3 ... p15) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
220 * DESCRIPTION: 変換パラメータを得る。 |
428 | 221 * |
222 * (wnn-server-set-param n sho p1 ... p15) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
223 * RETURNS: エラーの時 nil |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
224 * DESCRIPTION: 変換パラメータを設定する。 |
428 | 225 * |
226 * (wnn-server-get-msg error-no) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
227 * RETURNS: エラーメ臆技ージ |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
228 * DESCRIPTION: エラー番号からメッセージを得る。 |
428 | 229 * |
230 * (wnn-server-fuzokugo-set fname) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
231 * RETURNS: エラーの時 nil |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
232 * DESCRIPTION: バッファに附属語ファイルを読み込む。 |
428 | 233 * |
234 * (wnn-server-fuzokugo-get) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
235 * RETURNS: ファイル名 |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
236 * DESCRIPTION: バッファの附属語ファイル名を得る。 |
428 | 237 * |
238 * (wnn-server-isconnect) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
239 * RETURNS: コネクトしてれば t, してなければ nil |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
240 * DESCRIPTION: サーバと継っているか調べる。 |
428 | 241 * |
242 * (wnn-server-hinsi-dicts hinsi-no) | |
243 * RETURNS: (dic-no1 dic-no2 ...) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
244 * DESCRIPTION: hinsi-no の品詞が登録できる辞書のリストを得る。 |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
245 * hinsi-no = -1 のときには、登録可能な全辞書を得る。 |
428 | 246 * |
247 * (wnn-server-hinsi-list dic-no name) | |
248 * RETURNS: (name1 name2 ... ) | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
249 * DESCRIPTION: dic-no の辞書で、品詞ノードに属する |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
250 * 品詞ノード(名)のリストを得る。 |
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
251 * 品詞名を与えた時は、0を返す。 |
428 | 252 * |
253 * (wnn-server-hinsi-name hinsi-no) | |
254 * RETURNS: hinsi-name | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
255 * DESCRIPTION: 品詞番号から名前を取る。 |
428 | 256 * |
257 * (wnn-server-hinsi-number hinsi-name) | |
258 * RETURNS: hinsi-no | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
259 * DESCRIPTION: 品詞名を品詞番号に変換する。 |
428 | 260 * |
261 * (wnn-server-version) | |
262 * RETURNS: version ID(int) | |
263 * | |
264 */ | |
265 | |
266 #include <config.h> | |
267 #include "lisp.h" | |
268 | |
269 #include "buffer.h" | |
270 #include "window.h" | |
271 #include "sysdep.h" | |
272 | |
273 #include "wnn/commonhd.h" | |
771 | 274 #include "charset.h" |
428 | 275 #include "wnn/jllib.h" |
276 #include "wnn/cplib.h" | |
277 | |
4993
c0934cef10c6
convert some source files to utf-8
Ben Wing <ben@xemacs.org>
parents:
2367
diff
changeset
|
278 /* UCHAR が二重定義されるので */ |
428 | 279 #define _UCHAR_T |
280 | |
281 #define EGG_TIMEOUT 5 | |
282 #define NSERVER 4 | |
283 #define WNNSERVER_J 0 | |
284 #define WNNSERVER_C 1 | |
285 #define WNNSERVER_T 2 | |
286 #define WNNSERVER_K 3 | |
287 | |
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); | |
296 | |
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); | |
301 | |
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}; | |
308 | |
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; | |
458 | 324 Fixnum lb_sisheng; |
428 | 325 |
326 /* Lisp functions definition */ | |
327 | |
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. | |
444 | 331 Return nil if error occurs. |
428 | 332 */ |
333 (hname, lname)) | |
334 { | |
335 char *envname; | |
336 char *langname; | |
337 char *hostname; | |
338 int snum; | |
339 int size; | |
340 CHECK_STRING (lname); | |
341 | |
342 snum = check_wnn_server_type (); | |
343 switch (snum) | |
344 { | |
345 case WNNSERVER_J: | |
346 langname = "ja_JP"; | |
347 break; | |
348 case WNNSERVER_C: | |
349 langname = "zh_CN"; | |
350 break; | |
351 /* | |
352 case WNNSERVER_T: | |
353 strcpy (langname, "zh_TW"); | |
354 break; | |
355 */ | |
356 case WNNSERVER_K: | |
357 langname = "ko_KR"; | |
358 break; | |
359 case -1: | |
360 default: | |
361 return Qnil; | |
362 } | |
363 size = XSTRING_LENGTH (lname) > 1024 ? 1026 : XSTRING_LENGTH (lname) + 2; | |
2367 | 364 /* !!#### */ |
1650 | 365 envname = (char *) ALLOCA (size); |
428 | 366 strncpy (envname, (char *) XSTRING_DATA (lname), size-2); |
367 envname[size-2] = '\0'; | |
368 if (NILP (hname)) hostname = ""; | |
369 else | |
370 { | |
371 CHECK_STRING (hname); | |
372 size = XSTRING_LENGTH(hname) > 1024 ? 1025 : XSTRING_LENGTH(hname) + 1; | |
373 | |
1650 | 374 hostname = (char *) ALLOCA (size); |
428 | 375 strncpy (hostname, (char *) XSTRING_DATA (hname), size-1); |
376 hostname[size-1] = '\0'; | |
377 } | |
378 CHECK_STRING (lname); | |
379 /* 97/4/16 jhod@po.iijnet.or.jp | |
380 * libwnn uses SIGALRM, so we need to stop and start interrupts. | |
381 */ | |
382 stop_interrupts(); | |
383 if (!(wnnfns_buf[snum] = jl_open_lang (envname, hostname, langname, | |
384 0, 0, 0, EGG_TIMEOUT))) | |
385 { | |
386 start_interrupts(); | |
387 return Qnil; | |
388 } | |
389 if (!jl_isconnect (wnnfns_buf[snum])) | |
390 { | |
391 start_interrupts(); | |
392 return Qnil; | |
393 } | |
394 wnnfns_env_norm[snum] = jl_env_get (wnnfns_buf[snum]); | |
395 /* if (Vwnnenv_sticky == Qt) jl_env_sticky_e (wnnfns_env_norm[snum]); | |
396 else jl_env_un_sticky_e (wnnfns_env_norm[snum]);*/ | |
397 strcat (envname, "R"); | |
398 if (!(wnnfns_env_rev[snum] = jl_connect_lang (envname, hostname, langname, | |
399 0, 0, 0, EGG_TIMEOUT))) | |
400 { | |
401 start_interrupts(); | |
402 return Qnil; | |
403 } | |
404 /* if (Vwnnenv_sticky == Qt) jl_env_sticky_e (wnnfns_env_rev[snum]); | |
405 else jl_env_un_sticky_e (wnnfns_env_rev[snum]);*/ | |
406 start_interrupts(); | |
407 return Qt; | |
408 } | |
409 | |
410 | |
411 DEFUN ("wnn-server-close", Fwnn_close, 0, 0, 0, /* | |
412 Close the connection to jserver, Dictionary and frequency files | |
413 are not saved. | |
414 */ | |
415 ()) | |
416 { | |
417 int snum; | |
418 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
419 if (!wnnfns_buf[snum]) return Qnil; | |
420 if (wnnfns_env_norm[snum]) | |
421 { | |
422 if (NILP (Vwnnenv_sticky)) jl_env_un_sticky_e (wnnfns_env_norm[snum]); | |
423 else jl_env_sticky_e (wnnfns_env_norm[snum]); | |
424 jl_disconnect (wnnfns_env_norm[snum]); | |
425 } | |
426 if (wnnfns_env_rev[snum]) | |
427 { | |
428 if (NILP (Vwnnenv_sticky)) jl_env_un_sticky_e (wnnfns_env_rev[snum]); | |
429 else jl_env_sticky_e (wnnfns_env_rev[snum]); | |
430 jl_disconnect (wnnfns_env_rev[snum]); | |
431 } | |
432 jl_env_set (wnnfns_buf[snum], 0); | |
433 jl_close (wnnfns_buf[snum]); | |
434 wnnfns_buf[snum] = (struct wnn_buf *) 0; | |
435 wnnfns_env_norm[snum] = wnnfns_env_rev[snum] = (struct wnn_env *) 0; | |
436 return Qt; | |
437 } | |
438 | |
439 DEFUN ("wnn-server-dict-add", Fwnn_dict_add, 5, MANY, 0, /* | |
440 Add dictionary specified by DICT-FILE-NAME, FREQ-FILE-NAME, | |
441 PRIORITY, DICT-FILE-MODE, FREQ-FILE-MODE. | |
442 Specify password files of dictionary and frequency, PW1 and PW2, if needed. | |
443 */ | |
444 (int nargs, Lisp_Object *args)) | |
445 { | |
446 struct gcpro gcpro1; | |
447 int snum; | |
448 CHECK_STRING (args[0]); | |
449 CHECK_STRING (args[1]); | |
450 CHECK_INT (args[2]); | |
451 if (! NILP (args[5])) CHECK_STRING (args[5]); | |
452 if (! NILP (args[6])) CHECK_STRING (args[6]); | |
453 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
454 if (!wnnfns_buf[snum]) return Qnil; | |
455 GCPRO1 (*args); | |
456 gcpro1.nvars = nargs; | |
457 if (jl_dic_add (wnnfns_buf[snum], | |
458 XSTRING_DATA (args[0]), | |
459 XSTRING_DATA (args[1]), | |
460 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV, | |
461 XINT (args[2]), | |
462 NILP (args[3]) ? WNN_DIC_RDONLY : WNN_DIC_RW, | |
463 NILP (args[4]) ? WNN_DIC_RDONLY : WNN_DIC_RW, | |
464 NILP (args[5]) ? 0 : XSTRING_DATA (args[5]), | |
465 NILP (args[6]) ? 0 : XSTRING_DATA (args[6]), | |
466 yes_or_no, | |
467 puts2 ) < 0) | |
468 { | |
469 UNGCPRO; | |
470 return Qnil; | |
471 } | |
472 UNGCPRO; | |
473 return Qt; | |
474 } | |
475 | |
476 DEFUN ("wnn-server-dict-delete", Fwnn_dict_delete, 1, 1, 0, /* | |
477 Remove dictionary specified by DIC-NUMBER from buffer. | |
478 */ | |
479 (dicno)) | |
480 { | |
481 int no; | |
482 int snum; | |
483 CHECK_INT (dicno); | |
484 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
485 no = XINT (dicno); | |
486 if (!wnnfns_buf[snum]) return Qnil; | |
487 if (jl_dic_delete (wnnfns_buf[snum], no) < 0) return Qnil; | |
488 return Qt; | |
489 } | |
490 | |
491 DEFUN ("wnn-server-dict-list", Fwnn_dict_list, 0, 0, 0, /* | |
492 Return information of dictionaries. | |
493 */ | |
494 ()) | |
495 { | |
496 WNN_DIC_INFO *dicinfo; | |
497 int cnt, i; | |
498 unsigned char comment[1024]; | |
499 Lisp_Object val; | |
500 int snum; | |
501 unsigned char lb; | |
502 | |
503 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
504 lb = lb_wnn_server_type[snum]; | |
505 if (!wnnfns_buf[snum]) return Qnil; | |
506 #ifdef WNN6 | |
507 if((cnt = jl_fi_dic_list (wnnfns_buf[snum], 0x3f, &dicinfo)) < 0) | |
508 return Qnil; | |
509 #else | |
510 if((cnt = jl_dic_list (wnnfns_buf[snum], &dicinfo)) < 0) return Qnil; | |
511 #endif | |
512 val = Qnil; | |
513 for (i = 0, dicinfo += cnt; i < cnt; i++) | |
514 { | |
515 dicinfo--; | |
516 w2m (dicinfo->comment, comment, lb); | |
517 /* #### The following has not been Mule-ized!! | |
518 fname and comment must be ASCII strings! */ | |
519 val = | |
520 Fcons (Fcons (make_int (dicinfo->dic_no), | |
867 | 521 list4 (make_string ((Ibyte *) (dicinfo->fname), |
428 | 522 strlen (dicinfo->fname)), |
523 make_string (comment, strlen ((char *) comment)), | |
524 make_int (dicinfo->gosuu), | |
525 make_int (dicinfo->nice))), val); | |
526 } | |
527 return val; | |
528 } | |
529 | |
530 DEFUN ("wnn-server-dict-comment", Fwnn_dict_comment, 2, 2, 0, /* | |
531 Set comment to dictionary specified by DIC-NUMBER. | |
444 | 532 Comment string COMMENT. |
428 | 533 */ |
534 (dicno, comment)) | |
535 { | |
536 w_char wbuf[512]; | |
537 int snum; | |
538 CHECK_INT (dicno); | |
539 CHECK_STRING (comment); | |
540 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
541 if (!wnnfns_buf[snum]) return Qnil; | |
542 m2w (XSTRING_DATA (comment), wbuf); | |
543 if (jl_dic_comment_set (wnnfns_buf[snum], XINT (dicno), wbuf) < 0) | |
544 return Qnil; | |
545 return Qt; | |
546 } | |
547 | |
548 | |
549 DEFUN ("wnn-server-set-rev", Fwnn_set_rev, 1, 1, 0, /* | |
550 Switch the translation mode to normal if T, or reverse if NIL. | |
551 */ | |
552 (rev)) | |
553 { | |
554 int snum; | |
555 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
556 if (NILP (rev)) | |
557 { | |
558 if ((!wnnfns_buf[snum]) || (!wnnfns_env_norm[snum])) return Qnil; | |
559 jl_env_set (wnnfns_buf[snum], wnnfns_env_norm[snum]); | |
560 wnnfns_norm = 1; | |
561 } | |
562 else | |
563 { | |
564 if ((!wnnfns_buf[snum]) || (!wnnfns_env_rev[snum])) return Qnil; | |
565 jl_env_set (wnnfns_buf[snum], wnnfns_env_rev[snum]); | |
566 wnnfns_norm = 0; | |
567 } | |
568 return Qt; | |
569 } | |
570 | |
571 DEFUN ("wnn-server-henkan-begin", Fwnn_begin_henkan, 1, 1, 0, /* | |
572 Translate YOMI string to kanji. Retuen the number of bunsetsu. | |
573 */ | |
574 (hstring)) | |
575 { | |
576 int cnt; | |
577 w_char wbuf[5000]; | |
578 int snum; | |
579 CHECK_STRING (hstring); | |
580 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
581 if (!wnnfns_buf[snum]) return Qnil; | |
582 m2w (XSTRING_DATA (hstring), wbuf); | |
583 if (snum == WNNSERVER_C) | |
584 w2y (wbuf); | |
585 | |
586 #ifdef WNN6 | |
587 if ((cnt = jl_fi_ren_conv (wnnfns_buf[snum], wbuf, 0, -1, WNN_USE_MAE)) < 0) | |
588 return Qnil; | |
589 #else | |
590 if ((cnt = jl_ren_conv (wnnfns_buf[snum], wbuf, 0, -1, WNN_USE_MAE)) < 0) | |
591 return Qnil; | |
592 #endif | |
593 return make_int (cnt); | |
594 } | |
595 | |
596 DEFUN ("wnn-server-zenkouho", Fwnn_zenkouho, 2, 2, 0, /* | |
597 Get zenkouho at BUNSETSU-NUMBER. Second argument DAI is t. | |
598 if dai-bunsetsu, NIL if sho-bunsetsu. Return the current offset of zenkouho. | |
599 */ | |
600 (bunNo, dai)) | |
601 { | |
602 int no, offset; | |
603 int snum; | |
604 int uniq_level; | |
605 CHECK_INT (bunNo); | |
606 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
607 if (!wnnfns_buf[snum]) return Qnil; | |
608 no = XINT (bunNo); | |
609 if (EQ(Vwnn_uniq_level, Qwnn_no_uniq)) uniq_level = WNN_NO_UNIQ; | |
610 else if (EQ(Vwnn_uniq_level, Qwnn_uniq)) uniq_level = WNN_UNIQ; | |
611 else uniq_level = WNN_UNIQ_KNJ; | |
612 if (NILP (dai)) | |
613 { | |
614 if ((offset = jl_zenkouho (wnnfns_buf[snum],no,WNN_USE_MAE, | |
615 uniq_level)) < 0) | |
616 return Qnil; | |
617 } | |
618 else | |
619 { | |
620 if ((offset = jl_zenkouho_dai (wnnfns_buf[snum], no, dai_end (no, snum), | |
621 WNN_USE_MAE, uniq_level)) < 0) | |
622 return Qnil; | |
623 } | |
624 return make_int (offset); | |
625 } | |
626 | |
627 | |
628 DEFUN ("wnn-server-get-zenkouho", Fwnn_get_zenkouho, 1, 1, 0, /* | |
629 Get kanji string of KOUHO-NUMBER. | |
630 */ | |
631 (kouhoNo)) | |
632 { | |
633 unsigned char kanji_buf[256]; | |
634 w_char wbuf[256]; | |
635 int snum; | |
636 unsigned char lb; | |
637 CHECK_INT (kouhoNo); | |
638 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
639 lb = lb_wnn_server_type[snum]; | |
640 if (!wnnfns_buf[snum]) return Qnil; | |
641 jl_get_zenkouho_kanji (wnnfns_buf[snum], XINT (kouhoNo), wbuf); | |
642 w2m (wbuf, kanji_buf, lb); | |
643 return make_string (kanji_buf, strlen ((char *) kanji_buf)); | |
644 } | |
645 | |
646 DEFUN ("wnn-server-zenkouho-bun", Fwnn_zenkouho_bun, 0, 0, 0, /* | |
647 For Wnn. | |
648 */ | |
649 ()) | |
650 { | |
651 int snum; | |
652 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
653 return make_int (jl_zenkouho_bun (wnnfns_buf[snum])); | |
654 } | |
655 | |
656 DEFUN ("wnn-server-zenkouho-suu", Fwnn_zenkouho_suu, 0, 0, 0, /* | |
657 Return the number of zen kouho. | |
658 */ | |
659 ()) | |
660 { | |
661 int snum; | |
662 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
663 return make_int (jl_zenkouho_suu (wnnfns_buf[snum])); | |
664 } | |
665 | |
666 DEFUN ("wnn-server-dai-top", Fwnn_dai_top, 1, 1, 0, /* | |
667 Return t if bunsetsu BUN-NUMBER is dai-bunsetsu. | |
668 */ | |
669 (bunNo)) | |
670 { | |
671 int snum; | |
672 CHECK_INT (bunNo); | |
673 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
674 if (!wnnfns_buf[snum]) return Qnil; | |
675 if (jl_dai_top (wnnfns_buf[snum], XINT (bunNo)) == 1) return Qt; | |
676 else return Qnil; | |
677 } | |
678 | |
679 DEFUN ("wnn-server-dai-end", Fwnn_dai_end, 1, 1, 0, /* | |
680 Return the bunsetu number of the next dai-bunsetsu after BUN-NUMBER. | |
681 */ | |
682 (bunNo)) | |
683 { | |
684 int snum; | |
685 CHECK_INT (bunNo); | |
686 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
687 if (!wnnfns_buf[snum]) return Qnil; | |
688 return make_int (dai_end (XINT (bunNo), snum)); | |
689 } | |
690 | |
691 DEFUN ("wnn-server-henkan-kakutei", Fwnn_kakutei, 2, 2, 0, /* | |
692 Set candidate with OFFSET, DAI. DAI is T if dai-bunsetsu. | |
693 */ | |
694 (offset, dai)) | |
695 { | |
696 int snum; | |
697 CHECK_INT (offset); | |
698 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
699 if (!wnnfns_buf[snum]) return Qnil; | |
700 if (NILP (dai)) | |
701 { | |
702 if (jl_set_jikouho (wnnfns_buf[snum], XINT (offset)) < 0) return Qnil; | |
703 } | |
704 else | |
705 { | |
706 if (jl_set_jikouho_dai (wnnfns_buf[snum], XINT (offset)) < 0) | |
707 return Qnil; | |
708 } | |
709 return Qt; | |
710 } | |
711 | |
712 DEFUN ("wnn-server-bunsetu-henkou", Fwnn_bunsetu_henkou, 3, 3, 0, /* | |
713 Change length of BUN-NUMBER bunsetu to LEN. DAI is T if dai-bunsetsu. | |
714 */ | |
715 (bunNo, len, dai)) | |
716 { | |
717 int cnt, no; | |
718 int snum; | |
719 CHECK_INT (bunNo); | |
720 CHECK_INT (len); | |
721 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
722 if (!wnnfns_buf[snum]) return Qnil; | |
723 no = XINT (bunNo); | |
724 #ifdef WNN6 | |
725 if ((cnt = jl_fi_nobi_conv (wnnfns_buf[snum], no, XINT(len), -1, WNN_USE_MAE, | |
726 NILP (dai) ? WNN_SHO : WNN_DAI)) < 0) | |
727 return Qnil; | |
728 #else | |
729 if ((cnt = jl_nobi_conv (wnnfns_buf[snum], no, XINT(len), -1, WNN_USE_MAE, | |
730 NILP (dai) ? WNN_SHO : WNN_DAI)) < 0) | |
731 return Qnil; | |
732 #endif | |
733 return make_int (cnt); | |
734 } | |
735 | |
736 DEFUN ("wnn-server-inspect", Fwnn_inspect, 1, 1, 0, /* | |
737 Get bunsetsu information specified by BUN-NUMBER. | |
738 */ | |
739 (bunNo)) | |
740 { | |
741 Lisp_Object val; | |
742 unsigned char cbuf[512]; | |
743 w_char wbuf[256]; | |
744 int bun_no, yomilen, jirilen, i; | |
745 int snum; | |
746 unsigned char lb; | |
747 CHECK_INT (bunNo); | |
748 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
749 lb = lb_wnn_server_type[snum]; | |
750 if (!wnnfns_buf[snum]) return Qnil; | |
751 bun_no = XINT (bunNo); | |
752 val = Qnil; | |
753 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->kangovect), val); | |
754 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->daihyoka), val); | |
755 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->hyoka), val); | |
756 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->ima), val); | |
757 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->hindo), val); | |
758 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->hinsi), val); | |
759 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->entry), val); | |
760 val = Fcons (make_int (wnnfns_buf[snum]->bun[bun_no]->dic_no), val); | |
761 yomilen = jl_get_yomi (wnnfns_buf[snum], bun_no, bun_no + 1, wbuf); | |
762 jirilen = wnnfns_buf[snum]->bun[bun_no]->jirilen; | |
763 for (i = yomilen; i >= jirilen; i--) wbuf[i+1] = wbuf[i]; | |
764 wbuf[jirilen] = '+'; | |
765 w2m (wbuf, cbuf, lb); | |
766 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val); | |
767 jl_get_kanji (wnnfns_buf[snum], bun_no, bun_no + 1, wbuf); | |
768 w2m (wbuf, cbuf, lb); | |
793 | 769 return Fcons (make_string (cbuf, strlen ((char *) cbuf)), val); |
428 | 770 } |
771 | |
772 | |
773 DEFUN ("wnn-server-henkan-quit", Fwnn_quit_henkan, 0, 0, 0, /* | |
444 | 774 do nothing. |
428 | 775 */ |
776 ()) | |
777 { | |
778 int snum; | |
779 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
780 if (!wnnfns_buf[snum]) return Qnil; | |
781 return Qt; | |
782 } | |
783 | |
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. | |
786 */ | |
787 (bunNo)) | |
788 { | |
789 int no; | |
790 unsigned char kanji_buf[256]; | |
791 w_char wbuf[256]; | |
792 int kanji_len; | |
793 int snum; | |
794 unsigned char lb; | |
795 CHECK_INT (bunNo); | |
796 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
797 lb = lb_wnn_server_type[snum]; | |
798 if (!wnnfns_buf[snum]) return Qnil; | |
799 no = XINT (bunNo); | |
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)); | |
804 } | |
805 | |
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. | |
808 */ | |
809 (bunNo)) | |
810 { | |
811 int no; | |
812 unsigned char yomi_buf[256]; | |
813 w_char wbuf[256]; | |
814 int yomi_len; | |
815 int snum; | |
816 unsigned char lb; | |
817 CHECK_INT (bunNo); | |
818 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
819 lb = lb_wnn_server_type[snum]; | |
820 if (!wnnfns_buf[snum]) return Qnil; | |
821 no = XINT (bunNo); | |
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)); | |
826 } | |
827 | |
828 DEFUN ("wnn-server-bunsetu-suu", Fwnn_bunsetu_suu, 0, 0, 0, /* | |
829 Get the number of bunsetsu. | |
830 */ | |
831 ()) | |
832 { | |
833 int snum; | |
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])); | |
837 } | |
838 | |
839 DEFUN ("wnn-server-hindo-update", Fwnn_hindo_update, 0, 1, 0, /* | |
840 Update frequency of bunsetsu specified by NUM-NUMBER. | |
841 */ | |
842 (bunNo)) | |
843 { | |
844 int no; | |
845 int snum; | |
846 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
847 if (NILP (bunNo)) no = -1; | |
848 else | |
849 { | |
850 CHECK_INT (bunNo); | |
851 no = XINT (bunNo); | |
852 } | |
853 if (!wnnfns_buf[snum]) return Qnil; | |
854 #ifdef WNN6 | |
855 if (jl_optimize_fi (wnnfns_buf[snum], 0, no) < 0) return Qnil; | |
856 #else | |
857 if (jl_update_hindo (wnnfns_buf[snum], 0, no) < 0) return Qnil; | |
858 #endif | |
859 return Qt; | |
860 } | |
861 | |
862 | |
863 DEFUN ("wnn-server-word-add", Fwnn_word_toroku, 5, 5, 0, /* | |
864 Add a word to dictionary. Arguments are | |
444 | 865 DIC-NUMBER, KANJI, YOMI, COMMENT, HINSI-NUMBER. |
428 | 866 */ |
867 (dicno, kanji, yomi, comment, hinsi)) | |
868 { | |
869 w_char yomi_buf[256], kanji_buf[256], comment_buf[256]; | |
870 int snum; | |
871 CHECK_INT (dicno); | |
872 CHECK_STRING (kanji); | |
873 CHECK_STRING (yomi); | |
874 CHECK_STRING (comment); | |
875 CHECK_INT (hinsi); | |
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) | |
880 w2y (yomi_buf); | |
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) | |
885 return Qnil; | |
886 else return Qt; | |
887 } | |
888 | |
889 | |
890 DEFUN ("wnn-server-word-delete", Fwnn_word_sakujo, 2, 2, 0, /* | |
444 | 891 Delete a word from dictionary, specified by DIC-NUMBER, SERIAL-NUMBER. |
428 | 892 */ |
893 (no, serial)) | |
894 { | |
895 int snum; | |
896 CHECK_INT (no); | |
897 CHECK_INT (serial); | |
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) | |
901 return Qnil; | |
902 else return Qt; | |
903 } | |
904 | |
905 | |
906 DEFUN ("wnn-server-word-use", Fwnn_word_use, 2, 2, 0, /* | |
444 | 907 Toggle on/off word, specified by DIC-NUMBER and SERIAL-NUMBER. |
428 | 908 */ |
909 (no, serial)) | |
910 { | |
911 int snum; | |
912 CHECK_INT (no); | |
913 CHECK_INT (serial); | |
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) | |
917 return Qnil; | |
918 else return Qt; | |
919 } | |
920 | |
921 DEFUN ("wnn-server-word-info", Fwnn_word_info, 2, 2, 0, /* | |
922 Return list of yomi, kanji, comment, hindo, hinshi. | |
923 */ | |
924 (no, serial)) | |
925 { | |
926 Lisp_Object val; | |
927 struct wnn_jdata *info_buf; | |
928 unsigned char cbuf[512]; | |
929 int snum; | |
930 unsigned char lb; | |
931 CHECK_INT (no); | |
932 CHECK_INT (serial); | |
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) | |
938 { | |
939 return Qnil; | |
940 } | |
941 else | |
942 { | |
943 val = Qnil; | |
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); | |
952 return val; | |
953 } | |
954 } | |
955 | |
956 DEFUN ("wnn-server-word-hindo-set", Fwnn_hindo_set, 3, 3, 0, /* | |
957 Set frequency to arbitrary value. Specified by DIC-NUMBER, | |
444 | 958 SERIAL-NUMBER, FREQUENCY. |
428 | 959 */ |
960 (no, serial, hindo)) | |
961 { | |
962 int snum; | |
963 CHECK_INT (no); | |
964 CHECK_INT (serial); | |
965 CHECK_INT (hindo); | |
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]), | |
969 XINT (no), | |
970 XINT (serial), | |
971 WNN_HINDO_NOP, | |
972 XINT (hindo)) < 0) | |
973 return Qnil; | |
974 else return Qt; | |
975 } | |
976 | |
977 | |
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). | |
981 */ | |
982 (yomi)) | |
983 { | |
984 Lisp_Object val; | |
985 struct wnn_jdata *wordinfo; | |
986 int i, count; | |
987 w_char wbuf[256]; | |
988 unsigned char kanji_buf[256]; | |
989 int snum; | |
990 unsigned char lb; | |
991 CHECK_STRING (yomi); | |
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) | |
997 w2y (wbuf); | |
998 if ((count = jl_word_search_by_env (wnnfns_buf[snum], | |
999 wbuf, &wordinfo)) < 0) | |
1000 return Qnil; | |
1001 val = Qnil; | |
1002 for (i = 0, wordinfo += count; i < count; i++) | |
1003 { | |
1004 wordinfo--; | |
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))), | |
1011 val); | |
1012 } | |
1013 return val; | |
1014 } | |
1015 | |
1016 DEFUN ("wnn-server-dict-save", Fwnn_dict_save, 0, 0, 0, /* | |
1017 Save all dictionaries and frequency files. | |
1018 */ | |
1019 ()) | |
1020 { | |
1021 int snum; | |
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; | |
1025 else return Qt; | |
1026 } | |
1027 | |
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) | |
1031 */ | |
1032 ()) | |
1033 { | |
1034 struct wnn_param param; | |
1035 int snum; | |
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))))))))))))))))); | |
1056 } | |
1057 | |
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. | |
1064 */ | |
1065 (Vsetvalues_alist)) | |
1066 { | |
1067 int rc; | |
1068 struct wnn_param param; | |
1069 int snum; | |
1070 | |
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; | |
1075 | |
442 | 1076 { |
1077 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, val, Vsetvalues_alist) | |
1078 { | |
1079 int setval; | |
1080 CHECK_INT (val); | |
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; | |
1099 else | |
1100 { | |
563 | 1101 invalid_constant ("Invalid wnn keyword", key); |
442 | 1102 return Qnil; |
1103 } | |
1104 } | |
1105 } | |
428 | 1106 |
1107 #if 0 | |
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); | |
1125 #endif | |
1126 | |
1127 rc = jl_param_set (wnnfns_buf[snum], ¶m); | |
1128 if (rc < 0) return Qnil; | |
1129 return Qt; | |
1130 } | |
1131 | |
1132 DEFUN ("wnn-server-get-msg", Fwnn_get_msg, 0, 0, 0, /* | |
1133 Get message string from wnn_perror. | |
1134 */ | |
1135 ()) | |
1136 { | |
1137 unsigned char mbuf[256]; | |
1138 char *msgp; | |
1139 int snum; | |
1140 unsigned char lb; | |
1141 char langname[32]; | |
1142 /* CHECK_INT (errno);*/ | |
1143 if ((snum = check_wnn_server_type ()) == -1) return Qnil; | |
1144 lb = lb_wnn_server_type[snum]; | |
1145 switch (snum) | |
1146 { | |
1147 case WNNSERVER_J: | |
1148 strcpy (langname, "ja_JP"); | |
1149 break; | |
1150 case WNNSERVER_C: | |
1151 strcpy (langname, "zh_CN"); | |
1152 break; | |
1153 /* | |
1154 case WNNSERVER_T: | |
1155 strcpy (langname, "zh_TW"); | |
1156 break; | |
1157 */ | |
1158 case WNNSERVER_K: | |
1159 strcpy (langname, "ko_KR"); | |
1160 break; | |
1161 } | |
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)); | |
1167 } | |
1168 | |
1169 | |
1170 DEFUN ("wnn-server-fuzokugo-set", Fwnn_fuzokugo_set, 1, 1, 0, /* | |
1171 For Wnn. | |
1172 */ | |
1173 (file)) | |
1174 { | |
1175 int snum; | |
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) | |
1180 return Qnil; | |
1181 return Qt; | |
1182 } | |
1183 | |
1184 DEFUN ("wnn-server-fuzokugo-get", Fwnn_fuzokugo_get, 0, 0, 0, /* | |
1185 For Wnn. | |
1186 */ | |
1187 ()) | |
1188 { | |
1189 char fname[256]; | |
1190 int snum; | |
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; | |
867 | 1194 return make_string ((Ibyte *) fname, strlen (fname)); |
428 | 1195 } |
1196 | |
1197 | |
1198 DEFUN ("wnn-server-isconnect", Fwnn_isconnect, 0, 0, 0, /* | |
1199 For Wnn. | |
1200 */ | |
1201 ()) | |
1202 { | |
1203 int snum; | |
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; | |
1207 else return Qnil; | |
1208 } | |
1209 | |
1210 DEFUN ("wnn-server-hinsi-dicts", Fwnn_hinsi_dicts, 1, 1, 0, /* | |
1211 For Wnn. | |
1212 */ | |
1213 (hinsi)) | |
1214 { | |
1215 int *area; | |
1216 int cnt; | |
1217 Lisp_Object val; | |
1218 int snum; | |
1219 CHECK_INT (hinsi); | |
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) | |
1223 return Qnil; | |
1224 val = Qnil; | |
1225 for (area += cnt; cnt > 0; cnt--) | |
1226 { | |
1227 area--; | |
1228 val = Fcons (make_int (*area), val); | |
1229 } | |
1230 return val; | |
1231 } | |
1232 | |
1233 DEFUN ("wnn-server-hinsi-list", Fwnn_hinsi_list, 2, 2, 0, /* | |
1234 For Wnn. | |
1235 */ | |
1236 (dicno, name)) | |
1237 { | |
1238 int cnt; | |
1239 Lisp_Object val; | |
1240 w_char wbuf[256]; | |
1241 w_char **area; | |
1242 unsigned char cbuf[512]; | |
1243 int snum; | |
1244 unsigned char lb; | |
1245 CHECK_INT (dicno); | |
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) | |
1252 return Qnil; | |
1253 if (cnt == 0) return make_int (0); | |
1254 val = Qnil; | |
1255 for (area += cnt; cnt > 0; cnt--) | |
1256 { | |
1257 area--; | |
1258 w2m (*area, cbuf, lb); | |
1259 val = Fcons (make_string (cbuf, strlen ((char *) cbuf)), val); | |
1260 } | |
1261 return val; | |
1262 } | |
1263 | |
1264 DEFUN ("wnn-server-hinsi-name", Fwnn_hinsi_name, 1, 1, 0, /* | |
1265 For Wnn. | |
1266 */ | |
1267 (no)) | |
1268 { | |
1269 unsigned char name[256]; | |
1270 w_char *wname; | |
1271 int snum; | |
1272 unsigned char lb; | |
1273 CHECK_INT (no); | |
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)); | |
1280 } | |
1281 #ifdef WNN6 | |
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. | |
1286 */ | |
1287 (int nargs, Lisp_Object *args)) | |
1288 { | |
1289 struct gcpro gcpro1; | |
1290 int snum; | |
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; | |
1296 GCPRO1 (*args); | |
1297 gcpro1.nvars = nargs; | |
1298 if(jl_fi_dic_add(wnnfns_buf[snum], | |
1299 XSTRING_DATA (args[0]), | |
1300 XSTRING_DATA (args[1]), | |
1301 WNN_FI_SYSTEM_DICT, | |
1302 WNN_DIC_RDONLY, | |
1303 NILP (args[2]) ? WNN_DIC_RDONLY : WNN_DIC_RW, | |
1304 0, | |
1305 NILP (args[3]) ? 0 : XSTRING_DATA (args[3]), | |
1306 yes_or_no, | |
1307 puts2 ) < 0) { | |
1308 UNGCPRO; | |
1309 return Qnil; | |
1310 } | |
1311 UNGCPRO; | |
1312 return Qt; | |
1313 } | |
1314 | |
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. | |
1319 */ | |
1320 (int nargs, Lisp_Object *args)) | |
1321 { | |
1322 struct gcpro gcpro1; | |
1323 int snum; | |
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; | |
1330 GCPRO1 (*args); | |
1331 gcpro1.nvars = nargs; | |
1332 if(jl_fi_dic_add(wnnfns_buf[snum], | |
1333 XSTRING_DATA (args[0]), | |
1334 XSTRING_DATA (args[1]), | |
1335 WNN_FI_USER_DICT, | |
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]), | |
1340 yes_or_no, | |
1341 puts2 ) < 0) { | |
1342 UNGCPRO; | |
1343 return Qnil; | |
1344 } | |
1345 UNGCPRO; | |
1346 return Qt; | |
1347 } | |
1348 | |
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. | |
1352 */ | |
1353 (int nargs, Lisp_Object *args)) | |
1354 { | |
1355 struct gcpro gcpro1; | |
1356 int snum; | |
1357 int dic_no; | |
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; | |
1366 GCPRO1 (*args); | |
1367 gcpro1.nvars = nargs; | |
1368 if(wnnfns_norm) | |
1369 cur_env = wnnfns_env_norm[snum]; | |
1370 else | |
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]), | |
1376 0, | |
1377 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV, | |
1378 XINT(args[1]), | |
1379 WNN_DIC_RW, WNN_DIC_RW, | |
1380 NILP (args[3]) ? 0 : XSTRING_DATA (args[3]), | |
1381 0, | |
1382 yes_or_no, | |
1383 puts2)) < 0) { | |
1384 UNGCPRO; | |
1385 return Qnil; | |
1386 } | |
1387 js_set_autolearning_dic(cur_env, WNN_MUHENKAN_LEARNING, dic_no); | |
1388 } | |
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) { | |
1392 UNGCPRO; | |
1393 return Qnil; | |
1394 } | |
1395 } | |
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], | |
1399 vmask, | |
1400 &henv) < 0) { | |
1401 UNGCPRO; | |
1402 return Qnil; | |
1403 } | |
1404 UNGCPRO; | |
1405 return Qt; | |
1406 } | |
1407 | |
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. | |
1411 */ | |
1412 (int nargs, Lisp_Object *args)) | |
1413 { | |
1414 struct gcpro gcpro1; | |
1415 int snum; | |
1416 int dic_no; | |
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; | |
1425 GCPRO1 (*args); | |
1426 gcpro1.nvars = nargs; | |
1427 if(wnnfns_norm) | |
1428 cur_env = wnnfns_env_norm[snum]; | |
1429 else | |
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]), | |
1435 0, | |
1436 wnnfns_norm ? WNN_DIC_ADD_NOR : WNN_DIC_ADD_REV, | |
1437 XINT(args[1]), | |
1438 WNN_DIC_RW, WNN_DIC_RW, | |
1439 NILP (args[3]) ? 0 : XSTRING_DATA (args[3]), | |
1440 0, | |
1441 yes_or_no, | |
1442 puts2)) < 0) { | |
1443 UNGCPRO; | |
1444 return Qnil; | |
1445 } | |
1446 js_set_autolearning_dic(cur_env, WNN_BUNSETSUGIRI_LEARNING, dic_no); | |
1447 } | |
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) { | |
1451 UNGCPRO; | |
1452 return Qnil; | |
1453 } | |
1454 } | |
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], | |
1458 vmask, | |
1459 &henv) < 0) { | |
1460 UNGCPRO; | |
1461 return Qnil; | |
1462 } | |
1463 UNGCPRO; | |
1464 return Qt; | |
1465 } | |
1466 | |
1467 DEFUN ("wnn-server-set-last-is-first", Fwnn_last_is_first, 1, 1, 0, /* | |
1468 For FI-Wnn. | |
1469 */ | |
1470 (mode)) | |
1471 { | |
1472 int snum; | |
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], | |
1480 vmask, | |
1481 &henv) < 0) return Qnil; | |
1482 return Qt; | |
1483 } | |
1484 | |
1485 DEFUN ("wnn-server-set-complex-conv-mode", Fwnn_complex_conv, 1, 1, 0, /* | |
1486 For FI-Wnn. | |
1487 */ | |
1488 (mode)) | |
1489 { | |
1490 int snum; | |
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], | |
1498 vmask, | |
1499 &henv) < 0) return Qnil; | |
1500 return Qt; | |
1501 } | |
1502 | |
1503 DEFUN ("wnn-server-set-okuri-learn-mode", Fwnn_okuri_learn, 1, 1, 0, /* | |
1504 For FI-Wnn. | |
1505 */ | |
1506 (mode)) | |
1507 { | |
1508 int snum; | |
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], | |
1516 vmask, | |
1517 &henv) < 0) return Qnil; | |
1518 return Qt; | |
1519 } | |
1520 | |
1521 DEFUN ("wnn-server-set-okuri-flag", Fwnn_okuri_flag, 1, 1, 0, /* | |
1522 For FI-Wnn. | |
1523 */ | |
1524 (lmode)) | |
1525 { | |
1526 int snum, mode; | |
1527 unsigned long vmask = 0; | |
1528 struct wnn_henkan_env henv; | |
1529 CHECK_INT (lmode); | |
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) | |
1536 return Qnil; | |
1537 else | |
1538 henv.okuri_flag = mode; | |
1539 vmask |= WNN_ENV_OKURI_MASK; | |
1540 if(jl_set_henkan_env(wnnfns_buf[snum], | |
1541 vmask, | |
1542 &henv) < 0) return Qnil; | |
1543 return Qt; | |
1544 } | |
1545 | |
1546 DEFUN ("wnn-server-set-prefix-learn-mode", Fwnn_prefix_learn, 1, 1, 0, /* | |
1547 For FI-Wnn. | |
1548 */ | |
1549 (mode)) | |
1550 { | |
1551 int snum; | |
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], | |
1559 vmask, | |
1560 &henv) < 0) return Qnil; | |
1561 return Qt; | |
1562 } | |
1563 | |
1564 DEFUN ("wnn-server-set-prefix-flag", Fwnn_prefix_flag, 1, 1, 0, /* | |
1565 For FI-Wnn. | |
1566 */ | |
1567 (lmode)) | |
1568 { | |
1569 int snum, mode; | |
1570 unsigned long vmask = 0; | |
1571 struct wnn_henkan_env henv; | |
1572 CHECK_INT (lmode); | |
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) | |
1577 return Qnil; | |
1578 else | |
1579 henv.prefix_flag = mode; | |
1580 vmask |= WNN_ENV_PREFIX_MASK; | |
1581 if(jl_set_henkan_env(wnnfns_buf[snum], | |
1582 vmask, | |
1583 &henv) < 0) return Qnil; | |
1584 return Qt; | |
1585 } | |
1586 | |
1587 DEFUN ("wnn-server-set-suffix-learn-mode", Fwnn_suffix_learn, 1, 1, 0, /* | |
1588 For FI-Wnn. | |
1589 */ | |
1590 (mode)) | |
1591 { | |
1592 int snum; | |
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], | |
1600 vmask, | |
1601 &henv) < 0) return Qnil; | |
1602 return Qt; | |
1603 } | |
1604 | |
1605 DEFUN ("wnn-server-set-common-learn-mode", Fwnn_common_learn, 1, 1, 0, /* | |
1606 For FI-Wnn. | |
1607 */ | |
1608 (mode)) | |
1609 { | |
1610 int snum; | |
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], | |
1618 vmask, | |
1619 &henv) < 0) return Qnil; | |
1620 return Qt; | |
1621 } | |
1622 | |
1623 DEFUN ("wnn-server-set-freq-func-mode", Fwnn_freq_func, 1, 1, 0, /* | |
1624 For FI-Wnn. | |
1625 */ | |
1626 (lmode)) | |
1627 { | |
1628 int snum, mode; | |
1629 unsigned long vmask = 0; | |
1630 struct wnn_henkan_env henv; | |
1631 CHECK_INT (lmode); | |
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) | |
1636 return Qnil; | |
1637 else | |
1638 henv.freq_func_flag = mode; | |
1639 vmask |= WNN_ENV_FREQ_FUNC_MASK; | |
1640 if(jl_set_henkan_env(wnnfns_buf[snum], | |
1641 vmask, | |
1642 &henv) < 0) return Qnil; | |
1643 return Qt; | |
1644 } | |
1645 | |
1646 DEFUN ("wnn-server-set-numeric-mode", Fwnn_numeric, 1, 1, 0, /* | |
1647 For FI-Wnn. | |
1648 */ | |
1649 (lmode)) | |
1650 { | |
1651 int snum, mode; | |
1652 unsigned long vmask = 0; | |
1653 struct wnn_henkan_env henv; | |
1654 CHECK_INT (lmode); | |
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) | |
1665 return Qnil; | |
1666 else | |
1667 henv.numeric_flag = mode; | |
1668 vmask |= WNN_ENV_NUMERIC_MASK; | |
1669 if(jl_set_henkan_env(wnnfns_buf[snum], | |
1670 vmask, | |
1671 &henv) < 0) return Qnil; | |
1672 return Qt; | |
1673 } | |
1674 | |
1675 DEFUN ("wnn-server-set-alphabet-mode", Fwnn_alphabet, 1, 1, 0, /* | |
1676 For FI-Wnn. | |
1677 */ | |
1678 (lmode)) | |
1679 { | |
1680 int snum, mode; | |
1681 unsigned long vmask = 0; | |
1682 struct wnn_henkan_env henv; | |
1683 CHECK_INT (lmode); | |
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) | |
1688 return Qnil; | |
1689 else | |
1690 henv.alphabet_flag = mode; | |
1691 vmask |= WNN_ENV_ALPHABET_MASK; | |
1692 if(jl_set_henkan_env(wnnfns_buf[snum], | |
1693 vmask, | |
1694 &henv) < 0) return Qnil; | |
1695 return Qt; | |
1696 } | |
1697 | |
1698 DEFUN ("wnn-server-set-symbol-mode", Fwnn_symbol, 1, 1, 0, /* | |
1699 For FI-Wnn. | |
1700 */ | |
1701 (lmode)) | |
1702 { | |
1703 int snum, mode; | |
1704 unsigned long vmask = 0; | |
1705 struct wnn_henkan_env henv; | |
1706 CHECK_INT (lmode); | |
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) | |
1711 return Qnil; | |
1712 else | |
1713 henv.symbol_flag = mode; | |
1714 vmask |= WNN_ENV_SYMBOL_MASK; | |
1715 if(jl_set_henkan_env(wnnfns_buf[snum], | |
1716 vmask, | |
1717 &henv) < 0) return Qnil; | |
1718 return Qt; | |
1719 } | |
1720 | |
1721 DEFUN ("wnn-server-set-yuragi-mode", Fwnn_yuragi, 1, 1, 0, /* | |
1722 For FI-Wnn. | |
1723 */ | |
1724 (mode)) | |
1725 { | |
1726 int snum; | |
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], | |
1734 vmask, | |
1735 &henv) < 0) return Qnil; | |
1736 return Qt; | |
1737 } | |
1738 | |
1739 DEFUN ("wnn-reset-previous-info", Fwnn_reset_prev, 0, 0, 0, /* | |
1740 For FI-Wnn. | |
1741 */ | |
1742 ()) | |
1743 { | |
1744 int snum; | |
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; | |
1748 return Qt; | |
1749 } | |
1750 #endif /* Wnn6 */ | |
1751 | |
1752 DEFUN ("wnn-server-version", Fwnn_version, 0, 0, 0, /* | |
1753 Returns Wnn server version ID. | |
1754 */ | |
1755 ()) | |
1756 { | |
1757 int snum; | |
1758 int serv; | |
1759 int libv; | |
1760 struct wnn_env *cur_env; | |
1761 if ((snum = check_wnn_server_type()) == -1) return Qnil; | |
1762 if(!wnnfns_buf[snum]) return Qnil; | |
1763 if(wnnfns_norm) | |
1764 cur_env = wnnfns_env_norm[snum]; | |
1765 else | |
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); | |
1769 } | |
1770 | |
1771 DEFUN ("wnn-server-hinsi-number", Fwnn_hinsi_number, 1, 1, 0, /* | |
1772 For Wnn. | |
1773 */ | |
1774 (name)) | |
1775 { | |
1776 w_char w_buf[256]; | |
1777 int no; | |
1778 int snum; | |
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); | |
1785 } | |
1786 | |
1787 void | |
1788 syms_of_mule_wnn (void) | |
1789 { | |
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); | |
1829 #ifdef WNN6 | |
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); | |
1848 #endif /* Wnn6 */ | |
1849 DEFSUBR (Fwnn_version); | |
1850 | |
563 | 1851 DEFSYMBOL (Qjserver); |
1852 DEFSYMBOL (Qcserver); | |
1853 /* DEFSYMBOL (Qtserver); */ | |
1854 DEFSYMBOL (Qkserver); | |
428 | 1855 |
563 | 1856 DEFSYMBOL (Qwnn_no_uniq); |
1857 DEFSYMBOL (Qwnn_uniq); | |
1858 DEFSYMBOL (Qwnn_uniq_kanji); | |
428 | 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"); | |
1876 } | |
1877 | |
1878 void | |
1879 reinit_vars_of_mule_wnn (void) | |
1880 { | |
1881 int i; | |
1882 | |
1883 for (i = 0; i < NSERVER; i++) | |
1884 { | |
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; | |
1888 } | |
1889 } | |
1890 | |
1891 void | |
1892 vars_of_mule_wnn (void) | |
1893 { | |
1894 DEFVAR_INT ("lb-sisheng", &lb_sisheng /* | |
1895 Leading character for Sisheng. | |
1896 */ ); | |
1897 DEFVAR_LISP ("wnn-server-type", &Vwnn_server_type /* | |
1898 *jserver, cserver .. | |
1899 */ ); | |
1900 DEFVAR_LISP ("cwnn-zhuyin", &Vcwnn_zhuyin /* | |
1901 *pinyin or zhuyin | |
1902 */ ); | |
1903 DEFVAR_LISP ("wnnenv-sticky", &Vwnnenv_sticky /* | |
1904 *If non-nil, make environment sticky | |
1905 */ ); | |
1906 DEFVAR_LISP ("wnn-uniq-level", &Vwnn_uniq_level /* | |
1907 *Uniq level | |
1908 */ ); | |
1909 | |
1910 Vwnn_server_type = Qjserver; | |
1911 Vcwnn_zhuyin = Qnil; | |
1912 Vwnnenv_sticky = Qnil; | |
1913 | |
1914 Vwnn_uniq_level = Qwnn_uniq; | |
1915 | |
771 | 1916 Fprovide (intern ("wnn")); |
428 | 1917 } |
1918 | |
1919 void | |
1920 w2m (w_char *wp, unsigned char *mp, unsigned char lb) | |
1921 { | |
1922 w_char wc; | |
1923 w_char pzy[10]; | |
1924 int i, len; | |
1925 | |
1926 while ((wc = *wp++) != 0) | |
1927 { | |
1928 switch (wc & 0x8080) | |
1929 { | |
1930 case 0x80: | |
1931 if (EQ(Vwnn_server_type, Qcserver)) | |
1932 { | |
1933 len = cwnn_yincod_pzy (pzy, wc, | |
1934 NILP (Vcwnn_zhuyin) | |
1935 ? CWNN_PINYIN | |
1936 : CWNN_ZHUYIN); | |
1937 for (i = 0; i < len; i++) | |
1938 { | |
1939 if (pzy[i] & 0x80) | |
1940 { | |
1941 *mp++ = PRE_LEADING_BYTE_PRIVATE_1; /* #### Not sure about this one... */ | |
1942 *mp++ = lb_sisheng; | |
1943 } | |
1944 *mp++ = pzy[i]; | |
1945 } | |
1946 } | |
1947 else | |
1948 { | |
1949 *mp++ = LEADING_BYTE_KATAKANA_JISX0201; | |
1950 *mp++ = (wc & 0xff); | |
1951 } | |
1952 break; | |
1953 case 0x8080: | |
1954 *mp++ = lb; | |
1955 *mp++ = (wc & 0xff00) >> 8; | |
1956 *mp++ = wc & 0x00ff; | |
1957 break; | |
1958 case 0x8000: | |
1959 if (lb == LEADING_BYTE_JAPANESE_JISX0208) | |
1960 *mp++ = LEADING_BYTE_JAPANESE_JISX0212; | |
1961 else if (lb == LEADING_BYTE_CHINESE_BIG5_1) | |
1962 *mp++ = LEADING_BYTE_CHINESE_BIG5_2; | |
1963 else | |
1964 *mp++ = lb; | |
1965 *mp++ = (wc & 0xff00) >> 8; | |
1966 *mp++ = (wc & 0x00ff) | 0x80; | |
1967 break; | |
1968 default: | |
1969 *mp++ = wc & 0x00ff; | |
1970 break; | |
1971 } | |
1972 } | |
1973 *mp = 0; | |
1974 } | |
1975 | |
1976 void | |
1977 m2w (unsigned char *mp, w_char *wp) | |
1978 { | |
647 | 1979 int ch; |
428 | 1980 |
1981 while ((ch = *mp++) != 0) | |
1982 { | |
867 | 1983 if (ibyte_leading_byte_p (ch)) |
428 | 1984 { |
1985 switch (ch) | |
1986 { | |
1987 case LEADING_BYTE_KATAKANA_JISX0201: | |
1988 *wp++ = *mp++; break; | |
1989 case LEADING_BYTE_LATIN_JISX0201: | |
1990 *wp++ = *mp++ & 0x7F; break; | |
1991 case LEADING_BYTE_JAPANESE_JISX0208_1978: | |
1992 case LEADING_BYTE_CHINESE_GB2312: | |
1993 case LEADING_BYTE_JAPANESE_JISX0208: | |
1994 case LEADING_BYTE_KOREAN_KSC5601: | |
1995 /* case LEADING_BYTE_TW: */ | |
1996 ch = *mp++; | |
1997 *wp++ = (ch << 8) | *mp++; | |
1998 break; | |
1999 case LEADING_BYTE_JAPANESE_JISX0212: | |
2000 ch = *mp++; | |
2001 *wp++ = (ch << 8) | (*mp++ & 0x7f); | |
2002 break; | |
2003 case PRE_LEADING_BYTE_PRIVATE_1: /* #### Not sure about this one... */ | |
2004 ch = *mp++; | |
2005 if (ch == lb_sisheng) | |
2006 *wp++ = 0x8e80 | *mp++; | |
2007 else | |
2008 mp++; | |
2009 break; | |
2010 default: /* ignore this character */ | |
826 | 2011 mp += rep_bytes_by_first_byte(ch) - 1; |
428 | 2012 } |
2013 } | |
2014 else | |
2015 { | |
2016 *wp++ = ch; | |
2017 } | |
2018 } | |
2019 *wp = 0; | |
2020 } | |
2021 | |
2022 void | |
2023 w2y (w_char *w) | |
2024 { | |
2025 letter pbuf[5000], ybuf[5000]; | |
2026 unsigned int *pin; | |
2027 w_char *y; | |
2028 int len; | |
2029 | |
2030 pin = pbuf; | |
2031 y = w; | |
2032 while (1) | |
2033 { | |
2034 if (*w == 0) | |
2035 {*pin =0; break;} | |
2036 else *pin = *w; | |
2037 w++; pin++; | |
2038 } | |
2039 len = cwnn_pzy_yincod (ybuf, pbuf, | |
2040 NILP (Vcwnn_zhuyin) ? CWNN_PINYIN : CWNN_ZHUYIN); | |
2041 if (len <= 0) | |
2042 return; | |
2043 | |
2044 pin = ybuf; | |
2045 while (1) | |
2046 { | |
2047 if (*pin == 0 || len == 0) | |
2048 {*y = 0;break;} | |
2049 *y = *pin; | |
2050 y++; pin++; len--; | |
2051 } | |
2052 } | |
2053 | |
2054 void | |
2055 c2m (unsigned char *cp, unsigned char *mp, unsigned char lb) | |
2056 { | |
2057 unsigned char ch; | |
2058 while ((ch = *cp) != 0) | |
2059 { | |
2060 if (ch & 0x80) | |
2061 { | |
2062 *mp++ = lb; | |
2063 *mp++ = *cp++; | |
2064 } | |
2065 *mp++ = *cp++; | |
2066 } | |
2067 *mp = 0; | |
2068 } | |
2069 | |
2070 static int | |
2071 dai_end (int no, int server) | |
2072 { | |
2073 for (no++; no < jl_bun_suu (wnnfns_buf[server]) | |
2074 && !jl_dai_top (wnnfns_buf[server], no); no++); | |
2075 return (no); | |
2076 } | |
2077 | |
2078 static int | |
2079 yes_or_no (unsigned char *s) | |
2080 { | |
2081 unsigned char mbuf[512]; | |
2082 unsigned char lb; | |
2083 int len; | |
2084 int snum; | |
2085 if ((snum = check_wnn_server_type ()) == -1) return 0; | |
2086 lb = lb_wnn_server_type[snum]; | |
2087 /* if no message found, create file without query */ | |
2088 /* if (wnn_msg_cat->msg_bd == 0) return 1;*/ | |
2089 if (*s == 0) return 1; | |
2090 c2m (s, mbuf, lb); | |
2091 /* truncate "(Y/N)" */ | |
2092 for (len = 0; (mbuf[len]) && (len < 512); len++); | |
2093 for (; (mbuf[len] != '(') && (len > 0); len--); | |
2094 { | |
2095 Lisp_Object yes, str; | |
2096 struct gcpro gcpro1; | |
2097 | |
2098 str = make_string (mbuf, len); | |
2099 GCPRO1 (str); | |
2100 yes = call1(Qyes_or_no_p, str); | |
2101 UNGCPRO; | |
2102 if (NILP (yes)) return 0; | |
2103 else return (1); | |
2104 } | |
2105 } | |
2106 | |
2107 static void | |
2108 puts2 (char *s) | |
2109 { | |
2110 #if 0 /* jhod: We don't really need this echoed... */ | |
2111 #if 0 | |
2112 Lisp_Object args[1]; | |
2113 char mbuf[512]; | |
2114 unsigned char lb; | |
2115 extern Lisp_Object Fmessage (); | |
2116 int snum; | |
2117 if ((snum = check_wnn_server_type ()) == -1) return; | |
2118 lb = lb_wnn_server_type[snum]; | |
2119 c2m (s, mbuf, lb); | |
2120 args[0] = make_string (mbuf, strlen (mbuf)); | |
2121 Fmessage (1, args); | |
2122 #else | |
2123 message("%s",s); | |
2124 #endif | |
2125 #endif | |
2126 } | |
2127 | |
2128 int | |
2129 check_wnn_server_type (void) | |
2130 { | |
2131 if (EQ(Vwnn_server_type, Qjserver)) | |
2132 { | |
2133 return WNNSERVER_J; | |
2134 } | |
2135 else if (EQ(Vwnn_server_type, Qcserver)) | |
2136 { | |
2137 return WNNSERVER_C; | |
2138 } | |
2139 /* else if (Vwnn_server_type == Qtserver) | |
2140 { | |
2141 return WNNSERVER_T; | |
2142 } */ | |
2143 else if (EQ(Vwnn_server_type, Qkserver)) | |
2144 { | |
2145 return WNNSERVER_K; | |
2146 } | |
2147 else return -1; | |
2148 } |