Debian Codegraph @

src/bniutils/bnibuild.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2000 Marco Ziech
3 Copyright (C) 2000 Ross Combs ([email protected])
4
5 This program is xfree 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
21 #include <cerrno>
22 #include <cstdint>
23 #include <cstdlib>
24 #include <cstring>
25
26 #ifdef HAVE_SYS_STAT_Hcxx . . $ `build/config.h:21:9`!
27 # include <sys/stat.h>
28 #endif
29
30 #include "compat/statmacros.h"cxx . . $ `<file>/src/compat/statmacros.h`/
31 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
32 #include "common/version.h"cxx . . $ `<file>/src/common/version.h`/
33 #include "fileio.h"cxx . . $ `<file>/src/bniutils/fileio.h`/
34 #include "tga.h"cxx . . $ `<file>/src/bniutils/tga.h`/
35 #include "bni.h"cxx . . $ `<file>/src/bniutils/bni.h`/
36 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
37
38 #define BUFSIZEcxx . . $ `src/bniutils/bnibuild.cpp:38:9`! 1024
39
40 using namespace pvpgn;
41 using namespace pvpgncxx . . $ pvpgn/::bni;
42
43 namespacecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/
44 {
45
46 int read_listcxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/read_list(80d5cd1ef6c09de4).(char const * progname, t_bnifilecxx . . $ pvpgn/bni/t_bnifile# * bnifile, char const * name) {
47 stdcxx . . $ std/::FILEcxx . . $ std/FILE# * f;
48 char line[BUFSIZEcxx . . $ `src/bniutils/bnibuild.cpp:38:9`!];
49
50 f = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(name, "r");
51 if (f == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
52 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not open index file \"%s\" for reading (std::fopen: %s)\n", progname, name, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
53 return -1;
54 }
55 bnifile->unknown1cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown1. = 0x00000010; /* in case they are not set */
56 bnifile->unknown2cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown2. = 0x00000001;
57 bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons. = 0;
58 bnifile->dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset. = 16; /* size of header */
59 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons. = (struct bni_iconlist_structcxx . . $ pvpgn/bni/bni_iconlist_struct#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(1); /* some xrealloc()s are broken */
60 while (stdcxx . . $ std/::fgetscxx . . $ std/fgets(efb0aaba7ac866ae).(line, sizeof(line), f)) {
61 char cmd[BUFSIZEcxx . . $ `src/bniutils/bnibuild.cpp:38:9`!];
62 stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(line, "%s", cmd);
63 if (stdcxx . . $ std/::strcmp(cmd, "unknown1") == 0) {
64 stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(line, "unknown1 %08x", &bnifile->unknown1cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown1.);
65 }
66 else if (stdcxx . . $ std/::strcmp(cmd, "unknown2") == 0) {
67 stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(line, "unknown2 %08x", &bnifile->unknown2cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown2.);
68 }
69 else if (stdcxx . . $ std/::strcmp(cmd, "icon") == 0) {
70 char c;
71 stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(line, "icon %c", &c);
72 if (c == '!') {
73 unsigned char tg[4];
74 int tag;
75 unsigned int x, y, unknown;
76 stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(line, "icon !%c%c%c%c %u %u %08x", &tg[0], &tg[1], &tg[2], &tg[3], &x, &y, &unknown);
77 tag = tg[3] + (tg[2] << 8) + (tg[1] << 16) + (tg[0] << 24);
78 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Icon[%d]: id=0x%x x=%u y=%u unknown=0x%x tag=\"%c%c%c%c\"\n", bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons., 0, x, y, unknown, ((tag >> 24) & 0xff), ((tag >> 16) & 0xff), ((tag >> 8) & 0xff), ((tag >> 0) & 0xff));
79 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons. = (struct bni_iconlist_structcxx . . $ pvpgn/bni/bni_iconlist_struct#*)xrealloccxx . . $ `src/common/xalloc.h:47:9`!(bnifile->icons, ((bnifile->numicons + 1)*sizeof(t_bniicon)));
80 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].idcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#id. = 0;
81 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].xcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#x. = x;
82 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].ycxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#y. = y;
83 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].tagcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#tag. = tag;
84 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].unknowncxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#unknown. = unknown;
85 bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.++;
86 bnifile->dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset. += 20;
87 }
88 else if (c == '#') {
89 unsigned int id, x, y, unknown;
90 stdcxx . . $ std/::sscanfcxx . . $ std/sscanf(6246fabbf6b5312d).(line, "icon #%08x %u %u %08x", &id, &x, &y, &unknown);
91 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Icon[%d]: id=0x%x x=%u y=%u unknown=0x%x tag=0x00000000\n", bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons., id, x, y, unknown);
92 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons. = (struct bni_iconlist_structcxx . . $ pvpgn/bni/bni_iconlist_struct#*)xrealloccxx . . $ `src/common/xalloc.h:47:9`!(bnifile->icons, ((bnifile->numicons + 1)*sizeof(t_bniicon)));
93 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].idcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#id. = id;
94 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].xcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#x. = x;
95 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].ycxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#y. = y;
96 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].tagcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#tag. = 0;
97 bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.].unknowncxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#unknown. = unknown;
98 bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.++;
99 bnifile->dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset. += 16;
100 }
101 else
102 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Bad character '%c' in icon specifier for icon %u in index file \"%s\"\n", c, bnifile->numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons. + 1, name);
103 }
104 else
105 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown command \"%s\" in index file \"%s\"\n", cmd, name);
106 }
107 if (stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(f) < 0)
108 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not close index file \"%s\" after reading (std::fclose: %s)\n", progname, name, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
109 return 0;
110 }
111
112
113 char * geticonfilenamecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/geticonfilename(ddfaa0a9ae34a2e6).(t_bnifilecxx . . $ pvpgn/bni/t_bnifile# *bnifile, char const * indir, int i) {
114 char * name;
115
116 if (bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[i].idcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#id. == 0) {
117 unsigned int tag = bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[i].tagcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#tag.;
118 name = (char*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(std::strlen(indir) + 10);
119 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(name, "%s/%c%c%c%c.tga", indir, ((tag >> 24) & 0xff), ((tag >> 16) & 0xff), ((tag >> 8) & 0xff), ((tag >> 0) & 0xff));
120 }
121 else {
122 name = (char*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(std::strlen(indir) + 16);
123 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(name, "%s/%08x.tga", indir, bnifile->iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[i].idcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#id.);
124 }
125 return name;
126 }
127
128
129 int img2areacxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/img2area(56292d6966f91a89).(t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *dst, t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *src, int x, int y) {
130 unsigned char *sdp;
131 unsigned char *ddp;
132 int pixelsize;
133 int i;
134
135 pixelsize = getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(dst);
136 if (getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(src) != pixelsize) {
137 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: source pixelsize is %d should be %d!\n", getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(src), pixelsize);
138 return -1;
139 }
140 if (src->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. + x > dst->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.) return -1;
141 if (src->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height. + y > dst->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.) return -1;
142 sdp = src->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data.;
143 ddp = dst->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. + (y * dst->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. * pixelsize);
144 for (i = 0; i < src->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.; i++) {
145 ddp += x*pixelsize;
146 stdcxx . . $ std/::memcpy(ddp, sdp, src->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*pixelsize);
147 sdp += src->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*pixelsize;
148 ddp += (dst->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. - x)*pixelsize;
149 }
150 return 0;
151 }
152
153
154 void usagecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/usage(85c52e162fed56f9).(char const * progname)
155 {
156 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
157 "usage: %s [<options>] [--] <input directory> [<BNI file>]\n"
158 " -h, --help, --usage show this information and exit\n"
159 " -v, --version print version number and exit\n", progname);
160
161 stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!);
162 }
163
164 }
165
166 extern int maincxx . . $ main(afcd3168fc1188a4).(int argc, char * argv[])
167 {
168 char const * indir = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
169 char const * bnifile = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
170 stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fbni;
171 struct stat s;
172 int a;
173 int forcefile = 0;
174 char dash[] = "-"; /* unique address used as flag */
175
176 if (argc < 1 || !argv || !argv[0])
177 {
178 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "bad arguments\n");
179 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
180 }
181
182 for (a = 1; a < argc; a++)
183 if (forcefile && !indir)
184 indir = argv[a];
185 else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !indir)
186 indir = dash;
187 else if (argv[a][0] != '-' && !indir)
188 indir = argv[a];
189 else if (forcefile && !bnifile)
190 bnifile = argv[a];
191 else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !bnifile)
192 bnifile = dash;
193 else if (argv[a][0] != '-' && !bnifile)
194 bnifile = argv[a];
195 else if (forcefile || argv[a][0] != '-' || stdcxx . . $ std/::strcmp(argv[a], "-") == 0)
196 {
197 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: extra file argument \"%s\"\n", argv[0], argv[a]);
198 usagecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/usage(85c52e162fed56f9).(argv[0]);
199 }
200 else if (stdcxx . . $ std/::strcmp(argv[a], "--") == 0)
201 forcefile = 1;
202 else if (stdcxx . . $ std/::strcmp(argv[a], "-v") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--version") == 0)
203 {
204 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("version " PVPGN_VERSIONcxx . . $ `src/common/version.h:23:9`! "\n");
205 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
206 }
207 else if (stdcxx . . $ std/::strcmp(argv[a], "-h") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--help") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--usage")
208 == 0)
209 usagecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/usage(85c52e162fed56f9).(argv[0]);
210 else
211 {
212 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unknown option \"%s\"\n", argv[0], argv[a]);
213 usagecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/usage(85c52e162fed56f9).(argv[0]);
214 }
215
216 if (!indir)
217 {
218 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: input directory not specified\n", argv[0]);
219 usagecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/usage(85c52e162fed56f9).(argv[0]);
220 }
221 if (!bnifile)
222 bnifile = dash;
223
224 if (indir == dash)
225 {
226 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: can not read directory from <stdin>\n", argv[0]);
227 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
228 }
229 if (stat(indir, &s) < 0) {
230 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not stat input directory \"%s\" (stat: %s)\n", argv[0], indir, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
231 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
232 }
233 if (!S_ISDIRcxx . . $ `<external>/531885356569766532/stat.h:125:9`!(s.st_mode)) {
234 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: \"%s\" is not a directory\n", argv[0], indir);
235 return -1;
236 }
237
238 if (bnifile == dash)
239 fbni = stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!;
240 else
241 if (!(fbni = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(bnifile, "w")))
242 {
243 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not open BNI file \"%s\" for writing (std::fopen: %s)\n", argv[0], bnifile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
244 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
245 }
246
247 {
248 unsigned int i;
249 unsigned int yline;
250 t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * img;
251 t_bnifilecxx . . $ pvpgn/bni/t_bnifile# bni;
252 char * listfilename;
253
254 listfilename = (char*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(std::strlen(indir) + 14);
255 stdcxx . . $ std/::sprintfcxx . . $ std/sprintf(bb743b22d71e45d5).(listfilename, "%s/bniindex.lst", indir);
256 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Info: Reading index from file \"%s\"...\n", listfilename);
257 if (read_listcxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/read_list(80d5cd1ef6c09de4).(argv[0], &bni, listfilename) < 0)
258 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
259 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "BNIHeader: unknown1=%u unknown2=%u numicons=%u dataoffset=%u\n", bni.unknown1cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown1., bni.unknown2cxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#unknown2., bni.numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons., bni.dataoffsetcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#dataoffset.);
260 if (write_bnicxx . . $ pvpgn/bni/write_bni(330f3994042b07e0).(fbni, &bni) < 0) {
261 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: Failed to write BNI header.\n");
262 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
263 }
264 img = new_tgaimgcxx . . $ pvpgn/bni/new_tgaimg(c336b9b97445332).(0, 0, 24, tgaimgtype_rlecompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_truecolor.);
265 for (i = 0; i < bni.numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.; i++) {
266 if (bni.iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[i].xcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#x. > img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.) img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. = bni.iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[i].xcxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#x.;
267 img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height. += bni.iconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#icons.->iconcxx . . $ pvpgn/bni/bni_iconlist_struct#icon.[i].ycxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_0#y.;
268 }
269 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Info: Creating TGA with %ux%ux%ubpp.\n", img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width., img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height., img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp.);
270 img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. = (stdcxx . . $ std/::uint8_tcxx . . $ std/uint8_t#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(img->width*img->height*getpixelsize(img));
271 yline = 0;
272 for (i = 0; i < bni.numiconscxx . . $ pvpgn/bni/$anonymous_type_7e9560d5c9d60d71_1#numicons.; i++) {
273 t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *icon;
274 stdcxx . . $ std/::FILEcxx . . $ std/FILE# *f;
275 char *name;
276 name = geticonfilenamecxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/geticonfilename(ddfaa0a9ae34a2e6).(&bni, indir, i);
277 f = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(name, "r");
278 if (f == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
279 stdcxx . . $ std/::perrorcxx . . $ std/perror(85c52e162fed56f9).("std::fopen");
280 xfreecxx . . $ `src/common/xalloc.h:51:9`!(name);
281 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
282 }
283 xfreecxx . . $ `src/common/xalloc.h:51:9`!(name);
284 icon = load_tgacxx . . $ pvpgn/bni/load_tga(d209b58585032934).(f);
285 if (stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(f) < 0)
286 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: could not close TGA file \"%s\" after reading (std::fclose: %s)\n", name, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
287 if (icon == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
288 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: load_tga failed with data from TGA file \"%s\"\n", name);
289 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
290 }
291 if (img2areacxx . . $ `$anonymous_namespace_src/bniutils/bnibuild.cpp`/img2area(56292d6966f91a89).(img, icon, 0, yline) < 0) {
292 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: inserting icon from TGA file \"%s\" into big TGA failed\n", name);
293 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
294 }
295 yline += icon->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.;
296 destroy_imgcxx . . $ pvpgn/bni/destroy_img(537e23c0c2dd1c71).(icon);
297 }
298 if (write_tgacxx . . $ pvpgn/bni/write_tga(790b6d97a440dd74).(fbni, img) < 0) {
299 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Error: Failed to write TGA to BNI file.\n");
300 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
301 }
302 if (bnifile != dash && stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fbni) < 0) {
303 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: could not close BNI file \"%s\" after writing (std::fclose: %s)\n", argv[0], bnifile, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
304 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
305 }
306 }
307 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Info: Writing to \"%s\" finished.\n", bnifile);
308 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
309 }