Mercurial > freewnn
comparison Wnn/jserver/readfile.c @ 1:790205f476c0
applied wnn_dec12.diff
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 13 Dec 2007 04:47:24 +0900 |
parents | bbc77ca4def5 |
children | a7ccf412ba02 |
comparison
equal
deleted
inserted
replaced
0:bbc77ca4def5 | 1:790205f476c0 |
---|---|
99 { | 99 { |
100 FILE *fp; | 100 FILE *fp; |
101 struct wnn_file_head fh; | 101 struct wnn_file_head fh; |
102 if (wf->localf == REMOTE) | 102 if (wf->localf == REMOTE) |
103 { | 103 { |
104 if (fopen_read_cur (wf->name) == NULL) | 104 if (!fopen_read_cur (wf->name)) |
105 { | 105 { |
106 wnn_errorno = WNN_FILE_READ_ERROR; | 106 wnn_errorno = WNN_FILE_READ_ERROR; |
107 log_err ("read_file:could not open file %s.", wf->name); | 107 log_err ("read_file:could not open file %s.", wf->name); |
108 return (-1); | 108 return (-1); |
109 } | 109 } |
112 else | 112 else |
113 { | 113 { |
114 #ifdef WRITE_CHECK | 114 #ifdef WRITE_CHECK |
115 check_backup (wf->name); | 115 check_backup (wf->name); |
116 #endif | 116 #endif |
117 if ((fp = fopen (wf->name, "r")) == NULL) | 117 if (!(fp = fopen (wf->name, "r"))) |
118 { | 118 { |
119 wnn_errorno = WNN_FILE_READ_ERROR; | 119 wnn_errorno = WNN_FILE_READ_ERROR; |
120 log_err("read_file:could not open file %s.", wf->name); | 120 log_err("read_file:could not open file %s.", wf->name); |
121 return (-1); | 121 return (-1); |
122 } | 122 } |
339 new_bufsize = jt->maxhontai + MAXHONTAI; | 339 new_bufsize = jt->maxhontai + MAXHONTAI; |
340 if ((tp = (UCHAR *) realloc (jt->hontai, new_bufsize)) == NULL) | 340 if ((tp = (UCHAR *) realloc (jt->hontai, new_bufsize)) == NULL) |
341 { | 341 { |
342 wnn_errorno = WNN_MALLOC_ERR; | 342 wnn_errorno = WNN_MALLOC_ERR; |
343 log_err ("could not make the jisho area bigger."); | 343 log_err ("could not make the jisho area bigger."); |
344 return (NULL); | 344 return (FAILURE); |
345 } | 345 } |
346 jt->bufsize_hontai = new_bufsize; | 346 jt->bufsize_hontai = new_bufsize; |
347 jt->hontai = tp; | 347 jt->hontai = tp; |
348 return (SUCCESS); | 348 return (SUCCESS); |
349 } | 349 } |
358 new_bufsize = jt->maxkanji + MAXKANJI; | 358 new_bufsize = jt->maxkanji + MAXKANJI; |
359 if ((tp = (UCHAR *) realloc (jt->kanji, new_bufsize)) == NULL) | 359 if ((tp = (UCHAR *) realloc (jt->kanji, new_bufsize)) == NULL) |
360 { | 360 { |
361 wnn_errorno = WNN_MALLOC_ERR; | 361 wnn_errorno = WNN_MALLOC_ERR; |
362 log_err ("could not make the jisho area bigger."); | 362 log_err ("could not make the jisho area bigger."); |
363 return (NULL); | 363 return (FAILURE); |
364 } | 364 } |
365 jt->bufsize_kanji = new_bufsize; | 365 jt->bufsize_kanji = new_bufsize; |
366 jt->kanji = tp; | 366 jt->kanji = tp; |
367 return (SUCCESS); | 367 return (SUCCESS); |
368 } | 368 } |
401 free (tp_sisheng); | 401 free (tp_sisheng); |
402 #endif /* CONVERT_with_SiSheng */ | 402 #endif /* CONVERT_with_SiSheng */ |
403 | 403 |
404 wnn_errorno = WNN_MALLOC_ERR; | 404 wnn_errorno = WNN_MALLOC_ERR; |
405 log_err ("could notmake the jisho area bigger."); | 405 log_err ("could notmake the jisho area bigger."); |
406 return (NULL); | 406 return (FAILURE); |
407 } | 407 } |
408 jt->bufsize_serial = new_bufsize; | 408 jt->bufsize_serial = new_bufsize; |
409 jt->hindo = tp_hindo; | 409 jt->hindo = tp_hindo; |
410 jt->hinsi = tp_hinsi; | 410 jt->hinsi = tp_hinsi; |
411 #ifdef CONVERT_with_SiSheng | 411 #ifdef CONVERT_with_SiSheng |
423 new_bufsize * sizeof (struct rind2)); | 423 new_bufsize * sizeof (struct rind2)); |
424 if (tp_ri2 == NULL) | 424 if (tp_ri2 == NULL) |
425 { | 425 { |
426 wnn_errorno = WNN_MALLOC_ERR; | 426 wnn_errorno = WNN_MALLOC_ERR; |
427 log_err ("could not make the jisho area bigger."); | 427 log_err ("could not make the jisho area bigger."); |
428 return (NULL); | 428 return (FAILURE); |
429 } | 429 } |
430 jt->ri2 = tp_ri2; | 430 jt->ri2 = tp_ri2; |
431 } | 431 } |
432 | 432 |
433 return (SUCCESS); | 433 return (SUCCESS); |
444 tp = (struct uind1 *) realloc (jt->table, new_bufsize * sizeof (struct uind1)); | 444 tp = (struct uind1 *) realloc (jt->table, new_bufsize * sizeof (struct uind1)); |
445 if (tp == NULL) | 445 if (tp == NULL) |
446 { | 446 { |
447 wnn_errorno = WNN_MALLOC_ERR; | 447 wnn_errorno = WNN_MALLOC_ERR; |
448 log_err ("could not make the jisho area bigger."); | 448 log_err ("could not make the jisho area bigger."); |
449 return (NULL); | 449 return (FAILURE); |
450 } | 450 } |
451 jt->bufsize_table = new_bufsize; | 451 jt->bufsize_table = new_bufsize; |
452 jt->table = tp; | 452 jt->table = tp; |
453 return (SUCCESS); | 453 return (SUCCESS); |
454 } | 454 } |
465 new_bufsize * sizeof (struct rind1)); | 465 new_bufsize * sizeof (struct rind1)); |
466 if (tp == NULL) | 466 if (tp == NULL) |
467 { | 467 { |
468 wnn_errorno = WNN_MALLOC_ERR; | 468 wnn_errorno = WNN_MALLOC_ERR; |
469 log_err ("could not make the jisho area bigger."); | 469 log_err ("could not make the jisho area bigger."); |
470 return (NULL); | 470 return (FAILURE); |
471 } | 471 } |
472 jt->bufsize_ri1[which] = new_bufsize; | 472 jt->bufsize_ri1[which] = new_bufsize; |
473 jt->ri1[which] = tp; | 473 jt->ri1[which] = tp; |
474 return (SUCCESS); | 474 return (SUCCESS); |
475 } | 475 } |
486 tp = (UCHAR *) realloc (hjt->hindo, new_bufsize * sizeof (*hjt->hindo)); | 486 tp = (UCHAR *) realloc (hjt->hindo, new_bufsize * sizeof (*hjt->hindo)); |
487 if (tp == NULL) | 487 if (tp == NULL) |
488 { | 488 { |
489 wnn_errorno = WNN_MALLOC_ERR; | 489 wnn_errorno = WNN_MALLOC_ERR; |
490 log_err ("could not make the hindo file area bigger."); | 490 log_err ("could not make the hindo file area bigger."); |
491 return (NULL); | 491 return (FAILURE); |
492 } | 492 } |
493 hjt->bufsize_serial = new_bufsize; | 493 hjt->bufsize_serial = new_bufsize; |
494 hjt->hindo = tp; | 494 hjt->hindo = tp; |
495 return (SUCCESS); | 495 return (SUCCESS); |
496 } | 496 } |
507 tp = (struct b_node *) realloc (jt->bind, new_bufsize * sizeof (struct b_node)); | 507 tp = (struct b_node *) realloc (jt->bind, new_bufsize * sizeof (struct b_node)); |
508 if (tp == NULL) | 508 if (tp == NULL) |
509 { | 509 { |
510 wnn_errorno = WNN_MALLOC_ERR; | 510 wnn_errorno = WNN_MALLOC_ERR; |
511 log_err ("could not make the jisho area bigger."); | 511 log_err ("could not make the jisho area bigger."); |
512 return (NULL); | 512 return (FAILURE); |
513 } | 513 } |
514 jt->bufsize_bnode = new_bufsize; | 514 jt->bufsize_bnode = new_bufsize; |
515 jt->bind = tp; | 515 jt->bind = tp; |
516 return (SUCCESS); | 516 return (SUCCESS); |
517 } | 517 } |
611 int x; | 611 int x; |
612 | 612 |
613 /* if(wf->localf == REMOTE){ | 613 /* if(wf->localf == REMOTE){ |
614 } | 614 } |
615 */ | 615 */ |
616 if (fopen_write_cur (wf->name) == NULL) | 616 if (!fopen_write_cur (wf->name)) |
617 { | 617 { |
618 log_err ("receive_file:No file %s.", wf->name); | 618 log_err ("receive_file:No file %s.", wf->name); |
619 wnn_errorno = WNN_FILE_WRITE_ERROR; | 619 wnn_errorno = WNN_FILE_WRITE_ERROR; |
620 return (-1); | 620 return (-1); |
621 } | 621 } |
1049 case WNN_FT_DICT_FILE: | 1049 case WNN_FT_DICT_FILE: |
1050 jt = (struct JT *) wf->area; | 1050 jt = (struct JT *) wf->area; |
1051 new_size = Strlen (com) + 1; | 1051 new_size = Strlen (com) + 1; |
1052 if ((tp = (w_char *) realloc (jt->comment, jt->maxcomment * sizeof (w_char))) == NULL) | 1052 if ((tp = (w_char *) realloc (jt->comment, jt->maxcomment * sizeof (w_char))) == NULL) |
1053 { | 1053 { |
1054 return (NULL); | 1054 return (FAILURE); |
1055 } | 1055 } |
1056 jt->maxcomment = new_size; | 1056 jt->maxcomment = new_size; |
1057 jt->comment = tp; | 1057 jt->comment = tp; |
1058 Strcpy (jt->comment, com); | 1058 Strcpy (jt->comment, com); |
1059 jt->dirty = 1; | 1059 jt->dirty = 1; |
1061 case WNN_FT_HINDO_FILE: | 1061 case WNN_FT_HINDO_FILE: |
1062 hjt = (struct HJT *) wf->area; | 1062 hjt = (struct HJT *) wf->area; |
1063 new_size = Strlen (com) + 1; | 1063 new_size = Strlen (com) + 1; |
1064 if ((tp = (w_char *) realloc (hjt->comment, new_size * sizeof (w_char))) == NULL) | 1064 if ((tp = (w_char *) realloc (hjt->comment, new_size * sizeof (w_char))) == NULL) |
1065 { | 1065 { |
1066 return (NULL); | 1066 return (FAILURE); |
1067 } | 1067 } |
1068 hjt->maxcomment = new_size; | 1068 hjt->maxcomment = new_size; |
1069 hjt->comment = tp; | 1069 hjt->comment = tp; |
1070 Strcpy (hjt->comment, com); | 1070 Strcpy (hjt->comment, com); |
1071 hjt->hdirty = 1; | 1071 hjt->hdirty = 1; |
1072 break; | 1072 break; |
1073 case WNN_FT_FUZOKUGO_FILE: | 1073 case WNN_FT_FUZOKUGO_FILE: |
1074 wnn_errorno = NOT_SUPPORTED_OPERATION; | 1074 wnn_errorno = NOT_SUPPORTED_OPERATION; |
1075 return (NULL); | 1075 return (FAILURE); |
1076 } | 1076 } |
1077 return (SUCCESS); | 1077 return (SUCCESS); |
1078 } | 1078 } |
1079 | 1079 |
1080 int | 1080 int |