| 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/tgainfo.cpp`/ |
| 32 | { |
| 33 | |
| 34 | void usagecxx . . $ `$anonymous_namespace_src/bniutils/tgainfo.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>] [--] [<TGA 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 * tgafile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/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 && !tgafile) |
| 62 | tgafile = argv[a]; |
| 63 | else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !tgafile) |
| 64 | tgafile = dash; |
| 65 | else if (argv[a][0] != '-' && !tgafile) |
| 66 | tgafile = 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/tgainfo.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/tgainfo.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/tgainfo.cpp`/usage(85c52e162fed56f9).(argv[0]); |
| 86 | } |
| 87 | |
| 88 | if (!tgafile) |
| 89 | tgafile = dash; |
| 90 | |
| 91 | if (tgafile == dash) |
| 92 | fp = stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!; |
| 93 | else |
| 94 | if (!(fp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(tgafile, "r"))) |
| 95 | { |
| 96 | 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`!)); |
| 97 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 98 | } |
| 99 | |
| 100 | { |
| 101 | t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * tgaimg; |
| 102 | |
| 103 | file_rpushcxx . . $ pvpgn/bni/file_rpush(8d4262d45fc644ab).(fp); |
| 104 | if (!(tgaimg = load_tgaheadercxx . . $ pvpgn/bni/load_tgaheader(bf631a1f9eee4486).())) |
| 105 | { |
| 106 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not load TGA header\n", argv[0]); |
| 107 | if (tgafile != dash && stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp) < 0) |
| 108 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not close file \"%s\" after reading (std::fclose: %s)\n", argv[0], tgafile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 109 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 110 | } |
| 111 | print_tga_infocxx . . $ pvpgn/bni/print_tga_info(bced1c5b17084774).(tgaimg, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 112 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 113 | } |
| 114 | |
| 115 | if (tgafile != dash && stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp) < 0) |
| 116 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not close file \"%s\" after reading (std::fclose: %s)\n", argv[0], tgafile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 117 | return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!; |
| 118 | } |