1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Daniel Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 #if defined(SIMULATOR) && defined(__MINGW32__)
22 extern int printf(const char *format
, ...);
30 static unsigned char language_buffer
[MAX_LANGUAGE_SIZE
];
35 unsigned char *ptr
= (unsigned char *) language_builtin
;
37 for (i
= 0; i
< LANG_LAST_INDEX_IN_ARRAY
; i
++) {
38 language_strings
[i
] = ptr
;
39 ptr
+= strlen((char *)ptr
) + 1; /* advance pointer to next string */
43 int lang_load(const char *filename
)
46 int fd
= open(filename
, O_RDONLY
);
48 unsigned char lang_header
[3];
51 fsize
= filesize(fd
) - 2;
52 if(fsize
<= MAX_LANGUAGE_SIZE
) {
53 read(fd
, lang_header
, 3);
54 if((lang_header
[0] == LANGUAGE_COOKIE
) &&
55 (lang_header
[1] == LANGUAGE_VERSION
) &&
56 (lang_header
[2] == TARGET_ID
)) {
57 read(fd
, language_buffer
, MAX_LANGUAGE_SIZE
);
58 unsigned char *ptr
= language_buffer
;
60 lang_init(); /* initialize with builtin */
63 id
= (ptr
[0]<<8) | ptr
[1]; /* get two-byte id */
64 ptr
+=2; /* pass the id */
65 if(id
< LANG_LAST_INDEX_IN_ARRAY
) {
67 printf("%2x New: %30s ", id
, ptr
);
68 printf("Replaces: %s\n", language_strings
[id
]);
70 language_strings
[id
] = ptr
; /* point to this string */
72 while(*ptr
) { /* pass the string */
76 fsize
-=3; /* the id and the terminating zero */
77 ptr
++; /* pass the terminating zero-byte */
81 DEBUGF("Illegal language file\n");
86 DEBUGF("Language %s too large: %d\n", filename
, fsize
);