From 8fb336148fb34474c67fbc6e0354daa4512a22fb Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 18 Aug 2004 01:09:31 +0000 Subject: [PATCH] Const policed pointer arguments to functions, part 3 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4999 a1c6a512-1295-4272-9138-f99709370657 --- apps/bookmark.c | 44 +++++++++++++-------------- apps/bookmark.h | 4 +-- apps/debug_menu.c | 2 +- apps/filetypes.c | 18 ++++++------ apps/filetypes.h | 6 ++-- apps/language.c | 2 +- apps/language.h | 2 +- apps/menu.c | 4 +-- apps/menu.h | 2 +- apps/playlist.c | 67 ++++++++++++++++++++++-------------------- apps/playlist.h | 27 +++++++++-------- apps/playlist_viewer.c | 8 ++--- apps/plugin.c | 2 +- apps/plugin.h | 4 +-- apps/screens.c | 12 ++++---- apps/screens.h | 10 +++---- apps/settings.c | 24 +++++++-------- apps/settings.h | 16 +++++----- apps/sound_menu.c | 2 +- apps/status.c | 5 ++-- apps/status.h | 3 +- apps/talk.c | 4 +-- apps/talk.h | 6 ++-- apps/tree.c | 17 ++++++----- apps/tree.h | 6 ++-- apps/wps-display.c | 28 ++++++++++-------- apps/wps-display.h | 3 +- 27 files changed, 170 insertions(+), 158 deletions(-) diff --git a/apps/bookmark.c b/apps/bookmark.c index 8d60de28fe..ed85ff6222 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -51,19 +51,19 @@ #define MAX_BOOKMARK_SIZE 350 #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark" -static bool add_bookmark(char* bookmark_file_name, char* bookmark); +static bool add_bookmark(const char* bookmark_file_name, const char* bookmark); static bool bookmark_load_menu(void); -static bool check_bookmark(char* bookmark); +static bool check_bookmark(const char* bookmark); static char* create_bookmark(void); -static bool delete_bookmark(char* bookmark_file_name, int bookmark_id); -static void display_bookmark(char* bookmark, +static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id); +static void display_bookmark(const char* bookmark, int bookmark_id, int bookmark_count); -static void say_bookmark(char* bookmark, +static void say_bookmark(const char* bookmark, int bookmark_id); -static bool generate_bookmark_file_name(char *in); -static char* get_bookmark(char* bookmark_file, int bookmark_count); -static bool parse_bookmark(char *bookmark, +static bool generate_bookmark_file_name(const char *in); +static char* get_bookmark(const char* bookmark_file, int bookmark_count); +static bool parse_bookmark(const char *bookmark, int *resume_index, int *resume_offset, int *resume_seed, @@ -75,10 +75,10 @@ static bool parse_bookmark(char *bookmark, bool *shuffle, char* file_name, unsigned int max_file_name_size); -static char* select_bookmark(char* bookmark_file_name); +static char* select_bookmark(const char* bookmark_file_name); static bool system_check(void); static bool write_bookmark(bool create_bookmark_file); -static int get_bookmark_count(char* bookmark_file_name); +static int get_bookmark_count(const char* bookmark_file_name); static char global_temp_buffer[MAX_PATH+1]; static char global_bookmark_file_name[MAX_PATH]; @@ -332,7 +332,7 @@ static bool write_bookmark(bool create_bookmark_file) /* ----------------------------------------------------------------------- */ /* This function adds a bookmark to a file. */ /* ------------------------------------------------------------------------*/ -static bool add_bookmark(char* bookmark_file_name, char* bookmark) +static bool add_bookmark(const char* bookmark_file_name, const char* bookmark) { int temp_bookmark_file = 0; int bookmark_file = 0; @@ -447,7 +447,7 @@ static char* create_bookmark() return NULL; } -static bool check_bookmark(char* bookmark) +static bool check_bookmark(const char* bookmark) { return parse_bookmark(bookmark, NULL,NULL,NULL, NULL, @@ -459,7 +459,7 @@ static bool check_bookmark(char* bookmark) /* This function will determine if an autoload is necessary. This is an */ /* interface function. */ /* ------------------------------------------------------------------------*/ -bool bookmark_autoload(char* file) +bool bookmark_autoload(const char* file) { int key; int fd; @@ -537,7 +537,7 @@ bool bookmark_autoload(char* file) /* This function loads the bookmark information into the resume memory. */ /* This is an interface function. */ /* ------------------------------------------------------------------------*/ -bool bookmark_load(char* file, bool autoload) +bool bookmark_load(const char* file, bool autoload) { int fd; bool success = true; @@ -587,7 +587,7 @@ bool bookmark_load(char* file, bool autoload) } -static int get_bookmark_count(char* bookmark_file_name) +static int get_bookmark_count(const char* bookmark_file_name) { int read_count = 0; int file = open(bookmark_file_name, O_RDONLY); @@ -613,7 +613,7 @@ static int get_bookmark_count(char* bookmark_file_name) /* This displays a the bookmarks in a file and allows the user to */ /* select one to play. */ /* ------------------------------------------------------------------------*/ -static char* select_bookmark(char* bookmark_file_name) +static char* select_bookmark(const char* bookmark_file_name) { int bookmark_id = 0; int bookmark_id_prev = -1; @@ -732,7 +732,7 @@ static char* select_bookmark(char* bookmark_file_name) /* This function takes a location in a bookmark file and deletes that */ /* bookmark. */ /* ------------------------------------------------------------------------*/ -static bool delete_bookmark(char* bookmark_file_name, int bookmark_id) +static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id) { int temp_bookmark_file = 0; int bookmark_file = 0; @@ -784,7 +784,7 @@ static bool delete_bookmark(char* bookmark_file_name, int bookmark_id) /* ----------------------------------------------------------------------- */ /* This function parses a bookmark and displays it for the user. */ /* ------------------------------------------------------------------------*/ -static void display_bookmark(char* bookmark, +static void display_bookmark(const char* bookmark, int bookmark_id, int bookmark_count) { @@ -908,7 +908,7 @@ static void display_bookmark(char* bookmark, /* ----------------------------------------------------------------------- */ /* This function parses a bookmark, says the voice UI part of it. */ /* ------------------------------------------------------------------------*/ -static void say_bookmark(char* bookmark, +static void say_bookmark(const char* bookmark, int bookmark_id) { int resume_index; @@ -952,7 +952,7 @@ static void say_bookmark(char* bookmark, /* in the file, it will return the last one. */ /* It also returns the index number of the bookmark in the file */ /* ------------------------------------------------------------------------*/ -static char* get_bookmark(char* bookmark_file, int bookmark_count) +static char* get_bookmark(const char* bookmark_file, int bookmark_count) { int read_count = -1; int result = 0; @@ -989,7 +989,7 @@ static char* get_bookmark(char* bookmark_file, int bookmark_count) /* validates the bookmark. Passing in NULL for an output variable */ /* indicates that value is not requested. */ /* ----------------------------------------------------------------------- */ -static bool parse_bookmark(char *bookmark, +static bool parse_bookmark(const char *bookmark, int *resume_index, int *resume_offset, int *resume_seed, @@ -1123,7 +1123,7 @@ static bool parse_bookmark(char *bookmark, /* it would be here that the centralized/decentralized bookmark code */ /* could be placed. */ /* ----------------------------------------------------------------------- */ -static bool generate_bookmark_file_name(char *in) +static bool generate_bookmark_file_name(const char *in) { int len = strlen(in); diff --git a/apps/bookmark.h b/apps/bookmark.h index bff58f67a8..2f8b58af7e 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h @@ -25,8 +25,8 @@ bool bookmark_menu(void); bool bookmark_autobookmark(void); bool bookmark_create_menu(void); bool bookmark_mrb_load(void); -bool bookmark_autoload(char* file); -bool bookmark_load(char* file, bool autoload); +bool bookmark_autoload(const char* file); +bool bookmark_load(const char* file, bool autoload); void bookmark_play(char* resume_file, int index, int offset, int seed); #endif /* __BOOKMARK_H__ */ diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 0f4305640e..9fd2e33749 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -202,7 +202,7 @@ bool dbg_mpeg_thread(void) /* Tool function to calculate a CRC16 across some buffer */ -unsigned short crc_16(unsigned char* buf, unsigned len) +unsigned short crc_16(const unsigned char* buf, unsigned len) { /* CCITT standard polynomial 0x1021 */ static const unsigned short crc16_lookup[16] = diff --git a/apps/filetypes.c b/apps/filetypes.c index d7151ca661..09090c30d4 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -72,11 +72,11 @@ static char string_buffer[STRING_BUFFER_SIZE]; /* prototypes */ #ifdef HAVE_LCD_BITMAP -static char* string2icon(char*); +static char* string2icon(const char*); #endif -static char* get_string(char*); +static char* get_string(const char*); static int find_attr_index(int); -static bool read_config(char*); +static bool read_config(const char*); static void rm_whitespaces(char*); static void scan_plugins(void); @@ -160,7 +160,7 @@ int filetype_get_icon(int attr) } /* get plugin */ -char* filetype_get_plugin(struct entry* file) +char* filetype_get_plugin(const struct entry* file) { int ix; @@ -197,7 +197,7 @@ bool filetype_supported(int attr) } /* get the "dynamic" attribute for an extension */ -int filetype_get_attr(char* name) +int filetype_get_attr(const char* name) { int i; @@ -239,7 +239,7 @@ int filetype_load_menu(struct menu_item* menu,int max_items) } /* start a plugin with an argument (called from onplay.c) */ -int filetype_load_plugin(char* plugin, char* file) +int filetype_load_plugin(const char* plugin, char* file) { snprintf(plugin_name,sizeof(plugin_name),"%s/%s.rock", VIEWERS_DIR,plugin); @@ -427,7 +427,7 @@ static void scan_plugins(void) } /* read config file (or cahe file) */ -bool read_config(char* file) +bool read_config(const char* file) { enum {extension, plugin, @@ -584,7 +584,7 @@ bool read_config(char* file) #ifdef HAVE_LCD_BITMAP /* convert an ascii hexadecimal icon to a binary icon */ -static char* string2icon(char* str) +static char* string2icon(const char* str) { char tmp[ICON_LENGTH*2]; char *cp; @@ -634,7 +634,7 @@ static char* string2icon(char* str) #endif /* get string from buffer */ -static char* get_string(char* str) +static char* get_string(const char* str) { unsigned int l=strlen(str)+1; char* cp; diff --git a/apps/filetypes.h b/apps/filetypes.h index c5bccf4498..e72dd6ffd3 100644 --- a/apps/filetypes.h +++ b/apps/filetypes.h @@ -23,17 +23,17 @@ #include #include -int filetype_get_attr(char*); +int filetype_get_attr(const char*); #ifdef HAVE_LCD_BITMAP const char* filetype_get_icon(int); #else int filetype_get_icon(int); #endif -char* filetype_get_plugin(struct entry*); +char* filetype_get_plugin(const struct entry*); void filetype_init(void); bool filetype_supported(int); int filetype_load_menu(struct menu_item*, int); -int filetype_load_plugin(char*,char*); +int filetype_load_plugin(const char*, char*); struct file_type { #ifdef HAVE_LCD_BITMAP diff --git a/apps/language.c b/apps/language.c index 2b050c66ef..2b9b6ff30b 100644 --- a/apps/language.c +++ b/apps/language.c @@ -28,7 +28,7 @@ extern int printf(const char *format, ...); static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; -int lang_load(char *filename) +int lang_load(const char *filename) { int filesize; int fd = open(filename, O_RDONLY); diff --git a/apps/language.h b/apps/language.h index 454d852c7c..0262864431 100644 --- a/apps/language.h +++ b/apps/language.h @@ -25,4 +25,4 @@ #define LANGUAGE_VERSION 0x02 /* load a given language file */ -int lang_load(char *filename); +int lang_load(const char *filename); diff --git a/apps/menu.c b/apps/menu.c index 5e8a51200a..fccc88479b 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -49,7 +49,7 @@ struct menu { int (*callback)(int, int); #ifdef HAVE_LCD_BITMAP bool use_buttonbar; /* true if a buttonbar is defined */ - char *buttonbar[3]; + const char *buttonbar[3]; #endif }; @@ -225,7 +225,7 @@ static void put_cursor(int m, int target) } int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int), - char *button1, char *button2, char *button3) + const char *button1, const char *button2, const char *button3) { int i; diff --git a/apps/menu.h b/apps/menu.h index d097f73a0f..12d934fc18 100644 --- a/apps/menu.h +++ b/apps/menu.h @@ -28,7 +28,7 @@ struct menu_item { }; int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int), - char *button1, char *button2, char *button3); + const char *button1, const char *button2, const char *button3); void menu_exit(int menu); void put_cursorxy(int x, int y, bool on); diff --git a/apps/playlist.c b/apps/playlist.c index f702c1ad9d..fa663fe62f 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -128,19 +128,19 @@ static struct playlist_info current_playlist; static char now_playing[MAX_PATH+1]; static void empty_playlist(struct playlist_info* playlist, bool resume); -static void new_playlist(struct playlist_info* playlist, char *dir, - char *file); +static void new_playlist(struct playlist_info* playlist, const char *dir, + const char *file); static void create_control(struct playlist_info* playlist); static int check_control(struct playlist_info* playlist); static void update_playlist_filename(struct playlist_info* playlist, - char *dir, char *file); + const char *dir, const char *file); static int add_indices_to_playlist(struct playlist_info* playlist, char* buffer, int buflen); static int add_track_to_playlist(struct playlist_info* playlist, - char *filename, int position, bool queue, - int seek_pos); + const char *filename, int position, + bool queue, int seek_pos); static int add_directory_to_playlist(struct playlist_info* playlist, - char *dirname, int *position, bool queue, + const char *dirname, int *position, bool queue, int *count, bool recurse); static int remove_track_from_playlist(struct playlist_info* playlist, int position, bool write); @@ -149,18 +149,18 @@ static int randomise_playlist(struct playlist_info* playlist, bool write); static int sort_playlist(struct playlist_info* playlist, bool start_current, bool write); -static int get_next_index(struct playlist_info* playlist, int steps); +static int get_next_index(const struct playlist_info* playlist, int steps); static void find_and_set_playlist_index(struct playlist_info* playlist, unsigned int seek); static int compare(const void* p1, const void* p2); static int get_filename(struct playlist_info* playlist, int seek, bool control_file, char *buf, int buf_length); static int format_track_path(char *dest, char *src, int buf_length, int max, - char *dir); -static void display_playlist_count(int count, char *fmt); + const char *dir); +static void display_playlist_count(int count, const char *fmt); static void display_buffer_full(void); static int flush_pending_control(struct playlist_info* playlist); -static int rotate_index(struct playlist_info* playlist, int index); +static int rotate_index(const struct playlist_info* playlist, int index); /* * remove any files and indices associated with the playlist @@ -212,8 +212,8 @@ static void empty_playlist(struct playlist_info* playlist, bool resume) * Initialize a new playlist for viewing/editing/playing. dir is the * directory where the playlist is located and file is the filename. */ -static void new_playlist(struct playlist_info* playlist, char *dir, - char *file) +static void new_playlist(struct playlist_info* playlist, const char *dir, + const char *file) { empty_playlist(playlist, false); @@ -291,7 +291,7 @@ static int check_control(struct playlist_info* playlist) * store directory and name of playlist file */ static void update_playlist_filename(struct playlist_info* playlist, - char *dir, char *file) + const char *dir, const char *file) { char *sep=""; int dirlen = strlen(dir); @@ -400,8 +400,8 @@ static int add_indices_to_playlist(struct playlist_info* playlist, * PLAYLIST_INSERT_LAST - Add track to end of playlist */ static int add_track_to_playlist(struct playlist_info* playlist, - char *filename, int position, bool queue, - int seek_pos) + const char *filename, int position, + bool queue, int seek_pos) { int insert_position = position; unsigned int flags = PLAYLIST_INSERT_TYPE_INSERT; @@ -523,7 +523,7 @@ static int add_track_to_playlist(struct playlist_info* playlist, * Insert directory into playlist. May be called recursively. */ static int add_directory_to_playlist(struct playlist_info* playlist, - char *dirname, int *position, bool queue, + const char *dirname, int *position, bool queue, int *count, bool recurse) { char buf[MAX_PATH+1]; @@ -791,7 +791,7 @@ static int sort_playlist(struct playlist_info* playlist, bool start_current, * returns the index of the track that is "steps" away from current playing * track. */ -static int get_next_index(struct playlist_info* playlist, int steps) +static int get_next_index(const struct playlist_info* playlist, int steps) { int current_index = playlist->index; int next_index = -1; @@ -972,7 +972,7 @@ static int get_filename(struct playlist_info* playlist, int seek, * Returns absolute path of track */ static int format_track_path(char *dest, char *src, int buf_length, int max, - char *dir) + const char *dir) { int i = 0; int j; @@ -1037,7 +1037,7 @@ static int format_track_path(char *dest, char *src, int buf_length, int max, * Display splash message showing progress of playlist/directory insertion or * save. */ -static void display_playlist_count(int count, char *fmt) +static void display_playlist_count(int count, const char *fmt) { lcd_clear_display(); @@ -1120,7 +1120,7 @@ static int flush_pending_control(struct playlist_info* playlist) /* * Rotate indices such that first_index is index 0 */ -static int rotate_index(struct playlist_info* playlist, int index) +static int rotate_index(const struct playlist_info* playlist, int index) { index -= playlist->first_index; if (index < 0) @@ -1153,7 +1153,7 @@ void playlist_init(void) /* * Create new playlist */ -int playlist_create(char *dir, char *file) +int playlist_create(const char *dir, const char *file) { struct playlist_info* playlist = ¤t_playlist; @@ -1555,7 +1555,7 @@ int playlist_resume(void) /* * Add track to in_ram playlist. Used when playing directories. */ -int playlist_add(char *filename) +int playlist_add(const char *filename) { struct playlist_info* playlist = ¤t_playlist; int len = strlen(filename); @@ -1780,7 +1780,8 @@ int playlist_amount(void) * playlist indices (required for and only used if !current playlist). The * temp_buffer (if not NULL) is used as a scratchpad when loading indices. */ -int playlist_create_ex(struct playlist_info* playlist, char* dir, char* file, +int playlist_create_ex(struct playlist_info* playlist, + const char* dir, const char* file, void* index_buffer, int index_buffer_size, void* temp_buffer, int temp_buffer_size) { @@ -1897,7 +1898,7 @@ void playlist_close(struct playlist_info* playlist) * Insert track into playlist at specified position (or one of the special * positions). Returns position where track was inserted or -1 if error. */ -int playlist_insert_track(struct playlist_info* playlist, char *filename, +int playlist_insert_track(struct playlist_info* playlist, const char *filename, int position, bool queue) { int result; @@ -1925,8 +1926,9 @@ int playlist_insert_track(struct playlist_info* playlist, char *filename, /* * Insert all tracks from specified directory into playlist. */ -int playlist_insert_directory(struct playlist_info* playlist, char *dirname, - int position, bool queue, bool recurse) +int playlist_insert_directory(struct playlist_info* playlist, + const char *dirname, int position, bool queue, + bool recurse) { int count = 0; int result; @@ -2226,7 +2228,7 @@ int playlist_sort(struct playlist_info* playlist, bool start_current) } /* returns true if playlist has been modified */ -bool playlist_modified(struct playlist_info* playlist) +bool playlist_modified(const struct playlist_info* playlist) { if (!playlist) playlist = ¤t_playlist; @@ -2240,7 +2242,7 @@ bool playlist_modified(struct playlist_info* playlist) } /* returns index of first track in playlist */ -int playlist_get_first_index(struct playlist_info* playlist) +int playlist_get_first_index(const struct playlist_info* playlist) { if (!playlist) playlist = ¤t_playlist; @@ -2249,7 +2251,7 @@ int playlist_get_first_index(struct playlist_info* playlist) } /* returns shuffle seed of playlist */ -int playlist_get_seed(struct playlist_info* playlist) +int playlist_get_seed(const struct playlist_info* playlist) { if (!playlist) playlist = ¤t_playlist; @@ -2258,7 +2260,7 @@ int playlist_get_seed(struct playlist_info* playlist) } /* returns number of tracks in playlist (includes queued/inserted tracks) */ -int playlist_amount_ex(struct playlist_info* playlist) +int playlist_amount_ex(const struct playlist_info* playlist) { if (!playlist) playlist = ¤t_playlist; @@ -2267,7 +2269,8 @@ int playlist_amount_ex(struct playlist_info* playlist) } /* returns full path of playlist (minus extension) */ -char *playlist_name(struct playlist_info* playlist, char *buf, int buf_size) +char *playlist_name(const struct playlist_info* playlist, char *buf, + int buf_size) { char *sep; @@ -2288,7 +2291,7 @@ char *playlist_name(struct playlist_info* playlist, char *buf, int buf_size) } /* returns the playlist filename */ -char *playlist_get_name(struct playlist_info* playlist, char *buf, +char *playlist_get_name(const struct playlist_info* playlist, char *buf, int buf_size) { if (!playlist) diff --git a/apps/playlist.h b/apps/playlist.h index 482cecd128..8698981d26 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -68,9 +68,9 @@ struct playlist_track_info /* Exported functions only for current playlist. */ void playlist_init(void); -int playlist_create(char *dir, char *file); +int playlist_create(const char *dir, const char *file); int playlist_resume(void); -int playlist_add(char *filename); +int playlist_add(const char *filename); int playlist_shuffle(int random_seed, int start_index); int playlist_start(int start_index, int offset); bool playlist_check(int steps); @@ -82,15 +82,17 @@ int playlist_amount(void); /* Exported functions for all playlists. Pass NULL for playlist_info structure to work with current playlist. */ -int playlist_create_ex(struct playlist_info* playlist, char* dir, char* file, +int playlist_create_ex(struct playlist_info* playlist, + const char* dir, const char* file, void* index_buffer, int index_buffer_size, void* temp_buffer, int temp_buffer_size); int playlist_set_current(struct playlist_info* playlist); void playlist_close(struct playlist_info* playlist); -int playlist_insert_track(struct playlist_info* playlist, char *filename, +int playlist_insert_track(struct playlist_info* playlist, const char *filename, int position, bool queue); -int playlist_insert_directory(struct playlist_info* playlist, char *dirname, - int position, bool queue, bool recurse); +int playlist_insert_directory(struct playlist_info* playlist, + const char *dirname, int position, bool queue, + bool recurse); int playlist_insert_playlist(struct playlist_info* playlist, char *filename, int position, bool queue); int playlist_delete(struct playlist_info* playlist, int index); @@ -98,12 +100,13 @@ int playlist_move(struct playlist_info* playlist, int index, int new_index); int playlist_randomise(struct playlist_info* playlist, unsigned int seed, bool start_current); int playlist_sort(struct playlist_info* playlist, bool start_current); -bool playlist_modified(struct playlist_info* playlist); -int playlist_get_first_index(struct playlist_info* playlist); -int playlist_get_seed(struct playlist_info* playlist); -int playlist_amount_ex(struct playlist_info* playlist); -char *playlist_name(struct playlist_info* playlist, char *buf, int buf_size); -char *playlist_get_name(struct playlist_info* playlist, char *buf, +bool playlist_modified(const struct playlist_info* playlist); +int playlist_get_first_index(const struct playlist_info* playlist); +int playlist_get_seed(const struct playlist_info* playlist); +int playlist_amount_ex(const struct playlist_info* playlist); +char *playlist_name(const struct playlist_info* playlist, char *buf, + int buf_size); +char *playlist_get_name(const struct playlist_info* playlist, char *buf, int buf_size); int playlist_get_track_info(struct playlist_info* playlist, int index, struct playlist_track_info* info); diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index e5d95495fa..f093efd172 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -123,8 +123,8 @@ static bool initialize(char* filename, bool reload); static void load_playlist_entries(int start_index); static void load_playlist_entries_r(int end_index); static int load_entry(int index, int pos, char* p, int size); -static void format_name(char* dest, char* src); -static void format_line(struct playlist_entry* track, char* str, int len); +static void format_name(char* dest, const char* src); +static void format_line(const struct playlist_entry* track, char* str, int len); static void display_playlist(void); static void update_display_line(int line, bool scroll); static void scroll_display(int lines); @@ -392,7 +392,7 @@ static int load_entry(int index, int pos, char* p, int size) } /* Format trackname for display purposes */ -static void format_name(char* dest, char* src) +static void format_name(char* dest, const char* src) { switch (global_settings.playlist_viewer_track_display) { @@ -422,7 +422,7 @@ static void format_name(char* dest, char* src) } /* Format display line */ -static void format_line(struct playlist_entry* track, char* str, int len) +static void format_line(const struct playlist_entry* track, char* str, int len) { char name[MAX_PATH]; diff --git a/apps/plugin.c b/apps/plugin.c index f210462815..a7ae34f67e 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -261,7 +261,7 @@ static const struct plugin_api rockbox_api = { mpeg_get_last_header, }; -int plugin_load(char* plugin, void* parameter) +int plugin_load(const char* plugin, void* parameter) { enum plugin_status (*plugin_start)(struct plugin_api* api, void* param); int rc; diff --git a/apps/plugin.h b/apps/plugin.h index 53648ad4c7..e8fb25e555 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -153,7 +153,7 @@ struct plugin_api { #endif void (*backlight_on)(void); void (*backlight_off)(void); - void (*splash)(int ticks, bool center, char *fmt, ...); + void (*splash)(int ticks, bool center, const char *fmt, ...); /* button */ int (*button_get)(bool block); @@ -298,7 +298,7 @@ struct plugin_api { }; /* defined by the plugin loader (plugin.c) */ -int plugin_load(char* plugin, void* parameter); +int plugin_load(const char* plugin, void* parameter); void* plugin_get_buffer(int *buffer_size); void* plugin_get_mp3_buffer(int *buffer_size); int plugin_register_timer(int cycles, int prio, void (*timer_callback)(void)); diff --git a/apps/screens.c b/apps/screens.c index a926063efc..3e30e3e021 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -656,10 +656,10 @@ bool quick_screen(int context, int button) #define MAXLINES 2 #endif -void splash(int ticks, /* how long the splash is displayed */ - bool center, /* FALSE means left-justified, TRUE means - horizontal and vertical center */ - char *fmt, /* what to say *printf style */ +void splash(int ticks, /* how long the splash is displayed */ + bool center, /* FALSE means left-justified, TRUE means + horizontal and vertical center */ + const char *fmt, /* what to say *printf style */ ...) { char *next; @@ -813,7 +813,7 @@ void charging_splash(void) #ifdef HAVE_LCD_BITMAP /* little helper function for voice output */ -static void say_time(int cursorpos, struct tm *tm) +static void say_time(int cursorpos, const struct tm *tm) { const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; int value = 0; @@ -850,7 +850,7 @@ static void say_time(int cursorpos, struct tm *tm) #define INDEX_X 0 #define INDEX_Y 1 #define INDEX_WIDTH 2 -bool set_time_screen(char* string, struct tm *tm) +bool set_time_screen(const char* string, struct tm *tm) { bool done = false; int button; diff --git a/apps/screens.h b/apps/screens.h index b4f293f0ba..a119a9b853 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -31,14 +31,14 @@ int on_screen(void); bool quick_screen(const int, const int); #endif -void splash(int ticks, /* how long */ - bool center, /* FALSE means left-justified, TRUE means - horizontal and vertical center */ - char *fmt, /* what to say *printf style */ +void splash(int ticks, /* how long */ + bool center, /* FALSE means left-justified, TRUE means + horizontal and vertical center */ + const char *fmt, /* what to say *printf style */ ...); #ifdef HAVE_RTC -bool set_time_screen(char* string, struct tm *tm); +bool set_time_screen(const char* string, struct tm *tm); #endif bool shutdown_screen(void); diff --git a/apps/settings.c b/apps/settings.c index 47969d1abe..b469ce6d54 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -339,7 +339,7 @@ static const struct bit_entry hd_bits[] = /* helper function to extract n (<=32) bits from an arbitrary position */ static unsigned long get_bits( - unsigned long* p, /* the start of the bitfield array */ + const unsigned long* p, /* the start of the bitfield array */ unsigned int from, /* bit no. to start reading from */ unsigned int size) /* how many bits to read */ { @@ -418,7 +418,7 @@ static void set_bits( * Calculates the checksum for the config block and returns it */ -static unsigned short calculate_config_checksum(unsigned char* buf) +static unsigned short calculate_config_checksum(const unsigned char* buf) { unsigned int i; unsigned char cksum[2]; @@ -890,8 +890,8 @@ void set_file(char* filename, char* setting, int maxlen) static int load_cfg_table( const struct bit_entry* p_table, /* the table which describes the entries */ int count, /* number of entries in the table, including the first */ - char* name, /* the item to be searched */ - char* value, /* the value which got loaded for that item */ + const char* name, /* the item to be searched */ + const char* value, /* the value which got loaded for that item */ int hint) /* position to start looking */ { int i = hint; @@ -963,7 +963,7 @@ static int load_cfg_table( } -bool settings_load_config(char* file) +bool settings_load_config(const char* file) { int fd; char line[128]; @@ -1238,7 +1238,7 @@ void settings_reset(void) { } -bool set_bool(char* string, bool* variable ) +bool set_bool(const char* string, bool* variable ) { return set_bool_options(string, variable, STR(LANG_SET_BOOL_YES), @@ -1256,9 +1256,9 @@ void bool_funcwrapper(int value) boolfunction(false); } -bool set_bool_options(char* string, bool* variable, - char* yes_str, int yes_voice, - char* no_str, int no_voice, +bool set_bool_options(const char* string, bool* variable, + const char* yes_str, int yes_voice, + const char* no_str, int no_voice, void (*function)(bool)) { struct opt_items names[] = { {no_str, no_voice}, {yes_str, yes_voice} }; @@ -1270,8 +1270,8 @@ bool set_bool_options(char* string, bool* variable, return result; } -bool set_int(char* string, - char* unit, +bool set_int(const char* string, + const char* unit, int voice_unit, int* variable, void (*function)(int), @@ -1391,7 +1391,7 @@ bool set_int(char* string, different and bit-incompatible types and can not share the same access code. */ -bool set_option(char* string, void* variable, enum optiontype type, +bool set_option(const char* string, void* variable, enum optiontype type, const struct opt_items* options, int numoptions, void (*function)(int)) { bool done = false; diff --git a/apps/settings.h b/apps/settings.h index 78f46eaa4f..331e8dc904 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -264,19 +264,19 @@ void settings_apply(void); void settings_apply_pm_range(void); void settings_display(void); -bool settings_load_config(char* file); +bool settings_load_config(const char* file); bool settings_save_config(void); -bool set_bool_options(char* string, bool* variable, - char* yes_str, int yes_voice, - char* no_str, int no_voice, +bool set_bool_options(const char* string, bool* variable, + const char* yes_str, int yes_voice, + const char* no_str, int no_voice, void (*function)(bool)); -bool set_bool(char* string, bool* variable ); -bool set_option(char* string, void* variable, enum optiontype type, +bool set_bool(const char* string, bool* variable ); +bool set_option(const char* string, void* variable, enum optiontype type, const struct opt_items* options, int numoptions, void (*function)(int)); -bool set_int(char* string, char* unit, int voice_unit, int* variable, +bool set_int(const char* string, const char* unit, int voice_unit, int* variable, void (*function)(int), int step, int min, int max ); -bool set_time_screen(char* string, struct tm *tm); +bool set_time_screen(const char* string, struct tm *tm); int read_line(int fd, char* buffer, int buffer_size); void set_file(char* filename, char* setting, int maxlen); diff --git a/apps/sound_menu.c b/apps/sound_menu.c index bbf1c6c473..a037c94084 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -42,7 +42,7 @@ static const char* const fmt[] = "%d.%02d %s " /* 2 decimals */ }; -bool set_sound(char* string, +bool set_sound(const char* string, int* variable, int setting) { diff --git a/apps/status.c b/apps/status.c index 8c4a7ef809..f144adebef 100644 --- a/apps/status.c +++ b/apps/status.c @@ -268,7 +268,7 @@ void status_draw(bool force_redraw) } #ifdef HAVE_LCD_BITMAP -static void draw_buttonbar_btn(int num, char* caption) +static void draw_buttonbar_btn(int num, const char* caption) { int xpos, ypos, button_width, text_width; int fw, fh; @@ -294,7 +294,8 @@ static char stored_caption1[8]; static char stored_caption2[8]; static char stored_caption3[8]; -void buttonbar_set(char* caption1, char *caption2, char *caption3) +void buttonbar_set(const char* caption1, const char *caption2, + const char *caption3) { buttonbar_unset(); if(caption1) diff --git a/apps/status.h b/apps/status.h index c812b9cb75..ab8939cda5 100644 --- a/apps/status.h +++ b/apps/status.h @@ -34,7 +34,8 @@ void status_init(void); void status_set_ffmode(enum playmode mode); #ifdef HAVE_LCD_BITMAP bool statusbar(bool state); -void buttonbar_set(char* caption1, char* caption2, char* caption3); +void buttonbar_set(const char* caption1, const char* caption2, + const char* caption3); void buttonbar_unset(void); bool buttonbar_isset(void); void buttonbar_draw(void); diff --git a/apps/talk.c b/apps/talk.c index 1b3dda39ed..d90d23866e 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -378,7 +378,7 @@ int talk_id(int id, bool enqueue) /* play a thumbnail from file */ -int talk_file(char* filename, bool enqueue) +int talk_file(const char* filename, bool enqueue) { int fd; int size; @@ -532,7 +532,7 @@ int talk_value(int n, int unit, bool enqueue) } /* spell a string */ -int talk_spell(char* spell, bool enqueue) +int talk_spell(const char* spell, bool enqueue) { char c; /* currently processed char */ diff --git a/apps/talk.h b/apps/talk.h index de93b1678c..c4c8bc7285 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -49,7 +49,7 @@ enum { /* make a "talkable" ID from number + unit unit is upper 4 bits, number the remaining (in regular 2's complement) */ -#define TALK_ID(n,u) ((u)<