summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-07-22 17:17:53 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-07-22 17:17:53 +0000
commit3213d4a0f5d3aea725bb9ddf34ae0ec38ca4b097 (patch)
treea7e386aef4624f453201aca9b5bf5ca8b38c3fd2
parentc897c241d9f085c8a8288183b62b3ea1d9e1796f (diff)
downloadrockbox-3213d4a0f5d3aea725bb9ddf34ae0ec38ca4b097.tar.gz
rockbox-3213d4a0f5d3aea725bb9ddf34ae0ec38ca4b097.zip
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
-rw-r--r--apps/gui/wps_debug.c112
-rw-r--r--tools/checkwps.c23
-rw-r--r--uisimulator/sdl/uisdl.c1
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 @@
34 34
35#if defined(SIMULATOR) || defined(__PCTOOL__) 35#if defined(SIMULATOR) || defined(__PCTOOL__)
36extern bool debug_wps; 36extern bool debug_wps;
37extern int wps_verbose_level;
37#endif 38#endif
38 39
39static char *next_str(bool next) { 40static char *next_str(bool next) {
@@ -49,11 +50,6 @@ static void dump_wps_tokens(struct wps_data *data)
49 bool next; 50 bool next;
50 int num_string_tokens = 0; 51 int num_string_tokens = 0;
51 52
52 if (data->num_tokens > WPS_MAX_TOKENS) {
53 DEBUGF("Number of tokens is too high (%d)!!!\n", data->num_tokens);
54 return;
55 }
56
57 /* Dump parsed WPS */ 53 /* Dump parsed WPS */
58 for (i = 0, token = data->tokens; i < data->num_tokens; i++, token++) { 54 for (i = 0, token = data->tokens; i < data->num_tokens; i++, token++) {
59 next = token->next; 55 next = token->next;
@@ -383,16 +379,22 @@ static void dump_wps_tokens(struct wps_data *data)
383 break; 379 break;
384 } 380 }
385 381
386 for(j = 0; j < indent; j++) { 382 if (wps_verbose_level > 2)
387 DEBUGF("\t"); 383 {
388 } 384 for(j = 0; j < indent; j++) {
385 DEBUGF("\t");
386 }
389 387
390 DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf); 388 DEBUGF("[%3d] = (%2d) %s\n", i, token->type, buf);
389 }
391 } 390 }
392 DEBUGF("\n");
393 391
394 DEBUGF("Number of string tokens: %d\n", num_string_tokens); 392 if (wps_verbose_level > 0)
395 DEBUGF("\n"); 393 {
394 DEBUGF("\n");
395 DEBUGF("Number of string tokens: %d\n", num_string_tokens);
396 DEBUGF("\n");
397 }
396} 398}
397 399
398static void print_line_info(struct wps_data *data) 400static void print_line_info(struct wps_data *data)
@@ -401,56 +403,67 @@ static void print_line_info(struct wps_data *data)
401 struct wps_line *line; 403 struct wps_line *line;
402 struct wps_subline *subline; 404 struct wps_subline *subline;
403 405
404 DEBUGF("Number of lines : %d\n", data->num_lines); 406 if (wps_verbose_level > 0)
405 DEBUGF("Number of sublines: %d\n", data->num_sublines);
406 DEBUGF("Number of tokens : %d\n", data->num_tokens);
407 DEBUGF("\n");
408
409 for (i = 0, line = data->lines; i < data->num_lines; i++,line++)
410 { 407 {
411 DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n", 408 DEBUGF("Number of lines : %d\n", data->num_lines);
412 i, line->num_sublines, line->first_subline_idx); 409 DEBUGF("Number of sublines: %d\n", data->num_sublines);
410 DEBUGF("Number of tokens : %d\n", data->num_tokens);
411 DEBUGF("\n");
412 }
413 413
414 for (j = 0, subline = data->sublines + line->first_subline_idx; 414 if (wps_verbose_level > 1)
415 j < line->num_sublines; j++, subline++) 415 {
416 for (i = 0, line = data->lines; i < data->num_lines; i++,line++)
416 { 417 {
417 DEBUGF(" Subline %d: first_token=%3d, last_token=%3d", 418 DEBUGF("Line %2d (num_sublines=%d, first_subline=%d)\n",
418 j, subline->first_token_idx, 419 i, line->num_sublines, line->first_subline_idx);
419 wps_last_token_index(data, i, j)); 420
420 421 for (j = 0, subline = data->sublines + line->first_subline_idx;
421 if (subline->line_type & WPS_REFRESH_SCROLL) 422 j < line->num_sublines; j++, subline++)
422 DEBUGF(", scrolled"); 423 {
423 else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS) 424 DEBUGF(" Subline %d: first_token=%3d, last_token=%3d",
424 DEBUGF(", progressbar"); 425 j, subline->first_token_idx,
425 else if (subline->line_type & WPS_REFRESH_PEAK_METER) 426 wps_last_token_index(data, i, j));
426 DEBUGF(", peakmeter"); 427
427 428 if (subline->line_type & WPS_REFRESH_SCROLL)
428 DEBUGF("\n"); 429 DEBUGF(", scrolled");
430 else if (subline->line_type & WPS_REFRESH_PLAYER_PROGRESS)
431 DEBUGF(", progressbar");
432 else if (subline->line_type & WPS_REFRESH_PEAK_METER)
433 DEBUGF(", peakmeter");
434
435 DEBUGF("\n");
436 }
429 } 437 }
430 }
431 438
432 DEBUGF("\n"); 439 DEBUGF("\n");
440 }
433} 441}
434 442
435static void print_wps_strings(struct wps_data *data) 443static void print_wps_strings(struct wps_data *data)
436{ 444{
437 int i, len, total_len = 0, buf_used = 0; 445 int i, len, total_len = 0, buf_used = 0;
438 446
439 DEBUGF("Strings:\n"); 447 if (wps_verbose_level > 1) DEBUGF("Strings:\n");
440 for (i = 0; i < data->num_strings; i++) 448 for (i = 0; i < data->num_strings; i++)
441 { 449 {
442 len = strlen(data->strings[i]); 450 len = strlen(data->strings[i]);
443 total_len += len; 451 total_len += len;
444 buf_used += len + 1; 452 buf_used += len + 1;
445 DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]); 453 if (wps_verbose_level > 1)
454 DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]);
455 }
456 if (wps_verbose_level > 1) DEBUGF("\n");
457
458 if (wps_verbose_level > 0)
459 {
460 DEBUGF("Number of unique strings: %d (max: %d)\n",
461 data->num_strings, WPS_MAX_STRINGS);
462 DEBUGF("Total string length: %d\n", total_len);
463 DEBUGF("String buffer used: %d out of %d bytes\n",
464 buf_used, STRING_BUFFER_SIZE);
465 DEBUGF("\n");
446 } 466 }
447 DEBUGF("\n");
448 DEBUGF("Number of strings: %d out of an allowed %d\n",
449 data->num_strings, WPS_MAX_STRINGS);
450 DEBUGF("Total string length: %d\n", total_len);
451 DEBUGF("String buffer used: %d out of %d bytes\n",
452 buf_used, STRING_BUFFER_SIZE);
453 DEBUGF("\n");
454} 467}
455 468
456#ifdef HAVE_LCD_BITMAP 469#ifdef HAVE_LCD_BITMAP
@@ -470,17 +483,22 @@ static void print_img_cond_indexes(struct wps_data *data)
470void print_debug_info(struct wps_data *data, int fail, int line) 483void print_debug_info(struct wps_data *data, int fail, int line)
471{ 484{
472#if defined(SIMULATOR) || defined(__PCTOOL__) 485#if defined(SIMULATOR) || defined(__PCTOOL__)
473 if (debug_wps) 486 if (debug_wps && wps_verbose_level)
474 { 487 {
475 dump_wps_tokens(data); 488 dump_wps_tokens(data);
476 print_wps_strings(data); 489 print_wps_strings(data);
477 print_line_info(data); 490 print_line_info(data);
478#ifdef HAVE_LCD_BITMAP 491#ifdef HAVE_LCD_BITMAP
479 print_img_cond_indexes(data); 492 if (wps_verbose_level > 2) print_img_cond_indexes(data);
480#endif 493#endif
481 } 494 }
482#endif /* SIMULATOR */ 495#endif /* SIMULATOR */
483 496
497 if (data->num_tokens >= WPS_MAX_TOKENS - 1) {
498 DEBUGF("Warning: Max number of tokens was reached (%d)\n",
499 WPS_MAX_TOKENS - 1);
500 }
501
484 if (fail) 502 if (fail)
485 { 503 {
486 DEBUGF("Failed parsing on line %d : ", line); 504 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 @@
5#define MIN(x,y) ((x) > (y) ? (y) : (x)) 5#define MIN(x,y) ((x) > (y) ? (y) : (x))
6 6
7bool debug_wps = true; 7bool debug_wps = true;
8int wps_verbose_level = 0;
8 9
9int read_bmp_file(char* filename, 10int read_bmp_file(char* filename,
10 struct bitmap *bm, 11 struct bitmap *bm,
@@ -63,22 +64,36 @@ int main(int argc, char **argv)
63{ 64{
64 int res; 65 int res;
65 int fd; 66 int fd;
67 int filearg = 1;
66 68
67 struct wps_data wps; 69 struct wps_data wps;
68 70
69 if (argc != 2) { 71 if (argc < 2) {
70 printf("Usage: checkwps filename.wps\n"); 72 printf("Usage: checkwps [OPTIONS] filename.wps\n");
73 printf("\nOPTIONS:\n");
74 printf("\t-v\tverbose\n");
75 printf("\t-vv\tmore verbose\n");
76 printf("\t-vvv\tvery verbose\n");
71 return 1; 77 return 1;
72 } 78 }
73 79
74 fd = open(argv[1], O_RDONLY); 80 if (argv[1][0] == '-') {
81 filearg++;
82 int i = 1;
83 while (argv[1][i] && argv[1][i] == 'v') {
84 i++;
85 wps_verbose_level++;
86 }
87 }
88
89 fd = open(argv[filearg], O_RDONLY);
75 if (fd < 0) { 90 if (fd < 0) {
76 printf("Failed to open %s\n",argv[1]); 91 printf("Failed to open %s\n",argv[1]);
77 return 2; 92 return 2;
78 } 93 }
79 close(fd); 94 close(fd);
80 95
81 res = wps_data_load(&wps, argv[1], true); 96 res = wps_data_load(&wps, argv[filearg], true);
82 97
83 if (!res) { 98 if (!res) {
84 printf("WPS parsing failure\n"); 99 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 */
56bool debug_audio = false; 56bool debug_audio = false;
57 57
58bool debug_wps = false; 58bool debug_wps = false;
59int wps_verbose_level = 3;
59 60
60long start_tick; 61long start_tick;
61 62