Mercurial > freewnn
comparison Wnn/jlib/jl.c @ 11:aa17e2acfa01
add prototypes for function to jllib.h
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sun, 02 Mar 2008 04:48:21 +0900 |
parents | 790205f476c0 |
children | 778894f4449f |
comparison
equal
deleted
inserted
replaced
10:fc3022f61fc7 | 11:aa17e2acfa01 |
---|---|
191 /* | 191 /* |
192 * File management routines. | 192 * File management routines. |
193 */ | 193 */ |
194 | 194 |
195 static struct wnn_jl_env * | 195 static struct wnn_jl_env * |
196 find_jl_env (env) | 196 find_jl_env (register struct wnn_env *env) |
197 register struct wnn_env *env; | |
198 { | 197 { |
199 register int k; | 198 register int k; |
200 for (k = 0; k < MAXENVS; k++) | 199 for (k = 0; k < MAXENVS; k++) |
201 { | 200 { |
202 if (envs[k].env == env) | 201 if (envs[k].env == env) |
292 } | 291 } |
293 return (NULL); | 292 return (NULL); |
294 } | 293 } |
295 | 294 |
296 static char * | 295 static char * |
297 env_name (env) | 296 env_name (register struct wnn_env *env) |
298 register struct wnn_env *env; | |
299 { | 297 { |
300 register int k; | 298 register int k; |
301 | 299 |
302 for (k = 0; k < MAXENVS; k++) | 300 for (k = 0; k < MAXENVS; k++) |
303 { | 301 { |
333 break; | 331 break; |
334 } | 332 } |
335 } | 333 } |
336 } | 334 } |
337 | 335 |
338 static int | 336 static int |
339 delete_env (env) | 337 delete_env (register struct wnn_env *env) |
340 register struct wnn_env *env; | |
341 { | 338 { |
342 register int k; | 339 register int k; |
343 | 340 |
344 for (k = 0; k < MAXENVS; k++) | 341 for (k = 0; k < MAXENVS; k++) |
345 { | 342 { |
364 } | 361 } |
365 | 362 |
366 | 363 |
367 /* Routines to manipulate files */ | 364 /* Routines to manipulate files */ |
368 | 365 |
369 static int | 366 static int |
370 add_file_to_env (env, id, name) | 367 add_file_to_env (struct wnn_env *env, int id, register char *name) |
371 struct wnn_env *env; | |
372 int id; | |
373 register char *name; | |
374 { | 368 { |
375 register struct wnn_file_name_id *f, *f1; | 369 register struct wnn_file_name_id *f, *f1; |
376 if ((f = (struct wnn_file_name_id *) malloc (sizeof (struct wnn_file_name_id) + strlen (name) + 1)) == NULL) | 370 if ((f = (struct wnn_file_name_id *) malloc (sizeof (struct wnn_file_name_id) + strlen (name) + 1)) == NULL) |
377 { | 371 { |
378 wnn_errorno = WNN_ALLOC_FAIL; | 372 wnn_errorno = WNN_ALLOC_FAIL; |
385 find_jl_env (env)->file = f; | 379 find_jl_env (env)->file = f; |
386 return (0); | 380 return (0); |
387 } | 381 } |
388 | 382 |
389 static char * | 383 static char * |
390 find_file_name_from_id (env, id) | 384 find_file_name_from_id (struct wnn_env *env, register int id) |
391 struct wnn_env *env; | |
392 register int id; | |
393 { | 385 { |
394 register struct wnn_file_name_id *f; | 386 register struct wnn_file_name_id *f; |
395 f = find_jl_env (env)->file; | 387 f = find_jl_env (env)->file; |
396 for (; f; f = f->next) | 388 for (; f; f = f->next) |
397 { | 389 { |
402 } | 394 } |
403 /* wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT; */ | 395 /* wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT; */ |
404 return (NULL); | 396 return (NULL); |
405 } | 397 } |
406 | 398 |
407 static int | 399 static int |
408 delete_file_from_env (env, id) | 400 delete_file_from_env (struct wnn_env *env, register int id) |
409 struct wnn_env *env; | |
410 register int id; | |
411 { | 401 { |
412 struct wnn_file_name_id *f; | 402 struct wnn_file_name_id *f; |
413 register struct wnn_file_name_id **prev; | 403 register struct wnn_file_name_id **prev; |
414 register struct wnn_jl_env *jl_env_p; | 404 register struct wnn_jl_env *jl_env_p; |
415 | 405 |
432 /* | 422 /* |
433 * Libraries which handle Connection To Jserver | 423 * Libraries which handle Connection To Jserver |
434 */ | 424 */ |
435 | 425 |
436 struct wnn_env * | 426 struct wnn_env * |
437 jl_connect_lang (env_n, server_n, lang, wnnrc_n, error_handler, message_handler, timeout) | 427 jl_connect_lang (register char *env_n, register char *server_n, register char *lang, register char *wnnrc_n, int (*error_handler)(void), int (*message_handler)(void), int timeout) |
438 register char *env_n, *server_n, *wnnrc_n, *lang; | |
439 int (*error_handler) (), (*message_handler) (); | |
440 int timeout; | |
441 { | 428 { |
442 register WNN_JSERVER_ID *js = NULL; | 429 register WNN_JSERVER_ID *js = NULL; |
443 struct wnn_env *env; | 430 struct wnn_env *env; |
444 int env_exist; | 431 int env_exist; |
445 char p_lang[16]; | 432 char p_lang[16]; |
512 jl_set_env_wnnrc (env, wnnrc_n, error_handler, message_handler); | 499 jl_set_env_wnnrc (env, wnnrc_n, error_handler, message_handler); |
513 } | 500 } |
514 return (env); | 501 return (env); |
515 } | 502 } |
516 | 503 |
517 void | 504 void |
518 jl_disconnect (env) | 505 jl_disconnect (register struct wnn_env *env) |
519 register struct wnn_env *env; | |
520 { | 506 { |
521 int ret; | 507 int ret; |
522 wnn_errorno = 0; | 508 wnn_errorno = 0; |
523 if ((ret = delete_env (env)) < 0) | 509 if ((ret = delete_env (env)) < 0) |
524 { | 510 { |
533 js_close (env->js_id); | 519 js_close (env->js_id); |
534 env->js_id = 0; | 520 env->js_id = 0; |
535 } | 521 } |
536 } | 522 } |
537 | 523 |
538 int | 524 int |
539 jl_isconnect_e (env) | 525 jl_isconnect_e (register struct wnn_env *env) |
540 register struct wnn_env *env; | |
541 { | 526 { |
542 if (js_isconnect (env) == 0) | 527 if (js_isconnect (env) == 0) |
543 return (1); | 528 return (1); |
544 else | 529 else |
545 return (0); | 530 return (0); |
546 } | 531 } |
547 | 532 |
548 /* JSERVER が死んだら env を disconnect して回る */ | 533 /* JSERVER が死んだら env を disconnect して回る */ |
549 void | 534 void |
550 jl_disconnect_if_server_dead (env) | 535 jl_disconnect_if_server_dead (register struct wnn_env *env) |
551 register struct wnn_env *env; | |
552 { | 536 { |
553 register struct wnn_env *same_env; | 537 register struct wnn_env *same_env; |
554 int ret; | 538 int ret; |
555 | 539 |
556 if ((ret = delete_env (env)) < 0) | 540 if ((ret = delete_env (env)) < 0) |
573 env->js_id = 0; | 557 env->js_id = 0; |
574 } | 558 } |
575 | 559 |
576 | 560 |
577 struct wnn_buf * | 561 struct wnn_buf * |
578 jl_open_lang (env_n, server_n, lang, wnnrc_n, error_handler, message_handler, timeout) | 562 jl_open_lang (char *env_n, char *server_n, char *lang, char *wnnrc_n, int (*error_handler)(void), int (*message_handler)(void), int timeout) |
579 char *env_n, *server_n, *wnnrc_n, *lang; | |
580 int (*error_handler) (), (*message_handler) (); | |
581 int timeout; | |
582 { | 563 { |
583 register int k, dmy; | 564 register int k, dmy; |
584 register struct wnn_buf *buf; | 565 register struct wnn_buf *buf; |
585 struct wnn_env *env; | 566 struct wnn_env *env; |
586 | 567 |
629 buf->env = env; | 610 buf->env = env; |
630 return (buf); | 611 return (buf); |
631 } | 612 } |
632 | 613 |
633 | 614 |
634 static int | 615 static int |
635 alloc_heap (buf, len) | 616 alloc_heap (struct wnn_buf *buf, register int len) |
636 struct wnn_buf *buf; | |
637 register int len; | |
638 { | 617 { |
639 char **c; | 618 char **c; |
640 register WNN_BUN *d; | 619 register WNN_BUN *d; |
641 | 620 |
642 if ((c = (char **) malloc ((unsigned) (len * sizeof (WNN_BUN) + sizeof (char *)))) == NULL) | 621 if ((c = (char **) malloc ((unsigned) (len * sizeof (WNN_BUN) + sizeof (char *)))) == NULL) |
655 d->free_next = buf->free_heap; | 634 d->free_next = buf->free_heap; |
656 buf->free_heap = (WNN_BUN *) (c + 1); | 635 buf->free_heap = (WNN_BUN *) (c + 1); |
657 return (0); | 636 return (0); |
658 } | 637 } |
659 | 638 |
660 void | 639 void |
661 jl_close (buf) | 640 jl_close (register struct wnn_buf *buf) |
662 register struct wnn_buf *buf; | |
663 { | 641 { |
664 register char *c, *next; | 642 register char *c, *next; |
665 | 643 |
666 wnn_errorno = 0; | 644 wnn_errorno = 0; |
667 if (buf == NULL) | 645 if (buf == NULL) |
692 /* | 670 /* |
693 * Conversion Libraries | 671 * Conversion Libraries |
694 */ | 672 */ |
695 | 673 |
696 int | 674 int |
697 jl_ren_conv (buf, yomi, bun_no, bun_no2, use_maep) | 675 jl_ren_conv (register struct wnn_buf *buf, register w_char *yomi, int bun_no, bun_no2, int use_maep) |
698 register struct wnn_buf *buf; | |
699 register w_char *yomi; | |
700 int bun_no, bun_no2; | |
701 int use_maep; | |
702 { | 676 { |
703 wnn_errorno = 0; | 677 wnn_errorno = 0; |
704 if (bun_no < 0) | 678 if (bun_no < 0) |
705 return (-1); | 679 return (-1); |
706 if (bun_no2 >= buf->bun_suu || bun_no2 < 0) | 680 if (bun_no2 >= buf->bun_suu || bun_no2 < 0) |
779 } | 753 } |
780 return (buf->bun_suu); | 754 return (buf->bun_suu); |
781 } | 755 } |
782 | 756 |
783 int | 757 int |
784 jl_tan_conv (buf, yomi, bun_no, bun_no2, use_maep, ich_shop) | 758 jl_tan_conv (register struct wnn_buf *buf, w_char *yomi, register int bun_no, bun_no2, int use_maep, int ich_shop) |
785 register struct wnn_buf *buf; | |
786 w_char *yomi; | |
787 register int bun_no, bun_no2; | |
788 int use_maep, ich_shop; | |
789 { | 759 { |
790 wnn_errorno = 0; | 760 wnn_errorno = 0; |
791 if (bun_no < 0) | 761 if (bun_no < 0) |
792 return (-1); | 762 return (-1); |
793 if (bun_no2 >= buf->bun_suu || bun_no2 < 0) | 763 if (bun_no2 >= buf->bun_suu || bun_no2 < 0) |
879 buf->zenkouho_end_bun += ret - bun_no2; | 849 buf->zenkouho_end_bun += ret - bun_no2; |
880 } | 850 } |
881 return (ret); | 851 return (ret); |
882 } | 852 } |
883 | 853 |
884 int | 854 int |
885 jl_nobi_conv (buf, bun_no, ichbn_len, bun_no2, use_maep, ich_shop) | 855 jl_nobi_conv (register struct wnn_buf *buf, register int bun_no, int ichbn_len, register int bun_no2, int use_maep, int ich_shop) |
886 register struct wnn_buf *buf; | |
887 int ichbn_len, use_maep, ich_shop; | |
888 register int bun_no, bun_no2; | |
889 { | 856 { |
890 w_char yomi[LENGTHCONV], ytmp; | 857 w_char yomi[LENGTHCONV], ytmp; |
891 int ret; | 858 int ret; |
892 int len1; | 859 int len1; |
893 | 860 |
946 buf->down_bnst[bun_no] = b1; | 913 buf->down_bnst[bun_no] = b1; |
947 | 914 |
948 return (buf->bun_suu); | 915 return (buf->bun_suu); |
949 } | 916 } |
950 | 917 |
951 int | 918 int |
952 jl_nobi_conv_e2 (buf, env, bun_no, ichbn_len, bun_no2, use_maep, ich_shop) | 919 jl_nobi_conv_e2 (register struct wnn_buf *buf, struct wnn_env *env, register int bun_no, int ichbn_len, register int bun_no2, int use_maep, int ich_shop) |
953 register struct wnn_buf *buf; | |
954 struct wnn_env *env; | |
955 int ichbn_len, use_maep, ich_shop; | |
956 register int bun_no, bun_no2; | |
957 { | 920 { |
958 w_char yomi[LENGTHCONV], ytmp; | 921 w_char yomi[LENGTHCONV], ytmp; |
959 int ret; | 922 int ret; |
960 int len1; | 923 int len1; |
961 | 924 |
1019 buf->bun[bun_no]->nobi_top = 1; | 982 buf->bun[bun_no]->nobi_top = 1; |
1020 | 983 |
1021 return (buf->bun_suu); | 984 return (buf->bun_suu); |
1022 } | 985 } |
1023 | 986 |
1024 int | 987 int |
1025 jl_kill (buf, bun_no, bun_no2) | 988 jl_kill (struct wnn_buf *buf, register int bun_no, register int bun_no2) |
1026 struct wnn_buf *buf; | |
1027 register int bun_no, bun_no2; | |
1028 { | 989 { |
1029 wnn_errorno = 0; | 990 wnn_errorno = 0; |
1030 if (bun_no < 0) | 991 if (bun_no < 0) |
1031 return (0); | 992 return (0); |
1032 if (bun_no2 < bun_no || bun_no2 < 0) | 993 if (bun_no2 < bun_no || bun_no2 < 0) |
1038 bcopy ((char *) &buf->down_bnst[bun_no2], (char *) &buf->down_bnst[bun_no], (buf->bun_suu - bun_no2) * sizeof (WNN_BUN *)); | 999 bcopy ((char *) &buf->down_bnst[bun_no2], (char *) &buf->down_bnst[bun_no], (buf->bun_suu - bun_no2) * sizeof (WNN_BUN *)); |
1039 buf->bun_suu -= bun_no2 - bun_no; | 1000 buf->bun_suu -= bun_no2 - bun_no; |
1040 return (buf->bun_suu); | 1001 return (buf->bun_suu); |
1041 } | 1002 } |
1042 | 1003 |
1043 int | 1004 int |
1044 jl_zenkouho (buf, bun_no, use_maep, uniq_level) | 1005 jl_zenkouho (register struct wnn_buf *buf, int bun_no, int use_maep, int uniq_level) |
1045 register struct wnn_buf *buf; | |
1046 int bun_no, use_maep, uniq_level; | |
1047 { | 1006 { |
1048 int cnt; | 1007 int cnt; |
1049 w_char yomi[LENGTHBUNSETSU], yomi1[LENGTHBUNSETSU]; | 1008 w_char yomi[LENGTHBUNSETSU], yomi1[LENGTHBUNSETSU]; |
1050 struct wnn_sho_bunsetsu *sp; | 1009 struct wnn_sho_bunsetsu *sp; |
1051 register int k; | 1010 register int k; |
1135 } | 1094 } |
1136 } | 1095 } |
1137 return (buf->c_zenkouho); | 1096 return (buf->c_zenkouho); |
1138 } | 1097 } |
1139 | 1098 |
1140 int | 1099 int |
1141 jl_zenkouho_dai (buf, bun_no, bun_no2, use_maep, uniq_level) | 1100 jl_zenkouho_dai (register struct wnn_buf *buf, int bun_no, int bun_no2, int use_maep, int uniq_level) |
1142 register struct wnn_buf *buf; | |
1143 int bun_no, bun_no2, use_maep, uniq_level; | |
1144 { | 1101 { |
1145 int cnt; | 1102 int cnt; |
1146 w_char yomi[LENGTHBUNSETSU], yomi1[LENGTHBUNSETSU]; | 1103 w_char yomi[LENGTHBUNSETSU], yomi1[LENGTHBUNSETSU]; |
1147 struct wnn_dai_bunsetsu *dp; | 1104 struct wnn_dai_bunsetsu *dp; |
1148 int tmp; | 1105 int tmp; |
1247 } | 1204 } |
1248 } | 1205 } |
1249 return (buf->c_zenkouho); | 1206 return (buf->c_zenkouho); |
1250 } | 1207 } |
1251 | 1208 |
1252 int | 1209 int |
1253 jl_set_jikouho (buf, offset) | 1210 jl_set_jikouho (register struct wnn_buf *buf, register int offset) |
1254 register struct wnn_buf *buf; | |
1255 register int offset; | |
1256 { | 1211 { |
1257 wnn_errorno = 0; | 1212 wnn_errorno = 0; |
1258 if (buf->zenkouho_suu <= 0) | 1213 if (buf->zenkouho_suu <= 0) |
1259 return (-1); | 1214 return (-1); |
1260 if (buf->zenkouho_daip != SHO) | 1215 if (buf->zenkouho_daip != SHO) |
1269 buf->c_zenkouho = offset; | 1224 buf->c_zenkouho = offset; |
1270 return (offset); | 1225 return (offset); |
1271 } | 1226 } |
1272 | 1227 |
1273 | 1228 |
1274 int | 1229 int |
1275 jl_set_jikouho_dai (buf, offset) | 1230 jl_set_jikouho_dai (register struct wnn_buf *buf, int offset) |
1276 register struct wnn_buf *buf; | |
1277 int offset; | |
1278 { | 1231 { |
1279 register int st, end, bun, k; | 1232 register int st, end, bun, k; |
1280 | 1233 |
1281 wnn_errorno = 0; | 1234 wnn_errorno = 0; |
1282 if (buf->zenkouho_suu <= 0) | 1235 if (buf->zenkouho_suu <= 0) |
1299 buf->zenkouho_end_bun = buf->zenkouho_bun + end - st; | 1252 buf->zenkouho_end_bun = buf->zenkouho_bun + end - st; |
1300 buf->c_zenkouho = offset; | 1253 buf->c_zenkouho = offset; |
1301 return (offset); | 1254 return (offset); |
1302 } | 1255 } |
1303 | 1256 |
1304 int | 1257 int |
1305 jl_update_hindo (buf, bun_no, bun_no2) | 1258 jl_update_hindo (register struct wnn_buf *buf, int bun_no, int bun_no2) |
1306 register struct wnn_buf *buf; | |
1307 int bun_no, bun_no2; | |
1308 { | 1259 { |
1309 register int k; | 1260 register int k; |
1310 register WNN_BUN *wb; | 1261 register WNN_BUN *wb; |
1311 | 1262 |
1312 wnn_errorno = 0; | 1263 wnn_errorno = 0; |
1407 } | 1358 } |
1408 out: | 1359 out: |
1409 return (area); | 1360 return (area); |
1410 } | 1361 } |
1411 | 1362 |
1412 static int | 1363 static int |
1413 dai_end (buf, bun_no) | 1364 dai_end (register struct wnn_buf *buf, register int bun_no) |
1414 register struct wnn_buf *buf; | |
1415 register int bun_no; | |
1416 { | 1365 { |
1417 bun_no++; | 1366 bun_no++; |
1418 for (; bun_no < buf->bun_suu && !buf->bun[bun_no]->dai_top; bun_no++); | 1367 for (; bun_no < buf->bun_suu && !buf->bun[bun_no]->dai_top; bun_no++); |
1419 return (bun_no); | 1368 return (bun_no); |
1420 } | 1369 } |
1422 #define dai_end_zenkouho(buf, bun_no) (buf->zenkouho_dai[bun_no + 1]) | 1371 #define dai_end_zenkouho(buf, bun_no) (buf->zenkouho_dai[bun_no + 1]) |
1423 | 1372 |
1424 #ifdef CONVERT_by_STROKE | 1373 #ifdef CONVERT_by_STROKE |
1425 /* 筆形 (Bi Xing) */ | 1374 /* 筆形 (Bi Xing) */ |
1426 void | 1375 void |
1427 jl_get_zenkouho_yomi (buf, zen_num, area) | 1376 jl_get_zenkouho_yomi (register struct wnn_buf *buf, int zen_num, w_char *area) |
1428 register struct wnn_buf *buf; | |
1429 int zen_num; | |
1430 w_char *area; | |
1431 { | 1377 { |
1432 register int k, end; | 1378 register int k, end; |
1433 | 1379 |
1434 wnn_errorno = 0; | 1380 wnn_errorno = 0; |
1435 if (!buf->zenkouho_daip) | 1381 if (!buf->zenkouho_daip) |
1446 } | 1392 } |
1447 } | 1393 } |
1448 #endif | 1394 #endif |
1449 | 1395 |
1450 void | 1396 void |
1451 jl_get_zenkouho_kanji (buf, zen_num, area) | 1397 jl_get_zenkouho_kanji (register struct wnn_buf *buf, int zen_num, w_char *area) |
1452 register struct wnn_buf *buf; | |
1453 int zen_num; | |
1454 w_char *area; | |
1455 { | 1398 { |
1456 register int k, end; | 1399 register int k, end; |
1457 | 1400 |
1458 wnn_errorno = 0; | 1401 wnn_errorno = 0; |
1459 if (!buf->zenkouho_daip) | 1402 if (!buf->zenkouho_daip) |
1469 } | 1412 } |
1470 } | 1413 } |
1471 } | 1414 } |
1472 | 1415 |
1473 int | 1416 int |
1474 wnn_get_area (buf, bun_no, bun_no2, area, kanjip) | 1417 wnn_get_area (struct wnn_buf *buf, register int bun_no, register int bun_no2, w_char *area, int kanjip) |
1475 struct wnn_buf *buf; | |
1476 register int bun_no, bun_no2; | |
1477 w_char *area; | |
1478 int kanjip; | |
1479 { | 1418 { |
1480 register int k; | 1419 register int k; |
1481 w_char *area1 = area; | 1420 w_char *area1 = area; |
1482 | 1421 |
1483 if (bun_no < 0) | 1422 if (bun_no < 0) |
1494 | 1433 |
1495 #define JISHO 1 | 1434 #define JISHO 1 |
1496 #define HINDO 2 | 1435 #define HINDO 2 |
1497 | 1436 |
1498 /*********************************/ | 1437 /*********************************/ |
1499 int | 1438 int |
1500 jl_dic_add_e (env, dic_name, hindo_name, rev, prio, rw, hrw, pwd_dic, pwd_hindo, error_handler, message_handler) | 1439 jl_dic_add_e (register struct wnn_env *env, char *dic_name, char *hindo_name, int rev, int prio, int rw, int hrw, char *pwd_dic, char *pwd_hindo, int (*error_handler)(void), int (*message_handler)(void)) |
1501 register struct wnn_env *env; | |
1502 char *dic_name; | |
1503 char *hindo_name; | |
1504 int prio; | |
1505 int rw, hrw, rev; | |
1506 char *pwd_dic, *pwd_hindo; | |
1507 int (*error_handler) (), (*message_handler) (); | |
1508 { | 1440 { |
1509 char tmp[256]; | 1441 char tmp[256]; |
1510 char pwd[WNN_PASSWD_LEN], hpwd[WNN_PASSWD_LEN]; | 1442 char pwd[WNN_PASSWD_LEN], hpwd[WNN_PASSWD_LEN]; |
1511 int fid, hfid = -1; | 1443 int fid, hfid = -1; |
1512 register int ret; | 1444 register int ret; |
1627 } | 1559 } |
1628 return (ret); | 1560 return (ret); |
1629 } | 1561 } |
1630 | 1562 |
1631 | 1563 |
1632 int | 1564 int |
1633 jl_dic_delete_e (env, dic_no) | 1565 jl_dic_delete_e (register struct wnn_env *env, register int dic_no) |
1634 register struct wnn_env *env; | |
1635 register int dic_no; | |
1636 { | 1566 { |
1637 WNN_DIC_INFO dic; | 1567 WNN_DIC_INFO dic; |
1638 | 1568 |
1639 if (js_dic_info (env, dic_no, &dic) < 0) | 1569 if (js_dic_info (env, dic_no, &dic) < 0) |
1640 { | 1570 { |
1656 } | 1586 } |
1657 } | 1587 } |
1658 return (0); | 1588 return (0); |
1659 } | 1589 } |
1660 | 1590 |
1661 static int | 1591 static int |
1662 get_pwd (pwd_dic, pwd) | 1592 get_pwd (register char *pwd_dic, register char *pwd) |
1663 register char *pwd_dic, *pwd; | |
1664 { | 1593 { |
1665 FILE *fp; | 1594 FILE *fp; |
1666 | 1595 |
1667 if (pwd_dic && *pwd_dic) | 1596 if (pwd_dic && *pwd_dic) |
1668 { | 1597 { |
1679 pwd[0] = 0; | 1608 pwd[0] = 0; |
1680 } | 1609 } |
1681 return (0); | 1610 return (0); |
1682 } | 1611 } |
1683 | 1612 |
1684 static int | 1613 static int |
1685 create_pwd_file (env, pwd_file, error_handler, message_handler) | 1614 create_pwd_file (register struct wnn_env *env, char *pwd_file, int (*error_handler)(void), int (*message_handler)(void)) |
1686 register struct wnn_env *env; | |
1687 char *pwd_file; | |
1688 int (*error_handler) (), (*message_handler) (); | |
1689 { | 1615 { |
1690 FILE *fp; | 1616 FILE *fp; |
1691 char gomi[256]; | 1617 char gomi[256]; |
1692 | 1618 |
1693 if (pwd_file == NULL || *pwd_file == 0) | 1619 if (pwd_file == NULL || *pwd_file == 0) |
1717 return (0); | 1643 return (0); |
1718 } | 1644 } |
1719 | 1645 |
1720 | 1646 |
1721 /** jl_fuzokugo_set **/ | 1647 /** jl_fuzokugo_set **/ |
1722 int | 1648 int |
1723 jl_fuzokugo_set_e (env, fname) | 1649 jl_fuzokugo_set_e (struct wnn_env *env, char *fname) |
1724 struct wnn_env *env; | |
1725 char *fname; | |
1726 { | 1650 { |
1727 register int fid, orgfid; | 1651 register int fid, orgfid; |
1728 int ret; | 1652 int ret; |
1729 | 1653 |
1730 wnn_errorno = 0; | 1654 wnn_errorno = 0; |
1742 } | 1666 } |
1743 return (ret); | 1667 return (ret); |
1744 } | 1668 } |
1745 | 1669 |
1746 /** jl_fuzokugo_get **/ | 1670 /** jl_fuzokugo_get **/ |
1747 int | 1671 int |
1748 jl_fuzokugo_get_e (env, fname) | 1672 jl_fuzokugo_get_e (register struct wnn_env *env, char *fname) |
1749 register struct wnn_env *env; | |
1750 char *fname; | |
1751 { | 1673 { |
1752 WNN_FILE_INFO_STRUCT file; | 1674 WNN_FILE_INFO_STRUCT file; |
1753 int fid; | 1675 int fid; |
1754 char *c; | 1676 char *c; |
1755 | 1677 |
1767 strcpy (fname, c); | 1689 strcpy (fname, c); |
1768 return (fid); | 1690 return (fid); |
1769 } | 1691 } |
1770 | 1692 |
1771 /** jl_dic_save **/ | 1693 /** jl_dic_save **/ |
1772 int | 1694 int |
1773 jl_dic_save_e (env, dic_no) | 1695 jl_dic_save_e (register struct wnn_env *env, int dic_no) |
1774 register struct wnn_env *env; | |
1775 int dic_no; | |
1776 { | 1696 { |
1777 WNN_DIC_INFO dic; | 1697 WNN_DIC_INFO dic; |
1778 WNN_FILE_INFO_STRUCT file; | 1698 WNN_FILE_INFO_STRUCT file; |
1779 char *c; | 1699 char *c; |
1780 | 1700 |
1851 } | 1771 } |
1852 } | 1772 } |
1853 return (0); | 1773 return (0); |
1854 } | 1774 } |
1855 | 1775 |
1856 int | 1776 int |
1857 jl_dic_save_all_e (env) | 1777 jl_dic_save_all_e (struct wnn_env *env) |
1858 struct wnn_env *env; | |
1859 { | 1778 { |
1860 register WNN_DIC_INFO *dic; | 1779 register WNN_DIC_INFO *dic; |
1861 register int k; | 1780 register int k; |
1862 char *c; | 1781 char *c; |
1863 | 1782 |
1974 } | 1893 } |
1975 } | 1894 } |
1976 *wbp = NULL; | 1895 *wbp = NULL; |
1977 } | 1896 } |
1978 | 1897 |
1979 static void | 1898 static void |
1980 free_zenkouho (buf) | 1899 free_zenkouho (register struct wnn_buf *buf) |
1981 register struct wnn_buf *buf; | |
1982 { | 1900 { |
1983 register int k; | 1901 register int k; |
1984 | 1902 |
1985 for (k = 0; k < buf->zenkouho_suu; k++) | 1903 for (k = 0; k < buf->zenkouho_suu; k++) |
1986 { | 1904 { |
1991 buf->c_zenkouho = -1; | 1909 buf->c_zenkouho = -1; |
1992 buf->zenkouho_bun = -1; | 1910 buf->zenkouho_bun = -1; |
1993 buf->zenkouho_end_bun = -1; | 1911 buf->zenkouho_end_bun = -1; |
1994 } | 1912 } |
1995 | 1913 |
1996 static void | 1914 static void |
1997 free_bun (buf, bun_no, bun_no2) | 1915 free_bun (struct wnn_buf *buf, register int bun_no, register int bun_no2) |
1998 struct wnn_buf *buf; | |
1999 register int bun_no, bun_no2; | |
2000 { | 1916 { |
2001 register int k; | 1917 register int k; |
2002 | 1918 |
2003 for (k = bun_no; k < bun_no2; k++) | 1919 for (k = bun_no; k < bun_no2; k++) |
2004 { | 1920 { |
2005 free_sho (buf, &buf->bun[k]); | 1921 free_sho (buf, &buf->bun[k]); |
2006 } | 1922 } |
2007 } | 1923 } |
2008 | 1924 |
2009 static void | 1925 static void |
2010 free_down (buf, bun_no, bun_no2) | 1926 free_down (struct wnn_buf *buf, int bun_no, int bun_no2) |
2011 struct wnn_buf *buf; | |
2012 int bun_no, bun_no2; | |
2013 { | 1927 { |
2014 register WNN_BUN **wbp, **wbp1; | 1928 register WNN_BUN **wbp, **wbp1; |
2015 int k; | 1929 int k; |
2016 | 1930 |
2017 for (k = bun_no; k < bun_no2; k++) | 1931 for (k = bun_no; k < bun_no2; k++) |
2124 out: | 2038 out: |
2125 wb1->next = NULL; | 2039 wb1->next = NULL; |
2126 return (wb); | 2040 return (wb); |
2127 } | 2041 } |
2128 | 2042 |
2129 static void | 2043 static void |
2130 make_space_for (buf, zenp, bun_no, bun_no2, cnt) | 2044 make_space_for (register struct wnn_buf *buf, int zenp, int bun_no, int bun_no2, int cnt) |
2131 register struct wnn_buf *buf; | |
2132 int bun_no, bun_no2, zenp; | |
2133 int cnt; | |
2134 { | 2045 { |
2135 switch (zenp) | 2046 switch (zenp) |
2136 { | 2047 { |
2137 case BUN: | 2048 case BUN: |
2138 make_space_for_bun (buf, bun_no, bun_no2, cnt); | 2049 make_space_for_bun (buf, bun_no, bun_no2, cnt); |
2140 case ZENKOUHO: | 2051 case ZENKOUHO: |
2141 make_space_for_zenkouho (buf, bun_no, bun_no2, cnt); | 2052 make_space_for_zenkouho (buf, bun_no, bun_no2, cnt); |
2142 } | 2053 } |
2143 } | 2054 } |
2144 | 2055 |
2145 static void | 2056 static void |
2146 make_space_for_bun (buf, bun_no, bun_no2, cnt) | 2057 make_space_for_bun (register struct wnn_buf *buf, int bun_no, int bun_no2, int cnt) |
2147 register struct wnn_buf *buf; | |
2148 int bun_no, bun_no2; | |
2149 int cnt; | |
2150 { | 2058 { |
2151 int newsize; | 2059 int newsize; |
2152 register int k; | 2060 register int k; |
2153 | 2061 |
2154 newsize = buf->bun_suu + cnt - (bun_no2 - bun_no); | 2062 newsize = buf->bun_suu + cnt - (bun_no2 - bun_no); |
2174 bzero ((char *) &buf->down_bnst[bun_no2], (bun_no + cnt - bun_no2) * sizeof (WNN_BUN *)); | 2082 bzero ((char *) &buf->down_bnst[bun_no2], (bun_no + cnt - bun_no2) * sizeof (WNN_BUN *)); |
2175 } | 2083 } |
2176 buf->bun_suu = newsize; | 2084 buf->bun_suu = newsize; |
2177 } | 2085 } |
2178 | 2086 |
2179 static void | 2087 static void |
2180 make_space_for_zenkouho (buf, bun_no, bun_no2, cnt) | 2088 make_space_for_zenkouho (struct wnn_buf *buf, int bun_no, int bun_no2, register int cnt) |
2181 struct wnn_buf *buf; | |
2182 int bun_no, bun_no2; | |
2183 register int cnt; | |
2184 { | 2089 { |
2185 register int newsize; | 2090 register int newsize; |
2186 | 2091 |
2187 newsize = buf->zenkouho_suu + cnt - (bun_no2 - bun_no); | 2092 newsize = buf->zenkouho_suu + cnt - (bun_no2 - bun_no); |
2188 | 2093 |
2195 bcopy ((char *) &buf->zenkouho[bun_no2], (char *) &buf->zenkouho[bun_no + cnt], (buf->zenkouho_suu - bun_no2) * sizeof (WNN_BUN *)); | 2100 bcopy ((char *) &buf->zenkouho[bun_no2], (char *) &buf->zenkouho[bun_no + cnt], (buf->zenkouho_suu - bun_no2) * sizeof (WNN_BUN *)); |
2196 buf->zenkouho_suu = newsize; | 2101 buf->zenkouho_suu = newsize; |
2197 } | 2102 } |
2198 | 2103 |
2199 | 2104 |
2200 static int | 2105 static int |
2201 insert_sho (buf, zenp, bun_no, bun_no2, sp, cnt, uniq_level) | 2106 insert_sho ( |
2202 struct wnn_buf *buf; | 2107 struct wnn_buf *buf, |
2203 int bun_no, bun_no2; | 2108 int zenp, /* daip */ |
2204 register struct wnn_sho_bunsetsu *sp; | 2109 int bun_no, |
2205 int cnt; | 2110 int bun_no2, |
2206 int zenp; /* daip */ | 2111 register struct wnn_sho_bunsetsu *sp, |
2207 int uniq_level; /* uniq is only supported when bun_no = -1 | 2112 int cnt, |
2113 int uniq_level /* uniq is only supported when bun_no = -1 | |
2208 and zenp == ZENKOUHO */ | 2114 and zenp == ZENKOUHO */ |
2115 ) | |
2209 { | 2116 { |
2210 register WNN_BUN **b; | 2117 register WNN_BUN **b; |
2211 register int k; | 2118 register int k; |
2212 | 2119 |
2213 if (bun_no == -1) | 2120 if (bun_no == -1) |
2247 } | 2154 } |
2248 return (cnt + bun_no); | 2155 return (cnt + bun_no); |
2249 } | 2156 } |
2250 | 2157 |
2251 /* for zenkouho, assume bun_no = bun_no2 = zenkouho_suu */ | 2158 /* for zenkouho, assume bun_no = bun_no2 = zenkouho_suu */ |
2252 static int | 2159 static int |
2253 insert_dai (buf, zenp, bun_no, bun_no2, dp, dcnt, uniq_level) | 2160 insert_dai (struct wnn_buf *buf, int zenp, int bun_no, int bun_no2, struct wnn_dai_bunsetsu *dp, int dcnt, int uniq_level) |
2254 struct wnn_buf *buf; | |
2255 int bun_no, bun_no2; | |
2256 struct wnn_dai_bunsetsu *dp; | |
2257 int dcnt; | |
2258 int zenp; | |
2259 int uniq_level; | |
2260 { | 2161 { |
2261 register WNN_BUN **b, **b0; | 2162 register WNN_BUN **b, **b0; |
2262 register int k, l, m; | 2163 register int k, l, m; |
2263 register int cnt = 0; | 2164 register int cnt = 0; |
2264 struct wnn_sho_bunsetsu *sp, *sp1; | 2165 struct wnn_sho_bunsetsu *sp, *sp1; |
2519 } | 2420 } |
2520 } | 2421 } |
2521 return (0); | 2422 return (0); |
2522 } | 2423 } |
2523 | 2424 |
2524 static int | 2425 static int |
2525 find_same_kouho_dai (dp, buf, top, level) | 2426 find_same_kouho_dai (struct wnn_dai_bunsetsu *dp, struct wnn_buf *buf, int top, int level) |
2526 struct wnn_dai_bunsetsu *dp; | |
2527 struct wnn_buf *buf; | |
2528 int top; | |
2529 int level; | |
2530 { | 2427 { |
2531 int len; | 2428 int len; |
2532 register int k, l; | 2429 register int k, l; |
2533 w_char area[LENGTHKANJI]; | 2430 w_char area[LENGTHKANJI]; |
2534 WNN_BUN *b; | 2431 WNN_BUN *b; |
2556 return (1); | 2453 return (1); |
2557 } | 2454 } |
2558 return (0); | 2455 return (0); |
2559 } | 2456 } |
2560 | 2457 |
2561 int | 2458 int |
2562 wnn_cnt_free (buf) | 2459 wnn_cnt_free (struct wnn_buf *buf) |
2563 struct wnn_buf *buf; | |
2564 { | 2460 { |
2565 register int n; | 2461 register int n; |
2566 register WNN_BUN *b; | 2462 register WNN_BUN *b; |
2567 | 2463 |
2568 for (n = 0, b = buf->free_heap; b; n++, b = b->free_next); | 2464 for (n = 0, b = buf->free_heap; b; n++, b = b->free_next); |
2569 return (n); | 2465 return (n); |
2570 } | 2466 } |
2571 | 2467 |
2572 | 2468 |
2573 struct wnn_jdata * | 2469 struct wnn_jdata * |
2574 jl_word_info_e (env, dic_no, entry) | 2470 jl_word_info_e (register struct wnn_env *env, int dic_no, int entry) |
2575 register struct wnn_env *env; | |
2576 int dic_no, entry; | |
2577 { | 2471 { |
2578 wnn_errorno = 0; | 2472 wnn_errorno = 0; |
2579 if (js_word_info (env, dic_no, entry, &wordrb) < 0) | 2473 if (js_word_info (env, dic_no, entry, &wordrb) < 0) |
2580 if_dead_disconnect (env, NULL); | 2474 if_dead_disconnect (env, NULL); |
2581 return ((struct wnn_jdata *) (wordrb.buf)); | 2475 return ((struct wnn_jdata *) (wordrb.buf)); |
2582 } | 2476 } |
2583 | 2477 |
2584 int | 2478 int |
2585 jl_dic_list_e (env, dicinfo) | 2479 jl_dic_list_e (struct wnn_env *env, WNN_DIC_INFO **dicinfo) |
2586 struct wnn_env *env; | |
2587 WNN_DIC_INFO **dicinfo; | |
2588 { | 2480 { |
2589 WNN_DIC_INFO *info; | 2481 WNN_DIC_INFO *info; |
2590 int cnt; | 2482 int cnt; |
2591 register int k; | 2483 register int k; |
2592 register char *c; | 2484 register char *c; |
2615 *dicinfo = info; | 2507 *dicinfo = info; |
2616 return (cnt); | 2508 return (cnt); |
2617 } | 2509 } |
2618 | 2510 |
2619 | 2511 |
2620 static int | 2512 static int |
2621 sort_func_ws (a, b) | 2513 sort_func_ws (register char *a, register char *b) |
2622 register char *a, *b; | |
2623 { | 2514 { |
2624 int ah, bh, ai, bi, iah, ibh, iai, ibi; | 2515 int ah, bh, ai, bi, iah, ibh, iai, ibi; |
2625 ah = ((struct wnn_jdata *) a)->hindo; | 2516 ah = ((struct wnn_jdata *) a)->hindo; |
2626 bh = ((struct wnn_jdata *) b)->hindo; | 2517 bh = ((struct wnn_jdata *) b)->hindo; |
2627 iah = ((struct wnn_jdata *) a)->int_hindo; | 2518 iah = ((struct wnn_jdata *) a)->int_hindo; |
2657 return (1); | 2548 return (1); |
2658 return (0); | 2549 return (0); |
2659 } | 2550 } |
2660 | 2551 |
2661 int | 2552 int |
2662 jl_word_search_e (env, dic_no, yomi, jdp) | 2553 jl_word_search_e (register struct wnn_env *env, int dic_no, w_char *yomi, struct wnn_jdata **jdp) |
2663 register struct wnn_env *env; | |
2664 int dic_no; | |
2665 w_char *yomi; | |
2666 struct wnn_jdata **jdp; | |
2667 { | 2554 { |
2668 register int cnt; | 2555 register int cnt; |
2669 struct wnn_jdata *jd; | 2556 struct wnn_jdata *jd; |
2670 | 2557 |
2671 wnn_errorno = 0; | 2558 wnn_errorno = 0; |
2677 *jdp = jd; | 2564 *jdp = jd; |
2678 return (cnt); | 2565 return (cnt); |
2679 } | 2566 } |
2680 | 2567 |
2681 int | 2568 int |
2682 jl_word_search_by_env_e (env, yomi, jdp) | 2569 jl_word_search_by_env_e (register struct wnn_env *env, w_char *yomi, struct wnn_jdata **jdp) |
2683 register struct wnn_env *env; | |
2684 struct wnn_jdata **jdp; | |
2685 w_char *yomi; | |
2686 { | 2570 { |
2687 register int cnt; | 2571 register int cnt; |
2688 struct wnn_jdata *jd; | 2572 struct wnn_jdata *jd; |
2689 | 2573 |
2690 wnn_errorno = 0; | 2574 wnn_errorno = 0; |
2730 buf->down_bnst[k] = b; | 2614 buf->down_bnst[k] = b; |
2731 b->ref_cnt++; | 2615 b->ref_cnt++; |
2732 } | 2616 } |
2733 | 2617 |
2734 #ifdef JL_DEBUG | 2618 #ifdef JL_DEBUG |
2735 static void | 2619 static void |
2736 print_jdata (jd) | 2620 print_jdata (struct wnn_jdata *jd) |
2737 struct wnn_jdata *jd; | |
2738 { | 2621 { |
2739 putws (jd->kanji); | 2622 putws (jd->kanji); |
2740 printf ("\tDict:%d Serial:%d Hinsi:%s Hindo:%c%d ExHindo:%c%d\n", | 2623 printf ("\tDict:%d Serial:%d Hinsi:%s Hindo:%c%d ExHindo:%c%d\n", |
2741 jd->dic_no, jd->serial, wnn_get_hinsi_name (jd->hinshi), (jd->ima) ? '*' : ' ', jd->hindo, (jd->int_ima) ? '*' : ' ', jd->int_hindo); | 2624 jd->dic_no, jd->serial, wnn_get_hinsi_name (jd->hinshi), (jd->ima) ? '*' : ' ', jd->hindo, (jd->int_ima) ? '*' : ' ', jd->int_hindo); |
2742 } | 2625 } |
2744 | 2627 |
2745 #define REAL_PARAM(x) (strcmp(x, "-")) | 2628 #define REAL_PARAM(x) (strcmp(x, "-")) |
2746 | 2629 |
2747 | 2630 |
2748 /** wnnrc を見てのパラメータの設定 */ | 2631 /** wnnrc を見てのパラメータの設定 */ |
2749 int | 2632 int |
2750 jl_set_env_wnnrc (env, wnnrc_n, error_handler, message_handler) | 2633 jl_set_env_wnnrc (register struct wnn_env *env, char *wnnrc_n, int (*error_handler)(void), int (*message_handler)(void)) |
2751 register struct wnn_env *env; | |
2752 char *wnnrc_n; | |
2753 int (*error_handler) (), (*message_handler) (); | |
2754 { | 2634 { |
2755 int level = 0; | 2635 int level = 0; |
2756 int x; | 2636 int x; |
2757 wnn_errorno = 0; | 2637 wnn_errorno = 0; |
2758 if (error_handler == (void *)WNN_CREATE) | 2638 if (error_handler == (void *)WNN_CREATE) |
2770 x = jl_set_env_wnnrc1 (env, wnnrc_n, error_handler, message_handler, level); | 2650 x = jl_set_env_wnnrc1 (env, wnnrc_n, error_handler, message_handler, level); |
2771 confirm_state = 0; | 2651 confirm_state = 0; |
2772 return (x); | 2652 return (x); |
2773 } | 2653 } |
2774 | 2654 |
2775 int | 2655 int |
2776 jl_set_env_wnnrc1 (env, wnnrc_n, error_handler, message_handler, level) | 2656 jl_set_env_wnnrc1 (register struct wnn_env *env, char *wnnrc_n, int (*error_handler)(void), int (*message_handler)(void), int level) |
2777 register struct wnn_env *env; | |
2778 char *wnnrc_n; | |
2779 int (*error_handler) (), (*message_handler) (); | |
2780 int level; | |
2781 { | 2657 { |
2782 register int num; | 2658 register int num; |
2783 char s[20][EXPAND_PATH_LENGTH]; | 2659 char s[20][EXPAND_PATH_LENGTH]; |
2784 char code[EXPAND_PATH_LENGTH]; | 2660 char code[EXPAND_PATH_LENGTH]; |
2785 char tmp[1024]; | 2661 char tmp[1024]; |
2944 */ | 2820 */ |
2945 fclose (fp); | 2821 fclose (fp); |
2946 return (-1); | 2822 return (-1); |
2947 } | 2823 } |
2948 | 2824 |
2949 static int | 2825 static int |
2950 expand_expr_all (s, env) | 2826 expand_expr_all (register char *s, struct wnn_env *env) |
2951 struct wnn_env *env; | |
2952 register char *s; | |
2953 { | 2827 { |
2954 register char *c; | 2828 register char *c; |
2955 | 2829 |
2956 for (c = s; *c; c++) | 2830 for (c = s; *c; c++) |
2957 { | 2831 { |
2964 return (0); | 2838 return (0); |
2965 } | 2839 } |
2966 | 2840 |
2967 /* copy of js.c */ | 2841 /* copy of js.c */ |
2968 static char * | 2842 static char * |
2969 getlogname () | 2843 getlogname (void) |
2970 { | 2844 { |
2971 struct passwd *getpwuid (); | 2845 struct passwd *getpwuid (); |
2972 return getpwuid (getuid ())->pw_name; | 2846 return getpwuid (getuid ())->pw_name; |
2973 } | 2847 } |
2974 | 2848 |
2975 | 2849 |
2976 static int | 2850 static int |
2977 expand_expr (s, env) | 2851 expand_expr (register char *s, struct wnn_env *env) |
2978 struct wnn_env *env; | |
2979 /** ~user、@HOME、@LIBDIR @ENV @USR の展開(但し、文字列の先頭のみ)。 | |
2980 できない時は-1が | |
2981 返り、その場合sの中身は着々とそのまんま。sの長さ<256と仮定してる。*/ | |
2982 register char *s; | |
2983 { | 2852 { |
2984 char *p, *s1; | 2853 char *p, *s1; |
2985 char tmp[EXPAND_PATH_LENGTH]; | 2854 char tmp[EXPAND_PATH_LENGTH]; |
2986 int noerr, expandsuc; | 2855 int noerr, expandsuc; |
2987 struct passwd *u; | 2856 struct passwd *u; |
3065 strcpy (s, p); | 2934 strcpy (s, p); |
3066 strcat (s, tmp); | 2935 strcat (s, tmp); |
3067 return (noerr ? 0 : -1); | 2936 return (noerr ? 0 : -1); |
3068 } | 2937 } |
3069 | 2938 |
3070 static int | 2939 static int |
3071 change_ascii_to_int (st, dp) | 2940 change_ascii_to_int (register char *st, int *dp) |
3072 register char *st; | |
3073 int *dp; | |
3074 { | 2941 { |
3075 register int total, flag; | 2942 register int total, flag; |
3076 | 2943 |
3077 total = 0; | 2944 total = 0; |
3078 flag = 0; | 2945 flag = 0; |
3110 } | 2977 } |
3111 *dp = total * flag; | 2978 *dp = total * flag; |
3112 return (1); | 2979 return (1); |
3113 } | 2980 } |
3114 | 2981 |
3115 static int | 2982 static int |
3116 file_exist (env, n) | 2983 file_exist (struct wnn_env *env, char *n) |
3117 struct wnn_env *env; | |
3118 char *n; | |
3119 { | 2984 { |
3120 if (n[0] == C_LOCAL) | 2985 if (n[0] == C_LOCAL) |
3121 { | 2986 { |
3122 wnn_errorno = 0; | 2987 wnn_errorno = 0; |
3123 return (access (n + 1, 4)); | 2988 return (access (n + 1, 4)); |
3126 { | 2991 { |
3127 return (js_access (env, n, 4)); | 2992 return (js_access (env, n, 4)); |
3128 } | 2993 } |
3129 } | 2994 } |
3130 | 2995 |
3131 static int | 2996 static int |
3132 create_file (env, n, d, fid, pwd_dic, pwd_hindo, error_handler, message_handler) | 2997 create_file (register struct wnn_env *env, char *n, int d, int fid, char *pwd_dic, char *pwd_hindo, int (*error_handler)(void), int (*message_handler)(void)) |
3133 register struct wnn_env *env; | |
3134 char *n; | |
3135 int d; | |
3136 int fid; | |
3137 char *pwd_dic, *pwd_hindo; | |
3138 int (*error_handler) (), (*message_handler) (); | |
3139 { | 2998 { |
3140 char pwd[WNN_PASSWD_LEN], hpwd[WNN_PASSWD_LEN]; | 2999 char pwd[WNN_PASSWD_LEN], hpwd[WNN_PASSWD_LEN]; |
3141 int rev_dict_type; | 3000 int rev_dict_type; |
3142 | 3001 |
3143 if (make_dir_rec1 (env, n, error_handler, message_handler) == -1) | 3002 if (make_dir_rec1 (env, n, error_handler, message_handler) == -1) |
3237 } | 3096 } |
3238 } | 3097 } |
3239 } | 3098 } |
3240 } | 3099 } |
3241 | 3100 |
3242 static int | 3101 static int |
3243 make_dir_rec1 (env, path, error_handler, message_handler) | 3102 make_dir_rec1 (struct wnn_env *env, register char *path, int (*error_handler)(void), int (*message_handler)(void)) |
3244 struct wnn_env *env; | |
3245 register char *path; | |
3246 int (*error_handler) (), (*message_handler) (); | |
3247 { | 3103 { |
3248 char gomi[128]; | 3104 char gomi[128]; |
3249 register char *c; | 3105 register char *c; |
3250 for (c = path; *c; c++) | 3106 for (c = path; *c; c++) |
3251 { | 3107 { |
3260 } | 3116 } |
3261 } | 3117 } |
3262 return (0); | 3118 return (0); |
3263 } | 3119 } |
3264 | 3120 |
3265 static int | 3121 static int |
3266 make_dir1 (env, dirname, error_handler, message_handler) | 3122 make_dir1 (register struct wnn_env *env, register char *dirname, int (*error_handler)(void), int (*message_handler)(void)) |
3267 register struct wnn_env *env; | |
3268 register char *dirname; | |
3269 int (*error_handler) (), (*message_handler) (); | |
3270 { | 3123 { |
3271 char gomi[128]; | 3124 char gomi[128]; |
3272 if (dirname[0] == C_LOCAL) | 3125 if (dirname[0] == C_LOCAL) |
3273 { | 3126 { |
3274 if (*(dirname + 1) == 0) | 3127 if (*(dirname + 1) == 0) |
3320 } | 3173 } |
3321 return (0); | 3174 return (0); |
3322 } | 3175 } |
3323 | 3176 |
3324 | 3177 |
3325 static int | 3178 static int |
3326 call_error_handler (error_handler, c) | 3179 call_error_handler (int (*error_handler)(void), char *c) |
3327 int (*error_handler) (); | |
3328 char *c; | |
3329 { | 3180 { |
3330 register int x; | 3181 register int x; |
3331 x = error_handler (c); | 3182 x = error_handler (c); |
3332 if (confirm_state == CONFIRM1) | 3183 if (confirm_state == CONFIRM1) |
3333 { | 3184 { |
3337 confirm_state = NO_CREATE; | 3188 confirm_state = NO_CREATE; |
3338 } | 3189 } |
3339 return (x); | 3190 return (x); |
3340 } | 3191 } |
3341 | 3192 |
3342 static void | 3193 static void |
3343 message_out (message_handler, format, s1, s2, s3, s4, s5, s6, s7, s8) | 3194 message_out (int (*message_handler)(void), char *format, int s1, int s2, int s3, int s4, int s5, int s6, int s7, int s8) |
3344 int (*message_handler) (); | |
3345 char *format; | |
3346 int s1, s2, s3, s4, s5, s6, s7, s8; | |
3347 { | 3195 { |
3348 char buf[256]; | 3196 char buf[256]; |
3349 | 3197 |
3350 if (message_handler) | 3198 if (message_handler) |
3351 { | 3199 { |
3353 (*message_handler) (buf); | 3201 (*message_handler) (buf); |
3354 } | 3202 } |
3355 } | 3203 } |
3356 | 3204 |
3357 | 3205 |
3358 int | 3206 int |
3359 jl_yomi_len (buf, bun_no, bun_no2) | 3207 jl_yomi_len (struct wnn_buf *buf, register int bun_no, register int bun_no2) |
3360 struct wnn_buf *buf; | |
3361 register int bun_no, bun_no2; | |
3362 { | 3208 { |
3363 register int len = 0; | 3209 register int len = 0; |
3364 | 3210 |
3365 wnn_errorno = 0; | 3211 wnn_errorno = 0; |
3366 if (bun_no2 >= buf->bun_suu || bun_no2 < 0) | 3212 if (bun_no2 >= buf->bun_suu || bun_no2 < 0) |
3371 } | 3217 } |
3372 return (len); | 3218 return (len); |
3373 } | 3219 } |
3374 | 3220 |
3375 | 3221 |
3376 int | 3222 int |
3377 jl_kanji_len (buf, bun_no, bun_no2) | 3223 jl_kanji_len (struct wnn_buf *buf, register int bun_no, register int bun_no2) |
3378 struct wnn_buf *buf; | |
3379 register int bun_no, bun_no2; | |
3380 { | 3224 { |
3381 register int len = 0; | 3225 register int len = 0; |
3382 | 3226 |
3383 wnn_errorno = 0; | 3227 wnn_errorno = 0; |
3384 if (bun_no < 0) | 3228 if (bun_no < 0) |
3392 return (len); | 3236 return (len); |
3393 } | 3237 } |
3394 | 3238 |
3395 int wnn_word_use_initial_hindo = 0; | 3239 int wnn_word_use_initial_hindo = 0; |
3396 | 3240 |
3397 int | 3241 int |
3398 jl_word_use_e (env, dic_no, entry) | 3242 jl_word_use_e (register struct wnn_env *env, int dic_no, int entry) |
3399 register struct wnn_env *env; | |
3400 int dic_no, entry; | |
3401 { | 3243 { |
3402 register struct wnn_jdata *jd; | 3244 register struct wnn_jdata *jd; |
3403 | 3245 |
3404 wnn_errorno = 0; | 3246 wnn_errorno = 0; |
3405 if (js_word_info (env, dic_no, entry, &rb) == -1) | 3247 if (js_word_info (env, dic_no, entry, &rb) == -1) |
3420 } | 3262 } |
3421 } | 3263 } |
3422 return (0); | 3264 return (0); |
3423 } | 3265 } |
3424 | 3266 |
3425 void | 3267 void |
3426 jl_env_set (buf, env) | 3268 jl_env_set (register struct wnn_buf *buf, register struct wnn_env *env) |
3427 register struct wnn_env *env; | |
3428 register struct wnn_buf *buf; | |
3429 { | 3269 { |
3430 wnn_errorno = 0; | 3270 wnn_errorno = 0; |
3431 buf->env = env; | 3271 buf->env = env; |
3432 } | 3272 } |
3433 | 3273 |
3434 | 3274 |
3435 struct wnn_env * | 3275 struct wnn_env * |
3436 jl_env_get (buf) | 3276 jl_env_get (register struct wnn_buf *buf) |
3437 register struct wnn_buf *buf; | |
3438 { | 3277 { |
3439 | 3278 |
3440 wnn_errorno = 0; | 3279 wnn_errorno = 0; |
3441 return (buf->env); | 3280 return (buf->env); |
3442 } | 3281 } |
3443 | 3282 |
3444 | 3283 |
3445 int | 3284 int |
3446 jl_param_set_e (env, para) | 3285 jl_param_set_e (register struct wnn_env *env, struct wnn_param *para) |
3447 register struct wnn_env *env; | |
3448 struct wnn_param *para; | |
3449 { | 3286 { |
3450 register int x; | 3287 register int x; |
3451 | 3288 |
3452 wnn_errorno = 0; | 3289 wnn_errorno = 0; |
3453 if ((x = js_param_set (env, para)) == -1) | 3290 if ((x = js_param_set (env, para)) == -1) |
3454 if_dead_disconnect (env, -1); | 3291 if_dead_disconnect (env, -1); |
3455 return (x); | 3292 return (x); |
3456 } | 3293 } |
3457 | 3294 |
3458 int | 3295 int |
3459 jl_param_get_e (env, para) | 3296 jl_param_get_e (struct wnn_env *env, struct wnn_param *para) |
3460 struct wnn_env *env; | |
3461 struct wnn_param *para; | |
3462 { | 3297 { |
3463 register int x; | 3298 register int x; |
3464 wnn_errorno = 0; | 3299 wnn_errorno = 0; |
3465 if ((x = js_param_get (env, para)) == -1) | 3300 if ((x = js_param_get (env, para)) == -1) |
3466 if_dead_disconnect (env, -1); | 3301 if_dead_disconnect (env, -1); |
3467 return (x); | 3302 return (x); |
3468 } | 3303 } |
3469 | 3304 |
3470 | 3305 |
3471 int | 3306 int |
3472 jl_dic_use_e (env, dic_no, flag) | 3307 jl_dic_use_e (struct wnn_env *env, int dic_no, int flag) |
3473 struct wnn_env *env; | |
3474 int dic_no, flag; | |
3475 { | 3308 { |
3476 register int x; | 3309 register int x; |
3477 wnn_errorno = 0; | 3310 wnn_errorno = 0; |
3478 if ((x = js_dic_use (env, dic_no, flag)) == -1) | 3311 if ((x = js_dic_use (env, dic_no, flag)) == -1) |
3479 if_dead_disconnect (env, -1); | 3312 if_dead_disconnect (env, -1); |
3480 return (x); | 3313 return (x); |
3481 } | 3314 } |
3482 | 3315 |
3483 int | 3316 int |
3484 jl_word_add_e (env, dic_no, yomi, kanji, comment, hinsi, init_hindo) | 3317 jl_word_add_e (struct wnn_env *env, int dic_no, w_char *yomi, w_char *kanji, w_char *comment, int hinsi, int init_hindo) |
3485 struct wnn_env *env; | |
3486 int dic_no; | |
3487 w_char *yomi, *kanji, *comment; | |
3488 int hinsi, init_hindo; | |
3489 | 3318 |
3490 { | 3319 { |
3491 register int x; | 3320 register int x; |
3492 wnn_errorno = 0; | 3321 wnn_errorno = 0; |
3493 if ((x = js_word_add (env, dic_no, yomi, kanji, comment, hinsi, init_hindo)) == -1) | 3322 if ((x = js_word_add (env, dic_no, yomi, kanji, comment, hinsi, init_hindo)) == -1) |
3494 if_dead_disconnect (env, -1); | 3323 if_dead_disconnect (env, -1); |
3495 return (x); | 3324 return (x); |
3496 } | 3325 } |
3497 | 3326 |
3498 int | 3327 int |
3499 jl_word_delete_e (env, dic_no, entry) | 3328 jl_word_delete_e (struct wnn_env *env, int dic_no, int entry) |
3500 struct wnn_env *env; | |
3501 int dic_no; | |
3502 int entry; | |
3503 { | 3329 { |
3504 register int x; | 3330 register int x; |
3505 wnn_errorno = 0; | 3331 wnn_errorno = 0; |
3506 if ((x = js_word_delete (env, dic_no, entry)) == -1) | 3332 if ((x = js_word_delete (env, dic_no, entry)) == -1) |
3507 if_dead_disconnect (env, -1); | 3333 if_dead_disconnect (env, -1); |
3508 return (x); | 3334 return (x); |
3509 } | 3335 } |
3510 | 3336 |
3511 static int | 3337 static int |
3512 file_read (env, fname) | 3338 file_read (struct wnn_env *env, char *fname) |
3513 struct wnn_env *env; | |
3514 char *fname; | |
3515 { | 3339 { |
3516 register int fid; | 3340 register int fid; |
3517 if (fname[0] == C_LOCAL) | 3341 if (fname[0] == C_LOCAL) |
3518 { | 3342 { |
3519 fid = js_file_send (env, fname + 1); | 3343 fid = js_file_send (env, fname + 1); |
3544 return (js_file_remove (server, fname, pwd)); | 3368 return (js_file_remove (server, fname, pwd)); |
3545 } | 3369 } |
3546 } | 3370 } |
3547 | 3371 |
3548 | 3372 |
3549 static int | 3373 static int |
3550 file_discard (env, fid) | 3374 file_discard (register struct wnn_env *env, register int fid) |
3551 register struct wnn_env *env; | |
3552 register int fid; | |
3553 { | 3375 { |
3554 delete_file_from_env (env, fid); | 3376 delete_file_from_env (env, fid); |
3555 return (js_file_discard (env, fid)); | 3377 return (js_file_discard (env, fid)); |
3556 } | 3378 } |
3557 | 3379 |
3558 int | 3380 int |
3559 jl_hinsi_number_e (env, name) | 3381 jl_hinsi_number_e (register struct wnn_env *env, w_char *name) |
3560 register struct wnn_env *env; | |
3561 w_char *name; | |
3562 { | 3382 { |
3563 register int x; | 3383 register int x; |
3564 wnn_errorno = 0; | 3384 wnn_errorno = 0; |
3565 if ((x = js_hinsi_number (env->js_id, name)) == -1) | 3385 if ((x = js_hinsi_number (env->js_id, name)) == -1) |
3566 if_dead_disconnect (env, -1); | 3386 if_dead_disconnect (env, -1); |
3567 return (x); | 3387 return (x); |
3568 } | 3388 } |
3569 | 3389 |
3570 w_char * | 3390 w_char * |
3571 jl_hinsi_name_e (env, no) | 3391 jl_hinsi_name_e (register struct wnn_env *env, register int no) |
3572 register struct wnn_env *env; | |
3573 register int no; | |
3574 { | 3392 { |
3575 wnn_errorno = 0; | 3393 wnn_errorno = 0; |
3576 if (js_hinsi_name (env->js_id, no, &rb) == -1) | 3394 if (js_hinsi_name (env->js_id, no, &rb) == -1) |
3577 if_dead_disconnect (env, NULL); | 3395 if_dead_disconnect (env, NULL); |
3578 return ((w_char *) (rb.buf)); | 3396 return ((w_char *) (rb.buf)); |
3579 } | 3397 } |
3580 | 3398 |
3581 int | 3399 int |
3582 jl_hinsi_list_e (env, dic_no, name, area) | 3400 jl_hinsi_list_e (register struct wnn_env *env, int dic_no, w_char *name, w_char ***area) |
3583 register struct wnn_env *env; | |
3584 int dic_no; | |
3585 w_char *name; | |
3586 w_char ***area; | |
3587 { | 3401 { |
3588 int x; | 3402 int x; |
3589 wnn_errorno = 0; | 3403 wnn_errorno = 0; |
3590 if ((x = js_hinsi_list (env, dic_no, name, &rb)) == -1) | 3404 if ((x = js_hinsi_list (env, dic_no, name, &rb)) == -1) |
3591 if_dead_disconnect (env, -1); | 3405 if_dead_disconnect (env, -1); |
3592 *area = (w_char **) (rb.buf); | 3406 *area = (w_char **) (rb.buf); |
3593 return (x); | 3407 return (x); |
3594 } | 3408 } |
3595 | 3409 |
3596 int | 3410 int |
3597 jl_hinsi_dicts_e (env, no, area) | 3411 jl_hinsi_dicts_e (register struct wnn_env *env, int no, int **area) |
3598 register struct wnn_env *env; | |
3599 int no; | |
3600 int **area; | |
3601 { | 3412 { |
3602 int x; | 3413 int x; |
3603 wnn_errorno = 0; | 3414 wnn_errorno = 0; |
3604 if ((x = js_hinsi_dicts (env, no, &rb)) == -1) | 3415 if ((x = js_hinsi_dicts (env, no, &rb)) == -1) |
3605 if_dead_disconnect (env, -1); | 3416 if_dead_disconnect (env, -1); |
3607 return (x); | 3418 return (x); |
3608 } | 3419 } |
3609 | 3420 |
3610 | 3421 |
3611 int | 3422 int |
3612 jl_word_comment_set_e (env, dic_no, entry, comment) | 3423 jl_word_comment_set_e (register struct wnn_env *env, int dic_no, int entry, wchar *comment) |
3613 register struct wnn_env *env; | |
3614 int dic_no, entry; | |
3615 w_char *comment; | |
3616 { | 3424 { |
3617 register int x; | 3425 register int x; |
3618 wnn_errorno = 0; | 3426 wnn_errorno = 0; |
3619 if ((x = js_word_comment_set (env, dic_no, entry, comment)) == -1) | 3427 if ((x = js_word_comment_set (env, dic_no, entry, comment)) == -1) |
3620 if_dead_disconnect (env, -1); | 3428 if_dead_disconnect (env, -1); |