Make the formatter functions used by the settings return a pointer to avoid usless copying of lang strings, this brought with it a long chain of const correctness and a few random cleanups

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22440 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2009-08-20 16:47:44 +00:00
parent 0a17284448
commit 3200d04d75
43 changed files with 191 additions and 170 deletions

View file

@ -86,10 +86,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,
size_t buffer_len);
static const 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, const char *bookmark);
@ -515,10 +515,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,
size_t buffer_len)
static const 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;

View file

@ -234,10 +234,10 @@ 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,
size_t buffer_len)
static const char* list_get_name_cb(int selected_item,
void *data,
char *buffer,
size_t buffer_len)
{
struct cuesheet *cue = (struct cuesheet *)data;

View file

@ -141,8 +141,8 @@ static char thread_status_char(unsigned status)
return thread_status_chars[status];
}
static char* threads_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
static const char* threads_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
struct thread_entry *thread;
@ -183,6 +183,7 @@ static char* threads_getname(int selected_item, void *data,
return buffer;
}
static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
{
(void)lists;
@ -783,8 +784,8 @@ static bool dbg_hw_info(void)
#endif /* !SIMULATOR */
#ifndef SIMULATOR
static char* dbg_partitions_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
static const char* dbg_partitions_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
int partition = selected_item/2;
@ -2796,12 +2797,14 @@ static int menu_action_callback(int btn, struct gui_synclist *lists)
}
return btn;
}
static char* dbg_menu_getname(int item, void * data,
char *buffer, size_t buffer_len)
static const char* dbg_menu_getname(int item, void * data,
char *buffer, size_t buffer_len)
{
(void)data; (void)buffer; (void)buffer_len;
return menuitems[item].desc;
}
bool debug_menu(void)
{
struct simplelist_info info;

View file

@ -435,13 +435,13 @@ static enum themable_icons openwith_get_icon(int selected_item, void * data)
return filetypes[items[selected_item]].icon;
}
static char * openwith_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
static const char* openwith_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
(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, '/');
const char *s = strrchr(filetypes[items[selected_item]].plugin, '/');
if (s)
return s+1;
else return filetypes[items[selected_item]].plugin;

View file

@ -173,7 +173,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
for (i=start; i<end && i<list->nb_items; i++)
{
/* do the text */
unsigned char *s;
unsigned const char *s;
char entry_buffer[MAX_PATH];
unsigned char *entry_name;
int text_pos = 0;

View file

@ -69,7 +69,7 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list)
for (i = start; i < end; i++)
{
unsigned char *s;
unsigned const char *s;
char entry_buffer[MAX_PATH];
unsigned char *entry_name;
int current_item = gui_list->start_item[display->screen_type] + i;

View file

@ -827,10 +827,10 @@ void simplelist_addline(int line_number, const char *fmt, ...)
va_end(ap);
}
static char* simplelist_static_getname(int item,
void * data,
char *buffer,
size_t buffer_len)
static const char* simplelist_static_getname(int item,
void * data,
char *buffer,
size_t buffer_len)
{
(void)data; (void)buffer; (void)buffer_len;
return simplelist_text[item];
@ -841,7 +841,7 @@ bool simplelist_show_list(struct simplelist_info *info)
struct gui_synclist lists;
int action, old_line_count = simplelist_line_count;
int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
const char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
int wrap = LIST_WRAP_UNLESS_HELD;
if (info->get_name)
getname = info->get_name;

View file

@ -64,8 +64,8 @@ typedef enum themable_icons list_get_icon(int selected_item, void * data);
* - 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, size_t buffer_len);
typedef const 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

