1 /*
2 * $Id: gethinsi.c,v 2.13.2.1 2000/08/04 05:37:05 kaneda Exp $
3 */
4
5 /*
6 WNN6 CLIENT LIBRARY--SOFTWARE LICENSE TERMS AND CONDITIONS
7
8
9 Wnn6 Client Library :
10 (C) Copyright OMRON Corporation. 1995,1998,2000 all rights reserved.
11 (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000 all rights reserved.
12
13 Wnn Software :
14 (C) Copyright Kyoto University Research Institute for Mathematical Sciences
15 1987, 1988, 1989, 1990, 1991, 1992, 1993
16 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993
17 (C) Copyright ASCTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992, 1993
18
19 Preamble
20
21 These Wnn6 Client Library--Software License Terms and Conditions
22 (the "License Agreement") shall state the conditions under which you are
23 permitted to copy, distribute or modify the software which can be used
24 to create Wnn6 Client Library (the "Wnn6 Client Library"). The License
25 Agreement can be freely copied and distributed verbatim, however, you
26 shall NOT add, delete or change anything on the License Agreement.
27
28 OMRON Corporation and OMRON Software Co., Ltd. (collectively referred to
29 as "OMRON") jointly developed the Wnn6 Software (development code name
30 is FI-Wnn), based on the Wnn Software. Starting from November, 1st, 1998,
31 OMRON publishes the source code of the Wnn6 Client Library, and OMRON
32 permits anyone to copy, distribute or change the Wnn6 Client Library under
33 the License Agreement.
34
35 Wnn6 Client Library is based on the original version of Wnn developed by
36 Kyoto University Research Institute for Mathematical Sciences (KURIMS),
37 OMRON Corporation and ASTEC Inc.
38
39 Article 1. Definition.
40
41 "Source Code" means the embodiment of the computer code, readable and
42 understandable by a programmer of ordinary skills. It includes related
43 source code level system documentation, comments and procedural code.
44
45 "Object File" means a file, in substantially binary form, which is directly
46 executable by a computer after linking applicable files.
47
48 "Library" means a file, composed of several Object Files, which is directly
49 executable by a computer after linking applicable files.
50
51 "Software" means a set of Source Code including information on its use.
52
53 "Wnn6 Client Library" the computer program, originally supplied by OMRON,
54 which can be used to create Wnn6 Client Library.
55
56 "Executable Module" means a file, created after linking Object Files or
57 Library, which is directly executable by a computer.
58
59 "User" means anyone who uses the Wnn6 Client Library under the License
60 Agreement.
61
62 Article 2. Copyright
63
64 2.1 OMRON Corporation and OMRON Software Co., Ltd. jointly own the Wnn6
65 Client Library, including, without limitation, its copyright.
66
67 2.2 Following words followed by the above copyright notices appear
68 in all supporting documentation of software based on Wnn6 Client Library:
69
70 This software is based on the original version of Wnn6 Client Library
71 developed by OMRON Corporation and OMRON Software Co., Ltd. and also based on
72 the original version of Wnn developed by Kyoto University Research Institute
73 for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc.
74
75 Article 3. Grant
76
77 3.1 A User is permitted to make and distribute verbatim copies of
78 the Wnn6 Client Library, including verbatim of copies of the License
79 Agreement, under the License Agreement.
80
81 3.2 A User is permitted to modify the Wnn6 Client Library to create
82 Software ("Modified Software") under the License Agreement. A User
83 is also permitted to make or distribute copies of Modified Software,
84 including verbatim copies of the License Agreement with the following
85 information. Upon modifying the Wnn6 Client Library, a User MUST insert
86 comments--stating the name of the User, the reason for the modifications,
87 the date of the modifications, additional terms and conditions on the
88 part of the modifications if there is any, and potential risks of using
89 the Modified Software if they are known--right after the end of the
90 License Agreement (or the last comment, if comments are inserted already).
91
92 3.3 A User is permitted to create Library or Executable Modules by
93 modifying the Wnn6 Client Library in whole or in part under the License
94 Agreement. A User is also permitted to make or distribute copies of
95 Library or Executable Modules with verbatim copies of the License
96 Agreement under the License Agreement. Upon modifying the Wnn6 Client
97 Library for creating Library or Executable Modules, except for porting
98 a computer, a User MUST add a text file to a package of the Wnn6 Client
99 Library, providing information on the name of the User, the reason for
100 the modifications, the date of the modifications, additional terms and
101 conditions on the part of the modifications if there is any, and potential
102 risks associated with using the modified Wnn6 Client Library, Library or
103 Executable Modules if they are known.
104
105 3.4 A User is permitted to incorporate the Wnn6 Client Library in whole
106 or in part into another Software, although its license terms and
107 conditions may be different from the License Agreement, if such
108 incorporation or use associated with the incorporation does NOT violate
109 the License Agreement.
110
111 Article 4. Warranty
112
113 THE WNN6 CLIENT LIBRARY IS PROVIDED BY OMRON ON AN "AS IS" BAISIS.
114 OMRON EXPRESSLY DISLCIAMS ANY AND ALL WRRANTIES, EXPRESS OR IMPLIED,
115 INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY AND FITNESS
116 FOR A PARTICULAR PURPOSE, IN CONNECTION WITH THE WNN6 CLIENT LIBRARY
117 OR THE USE OR OTHER DEALING IN THE WNN6 CLIENT LIBRARY. IN NO EVENT
118 SHALL OMRON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE
119 OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER IN CONNECTION WITH THE
120 WNN6 CLIENT LIBRARY OR THE USE OR OTHER DEALING IN THE WNN6 CLIENT
121 LIBRARY.
122
123 ***************************************************************************
124 Wnn6 Client Library :
125 (C) Copyright OMRON Corporation. 1995,1998,2000 all rights reserved.
126 (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000 all rights reserved.
127
128 Wnn Software :
129 (C) Copyright Kyoto University Research Institute for Mathematical Sciences
130 1987, 1988, 1989, 1990, 1991, 1992, 1993
131 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993
132 (C) Copyright ASCTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992, 1993
133 ***************************************************************************
134
135 Comments on Modifications:
136 */
137
138 /* Version 4.0
139 */
140 /* �ʻ�ե�����ι�¤�˴ؤ������
141 */
142
143 #include <stdio.h>
144 #include "commonhd.h"
145 #include "config.h"
146 #include "wnnerror.h"
147 #include "jslib.h"
148 #include "wnn_os.h"
149 #include "wnn_string.h"
150 #ifdef NEW_HINSI
151 #include "fzk.h"
152 #include "kaiseki.h"
153 #else /* NEW_HINSI */
154 #include "hinsi_file.h"
155 #endif /* NEW_HINSI */
156 #include "mt_jserver.h"
157
158
159 /*
160 wnn_loadhinsi(NULL) �ʻ�ξ�����ɤ߹���
161
162 wnn_find_hinsi_by_name(c) ̾����Ϳ���ơ��ʻ��ֹ����
163 char *c;
164
165 char *wnn_get_hinsi_name(k) �ʻ��ֹ椫��̾������
166 int k;
167
168 int
169 wnn_get_fukugou_component(k,str, ) ʣ���ʻ���Ф��� �������Ǥ����
170 int k; �������ǤθĿ������ͤȤ����֤��졢
171 unsigned short **str; �������Ǥ� str �ʹߤ��֤���롣
172
173 */
174
175 /* extern int wnn_errorno; */
176
177
178 /*
179 *here start the real program
180 */
181
182 #define SIZE 1024
183
184 int wnnerror_hinsi;
185 static int hinsi_loaded = 0;
186 static int line_no = 0;
187
188 #ifdef NEW_HINSI
189 static w_char *heap, *hp;
190 static unsigned short *wheap, *whp;
191 static w_char **hinsi;
192 static struct wnn_fukugou *fukugou;
193 static struct wnn_hinsi_node *node;
194 static int cucucu, fufufu, eof;
195 #else /* NEW_HINSI */
196 static w_char heap[HEAP_LEN];
197 static w_char *hp = heap;
198 static unsigned short wheap[WHEAP_LEN];
199 static unsigned short *whp = wheap;
200 static w_char *hinsi[MAXHINSI];
201 static struct wnn_fukugou fukugou[MAXFUKUGOU];
202 static struct wnn_hinsi_node node[MAXNODE];
203 #endif /* NEW_HINSI */
204
205 int mhinsi = 0;
206 int mfukugou = 0;
207 int mnode = 0;
208
209 #if !defined(DSERVER) && defined(JSERVER)
210 extern char *hinsi_file_name;
211 #endif /* !DSERVER && JSERVER */
212
213 static void
error_long(args)214 error_long(args)
215 ARGS *args;
216 {
217 wnnerror_hinsi = WNN_TOO_LONG_HINSI_FILE_LINE;
218 }
219
220 static void
error_no_heap(args)221 error_no_heap(args)
222 ARGS *args;
223 {
224 wnnerror_hinsi = WNN_TOO_BIG_HINSI_FILE;
225 }
226
227 static int
get_char0(fp,args)228 get_char0(fp, args)
229 FILE *fp;
230 ARGS *args;
231 {
232 int c,d;
233
234 for(;(c = getc(fp)) == COMMENT_CHAR || c == CONTINUE_CHAR ||
235 c == IGNORE_CHAR1 || c == IGNORE_CHAR2;){
236 if(c == CONTINUE_CHAR){
237 if((d = getc(fp))== EOF){
238 break;
239 }
240 if(d == '\n'){
241 line_no += 1;
242 continue;
243 }else{
244 ungetc(d,fp);
245 break;
246 }
247 }else if(c == COMMENT_CHAR){
248 for(;;){
249 if((c = getc(fp))== EOF){
250 return(EOF);
251 }
252 if(c == '\n'){
253 ungetc(c,fp);
254 line_no += 1;
255 break;
256 }
257 }
258 }
259 }
260 if(c == '\n')line_no += 1;
261 return(c);
262 }
263
264 static int
get_char(fp,args)265 get_char(fp, args) /* remove null lines */
266 FILE *fp;
267 ARGS *args;
268 {
269 int d;
270 #ifndef NEW_HINSI
271 static int cucucu = -1;
272 static int fufufu = 0;
273 #endif /* NEW_HINSI */
274
275 if(cucucu != -1){
276 d = cucucu;
277 cucucu = -1;
278 return(d);
279 }else{
280 if(fufufu == 0){ /* remove all new lines in the head of the file */
281 for(;(d = get_char0(fp, args)) == '\n';);
282 fufufu = 1;
283 }else{
284 d = get_char0(fp, args);
285 }
286 if(d == '\n'){
287 while((cucucu = get_char0(fp, args)) == '\n');
288 }
289 return(d);
290 }
291 }
292
293 /* get one phrase and return the separater */
294 static int
get_phrase(s0,size,fp,args)295 get_phrase(s0,size,fp, args)
296 UCHAR *s0;
297 int size;
298 FILE *fp;
299 ARGS *args;
300 {
301 UCHAR *s = s0;
302 int c;
303 #ifndef NEW_HINSI
304 static int eof = 0;
305 #endif /* NEW_HINSI */
306
307 if(eof){
308 *s0 = 0;
309 return(EOF);
310 }
311
312 while((c = get_char(fp, args)) != '\n' && c != DEVIDE_CHAR && c != NODE_CHAR && c != HINSI_SEPARATE_CHAR && c != EOF){
313 if(s - s0 >= size){
314 error_long(args);
315 return(HINSI_ERR);
316 }
317 *s++ = c;
318 }
319
320 if(c == EOF) eof = 1;
321 if(s - s0 >= size - 1){
322 error_long(args);
323 return(HINSI_ERR);
324 }
325 *s++ = '\0';
326 return(c);
327 }
328
329 static int
stradd(cp,str,args)330 stradd(cp,str, args)
331 w_char **cp;
332 char *str;
333 ARGS *args;
334 {
335 int len = strlen(str);
336
337 if(hp + len + 1 >= heap + HEAP_LEN){
338 error_no_heap(args);
339 return(-1);
340 }
341 *cp = hp;
342 wnn_Sstrcpy(hp,str);
343 hp += wnn_Strlen(hp) + 1;
344 return(0);
345 }
346
347 static int
w_stradd(cp,str,args)348 w_stradd(cp,str, args)
349 unsigned short **cp;
350 unsigned short *str;
351 ARGS *args;
352 {
353
354 *cp = whp;
355 for(;*str != TERMINATE; str++,whp++){
356 if(whp >= wheap + WHEAP_LEN){
357 error_no_heap(args);
358 return(-1);
359 }
360 *whp = *str;
361 }
362 *whp++ = TERMINATE;
363 return(0);
364 }
365
366 int
wnn_loadhinsi(fname,args)367 wnn_loadhinsi(fname, args)
368 unsigned char *fname;
369 ARGS *args;
370 {
371 FILE *fp;
372 UCHAR buf[SIZE];
373 unsigned short fukugou_str[MAXHINSI];
374 int sep;
375 int h;
376 unsigned short *c;
377 char tmp[256];
378 extern int wnn_find_hinsi_by_name();
379
380 #ifdef NEW_HINSI
381 return(0);
382 #endif /* NEW_HINSI */
383
384 if(fname == NULL){
385 strcpy(tmp, LIBDIR);
386 strcat(tmp, HINSIDATA_FILE);
387 fname = (unsigned char *)tmp;
388 }
389
390
391 if((fp = fopen((char *)fname, "r")) == NULL){
392 wnnerror_hinsi = WNN_NO_HINSI_DATA_FILE;
393 goto err_1;
394 }
395
396 hinsi_loaded = 1;
397 while((sep = get_phrase(buf,SIZE,fp, args)) != EOF){
398 if(sep == HINSI_ERR){
399 goto err; /* wnnerror_hinsi set in get_phrase */
400 }
401 if(buf[0] == YOYAKU_CHAR){ /* yoyaku */
402 if(sep != '\n'){
403 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
404 goto err;
405 }
406 hinsi[mhinsi++] = NULL;
407 }else if(sep == '\n'){ /* hinsi */
408 if(stradd(&hinsi[mhinsi++],buf, args))goto err;
409 }else if(sep == DEVIDE_CHAR){ /* fukugou */
410 if(stradd(&fukugou[mfukugou].name,buf, args))goto err;
411 c = fukugou_str;
412 while((sep = get_phrase(buf,SIZE,fp, args)) != EOF){
413 if(sep == -1){
414 goto err; /* wnnerror_hinsi set in get_phrase */
415 }
416 if(sep != EOF && sep != HINSI_SEPARATE_CHAR && sep != '\n'){
417 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
418 goto err;
419 }
420 if((h = wnn_find_hinsi_by_name(buf, args)) == -1 ||
421 h >= mhinsi){
422 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
423 goto err;
424 }
425 *c++ = h;
426 if(sep == '\n' || sep == EOF)
427 break;
428 }
429 *c = TERMINATE;
430 if(w_stradd(&fukugou[mfukugou++].component,fukugou_str, args))goto err;
431 }else if(sep == NODE_CHAR){
432 int first = 1;
433 w_char *dummy;
434
435 node[mnode].kosuu = 0;
436 if(stradd(&node[mnode].name,buf, args))goto err;
437 while((sep = get_phrase(buf,SIZE,fp, args)) != EOF){
438 if(sep == -1){
439 goto err; /* wnnerror_hinsi set in get_phrase */
440 }
441 if(sep != EOF && sep != HINSI_SEPARATE_CHAR && sep != '\n'){
442 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
443 goto err;
444 }
445 node[mnode].kosuu++;
446 if(first){
447 if(stradd(&node[mnode].son,buf, args))goto err;
448 first = 0;
449 }else{
450 if(stradd(&dummy,buf, args))goto err;
451 }
452 if(sep == '\n' || sep == EOF)
453 break;
454 }
455 mnode++;
456 }
457 }
458 fclose(fp);
459 return(0);
460 err:
461 fclose(fp);
462 err_1:
463 return(HINSI_ERR);
464 }
465
466 static int
find_hinsi_by_name(c,args)467 find_hinsi_by_name(c, args)
468 register w_char *c;
469 ARGS *args;
470 {
471 register int k;
472 #if !defined(DSERVER) && defined(NEW_HINSI)
473 mhinsi = ft->hinsi_data->mhinsi;
474 mfukugou = ft->hinsi_data->mfukugou;
475 hinsi = ft->hinsi_data->hinsi;
476 fukugou = ft->hinsi_data->fukugou;
477 #endif /* !DSERVER && NEW_HINSI */
478 char *hfname = NULL;
479
480 #if !defined(DSERVER) && defined(JSERVER)
481 hfname = hinsi_file_name;
482 #endif /* !DSERVER && JSERVER */
483 if(!hinsi_loaded){
484 if(wnn_loadhinsi(hfname, args) != 0){
485 return(-1);
486 }
487 }
488 for(k = 0 ; k < mhinsi; k++){
489 if(hinsi[k] && wnn_Strcmp(hinsi[k],c) == 0){
490 return(k);
491 }
492 }
493 for(k = 0 ; k < mfukugou; k++){
494 if(fukugou[k].name && wnn_Strcmp(fukugou[k].name,c) == 0){
495 return(FUKUGOU_START - k);
496 }
497 }
498 return(-1);
499 }
500
501
502 int
wnn_find_hinsi_by_name(c,args)503 wnn_find_hinsi_by_name(c, args)
504 register char *c;
505 ARGS *args;
506 {
507 w_char hin[WNN_HINSI_NAME_LEN];
508
509 wnn_Sstrcpy(hin, c);
510 return(find_hinsi_by_name(hin, args));
511 }
512
513
514 static w_char *
get_hinsi_name(k,args)515 get_hinsi_name(k, args)
516 int k;
517 ARGS *args;
518 {
519 #if !defined(DSERVER) && defined(NEW_HINSI)
520 mhinsi = ft->hinsi_data->mhinsi;
521 mfukugou = ft->hinsi_data->mfukugou;
522 hinsi = ft->hinsi_data->hinsi;
523 fukugou = ft->hinsi_data->fukugou;
524 #endif /* !DSERVER && NEW_HINSI */
525 char *hfname = NULL;
526
527 #if !defined(DSERVER) && defined(JSERVER)
528 hfname = hinsi_file_name;
529 #endif /* !DSERVER && JSERVER */
530 if(!hinsi_loaded){
531 if(wnn_loadhinsi(hfname, args) != 0){
532 return(NULL);
533 }
534 }
535 if(k < mhinsi && k >= 0){
536 return(hinsi[k]);
537 }else if(k > FUKUGOU_START - mfukugou){
538 return(fukugou[FUKUGOU_START - k].name);
539 }
540 return(NULL);
541 }
542
543 char *
wnn_get_hinsi_name(k,args)544 wnn_get_hinsi_name(k, args)
545 int k;
546 ARGS *args;
547 {
548 w_char *s;
549 static char hin[WNN_HINSI_NAME_LEN * 2];
550
551 if((s = get_hinsi_name(k, args)) == NULL)return(NULL);
552 wnn_sStrcpy(hin, s);
553 return(hin);
554 }
555
556 static
557 int
wnn_get_fukugou_component_body(k,shp,args)558 wnn_get_fukugou_component_body(k,shp, args)
559 register int k;
560 register unsigned short **shp;
561 ARGS *args;
562 {
563 static unsigned short tmp;
564
565 register unsigned short *s;
566 int n;
567 #if !defined(DSERVER) && defined(NEW_HINSI)
568 mhinsi = ft->hinsi_data->mhinsi;
569 mfukugou = ft->hinsi_data->mfukugou;
570 hinsi = ft->hinsi_data->hinsi;
571 fukugou = ft->hinsi_data->fukugou;
572 #endif /* !DSERVER && NEW_HINSI */
573
574 if(k < mhinsi && k >= 0){
575 tmp = k;
576 *shp = &tmp;
577 return(1);
578 }
579 if(k > FUKUGOU_START - mfukugou && k <= FUKUGOU_START){
580 /* This fix for NEWS-OS 6.0.1 compiler bug!! */
581 n = FUKUGOU_START - k;
582 for(*shp = s = fukugou[n].component;*s != TERMINATE;s++);
583 return(s - *shp);
584 }
585 return(-1);
586 }
587
588 int
wnn_get_fukugou_component(k,shp,args)589 wnn_get_fukugou_component(k,shp, args)
590 register int k;
591 register unsigned short **shp;
592 ARGS *args;
593 {
594 char *hfname = NULL;
595
596 #if !defined(DSERVER) && defined(JSERVER)
597 hfname = hinsi_file_name;
598 #endif /* !DSERVER && JSERVER */
599 if(!hinsi_loaded){
600 if(wnn_loadhinsi(hfname, args) != 0){
601 return(-1);
602 }
603 }
604 return(wnn_get_fukugou_component_body(k, shp, args));
605 }
606
607
608
609
610 #ifdef NEW_HINSI
611 int
new_wnn_loadhinsi(fp,hinsi_data)612 new_wnn_loadhinsi(fp, hinsi_data)
613 FILE *fp;
614 struct HDT **hinsi_data;
615 {
616 UCHAR buf[SIZE];
617 unsigned short fukugou_str[MAXHINSI];
618 int sep;
619 int h;
620 unsigned short *c;
621
622 struct HDT *hdata;
623 static int wnn_find_load_hinsi_by_name();
624
625 if((hdata = (struct HDT *)malloc(sizeof(struct HDT))) == NULL) {
626 return(-1);
627 }
628 hp = heap = hdata->heap;
629 whp = wheap = hdata->wheap;
630 hdata->mhinsi = 0;
631 hdata->mfukugou = 0;
632 hdata->mnode = 0;
633 cucucu = -1;
634 eof = fufufu = 0;
635
636 hinsi_loaded = 1;
637
638 while((sep = get_phrase(buf,SIZE,fp)) != EOF){
639 if(sep == HINSI_ERR){
640 goto err; /* wnnerror_hinsi set in get_phrase */
641 }
642 if(buf[0] == YOYAKU_CHAR){ /* yoyaku */
643 if(sep != '\n'){
644 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
645 goto err;
646 }
647 hdata->hinsi[(hdata->mhinsi)++] = NULL;
648 }else if(sep == '\n'){ /* hinsi */
649 if(stradd(&(hdata->hinsi[(hdata->mhinsi)++]),buf))goto err;
650 }else if(sep == DEVIDE_CHAR){ /* fukugou */
651 if(stradd(&(hdata->fukugou[hdata->mfukugou].name),buf))goto err;
652 c = fukugou_str;
653 while((sep = get_phrase(buf,SIZE,fp)) != EOF){
654 if(sep == -1){
655 goto err; /* wnnerror_hinsi set in get_phrase */
656 }
657 if(sep != EOF && sep != HINSI_SEPARATE_CHAR && sep != '\n'){
658 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
659 goto err;
660 }
661 if((h = wnn_find_load_hinsi_by_name(hdata, buf)) == -1 ||
662 h >= hdata->mhinsi){
663 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
664 goto err;
665 }
666 *c++ = h;
667 if(sep == '\n' || sep == EOF)
668 break;
669 }
670 *c = TERMINATE;
671 if(w_stradd(&(hdata->fukugou[(hdata->mfukugou)++].component),fukugou_str))goto err;
672 }else if(sep == NODE_CHAR){
673 int first = 1;
674 w_char *dummy;
675
676 hdata->node[hdata->mnode].kosuu = 0;
677 if(stradd(&(hdata->node[hdata->mnode].name),buf))goto err;
678 while((sep = get_phrase(buf,SIZE,fp)) != EOF){
679 if(sep == -1){
680 goto err; /* wnnerror_hinsi set in get_phrase */
681 }
682 if(sep != EOF && sep != HINSI_SEPARATE_CHAR && sep != '\n'){
683 wnnerror_hinsi = WNN_BAD_HINSI_FILE;
684 goto err;
685 }
686 (hdata->node[hdata->mnode].kosuu)++;
687 if(first){
688 if(stradd(&(hdata->node[hdata->mnode].son),buf))goto err;
689 first = 0;
690 }else{
691 if(stradd(&dummy,buf))goto err;
692 }
693 if(sep == '\n' || sep == EOF)
694 break;
695 }
696 (hdata->mnode)++;
697 }
698 }
699
700 *hinsi_data = hdata;
701
702 return(0);
703 err:
704 free(hdata);
705 return(HINSI_ERR);
706 }
707
708
709 int
find_load_hinsi_by_name(hdata,c)710 find_load_hinsi_by_name(hdata, c)
711 struct HDT *hdata;
712 register w_char *c;
713 {
714 register int k;
715
716 for(k = 0 ; k < hdata->mhinsi; k++){
717 if(hdata->hinsi[k] && wnn_Strcmp(hdata->hinsi[k],c) == 0){
718 return(k);
719 }
720 }
721 for(k = 0 ; k < hdata->mfukugou; k++){
722 if(hdata->fukugou[k].name && wnn_Strcmp(hdata->fukugou[k].name,c) == 0){
723 return(FUKUGOU_START - k);
724 }
725 }
726 return(-1);
727 }
728
729
730 static int
wnn_find_load_hinsi_by_name(hdata,c)731 wnn_find_load_hinsi_by_name(hdata, c)
732 struct HDT *hdata;
733 register char *c;
734 {
735 w_char hin[WNN_HINSI_NAME_LEN];
736
737 wnn_Sstrcpy(hin, c);
738 return(find_load_hinsi_by_name(hdata, hin));
739 }
740 #endif /* NEW_HINSI */
741
742
743 /* ?? need doc. */
744 int
wnn_get_hinsi_i4_boundary_free(hinsi_pter)745 wnn_get_hinsi_i4_boundary_free(hinsi_pter)
746 register unsigned char *hinsi_pter;
747 {
748 register int ret;
749
750 ret = *hinsi_pter; ret = (ret<<8) | *(hinsi_pter+1);
751 return(ret);
752 }
753