summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-10-04 22:25:52 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-10-04 22:25:52 +0000
commit2a91a9a19eabbd38894bd08ac18250c97cb1f2cf (patch)
tree937261883bf713e42bb8a6ebe71dadf44c77e29e /apps
parent32d261e3f9b986f29356f63c1b4857eb6890a1b9 (diff)
downloadrockbox-2a91a9a19eabbd38894bd08ac18250c97cb1f2cf.tar.gz
rockbox-2a91a9a19eabbd38894bd08ac18250c97cb1f2cf.zip
Use similiar constants in genlang and language.c.
- In the future, they should be united. - Fix bug in max size calculation git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22930 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/language.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/language.c b/apps/language.c
index 73ed0fe39b..bba1359616 100644
--- a/apps/language.c
+++ b/apps/language.c
@@ -31,10 +31,12 @@
31 language! */ 31 language! */
32#include "max_language_size.h" 32#include "max_language_size.h"
33 33
34/* both these must match the two initial bytes in the binary lang file */ 34/* These defines must match the initial bytes in the binary lang file */
35#define LANGUAGE_COOKIE 0x1a 35/* See tools/genlang (TODO: Use common include for both) */
36#define LANGUAGE_VERSION 0x04 36#define LANGUAGE_COOKIE 0x1a
37#define LANGUAGE_VERSION 0x04
37 38
39#define HEADER_SIZE 3
38 40
39static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; 41static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
40 42
@@ -54,12 +56,12 @@ int lang_load(const char *filename)
54 int fsize; 56 int fsize;
55 int fd = open(filename, O_RDONLY); 57 int fd = open(filename, O_RDONLY);
56 int retcode=0; 58 int retcode=0;
57 unsigned char lang_header[3]; 59 unsigned char lang_header[HEADER_SIZE];
58 if(fd < 0) 60 if(fd < 0)
59 return 1; 61 return 1;
60 fsize = filesize(fd) - 2; 62 fsize = filesize(fd) - HEADER_SIZE;
61 if(fsize <= MAX_LANGUAGE_SIZE) { 63 if(fsize <= MAX_LANGUAGE_SIZE) {
62 read(fd, lang_header, 3); 64 read(fd, lang_header, HEADER_SIZE);
63 if((lang_header[0] == LANGUAGE_COOKIE) && 65 if((lang_header[0] == LANGUAGE_COOKIE) &&
64 (lang_header[1] == LANGUAGE_VERSION) && 66 (lang_header[1] == LANGUAGE_VERSION) &&
65 (lang_header[2] == TARGET_ID)) { 67 (lang_header[2] == TARGET_ID)) {