@ -69,10 +69,11 @@ static const char *unit_strings[] =
/* these two vars are needed so arbitrary values can be added to the
TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */
static int table_setting_oldval = 0, table_setting_array_position = 0;
char *option_get_valuestring(const struct settings_list *setting,
char *buffer, int buf_len,
intptr_t temp_var)
const char *option_get_valuestring(const struct settings_list *setting,
char *buffer, int buf_len,
intptr_t temp_var)
{
const char* str = buffer;
if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING)
{
bool val = (bool)temp_var;
@ -93,7 +94,7 @@ char *option_get_valuestring(const struct settings_list *setting,
const struct int_setting *int_info = setting->int_setting;
const struct table_setting *tbl_info = setting->table_setting;
const char *unit;
void (*formatter)(char*, size_t, int, const char*);
const char* (*formatter)(char*, size_t, int, const char*);
if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
{
formatter = int_info->formatter;
@ -105,7 +106,7 @@ char *option_get_valuestring(const struct settings_list *setting,
unit = unit_strings[tbl_info->unit];
}
if (formatter)
formatter(buffer, buf_len, (int)temp_var, unit);
str = formatter(buffer, buf_len, (int)temp_var, unit);
else
snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:"");
}
@ -152,7 +153,7 @@ char *option_get_valuestring(const struct settings_list *setting,
strlcpy(buffer, val, buf_len);
}
}
return buffer;
return str;
}
void option_talk_value(const struct settings_list *setting, int value, bool enqueue)
{
@ -363,10 +364,11 @@ static int selection_to_val(const struct settings_list *setting, int selection)
}
return max- (selection * step);
}
static char * value_setting_get_name_cb(int selected_item,
void * data,
char *buffer,
size_t buffer_len)
static const char * value_setting_get_name_cb(int selected_item,
void * data,
char *buffer,
size_t buffer_len)
{
selected_item = selection_to_val(data, selected_item);
return option_get_valuestring(data, buffer, buffer_len, selected_item);

View file

@ -33,7 +33,7 @@ bool option_screen(const struct settings_list *setting,
void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply);
#endif
char *option_get_valuestring(const struct settings_list *setting,
const char *option_get_valuestring(const struct settings_list *setting,
char *buffer, int buf_len,
intptr_t temp_var);
void option_talk_value(const struct settings_list *setting, int value, bool enqueue);

View file

@ -147,7 +147,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y;
}
static void quickscreen_draw_text(char *s, int item, bool title,
static void quickscreen_draw_text(const char *s, int item, bool title,
struct screen *display, struct viewport *vp)
{
int nb_lines = viewport_get_nb_lines(vp);
@ -186,7 +186,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen *qs,
int i;
char buf[MAX_PATH];
unsigned char *title, *value;
unsigned const char *title, *value;
void *setting;
int temp;
display->set_viewport(parent);

View file

@ -93,10 +93,10 @@ static int find_menu_selection(int selected)
return i;
return 0;
}
static char * get_menu_item_name(int selected_item,
void * data,
char *buffer,
size_t buffer_len)
static const 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);
@ -109,7 +109,7 @@ static char * get_menu_item_name(int selected_item,
if (menu->flags&MENU_DYNAMIC_DESC)
return menu->menu_get_name_and_icon->list_get_name(selected_item,
menu->menu_get_name_and_icon->list_get_name_data, buffer);
return (char*)menu->strings[selected_item];
return menu->strings[selected_item];
}
menu = menu->submenus[selected_item];

View file

@ -51,15 +51,18 @@
* Utility functions
*/
void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
const char* eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
{
snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR,
value % EQ_USER_DIVISOR, unit);
return buffer;
}
void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit)
const char* eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit)
{
snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
return buffer;
}
/*

View file

@ -43,7 +43,9 @@ bool eq_browse_presets(void);
bool eq_menu_graphical(void);
/* utility functions for settings_list.c */
void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit);
void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit);
const char* eq_q_format(char* buffer, size_t buffer_size, int value,
const char* unit);
const char* eq_precut_format(char* buffer, size_t buffer_size, int value,
const char* unit);
#endif

View file

