Pass the buffer length to the list_get_name callback functions instead of using hardcoded MAX_PATH

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17049 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2008-04-09 15:25:17 +00:00
parent ae64d2602b
commit 6848961aa5
22 changed files with 146 additions and 102 deletions

View file

@ -96,7 +96,10 @@ static bool parse_bookmark(const char *bookmark,
bool *shuffle,
char* file_name);
static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line);
static char* get_bookmark_info(int list_index, void* data, char *buffer);
static char* get_bookmark_info(int list_index,
void* data,
char *buffer,
size_t buffer_len);
static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resume);
static bool system_check(void);
static bool write_bookmark(bool create_bookmark_file);
@ -523,7 +526,10 @@ static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line)
return bookmarks->start + bookmarks->count;
}
static char* get_bookmark_info(int list_index, void* data, char *buffer)
static char* get_bookmark_info(int list_index,
void* data,
char *buffer,
size_t buffer_len)
{
struct bookmark_list* bookmarks = (struct bookmark_list*) data;
int index = list_index / 2;
@ -625,7 +631,7 @@ static char* get_bookmark_info(int list_index, void* data, char *buffer)
}
strrsplt(global_filename, '.');
snprintf(buffer, MAX_PATH, format, name, global_filename);
snprintf(buffer, buffer_len, format, name, global_filename);
return buffer;
}
else
@ -633,7 +639,7 @@ static char* get_bookmark_info(int list_index, void* data, char *buffer)
char time_buf[32];
format_time(time_buf, sizeof(time_buf), resume_time);
snprintf(buffer, MAX_PATH, "%s, %d%s", time_buf, resume_index + 1,
snprintf(buffer, buffer_len, "%s, %d%s", time_buf, resume_index + 1,
shuffle ? (char*) str(LANG_BOOKMARK_SHUFFLE) : "");
return buffer;
}

View file

