summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-08-10 22:04:47 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-08-10 22:04:47 +0000
commit3dabc565d995a34e0727a7c9980bbac6cc0d6e7b (patch)
tree8b9e6e4499fe2243247cecc8c6f9cd31a017a0a6
parentffeaea65c8c2e90c6baea06bd94adc0292a90b90 (diff)
downloadrockbox-3dabc565d995a34e0727a7c9980bbac6cc0d6e7b.tar.gz
rockbox-3dabc565d995a34e0727a7c9980bbac6cc0d6e7b.zip
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
-rw-r--r--tools/lngdump.c50
1 files changed, 50 insertions, 0 deletions
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 @@
1#include <stdio.h>
2#include <sys/stat.h>
3#include <fcntl.h>
4
5#define MAX_LANGUAGE_SIZE 20000
6
7static char language_buffer[MAX_LANGUAGE_SIZE];
8
9int lang_load(const char *filename)
10{
11 int fsize;
12 int fd = open(filename, O_RDONLY);
13 int retcode=0;
14 unsigned char lang_header[3];
15 if(fd == -1)
16 return 1;
17 if(3 == read(fd, lang_header, 3)) {
18 unsigned char *ptr = language_buffer;
19 int id;
20 printf("%02x %02x %02x\n",
21 lang_header[0], lang_header[1], lang_header[2]);
22
23 fsize = read(fd, language_buffer, MAX_LANGUAGE_SIZE);
24
25 while(fsize>3) {
26 id = (ptr[0]<<8) | ptr[1]; /* get two-byte id */
27 ptr+=2; /* pass the id */
28 if(id < 2000) {
29 printf("%03d %s\n", id, ptr);
30 }
31 while(*ptr) { /* pass the string */
32 fsize--;
33 ptr++;
34 }
35 fsize-=3; /* the id and the terminating zero */
36 ptr++; /* pass the terminating zero-byte */
37 }
38 }
39 close(fd);
40 return retcode;
41}
42
43int main(int argc, char **argv)
44{
45 if(argc < 2) {
46 printf("Usage: lngdump <lng file>\n");
47 return 2;
48 }
49 lang_load(argv[1]);
50}