From f0d4fc6c6b146197c0fc51753d838252766aeda2 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Tue, 29 May 2007 19:00:36 +0000 Subject: Commit my patch from FS#7179 - a standalone command-line checkwps tool. To build, just type "make checkwps" in tools and run it with "checkwps wpsname.wps". git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13517 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps_parser.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'apps/gui/wps_parser.c') diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index be0ef4e271..d363d6d8cb 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -24,6 +24,7 @@ #include #include "atoi.h" #include "gwps.h" +#ifndef __PCTOOL__ #include "settings.h" #include "debug.h" #include "plugin.h" @@ -36,6 +37,8 @@ #include "backdrop.h" #endif +#endif + #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" @@ -1008,6 +1011,7 @@ bool wps_data_load(struct wps_data *wps_data, * wants to be a virtual file. Feel free to modify dirbrowse() * if you're feeling brave. */ +#ifndef __PCTOOL__ if (! strcmp(buf, WPS_DEFAULTCFG) ) { global_settings.wps_file[0] = 0; @@ -1021,6 +1025,7 @@ bool wps_data_load(struct wps_data *wps_data, return false; } #endif +#endif /* __PCTOOL__ */ int fd = open(buf, O_RDONLY); @@ -1080,3 +1085,30 @@ bool wps_data_load(struct wps_data *wps_data, return true; } } + +int wps_subline_index(struct wps_data *data, int line, int subline) +{ + return data->lines[line].first_subline_idx + subline; +} + +int wps_first_token_index(struct wps_data *data, int line, int subline) +{ + int first_subline_idx = data->lines[line].first_subline_idx; + return data->sublines[first_subline_idx + subline].first_token_idx; +} + +int wps_last_token_index(struct wps_data *data, int line, int subline) +{ + int first_subline_idx = data->lines[line].first_subline_idx; + int idx = first_subline_idx + subline; + if (idx < data->num_sublines - 1) + { + /* This subline ends where the next begins */ + return data->sublines[idx+1].first_token_idx - 1; + } + else + { + /* The last subline goes to the end */ + return data->num_tokens - 1; + } +} -- cgit v1.2.3