Mercurial > hg > dmlib
comparison tools/dumpmod.c @ 2565:d56a0e86067a
Improve error handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 28 Feb 2022 11:49:58 +0200 |
parents | aacf3bd1cceb |
children | 9807ae37ad69 |
comparison
equal
deleted
inserted
replaced
2564:2cf4e995b50c | 2565:d56a0e86067a |
---|---|
432 dmVerbosity = 0; | 432 dmVerbosity = 0; |
433 | 433 |
434 // Parse arguments | 434 // Parse arguments |
435 if (!dmArgsProcess(argc, argv, optList, optListN, | 435 if (!dmArgsProcess(argc, argv, optList, optListN, |
436 argHandleOpt, argHandleFile, OPTH_BAILOUT)) | 436 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
437 { | 437 goto out; |
438 res = 1; | |
439 goto exit; | |
440 } | |
441 | 438 |
442 // Initialize miniJSS | 439 // Initialize miniJSS |
443 jssInit(); | 440 jssInit(); |
444 | 441 |
445 // Open the file | 442 // Open the file |
452 if (res != DMERR_OK) | 449 if (res != DMERR_OK) |
453 { | 450 { |
454 res = dmError(DMERR_FOPEN, | 451 res = dmError(DMERR_FOPEN, |
455 "Error opening input file '%s': %s\n", | 452 "Error opening input file '%s': %s\n", |
456 optFilename, dmErrorStr(res)); | 453 optFilename, dmErrorStr(res)); |
457 goto exit; | 454 goto out; |
458 } | 455 } |
459 | 456 |
460 // Read module file | 457 // Read module file |
461 dmMsg(1, "Reading file: %s\n", optFilename); | 458 dmMsg(1, "Reading file: %s\n", optFilename); |
462 #ifdef JSS_SUP_XM | 459 #ifdef JSS_SUP_XM |
495 // Check if we have anything | 492 // Check if we have anything |
496 if (mod == NULL) | 493 if (mod == NULL) |
497 { | 494 { |
498 res = dmError(DMERR_INIT_FAIL, | 495 res = dmError(DMERR_INIT_FAIL, |
499 "Could not load module file.\n"); | 496 "Could not load module file.\n"); |
500 goto exit; | 497 goto out; |
501 } | 498 } |
502 | 499 |
503 // Print out information | 500 // Print out information |
504 if (optViewGeneralInfo) | 501 if (optViewGeneralInfo) |
505 printGeneralInfo(stdout, mod); | 502 printGeneralInfo(stdout, mod); |
540 printf("#%02x: ", i + 1); | 537 printf("#%02x: ", i + 1); |
541 printInstrument(stdout, mod->instruments[i]); | 538 printInstrument(stdout, mod->instruments[i]); |
542 } | 539 } |
543 } | 540 } |
544 | 541 |
545 exit: | 542 out: |
546 // Free module data | 543 // Free module data |
547 jssFreeModule(mod); | 544 jssFreeModule(mod); |
548 jssClose(); | 545 jssClose(); |
549 | 546 |
550 return res; | 547 return res; |