@ -164,8 +164,8 @@ static const unsigned char *byte_units[] =
ID2P(LANG_MEGABYTE)
};
static char* info_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
static const char* info_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
struct info_data *info = (struct info_data*)data;
char s1[32];
@ -199,27 +199,27 @@ static char* info_getname(int selected_item, void *data,
#if CONFIG_CHARGING == CHARGING_SIMPLE
/* Only know if plugged */
if (charger_inserted())
return (char *)str(LANG_BATTERY_CHARGE);
return str(LANG_BATTERY_CHARGE);
else
#elif CONFIG_CHARGING >= CHARGING_MONITOR
#ifdef ARCHOS_RECORDER
/* Report the particular algorithm state */
if (charge_state == CHARGING)
return (char *)str(LANG_BATTERY_CHARGE);
return str(LANG_BATTERY_CHARGE);
else if (charge_state == TOPOFF)
return (char *)str(LANG_BATTERY_TOPOFF_CHARGE);
return str(LANG_BATTERY_TOPOFF_CHARGE);
else if (charge_state == TRICKLE)
return (char *)str(LANG_BATTERY_TRICKLE_CHARGE);
return str(LANG_BATTERY_TRICKLE_CHARGE);
else
#else /* !ARCHOS_RECORDER */
/* Go by what power management reports */
if (charging_state())
return (char *)str(LANG_BATTERY_CHARGE);
return str(LANG_BATTERY_CHARGE);
else
#endif /* ARCHOS_RECORDER */
#endif /* CONFIG_CHARGING = */
if (battery_level() >= 0)
snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_TIME),
snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME),
battery_level(), battery_time() / 60, battery_time() % 60);
else
return "(n/a)";
@ -399,19 +399,19 @@ MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
/* sleep Menu */
static void sleep_timer_formatter(char* buffer, size_t buffer_size, int value,
const char* unit)
static const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
int value, const char* unit)
{
int minutes, hours;
(void) unit;
int minutes, hours;
if (value) {
hours = value / 60;
minutes = value - (hours * 60);
snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
} else {
strlcpy(buffer, str(LANG_OFF), buffer_size);
return buffer;
} else {
return str(LANG_OFF);
}
}

View file

@ -415,7 +415,7 @@ static enum themable_icons trigger_get_icon(int selected_item, void * data)
return Icon_NOICON;
}
static char * trigger_get_name(int selected_item, void * data,
static const char * trigger_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
const struct settings_list **settings =

View file

@ -184,8 +184,8 @@ exit:
}
/* Callback for gui_synclist */
static char* playlist_callback_name(int selected_item, void* data,
char* buffer, size_t buffer_len)
static const char* playlist_callback_name(int selected_item, void* data,
char* buffer, size_t buffer_len)
{
char** playlists = (char**) data;

View file

@ -559,10 +559,10 @@ 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,
size_t buffer_len)
static const char* playlist_callback_name(int selected_item,
void *data,
char *buffer,
size_t buffer_len)
{
struct playlist_viewer * local_viewer = (struct playlist_viewer *)data;
@ -778,15 +778,15 @@ exit:
return ret;
}
static char *playlist_search_callback_name(int selected_item, void * data,
char *buffer, size_t buffer_len)
static const 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);
return(buffer);
return buffer;
}
bool search_playlist(void)

View file

@ -133,12 +133,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 170
#define PLUGIN_API_VERSION 171
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 170
#define PLUGIN_MIN_API_VERSION 171
/* plugin return codes */
enum plugin_status {
@ -672,7 +672,7 @@ struct plugin_api {
bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
const int* variable, void (*function)(int), int step,
int min, int max,
void (*formatter)(char*, size_t, int, const char*) );
const char* (*formatter)(char*, size_t, int, const char*) );
bool (*set_bool)(const char* string, const bool* variable );
#ifdef HAVE_LCD_COLOR

View file

