mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 18:47:39 -04:00
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
This commit is contained in:
parent
a53b85a52a
commit
b9bb723f12
4 changed files with 72 additions and 17 deletions
|
@ -17,18 +17,29 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "gwps.h"
|
||||||
|
#ifdef __PCTOOL__
|
||||||
|
#define DEBUGF printf
|
||||||
|
#define FONT_SYSFIXED 0
|
||||||
|
#define FONT_UI 1
|
||||||
|
#else
|
||||||
|
#include "debug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "font.h"
|
||||||
|
|
||||||
#include "atoi.h"
|
#include "atoi.h"
|
||||||
#include "gwps.h"
|
#include "gwps.h"
|
||||||
#include "font.h"
|
|
||||||
#ifndef __PCTOOL__
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "debug.h"
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
@ -382,7 +393,7 @@ static bool load_bitmap(struct wps_data *wps_data,
|
||||||
int ret = read_bmp_file(filename, bm,
|
int ret = read_bmp_file(filename, bm,
|
||||||
wps_data->img_buf_free,
|
wps_data->img_buf_free,
|
||||||
format);
|
format);
|
||||||
|
DEBUGF("Read %s, ret=%d\n",filename,ret);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
#if LCD_DEPTH == 16
|
#if LCD_DEPTH == 16
|
||||||
|
@ -1370,12 +1381,11 @@ static void wps_reset(struct wps_data *data)
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
||||||
static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
|
static bool load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
|
||||||
{
|
{
|
||||||
char img_path[MAX_PATH];
|
char img_path[MAX_PATH];
|
||||||
struct bitmap *bitmap;
|
struct bitmap *bitmap;
|
||||||
bool *loaded;
|
bool *loaded;
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
for (n = 0; n < BACKDROP_BMP; n++)
|
for (n = 0; n < BACKDROP_BMP; n++)
|
||||||
{
|
{
|
||||||
|
@ -1405,6 +1415,12 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
|
||||||
wps_data->img[n].subimage_height = wps_data->img[n].bm.height /
|
wps_data->img[n].subimage_height = wps_data->img[n].bm.height /
|
||||||
wps_data->img[n].num_subimages;
|
wps_data->img[n].num_subimages;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Abort if we can't load an image */
|
||||||
|
DEBUGF("ERR: Failed to load image %d - %s\n",n,img_path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,14 +1432,19 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
if (wps_data->remote_wps)
|
if (wps_data->remote_wps)
|
||||||
#if LCD_REMOTE_DEPTH > 1
|
#if LCD_REMOTE_DEPTH > 1
|
||||||
load_remote_wps_backdrop(img_path)
|
if (!load_remote_wps_backdrop(img_path))
|
||||||
|
return false
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
#endif /* HAVE_REMOTE_LCD */
|
#endif /* HAVE_REMOTE_LCD */
|
||||||
load_wps_backdrop(img_path);
|
if (!load_wps_backdrop(img_path))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif /* has backdrop support */
|
#endif /* has backdrop support */
|
||||||
|
|
||||||
|
/* If we got here, everything was OK */
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
@ -1552,7 +1573,8 @@ bool wps_data_load(struct wps_data *wps_data,
|
||||||
bmpdir[bmpdirlen] = 0;
|
bmpdir[bmpdirlen] = 0;
|
||||||
|
|
||||||
/* load the bitmaps that were found by the parsing */
|
/* load the bitmaps that were found by the parsing */
|
||||||
load_wps_bitmaps(wps_data, bmpdir);
|
if (!load_wps_bitmaps(wps_data, bmpdir))
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,16 @@
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
#include "lcd-remote.h"
|
#include "lcd-remote.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __PCTOOL__
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "bmp.h"
|
#include "bmp.h"
|
||||||
#include "lcd.h"
|
#include "debug.h"
|
||||||
|
#else
|
||||||
|
#undef DEBUGF
|
||||||
|
#define DEBUGF(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define STRUCT_PACKED __attribute__((packed))
|
#define STRUCT_PACKED __attribute__((packed))
|
||||||
|
|
|
@ -64,7 +64,7 @@ database: database.c ../apps/tagcache.c ../apps/metadata.c \
|
||||||
-D__PCTOOL__ -DHAVE_TAGCACHE -DROCKBOX_HAS_LOGF -DSIMULATOR \
|
-D__PCTOOL__ -DHAVE_TAGCACHE -DROCKBOX_HAS_LOGF -DSIMULATOR \
|
||||||
-DCONFIG_CODEC=1 -ldl -I../apps $+ -o $@
|
-DCONFIG_CODEC=1 -ldl -I../apps $+ -o $@
|
||||||
|
|
||||||
checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c ../firmware/common/ctype.c ../apps/misc.c
|
checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c ../firmware/common/ctype.c ../apps/misc.c ../apps/recorder/bmp.c
|
||||||
$(SILENT)$(CC) -g -I ../apps/gui -I../firmware/export \
|
$(SILENT)$(CC) -g -I ../apps/gui -I../firmware/export \
|
||||||
-D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" \
|
-D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" \
|
||||||
-I../apps -I../firmware/target/arm/ipod -I../firmware/include $+ -o $@
|
-I../apps -I../firmware/target/arm/ipod -I../firmware/include $+ -o $@
|
||||||
|
|
|
@ -7,15 +7,43 @@
|
||||||
bool debug_wps = true;
|
bool debug_wps = true;
|
||||||
int wps_verbose_level = 0;
|
int wps_verbose_level = 0;
|
||||||
|
|
||||||
int read_bmp_file(char* filename,
|
int errno;
|
||||||
struct bitmap *bm,
|
|
||||||
int maxsize,
|
/* static endianness conversion */
|
||||||
int format)
|
#define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
|
||||||
|
((unsigned short)(x) << 8)))
|
||||||
|
|
||||||
|
#define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
|
||||||
|
(((unsigned long)(x) & 0xff0000ul) >> 8) | \
|
||||||
|
(((unsigned long)(x) & 0xff00ul) << 8) | \
|
||||||
|
((unsigned long)(x) << 24)))
|
||||||
|
unsigned short letoh16(unsigned short x)
|
||||||
{
|
{
|
||||||
return 0;
|
unsigned short n = 0x1234;
|
||||||
|
unsigned char* ch = &n;
|
||||||
|
|
||||||
|
if (*ch == 0x34)
|
||||||
|
{
|
||||||
|
/* Little-endian */
|
||||||
|
return x;
|
||||||
|
} else {
|
||||||
|
return SWAP_16(x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int errno;
|
unsigned int htole32(unsigned int x)
|
||||||
|
{
|
||||||
|
unsigned short n = 0x1234;
|
||||||
|
unsigned char* ch = &n;
|
||||||
|
|
||||||
|
if (*ch == 0x34)
|
||||||
|
{
|
||||||
|
/* Little-endian */
|
||||||
|
return x;
|
||||||
|
} else {
|
||||||
|
return SWAP_32(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int read_line(int fd, char* buffer, int buffer_size)
|
int read_line(int fd, char* buffer, int buffer_size)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue