forked from len0rd/rockbox
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
This commit is contained in:
parent
32d261e3f9
commit
2a91a9a19e
2 changed files with 14 additions and 10 deletions
|
@ -31,10 +31,12 @@
|
||||||
language! */
|
language! */
|
||||||
#include "max_language_size.h"
|
#include "max_language_size.h"
|
||||||
|
|
||||||
/* both these must match the two initial bytes in the binary lang file */
|
/* These defines must match the initial bytes in the binary lang file */
|
||||||
#define LANGUAGE_COOKIE 0x1a
|
/* See tools/genlang (TODO: Use common include for both) */
|
||||||
#define LANGUAGE_VERSION 0x04
|
#define LANGUAGE_COOKIE 0x1a
|
||||||
|
#define LANGUAGE_VERSION 0x04
|
||||||
|
|
||||||
|
#define HEADER_SIZE 3
|
||||||
|
|
||||||
static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
|
static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
|
||||||
|
|
||||||
|
@ -54,12 +56,12 @@ int lang_load(const char *filename)
|
||||||
int fsize;
|
int fsize;
|
||||||
int fd = open(filename, O_RDONLY);
|
int fd = open(filename, O_RDONLY);
|
||||||
int retcode=0;
|
int retcode=0;
|
||||||
unsigned char lang_header[3];
|
unsigned char lang_header[HEADER_SIZE];
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return 1;
|
return 1;
|
||||||
fsize = filesize(fd) - 2;
|
fsize = filesize(fd) - HEADER_SIZE;
|
||||||
if(fsize <= MAX_LANGUAGE_SIZE) {
|
if(fsize <= MAX_LANGUAGE_SIZE) {
|
||||||
read(fd, lang_header, 3);
|
read(fd, lang_header, HEADER_SIZE);
|
||||||
if((lang_header[0] == LANGUAGE_COOKIE) &&
|
if((lang_header[0] == LANGUAGE_COOKIE) &&
|
||||||
(lang_header[1] == LANGUAGE_VERSION) &&
|
(lang_header[1] == LANGUAGE_VERSION) &&
|
||||||
(lang_header[2] == TARGET_ID)) {
|
(lang_header[2] == TARGET_ID)) {
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
# Copyright (C) 2006 - 2008 by Daniel Stenberg
|
# Copyright (C) 2006 - 2008 by Daniel Stenberg
|
||||||
#
|
#
|
||||||
|
|
||||||
# binary version for the binary lang file
|
# See apps/language.c (TODO: Use common include for both)
|
||||||
my $langversion = 4; # 3 was the latest one used in the v1 format
|
# Cookie and binary version for the binary lang file
|
||||||
|
my $LANGUAGE_COOKIE = 0x1a;
|
||||||
|
my $LANGUAGE_VERSION = 0x04;
|
||||||
|
|
||||||
# A note for future users and readers: The original v1 language system allowed
|
# A note for future users and readers: The original v1 language system allowed
|
||||||
# the build to create and use a different language than english built-in. We
|
# the build to create and use a different language than english built-in. We
|
||||||
|
@ -26,7 +28,7 @@ my %user2num =
|
||||||
|
|
||||||
if(!$ARGV[0]) {
|
if(!$ARGV[0]) {
|
||||||
print <<MOO
|
print <<MOO
|
||||||
Usage: genlang [options] <langv2 file>
|
Usage: genlang [options] <langv4 file>
|
||||||
|
|
||||||
-p=<prefix>
|
-p=<prefix>
|
||||||
Make the tool create a [prefix].c and [prefix].h file.
|
Make the tool create a [prefix].c and [prefix].h file.
|
||||||
|
@ -659,7 +661,7 @@ elsif($binary) {
|
||||||
|
|
||||||
open(OUTF, ">$binary") or die "Error: Can't create $binary";
|
open(OUTF, ">$binary") or die "Error: Can't create $binary";
|
||||||
binmode OUTF;
|
binmode OUTF;
|
||||||
printf OUTF ("\x1a%c%c", $langversion, $target_id); # magic lang file header
|
printf OUTF ("%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id); # magic lang file header
|
||||||
|
|
||||||
# loop over the target phrases
|
# loop over the target phrases
|
||||||
for $i (1 .. $idcount) {
|
for $i (1 .. $idcount) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue