summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/alpine_cdc.c10
-rw-r--r--apps/plugins/battery_bench.c4
-rw-r--r--apps/plugins/beatbox/beatbox.c4
-rw-r--r--apps/plugins/blackjack.c5
-rw-r--r--apps/plugins/bounce.c4
-rw-r--r--apps/plugins/brickmania.c4
-rw-r--r--apps/plugins/bubbles.c4
-rw-r--r--apps/plugins/calculator.c4
-rw-r--r--apps/plugins/calendar.c4
-rw-r--r--apps/plugins/chessbox.c2
-rw-r--r--apps/plugins/chessbox/chessbox.c2
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.c16
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.h14
-rw-r--r--apps/plugins/chessbox/gnuchess.c2
-rw-r--r--apps/plugins/chessbox/gnuchess.h2
-rw-r--r--apps/plugins/chessclock.c4
-rw-r--r--apps/plugins/chip8.c20
-rw-r--r--apps/plugins/chopper.c4
-rw-r--r--apps/plugins/clock/clock.c4
-rw-r--r--apps/plugins/clock/clock.h2
-rw-r--r--apps/plugins/credits.c4
-rw-r--r--apps/plugins/cube.c4
-rw-r--r--apps/plugins/demystify.c4
-rw-r--r--apps/plugins/dice.c4
-rw-r--r--apps/plugins/dict.c4
-rw-r--r--apps/plugins/disktidy.c4
-rw-r--r--apps/plugins/doom/rockdoom.c4
-rw-r--r--apps/plugins/doom/rockmacros.h2
-rw-r--r--apps/plugins/euroconverter.c4
-rw-r--r--apps/plugins/fire.c4
-rw-r--r--apps/plugins/fireworks.c4
-rw-r--r--apps/plugins/firmware_flash.c4
-rw-r--r--apps/plugins/flipit.c4
-rw-r--r--apps/plugins/greyscale.c4
-rw-r--r--apps/plugins/helloworld.c4
-rw-r--r--apps/plugins/invadrox.c4
-rw-r--r--apps/plugins/iriver_flash.c4
-rw-r--r--apps/plugins/iriverify.c4
-rw-r--r--apps/plugins/jackpot.c4
-rw-r--r--apps/plugins/jewels.c4
-rw-r--r--apps/plugins/jpeg.c4
-rw-r--r--apps/plugins/lamp.c4
-rw-r--r--apps/plugins/lib/bmp.c2
-rw-r--r--apps/plugins/lib/bmp.h2
-rw-r--r--apps/plugins/lib/checkbox.c2
-rw-r--r--apps/plugins/lib/checkbox.h2
-rw-r--r--apps/plugins/lib/configfile.c4
-rw-r--r--apps/plugins/lib/configfile.h2
-rw-r--r--apps/plugins/lib/grey.h22
-rw-r--r--apps/plugins/lib/grey_core.c2
-rw-r--r--apps/plugins/lib/helper.c12
-rw-r--r--apps/plugins/lib/helper.h12
-rw-r--r--apps/plugins/lib/highscore.c4
-rw-r--r--apps/plugins/lib/highscore.h2
-rw-r--r--apps/plugins/lib/oldmenuapi.c4
-rw-r--r--apps/plugins/lib/oldmenuapi.h2
-rw-r--r--apps/plugins/lib/overlay.c2
-rw-r--r--apps/plugins/lib/overlay.h2
-rw-r--r--apps/plugins/lib/playback_control.c6
-rw-r--r--apps/plugins/lib/playback_control.h4
-rw-r--r--apps/plugins/lib/playergfx.c4
-rw-r--r--apps/plugins/lib/playergfx.h2
-rw-r--r--apps/plugins/lib/pluginlib_actions.c2
-rw-r--r--apps/plugins/lib/pluginlib_actions.h2
-rw-r--r--apps/plugins/lib/profile_plugin.c4
-rw-r--r--apps/plugins/lib/profile_plugin.h2
-rw-r--r--apps/plugins/lib/xlcd.h4
-rw-r--r--apps/plugins/lib/xlcd_core.c4
-rw-r--r--apps/plugins/logo.c4
-rw-r--r--apps/plugins/mandelbrot.c4
-rw-r--r--apps/plugins/matrix.c4
-rw-r--r--apps/plugins/maze.c4
-rw-r--r--apps/plugins/mazezam.c4
-rw-r--r--apps/plugins/metronome.c4
-rw-r--r--apps/plugins/midi/midifile.c2
-rw-r--r--apps/plugins/midi/midifile.h2
-rw-r--r--apps/plugins/midi/midiplay.c8
-rw-r--r--apps/plugins/midi2wav.c10
-rw-r--r--apps/plugins/minesweeper.c4
-rw-r--r--apps/plugins/mosaique.c4
-rw-r--r--apps/plugins/mp3_encoder.c8
-rw-r--r--apps/plugins/mpegplayer/decode.c2
-rw-r--r--apps/plugins/mpegplayer/header.c2
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c4
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.h2
-rw-r--r--apps/plugins/nim.c4
-rw-r--r--apps/plugins/oscilloscope.c4
-rw-r--r--apps/plugins/pacbox/arcade.c2
-rw-r--r--apps/plugins/pacbox/hardware.c2
-rw-r--r--apps/plugins/pacbox/pacbox.c4
-rw-r--r--apps/plugins/pegbox.c4
-rw-r--r--apps/plugins/pictureflow.c4
-rw-r--r--apps/plugins/plasma.c4
-rw-r--r--apps/plugins/pong.c4
-rw-r--r--apps/plugins/properties.c16
-rw-r--r--apps/plugins/random_folder_advance_config.c4
-rw-r--r--apps/plugins/reversi/reversi-game.h2
-rw-r--r--apps/plugins/reversi/reversi-gui.c4
-rw-r--r--apps/plugins/robotfindskitten.c4
-rw-r--r--apps/plugins/rockblox.c4
-rw-r--r--apps/plugins/rockbox_flash.c4
-rw-r--r--apps/plugins/rockboy.c2
-rw-r--r--apps/plugins/rockboy/loader.c4
-rw-r--r--apps/plugins/rockboy/loader.h2
-rw-r--r--apps/plugins/rockboy/rockboy.c6
-rw-r--r--apps/plugins/rockboy/rockmacros.h2
-rw-r--r--apps/plugins/rocklife.c4
-rw-r--r--apps/plugins/rockpaint.c8
-rw-r--r--apps/plugins/search.c8
-rw-r--r--apps/plugins/searchengine/searchengine.c4
-rw-r--r--apps/plugins/searchengine/searchengine.h2
-rw-r--r--apps/plugins/shortcuts/shortcuts.h2
-rw-r--r--apps/plugins/shortcuts/shortcuts_append.c2
-rw-r--r--apps/plugins/shortcuts/shortcuts_view.c2
-rw-r--r--apps/plugins/sliding_puzzle.c4
-rw-r--r--apps/plugins/snake.c4
-rw-r--r--apps/plugins/snake2.c4
-rw-r--r--apps/plugins/snow.c4
-rw-r--r--apps/plugins/sokoban.c4
-rw-r--r--apps/plugins/solitaire.c4
-rw-r--r--apps/plugins/sort.c4
-rw-r--r--apps/plugins/spacerocks.c4
-rw-r--r--apps/plugins/splitedit.c4
-rw-r--r--apps/plugins/star.c4
-rw-r--r--apps/plugins/starfield.c6
-rw-r--r--apps/plugins/stats.c4
-rw-r--r--apps/plugins/stopwatch.c4
-rw-r--r--apps/plugins/sudoku/generator.c2
-rw-r--r--apps/plugins/sudoku/sudoku.c4
-rw-r--r--apps/plugins/superdom.c6
-rw-r--r--apps/plugins/test_codec.c4
-rw-r--r--apps/plugins/test_disk.c4
-rw-r--r--apps/plugins/test_fps.c4
-rw-r--r--apps/plugins/test_grey.c4
-rw-r--r--apps/plugins/test_resize.c4
-rw-r--r--apps/plugins/test_sampr.c4
-rw-r--r--apps/plugins/test_scanrate.c4
-rw-r--r--apps/plugins/test_touchpad.c4
-rw-r--r--apps/plugins/test_viewports.c6
-rw-r--r--apps/plugins/text_editor.c6
-rw-r--r--apps/plugins/vbrfix.c8
-rw-r--r--apps/plugins/video.c4
-rw-r--r--apps/plugins/viewer.c6
-rw-r--r--apps/plugins/vu_meter.c2
-rw-r--r--apps/plugins/wav2wv.c38
-rw-r--r--apps/plugins/wavplay.c4
-rw-r--r--apps/plugins/wavrecord.c4
-rw-r--r--apps/plugins/wavview.c6
-rw-r--r--apps/plugins/wormlet.c4
-rw-r--r--apps/plugins/xobox.c4
-rw-r--r--apps/plugins/zxbox.c2
-rw-r--r--apps/plugins/zxbox/spconf.c2
-rw-r--r--apps/plugins/zxbox/spconf.h2
-rw-r--r--apps/plugins/zxbox/spmain.c8
-rw-r--r--apps/plugins/zxbox/spmain.h4
-rw-r--r--apps/plugins/zxbox/zxbox.c4
-rw-r--r--apps/plugins/zxbox/zxconfig.h2
157 files changed, 355 insertions, 362 deletions
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index 89fc8401ac..6f921e3af8 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -133,8 +133,8 @@ void sound_neutral(void); /* set to everything flat and 0 dB volume */
133void sound_normal(void); /* return to user settings */ 133void sound_normal(void); /* return to user settings */
134 134
135void thread(void); /* the thread running it all */ 135void thread(void); /* the thread running it all */
136int main(void* parameter); /* main loop */ 136int main(const void* parameter); /* main loop */
137enum plugin_status plugin_start(struct plugin_api* api, void* parameter); /* entry */ 137enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter); /* entry */
138 138
139 139
140/****************** data types ******************/ 140/****************** data types ******************/
@@ -207,7 +207,7 @@ struct
207 struct thread_entry *thread; /* worker thread id */ 207 struct thread_entry *thread; /* worker thread id */
208} gTread; 208} gTread;
209 209
210static struct plugin_api* rb; /* here is the global API struct pointer */ 210static const struct plugin_api* rb; /* here is the global API struct pointer */
211 211
212 212
213/****************** implementation ******************/ 213/****************** implementation ******************/
@@ -1133,7 +1133,7 @@ bool exit_tsr(bool reenter)
1133/****************** main ******************/ 1133/****************** main ******************/
1134 1134
1135 1135
1136int main(void* parameter) 1136int main(const void* parameter)
1137{ 1137{
1138 (void)parameter; 1138 (void)parameter;
1139#ifdef DEBUG 1139#ifdef DEBUG
@@ -1189,7 +1189,7 @@ int main(void* parameter)
1189/***************** Plugin Entry Point *****************/ 1189/***************** Plugin Entry Point *****************/
1190 1190
1191 1191
1192enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1192enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1193{ 1193{
1194 rb = api; /* copy to global api pointer */ 1194 rb = api; /* copy to global api pointer */
1195 1195
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index e2f76062c6..de92c91fa3 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -169,14 +169,14 @@ PLUGIN_HEADER
169#endif 169#endif
170 170
171/****************************** Plugin Entry Point ****************************/ 171/****************************** Plugin Entry Point ****************************/
172static struct plugin_api* rb; 172static const struct plugin_api* rb;
173MEM_FUNCTION_WRAPPERS(rb); 173MEM_FUNCTION_WRAPPERS(rb);
174int main(void); 174int main(void);
175bool exit_tsr(bool); 175bool exit_tsr(bool);
176void thread(void); 176void thread(void);
177 177
178 178
179enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 179enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
180{ 180{
181 (void)parameter; 181 (void)parameter;
182 rb = api; 182 rb = api;
diff --git a/apps/plugins/beatbox/beatbox.c b/apps/plugins/beatbox/beatbox.c
index e24c8e7d0c..7cc7c167f9 100644
--- a/apps/plugins/beatbox/beatbox.c
+++ b/apps/plugins/beatbox/beatbox.c
@@ -178,7 +178,7 @@ const unsigned char * drumNames[]={
178long gmbuf[BUF_SIZE*NBUF]; 178long gmbuf[BUF_SIZE*NBUF];
179 179
180int quit=0; 180int quit=0;
181struct plugin_api * rb; 181const struct plugin_api * rb;
182 182
183 183
184#define STATE_STOPPED 0 184#define STATE_STOPPED 0
@@ -232,7 +232,7 @@ int editState=EDITSTATE_PATTERN;
232int playState=STATE_STOPPED, stepFlag=0; 232int playState=STATE_STOPPED, stepFlag=0;
233 233
234 234
235enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 235enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
236{ 236{
237 int retval = 0; 237 int retval = 0;
238 238
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index c3d4926683..a23a833128 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -313,7 +313,7 @@ extern const fb_data card_back[];
313#define NEXT_CARD bj->player_cards[done][bj->num_player_cards[done]] 313#define NEXT_CARD bj->player_cards[done][bj->num_player_cards[done]]
314 314
315/* global rockbox api */ 315/* global rockbox api */
316static struct plugin_api* rb; 316static const struct plugin_api* rb;
317 317
318MEM_FUNCTION_WRAPPERS(rb); 318MEM_FUNCTION_WRAPPERS(rb);
319 319
@@ -1529,7 +1529,8 @@ static int blackjack(struct game_context* bj) {
1529/***************************************************************************** 1529/*****************************************************************************
1530* plugin entry point. 1530* plugin entry point.
1531******************************************************************************/ 1531******************************************************************************/
1532enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 1532enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1533{
1533 struct game_context bj; 1534 struct game_context bj;
1534 bool exit = false; 1535 bool exit = false;
1535 unsigned int position; 1536 unsigned int position;
diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c
index c8a40dec4a..7ad73f6aa4 100644
--- a/apps/plugins/bounce.c
+++ b/apps/plugins/bounce.c
@@ -167,7 +167,7 @@ PLUGIN_HEADER
167#endif 167#endif
168#endif 168#endif
169 169
170static struct plugin_api* rb; 170static const struct plugin_api* rb;
171 171
172#define LETTER_WIDTH 11 172#define LETTER_WIDTH 11
173#define LETTER_HEIGHT 16 173#define LETTER_HEIGHT 16
@@ -573,7 +573,7 @@ static int loopit(void)
573} 573}
574 574
575 575
576enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 576enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
577{ 577{
578 int w, h; 578 int w, h;
579 char *off = "[Off] to stop"; 579 char *off = "[Off] to stop";
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index f0059ba633..756b4de0ec 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -195,7 +195,7 @@ PLUGIN_HEADER
195#endif 195#endif
196 196
197 197
198static struct plugin_api* rb; 198static const struct plugin_api* rb;
199 199
200enum menu_items { 200enum menu_items {
201 BM_START, 201 BM_START,
@@ -2015,7 +2015,7 @@ int game_loop(void)
2015} 2015}
2016 2016
2017/* this is the plugin entry point */ 2017/* this is the plugin entry point */
2018enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2018enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
2019{ 2019{
2020 (void)parameter; 2020 (void)parameter;
2021 rb = api; 2021 rb = api;
diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c
index bc76c15962..32e921338f 100644
--- a/apps/plugins/bubbles.c
+++ b/apps/plugins/bubbles.c
@@ -192,7 +192,7 @@ PLUGIN_HEADER
192#define MIN_DISTANCE ((BUBBLE_WIDTH*8)/10)*((BUBBLE_HEIGHT*8)/10) 192#define MIN_DISTANCE ((BUBBLE_WIDTH*8)/10)*((BUBBLE_HEIGHT*8)/10)
193 193
194/* global rockbox api */ 194/* global rockbox api */
195static struct plugin_api* rb; 195static const struct plugin_api* rb;
196 196
197/* levels */ 197/* levels */
198char level[NUM_LEVELS][BB_LEVEL_HEIGHT][BB_WIDTH] = { 198char level[NUM_LEVELS][BB_LEVEL_HEIGHT][BB_WIDTH] = {
@@ -2585,7 +2585,7 @@ static int bubbles(struct game_context* bb) {
2585/***************************************************************************** 2585/*****************************************************************************
2586* plugin entry point. 2586* plugin entry point.
2587******************************************************************************/ 2587******************************************************************************/
2588enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 2588enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
2589 struct game_context bb; 2589 struct game_context bb;
2590 bool exit = false; 2590 bool exit = false;
2591 int position; 2591 int position;
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 89bec041c9..47facaadf4 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -290,7 +290,7 @@ PLUGIN_HEADER
290#endif 290#endif
291#endif 291#endif
292 292
293static struct plugin_api* rb; 293static const struct plugin_api* rb;
294MEM_FUNCTION_WRAPPERS(rb); 294MEM_FUNCTION_WRAPPERS(rb);
295 295
296enum { 296enum {
@@ -1536,7 +1536,7 @@ void sciButtonsProcess(void){
1536/* ----------------------------------------------------------------------- 1536/* -----------------------------------------------------------------------
1537Main(); 1537Main();
1538----------------------------------------------------------------------- */ 1538----------------------------------------------------------------------- */
1539enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1539enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1540{ 1540{
1541 (void)parameter; 1541 (void)parameter;
1542 rb = api; 1542 rb = api;
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index 8798406b2e..70ca2b4b17 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -25,7 +25,7 @@
25 25
26PLUGIN_HEADER 26PLUGIN_HEADER
27 27
28static struct plugin_api* rb; 28static const struct plugin_api* rb;
29 29
30static bool leap_year; 30static bool leap_year;
31static int days_in_month[2][13] = { 31static int days_in_month[2][13] = {
@@ -659,7 +659,7 @@ static void prev_day(struct shown *shown, int step)
659 draw_calendar(shown); 659 draw_calendar(shown);
660} 660}
661 661
662enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 662enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
663{ 663{
664 struct today today; 664 struct today today;
665 struct shown shown; 665 struct shown shown;
diff --git a/apps/plugins/chessbox.c b/apps/plugins/chessbox.c
index fc3b703b2c..e6fca80a70 100644
--- a/apps/plugins/chessbox.c
+++ b/apps/plugins/chessbox.c
@@ -27,7 +27,7 @@
27PLUGIN_HEADER 27PLUGIN_HEADER
28 28
29/* this is the plugin entry point */ 29/* this is the plugin entry point */
30enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 30enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
31{ 31{
32 return run_overlay(api, parameter, PLUGIN_GAMES_DIR "/chessbox.ovl", "ChessBox"); 32 return run_overlay(api, parameter, PLUGIN_GAMES_DIR "/chessbox.ovl", "ChessBox");
33} 33}
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c
index f9e1020461..a90ddd68cb 100644
--- a/apps/plugins/chessbox/chessbox.c
+++ b/apps/plugins/chessbox/chessbox.c
@@ -902,7 +902,7 @@ void cb_play_game(void) {
902/***************************************************************************** 902/*****************************************************************************
903* plugin entry point. 903* plugin entry point.
904******************************************************************************/ 904******************************************************************************/
905enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 905enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
906 906
907 /* plugin init */ 907 /* plugin init */
908 908
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c
index 94bda2eaaa..a2b05af255 100644
--- a/apps/plugins/chessbox/chessbox_pgn.c
+++ b/apps/plugins/chessbox/chessbox_pgn.c
@@ -24,7 +24,7 @@
24#define LOG_FILE PLUGIN_GAMES_DIR "/chessbox.log" 24#define LOG_FILE PLUGIN_GAMES_DIR "/chessbox.log"
25int loghandler; 25int loghandler;
26 26
27struct plugin_api* rb; 27const struct plugin_api* rb;
28 28
29short kn_offs[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}}; 29short kn_offs[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}};
30short rk_offs[4][2] = {{1,0},{-1,0},{0,1},{0,-1}}; 30short rk_offs[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
@@ -556,7 +556,7 @@ void write_pgn_token(int fhandler, char *buffer, size_t *line_length){
556} 556}
557 557
558/* ---- api functions ---- */ 558/* ---- api functions ---- */
559struct pgn_game_node* pgn_list_games(struct plugin_api* api,const char* filename){ 559struct pgn_game_node* pgn_list_games(const struct plugin_api* api,const char* filename){
560 int fhandler; 560 int fhandler;
561 char line_buffer[128]; 561 char line_buffer[128];
562 struct pgn_game_node size_node, *first_game = NULL; 562 struct pgn_game_node size_node, *first_game = NULL;
@@ -614,7 +614,7 @@ struct pgn_game_node* pgn_list_games(struct plugin_api* api,const char* filename
614 return first_game; 614 return first_game;
615} 615}
616 616
617struct pgn_game_node* pgn_show_game_list(struct plugin_api* api, 617struct pgn_game_node* pgn_show_game_list(const struct plugin_api* api,
618 struct pgn_game_node* first_game){ 618 struct pgn_game_node* first_game){
619 int curr_selection = 0; 619 int curr_selection = 0;
620 int button; 620 int button;
@@ -659,7 +659,7 @@ struct pgn_game_node* pgn_show_game_list(struct plugin_api* api,
659 } 659 }
660} 660}
661 661
662void pgn_parse_game(struct plugin_api* api, const char* filename, 662void pgn_parse_game(const struct plugin_api* api, const char* filename,
663 struct pgn_game_node* selected_game){ 663 struct pgn_game_node* selected_game){
664 struct pgn_ply_node size_ply, *first_ply = NULL; 664 struct pgn_ply_node size_ply, *first_ply = NULL;
665 struct pgn_ply_node *temp_ply = NULL, *curr_node = NULL; 665 struct pgn_ply_node *temp_ply = NULL, *curr_node = NULL;
@@ -729,7 +729,7 @@ void pgn_parse_game(struct plugin_api* api, const char* filename,
729 rb->close(fhandler); 729 rb->close(fhandler);
730} 730}
731 731
732struct pgn_game_node* pgn_init_game(struct plugin_api* api){ 732struct pgn_game_node* pgn_init_game(const struct plugin_api* api){
733 struct pgn_game_node game_size, *game; 733 struct pgn_game_node game_size, *game;
734 struct pgn_ply_node ply_size, *ply; 734 struct pgn_ply_node ply_size, *ply;
735 struct tm *current_time; 735 struct tm *current_time;
@@ -767,7 +767,7 @@ struct pgn_game_node* pgn_init_game(struct plugin_api* api){
767 return game; 767 return game;
768} 768}
769 769
770void pgn_append_ply(struct plugin_api* api, struct pgn_game_node* game, 770void pgn_append_ply(const struct plugin_api* api, struct pgn_game_node* game,
771 unsigned short ply_player, char *move_buffer, bool is_mate){ 771 unsigned short ply_player, char *move_buffer, bool is_mate){
772 struct pgn_ply_node ply_size, *ply, *temp; 772 struct pgn_ply_node ply_size, *ply, *temp;
773 773
@@ -801,7 +801,7 @@ void pgn_append_ply(struct plugin_api* api, struct pgn_game_node* game,
801 temp->prev_node = ply; 801 temp->prev_node = ply;
802} 802}
803 803
804void pgn_set_result(struct plugin_api* api, struct pgn_game_node* game, 804void pgn_set_result(const struct plugin_api* api, struct pgn_game_node* game,
805 bool is_mate){ 805 bool is_mate){
806 806
807 rb = api; 807 rb = api;
@@ -815,7 +815,7 @@ void pgn_set_result(struct plugin_api* api, struct pgn_game_node* game,
815 } 815 }
816} 816}
817 817
818void pgn_store_game(struct plugin_api* api, struct pgn_game_node* game){ 818void pgn_store_game(const struct plugin_api* api, struct pgn_game_node* game){
819 int fhandler; 819 int fhandler;
820 struct pgn_ply_node *ply; 820 struct pgn_ply_node *ply;
821 unsigned ply_count; 821 unsigned ply_count;
diff --git a/apps/plugins/chessbox/chessbox_pgn.h b/apps/plugins/chessbox/chessbox_pgn.h
index 672bacaf6e..a457619887 100644
--- a/apps/plugins/chessbox/chessbox_pgn.h
+++ b/apps/plugins/chessbox/chessbox_pgn.h
@@ -350,35 +350,35 @@ struct pgn_game_node {
350 * the user selects a game, that obviously saves processing 350 * the user selects a game, that obviously saves processing
351 * and speeds up response when the user selects the file 351 * and speeds up response when the user selects the file
352 */ 352 */
353struct pgn_game_node* pgn_list_games(struct plugin_api* api, 353struct pgn_game_node* pgn_list_games(const struct plugin_api* api,
354 const char* filename); 354 const char* filename);
355 355
356/* Show the list of games found in a file and allow the user 356/* Show the list of games found in a file and allow the user
357 * to select a game to be parsed and showed 357 * to select a game to be parsed and showed
358 */ 358 */
359struct pgn_game_node* pgn_show_game_list(struct plugin_api* api, 359struct pgn_game_node* pgn_show_game_list(const struct plugin_api* api,
360 struct pgn_game_node* first_game); 360 struct pgn_game_node* first_game);
361 361
362/* Parse the pgn string of a game and assign it to the move 362/* Parse the pgn string of a game and assign it to the move
363 * list in the structure 363 * list in the structure
364 */ 364 */
365void pgn_parse_game(struct plugin_api* api, const char* filename, 365void pgn_parse_game(const struct plugin_api* api, const char* filename,
366 struct pgn_game_node* selected_game); 366 struct pgn_game_node* selected_game);
367 367
368/* Initialize a new game structure with default values and make 368/* Initialize a new game structure with default values and make
369 * it ready to store the history of a newly played match 369 * it ready to store the history of a newly played match
370 */ 370 */
371struct pgn_game_node* pgn_init_game(struct plugin_api* api); 371struct pgn_game_node* pgn_init_game(const struct plugin_api* api);
372 372
373/* Add a new ply to the game structure based on the positions */ 373/* Add a new ply to the game structure based on the positions */
374void pgn_append_ply(struct plugin_api* api, struct pgn_game_node* game, 374void pgn_append_ply(const struct plugin_api* api, struct pgn_game_node* game,
375 unsigned short ply_player, char *move_buffer, bool is_mate); 375 unsigned short ply_player, char *move_buffer, bool is_mate);
376 376
377/* Set the result of the game if it was reached during the opponent's ply 377/* Set the result of the game if it was reached during the opponent's ply
378 */ 378 */
379void pgn_set_result(struct plugin_api* api, struct pgn_game_node* game, 379void pgn_set_result(const struct plugin_api* api, struct pgn_game_node* game,
380 bool is_mate); 380 bool is_mate);
381 381
382/* Store a complete game in the PGN history file 382/* Store a complete game in the PGN history file
383 */ 383 */
384void pgn_store_game(struct plugin_api* api, struct pgn_game_node* game); 384void pgn_store_game(const struct plugin_api* api, struct pgn_game_node* game);
diff --git a/apps/plugins/chessbox/gnuchess.c b/apps/plugins/chessbox/gnuchess.c
index 3574dd6fbe..51e200d0f2 100644
--- a/apps/plugins/chessbox/gnuchess.c
+++ b/apps/plugins/chessbox/gnuchess.c
@@ -64,7 +64,7 @@
64#define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b])) 64#define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b]))
65 65
66/* ---- RockBox datatypes and variables */ 66/* ---- RockBox datatypes and variables */
67struct plugin_api* rb; 67const struct plugin_api* rb;
68 68
69/* ---- Chess datatypes and variables ---- */ 69/* ---- Chess datatypes and variables ---- */
70struct leaf 70struct leaf
diff --git a/apps/plugins/chessbox/gnuchess.h b/apps/plugins/chessbox/gnuchess.h
index 6a4a6bdd4e..b80647a287 100644
--- a/apps/plugins/chessbox/gnuchess.h
+++ b/apps/plugins/chessbox/gnuchess.h
@@ -44,7 +44,7 @@ extern struct TimeControlRec TimeControl;
44extern struct GameRec GameList[240]; 44extern struct GameRec GameList[240];
45 45
46/* ---- RockBox integration ---- */ 46/* ---- RockBox integration ---- */
47extern struct plugin_api* rb; 47extern const struct plugin_api* rb;
48 48
49/* ---- The beginning of a GNUChess v2 APIfication ---- */ 49/* ---- The beginning of a GNUChess v2 APIfication ---- */
50void SetTimeControl(void); 50void SetTimeControl(void);
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index d3e39e04ad..0235473438 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -224,7 +224,7 @@ PLUGIN_HEADER
224/* here is a global api struct pointer. while not strictly necessary, 224/* here is a global api struct pointer. while not strictly necessary,
225 it's nice not to have to pass the api pointer in all function calls 225 it's nice not to have to pass the api pointer in all function calls
226 in the plugin */ 226 in the plugin */
227static struct plugin_api* rb; 227static const struct plugin_api* rb;
228MEM_FUNCTION_WRAPPERS(rb); 228MEM_FUNCTION_WRAPPERS(rb);
229#define MAX_PLAYERS 10 229#define MAX_PLAYERS 10
230 230
@@ -257,7 +257,7 @@ static bool pause;
257#define MAX_TIME 7200 257#define MAX_TIME 7200
258 258
259/* this is the plugin entry point */ 259/* this is the plugin entry point */
260enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 260enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
261{ 261{
262 int i; 262 int i;
263 bool done; 263 bool done;
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index e00e4213e8..d62ff5a7bf 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -24,7 +24,7 @@
24 24
25PLUGIN_HEADER 25PLUGIN_HEADER
26 26
27static struct plugin_api* rb; /* here is a global api struct pointer */ 27static const struct plugin_api* rb; /* here is a global api struct pointer */
28 28
29#define EXTERN static 29#define EXTERN static
30#define STATIC static 30#define STATIC static
@@ -1287,7 +1287,7 @@ static void chip8_interrupt (void)
1287 starttimer = newtimer - runtime; 1287 starttimer = newtimer - runtime;
1288} 1288}
1289 1289
1290static bool chip8_init(char* file) 1290static bool chip8_init(const char* file)
1291{ 1291{
1292 int numread; 1292 int numread;
1293 int fd; 1293 int fd;
@@ -1307,14 +1307,16 @@ static bool chip8_init(char* file)
1307 1307
1308 rb->close(fd); 1308 rb->close(fd);
1309 /* is there a c8k file (chip8 keys) ? */ 1309 /* is there a c8k file (chip8 keys) ? */
1310 char c8kname[MAX_PATH];
1311 rb->strcpy(c8kname, file);
1310 for(i=0; i<16; i++) { 1312 for(i=0; i<16; i++) {
1311 chip8_virtual_keys[i] = 0; 1313 chip8_virtual_keys[i] = 0;
1312 chip8_keymap[i] = i; 1314 chip8_keymap[i] = i;
1313 } 1315 }
1314 len = rb->strlen(file); 1316 len = rb->strlen(c8kname);
1315 file[len-2] = '8'; 1317 c8kname[len-2] = '8';
1316 file[len-1] = 'k'; 1318 c8kname[len-1] = 'k';
1317 fd = rb->open(file, O_RDONLY); 1319 fd = rb->open(c8kname, O_RDONLY);
1318 if (fd!=-1) { 1320 if (fd!=-1) {
1319 rb->lcd_puts(0, 6, "File&Keymap OK."); 1321 rb->lcd_puts(0, 6, "File&Keymap OK.");
1320 numread = rb->read(fd, chip8_keymap, 16); 1322 numread = rb->read(fd, chip8_keymap, 16);
@@ -1340,7 +1342,7 @@ static bool chip8_init(char* file)
1340 return true; 1342 return true;
1341} 1343}
1342 1344
1343bool chip8_run(char* file) 1345bool chip8_run(const char* file)
1344{ 1346{
1345 int ok; 1347 int ok;
1346 1348
@@ -1406,9 +1408,9 @@ bool chip8_run(char* file)
1406 1408
1407/***************** Plugin Entry Point *****************/ 1409/***************** Plugin Entry Point *****************/
1408 1410
1409enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1411enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1410{ 1412{
1411 char* filename; 1413 const char* filename;
1412 1414
1413 rb = api; /* copy to global api pointer */ 1415 rb = api; /* copy to global api pointer */
1414 1416
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 2ab7c09d1c..09d281ea81 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -125,7 +125,7 @@ Still To do:
125#endif 125#endif
126#endif 126#endif
127 127
128static struct plugin_api* rb; 128static const struct plugin_api* rb;
129 129
130#define NUMBER_OF_BLOCKS 8 130#define NUMBER_OF_BLOCKS 8
131#define NUMBER_OF_PARTICLES 3 131#define NUMBER_OF_PARTICLES 3
@@ -979,7 +979,7 @@ void chopper_load(bool newgame)
979} 979}
980 980
981/* this is the plugin entry point */ 981/* this is the plugin entry point */
982enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 982enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
983{ 983{
984 (void)parameter; 984 (void)parameter;
985 rb = api; 985 rb = api;
diff --git a/apps/plugins/clock/clock.c b/apps/plugins/clock/clock.c
index 07057d21b2..588112cf63 100644
--- a/apps/plugins/clock/clock.c
+++ b/apps/plugins/clock/clock.c
@@ -54,7 +54,7 @@ const struct button_mapping* plugin_contexts[]={
54#define ACTION_SKIN_PREV PLA_DEC 54#define ACTION_SKIN_PREV PLA_DEC
55#define ACTION_SKIN_PREV_REPEAT PLA_DEC_REPEAT 55#define ACTION_SKIN_PREV_REPEAT PLA_DEC_REPEAT
56 56
57extern struct plugin_api* rb; 57extern const struct plugin_api* rb;
58 58
59/************************** 59/**************************
60 * Cleanup on plugin return 60 * Cleanup on plugin return
@@ -109,7 +109,7 @@ void format_date(char* buffer, struct time* time, enum date_format format){
109/********************************************************************** 109/**********************************************************************
110 * Plugin starts here 110 * Plugin starts here
111 **********************************************************************/ 111 **********************************************************************/
112enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ 112enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter){
113 int button; 113 int button;
114 int last_second = -1; 114 int last_second = -1;
115 bool redraw=true; 115 bool redraw=true;
diff --git a/apps/plugins/clock/clock.h b/apps/plugins/clock/clock.h
index eeb04380a2..76822ec162 100644
--- a/apps/plugins/clock/clock.h
+++ b/apps/plugins/clock/clock.h
@@ -20,7 +20,7 @@
20#ifndef _CLOCK_ 20#ifndef _CLOCK_
21#define _CLOCK_ 21#define _CLOCK_
22#include "clock_settings.h" 22#include "clock_settings.h"
23extern struct plugin_api* rb; 23extern const struct plugin_api* rb;
24 24
25struct time{ 25struct time{
26 int year, day, month; 26 int year, day, month;
diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c
index c0967c6235..dc19e0ebff 100644
--- a/apps/plugins/credits.c
+++ b/apps/plugins/credits.c
@@ -21,7 +21,7 @@
21 21
22PLUGIN_HEADER 22PLUGIN_HEADER
23 23
24static struct plugin_api* rb; 24static const struct plugin_api* rb;
25 25
26const char* const credits[] = { 26const char* const credits[] = {
27#include "credits.raw" /* generated list of names from docs/CREDITS */ 27#include "credits.raw" /* generated list of names from docs/CREDITS */
@@ -367,7 +367,7 @@ void roll_credits(void)
367 367
368#endif 368#endif
369 369
370enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 370enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
371{ 371{
372 (void)parameter; 372 (void)parameter;
373 rb = api; 373 rb = api;
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index aed27329ec..bc5564b473 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -425,7 +425,7 @@ static long matrice[3][3];
425static const int nb_points = 8; 425static const int nb_points = 8;
426static long z_off = 600; 426static long z_off = 600;
427 427
428static struct plugin_api* rb; 428static const struct plugin_api* rb;
429 429
430static void cube_rotate(int xa, int ya, int za) 430static void cube_rotate(int xa, int ya, int za)
431{ 431{
@@ -580,7 +580,7 @@ void cleanup(void *parameter)
580#endif 580#endif
581} 581}
582 582
583enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 583enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
584{ 584{
585 char buffer[30]; 585 char buffer[30];
586 int t_disp = 0; 586 int t_disp = 0;
diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c
index 580783f18d..df92184b08 100644
--- a/apps/plugins/demystify.c
+++ b/apps/plugins/demystify.c
@@ -65,7 +65,7 @@ struct line_color
65 65
66/******************************* Globals ***********************************/ 66/******************************* Globals ***********************************/
67 67
68static struct plugin_api* rb; /* global api struct pointer */ 68static const struct plugin_api* rb; /* global api struct pointer */
69 69
70/* 70/*
71 * Compute a new random step to make the point bounce the borders of the screen 71 * Compute a new random step to make the point bounce the borders of the screen
@@ -424,7 +424,7 @@ int plugin_main(void)
424 424
425/*************************** Plugin entry point ****************************/ 425/*************************** Plugin entry point ****************************/
426 426
427enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 427enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
428{ 428{
429 int ret; 429 int ret;
430 430
diff --git a/apps/plugins/dice.c b/apps/plugins/dice.c
index 7688d91a07..cde89e1144 100644
--- a/apps/plugins/dice.c
+++ b/apps/plugins/dice.c
@@ -44,7 +44,7 @@ struct dices
44#define PRINT_BUFFER_LENGTH MAX_DICES*4 44#define PRINT_BUFFER_LENGTH MAX_DICES*4
45PLUGIN_HEADER 45PLUGIN_HEADER
46 46
47static struct plugin_api* rb; 47static const struct plugin_api* rb;
48static struct dices dice; 48static struct dices dice;
49static int sides_index; 49static int sides_index;
50 50
@@ -72,7 +72,7 @@ void dice_print(struct dices* dice, struct screen* display);
72bool dice_menu(struct dices* dice); 72bool dice_menu(struct dices* dice);
73 73
74/* plugin entry point */ 74/* plugin entry point */
75enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 75enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
76 (void)parameter; 76 (void)parameter;
77 rb = api; 77 rb = api;
78 int i, action; 78 int i, action;
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c
index a149f0089a..26670f7aa4 100644
--- a/apps/plugins/dict.c
+++ b/apps/plugins/dict.c
@@ -22,7 +22,7 @@
22PLUGIN_HEADER 22PLUGIN_HEADER
23 23
24/* save the plugin api pointer. */ 24/* save the plugin api pointer. */
25static struct plugin_api* rb; 25static const struct plugin_api* rb;
26/* screen info */ 26/* screen info */
27static int display_columns, display_lines; 27static int display_columns, display_lines;
28 28
@@ -138,7 +138,7 @@ long reverse (long N) {
138#define DICT_DESC ROCKBOX_DIR "/rocks/apps/dict.desc" 138#define DICT_DESC ROCKBOX_DIR "/rocks/apps/dict.desc"
139 139
140/* the main plugin function */ 140/* the main plugin function */
141enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 141enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
142{ 142{
143 char searchword[WORDLEN]; /* word to search for */ 143 char searchword[WORDLEN]; /* word to search for */
144 char *description; /* pointer to description buffer */ 144 char *description; /* pointer to description buffer */
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index dd75408d48..ed29206d6b 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -19,7 +19,7 @@
19#include "plugin.h" 19#include "plugin.h"
20 20
21PLUGIN_HEADER 21PLUGIN_HEADER
22static struct plugin_api* rb; 22static const struct plugin_api* rb;
23 23
24/* function return values */ 24/* function return values */
25enum tidy_return 25enum tidy_return
@@ -412,7 +412,7 @@ int tidy_lcd_menu(void)
412} 412}
413 413
414/* this is the plugin entry point */ 414/* this is the plugin entry point */
415enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 415enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
416{ 416{
417 enum tidy_system system = TIDY_ALL; 417 enum tidy_system system = TIDY_ALL;
418 enum tidy_return status; 418 enum tidy_return status;
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index f23e856fdc..b36e677c49 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -99,7 +99,7 @@ int my_close(int id)
99 return 0; 99 return 0;
100} 100}
101#endif 101#endif
102struct plugin_api* rb; 102const struct plugin_api* rb;
103#define MAXARGVS 100 103#define MAXARGVS 100
104 104
105bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates 105bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates
@@ -675,7 +675,7 @@ int doom_menu()
675 675
676extern int systemvol; 676extern int systemvol;
677/* this is the plugin entry point */ 677/* this is the plugin entry point */
678enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 678enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
679{ 679{
680 PLUGIN_IRAM_INIT(api) 680 PLUGIN_IRAM_INIT(api)
681 681
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h
index 2ddbb94fcf..1611807b40 100644
--- a/apps/plugins/doom/rockmacros.h
+++ b/apps/plugins/doom/rockmacros.h
@@ -24,7 +24,7 @@
24#include "autoconf.h" 24#include "autoconf.h"
25#include "z_zone.h" 25#include "z_zone.h"
26 26
27extern struct plugin_api* rb; 27extern const struct plugin_api* rb;
28extern bool noprintf; 28extern bool noprintf;
29extern bool doomexit; 29extern bool doomexit;
30 30
diff --git a/apps/plugins/euroconverter.c b/apps/plugins/euroconverter.c
index 224fb85703..fe45bef6c3 100644
--- a/apps/plugins/euroconverter.c
+++ b/apps/plugins/euroconverter.c
@@ -140,7 +140,7 @@ static unsigned char *abbrev_str[12] = {
140 140
141static unsigned long heuro,hhome; /*Handles for the new patterns*/ 141static unsigned long heuro,hhome; /*Handles for the new patterns*/
142 142
143static struct plugin_api* rb; 143static const struct plugin_api* rb;
144 144
145static char *currency_str[12] = { 145static char *currency_str[12] = {
146 "France", 146 "France",
@@ -402,7 +402,7 @@ static void euro_exit(void *parameter)
402 402
403 403
404/* this is the plugin entry point */ 404/* this is the plugin entry point */
405enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 405enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
406{ 406{
407 bool end, pos; 407 bool end, pos;
408 longlong_t e,h,old_e,old_h; 408 longlong_t e,h,old_e,old_h;
diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c
index c26822c8dc..2755436c7c 100644
--- a/apps/plugins/fire.c
+++ b/apps/plugins/fire.c
@@ -41,7 +41,7 @@
41 41
42PLUGIN_HEADER 42PLUGIN_HEADER
43 43
44static struct plugin_api* rb; /* global api struct pointer */ 44static const struct plugin_api* rb; /* global api struct pointer */
45 45
46#ifndef HAVE_LCD_COLOR 46#ifndef HAVE_LCD_COLOR
47GREY_INFO_STRUCT 47GREY_INFO_STRUCT
@@ -344,7 +344,7 @@ int main(void)
344 344
345/*************************** Plugin entry point ****************************/ 345/*************************** Plugin entry point ****************************/
346 346
347enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 347enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
348{ 348{
349 int ret; 349 int ret;
350 350
diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c
index 361930f1c8..d06cbdf912 100644
--- a/apps/plugins/fireworks.c
+++ b/apps/plugins/fireworks.c
@@ -22,7 +22,7 @@
22 22
23PLUGIN_HEADER 23PLUGIN_HEADER
24 24
25static struct plugin_api* rb; 25static const struct plugin_api* rb;
26 26
27/*** 27/***
28 * FIREWORKS.C by ZAKK ROBERTS 28 * FIREWORKS.C by ZAKK ROBERTS
@@ -385,7 +385,7 @@ void fireworks_menu(void)
385} 385}
386 386
387/* this is the plugin entry point */ 387/* this is the plugin entry point */
388enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 388enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
389{ 389{
390 (void)parameter; 390 (void)parameter;
391 391
diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c
index f4daab2fcd..6cbb252cd1 100644
--- a/apps/plugins/firmware_flash.c
+++ b/apps/plugins/firmware_flash.c
@@ -126,7 +126,7 @@ typedef struct
126 char name[32]; 126 char name[32];
127} tFlashInfo; 127} tFlashInfo;
128 128
129static struct plugin_api* rb; /* here is a global api struct pointer */ 129static const struct plugin_api* rb; /* here is a global api struct pointer */
130 130
131#define MASK_ADR 0xFC /* position of hardware mask value in Flash */ 131#define MASK_ADR 0xFC /* position of hardware mask value in Flash */
132#define VERSION_ADR 0xFE /* position of firmware version value in Flash */ 132#define VERSION_ADR 0xFE /* position of firmware version value in Flash */
@@ -1072,7 +1072,7 @@ void DoUserDialog(char* filename)
1072 1072
1073/***************** Plugin Entry Point *****************/ 1073/***************** Plugin Entry Point *****************/
1074 1074
1075enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1075enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1076{ 1076{
1077 int oldmode; 1077 int oldmode;
1078 1078
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c
index 874ddf41f7..7e865b0ea8 100644
--- a/apps/plugins/flipit.c
+++ b/apps/plugins/flipit.c
@@ -244,7 +244,7 @@ PLUGIN_HEADER
244#endif 244#endif
245#endif 245#endif
246 246
247static struct plugin_api* rb; 247static const struct plugin_api* rb;
248static int spots[20]; 248static int spots[20];
249static int toggle[20]; 249static int toggle[20];
250static int cursor_pos, moves; 250static int cursor_pos, moves;
@@ -591,7 +591,7 @@ static bool flipit_loop(void)
591} 591}
592 592
593/* called function from outside */ 593/* called function from outside */
594enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 594enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
595{ 595{
596 int i, rc; 596 int i, rc;
597 597
diff --git a/apps/plugins/greyscale.c b/apps/plugins/greyscale.c
index 17449b9f62..cffa8f1940 100644
--- a/apps/plugins/greyscale.c
+++ b/apps/plugins/greyscale.c
@@ -102,7 +102,7 @@ PLUGIN_HEADER
102/******************************* Globals ***********************************/ 102/******************************* Globals ***********************************/
103 103
104GREY_INFO_STRUCT 104GREY_INFO_STRUCT
105static struct plugin_api* rb; /* global api struct pointer */ 105static const struct plugin_api* rb; /* global api struct pointer */
106static char pbuf[32]; /* global printf buffer */ 106static char pbuf[32]; /* global printf buffer */
107static unsigned char *gbuf; 107static unsigned char *gbuf;
108static size_t gbuf_size = 0; 108static size_t gbuf_size = 0;
@@ -361,7 +361,7 @@ int main(void)
361 361
362/*************************** Plugin entry point ****************************/ 362/*************************** Plugin entry point ****************************/
363 363
364enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 364enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
365{ 365{
366 rb = api; /* copy to global api pointer */ 366 rb = api; /* copy to global api pointer */
367 (void)parameter; 367 (void)parameter;
diff --git a/apps/plugins/helloworld.c b/apps/plugins/helloworld.c
index eca9d2e85a..ebad484d9c 100644
--- a/apps/plugins/helloworld.c
+++ b/apps/plugins/helloworld.c
@@ -27,10 +27,10 @@ PLUGIN_HEADER
27/* here is a global api struct pointer. while not strictly necessary, 27/* here is a global api struct pointer. while not strictly necessary,
28 it's nice not to have to pass the api pointer in all function calls 28 it's nice not to have to pass the api pointer in all function calls
29 in the plugin */ 29 in the plugin */
30static struct plugin_api* rb; 30static const struct plugin_api* rb;
31 31
32/* this is the plugin entry point */ 32/* this is the plugin entry point */
33enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 33enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
34{ 34{
35 /* if you don't use the parameter, you can do like 35 /* if you don't use the parameter, you can do like
36 this to avoid the compiler warning about it */ 36 this to avoid the compiler warning about it */
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index 946e36d05a..1294ed35c3 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -595,7 +595,7 @@ unsigned char fire_sprite[FIRE_HEIGHT] = {
595#define CYCLETIME 40 595#define CYCLETIME 40
596 596
597 597
598static struct plugin_api* rb; 598static const struct plugin_api* rb;
599 599
600/* Physical x is at PLAYFIELD_X + LIVES_X + x * ALIEN_SPEED 600/* Physical x is at PLAYFIELD_X + LIVES_X + x * ALIEN_SPEED
601 * Physical y is at y * ALIEN_HEIGHT 601 * Physical y is at y * ALIEN_HEIGHT
@@ -1785,7 +1785,7 @@ void game_loop(void)
1785 1785
1786 1786
1787/* this is the plugin entry point */ 1787/* this is the plugin entry point */
1788enum plugin_status plugin_start(struct plugin_api* api, UNUSED void* parameter) 1788enum plugin_status plugin_start(const struct plugin_api* api, UNUSED const void* parameter)
1789{ 1789{
1790 rb = api; 1790 rb = api;
1791 1791
diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c
index d9ea73b622..af002acb2f 100644
--- a/apps/plugins/iriver_flash.c
+++ b/apps/plugins/iriver_flash.c
@@ -54,7 +54,7 @@ struct flash_info
54 char name[32]; 54 char name[32];
55}; 55};
56 56
57static struct plugin_api* rb; /* here is a global api struct pointer */ 57static const struct plugin_api* rb; /* here is a global api struct pointer */
58 58
59#ifdef IRIVER_H100_SERIES 59#ifdef IRIVER_H100_SERIES
60#define SEC_SIZE 4096 60#define SEC_SIZE 4096
@@ -802,7 +802,7 @@ void DoUserDialog(char* filename)
802 802
803/***************** Plugin Entry Point *****************/ 803/***************** Plugin Entry Point *****************/
804 804
805enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 805enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
806{ 806{
807 int oldmode; 807 int oldmode;
808 808
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c
index b578cf7e0c..abff78266d 100644
--- a/apps/plugins/iriverify.c
+++ b/apps/plugins/iriverify.c
@@ -25,7 +25,7 @@
25 25
26PLUGIN_HEADER 26PLUGIN_HEADER
27 27
28static struct plugin_api* rb; 28static const struct plugin_api* rb;
29 29
30ssize_t buf_size; 30ssize_t buf_size;
31static char *filename; 31static char *filename;
@@ -130,7 +130,7 @@ static int write_file(void)
130 return 0; 130 return 0;
131} 131}
132 132
133enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 133enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
134{ 134{
135 char *buf; 135 char *buf;
136 int rc; 136 int rc;
diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c
index de99eae2a9..5950551b44 100644
--- a/apps/plugins/jackpot.c
+++ b/apps/plugins/jackpot.c
@@ -69,7 +69,7 @@ const struct picture jackpot_pictures[]={
69#define SLEEP_TIME (HZ/200) 69#define SLEEP_TIME (HZ/200)
70#endif /* HAVE_LCD_CHARCELLS */ 70#endif /* HAVE_LCD_CHARCELLS */
71 71
72static struct plugin_api* rb; 72static const struct plugin_api* rb;
73 73
74struct jackpot 74struct jackpot
75{ 75{
@@ -290,7 +290,7 @@ void jackpot_play_turn(struct jackpot* game)
290 jackpot_print_turn_result(game, gain, rb->screens[d]); 290 jackpot_print_turn_result(game, gain, rb->screens[d]);
291} 291}
292 292
293enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 293enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
294{ 294{
295 rb = api; 295 rb = api;
296 int action, i; 296 int action, i;
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index ddd659d2a1..7eec89eaa3 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -339,7 +339,7 @@ struct jewels_menu {
339}; 339};
340 340
341/* global rockbox api */ 341/* global rockbox api */
342static struct plugin_api* rb; 342static const struct plugin_api* rb;
343 343
344/* external bitmaps */ 344/* external bitmaps */
345extern const fb_data jewels[]; 345extern const fb_data jewels[];
@@ -1898,7 +1898,7 @@ static int jewels_main(struct game_context* bj) {
1898/***************************************************************************** 1898/*****************************************************************************
1899* plugin entry point. 1899* plugin entry point.
1900******************************************************************************/ 1900******************************************************************************/
1901enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 1901enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
1902 struct game_context bj; 1902 struct game_context bj;
1903 bool exit = false; 1903 bool exit = false;
1904 int position; 1904 int position;
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index e95c10bbfa..a05eaa72dc 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -279,7 +279,7 @@ GREY_INFO_STRUCT
279 279
280/******************************* Globals ***********************************/ 280/******************************* Globals ***********************************/
281 281
282static struct plugin_api* rb; 282static const struct plugin_api* rb;
283MEM_FUNCTION_WRAPPERS(rb); 283MEM_FUNCTION_WRAPPERS(rb);
284 284
285/* for portability of below JPEG code */ 285/* for portability of below JPEG code */
@@ -3318,7 +3318,7 @@ int load_and_show(char* filename)
3318 3318
3319/******************** Plugin entry point *********************/ 3319/******************** Plugin entry point *********************/
3320 3320
3321enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 3321enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
3322{ 3322{
3323 rb = api; 3323 rb = api;
3324 3324
diff --git a/apps/plugins/lamp.c b/apps/plugins/lamp.c
index 943cc97fce..2f91545edc 100644
--- a/apps/plugins/lamp.c
+++ b/apps/plugins/lamp.c
@@ -92,7 +92,7 @@ PLUGIN_HEADER
92# endif 92# endif
93#endif 93#endif
94 94
95static struct plugin_api* rb; /* global api struct pointer */ 95static const struct plugin_api* rb; /* global api struct pointer */
96 96
97#ifdef HAVE_LCD_COLOR 97#ifdef HAVE_LCD_COLOR
98/* RGB color sets */ 98/* RGB color sets */
@@ -102,7 +102,7 @@ static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */
102#endif /* HAVE_LCD_COLOR */ 102#endif /* HAVE_LCD_COLOR */
103 103
104/* this is the plugin entry point */ 104/* this is the plugin entry point */
105enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 105enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
106{ 106{
107 (void)parameter; 107 (void)parameter;
108 rb = api; 108 rb = api;
diff --git a/apps/plugins/lib/bmp.c b/apps/plugins/lib/bmp.c
index 20adc6de86..c46093a8d9 100644
--- a/apps/plugins/lib/bmp.c
+++ b/apps/plugins/lib/bmp.c
@@ -30,7 +30,7 @@
30/** 30/**
31 * Save to 24 bit bitmap. 31 * Save to 24 bit bitmap.
32 */ 32 */
33int save_bmp_file( char* filename, struct bitmap *bm, struct plugin_api* rb ) 33int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb )
34{ 34{
35 /* I'm not really sure about this one :) */ 35 /* I'm not really sure about this one :) */
36 int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0); 36 int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0);
diff --git a/apps/plugins/lib/bmp.h b/apps/plugins/lib/bmp.h
index 10f71865f7..9114df1ee5 100644
--- a/apps/plugins/lib/bmp.h
+++ b/apps/plugins/lib/bmp.h
@@ -26,7 +26,7 @@
26/** 26/**
27 * Save bitmap to file 27 * Save bitmap to file
28 */ 28 */
29int save_bmp_file( char* filename, struct bitmap *bm, struct plugin_api* rb ); 29int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb );
30#endif 30#endif
31 31
32/** 32/**
diff --git a/apps/plugins/lib/checkbox.c b/apps/plugins/lib/checkbox.c
index 5acc52a728..039d5f9cbf 100644
--- a/apps/plugins/lib/checkbox.c
+++ b/apps/plugins/lib/checkbox.c
@@ -25,7 +25,7 @@
25/* 25/*
26 * Print a checkbox 26 * Print a checkbox
27 */ 27 */
28void checkbox(struct plugin_api *api, int x, int y, int width, int height, bool checked) 28void checkbox(const struct plugin_api *api, int x, int y, int width, int height, bool checked)
29{ 29{
30 /* draw box */ 30 /* draw box */
31 api->lcd_drawrect(x, y, width, height); 31 api->lcd_drawrect(x, y, width, height);
diff --git a/apps/plugins/lib/checkbox.h b/apps/plugins/lib/checkbox.h
index 2a5ffea0aa..72de4952ca 100644
--- a/apps/plugins/lib/checkbox.h
+++ b/apps/plugins/lib/checkbox.h
@@ -24,6 +24,6 @@
24/* 24/*
25 * Print a checkbox 25 * Print a checkbox
26 */ 26 */
27void checkbox(struct plugin_api *api, int x, int y, int width, int height, bool checked); 27void checkbox(const struct plugin_api *api, int x, int y, int width, int height, bool checked);
28 28
29#endif 29#endif
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c
index b0d134fae9..516bf616cb 100644
--- a/apps/plugins/lib/configfile.c
+++ b/apps/plugins/lib/configfile.c
@@ -19,9 +19,9 @@
19#include "plugin.h" 19#include "plugin.h"
20#include "configfile.h" 20#include "configfile.h"
21 21
22static struct plugin_api *cfg_rb; 22static const struct plugin_api *cfg_rb;
23 23
24void configfile_init(struct plugin_api* newrb) 24void configfile_init(const struct plugin_api* newrb)
25{ 25{
26 cfg_rb = newrb; 26 cfg_rb = newrb;
27} 27}
diff --git a/apps/plugins/lib/configfile.h b/apps/plugins/lib/configfile.h
index 7aa69f3ecf..fe4b43c485 100644
--- a/apps/plugins/lib/configfile.h
+++ b/apps/plugins/lib/configfile.h
@@ -37,7 +37,7 @@ struct configdata
37 NULL otherwise */ 37 NULL otherwise */
38}; 38};
39 39
40void configfile_init(struct plugin_api* newrb); 40void configfile_init(const struct plugin_api* newrb);
41 41
42/* configfile_save - Given configdata entries this function will 42/* configfile_save - Given configdata entries this function will
43 create a config file with these entries, destroying any 43 create a config file with these entries, destroying any
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h
index 81912b1995..4a15bd38ea 100644
--- a/apps/plugins/lib/grey.h
+++ b/apps/plugins/lib/grey.h
@@ -50,7 +50,7 @@
50#define GREY_ON_COP 0x0004 /* Run ISR on COP (PP targets) */ 50#define GREY_ON_COP 0x0004 /* Run ISR on COP (PP targets) */
51 51
52/* Library initialisation and release */ 52/* Library initialisation and release */
53bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, 53bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
54 unsigned features, int width, int height, long *buf_taken); 54 unsigned features, int width, int height, long *buf_taken);
55void grey_release(void); 55void grey_release(void);
56 56
@@ -168,16 +168,16 @@ struct _grey_info
168 int by; /* 4-pixel or 8-pixel units */ 168 int by; /* 4-pixel or 8-pixel units */
169 int bheight; /* 4-pixel or 8-pixel units */ 169 int bheight; /* 4-pixel or 8-pixel units */
170#endif 170#endif
171 unsigned long flags; /* various flags, see #defines */ 171 unsigned long flags; /* various flags, see #defines */
172 struct plugin_api *rb; /* plugin API pointer */ 172 const struct plugin_api *rb; /* plugin API pointer */
173 unsigned char *values; /* start of greyscale pixel values */ 173 unsigned char *values; /* start of greyscale pixel values */
174 unsigned char *phases; /* start of greyscale pixel phases */ 174 unsigned char *phases; /* start of greyscale pixel phases */
175 unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ 175 unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */
176 unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */ 176 unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */
177 int fg_brightness; /* current foreground brightness */ 177 int fg_brightness; /* current foreground brightness */
178 int bg_brightness; /* current background brightness */ 178 int bg_brightness; /* current background brightness */
179 int drawmode; /* current draw mode */ 179 int drawmode; /* current draw mode */
180 int curfont; /* current selected font */ 180 int curfont; /* current selected font */
181}; 181};
182 182
183/* Global variable, defined in the plugin */ 183/* Global variable, defined in the plugin */
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index e2260cdf11..e7f02dd6cb 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -478,7 +478,7 @@ static void fill_gvalues(void)
478 478
479 The function is authentic regarding memory usage on the simulator, even 479 The function is authentic regarding memory usage on the simulator, even
480 if it doesn't use all of the allocated memory. */ 480 if it doesn't use all of the allocated memory. */
481bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, 481bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
482 unsigned features, int width, int height, long *buf_taken) 482 unsigned features, int width, int height, long *buf_taken)
483{ 483{
484 int bdim, i; 484 int bdim, i;
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c
index 8ac822b407..691a17f15c 100644
--- a/apps/plugins/lib/helper.c
+++ b/apps/plugins/lib/helper.c
@@ -21,7 +21,7 @@
21#include "helper.h" 21#include "helper.h"
22 22
23/* Force the backlight on */ 23/* Force the backlight on */
24void backlight_force_on(struct plugin_api* rb) 24void backlight_force_on(const struct plugin_api* rb)
25{ 25{
26 if(!rb) 26 if(!rb)
27 return; 27 return;
@@ -34,7 +34,7 @@ void backlight_force_on(struct plugin_api* rb)
34} 34}
35 35
36/* Reset backlight operation to its settings */ 36/* Reset backlight operation to its settings */
37void backlight_use_settings(struct plugin_api* rb) 37void backlight_use_settings(const struct plugin_api* rb)
38{ 38{
39 if (!rb) 39 if (!rb)
40 return; 40 return;
@@ -47,7 +47,7 @@ void backlight_use_settings(struct plugin_api* rb)
47 47
48#ifdef HAVE_REMOTE_LCD 48#ifdef HAVE_REMOTE_LCD
49/* Force the backlight on */ 49/* Force the backlight on */
50void remote_backlight_force_on(struct plugin_api* rb) 50void remote_backlight_force_on(const struct plugin_api* rb)
51{ 51{
52 if (!rb) 52 if (!rb)
53 return; 53 return;
@@ -60,7 +60,7 @@ void remote_backlight_force_on(struct plugin_api* rb)
60} 60}
61 61
62/* Reset backlight operation to its settings */ 62/* Reset backlight operation to its settings */
63void remote_backlight_use_settings(struct plugin_api* rb) 63void remote_backlight_use_settings(const struct plugin_api* rb)
64{ 64{
65 if (!rb) 65 if (!rb)
66 return; 66 return;
@@ -75,7 +75,7 @@ void remote_backlight_use_settings(struct plugin_api* rb)
75 75
76#ifdef HAVE_BUTTON_LIGHT 76#ifdef HAVE_BUTTON_LIGHT
77/* Force the buttonlight on */ 77/* Force the buttonlight on */
78void buttonlight_force_on(struct plugin_api* rb) 78void buttonlight_force_on(const struct plugin_api* rb)
79{ 79{
80 if (!rb) 80 if (!rb)
81 return; 81 return;
@@ -84,7 +84,7 @@ void buttonlight_force_on(struct plugin_api* rb)
84} 84}
85 85
86/* Reset buttonlight operation to its settings */ 86/* Reset buttonlight operation to its settings */
87void buttonlight_use_settings(struct plugin_api* rb) 87void buttonlight_use_settings(const struct plugin_api* rb)
88{ 88{
89 if (!rb) 89 if (!rb)
90 return; 90 return;
diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h
index 4d1328bd0c..d34e6334f0 100644
--- a/apps/plugins/lib/helper.h
+++ b/apps/plugins/lib/helper.h
@@ -24,14 +24,14 @@
24/** 24/**
25 * Backlight on/off operations 25 * Backlight on/off operations
26 */ 26 */
27void backlight_force_on(struct plugin_api* rb); 27void backlight_force_on(const struct plugin_api* rb);
28void backlight_use_settings(struct plugin_api* rb); 28void backlight_use_settings(const struct plugin_api* rb);
29#ifdef HAVE_REMOTE_LCD 29#ifdef HAVE_REMOTE_LCD
30void remote_backlight_force_on(struct plugin_api* rb); 30void remote_backlight_force_on(const struct plugin_api* rb);
31void remote_backlight_use_settings(struct plugin_api* rb); 31void remote_backlight_use_settings(const struct plugin_api* rb);
32#endif 32#endif
33#ifdef HAVE_BUTTON_LIGHT 33#ifdef HAVE_BUTTON_LIGHT
34void buttonlight_force_on(struct plugin_api* rb); 34void buttonlight_force_on(const struct plugin_api* rb);
35void buttonlight_use_settings(struct plugin_api* rb); 35void buttonlight_use_settings(const struct plugin_api* rb);
36#endif 36#endif
37#endif 37#endif
diff --git a/apps/plugins/lib/highscore.c b/apps/plugins/lib/highscore.c
index df7a71bcdf..94b6a7b947 100644
--- a/apps/plugins/lib/highscore.c
+++ b/apps/plugins/lib/highscore.c
@@ -19,9 +19,9 @@
19#include "plugin.h" 19#include "plugin.h"
20#include "highscore.h" 20#include "highscore.h"
21 21
22static struct plugin_api *rb; 22static const struct plugin_api *rb;
23 23
24void highscore_init(struct plugin_api* newrb) 24void highscore_init(const struct plugin_api* newrb)
25{ 25{
26 rb = newrb; 26 rb = newrb;
27} 27}
diff --git a/apps/plugins/lib/highscore.h b/apps/plugins/lib/highscore.h
index ba7da241f1..b6501cf568 100644
--- a/apps/plugins/lib/highscore.h
+++ b/apps/plugins/lib/highscore.h
@@ -26,7 +26,7 @@ struct highscore
26 int level; 26 int level;
27}; 27};
28 28
29void highscore_init(struct plugin_api* newrb); 29void highscore_init(const struct plugin_api* newrb);
30int highscore_save(char *filename, struct highscore *scores, int num_scores); 30int highscore_save(char *filename, struct highscore *scores, int num_scores);
31int highscore_load(char *filename, struct highscore *scores, int num_scores); 31int highscore_load(char *filename, struct highscore *scores, int num_scores);
32int highscore_update(int score, int level, struct highscore *scores, int num_scores); 32int highscore_update(int score, int level, struct highscore *scores, int num_scores);
diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c
index 27e4fdd49e..51fb4f3eb2 100644
--- a/apps/plugins/lib/oldmenuapi.c
+++ b/apps/plugins/lib/oldmenuapi.c
@@ -27,7 +27,7 @@
27#include "plugin.h" 27#include "plugin.h"
28#include "oldmenuapi.h" 28#include "oldmenuapi.h"
29 29
30struct plugin_api *rb = NULL; 30const struct plugin_api *rb = NULL;
31 31
32struct menu { 32struct menu {
33 struct menu_item* items; 33 struct menu_item* items;
@@ -65,7 +65,7 @@ static int menu_find_free(void)
65 return(i); 65 return(i);
66} 66}
67 67
68int menu_init(struct plugin_api *api, const struct menu_item* mitems, 68int menu_init(const struct plugin_api *api, const struct menu_item* mitems,
69 int count, int (*callback)(int, int), 69 int count, int (*callback)(int, int),
70 const char *button1, const char *button2, const char *button3) 70 const char *button1, const char *button2, const char *button3)
71{ 71{
diff --git a/apps/plugins/lib/oldmenuapi.h b/apps/plugins/lib/oldmenuapi.h
index 34f6226d59..ccfd1400dd 100644
--- a/apps/plugins/lib/oldmenuapi.h
+++ b/apps/plugins/lib/oldmenuapi.h
@@ -31,7 +31,7 @@ struct menu_item {
31 bool (*function) (void); /* return true if USB was connected */ 31 bool (*function) (void); /* return true if USB was connected */
32}; 32};
33 33
34int menu_init(struct plugin_api *api, const struct menu_item* mitems, 34int menu_init(const struct plugin_api *api, const struct menu_item* mitems,
35 int count, int (*callback)(int, int), 35 int count, int (*callback)(int, int),
36 const char *button1, const char *button2, const char *button3); 36 const char *button1, const char *button2, const char *button3);
37void menu_exit(int menu); 37void menu_exit(int menu);
diff --git a/apps/plugins/lib/overlay.c b/apps/plugins/lib/overlay.c
index 53cc4a84f0..63fb776f02 100644
--- a/apps/plugins/lib/overlay.c
+++ b/apps/plugins/lib/overlay.c
@@ -44,7 +44,7 @@
44 The linker script for the overlay should use a base address towards the 44 The linker script for the overlay should use a base address towards the
45 end of the audiobuffer, just low enough to make the overlay fit. */ 45 end of the audiobuffer, just low enough to make the overlay fit. */
46 46
47enum plugin_status run_overlay(struct plugin_api* rb, void* parameter, 47enum plugin_status run_overlay(const struct plugin_api* rb, const void* parameter,
48 unsigned char *filename, unsigned char *name) 48 unsigned char *filename, unsigned char *name)
49{ 49{
50 int fd, readsize; 50 int fd, readsize;
diff --git a/apps/plugins/lib/overlay.h b/apps/plugins/lib/overlay.h
index bbf7549274..ba9b1fa308 100644
--- a/apps/plugins/lib/overlay.h
+++ b/apps/plugins/lib/overlay.h
@@ -26,7 +26,7 @@
26#include "plugin.h" 26#include "plugin.h"
27 27
28/* load and run a plugin linked as an overlay. */ 28/* load and run a plugin linked as an overlay. */
29enum plugin_status run_overlay(struct plugin_api* api, void* parameter, 29enum plugin_status run_overlay(const struct plugin_api* api, const void* parameter,
30 unsigned char *filename, unsigned char *name); 30 unsigned char *filename, unsigned char *name);
31 31
32#endif /* !SIMULATOR */ 32#endif /* !SIMULATOR */
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c
index 7e74728ab4..b0456248a8 100644
--- a/apps/plugins/lib/playback_control.c
+++ b/apps/plugins/lib/playback_control.c
@@ -20,7 +20,7 @@
20#include "plugin.h" 20#include "plugin.h"
21#include "playback_control.h" 21#include "playback_control.h"
22 22
23struct plugin_api* api = 0; 23const struct plugin_api* api = 0;
24struct viewport *parentvp = NULL; 24struct viewport *parentvp = NULL;
25 25
26static bool prevtrack(void) 26static bool prevtrack(void)
@@ -105,14 +105,14 @@ MAKE_MENU(playback_control_menu, "Playback Control", NULL, Icon_NOICON,
105 &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item, 105 &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item,
106 &volume_item, &shuffle_item, &repeat_mode_item); 106 &volume_item, &shuffle_item, &repeat_mode_item);
107 107
108void playback_control_init(struct plugin_api* newapi, 108void playback_control_init(const struct plugin_api* newapi,
109 struct viewport parent[NB_SCREENS]) 109 struct viewport parent[NB_SCREENS])
110{ 110{
111 api = newapi; 111 api = newapi;
112 parentvp = parent; 112 parentvp = parent;
113} 113}
114 114
115bool playback_control(struct plugin_api* newapi, 115bool playback_control(const struct plugin_api* newapi,
116 struct viewport parent[NB_SCREENS]) 116 struct viewport parent[NB_SCREENS])
117{ 117{
118 api = newapi; 118 api = newapi;
diff --git a/apps/plugins/lib/playback_control.h b/apps/plugins/lib/playback_control.h
index a3a0d7afbc..23b586095e 100644
--- a/apps/plugins/lib/playback_control.h
+++ b/apps/plugins/lib/playback_control.h
@@ -25,11 +25,11 @@
25 So, make sure you use the same viewport for the rb->do_menu() call 25 So, make sure you use the same viewport for the rb->do_menu() call
26 that you use in the playback_control_init() call 26 that you use in the playback_control_init() call
27*/ 27*/
28void playback_control_init(struct plugin_api* newapi, 28void playback_control_init(const struct plugin_api* newapi,
29 struct viewport parent[NB_SCREENS]); 29 struct viewport parent[NB_SCREENS]);
30 30
31/* Use this if your menu still uses the old menu api */ 31/* Use this if your menu still uses the old menu api */
32bool playback_control(struct plugin_api* api, 32bool playback_control(const struct plugin_api* api,
33 struct viewport parent[NB_SCREENS]); 33 struct viewport parent[NB_SCREENS]);
34 34
35#endif /* __PLAYBACK_CONTROL_H__ */ 35#endif /* __PLAYBACK_CONTROL_H__ */
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c
index 8853078fa1..4139a6c605 100644
--- a/apps/plugins/lib/playergfx.c
+++ b/apps/plugins/lib/playergfx.c
@@ -26,7 +26,7 @@
26 26
27/*** globals ***/ 27/*** globals ***/
28 28
29static struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */ 29static const struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */
30static int char_width; 30static int char_width;
31static int char_height; 31static int char_height;
32static int pixel_height; 32static int pixel_height;
@@ -38,7 +38,7 @@ static int drawmode = DRMODE_SOLID;
38/*** Special functions ***/ 38/*** Special functions ***/
39 39
40/* library init */ 40/* library init */
41bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight) 41bool pgfx_init(const struct plugin_api* newrb, int cwidth, int cheight)
42{ 42{
43 int i; 43 int i;
44 44
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h
index 5f49831609..504599ae39 100644
--- a/apps/plugins/lib/playergfx.h
+++ b/apps/plugins/lib/playergfx.h
@@ -26,7 +26,7 @@
26 26
27#ifdef HAVE_LCD_CHARCELLS /* Player only :) */ 27#ifdef HAVE_LCD_CHARCELLS /* Player only :) */
28 28
29bool pgfx_init(struct plugin_api* newrb, int cwidth, int cheight); 29bool pgfx_init(const struct plugin_api* newrb, int cwidth, int cheight);
30void pgfx_release(void); 30void pgfx_release(void);
31void pgfx_display(int cx, int cy); 31void pgfx_display(int cx, int cy);
32void pgfx_display_block(int cx, int cy, int x, int y); 32void pgfx_display_block(int cx, int cy, int x, int y);
diff --git a/apps/plugins/lib/pluginlib_actions.c b/apps/plugins/lib/pluginlib_actions.c
index be78bf1408..a63ffb352a 100644
--- a/apps/plugins/lib/pluginlib_actions.c
+++ b/apps/plugins/lib/pluginlib_actions.c
@@ -464,7 +464,7 @@ static const struct button_mapping* get_context_map(int context)
464 else return NULL; 464 else return NULL;
465} 465}
466 466
467int pluginlib_getaction(struct plugin_api *api,int timeout, 467int pluginlib_getaction(const struct plugin_api *api,int timeout,
468 const struct button_mapping *plugin_contexts[], 468 const struct button_mapping *plugin_contexts[],
469 int count) 469 int count)
470{ 470{
diff --git a/apps/plugins/lib/pluginlib_actions.h b/apps/plugins/lib/pluginlib_actions.h
index c11a087904..601cd73a8c 100644
--- a/apps/plugins/lib/pluginlib_actions.h
+++ b/apps/plugins/lib/pluginlib_actions.h
@@ -58,7 +58,7 @@ extern const struct button_mapping generic_left_right_fire[];
58extern const struct button_mapping generic_actions[]; 58extern const struct button_mapping generic_actions[];
59extern const struct button_mapping generic_increase_decrease[]; 59extern const struct button_mapping generic_increase_decrease[];
60 60
61int pluginlib_getaction(struct plugin_api *api,int timeout, 61int pluginlib_getaction(const struct plugin_api *api,int timeout,
62 const struct button_mapping *plugin_contexts[], 62 const struct button_mapping *plugin_contexts[],
63 int count); 63 int count);
64 64
diff --git a/apps/plugins/lib/profile_plugin.c b/apps/plugins/lib/profile_plugin.c
index 38c6d81598..6f31288c8f 100644
--- a/apps/plugins/lib/profile_plugin.c
+++ b/apps/plugins/lib/profile_plugin.c
@@ -21,9 +21,9 @@
21 21
22#include "plugin.h" 22#include "plugin.h"
23 23
24static struct plugin_api *local_rb = NULL; /* global api struct pointer */ 24static const struct plugin_api *local_rb = NULL; /* global api struct pointer */
25 25
26void profile_init(struct plugin_api* pa) 26void profile_init(const struct plugin_api* pa)
27{ 27{
28 local_rb = pa; 28 local_rb = pa;
29} 29}
diff --git a/apps/plugins/lib/profile_plugin.h b/apps/plugins/lib/profile_plugin.h
index 71cff37033..6bc19734d8 100644
--- a/apps/plugins/lib/profile_plugin.h
+++ b/apps/plugins/lib/profile_plugin.h
@@ -24,7 +24,7 @@
24 24
25#include "plugin.h" 25#include "plugin.h"
26 26
27void profile_init(struct plugin_api* pa); 27void profile_init(const struct plugin_api* pa);
28 28
29void __cyg_profile_func_enter(void *this_fn, void *call_site) 29void __cyg_profile_func_enter(void *this_fn, void *call_site)
30 NO_PROF_ATTR ICODE_ATTR; 30 NO_PROF_ATTR ICODE_ATTR;
diff --git a/apps/plugins/lib/xlcd.h b/apps/plugins/lib/xlcd.h
index 59a048228b..a1e2389f39 100644
--- a/apps/plugins/lib/xlcd.h
+++ b/apps/plugins/lib/xlcd.h
@@ -26,7 +26,7 @@
26 26
27#ifdef HAVE_LCD_BITMAP 27#ifdef HAVE_LCD_BITMAP
28 28
29void xlcd_init(struct plugin_api* newrb); 29void xlcd_init(const struct plugin_api* newrb);
30void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); 30void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3);
31void xlcd_filltriangle_screen(struct screen* display, 31void xlcd_filltriangle_screen(struct screen* display,
32 int x1, int y1, int x2, int y2, int x3, int y3); 32 int x1, int y1, int x2, int y2, int x3, int y3);
@@ -49,7 +49,7 @@ void xlcd_scroll_up(int count);
49void xlcd_scroll_down(int count); 49void xlcd_scroll_down(int count);
50 50
51/* internal stuff */ 51/* internal stuff */
52extern struct plugin_api *_xlcd_rb; /* global api struct pointer */ 52extern const struct plugin_api *_xlcd_rb; /* global api struct pointer */
53 53
54#endif /* HAVE_LCD_BITMAP */ 54#endif /* HAVE_LCD_BITMAP */
55#endif /* __XLCD_H__ */ 55#endif /* __XLCD_H__ */
diff --git a/apps/plugins/lib/xlcd_core.c b/apps/plugins/lib/xlcd_core.c
index e8cc688591..7f8e566865 100644
--- a/apps/plugins/lib/xlcd_core.c
+++ b/apps/plugins/lib/xlcd_core.c
@@ -27,12 +27,12 @@
27 27
28/*** globals ***/ 28/*** globals ***/
29 29
30struct plugin_api *_xlcd_rb = NULL; /* global api struct pointer */ 30const struct plugin_api *_xlcd_rb = NULL; /* global api struct pointer */
31 31
32/*** functions ***/ 32/*** functions ***/
33 33
34/* library init */ 34/* library init */
35void xlcd_init(struct plugin_api* newrb) 35void xlcd_init(const struct plugin_api* newrb)
36{ 36{
37 _xlcd_rb = newrb; 37 _xlcd_rb = newrb;
38} 38}
diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c
index f08ca3a62a..79ff6acb62 100644
--- a/apps/plugins/logo.c
+++ b/apps/plugins/logo.c
@@ -176,12 +176,12 @@ const unsigned char rockbox16x7[] = {
176#endif 176#endif
177#endif 177#endif
178 178
179enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 179enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
180 int button; 180 int button;
181 int timer = 10; 181 int timer = 10;
182 int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2); 182 int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2);
183 int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2); 183 int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2);
184 struct plugin_api* rb = api; 184 const struct plugin_api* rb = api;
185 int dx; 185 int dx;
186 int dy; 186 int dy;
187#ifdef HAVE_LCD_CHARCELLS 187#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c
index 1576b875dd..8b045e74de 100644
--- a/apps/plugins/mandelbrot.c
+++ b/apps/plugins/mandelbrot.c
@@ -273,7 +273,7 @@ PLUGIN_HEADER
273#define MYXLCD(fn) xlcd_ ## fn 273#define MYXLCD(fn) xlcd_ ## fn
274#endif 274#endif
275 275
276static struct plugin_api* rb; 276static const struct plugin_api* rb;
277 277
278/* Fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */ 278/* Fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */
279static long x_min; 279static long x_min;
@@ -661,7 +661,7 @@ void cleanup(void *parameter)
661#define REDRAW_PARTIAL 1 661#define REDRAW_PARTIAL 1
662#define REDRAW_FULL 2 662#define REDRAW_FULL 2
663 663
664enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 664enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
665{ 665{
666 int button; 666 int button;
667 int lastbutton = BUTTON_NONE; 667 int lastbutton = BUTTON_NONE;
diff --git a/apps/plugins/matrix.c b/apps/plugins/matrix.c
index 33509dc69a..65a4a6b785 100644
--- a/apps/plugins/matrix.c
+++ b/apps/plugins/matrix.c
@@ -119,7 +119,7 @@ extern const fb_data matrix_normal[];
119#define SLEEP HZ/50 119#define SLEEP HZ/50
120 120
121/* Codec api pointer */ 121/* Codec api pointer */
122static struct plugin_api* rb; 122static const struct plugin_api* rb;
123 123
124/* Each position is of this type */ 124/* Each position is of this type */
125typedef struct cmatrix { 125typedef struct cmatrix {
@@ -284,7 +284,7 @@ static void matrix_loop(void)
284 } 284 }
285} 285}
286 286
287enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 287enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
288 int button; 288 int button;
289 int sleep = SLEEP; 289 int sleep = SLEEP;
290 bool frozen = false; 290 bool frozen = false;
diff --git a/apps/plugins/maze.c b/apps/plugins/maze.c
index cebdc46cff..f18dd68eb6 100644
--- a/apps/plugins/maze.c
+++ b/apps/plugins/maze.c
@@ -79,7 +79,7 @@ PLUGIN_HEADER
79#define BORDER_W 0x00000080 79#define BORDER_W 0x00000080
80#define PATH 0x00000100 80#define PATH 0x00000100
81 81
82static struct plugin_api* rb; 82static const struct plugin_api* rb;
83 83
84#ifdef __PLUGINLIB_ACTIONS_H__ 84#ifdef __PLUGINLIB_ACTIONS_H__
85const struct button_mapping *plugin_contexts[] 85const struct button_mapping *plugin_contexts[]
@@ -470,7 +470,7 @@ void maze_move_player_right(struct maze* maze)
470/**********************************/ 470/**********************************/
471/* this is the plugin entry point */ 471/* this is the plugin entry point */
472/**********************************/ 472/**********************************/
473enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 473enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
474{ 474{
475 int button, lastbutton = BUTTON_NONE; 475 int button, lastbutton = BUTTON_NONE;
476 int quit = 0; 476 int quit = 0;
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c
index 2ee6e20059..93d9ec4c9a 100644
--- a/apps/plugins/mazezam.c
+++ b/apps/plugins/mazezam.c
@@ -26,7 +26,7 @@
26/* Include standard plugin macro */ 26/* Include standard plugin macro */
27PLUGIN_HEADER 27PLUGIN_HEADER
28 28
29static struct plugin_api* rb; 29static const struct plugin_api* rb;
30 30
31/* The plugin actions of interest. */ 31/* The plugin actions of interest. */
32const struct button_mapping *plugin_contexts[] 32const struct button_mapping *plugin_contexts[]
@@ -916,7 +916,7 @@ static void main_menu(void)
916/***************************************************************************** 916/*****************************************************************************
917* Plugin entry point 917* Plugin entry point
918******************************************************************************/ 918******************************************************************************/
919enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 919enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
920{ 920{
921 enum plugin_status plugin_state; 921 enum plugin_status plugin_state;
922 922
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index a778429195..85b1260a86 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -78,7 +78,7 @@ const struct button_mapping *plugin_contexts[]={
78}; 78};
79#define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) 79#define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
80 80
81static struct plugin_api* rb; 81static const struct plugin_api* rb;
82 82
83MEM_FUNCTION_WRAPPERS(rb); 83MEM_FUNCTION_WRAPPERS(rb);
84 84
@@ -299,7 +299,7 @@ void tap(void)
299 reset_tap = false; 299 reset_tap = false;
300} 300}
301 301
302enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ 302enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter){
303 int button; 303 int button;
304 enum plugin_status status; 304 enum plugin_status status;
305 305
diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c
index 5f98e895a2..6411b8e658 100644
--- a/apps/plugins/midi/midifile.c
+++ b/apps/plugins/midi/midifile.c
@@ -26,7 +26,7 @@ int readID(int file);
26 26
27struct MIDIfile midi_file IBSS_ATTR; 27struct MIDIfile midi_file IBSS_ATTR;
28 28
29struct MIDIfile * loadFile(char * filename) 29struct MIDIfile * loadFile(const char * filename)
30{ 30{
31 struct MIDIfile * mfload; 31 struct MIDIfile * mfload;
32 int file = rb->open (filename, O_RDONLY); 32 int file = rb->open (filename, O_RDONLY);
diff --git a/apps/plugins/midi/midifile.h b/apps/plugins/midi/midifile.h
index a1024d500b..25ab2f5b19 100644
--- a/apps/plugins/midi/midifile.h
+++ b/apps/plugins/midi/midifile.h
@@ -17,5 +17,5 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20struct MIDIfile * loadFile(char * filename); 20struct MIDIfile * loadFile(const char * filename);
21 21
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index e97d7acf1c..69be53e75d 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -191,11 +191,11 @@ int32_t gmbuf[BUF_SIZE*NBUF];
191static unsigned int samples_in_buf; 191static unsigned int samples_in_buf;
192 192
193int quit=0; 193int quit=0;
194struct plugin_api * rb; 194const struct plugin_api * rb;
195 195
196static int midimain(void * filename); 196static int midimain(const void * filename);
197 197
198enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 198enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
199{ 199{
200 int retval = 0; 200 int retval = 0;
201 201
@@ -292,7 +292,7 @@ void get_more(unsigned char** start, size_t* size)
292#endif 292#endif
293} 293}
294 294
295static int midimain(void * filename) 295static int midimain(const void * filename)
296{ 296{
297 int notesUsed = 0; 297 int notesUsed = 0;
298 int a=0; 298 int a=0;
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c
index ad41451d88..6e4e7d1bc1 100644
--- a/apps/plugins/midi2wav.c
+++ b/apps/plugins/midi2wav.c
@@ -54,20 +54,14 @@ long bpm;
54#include "midi/synth.c" 54#include "midi/synth.c"
55 55
56 56
57
58
59int fd=-1; /* File descriptor where the output is written */ 57int fd=-1; /* File descriptor where the output is written */
60 58
61extern long tempo; /* The sequencer keeps track of this */ 59extern long tempo; /* The sequencer keeps track of this */
62 60
63 61const struct plugin_api * rb;
64struct plugin_api * rb;
65
66
67
68 62
69 63
70enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 64enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
71{ 65{
72 (void)parameter; 66 (void)parameter;
73 rb = api; 67 rb = api;
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index e4b8c939b4..7b1587ce6f 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -221,7 +221,7 @@ enum minesweeper_status {
221 * it's nice not to have to pass the api pointer in all function calls 221 * it's nice not to have to pass the api pointer in all function calls
222 * in the plugin 222 * in the plugin
223 */ 223 */
224static struct plugin_api *rb; 224static const struct plugin_api *rb;
225 225
226extern const fb_data minesweeper_tiles[]; 226extern const fb_data minesweeper_tiles[];
227 227
@@ -731,7 +731,7 @@ enum minesweeper_status minesweeper( void )
731} 731}
732 732
733/* plugin entry point */ 733/* plugin entry point */
734enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 734enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
735{ 735{
736 bool exit = false; 736 bool exit = false;
737 737
diff --git a/apps/plugins/mosaique.c b/apps/plugins/mosaique.c
index 9545f89f59..4d7b0af795 100644
--- a/apps/plugins/mosaique.c
+++ b/apps/plugins/mosaique.c
@@ -141,7 +141,7 @@ PLUGIN_HEADER
141#endif 141#endif
142#endif 142#endif
143 143
144enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 144enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
145{ 145{
146 int button; 146 int button;
147 int timer = 10; 147 int timer = 10;
@@ -149,7 +149,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
149 int y=0; 149 int y=0;
150 int sx = 3; 150 int sx = 3;
151 int sy = 3; 151 int sy = 3;
152 struct plugin_api* rb = api; 152 const struct plugin_api* rb = api;
153 (void)parameter; 153 (void)parameter;
154 154
155#ifdef HAVE_LCD_CHARCELLS 155#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index a344bdc7dc..db9c9d4e67 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -16,7 +16,7 @@
16PLUGIN_HEADER 16PLUGIN_HEADER
17PLUGIN_IRAM_DECLARE 17PLUGIN_IRAM_DECLARE
18 18
19static struct plugin_api* rb; 19static const struct plugin_api* rb;
20 20
21MEM_FUNCTION_WRAPPERS(rb); 21MEM_FUNCTION_WRAPPERS(rb);
22 22
@@ -806,7 +806,7 @@ static const int win_const[18][4] = {
806 { 134, -146,-3352,-3072 } }; 806 { 134, -146,-3352,-3072 } };
807 807
808 808
809static char* wav_filename; 809static const char* wav_filename;
810static int mp3file, wavfile, wav_size, frames; 810static int mp3file, wavfile, wav_size, frames;
811static uint32 enc_buffer[16384]; /* storage for 65536 Bytes */ 811static uint32 enc_buffer[16384]; /* storage for 65536 Bytes */
812static int enc_chunk = 0; /* encode chunk counter */ 812static int enc_chunk = 0; /* encode chunk counter */
@@ -2278,7 +2278,7 @@ void compress(void)
2278int num_file; 2278int num_file;
2279char mp3_name[80]; 2279char mp3_name[80];
2280 2280
2281void get_mp3_filename(char *wav_name) 2281void get_mp3_filename(const char *wav_name)
2282{ 2282{
2283 int slen = rb->strlen(wav_name); 2283 int slen = rb->strlen(wav_name);
2284 rb->strncpy(mp3_name, wav_name, 79); 2284 rb->strncpy(mp3_name, wav_name, 79);
@@ -2353,7 +2353,7 @@ void get_mp3_filename(char *wav_name)
2353#endif 2353#endif
2354#endif 2354#endif
2355 2355
2356enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2356enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
2357{ 2357{
2358 int rat, srat, nrat; /* for rate selection */ 2358 int rat, srat, nrat; /* for rate selection */
2359 int cont = 1, butt; 2359 int cont = 1, butt;
diff --git a/apps/plugins/mpegplayer/decode.c b/apps/plugins/mpegplayer/decode.c
index ab3a800d9b..1c85fa7a92 100644
--- a/apps/plugins/mpegplayer/decode.c
+++ b/apps/plugins/mpegplayer/decode.c
@@ -25,7 +25,7 @@
25 25
26#include "mpeg2dec_config.h" 26#include "mpeg2dec_config.h"
27 27
28extern struct plugin_api* rb; 28extern const struct plugin_api* rb;
29 29
30#include "mpeg2.h" 30#include "mpeg2.h"
31#include "attributes.h" 31#include "attributes.h"
diff --git a/apps/plugins/mpegplayer/header.c b/apps/plugins/mpegplayer/header.c
index 3dd3d280dd..d8d005b692 100644
--- a/apps/plugins/mpegplayer/header.c
+++ b/apps/plugins/mpegplayer/header.c
@@ -26,7 +26,7 @@
26 26
27#include "mpeg2dec_config.h" 27#include "mpeg2dec_config.h"
28 28
29extern struct plugin_api* rb; 29extern const struct plugin_api* rb;
30 30
31#include "mpeg2.h" 31#include "mpeg2.h"
32#include "attributes.h" 32#include "attributes.h"
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 8e46b24eee..82703ca840 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -257,7 +257,7 @@ PLUGIN_IRAM_DECLARE
257#endif 257#endif
258#endif 258#endif
259 259
260struct plugin_api* rb; 260const struct plugin_api* rb;
261 261
262CACHE_FUNCTION_WRAPPERS(rb); 262CACHE_FUNCTION_WRAPPERS(rb);
263ALIGN_BUFFER_WRAPPER(rb); 263ALIGN_BUFFER_WRAPPER(rb);
@@ -1544,7 +1544,7 @@ static void button_loop(void)
1544 backlight_use_settings(rb); 1544 backlight_use_settings(rb);
1545} 1545}
1546 1546
1547enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1547enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1548{ 1548{
1549 int status = PLUGIN_ERROR; /* assume failure */ 1549 int status = PLUGIN_ERROR; /* assume failure */
1550 int result; 1550 int result;
diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h
index b92af38e6c..fa13a1e378 100644
--- a/apps/plugins/mpegplayer/mpegplayer.h
+++ b/apps/plugins/mpegplayer/mpegplayer.h
@@ -22,7 +22,7 @@
22#define MPEGPLAYER_H 22#define MPEGPLAYER_H
23 23
24/* Global API pointer */ 24/* Global API pointer */
25extern struct plugin_api* rb; 25extern const struct plugin_api* rb;
26 26
27#ifdef HAVE_SCHEDULER_BOOSTCTRL 27#ifdef HAVE_SCHEDULER_BOOSTCTRL
28#define trigger_cpu_boost rb->trigger_cpu_boost 28#define trigger_cpu_boost rb->trigger_cpu_boost
diff --git a/apps/plugins/nim.c b/apps/plugins/nim.c
index b13cfe415b..ae3297d458 100644
--- a/apps/plugins/nim.c
+++ b/apps/plugins/nim.c
@@ -59,7 +59,7 @@ static unsigned char str[12]; /*String use to display the first line*/
59static unsigned long hsmile,hcry,h1,h2; /*Handle for the new pattern*/ 59static unsigned long hsmile,hcry,h1,h2; /*Handle for the new pattern*/
60 60
61static bool end; /*If true game is finished*/ 61static bool end; /*If true game is finished*/
62static struct plugin_api* rb; 62static const struct plugin_api* rb;
63 63
64 64
65/*Display that the action it's impossible*/ 65/*Display that the action it's impossible*/
@@ -138,7 +138,7 @@ static void nim_exit(void *parameter)
138} 138}
139 139
140/* this is the plugin entry point */ 140/* this is the plugin entry point */
141enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 141enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
142{ 142{
143 int y,z,button; 143 int y,z,button;
144 int x,v,min; 144 int x,v,min;
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c
index eae1a7bc4c..e126ff57d0 100644
--- a/apps/plugins/oscilloscope.c
+++ b/apps/plugins/oscilloscope.c
@@ -249,7 +249,7 @@ enum { OSC_HORIZ, OSC_VERT, MAX_OSC };
249 249
250/* global variables */ 250/* global variables */
251 251
252struct plugin_api* rb; /* global api struct pointer */ 252const struct plugin_api* rb; /* global api struct pointer */
253 253
254/* settings */ 254/* settings */
255struct osc_config { 255struct osc_config {
@@ -650,7 +650,7 @@ void cleanup(void *parameter)
650 backlight_use_settings(rb); /* backlight control in lib/helper.c */ 650 backlight_use_settings(rb); /* backlight control in lib/helper.c */
651} 651}
652 652
653enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 653enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
654{ 654{
655 int button, vol; 655 int button, vol;
656 int lastbutton = BUTTON_NONE; 656 int lastbutton = BUTTON_NONE;
diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c
index db7bf0bb89..5244ed8d8c 100644
--- a/apps/plugins/pacbox/arcade.c
+++ b/apps/plugins/pacbox/arcade.c
@@ -27,7 +27,7 @@
27#include <string.h> 27#include <string.h>
28#include "plugin.h" 28#include "plugin.h"
29 29
30extern struct plugin_api* rb; 30extern const struct plugin_api* rb;
31 31
32#ifndef HAVE_LCD_COLOR 32#ifndef HAVE_LCD_COLOR
33/* Convert RGB888 to 2-bit greyscale - logic taken from bmp2rb.c */ 33/* Convert RGB888 to 2-bit greyscale - logic taken from bmp2rb.c */
diff --git a/apps/plugins/pacbox/hardware.c b/apps/plugins/pacbox/hardware.c
index 23658cf61e..376fe3273f 100644
--- a/apps/plugins/pacbox/hardware.c
+++ b/apps/plugins/pacbox/hardware.c
@@ -25,7 +25,7 @@
25#include "plugin.h" 25#include "plugin.h"
26#include "hardware.h" 26#include "hardware.h"
27 27
28extern struct plugin_api* rb; 28extern const struct plugin_api* rb;
29 29
30/* The main data for Pacman */ 30/* The main data for Pacman */
31 31
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c
index fad27358d2..1eb040e24d 100644
--- a/apps/plugins/pacbox/pacbox.c
+++ b/apps/plugins/pacbox/pacbox.c
@@ -32,7 +32,7 @@
32PLUGIN_HEADER 32PLUGIN_HEADER
33PLUGIN_IRAM_DECLARE 33PLUGIN_IRAM_DECLARE
34 34
35struct plugin_api* rb; 35const struct plugin_api* rb;
36 36
37struct pacman_settings { 37struct pacman_settings {
38 int difficulty; 38 int difficulty;
@@ -361,7 +361,7 @@ static int gameProc( void )
361 return 0; 361 return 0;
362} 362}
363 363
364enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 364enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
365{ 365{
366 (void)parameter; 366 (void)parameter;
367 367
diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c
index e41c724da6..ed58ac605d 100644
--- a/apps/plugins/pegbox.c
+++ b/apps/plugins/pegbox.c
@@ -25,7 +25,7 @@
25#endif 25#endif
26#include "pegbox_pieces.h" 26#include "pegbox_pieces.h"
27 27
28static struct plugin_api* rb; 28static const struct plugin_api* rb;
29 29
30PLUGIN_HEADER 30PLUGIN_HEADER
31 31
@@ -1256,7 +1256,7 @@ static int pegbox(struct game_context* pb) {
1256/***************************************************************************** 1256/*****************************************************************************
1257* plugin entry point. 1257* plugin entry point.
1258******************************************************************************/ 1258******************************************************************************/
1259enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 1259enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
1260 bool exit = false; 1260 bool exit = false;
1261 struct game_context pb; 1261 struct game_context pb;
1262 1262
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c
index e5494d661a..bea028eadc 100644
--- a/apps/plugins/pictureflow.c
+++ b/apps/plugins/pictureflow.c
@@ -34,7 +34,7 @@ PLUGIN_HEADER
34 34
35/******************************* Globals ***********************************/ 35/******************************* Globals ***********************************/
36 36
37static struct plugin_api *rb; /* global api struct pointer */ 37static const struct plugin_api *rb; /* global api struct pointer */
38 38
39const struct button_mapping *plugin_contexts[] 39const struct button_mapping *plugin_contexts[]
40= {generic_actions, generic_directions}; 40= {generic_actions, generic_directions};
@@ -2080,7 +2080,7 @@ int main(void)
2080 2080
2081/*************************** Plugin entry point ****************************/ 2081/*************************** Plugin entry point ****************************/
2082 2082
2083enum plugin_status plugin_start(struct plugin_api *api, void *parameter) 2083enum plugin_status plugin_start(const struct plugin_api *api, const void *parameter)
2084{ 2084{
2085 int ret; 2085 int ret;
2086 2086
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index e8ae7645b4..027a8355da 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -36,7 +36,7 @@ PLUGIN_HEADER
36 36
37/******************************* Globals ***********************************/ 37/******************************* Globals ***********************************/
38 38
39static struct plugin_api* rb; /* global api struct pointer */ 39static const struct plugin_api* rb; /* global api struct pointer */
40static unsigned char wave_array[256]; /* Pre calculated wave array */ 40static unsigned char wave_array[256]; /* Pre calculated wave array */
41#ifdef HAVE_LCD_COLOR 41#ifdef HAVE_LCD_COLOR
42static fb_data colours[256]; /* Smooth transition of shades */ 42static fb_data colours[256]; /* Smooth transition of shades */
@@ -343,7 +343,7 @@ int main(void)
343 343
344/*************************** Plugin entry point ****************************/ 344/*************************** Plugin entry point ****************************/
345 345
346enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 346enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
347{ 347{
348 int ret; 348 int ret;
349 349
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c
index 8163915fb6..c7382a58b2 100644
--- a/apps/plugins/pong.c
+++ b/apps/plugins/pong.c
@@ -174,7 +174,7 @@ PLUGIN_HEADER
174#endif 174#endif
175#endif 175#endif
176 176
177static struct plugin_api* rb; 177static const struct plugin_api* rb;
178 178
179struct pong { 179struct pong {
180 int ballx; /* current X*RES position of the ball */ 180 int ballx; /* current X*RES position of the ball */
@@ -453,7 +453,7 @@ void showscore(struct pong *p)
453} 453}
454 454
455/* this is the plugin entry point */ 455/* this is the plugin entry point */
456enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 456enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
457{ 457{
458 struct pong pong; 458 struct pong pong;
459 int game = 1; 459 int game = 1;
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index 27805154b3..05d05a746b 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -20,7 +20,7 @@
20 20
21PLUGIN_HEADER 21PLUGIN_HEADER
22 22
23static struct plugin_api* rb; 23static const struct plugin_api* rb;
24 24
25MEM_FUNCTION_WRAPPERS(rb); 25MEM_FUNCTION_WRAPPERS(rb);
26 26
@@ -252,21 +252,23 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
252 return buffer; 252 return buffer;
253} 253}
254 254
255enum plugin_status plugin_start(struct plugin_api* api, void* file) 255enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
256{ 256{
257 rb = api; 257 rb = api;
258 struct gui_synclist properties_lists; 258 struct gui_synclist properties_lists;
259 int button; 259 int button;
260 bool prev_show_statusbar; 260 bool prev_show_statusbar;
261 bool quit = false; 261 bool quit = false;
262 char file[MAX_PATH];
263 rb->strcpy(file, (const char *) parameter);
262 264
263 /* determine if it's a file or a directory */ 265 /* determine if it's a file or a directory */
264 bool found = false; 266 bool found = false;
265 DIR* dir; 267 DIR* dir;
266 struct dirent* entry; 268 struct dirent* entry;
267 char* ptr = rb->strrchr((char*)file, '/') + 1; 269 char* ptr = rb->strrchr(file, '/') + 1;
268 int dirlen = (ptr - (char*)file); 270 int dirlen = (ptr - file);
269 rb->strncpy(str_dirname, (char*)file, dirlen); 271 rb->strncpy(str_dirname, file, dirlen);
270 str_dirname[dirlen] = 0; 272 str_dirname[dirlen] = 0;
271 273
272 dir = rb->opendir(str_dirname); 274 dir = rb->opendir(str_dirname);
@@ -288,13 +290,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
288 if(!found) 290 if(!found)
289 { 291 {
290 /* weird: we couldn't find the entry. This Should Never Happen (TM) */ 292 /* weird: we couldn't find the entry. This Should Never Happen (TM) */
291 rb->splash(0, "File/Dir not found: %s", (char*)file); 293 rb->splash(0, "File/Dir not found: %s", file);
292 rb->action_userabort(TIMEOUT_BLOCK); 294 rb->action_userabort(TIMEOUT_BLOCK);
293 return PLUGIN_OK; 295 return PLUGIN_OK;
294 } 296 }
295 297
296 /* get the info depending on its_a_dir */ 298 /* get the info depending on its_a_dir */
297 if(!(its_a_dir ? dir_properties((char*)file):file_properties((char*)file))) 299 if(!(its_a_dir ? dir_properties(file) : file_properties(file)))
298 { 300 {
299 /* something went wrong (to do: tell user what it was (nesting,...) */ 301 /* something went wrong (to do: tell user what it was (nesting,...) */
300 rb->splash(0, "Failed to gather information"); 302 rb->splash(0, "Failed to gather information");
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 413dc029b4..4df764285f 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -21,7 +21,7 @@
21 21
22PLUGIN_HEADER 22PLUGIN_HEADER
23 23
24static struct plugin_api* rb; 24static const struct plugin_api* rb;
25static bool abort; 25static bool abort;
26static int fd; 26static int fd;
27static int dirs_count; 27static int dirs_count;
@@ -544,7 +544,7 @@ int main_menu(void)
544 return 0; 544 return 0;
545} 545}
546 546
547enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 547enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
548{ 548{
549 (void)parameter; 549 (void)parameter;
550 550
diff --git a/apps/plugins/reversi/reversi-game.h b/apps/plugins/reversi/reversi-game.h
index de05df78f9..9558f000bf 100644
--- a/apps/plugins/reversi/reversi-game.h
+++ b/apps/plugins/reversi/reversi-game.h
@@ -58,7 +58,7 @@ typedef struct _reversi_board_t {
58 */ 58 */
59 move_t history[BOARD_SIZE*BOARD_SIZE - INIT_STONES]; 59 move_t history[BOARD_SIZE*BOARD_SIZE - INIT_STONES];
60 60
61 struct plugin_api *rb; 61 const struct plugin_api *rb;
62} reversi_board_t; 62} reversi_board_t;
63 63
64 64
diff --git a/apps/plugins/reversi/reversi-gui.c b/apps/plugins/reversi/reversi-gui.c
index 1995923f4f..a7e695529b 100644
--- a/apps/plugins/reversi/reversi-gui.c
+++ b/apps/plugins/reversi/reversi-gui.c
@@ -52,7 +52,7 @@ PLUGIN_HEADER
52/* The global api struct pointer. While not strictly necessary, 52/* The global api struct pointer. While not strictly necessary,
53 it's nice not to have to pass the api pointer in all function 53 it's nice not to have to pass the api pointer in all function
54 calls in the plugin */ 54 calls in the plugin */
55static struct plugin_api* rb; 55static const struct plugin_api* rb;
56 56
57/* Thickness of the grid lines */ 57/* Thickness of the grid lines */
58#define LINE_THCK 1 58#define LINE_THCK 1
@@ -543,7 +543,7 @@ static void reversi_gui_move_cursor(int new_row, int new_col) {
543 543
544 544
545/* plugin entry point */ 545/* plugin entry point */
546enum plugin_status plugin_start(struct plugin_api *api, void *parameter) { 546enum plugin_status plugin_start(const struct plugin_api *api, const void *parameter) {
547 bool exit, draw_screen; 547 bool exit, draw_screen;
548 int button; 548 int button;
549 int lastbutton = BUTTON_NONE; 549 int lastbutton = BUTTON_NONE;
diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c
index a2786b7e2d..a2208a30d5 100644
--- a/apps/plugins/robotfindskitten.c
+++ b/apps/plugins/robotfindskitten.c
@@ -180,7 +180,7 @@ int screen[X_MAX + 1][Y_MAX + 1];
180/* here is a global api struct pointer. while not strictly necessary, 180/* here is a global api struct pointer. while not strictly necessary,
181 it's nice not to have to pass the api pointer in all function calls 181 it's nice not to have to pass the api pointer in all function calls
182 in the plugin */ 182 in the plugin */
183static struct plugin_api* rb; 183static const struct plugin_api* rb;
184 184
185/****************************************************************************** 185/******************************************************************************
186 * 186 *
@@ -593,7 +593,7 @@ static void initialize_screen()
593} 593}
594 594
595/* this is the plugin entry point */ 595/* this is the plugin entry point */
596enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 596enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
597{ 597{
598 (void)parameter; 598 (void)parameter;
599 rb = api; 599 rb = api;
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 62e7c747e1..3df427da48 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -507,7 +507,7 @@ extern const fb_data rockblox_background[];
507 507
508 508
509/* must have variable */ 509/* must have variable */
510static struct plugin_api *rb; 510static const struct plugin_api *rb;
511 511
512static bool gameover = false; 512static bool gameover = false;
513/* c=current f=figure o=orientation n=next */ 513/* c=current f=figure o=orientation n=next */
@@ -1159,7 +1159,7 @@ static int rockblox_loop (void)
1159 return PLUGIN_OK; 1159 return PLUGIN_OK;
1160} 1160}
1161 1161
1162enum plugin_status plugin_start (struct plugin_api *api, void *parameter) 1162enum plugin_status plugin_start (const struct plugin_api *api, const void *parameter)
1163{ 1163{
1164 int ret; 1164 int ret;
1165 1165
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c
index ed0fd17f53..fd855ff520 100644
--- a/apps/plugins/rockbox_flash.c
+++ b/apps/plugins/rockbox_flash.c
@@ -95,7 +95,7 @@ typedef struct
95 char name[32]; 95 char name[32];
96} tFlashInfo; 96} tFlashInfo;
97 97
98static struct plugin_api* rb; /* here is a global api struct pointer */ 98static const struct plugin_api* rb; /* here is a global api struct pointer */
99 99
100static UINT8* sector; /* better not place this on the stack... */ 100static UINT8* sector; /* better not place this on the stack... */
101 101
@@ -1017,7 +1017,7 @@ void DoUserDialog(char* filename)
1017 1017
1018/***************** Plugin Entry Point *****************/ 1018/***************** Plugin Entry Point *****************/
1019 1019
1020enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1020enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1021{ 1021{
1022 int oldmode; 1022 int oldmode;
1023 1023
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c
index 67f10043ba..c4b1ff0425 100644
--- a/apps/plugins/rockboy.c
+++ b/apps/plugins/rockboy.c
@@ -27,7 +27,7 @@
27PLUGIN_HEADER 27PLUGIN_HEADER
28 28
29/* this is the plugin entry point */ 29/* this is the plugin entry point */
30enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 30enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
31{ 31{
32 return run_overlay(api, parameter, PLUGIN_GAMES_DIR "/rockboy.ovl", "RockBoy"); 32 return run_overlay(api, parameter, PLUGIN_GAMES_DIR "/rockboy.ovl", "RockBoy");
33} 33}
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index d48a06957e..71ab4e78d7 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -99,7 +99,7 @@ static const unsigned char ramsize_table[5] =
99 0, 1, 1, 4, 16 99 0, 1, 1, 4, 16
100}; 100};
101 101
102static char *romfile; 102static const char *romfile;
103static char sramfile[500]; 103static char sramfile[500];
104static char rtcfile[500]; 104static char rtcfile[500];
105static char saveprefix[500]; 105static char saveprefix[500];
@@ -284,7 +284,7 @@ void cleanup(void)
284 /* IDEA - if error, write emergency savestate..? */ 284 /* IDEA - if error, write emergency savestate..? */
285} 285}
286 286
287void loader_init(char *s) 287void loader_init(const char *s)
288{ 288{
289 romfile = s; 289 romfile = s;
290 if(rom_load()) 290 if(rom_load())
diff --git a/apps/plugins/rockboy/loader.h b/apps/plugins/rockboy/loader.h
index 33217d55f3..5ade6e7d8a 100644
--- a/apps/plugins/rockboy/loader.h
+++ b/apps/plugins/rockboy/loader.h
@@ -3,7 +3,7 @@
3#ifndef __LOADER_H__ 3#ifndef __LOADER_H__
4#define __LOADER_H__ 4#define __LOADER_H__
5 5
6void loader_init(char *s); 6void loader_init(const char *s);
7void cleanup(void); 7void cleanup(void);
8 8
9#endif 9#endif
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 58696a1f61..a0e87d041d 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -30,7 +30,7 @@ PLUGIN_IRAM_DECLARE
30/* here is a global api struct pointer. while not strictly necessary, 30/* here is a global api struct pointer. while not strictly necessary,
31 it's nice not to have to pass the api pointer in all function calls 31 it's nice not to have to pass the api pointer in all function calls
32 in the plugin */ 32 in the plugin */
33struct plugin_api* rb; 33const struct plugin_api* rb;
34int shut,cleanshut; 34int shut,cleanshut;
35char *errormsg; 35char *errormsg;
36 36
@@ -275,7 +275,7 @@ void doevents(void)
275 } 275 }
276} 276}
277 277
278static int gnuboy_main(char *rom) 278static int gnuboy_main(const char *rom)
279{ 279{
280 rb->lcd_puts(0,0,"Init video"); 280 rb->lcd_puts(0,0,"Init video");
281 vid_init(); 281 vid_init();
@@ -297,7 +297,7 @@ static int gnuboy_main(char *rom)
297} 297}
298 298
299/* this is the plugin entry point */ 299/* this is the plugin entry point */
300enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 300enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
301{ 301{
302 PLUGIN_IRAM_INIT(api) 302 PLUGIN_IRAM_INIT(api)
303 303
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index 89cb845ec2..18e4d5c255 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -26,7 +26,7 @@
26#define malloc(a) my_malloc(a) 26#define malloc(a) my_malloc(a)
27void *my_malloc(size_t size); 27void *my_malloc(size_t size);
28 28
29extern struct plugin_api* rb; 29extern const struct plugin_api* rb;
30extern int shut,cleanshut; 30extern int shut,cleanshut;
31void vid_init(void); 31void vid_init(void);
32inline void vid_begin(void); 32inline void vid_begin(void);
diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c
index 49e1e8fc33..507f131322 100644
--- a/apps/plugins/rocklife.c
+++ b/apps/plugins/rocklife.c
@@ -77,7 +77,7 @@ PLUGIN_HEADER
77#define PATTERN_ACORN 3 77#define PATTERN_ACORN 3
78#define PATTERN_GLIDER_GUN 4 /* not yet implemented */ 78#define PATTERN_GLIDER_GUN 4 /* not yet implemented */
79 79
80static struct plugin_api* rb; 80static const struct plugin_api* rb;
81const struct button_mapping *plugin_contexts[] 81const struct button_mapping *plugin_contexts[]
82= {generic_directions, generic_actions}; 82= {generic_directions, generic_actions};
83 83
@@ -393,7 +393,7 @@ static void next_generation(char *pgrid, char *pnext_grid){
393/**********************************/ 393/**********************************/
394/* this is the plugin entry point */ 394/* this is the plugin entry point */
395/**********************************/ 395/**********************************/
396enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 396enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
397{ 397{
398 int button = 0; 398 int button = 0;
399 int quit = 0; 399 int quit = 0;
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 997cbef0f3..e612d458bb 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -256,7 +256,7 @@ static void inv_cursor(bool update);
256static void restore_screen(void); 256static void restore_screen(void);
257static void clear_drawing(void); 257static void clear_drawing(void);
258static void goto_menu(void); 258static void goto_menu(void);
259static int load_bitmap( char *filename ); 259static int load_bitmap( const char *filename );
260static int save_bitmap( char *filename ); 260static int save_bitmap( char *filename );
261static void draw_rect_full( int x1, int y1, int x2, int y2 ); 261static void draw_rect_full( int x1, int y1, int x2, int y2 );
262extern int errno; 262extern int errno;
@@ -269,7 +269,7 @@ extern int errno;
269int errno; 269int errno;
270#endif 270#endif
271 271
272static struct plugin_api* rb; 272static const struct plugin_api* rb;
273 273
274MEM_FUNCTION_WRAPPERS(rb); 274MEM_FUNCTION_WRAPPERS(rb);
275 275
@@ -2953,7 +2953,7 @@ static bool rockpaint_loop( void )
2953 return PLUGIN_OK; 2953 return PLUGIN_OK;
2954} 2954}
2955 2955
2956static int load_bitmap( char *file ) 2956static int load_bitmap( const char *file )
2957{ 2957{
2958 struct bitmap bm; 2958 struct bitmap bm;
2959 bool ret; 2959 bool ret;
@@ -2992,7 +2992,7 @@ static int save_bitmap( char *file )
2992 return save_bmp_file( file, &bm, rb ); 2992 return save_bmp_file( file, &bm, rb );
2993} 2993}
2994 2994
2995enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2995enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
2996{ 2996{
2997 /** must have stuff **/ 2997 /** must have stuff **/
2998 rb = api; 2998 rb = api;
diff --git a/apps/plugins/search.c b/apps/plugins/search.c
index 097f4ac7d5..5f034ef8ae 100644
--- a/apps/plugins/search.c
+++ b/apps/plugins/search.c
@@ -22,7 +22,7 @@
22 22
23PLUGIN_HEADER 23PLUGIN_HEADER
24 24
25static struct plugin_api* rb; 25static const struct plugin_api* rb;
26 26
27#define BUFFER_SIZE 16384 27#define BUFFER_SIZE 16384
28 28
@@ -114,7 +114,7 @@ static void clear_display(void){
114 } 114 }
115} 115}
116 116
117static bool search_init(char* file){ 117static bool search_init(const char* file){
118 rb->memset(search_string, 0, sizeof(search_string)); 118 rb->memset(search_string, 0, sizeof(search_string));
119 119
120 if (!rb->kbd_input(search_string,sizeof search_string)){ 120 if (!rb->kbd_input(search_string,sizeof search_string)){
@@ -144,10 +144,10 @@ static bool search_init(char* file){
144} 144}
145 145
146/* this is the plugin entry point */ 146/* this is the plugin entry point */
147enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 147enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
148{ 148{
149 int ok; 149 int ok;
150 char *filename = parameter; 150 const char *filename = parameter;
151 char *p; 151 char *p;
152 152
153 rb = api; 153 rb = api;
diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c
index 62d3a91fa7..944714eb2f 100644
--- a/apps/plugins/searchengine/searchengine.c
+++ b/apps/plugins/searchengine/searchengine.c
@@ -26,7 +26,7 @@ PLUGIN_HEADER
26void *audio_bufferbase; 26void *audio_bufferbase;
27void *audio_bufferpointer; 27void *audio_bufferpointer;
28size_t audio_buffer_free; 28size_t audio_buffer_free;
29struct plugin_api* rb; 29const struct plugin_api* rb;
30int w, h, y; 30int w, h, y;
31 31
32void *my_malloc(size_t size) 32void *my_malloc(size_t size)
@@ -56,7 +56,7 @@ void setmallocpos(void *pointer)
56} 56}
57 57
58/* this is the plugin entry point */ 58/* this is the plugin entry point */
59enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 59enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
60{ 60{
61 unsigned char *result,buf[500]; 61 unsigned char *result,buf[500];
62 int parsefd,hits; 62 int parsefd,hits;
diff --git a/apps/plugins/searchengine/searchengine.h b/apps/plugins/searchengine/searchengine.h
index 07248ef37e..b0f6597971 100644
--- a/apps/plugins/searchengine/searchengine.h
+++ b/apps/plugins/searchengine/searchengine.h
@@ -38,7 +38,7 @@ rb->lcd_update()
38rb->lcd_update() 38rb->lcd_update()
39#endif 39#endif
40 40
41extern struct plugin_api* rb; 41extern const struct plugin_api* rb;
42 42
43void *my_malloc(size_t size); 43void *my_malloc(size_t size);
44void setmallocpos(void *pointer); 44void setmallocpos(void *pointer);
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h
index 34f200d193..2d2c705a66 100644
--- a/apps/plugins/shortcuts/shortcuts.h
+++ b/apps/plugins/shortcuts/shortcuts.h
@@ -32,7 +32,7 @@
32 32
33#define SHORTCUTS_FILENAME "/shortcuts.link" 33#define SHORTCUTS_FILENAME "/shortcuts.link"
34 34
35extern struct plugin_api* rb; 35extern const struct plugin_api* rb;
36 36
37typedef struct sc_entry_s 37typedef struct sc_entry_s
38{ 38{
diff --git a/apps/plugins/shortcuts/shortcuts_append.c b/apps/plugins/shortcuts/shortcuts_append.c
index afd03929ae..4174bdd2d8 100644
--- a/apps/plugins/shortcuts/shortcuts_append.c
+++ b/apps/plugins/shortcuts/shortcuts_append.c
@@ -49,7 +49,7 @@ bool append_entry_to_file(sc_file_t *file, char *path, bool is_dir)
49} 49}
50 50
51 51
52enum plugin_status plugin_start(struct plugin_api* api, void* void_parameter) 52enum plugin_status plugin_start(const struct plugin_api* api, const void* void_parameter)
53{ 53{
54 rb = api; 54 rb = api;
55 bool found; 55 bool found;
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c
index 5e7d9c2b00..47f0203b87 100644
--- a/apps/plugins/shortcuts/shortcuts_view.c
+++ b/apps/plugins/shortcuts/shortcuts_view.c
@@ -198,7 +198,7 @@ bool ends_with(char *string, char *suffix)
198} 198}
199 199
200 200
201enum plugin_status plugin_start(struct plugin_api* api, void* void_parameter) 201enum plugin_status plugin_start(const struct plugin_api* api, const void* void_parameter)
202{ 202{
203 rb = api; 203 rb = api;
204 bool leave_loop; 204 bool leave_loop;
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index 1e99a7adaf..36c95b9dda 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -184,7 +184,7 @@ PLUGIN_HEADER
184#define IMAGE_HEIGHT BMPHEIGHT_sliding_puzzle 184#define IMAGE_HEIGHT BMPHEIGHT_sliding_puzzle
185#define IMAGE_SIZE IMAGE_WIDTH 185#define IMAGE_SIZE IMAGE_WIDTH
186 186
187static struct plugin_api* rb; 187static const struct plugin_api* rb;
188 188
189/* use a square image, (the default Archos bitmap looks square on its display) 189/* use a square image, (the default Archos bitmap looks square on its display)
190 Puzzle image dimension is min(lcd_height,lcd_width) 190 Puzzle image dimension is min(lcd_height,lcd_width)
@@ -603,7 +603,7 @@ static int puzzle_loop(void)
603 } 603 }
604} 604}
605 605
606enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 606enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
607{ 607{
608 int i, w, h; 608 int i, w, h;
609 609
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index 6203a07a23..471b72f6b1 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -174,7 +174,7 @@ PLUGIN_HEADER
174static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength; 174static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength;
175static unsigned int score,hiscore=0,level=1; 175static unsigned int score,hiscore=0,level=1;
176static short dir,frames,apple,dead=0; 176static short dir,frames,apple,dead=0;
177static struct plugin_api* rb; 177static const struct plugin_api* rb;
178 178
179void die (void) 179void die (void)
180{ 180{
@@ -432,7 +432,7 @@ void game_init(void) {
432 } 432 }
433} 433}
434 434
435enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 435enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
436{ 436{
437 (void)(parameter); 437 (void)(parameter);
438 rb = api; 438 rb = api;
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index 0452294195..625e5c5a6a 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -354,7 +354,7 @@ static int apple;
354static int level = 4, speed = 5,dead = 0, quit = 0; 354static int level = 4, speed = 5,dead = 0, quit = 0;
355static int sillydir = 0, num_levels = 0; 355static int sillydir = 0, num_levels = 0;
356static int level_from_file = 0; 356static int level_from_file = 0;
357static struct plugin_api* rb; 357static const struct plugin_api* rb;
358static int headx, heady, tailx, taily, applecountdown = 5; 358static int headx, heady, tailx, taily, applecountdown = 5;
359static int game_type = 0; 359static int game_type = 0;
360static int num_apples_to_get=1; 360static int num_apples_to_get=1;
@@ -1398,7 +1398,7 @@ void game_init(void)
1398 1398
1399} 1399}
1400 1400
1401enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1401enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1402{ 1402{
1403 (void)(parameter); 1403 (void)(parameter);
1404 rb = api; 1404 rb = api;
diff --git a/apps/plugins/snow.c b/apps/plugins/snow.c
index 6550050646..becc7d871a 100644
--- a/apps/plugins/snow.c
+++ b/apps/plugins/snow.c
@@ -70,7 +70,7 @@ PLUGIN_HEADER
70#endif 70#endif
71 71
72static short particles[NUM_PARTICLES][2]; 72static short particles[NUM_PARTICLES][2];
73static struct plugin_api* rb; 73static const struct plugin_api* rb;
74 74
75#ifdef HAVE_LCD_BITMAP 75#ifdef HAVE_LCD_BITMAP
76#if LCD_WIDTH >= 160 76#if LCD_WIDTH >= 160
@@ -185,7 +185,7 @@ static void snow_init(void)
185#endif 185#endif
186} 186}
187 187
188enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 188enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
189{ 189{
190 int button; 190 int button;
191 (void)(parameter); 191 (void)(parameter);
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index 2b12a3da58..bc5bf42e8d 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -372,7 +372,7 @@ static struct BufferedBoards {
372} buffered_boards; 372} buffered_boards;
373 373
374 374
375static struct plugin_api* rb; 375static const struct plugin_api* rb;
376MEM_FUNCTION_WRAPPERS(rb); 376MEM_FUNCTION_WRAPPERS(rb);
377 377
378static char buf[ROWS*(COLS + 1)]; /* Enough for a whole board or a filename */ 378static char buf[ROWS*(COLS + 1)]; /* Enough for a whole board or a filename */
@@ -1576,7 +1576,7 @@ static bool sokoban_loop(void)
1576} 1576}
1577 1577
1578 1578
1579enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1579enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1580{ 1580{
1581 int w, h; 1581 int w, h;
1582 1582
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 0907054a1c..d16b65c549 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -28,7 +28,7 @@
28 28
29PLUGIN_HEADER 29PLUGIN_HEADER
30 30
31static struct plugin_api* rb; 31static const struct plugin_api* rb;
32#define min(a,b) (a<b?a:b) 32#define min(a,b) (a<b?a:b)
33 33
34/** 34/**
@@ -1843,7 +1843,7 @@ int solitaire( int skipmenu )
1843 * Plugin entry point 1843 * Plugin entry point
1844 */ 1844 */
1845 1845
1846enum plugin_status plugin_start( struct plugin_api* api, void* parameter ) 1846enum plugin_status plugin_start( const struct plugin_api* api, const void* parameter )
1847{ 1847{
1848 int result; 1848 int result;
1849 1849
diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c
index f99549ebd7..571978cf1c 100644
--- a/apps/plugins/sort.c
+++ b/apps/plugins/sort.c
@@ -57,7 +57,7 @@
57 57
58PLUGIN_HEADER 58PLUGIN_HEADER
59 59
60static struct plugin_api* rb; 60static const struct plugin_api* rb;
61 61
62ssize_t buf_size; 62ssize_t buf_size;
63static char *filename; 63static char *filename;
@@ -176,7 +176,7 @@ static int write_file(void)
176 return 0; 176 return 0;
177} 177}
178 178
179enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 179enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
180{ 180{
181 char *buf; 181 char *buf;
182 int rc; 182 int rc;
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c
index bfddb453dc..8db5ff92cf 100644
--- a/apps/plugins/spacerocks.c
+++ b/apps/plugins/spacerocks.c
@@ -25,7 +25,7 @@
25PLUGIN_HEADER 25PLUGIN_HEADER
26 26
27/******************************* Globals ***********************************/ 27/******************************* Globals ***********************************/
28static struct plugin_api* rb; /* global api struct pointer */ 28static const struct plugin_api* rb; /* global api struct pointer */
29/* variable button definitions */ 29/* variable button definitions */
30#if CONFIG_KEYPAD == RECORDER_PAD 30#if CONFIG_KEYPAD == RECORDER_PAD
31#define AST_PAUSE BUTTON_ON 31#define AST_PAUSE BUTTON_ON
@@ -2022,7 +2022,7 @@ enum plugin_status start_game(void)
2022 } 2022 }
2023} 2023}
2024 2024
2025enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2025enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
2026{ 2026{
2027 enum plugin_status retval; 2027 enum plugin_status retval;
2028 (void)(parameter); 2028 (void)(parameter);
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c
index ab4ce415b7..419ce7a676 100644
--- a/apps/plugins/splitedit.c
+++ b/apps/plugins/splitedit.c
@@ -97,7 +97,7 @@ unsigned char SCALE_BMP[][13] =
97#define SE_COUNT 5 97#define SE_COUNT 5
98 98
99/* the global api pointer */ 99/* the global api pointer */
100static struct plugin_api* rb; 100static const struct plugin_api* rb;
101 101
102/* contains the file name of the song that is to be split */ 102/* contains the file name of the song that is to be split */
103static char path_mp3[MAX_PATH]; 103static char path_mp3[MAX_PATH];
@@ -1248,7 +1248,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
1248 return retval; 1248 return retval;
1249} 1249}
1250 1250
1251enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1251enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1252{ 1252{
1253 struct mp3entry* mp3; 1253 struct mp3entry* mp3;
1254 1254
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index 46780f9ea7..1b7c4d01b5 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -310,7 +310,7 @@ static char board[STAR_HEIGHT][STAR_WIDTH];
310static int char_width = -1; 310static int char_width = -1;
311static int char_height = -1; 311static int char_height = -1;
312 312
313static struct plugin_api* rb; 313static const struct plugin_api* rb;
314 314
315/* this arrays contains a group of levels loaded into memory */ 315/* this arrays contains a group of levels loaded into memory */
316static unsigned char* levels = 316static unsigned char* levels =
@@ -1101,7 +1101,7 @@ static int star_menu(void)
1101/** 1101/**
1102 * Main entry point 1102 * Main entry point
1103 */ 1103 */
1104enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1104enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1105{ 1105{
1106 (void)parameter; 1106 (void)parameter;
1107 rb = api; 1107 rb = api;
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c
index 754af24f8c..130e077cc7 100644
--- a/apps/plugins/starfield.c
+++ b/apps/plugins/starfield.c
@@ -24,7 +24,7 @@ PLUGIN_HEADER
24 24
25/******************************* Globals ***********************************/ 25/******************************* Globals ***********************************/
26 26
27static struct plugin_api* rb; /* global api struct pointer */ 27static const struct plugin_api* rb; /* global api struct pointer */
28 28
29/* Key assignement */ 29/* Key assignement */
30#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ 30#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
@@ -169,7 +169,7 @@ static struct plugin_api* rb; /* global api struct pointer */
169 169
170#define MSG_DISP_TIME 30 170#define MSG_DISP_TIME 30
171 171
172static struct plugin_api* rb; /* global api struct pointer */ 172static const struct plugin_api* rb; /* global api struct pointer */
173 173
174/* 174/*
175 * Each star's stuffs 175 * Each star's stuffs
@@ -432,7 +432,7 @@ int plugin_main(void)
432 432
433/*************************** Plugin entry point ****************************/ 433/*************************** Plugin entry point ****************************/
434 434
435enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 435enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
436{ 436{
437 int ret; 437 int ret;
438 438
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index a65fde4704..be73e23406 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -20,7 +20,7 @@
20 20
21PLUGIN_HEADER 21PLUGIN_HEADER
22 22
23static struct plugin_api* rb; 23static const struct plugin_api* rb;
24static int files, dirs, musicfiles, largestdir; 24static int files, dirs, musicfiles, largestdir;
25static int lasttick; 25static int lasttick;
26static bool abort; 26static bool abort;
@@ -183,7 +183,7 @@ void traversedir(char* location, char* name)
183 largestdir = files_in_dir; 183 largestdir = files_in_dir;
184} 184}
185 185
186enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 186enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
187{ 187{
188 int button; 188 int button;
189 189
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c
index 18ad1c48cb..ece19b1e82 100644
--- a/apps/plugins/stopwatch.c
+++ b/apps/plugins/stopwatch.c
@@ -171,7 +171,7 @@ PLUGIN_HEADER
171#endif 171#endif
172#endif 172#endif
173 173
174static struct plugin_api* rb; 174static const struct plugin_api* rb;
175 175
176static int stopwatch = 0; 176static int stopwatch = 0;
177static long start_at = 0; 177static long start_at = 0;
@@ -228,7 +228,7 @@ static void ticks_to_string(int ticks,int lap,int buflen, char * buf)
228 } 228 }
229} 229}
230 230
231enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 231enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
232{ 232{
233 char buf[32]; 233 char buf[32];
234 int button; 234 int button;
diff --git a/apps/plugins/sudoku/generator.c b/apps/plugins/sudoku/generator.c
index eaef8c0f17..56dce48cc2 100644
--- a/apps/plugins/sudoku/generator.c
+++ b/apps/plugins/sudoku/generator.c
@@ -35,7 +35,7 @@
35#include "sudoku.h" 35#include "sudoku.h"
36#include "templates.h" 36#include "templates.h"
37 37
38extern struct plugin_api* rb; 38extern const struct plugin_api* rb;
39 39
40#define assert(x) 40#define assert(x)
41 41
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c
index d76b68ef27..64a6c8d7c9 100644
--- a/apps/plugins/sudoku/sudoku.c
+++ b/apps/plugins/sudoku/sudoku.c
@@ -80,7 +80,7 @@ PLUGIN_HEADER
80 it's nice not to have to pass the api pointer in all function calls 80 it's nice not to have to pass the api pointer in all function calls
81 in the plugin */ 81 in the plugin */
82 82
83struct plugin_api* rb; 83const struct plugin_api* rb;
84 84
85/* Default game - used to initialise sudoku.ss if it doesn't exist. */ 85/* Default game - used to initialise sudoku.ss if it doesn't exist. */
86static const char default_game[9][9] = 86static const char default_game[9][9] =
@@ -1188,7 +1188,7 @@ void move_cursor(struct sudoku_state_t* state, int newx, int newy)
1188} 1188}
1189 1189
1190/* plugin entry point */ 1190/* plugin entry point */
1191enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1191enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
1192{ 1192{
1193 bool exit; 1193 bool exit;
1194 int button; 1194 int button;
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c
index e99d456454..4f5cc53086 100644
--- a/apps/plugins/superdom.c
+++ b/apps/plugins/superdom.c
@@ -18,7 +18,7 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "plugin.h" 19#include "plugin.h"
20PLUGIN_HEADER 20PLUGIN_HEADER
21static struct plugin_api* rb; 21static const struct plugin_api* rb;
22 22
23extern const fb_data superdom_boarditems[]; 23extern const fb_data superdom_boarditems[];
24char buf[255]; 24char buf[255];
@@ -2153,7 +2153,7 @@ void computer_war(void) {
2153 } 2153 }
2154} 2154}
2155 2155
2156int load_game(char* file) { 2156static int load_game(const char* file) {
2157 int fd; 2157 int fd;
2158 2158
2159 fd = rb->open(file, O_RDONLY); 2159 fd = rb->open(file, O_RDONLY);
@@ -2222,7 +2222,7 @@ int average_strength(bool colour) {
2222 return totalpower/100; 2222 return totalpower/100;
2223} 2223}
2224 2224
2225enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2225enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
2226{ 2226{
2227 int tempmenu; 2227 int tempmenu;
2228 bool statusbar_setting; 2228 bool statusbar_setting;
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index 69d905a37e..40b1bfdd32 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -30,7 +30,7 @@ PLUGIN_HEADER
30#define TESTCODEC_EXITBUTTON BUTTON_SELECT 30#define TESTCODEC_EXITBUTTON BUTTON_SELECT
31#endif 31#endif
32 32
33static struct plugin_api* rb; 33static const struct plugin_api* rb;
34 34
35CACHE_FUNCTION_WRAPPERS(rb) 35CACHE_FUNCTION_WRAPPERS(rb)
36 36
@@ -629,7 +629,7 @@ exit:
629} 629}
630 630
631/* plugin entry point */ 631/* plugin entry point */
632enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 632enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
633{ 633{
634 uintptr_t* codec_stack_copy; 634 uintptr_t* codec_stack_copy;
635 int result, selection = 0; 635 int result, selection = 0;
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c
index 27dbdb3334..93464807c3 100644
--- a/apps/plugins/test_disk.c
+++ b/apps/plugins/test_disk.c
@@ -34,7 +34,7 @@ PLUGIN_HEADER
34#endif 34#endif
35#define TEST_TIME 10 /* in seconds */ 35#define TEST_TIME 10 /* in seconds */
36 36
37static struct plugin_api* rb; 37static const struct plugin_api* rb;
38static unsigned char* audiobuf; 38static unsigned char* audiobuf;
39static ssize_t audiobuflen; 39static ssize_t audiobuflen;
40 40
@@ -404,7 +404,7 @@ static bool test_speed(void)
404 404
405 405
406/* this is the plugin entry point */ 406/* this is the plugin entry point */
407enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 407enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
408{ 408{
409 static const struct menu_item items[] = { 409 static const struct menu_item items[] = {
410 { "Disk speed", test_speed }, 410 { "Disk speed", test_speed },
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index 46a94a91ec..0852e0a9fb 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -39,7 +39,7 @@ PLUGIN_IRAM_DECLARE
39 39
40PLUGIN_HEADER 40PLUGIN_HEADER
41 41
42static struct plugin_api* rb; 42static const struct plugin_api* rb;
43 43
44/* Screen logging */ 44/* Screen logging */
45static int line; 45static int line;
@@ -334,7 +334,7 @@ static void time_greyscale(void)
334#endif 334#endif
335 335
336/* plugin entry point */ 336/* plugin entry point */
337enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 337enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
338{ 338{
339#ifndef SIMULATOR 339#ifndef SIMULATOR
340 char str[32]; 340 char str[32];
diff --git a/apps/plugins/test_grey.c b/apps/plugins/test_grey.c
index a413854332..5d836633de 100644
--- a/apps/plugins/test_grey.c
+++ b/apps/plugins/test_grey.c
@@ -105,7 +105,7 @@ static const unsigned char dither_matrix[16][16] = {
105static unsigned char input_levels[STEPS+1]; 105static unsigned char input_levels[STEPS+1];
106static unsigned char lcd_levels[STEPS+1]; 106static unsigned char lcd_levels[STEPS+1];
107 107
108static struct plugin_api* rb; 108static const struct plugin_api* rb;
109static unsigned char *gbuf; 109static unsigned char *gbuf;
110static size_t gbuf_size = 0; 110static size_t gbuf_size = 0;
111 111
@@ -136,7 +136,7 @@ static void fill_rastered(int bx, int by, int bw, int bh, int step)
136} 136}
137 137
138/* plugin entry point */ 138/* plugin entry point */
139enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 139enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
140{ 140{
141 bool done = false; 141 bool done = false;
142 int cur_step = 1; 142 int cur_step = 1;
diff --git a/apps/plugins/test_resize.c b/apps/plugins/test_resize.c
index c50bc5f91c..218da2a625 100644
--- a/apps/plugins/test_resize.c
+++ b/apps/plugins/test_resize.c
@@ -28,7 +28,7 @@
28 28
29PLUGIN_HEADER 29PLUGIN_HEADER
30 30
31static struct plugin_api* rb; 31static const struct plugin_api* rb;
32 32
33const struct button_mapping *plugin_contexts[] 33const struct button_mapping *plugin_contexts[]
34= {generic_actions, generic_directions}; 34= {generic_actions, generic_directions};
@@ -62,7 +62,7 @@ static fb_data output_bmp_data[MAX_OUTPUT_WIDTH*MAX_OUTPUT_HEIGHT];
62 62
63 63
64/* this is the plugin entry point */ 64/* this is the plugin entry point */
65enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 65enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
66{ 66{
67 (void)parameter; 67 (void)parameter;
68 68
diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c
index 2cd95d7983..a036844880 100644
--- a/apps/plugins/test_sampr.c
+++ b/apps/plugins/test_sampr.c
@@ -21,7 +21,7 @@
21 21
22PLUGIN_HEADER 22PLUGIN_HEADER
23 23
24struct plugin_api *rb; 24const struct plugin_api *rb;
25 25
26enum 26enum
27{ 27{
@@ -253,7 +253,7 @@ void set_waveform(void)
253 253
254/* Tests hardware sample rate switching */ 254/* Tests hardware sample rate switching */
255/* TODO: needs a volume control */ 255/* TODO: needs a volume control */
256enum plugin_status plugin_start(struct plugin_api *api, void *parameter) 256enum plugin_status plugin_start(const struct plugin_api *api, const void *parameter)
257{ 257{
258 static const struct menu_item items[] = 258 static const struct menu_item items[] =
259 { 259 {
diff --git a/apps/plugins/test_scanrate.c b/apps/plugins/test_scanrate.c
index bd189bc85e..995e64a257 100644
--- a/apps/plugins/test_scanrate.c
+++ b/apps/plugins/test_scanrate.c
@@ -107,7 +107,7 @@ PLUGIN_HEADER
107#define NEED_BOOST 107#define NEED_BOOST
108#endif 108#endif
109 109
110static struct plugin_api* rb; 110static const struct plugin_api* rb;
111static unsigned char bitbuffer[2][BUF_HEIGHT][BUF_WIDTH]; 111static unsigned char bitbuffer[2][BUF_HEIGHT][BUF_WIDTH];
112static int curbuf = 0; 112static int curbuf = 0;
113static int scan_rate = DEFAULT_SCAN_RATE; 113static int scan_rate = DEFAULT_SCAN_RATE;
@@ -210,7 +210,7 @@ int plugin_main(void)
210 210
211 211
212/* this is the plugin entry point */ 212/* this is the plugin entry point */
213enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 213enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
214{ 214{
215 (void)parameter; 215 (void)parameter;
216 rb = api; 216 rb = api;
diff --git a/apps/plugins/test_touchpad.c b/apps/plugins/test_touchpad.c
index 2970f6fbf4..a9ad96eb32 100644
--- a/apps/plugins/test_touchpad.c
+++ b/apps/plugins/test_touchpad.c
@@ -28,10 +28,10 @@ PLUGIN_HEADER
28#define TOUCHPAD_TOGGLE BUTTON_RC_MODE 28#define TOUCHPAD_TOGGLE BUTTON_RC_MODE
29#endif 29#endif
30 30
31static struct plugin_api* rb; 31static const struct plugin_api* rb;
32 32
33/* plugin entry point */ 33/* plugin entry point */
34enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 34enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
35{ 35{
36 int button = 0; 36 int button = 0;
37 enum touchpad_mode mode = TOUCHPAD_BUTTON; 37 enum touchpad_mode mode = TOUCHPAD_BUTTON;
diff --git a/apps/plugins/test_viewports.c b/apps/plugins/test_viewports.c
index 1f1e99a0ff..bb1b4b9af9 100644
--- a/apps/plugins/test_viewports.c
+++ b/apps/plugins/test_viewports.c
@@ -21,7 +21,7 @@
21 21
22PLUGIN_HEADER 22PLUGIN_HEADER
23 23
24static struct plugin_api* rb; 24static const struct plugin_api* rb;
25 25
26#ifdef HAVE_LCD_BITMAP 26#ifdef HAVE_LCD_BITMAP
27 27
@@ -157,7 +157,7 @@ static struct viewport rvp1 =
157#endif 157#endif
158 158
159 159
160enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 160enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
161{ 161{
162 (void)parameter; 162 (void)parameter;
163 char buf[80]; 163 char buf[80];
@@ -278,7 +278,7 @@ static struct viewport vp2 =
278}; 278};
279 279
280 280
281enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 281enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
282{ 282{
283 (void)parameter; 283 (void)parameter;
284 284
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index 617155fb2b..0edde54e75 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -26,7 +26,7 @@
26#endif 26#endif
27#define MAX_LINE_LEN 2048 27#define MAX_LINE_LEN 2048
28PLUGIN_HEADER 28PLUGIN_HEADER
29static struct plugin_api* rb; 29static const struct plugin_api* rb;
30 30
31static char buffer[MAX_CHARS]; 31static char buffer[MAX_CHARS];
32static char eol[3]; 32static char eol[3];
@@ -118,8 +118,8 @@ int _do_action(int action, char* str, int line)
118char *list_get_name_cb(int selected_item, void* data, 118char *list_get_name_cb(int selected_item, void* data,
119 char* buf, size_t buf_len) 119 char* buf, size_t buf_len)
120{ 120{
121 char *b = &buffer[do_action(ACTION_GET,0,selected_item)];
122 (void)data; 121 (void)data;
122 char *b = &buffer[do_action(ACTION_GET,0,selected_item)];
123 if (rb->strlen(b) >= buf_len) 123 if (rb->strlen(b) >= buf_len)
124 { 124 {
125 char t = b[buf_len-10]; 125 char t = b[buf_len-10];
@@ -306,7 +306,7 @@ int hex_to_rgb(const char* hex, int* color)
306#endif /* HAVE_LCD_COLOR */ 306#endif /* HAVE_LCD_COLOR */
307 307
308/* this is the plugin entry point */ 308/* this is the plugin entry point */
309enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 309enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
310{ 310{
311 int fd; 311 int fd;
312 static char temp_line[MAX_LINE_LEN]; 312 static char temp_line[MAX_LINE_LEN];
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index 665a2aae5e..85a61cbfc3 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -20,7 +20,7 @@
20 20
21PLUGIN_HEADER 21PLUGIN_HEADER
22 22
23static struct plugin_api* rb; 23static const struct plugin_api* rb;
24 24
25static char *audiobuf; 25static char *audiobuf;
26static ssize_t audiobuflen; 26static ssize_t audiobuflen;
@@ -36,7 +36,7 @@ static void xingupdate(int percent)
36 rb->lcd_update(); 36 rb->lcd_update();
37} 37}
38 38
39static int insert_data_in_file(char *fname, int fpos, char *buf, int num_bytes) 39static int insert_data_in_file(const char *fname, int fpos, char *buf, int num_bytes)
40{ 40{
41 int readlen; 41 int readlen;
42 int rc; 42 int rc;
@@ -126,7 +126,7 @@ static const unsigned char empty_id3_header[] =
126 0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */ 126 0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */
127}; 127};
128 128
129static bool vbr_fix(char *selected_file) 129static bool vbr_fix(const char *selected_file)
130{ 130{
131 struct mp3entry entry; 131 struct mp3entry entry;
132 int fd; 132 int fd;
@@ -261,7 +261,7 @@ static bool vbr_fix(char *selected_file)
261 return false; 261 return false;
262} 262}
263 263
264enum plugin_status plugin_start(struct plugin_api* api, void *parameter) 264enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter)
265{ 265{
266 rb = api; 266 rb = api;
267 267
diff --git a/apps/plugins/video.c b/apps/plugins/video.c
index 3e7e53aec8..f1f6533f4f 100644
--- a/apps/plugins/video.c
+++ b/apps/plugins/video.c
@@ -141,7 +141,7 @@ typedef struct /* the little header for all audio blocks */
141 141
142/****************** globals ******************/ 142/****************** globals ******************/
143 143
144static struct plugin_api* rb; /* here is a global api struct pointer */ 144static const struct plugin_api* rb; /* here is a global api struct pointer */
145static char gPrint[32]; /* a global printf buffer, saves stack */ 145static char gPrint[32]; /* a global printf buffer, saves stack */
146 146
147 147
@@ -986,7 +986,7 @@ int main(char* filename)
986 986
987/***************** Plugin Entry Point *****************/ 987/***************** Plugin Entry Point *****************/
988 988
989enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 989enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
990{ 990{
991 rb = api; /* copy to global api pointer */ 991 rb = api; /* copy to global api pointer */
992 992
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c
index 885ac70bea..cd0d3694ba 100644
--- a/apps/plugins/viewer.c
+++ b/apps/plugins/viewer.c
@@ -357,7 +357,7 @@ static int display_lines; /* number of lines on the display */
357static int draw_columns; /* number of (pixel) columns available for text */ 357static int draw_columns; /* number of (pixel) columns available for text */
358static int par_indent_spaces; /* number of spaces to indent first paragraph */ 358static int par_indent_spaces; /* number of spaces to indent first paragraph */
359static int fd; 359static int fd;
360static char *file_name; 360static const char *file_name;
361static long file_size; 361static long file_size;
362static long start_position; /* position in the file after the viewer is started */ 362static long start_position; /* position in the file after the viewer is started */
363static bool mac_text; 363static bool mac_text;
@@ -368,7 +368,7 @@ static unsigned char *screen_top_ptr;
368static unsigned char *next_screen_ptr; 368static unsigned char *next_screen_ptr;
369static unsigned char *next_screen_to_draw_ptr; 369static unsigned char *next_screen_to_draw_ptr;
370static unsigned char *next_line_ptr; 370static unsigned char *next_line_ptr;
371static struct plugin_api* rb; 371static const struct plugin_api* rb;
372#ifdef HAVE_LCD_BITMAP 372#ifdef HAVE_LCD_BITMAP
373static struct font *pf; 373static struct font *pf;
374#endif 374#endif
@@ -1457,7 +1457,7 @@ static void viewer_menu(void)
1457 viewer_draw(col); 1457 viewer_draw(col);
1458} 1458}
1459 1459
1460enum plugin_status plugin_start(struct plugin_api* api, void* file) 1460enum plugin_status plugin_start(const struct plugin_api* api, const void* file)
1461{ 1461{
1462 int button, i, ok; 1462 int button, i, ok;
1463 int lastbutton = BUTTON_NONE; 1463 int lastbutton = BUTTON_NONE;
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index bdbab8ccf5..861adcc64c 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -648,7 +648,7 @@ void digital_meter(void) {
648 rb->lcd_hline(0,LCD_WIDTH-1,half_height+3); 648 rb->lcd_hline(0,LCD_WIDTH-1,half_height+3);
649} 649}
650 650
651enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { 651enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) {
652 int button; 652 int button;
653 int lastbutton = BUTTON_NONE; 653 int lastbutton = BUTTON_NONE;
654 654
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index f3e191d30d..45f99f7071 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -27,7 +27,7 @@ PLUGIN_HEADER
27 27
28#define SAMPLES_PER_BLOCK 22050 28#define SAMPLES_PER_BLOCK 22050
29 29
30static struct plugin_api* rb; 30static const struct plugin_api* rb;
31 31
32void *memset(void *s, int c, size_t n) { 32void *memset(void *s, int c, size_t n) {
33 return(rb->memset(s,c,n)); 33 return(rb->memset(s,c,n));
@@ -102,34 +102,35 @@ static void wvupdate (int32_t start_tick,
102 102
103static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR; 103static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR;
104 104
105static int wav2wv (char *filename) 105static int wav2wv(const char *infile)
106{ 106{
107 int in_fd, out_fd, num_chans, error = false, last_buttons; 107 int in_fd, out_fd, num_chans, error = false, last_buttons;
108 unsigned int32_t total_bytes_read = 0, total_bytes_written = 0; 108 unsigned int32_t total_bytes_read = 0, total_bytes_written = 0;
109 unsigned int32_t total_samples, samples_remaining; 109 unsigned int32_t total_samples, samples_remaining;
110 int32_t *input_buffer = (int32_t *) audiobuf; 110 int32_t *input_buffer = (int32_t *) audiobuf;
111 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000); 111 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000);
112 char *extension, save_a; 112 char outfile[MAX_PATH];
113 const char *inextension;
114 char *outextension;
113 WavpackConfig config; 115 WavpackConfig config;
114 WavpackContext *wpc; 116 WavpackContext *wpc;
115 int32_t start_tick; 117 int32_t start_tick;
116 118
117 rb->lcd_clear_display(); 119 rb->lcd_clear_display();
118 rb->lcd_puts_scroll(0, 0, (unsigned char *)filename); 120 rb->lcd_puts_scroll(0, 0, (unsigned char *)infile);
119#ifdef HAVE_LCD_BITMAP 121#ifdef HAVE_LCD_BITMAP
120 rb->lcd_update(); 122 rb->lcd_update();
121#endif 123#endif
122 124
123 last_buttons = rb->button_status (); 125 last_buttons = rb->button_status ();
124 start_tick = *rb->current_tick; 126 start_tick = *rb->current_tick;
125 extension = filename + rb->strlen (filename) - 3; 127 inextension = infile + rb->strlen(infile) - 3;
126 128 if (rb->strcasecmp (inextension, "wav")) {
127 if (rb->strcasecmp (extension, "wav")) {
128 rb->splash(HZ*2, "only for wav files!"); 129 rb->splash(HZ*2, "only for wav files!");
129 return 1; 130 return 1;
130 } 131 }
131 132
132 in_fd = rb->open(filename, O_RDONLY); 133 in_fd = rb->open(infile, O_RDONLY);
133 134
134 if (in_fd < 0) { 135 if (in_fd < 0) {
135 rb->splash(HZ*2, "could not open file!"); 136 rb->splash(HZ*2, "could not open file!");
@@ -171,14 +172,12 @@ static int wav2wv (char *filename)
171 } 172 }
172 173
173 WavpackAddWrapper (wpc, &raw_header, sizeof (raw_header)); 174 WavpackAddWrapper (wpc, &raw_header, sizeof (raw_header));
174 save_a = extension [1];
175 extension [1] = extension [2];
176 extension [2] = 0;
177
178 out_fd = rb->creat (filename);
179 175
180 extension [2] = extension [1]; 176 rb->strcpy(outfile, infile);
181 extension [1] = save_a; 177 outextension = outfile + rb->strlen(outfile) - 3;
178 outextension[1] = outextension[2];
179 outextension[2] = 0;
180 out_fd = rb->creat(outfile);
182 181
183 if (out_fd < 0) { 182 if (out_fd < 0) {
184 rb->splash(HZ*2, "could not create file!"); 183 rb->splash(HZ*2, "could not create file!");
@@ -278,12 +277,7 @@ static int wav2wv (char *filename)
278 rb->close (in_fd); 277 rb->close (in_fd);
279 278
280 if (error) { 279 if (error) {
281 save_a = extension [1]; 280 rb->remove (outfile);
282 extension [1] = extension [2];
283 extension [2] = 0;
284 rb->remove (filename);
285 extension [2] = extension [1];
286 extension [1] = save_a;
287 } 281 }
288 else 282 else
289 rb->splash(HZ*3, "operation successful"); 283 rb->splash(HZ*3, "operation successful");
@@ -291,7 +285,7 @@ static int wav2wv (char *filename)
291 return error; 285 return error;
292} 286}
293 287
294enum plugin_status plugin_start(struct plugin_api* api, void *parameter) 288enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter)
295{ 289{
296#ifdef RB_PROFILE 290#ifdef RB_PROFILE
297 /* This doesn't start profiling or anything, it just gives the 291 /* This doesn't start profiling or anything, it just gives the
diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c
index e20fa55d84..0ef7ef3584 100644
--- a/apps/plugins/wavplay.c
+++ b/apps/plugins/wavplay.c
@@ -3135,7 +3135,7 @@ void dma_end_isr(void) __attribute__((interrupt_handler));
3135 3135
3136/* variables */ 3136/* variables */
3137 3137
3138static struct plugin_api *rb; 3138static const struct plugin_api *rb;
3139 3139
3140static unsigned char *aud_buf; 3140static unsigned char *aud_buf;
3141static ssize_t aud_size; 3141static ssize_t aud_size;
@@ -3647,7 +3647,7 @@ int play_file(char* filename)
3647} 3647}
3648 3648
3649/* plugin entry point */ 3649/* plugin entry point */
3650enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 3650enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
3651{ 3651{
3652 ssize_t buf_size; 3652 ssize_t buf_size;
3653 3653
diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c
index f6969ff7b5..77e71b8b25 100644
--- a/apps/plugins/wavrecord.c
+++ b/apps/plugins/wavrecord.c
@@ -3178,7 +3178,7 @@ void rec_tick(void) __attribute__((interrupt_handler));
3178 3178
3179/* variables */ 3179/* variables */
3180 3180
3181static struct plugin_api *rb; 3181static const struct plugin_api *rb;
3182 3182
3183/* settings */ 3183/* settings */
3184struct rec_config { 3184struct rec_config {
@@ -3752,7 +3752,7 @@ static int recording_menu(void)
3752} 3752}
3753 3753
3754/* plugin entry point */ 3754/* plugin entry point */
3755enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 3755enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
3756{ 3756{
3757 ssize_t buf_size; 3757 ssize_t buf_size;
3758 int align; 3758 int align;
diff --git a/apps/plugins/wavview.c b/apps/plugins/wavview.c
index 9ce873476f..40031ac7f6 100644
--- a/apps/plugins/wavview.c
+++ b/apps/plugins/wavview.c
@@ -20,7 +20,7 @@
20 20
21PLUGIN_HEADER 21PLUGIN_HEADER
22 22
23static struct plugin_api* rb; 23static const struct plugin_api* rb;
24 24
25/* temp byte buffer */ 25/* temp byte buffer */
26uint8_t samples[10 * 1024]; /* read 10KB at the time */ 26uint8_t samples[10 * 1024]; /* read 10KB at the time */
@@ -100,7 +100,7 @@ void little_endian_to_native (void *data, char *format)
100/* read WAV file 100/* read WAV file
101 display some info about it 101 display some info about it
102 store peak info in aufiobuf for display routine */ 102 store peak info in aufiobuf for display routine */
103static int readwavpeaks(char *filename) 103static int readwavpeaks(const char *filename)
104{ 104{
105 register uint32_t bytes_read; 105 register uint32_t bytes_read;
106 register uint32_t fppmp_count; 106 register uint32_t fppmp_count;
@@ -352,7 +352,7 @@ void show_help(void)
352 rb->lcd_update(); 352 rb->lcd_update();
353} 353}
354 354
355enum plugin_status plugin_start(struct plugin_api* api, void *parameter) 355enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter)
356{ 356{
357 unsigned int quit = 0; 357 unsigned int quit = 0;
358 unsigned int action = 0; 358 unsigned int action = 0;
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c
index f84fad9e4b..f862c1b345 100644
--- a/apps/plugins/wormlet.c
+++ b/apps/plugins/wormlet.c
@@ -417,7 +417,7 @@ static int player3_dir = EAST;
417static int players = 1; 417static int players = 1;
418 418
419/* the rockbox plugin api */ 419/* the rockbox plugin api */
420static struct plugin_api* rb; 420static const struct plugin_api* rb;
421 421
422#define SETTINGS_VERSION 1 422#define SETTINGS_VERSION 1
423#define SETTINGS_MIN_VERSION 1 423#define SETTINGS_MIN_VERSION 1
@@ -2444,7 +2444,7 @@ bool launch_wormlet(void)
2444/** 2444/**
2445 * Main entry point 2445 * Main entry point
2446 */ 2446 */
2447enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2447enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
2448{ 2448{
2449 int result; 2449 int result;
2450 int menu_quit = 0; 2450 int menu_quit = 0;
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 331650eddc..5054fd21b1 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -258,7 +258,7 @@ static int speed = 6; /* CYCLETIME = (11-speed)*10 ms */
258static int difficulty = 75; /* Percentage of screen that needs to be filled 258static int difficulty = 75; /* Percentage of screen that needs to be filled
259 * in order to win the game */ 259 * in order to win the game */
260 260
261static struct plugin_api *rb; 261static const struct plugin_api *rb;
262 262
263MEM_FUNCTION_WRAPPERS(rb); 263MEM_FUNCTION_WRAPPERS(rb);
264 264
@@ -974,7 +974,7 @@ static int xobox_loop (void)
974} 974}
975 975
976/* plugin main procedure */ 976/* plugin main procedure */
977enum plugin_status plugin_start (struct plugin_api *api, void *parameter) 977enum plugin_status plugin_start (const struct plugin_api *api, const void *parameter)
978{ 978{
979 int ret = PLUGIN_OK; 979 int ret = PLUGIN_OK;
980 980
diff --git a/apps/plugins/zxbox.c b/apps/plugins/zxbox.c
index 61d9eea4ac..14f8b0911b 100644
--- a/apps/plugins/zxbox.c
+++ b/apps/plugins/zxbox.c
@@ -24,7 +24,7 @@
24PLUGIN_HEADER 24PLUGIN_HEADER
25 25
26/* this is the plugin entry point */ 26/* this is the plugin entry point */
27enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 27enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
28{ 28{
29 return run_overlay(api, parameter, PLUGIN_APPS_DIR "/zxbox.ovl", "ZXBox"); 29 return run_overlay(api, parameter, PLUGIN_APPS_DIR "/zxbox.ovl", "ZXBox");
30} 30}
diff --git a/apps/plugins/zxbox/spconf.c b/apps/plugins/zxbox/spconf.c
index d316ad0fbf..5a14959adc 100644
--- a/apps/plugins/zxbox/spconf.c
+++ b/apps/plugins/zxbox/spconf.c
@@ -103,7 +103,7 @@ static int find_extension(const char *ext)
103 103
104 104
105/* now actually a snapshot/tape loader*/ 105/* now actually a snapshot/tape loader*/
106void spcf_read_command_line(void* parameter) 106void spcf_read_command_line(const void* parameter)
107{ 107{
108 int ix; 108 int ix;
109 109
diff --git a/apps/plugins/zxbox/spconf.h b/apps/plugins/zxbox/spconf.h
index b7b89a22f7..7de5d2e857 100644
--- a/apps/plugins/zxbox/spconf.h
+++ b/apps/plugins/zxbox/spconf.h
@@ -31,7 +31,7 @@ extern int spcf_init_tapefile_type;
31 31
32 32
33/*extern int spcf_read_conf_file(const char *filename);*/ 33/*extern int spcf_read_conf_file(const char *filename);*/
34extern void spcf_read_command_line(void* parameter); 34extern void spcf_read_command_line(const void* parameter);
35extern void spcf_read_xresources(void); 35extern void spcf_read_xresources(void);
36extern int spcf_find_file_type(char *filename, int *ftp, int *ftsubp); 36extern int spcf_find_file_type(char *filename, int *ftp, int *ftsubp);
37 37
diff --git a/apps/plugins/zxbox/spmain.c b/apps/plugins/zxbox/spmain.c
index 51344763f9..136dcf0f24 100644
--- a/apps/plugins/zxbox/spmain.c
+++ b/apps/plugins/zxbox/spmain.c
@@ -519,17 +519,17 @@ static void run_singlemode(void)
519} 519}
520 520
521 521
522void check_params(void* parameter) 522void check_params(const void* parameter)
523{ 523{
524 spcf_read_conf_file(GLOBALCFG); 524 spcf_read_conf_file(GLOBALCFG);
525 spcf_read_command_line(parameter); 525 spcf_read_command_line(parameter);
526} 526}
527 527
528static void init_load(void *parameter) 528static void init_load(const void *parameter)
529{ 529{
530 if(load_immed) snsh_z80_load_intern(loadim, loadim_size); 530 if(load_immed) snsh_z80_load_intern(loadim, loadim_size);
531 531
532 check_params (parameter); 532 check_params(parameter);
533 if(spcf_init_snapshot != NULL) { 533 if(spcf_init_snapshot != NULL) {
534#ifndef USE_GREY 534#ifndef USE_GREY
535 rb->splash(HZ, "Loading snapshot '%s'", spcf_init_snapshot); 535 rb->splash(HZ, "Loading snapshot '%s'", spcf_init_snapshot);
@@ -548,7 +548,7 @@ static void init_load(void *parameter)
548 } 548 }
549} 549}
550 550
551void start_spectemu(void *parameter) 551void start_spectemu(const void *parameter)
552{ 552{
553 spti_init(); 553 spti_init();
554 init_load(parameter); 554 init_load(parameter);
diff --git a/apps/plugins/zxbox/spmain.h b/apps/plugins/zxbox/spmain.h
index 8168b261f6..5fb926ece9 100644
--- a/apps/plugins/zxbox/spmain.h
+++ b/apps/plugins/zxbox/spmain.h
@@ -21,8 +21,8 @@
21#ifndef SPMAIN_H 21#ifndef SPMAIN_H
22#define SPMAIN_H 22#define SPMAIN_H
23 23
24extern void check_params(void* parameter); 24extern void check_params(const void* parameter);
25extern void start_spectemu(void* parameter); 25extern void start_spectemu(const void* parameter);
26extern struct zxbox_settings settings; 26extern struct zxbox_settings settings;
27struct zxbox_settings { 27struct zxbox_settings {
28 int invert_colors; 28 int invert_colors;
diff --git a/apps/plugins/zxbox/zxbox.c b/apps/plugins/zxbox/zxbox.c
index 3d94981ce5..873ecdf6c3 100644
--- a/apps/plugins/zxbox/zxbox.c
+++ b/apps/plugins/zxbox/zxbox.c
@@ -22,7 +22,7 @@
22PLUGIN_HEADER 22PLUGIN_HEADER
23PLUGIN_IRAM_DECLARE 23PLUGIN_IRAM_DECLARE
24 24
25struct plugin_api* rb; 25const struct plugin_api* rb;
26 26
27#include "spkey_p.h" 27#include "spkey_p.h"
28 28
@@ -59,7 +59,7 @@ static size_t gbuf_size = 0;
59long video_frames IBSS_ATTR = 0 ; 59long video_frames IBSS_ATTR = 0 ;
60long start_time IBSS_ATTR = 0; 60long start_time IBSS_ATTR = 0;
61 61
62enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 62enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
63{ 63{
64 PLUGIN_IRAM_INIT(api) 64 PLUGIN_IRAM_INIT(api)
65 65
diff --git a/apps/plugins/zxbox/zxconfig.h b/apps/plugins/zxbox/zxconfig.h
index f83c091ab9..d0a6c5a7ea 100644
--- a/apps/plugins/zxbox/zxconfig.h
+++ b/apps/plugins/zxbox/zxconfig.h
@@ -5,7 +5,7 @@
5extern int load_tap; 5extern int load_tap;
6extern bool clear_kbd; 6extern bool clear_kbd;
7extern bool exit_requested; 7extern bool exit_requested;
8extern struct plugin_api* rb; 8extern const struct plugin_api* rb;
9extern void press_key(int c); 9extern void press_key(int c);
10extern long video_frames; 10extern long video_frames;
11extern long start_time; 11extern long start_time;