@ -266,16 +266,17 @@ int cue_find_current_track(struct cuesheet *cue, unsigned long curpos)
/* callback that gives list item titles for the cuesheet browser */
static char *list_get_name_cb(int selected_item,
void *data,
char *buffer)
void *data,
char *buffer,
size_t buffer_len)
{
struct cuesheet *cue = (struct cuesheet *)data;
if (selected_item & 1)
snprintf(buffer, MAX_PATH, "%s",
snprintf(buffer, buffer_len, "%s",
cue->tracks[selected_item/2].title);
else
snprintf(buffer, MAX_PATH, "%02d. %s", selected_item/2+1,
snprintf(buffer, buffer_len, "%02d. %s", selected_item/2+1,
cue->tracks[selected_item/2].performer);
return buffer;

View file

@ -134,7 +134,8 @@ static char thread_status_char(unsigned status)
return thread_status_chars[status];
}
static char* threads_getname(int selected_item, void * data, char *buffer)
static char* threads_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
struct thread_entry *thread;
@ -143,7 +144,7 @@ static char* threads_getname(int selected_item, void * data, char *buffer)
#if NUM_CORES > 1
if (selected_item < (int)NUM_CORES)
{
snprintf(buffer, MAX_PATH, "Idle (%d): %2d%%", selected_item,
snprintf(buffer, buffer_len, "Idle (%d): %2d%%", selected_item,
idle_stack_usage(selected_item));
return buffer;
}
@ -155,13 +156,13 @@ static char* threads_getname(int selected_item, void * data, char *buffer)
if (thread->state == STATE_KILLED)
{
snprintf(buffer, MAX_PATH, "%2d: ---", selected_item);
snprintf(buffer, buffer_len, "%2d: ---", selected_item);
return buffer;
}
thread_get_name(name, 32, thread);
snprintf(buffer, MAX_PATH,
snprintf(buffer, buffer_len,
"%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
selected_item,
IF_COP(thread->core,)
@ -771,18 +772,19 @@ static bool dbg_hw_info(void)
#endif /* !SIMULATOR */
#ifndef SIMULATOR
static char* dbg_partitions_getname(int selected_item, void * data, char *buffer)
static char* dbg_partitions_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
int partition = selected_item/2;
struct partinfo* p = disk_partinfo(partition);
if (selected_item%2)
{
snprintf(buffer, MAX_PATH, " T:%x %ld MB", p->type, p->size / 2048);
snprintf(buffer, buffer_len, " T:%x %ld MB", p->type, p->size / 2048);
}
else
{
snprintf(buffer, MAX_PATH, "P%d: S:%lx", partition, p->start);
snprintf(buffer, buffer_len, "P%d: S:%lx", partition, p->start);
}
return buffer;
}
@ -1468,7 +1470,8 @@ char *itob(int n, int len)
binary[j] = '\0';
return binary;
}
static char* tsc2100_debug_getname(int selected_item, void * data, char *buffer)
static char* tsc2100_debug_getname(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
int *page = (int*)data;
bool reserved = false;
@ -1491,9 +1494,9 @@ static char* tsc2100_debug_getname(int selected_item, void * data, char *buffer)
break;
}
if (reserved)
snprintf(buffer, MAX_PATH, "%02x: RESERVED", selected_item);
snprintf(buffer, buffer_len, "%02x: RESERVED", selected_item);
else
snprintf(buffer, MAX_PATH, "%02x: %s", selected_item,
snprintf(buffer, buffer_len, "%02x: %s", selected_item,
itob(tsc2100_readreg(*page, selected_item)&0xffff,16));
return buffer;
}
@ -2491,9 +2494,10 @@ static int menu_action_callback(int btn, struct gui_synclist *lists)
}
return btn;
}
static char* dbg_menu_getname(int item, void * data, char *buffer)
static char* dbg_menu_getname(int item, void * data,
char *buffer, size_t buffer_len)
{
(void)data; (void)buffer;
(void)data; (void)buffer; (void)buffer_len;
return menuitems[item].desc;
}
bool debug_menu(void)

View file

@ -421,15 +421,18 @@ struct cb_data {
int *items;
char *current_file;
};
enum themable_icons openwith_get_icon(int selected_item, void * data)
static enum themable_icons openwith_get_icon(int selected_item, void * data)
{
struct cb_data *info = (struct cb_data *)data;
int *items = info->items;
return filetypes[items[selected_item]].icon;
}
char * openwith_get_name(int selected_item, void * data, char * buffer)
static char * openwith_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
(void)buffer;
(void)buffer; (void)buffer_len;
struct cb_data *info = (struct cb_data *)data;
int *items = info->items;
char *s = strrchr(filetypes[items[selected_item]].plugin, '/');
@ -437,7 +440,8 @@ char * openwith_get_name(int selected_item, void * data, char * buffer)
return s+1;
else return filetypes[items[selected_item]].plugin;
}
int openwith_action_callback(int action, struct gui_synclist *lists)
static int openwith_action_callback(int action, struct gui_synclist *lists)
{
struct cb_data *info = (struct cb_data *)lists->data;
int *items = info->items;
@ -453,6 +457,7 @@ int openwith_action_callback(int action, struct gui_synclist *lists)
}
return action;
}
int filetype_list_viewers(const char* current_file)
{
int i, count = 0;

View file

@ -178,7 +178,8 @@ void list_draw(struct screen *display, struct viewport *parent,
char entry_buffer[MAX_PATH];
unsigned char *entry_name;
int text_pos = 0;
s = list->callback_get_item_name(i, list->data, entry_buffer);
s = list->callback_get_item_name(i, list->data, entry_buffer,
sizeof(entry_buffer));
entry_name = P2STR(s);
display->set_viewport(&list_text[display->screen_type]);
list_text[display->screen_type].drawmode = STYLE_DEFAULT;

View file

@ -82,7 +82,8 @@ void list_draw(struct screen *display, struct viewport *parent,
break;
s = gui_list->callback_get_item_name(current_item,
gui_list->data,
entry_buffer);
entry_buffer,
sizeof(entry_buffer));
entry_name = P2STR(s);

View file

@ -815,17 +815,21 @@ void simplelist_addline(int line_number, const char *fmt, ...)
va_end(ap);
}
static char* simplelist_static_getname(int item, void * data, char *buffer)
static char* simplelist_static_getname(int item,
void * data,
char *buffer,
size_t buffer_len)
{
(void)data; (void)buffer;
(void)data; (void)buffer; (void)buffer_len;
return simplelist_text[item];
}
bool simplelist_show_list(struct simplelist_info *info)
{
struct gui_synclist lists;
struct viewport vp[NB_SCREENS];
int action, old_line_count = simplelist_line_count,i;
char* (*getname)(int item, void * data, char *buffer);
char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
if (info->get_name)
getname = info->get_name;
else

View file

@ -59,9 +59,11 @@ typedef enum themable_icons list_get_icon(int selected_item, void * data);
* (The content of the buffer may not be used by the list, we use
* the return value of the function in all cases to avoid filling
* a buffer when it's not necessary)
* - buffer_len : length of the buffer
* Returns a pointer to a string that contains the text to display
*/
typedef char * list_get_name(int selected_item, void * data, char * buffer);
typedef char * list_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len);
/*
* Voice callback
* - selected_item : an integer that tells the number of the item to speak

View file

@ -331,10 +331,12 @@ static int selection_to_val(struct settings_list *setting, int selection)
return max- (selection * step);
}
static char * value_setting_get_name_cb(int selected_item,
void * data, char *buffer)
void * data,
char *buffer,
size_t buffer_len)
{
selected_item = selection_to_val(data, selected_item);
return option_get_valuestring(data, buffer, MAX_PATH, selected_item);
return option_get_valuestring(data, buffer, buffer_len, selected_item);
}
/* wrapper to convert from int param to bool param in option_screen */

View file

@ -93,13 +93,16 @@ static int find_menu_selection(int selected)
return i;
return 0;
}
static char * get_menu_item_name(int selected_item,void * data, char *buffer)
static char * get_menu_item_name(int selected_item,
void * data,
char *buffer,
size_t buffer_len)
{
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
int type = (menu->flags&MENU_TYPE_MASK);
selected_item = get_menu_selection(selected_item, menu);
(void)buffer;
(void)buffer_len;
/* only MT_MENU or MT_RETURN_ID is allowed in here */
if (type == MT_RETURN_ID)
{

View file

@ -146,7 +146,8 @@ enum infoscreenorder
};
static char* info_getname(int selected_item, void *data, char *buffer)
static char* info_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
struct info_data *info = (struct info_data*)data;
#if CONFIG_RTC
@ -176,13 +177,13 @@ static char* info_getname(int selected_item, void *data, char *buffer)
switch (selected_item)
{
case INFO_VERSION:
snprintf(buffer, MAX_PATH, "%s: %s",
snprintf(buffer, buffer_len, "%s: %s",
str(LANG_VERSION), appsversion);
break;
#if CONFIG_RTC
case INFO_TIME:
tm = get_time();
snprintf(buffer, MAX_PATH, "%02d:%02d:%02d %s",
snprintf(buffer, buffer_len, "%02d:%02d:%02d %s",
global_settings.timeformat == 0 ? tm->tm_hour :
((tm->tm_hour + 11) % 12) + 1,
tm->tm_min,
@ -192,7 +193,7 @@ static char* info_getname(int selected_item, void *data, char *buffer)
break;
case INFO_DATE:
tm = get_time();
snprintf(buffer, MAX_PATH, "%s %d %d",
snprintf(buffer, buffer_len, "%s %d %d",
str(LANG_MONTH_JANUARY + tm->tm_mon),
tm->tm_mday,
tm->tm_year+1900);
@ -203,31 +204,31 @@ static char* info_getname(int selected_item, void *data, char *buffer)
long buflen = ((audiobufend - audiobuf) * 2) / 2097; /* avoid overflow */
int integer = buflen / 1000;
int decimal = buflen % 1000;
snprintf(buffer, MAX_PATH, (char *)str(LANG_BUFFER_STAT),
snprintf(buffer, buffer_len, (char *)str(LANG_BUFFER_STAT),
integer, decimal);
}
break;
case INFO_BATTERY: /* battery */
#if CONFIG_CHARGING == CHARGING_SIMPLE
if (charger_input_state == CHARGER)
snprintf(buffer, MAX_PATH, (char *)str(LANG_BATTERY_CHARGE));
snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_CHARGE));
else
#elif CONFIG_CHARGING >= CHARGING_MONITOR
if (charge_state == CHARGING)
snprintf(buffer, MAX_PATH, (char *)str(LANG_BATTERY_CHARGE));
snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_CHARGE));
else
#if CONFIG_CHARGING == CHARGING_CONTROL
if (charge_state == TOPOFF)
snprintf(buffer, MAX_PATH, (char *)str(LANG_BATTERY_TOPOFF_CHARGE));
snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_TOPOFF_CHARGE));
else
#endif
if (charge_state == TRICKLE)
snprintf(buffer, MAX_PATH, (char *)str(LANG_BATTERY_TRICKLE_CHARGE));
snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_TRICKLE_CHARGE));
else
#endif
if (battery_level() >= 0)
snprintf(buffer, MAX_PATH, (char *)str(LANG_BATTERY_TIME), battery_level(),
battery_time() / 60, battery_time() % 60);
snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_TIME),
battery_level(), battery_time() / 60, battery_time() % 60);
else
strcpy(buffer, "(n/a)");
break;
@ -235,11 +236,11 @@ static char* info_getname(int selected_item, void *data, char *buffer)
#ifdef HAVE_MULTIVOLUME
output_dyn_value(s1, sizeof s1, info->free, kbyte_units, true);
output_dyn_value(s2, sizeof s2, info->size, kbyte_units, true);
snprintf(buffer, MAX_PATH, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL),
snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL),
s1, s2);
#else
output_dyn_value(s1, sizeof s1, info->free, kbyte_units, true);
snprintf(buffer, MAX_PATH, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1);
snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1);
#endif
break;
case INFO_DISK2: /* disk usage 2 */
@ -248,17 +249,17 @@ static char* info_getname(int selected_item, void *data, char *buffer)
{
output_dyn_value(s1, sizeof s1, info->free2, kbyte_units, true);
output_dyn_value(s2, sizeof s2, info->size2, kbyte_units, true);
snprintf(buffer, MAX_PATH, "%s %s/%s", str(LANG_DISK_NAME_MMC),
snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_MMC),
s1, s2);
}
else
{
snprintf(buffer, MAX_PATH, "%s %s", str(LANG_DISK_NAME_MMC),
snprintf(buffer, buffer_len, "%s %s", str(LANG_DISK_NAME_MMC),
str(LANG_NOT_PRESENT));
}
#else
output_dyn_value(s1, sizeof s1, info->size, kbyte_units, true);
snprintf(buffer, MAX_PATH, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1);
snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1);
#endif
break;
}

