70
|
1 ;; Wnn3 server interface for Egg
|
|
2 ;; Coded by S.Tomura, Electrotechnical Lab. (tomura@etl.go.jp)
|
|
3
|
|
4 ;; This file is part of Egg on Mule (Multilingual Environment)
|
|
5
|
|
6 ;; Egg is distributed in the forms of patches to GNU
|
|
7 ;; Emacs under the terms of the GNU EMACS GENERAL PUBLIC
|
|
8 ;; LICENSE which is distributed along with GNU Emacs by the
|
|
9 ;; Free Software Foundation.
|
|
10
|
|
11 ;; Egg is distributed in the hope that it will be useful,
|
|
12 ;; but WITHOUT ANY WARRANTY; without even the implied
|
|
13 ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
14 ;; PURPOSE. See the GNU EMACS GENERAL PUBLIC LICENSE for
|
|
15 ;; more details.
|
|
16
|
|
17 ;; You should have received a copy of the GNU EMACS GENERAL
|
|
18 ;; PUBLIC LICENSE along with Nemacs; see the file COPYING.
|
|
19 ;; If not, write to the Free Software Foundation, 675 Mass
|
|
20 ;; Ave, Cambridge, MA 02139, USA.
|
|
21
|
|
22 ;;;
|
|
23 ;;; Nemacs - Wnn V3 server interface in elisp
|
|
24 ;;;
|
|
25
|
|
26 ;;; 93.4.6 modified for Mule Ver.0.9.7.1
|
|
27 ;;; by T.Saneto <sanewo@pdp.crl.sony.co.jp>
|
|
28 ;;; Bug in wnn-bunsetu-yomi-equal fixed.
|
|
29
|
|
30 (provide 'wnn-client)
|
|
31
|
|
32 ;;;
|
|
33 ;;; Wnn deamon command constants
|
|
34 ;;;
|
|
35
|
|
36 (defconst JD_OPEN_IN 9 "$BJQ49(B") ;;; V3.0
|
|
37 (defconst JD_OPEN 1 "$BMxMQ<TEPO?(B")
|
|
38 (defconst JD_CLOSE 2 "$BMxMQ<T:o=|(B")
|
|
39 (defconst JD_BEGIN 3 "$BJQ493+;O(B")
|
|
40 (defconst JD_END 4 "$BIQEY99?7(B")
|
|
41 ;;;
|
|
42 (defconst JD_NEXT 17 "$B<!8uJd(B") ;;; 0x11
|
|
43 (defconst JD_RECONV 18 "$B:FJQ49!JJ8;zNsJQ99!K(B") ;;; 0x12
|
|
44 (defconst JD_TANCONV 19 "$B:FJQ49!JJ8@a?-=L!K(B") ;;; 0x13
|
|
45 ;;;
|
|
46 (defconst JD_UDP 33 "") ;;; 0x21
|
|
47 (defconst JD_UDCHG 34 "$BMxMQ<T<-=qJQ99(B") ;;; 0x22
|
|
48 (defconst JD_FREQSV 35 "$B<-=qB`Hr(B") ;;; 0x23
|
|
49 (defconst JD_DICADD 36 "$B<-=qDI2C(B") ;;; 0x24
|
|
50 (defconst JD_DICDEL 37 "$B<-=q:o=|(B") ;;; 0x25
|
|
51 (defconst JD_DICINFO 38 "$B<-=q>pJs(B") ;;; 0x26
|
|
52 (defconst JD_DICSTAT 39 "") ;;; 0x27 V3.0
|
|
53
|
|
54 (defconst JD_WDEL 49 "$BC18l:o=|(B") ;;; 0x31
|
|
55 (defconst JD_WSCH 50 "$BC18l8!:w(B") ;;; 0x32
|
|
56 (defconst JD_WREG 51 "$BC18lEPO?(B") ;;; 0x33
|
|
57 (defconst JD_WHDEL 52 "") ;;; 0x34
|
|
58
|
|
59 (defconst JD_SETEVF 65 "$BJQ49J}<0JQ99(B") ;;; 0x41
|
|
60 (defconst JD_GETEVF 66 "$BJQ49J}<0>pJs(B") ;;; 0x42
|
|
61
|
|
62 (defconst JD_MKDIR 81 "") ;;; 0x51 V3.0
|
|
63 (defconst JD_ACCESS 82 "") ;;; 0x52 V3.0
|
|
64 (defconst JD_WHO 83 "$BMxMQ<T0lMw(B") ;;; 0x53 V3.0
|
|
65 (defconst JD_VERSION 84 "") ;;; 0x54 V3.0
|
|
66
|
|
67
|
|
68 (defvar wnn-server-buffer nil "Buffer associated with Wnn server process.")
|
|
69
|
|
70 (defvar wnn-server-process nil "Wnn Kana Kanji hankan process.")
|
|
71
|
|
72 (defvar wnn-command-tail-position nil)
|
|
73 (defvar wnn-command-buffer nil)
|
|
74
|
|
75 (defvar wnn-result-buffer nil)
|
|
76 (defvar wnn-henkan-string nil)
|
|
77 (defvar wnn-bunsetu-suu nil)
|
|
78
|
|
79 (defvar wnn-return-code nil)
|
|
80 (defvar wnn-error-code nil)
|
|
81
|
|
82 ;;;
|
|
83 ;;; Put data into buffer
|
|
84 ;;;
|
|
85
|
|
86 (defun wnn-put-4byte (integer)
|
|
87 (insert (if (<= 0 integer) 0 255)
|
|
88 (logand 255 (lsh integer -16))
|
|
89 (logand 255 (lsh integer -8))
|
|
90 (logand 255 integer)))
|
|
91
|
|
92 (defun wnn-put-string (str)
|
|
93 (insert str 0))
|
|
94
|
|
95 (defun wnn-put-string* (str)
|
|
96 (let ((size (length str))
|
|
97 (i 0))
|
|
98 (while (< i size)
|
|
99 (if (<= 128 (aref str i))
|
|
100 (progn (insert (aref str i) (aref str (1+ i)))
|
|
101 (setq i (+ i 2)))
|
|
102 (progn (insert 0 (aref str i))
|
|
103 (setq i (1+ i))))))
|
|
104 (insert 0 0))
|
|
105
|
|
106 (defun wnn-put-bit-position (pos)
|
|
107 (if (< pos 24) (wnn-put-4byte (lsh 1 pos))
|
|
108 (insert (lsh 1 (- pos 24)) 0 0 0)))
|
|
109
|
|
110 ;;;
|
|
111 ;;; Get data from buffer
|
|
112 ;;;
|
|
113
|
|
114 (defun wnn-get-4byte ()
|
|
115
|
|
116 (let ((c 0) (point (point)))
|
|
117 ;;;(goto-char (point-min))
|
|
118 (while (< (point-max) (+ point 4))
|
|
119 (accept-process-output)
|
|
120 (if (= c 10) (error "Count exceed."))
|
|
121 (setq c (1+ c)))
|
|
122 (goto-char point))
|
|
123
|
|
124 (let ((point (point)))
|
|
125 (if (not (or (and (= (char-after point) 0)
|
|
126 (< (char-after (+ point 1)) 128))
|
|
127 (and (= (char-after point) 255)
|
|
128 (<= 128 (char-after (+ point 1))))))
|
|
129 (error "wnn-get-4byte: integer range overflow."))
|
|
130 (prog1
|
|
131 (logior
|
|
132 (lsh (char-after point) 24)
|
|
133 (lsh (char-after (+ point 1)) 16)
|
|
134 (lsh (char-after (+ point 2)) 8)
|
|
135 (lsh (char-after (+ point 3)) 0))
|
|
136 (goto-char (+ (point) 4)))))
|
|
137
|
|
138 (defun wnn-peek-4byte ()
|
|
139
|
|
140 (let ((c 0) (point (point)))
|
|
141 ;;;(goto-char (point-min))
|
|
142 (while (< (point-max) (+ point 4))
|
|
143 (accept-process-output)
|
|
144 (if (= c 10) (error "Count exceed."))
|
|
145 (setq c (1+ c)))
|
|
146 (goto-char point))
|
|
147
|
|
148 (let ((point (point)))
|
|
149 (if (not (or (and (= (char-after point) 0)
|
|
150 (< (char-after (+ point 1)) 128))
|
|
151 (and (= (char-after point) 255)
|
|
152 (<= 128 (char-after (+ point 1))))))
|
|
153 (error "wnn-get-4byte: integer range overflow."))
|
|
154 (prog1
|
|
155 (logior
|
|
156 (lsh (char-after point) 24)
|
|
157 (lsh (char-after (+ point 1)) 16)
|
|
158 (lsh (char-after (+ point 2)) 8)
|
|
159 (lsh (char-after (+ point 3)) 0)))))
|
|
160
|
|
161
|
|
162 (defun wnn-get-bit-positions ()
|
|
163
|
|
164 (let ((c 0) (point (point)))
|
|
165 ;;;(goto-char (point-min))
|
|
166 (while (< (point-max) (+ point 4))
|
|
167 (accept-process-output)
|
|
168 (if (= c 10) (error "Count exceed."))
|
|
169 (setq c (1+ c)))
|
|
170 (goto-char point))
|
|
171
|
|
172 (let* ((point (point))
|
|
173 (left (+ (lsh (char-after point) 8)
|
|
174 (char-after (+ point 1))))
|
|
175 (right (+ (lsh (char-after (+ point 2)) 8)
|
|
176 (char-after (+ point 3))))
|
|
177 (result))
|
|
178 (forward-char 4)
|
|
179 (let ((i 0))
|
|
180 (while (< 0 right)
|
|
181 (if (zerop (logand 1 right)) nil
|
|
182 (setq result (cons i result)))
|
|
183 (setq right (lsh right -1))
|
|
184 (setq i (1+ i)))
|
|
185 (setq i 16)
|
|
186 (while (< 0 left)
|
|
187 (if (zerop (logand 1 left)) nil
|
|
188 (setq result (cons i result)))
|
|
189 (setq left (lsh left -1))
|
|
190 (setq i (1+ i))))
|
|
191 (if (= (length result) 1)
|
|
192 (car result)
|
|
193 (nreverse result))))
|
|
194
|
|
195 (defun wnn-get-string ()
|
|
196 (let ((point (point)))
|
|
197 (skip-chars-forward "^\0")
|
|
198 (let ((c 0))
|
|
199 (while (not (= (following-char) 0))
|
|
200 (forward-char -1)
|
|
201 (accept-process-output)
|
|
202 (if (= c 10) (error "Count exceed"))
|
|
203 (setq c (1+ c))
|
|
204 (skip-chars-forward "^\0")))
|
|
205 (prog1
|
|
206 (buffer-substring point (point))
|
|
207 (forward-char 1))))
|
|
208
|
|
209 (defun wnn-get-string* ()
|
|
210 (let ((point (point)))
|
|
211 (let ((c 0))
|
|
212 (while (not (search-forward "\0\0" nil t))
|
|
213 (accept-process-output)
|
|
214 (goto-char point)
|
|
215 (if (= c 10) (error "Count exceed"))
|
|
216 (setq c (1+ c))))
|
|
217 (goto-char point)
|
|
218 (if (= (following-char) 0) (delete-char 1)
|
|
219 (forward-char 1))
|
|
220 (while (< 0 (following-char))
|
|
221 (forward-char 1)
|
|
222 (if (= (following-char) 0) (delete-char 1)
|
|
223 (forward-char 1)))
|
|
224 (prog1
|
|
225 (buffer-substring point (point))
|
|
226 (forward-char 1))))
|
|
227
|
|
228 ;;;
|
|
229 ;;; Wnn Server Command Primitives
|
|
230 ;;;
|
|
231
|
|
232 (defun wnn-command-start (command)
|
|
233 (set-buffer wnn-command-buffer)
|
|
234 (goto-char (point-min))
|
|
235 (if (not (= (point-max) (+ wnn-command-tail-position 1024)))
|
|
236 (error "wnn command start error"))
|
|
237 (delete-region (point-min) wnn-command-tail-position)
|
|
238 (wnn-put-4byte command))
|
|
239
|
|
240 (defun wnn-command-reset ()
|
|
241 (save-excursion
|
|
242 (progn
|
|
243 ;;; for Nemacs 3.0 and later
|
|
244 (if (fboundp 'set-process-kanji-code)
|
|
245 (set-process-kanji-code wnn-server-process 0))
|
|
246 (set-buffer wnn-command-buffer)
|
|
247 (setq kanji-flag nil)
|
|
248 (setq kanji-fileio-code 0) ;;; for Nemacs 2.1
|
|
249 (buffer-flush-undo wnn-command-buffer)
|
|
250 (erase-buffer)
|
|
251 (setq wnn-command-tail-position (point-min))
|
|
252 (let ((max 1024) (i 0))
|
|
253 (while (< i max)
|
|
254 (insert 0)
|
|
255 (setq i (1+ i)))))))
|
|
256
|
|
257 (defun wnn-command-end ()
|
|
258 (set-buffer wnn-server-buffer)
|
|
259 (erase-buffer)
|
|
260 (set-buffer wnn-command-buffer)
|
|
261 (setq wnn-command-tail-position (point))
|
|
262 (process-send-region wnn-server-process (point-min)
|
|
263 (+ (point-min) (lsh (1+ (lsh (- (point) (point-min)) -10)) 10)))
|
|
264 )
|
|
265
|
|
266 ;;;
|
|
267 ;;; Wnn Server Reply primitives
|
|
268 ;;;
|
|
269
|
|
270 (defun wnn-get-result ()
|
|
271 (set-buffer wnn-server-buffer)
|
|
272 (condition-case ()
|
|
273 (accept-process-output wnn-server-process)
|
|
274 (error nil))
|
|
275 (goto-char (point-min)))
|
|
276
|
|
277 (defun wnn-get-return-code ()
|
|
278 (setq wnn-return-code (wnn-get-4byte))
|
|
279 (setq wnn-error-code (if (= wnn-return-code -1)
|
|
280 (wnn-error-symbol (wnn-get-4byte))
|
|
281 nil))
|
|
282 (if wnn-error-code nil
|
|
283 wnn-return-code))
|
|
284
|
|
285 ;;;
|
|
286 ;;; Wnn Server Interface: wnn-server-open
|
|
287 ;;;
|
|
288
|
|
289 (defvar *wnn-server-max-kana-string-length* 1000)
|
|
290 (defvar *wnn-server-max-bunsetu-suu* 1000)
|
|
291
|
|
292 (defvar *wnn-service-name* "wnn")
|
|
293
|
|
294 (defun wnn-server-open (server-host-name login-name)
|
|
295 (if (wnn-server-active-p) t
|
|
296 (let ((kana_len *wnn-server-max-kana-string-length*)
|
|
297 (klist_len *wnn-server-max-bunsetu-suu*)
|
|
298 (jserver_name
|
|
299 (if (or (null server-host-name)
|
|
300 (equal server-host-name "")
|
|
301 (equal server-host-name "unix"))
|
|
302 (system-name)
|
|
303 server-host-name))
|
|
304 (user_name
|
|
305 (if (or (null login-name) (equal login-name ""))
|
|
306 (user-login-name)
|
|
307 login-name))
|
|
308 (host_name (system-name)))
|
|
309 (setq wnn-server-process
|
|
310 (condition-case var
|
|
311 (open-network-stream "Wnn V3" " [Wnn V3 Output Buffer] "
|
|
312 jserver_name *wnn-service-name* )
|
|
313 (error
|
|
314 (cond((string-match "Unknown host" (car (cdr var)))
|
|
315 (setq wnn-error-code (list ':WNN_UNKNOWN_HOST
|
|
316 jserver_name)))
|
|
317 ((string-match "Unknown service" (car (cdr var)))
|
|
318 (setq wnn-error-code (list ':WNN_UNKNOWN_SERVICE
|
|
319 *wnn-service-name*)))
|
|
320 (t ;;; "Host ... not respoding"
|
|
321 (setq wnn-error-code ':WNN_SOCK_OPEN_FAIL)))
|
|
322 nil)))
|
|
323 (if (null wnn-server-process) nil
|
|
324 (setq wnn-server-buffer (get-buffer " [Wnn V3 Output Buffer] "))
|
|
325 (setq wnn-command-buffer (get-buffer-create " [Wnn V3 Command Buffer] "))
|
|
326 (setq wnn-result-buffer (get-buffer-create " [Wnn V3 Result Buffer] "))
|
|
327
|
|
328 (save-excursion
|
|
329 ;;; for Nemacs 3.0
|
|
330 (if (fboundp 'set-process-kanji-code)
|
|
331 (set-process-kanji-code wnn-server-process 0))
|
|
332 (progn
|
|
333 (set-buffer wnn-server-buffer)
|
|
334 (setq kanji-flag nil)
|
|
335 ;;; for Nemacs 2.1
|
|
336 (setq kanji-fileio-code 0)
|
|
337 (buffer-flush-undo wnn-server-buffer)
|
|
338 )
|
|
339 (progn
|
|
340 (set-buffer wnn-result-buffer)
|
|
341 (setq kanji-flag nil)
|
|
342 ;;; for Nemacs 2.1
|
|
343 (setq kanji-fileio-code 0)
|
|
344 (buffer-flush-undo wnn-result-buffer))
|
|
345 (progn
|
|
346 (set-buffer wnn-command-buffer)
|
|
347 (setq kanji-flag nil)
|
|
348 ;;; for Nemacs 2.1
|
|
349 (setq kanji-fileio-code 0)
|
|
350 (buffer-flush-undo wnn-command-buffer)
|
|
351 (erase-buffer)
|
|
352 (setq wnn-command-tail-position (point-min))
|
|
353 (let ((max 1024) (i 0))
|
|
354 (while (< i max)
|
|
355 (insert 0)
|
|
356 (setq i (1+ i)))))
|
|
357 (wnn-command-start JD_OPEN_IN)
|
|
358 (wnn-put-4byte kana_len)
|
|
359 (wnn-put-4byte klist_len)
|
|
360 (wnn-put-string user_name)
|
|
361 (wnn-put-string host_name)
|
|
362 (wnn-command-end)
|
|
363 (wnn-get-result)
|
|
364 (wnn-get-return-code))))))
|
|
365
|
|
366 (defun wnn-server-active-p ()
|
|
367 (and wnn-server-process
|
|
368 (eq (process-status wnn-server-process) 'open)))
|
|
369
|
|
370 (defun wnn-connection-error ()
|
|
371 (setq wnn-error-code ':wnn-no-connection)
|
|
372 (setq wnn-return-code -1)
|
|
373 nil)
|
|
374
|
|
375 (defun wnn-zero-arg-command (op)
|
|
376 (if (wnn-server-active-p)
|
|
377 (save-excursion
|
|
378 (wnn-command-start op)
|
|
379 (wnn-command-end)
|
|
380 (wnn-get-result)
|
|
381 (wnn-get-return-code))
|
|
382 (wnn-connection-error)))
|
|
383
|
|
384 (defun wnn-server-close ()
|
|
385 (wnn-zero-arg-command JD_CLOSE))
|
|
386
|
|
387 (or (fboundp 'si:kill-emacs)
|
|
388 (fset 'si:kill-emacs (symbol-function 'kill-emacs)))
|
|
389
|
|
390 (defun kill-emacs (&optional arg)
|
|
391 (interactive "P")
|
|
392 (if (wnn-server-active-p)
|
|
393 (progn
|
|
394 (wnn-server-dict-save)
|
|
395 (message "Wnn$B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$^$7$?!#(B") (sit-for 0)
|
|
396 (wnn-server-close)))
|
|
397 (si:kill-emacs arg))
|
|
398
|
|
399 (or (fboundp 'si:do-auto-save)
|
|
400 (fset 'si:do-auto-save (symbol-function 'do-auto-save)))
|
|
401
|
|
402 (defvar *wnn-do-auto-save-dict* nil)
|
|
403
|
|
404 (defun do-auto-save (&optional nomsg)
|
|
405 (interactive)
|
|
406 (if (and *wnn-do-auto-save-dict*
|
|
407 (wnn-server-dict-save))
|
|
408 (progn
|
|
409 (wnn-serve-dict-save)
|
|
410 (message "Wnn$B$NIQEY>pJs!&<-=q>pJs$rB`Hr$7$^$7$?!#(B")
|
|
411 (sit-for 1)))
|
|
412 (si:do-auto-save nomsg))
|
|
413
|
|
414 ;;; Wnn Result Buffer's layout:
|
|
415 ;;;
|
|
416 ;;; { length:4 kana 0 kouhoSuu:4 kouhoNo:4
|
|
417 ;;; {jihoNo:4 serialNo:4 jirituGo 0 fuzokuGo 0 } ...
|
|
418 ;;; }
|
|
419 ;;; 0 0 0 0
|
|
420
|
|
421 (defun wnn-skip-length ()
|
|
422 (goto-char (+ (point) 4)))
|
|
423
|
|
424 (defun wnn-skip-4byte ()
|
|
425 (goto-char (+ (point) 4)))
|
|
426
|
|
427 (defun wnn-skip-yomi ()
|
|
428 (skip-chars-forward "^\0") (forward-char 1))
|
|
429
|
|
430 (defun wnn-skip-kouho ()
|
|
431 (goto-char (+ (point) 8))
|
|
432 (skip-chars-forward "^\0") (forward-char 1)
|
|
433 (skip-chars-forward "^\0") (forward-char 1)
|
|
434 )
|
|
435
|
|
436 (defun wnn-forward-char (n)
|
|
437 (let ((i 1))
|
|
438 (while (<= i n)
|
|
439 (if (<= 128 (following-char))
|
|
440 (forward-char 2)
|
|
441 (forward-char 1))
|
|
442 (setq i (1+ i)))))
|
|
443
|
|
444 ;;;
|
|
445 ;;; entry function
|
|
446 ;;;
|
|
447 (defun wnn-server-henkan-begin (henkan-string)
|
|
448 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
449 (let ((inhibit-quit t))
|
|
450 (save-excursion
|
|
451 (setq wnn-henkan-string henkan-string)
|
|
452 (set-buffer wnn-result-buffer)
|
|
453 (erase-buffer)
|
|
454 (setq wnn-bunsetu-suu 0)
|
|
455 (goto-char (point-min))
|
|
456 (wnn-command-start JD_BEGIN)
|
|
457 (wnn-put-string* henkan-string)
|
|
458 (wnn-command-end)
|
|
459 (wnn-get-result)
|
|
460 (wnn-henkan-recieve)))))
|
|
461
|
|
462 ;;;
|
|
463 ;;; entry function
|
|
464 ;;;
|
|
465 (defun wnn-server-henkan-quit () t)
|
|
466
|
|
467 ;;;
|
|
468 ;;; entry function
|
|
469 ;;;
|
|
470 (defun wnn-server-henkan-end (bunsetu-no)
|
|
471 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
472 (let ((inhibit-quit t))
|
|
473 (save-excursion
|
|
474 (let (length jisho-no serial-no kouho-no p0)
|
|
475 (wnn-command-start JD_END)
|
|
476 (set-buffer wnn-result-buffer)
|
|
477 (goto-char (point-min))
|
|
478 (let ((max (if (and (integerp bunsetu-no)
|
|
479 (<= 0 bunsetu-no)
|
|
480 (<= bunsetu-no wnn-bunsetu-suu))
|
|
481 bunsetu-no
|
|
482 wnn-bunsetu-suu))
|
|
483 (i 0))
|
|
484 (while (< i max)
|
|
485 (setq length (wnn-get-4byte))
|
|
486 (setq p0 (point))
|
|
487 (wnn-skip-yomi)
|
|
488 (wnn-skip-4byte) ;;; kouho suu
|
|
489 (setq kouho-no (wnn-get-4byte))
|
|
490 (let ((j 0))
|
|
491 (while (< j kouho-no)
|
|
492 (wnn-skip-kouho)
|
|
493 (setq j (1+ j))))
|
|
494 (setq jisho-no (wnn-get-4byte))
|
|
495 (setq serial-no (wnn-get-4byte))
|
|
496 (goto-char (+ p0 length))
|
|
497 (set-buffer wnn-command-buffer)
|
|
498 (insert 0 )
|
|
499 (wnn-put-4byte jisho-no)
|
|
500 (wnn-put-4byte serial-no)
|
|
501 (set-buffer wnn-result-buffer)
|
|
502 (setq i (1+ i)))))
|
|
503 (set-buffer wnn-command-buffer)
|
|
504 (insert 255)
|
|
505 (wnn-command-end)
|
|
506 (wnn-get-result)
|
|
507 (wnn-get-return-code)))))
|
|
508
|
|
509 (defun wnn-result-goto-bunsetu (bunsetu-no)
|
|
510 (goto-char (point-min))
|
|
511 (let (length (i 0))
|
|
512 (while (< i bunsetu-no)
|
|
513 (setq length (wnn-get-4byte))
|
|
514 (goto-char (+ (point) length))
|
|
515 (setq i (1+ i)))))
|
|
516
|
|
517 ;;;
|
|
518 ;;; entry function
|
|
519 ;;;
|
|
520 (defun wnn-server-henkan-kakutei (bunsetu-no jikouho-no)
|
|
521 (cond((not (wnn-server-active-p)) (wnn-connection-error))
|
|
522 ((or (< bunsetu-no 0) (<= wnn-bunsetu-suu bunsetu-no))
|
|
523 nil)
|
|
524 (t
|
|
525 (let ((inhibit-quit t))
|
|
526 (save-excursion
|
|
527 (set-buffer wnn-result-buffer)
|
|
528 (let (kouho-suu)
|
|
529 (wnn-result-goto-bunsetu bunsetu-no)
|
|
530 (wnn-skip-length)
|
|
531 (wnn-skip-yomi)
|
|
532 (setq kouho-suu (wnn-get-4byte))
|
|
533 (if (or (< jikouho-no 0) (<= kouho-suu jikouho-no)) nil
|
|
534 (delete-char 4) (wnn-put-4byte jikouho-no)
|
|
535 t)))))))
|
|
536
|
|
537 ;;;
|
|
538 ;;; entry function
|
|
539 ;;;
|
|
540 (defun wnn-server-henkan-next (bunsetu-no)
|
|
541 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
542 (let ((inhibit-quit t))
|
|
543 (save-excursion
|
|
544 (let (p0 p1 kouho-suu length yomi0 yomi1)
|
|
545 (set-buffer wnn-result-buffer)
|
|
546 (wnn-result-goto-bunsetu bunsetu-no)
|
|
547 (setq length (wnn-get-4byte))
|
|
548 (setq p0 (point))
|
|
549 (setq p1 (+ p0 length))
|
|
550 (setq yomi0 (point))
|
|
551 (wnn-skip-yomi)
|
|
552 (setq yomi1 (point))
|
|
553 (setq kouho-suu (wnn-peek-4byte))
|
|
554 (cond((< 1 kouho-suu) t)
|
|
555 (t
|
|
556 (wnn-command-start JD_NEXT)
|
|
557 (wnn-put-4byte bunsetu-no)
|
|
558 (wnn-command-end)
|
|
559 (wnn-get-result)
|
|
560 (wnn-get-return-code)
|
|
561 (if (= wnn-return-code -1) wnn-return-code
|
|
562 (let (jl jisho-no serial-no kanji)
|
|
563 (set-buffer wnn-result-buffer)
|
|
564 (delete-region (point) p1)
|
|
565 (wnn-put-4byte wnn-return-code)
|
|
566 (wnn-put-4byte 0) ;;; current jikouho number
|
|
567 (set-buffer wnn-server-buffer)
|
|
568 (while (not (= (setq jl (wnn-get-4byte)) -1))
|
|
569 (setq jisho-no (wnn-get-4byte)
|
|
570 serial-no (wnn-get-4byte)
|
|
571 kanji (wnn-get-string*))
|
|
572 (set-buffer wnn-result-buffer)
|
|
573 (wnn-put-4byte jisho-no)
|
|
574 (wnn-put-4byte serial-no)
|
|
575 (insert kanji 0)
|
|
576 (let ((p1 (point)) fuzoku)
|
|
577 (goto-char yomi0)
|
|
578 (wnn-forward-char jl)
|
|
579 (setq fuzoku (point))
|
|
580 (goto-char p1)
|
|
581 (insert-buffer-substring wnn-result-buffer fuzoku yomi1))
|
|
582 (set-buffer wnn-server-buffer))
|
|
583 (set-buffer wnn-result-buffer)
|
|
584 (setq length (- (point) p0))
|
|
585 (goto-char p0) (delete-char -4)
|
|
586 (wnn-put-4byte length))
|
|
587 t))))))))
|
|
588
|
|
589 (defun jd_reconv (bunsetu-no new-kana)
|
|
590 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
591 (if (= bunsetu-no 0) (jd_begin kana)
|
|
592 (let ((inhibit-quit t))
|
|
593 (save-excursion
|
|
594 (wnn-command-start JD_RECONV)
|
|
595 (wnn-put-4byte bunsetu-no)
|
|
596 (wnn-put-string* new-kana)
|
|
597 (wnn-command-end)
|
|
598 (wnn-get-result)
|
|
599 (wnn-henkan-recieve bunsetu-no))))))
|
|
600
|
|
601 ;;;
|
|
602 ;;; entry function
|
|
603 ;;;
|
|
604 (defun wnn-server-bunsetu-henkou (bunsetu-no bunsetu-length)
|
|
605 (cond((not (wnn-server-active-p)) (wnn-connection-error))
|
|
606 ((or (< bunsetu-no 0) (<= wnn-bunsetu-suu bunsetu-no))
|
|
607 nil)
|
|
608 (t
|
|
609 (let ((inhibit-quit t))
|
|
610 (save-excursion
|
|
611 (set-buffer wnn-result-buffer)
|
|
612 (wnn-result-goto-bunsetu bunsetu-no)
|
|
613 (wnn-command-start JD_TANCONV)
|
|
614 (wnn-put-4byte bunsetu-no)
|
|
615 (wnn-put-4byte bunsetu-length)
|
|
616 (wnn-command-end)
|
|
617 (wnn-get-result)
|
|
618 (setq wnn-bunsetu-suu bunsetu-no)
|
|
619 (wnn-henkan-recieve))))))
|
|
620
|
|
621 (defun wnn-henkan-recieve ()
|
|
622 (wnn-get-return-code)
|
|
623 (if (= wnn-return-code -1) nil
|
|
624 (let (p0 p1 length s-ichi jl fl jisho-no serial-no kanji fuzokugo)
|
|
625 (setq wnn-bunsetu-suu (+ wnn-bunsetu-suu wnn-return-code))
|
|
626 (if (zerop wnn-return-code) nil
|
|
627 (setq s-ichi (wnn-peek-4byte))
|
|
628 (set-buffer wnn-result-buffer)
|
|
629 (delete-region (point) (point-max))
|
|
630 (setq p0 (point))
|
|
631 (insert wnn-henkan-string 0 0 0 0)
|
|
632 (goto-char p0)
|
|
633 (wnn-forward-char s-ichi)
|
|
634 (delete-region p0 (point))
|
|
635 (set-buffer wnn-server-buffer)
|
|
636 (while (not (= (setq s-ichi (wnn-get-4byte)) -1))
|
|
637 (setq jl (wnn-get-4byte)
|
|
638 fl (wnn-get-4byte)
|
|
639 jisho-no (wnn-get-4byte)
|
|
640 serial-no (wnn-get-4byte)
|
|
641 kanji (wnn-get-string*))
|
|
642 (set-buffer wnn-result-buffer)
|
|
643 (setq p0 (point))
|
|
644 (wnn-forward-char jl)
|
|
645 (setq p1 (point))
|
|
646 (wnn-forward-char fl)
|
|
647 (setq fuzokugo (buffer-substring p1 (point)))
|
|
648 (insert 0) ;;; yomi
|
|
649 (wnn-put-4byte 1) ;;; kouho suu
|
|
650 (wnn-put-4byte 0) ;;; current kouho number
|
|
651 (wnn-put-4byte jisho-no)
|
|
652 (wnn-put-4byte serial-no)
|
|
653 (insert kanji 0 fuzokugo 0)
|
|
654 (setq length (- (point) p0))
|
|
655 (goto-char p0) (wnn-put-4byte length)
|
|
656 (goto-char (+ (point) length))
|
|
657 (set-buffer wnn-server-buffer)))))
|
|
658 wnn-return-code)
|
|
659
|
|
660 (defun wnn-bunsetu-suu () wnn-bunsetu-suu)
|
|
661
|
|
662 (defun wnn-bunsetu-kanji (bunsetu-no &optional buffer)
|
|
663 (let ((savebuffer (current-buffer)))
|
|
664 (unwind-protect
|
|
665 (progn
|
|
666 (set-buffer wnn-result-buffer)
|
|
667 (if (or (< bunsetu-no 0)
|
|
668 (<= wnn-bunsetu-suu bunsetu-no))
|
|
669 nil
|
|
670 (wnn-result-goto-bunsetu bunsetu-no)
|
|
671 (wnn-skip-length)
|
|
672 (wnn-skip-yomi)
|
|
673
|
|
674 (wnn-skip-4byte) ;;; kouho-suu
|
|
675 (let ((i 0) (max (wnn-get-4byte)))
|
|
676 (while (< i max)
|
|
677 (wnn-skip-kouho)
|
|
678 (setq i (1+ i))))
|
|
679
|
|
680 (let ( p1 p2 p3 )
|
|
681 (goto-char (+ (point) 4 4))
|
|
682 (setq p1 (point))
|
|
683 (skip-chars-forward "^\0") (setq p2 (point))
|
|
684 (forward-char 1) (skip-chars-forward "^\0")
|
|
685 (setq p3 (point))
|
|
686 (if (null buffer)
|
|
687 (concat (buffer-substring p1 p2) (buffer-substring (1+ p2) p3))
|
|
688 (set-buffer buffer)
|
|
689 (insert-buffer-substring wnn-result-buffer p1 p2)
|
|
690 (insert-buffer-substring wnn-result-buffer (1+ p2) p3)
|
|
691 nil))))
|
|
692 (set-buffer savebuffer))))
|
|
693
|
|
694 (defun wnn-bunsetu-kanji-length (bunsetu-no)
|
|
695 (save-excursion
|
|
696 (set-buffer wnn-result-buffer)
|
|
697 (if (or (< bunsetu-no 0)
|
|
698 (<= wnn-bunsetu-suu bunsetu-no))
|
|
699 nil
|
|
700 (wnn-result-goto-bunsetu bunsetu-no)
|
|
701 (wnn-skip-length)
|
|
702 (wnn-skip-yomi)
|
|
703
|
|
704 (wnn-skip-4byte) ;;; kouho-suu
|
|
705 (let ((i 0) (max (wnn-get-4byte)))
|
|
706 (while (< i max)
|
|
707 (wnn-skip-kouho)
|
|
708 (setq i (1+ i))))
|
|
709
|
|
710 (let ( p1 p3 )
|
|
711 (goto-char (+ (point) 4 4))
|
|
712 (setq p1 (point))
|
|
713 (skip-chars-forward "^\0")(forward-char 1) (skip-chars-forward "^\0")
|
|
714 (setq p3 (point))
|
|
715 (- p3 p1 1)))))
|
|
716
|
|
717 (defun wnn-bunsetu-yomi-moji-suu (bunsetu-no)
|
|
718 (save-excursion
|
|
719 (set-buffer wnn-result-buffer)
|
|
720 (if (or (< bunsetu-no 0)
|
|
721 (<= wnn-bunsetu-suu bunsetu-no))
|
|
722 nil
|
|
723 (wnn-result-goto-bunsetu bunsetu-no)
|
|
724 (wnn-skip-length)
|
|
725 (let ((c 0) ch)
|
|
726 (while (not (zerop (setq ch (following-char))))
|
|
727 (if (<= 128 ch) (forward-char 2)
|
|
728 (forward-char 1))
|
|
729 (setq c (1+ c)))
|
|
730 c))))
|
|
731
|
|
732 (defun wnn-bunsetu-yomi (bunsetu-no &optional buffer)
|
|
733 (let ((savebuff (current-buffer)))
|
|
734 (unwind-protect
|
|
735 (progn
|
|
736 (set-buffer wnn-result-buffer)
|
|
737 (if (or (< bunsetu-no 0)
|
|
738 (<= wnn-bunsetu-suu bunsetu-no))
|
|
739 nil
|
|
740 (wnn-result-goto-bunsetu bunsetu-no)
|
|
741 (wnn-skip-length)
|
|
742 (let (p1 p2 )
|
|
743 (setq p1 (point))
|
|
744 (skip-chars-forward "^\0")
|
|
745 (if (null buffer ) (buffer-substring p1 (point))
|
|
746 (setq p2 (point))
|
|
747 (set-buffer buffer)
|
|
748 (insert-buffer-substring wnn-result-buffer p1 p2)
|
|
749 t))))
|
|
750 (set-buffer savebuff))))
|
|
751
|
|
752 (defun wnn-bunsetu-yomi-equal (bunsetu-no yomi)
|
|
753 (save-excursion
|
|
754 (set-buffer wnn-result-buffer)
|
|
755 (if (or (< bunsetu-no 0)
|
|
756 (<= wnn-bunsetu-suu bunsetu-no))
|
|
757 nil
|
|
758 (wnn-result-goto-bunsetu bunsetu-no)
|
|
759 (wnn-skip-length)
|
|
760 (looking-at yomi)))) ; 93.4.6 by T.Saneto
|
|
761
|
|
762 (defun wnn-bunsetu-kouho-suu (bunsetu-no)
|
|
763 (save-excursion
|
|
764 (set-buffer wnn-result-buffer)
|
|
765 (if (or (< bunsetu-no 0)
|
|
766 (<= wnn-bunsetu-suu bunsetu-no))
|
|
767 nil
|
|
768 (wnn-result-goto-bunsetu bunsetu-no)
|
|
769 (wnn-skip-length)
|
|
770 (wnn-skip-yomi)
|
|
771 (wnn-get-4byte))))
|
|
772
|
|
773 (defun wnn-bunsetu-kouho-list (bunsetu-no)
|
|
774 (save-excursion
|
|
775 (set-buffer wnn-result-buffer)
|
|
776 (if (or (< bunsetu-no 0)
|
|
777 (<= wnn-bunsetu-suu bunsetu-no))
|
|
778 nil
|
|
779 (wnn-result-goto-bunsetu bunsetu-no)
|
|
780 (wnn-skip-length)
|
|
781 (wnn-skip-yomi)
|
|
782 (let ((max (wnn-get-4byte)) (i 0) (result nil) p0 p1)
|
|
783 (wnn-skip-4byte) ;;; current kouhou number
|
|
784 (while (< i max)
|
|
785 (wnn-skip-4byte) (wnn-skip-4byte)
|
|
786 (setq p0 (point))
|
|
787 (skip-chars-forward "^\0")
|
|
788 (setq p1 (point))
|
|
789 (forward-char 1)
|
|
790 (skip-chars-forward "^\0")
|
|
791 (setq result
|
|
792 (cons (concat (buffer-substring p0 p1)
|
|
793 (buffer-substring (1+ p1) (point)))
|
|
794 result))
|
|
795 (forward-char 1)
|
|
796 (setq i (1+ i)))
|
|
797 (nreverse result)))))
|
|
798
|
|
799 (defun wnn-bunsetu-kouho-number (bunsetu-no)
|
|
800 (save-excursion
|
|
801 (set-buffer wnn-result-buffer)
|
|
802 (if (or (< bunsetu-no 0)
|
|
803 (<= wnn-bunsetu-suu bunsetu-no))
|
|
804 nil
|
|
805 (wnn-result-goto-bunsetu bunsetu-no)
|
|
806 (wnn-skip-length)
|
|
807 (wnn-skip-yomi)
|
|
808 (wnn-skip-4byte)
|
|
809 (wnn-get-4byte)))
|
|
810 )
|
|
811
|
|
812 (defun wnn-bunsetu-kouho-kanji (bunsetu-no kouho-no)
|
|
813 (save-excursion
|
|
814 (set-buffer wnn-result-buffer)
|
|
815 (if (or (< bunsetu-no 0)
|
|
816 (<= wnn-bunsetu-suu bunsetu-no))
|
|
817 nil
|
|
818 (wnn-result-goto-bunsetu bunsetu-no)
|
|
819 (wnn-skip-length) (wnn-skip-yomi)
|
|
820 (let ((kouho-suu (wnn-get-4byte)))
|
|
821 (if (or (< kouho-no 0) (<= kouho-suu kouho-no))
|
|
822 nil
|
|
823 (wnn-skip-4byte) ;;; current kouho number
|
|
824 (let ((i 0))
|
|
825 (while (< i kouho-no)
|
|
826 (wnn-skip-kouho)
|
|
827 (setq i (1+ i))))
|
|
828 (let ( p1 p2 p3 )
|
|
829 (goto-char (+ (point) 4 4))
|
|
830 (setq p1 (point))
|
|
831 (skip-chars-forward "^\0") (setq p2 (point))
|
|
832 (forward-char 1) (skip-chars-forward "^\0")
|
|
833 (setq p3 (point))
|
|
834 (concat (buffer-substring p1 p2) (buffer-substring (1+ p2) p3))))))))
|
|
835
|
|
836 (defun wnn-bunsetu-kouho-inspect (bunsetu-no kouho-no)
|
|
837 (save-excursion
|
|
838 (set-buffer wnn-result-buffer)
|
|
839 (if (or (< bunsetu-no 0)
|
|
840 (<= wnn-bunsetu-suu bunsetu-no))
|
|
841 nil
|
|
842 (let (p0 p1 kouho-suu jiritugo fuzokugo yomi jishono serial )
|
|
843 (wnn-result-goto-bunsetu bunsetu-no)
|
|
844 (wnn-skip-length)
|
|
845 (setq p0 (point))
|
|
846 (wnn-skip-yomi)
|
|
847 (setq p1 (1- (point)))
|
|
848 (setq kouho-suu (wnn-get-4byte))
|
|
849 (if (or (< kouho-no 0) (<= kouho-suu kouho-no))
|
|
850 nil
|
|
851 (wnn-skip-4byte) ;;; current kouho number
|
|
852 (let ((i 0))
|
|
853 (while (< i kouho-no)
|
|
854 (wnn-skip-kouho)
|
|
855 (setq i (1+ i))))
|
|
856 (setq jishono (wnn-get-4byte))
|
|
857 (setq serial (wnn-get-4byte))
|
|
858 (setq jiritugo (wnn-get-string))
|
|
859 (setq fuzokugo (wnn-get-string))
|
|
860 (goto-char p1)
|
|
861 (if (not (equal "" fuzokugo)) (search-backward fuzokugo p0))
|
|
862 (setq yomi (buffer-substring p0 (point)))
|
|
863 (list jiritugo fuzokugo yomi jishono serial))))))
|
|
864
|
|
865 (defun wnn-simple-command (op arg)
|
|
866 (if (wnn-server-active-p)
|
|
867 (let ((inhibit-quit t))
|
|
868 (save-excursion
|
|
869 (wnn-command-start op)
|
|
870 (wnn-put-4byte arg)
|
|
871 (wnn-command-end)
|
|
872 (wnn-get-result)
|
|
873 (wnn-get-return-code)))
|
|
874 (wnn-connection-error)))
|
|
875
|
|
876 (defun jd_udp (dict-no)
|
|
877 (wnn-simpale-command JD_UDP dict-no))
|
|
878
|
|
879 (defun wnn-server-set-current-dict (dict-no)
|
|
880 (wnn-simple-command JD_UDCHG dict-no))
|
|
881
|
|
882 (defun wnn-server-dict-save ()
|
|
883 (wnn-zero-arg-command JD_FREQSV))
|
|
884
|
|
885 (defun wnn-server-use-dict (dict-file-name hindo-file-name priority readonly-flag)
|
|
886 (if (not (wnn-server-active-p))(wnn-connection-error)
|
|
887 (let ((inhibit-quit t))
|
|
888 (save-excursion
|
|
889 (wnn-command-start JD_DICADD)
|
|
890 (wnn-put-string dict-file-name)
|
|
891 (wnn-put-string hindo-file-name)
|
|
892 (wnn-put-4byte priority)
|
|
893 (wnn-put-4byte (if readonly-flag 1 0))
|
|
894 (wnn-command-end)
|
|
895 (wnn-get-result)
|
|
896 (wnn-get-return-code)))))
|
|
897
|
|
898 (defun jd_dicdel (dict-no)
|
|
899 (wnn-simple-command JD_DICDEL dict-no))
|
|
900
|
|
901 (defun jd_dicinfo ()
|
|
902 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
903 (let ((inhibit-quit t))
|
|
904 (save-excursion
|
|
905 (wnn-command-start JD_DICINFO)
|
|
906 (wnn-command-end)
|
|
907 (wnn-get-result)
|
|
908 (let ((dic-no 0) (result nil))
|
|
909 (while (not (= (setq dic-no (wnn-get-4byte)) -1))
|
|
910 (setq result
|
|
911 (cons (list
|
|
912 dic-no
|
|
913 (wnn-get-4byte) ;;; ttl_hindo
|
|
914 (wnn-get-4byte) ;;; dic_type
|
|
915 (wnn-get-4byte) ;;; udp
|
|
916 (wnn-get-4byte) ;;; dic_size
|
|
917 (wnn-get-4byte) ;;; prioritry
|
|
918 (wnn-get-4byte) ;;; readonly no:0 yes:1
|
|
919 (wnn-get-string) ;;; dic_name
|
|
920 (wnn-get-string) ;;; hindo_name
|
|
921 )
|
|
922 result))
|
|
923 (nreverse result)))))))
|
|
924
|
|
925 (defun jd_dicstat (file-name)
|
|
926 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
927 (let ((inhibit-quit t))
|
|
928 (save-excursion
|
|
929 (wnn-command-start JD_DICSTAT)
|
|
930 (wnn-put-string file-name)
|
|
931 (wnn-command-end)
|
|
932 (wnn-get-result)
|
|
933 (wnn-get-return-code)))))
|
|
934
|
|
935 (defun wnn-server-dict-delete (serial-no yomi)
|
|
936 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
937 (let ((inhibit-quit t))
|
|
938 (save-excursion
|
|
939 (wnn-command-start JD_WDEL)
|
|
940 (wnn-put-4byte serial-no)
|
|
941 (wnn-put-string* yomi)
|
|
942 (wnn-command-end)
|
|
943 (wnn-get-result)
|
|
944 (wnn-get-return-code)))))
|
|
945
|
|
946 (defun wnn-server-dict-info (yomi)
|
|
947 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
948 (let ((inhibit-quit t))
|
|
949 (save-excursion
|
|
950 (wnn-command-start JD_WSCH)
|
|
951 (wnn-put-string* yomi)
|
|
952 (wnn-command-end)
|
|
953 (wnn-get-result)
|
|
954 (wnn-get-return-code)
|
|
955 (if (= wnn-return-code -1) nil
|
|
956 (let ((hindo 0) bunpo jisho serial kanji (result nil))
|
|
957 (while (not (= (setq hindo (wnn-get-4byte)) -1))
|
|
958 (setq bunpo (wnn-get-bit-positions))
|
|
959 (setq jisho (wnn-get-4byte))
|
|
960 (setq serial (wnn-get-4byte))
|
|
961 (setq kanji (wnn-get-string*))
|
|
962 (setq result
|
|
963 (if (integerp bunpo)
|
|
964 (cons (list kanji bunpo hindo jisho serial)
|
|
965 result)
|
|
966 (append
|
|
967 (mapcar (function (lambda (x)
|
|
968 (list kanji x hindo jisho serial)))
|
|
969 bunpo)
|
|
970 result))))
|
|
971 (nreverse result)))))))
|
|
972
|
|
973 (defun wnn-server-dict-add (kanji yomi bunpo)
|
|
974 (if (not (wnn-server-active-p))(wnn-connection-error)
|
|
975 (let ((inhibit-quit t))
|
|
976 (save-excursion
|
|
977 (wnn-command-start JD_WREG)
|
|
978 (wnn-put-bit-position bunpo)
|
|
979 (wnn-put-4byte 129) ;;; 0x81 hindo always 1 with imatukattayo bit.(jl.c)
|
|
980 (wnn-put-string* kanji)
|
|
981 (wnn-put-string* yomi)
|
|
982 (wnn-command-end)
|
|
983 (wnn-get-result)
|
|
984 (wnn-get-return-code)))))
|
|
985
|
|
986 (defun jd_whdel (serial-no yomi bunpo)
|
|
987 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
988 (let ((inhibit-quit t))
|
|
989 (save-excursion
|
|
990 (wnn-command-start JD_WHDEL)
|
|
991 (wnn-put-4byte serial-no)
|
|
992 (wnn-put-string* yomi)
|
|
993 (wnn-put-4byte bunpo)
|
|
994 (wnn-command-end)
|
|
995 (wnn-get-result)
|
|
996 (wnn-get-return-code)))))
|
|
997
|
|
998 (defun jd_setevf (bunsetu-su p1 p2 p3 p4 p5)
|
|
999 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
1000 (let ((inhibit-quit t))
|
|
1001 (save-excursion
|
|
1002 (wnn-command-start JD_SETEVF)
|
|
1003 (wnn-put-4byte bunsetu-su)
|
|
1004 (wnn-put-4byte p1)
|
|
1005 (wnn-put-4byte p2)
|
|
1006 (wnn-put-4byte p3)
|
|
1007 (wnn-put-4byte p4)
|
|
1008 (wnn-put-4byte p5)
|
|
1009 (wnn-put-4byte 0);; p6
|
|
1010 (wnn-put-4byte 0);; p7
|
|
1011 (wnn-put-4byte 0);; p8
|
|
1012 (wnn-put-4byte 0);; p9
|
|
1013 (wnn-put-4byte 0);; p10
|
|
1014 (wnn-command-end)
|
|
1015 (wnn-get-result)
|
|
1016 (wnn-get-return-code)))))
|
|
1017
|
|
1018 (defun jd_getevf ()
|
|
1019 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
1020 (let ((inhibit-quit t))
|
|
1021 (save-excursion
|
|
1022 (wnn-command-start JD_GETEVF)
|
|
1023 (wnn-command-end)
|
|
1024 (wnn-get-result)
|
|
1025 (prog1
|
|
1026 (list
|
|
1027 (wnn-get-4byte) ;;; bunsetu-su
|
|
1028 (wnn-get-4byte) ;;; p1
|
|
1029 (wnn-get-4byte) ;;; p2
|
|
1030 (wnn-get-4byte) ;;; p3
|
|
1031 (wnn-get-4byte) ;;; p4
|
|
1032 (wnn-get-4byte) ;;; p5
|
|
1033 )
|
|
1034 (wnn-get-4byte);; p6
|
|
1035 (wnn-get-4byte);; p7
|
|
1036 (wnn-get-4byte);; p8
|
|
1037 (wnn-get-4byte);; p9
|
|
1038 (wnn-get-4byte);; p10
|
|
1039 )))))
|
|
1040
|
|
1041 (defun wnn-server-make-directory (dir-name)
|
|
1042 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
1043 (let ((inhibit-quit t))
|
|
1044 (save-excursion
|
|
1045 (wnn-command-start JD_MKDIR)
|
|
1046 (wnn-put-string dir-name)
|
|
1047 (wnn-command-end)
|
|
1048 (wnn-get-result)
|
|
1049 (wnn-get-return-code)))))
|
|
1050
|
|
1051 (defun wnn-server-file-access (file-name access-mode)
|
|
1052 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
1053 (let ((inhibit-quit t))
|
|
1054 (save-excursion
|
|
1055 (wnn-command-start JD_ACCESS)
|
|
1056 (wnn-put-4byte access-mode)
|
|
1057 (wnn-put-string file-name)
|
|
1058 (wnn-command-end)
|
|
1059 (wnn-get-result)
|
|
1060 (setq wnn-return-code (wnn-get-4byte))
|
|
1061 (setq wnn-error-code nil)
|
|
1062 wnn-return-code))))
|
|
1063
|
|
1064 (defun jd_who ()
|
|
1065 (if (not (wnn-server-active-p)) (wnn-connection-error)
|
|
1066 (let ((inhibit-quit t))
|
|
1067 (save-excursion
|
|
1068 (wnn-command-start JD_WHO)
|
|
1069 (wnn-command-end)
|
|
1070 (wnn-get-result)
|
|
1071 (let ( number user host result)
|
|
1072 (while (not (= (setq number (wnn-get-4byte)) -1))
|
|
1073 (setq result
|
|
1074 (cons
|
|
1075 (list number (wnn-get-string) (wnn-get-string))
|
|
1076 result)))
|
|
1077 (nreverse result))))))
|
|
1078
|
|
1079 (defun jd_version ()
|
|
1080 (wnn-zero-arg-command JD_VERSION))
|
|
1081
|
|
1082 (defconst *wnn-error-alist*
|
|
1083 '(
|
|
1084 (1 :WNN_NO_EXIST
|
|
1085 "$B%U%!%$%k$,B8:_$7$^$;$s!#(B")
|
|
1086 (2 :WNN_NOT_USERDICT
|
|
1087 "$B@5$7$$%f!<%6!<<-=q$G$O$"$j$^$;$s!#(B")
|
|
1088 (3 :WNN_MALLOC_ERR
|
|
1089 "$B%a%b%j(Balloc$B$G<:GT$7$^$7$?!#(B")
|
|
1090 (4 :WNN_NOT_SYSTEM
|
|
1091 "$B@5$7$$%7%9%F%`<-=q$G$O$"$j$^$;$s!#(B")
|
|
1092 (5 :WNN_NOT_A_DICT
|
|
1093 "$B@5$7$$<-=q$G$O$"$j$^$;$s!#(B")
|
|
1094 (6 :WNN_FILE_NO_SPECIFIED
|
|
1095 "$B%U%!%$%kL>$,;XDj$5$l$F$$$^$;$s!#(B")
|
|
1096 (8 :WNN_HINDO_FILE_NOT_SPECIFIED
|
|
1097 "$B%7%9%F%`<-=q$KBP$7$F!"IQEY%U%!%$%k$N;XDj$,$"$j$^$;$s!#(B")
|
|
1098 (9 :WNN_JISHOTABLE_FULL
|
|
1099 "$B<-=q%F!<%V%k$,0lGU$G$9!#(B")
|
|
1100 (10 :WNN_HINDO_NO_MATCH
|
|
1101 "$BIQEY%U%!%$%k$,!";XDj$5$l$?<-=q$NIQEY%U%!%$%k$G$O$"$j$^$;$s!#(B")
|
|
1102 (11 :WNN_PARAMR
|
|
1103 "$B%U%!%$%k$NFI$_9~$_8"8B$,$"$j$^$;$s!#(B")
|
|
1104 (12 :WNN_HJT_FULL
|
|
1105 "$B%0%m!<%P%kIQEY%F!<%V%k$,0lGU$G$9!#(B")
|
|
1106 (13 :WNN_JT_FULL
|
|
1107 "$B%0%m!<%P%k<-=q%F!<%V%k$,0lGU$G$9!#(B")
|
|
1108 (15 :WNN_PARAMW
|
|
1109 "$B%U%!%$%k$KBP$9$k=q$-9~$_8"8B$,$"$j$^$;$s!#(B")
|
|
1110 (16 :WNN_OPENF_ERR
|
|
1111 "$B%U%!%$%k$,%*!<%W%s$G$-$^$;$s!#(B")
|
|
1112 ;;; $B<-=q:o=|4X78$N%(%i!<(B
|
|
1113 (20 :WNN_DICT_NOT_USED
|
|
1114 "$B$=$NHV9f$N<-=q$O!";H$o$l$F$$$^$;$s!#(B")
|
|
1115 ;;; $B%f!<%6!<<-=qJQ994X78$N%(%i!<(B
|
|
1116 ;;;
|
|
1117 ;;;WNN_DICT_NOT_USED
|
|
1118 ;;;
|
|
1119 (21 :WNN_NOT_A_USERDICT
|
|
1120 "$B;XDj$5$l$F<-=q$O!"%f!<%6!<<-=q$G$O$"$j$^$;$s!#(B")
|
|
1121 (22 :WNN_READONLY
|
|
1122 "$B%j!<%I%*%s%j!<$N<-=q$O!"%+%l%s%H%f!<%6!<<-=q$K$O$G$-$^$;$s!#(B")
|
|
1123 ;;; $B<-=q%;!<%V4X78$N%(%i!<(B
|
|
1124 ;;;
|
|
1125 ;;; WNN_PARAMW
|
|
1126 ;;; WNN_OPENF_ERR
|
|
1127 ;;; $BJQ49;~$N%(%i!<(B
|
|
1128 ;;; jishobiki.c
|
|
1129 (30 :WNN_JMT_FULL
|
|
1130 "$B<-=q%F!<%V%k$,$"$U$l$F$$$^$9!#(B ")
|
|
1131
|
|
1132 (31 :WNN_LONG_MOJIRETSU
|
|
1133 "$BJQ49$7$h$&$H$9$kJ8;zNs$,D92a$.$^$9!#(B")
|
|
1134 (32 :WNN_WKAREA_FULL
|
|
1135 "$BIUB08l2r@ONN0h$,ITB-$7$F$$$^$9!#(B")
|
|
1136 (33 :WNN_KAREA_FULL
|
|
1137 "$B2r@ONN0h$,ITB-$7$F$$$^$9!#(B")
|
|
1138
|
|
1139 ;;; $BC18lEPO?;~$N%(%i!<(B
|
|
1140 (40 :WNN_YOMI_LONG
|
|
1141 "$BFI$_$,D92a$.$^$9!#(B")
|
|
1142 (41 :WNN_KANJI_LONG
|
|
1143 "$B4A;z$,D92a$.$^$9!#(B")
|
|
1144 (42 :WNN_BAD_YOMI
|
|
1145 "$BFI$_$KITE,Ev$JJ8;z$,4^$^$l$F$$$^$9!#(B")
|
|
1146 (43 :WNN_NO_YOMI
|
|
1147 "$BFI$_$ND9$5$,(B0$B$G$9!#(B")
|
|
1148 (44 :WNN_NO_CURRENT
|
|
1149 "$B%+%l%s%H<-=q$,B8:_$7$^$;$s!#(B")
|
|
1150 (45 :WNN_RDONLY
|
|
1151 "$B%j!<%I%*%s%j!<$N<-=q$KEPO?$7$h$&$H$7$^$7$?!#(B")
|
|
1152
|
|
1153 ;;; $BC18l:o=|;~!"IJ;l:o=|;~$N%(%i!<(B
|
|
1154 ;;;
|
|
1155 ;;;WNN_NO_CURRENT
|
|
1156 ;;;WNN_RDONLY
|
|
1157 ;;;
|
|
1158 (50 :WNN_WORD_NO_EXIST
|
|
1159 "$B;XDj$5$l$?C18l$,B8:_$7$^$;$s!#(B")
|
|
1160
|
|
1161 ;;; $B<!8uJd;~$N%(%i!<(B
|
|
1162 (55 :WNN_JIKOUHO_TOO_MANY
|
|
1163 "$B<!8uJd$N%(%s%H%j!<$N8D?t$,$*$*2a$.$^$9!#(B")
|
|
1164
|
|
1165 ;;; $B=i4|2=$N;~$N%(%i!<(B
|
|
1166 (60 :WNN_MALLOC_INITIALIZE
|
|
1167 "$B%a%b%j(Balloc$B$G<:GT$7$^$7$?!#(B")
|
|
1168
|
|
1169 ;;; $BC18l8!:w;~$N%(%i!<(B
|
|
1170 ;;;
|
|
1171 ;;;WNN_BAD_YOMI
|
|
1172 ;;;WNN_JMT_FULL
|
|
1173 ;;;
|
|
1174
|
|
1175 (68 :WNN_SOME_ERROR
|
|
1176 " $B2?$+$N%(%i!<$,5/$3$j$^$7$?!#(B")
|
|
1177 (69 :WNN_SONOTA
|
|
1178 "$B%P%0$,H/@8$7$F$$$kLOMM$G$9!#(B")
|
|
1179 (70 :WNN_JSERVER_DEAD
|
|
1180 "$B%5!<%P$,;`$s$G$$$^$9!#(B")
|
|
1181 (71 :WNN_ALLOC_FAIL
|
|
1182 "jd_begin$B$G(Balloc$B$K<:GT(B")
|
|
1183 (72 :WNN_SOCK_OPEN_FAIL
|
|
1184 "jd_begin$B$G(Bsocket$B$N(Bopen$B$K<:GT(B")
|
|
1185
|
|
1186 (73 :WNN_RCV_SPACE_OVER
|
|
1187 "$B<u?.%9%Z!<%9$+$i%G!<%?$,$O$_$@$7$?(B")
|
|
1188 (74 :WNN_MINUS_MOJIRETSU
|
|
1189 "$BJ8;zNs$ND9$5$N;XDj$,Ii$G$"$k(B")
|
|
1190 ;;; V3.0
|
|
1191 (80 :WNN_MKDIR_FAIL
|
|
1192 " $B%G%#%l%/%H%j$r:n$jB;$J$C$?(B ")
|
|
1193 (81 :WNN_BAD_USER
|
|
1194 " $B%f!<%6L>$,$J$$(B ")
|
|
1195 (82 :WNN_BAD_HOST
|
|
1196 " $B%[%9%HL>$,$J$$(B ")
|
|
1197 ))
|
|
1198
|
|
1199 (defun wnn-error-symbol (code)
|
|
1200 (let ((pair (assoc code *wnn-error-alist*)))
|
|
1201 (if (null pair)
|
|
1202 (list ':wnn-unknown-error-code code)
|
|
1203 (car (cdr pair)))))
|