@ -669,7 +669,7 @@ static bool edit_memo(int change, struct shown *shown)
return false;
}
static char * get_event_text(int selected, void *data,
static const char* get_event_text(int selected, void *data,
char *buffer, size_t buffer_len)
{
struct shown *shown = (struct shown *) data;

View file

@ -528,11 +528,10 @@ void coords_to_pgn(struct pgn_ply_node* ply){
}
}
char * get_game_text(int selected_item, void *data,
char *buffer, size_t buffer_len){
static const 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];
for (i=0;i<selected_item && temp_node != NULL;i++){
temp_node = temp_node->next_node;
@ -540,10 +539,9 @@ char * get_game_text(int selected_item, void *data,
if (temp_node == NULL){
return NULL;
}
rb->snprintf(text_buffer, 50,"%s vs. %s (%s)", temp_node->white_player,
rb->snprintf(buffer, buffer_len,"%s vs. %s (%s)", temp_node->white_player,
temp_node->black_player, temp_node->game_date);
rb->strlcpy(buffer, text_buffer, buffer_len);
return buffer;
}

View file

@ -380,8 +380,8 @@ enum themable_icons get_icon(int item, void * data)
return Icon_NOICON;
}
char * get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
static const char* get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
(void)data;
if (tidy_types[selected_item].directory)

View file

@ -550,14 +550,15 @@ static bool Doptions()
return (1);
}
char* choice_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
static const char* choice_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
char **names = (char **) data;
const char **names = (const char **) data;
(void) buffer;
(void) buffer_len;
return names[selected_item];
}
int list_action_callback(int action, struct gui_synclist *lists)
{
(void) lists;
@ -565,6 +566,7 @@ int list_action_callback(int action, struct gui_synclist *lists)
return ACTION_STD_CANCEL;
return action;
}
bool menuchoice(char **names, int count, int *selected)
{
struct simplelist_info info;

View file

@ -114,37 +114,39 @@ set_defaults (void)
autosave_time = 7;
}
static void
static const char*
komi_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
(void) unknown;
snprint_fixed (dest, size, menu_item);
return dest;
}
static void
static const char*
ruleset_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
(void) unknown;
rb->snprintf (dest, size, "%s", ruleset_names[menu_item]);
(void)dest, (void)size, (void)unknown;
return ruleset_names[menu_item];
}
static void
static const char*
autosave_formatter (char *dest, size_t size, int menu_item, const char *
unknown)
{
(void) unknown;
if (menu_item == 0)
{
rb->snprintf (dest, size, "Off");
return "Off";
}
else
{
rb->snprintf (dest, size, "%d minute%s", menu_item,
menu_item == 1 ? "" : "s");
return dest;
}
}
static void
static const char*
time_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
int time_values[4]; /* days hours minutes seconds */
@ -183,8 +185,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown)
if (max_set == -1)
{
rb->snprintf (dest, size, "0");
return;
return "0";
}
for (i = min_set; i <= 3; ++i)
@ -236,6 +237,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown)
dest += temp;
size -= temp;
}
return dest;
}
enum plugin_status

View file

@ -218,7 +218,7 @@ struct prop_t
/* The names of the rulesets, ex. "AGA", "Japanese", etc. */
extern char *ruleset_names[];
extern const char *ruleset_names[];
/* IMPORTANT! keep in sync with ruleset_names!!! */
enum ruleset_t

View file

@ -210,7 +210,7 @@ char *prop_names[] = {
/* These seems to be specified by the SGF specification. You can do free
form ones as well, but I haven't implemented that (and don't plan to) */
char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" };
const char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" };

View file

@ -122,8 +122,8 @@ MENUITEM_STRINGLIST(context_m, "Context menu", context_item_cb,
"Delete entry",
"Playback Control");
static char * kb_list_cb(int selected_item, void *data,
char *buffer, size_t buffer_len)
static const char* kb_list_cb(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
int i;

View file

@ -317,7 +317,7 @@ static bool mpeg_set_int(const char *string, const char *unit,
void (*function)(int), int step,
int min,
int max,
void (*formatter)(char*, size_t, int, const char*))
const char* (*formatter)(char*, size_t, int, const char*))
{
mpeg_menu_sysevent_clear();
@ -350,15 +350,16 @@ static void backlight_brightness_function(int value)
mpeg_backlight_update_brightness(value);
}
static void backlight_brightness_formatter(char *buf, size_t length,
int value, const char *input)
static const char* backlight_brightness_formatter(char *buf, size_t length,
int value, const char *input)
{
(void)input;
if (value < 0)
rb->strlcpy(buf, BACKLIGHT_OPTION_DEFAULT, length);
return BACKLIGHT_OPTION_DEFAULT;
else
rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING);
(void)input;
return buf;
}
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */

