0
|
1 /*
|
|
2 * $Id: js.c,v 1.16 2005/04/10 15:26:37 aonoto Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright FreeWnn Project 1999, 2000, 2001, 2002, 2003
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
|
|
16 *
|
|
17 * This library is free software; you can redistribute it and/or
|
|
18 * modify it under the terms of the GNU Lesser General Public
|
|
19 * License as published by the Free Software Foundation; either
|
|
20 * version 2 of the License, or (at your option) any later version.
|
|
21 *
|
|
22 * This library is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
25 * Lesser General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU Lesser General Public
|
|
28 * License along with this library; if not, write to the
|
|
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
30 * Boston, MA 02111-1307, USA.
|
|
31 */
|
|
32
|
|
33 /*
|
|
34 Nihongo Henkan Library
|
|
35 */
|
|
36 /*
|
|
37 entry functions
|
|
38
|
|
39 js_open_lang js_close
|
|
40 js_change_current_jserver
|
|
41 js_connect_lang js_disconnect
|
|
42 js_isconnect
|
|
43
|
|
44 js_param_get js_param_set
|
|
45
|
|
46 js_access js_mkdir
|
|
47
|
|
48 js_get_lang js_set_lang
|
|
49
|
|
50
|
|
51 extern Variables
|
|
52 int wnn_errorno;
|
|
53 */
|
|
54
|
|
55 #if defined(HAVE_CONFIG_H)
|
|
56 #include <config.h>
|
|
57 #endif
|
|
58
|
|
59 #include <stdio.h>
|
|
60 #include <ctype.h>
|
|
61 #include <errno.h>
|
|
62 #include <signal.h>
|
|
63 #if STDC_HEADERS
|
|
64 # include <stdlib.h>
|
|
65 # include <string.h>
|
|
66 #else
|
|
67 # if HAVE_MALLOC_H
|
|
68 # include <malloc.h>
|
|
69 # endif
|
|
70 # if HAVE_STRINGS_H
|
|
71 # include <strings.h>
|
|
72 # endif
|
|
73 #endif /* STDC_HEADERS */
|
|
74 #if HAVE_FCNTL_H
|
|
75 # include <fcntl.h>
|
|
76 #endif
|
|
77 #include <pwd.h>
|
|
78 #if HAVE_UNISTD_H
|
|
79 # include <unistd.h>
|
|
80 #endif
|
|
81 #include <sys/stat.h>
|
|
82 #include <sys/types.h>
|
|
83
|
|
84 #include "jd_sock.h"
|
|
85 #include "commonhd.h"
|
|
86 #include "demcom.h"
|
|
87 #include "wnn_config.h"
|
|
88
|
|
89 #include "wnnerror.h"
|
|
90 #include "jslib.h"
|
|
91 #include "jh.h"
|
|
92
|
|
93 #include "msg.h"
|
|
94
|
|
95 #define JS /* For include ../etc/bdic.c */
|
|
96 #include "../etc/bdic.c"
|
|
97 #include "../etc/pwd.c"
|
|
98
|
|
99 /* defined in wnn_os.h & should be modified in the future */
|
|
100 /* #define bzero(adr,n) memset((adr),0,(n)) */
|
|
101
|
|
102 int wnn_errorno = 0;
|
|
103 struct msg_cat *wnn_msg_cat = NULL;
|
|
104
|
|
105 /* j Lib. */
|
|
106
|
|
107 static int current_sd; /** ¥½¥±¥Ã¥Èfd **/
|
|
108 static WNN_JSERVER_ID *current_js = NULL;
|
|
109
|
|
110
|
|
111 /* Packet Buffers */
|
|
112 static unsigned char snd_buf[S_BUF_SIZ]; /** Á÷¿® **/
|
|
113 static int sbp = 0; /** Á÷¿®¥Ð¥Ã¥Õ¥¡¡¼¥Ý¥¤¥ó¥¿¡¼ **/
|
|
114 static int rbc = -1; /** ¼õ¿®¥Ð¥Ã¥Õ¥¡¡¼¥Ý¥¤¥ó¥¿¡¼ **/
|
|
115
|
|
116 #if defined(EAGAIN)
|
|
117 # if defined(EWOULDBLOCK)
|
|
118 # define ERRNO_CHECK(no) ((no) == EAGAIN || (no) == EWOULDBLOCK)
|
|
119 # else /* defined(EWOULDBLOCK) */
|
|
120 # define ERRNO_CHECK(no) ((no) == EAGAIN)
|
|
121 # endif /* defined(EWOULDBLOCK) */
|
|
122 #else /* defined(EAGAIN) */
|
|
123 # if defined(EWOULDBLOCK)
|
|
124 # define ERRNO_CHECK(no) ((no) == EWOULDBLOCK)
|
|
125 # else /* defined(EWOULDBLOCK) */
|
|
126 # define ERRNO_CHECK(no) (0)
|
|
127 # endif /* defined(EWOULDBLOCK) */
|
|
128 #endif /* defined(EAGAIN) */
|
|
129
|
|
130 static void connect_timeout ();
|
|
131 static int _get_server_name ();
|
|
132 static int writen ();
|
|
133 static char *get_unixdomain_of_serv_defs (), *get_service_of_serv_defs ();
|
|
134 static int get_port_num_of_serv_defs ();
|
|
135 #if DEBUG
|
|
136 void xerror ();
|
|
137 #endif
|
|
138
|
|
139 /********* V4 *****************/
|
|
140 /***
|
|
141 jserver_dead Macro
|
|
142 ***/
|
|
143
|
|
144 static jmp_buf current_jserver_dead;
|
|
145
|
|
146 #define handler_of_jserver_dead(err_val) \
|
|
147 { \
|
|
148 if (current_js) { \
|
|
149 if(current_js->js_dead){wnn_errorno=WNN_JSERVER_DEAD;return err_val;}\
|
|
150 if(setjmp(current_jserver_dead)){ \
|
|
151 wnn_errorno=WNN_JSERVER_DEAD; \
|
|
152 return err_val; \
|
|
153 } \
|
|
154 wnn_errorno = 0; /* here initialize wnn_errorno; */ \
|
|
155 } \
|
|
156 }
|
|
157
|
|
158 static void
|
|
159 set_current_js (server)
|
|
160 register WNN_JSERVER_ID *server;
|
|
161 {
|
|
162 current_js = server;
|
|
163 current_sd = current_js->sd;
|
|
164 }
|
|
165
|
|
166 /** ¥Ç¡¼¥â¥ó¤¬»à¤ó¤À»þ¤Î¤¿¤á¤Î¸å»ÏËö **/
|
|
167 static void
|
|
168 daemon_dead ()
|
|
169 {
|
|
170 current_js->js_dead = -1;
|
|
171 wnn_errorno = WNN_JSERVER_DEAD;
|
|
172 shutdown (current_sd, 2);
|
|
173 #ifdef HAVE_CLOSESOCKET
|
|
174 closesocket (current_sd);
|
|
175 #else
|
|
176 close (current_sd);
|
|
177 #endif
|
|
178 #if DEBUG
|
|
179 fprintf (stderr, "jslib:JSERVER %s is Dead\n", current_js->js_name);
|
|
180 #endif
|
|
181 if (current_js->js_dead_env_flg)
|
|
182 {
|
|
183 longjmp (current_js->js_dead_env, 666);
|
|
184 }
|
|
185 longjmp (current_jserver_dead, 666);
|
|
186 /* never reach */
|
|
187 }
|
|
188
|
|
189
|
|
190 /**
|
|
191 ¥½¥±¥Ã¥È¤ò¥ª¡¼¥×¥ó¤·¤Æcurrent_sd¤Ë¥½¥±¥Ã¥Èfd¤òÊÖ¤¹
|
|
192 (cd¤È¤¤¤¦¤Î¤Ï¥³¥ß¥å¥Ë¥±¡¼¥·¥ç¥ó¥Ç¥Ð¥¤¥¹¤Î̾»Ä)
|
|
193 **/
|
|
194 static int
|
|
195 cd_open_un (lang)
|
|
196 register char *lang;
|
|
197 {
|
|
198 #ifdef AF_UNIX
|
|
199 int sd;
|
|
200 struct sockaddr_un saddr; /** ¥½¥±¥Ã¥È **/
|
|
201 char *sock_name = NULL;
|
|
202 saddr.sun_family = AF_UNIX;
|
|
203
|
|
204 /* find socket name from table by lang */
|
|
205 if (lang && *lang)
|
|
206 {
|
|
207 if ((sock_name = get_unixdomain_of_serv_defs (lang)) == NULL)
|
|
208 {
|
|
209 sock_name = sockname;
|
|
210 }
|
|
211 }
|
|
212 else
|
|
213 {
|
|
214 sock_name = sockname; /* Jserver */
|
|
215 }
|
|
216 strcpy (saddr.sun_path, sock_name);
|
|
217
|
|
218 if ((sd = socket (AF_UNIX, SOCK_STREAM, 0)) == ERROR)
|
|
219 {
|
|
220 #if DEBUG
|
|
221 xerror ("jslib:Can't create unix domain socket.\n");
|
|
222 #endif
|
|
223 return -1;
|
|
224 }
|
|
225
|
|
226 #if !defined(SUN_LEN)
|
|
227 # define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
|
|
228 #endif
|
|
229 if (connect (sd, (struct sockaddr *) &saddr, SUN_LEN (&saddr)) == ERROR)
|
|
230 {
|
|
231
|
|
232 #if DEBUG
|
|
233 xerror ("jslib:Can't connect unix domain socket.\n");
|
|
234 #endif
|
|
235 close (sd);
|
|
236 return -1;
|
|
237 }
|
|
238 return sd;
|
|
239 #else
|
|
240 return -1;
|
|
241 #endif
|
|
242 }
|
|
243
|
|
244 static int
|
|
245 cd_open_in (server, lang, timeout)
|
|
246 register char *server;
|
|
247 register char *lang;
|
|
248 register int timeout;
|
|
249 {
|
|
250 int sd;
|
|
251 #ifdef INET6
|
|
252 struct addrinfo hints, *res, *res0;
|
|
253 int error;
|
|
254 char sport[6];
|
|
255 #else
|
|
256 struct sockaddr_in saddr_in; /** ¥½¥±¥Ã¥È **/
|
|
257 register struct hostent *hp;
|
|
258 #endif
|
|
259 struct servent *sp = NULL;
|
|
260 int serverNO, port_num;
|
|
261 int ret;
|
|
262 char pserver[64];
|
|
263 char sserver[64];
|
|
264 char *serv_name = NULL;
|
|
265
|
|
266 serverNO = _get_server_name (server, pserver);
|
|
267
|
|
268 /* find service name from table by lang */
|
|
269 if (lang && *lang)
|
|
270 {
|
|
271 if ((serv_name = get_service_of_serv_defs (lang)) == NULL)
|
|
272 {
|
|
273 strcpy (sserver, SERVERNAME);
|
|
274 }
|
|
275 else
|
|
276 {
|
|
277 strcpy (sserver, serv_name);
|
|
278 }
|
|
279 }
|
|
280 else
|
|
281 {
|
|
282 /*
|
|
283 serv_name = SERVERNAME;
|
|
284 */
|
|
285 strcpy (sserver, SERVERNAME);
|
|
286 }
|
|
287 /*
|
|
288 if ((sp = getservbyname(serv_name,"tcp")) != NULL) {
|
|
289 */
|
|
290 if ((sp = getservbyname (sserver, "tcp")) != NULL)
|
|
291 {
|
|
292 serverNO += ntohs (sp->s_port);
|
|
293 }
|
|
294 else
|
|
295 {
|
|
296 if ((port_num = get_port_num_of_serv_defs (lang)) == -1)
|
|
297 {
|
|
298 serverNO += WNN_PORT_IN;
|
|
299 }
|
|
300 else
|
|
301 {
|
|
302 serverNO += port_num;
|
|
303 }
|
|
304 }
|
|
305 #ifdef INET6
|
|
306 memset(&hints, 0, sizeof(hints));
|
|
307 hints.ai_family = PF_UNSPEC;
|
|
308 hints.ai_socktype = SOCK_STREAM;
|
|
309 sprintf(sport, "%d", serverNO);
|
|
310 error = getaddrinfo(pserver, sport, &hints, &res0);
|
|
311 if (error)
|
|
312 {
|
|
313 #if DEBUG
|
|
314 xerror (gai_strerror(error));
|
|
315 #endif
|
|
316 return -1;
|
|
317 }
|
|
318 for (res = res0; res ; res = res->ai_next) {
|
|
319 if (res->ai_family == AF_INET || res->ai_family == AF_INET6){
|
|
320 if ((sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) != ERROR){
|
|
321 #else
|
|
322 if ((hp = gethostbyname (pserver)) == NULL)
|
|
323 {
|
|
324 return -1;
|
|
325 }
|
|
326 bzero ((char *) &saddr_in, sizeof (saddr_in));
|
|
327 bcopy (hp->h_addr, (char *) &saddr_in.sin_addr, hp->h_length);
|
|
328 saddr_in.sin_family = AF_INET;
|
|
329 saddr_in.sin_port = htons (serverNO);
|
|
330 if ((sd = socket (AF_INET, SOCK_STREAM, 0)) == ERROR)
|
|
331 {
|
|
332 #if DEBUG
|
|
333 xerror ("jslib:Can't create inet socket.\n");
|
|
334 #endif
|
|
335 return -1;
|
|
336 }
|
|
337 #endif
|
|
338
|
|
339 if (timeout != 0 && timeout > 0)
|
|
340 {
|
|
341 signal (SIGALRM, connect_timeout);
|
|
342 alarm (timeout);
|
|
343 }
|
|
344 #ifdef INET6
|
|
345 ret = connect (sd, res->ai_addr, res->ai_addrlen);
|
|
346 #else
|
|
347 ret = connect (sd, (struct sockaddr *) &saddr_in, sizeof (saddr_in));
|
|
348 #endif
|
|
349 if (timeout != 0 && timeout > 0)
|
|
350 {
|
|
351 alarm (0);
|
|
352 signal (SIGALRM, SIG_IGN);
|
|
353 }
|
|
354 if (ret == ERROR)
|
|
355 {
|
|
356 #if DEBUG
|
|
357 #ifdef INET6
|
|
358 if (res->ai_family == AF_INET)
|
|
359 xerror ("jslib:Can't connect inet socket.\n");
|
|
360 else if (res->ai_family == AF_INET6)
|
|
361 xerror ("jslib:Can't connect inet6 socket.\n");
|
|
362 #else
|
|
363 xerror ("jslib:Can't connect inet socket.\n");
|
|
364 #endif
|
|
365 #endif
|
|
366 #ifdef HAVE_CLOSESOCKET
|
|
367 closesocket (sd);
|
|
368 #else
|
|
369 close (sd);
|
|
370 #endif
|
|
371 #ifdef INET6
|
|
372 sd = ERROR;
|
|
373 } else
|
|
374 break;
|
|
375 } else {
|
|
376 #if DEBUG
|
|
377 if (res->ai_family == AF_INET)
|
|
378 xerror ("jslib:Can't create inet socket.\n");
|
|
379 else if (res->ai_family == AF_INET6)
|
|
380 xerror ("jslib:Can't create inet6 socket.\n");
|
|
381 #endif
|
|
382 }
|
|
383 }
|
|
384 }
|
|
385 freeaddrinfo(res0);
|
|
386 if (sd == ERROR) {
|
|
387 #endif
|
|
388 return -1;
|
|
389 }
|
|
390 return sd;
|
|
391 }
|
|
392
|
|
393 static void
|
|
394 connect_timeout ()
|
|
395 {
|
|
396 }
|
|
397
|
|
398 /* get server name and return serverNo */
|
|
399 static int
|
|
400 _get_server_name (server, pserver)
|
|
401 char *server;
|
|
402 char *pserver;
|
|
403 {
|
|
404 register char *p;
|
|
405 #ifdef INET6
|
|
406 int len;
|
|
407
|
|
408 if (server[0] == '[') {
|
|
409 p = strchr(server++, ']');
|
|
410 if (p) {
|
|
411 len = p-server<64-1?p-server:64-1;
|
|
412 strncpy(pserver, server, len);
|
|
413 pserver[len] = '\0';
|
|
414 } else
|
|
415 pserver[0] = '\0';
|
|
416 } else {
|
|
417 #endif
|
|
418 /* Workaround for pserver buffer overrun : Nov 11,1999 by T.Aono */
|
|
419 /* assumes pserver[64]. variable length string is not supported. */
|
|
420 strncpy(pserver, server, 64-1);
|
|
421 pserver[64-1] = '\0';
|
|
422 p = pserver;
|
|
423 #ifdef INET6
|
|
424 }
|
|
425 #endif
|
|
426 for (; *p && *p != ':'; p++);
|
|
427 if (!*p)
|
|
428 return (0); /* does not have a colon */
|
|
429 *p = 0;
|
|
430 return (atoi (++p));
|
|
431 }
|
|
432
|
|
433 /* Packet SND/RCV subroutines */
|
|
434 static void put4com ();
|
|
435
|
|
436 /** ¥Ñ¥±¥Ã¥È¤Î¥Ø¥Ã¥À¡¼¤òÁ÷¤ë **/
|
|
437 static void
|
|
438 snd_head (cmd)
|
|
439 int cmd; /** cmd=¥³¥Þ¥ó¥É **/
|
|
440 {
|
|
441 sbp = 0;
|
|
442 put4com (cmd);
|
|
443 rbc = -1;
|
|
444 }
|
|
445
|
|
446 /** ¥Ñ¥±¥Ã¥È¤Î¥Ø¥Ã¥À¡¼¤òÁ÷¤ë **/
|
|
447 static int
|
|
448 snd_env_head (env, cmd)
|
|
449 register struct wnn_env *env;
|
|
450 int cmd; /** cmd=¥³¥Þ¥ó¥É **/
|
|
451 {
|
|
452 snd_head (cmd);
|
|
453 put4com (env->env_id);
|
|
454 return 0;
|
|
455 }
|
|
456
|
|
457 /** ¥Ñ¥±¥Ã¥È¤Î¥Ø¥Ã¥À¡¼¤òÁ÷¤ë **/
|
|
458 static int
|
|
459 snd_server_head (server, cmd)
|
|
460 register WNN_JSERVER_ID *server;
|
|
461 int cmd; /** cmd=¥³¥Þ¥ó¥É **/
|
|
462 {
|
|
463 snd_head (cmd);
|
|
464 return 0;
|
|
465 }
|
|
466
|
|
467 /** Á÷¿®¥Ð¥Ã¥Õ¥¡¤ò¥Õ¥é¥Ã¥·¥å¤¹¤ë **/
|
|
468 static int
|
|
469 snd_flush ()
|
|
470 {
|
|
471 if (sbp == 0)
|
|
472 return (-1);
|
|
473 writen (sbp);
|
|
474 sbp = 0;
|
|
475 return (0);
|
|
476 }
|
|
477
|
|
478 static int
|
|
479 writen (n)
|
|
480 int n;
|
|
481 {
|
|
482 int cc, x;
|
|
483 for (cc = 0; cc < n;)
|
|
484 {
|
|
485 errno = 0;
|
|
486 #ifdef HAVE_SEND
|
|
487 x = send (current_sd, &snd_buf[cc], n - cc, 0);
|
|
488 #else
|
|
489 x = write (current_sd, &snd_buf[cc], n - cc);
|
|
490 #endif
|
|
491 if (x < 0)
|
|
492 {
|
|
493 if (ERRNO_CHECK (errno) || errno == EINTR)
|
|
494 {
|
|
495 continue;
|
|
496 }
|
|
497 else
|
|
498 {
|
|
499 daemon_dead ();
|
|
500 return -1;
|
|
501 }
|
|
502 }
|
|
503 cc += x;
|
|
504 }
|
|
505 #if DEBUG
|
|
506 fprintf (stderr, "jslib:writen=%d\n", x);
|
|
507 /* dmp(snd_buf,x); */
|
|
508 #endif
|
|
509 return (0);
|
|
510 }
|
|
511
|
|
512 /** ¥µ¡¼¥Ð¤Ø1¥Ð¥¤¥ÈÁ÷¤ë **/
|
|
513 static void
|
|
514 put1com (c)
|
|
515 int c;
|
|
516 {
|
|
517 snd_buf[sbp++] = c;
|
|
518 if (sbp >= S_BUF_SIZ)
|
|
519 {
|
|
520 writen (S_BUF_SIZ);
|
|
521 sbp = 0;
|
|
522 }
|
|
523 }
|
|
524
|
|
525 /** ¥µ¡¼¥Ð¤Ø2¥Ð¥¤¥ÈÁ÷¤ë **/
|
|
526 static void
|
|
527 put2com (c)
|
|
528 int c;
|
|
529 {
|
|
530 put1com (c >> (8 * 1));
|
|
531 put1com (c);
|
|
532 }
|
|
533
|
|
534 /** ¥µ¡¼¥Ð¤Ø4¥Ð¥¤¥ÈÁ÷¤ë **/
|
|
535 static void
|
|
536 put4com (c)
|
|
537 int c;
|
|
538 {
|
|
539 put1com (c >> (8 * 3));
|
|
540 put1com (c >> (8 * 2));
|
|
541 put1com (c >> (8 * 1));
|
|
542 put1com (c);
|
|
543 }
|
|
544
|
|
545 /** ¥µ¡¼¥Ð¤Øʸ»úÎó¤òÁ÷¤ë **/
|
|
546 static void
|
|
547 putwscom (p)
|
|
548 register w_char *p;
|
|
549 {
|
|
550 if (p == NULL)
|
|
551 {
|
|
552 put2com (0);
|
|
553 return;
|
|
554 }
|
|
555 while (*p)
|
|
556 put2com (*p++);
|
|
557 put2com (0);
|
|
558 }
|
|
559
|
|
560 /** ¥µ¡¼¥Ð¤Øʸ»úÎó¤òÁ÷¤ë **/
|
|
561 static void
|
|
562 putscom (p)
|
|
563 register char *p;
|
|
564 {
|
|
565 if (p == NULL)
|
|
566 {
|
|
567 put1com (0);
|
|
568 return;
|
|
569 }
|
|
570 while (*p)
|
|
571 put1com (*p++);
|
|
572 put1com (0);
|
|
573 }
|
|
574
|
|
575 /** ¥µ¡¼¥Ð¤«¤é1¥Ð¥¤¥È¼õ¤±¤ë **/
|
|
576 static int
|
|
577 get1com ()
|
|
578 {
|
|
579 static int rbp;
|
|
580 static unsigned char rcv_buf[R_BUF_SIZ]; /** ¼õ¿® **/
|
|
581 if (rbc <= 0)
|
|
582 {
|
|
583 while (1)
|
|
584 {
|
|
585 errno = 0;
|
|
586 #ifdef HAVE_RECV
|
|
587 rbc = recv (current_sd, rcv_buf, R_BUF_SIZ, 0);
|
|
588 #else
|
|
589 rbc = read (current_sd, rcv_buf, R_BUF_SIZ);
|
|
590 #endif
|
|
591 if (rbc <= 0)
|
|
592 {
|
|
593 if (ERRNO_CHECK (errno))
|
|
594 {
|
|
595 continue;
|
|
596 }
|
|
597 else if (rbc == 0)
|
|
598 {
|
|
599 daemon_dead ();
|
|
600 return -1;
|
|
601 }
|
|
602 else
|
|
603 { /* cc == -1 */
|
|
604 if (errno != EINTR)
|
|
605 {
|
|
606 daemon_dead ();
|
|
607 return -1;
|
|
608 }
|
|
609 continue;
|
|
610 }
|
|
611 }
|
|
612 rbp = 0;
|
|
613 #if DEBUG
|
|
614 fprintf (stderr, "jslib:read:rbc=%d\n", rbc);
|
|
615 /* dmp(rcv_buf,rbc); */
|
|
616 #endif
|
|
617 break;
|
|
618 }
|
|
619 }
|
|
620 rbc--;
|
|
621 return rcv_buf[rbp++] & 0xFF;
|
|
622 }
|
|
623
|
|
624 /** ¥µ¡¼¥Ð¤«¤é2¥Ð¥¤¥È¼õ¤±¤ë **/
|
|
625 static int
|
|
626 get2com ()
|
|
627 {
|
|
628 register int h;
|
|
629 h = get1com ();
|
|
630 return (h << 8) | get1com ();
|
|
631 }
|
|
632
|
|
633 /** ¥µ¡¼¥Ð¤«¤é4¥Ð¥¤¥È¼õ¤±¤ë **/
|
|
634 static int
|
|
635 get4com ()
|
|
636 {
|
|
637 register int h1, h2, h3;
|
|
638 h1 = get1com () << 24;
|
|
639 h2 = get1com () << 16;
|
|
640 h3 = get1com () << 8;
|
|
641 return h1 | h2 | h3 | get1com ();
|
|
642 }
|
|
643
|
|
644 /** ¥µ¡¼¥Ð¤Øʸ»úÎó¤òÁ÷¤ë **/
|
|
645 static void
|
|
646 getscom (p)
|
|
647 register char *p;
|
|
648 {
|
5
|
649 while ((*p++ = get1com ()))
|
0
|
650 ;
|
|
651 }
|
|
652
|
|
653 /** ¥µ¡¼¥Ð¤Øʸ»úÎó¤òÁ÷¤ë **/
|
|
654 static void
|
|
655 getwscom (p)
|
|
656 w_char register *p;
|
|
657 {
|
5
|
658 while ((*p++ = get2com ()))
|
0
|
659 ;
|
|
660 }
|
|
661
|
|
662 #ifdef nodef
|
|
663 /* Moved from ../etc/string.c */
|
|
664 /** **/
|
|
665 static int
|
|
666 Strlen (s)
|
|
667 register w_char *s;
|
|
668 {
|
|
669 register int n;
|
|
670
|
|
671 for (n = 0; *s++ != 0; n++);
|
|
672 return n;
|
|
673 }
|
|
674
|
|
675 /** **/
|
|
676 static w_char *
|
|
677 Strcpy (s1, s2)
|
|
678 register w_char *s1;
|
|
679 register w_char *s2;
|
|
680 {
|
|
681 register w_char *d;
|
|
682
|
|
683 for (d = s1; (*d++ = *s2++) != 0;);
|
|
684 return s1;
|
|
685 }
|
|
686 #endif
|
|
687
|
|
688
|
|
689 /* Debug Subroutines */
|
|
690 #if DEBUG
|
|
691 void
|
|
692 xerror (s)
|
|
693 char *s;
|
|
694 {
|
|
695 fprintf (stderr, "%s\n", s);
|
|
696 }
|
|
697
|
|
698 void
|
|
699 dmp (p, c)
|
|
700 char *p;
|
|
701 {
|
|
702 int i, j;
|
|
703 for (i = 0;; i += 16)
|
|
704 {
|
|
705 for (j = 0; j < 16; j++)
|
|
706 {
|
|
707 if (c <= 0)
|
|
708 {
|
|
709 fprintf (stderr, "\n");
|
|
710 return;
|
|
711 }
|
|
712 fprintf (stderr, "%02x ", p[i + j] & 0xFF);
|
|
713 c--;
|
|
714 }
|
|
715 fprintf (stderr, "\n");
|
|
716 }
|
|
717 }
|
|
718
|
|
719 #endif
|
|
720
|
|
721 /* get login name form /etc/passwd file */
|
|
722 static char *
|
|
723 getlogname ()
|
|
724 {
|
|
725 struct passwd *getpwuid ();
|
|
726 return getpwuid (getuid ())->pw_name;
|
|
727 }
|
|
728
|
|
729
|
|
730
|
|
731
|
|
732 /*
|
|
733 * Lib. Functions
|
|
734 * raw lib.
|
|
735 */
|
|
736
|
|
737 /***
|
|
738 js
|
|
739 ¡¦global
|
|
740 ***/
|
|
741
|
|
742 /** jserver ¤ÈÀܳ¤¹¤ë¡£jserver_id ¤òÊÖ¤¹¡£ **/
|
|
743 WNN_JSERVER_ID *
|
|
744 js_open_lang (server, lang, timeout)
|
|
745 register char *server, *lang;
|
|
746 register int timeout;
|
|
747 {
|
|
748 char *new_js;
|
|
749 char host[WNN_HOSTLEN], user[WNN_ENVNAME_LEN];
|
|
750 int x;
|
|
751
|
|
752 if (wnn_msg_cat == NULL)
|
|
753 {
|
|
754 char nlspath[MAXPATHLEN];
|
|
755 strcpy (nlspath, LIBDIR);
|
|
756 strcat (nlspath, "/%L/%N");
|
|
757 wnn_msg_cat = msg_open ("libwnn.msg", nlspath, lang);
|
|
758 if (wnn_msg_cat == NULL)
|
|
759 {
|
|
760 fprintf (stderr, "libwnn: Cannot open message file for libwnn.a\n");
|
|
761 }
|
|
762 }
|
|
763 sbp = 0; /* init sndBufPointer */
|
|
764 if (!(new_js = (char *) malloc (sizeof (WNN_JSERVER_ID))))
|
|
765 {
|
|
766 wnn_errorno = WNN_ALLOC_FAIL;
|
|
767 return NULL;
|
|
768 }
|
|
769 current_js = (WNN_JSERVER_ID *) new_js;
|
|
770 if (server == NULL)
|
|
771 {
|
|
772 current_js->js_name[0] = '\0';
|
|
773 }
|
|
774 else
|
|
775 {
|
|
776 strncpy (current_js->js_name, server, sizeof (current_js->js_name) - 1);
|
|
777 current_js->js_name[sizeof (current_js->js_name) - 1] = '\0';
|
|
778 }
|
|
779 current_js->js_dead = 0;
|
|
780 current_js->js_dead_env_flg = 0;
|
|
781 /*
|
|
782 if(user == NULL || 0==strcmp(user,""))
|
|
783 */
|
|
784 strncpy (user, getlogname (), WNN_ENVNAME_LEN);
|
|
785 user[WNN_ENVNAME_LEN - 1] = '\0'; /* truncate by WNN_ENVNAME_LEN */
|
|
786 if (server == NULL || 0 == strcmp (server, "") || 0 == strcmp (server, "unix"))
|
|
787 {
|
|
788 strcpy (host, "unix");
|
|
789 if ((current_sd = cd_open_un (lang)) == -1)
|
|
790 {
|
|
791 wnn_errorno = WNN_SOCK_OPEN_FAIL;
|
|
792 free ((char *) current_js);
|
|
793 current_js = NULL;
|
|
794 return NULL;
|
|
795 }
|
|
796 }
|
|
797 else
|
|
798 {
|
|
799 gethostname (host, WNN_HOSTLEN);
|
|
800 host[WNN_HOSTLEN - 1] = '\0'; /* truncate by WNN_HOSTLEN */
|
|
801 if ((current_sd = cd_open_in (server, lang, timeout)) == -1)
|
|
802 {
|
|
803 wnn_errorno = WNN_SOCK_OPEN_FAIL;
|
|
804 free ((char *) current_js);
|
|
805 current_js = NULL;
|
|
806 return NULL;
|
|
807 }
|
|
808 }
|
|
809 current_js->sd = current_sd;
|
|
810 handler_of_jserver_dead (NULL);
|
|
811 snd_head (JS_OPEN);
|
|
812 put4com (JLIB_VERSION); /* H.T. */
|
|
813 putscom (host);
|
|
814 putscom (user);
|
|
815 snd_flush ();
|
|
816 if (get4com () == -1)
|
|
817 {
|
|
818 x = wnn_errorno = get4com ();
|
|
819 js_close (current_js); /* H.T. */
|
|
820 current_js = NULL;
|
|
821 wnn_errorno = x;
|
|
822 return NULL;
|
|
823 }
|
|
824 return current_js;
|
|
825 }
|
|
826
|
|
827
|
|
828 /** ¥½¥±¥Ã¥È¤ò¥¯¥í¡¼¥º¤¹¤ë **/
|
|
829 /** jserver ¤È¤ÎÀܳ¤ò close ¤¹¤ë¡£ **/
|
|
830 int
|
|
831 js_close (server)
|
|
832 WNN_JSERVER_ID *server;
|
|
833 {
|
|
834 register int x;
|
|
835 WNN_JSERVER_ID tmp_js_id;
|
|
836 if (server == 0)
|
|
837 return (-1);
|
|
838 tmp_js_id = *server;
|
|
839 free ((char *) server);
|
|
840 current_js = &tmp_js_id;
|
|
841 current_sd = current_js->sd;
|
|
842 /* handler of jserver dead */
|
|
843 handler_of_jserver_dead (-1);
|
|
844 snd_head (JS_CLOSE);
|
|
845 snd_flush ();
|
|
846 x = get4com ();
|
|
847 if (x == -1)
|
|
848 wnn_errorno = get4com ();
|
|
849 #ifdef HAVE_CLOSESOCKET
|
|
850 closesocket (current_sd);
|
|
851 #else
|
|
852 close (current_sd);
|
|
853 #endif
|
|
854 return x;
|
|
855 }
|
|
856
|
|
857
|
|
858 /*
|
|
859 jserver ¤È¤Î´Ö¤Ë connection ¤òÄ¥¤ê¡¢Æ±»þ¤Ë jserver ¤ÎÆâÉô¤Ë´Ä
|
|
860 ¶¤òºî¤ë¡£env_name ¤Ë´û¤Ë¸ºß¤¹¤ë´Ä¶¤ò»ØÄꤷ¤¿»þ¤Ë¤Ï¤½¤Î´Ä¶¤ò
|
|
861 ÊÖ¤·¡¢NULL ¤ò»ØÄꤷ¤¿»þ¤Ë¤Ï¿·¤·¤¤´Ä¶¤òºî¤Ã¤ÆÊÖ¤¹¡£
|
|
862 */
|
|
863
|
|
864 struct wnn_env *
|
|
865 js_connect_lang (server, env_name, lang)
|
|
866 register char *env_name;
|
|
867 WNN_JSERVER_ID *server;
|
|
868 char *lang;
|
|
869 {
|
|
870 register int e_id;
|
|
871 register struct wnn_env *env;
|
|
872 void js_set_lang ();
|
|
873
|
|
874 set_current_js (server);
|
|
875 if (!(env = (struct wnn_env *) malloc (sizeof (struct wnn_env))))
|
|
876 {
|
|
877 wnn_errorno = WNN_ALLOC_FAIL;
|
|
878 return NULL;
|
|
879 }
|
|
880 handler_of_jserver_dead (NULL);
|
|
881 snd_head (JS_CONNECT);
|
|
882 putscom (env_name);
|
|
883 snd_flush ();
|
|
884 e_id = get4com ();
|
|
885 if (e_id == -1)
|
|
886 {
|
|
887 wnn_errorno = get4com ();
|
|
888 free (env);
|
|
889 return NULL;
|
|
890 }
|
|
891 env->env_id = e_id;
|
|
892 env->js_id = server;
|
|
893 strcpy (env->lang, lang); /* set language name */
|
|
894 return env;
|
|
895 }
|
|
896
|
|
897 #ifdef nodef
|
|
898 /* set language value to env */
|
|
899 void
|
|
900 js_set_lang (env, lang)
|
|
901 struct wnn_env *env;
|
|
902 register char *lang;
|
|
903 {
|
|
904 register char *p;
|
|
905 extern char *getenv ();
|
|
906
|
|
907 /* if not specified language , use $LANG */
|
|
908 if (lang == 0 || *lang == 0)
|
|
909 lang = getenv ("LANG");
|
|
910 if (lang == 0 || *lang == 0)
|
|
911 lang = WNN_DEFAULT_LANG;
|
|
912 for (p = env->lang; *lang != '.' && *lang != '@' && *lang != 0; lang++, p++)
|
|
913 *p = *lang;
|
|
914 *p = 0;
|
|
915 }
|
|
916 #endif
|
|
917
|
|
918 /* get language value from env */
|
|
919 char *
|
|
920 js_get_lang (env)
|
|
921 struct wnn_env *env;
|
|
922 {
|
|
923 return (env->lang);
|
|
924 }
|
|
925
|
|
926 int
|
|
927 js_env_exist (server, env_name)
|
|
928 register char *env_name;
|
|
929 register WNN_JSERVER_ID *server;
|
|
930 {
|
|
931 set_current_js (server);
|
|
932 handler_of_jserver_dead (-1);
|
|
933 snd_head (JS_ENV_EXIST);
|
|
934 putscom (env_name);
|
|
935 snd_flush ();
|
|
936 return (get4com ());
|
|
937 }
|
|
938
|
|
939 int
|
|
940 js_env_sticky (env)
|
|
941 register struct wnn_env *env;
|
|
942 {
|
|
943 if (env == 0)
|
|
944 return (-1);
|
|
945 set_current_js (env->js_id);
|
|
946 handler_of_jserver_dead (-1);
|
|
947 snd_env_head (env, JS_ENV_STICKY);
|
|
948 snd_flush ();
|
|
949 return (get4com ());
|
|
950 }
|
|
951
|
|
952 int
|
|
953 js_env_un_sticky (env)
|
|
954 register struct wnn_env *env;
|
|
955 {
|
|
956 if (env == 0)
|
|
957 return (-1);
|
|
958 set_current_js (env->js_id);
|
|
959 handler_of_jserver_dead (-1);
|
|
960 snd_env_head (env, JS_ENV_UN_STICKY);
|
|
961 snd_flush ();
|
|
962 return (get4com ());
|
|
963 }
|
|
964
|
|
965 /**
|
|
966 env ¤Ç¼¨¤µ¤ì¤ë´Ä¶¤ò̵¤¯¤¹¡£
|
|
967 **/
|
|
968 int
|
|
969 js_disconnect (env)
|
|
970 register struct wnn_env *env;
|
|
971 {
|
|
972 register int x;
|
|
973 struct wnn_env tmp_env;
|
|
974 if (env == 0)
|
|
975 return (-1);
|
|
976 tmp_env = *env;
|
|
977 /* ËÜÍè¤Ï¡¢free ¤·¤Ê¤¤ã¤¢¤«¤ó¤Î¤À¤±¤É¡¢¥ê¥½¡¼¥¹´ÉÍý¤¬½ÐÍè¤Ê¤¤¤·¡¢
|
|
978 ¤Þ¤¢¡¢8¥Ð¥¤¥È¤À¤«¤é¡¢¥´¥ß¤¬»Ä¤ë¤±¤É¤¤¤¤¤À¤í¤¦¡£
|
|
979 free((char *)env);
|
|
980 */
|
|
981 set_current_js (env->js_id);
|
1
|
982 handler_of_jserver_dead (0);
|
0
|
983 snd_env_head (&tmp_env, JS_DISCONNECT);
|
|
984 snd_flush ();
|
|
985 x = get4com ();
|
|
986 if (x == -1)
|
|
987 {
|
|
988 wnn_errorno = get4com ();
|
|
989 }
|
|
990 return x;
|
|
991 }
|
|
992
|
|
993 /** ¥µ¡¼¥Ð¤È¥³¥Í¥¯¥È¤·¤Æ¤¤¤ë¤« **/
|
|
994 int
|
|
995 js_isconnect (env)
|
|
996 register struct wnn_env *env;
|
|
997 {
|
|
998 if (env && env->js_id)
|
|
999 return (env->js_id->js_dead);
|
|
1000 return (-1);
|
|
1001 }
|
|
1002
|
|
1003 /**
|
|
1004 env ¤Î ´Ä¶ ¤È¤ÎÄÌ¿®¥Ð¥Ã¥Õ¥¡¤ò flush ¤¹¤ë¡£
|
|
1005 **/
|
|
1006 void
|
|
1007 js_flush (env)
|
|
1008 struct wnn_env *env;
|
|
1009 {
|
|
1010 }
|
|
1011
|
|
1012
|
|
1013
|
|
1014 /* Parameter set/get */
|
|
1015 /** ÊÑ´¹ parameter ¤òÀßÄꤹ¤ë¡£ **/
|
|
1016 /** js_param_set **/
|
|
1017 int
|
|
1018 js_param_set (env, para)
|
|
1019 struct wnn_env *env;
|
|
1020 register struct wnn_param *para;
|
|
1021 {
|
|
1022 register int x;
|
|
1023 if (env == 0)
|
|
1024 return (-1);
|
|
1025 set_current_js (env->js_id);
|
|
1026 handler_of_jserver_dead (-1);
|
|
1027 snd_env_head (env, JS_PARAM_SET);
|
|
1028 put4com (para->n); /* £Î(Âç)ʸÀá²òÀϤΣΠ*/
|
|
1029 put4com (para->nsho); /* ÂçʸÀáÃæ¤Î¾®Ê¸Àá¤ÎºÇÂç¿ô */
|
|
1030 put4com (para->p1); /* ´´¸ì¤ÎÉÑÅ٤Υѥé¥á¡¼¥¿ */
|
|
1031 put4com (para->p2); /* ¾®Ê¸ÀáĹ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1032 put4com (para->p3); /* ´´¸ìĹ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1033 put4com (para->p4); /* º£»È¤Ã¤¿¤è¥Ó¥Ã¥È¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1034 put4com (para->p5); /* ¼½ñ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1035 put4com (para->p6); /* ¾®Ê¸Àá¤Îɾ²ÁÃͤΥѥé¥á¡¼¥¿ */
|
|
1036 put4com (para->p7); /* ÂçʸÀáĹ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1037 put4com (para->p8); /* ¾®Ê¸Àá¿ô¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1038
|
|
1039 put4com (para->p9); /* µ¿»÷ÉÊ»ì ¿ô»ú¤ÎÉÑÅÙ */
|
|
1040 put4com (para->p10); /* µ¿»÷ÉÊ»ì ¥«¥Ê¤ÎÉÑÅÙ *//* CWNN ±Ñ¿ô¤ÎÉÑÅÙ */
|
|
1041 put4com (para->p11); /* µ¿»÷ÉÊ»ì ±Ñ¿ô¤ÎÉÑÅÙ *//* CWNN µ¹æ¤ÎÉÑÅÙ */
|
|
1042 put4com (para->p12); /* µ¿»÷ÉÊ»ì µ¹æ¤ÎÉÑÅÙ *//* CWNN ³«³ç¸Ì¤ÎÉÑÅÙ */
|
|
1043 put4com (para->p13); /* µ¿»÷ÉÊ»ì Êijç¸Ì¤ÎÉÑÅÙ *//* CWNN Êijç¸Ì¤ÎÉÑÅÙ */
|
|
1044 put4com (para->p14); /* µ¿»÷ÉÊ»ì ÉÕ°¸ì¤ÎÉÑÅÙ *//* BWNN No of koho */
|
|
1045 put4com (para->p15); /* µ¿»÷ÉÊ»ì ³«³ç¸Ì¤ÎÉÑÅÙ *//* CWNN Not used */
|
|
1046
|
|
1047 snd_flush ();
|
|
1048 x = get4com ();
|
|
1049 if (x == -1)
|
|
1050 {
|
|
1051 wnn_errorno = get4com ();
|
|
1052 return -1;
|
|
1053 }
|
|
1054 return 0;
|
|
1055 }
|
|
1056
|
|
1057 /** js_param_get **/
|
|
1058 /** env ¤Ç¼¨¤µ¤ì¤ë´Ä¶¤ÎÊÑ´¹ parameter ¤ò¼è¤ê½Ð¤¹¡£ **/
|
|
1059 int
|
|
1060 js_param_get (env, para)
|
|
1061 struct wnn_env *env;
|
|
1062 register struct wnn_param *para;
|
|
1063 {
|
|
1064 if (env == 0)
|
|
1065 return (-1);
|
|
1066 set_current_js (env->js_id);
|
|
1067 handler_of_jserver_dead (-1);
|
|
1068 snd_env_head (env, JS_PARAM_GET);
|
|
1069 snd_flush ();
|
|
1070 if (get4com () == -1)
|
|
1071 {
|
|
1072 wnn_errorno = get4com ();
|
|
1073 return -1;
|
|
1074 }
|
|
1075 para->n = get4com (); /* £Î(Âç)ʸÀá²òÀϤΣΠ*/
|
|
1076 para->nsho = get4com (); /* ÂçʸÀáÃæ¤Î¾®Ê¸Àá¤ÎºÇÂç¿ô */
|
|
1077 para->p1 = get4com (); /* ´´¸ì¤ÎÉÑÅ٤Υѥé¥á¡¼¥¿ */
|
|
1078 para->p2 = get4com (); /* ¾®Ê¸ÀáĹ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1079 para->p3 = get4com (); /* ´´¸ìĹ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1080 para->p4 = get4com (); /* º£»È¤Ã¤¿¤è¥Ó¥Ã¥È¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1081 para->p5 = get4com (); /* ¼½ñ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1082 para->p6 = get4com (); /* ¾®Ê¸Àá¤Îɾ²ÁÃͤΥѥé¥á¡¼¥¿ */
|
|
1083 para->p7 = get4com (); /* ÂçʸÀáĹ¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1084 para->p8 = get4com (); /* ¾®Ê¸Àá¿ô¤Î¥Ñ¥é¥á¡¼¥¿ */
|
|
1085 para->p9 = get4com (); /* µ¿»÷ÉÊ»ì ¿ô»ú¤ÎÉÑÅÙ */
|
|
1086 para->p10 = get4com (); /* µ¿»÷ÉÊ»ì ¥«¥Ê¤ÎÉÑÅÙ */
|
|
1087 para->p11 = get4com (); /* µ¿»÷ÉÊ»ì ±Ñ¿ô¤ÎÉÑÅÙ */
|
|
1088 para->p12 = get4com (); /* µ¿»÷ÉÊ»ì µ¹æ¤ÎÉÑÅÙ */
|
|
1089 para->p13 = get4com (); /* µ¿»÷ÉÊ»ì Êijç¸Ì¤ÎÉÑÅÙ */
|
|
1090 para->p14 = get4com (); /* µ¿»÷ÉÊ»ì ÉÕ°¸ì¤ÎÉÑÅÙ */
|
|
1091 para->p15 = get4com (); /* µ¿»÷ÉÊ»ì ³«³ç¸Ì¤ÎÉÑÅÙ */
|
|
1092
|
|
1093 return 0;
|
|
1094 }
|
|
1095
|
|
1096 /*
|
|
1097 global File Operation
|
|
1098 */
|
|
1099 /** js_mkdir **/
|
|
1100 int
|
|
1101 js_mkdir (env, path)
|
|
1102 struct wnn_env *env;
|
|
1103 char *path;
|
|
1104 {
|
|
1105 register int x;
|
|
1106 if (env == 0)
|
|
1107 return (-1);
|
|
1108 set_current_js (env->js_id);
|
|
1109 handler_of_jserver_dead (-1);
|
|
1110 snd_env_head (env, JS_MKDIR);
|
|
1111 putscom (path);
|
|
1112 snd_flush ();
|
|
1113 x = get4com ();
|
|
1114 if (x == -1)
|
|
1115 wnn_errorno = get4com ();
|
|
1116 return x;
|
|
1117 }
|
|
1118
|
|
1119 /** js_access **/
|
|
1120 int
|
|
1121 js_access (env, path, amode)
|
|
1122 struct wnn_env *env;
|
|
1123 char *path;
|
|
1124 int amode;
|
|
1125 {
|
|
1126 register int x;
|
|
1127 if (env == 0)
|
|
1128 return (-1);
|
|
1129 set_current_js (env->js_id);
|
|
1130 handler_of_jserver_dead (-1);
|
|
1131 snd_env_head (env, JS_ACCESS);
|
|
1132 put4com (amode);
|
|
1133 putscom (path);
|
|
1134 snd_flush ();
|
|
1135 x = get4com ();
|
|
1136 return x;
|
|
1137 }
|
|
1138
|
|
1139 /** js_file_list_all **/
|
|
1140 static int rcv_file_list ();
|
|
1141
|
|
1142 int
|
|
1143 js_file_list_all (server, ret)
|
|
1144 WNN_JSERVER_ID *server;
|
|
1145 struct wnn_ret_buf *ret;
|
|
1146 {
|
|
1147 set_current_js (server);
|
|
1148 handler_of_jserver_dead (-1);
|
|
1149 snd_server_head (server, JS_FILE_LIST_ALL);
|
|
1150 snd_flush ();
|
|
1151 return rcv_file_list (ret);
|
|
1152 }
|
|
1153
|
|
1154
|
|
1155 /** js_file_list **/
|
|
1156 int
|
|
1157 js_file_list (env, ret)
|
|
1158 struct wnn_env *env;
|
|
1159 struct wnn_ret_buf *ret;
|
|
1160 {
|
|
1161 if (env == 0)
|
|
1162 return (-1);
|
|
1163 set_current_js (env->js_id);
|
|
1164 handler_of_jserver_dead (-1);
|
|
1165 snd_env_head (env, JS_FILE_LIST);
|
|
1166 snd_flush ();
|
|
1167 return rcv_file_list (ret);
|
|
1168 }
|
|
1169
|
|
1170 static void re_alloc ();
|
|
1171
|
|
1172 static int
|
|
1173 rcv_file_list (ret)
|
|
1174 struct wnn_ret_buf *ret;
|
|
1175 {
|
|
1176 register int i, count;
|
|
1177 WNN_FILE_INFO_STRUCT *files;
|
|
1178 count = get4com ();
|
|
1179 re_alloc (ret, sizeof (WNN_FILE_INFO_STRUCT) * count);
|
|
1180 files = (WNN_FILE_INFO_STRUCT *) ret->buf;
|
|
1181 for (i = 0; i < count; i++)
|
|
1182 {
|
|
1183 files->fid = get4com ();
|
|
1184 files->localf = get4com ();
|
|
1185 files->ref_count = get4com ();
|
|
1186 files->type = get4com ();
|
|
1187 getscom (files->name);
|
|
1188 files++;
|
|
1189 }
|
|
1190 return count;
|
|
1191 }
|
|
1192
|
|
1193 /** js_file_stat **/
|
|
1194 int
|
|
1195 js_file_stat (env, path, s)
|
|
1196 struct wnn_env *env;
|
|
1197 char *path;
|
|
1198 WNN_FILE_STAT *s;
|
|
1199 {
|
|
1200 register int x;
|
|
1201 if (env == 0)
|
|
1202 return (-1);
|
|
1203 set_current_js (env->js_id);
|
|
1204 handler_of_jserver_dead (-1);
|
|
1205 snd_env_head (env, JS_FILE_STAT);
|
|
1206 putscom (path);
|
|
1207 snd_flush ();
|
|
1208 x = get4com ();
|
|
1209 s->type = x;
|
|
1210 return x;
|
|
1211 }
|
|
1212
|
|
1213
|
|
1214 /** js_file_info **/
|
|
1215 int
|
|
1216 js_file_info (env, fid, file)
|
|
1217 struct wnn_env *env;
|
|
1218 int fid;
|
|
1219 register WNN_FILE_INFO_STRUCT *file;
|
|
1220 {
|
|
1221 register int x;
|
|
1222 if (env == 0)
|
|
1223 return (-1);
|
|
1224 set_current_js (env->js_id);
|
|
1225 handler_of_jserver_dead (-1);
|
|
1226 snd_env_head (env, JS_FILE_INFO);
|
|
1227 put4com (fid);
|
|
1228 snd_flush ();
|
|
1229 file->fid = fid;
|
|
1230 x = get4com ();
|
|
1231 if (x == -1)
|
|
1232 {
|
|
1233 wnn_errorno = get4com ();
|
|
1234 return (-1);
|
|
1235 }
|
|
1236 getscom (file->name);
|
|
1237 file->localf = get4com ();
|
|
1238 file->ref_count = get4com ();
|
|
1239 file->type = get4com ();
|
|
1240 return 0;
|
|
1241 }
|
|
1242
|
|
1243 /** js_file_loaded **/
|
|
1244 int
|
|
1245 js_file_loaded (server, path)
|
|
1246 WNN_JSERVER_ID *server;
|
|
1247 char *path;
|
|
1248 {
|
|
1249 register int x;
|
|
1250 set_current_js (server);
|
|
1251 handler_of_jserver_dead (-1);
|
|
1252 snd_server_head (server, JS_FILE_LOADED);
|
|
1253 putscom (path);
|
|
1254 snd_flush ();
|
|
1255 x = get4com ();
|
|
1256 return x;
|
|
1257 }
|
|
1258
|
|
1259 /** js_file_loaded_local **/
|
|
1260 static int check_local_file ();
|
|
1261 static int file_loaded_local ();
|
|
1262
|
|
1263 int
|
|
1264 js_file_loaded_local (server, path)
|
|
1265 WNN_JSERVER_ID *server;
|
|
1266 char *path;
|
|
1267 {
|
|
1268 int x;
|
|
1269 set_current_js (server);
|
|
1270 handler_of_jserver_dead (-1);
|
|
1271
|
|
1272 if (check_local_file (path) == -1)
|
|
1273 return (-1);
|
|
1274 snd_server_head (server, JS_FILE_LOADED_LOCAL);
|
|
1275 x = file_loaded_local (path);
|
|
1276 if (x == -1)
|
|
1277 {
|
|
1278 return -1;
|
|
1279 }
|
|
1280 return x;
|
|
1281 }
|
|
1282
|
|
1283 static int
|
|
1284 check_local_file (path)
|
|
1285 char *path;
|
|
1286 {
|
|
1287 register FILE *f;
|
|
1288 register int x;
|
|
1289 struct wnn_file_head fh;
|
|
1290
|
|
1291 #ifdef WRITE_CHECK
|
|
1292 check_backup (path);
|
|
1293 #endif /* WRITE_CHECK */
|
|
1294 f = fopen (path, "r");
|
|
1295 if (f == NULL)
|
|
1296 {
|
|
1297 wnn_errorno = WNN_OPENF_ERR;
|
|
1298 return -1;
|
|
1299 }
|
|
1300 x = input_file_header (f, &fh);
|
|
1301 if (x == -1)
|
|
1302 {
|
|
1303 fclose (f);
|
|
1304 wnn_errorno = WNN_NOT_A_FILE;
|
|
1305 return -1;
|
|
1306 }
|
|
1307 if (check_inode (f, &fh) == -1)
|
|
1308 {
|
|
1309 change_file_uniq (&fh, path);
|
|
1310 #ifdef WRITE_CHECK
|
|
1311 fclose (f);
|
|
1312 f = fopen (path, "r");
|
|
1313 if (f == NULL)
|
|
1314 {
|
|
1315 wnn_errorno = WNN_OPENF_ERR;
|
|
1316 return (-1);
|
|
1317 }
|
|
1318 #endif /* WRITE_CHECK */
|
|
1319 if (check_inode (f, &fh) == -1)
|
|
1320 {
|
|
1321 fclose (f);
|
|
1322 wnn_errorno = WNN_INODE_CHECK_ERROR;
|
|
1323 return (-1);
|
|
1324 }
|
|
1325 }
|
|
1326 fclose (f);
|
|
1327 return 0;
|
|
1328 }
|
|
1329
|
|
1330
|
|
1331 static int
|
|
1332 file_loaded_local (path)
|
|
1333 char *path;
|
|
1334 {
|
|
1335 register int x, i;
|
|
1336 FILE *f;
|
|
1337 struct wnn_file_head fh;
|
|
1338
|
|
1339 #ifdef WRITE_CHECK
|
|
1340 check_backup (path);
|
|
1341 #endif /* WRITE_CHECK */
|
|
1342 f = fopen (path, "r");
|
|
1343 if (f == NULL)
|
|
1344 {
|
|
1345 wnn_errorno = WNN_OPENF_ERR;
|
|
1346 return -1;
|
|
1347 }
|
|
1348 x = input_file_header (f, &fh);
|
|
1349 if (x == -1)
|
|
1350 {
|
|
1351 fclose (f);
|
|
1352 wnn_errorno = WNN_NOT_A_FILE;
|
|
1353 return -1;
|
|
1354 }
|
|
1355 put4com (fh.file_uniq.time);
|
|
1356 put4com (fh.file_uniq.dev);
|
|
1357 put4com (fh.file_uniq.inode);
|
|
1358 for (i = 0; i < WNN_HOSTLEN; i++)
|
|
1359 {
|
|
1360 put1com (fh.file_uniq.createhost[i]);
|
|
1361 }
|
|
1362
|
|
1363 snd_flush ();
|
|
1364 x = get4com ();
|
|
1365 fclose (f);
|
|
1366 return x;
|
|
1367 }
|
|
1368
|
|
1369
|
|
1370 /** js_hindo_file_create **/
|
|
1371 int
|
|
1372 js_hindo_file_create (env, fid, fn, comment, hpasswd)
|
|
1373 struct wnn_env *env;
|
|
1374 int fid;
|
|
1375 char *fn;
|
|
1376 w_char *comment;
|
|
1377 char *hpasswd;
|
|
1378 {
|
|
1379 register int x;
|
|
1380 if (env == 0)
|
|
1381 return (-1);
|
|
1382 set_current_js (env->js_id);
|
|
1383 handler_of_jserver_dead (-1);
|
|
1384 snd_env_head (env, JS_HINDO_FILE_CREATE);
|
|
1385 put4com (fid);
|
|
1386 putscom (fn);
|
|
1387 putwscom (comment);
|
|
1388 putscom (hpasswd);
|
|
1389 snd_flush ();
|
|
1390 x = get4com ();
|
|
1391 if (x == -1)
|
|
1392 wnn_errorno = get4com ();
|
|
1393 return x;
|
|
1394 }
|
|
1395
|
|
1396 /** js_dic_file_create **/
|
|
1397 int
|
|
1398 js_dic_file_create (env, fn, type, comment, passwd, hpasswd)
|
|
1399 struct wnn_env *env;
|
|
1400 char *fn;
|
|
1401 w_char *comment;
|
|
1402 char *passwd, *hpasswd;
|
|
1403 int type;
|
|
1404 {
|
|
1405 register int x;
|
|
1406 if (env == 0)
|
|
1407 return (-1);
|
|
1408 set_current_js (env->js_id);
|
|
1409 handler_of_jserver_dead (-1);
|
|
1410 snd_env_head (env, JS_DIC_FILE_CREATE);
|
|
1411 putscom (fn);
|
|
1412 putwscom (comment);
|
|
1413 putscom (passwd);
|
|
1414 putscom (hpasswd);
|
|
1415 put4com (type);
|
|
1416 snd_flush ();
|
|
1417 x = get4com ();
|
|
1418 if (x == -1)
|
|
1419 wnn_errorno = get4com ();
|
|
1420 return x;
|
|
1421 }
|
|
1422
|
|
1423
|
|
1424 /** js_file_discard **/
|
|
1425 int
|
|
1426 js_file_discard (env, fid)
|
|
1427 struct wnn_env *env;
|
|
1428 int fid;
|
|
1429 {
|
|
1430 register int x;
|
|
1431 if (env == 0)
|
|
1432 return (-1);
|
|
1433 set_current_js (env->js_id);
|
|
1434 handler_of_jserver_dead (-1);
|
|
1435 snd_env_head (env, JS_FILE_DISCARD);
|
|
1436 put4com (fid);
|
|
1437 snd_flush ();
|
|
1438 x = get4com ();
|
|
1439 if (x == -1)
|
|
1440 wnn_errorno = get4com ();
|
|
1441 return x;
|
|
1442 }
|
|
1443
|
|
1444 /** js_file_read **/
|
|
1445 int
|
|
1446 js_file_read (env, fn)
|
|
1447 struct wnn_env *env;
|
|
1448 char *fn;
|
|
1449 {
|
|
1450 register int x;
|
|
1451 if (env == 0)
|
|
1452 return (-1);
|
|
1453 set_current_js (env->js_id);
|
|
1454 handler_of_jserver_dead (-1);
|
|
1455 snd_env_head (env, JS_FILE_READ);
|
|
1456 putscom (fn);
|
|
1457 snd_flush ();
|
|
1458 x = get4com ();
|
|
1459 if (x == -1)
|
|
1460 wnn_errorno = get4com ();
|
|
1461 return x;
|
|
1462 }
|
|
1463
|
|
1464 /** js_file_write **/
|
|
1465 int
|
|
1466 js_file_write (env, fid, fn)
|
|
1467 struct wnn_env *env;
|
|
1468 int fid;
|
|
1469 char *fn;
|
|
1470 {
|
|
1471 register int x;
|
|
1472 if (env == 0)
|
|
1473 return (-1);
|
|
1474 set_current_js (env->js_id);
|
|
1475 handler_of_jserver_dead (-1);
|
|
1476 snd_env_head (env, JS_FILE_WRITE);
|
|
1477 put4com (fid);
|
|
1478 putscom (fn);
|
|
1479 snd_flush ();
|
|
1480 x = get4com ();
|
|
1481 if (x == -1)
|
|
1482 wnn_errorno = get4com ();
|
|
1483 return x;
|
|
1484 }
|
|
1485
|
|
1486 /** js_file_receive **/
|
|
1487 static int xget1com ();
|
|
1488 static void xput1com ();
|
|
1489
|
|
1490 int
|
|
1491 js_file_receive (env, fid, fn)
|
|
1492 struct wnn_env *env;
|
|
1493 int fid;
|
|
1494 char *fn;
|
|
1495 {
|
|
1496 register int mode, x;
|
|
1497 char file_name[1024];
|
|
1498 char buf[1024];
|
|
1499 FILE *f;
|
|
1500 int n;
|
|
1501 struct wnn_file_head fh;
|
|
1502 int i;
|
|
1503 #ifdef WRITE_CHECK
|
|
1504 char *tmp, *backup = NULL, tmp_x;
|
|
1505 int tmp_err = 0;
|
|
1506 #endif /* WRITE_CHECK */
|
|
1507
|
|
1508 if (env == 0)
|
|
1509 return (-1);
|
|
1510 set_current_js (env->js_id);
|
|
1511 handler_of_jserver_dead (-1);
|
|
1512 snd_env_head (env, JS_FILE_RECEIVE);
|
|
1513 put4com (fid);
|
|
1514 snd_flush ();
|
|
1515 /**/ getscom (file_name);
|
|
1516 if (fn == NULL || strcmp (fn, "") == 0)
|
|
1517 {
|
|
1518 gethostname (buf, 1024);
|
|
1519 n = strlen (buf);
|
|
1520 buf[n] = C_LOCAL;
|
|
1521 buf[n + 1] = 0;
|
|
1522 if (strncmp (buf, file_name, n + 1) == 0)
|
|
1523 {
|
|
1524 fn = file_name + n + 1;
|
|
1525 }
|
|
1526 }
|
|
1527 #ifdef WRITE_CHECK
|
|
1528 check_backup (fn);
|
|
1529 #endif /* WRITE_CHECK */
|
|
1530 if ((f = fopen (fn, "r")) == NULL)
|
|
1531 { /* New File */
|
|
1532 fh.file_uniq.time = fh.file_uniq.dev = fh.file_uniq.inode = 0;
|
|
1533 }
|
|
1534 else
|
|
1535 { /* Old File Exists */
|
|
1536 if (input_file_header (f, &fh) == -1)
|
|
1537 {
|
|
1538 wnn_errorno = WNN_NOT_A_FILE;
|
|
1539 fclose (f);
|
|
1540 put4com (-1);
|
|
1541 snd_flush ();
|
|
1542 sleep (1); /* enssure handshake */
|
|
1543 return (-1);
|
|
1544 }
|
|
1545 fclose (f);
|
|
1546 }
|
|
1547 put4com (0); /* Ack */
|
|
1548 put4com (fh.file_uniq.time);
|
|
1549 put4com (fh.file_uniq.dev);
|
|
1550 put4com (fh.file_uniq.inode);
|
|
1551 for (i = 0; i < WNN_HOSTLEN; i++)
|
|
1552 {
|
|
1553 put1com (fh.file_uniq.createhost[i]);
|
|
1554 }
|
|
1555
|
|
1556 snd_flush ();
|
|
1557
|
|
1558 if ((mode = get4com ()) == -1)
|
|
1559 { /* check stat */
|
|
1560 wnn_errorno = get4com ();
|
|
1561 return -1;
|
|
1562 }
|
|
1563 else if (mode == 0)
|
|
1564 {
|
|
1565 return 0; /* need not saving */
|
|
1566 }
|
|
1567 else if (mode == 1 || mode == 3)
|
|
1568 { /* mode == 3 means the file is a new one. */
|
|
1569 #ifdef WRITE_CHECK
|
|
1570 backup = make_backup_file (fn);
|
|
1571 if ((tmp = make_tmp_file (fn, 0, &f)) == NULL)
|
|
1572 {
|
|
1573 delete_tmp_file (backup);
|
|
1574 #else /* WRITE_CHECK */
|
|
1575 if ((f = fopen (fn, "w+")) == NULL)
|
|
1576 {
|
|
1577 #endif /* WRITE_CHECK */
|
|
1578 wnn_errorno = WNN_FILE_WRITE_ERROR;
|
|
1579 put4com (-1);
|
|
1580 snd_flush ();
|
|
1581 sleep (1); /* enssure handshake */
|
|
1582 return (-1);
|
|
1583 }
|
|
1584 }
|
|
1585 else if (mode == 2)
|
|
1586 {
|
|
1587 #ifdef WRITE_CHECK
|
|
1588 backup = make_backup_file (fn);
|
|
1589 if ((tmp = make_tmp_file (fn, 1, &f)) == NULL)
|
|
1590 {
|
|
1591 delete_tmp_file (backup);
|
|
1592 #else /* WRITE_CHECK */
|
|
1593 if ((f = fopen (fn, "r+")) == NULL)
|
|
1594 { /* New File */
|
|
1595 #endif /* WRITE_CHECK */
|
|
1596 wnn_errorno = WNN_FILE_WRITE_ERROR;
|
|
1597 put4com (-1);
|
|
1598 snd_flush ();
|
|
1599 sleep (1); /* enssure handshake */
|
|
1600 return (-1);
|
|
1601 }
|
|
1602 }
|
|
1603 put4com (0);
|
|
1604 snd_flush (); /* ACK */
|
|
1605 for (;;)
|
|
1606 {
|
|
1607 if ((x = xget1com ()) == -1)
|
|
1608 break; /* EOF */
|
|
1609 #ifdef WRITE_CHECK
|
|
1610 tmp_x = (char) x;
|
|
1611 if (fwrite (&tmp_x, sizeof (char), 1, f) == -1)
|
|
1612 tmp_err = 1;
|
|
1613 #else /* WRITE_CHECK */
|
|
1614 fputc (x, f);
|
|
1615 #endif /* WRITE_CHECK */
|
|
1616 }
|
|
1617 fclose (f);
|
|
1618 #ifdef WRITE_CHECK
|
|
1619 if (tmp_err == 0)
|
|
1620 {
|
|
1621 move_tmp_to_org (tmp, fn, 1);
|
|
1622 }
|
|
1623 else
|
|
1624 {
|
|
1625 delete_tmp_file (tmp);
|
|
1626 }
|
|
1627 delete_tmp_file (backup);
|
|
1628 #endif /* WRITE_CHECK */
|
|
1629
|
|
1630 x = get4com ();
|
|
1631 if (x == -1)
|
|
1632 wnn_errorno = get4com ();
|
|
1633 #ifdef WRITE_CHECK
|
|
1634 if (tmp_err)
|
|
1635 {
|
|
1636 wnn_errorno = WNN_FILE_WRITE_ERROR;
|
|
1637 return (-1);
|
|
1638 }
|
|
1639 #endif /* WRITE_CHECK */
|
|
1640
|
|
1641 return x;
|
|
1642 }
|
|
1643
|
|
1644 static int
|
|
1645 xget1com ()
|
|
1646 {
|
|
1647 register int x;
|
|
1648 if ((x = get1com ()) != 0xFF)
|
|
1649 return x;
|
|
1650 if (get1com () == 0xFF)
|
|
1651 return -1; /* EOF */
|
|
1652 return 0xFF;
|
|
1653 }
|
|
1654
|
|
1655 /** js_file_send **/
|
|
1656 int
|
|
1657 js_file_send (env, fn)
|
|
1658 struct wnn_env *env;
|
|
1659 char *fn;
|
|
1660 {
|
|
1661 register int x;
|
|
1662 FILE *f;
|
|
1663 int n;
|
|
1664 char buf[1024], *b;
|
|
1665 register int cc, i;
|
|
1666 if (env == 0)
|
|
1667 return (-1);
|
|
1668 set_current_js (env->js_id);
|
|
1669 handler_of_jserver_dead (-1);
|
|
1670
|
|
1671 if (check_local_file (fn) == -1)
|
|
1672 return (-1);
|
|
1673
|
|
1674 snd_env_head (env, JS_FILE_SEND);
|
|
1675 x = file_loaded_local (fn);
|
|
1676 if (x != -1)
|
|
1677 { /* file is already loaded */
|
|
1678 if (get4com () == -1)
|
|
1679 {
|
|
1680 wnn_errorno = get4com ();
|
|
1681 return (-1);
|
|
1682 }
|
|
1683 return x;
|
|
1684 }
|
|
1685
|
|
1686 x = get4com ();
|
|
1687 if (x == -1)
|
|
1688 {
|
|
1689 wnn_errorno = get4com ();
|
|
1690 return -1;
|
|
1691 }
|
|
1692
|
|
1693 gethostname (buf, 1024);
|
|
1694 n = strlen (buf);
|
|
1695 buf[n] = C_LOCAL;
|
|
1696 strcpy (buf + n + 1, fn);
|
|
1697 putscom (buf);
|
|
1698
|
|
1699 #ifdef WRITE_CHECK
|
|
1700 check_backup (fn);
|
|
1701 #endif /* WRITE_CHECK */
|
|
1702 if ((f = fopen (fn, "r")) == NULL)
|
|
1703 {
|
|
1704 xput1com (-1); /* EOF */
|
|
1705 return -1;
|
|
1706 }
|
|
1707
|
|
1708 /* send contents of file */
|
|
1709 for (;;)
|
|
1710 {
|
|
1711 cc = fread (buf, 1, 1024, f);
|
|
1712 if (cc <= 0)
|
|
1713 break; /* EOF */
|
|
1714 for (b = buf, i = 0; i < cc; i++)
|
|
1715 {
|
|
1716 xput1com ((int) *b++ & 0xff);
|
|
1717 }
|
|
1718 }
|
|
1719 fclose (f);
|
|
1720 xput1com (-1); /* EOF */
|
|
1721 snd_flush ();
|
|
1722 x = get4com ();
|
|
1723 if (x == -1)
|
|
1724 wnn_errorno = get4com ();
|
|
1725 return x;
|
|
1726 }
|
|
1727
|
|
1728 static void
|
|
1729 xput1com (d)
|
|
1730 int d;
|
|
1731 {
|
|
1732 if (d == -1)
|
|
1733 {
|
|
1734 put1com (0xFF);
|
|
1735 put1com (0xFF);
|
|
1736 return; /* EOF */
|
|
1737 }
|
|
1738 put1com (d);
|
|
1739 if (d == 0xFF)
|
|
1740 {
|
|
1741 put1com (0x00);
|
|
1742 }
|
|
1743 }
|
|
1744
|
|
1745
|
|
1746 /*** Dic. Operation for Env. ***/
|
|
1747
|
|
1748 /** js_dic_add **/
|
|
1749 int
|
|
1750 js_dic_add (env, fid, hfid, rev, jnice, rw, hrw, pw1, pw2)
|
|
1751 struct wnn_env *env;
|
|
1752 int fid, hfid, rev, jnice, rw, hrw;
|
|
1753 char *pw1, *pw2;
|
|
1754 {
|
|
1755 register int x;
|
|
1756 if (env == 0)
|
|
1757 return (-1);
|
|
1758 set_current_js (env->js_id);
|
|
1759 handler_of_jserver_dead (-1);
|
|
1760 snd_env_head (env, JS_DIC_ADD);
|
|
1761 put4com (fid);
|
|
1762 put4com (hfid);
|
|
1763 put4com (jnice);
|
|
1764 put4com (rw);
|
|
1765 put4com (hrw);
|
|
1766 putscom (pw1);
|
|
1767 putscom (pw2);
|
|
1768 put4com (rev); /* rev is to add it as reverse dict */
|
|
1769 snd_flush ();
|
|
1770 x = get4com ();
|
|
1771 if (x == -1)
|
|
1772 wnn_errorno = get4com ();
|
|
1773 return x;
|
|
1774 }
|
|
1775
|
|
1776 /** js_dic_delete **/
|
|
1777 int
|
|
1778 js_dic_delete (env, dicno)
|
|
1779 struct wnn_env *env;
|
|
1780 int dicno;
|
|
1781 {
|
|
1782 register int x;
|
|
1783 if (env == 0)
|
|
1784 return (-1);
|
|
1785 set_current_js (env->js_id);
|
|
1786 handler_of_jserver_dead (-1);
|
|
1787 snd_env_head (env, JS_DIC_DELETE);
|
|
1788 put4com (dicno);
|
|
1789 snd_flush ();
|
|
1790 x = get4com ();
|
|
1791 if (x == -1)
|
|
1792 wnn_errorno = get4com ();
|
|
1793 return x;
|
|
1794 }
|
|
1795
|
|
1796 /** js_dic_use **/
|
|
1797 int
|
|
1798 js_dic_use (env, dic_no, flag)
|
|
1799 struct wnn_env *env;
|
|
1800 int dic_no, flag;
|
|
1801 {
|
|
1802 register int x;
|
|
1803 if (env == 0)
|
|
1804 return (-1);
|
|
1805 set_current_js (env->js_id);
|
|
1806 handler_of_jserver_dead (-1);
|
|
1807 snd_env_head (env, JS_DIC_USE);
|
|
1808 put4com (dic_no);
|
|
1809 put4com (flag);
|
|
1810 snd_flush ();
|
|
1811 x = get4com ();
|
|
1812 if (x == -1)
|
|
1813 wnn_errorno = get4com ();
|
|
1814 return x;
|
|
1815 }
|
|
1816
|
|
1817 /** js_fuzokugo_set **/
|
|
1818 int
|
|
1819 js_fuzokugo_set (env, fid)
|
|
1820 struct wnn_env *env;
|
|
1821 int fid;
|
|
1822 {
|
|
1823 register int x;
|
|
1824 if (env == 0)
|
|
1825 return (-1);
|
|
1826 set_current_js (env->js_id);
|
|
1827 handler_of_jserver_dead (-1);
|
|
1828 snd_env_head (env, JS_FUZOKUGO_SET);
|
|
1829 put4com (fid);
|
|
1830 snd_flush ();
|
|
1831 x = get4com ();
|
|
1832 if (x == -1)
|
|
1833 wnn_errorno = get4com ();
|
|
1834 return x;
|
|
1835 }
|
|
1836
|
|
1837 /** js_fuzokugo_get **/
|
|
1838 int
|
|
1839 js_fuzokugo_get (env)
|
|
1840 struct wnn_env *env;
|
|
1841 {
|
|
1842 register int x;
|
|
1843 if (env == 0)
|
|
1844 return (-1);
|
|
1845 set_current_js (env->js_id);
|
|
1846 handler_of_jserver_dead (-1);
|
|
1847 snd_env_head (env, JS_FUZOKUGO_GET);
|
|
1848 snd_flush ();
|
|
1849 x = get4com ();
|
|
1850 if (x == -1)
|
|
1851 wnn_errorno = get4com ();
|
|
1852 return x;
|
|
1853 }
|
|
1854
|
|
1855 /** js_dic_list_all **/
|
|
1856 static int rcv_dic_list ();
|
|
1857 static void get_dic_info ();
|
|
1858
|
|
1859 int
|
|
1860 js_dic_list_all (server, ret)
|
|
1861 WNN_JSERVER_ID *server;
|
|
1862 struct wnn_ret_buf *ret;
|
|
1863 {
|
|
1864 set_current_js (server);
|
|
1865 handler_of_jserver_dead (-1);
|
|
1866 snd_server_head (server, JS_DIC_LIST_ALL);
|
|
1867 snd_flush ();
|
|
1868 return rcv_dic_list (ret);
|
|
1869 }
|
|
1870
|
|
1871
|
|
1872 /** js_dic_list **/
|
|
1873 int
|
|
1874 js_dic_list (env, ret)
|
|
1875 struct wnn_env *env;
|
|
1876 struct wnn_ret_buf *ret;
|
|
1877 {
|
|
1878 if (env == 0)
|
|
1879 return (-1);
|
|
1880 set_current_js (env->js_id);
|
|
1881 handler_of_jserver_dead (-1);
|
|
1882 snd_env_head (env, JS_DIC_LIST);
|
|
1883 snd_flush ();
|
|
1884 return rcv_dic_list (ret);
|
|
1885 }
|
|
1886
|
|
1887 static int
|
|
1888 rcv_dic_list (ret)
|
|
1889 struct wnn_ret_buf *ret;
|
|
1890 {
|
|
1891 register int i, count;
|
|
1892 register WNN_DIC_INFO *dic;
|
|
1893 count = get4com ();
|
|
1894 re_alloc (ret, sizeof (WNN_DIC_INFO) * (count + 1));
|
|
1895
|
|
1896 dic = (WNN_DIC_INFO *) ret->buf;
|
|
1897 for (i = 0; i < count; i++)
|
|
1898 {
|
|
1899 get_dic_info (dic);
|
|
1900 dic++;
|
|
1901 }
|
|
1902 dic->dic_no = -1;
|
|
1903 return count;
|
|
1904 }
|
|
1905
|
|
1906 static void
|
|
1907 get_dic_info (dic)
|
|
1908 register WNN_DIC_INFO *dic;
|
|
1909 {
|
|
1910 dic->dic_no = get4com (); /* dic_No */
|
|
1911 dic->body = get4com (); /* body fid */
|
|
1912 dic->hindo = get4com (); /* hindo fid */
|
|
1913 dic->rw = get4com (); /* r/w */
|
|
1914 dic->hindo_rw = get4com (); /* hindo r/w */
|
|
1915 dic->enablef = get4com (); /* enable/disable */
|
|
1916 dic->nice = get4com (); /* nice */
|
|
1917 dic->rev = get4com ();
|
|
1918 /* added H.T */
|
|
1919 getwscom (dic->comment);
|
|
1920 getscom (dic->fname);
|
|
1921 getscom (dic->hfname);
|
|
1922 getscom (dic->passwd);
|
|
1923 getscom (dic->hpasswd);
|
|
1924 dic->type = get4com ();
|
|
1925 dic->gosuu = get4com ();
|
|
1926 dic->localf = get4com ();
|
|
1927 dic->hlocalf = get4com ();
|
|
1928 }
|
|
1929
|
|
1930 /*** Dic. Operation by dic_No. ***/
|
|
1931
|
|
1932 /** js_word_add **/
|
|
1933 int
|
|
1934 js_word_add (env, dic_no, yomi, kanji, comment, hinshi, init_hindo)
|
|
1935 struct wnn_env *env;
|
|
1936 int dic_no;
|
|
1937 w_char *yomi, *kanji, *comment;
|
|
1938 int hinshi, init_hindo;
|
|
1939 {
|
|
1940 register int x;
|
|
1941 if (env == 0)
|
|
1942 return (-1);
|
|
1943 set_current_js (env->js_id);
|
|
1944 handler_of_jserver_dead (-1);
|
|
1945 snd_env_head (env, JS_WORD_ADD);
|
|
1946 put4com (dic_no);
|
|
1947 putwscom (yomi);
|
|
1948 putwscom (kanji);
|
|
1949 putwscom (comment);
|
|
1950 put4com (hinshi);
|
|
1951 put4com (init_hindo);
|
|
1952 snd_flush ();
|
|
1953 x = get4com ();
|
|
1954 if (x == -1)
|
|
1955 wnn_errorno = get4com ();
|
|
1956 return x;
|
|
1957 }
|
|
1958
|
|
1959 /** js_word_delete **/
|
|
1960 int
|
|
1961 js_word_delete (env, dic_no, entry)
|
|
1962 struct wnn_env *env;
|
|
1963 int dic_no;
|
|
1964 int entry;
|
|
1965 {
|
|
1966 register int x;
|
|
1967 if (env == 0)
|
|
1968 return (-1);
|
|
1969 set_current_js (env->js_id);
|
|
1970 handler_of_jserver_dead (-1);
|
|
1971 snd_env_head (env, JS_WORD_DELETE);
|
|
1972 put4com (dic_no);
|
|
1973 put4com (entry);
|
|
1974 snd_flush ();
|
|
1975 x = get4com ();
|
|
1976 if (x == -1)
|
|
1977 wnn_errorno = get4com ();
|
|
1978 return x;
|
|
1979 }
|
|
1980
|
|
1981
|
|
1982 /** js_word_search **/
|
|
1983 static int rcv_word_data ();
|
|
1984
|
|
1985 int
|
|
1986 js_word_search (env, dic_no, yomi, ret)
|
|
1987 struct wnn_env *env;
|
|
1988 int dic_no;
|
|
1989 w_char *yomi;
|
|
1990 struct wnn_ret_buf *ret;
|
|
1991 {
|
|
1992 if (env == 0)
|
|
1993 return (-1);
|
|
1994 set_current_js (env->js_id);
|
|
1995 handler_of_jserver_dead (-1);
|
|
1996 snd_env_head (env, JS_WORD_SEARCH);
|
|
1997 put4com (dic_no);
|
|
1998 putwscom (yomi);
|
|
1999 snd_flush ();
|
|
2000
|
|
2001 return (rcv_word_data (ret, yomi));
|
|
2002 }
|
|
2003
|
|
2004 /** js_word_search_by_env **/
|
|
2005 int
|
|
2006 js_word_search_by_env (env, yomi, ret)
|
|
2007 struct wnn_env *env;
|
|
2008 w_char *yomi;
|
|
2009 struct wnn_ret_buf *ret;
|
|
2010 {
|
|
2011 if (env == 0)
|
|
2012 return (-1);
|
|
2013 set_current_js (env->js_id);
|
|
2014 handler_of_jserver_dead (-1);
|
|
2015 snd_env_head (env, JS_WORD_SEARCH_BY_ENV);
|
|
2016 putwscom (yomi);
|
|
2017 snd_flush ();
|
|
2018
|
|
2019 return (rcv_word_data (ret, yomi));
|
|
2020 }
|
|
2021
|
|
2022 /** js_word_info **/
|
|
2023 int
|
|
2024 js_word_info (env, dic_no, entry, ret)
|
|
2025 struct wnn_env *env;
|
|
2026 int dic_no, entry;
|
|
2027 struct wnn_ret_buf *ret;
|
|
2028 {
|
|
2029 register int x;
|
|
2030 w_char yomi[LENGTHYOMI];
|
|
2031
|
|
2032 if (env == 0)
|
|
2033 return (-1);
|
|
2034 set_current_js (env->js_id);
|
|
2035 handler_of_jserver_dead (-1);
|
|
2036 snd_env_head (env, JS_WORD_INFO);
|
|
2037 put4com (dic_no);
|
|
2038 put4com (entry);
|
|
2039 snd_flush ();
|
|
2040 x = get4com ();
|
|
2041 if (x == -1)
|
|
2042 {
|
|
2043 wnn_errorno = get4com ();
|
|
2044 return (-1);
|
|
2045 }
|
|
2046 getwscom (yomi);
|
|
2047 rcv_word_data (ret, yomi);
|
|
2048 return (0);
|
|
2049 }
|
|
2050
|
|
2051 int
|
|
2052 js_word_comment_set (env, dic_no, entry, comment)
|
|
2053 struct wnn_env *env;
|
|
2054 int dic_no, entry;
|
|
2055 w_char *comment;
|
|
2056 {
|
|
2057 register int x;
|
|
2058 if (env == 0)
|
|
2059 return (-1);
|
|
2060 set_current_js (env->js_id);
|
|
2061 handler_of_jserver_dead (-1);
|
|
2062 snd_env_head (env, JS_WORD_COMMENT_SET);
|
|
2063 put4com (dic_no);
|
|
2064 put4com (entry);
|
|
2065 putwscom (comment);
|
|
2066 snd_flush ();
|
|
2067 x = get4com ();
|
|
2068 if (x == -1)
|
|
2069 {
|
|
2070 wnn_errorno = get4com ();
|
|
2071 return (-1);
|
|
2072 }
|
|
2073 return (0);
|
|
2074 }
|
|
2075
|
|
2076 /** rcv for word_search **/
|
|
2077 static int
|
|
2078 rcv_word_data (ret, yomi)
|
|
2079 struct wnn_ret_buf *ret;
|
|
2080 w_char *yomi; /* Yomi is not sent from server
|
|
2081 * (at least for the time being).
|
|
2082 */
|
|
2083 {
|
|
2084 register int x, j_c, k_c;
|
|
2085 w_char *k;
|
|
2086 register struct wnn_jdata *jd;
|
|
2087 register int cnt;
|
|
2088
|
|
2089 j_c = get4com ();
|
|
2090 k_c = get4com ();
|
|
2091 re_alloc (ret, sizeof (struct wnn_jdata) * (j_c + 1) + sizeof (w_char) * (k_c + j_c * 3 + j_c * wnn_Strlen (yomi)));
|
|
2092 jd = (struct wnn_jdata *) ret->buf;
|
|
2093 for (cnt = 0;; cnt++)
|
|
2094 {
|
|
2095 jd->dic_no = x = get4com ();
|
|
2096 if (x == -1)
|
|
2097 break;
|
|
2098 jd->serial = get4com ();
|
|
2099 jd->hinshi = get4com ();
|
|
2100 jd->hindo = get4com ();
|
|
2101 jd->ima = get4com ();
|
|
2102 jd->int_hindo = get4com ();
|
|
2103 jd->int_ima = get4com ();
|
|
2104 jd++;
|
|
2105 }
|
|
2106 jd++;
|
|
2107 k = (w_char *) jd;
|
|
2108 jd = (struct wnn_jdata *) ret->buf;
|
|
2109 for (;;)
|
|
2110 {
|
|
2111 if (jd->dic_no == -1)
|
|
2112 break;
|
|
2113
|
|
2114 jd->yomi = k; /* Copy Yomi */
|
|
2115 wnn_Strcpy (k, yomi);
|
|
2116 k += wnn_Strlen (k) + 1;
|
|
2117
|
|
2118 jd->kanji = k; /* Get Kanji */
|
|
2119 getwscom (k);
|
|
2120 k += wnn_Strlen (k) + 1;
|
|
2121
|
|
2122 jd->com = k; /* Get Comment */
|
|
2123 getwscom (k);
|
|
2124 k += wnn_Strlen (k) + 1;
|
|
2125 jd++;
|
|
2126 }
|
|
2127 return cnt;
|
|
2128 }
|
|
2129
|
|
2130
|
|
2131 /** js_dic_info **/
|
|
2132 int
|
|
2133 js_dic_info (env, dic_no, ret)
|
|
2134 struct wnn_env *env;
|
|
2135 int dic_no;
|
|
2136 register WNN_DIC_INFO *ret;
|
|
2137 {
|
|
2138 register int x;
|
|
2139 if (env == 0)
|
|
2140 return (-1);
|
|
2141 set_current_js (env->js_id);
|
|
2142 handler_of_jserver_dead (-1);
|
|
2143 snd_env_head (env, JS_DIC_INFO);
|
|
2144 put4com (dic_no);
|
|
2145 snd_flush ();
|
|
2146 x = get4com ();
|
|
2147 if (x == -1)
|
|
2148 {
|
|
2149 return get4com ();
|
|
2150 }
|
|
2151 get_dic_info (ret);
|
|
2152 return dic_no;
|
|
2153 }
|
|
2154
|
|
2155
|
|
2156 /** js_who **/
|
|
2157 int
|
|
2158 js_who (server, ret)
|
|
2159 WNN_JSERVER_ID *server;
|
|
2160 struct wnn_ret_buf *ret;
|
|
2161 {
|
|
2162 register int i, j, c;
|
|
2163 WNN_JWHO *w;
|
|
2164 set_current_js (server);
|
|
2165 handler_of_jserver_dead (-1);
|
|
2166 snd_server_head (server, JS_WHO);
|
|
2167 snd_flush ();
|
|
2168
|
|
2169 c = get4com ();
|
|
2170 if (c == -1)
|
|
2171 {
|
|
2172 wnn_errorno = get4com ();
|
|
2173 return -1;
|
|
2174 }
|
|
2175
|
|
2176 re_alloc (ret, sizeof (WNN_JWHO) * c);
|
|
2177 w = (WNN_JWHO *) ret->buf;
|
|
2178 for (i = 0; i < c; i++)
|
|
2179 {
|
|
2180 w->sd = get4com ();
|
|
2181 getscom (w->user_name);
|
|
2182 getscom (w->host_name);
|
|
2183 for (j = 0; j < WNN_MAX_ENV_OF_A_CLIENT; j++)
|
|
2184 {
|
|
2185 (w->env)[j] = get4com ();
|
|
2186 }
|
|
2187 w++;
|
|
2188 }
|
|
2189 return (c);
|
|
2190 }
|
|
2191
|
|
2192 /** jserver Ãæ¤ÎÁ´¤Æ¤Î´Ä¶¤Ë´Ø¤¹¤ë¾ðÊó¤òÆÀ¤ë¡£
|
|
2193 (¥¦¥éµ»)
|
|
2194 **/
|
|
2195 int
|
|
2196 js_env_list (server, ret)
|
|
2197 WNN_JSERVER_ID *server;
|
|
2198 struct wnn_ret_buf *ret;
|
|
2199 {
|
|
2200 register int i, j, c;
|
|
2201 WNN_ENV_INFO *w;
|
|
2202 set_current_js (server);
|
|
2203 handler_of_jserver_dead (-1);
|
|
2204 snd_server_head (server, JS_ENV_LIST);
|
|
2205 snd_flush ();
|
|
2206
|
|
2207 c = get4com ();
|
|
2208 if (c == -1)
|
|
2209 {
|
|
2210 wnn_errorno = get4com ();
|
|
2211 return -1;
|
|
2212 }
|
|
2213
|
|
2214 re_alloc (ret, sizeof (WNN_ENV_INFO) * c);
|
|
2215 w = (WNN_ENV_INFO *) ret->buf;
|
|
2216 for (i = 0; i < c; i++)
|
|
2217 {
|
|
2218 w->env_id = get4com ();
|
|
2219 getscom (w->env_name);
|
|
2220 w->ref_count = get4com ();
|
|
2221 w->fzk_fid = get4com ();
|
|
2222 w->jishomax = get4com ();
|
|
2223 for (j = 0; j < WNN_MAX_JISHO_OF_AN_ENV; j++)
|
|
2224 {
|
|
2225 (w->jisho)[j] = get4com ();
|
|
2226 }
|
|
2227 for (j = 0; j < WNN_MAX_FILE_OF_AN_ENV; j++)
|
|
2228 {
|
|
2229 (w->file)[j] = get4com ();
|
|
2230 }
|
|
2231 w++;
|
|
2232 }
|
|
2233 return (c);
|
|
2234 }
|
|
2235
|
|
2236 /****
|
|
2237
|
|
2238 ****/
|
|
2239 int
|
|
2240 js_hindo_set (env, dic, entry, ima, hindo)
|
|
2241 struct wnn_env *env;
|
|
2242 int dic, entry, ima, hindo;
|
|
2243 {
|
|
2244 register int x;
|
|
2245 if (env == 0)
|
|
2246 return (-1);
|
|
2247 set_current_js (env->js_id);
|
|
2248 handler_of_jserver_dead (-1);
|
|
2249 snd_env_head (env, JS_HINDO_SET);
|
|
2250
|
|
2251 put4com (dic);
|
|
2252 put4com (entry);
|
|
2253 put4com (ima);
|
|
2254 put4com (hindo);
|
|
2255 snd_flush ();
|
|
2256 if ((x = get4com ()) == -1)
|
|
2257 {
|
|
2258 wnn_errorno = get4com ();
|
|
2259 return -1;
|
|
2260 }
|
|
2261 return x;
|
|
2262 }
|
|
2263
|
|
2264
|
|
2265 /****
|
|
2266 Henkan
|
|
2267 ****/
|
|
2268
|
|
2269 static void
|
|
2270 put_fzk_vec (hinsi, fzk, vec, vec1)
|
|
2271 int hinsi;
|
|
2272 w_char *fzk;
|
|
2273 int vec;
|
|
2274 int vec1;
|
|
2275 {
|
|
2276 put4com (hinsi);
|
|
2277 putwscom (fzk);
|
|
2278 put4com (vec);
|
|
2279 put4com (vec1);
|
|
2280 }
|
|
2281
|
|
2282 /**
|
|
2283 kanren
|
|
2284 **/
|
|
2285 static int rcv_dai ();
|
|
2286 static void rcv_sho_x ();
|
|
2287 static void rcv_sho_kanji ();
|
|
2288
|
|
2289 int
|
|
2290 js_kanren (env, yomi, hinsi, fzk, vec, vec1, vec2, rb)
|
|
2291 struct wnn_env *env;
|
|
2292 w_char *yomi;
|
|
2293 int hinsi;
|
|
2294 w_char *fzk;
|
|
2295 int vec;
|
|
2296 int vec1;
|
|
2297 int vec2;
|
|
2298 struct wnn_ret_buf *rb;
|
|
2299 {
|
|
2300 if (env == 0)
|
|
2301 return (-1);
|
|
2302 set_current_js (env->js_id);
|
|
2303 handler_of_jserver_dead (-1);
|
|
2304
|
|
2305 snd_env_head (env, JS_KANREN);
|
|
2306 putwscom (yomi);
|
|
2307 put_fzk_vec (hinsi, fzk, vec, vec1);
|
|
2308 put4com (vec2);
|
|
2309 snd_flush ();
|
|
2310 return rcv_dai (rb);
|
|
2311 }
|
|
2312
|
|
2313 /* rcv dai */
|
|
2314 static int
|
|
2315 rcv_dai (ret)
|
|
2316 struct wnn_ret_buf *ret;
|
|
2317 {
|
|
2318 int dai_cnt, sho_sum, kanji_sum, d_size, s_size, k_size, x;
|
|
2319 register int i;
|
|
2320 struct wnn_dai_bunsetsu *dai_list;
|
|
2321 register struct wnn_dai_bunsetsu *dp;
|
|
2322 struct wnn_sho_bunsetsu *sho_list;
|
|
2323 register struct wnn_sho_bunsetsu *sp;
|
|
2324 w_char *kanji, *kp;
|
|
2325
|
|
2326 dai_cnt = get4com ();
|
|
2327 if (dai_cnt == -1)
|
|
2328 { /* error dayo */
|
|
2329 wnn_errorno = get4com ();
|
|
2330 return -1;
|
|
2331 }
|
|
2332 sho_sum = get4com ();
|
|
2333 kanji_sum = get4com ();
|
|
2334
|
|
2335 d_size = sizeof (struct wnn_dai_bunsetsu) * dai_cnt;
|
|
2336 s_size = sizeof (struct wnn_sho_bunsetsu) * sho_sum;
|
|
2337 k_size = sizeof (w_char) * kanji_sum;
|
|
2338
|
|
2339 /* re_alloc(ret, d_size+s_size+k_size); Seems This cause Bug?? H.T.*/
|
|
2340 re_alloc (ret, d_size + s_size + k_size);
|
|
2341
|
|
2342 dai_list = (struct wnn_dai_bunsetsu *) ret->buf;
|
|
2343 sho_list = (struct wnn_sho_bunsetsu *) ((char *) ret->buf + d_size);
|
|
2344 kanji = (w_char *) ((char *) ret->buf + d_size + s_size);
|
|
2345
|
|
2346 for (dp = dai_list, i = 0; i < dai_cnt; i++)
|
|
2347 {
|
|
2348 dp->end = get4com ();
|
|
2349 dp->start = get4com ();
|
|
2350 dp->sbncnt = get4com ();
|
|
2351 dp->hyoka = get4com ();
|
|
2352 dp++;
|
|
2353 }
|
|
2354
|
|
2355 for (dp = dai_list, sp = sho_list, i = 0; i < dai_cnt; i++)
|
|
2356 {
|
|
2357 dp->sbn = sp;
|
|
2358 x = dp->sbncnt;
|
|
2359 rcv_sho_x (sp, x);
|
|
2360 sp += x;
|
|
2361 dp++;
|
|
2362 }
|
|
2363
|
|
2364 for (dp = dai_list, kp = kanji, i = 0; i < dai_cnt; i++)
|
|
2365 {
|
|
2366 rcv_sho_kanji (dp->sbn, dp->sbncnt, &kp);
|
|
2367 dp++;
|
|
2368 }
|
|
2369 return dai_cnt;
|
|
2370 }
|
|
2371
|
|
2372 /* rcv sho routines */
|
|
2373 static void
|
|
2374 rcv_sho_x (sho_list, sho_cnt)
|
|
2375 register struct wnn_sho_bunsetsu *sho_list;
|
|
2376 int sho_cnt;
|
|
2377 {
|
|
2378 register int i;
|
|
2379 for (i = 0; i < sho_cnt; i++)
|
|
2380 {
|
|
2381 sho_list->end = get4com ();
|
|
2382 sho_list->start = get4com ();
|
|
2383 sho_list->jiriend = get4com ();
|
|
2384 sho_list->dic_no = get4com ();
|
|
2385 sho_list->entry = get4com ();
|
|
2386 sho_list->hindo = get4com ();
|
|
2387 sho_list->ima = get4com ();
|
|
2388 sho_list->hinsi = get4com ();
|
|
2389 sho_list->status = get4com ();
|
|
2390 sho_list->status_bkwd = get4com ();
|
|
2391 sho_list->kangovect = get4com ();
|
|
2392 sho_list->hyoka = get4com ();
|
|
2393 sho_list++;
|
|
2394 }
|
|
2395 }
|
|
2396
|
|
2397 static void
|
|
2398 rcv_sho_kanji (sho_list, sho_cnt, kanji)
|
|
2399 struct wnn_sho_bunsetsu *sho_list;
|
|
2400 int sho_cnt;
|
|
2401 w_char **kanji;
|
|
2402 {
|
|
2403 register w_char *k;
|
|
2404 register int i, x;
|
|
2405 k = *kanji;
|
|
2406 for (i = 0; i < sho_cnt; i++)
|
|
2407 {
|
|
2408 sho_list->kanji = k;
|
|
2409 getwscom (k);
|
|
2410 x = wnn_Strlen (k);
|
|
2411 k += x + 1;
|
|
2412
|
|
2413 sho_list->yomi = k;
|
|
2414 getwscom (k);
|
|
2415 x = wnn_Strlen (k);
|
|
2416 k += x + 1;
|
|
2417
|
|
2418 sho_list->fuzoku = k;
|
|
2419 getwscom (k);
|
|
2420 x = wnn_Strlen (k);
|
|
2421 k += x + 1;
|
|
2422 sho_list++;
|
|
2423 }
|
|
2424 *kanji = k;
|
|
2425 }
|
|
2426
|
|
2427
|
|
2428 static int
|
|
2429 rcv_sho (ret)
|
|
2430 struct wnn_ret_buf *ret;
|
|
2431 {
|
|
2432 register int sho_sum, kanji_sum, s_size, k_size;
|
|
2433 struct wnn_sho_bunsetsu *sho_list;
|
|
2434 w_char *kanji, *kp;
|
|
2435
|
|
2436 sho_sum = get4com ();
|
|
2437 if (sho_sum == -1)
|
|
2438 { /* error dayo */
|
|
2439 wnn_errorno = get4com ();
|
|
2440 return -1;
|
|
2441 }
|
|
2442 kanji_sum = get4com ();
|
|
2443
|
|
2444 s_size = sizeof (struct wnn_sho_bunsetsu) * sho_sum;
|
|
2445 k_size = sizeof (w_char) * kanji_sum;
|
|
2446
|
|
2447 re_alloc (ret, s_size + k_size);
|
|
2448
|
|
2449 sho_list = (struct wnn_sho_bunsetsu *) ((char *) ret->buf);
|
|
2450 kanji = (w_char *) ((char *) ret->buf + s_size);
|
|
2451
|
|
2452 rcv_sho_x (sho_list, sho_sum);
|
|
2453 kp = kanji;
|
|
2454 rcv_sho_kanji (sho_list, sho_sum, &kp);
|
|
2455 return sho_sum;
|
|
2456 }
|
|
2457
|
|
2458 /**
|
|
2459 kantan
|
|
2460 **/
|
|
2461 int
|
|
2462 js_kantan_dai (env, yomi, hinsi, fzk, vec, vec1, rb)
|
|
2463 struct wnn_env *env;
|
|
2464 w_char *yomi;
|
|
2465 int hinsi;
|
|
2466 w_char *fzk;
|
|
2467 int vec;
|
|
2468 int vec1;
|
|
2469 struct wnn_ret_buf *rb;
|
|
2470 {
|
|
2471 if (env == 0)
|
|
2472 return (-1);
|
|
2473 set_current_js (env->js_id);
|
|
2474 handler_of_jserver_dead (-1);
|
|
2475
|
|
2476 snd_env_head (env, JS_KANTAN_DAI);
|
|
2477 putwscom (yomi);
|
|
2478 put_fzk_vec (hinsi, fzk, vec, vec1);
|
|
2479 snd_flush ();
|
|
2480
|
|
2481 return rcv_dai (rb);
|
|
2482 }
|
|
2483
|
|
2484 int
|
|
2485 js_kantan_sho (env, yomi, hinsi, fzk, vec, vec1, rb)
|
|
2486 struct wnn_env *env;
|
|
2487 w_char *yomi;
|
|
2488 int hinsi;
|
|
2489 w_char *fzk;
|
|
2490 int vec;
|
|
2491 int vec1;
|
|
2492 struct wnn_ret_buf *rb;
|
|
2493 {
|
|
2494 int sbncnt;
|
|
2495 if (env == 0)
|
|
2496 return (-1);
|
|
2497 set_current_js (env->js_id);
|
|
2498 handler_of_jserver_dead (-1);
|
|
2499
|
|
2500 snd_env_head (env, JS_KANTAN_SHO);
|
|
2501 putwscom (yomi);
|
|
2502 put_fzk_vec (hinsi, fzk, vec, vec1);
|
|
2503 snd_flush ();
|
|
2504
|
|
2505 sbncnt = rcv_sho (rb);
|
|
2506 return sbncnt;
|
|
2507 }
|
|
2508
|
|
2509 /**
|
|
2510 kanzen
|
|
2511 **/
|
|
2512 int
|
|
2513 js_kanzen_dai (env, yomi, hinsi, fzk, vec, vec1, rb)
|
|
2514 struct wnn_env *env;
|
|
2515 w_char *yomi;
|
|
2516 int hinsi;
|
|
2517 w_char *fzk;
|
|
2518 int vec;
|
|
2519 int vec1;
|
|
2520 struct wnn_ret_buf *rb;
|
|
2521 {
|
|
2522 if (env == 0)
|
|
2523 return (-1);
|
|
2524 set_current_js (env->js_id);
|
|
2525 handler_of_jserver_dead (-1);
|
|
2526 snd_env_head (env, JS_KANZEN_DAI);
|
|
2527 putwscom (yomi);
|
|
2528 put_fzk_vec (hinsi, fzk, vec, vec1);
|
|
2529 snd_flush ();
|
|
2530
|
|
2531 return rcv_dai (rb);
|
|
2532 }
|
|
2533
|
|
2534
|
|
2535 int
|
|
2536 js_kanzen_sho (env, yomi, hinsi, fzk, vec, vec1, rb)
|
|
2537 struct wnn_env *env;
|
|
2538 w_char *yomi;
|
|
2539 int hinsi;
|
|
2540 w_char *fzk;
|
|
2541 int vec;
|
|
2542 int vec1;
|
|
2543 struct wnn_ret_buf *rb;
|
|
2544 {
|
|
2545 int sbncnt;
|
|
2546 if (env == 0)
|
|
2547 return (-1);
|
|
2548 set_current_js (env->js_id);
|
|
2549 handler_of_jserver_dead (-1);
|
|
2550 snd_env_head (env, JS_KANZEN_SHO);
|
|
2551 putwscom (yomi);
|
|
2552 put_fzk_vec (hinsi, fzk, vec, vec1);
|
|
2553 snd_flush ();
|
|
2554
|
|
2555 sbncnt = rcv_sho (rb);
|
|
2556 return sbncnt;
|
|
2557 }
|
|
2558
|
|
2559 /** js_version **/
|
|
2560 int
|
|
2561 js_version (server, serv, libv)
|
|
2562 int *serv, *libv;
|
|
2563 WNN_JSERVER_ID *server;
|
|
2564 {
|
|
2565 set_current_js (server);
|
|
2566 handler_of_jserver_dead (-1);
|
|
2567 snd_server_head (server, JS_VERSION);
|
|
2568 snd_flush ();
|
|
2569 *libv = JLIB_VERSION;
|
|
2570 return *serv = get4com ();
|
|
2571 }
|
|
2572
|
|
2573 static void
|
|
2574 re_alloc (ret, size)
|
|
2575 register struct wnn_ret_buf *ret;
|
|
2576 int size;
|
|
2577 {
|
|
2578 if (ret->size < size)
|
|
2579 {
|
|
2580 if (ret->buf)
|
|
2581 free ((char *) ret->buf);
|
|
2582 ret->buf = malloc (size);
|
|
2583 ret->size = size;
|
|
2584 }
|
|
2585 }
|
|
2586
|
|
2587
|
|
2588 int
|
|
2589 js_kill (server)
|
|
2590 WNN_JSERVER_ID *server;
|
|
2591 {
|
|
2592 int x;
|
|
2593 set_current_js (server);
|
|
2594 handler_of_jserver_dead (-1);
|
|
2595 snd_server_head (server, JS_KILL);
|
|
2596 snd_flush ();
|
|
2597 x = get4com ();
|
|
2598 return (x);
|
|
2599 }
|
|
2600
|
|
2601
|
|
2602 int
|
|
2603 js_file_remove (server, n, pwd)
|
|
2604 WNN_JSERVER_ID *server;
|
|
2605 char *n, *pwd;
|
|
2606 {
|
|
2607 register int x;
|
|
2608 set_current_js (server);
|
|
2609 handler_of_jserver_dead (-1);
|
|
2610 snd_server_head (server, JS_FILE_REMOVE);
|
|
2611 putscom (n);
|
|
2612 putscom (pwd);
|
|
2613 snd_flush ();
|
|
2614 if ((x = get4com ()) == -1)
|
|
2615 {
|
|
2616 wnn_errorno = get4com ();
|
|
2617 return -1;
|
|
2618 }
|
|
2619 return (x);
|
|
2620 }
|
|
2621
|
|
2622 int
|
|
2623 js_file_remove_client (server, n, pwd)
|
|
2624 WNN_JSERVER_ID *server;
|
|
2625 char *n, *pwd;
|
|
2626 {
|
|
2627 struct wnn_file_head fh;
|
|
2628 register FILE *fp;
|
|
2629 set_current_js (server);
|
|
2630 handler_of_jserver_dead (-1);
|
|
2631 if (js_file_loaded_local (server, n) != -1)
|
|
2632 {
|
|
2633 wnn_errorno = WNN_FILE_IN_USE;
|
|
2634 return (-1);
|
|
2635 }
|
|
2636 #ifdef WRITE_CHECK
|
|
2637 check_backup (n);
|
|
2638 #endif /* WRITE_CHECK */
|
|
2639 if ((fp = fopen (n, "r")) == NULL)
|
|
2640 {
|
|
2641 wnn_errorno = WNN_FILE_READ_ERROR;
|
|
2642 return (-1);
|
|
2643 }
|
|
2644 if (input_file_header (fp, &fh) == -1)
|
|
2645 {
|
|
2646 fclose (fp);
|
|
2647 wnn_errorno = WNN_NOT_A_FILE;
|
|
2648 return (-1);
|
|
2649 }
|
|
2650 fclose (fp);
|
|
2651 if (!check_pwd (pwd, fh.file_passwd))
|
|
2652 {
|
|
2653 wnn_errorno = WNN_INCORRECT_PASSWD;
|
|
2654 return (-1);
|
|
2655 }
|
|
2656 if (unlink (n) == -1)
|
|
2657 {
|
|
2658 wnn_errorno = WNN_UNLINK;
|
|
2659 return (-1);
|
|
2660 }
|
|
2661 return (0);
|
|
2662 }
|
|
2663
|
|
2664 /** js_dic_file_create_client **/
|
|
2665 int
|
|
2666 js_dic_file_create_client (env, fn, type, com, passwd, hpasswd)
|
|
2667 struct wnn_env *env;
|
|
2668 int type;
|
|
2669 char *fn;
|
|
2670 w_char *com;
|
|
2671 char *passwd, *hpasswd;
|
|
2672 {
|
|
2673 int x;
|
|
2674 if (type != WNN_REV_DICT && type != CWNN_REV_DICT && type != BWNN_REV_DICT && type != WNN_UD_DICT)
|
|
2675 {
|
|
2676 wnn_errorno = WNN_NOT_A_UD;
|
|
2677 return (-1);
|
|
2678 }
|
|
2679 x = create_null_dic (fn, com, passwd, hpasswd, type);
|
|
2680 if (x == -1)
|
|
2681 {
|
|
2682 wnn_errorno = WNN_FILE_CREATE_ERROR;
|
|
2683 return (-1);
|
|
2684 }
|
|
2685 return (0);
|
|
2686 }
|
|
2687
|
|
2688
|
|
2689 /** js_hindo_file_create_client **/
|
|
2690 int
|
|
2691 js_hindo_file_create_client (env, fid, fn, com, hpasswd)
|
|
2692 struct wnn_env *env;
|
|
2693 int fid;
|
|
2694 char *fn;
|
|
2695 w_char *com;
|
|
2696 char *hpasswd;
|
|
2697 {
|
|
2698 register int x;
|
|
2699 struct wnn_file_uniq funiq;
|
|
2700 int serial;
|
|
2701 register int i;
|
|
2702
|
|
2703 if (env == 0)
|
|
2704 return (-1);
|
|
2705 set_current_js (env->js_id);
|
|
2706 handler_of_jserver_dead (-1);
|
|
2707 snd_env_head (env, JS_HINDO_FILE_CREATE_CLIENT);
|
|
2708 put4com (fid);
|
|
2709 snd_flush ();
|
|
2710 x = get4com ();
|
|
2711 if (x == -1)
|
|
2712 {
|
|
2713 wnn_errorno = get4com ();
|
|
2714 return (-1);
|
|
2715 }
|
|
2716 serial = get4com ();
|
|
2717 funiq.time = get4com ();
|
|
2718 funiq.dev = get4com ();
|
|
2719 funiq.inode = get4com ();
|
|
2720 for (i = 0; i < WNN_HOSTLEN; i++)
|
|
2721 {
|
|
2722 funiq.createhost[i] = get1com ();
|
|
2723 }
|
|
2724 /* getscom(funiq.createhost); */
|
|
2725 if (create_hindo_file (&funiq, fn, com, hpasswd, serial) == -1)
|
|
2726 {
|
|
2727 wnn_errorno = WNN_FILE_CREATE_ERROR;
|
|
2728 return (-1);
|
|
2729 }
|
|
2730 return (0);
|
|
2731 }
|
|
2732
|
|
2733 int
|
|
2734 js_file_comment_set (env, fid, comment)
|
|
2735 struct wnn_env *env;
|
|
2736 int fid;
|
|
2737 w_char *comment;
|
|
2738 {
|
|
2739 register int x;
|
|
2740 if (env == 0)
|
|
2741 return (-1);
|
|
2742 set_current_js (env->js_id);
|
|
2743 handler_of_jserver_dead (-1);
|
|
2744 snd_env_head (env, JS_FILE_COMMENT_SET);
|
|
2745 put4com (fid);
|
|
2746 putwscom (comment);
|
|
2747 snd_flush ();
|
|
2748 x = get4com ();
|
|
2749 if (x == -1)
|
|
2750 {
|
|
2751 wnn_errorno = get4com ();
|
|
2752 return (-1);
|
|
2753 }
|
|
2754 return (0);
|
|
2755 }
|
|
2756
|
|
2757
|
|
2758 /*
|
|
2759 * Hinsi Primitives
|
|
2760 */
|
|
2761
|
|
2762 int
|
|
2763 js_hinsi_name (server, no, rb)
|
|
2764 WNN_JSERVER_ID *server;
|
|
2765 int no;
|
|
2766 struct wnn_ret_buf *rb;
|
|
2767 {
|
|
2768 register int size;
|
|
2769
|
|
2770 set_current_js (server);
|
|
2771 handler_of_jserver_dead (-1);
|
|
2772 snd_server_head (server, JS_HINSI_NAME);
|
|
2773 put4com (no);
|
|
2774 snd_flush ();
|
|
2775 if ((size = get4com ()) == -1)
|
|
2776 {
|
|
2777 wnn_errorno = get4com ();
|
|
2778 return (-1);
|
|
2779 }
|
|
2780 re_alloc (rb, sizeof (w_char) * (size + 1));
|
|
2781 getwscom ((w_char *) rb->buf);
|
|
2782 return (0);
|
|
2783 }
|
|
2784
|
|
2785
|
|
2786 int
|
|
2787 js_hinsi_number (server, name)
|
|
2788 WNN_JSERVER_ID *server;
|
|
2789 w_char *name;
|
|
2790 {
|
|
2791 register int no;
|
|
2792
|
|
2793 set_current_js (server);
|
|
2794 handler_of_jserver_dead (-1);
|
|
2795 snd_server_head (server, JS_HINSI_NUMBER);
|
|
2796 putwscom (name);
|
|
2797 snd_flush ();
|
|
2798 if ((no = get4com ()) == -1)
|
|
2799 {
|
|
2800 wnn_errorno = get4com ();
|
|
2801 return (-1);
|
|
2802 }
|
|
2803 return (no);
|
|
2804 }
|
|
2805
|
|
2806
|
|
2807 int
|
|
2808 js_hinsi_list (env, dic_no, name, rb)
|
|
2809 struct wnn_env *env;
|
|
2810 int dic_no;
|
|
2811 w_char *name;
|
|
2812 struct wnn_ret_buf *rb;
|
|
2813 {
|
|
2814 int size;
|
|
2815 int count;
|
|
2816 register w_char *s;
|
|
2817 register w_char **r;
|
|
2818 register int k;
|
|
2819
|
|
2820 if (env == 0)
|
|
2821 return (-1);
|
|
2822 set_current_js (env->js_id);
|
|
2823 handler_of_jserver_dead (-1);
|
|
2824 snd_env_head (env, JS_HINSI_LIST);
|
|
2825 put4com (dic_no);
|
|
2826 putwscom (name);
|
|
2827 snd_flush ();
|
|
2828 if ((count = get4com ()) == -1)
|
|
2829 {
|
|
2830 wnn_errorno = get4com ();
|
|
2831 return (-1);
|
|
2832 }
|
|
2833 size = get4com ();
|
|
2834 re_alloc (rb, sizeof (w_char) * (size + 1) + count * sizeof (w_char *));
|
|
2835 r = (w_char **) rb->buf;
|
|
2836 s = (w_char *) ((w_char **) rb->buf + count);
|
|
2837 for (k = 0; k < count; k++)
|
|
2838 {
|
|
2839 *r++ = s;
|
|
2840 getwscom (s);
|
|
2841 s += wnn_Strlen (s) + 1;
|
|
2842 }
|
|
2843 return (count);
|
|
2844 }
|
|
2845
|
|
2846
|
|
2847 int
|
|
2848 js_hinsi_dicts (env, no, rb)
|
|
2849 struct wnn_env *env;
|
|
2850 int no;
|
|
2851 struct wnn_ret_buf *rb;
|
|
2852 {
|
|
2853 register int k, count;
|
|
2854 int *p;
|
|
2855
|
|
2856 if (env == 0)
|
|
2857 return (-1);
|
|
2858 set_current_js (env->js_id);
|
|
2859 handler_of_jserver_dead (-1);
|
|
2860 snd_env_head (env, JS_HINSI_DICTS);
|
|
2861 put4com (no);
|
|
2862 snd_flush ();
|
|
2863 if ((count = get4com ()) == -1)
|
|
2864 {
|
|
2865 wnn_errorno = get4com ();
|
|
2866 return (-1);
|
|
2867 }
|
|
2868 re_alloc (rb, sizeof (int) * (count + 1));
|
|
2869 p = (int *) rb->buf;
|
|
2870
|
|
2871 for (k = 0; k < count; k++)
|
|
2872 {
|
|
2873 *p++ = get4com ();
|
|
2874 }
|
|
2875 return (count);
|
|
2876 }
|
|
2877
|
|
2878
|
|
2879 char *wnn_dic_types[] = { "", "¸ÇÄê", "ÅÐÏ¿", "µÕ°ú", "Àµµ¬" };
|
|
2880
|
|
2881 char *cwnn_dic_types[] = { "", "¹Ì¶¨", "µÇ¼", "Æ´Òô", "Õý¹æ" };
|
|
2882 char *bwnn_dic_types[] = { "", "¹Ì¶¨", "µÇ¼", "±ÊÐÍ", "Õý¹æ" };
|
|
2883
|
|
2884 char *kwnn_dic_types[] = { "", "°íÁ¤", "µî·Ï", "¿ª¿ë", "Á¤±Ô" };
|
|
2885 /* ͳïÒ ÔôÖâ æ½ìÚ ïáЮ */
|
|
2886
|
|
2887 /* New primitives 9/8 */
|
|
2888
|
|
2889 int
|
|
2890 js_file_password_set (env, fid, which, old, new)
|
|
2891 struct wnn_env *env;
|
|
2892 int fid;
|
|
2893 int which; /* 1 for dic, 2 for hindo 3(0) for both */
|
|
2894 char *old, *new;
|
|
2895 {
|
|
2896 register int x;
|
|
2897 if (env == 0)
|
|
2898 return (-1);
|
|
2899 set_current_js (env->js_id);
|
|
2900 handler_of_jserver_dead (-1);
|
|
2901 snd_env_head (env, JS_FILE_PASSWORD_SET);
|
|
2902 put4com (fid);
|
|
2903 put4com (which);
|
|
2904 putscom (old);
|
|
2905 putscom (new);
|
|
2906 snd_flush ();
|
|
2907 x = get4com ();
|
|
2908 if (x == -1)
|
|
2909 {
|
|
2910 wnn_errorno = get4com ();
|
|
2911 return (-1);
|
|
2912 }
|
|
2913 return (0);
|
|
2914 }
|
|
2915
|
|
2916 int
|
|
2917 js_hinsi_table_set (env, dic_no, hinsi_table)
|
|
2918 struct wnn_env *env;
|
|
2919 int dic_no;
|
|
2920 w_char *hinsi_table;
|
|
2921 {
|
|
2922 int x;
|
|
2923 if (env == 0)
|
|
2924 return (-1);
|
|
2925 set_current_js (env->js_id);
|
|
2926 handler_of_jserver_dead (-1);
|
|
2927 snd_env_head (env, JS_HINSI_TABLE_SET);
|
|
2928 put4com (dic_no);
|
|
2929 putwscom (hinsi_table);
|
|
2930 snd_flush ();
|
|
2931 x = get4com ();
|
|
2932 if (x == -1)
|
|
2933 {
|
|
2934 wnn_errorno = get4com ();
|
|
2935 return (-1);
|
|
2936 }
|
|
2937 return (0);
|
|
2938 }
|
|
2939
|
|
2940 #define SERVERDEFS_FILE "/serverdefs"
|
|
2941
|
|
2942 #define MACHINE_NAME 1
|
|
2943 #define UNIXDOMAIN_NAME 2
|
|
2944 #define SERVICE_NAME 3
|
|
2945 #define SERVICE_PORT_NUM 4
|
|
2946
|
|
2947 static char *
|
|
2948 get_serv_defs (lang, cnt)
|
|
2949 char *lang;
|
|
2950 int cnt;
|
|
2951 {
|
|
2952 FILE *fp;
|
|
2953 static char s[7][EXPAND_PATH_LENGTH];
|
|
2954 char serv_defs[EXPAND_PATH_LENGTH];
|
|
2955 char data[1024];
|
|
2956 int num;
|
|
2957
|
|
2958 strcpy (serv_defs, LIBDIR);
|
|
2959 strcat (serv_defs, SERVERDEFS_FILE);
|
|
2960 if ((fp = fopen (serv_defs, "r")) == NULL)
|
|
2961 {
|
|
2962 return (NULL);
|
|
2963 }
|
|
2964 while (fgets (data, 1024, fp) != NULL)
|
|
2965 {
|
|
2966 num = sscanf (data, "%s %s %s %s %s %s %s", s[0], s[1], s[2], s[3], s[4], s[5], s[6]);
|
|
2967 if ((num < 4) || s[0][0] == ';')
|
|
2968 {
|
|
2969 continue;
|
|
2970 }
|
|
2971 if (!strncmp (lang, s[0], strlen (s[0])))
|
|
2972 {
|
|
2973 fclose (fp);
|
|
2974 if (cnt == SERVICE_PORT_NUM && num < 5)
|
|
2975 return (NULL);
|
|
2976 if (strlen (s[cnt]) == strlen ("NULL") && !strcmp (s[cnt], "NULL"))
|
|
2977 {
|
|
2978 return (NULL);
|
|
2979 }
|
|
2980 else
|
|
2981 {
|
|
2982 return (s[cnt]);
|
|
2983 }
|
|
2984 }
|
|
2985 }
|
|
2986 fclose (fp);
|
|
2987 return (NULL);
|
|
2988 }
|
|
2989
|
|
2990 char *
|
|
2991 _wnn_get_machine_of_serv_defs (lang)
|
|
2992 char *lang;
|
|
2993 {
|
|
2994 return (get_serv_defs (lang, MACHINE_NAME));
|
|
2995 }
|
|
2996
|
|
2997 static char *
|
|
2998 get_unixdomain_of_serv_defs (lang)
|
|
2999 char *lang;
|
|
3000 {
|
|
3001 return (get_serv_defs (lang, UNIXDOMAIN_NAME));
|
|
3002 }
|
|
3003
|
|
3004 static char *
|
|
3005 get_service_of_serv_defs (lang)
|
|
3006 char *lang;
|
|
3007 {
|
|
3008 return (get_serv_defs (lang, SERVICE_NAME));
|
|
3009 }
|
|
3010
|
|
3011 static int
|
|
3012 get_port_num_of_serv_defs (lang)
|
|
3013 char *lang;
|
|
3014 {
|
|
3015 char *port_char;
|
|
3016
|
|
3017 if ((port_char = get_serv_defs (lang, SERVICE_PORT_NUM)) == NULL)
|
|
3018 {
|
|
3019 return (-1);
|
|
3020 }
|
|
3021 else
|
|
3022 {
|
|
3023 return (atoi (port_char));
|
|
3024 }
|
|
3025 }
|