Tamagotchy snapshot.
[elisp/egg.git] / egg / wnnrpc.el
1 ;;; egg/wnnrpc.el --- WNN Support (low level interface) in Egg
2 ;;;                   Input Method Architecture
3
4 ;; Copyright (C) 1997 Mule Project, Powered by Electrotechnical
5 ;; Laboratory, JAPAN.
6 ;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
7
8 ;; Author: NIIBE Yutaka <gniibe@mri.co.jp>
9 ;; Maintainer: NIIBE Yutaka <gniibe@mri.co.jp>
10
11 ;; This file will be part of GNU Emacs (in future).
12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29
30 ;;; Code:
31
32 (eval-when-compile
33   (require 'egg-com)
34   (load-library "egg/wnn")
35   (defmacro wnn-const (c)
36     "Macro for WNN constants."
37     (cond ((eq c 'JS_VERSION)             0)
38           ((eq c 'JS_OPEN)                1)
39           ((eq c 'JS_CLOSE)               3)
40           ((eq c 'JS_CONNECT)             5)
41           ((eq c 'JS_DISCONNECT)          6)
42           ((eq c 'JS_ENV_EXIST)           7)
43           ((eq c 'JS_ENV_STICKY)          8)
44           ((eq c 'JS_ENV_UNSTICKY)        9)
45           ((eq c 'JS_KANREN)             17)
46           ((eq c 'JS_KANTAN_SHO)         18)
47           ((eq c 'JS_KANZEN_SHO)         19)
48           ((eq c 'JS_KANTAN_DAI)         20)
49           ((eq c 'JS_KANZEN_DAI)         21)
50           ((eq c 'JS_HINDO_SET)          24)
51           ((eq c 'JS_DIC_ADD)            33)
52           ((eq c 'JS_DIC_DELETE)         34)
53           ((eq c 'JS_DIC_USE)            35)
54           ((eq c 'JS_DIC_LIST)           36)
55           ((eq c 'JS_DIC_INFO)           37)
56           ((eq c 'JS_FUZOKUGO_SET)       41)
57           ((eq c 'JS_FUZOKUGO_GET)       48)
58           ((eq c 'JS_WORD_ADD)           49)
59           ((eq c 'JS_WORD_DELETE)        50)
60           ((eq c 'JS_WORD_SEARCH)        51)
61           ((eq c 'JS_WORD_SEARCH_BY_ENV) 52)
62           ((eq c 'JS_WORD_INFO)          53)
63           ((eq c 'JS_WORD_COMMENT_SET)   54)
64           ((eq c 'JS_PARAM_SET)          65)
65           ((eq c 'JS_PARAM_GET)          66)
66           ((eq c 'JS_MKDIR)              81)
67           ((eq c 'JS_ACCESS)             82)
68           ((eq c 'JS_WHO)                83)
69           ((eq c 'JS_ENV_LIST)           85)
70           ((eq c 'JS_FILE_LIST_ALL)      86)
71           ((eq c 'JS_DIC_LIST_ALL)       87)
72           ((eq c 'JS_FILE_READ)          97)
73           ((eq c 'JS_FILE_WRITE)         98)
74           ((eq c 'JS_FILE_SEND)          99)
75           ((eq c 'JS_FILE_RECEIVE)      100)
76           ((eq c 'JS_HINDO_FILE_CREATE) 101)
77           ((eq c 'JS_DIC_FILE_CREATE)   102)
78           ((eq c 'JS_FILE_REMOVE)       103)
79           ((eq c 'JS_FILE_LIST)         104)
80           ((eq c 'JS_FILE_INFO)         105)
81           ((eq c 'JS_FILE_LOADED)       106)
82           ((eq c 'JS_FILE_LOADED_LOCAL) 107)
83           ((eq c 'JS_FILE_DISCARD)      108)
84           ((eq c 'JS_FILE_COMMENT_SET)  109)
85           ((eq c 'JS_FILE_PASSWORD)     110)
86           ((eq c 'JS_FILE_STAT)         111)
87           ((eq c 'JS_KILL)              112)
88           ((eq c 'JS_HINSI_LIST)        114)
89           ((eq c 'JS_HINSI_NAME)        115)
90           ((eq c 'JS_HINSI_NUMBER)      116)
91           ((eq c 'JS_HINSI_DICTS)       117)
92           ((eq c 'JS_HINSI_TABLE_SET)   118)
93
94           ((eq c 'JLIB_VERSION) 16387)  ; 0x4003
95
96           ((eq c 'WNN_REV_DICT) 3)
97           ((eq c 'WNN_VECT_NO)      -1)
98           ((eq c 'WNN_VECT_BUNSETSU) 2)
99           ((eq c 'WNN_VECT_KANREN) 0)
100           ((eq c 'WNN_VECT_KANZEN) 1)
101           ((eq c 'WNN_VECT_KANTAN) 1)
102           ((eq c 'WNN_MAX_ENV_OF_A_CLIENT) 32)
103           ((eq c 'WNN_MAX_DIC_OF_AN_ENV)   30)
104           ((eq c 'WNN_MAX_FILE_OF_AN_ENV)  60))))
105
106 (defconst wnnrpc-error-message
107   [
108    nil
109    "\e$B%U%!%$%k$,B8:_$7$^$;$s\e(B"
110    nil
111    "\e$B%a%b%j\e(B allocation \e$B$G<:GT$7$^$7$?\e(B"
112    nil
113    "\e$B<-=q$G$O$"$j$^$;$s\e(B"
114    "\e$BIQEY%U%!%$%k$G$O$"$j$^$;$s\e(B"
115    "\e$BIUB08l%U%!%$%k$G$O$"$j$^$;$s\e(B"
116    nil
117    "\e$B<-=q%F!<%V%k$,0lGU$G$9\e(B"
118    "\e$BIQEY%U%!%$%k$,;XDj$5$l$?<-=q$NIQEY%U%!%$%k$G$O$"$j$^$;$s\e(B"
119    nil
120    nil
121    nil
122    nil
123    nil
124    "\e$B%U%!%$%k$,%*!<%W%s$G$-$^$;$s\e(B"
125    "\e$B@5$7$$IQEY%U%!%$%k$G$O$"$j$^$;$s\e(B"
126    "\e$B@5$7$$IUB08l%U%!%$%k$G$O$"$j$^$;$s\e(B"
127    "\e$BIUB08l$N8D?t\e(B, \e$B%Y%/%?D9$5$J$I$,B?2a$.$^$9\e(B"
128    "\e$B$=$NHV9f$N<-=q$O;H$o$l$F$$$^$;$s\e(B"
129    nil
130    nil
131    nil
132    "\e$BIUB08l%U%!%$%k$NFbMF$,@5$7$/$"$j$^$;$s\e(B"
133    "\e$B5?;wIJ;lHV9f$,0[>o$G$9\e(B(hinsi.data \e$B$,@5$7$/$"$j$^$;$s\e(B)"
134    "\e$BL$Dj5A$NIJ;l$,A0C<IJ;l$H$7$FDj5A$5$l$F$$$^$9\e(B"
135    "\e$BIUB08l%U%!%$%k$,FI$_9~$^$l$F$$$^$;$s\e(B"
136    nil
137    nil
138    "\e$B<-=q$N%(%$%s%H%j$,B?2a$.$^$9\e(B"
139    "\e$BJQ49$7$h$&$H$9$kJ8;zNs$,D92a$.$^$9\e(B"
140    "\e$BIUB08l2r@ONN0h$,ITB-$7$F$$$^$9\e(B"
141    nil
142    "\e$B<!8uJdNN0h$,ITB-$7$F$$$^$9\e(B"
143    "\e$B8uJd$,\e(B 1 \e$B$D$b:n$l$^$;$s$G$7$?\e(B"
144    nil
145    nil
146    nil
147    nil
148    "\e$BFI$_$,D92a$.$^$9\e(B"
149    "\e$B4A;z$,D92a$.$^$9\e(B"
150    "\e$B;XDj$5$l$?<-=q$OEPO?2DG=$G$O$"$j$^$;$s\e(B"
151    "\e$BFI$_$ND9$5$,\e(B 0 \e$B$G$9\e(B"
152    "\e$B;XDj$5$l$?<-=q$O5U0z$-2DG=$G$O$"$j$^$;$s\e(B"
153    "\e$B%j!<%I%*%s%j!<$N<-=q$KEPO?\e(B/\e$B:o=|$7$h$&$H$7$^$7$?\e(B"
154    "\e$B4D6-$KB8:_$7$J$$<-=q$KEPO?$7$h$&$H$7$^$7$?\e(B"
155    nil
156    nil
157    "\e$B%j!<%I%*%s%j!<$NIQEY$rJQ99$7$h$&$H$7$^$7$?\e(B"
158    "\e$B;XDj$5$l$?C18l$,B8:_$7$^$;$s\e(B"
159    nil
160    nil
161    nil
162    nil
163    nil
164    nil
165    nil
166    nil
167    nil
168    "\e$B%a%b%j\e(B allocation \e$B$G<:GT$7$^$7$?\e(B"
169    nil
170    nil
171    nil
172    nil
173    nil
174    nil
175    nil
176    "\e$B2?$+$N%(%i!<$,5/$3$j$^$7$?\e(B"
177    "\e$B%P%0$,H/@8$7$F$$$kLOMM$G$9\e(B"
178    "\e$B%5!<%P$,;`$s$G$$$^$9\e(B"
179    "allocation \e$B$K<:GT$7$^$7$?\e(B"
180    "\e$B%5!<%P$H@\B3$G$-$^$;$s$G$7$?\e(B"
181    "\e$BDL?.%W%m%H%3%k$N%P!<%8%g%s$,9g$C$F$$$^$;$s\e(B"
182    "\e$B%/%i%$%"%s%H$N@8@.$7$?4D6-$G$O$"$j$^$;$s\e(B"
183    nil
184    nil
185    nil
186    nil
187    nil
188    "\e$B%G%#%l%/%H%j$r:n$k$3$H$,$G$-$^$;$s\e(B"
189    nil
190    nil
191    nil
192    nil
193    nil
194    nil
195    nil
196    nil
197    nil
198    "\e$B%U%!%$%k$rFI$_9~$`$3$H$,$G$-$^$;$s\e(B"
199    "\e$B%U%!%$%k$r=q$-=P$9$3$H$,$G$-$^$;$s\e(B"
200    "\e$B%/%i%$%"%s%H$NFI$_9~$s$@%U%!%$%k$G$O$"$j$^$;$s\e(B"
201    "\e$B$3$l0J>e%U%!%$%k$rFI$_9~$`$3$H$,$G$-$^$;$s\e(B"
202    "\e$B%Q%9%o!<%I$,4V0c$C$F$$$^$9\e(B"
203    "\e$B%U%!%$%k$,FI$_9~$^$l$F$$$^$9\e(B"
204    "\e$B%U%!%$%k$,:o=|$G$-$^$;$s\e(B"
205    "\e$B%U%!%$%k$,:n@.=PMh$^$;$s\e(B"
206    "WNN \e$B$N%U%!%$%k$G$"$j$^$;$s\e(B"
207    "\e$B%U%!%$%k$N\e(B inode \e$B$H\e(B FILE_UNIQ \e$B$r0lCW$5$;$k;v$,$G$-$^$;$s\e(B"
208    "\e$BIJ;l%U%!%$%k$,Bg$-2a$.$^$9\e(B"
209    "\e$BIJ;l%U%!%$%k$,Bg$-2a$.$^$9\e(B"
210    "\e$BIJ;l%U%!%$%k$,B8:_$7$^$;$s\e(B"
211    "\e$BIJ;l%U%!%$%k$NFbMF$,4V0c$C$F$$$^$9\e(B"
212    nil
213    "\e$BIJ;l%U%!%$%k$,FI$_9~$^$l$F$$$^$;$s\e(B"
214    "\e$BIJ;lL>$,4V0c$C$F$$$^$9\e(B"
215    "\e$BIJ;lHV9f$,4V0c$C$F$$$^$9\e(B"
216    nil
217    "\e$B$=$NA`:n$O%5%]!<%H$5$l$F$$$^$;$s\e(B"
218    "\e$B%Q%9%o!<%I$NF~$C$F$$$k%U%!%$%k$,%*!<%W%s$G$-$^$;$s\e(B"
219    "uumrc \e$B%U%!%$%k$,B8:_$7$^$;$s\e(B"
220    "uumrc \e$B%U%!%$%k$N7A<0$,8m$C$F$$$^$9\e(B"
221    "\e$B$3$l0J>e4D6-$r:n$k$3$H$O$G$-$^$;$s\e(B"
222    "\e$B$3$N%/%i%$%"%s%H$,FI$_9~$s$@%U%!%$%k$G$"$j$^$;$s\e(B"
223    "\e$B<-=q$KIQEY%U%!%$%k$,$D$$$F$$$^$;$s\e(B"
224    "\e$B%Q%9%o!<%I$N%U%!%$%k$,:n@.=PMh$^$;$s\e(B"
225 ]
226   "Array of WNN error messages.  Indexed by error code.")
227
228 (defun wnnrpc-get-error-message (errno)
229   "Return error message string specified by ERRNO."
230   (or (aref wnnrpc-error-message errno) (format "#%d" errno)))
231
232 (defmacro wnnrpc-call-with-environment (e vlist send-expr &rest receive-exprs)
233   (let ((v (append
234             `((proc (wnnenv-get-proc ,e))
235               (env-id (wnnenv-get-env-id ,e)))
236             vlist)))
237     (list
238      'let v
239      (append
240         `(save-excursion
241            (set-buffer (process-buffer proc))
242            (erase-buffer)
243            ,send-expr
244            (process-send-region proc (point-min) (point-max))
245            (goto-char (prog1 (point) (accept-process-output proc))))
246         receive-exprs))))
247
248 (defsubst wnnrpc-test-result-and-get-error (proc result)
249   (if (< result 0)                      ; Get error # (XXX: Bad protocol)
250       (let (error)
251         (comm-unpack (u) error)
252         (- error))
253     result))
254 \f
255 (defun wnnrpc-open (proc myhostname username)
256   "Open the session.  Return 0 on success, error code on failure."
257   (comm-call-with-proc proc (result)
258     (comm-format (u u s s)
259                  (wnn-const JS_OPEN)
260                  (wnn-const JLIB_VERSION)
261                  myhostname username)
262     (comm-unpack (u) result)
263     (wnnrpc-test-result-and-get-error proc result)))
264
265 (defun wnnrpc-connect (proc envname)
266   "Establish new `connection' and make an environment.
267 Return the identitifation of the environment on success, 
268 negate-encoded error code on failure."
269   (comm-call-with-proc proc (result)
270     (comm-format (u s) (wnn-const JS_CONNECT) envname)
271     (comm-unpack (u) result)
272     (wnnrpc-test-result-and-get-error proc result)))
273
274 (defun wnnrpc-open-file (proc env-id filename)
275   "Open the file FILENAME on the environment ENV-ID on server process PROC.
276 Return file descripter on success, negate-encoded error code on failure."
277   (comm-call-with-proc proc (result)
278     (comm-format (u u s) (wnn-const JS_FILE_READ) env-id filename)
279     (comm-unpack (u) result)
280     (wnnrpc-test-result-and-get-error proc result)))
281
282 (defun wnnrpc-set-fuzokugo-file (proc env-id fid)
283   "For PROC, on environment ENV-ID, 
284 Set Fuzokugo file specified by FID.
285 Return 0 on success, negate-encoded error code on failure."
286   (comm-call-with-proc proc (result)
287     (comm-format (u u i) (wnn-const JS_FUZOKUGO_SET) env-id fid)
288     (comm-unpack (u) result)
289     (wnnrpc-test-result-and-get-error proc result)))
290
291 (defun wnnrpc-set-dictionary (proc env-id rev dic freq pri dic-mode freq-mode)
292   "Set dictionary on server.
293 Return 0 on success, negate-encoded error code on faiulure."
294   (comm-call-with-proc proc (result)
295     (comm-format (u u i i i u u s s u) (wnn-const JS_DIC_ADD)
296                  env-id dic freq pri
297                  (if dic-mode 0 1)
298                  (if freq-mode 0 1)
299                  "" ""          ; XXX: No password
300                  (if rev 1 0))
301     (comm-unpack (u) result)
302     (wnnrpc-test-result-and-get-error proc result)))
303
304 (defun wnnrpc-version (proc)
305   "Return the version number of WNN server."
306   (comm-call-with-proc proc (result)
307     (comm-format (u) (wnn-const JS_VERSION))
308     (comm-unpack (u) result)
309     result))
310
311 (defun wnnrpc-access (proc env-id mode path) 
312   "On the server connected by PROC, check the accessibility of file in
313 the environment ENV-ID.  Return 0 when the remote file
314 (dictionary/frequency) of PATH can be accessed in mode MODE.  Return
315 Non-zero otherwise."
316   (comm-call-with-proc proc (result)
317     (comm-format (u u u s) (wnn-const JS_ACCESS) env-id mode path)
318     (comm-unpack (u) result)
319     result))
320
321 (defun wnnrpc-mkdir (proc env-id path)
322   "Create directory specified by PATH."
323   (comm-call-with-proc proc (result)
324     (comm-format (u u s) (wnn-const JS_MKDIR) env-id path)
325     (comm-unpack (u) result)
326     (wnnrpc-test-result-and-get-error proc result)))
327
328 (defun wnnrpc-create-dictionary (proc env-id dicname)
329   "Create dictionary on server."
330   (comm-call-with-proc proc (result)
331     (comm-format (u u s S s s u) (wnn-const JS_DIC_FILE_CREATE)
332                  env-id dicname ""      ; XXX: No comment
333                  "" ""          ; XXX: No passwd
334                  (wnn-const WNN_REV_DICT))
335     (comm-unpack (u) result)
336     (wnnrpc-test-result-and-get-error proc result)))
337
338 (defun wnnrpc-create-frequency (proc env-id freqname dictionary)
339   "Create frequency file on server."
340   (comm-call-with-proc proc (result)
341     (comm-format (u u u s S s) (wnn-const JS_HINDO_FILE_CREATE)
342                  env-id dictionary freqname "" ; XXX: No comment
343                  "")                    ; XXX: No password
344     (comm-unpack (u) result)
345     (wnnrpc-test-result-and-get-error proc result)))
346
347 (defun wnnrpc-discard-file (proc env-id fid)
348   "Discard a file specified by FID.  Call this for already-opened file
349 before remove and create new file."
350   (comm-call-with-proc proc (result)
351     (comm-format (u u u) (wnn-const JS_FILE_DISCARD)
352                  env-id fid)
353     (comm-unpack (u) result)
354     (wnnrpc-test-result-and-get-error proc result)))
355
356 (defun wnnrpc-remove-file (proc filename)
357   "Remove the file."
358   (comm-call-with-proc proc (result)
359     (comm-format (u s s) (wnn-const JS_FILE_REMOVE) filename "") ; No passwd
360     (comm-unpack (u) result)
361     (wnnrpc-test-result-and-get-error proc result)))
362
363 (defun wnnrpc-set-conversion-parameters (proc env-id v)
364   "Set conversion parameters."
365   (comm-call-with-proc proc (result)
366     (comm-format  (u u i i i i i i i i i i i i i i i i i)
367                   (wnn-const JS_PARAM_SET)
368                   env-id
369                   (aref v  0) (aref v  1) (aref v  2) (aref v  3)
370                   (aref v  4) (aref v  5) (aref v  6) (aref v  7)
371                   (aref v  8) (aref v  9) (aref v 10) (aref v 11)
372                   (aref v 12) (aref v 13) (aref v 14) (aref v 15)
373                   (aref v 16) (aref v 17))
374     (comm-unpack (u) result)
375     (wnnrpc-test-result-and-get-error proc result)))
376
377 (defsubst wnnrpc-receive-sho-bunsetsu-list-sub (e proc number-of-sho-bunsetsu)
378   (let ((i 0)
379         slist
380         end start jiritsugo-end dic-no entry freq right-now
381         hinshi status status-backward kangovect evaluation)
382     (while (< i number-of-sho-bunsetsu)
383       (comm-unpack (u u u u u u u u u u u u)
384                    end start jiritsugo-end dic-no entry freq right-now
385                    hinshi status status-backward kangovect evaluation)
386       (setq slist
387             (cons
388              (wnn-bunsetsu-create e
389               end start jiritsugo-end dic-no entry freq right-now
390               hinshi status status-backward kangovect evaluation)
391              slist))
392       (setq i (1+ i)))
393     (reverse slist)))
394
395 (defsubst wnnrpc-receive-sho-bunsetsu-list-sub-2 (proc slist)
396   (let ((l slist)
397         result origin fuzokugo b)
398     (while l
399       (setq b (car l))
400       (comm-unpack (S S S) result origin fuzokugo)
401       (wnn-bunsetsu-set-converted b result)
402       (wnn-bunsetsu-set-yomi b origin)
403       (wnn-bunsetsu-set-fuzokugo b fuzokugo)
404       (setq l (cdr l)))
405     slist))
406
407 (defun wnnrpc-receive-sho-bunsetsu-list (e proc number-of-sho-bunsetsu)
408   (let ((slist (wnnrpc-receive-sho-bunsetsu-list-sub e proc
409                                                      number-of-sho-bunsetsu)))
410     (wnnrpc-receive-sho-bunsetsu-list-sub-2 proc slist)))
411
412 (defun wnnrpc-renbunsetsu-conversion (e yomi hinshi fuzoku &optional v)
413   "Convert YOMI string into Kanji.
414 HINSHI and FUZOKU are information of preceding bunsetsu."
415   (let (v0 v1)
416     (if v
417         (setq v0 v
418               v1 (wnn-const WNN_VECT_KANREN))
419       (setq v0 (wnn-const WNN_VECT_KANREN)
420             v1 (wnn-const WNN_VECT_NO)))
421     (wnnrpc-call-with-environment e (number-of-dai-bunsetsu kanji-length error
422                                      number-of-sho-bunsetsu dlist)
423       (comm-format (u u S i S i i i) (wnn-const JS_KANREN)
424                    env-id yomi hinshi fuzoku v0 v1
425                    (wnn-const WNN_VECT_BUNSETSU))
426       (comm-unpack (u) number-of-dai-bunsetsu)
427       (if (< number-of-dai-bunsetsu 0)
428           (let (error)
429             (comm-unpack (u) error)
430             (error "WNN Error on renbunsetsu conversion: %s"
431                    (wnnrpc-get-error-message error)))
432         (comm-unpack (u u) number-of-sho-bunsetsu kanji-length)
433         (setq dlist (cons nil nil))
434         (let ((i 0)
435               (d dlist)
436               end start count evaluation)
437           (catch 'break
438             (while t
439               (comm-unpack (u u u u) end start count evaluation)
440               (setcar d (vector end start count evaluation))
441               (if (< (setq i (1+ i)) number-of-dai-bunsetsu)
442                   (setq d (setcdr d (cons nil nil)))
443                 (throw 'break nil))))
444           (cons dlist
445                 (wnnrpc-receive-sho-bunsetsu-list e proc
446                                                   number-of-sho-bunsetsu)))))))
447
448 (defun wnnrpc-get-bunsetsu-candidates (e yomi hinshi fuzoku &optional v)
449   ""
450   (let (v0 v1)
451     (if v
452         (setq v0 v
453               v1 (wnn-const WNN_VECT_KANZEN))
454       (setq v0 (wnn-const WNN_VECT_KANZEN)
455             v1 (wnn-const WNN_VECT_NO)))
456     (wnnrpc-call-with-environment e (number-of-sho-bunsetsu kanji-length slist)
457       (comm-format (u u S i S i i) (wnn-const JS_KANZEN_SHO)
458                      env-id yomi hinshi fuzoku v0 v1)
459       (comm-unpack (u) number-of-sho-bunsetsu)
460       (if (< number-of-sho-bunsetsu 0)
461           (let (error)
462             (comm-unpack (u) error)
463             (error "WNN Error on getting candidates: %s"
464                    (wnnrpc-get-error-message error)))
465         (comm-unpack (u) kanji-length)
466         (wnnrpc-receive-sho-bunsetsu-list e proc number-of-sho-bunsetsu)))))
467
468 (defun wnnrpc-tanbunsetsu-conversion (e yomi hinshi fuzoku &optional v)
469   ""
470   (let (v0 v1)
471     (if v
472         (setq v0 v
473               v1 (wnn-const WNN_VECT_KANTAN))
474       (setq v0 (wnn-const WNN_VECT_KANTAN)
475             v1 (wnn-const WNN_VECT_NO)))
476     (wnnrpc-call-with-environment e (number-of-sho-bunsetsu kanji-length slist)
477       (comm-format (u u S i S i i) (wnn-const JS_KANTAN_SHO)
478                      env-id yomi hinshi fuzoku v0 v1)
479       (comm-unpack (u) number-of-sho-bunsetsu)
480       (if (< number-of-sho-bunsetsu 0)  ; Get error # (XXX: Bad protocol)
481           (let (error)
482             (comm-unpack (u) error)
483             (error "WNN Error on tanbunsetsu conversion: %s"
484                    (wnnrpc-get-error-message error)))
485         (comm-unpack (u) kanji-length)
486         (wnnrpc-receive-sho-bunsetsu-list e proc number-of-sho-bunsetsu)))))
487
488 (defun wnnrpc-set-frequency (e dicno entry ima hindo)
489   ""
490   (wnnrpc-call-with-environment e (result)
491     (comm-format (u u i i i i) (wnn-const JS_HINDO_SET)
492                  env-id dicno entry ima hindo)
493     (comm-unpack (u) result)
494     (wnnrpc-test-result-and-get-error proc result)))
495
496 (defun wnnrpc-close (proc)
497   ""
498   (comm-call-with-proc proc (result)
499     (comm-format (u) (wnn-const JS_CLOSE))
500     (comm-unpack (u) result)
501     (wnnrpc-test-result-and-get-error proc result)))
502
503 (defun wnnrpc-env-exist (proc envname)
504   ""
505   (comm-call-with-proc proc (result)
506     (comm-format (u s) (wnn-const JS_ENV_EXIST) envname)
507     (comm-unpack (u) result)
508     result))
509
510 (defun wnnrpc-make-env-sticky (e)
511   ""
512   (wnnrpc-call-with-environment e (result)
513     (comm-format (u u) (wnn-const JS_ENV_STICKY) env-id)
514     (comm-unpack (u) result)
515     (wnnrpc-test-result-and-get-error proc result)))
516
517 (defun wnnrpc-make-env-unsticky (e)
518   ""
519   (wnnrpc-call-with-environment e (result)
520     (comm-format (u u) (wnn-const JS_ENV_UNSTICKY) env-id)
521     (comm-unpack (u) result)
522     (wnnrpc-test-result-and-get-error proc result)))
523
524 (defun wnnrpc-disconnect (e)
525   ""
526   (wnnrpc-call-with-environment e (result)
527     (comm-format (u u) (wnn-const JS_DISCONNECT) env-id)
528     (comm-unpack (u) result)
529     (wnnrpc-test-result-and-get-error proc result)))
530
531 (defun wnnrpc-add-word (e dictionary yomi kanji comment hinshi initial-freq)
532   ""
533   (wnnrpc-call-with-environment e (result)
534     (comm-format (u u u S S S u u) (wnn-const JS_WORD_ADD)
535                  env-id
536                  dictionary yomi kanji comment
537                  hinshi initial-freq)
538     (comm-unpack (u) result)
539     (wnnrpc-test-result-and-get-error proc result)))
540
541 (defun wnnrpc-get-dictionary-list-with-environment (e)
542   ""
543   (wnnrpc-call-with-environment e (number-of-dic)
544     (comm-format (u u) (wnn-const JS_DIC_LIST) env-id)
545     (comm-unpack (u) number-of-dic)
546     (if (< number-of-dic 0)
547         (let (error)                    ; XXX js.c is correct?
548           (comm-unpack (u) error)
549           (error "WNN Error on listing dictionaries: %s"
550                  (wnnrpc-get-error-message error)))
551       (wnnrpc-receive-dictionary-list proc number-of-dic))))
552
553 (defun wnnrpc-receive-dictionary-list (proc number-of-dic)
554   (let (dic-entry dic freq dic-mode freq-mode enable-flag nice
555         rev comment dicname freqname dic-passwd freq-passwd
556         type gosuu dic-local-flag freq-local-flag)
557     (if (= number-of-dic 0)
558         nil
559       (comm-unpack (u u u u u u u u S s s s s u u u u)
560                    dic-entry dic freq dic-mode freq-mode enable-flag nice
561                    rev comment dicname freqname dic-passwd freq-passwd
562                    type gosuu dic-local-flag freq-local-flag)
563       (cons 
564        (vector dic-entry dic freq dic-mode freq-mode enable-flag nice
565                rev comment dicname freqname dic-passwd freq-passwd
566                type gosuu dic-local-flag freq-local-flag)
567        (wnnrpc-receive-dictionary-list proc (1- number-of-dic))))))
568
569 (defsubst wnndic-get-id (dic)
570   (aref dic 0))
571
572 (defsubst wnndic-get-comment (dic)
573   (aref dic 8))
574
575 (defsubst wnndic-get-dictname (dic)
576   (aref dic 9))
577
578 (defun wnnrpc-get-writable-dictionary-id-list (e)
579   ""
580   (wnnrpc-call-with-environment e (number-of-dic result)
581     (comm-format (u u i) (wnn-const JS_HINSI_DICTS) env-id -1)
582     (comm-unpack (u) number-of-dic)
583     (if (> number-of-dic 0)
584         (let ((l (cons nil nil))
585               (i 0)
586               dic)
587           (setq result l)
588           (catch 'break
589             (while t
590               (comm-unpack (u) dic)
591               (setcar l dic)
592               (if (< (setq i (1+ i)) number-of-dic)
593                   (setq l (setcdr l (cons nil nil)))
594                 (throw 'break nil))))
595           result)
596       (if (= number-of-dic 0)
597           nil
598         (let (error)
599           (comm-unpack (u) error)
600           (error "WNN Error on listing dictionaries: %s"
601                  (wnnrpc-get-error-message error)))))))
602
603 (defun wnnrpc-get-hinshi-list (e dic name)
604   ""
605   (wnnrpc-call-with-environment e (number-of-hinshi size result)
606     (comm-format (u u u S) (wnn-const JS_HINSI_LIST) env-id dic name)
607     (comm-unpack (u u) number-of-hinshi size)
608     (if (> number-of-hinshi 0)
609         (let ((l (cons nil nil))
610               (i 0)
611               hinshi)
612           (setq result l)
613           (catch 'break
614             (while t
615               (comm-unpack (S) hinshi)
616               (setcar l hinshi)
617               (if (< (setq i (1+ i)) number-of-hinshi)
618                   (setq l (setcdr l (cons nil nil)))
619                 (throw 'break nil))))
620           result)
621       (if (= number-of-hinshi 0)
622           nil
623         (let (error)
624           (comm-unpack (u) error)
625           (error "WNN Error on listing HINSHI: %s"
626                  (wnnrpc-get-error-message error)))))))
627
628 (defun wnnrpc-hinshi-number (proc name)
629   ""
630   (comm-call-with-proc proc (result)
631     (comm-format (u S) (wnn-const JS_HINSI_NUMBER) name)
632     (comm-unpack (u) result)
633     (wnnrpc-test-result-and-get-error proc result)))
634
635 (defun wnnrpc-get-conversion-parameters (e)
636   ""
637   (wnnrpc-call-with-environment e (result
638                                    n nsho p1 p2 p3 p4 p5 p6 p7 p8 p9
639                                    p10 p11 p12 p13 p14 p15)
640     (comm-format (u u) (wnn-const JS_PARAM_GET) env-id)
641     (comm-unpack (u) result)
642     (if (< result 0)
643         (let (error)
644           (comm-unpack (u) error)
645           (- error))
646       (comm-unpack  (u u u u u  u u u u u  u u u u u u u)
647                     n nsho p1 p2 p3 p4 p5 p6 p7 p8 p9
648                     p10 p11 p12 p13 p14 p15)
649       (vector n nsho p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15))))
650
651 (defun wnnrpc-file-loaded (proc path)
652   ""
653   (comm-call-with-proc proc (result)
654     (comm-format (u s) (wnn-const JS_FILE_LOADED) path)
655     (comm-unpack (u) result)
656     result))
657
658 (defun wnnrpc-write-file (e fid filename)
659   (wnnrpc-call-with-environment e (result)
660     (comm-format (u u u s) (wnn-const JS_FILE_WRITE) env-id fid filename)
661     (comm-unpack (u) result)
662     (wnnrpc-test-result-and-get-error proc result)))
663
664 (defun wnnrpc-get-fuzokugo-file (e)
665   ""
666   (wnnrpc-call-with-environment e (result)
667     (comm-format (u u u) (wnn-const JS_FUZOKUGO_GET) env-id)
668     (comm-unpack (u) result)
669     (wnnrpc-test-result-and-get-error proc result)))
670
671 (defsubst wnnrpc-receive-file-list (proc)
672   (let ((i 0)
673         flist
674         number-of-files fid local-flag ref-count type name)
675     (comm-unpack (u) number-of-files)
676     (if (< number-of-files 0)
677         (error "WNN: wnnrpc-receive-file-list")
678       (while (< i number-of-files)
679         (comm-unpack (u u u u s) fid local-flag ref-count type name)
680         (setq flist (cons (vector fid local-flag ref-count type name) flist))
681         (setq i (1+ i)))
682       flist)))
683
684 (defun wnnrpc-get-file-list (proc)
685   ""
686   (comm-call-with-proc proc (result)
687     (comm-format (u) (wnn-const JS_FILE_LIST_ALL))
688     (wnnrpc-receive-file-list proc)))
689
690 (defun wnnrpc-get-file-list-with-env (e)
691   ""
692   (wnnrpc-call-with-environment e (result)
693     (comm-format (u u) (wnn-const JS_FILE_LIST) env-id)
694     (wnnrpc-receive-file-list proc)))
695
696 (defun wnnrpc-file-attribute (e path)
697   "3: dictionary, 4: hindo file, 5: fuzokugo-file"
698   (wnnrpc-call-with-environment e (result)
699     (comm-format (u u s) (wnn-const JS_FILE_STAT) env-id path)
700     (comm-unpack (u) result)
701     (wnnrpc-test-result-and-get-error proc result)))
702
703 (defun wnnrpc-get-file-info (e fid)
704   ""
705   (wnnrpc-call-with-environment e (result name local-flag ref-count type)
706     (comm-format (u u u) (wnn-const JS_FILE_INFO) env-id fid)
707     (comm-unpack (u) result)
708     (if (< result 0)
709         (let (error)
710           (comm-unpack (u) error)
711           (- error))
712       (comm-unpack (s u u u) name local-flag ref-count type)
713       (vector name local-flag ref-count type))))
714
715 (defun wnnrpc-who (proc)
716   ""
717   (comm-call-with-proc proc (number-of-entry w)
718     (comm-format (u) (wnn-const JS_WHO))
719     (comm-unpack (u) number-of-entry)
720     (if (< number-of-entry 0)
721         (let (error)
722           (comm-unpack (u) error)
723           (- error))
724       (let ((i 0)
725             sd username hostname e-array)
726         (while (< i number-of-entry)
727           (comm-unpack (u s s) sd username hostname)
728           (setq e-array (make-vector 32 nil))
729           (let ((j 0) e)
730             (while (< j (wnn-const WNN_MAX_ENV_OF_A_CLIENT))
731               (comm-unpack (u) e)
732               (aset e-array j e)
733               (setq j (1+ j))))
734           (setq w (cons (vector sd username hostname e-array) w))
735           (setq i (1+ i)))
736         (reverse w)))))
737
738 (defun wnnrpc-get-env-list (proc)
739   (comm-call-with-proc proc (number-of-entry l)
740     (comm-format (u) (wnn-const JS_ENV_LIST))
741     (comm-unpack (u) number-of-entry)
742     (if (< number-of-entry 0)
743         (let (error)
744           (comm-unpack (u) error)
745           (- error))
746       (let ((i 0)
747             env-id env-name ref-count fuzokugo-fid dic-max
748             dic-array file-array)
749         (while (< i number-of-entry)
750           (comm-unpack (u s u u u) env-id env-name ref-count
751                          fuzokugo-fid dic-max)
752           (setq dic-array (make-vector 30 nil))
753           (setq file-array (make-vector 60 nil))
754           (let ((j 0) d)
755             (while (< j (wnn-const WNN_MAX_DIC_OF_AN_ENV))
756               (comm-unpack (u) d)
757               (aset dic-array j d)
758               (setq j (1+ j))))
759           (let ((j 0) f)
760             (while (< j (wnn-const WNN_MAX_FILE_OF_AN_ENV))
761               (comm-unpack (u) f)
762               (aset file-array j f)
763               (setq j (1+ j))))
764           (setq l (cons (vector env-id env-name ref-count fuzokugo-fid dic-max
765                                 dic-array file-array) l))
766           (setq i (1+ i)))
767         (reverse l)))))
768
769 (defun wnnrpc-kill (proc)
770   ""
771   (comm-call-with-proc proc (result)
772     (comm-format (u) (wnn-const JS_KILL))
773     (comm-unpack (u) result)
774     result))                            ; XXX: Bad protocol: error?
775
776 (defun wnnrpc-delete-dictionary (e dic)
777   ""
778   (wnnrpc-call-with-environment e (result)
779     (comm-format (u u u) (wnn-const JS_DIC_DELETE) env-id dic)
780     (comm-unpack (u) result)
781     (wnnrpc-test-result-and-get-error proc result)))
782
783 (defun wnnrpc-set-flag-on-dictionary (e dic flag)
784   ""
785   (wnnrpc-call-with-environment e (result)
786     (comm-format (u u u u) (wnn-const JS_DIC_USE) env-id dic flag)
787     (comm-unpack (u) result)
788     (wnnrpc-test-result-and-get-error proc result)))
789
790 (defun wnnrpc-get-dictionary-list (proc)
791   ""
792   (comm-call-with-proc proc (number-of-dic)
793     (comm-format (u) (wnn-const JS_DIC_LIST_ALL))
794     (comm-unpack (u) number-of-dic)
795     (wnnrpc-receive-dictionary-list proc number-of-dic)))
796
797 (defun wnnrpc-delete-word (e dic entry)
798   ""
799   (wnnrpc-call-with-environment e (result)
800     (comm-format (u u u u) (wnn-const JS_WORD_DELETE) env-id dic entry)
801     (comm-unpack (u) result)
802     (wnnrpc-test-result-and-get-error proc result)))
803
804 (defun wnnrpc-receive-word (proc yomi)
805   (let ((loop t)
806         dic serial hinshi hindo right-now internal-hindo internal-right-now
807         l l1 kanji comment)
808     (while loop
809       (comm-unpack (u) dic)
810       (if (< dic 0)
811           (setq loop nil)
812         (comm-unpack (u u u u u u) serial hinshi hindo right-now
813                      internal-hindo internal-right-now)
814         (setq l (cons (vector dic serial hinshi hindo right-now
815                               internal-hindo internal-right-now
816                               yomi nil nil) l) )))
817     (setq l (reverse l)
818           l1 l)
819     (while l1
820       (comm-unpack (S S) kanji comment)
821       (aset (car l1) 8 kanji)
822       (aset (car l1) 9 comment)
823       (setq l1 (cdr l1)))
824     l))
825
826 (defun wnnrpc-search-word-in-dictionary (e dic yomi)
827   ""
828   (wnnrpc-call-with-environment e (c0 c1)
829     (comm-format (u u u S) (wnn-const JS_WORD_SEARCH) env-id dic yomi)
830     ;; XXX Bad protocol: error?
831     (comm-unpack (u u) c0 c1)           ; ignored
832     (wnnrpc-receive-word proc yomi)))
833
834 (defun wnnrpc-search-word (e yomi)
835   ""
836   (wnnrpc-call-with-environment e (c0 c1)
837     (comm-format (u u S) (wnn-const JS_WORD_SEARCH_BY_ENV) env-id yomi)
838     ;; XXX Bad protocol: error?
839     (comm-unpack (u u) c0 c1)           ; ignored
840     (wnnrpc-receive-word proc yomi)))
841
842 (defun wnnrpc-get-word-info (e dic entry)
843   ""
844   (wnnrpc-call-with-environment e (result c0 c1 yomi)
845     (comm-format (u u u u) (wnn-const JS_WORD_INFO) env-id dic entry)
846     (comm-unpack (u) result)
847     (if (< result 0)
848         (let (error)
849           (comm-unpack (u) error)
850           (- error))
851       (comm-unpack (S) yomi)            ; XXX: reversed string
852       (comm-unpack (u u) c0 c1) ; ignored
853       (wnnrpc-receive-word proc yomi))))
854
855 (defun wnnrpc-set-comment-on-word (e dic entry comment)
856   ""
857   (wnnrpc-call-with-environment e (result)
858     (comm-format (u u u u S) (wnn-const JS_WORD_COMMENT_SET)
859                  env-id dic entry comment)
860     (comm-unpack (u) result)
861     (wnnrpc-test-result-and-get-error proc result)))
862
863 (defun wnnrpc-get-dictionary-info (e dic)
864   ""
865   (wnnrpc-call-with-environment e (result)
866     (comm-format (u u u) (wnn-const JS_DIC_INFO) env-id dic)
867     (comm-unpack (u) result)
868     (if (< result 0)
869         (let (error)
870           (comm-unpack (u) error)
871           (- error))
872       (wnnrpc-receive-dictionary-list proc 1))))
873
874 (defun wnnrpc-set-file-comment (e fid comment)
875   ""
876   (wnnrpc-call-with-environment e (result)
877     (comm-format (u u u S) (wnn-const JS_FILE_COMMENT_SET) env-id fid comment)
878     (comm-unpack (u) result)
879     (wnnrpc-test-result-and-get-error proc result)))
880
881 (defun wnnrpc-hinshi-name (proc hinshi)
882   ""
883   (comm-call-with-proc proc (result)
884     (comm-format (u u) (wnn-const JS_HINSI_NAME) hinshi)
885     (comm-unpack (u) result)
886     (if (< result 0)
887         (let (error)
888           (comm-unpack (u) error)
889           (- error))
890       (comm-unpack (S) result)
891       result)))
892
893 ;;; WHICH: 1: DIC, 2: HINDO, 3(0): Both
894 (defun wnnrpc-set-file-password (e fid which old new)
895   ""
896   (wnnrpc-call-with-environment e (result)
897     (comm-format (u u u u s s) (wnn-const JS_FILE_PASSWORD)
898                  env-id fid which old new)
899     (comm-unpack (u) result)
900     (wnnrpc-test-result-and-get-error proc result)))
901
902 (defun wnnrpc-set-hinshi-table (e dic hinshi-table)
903   ""
904   (wnnrpc-call-with-environment e (result)
905     (comm-format (u u u S) (wnn-const JS_HINSI_TABLE_SET)
906                  env-id dic hinshi-table)
907     (comm-unpack (u) result)
908     (wnnrpc-test-result-and-get-error proc result)))
909
910 (defsubst wnnrpc-receive-dai-bunsetsu-list (proc number-of-bunsetsu)
911   (let ((i 0)
912         slist
913         end start number-of-sho-bunsetsu evaluation v)
914     (while (< i number-of-bunsetsu)
915       (comm-unpack (u u u u)
916                    end start number-of-sho-bunsetsu evaluation)
917       (setq slist
918             (cons (vector end start number-of-sho-bunsetsu evaluation nil)
919                   slist))
920       (setq i (1+ i)))
921     (setq slist (reverse slist))
922     (let ((s slist)
923           result)
924       (while s
925         (setq v (car s))
926         (setq result (wnnrpc-receive-sho-bunsetsu-list-sub-2 proc (aref v 2)))
927         (aset v 4 result)
928         (setq s (cdr s)))
929       (setq s slist)
930       (while s
931         (setq v (car s))
932         (wnnrpc-receive-sho-bunsetsu-list-sub-2 proc (aref v 4))
933         (setq s (cdr s)))
934       slist)))
935
936 (defun wnnrpc-daibunsetsu-conversion (e yomi hinshi fuzoku &optional v)
937   ""
938   (let (v0 v1)
939     (if v
940         (setq v0 v
941               v1 (wnn-const WNN_VECT_KANTAN))
942       (setq v0 (wnn-const WNN_VECT_KANTAN)
943             v1 (wnn-const WNN_VECT_NO)))
944     (wnnrpc-call-with-environment e (number-of-bunsetsu sho-size kanji-size)
945       (comm-format (u u S i S i i) (wnn-const JS_KANTAN_DAI)
946                    env-id yomi hinshi fuzoku v0 v1)
947       (comm-unpack (u) number-of-bunsetsu)
948       (if (< number-of-bunsetsu 0)      ; Get error # (XXX: Bad protocol)
949           (let (error)
950             (comm-unpack (u) error)
951             (error "WNN Error on daibunsetsu conversion: %s"
952                    (wnnrpc-get-error-message error)))
953         (comm-unpack (u u) sho-size kanji-size)
954         (wnnrpc-receive-dai-bunsetsu-list proc number-of-bunsetsu)))))
955
956 (defun wnnrpc-get-daibunsetsu-candidate (e yomi hinshi fuzoku &optional v)
957   ""
958   (let (v0 v1)
959     (if v
960         (setq v0 v
961               v1 (wnn-const WNN_VECT_KANZEN))
962       (setq v0 (wnn-const WNN_VECT_KANZEN)
963             v1 (wnn-const WNN_VECT_NO)))
964     (wnnrpc-call-with-environment e (number-of-bunsetsu sho-size kanji-size)
965       (comm-format (u u S i S i i) (wnn-const JS_KANZEN_DAI)
966                    env-id yomi hinshi fuzoku v0 v1)
967       (comm-unpack (u) number-of-bunsetsu)
968       (if (< number-of-bunsetsu 0)      ; Get error # (XXX: Bad protocol)
969           (let (error)
970             (comm-unpack (u) error)
971             (error "WNN Error on daibunsetsu conversion: %s"
972                    (wnnrpc-get-error-message error)))
973         (comm-unpack (u u) sho-size kanji-size)
974         (wnnrpc-receive-dai-bunsetsu-list proc number-of-bunsetsu)))))
975 \f
976 ;; XXX: NIY: check in the file contents
977 ;; 16
978 (defun wnnrpc-local-file-loaded (proc path)
979   ""
980   (let ((attr (file-attributes path)))
981     (let ((time (cons (car (nth 6 attr)) (car (cdr (nth 6 attr)))))
982           (inode (nth 10 attr))
983           (dev (nth 11 attr))
984           (padded-hostname
985            (substring 
986             (concat (system-name)
987                     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") 0 16)))
988       (comm-call-with-proc proc (result)
989         (comm-format (u U U U s) (wnn-const JS_FILE_LOADED_LOCAL)
990                      time dev inode padded-hostname)
991         (comm-unpack (u) result)
992         result))))
993
994 (defun wnnrpc-file-receive (e fid local-filename)
995   ""
996   (wnnrpc-call-with-environment e (filename)
997     (comm-format (u u u) (wnn-const JS_FILE_RECEIVE)
998                  env-id fid)
999     (comm-unpack (s) filename)
1000     (if (null local-filename)
1001         (setq local-filename (substring filename
1002                                         (1+ (string-match "!" filename)))))
1003     (wnnrpc-file-receive-sub proc local-filename)))
1004
1005 (defun wnnrpc-file-receive-sub (proc local-filename)
1006   ;; XXX check file header
1007   (let ((attr (file-attributes local-filename)))
1008     (let ((time (cons (car (nth 6 attr)) (car (cdr (nth 6 attr)))))
1009           (inode (nth 10 attr))
1010           (dev (nth 11 attr))
1011           (padded-hostname
1012            (substring 
1013             (concat (system-name)
1014                     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") 0 16)))
1015     (comm-call-with-proc-1 proc (result)
1016       (comm-format (u U U U s) 0 ; ACK
1017                    time dev inode padded-hostname)
1018       (comm-unpack (s) result)
1019       (cond ((< result 0)
1020              (let (error)
1021                (comm-unpack (u) error)
1022                (- error)))
1023             ((= result 0)
1024              )          ; done
1025             ((or (= result 1) (= result 3) (= result 2))
1026               ;; XXX distingush creation...
1027              (comm-call-with-proc-1 proc (contents result)
1028                (comm-format (u) 0)      ; ACK
1029                (comm-unpack (B u) contents result)
1030                ;; XXX XXXXXXXXXXXXXXXXX save the contents...
1031                (wnnrpc-test-result-and-get-error proc result))))))))
1032
1033 (defun wnnrpc-file-send (e filename)
1034   ""
1035   (wnnrpc-call-with-environment e (result)
1036     (comm-format (u u U U U s) (wnn-const JS_FILE_SEND)
1037                  env-id time dev inode padded-hostname)
1038     (comm-unpack (u) result)
1039     (if (/= result -1)
1040         (progn
1041           (comm-unpack (u) result)
1042           (if (< result 0)
1043               (let (error)
1044                 (comm-unpack (u) error)
1045                 (- error))
1046             result))
1047       (comm-unpack (u) result)
1048       (if (< result 0)
1049           (let (error)
1050             (comm-unpack (u) error)
1051             (- error))
1052         (let ((path (concat (system-name) "!" filename)))
1053           (wnnrpc-send-file-sub proc path))))))
1054
1055 (defun wnnrpc-send-file-sub (proc path)
1056   (comm-call-with-proc-1 proc (result)
1057     (progn
1058       (comm-format (s) path)
1059       ;; XXXXXXXXXXXXXX send the contents of file...
1060       (while xxx
1061         (if (= c 255)
1062             (comm-format (b b) 255 0)
1063           (comm-format (b) c)))
1064       (comm-format (b b) 255 255))
1065     (comm-unpack (u) result)
1066     (wnnrpc-test-result-and-get-error proc result)))
1067
1068 (defun wnnrpc-file-remove-client ()
1069 )
1070
1071 (defun wnnrpc-dic-file-create-client ()
1072 )
1073
1074 (defun wnnrpc-hindo-file-create-client ()
1075 113
1076 )
1077
1078 ;;; egg/wnnrpc.el ends here.