View file

@ -228,7 +228,8 @@ static bool dir_properties(char* selected_file)
return true;
}
char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
static const char * get_props(int selected_item, void* data,
char *buffer, size_t buffer_len)
{
(void)data;
@ -263,8 +264,7 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
rb->strlcpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
break;
default:
rb->strlcpy(buffer, "ERROR", buffer_len);
break;
return "ERROR";
}
return buffer;
}

View file

@ -234,7 +234,9 @@ void generate(void)
rb->close(fd);
rb->splash(HZ, "Done");
}
char *list_get_name_cb(int selected_item, void* data, char* buf, size_t buf_len)
static const char* list_get_name_cb(int selected_item, void* data,
char* buf, size_t buf_len)
{
(void)data;
rb->strlcpy(buf, list->folder[selected_item], buf_len);

View file

@ -270,10 +270,10 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) {
/*
* slot_get_name
*/
static char *slot_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
static const char* slot_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
char (*items)[20] = data;
const char (*items)[20] = data;
(void) buffer;
(void) buffer_len;
return items[selected_item];

View file

@ -600,8 +600,8 @@ char bbuf[MAX_PATH+1]; /* used by file and font browsers */
char bbuf_s[MAX_PATH+1]; /* used by file and font browsers */
struct tree_context *tree = NULL;
static char * browse_get_name_cb( int selected_item, void *data,
char *buffer, size_t buffer_len )
static const char* browse_get_name_cb(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
int *indexes = (int *) data;
struct entry* dc = tree->dircache;
@ -609,7 +609,7 @@ static char * browse_get_name_cb( int selected_item, void *data,
(void) buffer;
(void) buffer_len;
return (e->name);
return e->name;
}
static bool browse( char *dst, int dst_size, const char *start )
@ -633,8 +633,8 @@ static bool browse( char *dst, int dst_size, const char *start )
}
bbuf_s[0] = '\0';
rb->gui_synclist_init( &browse_list, browse_get_name_cb,
(void*) indexes, false, 1, NULL );
rb->gui_synclist_init(&browse_list, browse_get_name_cb,
(void*) indexes, false, 1, NULL);
tree = rb->tree_get_context();
backup = *tree;

View file

@ -40,8 +40,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, size_t buffer_len);
static const 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(void);
@ -89,8 +89,8 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc)
}
char* build_sc_list(int selected_item, void *data,
char *buffer, size_t buffer_len)
static const char* build_sc_list(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
sc_file_t *file = (sc_file_t*)data;

View file

@ -1251,8 +1251,8 @@ int movement_menu(void) {
return RET_VAL_OK;
}
static char * inventory_data(int selected_item, void * data,
char * buffer, size_t buffer_len) {
static const char* inventory_data(int selected_item, void * data,
char * buffer, size_t buffer_len) {
(void)data;
switch(selected_item) {
case 0:

View file

@ -121,8 +121,8 @@ 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, size_t buf_len)
static const char* list_get_name_cb(int selected_item, void* data,
char* buf, size_t buf_len)
{
(void)data;
char *b = &buffer[do_action(ACTION_GET,0,selected_item)];

View file

@ -1347,8 +1347,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 */
static char * presets_get_name(int selected_item, void *data,
char *buffer, size_t buffer_len)
static const char* presets_get_name(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
(void)data;
struct fmstation *p = &presets[selected_item];

View file

@ -848,8 +848,8 @@ enum rec_list_items_spdif {
static int listid_to_enum[ITEM_COUNT];
static char * reclist_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
static const char* reclist_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
char buf2[32];
#ifdef HAVE_AGC

View file

@ -789,20 +789,22 @@ static const int id3_headers[]=
#endif
LANG_ID3_PATH,
};
struct id3view_info {
struct mp3entry* id3;
int count;
int info_id[sizeof(id3_headers)/sizeof(id3_headers[0])];
int info_id[ARRAYLEN(id3_headers)];
};
static char * id3_get_info(int selected_item, void* data,
char *buffer, size_t buffer_len)
static const char* id3_get_info(int selected_item, void* data,
char *buffer, size_t buffer_len)
{
struct id3view_info *info = (struct id3view_info*)data;
struct mp3entry* id3 =info->id3;
int info_no=selected_item/2;
if(!(selected_item%2))
{/* header */
return( str(id3_headers[info->info_id[info_no]]));
return(str(id3_headers[info->info_id[info_no]]));
}
else
{/* data */
@ -903,7 +905,7 @@ bool browse_id3(void)
struct id3view_info info;
info.count = 0;
info.id3 = id3;
for (i=0; i<sizeof(id3_headers)/sizeof(id3_headers[0]); i++)
for (i = 0; i < ARRAYLEN(id3_headers); i++)
{
char temp[8];
info.info_id[i] = i;
@ -924,8 +926,8 @@ bool browse_id3(void)
}
}
static char* runtime_get_data(int selected_item, void* data,
char* buffer, size_t buffer_len)
static const char* runtime_get_data(int selected_item, void* data,
char* buffer, size_t buffer_len)
{
(void)data;
int t;

View file

@ -1083,7 +1083,7 @@ bool set_int(const unsigned char* string,
int step,
int min,
int max,
void (*formatter)(char*, size_t, int, const char*) )
const char* (*formatter)(char*, size_t, int, const char*) )
{
return set_int_ex(string, unit, voice_unit, variable, function,
step, min, max, formatter, NULL);
@ -1097,7 +1097,7 @@ bool set_int_ex(const unsigned char* string,
int step,
int min,
int max,
void (*formatter)(char*, size_t, int, const char*),
const char* (*formatter)(char*, size_t, int, const char*),
int32_t (*get_talk_id)(int, int))
{
(void)unit;
@ -1117,17 +1117,18 @@ bool set_int_ex(const unsigned char* string,
static const struct opt_items *set_option_options;
static void set_option_formatter(char* buf, size_t size, int item, const char* unit)
static const char* set_option_formatter(char* buf, size_t size, int item, const char* unit)
{
(void)unit;
const unsigned char *text = set_option_options[item].string;
strlcpy(buf, P2STR(text), size);
(void)buf, (void)unit, (void)size;
return P2STR(set_option_options[item].string);
}
static int32_t set_option_get_talk_id(int value, int unit)
{
(void)unit;
return set_option_options[value].voice_id;
}
bool set_option(const char* string, const void* variable, enum optiontype type,
const struct opt_items* options,
int numoptions, void (*function)(int))

View file

@ -271,13 +271,13 @@ bool set_bool(const char* string, const bool* variable);
bool set_int(const unsigned char* string, const char* unit, int voice_unit,
const int* variable,
void (*function)(int), int step, int min, int max,
void (*formatter)(char*, size_t, int, const char*) );
const char* (*formatter)(char*, size_t, int, const char*) );
/* use this one if you need to create a lang from the value (i.e with TALK_ID()) */
bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit,
const int* variable,
void (*function)(int), int step, int min, int max,
void (*formatter)(char*, size_t, int, const char*),
const char* (*formatter)(char*, size_t, int, const char*),
int32_t (*get_talk_id)(int, int));
void set_file(const char* filename, char* setting, int maxlen);

View file

@ -269,13 +269,14 @@ static const char graphic_numeric[] = "graphic,numeric";
#endif /* HAVE_RECORDING */
static void formatter_unit_0_is_off(char *buffer, size_t buffer_size,
static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size,
int val, const char *unit)
{
if (val == 0)
strcpy(buffer, str(LANG_OFF));
return str(LANG_OFF);
else
snprintf(buffer, buffer_size, "%d %s", val, unit);
return buffer;
}
static int32_t getlang_unit_0_is_off(int value, int unit)
@ -286,16 +287,17 @@ static int32_t getlang_unit_0_is_off(int value, int unit)
return TALK_ID(value,unit);
}
static void formatter_unit_0_is_skip_track(char *buffer, size_t buffer_size,
static const char* formatter_unit_0_is_skip_track(char *buffer, size_t buffer_size,
int val, const char *unit)
{
(void)unit;
if (val == 0)
strcpy(buffer, str(LANG_SKIP_TRACK));
return str(LANG_SKIP_TRACK);
else if (val % 60 == 0)
snprintf(buffer, buffer_size, "%d min", val/60);
else
snprintf(buffer, buffer_size, "%d s", val);
return buffer;
}
static int32_t getlang_unit_0_is_skip_track(int value, int unit)
@ -310,15 +312,16 @@ static int32_t getlang_unit_0_is_skip_track(int value, int unit)
}
#ifdef HAVE_BACKLIGHT
static void backlight_formatter(char *buffer, size_t buffer_size,
static const char* backlight_formatter(char *buffer, size_t buffer_size,
int val, const char *unit)
{
if (val == -1)
strcpy(buffer, str(LANG_OFF));
return str(LANG_OFF);
else if (val == 0)
strcpy(buffer, str(LANG_ON));
return str(LANG_ON);
else
snprintf(buffer, buffer_size, "%d %s", val, unit);
return buffer;
}
static int32_t backlight_getlang(int value, int unit)
{
@ -332,14 +335,15 @@ static int32_t backlight_getlang(int value, int unit)
#endif
#ifndef HAVE_WHEEL_ACCELERATION
static void scanaccel_formatter(char *buffer, size_t buffer_size,
static const char* scanaccel_formatter(char *buffer, size_t buffer_size,
int val, const char *unit)
{
(void)unit;
if (val == 0)
strcpy(buffer, str(LANG_OFF));
return str(LANG_OFF);
else
snprintf(buffer, buffer_size, "2x/%ds", val);
return buffer;
}
#endif
@ -352,13 +356,14 @@ static void crossfeed_cross_set(int val)
global_settings.crossfeed_hf_cutoff);
}
static void db_format(char* buffer, size_t buffer_size, int value,
static const char* db_format(char* buffer, size_t buffer_size, int value,
const char* unit)
{
int v = abs(value);
snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
v / 10, v % 10, unit);
return buffer;
}
static int32_t get_dec_talkid(int value, int unit)
@ -384,27 +389,25 @@ static void set_superbass(bool value)
#endif
#ifdef HAVE_LCD_CHARCELLS
static void jumpscroll_format(char* buffer, size_t buffer_size, int value,
static const char* jumpscroll_format(char* buffer, size_t buffer_size, int value,
const char* unit)
{
(void)unit;
switch (value)
{
case 0:
strcpy(buffer, str(LANG_OFF));
break;
return str(LANG_OFF);
case 1:
strcpy(buffer, str(LANG_ONE_TIME));
break;
return str(LANG_ONE_TIME);
case 2:
case 3:
case 4:
snprintf(buffer, buffer_size, "%d", value);
break;
case 5:
strcpy(buffer, str(LANG_ALWAYS));
break;
return str(LANG_ALWAYS);
}
return buffer;
}
static int32_t jumpscroll_getlang(int value, int unit)
{

View file

@ -73,7 +73,7 @@ struct int_setting {
int min;
int max;
int step;
void (*formatter)(char*, size_t, int, const char*);
const char* (*formatter)(char*, size_t, int, const char*);
int32_t (*get_talk_id)(int, int);
};
#define F_INT_SETTING 0x80
@ -92,7 +92,7 @@ struct choice_setting {
struct table_setting {
void (*option_callback)(int);
void (*formatter)(char*, size_t, int, const char*);
const char* (*formatter)(char*, size_t, int, const char*);
int32_t (*get_talk_id)(int, int);
int unit;
int count;

View file

@ -106,8 +106,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, size_t buffer_len)
static const 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;