| 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 "tga.h"cxx . . $ `<file>/src/bniutils/tga.h`/ |
| 26 | #include "fileio.h"cxx . . $ `<file>/src/bniutils/fileio.h`/ |
| 27 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 28 | |
| 29 | using namespace pvpgncxx . . $ pvpgn/::bni; |
| 30 | |
| 31 | namespacecxx . . $ `$anonymous_namespace_src/bniutils/bnilist.cpp`/ |
| 32 | { |
| 33 | |
| 34 | void usagecxx . . $ `$anonymous_namespace_src/bniutils/bnilist.cpp`/usage(85c52e162fed56f9).(char const * progname) |
| 35 | { |
| 36 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, |
| 37 | "usage: %s [<options>] [--] [<BNI file>]\n" |
| 38 | " -h, --help, --usage show this information and exit\n" |
| 39 | " -v, --version print version number and exit\n", progname); |
| 40 | |
| 41 | stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 42 | } |
| 43 | |
| 44 | } |
| 45 | |
| 46 | extern int maincxx . . $ main(afcd3168fc1188a4).(int argc, char * argv[]) |
| 47 | { |
| 48 | char const * bnifile = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 49 | stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fp; |
| 50 | int a; |
| 51 | int forcefile = 0; |
| 52 | char dash[] = "-"; /* unique address used as flag */ |
| 53 | |
| 54 | if (argc < 1 || !argv || !argv[0]) |
| 55 | { |
| 56 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "bad arguments\n"); |
| 57 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 58 | } |
| 59 | |
| 60 | for (a = 1; a < argc; a++) |
| 61 | if (forcefile && !bnifile) |
| 62 | bnifile = argv[a]; |
| 63 | else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !bnifile) |
| 64 | bnifile = dash; |
| 65 | else if (argv[a][0] != '-' && !bnifile) |
| 66 | bnifile = argv[a]; |
| 67 | else if (forcefile || argv[a][0] != '-' || stdcxx . . $ std/::strcmp(argv[a], "-") == 0) |
| 68 | { |
| 69 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: extra file argument \"%s\"\n", argv[0], argv[a]); |
| 70 | usagecxx . . $ `$anonymous_namespace_src/bniutils/bnilist.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 71 | } |
| 72 | else if (stdcxx . . $ std/::strcmp(argv[a], "--") == 0) |
| 73 | forcefile = 1; |
| 74 | else if (stdcxx . . $ std/::strcmp(argv[a], "-v") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--version") == 0) |
| 75 | { |
| 76 | stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("version " PVPGN_VERSIONcxx . . $ `src/common/version.h:23:9`! "\n"); |
| 77 | return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!; |
| 78 | } |
| 79 | else if (stdcxx . . $ std/::strcmp(argv[a], "-h") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--help") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--usage") |
| 80 | == 0) |
| 81 | usagecxx . . $ `$anonymous_namespace_src/bniutils/bnilist.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 82 | else |
| 83 | { |
| 84 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unknown option \"%s\"\n", argv[0], argv[a]); |
| 85 | usagecxx . . $ `$anonymous_namespace_src/bniutils/bnilist.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 86 | } |
| 87 | |
| 88 | if (!bnifile) |
| 89 | bnifile = dash; |
| 90 | |
| 91 | if (bnifile == dash) |
| 92 | fp = stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!; |
| 93 | else |
| 94 | if (!(fp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(bnifile, "r"))) |
| 95 | { |
| 96 | 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`!)); |
| 97 | stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 98 | } |
| 99 | |
| 100 | { |
| 101 | t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * tgaimg; |
| 102 | int i; |
| 103 | int bniid, unknown, icons, datastart; |
| 104 | int expected_width, expected_height; |
| 105 | |
| 106 | file_rpushcxx . . $ pvpgn/bni/file_rpush(8d4262d45fc644ab).(fp); |
| 107 | bniid = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 108 | unknown = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 109 | icons = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 110 | datastart = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 111 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "BNIHeader: id=0x%08x unknown=0x%08x icons=0x%08x datastart=0x%08x\n", bniid, unknown, icons, datastart); |
| 112 | expected_width = 0; |
| 113 | expected_height = 0; |
| 114 | for (i = 0; i < icons; i++) { |
| 115 | int id, x, y, flags, tag; |
| 116 | id = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 117 | x = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 118 | y = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 119 | if (id == 0) { |
| 120 | tag = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 121 | } |
| 122 | else { |
| 123 | tag = 0; |
| 124 | } |
| 125 | flags = file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(); |
| 126 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Icon[%d]: id=0x%08x x=%d y=%d tag=0x%08x(\"%c%c%c%c\") flags=0x%08x\n", i, id, x, y, tag, |
| 127 | ((unsigned char)((tag >> 24) & 0xff)), |
| 128 | ((unsigned char)((tag >> 16) & 0xff)), |
| 129 | ((unsigned char)((tag >> 8) & 0xff)), |
| 130 | ((unsigned char)((tag)& 0xff)), flags); |
| 131 | if (x > expected_width) expected_width = x; |
| 132 | expected_height += y; |
| 133 | } |
| 134 | if (stdcxx . . $ std/::ftellcxx . . $ std/ftell(1dcafcd8ef4c6e6c).(fp) != datastart) { |
| 135 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Warning: garbage after header (pos=0x%lx-datastart=0x%lx) = %ld bytes of garbage! \n", (unsigned long)stdcxx . . $ std/::ftellcxx . . $ std/ftell(1dcafcd8ef4c6e6c).(fp), (unsigned long)datastart, (long)(stdcxx . . $ std/::ftellcxx . . $ std/ftell(1dcafcd8ef4c6e6c).(fp) - datastart)); |
| 136 | } |
| 137 | tgaimg = load_tgaheadercxx . . $ pvpgn/bni/load_tgaheader(bf631a1f9eee4486).(); |
| 138 | print_tga_infocxx . . $ pvpgn/bni/print_tga_info(bced1c5b17084774).(tgaimg, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 139 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"); |
| 140 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Check: Expected %dx%d TGA, got %ux%u. %s\n", expected_width, expected_height, tgaimg->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width., tgaimg->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height., ((tgaimg->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. == expected_width) && (tgaimg->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height. == expected_height)) ? "OK." : "FAIL."); |
| 141 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Check: Expected 24bit color depth TGA, got %dbit. %s\n", tgaimg->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp., (tgaimg->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp. == 24) ? "OK." : "FAIL."); |
| 142 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Check: Expected ImageType 10, got %d. %s\n", tgaimg->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype., (tgaimg->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. == 10) ? "OK." : "FAIL."); |
| 143 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 144 | } |
| 145 | |
| 146 | if (bnifile != dash && stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp) < 0) |
| 147 | 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`!)); |
| 148 | return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!; |
| 149 | } |