diff options
author | Dave Chapman <dave@dchapman.com> | 2008-03-26 18:18:22 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2008-03-26 18:18:22 +0000 |
commit | b9bb723f12c95f2b253f822bc9dc9d7f474f8d75 (patch) | |
tree | ce8e31b32aec877c2918b040254e29734f99c16f | |
parent | a53b85a52a71b84cc3137da8b7cbfb035a5285cb (diff) | |
download | rockbox-b9bb723f12c95f2b253f822bc9dc9d7f474f8d75.tar.gz rockbox-b9bb723f12c95f2b253f822bc9dc9d7f474f8d75.zip |
1) Make Rockbox reject any WPSs if there are errors loading any of the required bmps; 2) Make checkwps actually load the images using the Rockbox bmp loader, and reject the WPS in the same was as Rockbox on bmp errors.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16822 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/wps_parser.c | 40 | ||||
-rw-r--r-- | apps/recorder/bmp.c | 7 | ||||
-rw-r--r-- | tools/Makefile | 2 | ||||
-rw-r--r-- | tools/checkwps.c | 40 |
4 files changed, 72 insertions, 17 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index ae50499960..55b4ed9cae 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -17,18 +17,29 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include <stdio.h> | ||
21 | #include <string.h> | ||
22 | #include "gwps.h" | ||
23 | #ifdef __PCTOOL__ | ||
24 | #define DEBUGF printf | ||
25 | #define FONT_SYSFIXED 0 | ||
26 | #define FONT_UI 1 | ||
27 | #else | ||
28 | #include "debug.h" | ||
29 | #endif | ||
30 | |||
31 | #ifndef __PCTOOL__ | ||
20 | #include <ctype.h> | 32 | #include <ctype.h> |
21 | #include <stdbool.h> | 33 | #include <stdbool.h> |
22 | #include <stdio.h> | 34 | #include <stdio.h> |
23 | #include <stdlib.h> | 35 | #include <stdlib.h> |
24 | #include <string.h> | 36 | #include <string.h> |
37 | #include "font.h" | ||
38 | |||
25 | #include "atoi.h" | 39 | #include "atoi.h" |
26 | #include "gwps.h" | 40 | #include "gwps.h" |
27 | #include "font.h" | ||
28 | #ifndef __PCTOOL__ | ||
29 | #include "settings.h" | 41 | #include "settings.h" |
30 | #include "misc.h" | 42 | #include "misc.h" |
31 | #include "debug.h" | ||
32 | #include "plugin.h" | 43 | #include "plugin.h" |
33 | 44 | ||
34 | #ifdef HAVE_LCD_BITMAP | 45 | #ifdef HAVE_LCD_BITMAP |
@@ -382,7 +393,7 @@ static bool load_bitmap(struct wps_data *wps_data, | |||
382 | int ret = read_bmp_file(filename, bm, | 393 | int ret = read_bmp_file(filename, bm, |
383 | wps_data->img_buf_free, | 394 | wps_data->img_buf_free, |
384 | format); | 395 | format); |
385 | 396 | DEBUGF("Read %s, ret=%d\n",filename,ret); | |
386 | if (ret > 0) | 397 | if (ret > 0) |
387 | { | 398 | { |
388 | #if LCD_DEPTH == 16 | 399 | #if LCD_DEPTH == 16 |
@@ -1370,12 +1381,11 @@ static void wps_reset(struct wps_data *data) | |||
1370 | 1381 | ||
1371 | #ifdef HAVE_LCD_BITMAP | 1382 | #ifdef HAVE_LCD_BITMAP |
1372 | 1383 | ||
1373 | static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) | 1384 | static bool load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) |
1374 | { | 1385 | { |
1375 | char img_path[MAX_PATH]; | 1386 | char img_path[MAX_PATH]; |
1376 | struct bitmap *bitmap; | 1387 | struct bitmap *bitmap; |
1377 | bool *loaded; | 1388 | bool *loaded; |
1378 | |||
1379 | int n; | 1389 | int n; |
1380 | for (n = 0; n < BACKDROP_BMP; n++) | 1390 | for (n = 0; n < BACKDROP_BMP; n++) |
1381 | { | 1391 | { |
@@ -1405,6 +1415,12 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1405 | wps_data->img[n].subimage_height = wps_data->img[n].bm.height / | 1415 | wps_data->img[n].subimage_height = wps_data->img[n].bm.height / |
1406 | wps_data->img[n].num_subimages; | 1416 | wps_data->img[n].num_subimages; |
1407 | } | 1417 | } |
1418 | else | ||
1419 | { | ||
1420 | /* Abort if we can't load an image */ | ||
1421 | DEBUGF("ERR: Failed to load image %d - %s\n",n,img_path); | ||
1422 | return false; | ||
1423 | } | ||
1408 | } | 1424 | } |
1409 | } | 1425 | } |
1410 | 1426 | ||
@@ -1416,14 +1432,19 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1416 | #ifdef HAVE_REMOTE_LCD | 1432 | #ifdef HAVE_REMOTE_LCD |
1417 | if (wps_data->remote_wps) | 1433 | if (wps_data->remote_wps) |
1418 | #if LCD_REMOTE_DEPTH > 1 | 1434 | #if LCD_REMOTE_DEPTH > 1 |
1419 | load_remote_wps_backdrop(img_path) | 1435 | if (!load_remote_wps_backdrop(img_path)) |
1436 | return false | ||
1420 | #endif | 1437 | #endif |
1421 | ; | 1438 | ; |
1422 | else | 1439 | else |
1423 | #endif /* HAVE_REMOTE_LCD */ | 1440 | #endif /* HAVE_REMOTE_LCD */ |
1424 | load_wps_backdrop(img_path); | 1441 | if (!load_wps_backdrop(img_path)) |
1442 | return false; | ||
1425 | } | 1443 | } |
1426 | #endif /* has backdrop support */ | 1444 | #endif /* has backdrop support */ |
1445 | |||
1446 | /* If we got here, everything was OK */ | ||
1447 | return true; | ||
1427 | } | 1448 | } |
1428 | 1449 | ||
1429 | #endif /* HAVE_LCD_BITMAP */ | 1450 | #endif /* HAVE_LCD_BITMAP */ |
@@ -1552,7 +1573,8 @@ bool wps_data_load(struct wps_data *wps_data, | |||
1552 | bmpdir[bmpdirlen] = 0; | 1573 | bmpdir[bmpdirlen] = 0; |
1553 | 1574 | ||
1554 | /* load the bitmaps that were found by the parsing */ | 1575 | /* load the bitmaps that were found by the parsing */ |
1555 | load_wps_bitmaps(wps_data, bmpdir); | 1576 | if (!load_wps_bitmaps(wps_data, bmpdir)) |
1577 | return false; | ||
1556 | #endif | 1578 | #endif |
1557 | return true; | 1579 | return true; |
1558 | } | 1580 | } |
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 3db2cb1817..f844c8908f 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -38,11 +38,16 @@ | |||
38 | #ifdef HAVE_REMOTE_LCD | 38 | #ifdef HAVE_REMOTE_LCD |
39 | #include "lcd-remote.h" | 39 | #include "lcd-remote.h" |
40 | #endif | 40 | #endif |
41 | #ifndef __PCTOOL__ | ||
41 | #include "file.h" | 42 | #include "file.h" |
42 | #include "config.h" | 43 | #include "config.h" |
43 | #include "system.h" | 44 | #include "system.h" |
44 | #include "bmp.h" | 45 | #include "bmp.h" |
45 | #include "lcd.h" | 46 | #include "debug.h" |
47 | #else | ||
48 | #undef DEBUGF | ||
49 | #define DEBUGF(...) | ||
50 | #endif | ||
46 | 51 | ||
47 | #ifdef __GNUC__ | 52 | #ifdef __GNUC__ |
48 | #define STRUCT_PACKED __attribute__((packed)) | 53 | #define STRUCT_PACKED __attribute__((packed)) |
diff --git a/tools/Makefile b/tools/Makefile index 4db43c1b6c..94378d8fc5 100644 --- a/tools/Makefile +++ b/tools/Makefile | |||
@@ -64,7 +64,7 @@ database: database.c ../apps/tagcache.c ../apps/metadata.c \ | |||
64 | -D__PCTOOL__ -DHAVE_TAGCACHE -DROCKBOX_HAS_LOGF -DSIMULATOR \ | 64 | -D__PCTOOL__ -DHAVE_TAGCACHE -DROCKBOX_HAS_LOGF -DSIMULATOR \ |
65 | -DCONFIG_CODEC=1 -ldl -I../apps $+ -o $@ | 65 | -DCONFIG_CODEC=1 -ldl -I../apps $+ -o $@ |
66 | 66 | ||
67 | checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c ../firmware/common/ctype.c ../apps/misc.c | 67 | checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c ../firmware/common/ctype.c ../apps/misc.c ../apps/recorder/bmp.c |
68 | $(SILENT)$(CC) -g -I ../apps/gui -I../firmware/export \ | 68 | $(SILENT)$(CC) -g -I ../apps/gui -I../firmware/export \ |
69 | -D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" \ | 69 | -D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" \ |
70 | -I../apps -I../firmware/target/arm/ipod -I../firmware/include $+ -o $@ | 70 | -I../apps -I../firmware/target/arm/ipod -I../firmware/include $+ -o $@ |
diff --git a/tools/checkwps.c b/tools/checkwps.c index 92e7a5db94..ddaaf49b73 100644 --- a/tools/checkwps.c +++ b/tools/checkwps.c | |||
@@ -7,15 +7,43 @@ | |||
7 | bool debug_wps = true; | 7 | bool debug_wps = true; |
8 | int wps_verbose_level = 0; | 8 | int wps_verbose_level = 0; |
9 | 9 | ||
10 | int read_bmp_file(char* filename, | 10 | int errno; |
11 | struct bitmap *bm, | 11 | |
12 | int maxsize, | 12 | /* static endianness conversion */ |
13 | int format) | 13 | #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \ |
14 | ((unsigned short)(x) << 8))) | ||
15 | |||
16 | #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \ | ||
17 | (((unsigned long)(x) & 0xff0000ul) >> 8) | \ | ||
18 | (((unsigned long)(x) & 0xff00ul) << 8) | \ | ||
19 | ((unsigned long)(x) << 24))) | ||
20 | unsigned short letoh16(unsigned short x) | ||
14 | { | 21 | { |
15 | return 0; | 22 | unsigned short n = 0x1234; |
23 | unsigned char* ch = &n; | ||
24 | |||
25 | if (*ch == 0x34) | ||
26 | { | ||
27 | /* Little-endian */ | ||
28 | return x; | ||
29 | } else { | ||
30 | return SWAP_16(x); | ||
31 | } | ||
16 | } | 32 | } |
17 | 33 | ||
18 | int errno; | 34 | unsigned int htole32(unsigned int x) |
35 | { | ||
36 | unsigned short n = 0x1234; | ||
37 | unsigned char* ch = &n; | ||
38 | |||
39 | if (*ch == 0x34) | ||
40 | { | ||
41 | /* Little-endian */ | ||
42 | return x; | ||
43 | } else { | ||
44 | return SWAP_32(x); | ||
45 | } | ||
46 | } | ||
19 | 47 | ||
20 | int read_line(int fd, char* buffer, int buffer_size) | 48 | int read_line(int fd, char* buffer, int buffer_size) |
21 | { | 49 | { |