diff options
author | Jens Arnold <amiconn@rockbox.org> | 2004-08-18 01:09:31 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2004-08-18 01:09:31 +0000 |
commit | 8fb336148fb34474c67fbc6e0354daa4512a22fb (patch) | |
tree | 5910d0a54bf8424b424939a263abef0f570591f7 /apps/playlist.c | |
parent | 6d0da414bfea35b4370ad820d28d4565521d7b12 (diff) | |
download | rockbox-8fb336148fb34474c67fbc6e0354daa4512a22fb.tar.gz rockbox-8fb336148fb34474c67fbc6e0354daa4512a22fb.zip |
Const policed pointer arguments to functions, part 3
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4999 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist.c')
-rw-r--r-- | apps/playlist.c | 67 |
1 files changed, 35 insertions, 32 deletions
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; | |||
128 | static char now_playing[MAX_PATH+1]; | 128 | static char now_playing[MAX_PATH+1]; |
129 | 129 | ||
130 | static void empty_playlist(struct playlist_info* playlist, bool resume); | 130 | static void empty_playlist(struct playlist_info* playlist, bool resume); |
131 | static void new_playlist(struct playlist_info* playlist, char *dir, | 131 | static void new_playlist(struct playlist_info* playlist, const char *dir, |
132 | char *file); | 132 | const char *file); |
133 | static void create_control(struct playlist_info* playlist); | 133 | static void create_control(struct playlist_info* playlist); |
134 | static int check_control(struct playlist_info* playlist); | 134 | static int check_control(struct playlist_info* playlist); |
135 | static void update_playlist_filename(struct playlist_info* playlist, | 135 | static void update_playlist_filename(struct playlist_info* playlist, |
136 | char *dir, char *file); | 136 | const char *dir, const char *file); |
137 | static int add_indices_to_playlist(struct playlist_info* playlist, | 137 | static int add_indices_to_playlist(struct playlist_info* playlist, |
138 | char* buffer, int buflen); | 138 | char* buffer, int buflen); |
139 | static int add_track_to_playlist(struct playlist_info* playlist, | 139 | static int add_track_to_playlist(struct playlist_info* playlist, |
140 | char *filename, int position, bool queue, | 140 | const char *filename, int position, |
141 | int seek_pos); | 141 | bool queue, int seek_pos); |
142 | static int add_directory_to_playlist(struct playlist_info* playlist, | 142 | static int add_directory_to_playlist(struct playlist_info* playlist, |
143 | char *dirname, int *position, bool queue, | 143 | const char *dirname, int *position, bool queue, |
144 | int *count, bool recurse); | 144 | int *count, bool recurse); |
145 | static int remove_track_from_playlist(struct playlist_info* playlist, | 145 | static int remove_track_from_playlist(struct playlist_info* playlist, |
146 | int position, bool write); | 146 | int position, bool write); |
@@ -149,18 +149,18 @@ static int randomise_playlist(struct playlist_info* playlist, | |||
149 | bool write); | 149 | bool write); |
150 | static int sort_playlist(struct playlist_info* playlist, bool start_current, | 150 | static int sort_playlist(struct playlist_info* playlist, bool start_current, |
151 | bool write); | 151 | bool write); |
152 | static int get_next_index(struct playlist_info* playlist, int steps); | 152 | static int get_next_index(const struct playlist_info* playlist, int steps); |
153 | static void find_and_set_playlist_index(struct playlist_info* playlist, | 153 | static void find_and_set_playlist_index(struct playlist_info* playlist, |
154 | unsigned int seek); | 154 | unsigned int seek); |
155 | static int compare(const void* p1, const void* p2); | 155 | static int compare(const void* p1, const void* p2); |
156 | static int get_filename(struct playlist_info* playlist, int seek, | 156 | static int get_filename(struct playlist_info* playlist, int seek, |
157 | bool control_file, char *buf, int buf_length); | 157 | bool control_file, char *buf, int buf_length); |
158 | static int format_track_path(char *dest, char *src, int buf_length, int max, | 158 | static int format_track_path(char *dest, char *src, int buf_length, int max, |
159 | char *dir); | 159 | const char *dir); |
160 | static void display_playlist_count(int count, char *fmt); | 160 | static void display_playlist_count(int count, const char *fmt); |
161 | static void display_buffer_full(void); | 161 | static void display_buffer_full(void); |
162 | static int flush_pending_control(struct playlist_info* playlist); | 162 | static int flush_pending_control(struct playlist_info* playlist); |
163 | static int rotate_index(struct playlist_info* playlist, int index); | 163 | static int rotate_index(const struct playlist_info* playlist, int index); |
164 | 164 | ||
165 | /* | 165 | /* |
166 | * remove any files and indices associated with the playlist | 166 | * remove any files and indices associated with the playlist |
@@ -212,8 +212,8 @@ static void empty_playlist(struct playlist_info* playlist, bool resume) | |||
212 | * Initialize a new playlist for viewing/editing/playing. dir is the | 212 | * Initialize a new playlist for viewing/editing/playing. dir is the |
213 | * directory where the playlist is located and file is the filename. | 213 | * directory where the playlist is located and file is the filename. |
214 | */ | 214 | */ |
215 | static void new_playlist(struct playlist_info* playlist, char *dir, | 215 | static void new_playlist(struct playlist_info* playlist, const char *dir, |
216 | char *file) | 216 | const char *file) |
217 | { | 217 | { |
218 | empty_playlist(playlist, false); | 218 | empty_playlist(playlist, false); |
219 | 219 | ||
@@ -291,7 +291,7 @@ static int check_control(struct playlist_info* playlist) | |||
291 | * store directory and name of playlist file | 291 | * store directory and name of playlist file |
292 | */ | 292 | */ |
293 | static void update_playlist_filename(struct playlist_info* playlist, | 293 | static void update_playlist_filename(struct playlist_info* playlist, |
294 | char *dir, char *file) | 294 | const char *dir, const char *file) |
295 | { | 295 | { |
296 | char *sep=""; | 296 | char *sep=""; |
297 | int dirlen = strlen(dir); | 297 | int dirlen = strlen(dir); |
@@ -400,8 +400,8 @@ static int add_indices_to_playlist(struct playlist_info* playlist, | |||
400 | * PLAYLIST_INSERT_LAST - Add track to end of playlist | 400 | * PLAYLIST_INSERT_LAST - Add track to end of playlist |
401 | */ | 401 | */ |
402 | static int add_track_to_playlist(struct playlist_info* playlist, | 402 | static int add_track_to_playlist(struct playlist_info* playlist, |
403 | char *filename, int position, bool queue, | 403 | const char *filename, int position, |
404 | int seek_pos) | 404 | bool queue, int seek_pos) |
405 | { | 405 | { |
406 | int insert_position = position; | 406 | int insert_position = position; |
407 | unsigned int flags = PLAYLIST_INSERT_TYPE_INSERT; | 407 | unsigned int flags = PLAYLIST_INSERT_TYPE_INSERT; |
@@ -523,7 +523,7 @@ static int add_track_to_playlist(struct playlist_info* playlist, | |||
523 | * Insert directory into playlist. May be called recursively. | 523 | * Insert directory into playlist. May be called recursively. |
524 | */ | 524 | */ |
525 | static int add_directory_to_playlist(struct playlist_info* playlist, | 525 | static int add_directory_to_playlist(struct playlist_info* playlist, |
526 | char *dirname, int *position, bool queue, | 526 | const char *dirname, int *position, bool queue, |
527 | int *count, bool recurse) | 527 | int *count, bool recurse) |
528 | { | 528 | { |
529 | char buf[MAX_PATH+1]; | 529 | char buf[MAX_PATH+1]; |
@@ -791,7 +791,7 @@ static int sort_playlist(struct playlist_info* playlist, bool start_current, | |||
791 | * returns the index of the track that is "steps" away from current playing | 791 | * returns the index of the track that is "steps" away from current playing |
792 | * track. | 792 | * track. |
793 | */ | 793 | */ |
794 | static int get_next_index(struct playlist_info* playlist, int steps) | 794 | static int get_next_index(const struct playlist_info* playlist, int steps) |
795 | { | 795 | { |
796 | int current_index = playlist->index; | 796 | int current_index = playlist->index; |
797 | int next_index = -1; | 797 | int next_index = -1; |
@@ -972,7 +972,7 @@ static int get_filename(struct playlist_info* playlist, int seek, | |||
972 | * Returns absolute path of track | 972 | * Returns absolute path of track |
973 | */ | 973 | */ |
974 | static int format_track_path(char *dest, char *src, int buf_length, int max, | 974 | static int format_track_path(char *dest, char *src, int buf_length, int max, |
975 | char *dir) | 975 | const char *dir) |
976 | { | 976 | { |
977 | int i = 0; | 977 | int i = 0; |
978 | int j; | 978 | int j; |
@@ -1037,7 +1037,7 @@ static int format_track_path(char *dest, char *src, int buf_length, int max, | |||
1037 | * Display splash message showing progress of playlist/directory insertion or | 1037 | * Display splash message showing progress of playlist/directory insertion or |
1038 | * save. | 1038 | * save. |
1039 | */ | 1039 | */ |
1040 | static void display_playlist_count(int count, char *fmt) | 1040 | static void display_playlist_count(int count, const char *fmt) |
1041 | { | 1041 | { |
1042 | lcd_clear_display(); | 1042 | lcd_clear_display(); |
1043 | 1043 | ||
@@ -1120,7 +1120,7 @@ static int flush_pending_control(struct playlist_info* playlist) | |||
1120 | /* | 1120 | /* |
1121 | * Rotate indices such that first_index is index 0 | 1121 | * Rotate indices such that first_index is index 0 |
1122 | */ | 1122 | */ |
1123 | static int rotate_index(struct playlist_info* playlist, int index) | 1123 | static int rotate_index(const struct playlist_info* playlist, int index) |
1124 | { | 1124 | { |
1125 | index -= playlist->first_index; | 1125 | index -= playlist->first_index; |
1126 | if (index < 0) | 1126 | if (index < 0) |
@@ -1153,7 +1153,7 @@ void playlist_init(void) | |||
1153 | /* | 1153 | /* |
1154 | * Create new playlist | 1154 | * Create new playlist |
1155 | */ | 1155 | */ |
1156 | int playlist_create(char *dir, char *file) | 1156 | int playlist_create(const char *dir, const char *file) |
1157 | { | 1157 | { |
1158 | struct playlist_info* playlist = ¤t_playlist; | 1158 | struct playlist_info* playlist = ¤t_playlist; |
1159 | 1159 | ||
@@ -1555,7 +1555,7 @@ int playlist_resume(void) | |||
1555 | /* | 1555 | /* |
1556 | * Add track to in_ram playlist. Used when playing directories. | 1556 | * Add track to in_ram playlist. Used when playing directories. |
1557 | */ | 1557 | */ |
1558 | int playlist_add(char *filename) | 1558 | int playlist_add(const char *filename) |
1559 | { | 1559 | { |
1560 | struct playlist_info* playlist = ¤t_playlist; | 1560 | struct playlist_info* playlist = ¤t_playlist; |
1561 | int len = strlen(filename); | 1561 | int len = strlen(filename); |
@@ -1780,7 +1780,8 @@ int playlist_amount(void) | |||
1780 | * playlist indices (required for and only used if !current playlist). The | 1780 | * playlist indices (required for and only used if !current playlist). The |
1781 | * temp_buffer (if not NULL) is used as a scratchpad when loading indices. | 1781 | * temp_buffer (if not NULL) is used as a scratchpad when loading indices. |
1782 | */ | 1782 | */ |
1783 | int playlist_create_ex(struct playlist_info* playlist, char* dir, char* file, | 1783 | int playlist_create_ex(struct playlist_info* playlist, |
1784 | const char* dir, const char* file, | ||
1784 | void* index_buffer, int index_buffer_size, | 1785 | void* index_buffer, int index_buffer_size, |
1785 | void* temp_buffer, int temp_buffer_size) | 1786 | void* temp_buffer, int temp_buffer_size) |
1786 | { | 1787 | { |
@@ -1897,7 +1898,7 @@ void playlist_close(struct playlist_info* playlist) | |||
1897 | * Insert track into playlist at specified position (or one of the special | 1898 | * Insert track into playlist at specified position (or one of the special |
1898 | * positions). Returns position where track was inserted or -1 if error. | 1899 | * positions). Returns position where track was inserted or -1 if error. |
1899 | */ | 1900 | */ |
1900 | int playlist_insert_track(struct playlist_info* playlist, char *filename, | 1901 | int playlist_insert_track(struct playlist_info* playlist, const char *filename, |
1901 | int position, bool queue) | 1902 | int position, bool queue) |
1902 | { | 1903 | { |
1903 | int result; | 1904 | int result; |
@@ -1925,8 +1926,9 @@ int playlist_insert_track(struct playlist_info* playlist, char *filename, | |||
1925 | /* | 1926 | /* |
1926 | * Insert all tracks from specified directory into playlist. | 1927 | * Insert all tracks from specified directory into playlist. |
1927 | */ | 1928 | */ |
1928 | int playlist_insert_directory(struct playlist_info* playlist, char *dirname, | 1929 | int playlist_insert_directory(struct playlist_info* playlist, |
1929 | int position, bool queue, bool recurse) | 1930 | const char *dirname, int position, bool queue, |
1931 | bool recurse) | ||
1930 | { | 1932 | { |
1931 | int count = 0; | 1933 | int count = 0; |
1932 | int result; | 1934 | int result; |
@@ -2226,7 +2228,7 @@ int playlist_sort(struct playlist_info* playlist, bool start_current) | |||
2226 | } | 2228 | } |
2227 | 2229 | ||
2228 | /* returns true if playlist has been modified */ | 2230 | /* returns true if playlist has been modified */ |
2229 | bool playlist_modified(struct playlist_info* playlist) | 2231 | bool playlist_modified(const struct playlist_info* playlist) |
2230 | { | 2232 | { |
2231 | if (!playlist) | 2233 | if (!playlist) |
2232 | playlist = ¤t_playlist; | 2234 | playlist = ¤t_playlist; |
@@ -2240,7 +2242,7 @@ bool playlist_modified(struct playlist_info* playlist) | |||
2240 | } | 2242 | } |
2241 | 2243 | ||
2242 | /* returns index of first track in playlist */ | 2244 | /* returns index of first track in playlist */ |
2243 | int playlist_get_first_index(struct playlist_info* playlist) | 2245 | int playlist_get_first_index(const struct playlist_info* playlist) |
2244 | { | 2246 | { |
2245 | if (!playlist) | 2247 | if (!playlist) |
2246 | playlist = ¤t_playlist; | 2248 | playlist = ¤t_playlist; |
@@ -2249,7 +2251,7 @@ int playlist_get_first_index(struct playlist_info* playlist) | |||
2249 | } | 2251 | } |
2250 | 2252 | ||
2251 | /* returns shuffle seed of playlist */ | 2253 | /* returns shuffle seed of playlist */ |
2252 | int playlist_get_seed(struct playlist_info* playlist) | 2254 | int playlist_get_seed(const struct playlist_info* playlist) |
2253 | { | 2255 | { |
2254 | if (!playlist) | 2256 | if (!playlist) |
2255 | playlist = ¤t_playlist; | 2257 | playlist = ¤t_playlist; |
@@ -2258,7 +2260,7 @@ int playlist_get_seed(struct playlist_info* playlist) | |||
2258 | } | 2260 | } |
2259 | 2261 | ||
2260 | /* returns number of tracks in playlist (includes queued/inserted tracks) */ | 2262 | /* returns number of tracks in playlist (includes queued/inserted tracks) */ |
2261 | int playlist_amount_ex(struct playlist_info* playlist) | 2263 | int playlist_amount_ex(const struct playlist_info* playlist) |
2262 | { | 2264 | { |
2263 | if (!playlist) | 2265 | if (!playlist) |
2264 | playlist = ¤t_playlist; | 2266 | playlist = ¤t_playlist; |
@@ -2267,7 +2269,8 @@ int playlist_amount_ex(struct playlist_info* playlist) | |||
2267 | } | 2269 | } |
2268 | 2270 | ||
2269 | /* returns full path of playlist (minus extension) */ | 2271 | /* returns full path of playlist (minus extension) */ |
2270 | char *playlist_name(struct playlist_info* playlist, char *buf, int buf_size) | 2272 | char *playlist_name(const struct playlist_info* playlist, char *buf, |
2273 | int buf_size) | ||
2271 | { | 2274 | { |
2272 | char *sep; | 2275 | char *sep; |
2273 | 2276 | ||
@@ -2288,7 +2291,7 @@ char *playlist_name(struct playlist_info* playlist, char *buf, int buf_size) | |||
2288 | } | 2291 | } |
2289 | 2292 | ||
2290 | /* returns the playlist filename */ | 2293 | /* returns the playlist filename */ |
2291 | char *playlist_get_name(struct playlist_info* playlist, char *buf, | 2294 | char *playlist_get_name(const struct playlist_info* playlist, char *buf, |
2292 | int buf_size) | 2295 | int buf_size) |
2293 | { | 2296 | { |
2294 | if (!playlist) | 2297 | if (!playlist) |