View file

@ -188,11 +188,11 @@ exit:
/* Callback for gui_synclist */
static char* playlist_callback_name(int selected_item, void* data,
char* buffer)
char* buffer, size_t buffer_len)
{
char** playlists = (char**) data;
strncpy(buffer, playlists[selected_item], MAX_PATH);
strncpy(buffer, playlists[selected_item], buffer_len);
if (buffer[0] != '.' && !(global_settings.show_filename_ext == 1
|| (global_settings.show_filename_ext == 3

View file

@ -544,11 +544,14 @@ static int get_track_num( struct playlist_viewer * local_viewer,
return selected_item;
}
static char *playlist_callback_name(int selected_item, void *data, char *buffer)
static char *playlist_callback_name(int selected_item,
void *data,
char *buffer,
size_t buffer_len)
{
struct playlist_viewer * local_viewer = (struct playlist_viewer *)data;
struct playlist_entry *track = playlist_buffer_get_track(&(local_viewer->buffer), get_track_num(local_viewer,selected_item));
format_line(track, buffer, MAX_PATH);
format_line(track, buffer, buffer_len);
return(buffer);
}
@ -752,12 +755,14 @@ exit:
return ret;
}
static char *playlist_search_callback_name(int selected_item, void * data, char *buffer)
static char *playlist_search_callback_name(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
(void)buffer_len; /* this should probably be used */
int *found_indicies = (int*)data;
static struct playlist_track_info track;
playlist_get_track_info(viewer.playlist,found_indicies[selected_item],&track);
format_name(buffer,track.filename);
playlist_get_track_info(viewer.playlist, found_indicies[selected_item], &track);
format_name(buffer, track.filename);
return(buffer);
}

View file

@ -527,7 +527,8 @@ void coords_to_pgn(struct pgn_ply_node* ply){
}
}
char * get_game_text(int selected_item, void *data, char *buffer){
char * get_game_text(int selected_item, void *data,
char *buffer, size_t buffer_len){
int i;
struct pgn_game_node *temp_node = (struct pgn_game_node *)data;
char text_buffer[50];
@ -541,7 +542,7 @@ char * get_game_text(int selected_item, void *data, char *buffer){
rb->snprintf(text_buffer, 50,"%s vs. %s (%s)", temp_node->white_player,
temp_node->black_player, temp_node->game_date);
rb->strcpy(buffer, text_buffer);
rb->strncpy(buffer, text_buffer, buffer_len);
return buffer;
}

View file

@ -40,10 +40,11 @@ struct menu {
static struct menu menus[MAX_MENUS];
static bool inuse[MAX_MENUS] = { false };
static char * menu_get_itemname(int selected_item, void * data, char *buffer)
static char * menu_get_itemname(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
(void)buffer; (void)buffer_len;
struct menu *local_menus=(struct menu *)data;
(void)buffer;
return(local_menus->items[selected_item].desc);
}

View file

@ -214,38 +214,39 @@ static bool dir_properties(char* selected_file)
return true;
}
char * get_props(int selected_item, void* data, char *buffer)
char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
{
(void)data;
switch(selected_item)
{
case 0:
rb->strcpy(buffer, str_dirname);
rb->strncpy(buffer, str_dirname, buffer_len);
break;
case 1:
rb->strcpy(buffer, its_a_dir ? str_dircount : str_filename);
rb->strncpy(buffer, its_a_dir ? str_dircount : str_filename,
buffer_len);
break;
case 2:
rb->strcpy(buffer, its_a_dir ? str_filecount : str_size);
rb->strncpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len);
break;
case 3:
rb->strcpy(buffer, its_a_dir ? str_size : str_date);
rb->strncpy(buffer, its_a_dir ? str_size : str_date, buffer_len);
break;
case 4:
rb->strcpy(buffer, its_a_dir ? "" : str_time);
rb->strncpy(buffer, its_a_dir ? "" : str_time, buffer_len);
break;
case 5:
rb->strcpy(buffer, its_a_dir ? "" : str_artist);
rb->strncpy(buffer, its_a_dir ? "" : str_artist, buffer_len);
break;
case 6:
rb->strcpy(buffer, its_a_dir ? "" : str_title);
rb->strncpy(buffer, its_a_dir ? "" : str_title, buffer_len);
break;
case 7:
rb->strcpy(buffer, its_a_dir ? "" : str_album);
rb->strncpy(buffer, its_a_dir ? "" : str_album, buffer_len);
break;
default:
rb->strcpy(buffer, "ERROR");
rb->strncpy(buffer, "ERROR", buffer_len);
break;
}
return buffer;

View file

@ -254,10 +254,10 @@ void generate(void)
rb->write(fd,&dirs_count,sizeof(int));
rb->close(fd);
}
char *list_get_name_cb(int selected_item,void* data,char* buf)
char *list_get_name_cb(int selected_item, void* data, char* buf, size_t buf_len)
{
(void)data;
rb->strcpy(buf,list->folder[selected_item]);
rb->strncpy(buf, list->folder[selected_item], buf_len);
return buf;
}

View file

@ -39,7 +39,8 @@ static bool usb_connected = false;
enum sc_list_action_type draw_sc_list(struct gui_synclist gui_sc);
/* Will be passed sc_file* as data */
char* build_sc_list(int selected_item, void *data, char *buffer);
char* build_sc_list(int selected_item, void *data,
char *buffer, size_t buffer_len);
/* Returns true iff we should leave the main loop */
bool list_sc(bool is_editable);
@ -91,17 +92,16 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist gui_sc)
}
char* build_sc_list(int selected_item, void *data, char *buffer)
char* build_sc_list(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
char text_buffer[MAX_PATH];
sc_file_t *file = (sc_file_t*)data;
if (!is_valid_index(file, selected_item)) {
return NULL;
}
sc_entry_t *entry = file->entries + selected_item;
rb->snprintf(text_buffer, sizeof(text_buffer), "%s", entry->disp);
rb->strcpy(buffer, text_buffer);
rb->snprintf(buffer, buffer_len, "%s", entry->disp);
return buffer;
}

View file

@ -115,18 +115,19 @@ int _do_action(int action, char* str, int line)
last_char_index = c;
return 1;
}
char *list_get_name_cb(int selected_item,void* data,char* buf)
char *list_get_name_cb(int selected_item, void* data,
char* buf, size_t buf_len)
{
char *b = &buffer[do_action(ACTION_GET,0,selected_item)];
(void)data;
if (rb->strlen(b) >= MAX_PATH)
if (rb->strlen(b) >= buf_len)
{
char t = b[MAX_PATH-10];
b[MAX_PATH-10] = '\0';
rb->snprintf(buf,MAX_PATH,"%s ...",b);
b[MAX_PATH-10] = t;
char t = b[buf_len-10];
b[buf_len-10] = '\0';
rb->snprintf(buf , buf_len, "%s ...", b);
b[buf_len-10] = t;
}
else rb->strcpy(buf,b);
else rb->strncpy(buf, b, buf_len);
return buf;
}
char filename[MAX_PATH];

