trunk/src/tools/jedutil.c
| r20407 | r20408 | |
| 3338 | 3338 | /* read the source file */ |
| 3339 | 3339 | err = read_source_file(srcfile); |
| 3340 | 3340 | if (err != 0) |
| 3341 | { |
| 3342 | free(srcbuf); |
| 3341 | 3343 | return 1; |
| 3344 | } |
| 3342 | 3345 | |
| 3343 | 3346 | memset(&jed, 0, sizeof(jed)); |
| 3344 | 3347 | |
| r20407 | r20408 | |
| 3374 | 3377 | if (!dstbuf) |
| 3375 | 3378 | { |
| 3376 | 3379 | fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen); |
| 3380 | free(srcbuf); |
| 3377 | 3381 | return 1; |
| 3378 | 3382 | } |
| 3379 | 3383 | dstbuflen = jedbin_output(&jed, dstbuf, dstbuflen); |
| r20407 | r20408 | |
| 3401 | 3405 | if (!dstbuf) |
| 3402 | 3406 | { |
| 3403 | 3407 | fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen); |
| 3408 | free(srcbuf); |
| 3404 | 3409 | return 1; |
| 3405 | 3410 | } |
| 3406 | 3411 | dstbuflen = jed_output(&jed, dstbuf, dstbuflen); |
| r20407 | r20408 | |
| 3408 | 3413 | |
| 3409 | 3414 | /* write the destination file */ |
| 3410 | 3415 | err = write_dest_file(dstfile); |
| 3416 | free(srcbuf); |
| 3411 | 3417 | if (err != 0) |
| 3412 | 3418 | return 1; |
| 3413 | 3419 | |
| r20407 | r20408 | |
| 3453 | 3459 | /* read the source file */ |
| 3454 | 3460 | err = read_source_file(srcfile); |
| 3455 | 3461 | if (err != 0) |
| 3462 | { |
| 3463 | free(srcbuf); |
| 3456 | 3464 | return 1; |
| 3465 | } |
| 3457 | 3466 | |
| 3458 | 3467 | /* if the source is JED, convert to binary */ |
| 3459 | 3468 | if (is_jed) |
| r20407 | r20408 | |
| 3488 | 3497 | else |
| 3489 | 3498 | { |
| 3490 | 3499 | fprintf(stderr, "Viewing product terms not supported for this pal type."); |
| 3491 | | |
| 3500 | free(srcbuf); |
| 3492 | 3501 | return 1; |
| 3493 | 3502 | } |
| 3494 | 3503 | |
| 3504 | free(srcbuf); |
| 3495 | 3505 | return 0; |
| 3496 | 3506 | } |
| 3497 | 3507 | |