From 3213d4a0f5d3aea725bb9ddf34ae0ec38ca4b097 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sun, 22 Jul 2007 17:17:53 +0000 Subject: Add a verbosity level command line option to the chackwps tool. This should make life easier for the themes.rockbox.org people. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13958 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps_debug.c | 112 ++++++++++++++++++++++++++++-------------------- tools/checkwps.c | 23 ++++++++-- uisimulator/sdl/uisdl.c | 1 + 3 files changed, 85 insertions(+), 51 deletions(-) diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index 935384faba..317e73cf2a 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c @@ -34,6 +34,7 @@ #if defined(SIMULATOR) || defined(__PCTOOL__) extern bool debug_wps; +extern int wps_verbose_level; #endif static char *next_str(bool next) { @@ -49,11 +50,6 @@ static void dump_wps_tokens(struct wps_data *data) bool next; int num_string_tokens = 0; - if (data->num_tokens > WPS_MAX_TOKENS) { - DEBUGF("Number of tokens is too high (%d)!!!\n", data->num_tokens); - return; - } - /* Dump parsed WPS */ for (i = 0, token = data->tokens; i < data->num_tokens; i++, token++) { next = token->next; @@ -383,16 +379,22 @@ static void dump_wps_tokens(struct wps_data *data) break; } - for(j = 0; j < indent; j++) { - DEBUGF("\t"); - } + if (wps_verbose_level > 2) + { + for(j = 0; j < indent; j++) { + DEBUGF("\t"); + } - DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf); + DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf); + } } - DEBUGF("\n"); - DEBUGF("Number of string tokens: %d\n", num_string_tokens); - DEBUGF("\n"); + if (wps_verbose_level > 0) + { + DEBUGF("\n"); + DEBUGF("Number of string tokens: %d\n", num_string_tokens); + DEBUGF("\n"); + } } static void print_line_info(struct wps_data *data) @@ -401,56 +403,67 @@ static void print_line_info(struct wps_data *data) struct wps_line *line; struct wps_subline *subline; - DEBUGF("Number of lines : %d\n", data->num_lines); - DEBUGF("Number of sublines: %d\n", data->num_sublines); - DEBUGF("Number of tokens : %d\n", data->num_tokens); - DEBUGF("\n"); - - for (i = 0, line = data->lines; i < data->num_lines; i++,line++) + if (wps_verbose_level > 0) { - DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n", - i, line->num_sublines, line->first_subline_idx); + DEBUGF("Number of lines : %d\n", data->num_lines); + DEBUGF("Number of sublines: %d\n", data->num_sublines); + DEBUGF("Number of tokens : %d\n", data->num_tokens); + DEBUGF("\n"); + } - for (j = 0, subline = data->sublines + line->first_subline_idx; - j < line->num_sublines; j++, subline++) + if (wps_verbose_level > 1) + { + for (i = 0, line = data->lines; i < data->num_lines; i++,line++) { - DEBUGF(" Subline %d: first_token=%3d, last_token=%3d", - j, subline->first_token_idx, - wps_last_token_index(data, i, j)); - - if (subline->line_type & WPS_REFRESH_SCROLL) - DEBUGF(", scrolled"); - else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS) - DEBUGF(", progressbar"); - else if (subline->line_type & WPS_REFRESH_PEAK_METER) - DEBUGF(", peakmeter"); - - DEBUGF("\n"); + DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n", + i, line->num_sublines, line->first_subline_idx); + + for (j = 0, subline = data->sublines + line->first_subline_idx; + j < line->num_sublines; j++, subline++) + { + DEBUGF(" Subline %d: first_token=%3d, last_token=%3d", + j, subline->first_token_idx, + wps_last_token_index(data, i, j)); + + if (subline->line_type & WPS_REFRESH_SCROLL) + DEBUGF(", scrolled"); + else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS) + DEBUGF(", progressbar"); + else if (subline->line_type & WPS_REFRESH_PEAK_METER) + DEBUGF(", peakmeter"); + + DEBUGF("\n"); + } } - } - DEBUGF("\n"); + DEBUGF("\n"); + } } static void print_wps_strings(struct wps_data *data) { int i, len, total_len = 0, buf_used = 0; - DEBUGF("Strings:\n"); + if (wps_verbose_level > 1) DEBUGF("Strings:\n"); for (i = 0; i < data->num_strings; i++) { len = strlen(data->strings[i]); total_len += len; buf_used += len + 1; - DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]); + if (wps_verbose_level > 1) + DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]); + } + if (wps_verbose_level > 1) DEBUGF("\n"); + + if (wps_verbose_level > 0) + { + DEBUGF("Number of unique strings: %d (max: %d)\n", + data->num_strings, WPS_MAX_STRINGS); + DEBUGF("Total string length: %d\n", total_len); + DEBUGF("String buffer used: %d out of %d bytes\n", + buf_used, STRING_BUFFER_SIZE); + DEBUGF("\n"); } - DEBUGF("\n"); - DEBUGF("Number of strings: %d out of an allowed %d\n", - data->num_strings, WPS_MAX_STRINGS); - DEBUGF("Total string length: %d\n", total_len); - DEBUGF("String buffer used: %d out of %d bytes\n", - buf_used, STRING_BUFFER_SIZE); - DEBUGF("\n"); } #ifdef HAVE_LCD_BITMAP @@ -470,17 +483,22 @@ static void print_img_cond_indexes(struct wps_data *data) void print_debug_info(struct wps_data *data, int fail, int line) { #if defined(SIMULATOR) || defined(__PCTOOL__) - if (debug_wps) + if (debug_wps && wps_verbose_level) { dump_wps_tokens(data); print_wps_strings(data); print_line_info(data); #ifdef HAVE_LCD_BITMAP - print_img_cond_indexes(data); + if (wps_verbose_level > 2) print_img_cond_indexes(data); #endif } #endif /* SIMULATOR */ + if (data->num_tokens >= WPS_MAX_TOKENS - 1) { + DEBUGF("Warning: Max number of tokens was reached (%d)\n", + WPS_MAX_TOKENS - 1); + } + if (fail) { DEBUGF("Failed parsing on line %d : ", line); diff --git a/tools/checkwps.c b/tools/checkwps.c index 74ce1e82be..950c341bfc 100644 --- a/tools/checkwps.c +++ b/tools/checkwps.c @@ -5,6 +5,7 @@ #define MIN(x,y) ((x) > (y) ? (y) : (x)) bool debug_wps = true; +int wps_verbose_level = 0; int read_bmp_file(char* filename, struct bitmap *bm, @@ -63,22 +64,36 @@ int main(int argc, char **argv) { int res; int fd; + int filearg = 1; struct wps_data wps; - if (argc != 2) { - printf("Usage: checkwps filename.wps\n"); + if (argc < 2) { + printf("Usage: checkwps [OPTIONS] filename.wps\n"); + printf("\nOPTIONS:\n"); + printf("\t-v\tverbose\n"); + printf("\t-vv\tmore verbose\n"); + printf("\t-vvv\tvery verbose\n"); return 1; } - fd = open(argv[1], O_RDONLY); + if (argv[1][0] == '-') { + filearg++; + int i = 1; + while (argv[1][i] && argv[1][i] == 'v') { + i++; + wps_verbose_level++; + } + } + + fd = open(argv[filearg], O_RDONLY); if (fd < 0) { printf("Failed to open %s\n",argv[1]); return 2; } close(fd); - res = wps_data_load(&wps, argv[1], true); + res = wps_data_load(&wps, argv[filearg], true); if (!res) { printf("WPS parsing failure\n"); diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c index bac11ff7a9..052fd4af83 100644 --- a/uisimulator/sdl/uisdl.c +++ b/uisimulator/sdl/uisdl.c @@ -56,6 +56,7 @@ char having_new_lcd = true; /* Used for player simulator */ bool debug_audio = false; bool debug_wps = false; +int wps_verbose_level = 3; long start_tick; -- cgit v1.2.3