1 /*
2 */
3
4 /*
5 WNN7 CLIENT LIBRARY--SOFTWARE LICENSE TERMS AND CONDITIONS
6
7
8 Wnn7 Client Library :
9 (C) Copyright OMRON Corporation. 1995,1998,2000,2001 all rights reserved.
10 (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000,2001 all rights reserved.
11
12 Wnn Software :
13 (C) Copyright Kyoto University Research Institute for Mathematical Sciences
14 1987, 1988, 1989, 1990, 1991, 1992, 1993
15 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993
16 (C) Copyright ASCTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992, 1993
17
18 Preamble
19
20 These Wnn7 Client Library--Software License Terms and Conditions
21 (the "License Agreement") shall state the conditions under which you are
22 permitted to copy, distribute or modify the software which can be used
23 to create Wnn7 Client Library (the "Wnn7 Client Library"). The License
24 Agreement can be freely copied and distributed verbatim, however, you
25 shall NOT add, delete or change anything on the License Agreement.
26
27 OMRON Corporation and OMRON Software Co., Ltd. (collectively referred to
28 as "OMRON") jointly developed the Wnn7 Software (development code name
29 is FI-Wnn), based on the Wnn Software. Starting from November, 1st, 1998,
30 OMRON publishes the source code of the Wnn7 Client Library, and OMRON
31 permits anyone to copy, distribute or change the Wnn7 Client Library under
32 the License Agreement.
33
34 Wnn7 Client Library is based on the original version of Wnn developed by
35 Kyoto University Research Institute for Mathematical Sciences (KURIMS),
36 OMRON Corporation and ASTEC Inc.
37
38 Article 1. Definition.
39
40 "Source Code" means the embodiment of the computer code, readable and
41 understandable by a programmer of ordinary skills. It includes related
42 source code level system documentation, comments and procedural code.
43
44 "Object File" means a file, in substantially binary form, which is directly
45 executable by a computer after linking applicable files.
46
47 "Library" means a file, composed of several Object Files, which is directly
48 executable by a computer after linking applicable files.
49
50 "Software" means a set of Source Code including information on its use.
51
52 "Wnn7 Client Library" the computer program, originally supplied by OMRON,
53 which can be used to create Wnn7 Client Library.
54
55 "Executable Module" means a file, created after linking Object Files or
56 Library, which is directly executable by a computer.
57
58 "User" means anyone who uses the Wnn7 Client Library under the License
59 Agreement.
60
61 Article 2. Copyright
62
63 2.1 OMRON Corporation and OMRON Software Co., Ltd. jointly own the Wnn7
64 Client Library, including, without limitation, its copyright.
65
66 2.2 Following words followed by the above copyright notices appear
67 in all supporting documentation of software based on Wnn7 Client Library:
68
69 This software is based on the original version of Wnn7 Client Library
70 developed by OMRON Corporation and OMRON Software Co., Ltd. and also based on
71 the original version of Wnn developed by Kyoto University Research Institute
72 for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc.
73
74 Article 3. Grant
75
76 3.1 A User is permitted to make and distribute verbatim copies of
77 the Wnn7 Client Library, including verbatim of copies of the License
78 Agreement, under the License Agreement.
79
80 3.2 A User is permitted to modify the Wnn7 Client Library to create
81 Software ("Modified Software") under the License Agreement. A User
82 is also permitted to make or distribute copies of Modified Software,
83 including verbatim copies of the License Agreement with the following
84 information. Upon modifying the Wnn7 Client Library, a User MUST insert
85 comments--stating the name of the User, the reason for the modifications,
86 the date of the modifications, additional terms and conditions on the
87 part of the modifications if there is any, and potential risks of using
88 the Modified Software if they are known--right after the end of the
89 License Agreement (or the last comment, if comments are inserted already).
90
91 3.3 A User is permitted to create Library or Executable Modules by
92 modifying the Wnn7 Client Library in whole or in part under the License
93 Agreement. A User is also permitted to make or distribute copies of
94 Library or Executable Modules with verbatim copies of the License
95 Agreement under the License Agreement. Upon modifying the Wnn7 Client
96 Library for creating Library or Executable Modules, except for porting
97 a computer, a User MUST add a text file to a package of the Wnn7 Client
98 Library, providing information on the name of the User, the reason for
99 the modifications, the date of the modifications, additional terms and
100 conditions on the part of the modifications if there is any, and potential
101 risks associated with using the modified Wnn7 Client Library, Library or
102 Executable Modules if they are known.
103
104 3.4 A User is permitted to incorporate the Wnn7 Client Library in whole
105 or in part into another Software, although its license terms and
106 conditions may be different from the License Agreement, if such
107 incorporation or use associated with the incorporation does NOT violate
108 the License Agreement.
109
110 Article 4. Warranty
111
112 THE WNN7 CLIENT LIBRARY IS PROVIDED BY OMRON ON AN "AS IS" BAISIS.
113 OMRON EXPRESSLY DISLCIAMS ANY AND ALL WRRANTIES, EXPRESS OR IMPLIED,
114 INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY AND FITNESS
115 FOR A PARTICULAR PURPOSE, IN CONNECTION WITH THE WNN7 CLIENT LIBRARY
116 OR THE USE OR OTHER DEALING IN THE WNN7 CLIENT LIBRARY. IN NO EVENT
117 SHALL OMRON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE
118 OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER IN CONNECTION WITH THE
119 WNN7 CLIENT LIBRARY OR THE USE OR OTHER DEALING IN THE WNN7 CLIENT
120 LIBRARY.
121
122 ***************************************************************************
123 Wnn7 Client Library :
124 (C) Copyright OMRON Corporation. 1995,1998,2000,2001 all rights reserved.
125 (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000,2001 all rights reserved.
126
127 Wnn Software :
128 (C) Copyright Kyoto University Research Institute for Mathematical Sciences
129 1987, 1988, 1989, 1990, 1991, 1992, 1993
130 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993
131 (C) Copyright ASCTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992, 1993
132 ***************************************************************************
133
134 Comments on Modifications:
135 */
136
137 /* Version 4
138 */
139 /*
140 Nihongo Henkan Library
141 */
142 /*
143 entry functions
144
145 js_open_lang js_close
146 js_change_current_jserver
147 js_connect_lang js_disconnect
148 js_isconnect
149
150 js_param_get js_param_set
151
152 js_access js_mkdir
153
154 js_get_lang js_set_lang
155
156
157 extern Variables
158 int wnn_errorno;
159 */
160
161 #if defined(__DragonFly__)
162 #include <stdlib.h>
163 #include <string.h>
164 #include <unistd.h>
165 #include <arpa/inet.h>
166 #endif
167
168 #include <stdio.h>
169 #include <stdlib.h>
170 #include <string.h>
171 #include <ctype.h>
172 #ifdef UX386
173 #include <X11/Xos.h>
174 #else
175 #include <fcntl.h>
176 #endif
177 #include <pwd.h>
178 #ifndef UX386
179 #include <sys/types.h>
180 #endif
181 #include <sys/stat.h>
182 #include <errno.h>
183 extern int errno;
184 #include <signal.h>
185 #include "jd_sock.h"
186 #include "commonhd.h"
187 #include "demcom.h"
188 #include "config.h"
189
190 #include "wnnerror.h"
191 #include "jslib.h"
192 #include "jllib.h"
193 #include "mt_jlib.h"
194 #include "jh.h"
195
196 #include "msg.h"
197
198 #define JS /* For include ../etc/bdic.c */
199 #include "../etc/bdic.c"
200 /*
201 * (Jul. 11, 1994)
202 * New bdic function for FI-Wnn
203 */
204 #include "../etc/fi_bdic.c"
205 #include "../etc/pwd.c"
206
207
208 typedef struct _host_address {
209 int address_len;
210 char *address;
211 } host_address;
212
213 int wnn_errorno =0;
214
215 struct msg_cat *wnn_msg_cat = NULL;
216
217 /* j Lib. */
218
219 static int current_sd; /** �����å�fd **/
220 static WNN_JSERVER_ID_INT *current_js = NULL;
221
222 /* Packet Buffers */
223 static unsigned char snd_buf[S_BUF_SIZ]; /** ���� **/
224 static int sbp=0; /** �����Хåե����ݥ��� **/
225 static int rbc= -1; /** �����Хåե����ݥ��� **/
226 static int rbp=0;
227 static unsigned char rcv_buf[R_BUF_SIZ]; /** ���� **/
228
229 #if defined(EAGAIN)
230 # if defined(EWOULDBLOCK)
231 # define ERRNO_CHECK(no) ((no) == EAGAIN || (no) == EWOULDBLOCK)
232 # else /* defined(EWOULDBLOCK) */
233 # define ERRNO_CHECK(no) ((no) == EAGAIN)
234 # endif /* defined(EWOULDBLOCK) */
235 #else /* defined(EAGAIN) */
236 # if defined(EWOULDBLOCK)
237 # define ERRNO_CHECK(no) ((no) == EWOULDBLOCK)
238 # else /* defined(EWOULDBLOCK) */
239 # define ERRNO_CHECK(no) (0)
240 # endif /* defined(EWOULDBLOCK) */
241 #endif /* defined(EAGAIN) */
242
243 static int _get_server_name(
244 char *server,
245 char *pserver,
246 int pserver_size,
247 int *portNO
248 );
249 static int writen();
250
251 static WNN_JSERVER_ID *js_open_lang_core(
252 char *servername, char *lang, int tmout
253 );
254
255
256 /********* V4 *****************/
257 /***
258 jserver_dead Macro
259 ***/
260
261 static jmp_buf current_jserver_dead;
262
263 #define handler_of_jserver_dead(current_js) \
264 { \
265 if (current_js) { \
266 if(current_js->js_dead){ \
267 js_wnn_errorno_set=WNN_JSERVER_DEAD; \
268 } else \
269 if(setjmp(js_current_jserver_dead)){ \
270 if (!js_wnn_errorno_eql) js_wnn_errorno_set=WNN_JSERVER_DEAD; \
271 } else \
272 js_wnn_errorno_set = 0; /* here initialize wnn_errorno; */ \
273 } \
274 }
275
276 #define handler_of_jserver_dead_env(env) \
277 { \
278 if (env->js_id) { \
279 if(env->js_id->js_dead){ \
280 env_wnn_errorno_set=WNN_JSERVER_DEAD; \
281 } else \
282 if(setjmp(env_current_jserver_dead)){ \
283 if (!env_wnn_errorno_eql) env_wnn_errorno_set=WNN_JSERVER_DEAD; \
284 } else \
285 env_wnn_errorno_set = 0; /* here initialize wnn_errorno; */ \
286 } \
287 }
288
289 /* put1com(), put2com(), put4com() �Υޥ��� */
290 /* 2000/09/22 */
291 /** ������1�������� **/
292 #define JS_Put1Com(data, server) { \
293 snd_buf[sbp++] = (data) & 0xff; \
294 if (sbp >= S_BUF_SIZ) { \
295 writen(S_BUF_SIZ, (server)); \
296 sbp = 0; \
297 } \
298 }
299
300 /** ������2�������� **/
301 #define JS_Put2Com(data, server) { \
302 JS_Put1Com(data>>8, server); \
303 JS_Put1Com(data, server); \
304 }
305
306 /** ������4�������� **/
307 #define JS_Put4Com(data, server) { \
308 JS_Put1Com(data>>24, server); \
309 JS_Put1Com(data>>16, server); \
310 JS_Put1Com(data>>8, server); \
311 JS_Put1Com(data, server); \
312 }
313
314 static void
set_current_js(server)315 set_current_js(server)
316 register WNN_JSERVER_ID *server;
317 {
318 current_js = (WNN_JSERVER_ID_INT *)server;
319 current_sd = current_js->orig.sd;
320 }
321
322 #undef ARGS
323 #define ARGS char
324 #define js_wnn_errorno_set wnn_errorno
325 #define js_wnn_errorno_eql wnn_errorno
326 #define env_wnn_errorno_set wnn_errorno
327 #define env_wnn_errorno_eql wnn_errorno
328 #define js_current_jserver_dead current_jserver_dead
329 #define env_current_jserver_dead current_jserver_dead
330
331 /** �ǡ���������Τ���θ���� **/
332 static void
demon_dead(server)333 demon_dead(server)
334 ARGS *server;
335 {
336 current_js->orig.js_dead= -1;
337 js_wnn_errorno_set = WNN_JSERVER_DEAD;
338 shutdown(current_sd, 2);
339 close(current_sd);
340 if(current_js->orig.js_dead_env_flg){
341 longjmp(current_js->orig.js_dead_env,666);
342 }
343 longjmp(js_current_jserver_dead,666);
344 /* never reach */
345 }
346
347
348 /**
349 �����åȤ��ץ�current_sd�˥����å�fd���֤�
350 (cd�Ȥ����Τϥ��ߥ�˥��������ǥХ�����̾��)
351 **/
352 static int
cd_open(lang)353 cd_open(lang)
354 register char *lang;
355 {
356 #ifdef AF_UNIX
357 int sd;
358 struct sockaddr_un saddr; /** �����å� **/
359 char *sock_name = NULL;
360 saddr.sun_family = AF_UNIX;
361
362 /* find socket name from table by lang */
363 sock_name = UNIX_SOCKET_NAME; /* Jserver */
364 strcpy(saddr.sun_path, sock_name);
365 #if ((defined AIXV3))
366 strcat(saddr.sun_path, "=");
367 #endif
368
369 if ((sd = socket(AF_UNIX,SOCK_STREAM, 0)) == ERROR) {
370 return -1;
371 }
372 #if !defined(SUN_LEN)
373 # define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
374 #endif
375 if (connect(sd,(struct sockaddr *)&saddr, SUN_LEN(&saddr)) == ERROR) {
376 close(sd);
377 return -1;
378 }
379 return sd;
380 #else
381 return -1;
382 #endif
383 }
384
385 static intfntype
connect_timeout()386 connect_timeout()
387 {
388 SIGNAL_RETURN;
389 }
390
391 static int
cd_open_in_core(sa,tmout)392 cd_open_in_core(sa, tmout)
393 register struct sockaddr_in *sa;
394 register int tmout;
395 {
396 int sd;
397 int ret;
398 int old_alarm = 0;
399 intfntype (*save_alarm_proc)() = NULL;
400
401 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == ERROR){
402 return -1 ;
403 }
404
405 if (tmout > 0) {
406 save_alarm_proc = signal(SIGALRM, connect_timeout);
407 old_alarm = alarm(tmout);
408 }
409 ret = connect(sd, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
410 if (tmout > 0) {
411 alarm(old_alarm);
412 if (save_alarm_proc)
413 signal(SIGALRM, save_alarm_proc);
414 else
415 signal(SIGALRM, SIG_IGN);
416 }
417 if (ret == ERROR) {
418 close(sd);
419 return -1 ;
420 }
421 return sd;
422 }
423
424 static int
cd_open_in_by_addr(addr,addrlen,port,tmout)425 cd_open_in_by_addr(addr, addrlen, port, tmout)
426 char *addr;
427 int addrlen, port, tmout;
428 {
429 struct sockaddr_in saddr_in;
430
431 memset((char *)&saddr_in,0,sizeof(saddr_in));
432 memcpy((char *)&saddr_in.sin_addr, addr, addrlen);
433 saddr_in.sin_family = AF_INET;
434 saddr_in.sin_port = port;
435 return(cd_open_in_core(&saddr_in, tmout));
436 }
437
438 typedef struct _my_serv_struct {
439 char *name;
440 int port;
441 struct _my_serv_struct *next;
442 } my_serv_struct;
443
my_getservbyname(name)444 static int my_getservbyname(name)
445 register char *name;
446 {
447 static my_serv_struct *tbl = NULL;
448 register my_serv_struct *p;
449 struct servent *sp = NULL;
450 register int len;
451
452 for (p = tbl; p; p = p->next) {
453 if (p->name && !strcmp(p->name, name)) return(p->port);
454 }
455 sp = getservbyname(name,"tcp");
456 endservent();
457 if (!sp) return(-1);
458 len = strlen(name);
459 if (!(p = (my_serv_struct *)malloc(sizeof(my_serv_struct) + len + 1)))
460 return(-1);
461 p->name = ((char *)p) + sizeof(my_serv_struct);
462 strcpy(p->name, name);
463 p->port = ntohs(sp->s_port);
464 p->next = tbl;
465 tbl = p;
466 return(p->port);
467 }
468
469 static int
cd_open_in(server,lang,tmout)470 cd_open_in(server, lang, tmout)
471 register char *server;
472 register char *lang;
473 register int tmout;
474 {
475 struct sockaddr_in saddr_in; /** �����å� **/
476 register struct hostent *hp;
477 int serverNO, port_num;
478 char pserver[MAXHOSTNAMELEN];
479 char sserver[64];
480 unsigned long ia;
481 char *inet_ntoa();
482
483 serverNO = _get_server_name(server, pserver, sizeof(pserver), &port_num);
484
485 if (port_num > 0) {
486 /* absolute port number is specified */
487 serverNO += port_num;
488 } else {
489 /* find service name from table by lang */
490 strncpy(sserver, SERVERNAME, sizeof(sserver) - 1);
491 sserver[sizeof(sserver) - 1] = 0;
492 if ((port_num = my_getservbyname(sserver)) != -1) {
493 serverNO += port_num;
494 } else {
495 serverNO += WNN_PORT_IN;
496 }
497 }
498 memset((char *)&saddr_in,0,sizeof(saddr_in));
499
500 if (isascii((unsigned char)pserver[0]) && isdigit((unsigned char)pserver[0])) {
501 ia = inet_addr(pserver);
502 saddr_in.sin_addr.s_addr = ia;
503 } else {
504 hp = gethostbyname(pserver);
505 endhostent();
506 if (!hp)
507 return -1;
508 memcpy((char *)&saddr_in.sin_addr, hp->h_addr, hp->h_length);
509 }
510 saddr_in.sin_family = AF_INET;
511 saddr_in.sin_port = htons(serverNO);
512 return(cd_open_in_core(&saddr_in, tmout));
513 }
514
515 /* get server name and return serverNo */
516 /* and return absolute port number 1993/12/07 */
517 static int
_get_server_name(server,pserver,pserver_size,portNO)518 _get_server_name(server, pserver, pserver_size, portNO)
519 char *server;
520 char *pserver;
521 int pserver_size;
522 int *portNO;
523 {
524 register char *p;
525 register int port = 0, offset = 0;
526
527 strncpy(pserver, server, pserver_size - 1);
528 pserver[pserver_size - 1] = '\0';
529 if ((p = strchr(pserver, ':'))) {
530 *p = '\0';
531 if (*(p+1)) offset = atoi(p+1);
532 }
533 if ((p = strchr(pserver, '/'))) {
534 *p = '\0';
535 if (*(p+1)) port = atoi(p+1);
536 }
537 *portNO = port;
538 return(offset);
539 }
540
541 /* �����Ф�����ץ�ȥ���ݡ��Ȥ��Ƥ��뤫�ɤ����Υ����å� */
542 #define check_version(cmd) \
543 (((cmd>>12) & 0xFFF) > (current_js->version & 0xFFF))
544
545 /* �����Ф��ƣɴط������ݡ��Ȥ��Ƥ��뤫�ɤ����Υ����å� */
546 #define CHECK_FI \
547 ((current_js->version & 0xFFF) >= 0xF00)
548
549 /* �����Ф� Wnn7 �ط������ݡ��Ȥ��Ƥ��뤫�ɤ����Υ����å� */
550 #define CHECK_VERSION_WNN7 \
551 ((current_js->version & 0xFFF) >= 0xF01)
552
553 /** �ѥ��åȤΥإå��������� **/
554 static void
snd_head(cmd,server)555 snd_head(cmd, server)
556 int cmd; /** cmd=���ޥ�� **/
557 ARGS *server;
558 {
559 sbp=0;
560 if (check_version(cmd)) {
561 js_wnn_errorno_set = WNN_NOT_SUPPORT_PACKET;
562 longjmp(js_current_jserver_dead,666);
563 }
564 JS_Put4Com(cmd, server);
565 rbc= -1;
566 }
567
568 /** �ѥ��åȤΥإå��������� **/
569 static int
snd_env_head(env,cmd)570 snd_env_head(env,cmd)
571 register struct wnn_env *env;
572 int cmd; /** cmd=���ޥ�� **/
573 {
574 ARGS *args = NULL;
575
576 snd_head(cmd, args);
577 JS_Put4Com(env->env_id, args);
578 return 0;
579 }
580
581 /** �ѥ��åȤΥإå��������� **/
582 static int
snd_server_head(server,cmd)583 snd_server_head(server,cmd)
584 register WNN_JSERVER_ID *server;
585 int cmd; /** cmd=���ޥ�� **/
586 {
587 ARGS *args = NULL;
588
589 snd_head(cmd, args);
590 return 0;
591 }
592
593 /** �����Хåե���ե�å��夹�� **/
594 static int
snd_flush(server)595 snd_flush(server)
596 ARGS *server;
597 {
598 if(sbp==0)return(-1);
599 writen(sbp, server);
600 sbp=0;
601 return(0);
602 }
603
604 static int
writen(n,server)605 writen(n, server)
606 int n;
607 ARGS *server;
608 {
609 int cc,x;
610 for(cc=0;cc<n;){
611 errno = 0;
612 x=write(current_sd, &(snd_buf[cc]), n-cc );
613 if(x < 0) {
614 if (ERRNO_CHECK(errno) || errno == EINTR) {
615 continue;
616 } else {
617 demon_dead(server);
618 return -1;
619 }
620 }
621 cc+=x;
622 }
623 return(0);
624 }
625
626 /** �����Ф�ʸ��������� **/
627 static void
putwscom(p,server)628 putwscom(p, server)
629 register w_char *p;
630 ARGS *server;
631 {
632 if (p != NULL) {
633 while (*p) {
634 JS_Put2Com(*p, server);
635 p++;
636 }
637 }
638 JS_Put2Com(0, server);
639 return;
640 }
641
642 /** �����Ф�ʸ��������� **/
643 static void
putscom(p,server)644 putscom(p, server)
645 register char *p;
646 ARGS *server;
647 {
648 if (p != NULL) {
649 while (*p) {
650 JS_Put1Com(*p, server);
651 p++;
652 }
653 }
654 JS_Put1Com(0, server);
655 return;
656 }
657
658 static int
rcv_1_client(server)659 rcv_1_client(server)
660 ARGS *server;
661 {
662 while(1) {
663 errno = 0;
664 rbc = read(current_sd, rcv_buf, R_BUF_SIZ);
665 if (rbc <= 0) {
666 if (ERRNO_CHECK(errno)) {
667 continue;
668 } else if (rbc == 0) {
669 demon_dead(server);
670 return -1;
671 } else {
672 if (errno != EINTR) {
673 demon_dead(server);
674 return -1;
675 }
676 continue;
677 }
678 }
679 rbp = 0;
680 break;
681 }
682 return rbc;
683 }
684
685 /** �����Ф���1�Х��ȼ����� **/
686 static int
get1com(server)687 get1com(server)
688 ARGS *server;
689 {
690 if (rbc <= 0) {
691 rbc = rcv_1_client(server);
692 }
693 rbc--;
694 return rcv_buf[rbp++] & 0xFF ;
695 }
696
697 /** �����Ф���2�Х��ȼ����� **/
698 static int
get2com(server)699 get2com(server)
700 ARGS *server;
701 {
702 register int i;
703 int x[2];
704
705 for (i = 0; i < 2; i++) {
706 if (rbc <= 0) {
707 rbc = rcv_1_client(server);
708 }
709 rbc--;
710 x[i] = rcv_buf[rbp++] & 0xFF;
711 }
712 return (x[0] << 8) | x[1];
713 }
714
715 /** �����Ф���4�Х��ȼ����� **/
716 static int
get4com(server)717 get4com(server)
718 ARGS *server;
719 {
720 register int i;
721 int x[4];
722
723 for (i = 0; i < 4; i++) {
724 if (rbc <= 0) {
725 rbc = rcv_1_client(server);
726 }
727 rbc--;
728 x[i] = rcv_buf[rbp++] & 0xFF;
729 }
730 return (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3];
731 }
732
733 /** �����Ф���ʸ����������� **/
734 static void
getscom(cp,server,buflen)735 getscom(cp, server, buflen)
736 register char *cp;
737 ARGS *server;
738 register int buflen;
739 {
740 register int i;
741
742 for (i = 0 ; i < buflen ; i++) {
743 if (rbc <= 0) {
744 rbc = rcv_1_client(server);
745 }
746 rbc--;
747 if ((*cp++ = rcv_buf[rbp++] & 0xFF) == '\0') {
748 break;
749 }
750 }
751
752 /* Buffer Overflow size? */
753 if (i >= buflen) {
754 /* �Ĥ�Υǡ������˴����� */
755 while(1) {
756 if (rbc <= 0) {
757 rbc = rcv_1_client(server);
758 }
759 rbc--;
760 if (rcv_buf[rbp++] == '\0') {
761 break;
762 }
763 }
764 if (i > 0) {
765 *(cp - 1) = '\0'; /* set null terminate */
766 }
767 }
768 }
769
770 /** �����Ф���ʸ����������� **/
771 static void
getwscom(wp,server,buflen)772 getwscom(wp, server, buflen)
773 register w_char *wp;
774 ARGS *server;
775 register int buflen; /* not bytes. "buflen" is word length. */
776 {
777 register int i, j;
778 int x[2];
779
780 for (i = 0 ; i < buflen ; i++) {
781 for (j = 0; j < 2; j++) {
782 if (rbc <= 0) {
783 rbc = rcv_1_client(server);
784 }
785 rbc--;
786 x[j] = rcv_buf[rbp++] & 0xFF;
787 }
788 if ((*wp++ = ((x[0] << 8) | x[1])) == '\0') {
789 break;
790 }
791 }
792
793 /* Buffer Overflow size? */
794 if (i >= buflen) {
795 /* �Ĥ�Υǡ������˴����� */
796 while(1) {
797 for (j = 0; j < 2; j++) {
798 if (rbc <= 0) {
799 rbc = rcv_1_client(server);
800 }
801 rbc--;
802 x[j] = rcv_buf[rbp++] & 0xFF;
803 }
804 if (((x[0] << 8) | x[1]) == '\0') {
805 break;
806 }
807 }
808 if (i > 0) {
809 *(wp - 1) = '\0'; /* set null terminate */
810 }
811 }
812 }
813
814 /* get login name form /etc/passwd file */
815 static char*
getlogname()816 getlogname()
817 {
818 extern struct passwd *getpwuid();
819 struct passwd *pw;
820
821 pw = getpwuid(getuid());
822 endpwent();
823 if (pw == NULL)
824 return NULL;
825 return pw->pw_name;
826 }
827
828 static int
send_js_open_core(server,host,user,version)829 send_js_open_core(server, host, user, version)
830 WNN_JSERVER_ID *server;
831 char *host, *user;
832 int version;
833 {
834 int x;
835
836 handler_of_jserver_dead(server);
837 if(js_wnn_errorno_eql) return(-1);
838 snd_head(JS_OPEN, server);
839 JS_Put4Com(version, server); /* H.T. */
840 putscom(host, server);
841 putscom(user, server);
842 snd_flush(server);
843 if((x = get4com(server)) == -1){
844 js_wnn_errorno_set=get4com(server);
845 return(-1);
846 }
847 return(x);
848 }
849
850
851
852 /*:::DOC_START
853 *
854 * Function Name: version_negotiation
855 * Description :
856 * ���饤����ȡ������д֤Υץ�ȥ���С�������Ĵ����Ԥ�
857 * Parameter :
858 * server : (InOut) �����о���¤�ΤؤΥݥ���
859 * host : (In) ���饤����Ȼ��ѥۥ���̾
860 * user : (In) ���饤����Ȼ��ѥ桼��̾
861 * init_version : (In) ���饤����ȤΥץ�ȥ������С�������ֹ�
862 *
863 * Return value : 0==SUCCESS, -1==ERROR
864 *
865 * Revision history:
866 *
867 *:::DOC_END
868 */
869 static int
version_negotiation(server,host,user,init_version)870 version_negotiation(server, host, user, init_version)
871 WNN_JSERVER_ID *server;
872 char *host, *user;
873 int init_version;
874 {
875 int version, dummy;
876
877 /* ��㡼���С����������å� */
878 if((init_version >> 12) != 4) return(-1);
879
880 if (init_version > 0x4F00) {
881 /* 4.F00 ����礭����� 4.F00 �Ǻƥȥ饤 */
882 if (send_js_open_core(server, host, user, 0x4F00) < 0) {
883 if (js_wnn_errorno_eql == WNN_BAD_VERSION) {
884 /* 4.003 �Ǻƥȥ饤 */
885 if (send_js_open_core(server, host, user, 0x4003) < 0)
886 return(-1);
887 ((WNN_JSERVER_ID_INT *)server)->version = 0x4003;
888 return(0);
889 }
890 return(-1);
891 }
892 /* �����ХС������Υ����å� */
893 if (js_version(server, &version, &dummy) == -1) return(-1);
894 if (version > 0x4F00) {
895 /* �����ХС������Ǻƥȥ饤 */
896 if (send_js_open_core(server, host, user, version) >= 0) {
897 ((WNN_JSERVER_ID_INT *)server)->version = version;
898 return(0);
899 }
900 }
901 ((WNN_JSERVER_ID_INT *)server)->version = 0x4F00;
902 } else {
903 /* 4.003 �Ǻƥȥ饤 */
904 if (send_js_open_core(server, host, user, 0x4003) < 0)
905 return(-1);
906 ((WNN_JSERVER_ID_INT *)server)->version = 0x4003;
907 }
908
909 return(0);
910
911 } /* End of version_negotiation */
912
913
914
915 static WNN_JSERVER_ID *
reconnect_other_host(server,user,host,tmout)916 reconnect_other_host(server, user, host, tmout)
917 WNN_JSERVER_ID *server;
918 char *user, *host;
919 int tmout;
920 {
921 char addr[32];
922 int addrlen, i, port;
923 char *new_js;
924 int x;
925 struct hostent *hp;
926
927 addrlen = get4com(server);
928 /* Buffer Overflow size? */
929 if (addrlen > sizeof(addr)) {
930 for (i = 0; i < addrlen; i++) get1com(server);
931 } else {
932 for (i = 0; i < addrlen; i++) addr[i] = get1com(server);
933 }
934 port = get4com(server);
935 js_close(server);
936
937 /* Buffer Overflow size? */
938 if (addrlen > sizeof(addr)) {
939 js_wnn_errorno_set = WNN_SOME_ERROR;
940 return NULL;
941 }
942 hp = gethostbyaddr(addr, addrlen, AF_INET);
943 endhostent();
944 if (!hp) {
945 js_wnn_errorno_set = WNN_NO_JSERVER;
946 return NULL;
947 }
948 sbp=0; /* init sndBufPointer */
949 if(!(new_js=(char *)malloc(sizeof(WNN_JSERVER_ID_INT)))){
950 js_wnn_errorno_set=WNN_ALLOC_FAIL;
951 return NULL;
952 }
953 server =(WNN_JSERVER_ID *) new_js;
954 strncpy(server->js_name, hp->h_name, sizeof(server->js_name) - 1);
955 server->js_name[sizeof(server->js_name) - 1] = '\0';
956 server->js_dead= 0;
957 server->js_dead_env_flg= 0;
958 if((current_sd= cd_open_in_by_addr(addr, addrlen, port, tmout))==-1){
959 js_wnn_errorno_set = WNN_NO_JSERVER;
960 free((char*)server);
961 current_js=NULL;
962 return NULL;
963 }
964 server->sd= current_sd;
965 ((WNN_JSERVER_ID_INT *)server)->version = JLIB_VERSION;
966 ((WNN_JSERVER_ID_INT *)server)->extensions = NULL;
967 if ((x = send_js_open_core(server, host, user, JLIB_VERSION)) == -1) {
968 x = js_wnn_errorno_eql;
969 js_wnn_errorno_set = 0;
970 if ((x != WNN_BAD_VERSION) ||
971 version_negotiation(server, host, user, JLIB_VERSION)) {
972 js_close(server); /* H.T. */
973 current_js = NULL;
974 return NULL;
975 }
976 } else if (x == 1) {
977 /* re-connect to other server */
978 return(reconnect_other_host(server, user, host, tmout));
979 }
980 return(server);
981 }
982
983 /*
984 * Lib. Functions
985 * raw lib.
986 */
987
988 /***
989 js
990 ��global
991 ***/
992
993
994 /** jserver ����³���롣jserver_id ���֤��� **/
995 WNN_JSERVER_ID *
js_open_lang(servername,lang,tmout)996 js_open_lang(servername, lang, tmout)
997 register char *servername, *lang;
998 register int tmout;
999 {
1000 return(js_open_lang_core(servername, lang, tmout
1001 ));
1002 }
1003
1004
1005
1006 static WNN_JSERVER_ID *
js_open_lang_core(servername,lang,tmout)1007 js_open_lang_core(servername, lang, tmout
1008 )
1009 register char *servername, *lang;
1010 register int tmout;
1011 {
1012 char *new_js, *username;
1013 char host[MAXHOSTNAMELEN],user[WNN_ENVNAME_LEN];
1014 int x;
1015 WNN_JSERVER_ID_INT *server;
1016
1017 if (wnn_msg_cat == NULL){
1018 wnn_msg_cat = msg_open("libwnn.msg");
1019 if(wnn_msg_cat == NULL){
1020 fprintf(stderr, "libwnn: Can't open message file for libwnn.a\n");
1021 }
1022 }
1023
1024
1025 if(!(new_js=(char *)malloc(sizeof(WNN_JSERVER_ID_INT)))){
1026 wnn_errorno=WNN_ALLOC_FAIL;
1027 return NULL;
1028 }
1029
1030
1031 current_js =(WNN_JSERVER_ID_INT *) new_js;
1032 if (servername == NULL) {
1033 current_js->orig.js_name[0] = '\0';
1034 } else {
1035 strncpy(current_js->orig.js_name, servername, sizeof(current_js->orig.js_name) - 1);
1036 current_js->orig.js_name[sizeof(current_js->orig.js_name) - 1] = '\0';
1037 }
1038 current_js->orig.js_dead= 0;
1039 current_js->orig.js_dead_env_flg= 0;
1040
1041 /*
1042 if(user == NULL || 0==strcmp(user,""))
1043 */
1044 username = getlogname();
1045 if (username) {
1046 strncpy(user, username, WNN_ENVNAME_LEN);
1047 user[WNN_ENVNAME_LEN-1] = '\0'; /* truncate by WNN_ENVNAME_LEN */
1048 } else {
1049 user[0] = '\0';
1050 }
1051 if(servername == NULL || 0==strcmp(servername,"") || 0==strcmp(servername,"unix")){
1052 strcpy(host,"unix");
1053 if((current_sd= cd_open(lang))==-1){
1054
1055 wnn_errorno=WNN_SOCK_OPEN_FAIL;
1056 free((char*)current_js);
1057 current_js=NULL;
1058 return NULL;
1059 }
1060 } else{
1061 gethostname(host, sizeof(host) - 1);
1062 host[sizeof(host) - 1] = '\0';
1063 if((current_sd= cd_open_in(servername, lang, tmout))==-1){
1064
1065 wnn_errorno=WNN_SOCK_OPEN_FAIL;
1066 free((char*)current_js);
1067 current_js=NULL;
1068 return NULL;
1069 }
1070 }
1071 current_js->orig.sd= current_sd;
1072 current_js->version= JLIB_VERSION;
1073 current_js->extensions= NULL;
1074 server = current_js;
1075 x = send_js_open_core(server, host, user, JLIB_VERSION);
1076 if (x == -1) {
1077 x = wnn_errorno;
1078 wnn_errorno = 0;
1079 if ((x != WNN_BAD_VERSION) ||
1080 version_negotiation(server, host, user, JLIB_VERSION)) {
1081 js_close(current_js);
1082 current_js = NULL;
1083 wnn_errorno = x;
1084
1085 return NULL;
1086 }
1087 } else if (x == 1) {
1088 /* re-connect to other server */
1089 return(reconnect_other_host(server, user, host, tmout));
1090 }
1091
1092 return (WNN_JSERVER_ID *)current_js;
1093 }
1094
1095
1096 /** �����åȤ������� **/
1097 /** jserver �Ȥ���³�� close ���롣 **/
1098 int
js_close(server)1099 js_close(server)
1100 WNN_JSERVER_ID *server;
1101 {
1102 register int x;
1103 WNN_JSERVER_ID_INT tmp_js_id;
1104
1105 if(server==0) return(-1);
1106 tmp_js_id = *(WNN_JSERVER_ID_INT *)server;
1107 free((char *)server);
1108 current_js = &tmp_js_id;
1109 server = (WNN_JSERVER_ID *)current_js;
1110 set_current_js(server);
1111
1112 /* handler of jserver dead */
1113 handler_of_jserver_dead(server);
1114 if(wnn_errorno) {
1115
1116 return(-1);
1117 }
1118 snd_head(JS_CLOSE, server);
1119 snd_flush(server);
1120 x=get4com(server);
1121 if(x==-1)wnn_errorno=get4com(server);
1122 close(current_sd);
1123
1124 return x;
1125 }
1126
1127
1128 /*
1129 jserver �Ȥδ֤� connection ��ĥ�ꡢƱ���� jserver �������˴�
1130 �����롣env_name �˴���¸�ߤ���Ķ�����ꤷ�����ˤϤ��δĶ���
1131 �֤���NULL ����ꤷ�����ˤϿ������Ķ����ä��֤���
1132 */
1133
1134 struct wnn_env *
js_connect_lang(server,env_name,lang)1135 js_connect_lang(server, env_name, lang)
1136 register char *env_name;
1137 WNN_JSERVER_ID *server;
1138 char *lang;
1139 {
1140 register int e_id;
1141 register struct wnn_env_int *env;
1142 void js_set_lang();
1143
1144 set_current_js(server);
1145 if(!(env=(struct wnn_env_int *)malloc(sizeof(struct wnn_env_int)))){
1146 js_wnn_errorno_set=WNN_ALLOC_FAIL;
1147 return NULL;
1148 }
1149
1150 handler_of_jserver_dead(server);
1151 if(js_wnn_errorno_eql) {
1152
1153 free(env);
1154 return(NULL);
1155 }
1156 snd_head(JS_CONNECT, server);
1157 putscom(env_name, server);
1158 snd_flush(server);
1159 e_id=get4com(server);
1160 if(e_id==-1){
1161 js_wnn_errorno_set= get4com(server);
1162 free(env);
1163 return NULL;
1164 }
1165
1166 env->orig.env_id = e_id;
1167 env->orig.js_id = (WNN_JSERVER_ID *)server;
1168 env->orig.muhenkan_mode = WNN_DIC_RDONLY;
1169 env->orig.bunsetsugiri_mode = WNN_DIC_RDONLY;
1170 env->orig.kutouten_mode = 1;
1171 env->orig.kakko_mode = 1;
1172 env->orig.kigou_mode = 1;
1173 /* set language name */
1174 strncpy(env->orig.lang, lang, sizeof(env->orig.lang) - 1);
1175 env->orig.lang[sizeof(env->orig.lang) - 1] = 0;
1176 /* �ؽ�����ư�����֤γ�����������ʥǥե���� 50 ���*/
1177 env->orig.autosave = 50;
1178 /* ����ͽ¬(�ǥե���Ȥϡֻ��ѡס֥ꥢ�륿�����) */
1179 env->orig.yosoku_use_mode = 1;
1180 env->orig.yosoku_realtime = 1;
1181 return (struct wnn_env *)env;
1182 }
1183
1184
1185 /* get language value from env */
1186 char *
js_get_lang(env)1187 js_get_lang(env)
1188 struct wnn_env *env;
1189 {
1190 return(env->lang);
1191 }
1192
1193 int
js_env_exist(server,env_name)1194 js_env_exist(server,env_name)
1195 register char *env_name;
1196 register WNN_JSERVER_ID *server;
1197 {
1198 int x;
1199
1200 set_current_js(server);
1201
1202 handler_of_jserver_dead(server);
1203 if(js_wnn_errorno_eql) {
1204
1205 return(-1);
1206 }
1207 snd_head(JS_ENV_EXIST, server);
1208 putscom(env_name, server);
1209 snd_flush(server);
1210 x =get4com(server);
1211
1212 return x;
1213 }
1214
1215 int
js_env_sticky(env)1216 js_env_sticky(env)
1217 register struct wnn_env *env;
1218 {
1219 int x;
1220
1221 if(env==0) return(-1);
1222 set_current_js(env->js_id);
1223
1224 handler_of_jserver_dead_env(env);
1225 if(env_wnn_errorno_eql) {
1226
1227 return(-1);
1228 }
1229 snd_env_head(env,JS_ENV_STICKY);
1230 snd_flush(env->js_id);
1231 x = get4com(env->js_id);
1232
1233 return x;
1234 }
1235
1236 int
js_env_un_sticky(env)1237 js_env_un_sticky(env)
1238 register struct wnn_env *env;
1239 {
1240 int x;
1241
1242 if(env==0) return(-1);
1243 set_current_js(env->js_id);
1244
1245 handler_of_jserver_dead_env(env);
1246 if(env_wnn_errorno_eql) {
1247
1248 return(-1);
1249 }
1250 snd_env_head(env,JS_ENV_UN_STICKY);
1251 snd_flush(env->js_id);
1252 x = get4com(env->js_id);
1253
1254 return x;
1255 }
1256
1257 /**
1258 env �Ǽ������Ķ���̵������
1259 **/
1260 int
js_disconnect(env)1261 js_disconnect(env)
1262 register struct wnn_env *env;
1263 {
1264 register int x;
1265 if(env==0) return(-1);
1266 set_current_js(env->js_id);
1267
1268 handler_of_jserver_dead_env(env);
1269 if(env_wnn_errorno_eql) {
1270 free(env);
1271 return(-1);
1272 }
1273 snd_env_head(env,JS_DISCONNECT);
1274 snd_flush(env->js_id);
1275 x=get4com(env->js_id);
1276 if(x==-1){
1277 env_wnn_errorno_set= get4com(env->js_id);
1278 }
1279 free(env);
1280 return x;
1281 }
1282
1283
1284 /** �����Фȥ��ͥ��Ȥ��Ƥ��뤫 **/
1285 int
js_isconnect(env)1286 js_isconnect(env)
1287 struct wnn_env *env;
1288 {
1289 if (env && env->js_id)
1290 return(env->js_id->js_dead);
1291 return(-1);
1292 }
1293
1294 /**
1295 env �� �Ķ� �Ȥ��̿��Хåե��� flush ���롣
1296 **/
1297 void
js_flush(env)1298 js_flush(env)
1299 struct wnn_env *env;
1300 {
1301 }
1302
1303
1304
1305 /* Parameter set/get */
1306 /** �Ѵ� parameter �����ꤹ�롣 **/
1307 /** js_param_set **/
1308 int
js_param_set(env,para)1309 js_param_set(env,para)
1310 struct wnn_env *env;
1311 register struct wnn_param *para;
1312 {
1313 register int x;
1314 if(env==0) return(-1);
1315 set_current_js(env->js_id);
1316
1317 handler_of_jserver_dead_env(env);
1318 if(env_wnn_errorno_eql) {
1319
1320 return(-1);
1321 }
1322 snd_env_head(env,JS_PARAM_SET);
1323 JS_Put4Com(para->n, env->js_id); /* ��(��)ʸ����ϤΣ� */
1324 JS_Put4Com(para->nsho, env->js_id); /* ��ʸ����ξ�ʸ��κ���� */
1325 JS_Put4Com(para->p1, env->js_id); /* ��������٤Υѥ��� */
1326 JS_Put4Com(para->p2, env->js_id); /* ��ʸ��Ĺ�Υѥ��� */
1327 JS_Put4Com(para->p3, env->js_id); /* ����Ĺ�Υѥ��� */
1328 JS_Put4Com(para->p4, env->js_id); /* ���Ȥä���ӥåȤΥѥ��� */
1329 JS_Put4Com(para->p5, env->js_id); /* ����Υѥ��� */
1330 JS_Put4Com(para->p6, env->js_id); /* ��ʸ���ɾ���ͤΥѥ��� */
1331 JS_Put4Com(para->p7, env->js_id); /* ��ʸ��Ĺ�Υѥ��� */
1332 JS_Put4Com(para->p8, env->js_id); /* ��ʸ����Υѥ��� */
1333
1334 JS_Put4Com(para->p9, env->js_id); /* �����ʻ� ���������� */
1335 JS_Put4Com(para->p10, env->js_id); /* �����ʻ� ���ʤ����� */
1336 /* CWNN �ѿ������� */
1337 JS_Put4Com(para->p11, env->js_id); /* �����ʻ� �ѿ������� */
1338 /* CWNN ��������� */
1339 JS_Put4Com(para->p12, env->js_id); /* �����ʻ� ��������� */
1340 /* CWNN ����̤����� */
1341 JS_Put4Com(para->p13, env->js_id); /* �����ʻ� �ij�̤����� */
1342 /* CWNN �ij�̤����� */
1343 JS_Put4Com(para->p14, env->js_id); /* �����ʻ� ��°������� */
1344 /* BWNN No of koho */
1345 JS_Put4Com(para->p15, env->js_id); /* �����ʻ� ����̤����� */
1346 /* CWNN Not used */
1347
1348 snd_flush(env->js_id);
1349 x=get4com(env->js_id);
1350 if(x==-1){
1351 env_wnn_errorno_set= get4com(env->js_id);
1352 return -1;
1353 }
1354 return 0;
1355 }
1356
1357 extern int js_get_autolearning_mode_core();
1358
1359 #define WNN_ENV_LOCAL_MASK \
1360 (WNN_ENV_KUTOUTEN_MASK|WNN_ENV_KAKKO_MASK|WNN_ENV_KIGOU_MASK|WNN_ENV_YOSOKU_USE_MASK|WNN_ENV_YOSOKU_REALTIME_MASK)
1361
1362 /*:::DOC_START
1363 *
1364 * Function Name: js_set_henkan_env
1365 * Description : ����������Ѵ��Ķ������ꤹ��
1366 * Parameter :
1367 * env : (In) �Ķ��ؤΥݥ���
1368 * valuemask : (In) ͭ�������ͥӥåȥޥ���
1369 * henv : (In) �Ѵ��Ķ��ι�¤�ΤؤΥݥ���
1370 *
1371 * Return value : 0==SUCCESS, -1==ERROR
1372 *
1373 * Revision history:
1374 *
1375 *:::DOC_END
1376 */
1377 int
js_set_henkan_env(env,valuemask,henv)1378 js_set_henkan_env(env,valuemask,henv)
1379 struct wnn_env *env;
1380 unsigned long valuemask;
1381 register struct wnn_henkan_env *henv;
1382 {
1383 register int x;
1384
1385 if(env==0) return(-1);
1386 set_current_js(env->js_id);
1387
1388 handler_of_jserver_dead_env(env);
1389 if(env_wnn_errorno_eql) {
1390
1391 return(-1);
1392 }
1393 if (valuemask & WNN_ENV_LOCAL_MASK){
1394 if (valuemask & WNN_ENV_KUTOUTEN_MASK)
1395 env->kutouten_mode = henv->kutouten_flag;
1396 if (valuemask & WNN_ENV_KAKKO_MASK)
1397 env->kakko_mode = henv->kakko_flag;
1398 if (valuemask & WNN_ENV_KIGOU_MASK)
1399 env->kigou_mode = henv->kigou_flag;
1400 if (valuemask & WNN_ENV_YOSOKU_USE_MASK)
1401 env->yosoku_use_mode = henv->yosoku_use_flag;
1402 if (valuemask & WNN_ENV_YOSOKU_REALTIME_MASK)
1403 env->yosoku_realtime = henv->yosoku_realtime_flag;
1404 }
1405 if (!(valuemask & ~WNN_ENV_LOCAL_MASK)) {
1406
1407 return 0;
1408 }
1409 snd_env_head(env,JS_SET_HENKAN_ENV);
1410 JS_Put4Com(valuemask, env->js_id); /* ����ӥåȥޥ��� */
1411 JS_Put4Com(henv->last_is_first_flag, env->js_id); /* �ǽ����Ѻ�ͥ�� */
1412 JS_Put4Com(henv->complex_flag, env->js_id); /* ʣ���ͥ�� */
1413 JS_Put4Com(henv->okuri_learn_flag, env->js_id); /* ������ؽ� */
1414 JS_Put4Com(henv->okuri_flag, env->js_id); /* ��������� */
1415 JS_Put4Com(henv->prefix_learn_flag, env->js_id); /* ��Ƭ��ؽ� */
1416 JS_Put4Com(henv->prefix_flag, env->js_id); /* ��Ƭ����� */
1417 JS_Put4Com(henv->suffix_learn_flag, env->js_id); /* ������ؽ� */
1418 JS_Put4Com(henv->common_learn_flag, env->js_id); /* ���Ѹ�ؽ� */
1419 JS_Put4Com(henv->freq_func_flag, env->js_id); /* ���پ徺��Ψ�ؿ� */
1420 JS_Put4Com(henv->numeric_flag, env->js_id); /* ���������ν��ɽ����ˡ */
1421 JS_Put4Com(henv->alphabet_flag, env->js_id); /* ��������ե��٥åȤν��ɽ����ˡ */
1422 JS_Put4Com(henv->symbol_flag, env->js_id); /* ��������ν��ɽ����ˡ */
1423 JS_Put4Com(henv->yuragi_flag, env->js_id); /* Ĺ������餮���� */
1424 JS_Put4Com(henv->rendaku_flag, env->js_id); /* Ϣ������ */
1425 JS_Put4Com(henv->bunsetsugiri_flag, env->js_id); /* ʸ���ڤ�ؽ��⡼�� */
1426 JS_Put4Com(henv->muhenkan_flag, env->js_id); /* ̵�Ѵ��ؽ��⡼�� */
1427 JS_Put4Com(henv->fi_relation_learn_flag, env->js_id); /* �ƣɴط��ؽ��⡼�� */
1428 JS_Put4Com(henv->fi_freq_func_flag, env->js_id); /* �ƣɴط����پ徺��Ψ�ؿ� */
1429 /* ����ͽ¬�ɲ�ʬ Jun. 1,2000 */
1430 JS_Put4Com(henv->yosoku_learn_flag, env->js_id); /* ����ͽ¬�ؽ� */
1431 JS_Put4Com(henv->yosoku_max_disp, env->js_id); /* ͽ¬�������ɽ���� */
1432 JS_Put4Com(henv->yosoku_last_is_first_flag, env->js_id); /* ͽ¬�ǽ�����ͥ�� */
1433 /* �������� 2000/07/21 NTWnn����� */
1434 JS_Put4Com(henv->boin_kabusoku_flag, env->js_id); /* �첻�β��� */
1435 JS_Put4Com(henv->shiin_choka_flag, env->js_id); /* �Ҳ���Ķ�� */
1436 JS_Put4Com(henv->n_choka_flag, env->js_id); /* [N]��Ķ�� */
1437
1438 snd_flush(env->js_id);
1439 x=get4com(env->js_id);
1440 if(x==-1){
1441 env_wnn_errorno_set= get4com(env->js_id);
1442
1443 return -1;
1444 }
1445 if (valuemask & WNN_ENV_BUNSETSUGIRI_LEARN_MASK)
1446 env->bunsetsugiri_mode = henv->bunsetsugiri_flag;
1447 if (valuemask & WNN_ENV_MUHENKAN_LEARN_MASK)
1448 env->muhenkan_mode = henv->muhenkan_flag;
1449
1450 return 0;
1451 } /* End of js_set_henkan_env */
1452
1453 /*:::DOC_START
1454 *
1455 * Function Name: js_set_henkan_hinsi
1456 * Description : �Ѵ��ˡʻ��ѡ��Ի��ѡˤ����ʻ췲�����ꤹ��
1457 * Parameter :
1458 * env : (In) �Ķ��ؤΥݥ���
1459 * mode : (In) ����⡼�ɡ�0 == ��������, else ���������
1460 * nhinsi : (In) �����ʻ������ == �Ի���, �� ���ѡ�
1461 * hlist : (In) �����ʻ�ꥹ�ȤؤΥݥ���
1462 *
1463 * Return value : 0==SUCCESS, -1==ERROR
1464 *
1465 * Revision history:
1466 *
1467 *:::DOC_END
1468 */
1469 int
js_set_henkan_hinsi(env,mode,nhinsi,hlist)1470 js_set_henkan_hinsi(env,mode,nhinsi,hlist)
1471 struct wnn_env *env;
1472 int mode, nhinsi, *hlist;
1473 {
1474 register int x;
1475 if(env==0) return(-1);
1476 set_current_js(env->js_id);
1477
1478 handler_of_jserver_dead_env(env);
1479 if(env_wnn_errorno_eql) {
1480
1481 return(-1);
1482 }
1483 snd_env_head(env,JS_SET_HENKAN_HINSI);
1484 JS_Put4Com(mode, env->js_id);
1485 JS_Put4Com(nhinsi, env->js_id);
1486 for(x = 0; x < abs(nhinsi); x++) JS_Put4Com(hlist[x], env->js_id);
1487 snd_flush(env->js_id);
1488 x=get4com(env->js_id);
1489 if(x==-1){
1490 env_wnn_errorno_set= get4com(env->js_id);
1491 return -1;
1492 }
1493 return 0;
1494 }
1495
1496 /** js_param_get **/
1497 /** env �Ǽ������Ķ����Ѵ� parameter ����Ф��� **/
1498 int
js_param_get(env,para)1499 js_param_get(env,para)
1500 struct wnn_env *env;
1501 register struct wnn_param *para;
1502 {
1503 if(env==0) return(-1);
1504 set_current_js(env->js_id);
1505
1506 handler_of_jserver_dead_env(env);
1507 if(env_wnn_errorno_eql) {
1508
1509 return(-1);
1510 }
1511 snd_env_head(env,JS_PARAM_GET);
1512 snd_flush(env->js_id);
1513 if(get4com(env->js_id) == -1){
1514 env_wnn_errorno_set= get4com(env->js_id);
1515
1516 }
1517 para->n=get4com(env->js_id); /* ��(��)ʸ����ϤΣ� */
1518 para->nsho=get4com(env->js_id); /* ��ʸ����ξ�ʸ��κ���� */
1519 para->p1=get4com(env->js_id); /* ��������٤Υѥ��� */
1520 para->p2=get4com(env->js_id); /* ��ʸ��Ĺ�Υѥ��� */
1521 para->p3=get4com(env->js_id); /* ����Ĺ�Υѥ��� */
1522 para->p4=get4com(env->js_id); /* ���Ȥä���ӥåȤΥѥ��� */
1523 para->p5=get4com(env->js_id); /* ����Υѥ��� */
1524 para->p6=get4com(env->js_id); /* ��ʸ���ɾ���ͤΥѥ��� */
1525 para->p7=get4com(env->js_id); /* ��ʸ��Ĺ�Υѥ��� */
1526 para->p8=get4com(env->js_id); /* ��ʸ����Υѥ��� */
1527 para->p9=get4com(env->js_id); /* �����ʻ� ���������� */
1528 para->p10=get4com(env->js_id); /* �����ʻ� ���ʤ����� */
1529 para->p11=get4com(env->js_id); /* �����ʻ� �ѿ������� */
1530 para->p12=get4com(env->js_id); /* �����ʻ� ��������� */
1531 para->p13=get4com(env->js_id); /* �����ʻ� �ij�̤����� */
1532 para->p14=get4com(env->js_id); /* �����ʻ� ��°������� */
1533 para->p15=get4com(env->js_id); /* �����ʻ� ����̤����� */
1534
1535 return 0;
1536 }
1537
1538 /*:::DOC_START
1539 *
1540 * Function Name: js_get_henkan_env
1541 * Description : ����������Ѵ��Ķ�������
1542 * Parameter :
1543 * env : (In) �Ķ��ؤΥݥ���
1544 * henv : (Out) �Ѵ��Ķ��ι�¤�ΤؤΥݥ���
1545 *
1546 * Return value : 0==SUCCESS, -1==ERROR
1547 *
1548 * Revision history:
1549 *
1550 *:::DOC_END
1551 */
1552 int
js_get_henkan_env(env,henv)1553 js_get_henkan_env(env,henv)
1554 struct wnn_env *env;
1555 register struct wnn_henkan_env *henv;
1556 {
1557 if(env==0) return(-1);
1558 set_current_js(env->js_id);
1559
1560 handler_of_jserver_dead_env(env);
1561 if(env_wnn_errorno_eql) {
1562
1563 return(-1);
1564 }
1565 snd_env_head(env,JS_GET_HENKAN_ENV);
1566 snd_flush(env->js_id);
1567 if(get4com(env->js_id) == -1){
1568 env_wnn_errorno_set= get4com(env->js_id);
1569
1570 }
1571 henv->last_is_first_flag=get4com(env->js_id); /* �ǽ����Ѻ�ͥ�� */
1572 henv->complex_flag=get4com(env->js_id); /* ʣ���ͥ�� */
1573 henv->okuri_learn_flag=get4com(env->js_id); /* ������ؽ� */
1574 henv->okuri_flag=get4com(env->js_id); /* ��������� */
1575 henv->prefix_learn_flag=get4com(env->js_id); /* ��Ƭ��ؽ� */
1576 henv->prefix_flag=get4com(env->js_id); /* ��Ƭ����� */
1577 henv->suffix_learn_flag=get4com(env->js_id); /* ������ؽ� */
1578 henv->common_learn_flag=get4com(env->js_id); /* ���Ѹ�ؽ� */
1579 henv->freq_func_flag=get4com(env->js_id); /* ���پ徺��Ψ�ؿ� */
1580 henv->numeric_flag=get4com(env->js_id); /* ���������ν��ɽ����ˡ */
1581 henv->alphabet_flag=get4com(env->js_id); /* ��������ե��٥åȤν��ɽ����ˡ */
1582 henv->symbol_flag=get4com(env->js_id); /* ��������ν��ɽ����ˡ */
1583 henv->yuragi_flag=get4com(env->js_id); /* Ĺ������餮���� */
1584 henv->rendaku_flag=get4com(env->js_id); /* Ϣ������ */
1585 henv->bunsetsugiri_flag=get4com(env->js_id); /* ʸ���ڤ�ؽ��⡼�� */
1586 henv->muhenkan_flag=get4com(env->js_id); /* ̵�Ѵ��ؽ��⡼�� */
1587 henv->fi_relation_learn_flag=get4com(env->js_id); /* �ƣɴط��ؽ��⡼�� */
1588 henv->fi_freq_func_flag=get4com(env->js_id); /* �ƣɴط����پ徺��Ψ�ؿ� */
1589 /* ����ͽ¬�ɲ�ʬ S.Fuki Jun. 1, 2000 */
1590 henv->yosoku_learn_flag=get4com(env->js_id);/* ͽ¬�ؽ� */
1591 henv->yosoku_max_disp=get4com(env->js_id);/* ͽ¬�������ɽ���� */
1592 henv->yosoku_last_is_first_flag=get4com(env->js_id);/* ͽ¬�ǽ�����ͥ�� */
1593 /* �������� 2000/07/21 NTWnn����� */
1594 henv->boin_kabusoku_flag=get4com(env->js_id); /* �첻�β��� */
1595 henv->shiin_choka_flag=get4com(env->js_id); /* �Ҳ���Ķ�� */
1596 henv->n_choka_flag=get4com(env->js_id); /* [N]��Ķ�� */
1597
1598 env->bunsetsugiri_mode = henv->bunsetsugiri_flag;
1599 env->muhenkan_mode = henv->muhenkan_flag;
1600
1601 henv->kutouten_flag = env->kutouten_mode; /* ������ */
1602 henv->kakko_flag = env->kakko_mode; /* ��� */
1603 henv->kigou_flag = env->kigou_mode; /* ���� */
1604 henv->yosoku_use_flag = env->yosoku_use_mode;
1605 henv->yosoku_realtime_flag = env->yosoku_realtime;
1606
1607
1608 return 0;
1609 } /* End of js_get_henkan_env */
1610
1611 /*:::DOC_START
1612 *
1613 * Function Name: js_get_henkan_env_local
1614 * Description : �Ѵ��δĶ����⡤�饤�֥��ˤ����Τ���
1615 * ����������̡�����
1616 * Parameter :
1617 * env : (In) �Ķ��ؤΥݥ���
1618 * henv : (In) �Ѵ��Ķ��ι�¤�ΤؤΥݥ���
1619 *
1620 * Return value : 0==SUCCESS, -1==ERROR
1621 *
1622 * Revision history:
1623 * ����ͽ¬�Υѥ����ɲ�
1624 *
1625 *:::DOC_END
1626 */
1627 int
js_get_henkan_env_local(env,henv)1628 js_get_henkan_env_local(env,henv)
1629 struct wnn_env *env;
1630 register struct wnn_henkan_env *henv;
1631 {
1632 if(env==0) return(-1);
1633
1634 if(env_wnn_errorno_eql) {
1635
1636 return(-1);
1637 }
1638 henv->kutouten_flag = env->kutouten_mode; /* ������ */
1639 henv->kakko_flag = env->kakko_mode; /* ��� */
1640 henv->kigou_flag = env->kigou_mode; /* ���� */
1641 henv->yosoku_use_flag = env->yosoku_use_mode;
1642 henv->yosoku_realtime_flag = env->yosoku_realtime;
1643
1644 return 0;
1645 }
1646
1647 /*:::DOC_START
1648 *
1649 * Function Name: js_get_henkan_hinsi
1650 * Description : �Ѵ��ˡʻ��ѡ��Ի��ѡˤ����ʻ췲������
1651 * Parameter :
1652 * env : (In) �Ķ��ؤΥݥ���
1653 * nhinsi : (Out) �����ʻ������ == �Ի���, �� ���ѡ�
1654 * hlist : (Out) �����ʻ�ꥹ�ȤؤΥݥ���
1655 *
1656 * Return value : 0==SUCCESS, -1==ERROR
1657 *
1658 * Revision history:
1659 *
1660 *:::DOC_END
1661 */
1662 int
js_get_henkan_hinsi(env,nhinsi,hlist)1663 js_get_henkan_hinsi(env,nhinsi,hlist)
1664 struct wnn_env *env;
1665 int *nhinsi, **hlist;
1666 {
1667 int i;
1668 if(env==0) return(-1);
1669 set_current_js(env->js_id);
1670
1671 handler_of_jserver_dead_env(env);
1672 if(env_wnn_errorno_eql) {
1673
1674 return(-1);
1675 }
1676 snd_env_head(env,JS_GET_HENKAN_HINSI);
1677 snd_flush(env->js_id);
1678 if(get4com(env->js_id) == -1){
1679 env_wnn_errorno_set= get4com(env->js_id);
1680
1681 }
1682 *nhinsi = get4com(env->js_id);
1683 if(((*hlist) = (int *)malloc(abs(*nhinsi) * sizeof(int))) == NULL) {
1684 int dummy;
1685 for(i = 0; i < abs(*nhinsi); i++) dummy = get4com(env->js_id);
1686 env_wnn_errorno_set = WNN_ALLOC_FAIL;
1687
1688 }
1689 for(i = 0; i < abs(*nhinsi); i++) (*hlist)[i] = get4com(env->js_id);
1690
1691 return 0;
1692 } /* End of js_get_henkan_hinsi */
1693
1694 /*
1695 global File Operation
1696 */
1697 /** js_mkdir **/
1698 int
js_mkdir(env,path)1699 js_mkdir(env,path)
1700 struct wnn_env *env;
1701 char *path;
1702 {
1703 register int x;
1704 if(env==0) return(-1);
1705 set_current_js(env->js_id);
1706
1707 handler_of_jserver_dead_env(env);
1708 if(env_wnn_errorno_eql) {
1709
1710 return(-1);
1711 }
1712 snd_env_head(env,JS_MKDIR);
1713 putscom(path, env->js_id);
1714 snd_flush(env->js_id);
1715 x=get4com(env->js_id);
1716 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
1717
1718 return x;
1719 }
1720
1721 /** js_access **/
1722 int
js_access(env,path,amode)1723 js_access(env,path,amode)
1724 struct wnn_env *env;
1725 char *path;
1726 int amode;
1727 {
1728 register int x;
1729 if(env==0) return(-1);
1730 set_current_js(env->js_id);
1731
1732 handler_of_jserver_dead_env(env);
1733 if(env_wnn_errorno_eql) {
1734
1735 return(-1);
1736 }
1737 snd_env_head(env,JS_ACCESS);
1738 JS_Put4Com(amode, env->js_id);
1739 putscom(path, env->js_id);
1740 snd_flush(env->js_id);
1741 x=get4com(env->js_id);
1742
1743 return x;
1744 }
1745
1746 /** js_file_list_all **/
1747 static int rcv_file_list();
1748
1749 int
js_file_list_all(server,ret)1750 js_file_list_all(server,ret)
1751 WNN_JSERVER_ID *server;
1752 struct wnn_ret_buf *ret;
1753 {
1754 int x;
1755
1756 set_current_js(server);
1757
1758 handler_of_jserver_dead(server);
1759 if(js_wnn_errorno_eql) {
1760
1761 return(-1);
1762 }
1763 snd_server_head(server,JS_FILE_LIST_ALL);
1764 snd_flush(server);
1765 x = rcv_file_list(ret, server);
1766
1767 return x;
1768 }
1769
1770 /** js_file_list **/
1771 int
js_file_list(env,ret)1772 js_file_list(env,ret)
1773 struct wnn_env *env;
1774 struct wnn_ret_buf *ret;
1775 {
1776 int x;
1777
1778 if(env==0) return(-1);
1779 set_current_js(env->js_id);
1780
1781 handler_of_jserver_dead_env(env);
1782 if(env_wnn_errorno_eql) {
1783
1784 return(-1);
1785 }
1786 snd_env_head(env,JS_FILE_LIST);
1787 snd_flush(env->js_id);
1788 x = rcv_file_list(ret, env->js_id);
1789
1790 return x;
1791 }
1792
1793 static void re_alloc();
1794
1795 static int
rcv_file_list(ret,server)1796 rcv_file_list(ret, server)
1797 struct wnn_ret_buf *ret;
1798 ARGS *server;
1799 {
1800 register int i,count;
1801 WNN_FILE_INFO_STRUCT *files;
1802 count=get4com(server);
1803 re_alloc(ret,sizeof(WNN_FILE_INFO_STRUCT)*count);
1804 files=(WNN_FILE_INFO_STRUCT *)ret->buf;
1805 for(i=0;i<count;i++){
1806 files->fid= get4com(server);
1807 files->localf= get4com(server);
1808 files->ref_count= get4com(server);
1809 files->type= get4com(server);
1810 getscom(files->name, server, WNN_F_NAMELEN);
1811 files++;
1812 }
1813 return count;
1814 }
1815
1816 /** js_file_stat **/
1817 int
js_file_stat(env,path,s)1818 js_file_stat(env,path, s)
1819 struct wnn_env *env;
1820 char *path;
1821 WNN_FILE_STAT *s;
1822 {
1823 register int x;
1824 if(env==0) return(-1);
1825 set_current_js(env->js_id);
1826
1827 handler_of_jserver_dead_env(env);
1828 if(env_wnn_errorno_eql) {
1829
1830 return(-1);
1831 }
1832 snd_env_head(env,JS_FILE_STAT);
1833 putscom(path, env->js_id);
1834 snd_flush(env->js_id);
1835 x=get4com(env->js_id);
1836
1837 s->type = x;
1838 return x;
1839 }
1840
1841
1842 /** js_file_info **/
1843 int
js_file_info(env,fid,file)1844 js_file_info(env,fid,file)
1845 struct wnn_env *env;
1846 int fid;
1847 register WNN_FILE_INFO_STRUCT *file;
1848 {
1849 register int x;
1850 if(env==0) return(-1);
1851 set_current_js(env->js_id);
1852
1853 handler_of_jserver_dead_env(env);
1854 if(env_wnn_errorno_eql) {
1855
1856 return(-1);
1857 }
1858 snd_env_head(env,JS_FILE_INFO);
1859 JS_Put4Com(fid, env->js_id);
1860 snd_flush(env->js_id);
1861 file->fid= fid;
1862 x=get4com(env->js_id);
1863 if(x==-1){
1864 env_wnn_errorno_set= get4com(env->js_id);
1865
1866 return(-1);
1867 }
1868 getscom(file->name, env->js_id, WNN_F_NAMELEN);
1869 file->localf= get4com(env->js_id);
1870 file->ref_count= get4com(env->js_id);
1871 file->type= get4com(env->js_id);
1872
1873 return 0;
1874 }
1875
1876 /** js_file_loaded **/
1877 int
js_file_loaded(server,path)1878 js_file_loaded(server,path)
1879 WNN_JSERVER_ID *server;
1880 char *path;
1881 {
1882 register int x;
1883 set_current_js(server);
1884
1885 handler_of_jserver_dead(server);
1886 if(js_wnn_errorno_eql) {
1887
1888 return(-1);
1889 }
1890 snd_server_head(server,JS_FILE_LOADED);
1891 putscom(path, server);
1892 snd_flush(server);
1893 x=get4com(server);
1894
1895 return x;
1896 }
1897
1898 /** js_file_loaded_local **/
1899 static int check_local_file();
1900 static int file_loaded_local();
1901
1902 static int
js_file_loaded_local_body(server,path)1903 js_file_loaded_local_body(server,path)
1904 WNN_JSERVER_ID *server;
1905 char *path;
1906 {
1907 int x;
1908
1909 handler_of_jserver_dead(server);
1910 if(js_wnn_errorno_eql) {
1911 return(-1);
1912 }
1913 if(check_local_file(path, server) == -1) return (-1);
1914 snd_server_head(server, JS_FILE_LOADED_LOCAL);
1915 x=file_loaded_local(path, server);
1916 return x;
1917 }
1918
1919 int
js_file_loaded_local(server,path)1920 js_file_loaded_local(server,path)
1921 WNN_JSERVER_ID *server;
1922 char *path;
1923 {
1924 int x;
1925 set_current_js(server);
1926
1927 x = js_file_loaded_local_body(server,path);
1928
1929 return x;
1930 }
1931
1932 static int
check_local_file(path,server)1933 check_local_file(path, server)
1934 char *path;
1935 ARGS *server;
1936 {
1937 register FILE *f;
1938 register int x;
1939 struct wnn_file_head fh;
1940
1941 #ifdef WRITE_CHECK
1942 check_backup(path);
1943 #endif /* WRITE_CHECK */
1944 f=dic_fopen(path,"r");
1945 if(f == NULL){
1946 js_wnn_errorno_set = WNN_OPENF_ERR;
1947 return -1;
1948 }
1949 x=input_file_header(f, &fh);
1950 if(x==-1){
1951 dic_fclose(f);
1952 js_wnn_errorno_set = WNN_NOT_A_FILE;
1953 return -1;
1954 }
1955
1956 #ifdef WNN_CHECK_INODE
1957 if(dic_check_inode(f, &fh) == -1){
1958 change_file_uniq(&fh, path);
1959 #ifdef WRITE_CHECK
1960 dic_fclose(f);
1961 f=dic_fopen(path,"r");
1962 if(f == NULL){
1963 js_wnn_errorno_set = WNN_OPENF_ERR;
1964 return (-1);
1965 }
1966 #endif /* WRITE_CHECK */
1967 if(dic_check_inode(f, &fh) == -1){
1968 dic_fclose(f);
1969 js_wnn_errorno_set = WNN_INODE_CHECK_ERROR;
1970 return (-1);
1971 }
1972 }
1973 #endif /* WNN_CHECK_INODE */
1974
1975 dic_fclose(f);
1976 return 0;
1977 }
1978
1979
1980 static int
file_loaded_local(path,server)1981 file_loaded_local(path, server)
1982 char *path;
1983 ARGS *server;
1984 {
1985 register int x,i;
1986 FILE *f;
1987 struct wnn_file_head fh;
1988
1989 #ifdef WRITE_CHECK
1990 check_backup(path);
1991 #endif /* WRITE_CHECK */
1992 f=dic_fopen(path,"r");
1993 if(f == NULL){
1994 js_wnn_errorno_set = WNN_OPENF_ERR;
1995 return -1;
1996 }
1997 x=input_file_header(f, &fh);
1998 if(x==-1){
1999 dic_fclose(f);
2000 js_wnn_errorno_set = WNN_NOT_A_FILE;
2001 return -1;
2002 }
2003 JS_Put4Com(fh.file_uniq.time, server);
2004 JS_Put4Com(fh.file_uniq.dev, server);
2005 JS_Put4Com(fh.file_uniq.inode, server);
2006 for(i=0;i<WNN_HOSTLEN;i++){
2007 JS_Put1Com(fh.file_uniq.createhost[i], server);
2008 }
2009
2010 snd_flush(server);
2011 x=get4com(server);
2012 dic_fclose(f);
2013 return x;
2014 }
2015
2016 /** js_hindo_file_create **/
2017 int
js_hindo_file_create(env,fid,fn,comment,hpasswd)2018 js_hindo_file_create(env,fid,fn,comment,hpasswd)
2019 struct wnn_env *env;
2020 int fid;
2021 char *fn;
2022 w_char *comment;
2023 char *hpasswd;
2024 {
2025 register int x;
2026 if(env==0) return(-1);
2027 set_current_js(env->js_id);
2028
2029 handler_of_jserver_dead_env(env);
2030 if(env_wnn_errorno_eql) {
2031
2032 return(-1);
2033 }
2034 snd_env_head(env,JS_HINDO_FILE_CREATE);
2035 JS_Put4Com(fid, env->js_id);
2036 putscom(fn, env->js_id);
2037 putwscom(comment, env->js_id);
2038 putscom(hpasswd, env->js_id);
2039 snd_flush(env->js_id);
2040 x=get4com(env->js_id);
2041 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2042
2043 return x;
2044 }
2045
2046 /*:::DOC_START
2047 *
2048 * Function Name: js_fi_hindo_file_create
2049 * Description : ������¦�ˣƣɴط����٥ե�������������
2050 * Parameter :
2051 * env : (In) �Ķ��ؤΥݥ���
2052 * fid : (In) �б��ƣɴط�����ե�����ɣ�
2053 * fn : (In) �ƣɴط����٥ե�����̾
2054 * comment : (In) �ƣɴط����٥ե����륳����
2055 * hpasswd : (In) �ƣɴط����٥ե�����ѥ����
2056 *
2057 * Return value : 0==SUCCESS, -1==ERROR
2058 *
2059 * Revision history:
2060 *
2061 *:::DOC_END
2062 */
2063 int
js_fi_hindo_file_create(env,fid,fn,comment,hpasswd)2064 js_fi_hindo_file_create(env, fid, fn, comment, hpasswd)
2065 struct wnn_env *env;
2066 int fid;
2067 char *fn;
2068 w_char *comment;
2069 char *hpasswd;
2070 {
2071 register int x;
2072 if(env==0) return(-1);
2073 set_current_js(env->js_id);
2074
2075 handler_of_jserver_dead_env(env);
2076 if(env_wnn_errorno_eql) {
2077
2078 return(-1);
2079 }
2080 snd_env_head(env,JS_FI_HINDO_FILE_CREATE);
2081 JS_Put4Com(fid, env->js_id);
2082 putscom(fn, env->js_id);
2083 putwscom(comment, env->js_id);
2084 putscom(hpasswd, env->js_id);
2085 snd_flush(env->js_id);
2086 x=get4com(env->js_id);
2087 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2088
2089 return x;
2090 } /* End of js_fi_hindo_file_create */
2091
2092 /*:::DOC_START
2093 *
2094 * Function Name: js_dic_file_create
2095 * Description : ������¦�˼���ե�������������
2096 * Parameter :
2097 * env : (In) �Ķ��ؤΥݥ���
2098 * fn : (In) ��������ե�����̾
2099 * type : (In) ��������ե����륿����
2100 * comment : (In) ��������ե����륳����
2101 * passwd (In) ��������ե�����ѥ����
2102 * hpasswd : (In) �������������٥ѥ����
2103 *
2104 * Return value : 0==SUCCESS, -1==ERROR
2105 *
2106 * Revision history:
2107 *
2108 *:::DOC_END
2109 */
2110 int
js_dic_file_create(env,fn,type,comment,passwd,hpasswd)2111 js_dic_file_create(env, fn, type, comment, passwd, hpasswd)
2112 struct wnn_env *env;
2113 char *fn;
2114 w_char *comment;
2115 char *passwd, *hpasswd;
2116 int type;
2117 {
2118 register int x;
2119 if(env==0) return(-1);
2120 set_current_js(env->js_id);
2121
2122 handler_of_jserver_dead_env(env);
2123 if(env_wnn_errorno_eql) {
2124
2125 return(-1);
2126 }
2127 snd_env_head(env,JS_DIC_FILE_CREATE);
2128 putscom(fn, env->js_id);
2129 putwscom(comment, env->js_id);
2130 putscom(passwd, env->js_id);
2131 putscom(hpasswd, env->js_id);
2132 JS_Put4Com(type, env->js_id);
2133 snd_flush(env->js_id);
2134 x=get4com(env->js_id);
2135 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2136
2137 return x;
2138 } /* End of js_dic_file_create */
2139
2140
2141 /** js_file_discard **/
2142 int
js_file_discard(env,fid)2143 js_file_discard(env,fid)
2144 struct wnn_env *env;
2145 int fid;
2146 {
2147 register int x;
2148 if(env==0) return(-1);
2149 set_current_js(env->js_id);
2150
2151 handler_of_jserver_dead_env(env);
2152 if(env_wnn_errorno_eql) {
2153
2154 return(-1);
2155 }
2156 snd_env_head(env,JS_FILE_DISCARD);
2157 JS_Put4Com(fid, env->js_id);
2158 snd_flush(env->js_id);
2159 x=get4com(env->js_id);
2160 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2161
2162 return x;
2163 }
2164
2165 /** js_file_read **/
2166 int
js_file_read(env,fn)2167 js_file_read(env,fn)
2168 struct wnn_env *env;
2169 char *fn;
2170 {
2171 register int x;
2172 if(env==0) return(-1);
2173 set_current_js(env->js_id);
2174
2175 handler_of_jserver_dead_env(env);
2176 if(env_wnn_errorno_eql) {
2177
2178 return(-1);
2179 }
2180 snd_env_head(env,JS_FILE_READ);
2181 putscom(fn, env->js_id);
2182 snd_flush(env->js_id);
2183 x=get4com(env->js_id);
2184 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2185
2186 return x;
2187 }
2188
2189 /** js_file_write **/
2190 int
js_file_write(env,fid,fn)2191 js_file_write(env,fid,fn)
2192 struct wnn_env *env;
2193 int fid;
2194 char *fn;
2195 {
2196 register int x;
2197 if(env==0) return(-1);
2198 set_current_js(env->js_id);
2199
2200 handler_of_jserver_dead_env(env);
2201 if(env_wnn_errorno_eql) {
2202
2203 return(-1);
2204 }
2205 snd_env_head(env,JS_FILE_WRITE);
2206 JS_Put4Com(fid, env->js_id);
2207 putscom(fn, env->js_id);
2208 snd_flush(env->js_id);
2209 x=get4com(env->js_id);
2210 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2211
2212 return x;
2213 }
2214
2215 /** js_file_receive **/
2216 static int xget1com();
2217 static void xput1com();
2218
2219 int
js_file_receive(env,fid,fn)2220 js_file_receive(env,fid,fn)
2221 struct wnn_env *env;
2222 int fid;
2223 char *fn;
2224 {
2225 register int mode, x;
2226 char file_name[MAXPATHLEN];
2227 char buf[MAXHOSTNAMELEN + 1]; /* 1=C_LOCAL */
2228 FILE *f;
2229 int n;
2230 struct wnn_file_head fh;
2231 int i;
2232 #ifdef WRITE_CHECK
2233 char *tmp = NULL, *backup = NULL, tmp_x;
2234 int tmp_err = 0;
2235 #endif /* WRITE_CHECK */
2236
2237 if(env==0) return(-1);
2238 set_current_js(env->js_id);
2239
2240 handler_of_jserver_dead_env(env);
2241 if(env_wnn_errorno_eql)
2242 return(-1);
2243
2244 snd_env_head(env,JS_FILE_RECEIVE);
2245 JS_Put4Com(fid, env->js_id);
2246 snd_flush(env->js_id);
2247 getscom(file_name, env->js_id, sizeof(file_name));
2248 if(fn ==NULL || strcmp(fn,"")==0){
2249 gethostname(buf, sizeof(buf) - 1 - 1); /* 1=C_LOCAL, 1=NULL */
2250 buf[sizeof(buf) - 1 - 1] = '\0';
2251 n = strlen(buf);
2252 buf[n] = C_LOCAL;
2253 buf[n+1] = 0;
2254 if(strncmp(buf, file_name, n + 1) == 0)
2255 fn = file_name + n + 1;
2256 }
2257 #ifdef WRITE_CHECK
2258 check_backup(fn);
2259 #endif /* WRITE_CHECK */
2260 if((f = dic_fopen(fn, "r")) == NULL){ /* New File */
2261 fh.file_uniq.time = fh.file_uniq.dev = fh.file_uniq.inode = 0;
2262 } else{ /* Old File Exists */
2263 if(input_file_header(f, &fh) == -1){
2264 env_wnn_errorno_set=WNN_NOT_A_FILE;
2265 dic_fclose(f);
2266 JS_Put4Com(-1, env->js_id);
2267 snd_flush(env->js_id);
2268 return(-1);
2269 }
2270 dic_fclose(f);
2271 }
2272 JS_Put4Com(0, env->js_id); /* Ack */
2273 JS_Put4Com(fh.file_uniq.time, env->js_id);
2274 JS_Put4Com(fh.file_uniq.dev, env->js_id);
2275 JS_Put4Com(fh.file_uniq.inode, env->js_id);
2276 for(i=0;i<WNN_HOSTLEN;i++){
2277 JS_Put1Com(fh.file_uniq.createhost[i], env->js_id);
2278 }
2279
2280 snd_flush(env->js_id);
2281
2282 if((mode=get4com(env->js_id))==-1){ /* check stat */
2283 env_wnn_errorno_set= get4com(env->js_id);
2284 return -1;
2285 }
2286 if(mode==WNN_NEED_WRITE_NO){
2287 return 0; /* need not saving */
2288 }
2289 if(mode == WNN_NEED_WRITE_ALL || mode == WNN_NEED_WRITE_NOTREAD){
2290 #ifdef WRITE_CHECK
2291 backup = make_backup_file(fn);
2292 if ((tmp = make_tmp_file(fn, 0, &f)) == NULL) {
2293 delete_tmp_file(backup);
2294 env_wnn_errorno_set=WNN_FILE_WRITE_ERROR;
2295 JS_Put4Com(-1, env->js_id);
2296 snd_flush(env->js_id);
2297 return(-1);
2298 }
2299 #else /* WRITE_CHECK */
2300 if((f = fopen(fn, "w+")) == NULL){
2301 env_wnn_errorno_set=WNN_FILE_WRITE_ERROR;
2302 JS_Put4Com(-1, env->js_id);
2303 snd_flush(env->js_id);
2304 return(-1);
2305 }
2306 #endif /* WRITE_CHECK */
2307 } else if(mode == WNN_NEED_WRITE_HINDO){
2308 #ifdef WRITE_CHECK
2309 backup = make_backup_file(fn);
2310 if ((tmp = make_tmp_file(fn, 1, &f)) == NULL) {
2311 delete_tmp_file(backup);
2312 env_wnn_errorno_set=WNN_FILE_WRITE_ERROR;
2313 JS_Put4Com(-1, env->js_id);
2314 snd_flush(env->js_id);
2315 return(-1);
2316 }
2317 #else /* WRITE_CHECK */
2318 if((f = fopen(fn, "r+")) == NULL){ /* New File */
2319 env_wnn_errorno_set=WNN_FILE_WRITE_ERROR;
2320 JS_Put4Com(-1, env->js_id);
2321 snd_flush(env->js_id);
2322 return(-1);
2323 }
2324 #endif /* WRITE_CHECK */
2325 }
2326 JS_Put4Com(0, env->js_id);
2327 snd_flush(env->js_id); /* ACK */
2328 for(;;){
2329 if((x=xget1com(env->js_id))== -1) break; /* EOF */
2330 #ifdef WRITE_CHECK
2331 tmp_x = (char)x;
2332 if (fwrite(&tmp_x, sizeof(char), 1, f) == -1) tmp_err = 1;
2333 #else /* WRITE_CHECK */
2334 fputc(x,f);
2335 #endif /* WRITE_CHECK */
2336 }
2337 #ifdef WRITE_CHECK
2338 if (tmp_err == 0) {
2339 rewind(f);
2340 x = input_file_header(f, &fh);
2341 fclose(f);
2342 write_file_move_tmp_to_org(tmp, fn,
2343 fh.file_type, fh.file_passwd, &(fh.file_uniq_org));
2344 } else {
2345 fclose(f);
2346 delete_tmp_file(tmp);
2347 }
2348 delete_tmp_file(backup);
2349 #else
2350 #ifndef WNN_CHECK_INODE
2351 rewind(f);
2352 if (input_file_header(f, &fh) != -1) {
2353 change_file_uniq1(f,
2354 fh.file_type, fh.file_passwd, &(fh.file_uniq_org));
2355 }
2356 #endif
2357 fclose(f);
2358 #endif /* WRITE_CHECK */
2359
2360 x=get4com(env->js_id);
2361 if(x==-1) env_wnn_errorno_set= get4com(env->js_id);
2362 #ifdef WRITE_CHECK
2363 if (tmp_err) {
2364 env_wnn_errorno_set = WNN_FILE_WRITE_ERROR;
2365 return(-1);
2366 }
2367 #endif /* WRITE_CHECK */
2368
2369 return x;
2370 }
2371
2372 static int
xget1com(server)2373 xget1com(server)
2374 ARGS *server;
2375 {
2376 register int x;
2377 if((x= get1com(server)) != 0xFF) return x;
2378 if(get1com(server) == 0xFF) return -1; /* EOF */
2379 return 0xFF;
2380 }
2381
2382 /** js_file_send **/
2383 int
js_file_send(env,fn)2384 js_file_send(env,fn)
2385 struct wnn_env *env;
2386 char *fn;
2387 {
2388 register int x;
2389 FILE *f;
2390 int n;
2391 char buf[MAXHOSTNAMELEN + 1 + MAXPATHLEN]; /* 1=C_LOCAL */
2392 char *b;
2393 register int cc,i;
2394
2395 if(env==0) return(-1);
2396 set_current_js(env->js_id);
2397
2398 handler_of_jserver_dead_env(env);
2399 if(env_wnn_errorno_eql) {
2400
2401 return(-1);
2402 }
2403 if(check_local_file(fn, env->js_id) == -1) {
2404
2405 return (-1);
2406 }
2407 snd_env_head(env,JS_FILE_SEND);
2408 x=file_loaded_local(fn, env->js_id);
2409 if(x!= -1){ /* file is already loaded */
2410 if(get4com(env->js_id) == -1) {
2411 env_wnn_errorno_set= get4com(env->js_id);
2412
2413 return(-1);
2414 }
2415 return x;
2416
2417 }
2418
2419 x=get4com(env->js_id);
2420 if(x==-1){
2421 env_wnn_errorno_set= get4com(env->js_id);
2422
2423 return -1;
2424 }
2425
2426 gethostname(buf, sizeof(buf) - 1 - 1); /* 1=C_LOCAL, 1=NULL */
2427 buf[sizeof(buf) - 1 - 1] = '\0';
2428 n = strlen(buf);
2429 buf[n] = C_LOCAL;
2430 strncpy(buf + n + 1, fn, sizeof(buf) - n - 1);
2431 buf[sizeof(buf) - 1] = '\0';
2432 putscom(buf, env->js_id);
2433
2434 #ifdef WRITE_CHECK
2435 check_backup(fn);
2436 #endif /* WRITE_CHECK */
2437 if((f=dic_fopen(fn,"r"))== NULL){
2438 xput1com(-1, env->js_id); /* EOF */
2439
2440 return -1;
2441 }
2442
2443 /* send contents of file */
2444 for(;;){
2445 cc = fread(buf,1,sizeof(buf),f);
2446 if(cc <= 0) break; /* EOF */
2447 for(b=buf,i=0;i<cc;i++){
2448 xput1com((int)*b++ & 0xff, env->js_id);
2449 }
2450 }
2451 dic_fclose(f);
2452 xput1com(-1, env->js_id); /* EOF */
2453 snd_flush(env->js_id);
2454 x=get4com(env->js_id);
2455 if(x==-1) env_wnn_errorno_set= get4com(env->js_id);
2456
2457 return x;
2458 }
2459
2460 static void
xput1com(d,server)2461 xput1com(d, server)
2462 int d;
2463 ARGS *server;
2464 {
2465 if(d == -1){
2466 JS_Put1Com(0xFF, server);
2467 JS_Put1Com(0xFF, server);
2468 return;/* EOF */
2469 }
2470 JS_Put1Com(d, server);
2471 if(d == 0xFF){
2472 JS_Put1Com(0x00, server);
2473 }
2474 }
2475
2476
2477 /*** Dic. Operation for Env. ***/
2478
2479 /** js_dic_add **/
2480 static int
js_dic_add_body(env,fid,hfid,rev,jnice,rw,hrw,pw1,pw2)2481 js_dic_add_body(env,fid,hfid,rev, jnice,rw,hrw, pw1, pw2)
2482 struct wnn_env *env;
2483 int fid,hfid,rev,jnice,rw,hrw;
2484 char *pw1, *pw2;
2485 {
2486 register int x;
2487 snd_env_head(env,JS_DIC_ADD);
2488 JS_Put4Com(fid, env->js_id);
2489 JS_Put4Com(hfid, env->js_id);
2490 JS_Put4Com(jnice, env->js_id);
2491 JS_Put4Com(rw, env->js_id);
2492 JS_Put4Com(hrw, env->js_id);
2493 putscom(pw1, env->js_id);
2494 putscom(pw2, env->js_id);
2495 JS_Put4Com(rev, env->js_id); /* rev is to add it as reverse dict */
2496 snd_flush(env->js_id);
2497 x=get4com(env->js_id);
2498 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2499 return x;
2500 }
2501 int
js_dic_add(env,fid,hfid,rev,jnice,rw,hrw,pw1,pw2)2502 js_dic_add(env,fid,hfid,rev, jnice,rw,hrw, pw1, pw2)
2503 struct wnn_env *env;
2504 int fid,hfid,rev,jnice,rw,hrw;
2505 char *pw1, *pw2;
2506 {
2507 register int x;
2508 if(env==0) return(-1);
2509 set_current_js(env->js_id);
2510
2511 handler_of_jserver_dead_env(env);
2512 if(env_wnn_errorno_eql) {
2513
2514 return(-1);
2515 }
2516 x = js_dic_add_body(env,fid,hfid,rev, jnice,rw,hrw, pw1, pw2);
2517
2518 return x;
2519 }
2520
2521 /*:::DOC_START
2522 *
2523 * Function Name: js_fi_dic_add_body
2524 * Description : js_fi_dic_add �Υ��֥롼����ؿ�
2525 * Parameter :
2526 * env : (In) �Ķ��ؤΥݥ���
2527 * fid : (In) �ƣɴط�����ե�����ɣ�
2528 * hfid : (In) �ƣɴط����٥ե�����ɣ�
2529 * suflag : (In) �����ƥ༭����桼������
2530 * rw : (In) ��������ǽ����Բ�ǽ
2531 * hrw : (In) ���ٹ�������ǽ����Բ�ǽ
2532 * pw1 : (In) �ƣɴط�����ե�����Υѥ����
2533 * pw2 : (In) �ƣɴط����٥ե�����Υѥ����
2534 *
2535 * Return value : -1==ERROR, else ��Ͽ�����ֹ�
2536 *
2537 * Revision history:
2538 *
2539 *:::DOC_END
2540 */
2541 static int
js_fi_dic_add_body(env,fid,hfid,suflag,rw,hrw,pw1,pw2)2542 js_fi_dic_add_body(env, fid, hfid, suflag, rw, hrw, pw1, pw2)
2543 struct wnn_env *env;
2544 int fid,hfid,suflag,rw,hrw;
2545 char *pw1, *pw2;
2546 {
2547 register int x;
2548 snd_env_head(env,JS_FI_DIC_ADD);
2549 JS_Put4Com(fid, env->js_id);
2550 JS_Put4Com(hfid, env->js_id);
2551 JS_Put4Com(suflag, env->js_id);
2552 JS_Put4Com(rw, env->js_id);
2553 JS_Put4Com(hrw, env->js_id);
2554 putscom(pw1, env->js_id);
2555 putscom(pw2, env->js_id);
2556 snd_flush(env->js_id);
2557 x=get4com(env->js_id);
2558 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2559 return x;
2560 } /* End of js_fi_dic_add_body */
2561
2562 /*:::DOC_START
2563 *
2564 * Function Name: js_fi_dic_add
2565 * Description : �Ķ��ˣƣɼ�����ɲä���
2566 * Parameter :
2567 * env : (In) �Ķ��ؤΥݥ���
2568 * fid : (In) �ƣɴط�����ե�����ɣ�
2569 * hfid : (In) �ƣɴط����٥ե�����ɣ�
2570 * suflag : (In) �����ƥ༭����桼������
2571 * rw : (In) ��������ǽ����Բ�ǽ
2572 * hrw : (In) ���ٹ�������ǽ����Բ�ǽ
2573 * pw1 : (In) �ƣɴط�����ե�����Υѥ����
2574 * pw2 : (In) �ƣɴط����٥ե�����Υѥ����
2575 *
2576 * Return value : -1==ERROR, else ��Ͽ�����ֹ�
2577 *
2578 * Revision history:
2579 *
2580 *:::DOC_END
2581 */
2582 int
js_fi_dic_add(env,fid,hfid,suflag,rw,hrw,pw1,pw2)2583 js_fi_dic_add(env, fid, hfid, suflag, rw, hrw, pw1, pw2)
2584 struct wnn_env *env;
2585 int fid,hfid,suflag,rw,hrw;
2586 char *pw1, *pw2;
2587 {
2588 register int x;
2589 if(env==0) return(-1);
2590 set_current_js(env->js_id);
2591
2592 handler_of_jserver_dead_env(env);
2593 if(env_wnn_errorno_eql) {
2594
2595 return(-1);
2596 }
2597 /* call sub routine function */
2598 x = js_fi_dic_add_body(env, fid, hfid, suflag, rw, hrw, pw1, pw2);
2599
2600 return x;
2601 } /* End of js_fi_dic_add */
2602
2603 /** js_dic_delete **/
2604 int
js_dic_delete(env,dicno)2605 js_dic_delete(env,dicno)
2606 struct wnn_env *env;
2607 int dicno;
2608 {
2609 register int x;
2610 if(env==0) return(-1);
2611 set_current_js(env->js_id);
2612
2613 handler_of_jserver_dead_env(env);
2614 if(env_wnn_errorno_eql) {
2615
2616 return(-1);
2617 }
2618 snd_env_head(env,JS_DIC_DELETE);
2619 JS_Put4Com(dicno, env->js_id);
2620 snd_flush(env->js_id);
2621 x=get4com(env->js_id);
2622 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2623
2624 return x;
2625 }
2626
2627 /** js_dic_use **/
2628 int
js_dic_use(env,dic_no,flag)2629 js_dic_use(env,dic_no,flag)
2630 struct wnn_env *env;
2631 int dic_no,flag;
2632 {
2633 register int x;
2634 if(env==0) return(-1);
2635 set_current_js(env->js_id);
2636
2637 handler_of_jserver_dead_env(env);
2638 if(env_wnn_errorno_eql) {
2639
2640 return(-1);
2641 }
2642 snd_env_head(env,JS_DIC_USE);
2643 JS_Put4Com(dic_no, env->js_id);
2644 JS_Put4Com(flag, env->js_id);
2645 snd_flush(env->js_id);
2646 x=get4com(env->js_id);
2647 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2648
2649 return x;
2650 }
2651
2652 /** js_fuzokugo_set **/
2653 int
js_fuzokugo_set(env,fid)2654 js_fuzokugo_set(env,fid)
2655 struct wnn_env *env;
2656 int fid;
2657 {
2658 register int x;
2659 if(env==0) return(-1);
2660 set_current_js(env->js_id);
2661
2662 handler_of_jserver_dead_env(env);
2663 if(env_wnn_errorno_eql) {
2664
2665 return(-1);
2666 }
2667 snd_env_head(env,JS_FUZOKUGO_SET);
2668 JS_Put4Com(fid, env->js_id);
2669 snd_flush(env->js_id);
2670 x=get4com(env->js_id);
2671 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2672
2673 return x;
2674 }
2675
2676 /** js_fuzokugo_get **/
2677 int
js_fuzokugo_get(env)2678 js_fuzokugo_get(env)
2679 struct wnn_env *env;
2680 {
2681 register int x;
2682 if(env==0) return(-1);
2683 set_current_js(env->js_id);
2684
2685 handler_of_jserver_dead_env(env);
2686 if(env_wnn_errorno_eql) {
2687
2688 return(-1);
2689 }
2690 snd_env_head(env,JS_FUZOKUGO_GET);
2691 snd_flush(env->js_id);
2692 x=get4com(env->js_id);
2693 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
2694
2695 return x;
2696 }
2697
2698 static int rcv_dic_list();
2699 static void get_dic_info();
2700
2701 /*:::DOC_START
2702 *
2703 * Function Name: js_dic_list_all
2704 * Description : ���ꤵ�줿�����Ф����Ķ�����Ͽ����Ƥ���ף����
2705 * ������֤�
2706 * Parameter :
2707 * server : (In) �����ФؤΥݥ���
2708 * ret : (Out) �ǡ�����������ѹ�¤�ΤؤΥݥ���
2709 *
2710 * Return value : -1==ERROR, else ��Ͽ�����
2711 *
2712 * Revision history:
2713 *
2714 *:::DOC_END
2715 */
2716 int
js_dic_list_all(server,ret)2717 js_dic_list_all(server,ret)
2718 WNN_JSERVER_ID *server;
2719 struct wnn_ret_buf *ret;
2720 {
2721 int x;
2722
2723 set_current_js(server);
2724
2725 handler_of_jserver_dead(server);
2726 if(js_wnn_errorno_eql) {
2727
2728 return(-1);
2729 }
2730 snd_server_head(server,JS_DIC_LIST_ALL);
2731 snd_flush(server);
2732 x = rcv_dic_list(ret, server);
2733
2734 return x;
2735 } /* End of js_dic_list_all */
2736
2737 /*:::DOC_START
2738 *
2739 * Function Name: js_dic_list
2740 * Description : ���ꤵ�줿�Ķ�����Ͽ����Ƥ���ף���ξ�����֤�
2741 * Parameter :
2742 * env : (In) �Ķ��ؤΥݥ���
2743 * ret : (Out) �ǡ�����������ѹ�¤�ΤؤΥݥ���
2744 *
2745 * Return value : -1==ERROR, else ��Ͽ�����
2746 *
2747 * Revision history:
2748 *
2749 *:::DOC_END
2750 */
2751 int
js_dic_list(env,ret)2752 js_dic_list(env,ret)
2753 struct wnn_env *env;
2754 struct wnn_ret_buf *ret;
2755 {
2756 int x;
2757
2758 if(env==0) return(-1);
2759 set_current_js(env->js_id);
2760
2761 handler_of_jserver_dead_env(env);
2762 if(env_wnn_errorno_eql) {
2763
2764 return(-1);
2765 }
2766 snd_env_head(env,JS_DIC_LIST);
2767 snd_flush(env->js_id);
2768 x = rcv_dic_list(ret, env->js_id);
2769
2770 return x;
2771 } /* End of js_dic_list */
2772
2773 /*:::DOC_START
2774 *
2775 * Function Name: js_fi_dic_list_all
2776 * Description : ���ꤵ�줿�����Ф����Ķ�����Ͽ����Ƥ��뼭����⡢
2777 * ���ꤵ�줿���ξ�����֤�
2778 * Parameter :
2779 * server : (In) �����ФؤΥݥ���
2780 * dmask : (In) ��������ޥ���
2781 * ret : (Out) �ǡ�����������ѹ�¤�ΤؤΥݥ���
2782 *
2783 * Return value : -1==ERROR, else ��Ͽ�����
2784 *
2785 * Revision history:
2786 *
2787 *:::DOC_END
2788 */
2789 int
js_fi_dic_list_all(server,dmask,ret)2790 js_fi_dic_list_all(server, dmask, ret)
2791 WNN_JSERVER_ID *server;
2792 unsigned long dmask;
2793 struct wnn_ret_buf *ret;
2794 {
2795 int x;
2796
2797 set_current_js(server);
2798
2799 /* �����Ф� FI-Wnn ������ΥС������ʤ顢����� dic_list ̿������� */
2800 if(!CHECK_FI) return(js_dic_list_all(server, ret));
2801
2802
2803 handler_of_jserver_dead(server);
2804 if(js_wnn_errorno_eql) {
2805
2806 return(-1);
2807 }
2808 snd_server_head(server,JS_FI_DIC_LIST_ALL);
2809 JS_Put4Com(dmask, server);
2810 snd_flush(server);
2811 x = rcv_dic_list(ret, server);
2812
2813 return x;
2814 } /* End of js_fi_dic_list_all */
2815
2816 /*:::DOC_START
2817 *
2818 * Function Name: js_fi_dic_list
2819 * Description : ���ꤵ�줿�Ķ�����Ͽ����Ƥ��뼭����⡢
2820 * ���ꤵ�줿���ξ�����֤�
2821 * Parameter :
2822 * env : (In) �Ķ��ؤΥݥ���
2823 * dmask : (In) ��������ޥ���
2824 * ret : (Out) �ǡ�����������ѹ�¤�ΤؤΥݥ���
2825 *
2826 * Return value : -1==ERROR, else ��Ͽ�����
2827 *
2828 * Revision history:
2829 *
2830 *:::DOC_END
2831 */
2832 int
js_fi_dic_list(env,dmask,ret)2833 js_fi_dic_list(env, dmask, ret)
2834 struct wnn_env *env;
2835 unsigned long dmask;
2836 struct wnn_ret_buf *ret;
2837 {
2838 int x;
2839
2840 if(env==0) return(-1);
2841 set_current_js(env->js_id);
2842
2843 /* �����Ф� FI-Wnn ������ΥС������ʤ顢����� dic_list ̿������� */
2844 if(!CHECK_FI) return(js_dic_list(env, ret));
2845
2846
2847 handler_of_jserver_dead_env(env);
2848 if(env_wnn_errorno_eql) {
2849
2850 return(-1);
2851 }
2852 snd_env_head(env,JS_FI_DIC_LIST);
2853 JS_Put4Com(dmask, env->js_id);
2854 snd_flush(env->js_id);
2855 x = rcv_dic_list(ret, env->js_id);
2856
2857 return x;
2858 } /* End of js_fi_dic_list */
2859
2860 /*:::DOC_START
2861 *
2862 * Function Name: rcv_dic_list
2863 * Description : ��������������ѹ�¤�Τ��ΰ����ݤ���
2864 * Parameter :
2865 * ret : (Out) �ǡ�����������ѹ�¤�ΤؤΥݥ���
2866 * server : (In) �����ФؤΥݥ���
2867 *
2868 * Return value : -1==ERROR, else ��Ͽ�����
2869 *
2870 * Revision history:
2871 *
2872 *:::DOC_END
2873 */
2874 static int
rcv_dic_list(ret,server)2875 rcv_dic_list(ret, server)
2876 struct wnn_ret_buf *ret;
2877 ARGS *server;
2878 {
2879 register int i,count;
2880 register WNN_DIC_INFO *dic;
2881 if((count=get4com(server)) == -1) {
2882 js_wnn_errorno_set = get4com(server);
2883 return(-1);
2884 }
2885 re_alloc(ret, sizeof(WNN_DIC_INFO)*(count + 1));
2886
2887 dic=(WNN_DIC_INFO *)ret->buf;
2888 for(i=0;i<count;i++){
2889 get_dic_info(dic, server);
2890 dic++;
2891 }
2892 dic->dic_no = -1;
2893 return count;
2894 } /* End of rcv_dic_list */
2895
2896 /*:::DOC_START
2897 *
2898 * Function Name: get_dic_info
2899 * Description : ������������������
2900 * Parameter :
2901 * dic : (Out) ��������������ѹ�¤�ΤؤΥݥ���
2902 * server : (In) �����ФؤΥݥ���
2903 *
2904 * Return value : -1==ERROR, else ��Ͽ�����
2905 *
2906 * Revision history:
2907 *
2908 *:::DOC_END
2909 */
2910 static void
get_dic_info(dic,server)2911 get_dic_info(dic, server)
2912 register WNN_DIC_INFO *dic;
2913 ARGS *server;
2914 {
2915 dic->dic_no =get4com(server); /* dic_No */
2916 dic->body =get4com(server); /* body fid */
2917 dic->hindo =get4com(server); /* hindo fid */
2918 dic->rw =get4com(server); /* r/w */
2919 dic->hindo_rw =get4com(server); /* hindo r/w */
2920 dic->enablef =get4com(server); /* enable/disable */
2921 dic->nice =get4com(server); /* nice */
2922 dic->rev = get4com(server);
2923 /* added H.T */
2924 getwscom(dic->comment, server, WNN_COMMENT_LEN);
2925 getscom(dic->fname, server, WNN_F_NAMELEN);
2926 getscom(dic->hfname, server, WNN_F_NAMELEN);
2927 getscom(dic->passwd, server, WNN_PASSWD_LEN);
2928 getscom(dic->hpasswd, server, WNN_PASSWD_LEN);
2929 dic->type = get4com(server);
2930 dic->gosuu = get4com(server);
2931 dic->localf = get4com(server);
2932 dic->hlocalf = get4com(server);
2933 } /* End of get_dic_info */
2934
2935 /*:::DOC_START
2936 *
2937 * Function Name: rcv_fzk_list
2938 * Description : ��°������������ѹ�¤�Τ��ΰ����ݤ���
2939 * ������������������
2940 * Parameter :
2941 * curfzk : (Out) �����ѥե����뼱�̻�
2942 * ret : (Out) ��°������������ѹ�¤�ΤؤΥݥ���
2943 * server : (In) �����ФؤΥݥ���
2944 *
2945 * Return value : -1==ERROR, else �ɹ�����°���
2946 *
2947 * Revision history:
2948 *
2949 *:::DOC_END
2950 */
2951 static int
rcv_fzk_list(curfzk,ret,server)2952 rcv_fzk_list(curfzk, ret, server)
2953 int *curfzk;
2954 WNN_FZK_INFO **ret;
2955 ARGS *server;
2956 {
2957 register int i, count;
2958 register WNN_FZK_INFO *fzk;
2959
2960 /* �ɹ�����°����������ѥե����뼱�̻Ҥ������� */
2961 if((count = get4com(server)) == -1) {
2962 js_wnn_errorno_set = get4com(server);
2963 return(-1);
2964 }
2965 *curfzk = get4com(server);
2966
2967 /* �����������ѹ�¤�Τ��ΰ����ݤ��� */
2968 if(((*ret) = (WNN_FZK_INFO *)malloc((count + 1) *
2969 sizeof(WNN_FZK_INFO))) == NULL) {
2970 WNN_FZK_INFO dummy;
2971 for(i = 0; i < count; i++){
2972 getwscom(dummy.comment, server, WNN_COMMENT_LEN);
2973 getscom(dummy.fname, server, WNN_F_NAMELEN);
2974 }
2975 js_wnn_errorno_set = WNN_ALLOC_FAIL;
2976 return(-1);
2977 }
2978 fzk = (WNN_FZK_INFO *)*ret;
2979
2980 /* ��°������������ */
2981 for(i = 0; i < count; i++){
2982 getwscom(fzk->comment, server, WNN_COMMENT_LEN);
2983 getscom(fzk->fname, server, WNN_F_NAMELEN);
2984 fzk++;
2985 }
2986
2987 fzk->fname[0] = 0;
2988 return count;
2989 } /* End of rcv_fzk_list */
2990
2991 /*:::DOC_START
2992 *
2993 * Function Name: js_fuzokugo_list
2994 * Description : ���ꤵ�줿�����Ф��ɤ߹��ޤ�Ƥ�������°������
2995 * �Ķ��˸������ꤵ��Ƥ������μ��̻Ҥ��֤�
2996 * Parameter :
2997 * env : (In) �Ķ��ؤΥݥ���
2998 * curfzk : (Out) �����ѥե����뼱�̻�
2999 * ret : (Out) ��°������������ѹ�¤�ΤؤΥݥ���
3000 *
3001 * Return value : -1==ERROR, else �ɹ�����°���
3002 *
3003 * Revision history:
3004 *
3005 *:::DOC_END
3006 */
3007 int
js_fuzokugo_list(env,curfzk,ret)3008 js_fuzokugo_list(env, curfzk, ret)
3009 struct wnn_env *env;
3010 int *curfzk;
3011 WNN_FZK_INFO **ret;
3012 {
3013 register int x;
3014
3015 if(env==0) return(-1);
3016 set_current_js(env->js_id);
3017
3018 handler_of_jserver_dead_env(env);
3019 if(env_wnn_errorno_eql) {
3020
3021 return(-1);
3022 }
3023 snd_env_head(env,JS_FUZOKUGO_LIST);
3024 snd_flush(env->js_id);
3025 x = rcv_fzk_list(curfzk, ret, env->js_id);
3026
3027 return x;
3028 } /* End of js_fuzokugo_list */
3029
3030 /*** Dic. Operation by dic_No. ***/
3031
3032 /** js_word_add **/
3033 int
js_word_add(env,dic_no,yomi,kanji,comment,hinshi,init_hindo)3034 js_word_add(env,dic_no,yomi,kanji,comment,hinshi,init_hindo)
3035 struct wnn_env *env;
3036 int dic_no;
3037 w_char *yomi,*kanji,*comment;
3038 int hinshi,init_hindo;
3039 {
3040 register int x;
3041 if(env==0) return(-1);
3042 set_current_js(env->js_id);
3043
3044 handler_of_jserver_dead_env(env);
3045 if(env_wnn_errorno_eql) {
3046
3047 return(-1);
3048 }
3049 snd_env_head(env,JS_WORD_ADD);
3050 JS_Put4Com(dic_no, env->js_id);
3051 putwscom(yomi, env->js_id);
3052 putwscom(kanji, env->js_id);
3053 putwscom(comment, env->js_id);
3054 JS_Put4Com(hinshi, env->js_id);
3055 JS_Put4Com(init_hindo, env->js_id);
3056 snd_flush(env->js_id);
3057 x=get4com(env->js_id);
3058 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
3059
3060 return x;
3061 }
3062
3063 /** js_word_delete **/
3064 int
js_word_delete(env,dic_no,entry)3065 js_word_delete(env,dic_no,entry)
3066 struct wnn_env *env;
3067 int dic_no;
3068 int entry;
3069 {
3070 register int x;
3071 if(env==0) return(-1);
3072 set_current_js(env->js_id);
3073
3074 handler_of_jserver_dead_env(env);
3075 if(env_wnn_errorno_eql) {
3076
3077 return(-1);
3078 }
3079 snd_env_head(env,JS_WORD_DELETE);
3080 JS_Put4Com(dic_no, env->js_id);
3081 JS_Put4Com(entry, env->js_id);
3082 snd_flush(env->js_id);
3083 x=get4com(env->js_id);
3084 if(x==-1)env_wnn_errorno_set= get4com(env->js_id);
3085
3086 return x;
3087 }
3088
3089
3090 /** js_word_search **/
3091 static int rcv_word_data();
3092
3093 int
js_word_search(env,dic_no,yomi,ret)3094 js_word_search(env,dic_no,yomi,ret)
3095 struct wnn_env *env;
3096 int dic_no;
3097 w_char *yomi;
3098 struct wnn_ret_buf *ret;
3099 {
3100 int x;
3101
3102 if(env==0) return(-1);
3103 set_current_js(env->js_id);
3104
3105 handler_of_jserver_dead_env(env);
3106 if(env_wnn_errorno_eql) {
3107
3108 return(-1);
3109 }
3110 snd_env_head(env,JS_WORD_SEARCH);
3111 JS_Put4Com(dic_no, env->js_id);
3112 putwscom(yomi, env->js_id);
3113 snd_flush(env->js_id);
3114 x = rcv_word_data(ret, yomi, env->js_id);
3115
3116 return x;
3117 }
3118
3119 /** js_word_search_by_env **/
3120 int
js_word_search_by_env(env,yomi,ret)3121 js_word_search_by_env(env,yomi,ret)
3122 struct wnn_env *env;
3123 w_char *yomi;
3124 struct wnn_ret_buf *ret;
3125 {
3126 int x;
3127
3128 if(env==0) return(-1);
3129 set_current_js(env->js_id);
3130
3131 handler_of_jserver_dead_env(env);
3132 if(env_wnn_errorno_eql) {
3133
3134 return(-1);
3135 }
3136 snd_env_head(env,JS_WORD_SEARCH_BY_ENV);
3137 putwscom(yomi, env->js_id);
3138 snd_flush(env->js_id);
3139 x = rcv_word_data(ret, yomi, env->js_id);
3140
3141 return x;
3142 }
3143
3144 /** js_word_info **/
3145 int
js_word_info(env,dic_no,entry,ret)3146 js_word_info(env,dic_no,entry,ret)
3147 struct wnn_env *env;
3148 int dic_no,entry;
3149 struct wnn_ret_buf *ret;
3150 {
3151 register int x;
3152 w_char yomi[LENGTHYOMI];
3153
3154 if(env==0) return(-1);
3155 set_current_js(env->js_id);
3156
3157 handler_of_jserver_dead_env(env);
3158 if(env_wnn_errorno_eql) {
3159
3160 return(-1);
3161 }
3162 snd_env_head(env,JS_WORD_INFO);
3163 JS_Put4Com(dic_no, env->js_id);
3164 JS_Put4Com(entry, env->js_id);
3165 snd_flush(env->js_id);
3166 x=get4com(env->js_id);
3167 if(x==-1){
3168 env_wnn_errorno_set= get4com(env->js_id);
3169
3170 return(-1);
3171 }
3172 getwscom(yomi, env->js_id, sizeof(yomi) / sizeof(w_char));
3173 rcv_word_data(ret, yomi, env->js_id);
3174
3175 return(0);
3176 }
3177
3178 int
js_word_comment_set(env,dic_no,entry,comment)3179 js_word_comment_set(env, dic_no, entry, comment)
3180 struct wnn_env *env;
3181 int dic_no,entry;
3182 w_char *comment;
3183 {
3184 register int x;
3185 if(env==0) return(-1);
3186 set_current_js(env->js_id);
3187
3188 handler_of_jserver_dead_env(env);
3189 if(env_wnn_errorno_eql) {
3190
3191 return(-1);
3192 }
3193 snd_env_head(env,JS_WORD_COMMENT_SET);
3194 JS_Put4Com(dic_no, env->js_id);
3195 JS_Put4Com(entry, env->js_id);
3196 putwscom(comment, env->js_id);
3197 snd_flush(env->js_id);
3198 x=get4com(env->js_id);
3199 if(x==-1){
3200 env_wnn_errorno_set= get4com(env->js_id);
3201
3202 return(-1);
3203 }
3204
3205 return(0);
3206 }
3207
3208 /** rcv for word_search **/
3209 static int
rcv_word_data(ret,yomi,server)3210 rcv_word_data(ret, yomi, server)
3211 struct wnn_ret_buf *ret;
3212 w_char *yomi; /* Yomi is not sent from server
3213 * (at least for the time being).
3214 */
3215 ARGS *server;
3216 {
3217 register int x, j_c,k_c, databytes, wlen;
3218 w_char *k;
3219 w_char wbuf[LENGTHKANJI];
3220 register struct wnn_jdata *jd;
3221 register int cnt, error_flag;
3222
3223 j_c = get4com(server);
3224 k_c = get4com(server);
3225 databytes = sizeof(w_char)*(k_c + j_c * 3 + j_c * wnn_Strlen(yomi));
3226 re_alloc(ret, sizeof(struct wnn_jdata)*(j_c + 1) + databytes);
3227 jd=(struct wnn_jdata *)ret->buf;
3228 for(cnt = 0;;cnt++){
3229 jd->dic_no = x = get4com(server);
3230 if(x==-1) break;
3231 jd->serial = get4com(server);
3232 jd->hinshi = get4com(server);
3233 jd->hindo = get4com(server);
3234 jd->ima = get4com(server);
3235 jd->int_hindo = get4com(server);
3236 jd->int_ima = get4com(server);
3237 jd++;
3238 }
3239 jd++;
3240 k= (w_char *)jd;
3241 jd=(struct wnn_jdata *)ret->buf;
3242 error_flag = 0;
3243 for(;;){
3244 if(jd->dic_no==-1) break;
3245
3246 if (!error_flag) {
3247 wlen = wnn_Strlen(yomi) + 1;
3248 if ((wlen * sizeof(w_char)) > databytes) {
3249 error_flag = 1;
3250 } else {
3251 jd->yomi = k; /* Copy Yomi */
3252 wnn_Strcpy(k, yomi);
3253 k+= wlen;
3254 databytes -= (wlen * sizeof(w_char));
3255 }
3256 }
3257
3258 getwscom(wbuf, server, sizeof(wbuf) / sizeof(w_char));
3259 if (!error_flag) {
3260 wlen = wnn_Strlen(wbuf) + 1;
3261 if ((wlen * sizeof(w_char)) > databytes) {
3262 error_flag = 1;
3263 } else {
3264 jd->kanji = k; /* Get Kanji */
3265 wnn_Strcpy(k, wbuf);
3266 k+= wlen;
3267 databytes -= (wlen * sizeof(w_char));
3268 }
3269 }
3270
3271 getwscom(wbuf, server, sizeof(wbuf) / sizeof(w_char));
3272 if (!error_flag) {
3273 wlen = wnn_Strlen(wbuf) + 1;
3274 if ((wlen * sizeof(w_char)) > databytes) {
3275 error_flag = 1;
3276 } else {
3277 jd->com = k; /* Get Comment */
3278 wnn_Strcpy(k, wbuf);
3279 k+= wlen;
3280 databytes -= (wlen * sizeof(w_char));
3281 }
3282 }
3283 jd++;
3284 }
3285 return cnt;
3286 }
3287
3288
3289 /** js_dic_info **/
3290 int
js_dic_info(env,dic_no,ret)3291 js_dic_info(env,dic_no,ret)
3292 struct wnn_env *env;
3293 int dic_no;
3294 register WNN_DIC_INFO *ret;
3295 {
3296 register int x;
3297 if(env==0) return(-1);
3298 set_current_js(env->js_id);
3299
3300 handler_of_jserver_dead_env(env);
3301 if(env_wnn_errorno_eql) {
3302
3303 return(-1);
3304 }
3305 snd_env_head(env,JS_DIC_INFO);
3306 JS_Put4Com(dic_no, env->js_id);
3307 snd_flush(env->js_id);
3308 x=get4com(env->js_id);
3309 if(x==-1){
3310 env_wnn_errorno_set = get4com(env->js_id);
3311
3312 return x;
3313 }
3314 get_dic_info(ret, env->js_id);
3315
3316 return dic_no;
3317 }
3318
3319 /** js_who **/
3320 int
js_who(server,ret)3321 js_who(server,ret)
3322 WNN_JSERVER_ID *server;
3323 struct wnn_ret_buf *ret;
3324 {
3325 register int i,j,c;
3326 WNN_JWHO *w;
3327 set_current_js(server);
3328
3329 handler_of_jserver_dead(server);
3330 if(js_wnn_errorno_eql) {
3331
3332 return(-1);
3333 }
3334 snd_server_head(server,JS_WHO);
3335 snd_flush(server);
3336
3337 c=get4com(server);
3338 if(c==-1){
3339 js_wnn_errorno_set= get4com(server);
3340
3341 return -1;
3342 }
3343
3344 re_alloc(ret, sizeof(WNN_JWHO)*c);
3345 w=(WNN_JWHO *)ret->buf;
3346 for(i=0;i<c;i++){
3347 w->sd=get4com(server);
3348 getscom(w->user_name, server, sizeof(w->user_name));
3349 getscom(w->host_name, server, sizeof(w->host_name));
3350 for(j=0;j<WNN_MAX_ENV_OF_A_CLIENT;j++){
3351 (w->env)[j]=get4com(server);
3352 }
3353 w++;
3354 }
3355
3356 return(c);
3357 }
3358
3359 /** jserver ������ƤδĶ��˴ؤ����������롣
3360 (���鵻)
3361 **/
3362 int
js_env_list(server,ret)3363 js_env_list(server,ret)
3364 WNN_JSERVER_ID *server;
3365 struct wnn_ret_buf *ret;
3366 {
3367 register int i,j,c;
3368 WNN_ENV_INFO *w;
3369 set_current_js(server);
3370
3371 handler_of_jserver_dead(server);
3372 if(js_wnn_errorno_eql) {
3373
3374 return(-1);
3375 }
3376 snd_server_head(server,JS_ENV_LIST);
3377 snd_flush(server);
3378
3379 c=get4com(server);
3380 if(c==-1){
3381 js_wnn_errorno_set= get4com(server);
3382
3383 return -1;
3384 }
3385
3386 re_alloc(ret, sizeof(WNN_ENV_INFO)*c);
3387 w=(WNN_ENV_INFO *)ret->buf;
3388 for(i=0;i<c;i++){
3389 w->env_id = get4com(server);
3390 getscom(w->env_name, server, WNN_ENVNAME_LEN);
3391 w->ref_count=get4com(server);
3392 w->fzk_fid=get4com(server);
3393 w->jishomax=get4com(server);
3394 for(j=0;j<WNN_MAX_JISHO_OF_AN_ENV;j++){
3395 (w->jisho)[j]= get4com(server);
3396 }
3397 for(j=0;j<WNN_MAX_FILE_OF_AN_ENV;j++){
3398 (w->file)[j]= get4com(server);
3399 }
3400 w++;
3401 }
3402
3403 return(c);
3404 }
3405
3406 /****
3407
3408 ****/
3409 /*:::DOC_START
3410 *
3411 * Function Name: js_hindo_set
3412 * Description : ���ꤵ�줿����κ��ӥåȡ����٤����ꤹ��
3413 * Parameter :
3414 * env : (In) �Ķ��ؤΥݥ���
3415 * dic : (In) ���䤬��Ͽ����Ƥ��뼭���ֹ�
3416 * entry : (In) ����Υ���ȥ��ֹ�
3417 * ima : (In) ���ӥåȤ�������ˡ�ե饰
3418 * hindo : (In) ���٤�������ˡ�ե饰
3419 *
3420 * Return value : 0==SUCCESS, -1==ERROR
3421 *
3422 * Revision history:
3423 *
3424 *:::DOC_END
3425 */
3426 int
js_hindo_set(env,dic,entry,ima,hindo)3427 js_hindo_set(env,dic,entry,ima,hindo)
3428 struct wnn_env *env;
3429 int dic, entry, ima,hindo;
3430 {
3431 register int x;
3432 if(env==0) return(-1);
3433 set_current_js(env->js_id);
3434
3435 handler_of_jserver_dead_env(env);
3436 if(env_wnn_errorno_eql) {
3437
3438 return(-1);
3439 }
3440 snd_env_head(env,JS_HINDO_SET);
3441
3442 JS_Put4Com(dic, env->js_id);
3443 JS_Put4Com(entry, env->js_id);
3444 JS_Put4Com(ima, env->js_id);
3445 JS_Put4Com(hindo, env->js_id);
3446 snd_flush(env->js_id);
3447 if((x=get4com(env->js_id))==-1){
3448 env_wnn_errorno_set= get4com(env->js_id);
3449
3450 }
3451
3452 return x;
3453 } /* End of js_hindo_set */
3454
3455 /*:::DOC_START
3456 *
3457 * Function Name: js_set_fi_priority
3458 * Description : ����ƣɴط��ǡ����Σƣɴط���³���ӥåȤ�
3459 * �ƣɴط���³���٤����ꤹ��
3460 * Parameter :
3461 * env : (In) �Ķ��ؤΥݥ���
3462 * fi_rel_entry : (In) ���ѣƣɴط������ѹ�¤�ΤؤΥݥ���
3463 *
3464 * Return value : 0==SUCCESS, -1==ERROR
3465 *
3466 * Revision history:
3467 *
3468 *:::DOC_END
3469 */
3470 int
js_set_fi_priority(env,fi_rel_entry)3471 js_set_fi_priority(env, fi_rel_entry)
3472 struct wnn_env *env;
3473 struct wnn_fi_rel_buf *fi_rel_entry;
3474 {
3475 register int x;
3476
3477 if(env==0) return(-1);
3478 set_current_js(env->js_id);
3479
3480 /* �����Ф��ƣɳؽ��ݡ��Ȥ��Ƥ��ʤ����ϲ��⤷�ʤ� */
3481 if(!CHECK_FI) return(0);
3482
3483
3484 handler_of_jserver_dead_env(env);
3485 if(env_wnn_errorno_eql) {
3486
3487 return(-1);
3488 }
3489 snd_env_head(env,JS_SET_FI_PRIORITY);
3490
3491 JS_Put4Com(fi_rel_entry->num, env->js_id);
3492 for(x = 0; x < fi_rel_entry->num; x++) {
3493 JS_Put4Com(fi_rel_entry->fi_buf[x].fi_dic_no, env->js_id);
3494 JS_Put4Com(fi_rel_entry->fi_buf[x].dic_no, env->js_id);
3495 JS_Put4Com(fi_rel_entry->fi_buf[x].entry, env->js_id);
3496 JS_Put4Com(fi_rel_entry->fi_buf[x].offset, env->js_id);
3497 JS_Put4Com(fi_rel_entry->fi_buf[x].fi_hindo, env->js_id);
3498 JS_Put4Com(fi_rel_entry->fi_buf[x].fi_ima, env->js_id);
3499 }
3500 snd_flush(env->js_id);
3501
3502 if((x = get4com(env->js_id)) == -1) {
3503 env_wnn_errorno_set= get4com(env->js_id);
3504
3505 }
3506
3507 return x;
3508 } /* End of js_set_fi_priority */
3509
3510 /*:::DOC_START
3511 *
3512 * Function Name: js_optimize_fi
3513 * Description : ���ꤵ�줿������κ��ӥåȡ����٤����ꤷ���Ƴؽ�����
3514 * ����Ƭ�졦�����ࡦ���Ѹ졦�����졦�ƣɡˤ�Ԥ�
3515 * Parameter :
3516 * env : (In) �Ķ��ؤΥݥ���
3517 * nkouho : (In) ��������
3518 * dic : (In) ���䤬��Ͽ����Ƥ��뼭���ֹ�����ؤΥݥ���
3519 * entry (In) ����Υ���ȥ��ֹ�����ؤΥݥ���
3520 * ima : (In) ���ӥåȤ�������ˡ�ե饰����ؤΥݥ���
3521 * hindo : (In) ���٤�������ˡ�ե饰����ؤΥݥ���
3522 * kmoji : (In) ����ʸ��������°��ʤ�������ؤΥݥ���
3523 * kouho : (In) ����ʸ�������°�줢�������ؤΥݥ���
3524 *
3525 * Return value : 0==SUCCESS, -1==ERROR
3526 *
3527 * Revision history:
3528 *
3529 *:::DOC_END
3530 */
3531 int
js_optimize_fi(env,nkouho,dic,entry,ima,hindo,kmoji,kouho)3532 js_optimize_fi(env,nkouho,dic,entry,ima,hindo,kmoji,kouho)
3533 struct wnn_env *env;
3534 int nkouho, *dic, *entry, *ima, *hindo, *kmoji;
3535 w_char **kouho;
3536 {
3537 register int x, i;
3538
3539 x = 0;
3540 if(env==0) return(-1);
3541 set_current_js(env->js_id);
3542
3543 /* �����Ф��ƣɳؽ��ݡ��Ȥ��Ƥ��ʤ����ϡ�
3544 �������������ץ�ȥ����������������� */
3545 if(!CHECK_FI) {
3546 for(i = 0; i < nkouho; i++) {
3547 x = js_hindo_set(env, dic[i], entry[i], ima[i], hindo[i]);
3548 if(x == -1) return(-1);
3549 }
3550 return(x);
3551 }
3552
3553
3554 handler_of_jserver_dead_env(env);
3555 if(env_wnn_errorno_eql) {
3556
3557 return(-1);
3558 }
3559 snd_env_head(env,JS_OPTIMIZE_FI);
3560
3561 JS_Put4Com(nkouho, env->js_id);
3562 for(x = 0; x < nkouho; x++) {
3563 JS_Put4Com(dic[x], env->js_id);
3564 JS_Put4Com(entry[x], env->js_id);
3565 JS_Put4Com(ima[x], env->js_id);
3566 JS_Put4Com(hindo[x], env->js_id);
3567 JS_Put4Com(kmoji[x], env->js_id);
3568 putwscom(kouho[x], env->js_id);
3569 }
3570 snd_flush(env->js_id);
3571
3572 if((x = get4com(env->js_id)) == -1) {
3573 env_wnn_errorno_set= get4com(env->js_id);
3574
3575 }
3576
3577 return x;
3578 } /* End of js_optimize_fi */
3579
3580
3581 /****
3582 Henkan
3583 ****/
3584
3585 static void
put_fzk_vec(hinsi,fzk,vec,vec1,server)3586 put_fzk_vec(hinsi,fzk,vec,vec1, server)
3587 int hinsi;
3588 w_char *fzk;
3589 int vec;
3590 int vec1;
3591 ARGS *server;
3592 {
3593 JS_Put4Com(hinsi, server);
3594 putwscom(fzk, server);
3595 JS_Put4Com(vec, server);
3596 JS_Put4Com(vec1, server);
3597 }
3598
3599 /**
3600 kanren
3601 **/
3602 static int rcv_dai(), rcv_fi_rel_data();
3603 static void rcv_sho_x();
3604 static void rcv_sho_kanji();
3605
3606 int
js_kanren(env,yomi,hinsi,fzk,vec,vec1,vec2,rb)3607 js_kanren(env,yomi,hinsi,fzk,vec,vec1,vec2,rb)
3608 struct wnn_env *env;
3609 w_char *yomi;
3610 int hinsi;
3611 w_char *fzk;
3612 int vec;
3613 int vec1;
3614 int vec2;
3615 struct wnn_ret_buf *rb;
3616 {
3617 int x;
3618
3619 if(env==0) return(-1);
3620 set_current_js(env->js_id);
3621
3622 handler_of_jserver_dead_env(env);
3623 if(env_wnn_errorno_eql) {
3624
3625 return(-1);
3626 }
3627 snd_env_head(env,JS_KANREN);
3628 putwscom(yomi, env->js_id);
3629 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
3630 JS_Put4Com(vec2, env->js_id);
3631 snd_flush(env->js_id);
3632 x = rcv_dai(rb, env->js_id);
3633
3634 return x;
3635 }
3636
3637 /*:::DOC_START
3638 *
3639 * Function Name: js_fi_kanren
3640 * Description : Ϣʸ��ƣ��Ѵ���Ԥ�����̤�������
3641 * Parameter :
3642 * env : (In) �Ķ��ؤΥݥ���
3643 * yomi: (In) �Ѵ��ɤ�ʸ����ؤΥݥ���
3644 * hinsi (In) ����ʸ����ʻ��ֹ�
3645 * fzk : (In) ����ʸ�����°��ʸ����ؤΥݥ���
3646 * vec : (In) ��ü�٥��ȥ룱
3647 * vec1 : (In) ��ü�٥��ȥ룲
3648 * vec2 : (In) Ϣʸ���Ѵ��������ʸ��ν�ü�٥��ȥ�
3649 * prev : (In) ľ������ʸ�����¤�ΤؤΥݥ���
3650 * rb : (Out) �Ѵ���������ѹ�¤�ΤؤΥݥ���
3651 * fi_rb : (Out) ���ѣƣɴط������ѹ�¤�ΤؤΥݥ���
3652 *
3653 * Return value : 0==SUCCESS, -1==ERROR
3654 *
3655 * Revision history:
3656 *
3657 *:::DOC_END
3658 */
3659 int
js_fi_kanren(env,yomi,hinsi,fzk,vec,vec1,vec2,prev,rb,fi_rb)3660 js_fi_kanren(env,yomi,hinsi,fzk,vec,vec1,vec2,prev,rb,fi_rb)
3661 struct wnn_env *env;
3662 w_char *yomi;
3663 int hinsi;
3664 w_char *fzk;
3665 int vec;
3666 int vec1;
3667 int vec2;
3668 struct wnn_prev_bun *prev;
3669 struct wnn_ret_buf *rb;
3670 struct wnn_fi_rel_buf *fi_rb;
3671 {
3672 int x;
3673
3674 if(env==0) return(-1);
3675 set_current_js(env->js_id);
3676
3677 /* �����Ф��ƣ��Ѵ��ݡ��Ȥ��Ƥ��ʤ����ϡ������Ϣʸ�����
3678 �ץ�ȥ�������� */
3679 if(!CHECK_FI) return(js_kanren(env,yomi,hinsi,fzk,vec,vec1,vec2,rb));
3680
3681
3682 handler_of_jserver_dead_env(env);
3683 if(env_wnn_errorno_eql) {
3684
3685 return(-1);
3686 }
3687 snd_env_head(env,JS_FI_KANREN);
3688 putwscom(yomi, env->js_id);
3689 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
3690 JS_Put4Com(vec2, env->js_id);
3691 /* ľ������ʸ����� */
3692 for(x = 0; x < WNN_PREV_BUN_SUU; x++) {
3693 JS_Put4Com(prev[x].dic_no, env->js_id); /* Wnn �����ֹ� */
3694 JS_Put4Com(prev[x].entry, env->js_id); /* ����ȥ��ֹ� */
3695 JS_Put4Com(prev[x].jirilen, env->js_id); /* ��Ω���ɤ�Ĺ */
3696 JS_Put4Com(prev[x].hinsi, env->js_id); /* �ʻ��ֹ� */
3697 putwscom((prev[x].kouho + prev[x].real_kanjilen), env->js_id);
3698 /* ��°��ʸ���� */
3699 }
3700 snd_flush(env->js_id);
3701
3702 /* Ϣʸ��ƣ��Ѵ���̤������� */
3703 x = rcv_dai(rb, env->js_id);
3704 /* ���ѣƣɴط��������� */
3705 if(x != -1) {
3706 if(rcv_fi_rel_data(fi_rb, env->js_id) == -1) x = -1;
3707 }
3708
3709
3710 return x;
3711 } /* End of js_fi_kanren */
3712
3713 /* rcv dai */
3714 static int
rcv_dai(ret,server)3715 rcv_dai(ret, server)
3716 struct wnn_ret_buf *ret;
3717 ARGS *server;
3718 {
3719 int dai_cnt,sho_sum,kanji_sum,d_size,s_size,k_size,x;
3720 register int i;
3721 struct wnn_dai_bunsetsu *dai_list;
3722 register struct wnn_dai_bunsetsu *dp;
3723 struct wnn_sho_bunsetsu *sho_list;
3724 register struct wnn_sho_bunsetsu *sp;
3725 w_char *kanji,*kp;
3726
3727 dai_cnt = get4com(server);
3728 if(dai_cnt == -1){ /* error dayo */
3729 js_wnn_errorno_set = get4com(server);
3730 return -1;
3731 }
3732 sho_sum = get4com(server);
3733 kanji_sum = get4com(server);
3734
3735 d_size=sizeof(struct wnn_dai_bunsetsu)*dai_cnt;
3736 s_size=sizeof(struct wnn_sho_bunsetsu)*sho_sum;
3737 k_size=sizeof(w_char)*kanji_sum;
3738
3739 /* re_alloc(ret, d_size+s_size+k_size); Seems This cause Bug?? H.T.*/
3740 re_alloc(ret, d_size+s_size+k_size);
3741
3742 dai_list = ( struct wnn_dai_bunsetsu *) ret->buf;
3743 sho_list = ( struct wnn_sho_bunsetsu *)((char *)ret->buf + d_size);
3744 kanji = (w_char *)((char *)ret->buf + d_size + s_size);
3745
3746 for(dp = dai_list,i=0; i<dai_cnt; i++){
3747 dp -> end = get4com(server);
3748 dp -> start = get4com(server);
3749 dp -> sbncnt = get4com(server);
3750 dp -> hyoka = get4com(server);
3751 dp++;
3752 }
3753
3754 for(dp = dai_list, sp = sho_list, i=0; i<dai_cnt; i++){
3755 dp -> sbn = sp;
3756 x = dp -> sbncnt;
3757 rcv_sho_x(sp,x, server);
3758 sp += x;
3759 dp++;
3760 }
3761
3762 for(dp=dai_list, kp=kanji, i=0; i<dai_cnt; i++){
3763 rcv_sho_kanji(dp->sbn,dp->sbncnt,&kp,&k_size,server);
3764 dp++;
3765 }
3766 return dai_cnt;
3767 }
3768
3769 /* rcv sho routines */
3770 static void
rcv_sho_x(sho_list,sho_cnt,server)3771 rcv_sho_x(sho_list,sho_cnt, server)
3772 register struct wnn_sho_bunsetsu *sho_list;
3773 int sho_cnt;
3774 ARGS *server;
3775 {
3776 register int i;
3777 for(i=0;i<sho_cnt;i++){
3778 sho_list -> end = get4com(server);
3779 sho_list -> start = get4com(server);
3780 sho_list -> jiriend = get4com(server);
3781 sho_list -> dic_no = get4com(server);
3782 sho_list -> entry = get4com(server);
3783 sho_list -> hindo = get4com(server);
3784 sho_list -> ima = get4com(server);
3785 sho_list -> hinsi = get4com(server);
3786 sho_list -> status = get4com(server);
3787 sho_list -> status_bkwd = get4com(server);
3788 sho_list ->kangovect = get4com(server);
3789 sho_list -> hyoka = get4com(server);
3790 sho_list++;
3791 }
3792 }
3793
3794 static void
rcv_sho_kanji(sho_list,sho_cnt,kanji,kanjibytes,server)3795 rcv_sho_kanji(sho_list,sho_cnt,kanji,kanjibytes,server)
3796 struct wnn_sho_bunsetsu *sho_list;
3797 int sho_cnt;
3798 w_char **kanji;
3799 int *kanjibytes;
3800 ARGS *server;
3801 {
3802 register w_char *k;
3803 register int i, bytes, error_flag, wlen;
3804 w_char wbuf[LENGTHKANJI];
3805
3806 k = *kanji;
3807 bytes = *kanjibytes;
3808 if (bytes <= 0)
3809 error_flag = 1;
3810 else
3811 error_flag = 0;
3812
3813 for(i=0;i<sho_cnt;i++){
3814 getwscom(wbuf, server, sizeof(wbuf) / sizeof(w_char));
3815 if (!error_flag) {
3816 wlen = wnn_Strlen(wbuf) + 1;
3817 if ((wlen * sizeof(w_char)) > bytes) {
3818 error_flag = 1;
3819 } else {
3820 sho_list->kanji = k;
3821 wnn_Strcpy(k, wbuf);
3822 k += wlen;
3823 bytes -= (wlen * sizeof(w_char));
3824 }
3825 }
3826
3827 getwscom(wbuf, server, sizeof(wbuf) / sizeof(w_char));
3828 if (!error_flag) {
3829 wlen = wnn_Strlen(wbuf) + 1;
3830 if ((wlen * sizeof(w_char)) > bytes) {
3831 error_flag = 1;
3832 } else {
3833 sho_list->yomi = k;
3834 wnn_Strcpy(k, wbuf);
3835 k += wlen;
3836 bytes -= (wlen * sizeof(w_char));
3837 }
3838 }
3839
3840 getwscom(wbuf, server, sizeof(wbuf) / sizeof(w_char));
3841 if (!error_flag) {
3842 wlen = wnn_Strlen(wbuf) + 1;
3843 if ((wlen * sizeof(w_char)) > bytes) { /* '>=' �ǤϤʤ� */
3844 error_flag = 1;
3845 } else {
3846 sho_list->fuzoku = k;
3847 wnn_Strcpy(k, wbuf);
3848 k += wlen;
3849 bytes -= (wlen * sizeof(w_char));
3850 }
3851 }
3852 sho_list++;
3853 }
3854 *kanji = k;
3855 *kanjibytes = bytes;
3856 }
3857
3858
3859 static int
rcv_sho(ret,server)3860 rcv_sho(ret, server)
3861 struct wnn_ret_buf *ret;
3862 ARGS *server;
3863 {
3864 int sho_sum,kanji_sum,s_size,k_size;
3865 struct wnn_sho_bunsetsu *sho_list;
3866 w_char *kanji,*kp;
3867
3868 sho_sum = get4com(server);
3869 if(sho_sum == -1){ /* error dayo */
3870 js_wnn_errorno_set = get4com(server);
3871 return -1;
3872 }
3873 kanji_sum = get4com(server);
3874
3875 s_size=sizeof(struct wnn_sho_bunsetsu)*sho_sum;
3876 k_size=sizeof(w_char)*kanji_sum;
3877
3878 re_alloc(ret, s_size+k_size);
3879
3880 sho_list = ( struct wnn_sho_bunsetsu *)((char *)ret->buf);
3881 kanji = (w_char *)((char *)ret->buf + s_size);
3882
3883 rcv_sho_x(sho_list,sho_sum, server);
3884 kp=kanji;
3885 rcv_sho_kanji(sho_list,sho_sum,&kp,&k_size,server);
3886 return sho_sum;
3887 }
3888
3889 /*:::DOC_START
3890 *
3891 * Function Name: rcv_fi_rel_data
3892 * Description : Ϣʸ��ƣ��Ѵ��˻��Ѥ����ƣɴط������������
3893 * Parameter :
3894 * ret : (Out) ���ѣƣɴط������ѹ�¤�ΤؤΥݥ���
3895 * server : (In) �о� jserver ����¤�ΤؤΥݥ���
3896 *
3897 * Return value : 0==SUCCESS, -1==ERROR
3898 *
3899 * Revision history:
3900 *
3901 *:::DOC_END
3902 */
3903 static int
rcv_fi_rel_data(ret,server)3904 rcv_fi_rel_data(ret, server)
3905 struct wnn_fi_rel_buf *ret;
3906 ARGS *server;
3907 {
3908 register int i, fi_num;
3909 struct fi_rel_data *fi_data;
3910
3911 fi_num = get4com(server); /* ���ѣƣɴط��� */
3912 if(fi_num == 0) return(0); /* ���ѣƣɴط����ʤ��ä� */
3913
3914 if(ret->size < ret->num + fi_num) {
3915 /* �����ˣƣɴط��ǡ�����¤���������ݤ��� */
3916 fi_data = (struct fi_rel_data *)
3917 malloc((ret->num + fi_num) * sizeof(struct fi_rel_data));
3918
3919 /* ���˻��Ѥ��Ƥ����ƣɴط��ǡ����ԡ����� */
3920 if(fi_data) {
3921 if(ret->fi_buf) {
3922 memcpy(fi_data, ret->fi_buf, ret->num * sizeof(struct fi_rel_data));
3923 free((char *)ret->fi_buf);
3924 }
3925 }
3926 ret->fi_buf = fi_data;
3927 ret->size = ret->num + fi_num;
3928 }
3929
3930 /* �ƣɴط��ǡ�����¤�������ݤǤ������� */
3931 if(ret->fi_buf == NULL) {
3932 int dummy;
3933 for(i = 0; i < 4 * fi_num; i++) dummy = get4com(server);
3934 js_wnn_errorno_set = WNN_MALLOC_ERR;
3935 return(-1);
3936 }
3937
3938 /* ���ѣƣɴط��ǡ����������� */
3939 fi_data = ret->fi_buf + ret->num;
3940 for(i = 0; i < fi_num; i++, fi_data++) {
3941 fi_data->fi_dic_no = get4com(server);
3942 fi_data->dic_no = get4com(server);
3943 fi_data->entry = get4com(server);
3944 fi_data->offset = get4com(server);
3945 fi_data->fi_hindo = WNN_HINDO_NOP;
3946 fi_data->fi_ima = WNN_IMA_OFF;
3947 }
3948 ret->num = ret->num + fi_num;
3949 return(0);
3950 } /* End of rcv_fi_rel_data */
3951
3952
3953 /**
3954 kantan
3955 **/
3956 int
js_kantan_dai(env,yomi,hinsi,fzk,vec,vec1,rb)3957 js_kantan_dai(env,yomi,hinsi,fzk,vec,vec1,rb)
3958 struct wnn_env *env;
3959 w_char *yomi;
3960 int hinsi;
3961 w_char *fzk;
3962 int vec;
3963 int vec1;
3964 struct wnn_ret_buf *rb;
3965 {
3966 int x;
3967
3968 if(env==0) return(-1);
3969 set_current_js(env->js_id);
3970
3971 handler_of_jserver_dead_env(env);
3972 if(env_wnn_errorno_eql) {
3973
3974 return(-1);
3975 }
3976 snd_env_head(env,JS_KANTAN_DAI);
3977 putwscom(yomi, env->js_id);
3978 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
3979 snd_flush(env->js_id);
3980 x = rcv_dai(rb, env->js_id);
3981
3982 return x;
3983 }
3984
3985 int
js_kantan_sho(env,yomi,hinsi,fzk,vec,vec1,rb)3986 js_kantan_sho(env,yomi,hinsi,fzk,vec,vec1,rb)
3987 struct wnn_env *env;
3988 w_char *yomi;
3989 int hinsi;
3990 w_char *fzk;
3991 int vec;
3992 int vec1;
3993 struct wnn_ret_buf *rb;
3994 {
3995 int sbncnt;
3996 if(env==0) return(-1);
3997 set_current_js(env->js_id);
3998
3999 handler_of_jserver_dead_env(env);
4000 if(env_wnn_errorno_eql) {
4001
4002 return(-1);
4003 }
4004 snd_env_head(env,JS_KANTAN_SHO);
4005 putwscom(yomi, env->js_id);
4006 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
4007 snd_flush(env->js_id);
4008
4009 sbncnt = rcv_sho(rb, env->js_id);
4010
4011 return sbncnt;
4012 }
4013
4014 /**
4015 kanzen
4016 **/
4017 int
js_kanzen_dai(env,yomi,hinsi,fzk,vec,vec1,rb)4018 js_kanzen_dai(env,yomi,hinsi,fzk,vec,vec1,rb)
4019 struct wnn_env *env;
4020 w_char *yomi;
4021 int hinsi;
4022 w_char *fzk;
4023 int vec;
4024 int vec1;
4025 struct wnn_ret_buf *rb;
4026 {
4027 int x;
4028
4029 if(env==0) return(-1);
4030 set_current_js(env->js_id);
4031
4032 handler_of_jserver_dead_env(env);
4033 if(env_wnn_errorno_eql) {
4034
4035 return(-1);
4036 }
4037 snd_env_head(env,JS_KANZEN_DAI);
4038 putwscom(yomi, env->js_id);
4039 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
4040 snd_flush(env->js_id);
4041 x = rcv_dai(rb, env->js_id);
4042
4043 return x;
4044 }
4045
4046
4047 int
js_kanzen_sho(env,yomi,hinsi,fzk,vec,vec1,rb)4048 js_kanzen_sho(env,yomi,hinsi,fzk,vec,vec1,rb)
4049 struct wnn_env *env;
4050 w_char *yomi;
4051 int hinsi;
4052 w_char *fzk;
4053 int vec;
4054 int vec1;
4055 struct wnn_ret_buf *rb;
4056 {
4057 int sbncnt;
4058 if(env==0) return(-1);
4059 set_current_js(env->js_id);
4060
4061 handler_of_jserver_dead_env(env);
4062 if(env_wnn_errorno_eql) {
4063
4064 return(-1);
4065 }
4066 snd_env_head(env,JS_KANZEN_SHO);
4067 putwscom(yomi, env->js_id);
4068 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
4069 snd_flush(env->js_id);
4070
4071 sbncnt = rcv_sho(rb, env->js_id);
4072
4073 return sbncnt;
4074 }
4075
4076 /**
4077 henkan with data
4078 **/
4079 int
js_henkan_with_data(env,fuku,nhinsi,hlist,henkan,yomi,hinsi,fzk,vec,vec1,vec2,rb)4080 js_henkan_with_data(env,fuku,nhinsi,hlist,henkan,yomi,hinsi,fzk,vec,vec1,vec2,rb)
4081 struct wnn_env *env;
4082 int fuku, nhinsi, *hlist, henkan;
4083 w_char *yomi;
4084 int hinsi;
4085 w_char *fzk;
4086 int vec;
4087 int vec1;
4088 int vec2;
4089 struct wnn_ret_buf *rb;
4090 {
4091 int x, i, loop = abs(nhinsi);
4092
4093 if(env==0) return(-1);
4094 set_current_js(env->js_id);
4095
4096 handler_of_jserver_dead_env(env);
4097 if(env_wnn_errorno_eql) {
4098
4099 return(-1);
4100 }
4101 snd_env_head(env,JS_HENKAN_WITH_DATA);
4102 JS_Put4Com(fuku, env->js_id); /* ʣ���ͥ�� */
4103 JS_Put4Com(nhinsi, env->js_id); /* �Ѵ������ʻ�� */
4104 for(i = 0; i < loop; i++)
4105 JS_Put4Com(hlist[i], env->js_id); /* �Ѵ������ʻ��ֹ� */
4106 JS_Put4Com(henkan, env->js_id); /* �Ѵ����� */
4107 putwscom(yomi, env->js_id);
4108 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
4109 JS_Put4Com(vec2, env->js_id);
4110 snd_flush(env->js_id);
4111
4112 switch(henkan) {
4113 case WNN_KANREN:
4114 case WNN_KANTAN_DAI:
4115 case WNN_KANZEN_DAI:
4116 x = rcv_dai(rb, env->js_id);
4117 break;
4118 case WNN_KANTAN_SHO:
4119 case WNN_KANZEN_SHO:
4120 x = rcv_sho(rb, env->js_id);
4121 break;
4122 default:
4123 x = get4com(env->js_id);
4124 env_wnn_errorno_set= get4com(env->js_id);
4125 }
4126
4127 return x;
4128 }
4129
4130 /** js_version **/
4131 int
js_version(server,serv,libv)4132 js_version(server,serv,libv)
4133 int *serv,*libv;
4134 WNN_JSERVER_ID *server;
4135 {
4136 set_current_js(server);
4137
4138 handler_of_jserver_dead(server);
4139 if(js_wnn_errorno_eql) {
4140
4141 return(-1);
4142 }
4143 snd_server_head(server, JS_VERSION);
4144 snd_flush(server);
4145 *libv= JLIB_VERSION;
4146 *serv = get4com(server);
4147
4148 return *serv;
4149 }
4150
4151 static void
re_alloc(ret,size)4152 re_alloc(ret,size)
4153 register struct wnn_ret_buf *ret;
4154 int size;
4155 {
4156 if(ret->size < size){
4157 if(ret->buf)
4158 free((char *)ret->buf);
4159 ret->buf = malloc(size);
4160 ret->size = size;
4161 }
4162 }
4163
4164 int
js_kill(server)4165 js_kill(server)
4166 WNN_JSERVER_ID *server;
4167 {
4168 int x;
4169 set_current_js(server);
4170
4171 handler_of_jserver_dead(server);
4172 if(js_wnn_errorno_eql) {
4173
4174 return(-1);
4175 }
4176 snd_server_head(server, JS_KILL);
4177 snd_flush(server);
4178 x = get4com(server);
4179
4180 return(x);
4181 }
4182
4183 int
js_file_remove(server,n,pwd)4184 js_file_remove(server, n, pwd)
4185 WNN_JSERVER_ID *server;
4186 char *n, *pwd;
4187 {
4188 register int x;
4189 set_current_js(server);
4190
4191 handler_of_jserver_dead(server);
4192 if(js_wnn_errorno_eql) {
4193
4194 return(-1);
4195 }
4196 snd_server_head(server,JS_FILE_REMOVE);
4197 putscom(n, server);
4198 putscom(pwd, server);
4199 snd_flush(server);
4200 if((x=get4com(server))==-1){
4201 js_wnn_errorno_set= get4com(server);
4202
4203 return -1;
4204 }
4205
4206 return(x);
4207 }
4208
4209 int
js_file_remove_client(server,n,pwd)4210 js_file_remove_client(server, n, pwd)
4211 WNN_JSERVER_ID *server;
4212 char *n, *pwd;
4213 {
4214 struct wnn_file_head fh;
4215 register FILE *fp;
4216
4217 set_current_js(server);
4218
4219 handler_of_jserver_dead(server);
4220 if(js_wnn_errorno_eql) {
4221
4222 return(-1);
4223 }
4224 if(js_file_loaded_local_body(server, n) != -1){
4225 js_wnn_errorno_set = WNN_FILE_IN_USE;
4226
4227 return(-1);
4228 }
4229 #ifdef WRITE_CHECK
4230 check_backup(n);
4231 #endif /* WRITE_CHECK */
4232 if((fp=dic_fopen(n,"r")) == NULL){
4233 js_wnn_errorno_set = WNN_FILE_READ_ERROR;
4234
4235 return(-1);
4236 }
4237 if(input_file_header(fp, &fh) == -1){
4238 dic_fclose(fp);
4239
4240 return(-1);
4241 }
4242 dic_fclose(fp);
4243 if(!check_pwd(pwd, fh.file_passwd)){
4244 js_wnn_errorno_set = WNN_INCORRECT_PASSWD;
4245
4246 return(-1);
4247 }
4248 if(unlink(n) == -1){
4249 js_wnn_errorno_set = WNN_UNLINK;
4250
4251 return(-1);
4252 }
4253
4254 return(0);
4255 }
4256
4257 /*:::DOC_START
4258 *
4259 * Function Name: js_dic_file_create_client
4260 * Description : ���饤�����¦�˼���ե�������������
4261 * Parameter :
4262 * env : (In) �Ķ��ؤΥݥ���
4263 * fn : (In) ��������ե�����̾
4264 * type : (In) ��������ե����륿����
4265 * com : (In) ��������ե����륳����
4266 * passwd (In) ��������ե�����ѥ����
4267 * hpasswd : (In) �������������٥ѥ����
4268 *
4269 * Return value : 0==SUCCESS, -1==ERROR
4270 *
4271 * Revision history:
4272 *
4273 *:::DOC_END
4274 */
4275 int
js_dic_file_create_client(env,fn,type,com,passwd,hpasswd)4276 js_dic_file_create_client(env, fn, type, com, passwd, hpasswd)
4277 struct wnn_env *env;
4278 int type;
4279 char *fn;
4280 w_char *com;
4281 char *passwd, *hpasswd;
4282 {
4283 int x, js_jishonum;
4284
4285 if(env==0) return(-1);
4286
4287 /*
4288 * (Jul. 7, 1994)
4289 * �ƣɴط������롼���ޡ�������κ����������ɲ�
4290 */
4291 if(type != WNN_REV_DICT &&
4292 type != WNN_UD_DICT &&
4293 type != WNN_FI_USER_DICT &&
4294 type != WNN_GROUP_DICT &&
4295 type != WNN_MERGE_DICT){
4296 env_wnn_errorno_set = WNN_NOT_A_UD;
4297
4298 return(-1);
4299 }
4300 if(type == WNN_FI_USER_DICT) { /* �ƣɴط���������ؿ���Ƥ� */
4301 int i, j;
4302 unsigned char njisho;
4303 struct wnn_file_uniq duniq[WNN_MAX_JISHO_OF_AN_ENV];
4304 int dprimary[WNN_MAX_JISHO_OF_AN_ENV];
4305
4306 /* ��³�����������primary index table��file uniq�ˤμ������ */
4307 set_current_js(env->js_id);
4308 handler_of_jserver_dead_env(env);
4309 if(env_wnn_errorno_eql) {
4310
4311 return(-1);
4312 }
4313 snd_env_head(env, JS_DIC_FILE_CREATE_CLIENT);
4314 snd_flush(env->js_id);
4315 x = get4com(env->js_id);
4316 if(x == -1) {
4317 env_wnn_errorno_set = get4com(env->js_id);
4318
4319 return(-1);
4320 }
4321 js_jishonum = get1com(env->js_id); /* ��³�������� */
4322 if (js_jishonum > WNN_MAX_JISHO_OF_AN_ENV)
4323 njisho = WNN_MAX_JISHO_OF_AN_ENV;
4324 else
4325 njisho = js_jishonum;
4326 for(i = 0; i < njisho; i++) {
4327 /* ��³������� file uniq */
4328 duniq[i].time = get4com(env->js_id);
4329 duniq[i].dev = get4com(env->js_id);
4330 duniq[i].inode = get4com(env->js_id);
4331 for(j = 0; j < WNN_HOSTLEN; j++){
4332 duniq[i].createhost[j] = get1com(env->js_id);
4333 }
4334 /* ��³���������Ͽ���ÿ� */
4335 dprimary[i] = get4com(env->js_id);
4336 }
4337 if (js_jishonum > WNN_MAX_JISHO_OF_AN_ENV) {
4338 js_jishonum -= WNN_MAX_JISHO_OF_AN_ENV;
4339 for(i = 0; i < js_jishonum; i++) {
4340 get4com(env->js_id);
4341 get4com(env->js_id);
4342 get4com(env->js_id);
4343 for(j = 0; j < WNN_HOSTLEN; j++){
4344 get1com(env->js_id);
4345 }
4346 get4com(env->js_id);
4347 }
4348 }
4349 x = create_null_fi_dic(fn, com, passwd, hpasswd, type, njisho, duniq, dprimary);
4350
4351 } else /* �ף�������ؿ���Ƥ� */
4352 x = create_null_dic(fn,com, passwd, hpasswd, type);
4353
4354 if(x == -1){
4355 env_wnn_errorno_set = WNN_FILE_CREATE_ERROR;
4356
4357 return(-1);
4358 }
4359
4360 return(0);
4361 } /* End of js_dic_file_create_client */
4362
4363
4364 /** js_hindo_file_create_client **/
4365 int
js_hindo_file_create_client(env,fid,fn,com,hpasswd)4366 js_hindo_file_create_client(env,fid,fn,com,hpasswd)
4367 struct wnn_env *env;
4368 int fid;
4369 char *fn;
4370 w_char *com;
4371 char *hpasswd;
4372 {
4373 register int x;
4374 struct wnn_file_uniq funiq;
4375 int serial;
4376 register int i;
4377
4378 if(env==0) return(-1);
4379 set_current_js(env->js_id);
4380
4381 handler_of_jserver_dead_env(env);
4382 if(env_wnn_errorno_eql) {
4383
4384 return(-1);
4385 }
4386 snd_env_head(env,JS_HINDO_FILE_CREATE_CLIENT);
4387 JS_Put4Com(fid, env->js_id);
4388 snd_flush(env->js_id);
4389 x = get4com(env->js_id);
4390 if(x == -1){
4391 env_wnn_errorno_set = get4com(env->js_id);
4392
4393 return(-1);
4394 }
4395 serial = get4com(env->js_id);
4396 funiq.time = get4com(env->js_id);
4397 funiq.dev = get4com(env->js_id);
4398 funiq.inode = get4com(env->js_id);
4399 for(i=0;i<WNN_HOSTLEN;i++){
4400 funiq.createhost[i]=get1com(env->js_id);
4401 }
4402 if(create_hindo_file(&funiq,fn,com,hpasswd,serial) == -1){
4403 env_wnn_errorno_set = WNN_FILE_CREATE_ERROR;
4404
4405 return(-1);
4406 }
4407
4408 return(0);
4409 }
4410
4411 /*:::DOC_START
4412 *
4413 * Function Name: js_fi_hindo_file_create_client
4414 * Description : ���饤�����¦�ˣƣɴط����٥ե�������������
4415 * Parameter :
4416 * env : (In) �Ķ��ؤΥݥ���
4417 * fid : (In) �б��ƣɴط�����ե�����ɣ�
4418 * fn : (In) �ƣɴط����٥ե�����̾
4419 * com : (In) �ƣɴط����٥ե����륳����
4420 * hpasswd : (In) �ƣɴط����٥ե�����ѥ����
4421 *
4422 * Return value : 0==SUCCESS, -1==ERROR
4423 *
4424 * Revision history:
4425 *
4426 *:::DOC_END
4427 */
4428 int
js_fi_hindo_file_create_client(env,fid,fn,com,hpasswd)4429 js_fi_hindo_file_create_client(env, fid, fn, com, hpasswd)
4430 struct wnn_env *env;
4431 int fid;
4432 char *fn;
4433 w_char *com;
4434 char *hpasswd;
4435 {
4436 register int x;
4437 struct wnn_file_uniq funiq;
4438 unsigned char njisho;
4439 int *primary;
4440 register int i;
4441
4442 if(env==0) return(-1);
4443 set_current_js(env->js_id);
4444
4445 handler_of_jserver_dead_env(env);
4446 if(env_wnn_errorno_eql) {
4447
4448 return(-1);
4449 }
4450 snd_env_head(env,JS_FI_HINDO_FILE_CREATE_CLIENT);
4451 JS_Put4Com(fid, env->js_id);
4452 snd_flush(env->js_id);
4453 x = get4com(env->js_id);
4454 if(x == -1){
4455 env_wnn_errorno_set = get4com(env->js_id);
4456
4457 return(-1);
4458 }
4459 funiq.time = get4com(env->js_id);
4460 funiq.dev = get4com(env->js_id);
4461 funiq.inode = get4com(env->js_id);
4462 for(i=0;i<WNN_HOSTLEN;i++){
4463 funiq.createhost[i]=get1com(env->js_id);
4464 }
4465 njisho = get1com(env->js_id);
4466 if((primary = (int *)malloc(njisho * sizeof(int))) == NULL) {
4467 env_wnn_errorno_set = WNN_MALLOC_ERR;
4468
4469 return(-1);
4470 }
4471 for(i = 0; i < njisho; i++)
4472 primary[i] = get4com(env->js_id);
4473 if(create_fi_hindo_file(&funiq,fn,com,hpasswd,njisho,primary) == -1){
4474 free(primary);
4475 env_wnn_errorno_set = WNN_FILE_CREATE_ERROR;
4476
4477 return(-1);
4478 }
4479 free(primary);
4480
4481 return(0);
4482 } /* End of js_fi_hindo_file_create_client */
4483
4484 int
js_file_comment_set(env,fid,comment)4485 js_file_comment_set(env, fid, comment)
4486 struct wnn_env *env;
4487 int fid;
4488 w_char *comment;
4489 {
4490 register int x;
4491 if(env==0) return(-1);
4492 set_current_js(env->js_id);
4493
4494 handler_of_jserver_dead_env(env);
4495 if(env_wnn_errorno_eql) {
4496
4497 return(-1);
4498 }
4499 snd_env_head(env,JS_FILE_COMMENT_SET);
4500 JS_Put4Com(fid, env->js_id);
4501 putwscom(comment, env->js_id);
4502 snd_flush(env->js_id);
4503 x=get4com(env->js_id);
4504 if(x==-1){
4505 env_wnn_errorno_set= get4com(env->js_id);
4506
4507 return(-1);
4508 }
4509
4510 return(0);
4511 }
4512
4513 /*
4514 * Hinsi Primitives
4515 */
4516
4517 int
js_hinsi_name(server,no,rb)4518 js_hinsi_name(server, no, rb)
4519 WNN_JSERVER_ID *server;
4520 int no;
4521 struct wnn_ret_buf *rb;
4522 {
4523 register int size;
4524
4525 set_current_js(server);
4526
4527 handler_of_jserver_dead(server);
4528 if(js_wnn_errorno_eql) {
4529
4530 return(-1);
4531 }
4532 snd_server_head(server,JS_HINSI_NAME);
4533 JS_Put4Com(no, server);
4534 snd_flush(server);
4535 if((size = get4com(server)) == -1){
4536 js_wnn_errorno_set = get4com(server);
4537
4538 return(-1);
4539 }
4540 re_alloc(rb,sizeof(w_char)*(size + 1));
4541 getwscom((w_char *)rb->buf, server, size + 1);
4542
4543 return(0);
4544 }
4545
4546
4547 int
js_hinsi_number(server,name)4548 js_hinsi_number(server, name)
4549 WNN_JSERVER_ID *server;
4550 w_char *name;
4551 {
4552 register int no;
4553
4554 set_current_js(server);
4555
4556 handler_of_jserver_dead(server);
4557 if(js_wnn_errorno_eql) {
4558
4559 return(-1);
4560 }
4561 snd_server_head(server,JS_HINSI_NUMBER);
4562 putwscom(name, server);
4563 snd_flush(server);
4564 if((no = get4com(server)) == -1){
4565 js_wnn_errorno_set = get4com(server);
4566
4567 return(-1);
4568 }
4569
4570 return(no);
4571 }
4572
4573 int
js_hinsi_list(env,dic_no,name,rb)4574 js_hinsi_list(env, dic_no, name, rb)
4575 struct wnn_env *env;
4576 int dic_no;
4577 w_char *name;
4578 struct wnn_ret_buf *rb;
4579 {
4580 int size;
4581 int count;
4582 register w_char *s;
4583 register w_char **r;
4584 register int k, wlen, error_flag;
4585 w_char wbuf[LENGTHKANJI];
4586
4587 if(env==0) return(-1);
4588 set_current_js(env->js_id);
4589
4590 handler_of_jserver_dead_env(env);
4591 if(env_wnn_errorno_eql) {
4592
4593 return(-1);
4594 }
4595 snd_env_head(env,JS_HINSI_LIST);
4596 JS_Put4Com(dic_no, env->js_id);
4597 putwscom(name, env->js_id);
4598 snd_flush(env->js_id);
4599 if((count = get4com(env->js_id)) == -1){
4600 env_wnn_errorno_set = get4com(env->js_id);
4601
4602 return(-1);
4603 }
4604 size = get4com(env->js_id);
4605 size += 1;
4606 re_alloc(rb,sizeof(w_char)*(size) + count * sizeof(w_char *) );
4607 r = (w_char **)rb->buf;
4608 s = (w_char *)((w_char **)rb->buf + count);
4609 error_flag = 0;
4610 for(k = 0 ; k < count ; k++){
4611 getwscom(wbuf, env->js_id, sizeof(wbuf) / sizeof(w_char));
4612 if (!error_flag) {
4613 wlen = wnn_Strlen(wbuf) + 1;
4614 if (wlen > size) {
4615 error_flag = 1;
4616 } else {
4617 *r++ = s;
4618 wnn_Strcpy(s, wbuf);
4619 s += wlen;
4620 size -= wlen;
4621 }
4622 }
4623 }
4624
4625 return(count);
4626 }
4627
4628 int
js_hinsi_dicts(env,no,rb)4629 js_hinsi_dicts(env, no, rb)
4630 struct wnn_env *env;
4631 int no;
4632 struct wnn_ret_buf *rb;
4633 {
4634 register int k, count;
4635 int *p;
4636
4637 if(env==0) return(-1);
4638 set_current_js(env->js_id);
4639
4640 handler_of_jserver_dead_env(env);
4641 if(env_wnn_errorno_eql) {
4642
4643 return(-1);
4644 }
4645 snd_env_head(env,JS_HINSI_DICTS);
4646 JS_Put4Com(no, env->js_id);
4647 snd_flush(env->js_id);
4648 if((count = get4com(env->js_id)) == -1){
4649 env_wnn_errorno_set = get4com(env->js_id);
4650
4651 return(-1);
4652 }
4653 re_alloc(rb,sizeof(int) * (count + 1));
4654 p = (int *)rb->buf;
4655
4656 for(k = 0 ; k < count ; k++){
4657 *p++ = get4com(env->js_id);
4658 }
4659
4660 return(count);
4661 }
4662
4663
4664 char *wnn_dic_types[] = {
4665 "","����","��Ͽ","�հ�","����","����","FI����","FI�桼��","FI����","���롼��","�ޡ���","����","����"};
4666
4667 char *cwnn_dic_types[] = {
4668 "","�̶�","��¼","ƴ��","����"};
4669 char *bwnn_dic_types[] = {
4670 "","�̶�","��¼","����","����"};
4671
4672 char *kwnn_dic_types[] = {
4673 "","����","���","����","����"};
4674 /* ͳ�� ���� ��� ��Ю */
4675
4676
4677 /* New primitives 9/8 */
4678
4679 int
js_file_password_set(env,fid,which,old,new)4680 js_file_password_set(env, fid, which, old, new)
4681 struct wnn_env *env;
4682 int fid;
4683 int which; /* 1 for dic, 2 for hindo 3(0) for both*/
4684 char *old, *new;
4685 {
4686 register int x;
4687 if(env==0) return(-1);
4688 set_current_js(env->js_id);
4689
4690 handler_of_jserver_dead_env(env);
4691 if(env_wnn_errorno_eql) {
4692
4693 return(-1);
4694 }
4695 snd_env_head(env,JS_FILE_PASSWORD_SET);
4696 JS_Put4Com(fid, env->js_id);
4697 JS_Put4Com(which, env->js_id);
4698 putscom(old, env->js_id);
4699 putscom(new, env->js_id);
4700 snd_flush(env->js_id);
4701 x=get4com(env->js_id);
4702 if(x==-1){
4703 env_wnn_errorno_set= get4com(env->js_id);
4704
4705 return(-1);
4706 }
4707
4708 return(0);
4709 }
4710
4711 int
js_hinsi_table_set(env,dic_no,hinsi_table)4712 js_hinsi_table_set(env, dic_no, hinsi_table)
4713 struct wnn_env *env;
4714 int dic_no;
4715 w_char *hinsi_table;
4716 {
4717 int x;
4718 if(env==0) return(-1);
4719 set_current_js(env->js_id);
4720
4721 handler_of_jserver_dead_env(env);
4722 if(env_wnn_errorno_eql) {
4723
4724 return(-1);
4725 }
4726 snd_env_head(env,JS_HINSI_TABLE_SET);
4727 JS_Put4Com(dic_no, env->js_id);
4728 putwscom(hinsi_table, env->js_id);
4729 snd_flush(env->js_id);
4730 x=get4com(env->js_id);
4731 if(x==-1){
4732 env_wnn_errorno_set= get4com(env->js_id);
4733
4734 return(-1);
4735 }
4736
4737 return(0);
4738 }
4739
4740 /* Start of packets in 4004 */
4741 int
js_open_extension(server,ext_name)4742 js_open_extension(server, ext_name)
4743 WNN_JSERVER_ID *server;
4744 char *ext_name;
4745 {
4746 register wnn_extension_set *p;
4747
4748 if (!ext_name || !*ext_name) {
4749 js_wnn_errorno_set = WNN_NOT_SUPPORT_EXTENSION;
4750 return(-1);
4751 }
4752 for (p = ((WNN_JSERVER_ID_INT *)server)->extensions;
4753 p && p->id && p->name; p++) {
4754 if (!strcmp(p->name, ext_name)) {
4755 return(p->id);
4756 }
4757 }
4758 js_wnn_errorno_set = WNN_NOT_SUPPORT_EXTENSION;
4759 return(0);
4760 }
4761
4762 int
js_get_extension(server,ret)4763 js_get_extension(server, ret)
4764 WNN_JSERVER_ID *server;
4765 char ***ret;
4766 {
4767 register wnn_extension_set *p;
4768 register char *s, **l;
4769 int total = 0, num = 0;
4770
4771 if (!((WNN_JSERVER_ID_INT *)server)->extensions) {
4772 js_wnn_errorno_set = WNN_NOT_SUPPORT_PACKET;
4773 return(-1);
4774 }
4775 for (p = ((WNN_JSERVER_ID_INT *)server)->extensions;
4776 p && p->id && p->name; p++) {
4777 total += strlen(p->name) + 1;
4778 num++;
4779 }
4780 if (num == 0) return(0);
4781 if (!(l = (char **)(s = malloc((sizeof(char *) * num) + total)))) {
4782 js_wnn_errorno_set = WNN_MALLOC_ERR;
4783 return(-1);
4784 }
4785 *ret = l;
4786 s += sizeof(char *) * num;
4787 for (p = ((WNN_JSERVER_ID_INT *)server)->extensions;
4788 p && p->id && p->name; p++) {
4789 *l++ = s;
4790 strcpy(s, p->name);
4791 s += strlen(s) + 1;
4792 }
4793 return(num);
4794 }
4795
4796
4797 static int
access_host_core(server,ha,enable,ule)4798 access_host_core(server, ha, enable, ule)
4799 WNN_JSERVER_ID *server;
4800 host_address *ha;
4801 int enable, ule;
4802 {
4803 register int x;
4804 register char *p;
4805
4806 handler_of_jserver_dead(server);
4807 if (js_wnn_errorno_eql) return(-1);
4808 if (enable) {
4809 snd_server_head(server, JS_ACCESS_ADD_HOST);
4810 JS_Put4Com(ule, server);
4811 } else {
4812 snd_server_head(server, JS_ACCESS_REMOVE_HOST);
4813 }
4814 JS_Put4Com(ha->address_len, server);
4815 p = ha->address;
4816 for (x = 0; x < ha->address_len; x++) {
4817 JS_Put1Com(*p, server);
4818 p++;
4819 }
4820 snd_flush(server);
4821 x=get4com(server);
4822 if(x==-1){
4823 js_wnn_errorno_set= get4com(server);
4824 return(-1);
4825 }
4826 return(x);
4827 }
4828
4829 static int
access_host(server,host,enable,ule)4830 access_host(server, host, enable, ule)
4831 WNN_JSERVER_ID *server;
4832 char *host;
4833 int enable, ule;
4834 {
4835 struct hostent *hp;
4836 struct in_addr addr;
4837 host_address ha;
4838 char **l;
4839 int x;
4840
4841 if ((addr.s_addr = inet_addr(host)) != -1) {
4842 ha.address = (char *)&addr.s_addr;
4843 ha.address_len = sizeof(addr.s_addr);
4844 x = access_host_core(server, &ha, enable, ule);
4845 return(x);
4846 }
4847 hp = gethostbyname(host);
4848 endhostent();
4849 if (hp && hp->h_addrtype == AF_INET) {
4850 ha.address_len = sizeof(addr.s_addr);
4851 for (l = hp->h_addr_list; *l; l++) {
4852 ha.address = *l;
4853 if ((x = access_host_core(server, &ha, enable, ule)) == -1) {
4854 return(-1);
4855 }
4856 }
4857 return(0);
4858 } else {
4859 js_wnn_errorno_set = WNN_ACCESS_NO_HOST;
4860 return(-1);
4861 }
4862 }
4863
4864 int
js_access_add_host(server,host,ule)4865 js_access_add_host(server, host, ule)
4866 WNN_JSERVER_ID *server;
4867 char *host;
4868 int ule;
4869 {
4870 int x;
4871
4872 set_current_js(server);
4873
4874 x = access_host(server, host, 1, ule);
4875
4876 return(x);
4877 }
4878
4879 int
js_access_remove_host(server,host)4880 js_access_remove_host(server, host)
4881 WNN_JSERVER_ID *server;
4882 char *host;
4883 {
4884 int x;
4885
4886 set_current_js(server);
4887
4888 x = access_host(server, host, 0, 0);
4889
4890 return(x);
4891 }
4892
4893 static int
access_user_core(server,ha,user,enable)4894 access_user_core(server, ha, user, enable)
4895 WNN_JSERVER_ID *server;
4896 host_address *ha;
4897 char *user;
4898 int enable;
4899 {
4900 register int x;
4901 register char *p;
4902
4903 handler_of_jserver_dead(server);
4904 if (js_wnn_errorno_eql) return(-1);
4905 if (enable) {
4906 snd_server_head(server, JS_ACCESS_ADD_USER);
4907 } else {
4908 snd_server_head(server, JS_ACCESS_REMOVE_USER);
4909 }
4910 JS_Put4Com(ha->address_len, server);
4911 p = ha->address;
4912 for (x = 0; x < ha->address_len; x++) {
4913 JS_Put1Com(*p, server);
4914 p++;
4915 }
4916 putscom(user, server);
4917 snd_flush(server);
4918 x=get4com(server);
4919 if(x==-1){
4920 js_wnn_errorno_set= get4com(server);
4921 return(-1);
4922 }
4923 return(x);
4924 }
4925
4926 static int
access_user(server,host,user,enable)4927 access_user(server, host, user, enable)
4928 WNN_JSERVER_ID *server;
4929 char *host, *user;
4930 int enable;
4931 {
4932 struct hostent *hp;
4933 struct in_addr addr;
4934 host_address ha;
4935 char **l;
4936 int x;
4937
4938 if (!host || !*host) {
4939 ha.address = NULL;
4940 ha.address_len = 0;
4941 x = access_user_core(server, &ha, user, enable);
4942 return(x);
4943 } else if ((addr.s_addr = inet_addr(host)) != -1) {
4944 ha.address = (char *)&addr.s_addr;
4945 ha.address_len = sizeof(addr.s_addr);
4946 x = access_user_core(server, &ha, user, enable);
4947 return(x);
4948 }
4949 hp = gethostbyname(host);
4950 endhostent();
4951 if (hp && hp->h_addrtype == AF_INET) {
4952 ha.address_len = sizeof(addr.s_addr);
4953 for (l = hp->h_addr_list; *l; l++) {
4954 ha.address = *l;
4955 if ((x = access_user_core(server, &ha, user, enable)) == -1) {
4956 return(-1);
4957 }
4958 }
4959 return(0);
4960 } else {
4961 js_wnn_errorno_set = WNN_ACCESS_NO_USER;
4962 return(-1);
4963 }
4964 }
4965
4966 int
js_access_add_user(server,host,user)4967 js_access_add_user(server, host, user)
4968 WNN_JSERVER_ID *server;
4969 char *host, *user;
4970 {
4971 int x;
4972
4973 set_current_js(server);
4974
4975 x = access_user(server, host, user, 1);
4976
4977 return(x);
4978 }
4979
4980 int
js_access_remove_user(server,host,user)4981 js_access_remove_user(server, host, user)
4982 WNN_JSERVER_ID *server;
4983 char *host, *user;
4984 {
4985 int x;
4986
4987 set_current_js(server);
4988
4989 x = access_user(server, host, user, 0);
4990
4991 return(x);
4992 }
4993
4994 static int
access_control(server,enable)4995 access_control(server, enable)
4996 WNN_JSERVER_ID *server;
4997 int enable;
4998 {
4999 int x;
5000
5001 handler_of_jserver_dead(server);
5002 if (js_wnn_errorno_eql) return(-1);
5003 if (enable) {
5004 snd_server_head(server, JS_ACCESS_ENABLE);
5005 } else {
5006 snd_server_head(server, JS_ACCESS_DISABLE);
5007 }
5008 snd_flush(server);
5009 x=get4com(server);
5010 if(x==-1){
5011 js_wnn_errorno_set= get4com(server);
5012 return(-1);
5013 }
5014 return(x);
5015 }
5016
5017 int
js_access_enable(server)5018 js_access_enable(server)
5019 WNN_JSERVER_ID *server;
5020 {
5021 int x;
5022
5023 set_current_js(server);
5024
5025 x = access_control(server, 1);
5026
5027 return(x);
5028 }
5029
5030 int
js_access_disable(server)5031 js_access_disable(server)
5032 WNN_JSERVER_ID *server;
5033 {
5034 int x;
5035
5036 set_current_js(server);
5037
5038 x = access_control(server, 0);
5039
5040 return(x);
5041 }
5042
5043 static int
get_host_name_len(host_p)5044 get_host_name_len(host_p)
5045 host_address *host_p;
5046 {
5047 char *p;
5048 register struct hostent *hp;
5049 int user_len = 0;
5050 char address[32];
5051 char *inet_ntoa();
5052
5053 if ((p = strchr(host_p->address, ':'))) {
5054 user_len = strlen(p);
5055 }
5056 if (sizeof(address) < host_p->address_len)
5057 return 0;
5058 memcpy(address, (char *)host_p->address, host_p->address_len);
5059 hp = gethostbyaddr (address, host_p->address_len, AF_INET);
5060 endhostent();
5061 if (hp)
5062 return(strlen(hp->h_name) + user_len);
5063 if (!(p = inet_ntoa(*((struct in_addr *)(address))))) return(0);
5064 return(strlen(p) + user_len);
5065 }
5066
5067 static int
get_host_name(host_p,host)5068 get_host_name(host_p, host)
5069 host_address *host_p;
5070 char *host;
5071 {
5072 char *p, *user;
5073 register struct hostent *hp;
5074 int user_len = 0;
5075 char address[32];
5076 char *inet_ntoa();
5077
5078 if ((user = strchr(host_p->address, ':'))) {
5079 user_len = strlen(user);
5080 }
5081 if (sizeof(address) < host_p->address_len)
5082 return 0;
5083 memcpy(address, (char *)host_p->address, host_p->address_len);
5084 hp = gethostbyaddr (address, host_p->address_len, AF_INET);
5085 endhostent();
5086 if (hp) {
5087 strcpy(host, hp->h_name);
5088 if (user) strcat(host, user);
5089 return(strlen(host));
5090 }
5091 if (!(p = inet_ntoa(*((struct in_addr *)(address))))) return(0);
5092 strcpy(host, p);
5093 if (user) strcat(host, user);
5094 return(strlen(host));
5095 }
5096
5097 char **
js_access_get_info(server,enable,ret_num)5098 js_access_get_info(server, enable, ret_num)
5099 WNN_JSERVER_ID *server;
5100 int *enable;
5101 int *ret_num;
5102 {
5103 int i, j, host_num, except_num, total_num, bytes, total, error_flag;
5104 register char *p, **out, *save, **out_save;
5105 host_address *host_p;
5106 char dummy[1024];
5107
5108 *ret_num = -1;
5109 set_current_js(server);
5110
5111 handler_of_jserver_dead(server);
5112 if (js_wnn_errorno_eql) {
5113
5114 return(NULL);
5115 }
5116 snd_server_head(server, JS_ACCESS_GET_INFO);
5117 snd_flush(server);
5118 *enable = get4com(server);
5119 if(*enable == -1){
5120 js_wnn_errorno_set= get4com(server);
5121
5122 return((char **)NULL);
5123 }
5124 bytes = get4com(server);
5125 host_num = get4com(server);
5126 except_num = get4com(server);
5127 total_num = host_num + except_num;
5128 if (total_num == 0) {
5129 *ret_num = 0;
5130
5131 return((char **)NULL);
5132 }
5133 if (!(save = p = malloc((sizeof(host_address) * total_num) + bytes))) {
5134 for (i = 0; i < bytes; i++) get1com(server);
5135 js_wnn_errorno_set = WNN_MALLOC_ERR;
5136 return((char **)NULL);
5137 }
5138 host_p = (host_address *)p;
5139 p += sizeof(host_address) * total_num;
5140 error_flag = 0;
5141 for (i = 0; i < host_num; i++, host_p++) {
5142 host_p->address_len = get4com(server);
5143 if ((host_p->address_len >= bytes) || (bytes <= 0) || error_flag) {
5144 error_flag = 1;
5145 for (j = 0; j < host_p->address_len; j++) get1com(server);
5146 if (get4com(server))
5147 getscom(dummy, server, sizeof(dummy));
5148 } else {
5149 for (j = 0; j < host_p->address_len; j++) p[j] = get1com(server);
5150 host_p->address = p;
5151 p += host_p->address_len;
5152 bytes -= host_p->address_len;
5153 if (get4com(server)) {
5154 *p++ = ':';
5155 bytes--;
5156 getscom(p, server, bytes);
5157 if (bytes > 0) {
5158 p += strlen(p) + 1;
5159 bytes -= strlen(p) + 1;
5160 }
5161 } else {
5162 *p++ = '\0';
5163 bytes--;
5164 }
5165 }
5166 }
5167 for (i = 0; i < except_num; i++, host_p++) {
5168 if ((bytes <= 0) || error_flag) {
5169 error_flag = 1;
5170 getscom(dummy, server, sizeof(dummy));
5171 } else {
5172 host_p->address = p;
5173 *p++ = '@';
5174 bytes--;
5175 getscom(p, server, bytes);
5176 if (bytes > 0) {
5177 p += strlen(p) + 1;
5178 bytes -= strlen(p) + 1;
5179 host_p->address_len = strlen(host_p->address);
5180 }
5181 }
5182 }
5183 if (error_flag) {
5184 free((char *)save);
5185 js_wnn_errorno_set = WNN_SOME_ERROR;
5186
5187 return((char **)NULL);
5188 }
5189 for (host_p = (host_address *)save, total = 0, i = 0;
5190 i < total_num; i++, host_p++) {
5191 if (host_p->address_len > 0 && host_p->address[0] == '@')
5192 total += strlen(host_p->address); /* exceptional user name */
5193 else
5194 total += get_host_name_len(host_p);
5195 }
5196 if (!(p = malloc((sizeof(char *) * total_num) + total + total_num))) {
5197 free((char *)save);
5198 js_wnn_errorno_set = WNN_MALLOC_ERR;
5199
5200 return((char **)NULL);
5201 }
5202 out = out_save = (char **)p;
5203 p += (sizeof(char *) * total_num);
5204 for (host_p = (host_address *)save, i = 0; i < total_num; i++, host_p++) {
5205 *out++ = p;
5206 if (host_p->address_len > 0 && host_p->address[0] == '@') {
5207 strcpy(p, host_p->address) /* exceptional user name */;
5208 p += strlen(host_p->address) + 1;
5209 } else
5210 p += get_host_name(host_p, p) + 1;
5211 }
5212 free((char *)save);
5213 *ret_num = total_num;
5214
5215 return(out_save);
5216 }
5217
5218 /*:::DOC_START
5219 *
5220 * Function Name: js_is_loaded_temporary_dic
5221 * Description :
5222 * �ƥ�ݥ�꼭�Ķ��ˤ��뤫�ɤ�����Ĵ�٤�
5223 * Parameter :
5224 * env : (In) �Ķ��ؤΥݥ���
5225 *
5226 * Return value : 1==EXIST, 0==NO EXIST, -1==ERROR
5227 *
5228 * Revision history:
5229 *
5230 *:::DOC_END
5231 */
5232 int
js_is_loaded_temporary_dic(env)5233 js_is_loaded_temporary_dic(env)
5234 struct wnn_env *env;
5235 {
5236 register int x = 0;
5237
5238 if(!env) return(-1);
5239 set_current_js(env->js_id);
5240
5241 handler_of_jserver_dead_env(env);
5242 if(env_wnn_errorno_eql) {
5243
5244 return(-1);
5245 }
5246 snd_env_head(env,JS_IS_LOADED_TEMPORARY_DIC);
5247 snd_flush(env->js_id);
5248 x=get4com(env->js_id);
5249 if (x == -1) {
5250 wnn_errorno = get4com(env->js_id);
5251 }
5252
5253 return x;
5254 }
5255
5256 /*:::DOC_START
5257 *
5258 * Function Name: js_temporary_dic_delete
5259 * Description :
5260 * �ƥ�ݥ�꼭���Ķ����ɲä���
5261 * Parameter :
5262 * env : (In) �Ķ��ؤΥݥ���
5263 *
5264 * Return value : 0==SUCCESS, -1==ERROR
5265 *
5266 * Revision history:
5267 *
5268 *:::DOC_END
5269 */
5270 int
js_temporary_dic_add(env,rev)5271 js_temporary_dic_add(env, rev)
5272 struct wnn_env *env;
5273 int rev;
5274 {
5275 register int x = 0;
5276
5277 if(!env) return(-1);
5278 set_current_js(env->js_id);
5279
5280 handler_of_jserver_dead_env(env);
5281 if(env_wnn_errorno_eql) {
5282
5283 return(-1);
5284 }
5285 snd_env_head(env,JS_TEMPORARY_DIC_ADD);
5286 JS_Put4Com(rev, env->js_id);
5287 snd_flush(env->js_id);
5288 x=get4com(env->js_id);
5289 if (x == -1) wnn_errorno = get4com(env->js_id);
5290
5291 return x;
5292 }
5293
5294 /*:::DOC_START
5295 *
5296 * Function Name: js_temporary_dic_delete
5297 * Description :
5298 * �ƥ�ݥ�꼭���Ķ�����������
5299 * Parameter :
5300 * env : (In) �Ķ��ؤΥݥ���
5301 *
5302 * Return value : 0==SUCCESS, -1==ERROR
5303 *
5304 * Revision history:
5305 *
5306 *:::DOC_END
5307 */
5308 int
js_temporary_dic_delete(env)5309 js_temporary_dic_delete(env)
5310 struct wnn_env *env;
5311 {
5312 register int x;
5313
5314 if(!env) return(-1);
5315 set_current_js(env->js_id);
5316
5317 handler_of_jserver_dead_env(env);
5318 if(env_wnn_errorno_eql) {
5319
5320 return(-1);
5321 }
5322 snd_env_head(env,JS_TEMPORARY_DIC_DELETE);
5323 snd_flush(env->js_id);
5324 x=get4com(env->js_id);
5325 if (x == -1) wnn_errorno = get4com(env->js_id);
5326
5327 return x;
5328 }
5329
5330 /*:::DOC_START
5331 *
5332 * Function Name: js_temporary_word_add
5333 * Description :
5334 * �ƥ�ݥ�꼭���ñ�����Ͽ���롣
5335 * Parameter :
5336 * env : (In) �Ķ��ؤΥݥ���
5337 * yomi : (In) �ɤ�
5338 * kanji : (In) ����
5339 * comment : (In) ������
5340 * hinsi : (In) �ʻ�
5341 * init_hindo :(In) �������
5342 *
5343 * Return value : 0==SUCCESS, -1==ERROR
5344 *
5345 * Revision history:
5346 *
5347 *:::DOC_END
5348 */
5349 int
js_temporary_word_add(env,yomi,kanji,comment,hinshi,init_hindo)5350 js_temporary_word_add(env, yomi, kanji, comment, hinshi, init_hindo)
5351 struct wnn_env *env;
5352 w_char *yomi,*kanji,*comment;
5353 int hinshi,init_hindo;
5354 {
5355 register int x;
5356
5357 if(!env) return(-1);
5358 set_current_js(env->js_id);
5359
5360 handler_of_jserver_dead_env(env);
5361 if(env_wnn_errorno_eql) {
5362
5363 return(-1);
5364 }
5365 snd_env_head(env,JS_TEMPORARY_WORD_ADD);
5366 putwscom(yomi, env->js_id);
5367 putwscom(kanji, env->js_id);
5368 putwscom(comment, env->js_id);
5369 JS_Put4Com(hinshi, env->js_id);
5370 JS_Put4Com(init_hindo, env->js_id);
5371 snd_flush(env->js_id);
5372 x=get4com(env->js_id);
5373 if (x == -1) wnn_errorno = get4com(env->js_id);
5374
5375 return x;
5376 }
5377
5378 /*:::DOC_START
5379 *
5380 * Function Name: js_autolearning_word_add
5381 * Description :
5382 * ��ư��Ͽ��ñ�����Ͽ���롣
5383 * Parameter :
5384 * env : (In) �Ķ��ؤΥݥ���
5385 * type : (In) �ؽ����륿����(��������/ʸ���ڤ�)
5386 * yomi : (In) �ɤ�
5387 * kanji : (In) ����
5388 * comment : (In) ������
5389 * hinsi : (In) �ʻ�
5390 * init_hindo :(In) �������
5391 *
5392 * Return value : 0==SUCCESS, -1==ERROR
5393 *
5394 * Revision history:
5395 *
5396 *:::DOC_END
5397 */
5398 int
js_autolearning_word_add(env,type,yomi,kanji,comment,hinshi,init_hindo)5399 js_autolearning_word_add(env, type, yomi, kanji, comment, hinshi, init_hindo)
5400 struct wnn_env *env;
5401 w_char *yomi,*kanji,*comment;
5402 int type, hinshi,init_hindo;
5403 {
5404 register int x;
5405
5406 if(!env) return(-1);
5407 set_current_js(env->js_id);
5408
5409 handler_of_jserver_dead_env(env);
5410 if(env_wnn_errorno_eql) {
5411
5412 return(-1);
5413 }
5414 snd_env_head(env,JS_AUTOLEARNING_WORD_ADD);
5415 JS_Put4Com(type, env->js_id);
5416 putwscom(yomi, env->js_id);
5417 putwscom(kanji, env->js_id);
5418 putwscom(comment, env->js_id);
5419 JS_Put4Com(hinshi, env->js_id);
5420 JS_Put4Com(init_hindo, env->js_id);
5421 snd_flush(env->js_id);
5422 x=get4com(env->js_id);
5423 if (x == -1) wnn_errorno = get4com(env->js_id);
5424
5425 return x;
5426 }
5427
5428 /*:::DOC_START
5429 *
5430 * Function Name: js_set_autolearning_dic
5431 * Description :
5432 * ��ư��Ͽ�Ѥμ������Ͽ����
5433 * Parameter :
5434 * env : (In) �Ķ��ؤΥݥ���
5435 * type : (In) ����Υ�����(��������/ʸ���ڤ�)
5436 * dic_no : (In) �����ֹ�
5437 *
5438 * Return value : 0==SUCCESS, -1==ERROR
5439 *
5440 * Revision history:
5441 *
5442 *:::DOC_END
5443 */
5444 int
js_set_autolearning_dic(env,type,dic_no)5445 js_set_autolearning_dic(env, type, dic_no)
5446 register struct wnn_env *env;
5447 register int type, dic_no;
5448 {
5449 int x;
5450
5451 if(!env) return(-1);
5452 set_current_js(env->js_id);
5453
5454 handler_of_jserver_dead_env(env);
5455 if(env_wnn_errorno_eql) {
5456
5457 return(-1);
5458 }
5459 snd_env_head(env,JS_SET_AUTOLEARNING_DIC);
5460 JS_Put4Com(type, env->js_id);
5461 JS_Put4Com(dic_no, env->js_id);
5462 snd_flush(env->js_id);
5463 x=get4com(env->js_id);
5464 if (x == -1) wnn_errorno = get4com(env->js_id);
5465
5466 return(x);
5467 }
5468
5469 /*:::DOC_START
5470 *
5471 * Function Name: js_get_autolearning_dic
5472 * Description :
5473 * ��ư��Ͽ�Ѥμ����Ĵ�٤�
5474 * Parameter :
5475 * env : (In) �Ķ��ؤΥݥ���
5476 * type : (In) ����Υ�����(��������/ʸ���ڤ�)
5477 *
5478 * Return value : -1==ERROR, ELSE==������ֹ�
5479 *
5480 * Revision history:
5481 *
5482 *:::DOC_END
5483 */
5484 int
js_get_autolearning_dic(env,type)5485 js_get_autolearning_dic(env, type)
5486 register struct wnn_env *env;
5487 register int type;
5488 {
5489 register int x;
5490
5491 if(!env) return(-1);
5492 set_current_js(env->js_id);
5493
5494 handler_of_jserver_dead_env(env);
5495 if(env_wnn_errorno_eql) {
5496
5497 return(-1);
5498 }
5499 snd_env_head(env,JS_GET_AUTOLEARNING_DIC);
5500 JS_Put4Com(type, env->js_id);
5501 snd_flush(env->js_id);
5502 x=get4com(env->js_id);
5503 if (x == -1) {
5504
5505 wnn_errorno = get4com(env->js_id);
5506 return -1;
5507 }
5508 x=get4com(env->js_id);
5509
5510 return(x);
5511 }
5512
5513
5514 /*:::DOC_START
5515 *
5516 * Function Name:
5517 * rcv_dai_sim, rcv_sho_x_sim, rcv_sho_kanji_sim, rcv_sho_sim
5518 * Description :
5519 * emulate rcv_dai etc. for local test
5520 * Parameter : same as emulated (omitted)
5521 *
5522 * Return value : same as emulated (omitted)
5523 *
5524 * Revision history:
5525 * 20-Dec-94: initial release
5526 *
5527 *:::DOC_END
5528 */
5529
5530
5531
5532 /*:::DOC_START
5533 *
5534 * Function Name: js_ikeiji_with_data
5535 * Description :
5536 * �Ѵ��ѳƼ�ǡ�����ʣ����Ѵ����Ѵ��ʻ�ꥹ�ȡˤ�
5537 * ���ꤷ�ơ��۷��� �Ѵ�������Ԥʤ�
5538 * Parameter :
5539 * env : (In) �Ķ��ؤΥݥ���
5540 * fuku : (In) ʣ����Ѵ�
5541 * nhinsi : (In) �ʻ�ο�
5542 * hlist : (In) �ʻ�ꥹ��
5543 * henkan : (In) �Ѵ��Υ�����
5544 * yomi : (In) ��������
5545 * hinsi : (In) ������̤��ʻ�
5546 * fzk : (In) ��°��ξ���
5547 * vec : (In) ��³�ξ���
5548 * vec1 : (In) ��³�ξ��� 1
5549 * vec2 : (In) ��³�ξ��� 2
5550 * cur_bun : (In) ʸ��ξ���
5551 * yomi_orig : (In) �ɤ�
5552 * rb : (Out) ������
5553 *
5554 * Return value : ��ʸ��ο�
5555 *
5556 * Revision history:
5557 * 20-Dec-94: initial release
5558 *
5559 *:::DOC_END
5560 */
5561 int
js_ikeiji_with_data(env,fuku,nhinsi,hlist,henkan,yomi,hinsi,fzk,vec,vec1,vec2,cur_bun,yomi_orig,rb)5562 js_ikeiji_with_data(env,fuku,nhinsi,hlist,henkan,yomi,hinsi,fzk,vec,vec1,vec2,
5563 cur_bun, yomi_orig,
5564 rb)
5565 struct wnn_env *env;
5566 int fuku, nhinsi, *hlist, henkan;
5567 w_char *yomi;
5568 int hinsi;
5569 w_char *fzk;
5570 int vec;
5571 int vec1;
5572 int vec2;
5573 WNN_BUN *cur_bun;
5574 w_char *yomi_orig;
5575 struct wnn_ret_buf *rb;
5576 {
5577 int x;
5578 int i, loop = abs(nhinsi);
5579 register int put_val;
5580
5581 int for_ret_status;
5582 int for_ret_status_bkwd;
5583
5584 for_ret_status = (cur_bun->dai_top)? WNN_NOT_CONNECT : WNN_CONNECT;
5585 /* where are WNN_SENTOU and WNN_GIJI gone to ? */
5586 for_ret_status_bkwd = (cur_bun->dai_end)? WNN_NOT_CONNECT_BK : WNN_CONNECT_BK;
5587
5588
5589 if(env==0) return(-1);
5590 set_current_js(env->js_id);
5591
5592 handler_of_jserver_dead_env(env);
5593 if(env_wnn_errorno_eql) {
5594
5595 return(-1);
5596 }
5597
5598
5599 snd_env_head(env,JS_HENKAN_IKEIJI);
5600 JS_Put4Com(fuku, env->js_id); /* ʣ���ͥ�� */
5601 JS_Put4Com(nhinsi, env->js_id); /* �Ѵ������ʻ�� */
5602 for(i = 0; i < loop; i++)
5603 JS_Put4Com(hlist[i], env->js_id); /* �Ѵ������ʻ��ֹ� */
5604 JS_Put4Com(henkan, env->js_id); /* �Ѵ����� */
5605 putwscom(yomi, env->js_id);
5606 put_fzk_vec(hinsi,fzk,vec,vec1, env->js_id);
5607 JS_Put4Com(vec2, env->js_id);
5608 /* need fugokugo-len, hinsi, etc */
5609 put_val = (int) (cur_bun->yomilen - cur_bun->jirilen);
5610 JS_Put4Com(put_val, env->js_id);
5611 JS_Put4Com(cur_bun->hinsi, env->js_id);
5612
5613 /* more */
5614 JS_Put4Com( cur_bun->hyoka, env->js_id);
5615 /* for ret_sho_hyoka in jserver */
5616 JS_Put4Com( cur_bun->daihyoka, env->js_id);
5617 /* for ret_hyoka in jserver */
5618 JS_Put4Com( for_ret_status /* (wnn_sho_bunsetsu*)->status */ , env->js_id);
5619 /* for ret_status in jserver */
5620 JS_Put4Com( for_ret_status_bkwd /* (wnn_sho_bunsetsu*)->status_bkwd */ , env->js_id);
5621 /* for int ret_status_bkwd in jserver */
5622 JS_Put4Com( cur_bun->kangovect, env->js_id);
5623 /* for ret_kangovect in jserver */
5624 /* �Ѵ��ɤ�ʸ������Ф��������� ����� ������ ���Ϥ� */
5625 putwscom(yomi_orig, env->js_id);
5626 /* for ret_yomi_orig[i] in jserver */
5627 JS_Put4Com( cur_bun->jirilen, env->js_id);
5628 /* for ret_jirilen_orig in jserver */
5629 JS_Put4Com( cur_bun->yomilen, env->js_id);
5630 /* for ret_yomilen_orig in jserver */
5631 JS_Put4Com( cur_bun->kanjilen, env->js_id);
5632 /* for ret_kanjilen_orig in jserver */
5633 JS_Put4Com( cur_bun->real_kanjilen, env->js_id);
5634 /* for ret_real_kanjilen_orig in jserver */
5635
5636 snd_flush(env->js_id);
5637
5638 switch(henkan) {
5639 case WNN_IKEIJI_DAI:
5640 x = rcv_dai(rb, env->js_id);
5641 break;
5642 default:
5643 x = get4com(env->js_id);
5644 env_wnn_errorno_set= get4com(env->js_id);
5645 }
5646
5647 return x;
5648 }
5649 /* end of js_ikeiji_with_data */
5650
5651
5652 /*:::DOC_START
5653 *
5654 * Function Name: js_yosoku_init
5655 *
5656 * Description : ����ͽ¬ �����
5657 *
5658 * Parameter :
5659 * env : (In) �Ķ�����ǡ���
5660 *
5661 * Return value :
5662 * 0 = ���ェλ
5663 * -1 = ���顼
5664 *
5665 * Revision history: Ver 1.00
5666 *
5667 *:::DOC_END
5668 */
js_yosoku_init(struct wnn_env * env)5669 int js_yosoku_init(struct wnn_env *env)
5670 {
5671 int x;
5672
5673 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
5674 if(!CHECK_VERSION_WNN7) return(0);
5675
5676 if (env == 0) return(-1);
5677 set_current_js(env->js_id);
5678
5679 handler_of_jserver_dead_env(env);
5680 if(env_wnn_errorno_eql) {
5681 return(-1);
5682 }
5683
5684 snd_env_head(env,JS_YOSOKU_INIT);
5685 snd_flush(env->js_id);
5686
5687 x = get4com(env->js_id);
5688 if (x != 0) {
5689 env_wnn_errorno_set = get4com(env->js_id);
5690 return -1;
5691 }
5692 return 0;
5693 }
5694
5695 /*:::DOC_START
5696 *
5697 * Function Name: js_yosoku_set_param
5698 *
5699 * Description : ����ͽ¬�Ķ�����������
5700 *
5701 * Parameter :
5702 * env : (In) �Ķ�����ǡ���
5703 * learn_flag : (In) ͽ¬�ؽ�����(=1) ���ʤ�(=0)
5704 * max_disp : (In) ͽ¬�������ɽ���� (1��10)
5705 * last_is_first_flag : (In) �ǽ�����ͥ�褹��(=1) ���ʤ�(=0)
5706 *
5707 * Return value :
5708 * 0 = ���ェλ
5709 * -1 = ���顼
5710 *
5711 * Revision history: Ver 1.00
5712 *
5713 *:::DOC_END
5714 */
js_yosoku_set_param(struct wnn_env * env,int learn_flag,int max_disp,int last_is_first_flag)5715 int js_yosoku_set_param(struct wnn_env *env, int learn_flag, int max_disp, int last_is_first_flag)
5716 {
5717 int x;
5718
5719 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
5720 if(!CHECK_VERSION_WNN7) return(0);
5721
5722 if (env == 0) return(-1);
5723 set_current_js(env->js_id);
5724
5725 handler_of_jserver_dead_env(env);
5726 if(env_wnn_errorno_eql) {
5727 return(-1);
5728 }
5729
5730 /* ���̻Ҥ��С������� */
5731 snd_env_head(env,JS_YOSOKU_SET_PARAM);
5732
5733 /* �ѥ������� */
5734 JS_Put4Com(learn_flag, env->js_id);
5735 JS_Put4Com(max_disp, env->js_id);
5736 JS_Put4Com(last_is_first_flag, env->js_id);
5737
5738 /* �����Хåե���ե�å��� */
5739 snd_flush(env->js_id);
5740
5741 x = get4com(env->js_id);
5742 if (x != 0) {
5743 env_wnn_errorno_set = get4com(env->js_id);
5744 return -1;
5745 }
5746 return 0;
5747 }
5748
5749 /*:::DOC_START
5750 *
5751 * Function Name: js_yosoku_free
5752 *
5753 * Description : ͽ¬�ǡ��� �������
5754 *
5755 * Parameter :
5756 * env : (In) �Ķ�����ǡ���
5757 *
5758 * Return value :
5759 * 0 = ���ェλ
5760 * -1 = ���顼
5761 *
5762 * Revision history: Ver 1.00
5763 *
5764 *:::DOC_END
5765 */
js_yosoku_free(struct wnn_env * env)5766 int js_yosoku_free(struct wnn_env *env)
5767 {
5768 int x;
5769
5770 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
5771 if(!CHECK_VERSION_WNN7) return(0);
5772
5773 if(env==0) return(-1);
5774 set_current_js(env->js_id);
5775
5776 handler_of_jserver_dead_env(env);
5777 if(env_wnn_errorno_eql) {
5778 return(-1);
5779 }
5780
5781 snd_env_head(env, JS_YOSOKU_FREE);
5782 snd_flush(env->js_id);
5783
5784 x=get4com(env->js_id);
5785 if (x != 0) {
5786 env_wnn_errorno_set = get4com(env->js_id);
5787 return -1;
5788 }
5789 return 0;
5790 }
5791
5792 int ykYosokuKouhoNum = 0; /* ͽ¬����� */
5793 char **ykYosokuKouho = NULL; /* ͽ¬����(����ʸ����) */
5794
5795 /*:::DOC_START
5796 *
5797 * Function Name: js_yosoku_yosoku
5798 *
5799 * Description : ����ͽ¬
5800 *
5801 * Parameter :
5802 * env : (In) �Ķ�����ǡ���
5803 * yosoku_moji : (In) ����ʸ����
5804 *
5805 * Return value :
5806 * 0 = ���ェλ
5807 * -1 = ���顼
5808 *
5809 * Revision history: Ver 1.00
5810 *
5811 *:::DOC_END
5812 */
js_yosoku_yosoku(struct wnn_env * env,char * yosoku_moji)5813 int js_yosoku_yosoku(struct wnn_env *env, char *yosoku_moji)
5814 {
5815
5816 register int i, j;
5817 int x;
5818 int kanjisize;
5819
5820 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
5821 if(!CHECK_VERSION_WNN7) return(0);
5822
5823 /* �Ķ�ID���Ф������ */
5824 if(env == 0) return(-1);
5825 set_current_js(env->js_id);
5826
5827 handler_of_jserver_dead_env(env);
5828 if(env_wnn_errorno_eql) {
5829 return(-1);
5830 }
5831
5832 /* ���̻Ҥ��С������� */
5833 snd_env_head(env, JS_YOSOKU_YOSOKU);
5834
5835 /* �����С�������ʸ��������� */
5836 putscom(yosoku_moji, env->js_id);
5837
5838 /* �����Хåե���ե�å��� */
5839 snd_flush(env->js_id);
5840
5841 /* �����С����饹�ơ���������� */
5842 x = get4com(env->js_id);
5843 if(x != 0){
5844 env_wnn_errorno_set = get4com(env->js_id); /* ���顼NO���� */
5845 return(-1);
5846 }
5847
5848 /* �⤷ͽ¬�����ΰ���ݺ�(free��˺��) �Ǥ���а�ö���� */
5849 if (ykYosokuKouhoNum != 0 || ykYosokuKouho != NULL)
5850 js_yosoku_kouho_free();
5851
5852 /* �����С������ͽ¬��������� */
5853 ykYosokuKouhoNum = get4com(env->js_id);
5854 if (ykYosokuKouhoNum < 0) {
5855 env_wnn_errorno_set = WNN_YOSOKU_ETC_ERROR;
5856 return (-1);
5857 }
5858 if (ykYosokuKouhoNum == 0)
5859 return(0); /* ���ェλ */
5860
5861 ykYosokuKouho = (char **)calloc(ykYosokuKouhoNum, sizeof(char *));
5862 if (ykYosokuKouho == NULL) {
5863 /* ���ɤ� */
5864 for (i = 0; i < ykYosokuKouhoNum; i++) {
5865 kanjisize = get4com(env->js_id);
5866 for (j = 0; j < kanjisize; j++)
5867 get1com(env->js_id);
5868 }
5869 ykYosokuKouhoNum = 0;
5870 env_wnn_errorno_set = WNN_MALLOC_ERR;
5871 return (-1);
5872 }
5873
5874 /* ͽ¬�����ʬ�롼�פ����ơ�ͽ¬��̤���� */
5875 for (i = 0; i < ykYosokuKouhoNum; i++) {
5876 kanjisize = get4com(env->js_id);
5877 ykYosokuKouho[i] = (char *)calloc(kanjisize + 1, sizeof(char));
5878 if (ykYosokuKouho[i] == NULL) {
5879 /* ����ޤǤ�ʬ���� */
5880 for (j = 0; j < i; j++)
5881 free(ykYosokuKouho[j]);
5882 /* ���椫����ɤ� */
5883 for (j = 0; j < kanjisize; j++)
5884 get1com(env->js_id);
5885 for (i=i+1 ; i < ykYosokuKouhoNum; i++) {
5886 kanjisize = get4com(env->js_id);
5887 for (j = 0; j < kanjisize; j++)
5888 get1com(env->js_id);
5889 }
5890 ykYosokuKouhoNum = 0;
5891 free(ykYosokuKouho);
5892 env_wnn_errorno_set = WNN_MALLOC_ERR;
5893 return (-1);
5894 }
5895 getscom(ykYosokuKouho[i], env->js_id, kanjisize + 1);
5896 }
5897
5898 return(0); /* ���ェλ */
5899
5900 }
5901
5902 /*:::DOC_START
5903 *
5904 * Function Name: js_yosoku_kouho_free()
5905 *
5906 * Description : ͽ¬����ǡ����ΰ�β���
5907 *
5908 * Parameter : �ʤ�
5909 *
5910 * Return value : �ʤ�
5911 *
5912 * Revision history: Ver 1.00
5913 *
5914 *:::DOC_END
5915 */
js_yosoku_kouho_free()5916 void js_yosoku_kouho_free()
5917 {
5918 register int i;
5919
5920 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
5921 if(!CHECK_VERSION_WNN7) return;
5922
5923 for (i = 0; i < ykYosokuKouhoNum; i++)
5924 if (ykYosokuKouho[i] != NULL)
5925 free(ykYosokuKouho[i]);
5926
5927 free(ykYosokuKouho);
5928
5929 ykYosokuKouhoNum = 0;
5930 ykYosokuKouho = NULL;
5931 }
5932
5933 /*:::DOC_START
5934 *
5935 * Function Name: js_yosoku_toroku
5936 *
5937 * Description : ����ͽ¬ ��Ͽ
5938 *
5939 * Parameter :
5940 * env : (In) �Ķ�����ǡ���
5941 * bunsetsu_num : (In) ��Ͽ����ʸ������
5942 * ykbun : (In) ��Ͽ����ʸ�����¤�ΤؤΥݥ���
5943 *
5944 * Return value :
5945 * 0 = ���ェλ
5946 * -1 = ���顼
5947 *
5948 * Revision history: Ver 1.00
5949 *
5950 *:::DOC_END
5951 */
js_yosoku_toroku(struct wnn_env * env,int bunsetsu_num,struct wnn_yosoku_bunsetsu * ykbun)5952 int js_yosoku_toroku(struct wnn_env *env, int bunsetsu_num, struct wnn_yosoku_bunsetsu *ykbun)
5953 {
5954 register int i;
5955 int x;
5956
5957 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
5958 if(!CHECK_VERSION_WNN7) return(0);
5959
5960 /* �Ķ�ID���Ф������ */
5961 if(env == 0) return(-1);
5962 set_current_js(env->js_id);
5963
5964 handler_of_jserver_dead_env(env);
5965 if(env_wnn_errorno_eql) {
5966 return(-1);
5967 }
5968
5969 /* ���̻Ҥ��С������� */
5970 snd_env_head(env, JS_YOSOKU_TOROKU);
5971
5972 /* �����С���ʸ������������ */
5973 JS_Put4Com(bunsetsu_num, env->js_id);
5974
5975 /* �����С���ʸ���������� */
5976 for(i = 0; i < bunsetsu_num; i++){
5977 putscom(ykbun[i].yomi, env->js_id); /* �ɤ�ʸ���� */
5978 JS_Put4Com(ykbun[i].jirilen, env->js_id); /* ��Ω��Ĺ */
5979 putscom(ykbun[i].kanji, env->js_id); /* ����ʸ���� */
5980 JS_Put4Com(ykbun[i].real_kanjilen, env->js_id); /* ������ʬĹ */
5981 JS_Put4Com(ykbun[i].hinsi, env->js_id); /* �ʻ� */
5982 }
5983
5984 /* �����Хåե���ե�å��� */
5985 snd_flush(env->js_id);
5986
5987 x = get4com(env->js_id);
5988 if (x != 0) {
5989 env_wnn_errorno_set = get4com(env->js_id);
5990 return -1;
5991 }
5992 return 0;
5993 }
5994
5995 /*:::DOC_START
5996 *
5997 * Function Name: js_yosoku_selected_cand
5998 *
5999 * Description : ͽ¬��������
6000 *
6001 * Parameter :
6002 * env : (In) �Ķ�����ǡ���
6003 * selectpos : (In) �����������
6004 *
6005 * Return value :
6006 * 0 = ���ェλ
6007 * -1 = ���顼
6008 *
6009 * Revision history: Ver 1.00
6010 *
6011 *:::DOC_END
6012 */
js_yosoku_selected_cand(struct wnn_env * env,int selectpos)6013 int js_yosoku_selected_cand(struct wnn_env *env, int selectpos)
6014 {
6015
6016 int x;
6017
6018 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6019 if(!CHECK_VERSION_WNN7) return(0);
6020
6021 /* �Ķ�ID���Ф������ */
6022 if(env == 0) return(-1);
6023 set_current_js(env->js_id);
6024
6025 handler_of_jserver_dead_env(env);
6026 if(env_wnn_errorno_eql) {
6027 return(-1);
6028 }
6029
6030 /* ���̻Ҥ��С������� */
6031 snd_env_head(env,JS_YOSOKU_SELECTED_CAND);
6032
6033 /* ���줿������֤����� */
6034 JS_Put4Com(selectpos, env->js_id);
6035
6036 /* �����Хåե���ե�å��� */
6037 snd_flush(env->js_id);
6038
6039 x = get4com(env->js_id);
6040 if (x >= 0) {
6041 return(x);
6042 } else {
6043 env_wnn_errorno_set = get4com(env->js_id);
6044 return -1;
6045 }
6046
6047 }
6048
6049 /*:::DOC_START
6050 *
6051 * Function Name: js_yosoku_delete_cand
6052 *
6053 * Description : ͽ¬������
6054 *
6055 * Parameter :
6056 * env : (In) �Ķ�����ǡ���
6057 * selectpos : (In) �����������
6058 *
6059 * Return value :
6060 * 0 = ���ェλ
6061 * -1 = ���顼
6062 *
6063 * Revision history: Ver 1.00
6064 *
6065 *:::DOC_END
6066 */
js_yosoku_delete_cand(struct wnn_env * env,int selectpos)6067 int js_yosoku_delete_cand(struct wnn_env *env, int selectpos)
6068 {
6069 int x;
6070
6071 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6072 if(!CHECK_VERSION_WNN7) return(0);
6073
6074 /* �Ķ�ID���Ф������ */
6075 if(env == 0) return(-1);
6076 set_current_js(env->js_id);
6077
6078 handler_of_jserver_dead_env(env);
6079 if(env_wnn_errorno_eql) {
6080 return(-1);
6081 }
6082
6083 /* ���̻Ҥ��С������� */
6084 snd_env_head(env,JS_YOSOKU_DELETE_CAND);
6085
6086 /* ���줿������֤����� */
6087 JS_Put4Com(selectpos, env->js_id);
6088
6089 /* �����Хåե���ե�å��� */
6090 snd_flush(env->js_id);
6091
6092 x = get4com(env->js_id);
6093 if (x != 0) {
6094 env_wnn_errorno_set = get4com(env->js_id);
6095 return -1;
6096 }
6097 return 0;
6098
6099 }
6100
6101 /*:::DOC_START
6102 *
6103 * Function Name: js_yosoku_cancel_latest_toroku
6104 *
6105 * Description : ľ����Ͽ�ǡ����������
6106 *
6107 * Parameter :
6108 * env : (In) �Ķ�����ǡ���
6109 *
6110 * Return value :
6111 * 0 = ���ェλ
6112 * -1 = ���顼
6113 *
6114 * Revision history: Ver 1.00
6115 *
6116 *:::DOC_END
6117 */
js_yosoku_cancel_latest_toroku(struct wnn_env * env)6118 int js_yosoku_cancel_latest_toroku(struct wnn_env *env)
6119 {
6120 int x;
6121
6122 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6123 if(!CHECK_VERSION_WNN7) return(0);
6124
6125 /* �Ķ�ID���Ф������ */
6126 if(env == 0) return(-1);
6127 set_current_js(env->js_id);
6128
6129 handler_of_jserver_dead_env(env);
6130 if(env_wnn_errorno_eql) {
6131 return(-1);
6132 }
6133
6134 /* ���̻Ҥ��С������� */
6135 snd_env_head(env,JS_YOSOKU_CANCEL_LATEST_TOROKU);
6136
6137 /* �����Хåե���ե�å��� */
6138 snd_flush(env->js_id);
6139
6140 x = get4com(env->js_id);
6141 if (x != 0) {
6142 env_wnn_errorno_set = get4com(env->js_id);
6143 return -1;
6144 }
6145 return 0;
6146
6147 }
6148
6149 /*:::DOC_START
6150 *
6151 * Function Name: js_yosoku_reset_pre_yosoku
6152 *
6153 * Description : ͽ¬������ꥢ
6154 *
6155 * Parameter :
6156 * env : (In) �Ķ�����ǡ���
6157 *
6158 * Return value :
6159 * 0 = ���ェλ
6160 * -1 = ���顼
6161 *
6162 * Revision history: Ver 1.00
6163 *
6164 *:::DOC_END
6165 */
js_yosoku_reset_pre_yosoku(struct wnn_env * env)6166 int js_yosoku_reset_pre_yosoku(struct wnn_env *env)
6167 {
6168 int x;
6169
6170 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6171 if(!CHECK_VERSION_WNN7) return(0);
6172
6173 /* �Ķ�ID���Ф������ */
6174 if(env == 0) return(-1);
6175 set_current_js(env->js_id);
6176
6177 handler_of_jserver_dead_env(env);
6178 if(env_wnn_errorno_eql) {
6179 return(-1);
6180 }
6181
6182 /* ���̻Ҥ��С������� */
6183 snd_env_head(env,JS_YOSOKU_RESET_PRE_YOSOKU);
6184
6185 /* �����Хåե���ե�å��� */
6186 snd_flush(env->js_id);
6187
6188 x = get4com(env->js_id);
6189 if (x != 0) {
6190 env_wnn_errorno_set = get4com(env->js_id);
6191 return -1;
6192 }
6193 return 0;
6194
6195 }
6196
6197 /*:::DOC_START
6198 *
6199 * Function Name: js_yosoku_ikkatsu_toroku
6200 *
6201 * Description : �����Ͽ (ɽ��ʸ�������)
6202 *
6203 * Parameter :
6204 * env : (In) �Ķ�����ǡ���
6205 * toroku_data : (In) ��Ͽ�ǡ���
6206 * size : (In) �ǡ���������
6207 *
6208 * Return value :
6209 * 0 = ���ェλ
6210 * -1 = ���顼
6211 *
6212 * Revision history: Ver 1.00
6213 *
6214 *:::DOC_END
6215 */
js_yosoku_ikkatsu_toroku(struct wnn_env * env,char * toroku_data,int size)6216 int js_yosoku_ikkatsu_toroku(struct wnn_env *env, char *toroku_data, int size)
6217 {
6218 int x;
6219 register int i, data;
6220
6221 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6222 if(!CHECK_VERSION_WNN7) return(0);
6223
6224 /* �Ķ�ID���Ф������ */
6225 if(env == 0) return(-1);
6226 set_current_js(env->js_id);
6227
6228 handler_of_jserver_dead_env(env);
6229 if(env_wnn_errorno_eql) {
6230 return(-1);
6231 }
6232
6233 /* ���̻Ҥ��С������� */
6234 snd_env_head(env,JS_YOSOKU_IKKATSU_TOROKU);
6235
6236 /* �ǡ������������С������� */
6237 JS_Put4Com(size, env->js_id);
6238
6239 /* �ǡ������С������� */
6240 for(i=0; i<size; i++){
6241 data = (int)*(toroku_data + i) & 0xff;
6242 JS_Put1Com(data, env->js_id);
6243 }
6244
6245 /* �����Хåե���ե�å��� */
6246 snd_flush(env->js_id);
6247
6248 /* �����С����饹�ơ���������� */
6249 x = get4com(env->js_id);
6250 if (x != 0){
6251 env_wnn_errorno_set = get4com(env->js_id); /* ���顼NO���� */
6252 return(-1);
6253 }
6254
6255 /* ���ェλ */
6256 return(0);
6257
6258 }
6259
6260 /*:::DOC_START
6261 *
6262 * Function Name: js_yosoku_ikkatsu_toroku_init
6263 *
6264 * Description : �����Ͽ�����
6265 *
6266 * Parameter :
6267 * env : (In) �Ķ�����ǡ���
6268 *
6269 * Return value :
6270 * 0 = ���ェλ
6271 * -1 = ���顼
6272 *
6273 * Revision history: Ver 1.00
6274 *
6275 *:::DOC_END
6276 */
js_yosoku_ikkatsu_toroku_init(struct wnn_env * env)6277 int js_yosoku_ikkatsu_toroku_init(struct wnn_env *env)
6278 {
6279 int x;
6280
6281 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6282 if(!CHECK_VERSION_WNN7) return(0);
6283
6284 if(env==0) return(-1);
6285 set_current_js(env->js_id);
6286
6287 handler_of_jserver_dead_env(env);
6288 if(env_wnn_errorno_eql) {
6289 return(-1);
6290 }
6291
6292 /* ���̻Ҥ��С������� */
6293 snd_env_head(env,JS_YOSOKU_IKKATSU_TOROKU_INIT);
6294 snd_flush(env->js_id);
6295
6296 /* �����С����饹�ơ���������� */
6297 x=get4com(env->js_id);
6298 if (x != 0) {
6299 env_wnn_errorno_set = get4com(env->js_id);
6300 return -1;
6301 }
6302
6303 /* ���ェλ */
6304 return(0);
6305 }
6306
6307 /*:::DOC_START
6308 *
6309 * Function Name: js_yosoku_ikkatsu_toroku_end
6310 *
6311 * Description : �����Ͽ��λ
6312 *
6313 * Parameter :
6314 * env : (In) �Ķ�����ǡ���
6315 *
6316 * Return value :
6317 * 0 = ���ェλ
6318 * -1 = ���顼
6319 *
6320 * Revision history: Ver 1.00
6321 *
6322 *:::DOC_END
6323 */
js_yosoku_ikkatsu_toroku_end(struct wnn_env * env)6324 int js_yosoku_ikkatsu_toroku_end(struct wnn_env *env)
6325 {
6326 int x;
6327
6328 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6329 if(!CHECK_VERSION_WNN7) return(0);
6330
6331 if(env==0) return(-1);
6332 set_current_js(env->js_id);
6333
6334 handler_of_jserver_dead_env(env);
6335 if(env_wnn_errorno_eql) {
6336 return(-1);
6337 }
6338
6339 /* ���̻Ҥ��С������� */
6340 snd_env_head(env,JS_YOSOKU_IKKATSU_TOROKU_END);
6341 snd_flush(env->js_id);
6342
6343 /* �����С����饹�ơ���������� */
6344 x=get4com(env->js_id);
6345 if (x != 0) {
6346 env_wnn_errorno_set = get4com(env->js_id);
6347 return -1;
6348 }
6349
6350 /* ���ェλ */
6351 return(0);
6352 }
6353
6354 /*:::DOC_START
6355 *
6356 * Function Name: js_yosoku_save_datalist
6357 *
6358 * Description : ͽ¬�ǡ�����¸
6359 *
6360 * Parameter :
6361 * env : (In) �Ķ�����ǡ���
6362 *
6363 * Return value :
6364 * 0 = ���ェλ
6365 * -1 = ���顼
6366 *
6367 * Revision history: Ver 1.00
6368 *
6369 *:::DOC_END
6370 */
js_yosoku_save_datalist(struct wnn_env * env)6371 int js_yosoku_save_datalist(struct wnn_env *env)
6372 {
6373 int x;
6374
6375 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6376 if(!CHECK_VERSION_WNN7) return(0);
6377
6378 /* �Ķ�ID���Ф������ */
6379 if(env == 0) return(-1);
6380 set_current_js(env->js_id);
6381
6382 handler_of_jserver_dead_env(env);
6383 if(env_wnn_errorno_eql) {
6384 return(-1);
6385 }
6386
6387 /* ���̻Ҥ��С������� */
6388 snd_env_head(env,JS_YOSOKU_SAVE_DATALIST);
6389
6390 /* �����Хåե���ե�å��� */
6391 snd_flush(env->js_id);
6392
6393 x = get4com(env->js_id);
6394 if (x != 0) {
6395 env_wnn_errorno_set = get4com(env->js_id);
6396 return -1;
6397 }
6398 return 0;
6399
6400 }
6401
6402
6403 /*:::DOC_START
6404 *
6405 * Function Name: js_yosoku_init_time_keydata
6406 *
6407 * Description : �������Ͽ�������ϻ��֤ν����
6408 *
6409 * Parameter :
6410 * env : (In) �Ķ�����ǡ���
6411 *
6412 * Return value :
6413 * 0 = ���ェλ
6414 * -1 = ���顼
6415 *
6416 * Revision history: Ver 1.00
6417 *
6418 *:::DOC_END
6419 */
js_yosoku_init_time_keydata(struct wnn_env * env)6420 int js_yosoku_init_time_keydata(struct wnn_env *env)
6421 {
6422 int x;
6423
6424 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6425 if(!CHECK_VERSION_WNN7) return(0);
6426
6427 /* �Ķ�ID���Ф������ */
6428 if(env == 0) return(-1);
6429 set_current_js(env->js_id);
6430
6431 handler_of_jserver_dead_env(env);
6432 if(env_wnn_errorno_eql) {
6433 return(-1);
6434 }
6435
6436 /* ���̻Ҥ��С������� */
6437 snd_env_head(env,JS_YOSOKU_INIT_TIME_KEYDATA);
6438
6439 /* �����Хåե���ե�å��� */
6440 snd_flush(env->js_id);
6441
6442 x = get4com(env->js_id);
6443 if (x != 0) {
6444 env_wnn_errorno_set = get4com(env->js_id);
6445 return -1;
6446 }
6447 return 0;
6448 }
6449
6450 /*:::DOC_START
6451 *
6452 * Function Name: js_yosoku_init_inputinfo
6453 *
6454 * Description : ���ϻ��֤˴�Ϣ�����ѿ�������
6455 *
6456 * Parameter :
6457 * env : (In) �Ķ�����ǡ���
6458 *
6459 * Return value :
6460 * 0 = ���ェλ
6461 * -1 = ���顼
6462 *
6463 * Revision history: Ver 1.00
6464 *
6465 *:::DOC_END
6466 */
js_yosoku_init_inputinfo(struct wnn_env * env)6467 int js_yosoku_init_inputinfo(struct wnn_env *env)
6468 {
6469 int x;
6470
6471 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6472 if(!CHECK_VERSION_WNN7) return(0);
6473
6474 /* �Ķ�ID���Ф������ */
6475 if(env == 0) return(-1);
6476 set_current_js(env->js_id);
6477
6478 handler_of_jserver_dead_env(env);
6479 if(env_wnn_errorno_eql) {
6480 return(-1);
6481 }
6482
6483 /* ���̻Ҥ��С������� */
6484 snd_env_head(env,JS_YOSOKU_INIT_INPUTINFO);
6485
6486 /* �����Хåե���ե�å��� */
6487 snd_flush(env->js_id);
6488
6489 x = get4com(env->js_id);
6490 if (x != 0) {
6491 env_wnn_errorno_set = get4com(env->js_id);
6492 return -1;
6493 }
6494 return 0;
6495 }
6496
6497 /*:::DOC_START
6498 *
6499 * Function Name: js_yosoku_set_user_inputinfo
6500 *
6501 * Description : �������Ͽ�����å�
6502 *
6503 * Parameter :
6504 * env : (In) �Ķ�����ǡ���
6505 * allkey : (In) ͽ¬��ޤ�������Ͽ�
6506 * userkey : (In) �桼�����ºݤ����Ϥ����������Ͽ�
6507 *
6508 * Return value :
6509 * 0 = ���ェλ
6510 * -1 = ���顼
6511 *
6512 * Revision history: Ver 1.00
6513 *
6514 *:::DOC_END
6515 */
js_yosoku_set_user_inputinfo(struct wnn_env * env,int allkey,int userkey)6516 int js_yosoku_set_user_inputinfo(struct wnn_env *env, int allkey, int userkey)
6517 {
6518 int x;
6519
6520 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6521 if(!CHECK_VERSION_WNN7) return(0);
6522
6523 /* �Ķ�ID���Ф������ */
6524 if(env == 0) return(-1);
6525 set_current_js(env->js_id);
6526
6527 handler_of_jserver_dead_env(env);
6528 if(env_wnn_errorno_eql) {
6529 return(-1);
6530 }
6531
6532 /* ���̻Ҥ��С������� */
6533 snd_env_head(env,JS_YOSOKU_SET_USER_INPUTINFO);
6534
6535 /* ͽ¬��ޤ�������Ͽ������� */
6536 JS_Put4Com(allkey, env->js_id);
6537
6538 /* �桼�����ºݤ����Ϥ����������Ͽ������� */
6539 JS_Put4Com(userkey, env->js_id);
6540
6541 /* �����Хåե���ե�å��� */
6542 snd_flush(env->js_id);
6543
6544 x = get4com(env->js_id);
6545 if (x != 0) {
6546 env_wnn_errorno_set = get4com(env->js_id);
6547 return -1;
6548 }
6549 return 0;
6550 }
6551
6552 /*:::DOC_START
6553 *
6554 * Function Name: js_yosoku_set_timeinfo
6555 *
6556 * Description : �������ϻ��֤å�
6557 *
6558 * Parameter :
6559 * env : (In) �Ķ�����ǡ���
6560 * yosokuselect : (In) ��������Ƥ��뤫�ե饰
6561 * throughyosoku : (In) ��������������ե饰
6562 * inputtime : (In) ���ϻ���
6563 * keylen : (In) ��������
6564 *
6565 * Return value :
6566 * 0 = ���ェλ
6567 * -1 = ���顼
6568 *
6569 * Revision history: Ver 1.00
6570 *
6571 *:::DOC_END
6572 */
js_yosoku_set_timeinfo(struct wnn_env * env,int yosokuselect,int throughyosoku,unsigned int inputtime,int keylen)6573 int js_yosoku_set_timeinfo(struct wnn_env *env, int yosokuselect, int throughyosoku, unsigned int inputtime, int keylen)
6574 {
6575 int x;
6576
6577 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6578 if(!CHECK_VERSION_WNN7) return(0);
6579
6580 /* �Ķ�ID���Ф������ */
6581 if(env == 0) return(-1);
6582 set_current_js(env->js_id);
6583
6584 handler_of_jserver_dead_env(env);
6585 if(env_wnn_errorno_eql) {
6586 return(-1);
6587 }
6588
6589 /* ���̻Ҥ��С������� */
6590 snd_env_head(env,JS_YOSOKU_SET_TIMEINFO);
6591
6592 /* �ѥ������� */
6593 JS_Put4Com(yosokuselect, env->js_id);
6594 JS_Put4Com(throughyosoku, env->js_id);
6595 JS_Put4Com((int)inputtime, env->js_id);
6596 JS_Put4Com(keylen, env->js_id);
6597
6598 /* �����Хåե���ե�å��� */
6599 snd_flush(env->js_id);
6600
6601 x = get4com(env->js_id);
6602 if (x != 0) {
6603 env_wnn_errorno_set = get4com(env->js_id);
6604 return -1;
6605 }
6606 return 0;
6607 }
6608
6609 /*:::DOC_START
6610 *
6611 * Function Name: js_yosoku_status
6612 *
6613 * Description : ����ͽ¬��Ψ�ǡ�������
6614 *
6615 * Parameter :
6616 * env : (In) �Ķ�����ǡ���
6617 * ykinfo : (Out) ����ͽ¬��Ψ�ǡ�����¤��
6618 *
6619 * Return value :
6620 * 0 = ���ェλ
6621 * -1 = ���顼
6622 *
6623 * Revision history: Ver 1.00
6624 *
6625 *:::DOC_END
6626 */
js_yosoku_status(struct wnn_env * env,struct wnn_yosoku_info * ykinfo)6627 int js_yosoku_status(struct wnn_env *env, struct wnn_yosoku_info *ykinfo)
6628 {
6629 /* �����Ф� Wnn7 �Ǥʤ����ϲ��⤷�ʤ� */
6630 if(!CHECK_VERSION_WNN7) return(0);
6631
6632 /* �Ķ�ID���Ф������ */
6633 if(env == 0) return(-1);
6634 set_current_js(env->js_id);
6635
6636 handler_of_jserver_dead_env(env);
6637 if(env_wnn_errorno_eql) {
6638 return(-1);
6639 }
6640
6641 /* ���̻Ҥ��С������� */
6642 snd_env_head(env,JS_YOSOKU_STATUS);
6643
6644 /* �����Хåե���ե�å��� */
6645 snd_flush(env->js_id);
6646
6647 ykinfo->nTotalRod = get4com(env->js_id);
6648 ykinfo->nTotalAllKey = get4com(env->js_id);
6649 ykinfo->nTotalUserKey = get4com(env->js_id);
6650 ykinfo->nTotalRot = get4com(env->js_id);
6651 ykinfo->nTotalAllTime = get4com(env->js_id);
6652 ykinfo->nTotalUserTime = get4com(env->js_id);
6653 ykinfo->st_mday = get4com(env->js_id);
6654 ykinfo->st_hour = get4com(env->js_id);
6655 ykinfo->st_min = get4com(env->js_id);
6656 ykinfo->lt_mday = get4com(env->js_id);
6657 ykinfo->lt_hour = get4com(env->js_id);
6658 ykinfo->lt_min = get4com(env->js_id);
6659 ykinfo->nTotalRoYkInput = get4com(env->js_id);
6660 ykinfo->nTotalAllYkKey = get4com(env->js_id);
6661 ykinfo->nNowRod = get4com(env->js_id);
6662 ykinfo->nNowAllKey = get4com(env->js_id);
6663 ykinfo->nNowUserKey = get4com(env->js_id);
6664 ykinfo->nNowRot = get4com(env->js_id);
6665 ykinfo->nNowAllTime = get4com(env->js_id);
6666 ykinfo->nNowUserTime = get4com(env->js_id);
6667 ykinfo->nTimePerOneKey = get4com(env->js_id);
6668
6669 return 0;
6670 }
6671
6672 /*:::DOC_START
6673 *
6674 * Function Name : js_assoc_with_data()
6675 * Description : Ϣ���Ѵ���protocol���������
6676 *
6677 * Parameter :
6678 * env : �Ķ��ؤ�pointer
6679 * fuku : ʣ���ͥ��flag
6680 * nhinsi : ���ꤵ�줿�ʻ�ο�
6681 * hlist : �ʻ�list
6682 * henkan : �Ѵ��μ���
6683 * yomi : �ɤ�
6684 * hinsi : ľ����ʸ����ʻ�
6685 * fzk : ľ����ʸ�����°��
6686 * vec : vector
6687 * vec1 : vector
6688 * vec2 : vector
6689 * cur_bun : �о�ʸ��
6690 * yomi_orig : ��Ȥ�Ȥ��ɤ�
6691 * rb_l : �Ѵ���̤��֤���¤��
6692 *
6693 * Return Value : server������������ο�
6694 * Revision History:
6695 *
6696 *:::DOC_END
6697 */
6698 int
js_assoc_with_data(env,fuku,nhinsi,henkan,yomi,hinsi,fzk,vec,vec1,vec2,cur_bun,yomi_orig,rb_l)6699 js_assoc_with_data(env, fuku, nhinsi, henkan, yomi, hinsi,
6700 fzk, vec, vec1, vec2, cur_bun, yomi_orig, rb_l)
6701 struct wnn_env *env;
6702 int fuku, nhinsi, henkan;
6703 w_char *yomi;
6704 int hinsi;
6705 w_char *fzk;
6706 int vec, vec1, vec2;
6707 WNN_BUN *cur_bun;
6708 w_char *yomi_orig;
6709 struct wnn_ret_buf *rb_l;
6710 {
6711 int sbncnt;
6712
6713 if(env==0) return(-1);
6714 set_current_js(env->js_id);
6715 handler_of_jserver_dead_env(env);
6716
6717 if(env_wnn_errorno_eql) {
6718 return(-1);
6719 }
6720
6721 snd_env_head(env,JS_HENKAN_ASSOC);
6722 /* �Ѵ����ʸ���� */
6723 putwscom(yomi, (ARGS *)(env->js_id));
6724 put_fzk_vec(hinsi,fzk,vec,vec1, (ARGS *)(env->js_id));
6725 /* �Ѵ���μ�Ω����ʻ� */
6726 JS_Put4Com(cur_bun->hinsi, (ARGS *)env->js_id);
6727 /* for ret_kangovect in jserver */
6728 /* �Ѵ��ɤ�ʸ������Ф��������� ����� ������ ���Ϥ� */
6729 putwscom(yomi_orig, (ARGS *)env->js_id);
6730 /* for ret_yomi_orig[i] in jserver */
6731 /* �Ѵ����μ�Ω����ɤߤ�Ĺ�� */
6732 JS_Put4Com(cur_bun->jirilen, (ARGS *)env->js_id);
6733 /* for ret_jirilen_orig in jserver */
6734 /* �Ѵ������ɤߤ�Ĺ�� */
6735 JS_Put4Com(cur_bun->yomilen, (ARGS *)env->js_id);
6736 /* for ret_yomilen_orig in jserver */
6737 /* �Ѵ�����ɤߤ�Ĺ�� */
6738 JS_Put4Com(cur_bun->kanjilen, (ARGS *)env->js_id);
6739 /* for ret_kanjilen_orig in jserver */
6740 /* �Ѵ���μ�Ω���Ĺ�� */
6741 JS_Put4Com(cur_bun->real_kanjilen, (ARGS *)env->js_id);
6742 /* for ret_real_kanjilen_orig in jserver */
6743
6744 snd_flush((ARGS *)env->js_id);
6745
6746 sbncnt = rcv_sho(rb_l, (ARGS *)(env->js_id));
6747
6748 return sbncnt;
6749 }
6750 /* End of js_assoc_with_data() */
6751
6752 /*:::DOC_START
6753 *
6754 * Function Name : js_set_henkan_hinsi_group()
6755 * Description : �Ѵ��˻Ȥ����Ȥ�ʤ��ʻ�����ꤹ�롣
6756 *
6757 * Parameter :
6758 * env : �Ķ��ؤΥݥ���
6759 * hinsi : �ʻ��ֹ�
6760 * start : ʣ���ʻ줬������Ρ��ʻ��ֹ���ϰϤ���Ƭ
6761 * end : ʣ���ʻ줬������Ρ��ʻ��ֹ���ϰϤ�����
6762 * use : True:�Ȥ� FalSe:�Ȥ�ʤ�
6763 *
6764 * Return Value : 0==SUCCESS, -1==ERROR
6765 * Revision History:
6766 *
6767 *:::DOC_END
6768 */
6769 int
js_set_henkan_hinsi_group(env,hinsi,start,end,use)6770 js_set_henkan_hinsi_group(env, hinsi, start, end, use)
6771 struct wnn_env_int *env;
6772 int hinsi;
6773 int start;
6774 int use;
6775 {
6776 int *hlist;
6777 int ii;
6778 int nhinsi;
6779 int ret;
6780
6781 if (start > end)
6782 return -1;
6783 hlist = (int *)malloc((1 + end - start + 1 + 1) * sizeof(int));
6784 if (!hlist)
6785 return -1;
6786
6787 nhinsi = 0;
6788 hlist[nhinsi++] = hinsi;
6789 for (ii = start; ii <= end ; ii++)
6790 hlist[nhinsi++] = ii;
6791 hlist[nhinsi] = 0;
6792
6793 /* use == FALSE �����Ѵ��˻��Ѥ��ʤ��ʻ�ˤ��� */
6794 if (!use)
6795 nhinsi *= -1;
6796 if(js_set_henkan_hinsi(env, 1, nhinsi, hlist) < 0)
6797 ret = -1;
6798 else
6799 ret = 0;
6800 free(hlist);
6801 return ret;
6802 }
6803