diff options
| author | Antoine Cellerier <dionoea@videolan.org> | 2008-12-07 16:20:35 +0000 |
|---|---|---|
| committer | Antoine Cellerier <dionoea@videolan.org> | 2008-12-07 16:20:35 +0000 |
| commit | 8289b966b810eb21732ecb905433debf4e872857 (patch) | |
| tree | 4665d7ca2d8c2f5bfa41686f9e7ddba65fb4e18f /apps/gui/wps_parser.c | |
| parent | 3ad535031a84f0fa9c65a24e140c81b0a60c3026 (diff) | |
| download | rockbox-8289b966b810eb21732ecb905433debf4e872857.zip rockbox-8289b966b810eb21732ecb905433debf4e872857.tar.gz rockbox-8289b966b810eb21732ecb905433debf4e872857.tar.bz2 rockbox-8289b966b810eb21732ecb905433debf4e872857.tar.xz | |
Apply FS#9368 : add generic settings tag to WPS.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19357 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/wps_parser.c')
| -rw-r--r-- | apps/gui/wps_parser.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 88601fd..22b1611 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -56,6 +56,7 @@ #include "gwps.h" #include "settings.h" +#include "settings_list.h" #ifdef HAVE_LCD_BITMAP #include "bmp.h" @@ -137,6 +138,8 @@ static int parse_progressbar(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); static int parse_dir_level(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); +static int parse_setting(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data); #ifdef HAVE_LCD_BITMAP static int parse_viewport_display(const char *wps_bufptr, @@ -342,6 +345,8 @@ static const struct wps_tag all_tags[] = { #endif #endif + { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, parse_setting }, + { WPS_TOKEN_UNKNOWN, "", 0, NULL } /* the array MUST end with an empty string (first char is \0) */ }; @@ -726,6 +731,39 @@ static int parse_viewport(const char *wps_bufptr, return skip_end_of_line(wps_bufptr); } +static int parse_setting(const char *wps_bufptr, + struct wps_token *token, + struct wps_data *wps_data) +{ + (void)wps_data; + const char *ptr = wps_bufptr; + const char *end; + int i; + + /* Find the setting's cfg_name */ + if (*ptr != '|') + return WPS_ERROR_INVALID_PARAM; + ptr++; + end = strchr(ptr,'|'); + if (!end) + return WPS_ERROR_INVALID_PARAM; + + /* Find the setting */ + for (i=0; i<nb_settings; i++) + if (settings[i].cfg_name && + !strncmp(settings[i].cfg_name,ptr,end-ptr) && + /* prevent matches on cfg_name prefixes */ + strlen(settings[i].cfg_name)==end-ptr) break; + if (i == nb_settings) + return WPS_ERROR_INVALID_PARAM; + + /* Store the setting number */ + token->value.i = i; + + /* Skip the rest of the line */ + return end-ptr+2; +} + #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) static int parse_image_special(const char *wps_bufptr, |