diff options
author | Tomer Shalev <shalev.tomer@gmail.com> | 2009-12-29 18:14:31 +0000 |
---|---|---|
committer | Tomer Shalev <shalev.tomer@gmail.com> | 2009-12-29 18:14:31 +0000 |
commit | e15a0c911846d974e0a5d202b30864a0725ff839 (patch) | |
tree | c42aceaa77818e1e3966fbefa59cd0d82311905f /apps/gui/skin_engine/skin_parser.c | |
parent | 98676a910753e71acd75a26fbf8bf2d3ee4a3203 (diff) | |
download | rockbox-e15a0c911846d974e0a5d202b30864a0725ff839.tar.gz rockbox-e15a0c911846d974e0a5d202b30864a0725ff839.zip |
WPS: Use helper function to parse int value on album-art directive
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24121 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 501d76e5c7..568f9cb578 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1026,6 +1026,13 @@ static int parse_progressbar(const char *wps_bufptr, } #ifdef HAVE_ALBUMART +static int parse_int(const char *newline, const char **_pos, int *num) +{ + *_pos = parse_list("d", NULL, '|', *_pos, num); + + return (!*_pos || *_pos > newline || **_pos != '|'); +} + static int parse_albumart_load(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) @@ -1050,16 +1057,22 @@ static int parse_albumart_load(const char *wps_bufptr, newline = strchr(wps_bufptr, '\n'); - /* initial validation and parsing of x and y components */ - if (*wps_bufptr != '|') + _pos = wps_bufptr; + + if (*_pos != '|') return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ - _pos = wps_bufptr + 1; - _pos = parse_list("dd", NULL, '|', _pos, &aa->x, &aa->y); + ++_pos; + + /* initial validation and parsing of x component */ + if (parse_int(newline, &_pos, &aa->x)) + return WPS_ERROR_INVALID_PARAM; - if (!_pos || _pos > newline || *_pos != '|') - return WPS_ERROR_INVALID_PARAM; /* malformed token: no | after y coordinate - e.g. %Cl|7|59\n */ + ++_pos; + + /* initial validation and parsing of y component */ + if (parse_int(newline, &_pos, &aa->y)) + return WPS_ERROR_INVALID_PARAM; /* parsing width field */ parsing = true; @@ -1099,8 +1112,7 @@ static int parse_albumart_load(const char *wps_bufptr, /* extract max width data */ if (*_pos != '|') { - _pos = parse_list("d", NULL, '|', _pos, &aa->width); - if (!_pos || _pos > newline || *_pos != '|') + if (parse_int(newline, &_pos, &aa->width)) return WPS_ERROR_INVALID_PARAM; } @@ -1142,8 +1154,7 @@ static int parse_albumart_load(const char *wps_bufptr, /* extract max height data */ if (*_pos != '|') { - _pos = parse_list("d", NULL, '|', _pos, &aa->height); - if (!_pos || _pos > newline || *_pos != '|') + if (parse_int(newline, &_pos, &aa->height)) return WPS_ERROR_INVALID_PARAM; } |