View file

@ -1290,7 +1290,8 @@ MAKE_MENU(handle_radio_preset_menu, ID2P(LANG_PRESET),
radio_preset_callback, Icon_NOICON, &radio_edit_preset_item,
&radio_delete_preset_item);
/* present a list of preset stations */
char * presets_get_name(int selected_item, void * data, char *buffer)
static char * presets_get_name(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
struct fmstation *p = &presets[selected_item];
@ -1299,7 +1300,7 @@ char * presets_get_name(int selected_item, void * data, char *buffer)
int freq = p->frequency / 10000;
int frac = freq % 100;
freq /= 100;
snprintf(buffer, MAX_PATH,
snprintf(buffer, buffer_len,
str(LANG_FM_DEFAULT_PRESET_NAME), freq, frac);
return buffer;
}

View file

@ -1116,7 +1116,8 @@ static const int id3_headers[]=
LANG_ID3_PATH,
};
static char * id3_get_info(int selected_item, void* data, char *buffer)
static char * id3_get_info(int selected_item, void* data,
char *buffer, size_t buffer_len)
{
struct mp3entry* id3 =(struct mp3entry*)data;
int info_no=selected_item/2;
@ -1150,7 +1151,7 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
info = id3->disc_string;
else if (id3->discnum)
{
snprintf(buffer, MAX_PATH, "%d", id3->discnum);
snprintf(buffer, buffer_len, "%d", id3->discnum);
info = buffer;
}
break;
@ -1159,7 +1160,7 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
info = id3->track_string;
else if (id3->tracknum)
{
snprintf(buffer, MAX_PATH, "%d", id3->tracknum);
snprintf(buffer, buffer_len, "%d", id3->tracknum);
info = buffer;
}
break;
@ -1174,26 +1175,26 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
info = id3->year_string;
else if (id3->year)
{
snprintf(buffer, MAX_PATH, "%d", id3->year);
snprintf(buffer, buffer_len, "%d", id3->year);
info = buffer;
}
break;
case 10:/*LANG_ID3_LENGTH*/
format_time(buffer, MAX_PATH, id3->length);
format_time(buffer, buffer_len, id3->length);
info=buffer;
break;
case 11:/*LANG_ID3_PLAYLIST*/
snprintf(buffer, MAX_PATH, "%d/%d", playlist_get_display_index(),
snprintf(buffer, buffer_len, "%d/%d", playlist_get_display_index(),
playlist_amount());
info=buffer;
break;
case 12:/*LANG_ID3_BITRATE*/
snprintf(buffer, MAX_PATH, "%d kbps%s", id3->bitrate,
snprintf(buffer, buffer_len, "%d kbps%s", id3->bitrate,
id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
info=buffer;
break;
case 13:/*LANG_ID3_FREQUENCY*/
snprintf(buffer, MAX_PATH, "%ld Hz", id3->frequency);
snprintf(buffer, buffer_len, "%ld Hz", id3->frequency);
info=buffer;
break;
#if CONFIG_CODEC == SWCODEC
@ -1236,21 +1237,23 @@ bool browse_id3(void)
}
}
static char* runtime_get_data(int selected_item, void* data, char* buffer)
static char* runtime_get_data(int selected_item, void* data,
char* buffer, size_t buffer_len)
{
(void) data;
(void)data;
unsigned char *headers[] = {str(LANG_RUNNING_TIME), str(LANG_TOP_TIME) };
int t;
if(!(selected_item%2))
return headers[selected_item/2];
if(selected_item/2) t = global_status.topruntime;
if(selected_item/2)
t = global_status.topruntime;
else t = global_status.runtime;
snprintf(buffer, 16, "%dh %dm %ds",
snprintf(buffer, buffer_len, "%dh %dm %ds",
t / 3600, (t % 3600) / 60, t % 60);
return buffer;
}
static int runtime_speak_data(int selected_item, void* data)

View file

@ -112,7 +112,8 @@ static int ft_play_dirname(char* name);
static void ft_play_filename(char *dir, char *file);
static void say_filetype(int attr);
static char * tree_get_filename(int selected_item, void * data, char *buffer)
static char * tree_get_filename(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
struct tree_context * local_tc=(struct tree_context *)data;
char *name;
@ -160,7 +161,7 @@ static char * tree_get_filename(int selected_item, void * data, char *buffer)
if(stripit)
{
return(strip_extension(buffer, MAX_PATH, name));
return(strip_extension(buffer, buffer_len, name));
}
return(name);
}