summaryrefslogtreecommitdiff
path: root/utils/jz4740_tools/HXFsplit.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/jz4740_tools/HXFsplit.c')
-rw-r--r--utils/jz4740_tools/HXFsplit.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/utils/jz4740_tools/HXFsplit.c b/utils/jz4740_tools/HXFsplit.c
index d5e578625b..6e945b067a 100644
--- a/utils/jz4740_tools/HXFsplit.c
+++ b/utils/jz4740_tools/HXFsplit.c
@@ -31,11 +31,11 @@
31#define VERSION "0.2" 31#define VERSION "0.2"
32 32
33struct header{ 33struct header{
34 char main_header[20]; 34 char main_header[20];
35 unsigned int size; 35 unsigned int size;
36 unsigned int checksum; 36 unsigned int checksum;
37 unsigned int unknown; 37 unsigned int unknown;
38 char other_header[32]; 38 char other_header[32];
39}; 39};
40 40
41static char* basepath(char* path) 41static char* basepath(char* path)
@@ -197,7 +197,7 @@ static int split_hxf(const unsigned char* infile, unsigned int size, const char*
197 if(!file_exists(filename)) 197 if(!file_exists(filename))
198 { 198 {
199 printf("[INFO] %s: %d bytes\n", filename, filesize); 199 printf("[INFO] %s: %d bytes\n", filename, filesize);
200 if((outfile = fopen(filename, "wb")) == NULL) 200 if((outfile = fopen(filename, "wb")) == NULL)
201 { 201 {
202 fprintf(stderr, "[ERR] Error opening file %s\n", filename); 202 fprintf(stderr, "[ERR] Error opening file %s\n", filename);
203 return -1; 203 return -1;
@@ -251,20 +251,20 @@ int main(int argc, char *argv[])
251#ifdef _WIN32 251#ifdef _WIN32
252 if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "\\") != 0) 252 if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "\\") != 0)
253 { 253 {
254 fprintf(stderr, "[ERR] Output path must end with a \\\n"); 254 fprintf(stderr, "[ERR] Output path must end with a \\\n");
255#else 255#else
256 if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "/") != 0) 256 if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "/") != 0)
257 { 257 {
258 fprintf(stderr, "[ERR] Output path must end with a /\n"); 258 fprintf(stderr, "[ERR] Output path must end with a /\n");
259#endif 259#endif
260 return 2; 260 return 2;
261 } 261 }
262 262
263 if((infile = fopen(argv[1], "rb")) == NULL) 263 if((infile = fopen(argv[1], "rb")) == NULL)
264 { 264 {
265 fprintf(stderr, "[ERR] Cannot open %s\n", argv[1]); 265 fprintf(stderr, "[ERR] Cannot open %s\n", argv[1]);
266 return 3; 266 return 3;
267 } 267 }
268 268
269 if((inbuffer = (unsigned char*)malloc(sizeof(struct header))) == NULL) 269 if((inbuffer = (unsigned char*)malloc(sizeof(struct header))) == NULL)
270 { 270 {
@@ -273,12 +273,12 @@ int main(int argc, char *argv[])
273 return 4; 273 return 4;
274 } 274 }
275 275
276 if(fread(inbuffer, sizeof(struct header), 1, infile) != 1) 276 if(fread(inbuffer, sizeof(struct header), 1, infile) != 1)
277 { 277 {
278 fclose(infile); 278 fclose(infile);
279 fprintf(stderr, "Cannot read header of %s\n", argv[1]); 279 fprintf(stderr, "Cannot read header of %s\n", argv[1]);
280 return 5; 280 return 5;
281 } 281 }
282 282
283 memcpy(hdr.main_header, inbuffer, 20); 283 memcpy(hdr.main_header, inbuffer, 20);
284 hdr.size = le2int(&inbuffer[20]); 284 hdr.size = le2int(&inbuffer[20]);
@@ -290,8 +290,8 @@ int main(int argc, char *argv[])
290 if(strcmp(hdr.other_header, "Chinachip PMP firmware V1.0") != 0) 290 if(strcmp(hdr.other_header, "Chinachip PMP firmware V1.0") != 0)
291 { 291 {
292 fclose(infile); 292 fclose(infile);
293 fprintf(stderr, "[ERR] Header doesn't match\n"); 293 fprintf(stderr, "[ERR] Header doesn't match\n");
294 return 6; 294 return 6;
295 } 295 }
296 296
297 if((inbuffer = (unsigned char*)malloc(hdr.size)) == NULL) 297 if((inbuffer = (unsigned char*)malloc(hdr.size)) == NULL)
@@ -303,13 +303,13 @@ int main(int argc, char *argv[])
303 303
304 fseek(infile, sizeof(struct header), SEEK_SET); 304 fseek(infile, sizeof(struct header), SEEK_SET);
305 305
306 if(fread(inbuffer, hdr.size-sizeof(struct header), 1, infile) != 1) 306 if(fread(inbuffer, hdr.size-sizeof(struct header), 1, infile) != 1)
307 { 307 {
308 fclose(infile); 308 fclose(infile);
309 free(inbuffer); 309 free(inbuffer);
310 fprintf(stderr, "[ERR] Cannot read file in buffer\n"); 310 fprintf(stderr, "[ERR] Cannot read file in buffer\n");
311 return 8; 311 return 8;
312 } 312 }
313 313
314 fclose(infile); 314 fclose(infile);
315 315