| 1 | /* |
| 2 | Copyright (C) 2000 Marco Ziech ([email protected]) |
| 3 | Copyright (C) 2000 Ross Combs ([email protected]) |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/ |
| 20 | #include <cstdlib> |
| 21 | #include <cstring> |
| 22 | #include <cerrno> |
| 23 | |
| 24 | #include "common/version.h"cxx . . $ `<file>/src/common/version.h`/ |
| 25 | #include "fileio.h"cxx . . $ `<file>/src/bniutils/fileio.h`/ |
| 26 | #include "bni.h"cxx . . $ `<file>/src/bniutils/bni.h`/ |
| 27 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 28 | |
| 29 | #define BUFSIZEcxx . . $ `src/bniutils/bni2tga.cpp:29:9`! 1024 |
| 30 | |
| 31 | using namespace pvpgncxx . . $ pvpgn/::bni; |
| 32 | |
| 33 | namespacecxx . . $ `$anonymous_namespace_src/bniutils/bni2tga.cpp`/ |
| 34 | { |
| 35 | |
| 36 | void usagecxx . . $ `$anonymous_namespace_src/bniutils/bni2tga.cpp`/usage(85c52e162fed56f9).(char const * progname) |
| 37 | { |
| 38 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, |
| 39 | "usage: %s [<options>] [--] [<BNI file> [<TGA file>]]\n" |
| 40 | " -h, --help, --usage show this information and exit\n" |
| 41 | " -v, --version print version number and exit\n", progname); |
| 42 | |
| 43 | stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | |
| 48 | extern int maincxx . . $ main(afcd3168fc1188a4).(int argc, char * argv[]) |
| 49 | { |
| 50 | char const * bnifile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 51 | char const * tgafile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 52 | stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fbni; |
| 53 | stdcxx . . $ std/::FILEcxx . . $ std/FILE# * ftga; |
| 54 | int a; |
| 55 | int forcefile = 0; |
| 56 | char dash[] = "-"; /* unique address used as flag */ |
| 57 | |
| 58 | if (argc < 1 || !argv || !argv[0]) |
| 59 | { |
| 60 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "bad arguments\n"); |
| 61 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 62 | } |
| 63 | |
| 64 | for (a = 1; a < argc; a++) |
| 65 | if (forcefile && !bnifile) |
| 66 | bnifile = argv[a]; |
| 67 | else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !bnifile) |
| 68 | bnifile = dash; |
| 69 | else if (argv[a][0] != '-' && !bnifile) |
| 70 | bnifile = argv[a]; |
| 71 | else if (forcefile && !tgafile) |
| 72 | tgafile = argv[a]; |
| 73 | else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !tgafile) |
| 74 | tgafile = dash; |
| 75 | else if (argv[a][0] != '-' && !tgafile) |
| 76 | tgafile = argv[a]; |
| 77 | else if (forcefile || argv[a][0] != '-' || stdcxx . . $ std/::strcmp(argv[a], "-") == 0) |
| 78 | { |
| 79 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: extra file argument \"%s\"\n", argv[0], argv[a]); |
| 80 | usagecxx . . $ `$anonymous_namespace_src/bniutils/bni2tga.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 81 | } |
| 82 | else if (stdcxx . . $ std/::strcmp(argv[a], "--") == 0) |
| 83 | forcefile = 1; |
| 84 | else if (stdcxx . . $ std/::strcmp(argv[a], "-v") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--version") == 0) |
| 85 | { |
| 86 | stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("version " PVPGN_VERSIONcxx . . $ `src/common/version.h:23:9`! "\n"); |
| 87 | return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!; |
| 88 | } |
| 89 | else if (stdcxx . . $ std/::strcmp(argv[a], "-h") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--help") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--usage") |
| 90 | == 0) |
| 91 | usagecxx . . $ `$anonymous_namespace_src/bniutils/bni2tga.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 92 | else |
| 93 | { |
| 94 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unknown option \"%s\"\n", argv[0], argv[a]); |
| 95 | usagecxx . . $ `$anonymous_namespace_src/bniutils/bni2tga.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 96 | } |
| 97 | |
| 98 | if (!bnifile) |
| 99 | bnifile = dash; |
| 100 | if (!tgafile) |
| 101 | tgafile = dash; |
| 102 | |
| 103 | if (bnifile == dash) |
| 104 | fbni = stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!; |
| 105 | else |
| 106 | if (!(fbni = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(bnifile, "r"))) |
| 107 | { |
| 108 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not open BNI file \"%s\" for reading (std::fopen: %s)\n", argv[0], bnifile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 109 | stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 110 | } |
| 111 | if (tgafile == dash) |
| 112 | ftga = stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!; |
| 113 | else |
| 114 | if (!(ftga = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(tgafile, "w"))) |
| 115 | { |
| 116 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not open TGA file \"%s\" for reading (std::fopen: %s)\n", argv[0], tgafile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 117 | stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 118 | } |
| 119 | |
| 120 | { |
| 121 | unsigned char buf[BUFSIZEcxx . . $ `src/bniutils/bni2tga.cpp:29:9`!]; |
| 122 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# rc; |
| 123 | t_bnifilecxx . . $ pvpgn/bni/t_bnifile# bnih; |
| 124 | |
| 125 | file_rpushcxx . . $ pvpgn/bni/file_rpush(8d4262d45fc644ab).(fbni); |
| 126 | bnih.unknown1cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown1. = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 127 | bnih.unknown2cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown2. = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 128 | bnih.numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons. = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 129 | bnih.dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset. = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 130 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Info: numicons=%d dataoffset=0x%08x(%d)\n", bnih.numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons., bnih.dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset., bnih.dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset.); |
| 131 | if (stdcxx . . $ std/::fseekcxx . . $ std/fseek(543fae30d249f6b1).(fbni, bnih.dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset., SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!)<0) |
| 132 | { |
| 133 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not seek to offset %u in BNI file \"%s\" (std::fseek: %s)\n", argv[0], bnih.dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset., bnifile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 134 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 135 | } |
| 136 | while ((rc = stdcxx . . $ std/::freadcxx . . $ std/fread(738fc8ac1d711e58).(buf, 1, sizeof(buf), fbni))>0) { |
| 137 | if (stdcxx . . $ std/::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(buf, rc, 1, ftga) < 1) { |
| 138 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not write data to TGA file \"%s\" (std::fwrite: %s)\n", argv[0], tgafile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 139 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 140 | } |
| 141 | } |
| 142 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 143 | } |
| 144 | |
| 145 | if (tgafile != dash && stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(ftga) < 0) |
| 146 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not close TGA file \"%s\" after writing (std::fclose: %s)\n", argv[0], tgafile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 147 | if (bnifile != dash && stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fbni) < 0) |
| 148 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not close BNI file \"%s\" after reading (std::fclose: %s)\n", argv[0], bnifile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 149 | |
| 150 | return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!; |
| 151 | } |