summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-04-26 09:30:24 +0000
committerNils Wallménius <nils@rockbox.org>2008-04-26 09:30:24 +0000
commit33c44461e1b5fb9aff2f8ba7470ad2449b3c410e (patch)
tree4dac157ab03a45868ba75e07af9fb92766fa4ccd
parente1bc2d5b71bd424325e852b0ef9a89252dac1471 (diff)
downloadrockbox-33c44461e1b5fb9aff2f8ba7470ad2449b3c410e.tar.gz
rockbox-33c44461e1b5fb9aff2f8ba7470ad2449b3c410e.zip
Const police raid, making a lot of pointers to lang strings const and removing some ugly casting
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17251 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/bookmark.c8
-rw-r--r--apps/filetree.c6
-rw-r--r--apps/gui/textarea.c4
-rw-r--r--apps/gui/textarea.h6
-rw-r--r--apps/gui/yesno.c14
-rw-r--r--apps/gui/yesno.h10
-rw-r--r--apps/menus/main_menu.c17
-rw-r--r--apps/misc.c6
-rw-r--r--apps/onplay.c12
-rw-r--r--apps/playlist_catalog.c8
-rw-r--r--apps/recorder/radio.c6
-rw-r--r--apps/root_menu.c5
-rw-r--r--apps/screens.c4
-rw-r--r--apps/tagtree.c4
-rw-r--r--apps/tree.c4
15 files changed, 58 insertions, 56 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 30102bb954..13c9abe936 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -187,12 +187,12 @@ bool bookmark_autobookmark(void)
187 return write_bookmark(false); 187 return write_bookmark(false);
188 } 188 }
189#ifdef HAVE_LCD_BITMAP 189#ifdef HAVE_LCD_BITMAP
190 unsigned char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY)}; 190 const char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY)};
191 struct text_message message={(char **)lines, 1}; 191 const struct text_message message={lines, 1};
192#else 192#else
193 unsigned char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY), 193 const char *lines[]={ID2P(LANG_AUTO_BOOKMARK_QUERY),
194 str(LANG_CONFIRM_WITH_BUTTON)}; 194 str(LANG_CONFIRM_WITH_BUTTON)};
195 struct text_message message={(char **)lines, 2}; 195 const struct text_message message={lines, 2};
196#endif 196#endif
197#if LCD_DEPTH > 1 197#if LCD_DEPTH > 1
198 show_main_backdrop(); /* switch to main backdrop as we may come from wps */ 198 show_main_backdrop(); /* switch to main backdrop as we may come from wps */
diff --git a/apps/filetree.c b/apps/filetree.c
index e8fb459d52..cac2c79034 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -104,7 +104,7 @@ bool ft_play_playlist(char* pathname, char* dirname, char* filename)
104 if (global_settings.warnon_erase_dynplaylist && 104 if (global_settings.warnon_erase_dynplaylist &&
105 playlist_modified(NULL)) 105 playlist_modified(NULL))
106 { 106 {
107 char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; 107 const char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
108 struct text_message message = {lines, 1}; 108 struct text_message message = {lines, 1};
109 109
110 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) 110 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
@@ -408,8 +408,8 @@ int ft_enter(struct tree_context* c)
408 !global_settings.party_mode && 408 !global_settings.party_mode &&
409 playlist_modified(NULL)) 409 playlist_modified(NULL))
410 { 410 {
411 char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; 411 static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
412 struct text_message message={lines, 1}; 412 static const struct text_message message={lines, 1};
413 413
414 if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) 414 if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
415 break; 415 break;
diff --git a/apps/gui/textarea.c b/apps/gui/textarea.c
index b30667df4e..dcffd0e621 100644
--- a/apps/gui/textarea.c
+++ b/apps/gui/textarea.c
@@ -47,7 +47,7 @@ void gui_textarea_update(struct screen * display)
47} 47}
48 48
49int gui_textarea_put_message(struct screen * display, 49int gui_textarea_put_message(struct screen * display,
50 struct text_message * message, 50 const struct text_message * message,
51 int ystart) 51 int ystart)
52{ 52{
53 int i; 53 int i;
@@ -78,7 +78,7 @@ void gui_textarea_update_nblines(struct screen * display)
78 display->nb_lines = height / display->char_height; 78 display->nb_lines = height / display->char_height;
79} 79}
80 80
81void talk_text_message(struct text_message * message, bool enqueue) 81void talk_text_message(const struct text_message * message, bool enqueue)
82{ 82{
83 int line; 83 int line;
84 if(message) 84 if(message)
diff --git a/apps/gui/textarea.h b/apps/gui/textarea.h
index 765add084a..3f16dd440c 100644
--- a/apps/gui/textarea.h
+++ b/apps/gui/textarea.h
@@ -25,7 +25,7 @@
25 25
26struct text_message 26struct text_message
27{ 27{
28 char **message_lines; 28 const char **message_lines;
29 int nb_lines; 29 int nb_lines;
30}; 30};
31 31
@@ -50,7 +50,7 @@ extern void gui_textarea_update(struct screen * display);
50 * returns : the number of lines effectively displayed 50 * returns : the number of lines effectively displayed
51 */ 51 */
52extern int gui_textarea_put_message(struct screen * display, 52extern int gui_textarea_put_message(struct screen * display,
53 struct text_message * message, 53 const struct text_message * message,
54 int ystart); 54 int ystart);
55/* 55/*
56 * Compute the number of text lines the display can draw with the current font 56 * Compute the number of text lines the display can draw with the current font
@@ -63,7 +63,7 @@ extern void gui_textarea_update_nblines(struct screen * display);
63 * Speak a text_message. The message's lines may be virtual pointers 63 * Speak a text_message. The message's lines may be virtual pointers
64 * representing language / voicefont IDs (see settings.h). 64 * representing language / voicefont IDs (see settings.h).
65 */ 65 */
66extern void talk_text_message(struct text_message * message, bool enqueue); 66extern void talk_text_message(const struct text_message * message, bool enqueue);
67 67
68#ifdef HAVE_LCD_BITMAP 68#ifdef HAVE_LCD_BITMAP
69/* 69/*
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c
index 891e73809b..51a1eabd60 100644
--- a/apps/gui/yesno.c
+++ b/apps/gui/yesno.c
@@ -33,9 +33,9 @@
33 * - no_message : message displayed if answer is 'no' 33 * - no_message : message displayed if answer is 'no'
34 */ 34 */
35static void gui_yesno_init(struct gui_yesno * yn, 35static void gui_yesno_init(struct gui_yesno * yn,
36 struct text_message * main_message, 36 const struct text_message * main_message,
37 struct text_message * yes_message, 37 const struct text_message * yes_message,
38 struct text_message * no_message) 38 const struct text_message * no_message)
39{ 39{
40 yn->main_message=main_message; 40 yn->main_message=main_message;
41 yn->result_message[YESNO_YES]=yes_message; 41 yn->result_message[YESNO_YES]=yes_message;
@@ -92,7 +92,7 @@ static void gui_yesno_draw(struct gui_yesno * yn)
92 */ 92 */
93static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) 93static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
94{ 94{
95 struct text_message * message=yn->result_message[result]; 95 const struct text_message * message=yn->result_message[result];
96 if(message==NULL) 96 if(message==NULL)
97 return false; 97 return false;
98 gui_textarea_put_message(yn->display, message, 0); 98 gui_textarea_put_message(yn->display, message, 0);
@@ -101,9 +101,9 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
101 101
102#include "debug.h" 102#include "debug.h"
103 103
104enum yesno_res gui_syncyesno_run(struct text_message * main_message, 104enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
105 struct text_message * yes_message, 105 const struct text_message * yes_message,
106 struct text_message * no_message) 106 const struct text_message * no_message)
107{ 107{
108 int i; 108 int i;
109 unsigned button; 109 unsigned button;
diff --git a/apps/gui/yesno.h b/apps/gui/yesno.h
index 67456cf69b..b57ee89d48 100644
--- a/apps/gui/yesno.h
+++ b/apps/gui/yesno.h
@@ -32,8 +32,8 @@ enum yesno_res
32 32
33struct gui_yesno 33struct gui_yesno
34{ 34{
35 struct text_message * main_message; 35 const struct text_message * main_message;
36 struct text_message * result_message[2]; 36 const struct text_message * result_message[2];
37 37
38 struct screen * display; 38 struct screen * display;
39}; 39};
@@ -47,7 +47,7 @@ struct gui_yesno
47 * - no_message : message displayed if answer is 'no' 47 * - no_message : message displayed if answer is 'no'
48 */ 48 */
49extern enum yesno_res gui_syncyesno_run( 49extern enum yesno_res gui_syncyesno_run(
50 struct text_message * main_message, 50 const struct text_message * main_message,
51 struct text_message * yes_message, 51 const struct text_message * yes_message,
52 struct text_message * no_message); 52 const struct text_message * no_message);
53#endif /* _GUI_YESNO_H_ */ 53#endif /* _GUI_YESNO_H_ */
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index 8e4ee61aee..57db13f52c 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -55,15 +55,18 @@ static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG};
55 55
56static int reset_settings(void) 56static int reset_settings(void)
57{ 57{
58 const unsigned char *lines[]={ID2P(LANG_RESET_ASK)}; 58 static const char *lines[]={ID2P(LANG_RESET_ASK)};
59 const unsigned char *yes_lines[]={ 59 static const char *yes_lines[]={
60 str(LANG_SETTINGS), 60 ID2P(LANG_SETTINGS),
61 ID2P(LANG_RESET_DONE_CLEAR) 61 ID2P(LANG_RESET_DONE_CLEAR)
62 }; 62 };
63 const unsigned char *no_lines[]={yes_lines[0], ID2P(LANG_CANCEL)}; 63 static const char *no_lines[]={
64 struct text_message message={(char **)lines, 1}; 64 ID2P(LANG_SETTINGS),
65 struct text_message yes_message={(char **)yes_lines, 2}; 65 ID2P(LANG_CANCEL)
66 struct text_message no_message={(char **)no_lines, 2}; 66 };
67 static const struct text_message message={lines, 1};
68 static const struct text_message yes_message={yes_lines, 2};
69 static const struct text_message no_message={no_lines, 2};
67 70
68 switch(gui_syncyesno_run(&message, &yes_message, &no_message)) 71 switch(gui_syncyesno_run(&message, &yes_message, &no_message))
69 { 72 {
diff --git a/apps/misc.c b/apps/misc.c
index f6e5e6b880..ef4f968119 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1050,9 +1050,9 @@ void check_bootfile(bool do_rolo)
1050 if((entry->wrtdate != wrtdate) || 1050 if((entry->wrtdate != wrtdate) ||
1051 (entry->wrttime != wrttime)) 1051 (entry->wrttime != wrttime))
1052 { 1052 {
1053 char *lines[] = { ID2P(LANG_BOOT_CHANGED), 1053 static const char *lines[] = { ID2P(LANG_BOOT_CHANGED),
1054 ID2P(LANG_REBOOT_NOW) }; 1054 ID2P(LANG_REBOOT_NOW) };
1055 struct text_message message={ lines, 2 }; 1055 static const struct text_message message={ lines, 2 };
1056 button_clear_queue(); /* Empty the keyboard buffer */ 1056 button_clear_queue(); /* Empty the keyboard buffer */
1057 if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES) 1057 if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES)
1058 rolo_load(BOOTDIR "/" BOOTFILE); 1058 rolo_load(BOOTDIR "/" BOOTFILE);
diff --git a/apps/onplay.c b/apps/onplay.c
index 21b16c9381..a0de6f2e81 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -160,11 +160,11 @@ static bool save_playlist(void)
160static bool add_to_playlist(int position, bool queue) 160static bool add_to_playlist(int position, bool queue)
161{ 161{
162 bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY); 162 bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY);
163 char *lines[] = { 163 const char *lines[] = {
164 ID2P(LANG_RECURSE_DIRECTORY_QUESTION), 164 ID2P(LANG_RECURSE_DIRECTORY_QUESTION),
165 selected_file 165 selected_file
166 }; 166 };
167 struct text_message message={lines, 2}; 167 const struct text_message message={lines, 2};
168 168
169 gui_syncsplash(0, ID2P(LANG_WAIT)); 169 gui_syncsplash(0, ID2P(LANG_WAIT));
170 170
@@ -523,11 +523,11 @@ static int remove_dir(char* dirname, int len)
523/* share code for file and directory deletion, saves space */ 523/* share code for file and directory deletion, saves space */
524static bool delete_handler(bool is_dir) 524static bool delete_handler(bool is_dir)
525{ 525{
526 char *lines[]={ 526 const char *lines[]={
527 ID2P(LANG_REALLY_DELETE), 527 ID2P(LANG_REALLY_DELETE),
528 selected_file 528 selected_file
529 }; 529 };
530 char *yes_lines[]={ 530 const char *yes_lines[]={
531 ID2P(LANG_DELETED), 531 ID2P(LANG_DELETED),
532 selected_file 532 selected_file
533 }; 533 };
@@ -867,8 +867,8 @@ static bool clipboard_paste(void)
867 char *cwd, *nameptr; 867 char *cwd, *nameptr;
868 bool success; 868 bool success;
869 869
870 unsigned char *lines[]={ID2P(LANG_REALLY_OVERWRITE)}; 870 static const char *lines[]={ID2P(LANG_REALLY_OVERWRITE)};
871 struct text_message message={(char **)lines, 1}; 871 static const struct text_message message={lines, 1};
872 872
873 /* Get the name of the current directory */ 873 /* Get the name of the current directory */
874 cwd = getcwd(NULL, 0); 874 cwd = getcwd(NULL, 0);
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 9ac9e32e00..2b5020f7f3 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -378,11 +378,9 @@ static int add_to_playlist(const char* playlist, char* sel, int sel_attr)
378 { 378 {
379 /* search directory for tracks and append to playlist */ 379 /* search directory for tracks and append to playlist */
380 bool recurse = false; 380 bool recurse = false;
381 char *lines[] = { 381 const char *lines[] = {
382 (char *)str(LANG_RECURSE_DIRECTORY_QUESTION), 382 str(LANG_RECURSE_DIRECTORY_QUESTION), sel};
383 sel 383 const struct text_message message={lines, 2};
384 };
385 struct text_message message={lines, 2};
386 struct add_track_context context; 384 struct add_track_context context;
387 385
388 if (global_settings.recursive_dir_insert != RECURSE_ASK) 386 if (global_settings.recursive_dir_insert != RECURSE_ASK)
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index e103c6bc82..522f1dac93 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -136,11 +136,11 @@ static int scan_presets(void);
136 136
137/* Function to manipulate all yesno dialogues. 137/* Function to manipulate all yesno dialogues.
138 This function needs the output text as an argument. */ 138 This function needs the output text as an argument. */
139static bool yesno_pop(char* text) 139static bool yesno_pop(const char* text)
140{ 140{
141 int i; 141 int i;
142 char *lines[]={text}; 142 const char *lines[]={text};
143 struct text_message message={lines, 1}; 143 const struct text_message message={lines, 1};
144 bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES); 144 bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES);
145 FOR_NB_SCREENS(i) 145 FOR_NB_SCREENS(i)
146 gui_textarea_clear(&screens[i]); 146 gui_textarea_clear(&screens[i]);
diff --git a/apps/root_menu.c b/apps/root_menu.c
index dcbd95c23f..378b776b81 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -143,8 +143,9 @@ static int browser(void* param)
143 { 143 {
144 /* Prompt the user */ 144 /* Prompt the user */
145 reinit_attempted = true; 145 reinit_attempted = true;
146 char *lines[]={ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)}; 146 static const char *lines[]={
147 struct text_message message={lines, 2}; 147 ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)};
148 static const struct text_message message={lines, 2};
148 if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO) 149 if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO)
149 break; 150 break;
150 int i; 151 int i;
diff --git a/apps/screens.c b/apps/screens.c
index 569ece4faa..0855b12002 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1270,8 +1270,8 @@ static int runtime_speak_data(int selected_item, void* data)
1270 1270
1271bool view_runtime(void) 1271bool view_runtime(void)
1272{ 1272{
1273 unsigned char *lines[]={ID2P(LANG_CLEAR_TIME)}; 1273 static const char *lines[]={ID2P(LANG_CLEAR_TIME)};
1274 struct text_message message={(char **)lines, 1}; 1274 static const struct text_message message={lines, 1};
1275 1275
1276 struct gui_synclist lists; 1276 struct gui_synclist lists;
1277 int action; 1277 int action;
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 50921d0baf..f9646a0b00 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1501,8 +1501,8 @@ int tagtree_enter(struct tree_context* c)
1501 !global_settings.party_mode && 1501 !global_settings.party_mode &&
1502 playlist_modified(NULL)) 1502 playlist_modified(NULL))
1503 { 1503 {
1504 char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; 1504 static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
1505 struct text_message message={lines, 1}; 1505 static const struct text_message message={lines, 1};
1506 1506
1507 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) 1507 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
1508 break; 1508 break;
diff --git a/apps/tree.c b/apps/tree.c
index 275eb6ad2d..d1d9adb3b2 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -645,8 +645,8 @@ static int dirbrowse()
645 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ 645 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
646#ifdef BOOTFILE 646#ifdef BOOTFILE
647 if (boot_changed) { 647 if (boot_changed) {
648 char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)}; 648 static const char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)};
649 struct text_message message={lines, 2}; 649 static const struct text_message message={lines, 2};
650 if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) 650 if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
651 rolo_load("/" BOOTFILE); 651 rolo_load("/" BOOTFILE);
652 restore = true; 652 restore = true;