From 3dabc565d995a34e0727a7c9980bbac6cc0d6e7b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 10 Aug 2007 22:04:47 +0000 Subject: tiny tool to help with dumping a binary lng file to the screen to make it easier to compare with the generated lang.[ch] git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14272 a1c6a512-1295-4272-9138-f99709370657 --- tools/lngdump.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tools/lngdump.c diff --git a/tools/lngdump.c b/tools/lngdump.c new file mode 100644 index 0000000000..f304fc8521 --- /dev/null +++ b/tools/lngdump.c @@ -0,0 +1,50 @@ +#include +#include +#include + +#define MAX_LANGUAGE_SIZE 20000 + +static char language_buffer[MAX_LANGUAGE_SIZE]; + +int lang_load(const char *filename) +{ + int fsize; + int fd = open(filename, O_RDONLY); + int retcode=0; + unsigned char lang_header[3]; + if(fd == -1) + return 1; + if(3 == read(fd, lang_header, 3)) { + unsigned char *ptr = language_buffer; + int id; + printf("%02x %02x %02x\n", + lang_header[0], lang_header[1], lang_header[2]); + + fsize = read(fd, language_buffer, MAX_LANGUAGE_SIZE); + + while(fsize>3) { + id = (ptr[0]<<8) | ptr[1]; /* get two-byte id */ + ptr+=2; /* pass the id */ + if(id < 2000) { + printf("%03d %s\n", id, ptr); + } + while(*ptr) { /* pass the string */ + fsize--; + ptr++; + } + fsize-=3; /* the id and the terminating zero */ + ptr++; /* pass the terminating zero-byte */ + } + } + close(fd); + return retcode; +} + +int main(int argc, char **argv) +{ + if(argc < 2) { + printf("Usage: lngdump \n"); + return 2; + } + lang_load(argv[1]); +} -- cgit v1.2.3