Changeset 5095d40 in thomson
- Timestamp:
- Mar 13, 2015, 10:12:59 PM (9 years ago)
- Branches:
- main
- Children:
- b3195d1
- Parents:
- 2ee52fb
- Location:
- tools
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/binxploder.cpp
r2ee52fb r5095d40 3 3 * This file is distributed under the terms of the MIT Licence. 4 4 */ 5 6 #include <arpa/inet.h>7 5 8 6 #include <stdint.h> … … 11 9 #include <string.h> 12 10 13 struct __attribute__((packed)) Header { 14 uint8_t type; 15 uint16_t length; 16 uint16_t addr; 17 }; 11 #include "decb.cpp" 18 12 19 13 int main(int argc, char* argv[]) 20 14 { 21 FILE* f1, * f2;22 Header h;23 24 15 if (argc < 2) 25 16 { … … 28 19 } 29 20 21 FILE* f1, * f2; 22 uint8_t i = 0; 23 DECB_Chunk h; 24 30 25 f1 = fopen(argv[1], "rb"); 26 char* buf = (char*)malloc(strlen(argv[1] + 3)); 31 27 32 char* buf = (char*)malloc(strlen(argv[1] + 3)); 33 uint8_t i; 34 35 while(fread(&h, sizeof(h), 1, f1)) 28 while(DECB_ReadChunk(f1, h)) 36 29 { 37 // 6809 is little endian, take that into account...38 h.length = ntohs(h.length);39 h.addr = ntohs(h.addr);40 41 30 printf("Type: %02x - Size: %04x - Load: %04x\n", h.type, h.length, h.addr); 42 31 … … 44 33 f2 = fopen(buf, "wb"); 45 34 46 char* b2 = (char*)malloc(h.length); 47 fread(b2, h.length, 1, f1); 48 fwrite(b2, h.length, 1, f2); 35 fwrite(&h.data[0], h.length, 1, f2); 49 36 50 free(b2);51 37 fclose(f2); 52 38 }
Note:
See TracChangeset
for help on using the changeset viewer.