From 0cfeff8e1ef91a97a1944d5399ceca7bd6236949 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 2 Jun 2015 18:28:51 +0200 Subject: [PATCH] Cleanups --- command_event.c | 31 +-- driver.c | 52 ++-- driver.h | 14 +- frontend/drivers/platform_android.c | 8 +- frontend/drivers/platform_darwin.m | 24 +- frontend/drivers/platform_gx.c | 10 +- frontend/drivers/platform_linux.c | 4 +- frontend/drivers/platform_psp.c | 4 +- frontend/drivers/platform_win32.c | 22 +- frontend/drivers/platform_xdk.c | 5 +- frontend/frontend_driver.h | 2 +- frontend/frontend_salamander.c | 18 +- gfx/drivers_context/androidegl_ctx.c | 8 +- menu/drivers/rmenu.c | 12 +- menu/menu_entries_cbs_title.c | 118 ++++----- menu/menu_list.h | 2 +- retroarch.c | 18 +- retroarch.h | 8 +- runloop_data.c | 4 +- settings.c | 371 +++++++++++++-------------- settings.h | 16 +- settings_list.h | 2 +- tasks/tasks.h | 2 +- 23 files changed, 372 insertions(+), 383 deletions(-) diff --git a/command_event.c b/command_event.c index c49c363742..1d1b471983 100644 --- a/command_event.c +++ b/command_event.c @@ -840,58 +840,51 @@ static bool event_save_core_config(void) /** * event_save_state * @path : Path to state. - * @msg : Message. - * @sizeof_msg : Size of @msg. + * @s : Message. + * @len : Size of @s. * * Saves a state with path being @path. **/ static void event_save_state(const char *path, - char *msg, size_t sizeof_msg) + char *s, size_t len) { settings_t *settings = config_get_ptr(); if (!save_state(path)) { - snprintf(msg, sizeof_msg, - "Failed to save state to \"%s\".", path); + snprintf(s, len, "Failed to save state to \"%s\".", path); return; } if (settings->state_slot < 0) - snprintf(msg, sizeof_msg, - "Saved state to slot #-1 (auto)."); + snprintf(s, len, "Saved state to slot #-1 (auto)."); else - snprintf(msg, sizeof_msg, - "Saved state to slot #%d.", settings->state_slot); + snprintf(s, len, "Saved state to slot #%d.", settings->state_slot); } /** * event_load_state * @path : Path to state. - * @msg : Message. - * @sizeof_msg : Size of @msg. + * @s : Message. + * @len : Size of @s. * * Loads a state with path being @path. **/ -static void event_load_state(const char *path, - char *msg, size_t sizeof_msg) +static void event_load_state(const char *path, char *s, size_t len) { settings_t *settings = config_get_ptr(); if (!load_state(path)) { - snprintf(msg, sizeof_msg, - "Failed to load state from \"%s\".", path); + snprintf(s, len, "Failed to load state from \"%s\".", path); return; } if (settings->state_slot < 0) - snprintf(msg, sizeof_msg, - "Loaded state from slot #-1 (auto)."); + snprintf(s, len, "Loaded state from slot #-1 (auto)."); else - snprintf(msg, sizeof_msg, - "Loaded state from slot #%d.", settings->state_slot); + snprintf(s, len, "Loaded state from slot #%d.", settings->state_slot); } static void event_main_state(unsigned cmd) diff --git a/driver.c b/driver.c index c960746e13..d7b05748c8 100644 --- a/driver.c +++ b/driver.c @@ -66,7 +66,7 @@ driver_t *driver_get_ptr(void) * @i : index of driver. * @str : identifier name of the found driver * gets written to this string. - * @sizeof_str : size of @str. + * @len : size of @str. * * Find driver based on @label. * @@ -74,7 +74,7 @@ driver_t *driver_get_ptr(void) * pointer to driver. **/ static const void *find_driver_nonempty(const char *label, int i, - char *str, size_t sizeof_str) + char *s, size_t len) { const void *drv = NULL; @@ -82,57 +82,57 @@ static const void *find_driver_nonempty(const char *label, int i, { drv = camera_driver_find_handle(i); if (drv) - strlcpy(str, camera_driver_find_ident(i), sizeof_str); + strlcpy(s, camera_driver_find_ident(i), len); } else if (!strcmp(label, "location_driver")) { drv = location_driver_find_handle(i); if (drv) - strlcpy(str, location_driver_find_ident(i), sizeof_str); + strlcpy(s, location_driver_find_ident(i), len); } #ifdef HAVE_MENU else if (!strcmp(label, "menu_driver")) { drv = menu_driver_find_handle(i); if (drv) - strlcpy(str, menu_driver_find_ident(i), sizeof_str); + strlcpy(s, menu_driver_find_ident(i), len); } #endif else if (!strcmp(label, "input_driver")) { drv = input_driver_find_handle(i); if (drv) - strlcpy(str, input_driver_find_ident(i), sizeof_str); + strlcpy(s, input_driver_find_ident(i), len); } else if (!strcmp(label, "input_joypad_driver")) { drv = joypad_driver_find_handle(i); if (drv) - strlcpy(str, joypad_driver_find_ident(i), sizeof_str); + strlcpy(s, joypad_driver_find_ident(i), len); } else if (!strcmp(label, "video_driver")) { drv = video_driver_find_handle(i); if (drv) - strlcpy(str, video_driver_find_ident(i), sizeof_str); + strlcpy(s, video_driver_find_ident(i), len); } else if (!strcmp(label, "audio_driver")) { drv = audio_driver_find_handle(i); if (drv) - strlcpy(str, audio_driver_find_ident(i), sizeof_str); + strlcpy(s, audio_driver_find_ident(i), len); } else if (!strcmp(label, "record_driver")) { drv = record_driver_find_handle(i); if (drv) - strlcpy(str, record_driver_find_ident(i), sizeof_str); + strlcpy(s, record_driver_find_ident(i), len); } else if (!strcmp(label, "audio_resampler_driver")) { drv = audio_resampler_driver_find_handle(i); if (drv) - strlcpy(str, audio_resampler_driver_find_ident(i), sizeof_str); + strlcpy(s, audio_resampler_driver_find_ident(i), len); } return drv; @@ -168,29 +168,29 @@ int find_driver_index(const char * label, const char *drv) return -1; } -bool find_first_driver(const char *label, char *str, size_t sizeof_str) +bool find_first_driver(const char *label, char *s, size_t len) { - find_driver_nonempty(label, 0, str, sizeof_str); + find_driver_nonempty(label, 0, s, len); return true; } /** * find_prev_driver: * @label : string of driver type to be found. - * @str : identifier of driver to be found. - * @sizeof_str : size of @str. + * @s : identifier of driver to be found. + * @len : size of @s. * * Find previous driver in driver array. **/ -bool find_prev_driver(const char *label, char *str, size_t sizeof_str) +bool find_prev_driver(const char *label, char *s, size_t len) { - int i = find_driver_index(label, str); + int i = find_driver_index(label, s); if (i > 0) - find_driver_nonempty(label, i - 1, str, sizeof_str); + find_driver_nonempty(label, i - 1, s, len); else { RARCH_WARN( - "Couldn't find any previous driver (current one: \"%s\").\n", str); + "Couldn't find any previous driver (current one: \"%s\").\n", s); return false; } return true; @@ -199,19 +199,19 @@ bool find_prev_driver(const char *label, char *str, size_t sizeof_str) /** * find_next_driver: * @label : string of driver type to be found. - * @str : identifier of driver to be found. - * @sizeof_str : size of @str. + * @s : identifier of driver to be found. + * @len : size of @s. * * Find next driver in driver array. **/ -bool find_next_driver(const char *label, char *str, size_t sizeof_str) +bool find_next_driver(const char *label, char *s, size_t len) { - int i = find_driver_index(label, str); - if (i >= 0 && (strcmp(str, "null") != 0)) - find_driver_nonempty(label, i + 1, str, sizeof_str); + int i = find_driver_index(label, s); + if (i >= 0 && (strcmp(s, "null") != 0)) + find_driver_nonempty(label, i + 1, s, len); else { - RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str); + RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", s); return false; } return true; diff --git a/driver.h b/driver.h index 6dc0143ac1..b5a9961e4a 100644 --- a/driver.h +++ b/driver.h @@ -330,31 +330,31 @@ void init_drivers_pre(void); **/ void uninit_drivers(int flags); -bool find_first_driver(const char *label, char *str, size_t sizeof_str); +bool find_first_driver(const char *label, char *s, size_t len); /** * find_prev_driver: * @label : string of driver type to be found. - * @str : identifier of driver to be found. - * @sizeof_str : size of @str. + * @s : identifier of driver to be found. + * @len : size of @s. * * Find previous driver in driver array. * * Returns: true (1) if successful, otherwise false (0). **/ -bool find_prev_driver(const char *label, char *str, size_t sizeof_str); +bool find_prev_driver(const char *label, char *s, size_t len); /** * find_next_driver: * @label : string of driver type to be found. - * @str : identifier of driver to be found. - * @sizeof_str : size of @str. + * @s : identifier of driver to be found. + * @len : size of @. * * Find next driver in driver array. * * Returns: true (1) if successful, otherwise false (0). **/ -bool find_next_driver(const char *label, char *str, size_t sizeof_str); +bool find_next_driver(const char *label, char *s, size_t len); /** * driver_set_nonblock_state: diff --git a/frontend/drivers/platform_android.c b/frontend/drivers/platform_android.c index 841c9afd22..41206f2e33 100644 --- a/frontend/drivers/platform_android.c +++ b/frontend/drivers/platform_android.c @@ -354,9 +354,9 @@ int system_property_get(const char *name, char *value) return length; } -static void frontend_android_get_name(char *name, size_t sizeof_name) +static void frontend_android_get_name(char *s, size_t len) { - int len = system_property_get("ro.product.model", name); + int len = system_property_get("ro.product.model", s); (void)len; } @@ -386,13 +386,13 @@ static void frontend_android_get_version(int32_t *major, int32_t *minor, int32_t } } -static void frontend_android_get_os(char *name, size_t sizeof_name, int *major, int *minor) +static void frontend_android_get_os(char *s, size_t len, int *major, int *minor) { int rel; frontend_android_get_version(major, minor, &rel); - strlcpy(name, "Android", sizeof_name); + strlcpy(s, "Android", len); } static void frontend_android_get_version_sdk(int32_t *sdk) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index d188b0f358..2c5a53a8d6 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -131,7 +131,7 @@ static NSSearchPathDomainMask NSConvertDomainFlagsCF(unsigned flags) static void CFSearchPathForDirectoriesInDomains(unsigned flags, unsigned domain_mask, unsigned expand_tilde, - char *buf, size_t sizeof_buf) + char *s, size_t len) { CFTypeRef array_val = (CFTypeRef)CFBridgingRetainCompat( NSSearchPathForDirectoriesInDomains(NSConvertFlagsCF(flags), @@ -142,19 +142,19 @@ static void CFSearchPathForDirectoriesInDomains(unsigned flags, if (!path || !array) return; - CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8); + CFStringGetCString(path, s, len, kCFStringEncodingUTF8); CFRelease(path); CFRelease(array); } -static void CFTemporaryDirectory(char *buf, size_t sizeof_buf) +static void CFTemporaryDirectory(char *s, size_t len) { #if __has_feature(objc_arc) CFStringRef path = (__bridge_retained CFStringRef)NSTemporaryDirectory(); #else CFStringRef path = (CFStringRef)NSTemporaryDirectory(); #endif - CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8); + CFStringGetCString(path, s, len, kCFStringEncodingUTF8); } #if defined(IOS) @@ -266,7 +266,7 @@ static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, } #endif -static void frontend_darwin_get_name(char *name, size_t sizeof_name) +static void frontend_darwin_get_name(char *s, size_t len) { #if defined(IOS) struct utsname buffer; @@ -274,25 +274,25 @@ static void frontend_darwin_get_name(char *name, size_t sizeof_name) if (uname(&buffer) != 0) return; - strlcpy(name, buffer.machine, sizeof_name); + strlcpy(s, buffer.machine, len); #elif defined(OSX) size_t length = 0; - sysctlbyname("hw.model", name, &length, NULL, 0); + sysctlbyname("hw.model", s, &length, NULL, 0); #endif } -static void frontend_darwin_get_os(char *name, size_t sizeof_name, int *major, int *minor) +static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor) { - (void)name; - (void)sizeof_name; + (void)s; + (void)len; (void)major; (void)minor; #if defined(IOS) get_ios_version(major, minor); - strlcpy(name, "iOS", sizeof_name); + strlcpy(s, "iOS", len); #elif defined(OSX) - strlcpy(name, "OSX", sizeof_name); + strlcpy(s, "OSX", len); #endif } diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index fe5b51c4d7..651e0afbf5 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -314,7 +314,7 @@ static void frontend_gx_init(void *data) static void frontend_gx_exec(const char *path, bool should_load_game); -static void frontend_gx_exitspawn(char *core_path, size_t sizeof_core_path) +static void frontend_gx_exitspawn(char *s, size_t len) { bool should_load_game = false; #if defined(IS_SALAMANDER) @@ -326,15 +326,15 @@ static void frontend_gx_exitspawn(char *core_path, size_t sizeof_core_path) if (!exit_spawn) return; - frontend_gx_exec(core_path, should_load_game); + frontend_gx_exec(s, should_load_game); /* FIXME/TODO - hack * direct loading failed (out of memory), try to jump to Salamander, * then load the correct core */ - fill_pathname_join(core_path, g_defaults.core_dir, - "boot.dol", sizeof_core_path); + fill_pathname_join(s, g_defaults.core_dir, + "boot.dol", len); #endif - frontend_gx_exec(core_path, should_load_game); + frontend_gx_exec(s, should_load_game); } static void frontend_gx_process_args(int *argc, char *argv[]) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index b31b3a169f..0e648a2707 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -410,7 +410,7 @@ enum frontend_architecture frontend_linux_get_architecture(void) return FRONTEND_ARCH_NONE; } -static void frontend_linux_get_os(char *name, size_t sizeof_name, int *major, int *minor) +static void frontend_linux_get_os(char *s, size_t len, int *major, int *minor) { unsigned krel; struct utsname buffer; @@ -419,7 +419,7 @@ static void frontend_linux_get_os(char *name, size_t sizeof_name, int *major, in return; sscanf(buffer.release, "%u.%u.%u", major, minor, &krel); - strlcpy(name, "Linux", sizeof_name); + strlcpy(s, "Linux", len); } const frontend_ctx_driver_t frontend_ctx_linux = { diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index ef739ff863..e94824301a 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -219,7 +219,7 @@ static void frontend_psp_set_fork(bool exit, bool start_game) exitspawn_start_game = start_game; } -static void frontend_psp_exitspawn(char *core_path, size_t sizeof_core_path) +static void frontend_psp_exitspawn(char *s, size_t len) { bool should_load_game = false; #ifndef IS_SALAMANDER @@ -228,7 +228,7 @@ static void frontend_psp_exitspawn(char *core_path, size_t sizeof_core_path) if (!exit_spawn) return; #endif - frontend_psp_exec(core_path, should_load_game); + frontend_psp_exec(s, should_load_game); } static int frontend_psp_get_rating(void) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index c143d0cb48..dc6e82580d 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -97,7 +97,7 @@ static void gfx_set_dwm(void) } #endif -static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, int *minor) +static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) { uint32_t version = GetVersion(); @@ -110,16 +110,16 @@ static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, in switch (*minor) { case 3: - strlcpy(name, "Windows 8.1", sizeof_name); + strlcpy(s, "Windows 8.1", len); break; case 2: - strlcpy(name, "Windows 8", sizeof_name); + strlcpy(s, "Windows 8", len); break; case 1: - strlcpy(name, "Windows 7/2008 R2", sizeof_name); + strlcpy(s, "Windows 7/2008 R2", len); break; case 0: - strlcpy(name, "Windows Vista/2008", sizeof_name); + strlcpy(s, "Windows Vista/2008", len); break; default: break; @@ -129,13 +129,13 @@ static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, in switch (*minor) { case 2: - strlcpy(name, "Windows 2003", sizeof_name); + strlcpy(s, "Windows 2003", len); break; case 1: - strlcpy(name, "Windows XP", sizeof_name); + strlcpy(s, "Windows XP", len); break; case 0: - strlcpy(name, "Windows 2000", sizeof_name); + strlcpy(s, "Windows 2000", len); break; } break; @@ -143,13 +143,13 @@ static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, in switch (*minor) { case 0: - strlcpy(name, "Windows NT 4.0", sizeof_name); + strlcpy(s, "Windows NT 4.0", len); break; case 90: - strlcpy(name, "Windows ME", sizeof_name); + strlcpy(s, "Windows ME", len); break; case 10: - strlcpy(name, "Windows 98", sizeof_name); + strlcpy(s, "Windows 98", len); break; } break; diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 7c1e3e6f16..a870c526fc 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -305,8 +305,7 @@ static void frontend_xdk_set_fork(bool exit, bool start_game) exitspawn_start_game = start_game; } -static void frontend_xdk_exitspawn(char *core_path, - size_t sizeof_core_path) +static void frontend_xdk_exitspawn(char *s, size_t len) { bool should_load_game = false; #ifndef IS_SALAMANDER @@ -315,7 +314,7 @@ static void frontend_xdk_exitspawn(char *core_path, if (!exit_spawn) return; #endif - frontend_xdk_exec(core_path, should_load_game); + frontend_xdk_exec(s, should_load_game); } static void frontend_xdk_exec(const char *path, bool should_load_game) diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index d77a293c23..ef214fd2a4 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -57,7 +57,7 @@ typedef struct frontend_ctx_driver environment_get_t environment_get; void (*init)(void *data); void (*deinit)(void *data); - void (*exitspawn)(char *core_path, size_t sizeof_core_path); + void (*exitspawn)(char *s, size_t len); process_args_t process_args; void (*exec)(const char *, bool); diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index 25a76b9a80..4593efabf4 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -80,7 +80,7 @@ static void find_first_libretro_core(char *first_file, dir_list_free(list); } -static void find_and_set_first_file(char *path, size_t sizeof_path, +static void find_and_set_first_file(char *s, size_t len, const char *ext) { /* Last fallback - we'll need to start the first executable file @@ -93,14 +93,14 @@ static void find_and_set_first_file(char *path, size_t sizeof_path, if (first_file[0] != '\0') { - fill_pathname_join(path, g_defaults.core_dir, first_file, sizeof_path); - RARCH_LOG("libretro_path now set to: %s.\n", path); + fill_pathname_join(s, g_defaults.core_dir, first_file, len); + RARCH_LOG("libretro_path now set to: %s.\n", s); } else RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n"); } -static void salamander_init(char *libretro_path, size_t sizeof_libretro_path) +static void salamander_init(char *s, size_t len) { /* normal executable loading path */ bool config_file_exists = false; @@ -117,7 +117,7 @@ static void salamander_init(char *libretro_path, size_t sizeof_libretro_path) { config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); config_file_free(conf); - strlcpy(libretro_path, tmp_str, sizeof_libretro_path); + strlcpy(s, tmp_str, len); } #ifdef GEKKO else /* stupid libfat bug or something; sometimes it says the file is there when it doesn't */ @@ -125,10 +125,10 @@ static void salamander_init(char *libretro_path, size_t sizeof_libretro_path) #endif } - if (!config_file_exists || !strcmp(libretro_path, "")) - find_and_set_first_file(libretro_path, sizeof_libretro_path, EXT_EXECUTABLES); + if (!config_file_exists || !strcmp(s, "")) + find_and_set_first_file(s, len, EXT_EXECUTABLES); else - RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); + RARCH_LOG("Start [%s] found in retroarch.cfg.\n", len); if (!config_file_exists) { @@ -136,7 +136,7 @@ static void salamander_init(char *libretro_path, size_t sizeof_libretro_path) if (conf) { - config_set_string(conf, "libretro_path", libretro_path); + config_set_string(conf, "libretro_path", len); config_file_write(conf, g_defaults.config_path); config_file_free(conf); } diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index 94d67f8f44..7fe39de105 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -425,12 +425,12 @@ static int system_property_get_density(char *value) return length; } -static void dpi_get_density(char *name, size_t sizeof_name) +static void dpi_get_density(char *s, size_t len) { - system_property_get("ro.sf.lcd_density", name); + system_property_get("ro.sf.lcd_density", s); - if (name[0] == '\0') - system_property_get_density(name); + if (s[0] == '\0') + system_property_get_density(s); } static bool android_gfx_ctx_get_metrics(void *data, diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 0d43e4e5f1..9d614912a6 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -238,18 +238,18 @@ static void rmenu_set_texture(void) menu_texture_inited = true; } -static void rmenu_wallpaper_set_defaults(char *menu_bg, size_t sizeof_menu_bg) +static void rmenu_wallpaper_set_defaults(char *s, size_t len) { settings_t *settings = config_get_ptr(); - fill_pathname_join(menu_bg, settings->assets_directory, - "rmenu", sizeof_menu_bg); + fill_pathname_join(s, settings->assets_directory, + "rmenu", len); #ifdef _XBOX1 - fill_pathname_join(menu_bg, menu_bg, "sd", sizeof_menu_bg); + fill_pathname_join(s, s, "sd", len); #else - fill_pathname_join(menu_bg, menu_bg, "hd", sizeof_menu_bg); + fill_pathname_join(s, s, "hd", len); #endif - fill_pathname_join(menu_bg, menu_bg, "main_menu.png", sizeof_menu_bg); + fill_pathname_join(s, s, "main_menu.png", len); } static void rmenu_context_reset(void) diff --git a/menu/menu_entries_cbs_title.c b/menu/menu_entries_cbs_title.c index a7d5ae6b44..8f0e4c62ec 100644 --- a/menu/menu_entries_cbs_title.c +++ b/menu/menu_entries_cbs_title.c @@ -27,16 +27,16 @@ static INLINE void replace_chars(char *str, char c1, char c2) *pos = c2; } -static INLINE void sanitize_to_string(char *title, const char *label, size_t sizeof_title) +static INLINE void sanitize_to_string(char *s, const char *label, size_t len) { char new_label[PATH_MAX_LENGTH]; strlcpy(new_label, label, sizeof(new_label)); - strlcpy(title, string_to_upper(new_label), sizeof_title); - replace_chars(title, '_', ' '); + strlcpy(s, string_to_upper(new_label), len); + replace_chars(s, '_', ' '); } static int action_get_title_default(const char *path, const char *label, - unsigned menu_type, char *title, size_t sizeof_title) + unsigned menu_type, char *s, size_t len) { char elem0[PATH_MAX_LENGTH], elem1[PATH_MAX_LENGTH]; char elem0_path[PATH_MAX_LENGTH], elem1_path[PATH_MAX_LENGTH]; @@ -71,62 +71,62 @@ static int action_get_title_default(const char *path, const char *label, RARCH_LOG("label %s, elem0 %s, elem1 %s\n", label, elem0, elem1); #endif if (!strcmp(label, "deferred_database_manager_list")) - snprintf(title, sizeof_title, "DATABASE SELECTION - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); + snprintf(s, len, "DATABASE SELECTION - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); else if (!strcmp(label, "deferred_cursor_manager_list")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); + snprintf(s, len, "DATABASE CURSOR LIST - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: DEVELOPER - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: DEVELOPER - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: PUBLISHER - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: PUBLISHER - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_origin")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: ORIGIN - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: ORIGIN - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_franchise")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: FRANCHISE - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: FRANCHISE - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_rating")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: EDGE MAGAZINE RATING - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: EDGE MAGAZINE RATING - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_edge_magazine_issue")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: EDGE MAGAZINE ISSUE - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: EDGE MAGAZINE ISSUE - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releasemonth")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: RELEASEDATE BY MONTH - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: RELEASEDATE BY MONTH - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_releaseyear")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: RELEASEDATE BY YEAR - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: RELEASEDATE BY YEAR - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_esrb_rating")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: ESRB RATING - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: ESRB RATING - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_elspa_rating")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: ELSPA RATING - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: ELSPA RATING - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_pegi_rating")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: PEGI RATING - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: PEGI RATING - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_cero_rating")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: CERO RATING - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: CERO RATING - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_bbfc_rating")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: BBFC RATING - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: BBFC RATING - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_max_users")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: MAX USERS - %s)", elem0_path); + snprintf(s, len, "DATABASE CURSOR LIST (FILTER: MAX USERS - %s)", elem0_path); else if (!strcmp(elem0, "deferred_rdb_entry_detail")) - snprintf(title, sizeof_title, "DATABASE INFO: %s", elem1); + snprintf(s, len, "DATABASE INFO: %s", elem1); else if (!strcmp(label, "deferred_core_list")) - snprintf(title, sizeof_title, "DETECTED CORES %s", path); + snprintf(s, len, "DETECTED CORES %s", path); else if (!strcmp(label, "configurations")) - snprintf(title, sizeof_title, "CONFIG %s", path); + snprintf(s, len, "CONFIG %s", path); else if (!strcmp(label, "disk_image_append")) - snprintf(title, sizeof_title, "DISK APPEND %s", path); + snprintf(s, len, "DISK APPEND %s", path); else if (menu_entries_common_is_settings_entry(elem0)) { - strlcpy(title, string_to_upper(elem0), sizeof_title); + strlcpy(s, string_to_upper(elem0), len); if (elem1[0] != '\0') { - strlcat(title, " - ", sizeof_title); - strlcat(title, string_to_upper(elem1), sizeof_title); + strlcat(s, " - ", len); + strlcat(s, string_to_upper(elem1), len); } } else if (menu_type == MENU_SETTINGS_CUSTOM_BIND || menu_type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD) { - strlcpy(title, "INPUT SETTINGS", sizeof_title); + strlcpy(s, "INPUT SETTINGS", len); if (elem1[0] != '\0') { - strlcat(title, " - ", sizeof_title); - strlcat(title, string_to_upper(elem1), sizeof_title); + strlcat(s, " - ", len); + strlcat(s, string_to_upper(elem1), len); } } else if ( @@ -154,69 +154,69 @@ static int action_get_title_default(const char *path, const char *label, || (!strcmp(label, "deferred_core_updater_list")) ) { - sanitize_to_string(title, label, sizeof_title); + sanitize_to_string(s, label, len); } else if (!strcmp(label, "video_shader_pass")) - snprintf(title, sizeof_title, "SHADER %s", path); + snprintf(s, len, "SHADER %s", path); else if (!strcmp(label, "video_shader_preset")) - snprintf(title, sizeof_title, "SHADER PRESET %s", path); + snprintf(s, len, "SHADER PRESET %s", path); else if (!strcmp(label, "cheat_file_load")) - snprintf(title, sizeof_title, "CHEAT FILE %s", path); + snprintf(s, len, "CHEAT FILE %s", path); else if (!strcmp(label, "remap_file_load")) - snprintf(title, sizeof_title, "REMAP FILE %s", path); + snprintf(s, len, "REMAP FILE %s", path); else if (menu_type == MENU_SETTINGS_CUSTOM_VIEWPORT || !strcmp(label, "custom_viewport_2") || !strcmp(label, "help") || menu_type == MENU_SETTINGS) - snprintf(title, sizeof_title, "MENU %s", path); + snprintf(s, len, "MENU %s", path); else if (!strcmp(label, "input_overlay")) - snprintf(title, sizeof_title, "OVERLAY %s", path); + snprintf(s, len, "OVERLAY %s", path); else if (!strcmp(label, "video_font_path")) - snprintf(title, sizeof_title, "FONT %s", path); + snprintf(s, len, "FONT %s", path); else if (!strcmp(label, "video_filter")) - snprintf(title, sizeof_title, "FILTER %s", path); + snprintf(s, len, "FILTER %s", path); else if (!strcmp(label, "audio_dsp_plugin")) - snprintf(title, sizeof_title, "DSP FILTER %s", path); + snprintf(s, len, "DSP FILTER %s", path); else if (!strcmp(label, "rgui_browser_directory")) - snprintf(title, sizeof_title, "BROWSER DIR %s", path); + snprintf(s, len, "BROWSER DIR %s", path); else if (!strcmp(label, "playlist_directory")) - snprintf(title, sizeof_title, "PLAYLIST DIR %s", path); + snprintf(s, len, "PLAYLIST DIR %s", path); else if (!strcmp(label, "content_directory")) - snprintf(title, sizeof_title, "CONTENT DIR %s", path); + snprintf(s, len, "CONTENT DIR %s", path); else if (!strcmp(label, "screenshot_directory")) - snprintf(title, sizeof_title, "SCREENSHOT DIR %s", path); + snprintf(s, len, "SCREENSHOT DIR %s", path); else if (!strcmp(label, "video_shader_dir")) - snprintf(title, sizeof_title, "SHADER DIR %s", path); + snprintf(s, len, "SHADER DIR %s", path); else if (!strcmp(label, "video_filter_dir")) - snprintf(title, sizeof_title, "FILTER DIR %s", path); + snprintf(s, len, "FILTER DIR %s", path); else if (!strcmp(label, "audio_filter_dir")) - snprintf(title, sizeof_title, "DSP FILTER DIR %s", path); + snprintf(s, len, "DSP FILTER DIR %s", path); else if (!strcmp(label, "savestate_directory")) - snprintf(title, sizeof_title, "SAVESTATE DIR %s", path); + snprintf(s, len, "SAVESTATE DIR %s", path); else if (!strcmp(label, "libretro_dir_path")) - snprintf(title, sizeof_title, "LIBRETRO DIR %s", path); + snprintf(s, len, "LIBRETRO DIR %s", path); else if (!strcmp(label, "libretro_info_path")) - snprintf(title, sizeof_title, "LIBRETRO INFO DIR %s", path); + snprintf(s, len, "LIBRETRO INFO DIR %s", path); else if (!strcmp(label, "rgui_config_directory")) - snprintf(title, sizeof_title, "CONFIG DIR %s", path); + snprintf(s, len, "CONFIG DIR %s", path); else if (!strcmp(label, "savefile_directory")) - snprintf(title, sizeof_title, "SAVEFILE DIR %s", path); + snprintf(s, len, "SAVEFILE DIR %s", path); else if (!strcmp(label, "overlay_directory")) - snprintf(title, sizeof_title, "OVERLAY DIR %s", path); + snprintf(s, len, "OVERLAY DIR %s", path); else if (!strcmp(label, "system_directory")) - snprintf(title, sizeof_title, "SYSTEM DIR %s", path); + snprintf(s, len, "SYSTEM DIR %s", path); else if (!strcmp(label, "assets_directory")) - snprintf(title, sizeof_title, "ASSETS DIR %s", path); + snprintf(s, len, "ASSETS DIR %s", path); else if (!strcmp(label, "extraction_directory")) - snprintf(title, sizeof_title, "EXTRACTION DIR %s", path); + snprintf(s, len, "EXTRACTION DIR %s", path); else if (!strcmp(label, "joypad_autoconfig_dir")) - snprintf(title, sizeof_title, "AUTOCONFIG DIR %s", path); + snprintf(s, len, "AUTOCONFIG DIR %s", path); else { driver_t *driver = driver_get_ptr(); if (driver->menu->defer_core) - snprintf(title, sizeof_title, "CONTENT %s", path); + snprintf(s, len, "CONTENT %s", path); else { global_t *global = global_get_ptr(); @@ -226,7 +226,7 @@ static int action_get_title_default(const char *path, const char *label, core_name = global->system.info.library_name; if (!core_name) core_name = "No Core"; - snprintf(title, sizeof_title, "CONTENT (%s) %s", core_name, path); + snprintf(s, len, "CONTENT (%s) %s", core_name, path); } } diff --git a/menu/menu_list.h b/menu/menu_list.h index 60f04c5f10..7a2f749a96 100644 --- a/menu/menu_list.h +++ b/menu/menu_list.h @@ -39,7 +39,7 @@ typedef struct menu_file_list_cbs int (*action_select)(const char *path, const char *label, unsigned type, size_t idx); int (*action_get_title)(const char *path, const char *label, - unsigned type, char *title, size_t sizeof_title); + unsigned type, char *s, size_t len); int (*action_ok)(const char *path, const char *label, unsigned type, size_t idx); int (*action_cancel)(const char *path, const char *label, unsigned type, diff --git a/retroarch.c b/retroarch.c index bcab8cb93b..ec5a8d408a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1361,19 +1361,19 @@ void rarch_playlist_load_content(void *data, unsigned idx) * @dir : Directory. Gets joined with @path. * @path : Path. Gets joined with @dir. * @menu_label : Label identifier of menu setting. - * @deferred_path : Deferred core path. Will be filled in + * @s : Deferred core path. Will be filled in * by function. - * @sizeof_deferred_path : Size of @deferred_path. + * @len : Size of @s. * * Gets deferred core. * * Returns: 0 if there are multiple deferred cores and a * selection needs to be made from a list, otherwise - * returns -1 and fills in @deferred_path with path to core. + * returns -1 and fills in @s with path to core. **/ int rarch_defer_core(core_info_list_t *core_info, const char *dir, const char *path, const char *menu_label, - char *deferred_path, size_t sizeof_deferred_path) + char *s, size_t len) { char new_core_path[PATH_MAX_LENGTH]; const core_info_t *info = NULL; @@ -1381,20 +1381,20 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir, settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path); + fill_pathname_join(s, dir, path, len); #ifdef HAVE_COMPRESSION if (path_is_compressed_file(dir)) { /* In case of a compressed archive, we have to join with a hash */ /* We are going to write at the position of dir: */ - rarch_assert(strlen(dir) < strlen(deferred_path)); - deferred_path[strlen(dir)] = '#'; + rarch_assert(strlen(dir) < strlen(s)); + s[strlen(dir)] = '#'; } #endif if (core_info) - core_info_list_get_supported_cores(core_info, deferred_path, &info, + core_info_list_get_supported_cores(core_info, s, &info, &supported); if (!strcmp(menu_label, "load_content")) @@ -1415,7 +1415,7 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir, if (supported != 1) return 0; - strlcpy(global->fullpath, deferred_path, sizeof(global->fullpath)); + strlcpy(global->fullpath, s, sizeof(global->fullpath)); if (path_file_exists(new_core_path)) strlcpy(settings->libretro, new_core_path, diff --git a/retroarch.h b/retroarch.h index 5513a2c266..f5437bd47c 100644 --- a/retroarch.h +++ b/retroarch.h @@ -131,19 +131,19 @@ void rarch_playlist_load_content(void *data, unsigned index); * @dir : Directory. Gets joined with @path. * @path : Path. Gets joined with @dir. * @menu_label : Label identifier of menu setting. - * @deferred_path : Deferred core path. Will be filled in + * @s : Deferred core path. Will be filled in * by function. - * @sizeof_deferred_path : Size of @deferred_path. + * @len : Size of @s. * * Gets deferred core. * * Returns: 0 if there are multiple deferred cores and a * selection needs to be made from a list, otherwise - * returns -1 and fills in @deferred_path with path to core. + * returns -1 and fills in @s with path to core. **/ int rarch_defer_core(core_info_list_t *data, const char *dir, const char *path, const char *menu_label, - char *deferred_path, size_t sizeof_deferred_path); + char *s, size_t len); void rarch_fill_pathnames(void); diff --git a/runloop_data.c b/runloop_data.c index 1e2d32ba76..e4d7241fdd 100644 --- a/runloop_data.c +++ b/runloop_data.c @@ -369,7 +369,7 @@ void rarch_main_data_msg_queue_push(unsigned type, msg_queue_push(queue, new_msg, prio, duration); } -void data_runloop_osd_msg(const char *msg, size_t sizeof_msg) +void data_runloop_osd_msg(const char *msg, size_t len) { - strlcpy(data_runloop_msg, msg, sizeof_msg); + strlcpy(data_runloop_msg, msg, len); } diff --git a/settings.c b/settings.c index 34ffe6e861..e6c7d2338b 100644 --- a/settings.c +++ b/settings.c @@ -233,20 +233,19 @@ void setting_set_with_string_representation(rarch_setting_t* setting, /** * setting_get_string_representation: * @setting : pointer to setting - * @type_str : buffer to write contents of string representation to. - * @sizeof_type_str : size of the buffer (@type_str) + * @s : buffer to write contents of string representation to. + * @len : size of the buffer (@s) * * Get a setting value's string representation. **/ -void setting_get_string_representation(void *data, - char *type_str, size_t sizeof_type_str) +void setting_get_string_representation(void *data, char *s, size_t len) { rarch_setting_t* setting = (rarch_setting_t*)data; - if (!setting || !type_str || !sizeof_type_str) + if (!setting || !s) return; if (setting->get_string_representation) - setting->get_string_representation(setting, type_str, sizeof_type_str); + setting->get_string_representation(setting, s, len); } /** @@ -1065,67 +1064,67 @@ static int setting_string_action_ok_allow_input(void *data, /** * setting_get_string_representation_st_bool: * @setting : pointer to setting - * @type_str : string for the type to be represented on-screen as + * @s : string for the type to be represented on-screen as * a label. - * @type_str_size : size of @type_str + * @len : size of @s * * Set a settings' label value. The setting is of type ST_BOOL. **/ static void setting_get_string_representation_st_bool(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, *setting->value.boolean ? setting->boolean.on_label : - setting->boolean.off_label, type_str_size); + strlcpy(s, *setting->value.boolean ? setting->boolean.on_label : + setting->boolean.off_label, len); } static void setting_get_string_representation_st_action(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { - strlcpy(type_str, "...", type_str_size); + strlcpy(s, "...", len); } static void setting_get_string_representation_st_group(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, "...", type_str_size); + strlcpy(s, "...", len); } static void setting_get_string_representation_st_sub_group(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, "...", type_str_size); + strlcpy(s, "...", len); } /** * setting_get_string_representation_st_float: * @setting : pointer to setting - * @type_str : string for the type to be represented on-screen as + * @s : string for the type to be represented on-screen as * a label. - * @type_str_size : size of @type_str + * @len : size of @s * * Set a settings' label value. The setting is of type ST_FLOAT. **/ static void setting_get_string_representation_st_float(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - snprintf(type_str, type_str_size, setting->rounding_fraction, + snprintf(s, len, setting->rounding_fraction, *setting->value.fraction); } static void setting_get_string_representation_st_float_video_refresh_rate_auto(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { double video_refresh_rate = 0.0; double deviation = 0.0; @@ -1136,7 +1135,7 @@ static void setting_get_string_representation_st_float_video_refresh_rate_auto(v if (video_monitor_fps_statistics(&video_refresh_rate, &deviation, &sample_points)) { - snprintf(type_str, type_str_size, "%.3f Hz (%.1f%% dev, %u samples)", + snprintf(s, len, "%.3f Hz (%.1f%% dev, %u samples)", video_refresh_rate, 100.0 * deviation, sample_points); #ifdef HAVE_MENU { @@ -1148,41 +1147,41 @@ static void setting_get_string_representation_st_float_video_refresh_rate_auto(v #endif } else - strlcpy(type_str, "N/A", type_str_size); + strlcpy(s, "N/A", len); } static void setting_get_string_representation_st_dir(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, + strlcpy(s, *setting->value.string ? setting->value.string : setting->dir.empty_path, - type_str_size); + len); } static void setting_get_string_representation_st_path(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, path_basename(setting->value.string), type_str_size); + strlcpy(s, path_basename(setting->value.string), len); } static void setting_get_string_representation_st_string(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, setting->value.string, type_str_size); + strlcpy(s, setting->value.string, len); } static void setting_get_string_representation_st_bind(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; const struct retro_keybind* keybind = NULL; @@ -1194,53 +1193,53 @@ static void setting_get_string_representation_st_bind(void *data, keybind = (const struct retro_keybind*)setting->value.keybind; auto_bind = (const struct retro_keybind*)input_get_auto_bind(setting->index_offset, keybind->id); - input_get_bind_string(type_str, keybind, auto_bind, type_str_size); + input_get_bind_string(s, keybind, auto_bind, len); } static void setting_get_string_representation_int(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - snprintf(type_str, type_str_size, "%d", *setting->value.integer); + snprintf(s, len, "%d", *setting->value.integer); } static void setting_get_string_representation_uint_video_monitor_index(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (!setting) return; if (*setting->value.unsigned_integer) - snprintf(type_str, type_str_size, "%u", + snprintf(s, len, "%u", *setting->value.unsigned_integer); else - strlcpy(type_str, "0 (Auto)", type_str_size); + strlcpy(s, "0 (Auto)", len); } static void setting_get_string_representation_uint_video_rotation(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, rotation_lut[*setting->value.unsigned_integer], - type_str_size); + strlcpy(s, rotation_lut[*setting->value.unsigned_integer], + len); } static void setting_get_string_representation_uint_aspect_ratio_index(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - strlcpy(type_str, + strlcpy(s, aspectratio_lut[*setting->value.unsigned_integer].name, - type_str_size); + len); } static void setting_get_string_representation_uint_libretro_device(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { const struct retro_controller_description *desc = NULL; const char *name = NULL; @@ -1282,11 +1281,11 @@ static void setting_get_string_representation_uint_libretro_device(void *data, } } - strlcpy(type_str, name, type_str_size); + strlcpy(s, name, len); } static void setting_get_string_representation_uint_archive_mode(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { const char *name = "Unknown"; settings_t *settings = config_get_ptr(); @@ -1306,11 +1305,11 @@ static void setting_get_string_representation_uint_archive_mode(void *data, break; } - strlcpy(type_str, name, type_str_size); + strlcpy(s, name, len); } static void setting_get_string_representation_uint_analog_dpad_mode(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { static const char *modes[] = { "None", @@ -1324,27 +1323,27 @@ static void setting_get_string_representation_uint_analog_dpad_mode(void *data, (void)data; - strlcpy(type_str, modes[settings->input.analog_dpad_mode + strlcpy(s, modes[settings->input.analog_dpad_mode [setting->index_offset] % ANALOG_DPAD_LAST], - type_str_size); + len); } static void setting_get_string_representation_uint_autosave_interval(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (!setting) return; if (*setting->value.unsigned_integer) - snprintf(type_str, type_str_size, "%u seconds", + snprintf(s, len, "%u seconds", *setting->value.unsigned_integer); else - strlcpy(type_str, "OFF", type_str_size); + strlcpy(s, "OFF", len); } static void setting_get_string_representation_uint_user_language(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { static const char *modes[] = { "English", @@ -1365,11 +1364,11 @@ static void setting_get_string_representation_uint_user_language(void *data, if (!setting) return; - strlcpy(type_str, modes[settings->user_language], type_str_size); + strlcpy(s, modes[settings->user_language], len); } static void setting_get_string_representation_uint_libretro_log_level(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (!setting) @@ -1381,25 +1380,25 @@ static void setting_get_string_representation_uint_libretro_log_level(void *data "3 (Error)" }; - strlcpy(type_str, modes[*setting->value.unsigned_integer], - type_str_size); + strlcpy(s, modes[*setting->value.unsigned_integer], + len); } static void setting_get_string_representation_uint(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - snprintf(type_str, type_str_size, "%u", + snprintf(s, len, "%u", *setting->value.unsigned_integer); } static void setting_get_string_representation_hex(void *data, - char *type_str, size_t type_str_size) + char *s, size_t len) { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - snprintf(type_str, type_str_size, "%08x", + snprintf(s, len, "%08x", *setting->value.unsigned_integer); } @@ -1871,24 +1870,24 @@ rarch_setting_t setting_string_setting_options(enum setting_type type, /** * setting_get_description: * @label : identifier label of setting - * @msg : output message - * @sizeof_msg : size of @msg + * @s : output message + * @len : size of @s * - * Writes a 'Help' description message to @msg if there is + * Writes a 'Help' description message to @s if there is * one available based on the identifier label of the setting * (@label). * * Returns: 0 (always for now). TODO: make it handle -1 as well. **/ -int setting_get_description(const char *label, char *msg, - size_t sizeof_msg) +int setting_get_description(const char *label, char *s, + size_t len) { settings_t *settings = config_get_ptr(); if (!strcmp(label, "input_driver")) { if (!strcmp(settings->input.driver, "udev")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- udev Input driver. \n" " \n" "This driver can run without X. \n" @@ -1907,7 +1906,7 @@ int setting_get_description(const char *label, char *msg, "rule which makes these accessible to non-root." ); else if (!strcmp(settings->input.driver, "linuxraw")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- linuxraw Input driver. \n" " \n" "This driver requires an active TTY. Keyboard \n" @@ -1917,7 +1916,7 @@ int setting_get_description(const char *label, char *msg, "This driver uses the older joystick API \n" "(/dev/input/js*)."); else - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Input driver.\n" " \n" "Depending on video driver, it might \n" @@ -1926,7 +1925,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "load_content")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Load Content. \n" "Browse for content. \n" " \n" @@ -1947,7 +1946,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "core_list")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Core Selection. \n" " \n" "Browse for a libretro core \n" @@ -1962,7 +1961,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "history_list")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Loading content from history. \n" " \n" "As content is loaded, content and libretro \n" @@ -1978,16 +1977,16 @@ int setting_get_description(const char *label, char *msg, else if (!strcmp(label, "audio_resampler_driver")) { if (!strcmp(settings->audio.resampler, "sinc")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Windowed SINC implementation."); else if (!strcmp(settings->audio.resampler, "CC")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Convoluted Cosine implementation."); } else if (!strcmp(label, "video_driver")) { if (!strcmp(settings->video.driver, "gl")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- OpenGL Video driver. \n" " \n" "This driver allows libretro GL cores to \n" @@ -1999,7 +1998,7 @@ int setting_get_description(const char *label, char *msg, "dependent on your graphics card's \n" "underlying GL driver)."); else if (!strcmp(settings->video.driver, "sdl2")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- SDL 2 Video driver.\n" " \n" "This is an SDL 2 software-rendered video \n" @@ -2009,7 +2008,7 @@ int setting_get_description(const char *label, char *msg, "core implementations is dependent \n" "on your platform SDL implementation."); else if (!strcmp(settings->video.driver, "sdl")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- SDL Video driver.\n" " \n" "This is an SDL 1.2 software-rendered video \n" @@ -2018,14 +2017,14 @@ int setting_get_description(const char *label, char *msg, "Performance is considered to be suboptimal. \n" "Consider using it only as a last resort."); else if (!strcmp(settings->video.driver, "d3d")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Direct3D Video driver. \n" " \n" "Performance for software-rendered cores \n" "is dependent on your graphic card's \n" "underlying D3D driver)."); else if (!strcmp(settings->video.driver, "exynos")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Exynos-G2D Video Driver. \n" " \n" "This is a low-level Exynos video driver. \n" @@ -2035,18 +2034,18 @@ int setting_get_description(const char *label, char *msg, "Performance for software rendered cores \n" "should be optimal."); else if (!strcmp(settings->video.driver, "sunxi")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Sunxi-G2D Video Driver. \n" " \n" "This is a low-level Sunxi video driver. \n" "Uses the G2D block in Allwinner SoCs."); else - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Current Video driver."); } else if (!strcmp(label, "audio_dsp_plugin")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Audio DSP plugin.\n" " Processes audio before it's sent to \n" "the driver." @@ -2054,7 +2053,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "libretro_dir_path")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Core Directory. \n" " \n" "A directory for where to search for \n" @@ -2062,13 +2061,13 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_disable_composition")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- Forcibly disable composition.\n" "Only valid on Windows Vista/7 for now."); } else if (!strcmp(label, "libretro_log_level")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- Sets log level for libretro cores \n" "(GET_LOG_INTERFACE). \n" " \n" @@ -2087,19 +2086,19 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "log_verbosity")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- Enable or disable verbosity level \n" "of frontend."); } else if (!strcmp(label, "perfcnt_enable")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- Enable or disable frontend \n" "performance counters."); } else if (!strcmp(label, "system_directory")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- System Directory. \n" " \n" "Sets the 'system' directory.\n" @@ -2109,7 +2108,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "rgui_show_start_screen")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Show startup screen in menu.\n" "Is automatically set to false when seen\n" "for the first time.\n" @@ -2119,7 +2118,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "config_save_on_exit")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Flushes config to disk on exit.\n" "Useful for menu as settings can be\n" "modified. Overwrites the config.\n" @@ -2142,13 +2141,13 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "core_specific_config")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Load up a specific config file \n" "based on the core being used.\n"); } else if (!strcmp(label, "video_scale")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Fullscreen resolution.\n" " \n" "Resolution of 0 uses the \n" @@ -2156,12 +2155,12 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_vsync")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Video V-Sync.\n"); } else if (!strcmp(label, "video_hard_sync")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Attempts to hard-synchronize \n" "CPU and GPU.\n" " \n" @@ -2170,7 +2169,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_hard_sync_frames")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Sets how many frames CPU can \n" "run ahead of GPU when using 'GPU \n" "Hard Sync'.\n" @@ -2183,7 +2182,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_frame_delay")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Sets how many milliseconds to delay\n" "after VSync before running the core.\n" "\n" @@ -2194,7 +2193,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "audio_rate_control_delta")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Audio rate control.\n" " \n" "Setting this to 0 disables rate control.\n" @@ -2209,7 +2208,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "audio_max_timing_skew")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Maximum audio timing skew.\n" " \n" "Defines the maximum change in input rate.\n" @@ -2224,10 +2223,10 @@ int setting_get_description(const char *label, char *msg, else if (!strcmp(label, "video_filter")) { #ifdef HAVE_FILTERS_BUILTIN - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- CPU-based video filter."); #else - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- CPU-based video filter.\n" " \n" "Path to a dynamic library."); @@ -2235,11 +2234,11 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_fullscreen")) { - snprintf(msg, sizeof_msg, " -- Toggles fullscreen."); + snprintf(s, len, " -- Toggles fullscreen."); } else if (!strcmp(label, "audio_device")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Override the default audio device \n" "the audio driver uses.\n" "This is driver dependent. E.g.\n" @@ -2265,7 +2264,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_black_frame_insertion")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Inserts a black frame inbetween \n" "frames.\n" " \n" @@ -2279,7 +2278,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_threaded")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Use threaded video driver.\n" " \n" "Using this might improve performance at \n" @@ -2288,7 +2287,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_scale_integer")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Only scales video in integer \n" "steps.\n" " \n" @@ -2300,7 +2299,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_crop_overscan")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Forces cropping of overscanned \n" "frames.\n" " \n" @@ -2309,7 +2308,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_monitor_index")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Which monitor to prefer.\n" " \n" "0 (default) means no particular monitor \n" @@ -2319,7 +2318,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_rotation")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Forces a certain rotation \n" "of the screen.\n" " \n" @@ -2329,7 +2328,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "audio_volume")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Audio volume, expressed in dB.\n" " \n" " 0 dB is normal volume. No gain will be applied.\n" @@ -2338,7 +2337,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "block_sram_overwrite")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Block SRAM from being overwritten \n" "when loading save states.\n" " \n" @@ -2346,7 +2345,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "fastforward_ratio")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Fastforward ratio." " \n" "The maximum rate at which content will\n" @@ -2362,19 +2361,19 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "pause_nonactive")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Pause gameplay when window focus \n" "is lost."); } else if (!strcmp(label, "video_gpu_screenshot")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Screenshots output of GPU shaded \n" "material if available."); } else if (!strcmp(label, "autosave_interval")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Autosaves the non-volatile SRAM \n" "at a regular interval.\n" " \n" @@ -2386,7 +2385,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "screenshot_directory")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Screenshot Directory. \n" " \n" "Directory to dump screenshots to." @@ -2394,7 +2393,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_swap_interval")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- VSync Swap Interval.\n" " \n" "Uses a custom swap interval for VSync. Set this \n" @@ -2402,7 +2401,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_refresh_rate_auto")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Refresh Rate Auto.\n" " \n" "The accurate refresh rate of our monitor (Hz).\n" @@ -2423,7 +2422,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "savefile_directory")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Savefile Directory. \n" " \n" "Save all save files (*.srm) to this \n" @@ -2435,7 +2434,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "savestate_directory")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Savestate Directory. \n" " \n" "Save all save states (*.state) to this \n" @@ -2446,7 +2445,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "assets_directory")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Assets Directory. \n" " \n" " This location is queried by default when \n" @@ -2455,7 +2454,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "slowmotion_ratio")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Slowmotion ratio." " \n" "When slowmotion, content will slow\n" @@ -2463,7 +2462,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "input_axis_threshold")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Defines axis threshold.\n" " \n" "How far an axis must be tilted to result\n" @@ -2472,7 +2471,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "input_turbo_period")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Turbo period.\n" " \n" "Describes speed of which turbo-enabled\n" @@ -2481,7 +2480,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "rewind_granularity")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Rewind granularity.\n" " \n" " When rewinding defined number of \n" @@ -2491,7 +2490,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "rewind_enable")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Enable rewinding.\n" " \n" "This will take a performance hit, \n" @@ -2499,7 +2498,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "input_autodetect_enable")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Enable input auto-detection.\n" " \n" "Will attempt to auto-configure \n" @@ -2507,19 +2506,19 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "camera_allow")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Allow or disallow camera access by \n" "cores."); } else if (!strcmp(label, "location_allow")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Allow or disallow location services \n" "access by cores."); } else if (!strcmp(label, "savestate_auto_save")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Automatically saves a savestate at the \n" "end of RetroArch's lifetime.\n" " \n" @@ -2529,7 +2528,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "shader_apply_changes")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Apply Shader Changes. \n" " \n" "After changing shader settings, use this to \n" @@ -2549,7 +2548,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_preset")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Load Shader Preset. \n" " \n" " Load a " @@ -2579,7 +2578,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_num_passes")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Shader Passes. \n" " \n" "RetroArch allows you to mix and match various \n" @@ -2595,7 +2594,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_parameters")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- Shader Parameters. \n" " \n" "Modifies current shader directly. Will not be \n" @@ -2603,7 +2602,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_preset_parameters")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- Shader Preset Parameters. \n" " \n" "Modifies shader preset currently in menu." @@ -2611,7 +2610,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_pass")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Path to shader. \n" " \n" "All shaders must be of the same \n" @@ -2624,7 +2623,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_filter_pass")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Hardware filter for this pass. \n" " \n" "If 'Don't Care' is set, 'Default \n" @@ -2633,7 +2632,7 @@ int setting_get_description(const char *label, char *msg, } else if (!strcmp(label, "video_shader_scale_pass")) { - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Scale for this pass. \n" " \n" "The scale factor accumulates, i.e. 2x \n" @@ -2657,7 +2656,7 @@ int setting_get_description(const char *label, char *msg, !strcmp(label, "l_y_plus") || !strcmp(label, "l_y_minus") ) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Axis for analog stick (DualShock-esque).\n" " \n" "Bound as usual, however, if a real analog \n" @@ -2666,7 +2665,7 @@ int setting_get_description(const char *label, char *msg, "Positive X axis is right. \n" "Positive Y axis is down."); else if (!strcmp(label, "turbo")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Turbo enable.\n" " \n" "Holding the turbo while pressing another \n" @@ -2677,7 +2676,7 @@ int setting_get_description(const char *label, char *msg, "The modulation stops when the button \n" "itself (not turbo button) is released."); else if (!strcmp(label, "exit_emulator")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Key to exit RetroArch cleanly." #if !defined(RARCH_MOBILE) && !defined(RARCH_CONSOLE) "\nKilling it in any hard way (SIGKILL, \n" @@ -2688,19 +2687,19 @@ int setting_get_description(const char *label, char *msg, #endif ); else if (!strcmp(label, "rewind")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Hold button down to rewind.\n" " \n" "Rewind must be enabled."); else if (!strcmp(label, "load_state")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Loads state."); else if (!strcmp(label, "save_state")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Saves state."); else if (!strcmp(label, "state_slot_increase") || !strcmp(label, "state_slot_decrease")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- State slots.\n" " \n" " With slot set to 0, save state name is *.state \n" @@ -2708,13 +2707,13 @@ int setting_get_description(const char *label, char *msg, "When slot is != 0, path will be (path)(d), \n" "where (d) is slot number."); else if (!strcmp(label, "netplay_flip_players")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Netplay flip users."); else if (!strcmp(label, "frame_advance")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Frame advance when content is paused."); else if (!strcmp(label, "enable_hotkey")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Enable other hotkeys.\n" " \n" " If this hotkey is bound to either keyboard, \n" @@ -2727,69 +2726,69 @@ int setting_get_description(const char *label, char *msg, "the keyboard, where it is not desirable that \n" "hotkeys get in the way."); else if (!strcmp(label, "slowmotion")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Hold for slowmotion."); else if (!strcmp(label, "movie_record_toggle")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggle between recording and not."); else if (!strcmp(label, "pause_toggle")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggle between paused and non-paused state."); else if (!strcmp(label, "hold_fast_forward")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Hold for fast-forward. Releasing button \n" "disables fast-forward."); else if (!strcmp(label, "shader_next")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Applies next shader in directory."); else if (!strcmp(label, "reset")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Reset the content.\n"); else if (!strcmp(label, "cheat_index_plus")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Increment cheat index.\n"); else if (!strcmp(label, "cheat_index_minus")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Decrement cheat index.\n"); else if (!strcmp(label, "cheat_toggle")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggle cheat index.\n"); else if (!strcmp(label, "shader_prev")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Applies previous shader in directory."); else if (!strcmp(label, "audio_mute")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Mute/unmute audio."); else if (!strcmp(label, "osk_enable")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Enable/disable on-screen keyboard."); else if (!strcmp(label, "screenshot")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Take screenshot."); else if (!strcmp(label, "volume_up")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Increases audio volume."); else if (!strcmp(label, "volume_down")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Decreases audio volume."); else if (!strcmp(label, "overlay_next")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggles to next overlay.\n" " \n" "Wraps around."); else if (!strcmp(label, "disk_eject_toggle")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggles eject for disks.\n" " \n" "Used for multiple-disk content."); else if (!strcmp(label, "disk_next")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Cycles through disk images. Use after \n" "ejecting. \n" " \n" " Complete by toggling eject again."); else if (!strcmp(label, "grab_mouse_toggle")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggles mouse grab.\n" " \n" "When mouse is grabbed, RetroArch hides the \n" @@ -2797,32 +2796,32 @@ int setting_get_description(const char *label, char *msg, "the window to allow relative mouse input to \n" "work better."); else if (!strcmp(label, "menu_toggle")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Toggles menu."); else if (!strcmp(label, "input_bind_device_id")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Input Device. \n" " \n" "Picks which gamepad to use for user N. \n" "The name of the pad is available." ); else if (!strcmp(label, "input_bind_device_type")) - snprintf(msg, sizeof_msg, + snprintf(s, len, " -- Input Device Type. \n" " \n" "Picks which device type to use. This is \n" "relevant for the libretro core itself." ); else - snprintf(msg, sizeof_msg, + snprintf(s, len, "-- No info on this item is available. --\n"); return 0; } #ifdef HAVE_MENU -static void get_string_representation_bind_device(void * data, char *type_str, - size_t type_str_size) +static void get_string_representation_bind_device(void * data, char *s, + size_t len) { unsigned map = 0; rarch_setting_t *setting = (rarch_setting_t*)data; @@ -2838,32 +2837,32 @@ static void get_string_representation_bind_device(void * data, char *type_str, const char *device_name = settings->input.device_names[map]; if (*device_name) - strlcpy(type_str, device_name, type_str_size); + strlcpy(s, device_name, len); else - snprintf(type_str, type_str_size, + snprintf(s, len, "N/A (port #%u)", map); } else - strlcpy(type_str, "Disabled", type_str_size); + strlcpy(s, "Disabled", len); } -static void get_string_representation_savestate(void * data, char *type_str, - size_t type_str_size) +static void get_string_representation_savestate(void * data, char *s, + size_t len) { settings_t *settings = config_get_ptr(); - snprintf(type_str, type_str_size, "%d", settings->state_slot); + snprintf(s, len, "%d", settings->state_slot); if (settings->state_slot == -1) - strlcat(type_str, " (Auto)", type_str_size); + strlcat(s, " (Auto)", len); } /** * setting_get_label: * @list : File list on which to perform the search - * @type_str : String for the type to be represented on-screen as + * @s : String for the type to be represented on-screen as * a label. - * @type_str_size : Size of @type_str + * @len : Size of @s * @w : Width of the string (for text label representation * purposes in the menu display driver). * @type : Identifier of setting. @@ -2873,8 +2872,8 @@ static void get_string_representation_savestate(void * data, char *type_str, * * Get associated label of a setting. **/ -void setting_get_label(file_list_t *list, char *type_str, - size_t type_str_size, unsigned *w, unsigned type, +void setting_get_label(file_list_t *list, char *s, + size_t len, unsigned *w, unsigned type, const char *menu_label, const char *label, unsigned idx) { rarch_setting_t *setting_data = NULL; @@ -2892,7 +2891,7 @@ void setting_get_label(file_list_t *list, char *type_str, setting = setting_find_setting(setting_data, list->list[idx].label); if (setting) - setting_get_string_representation(setting, type_str, type_str_size); + setting_get_string_representation(setting, s, len); } #endif diff --git a/settings.h b/settings.h index a32cccf5ae..fbb65660fc 100644 --- a/settings.h +++ b/settings.h @@ -71,13 +71,12 @@ void setting_set_with_string_representation( /** * setting_get_string_representation: * @setting : pointer to setting - * @buf : buffer to write contents of string representation to. - * @sizeof_buf : size of the buffer (@buf) + * @s : buffer to write contents of string representation to. + * @len : size of the buffer (@s) * * Get a setting value's string representation. **/ -void setting_get_string_representation(void *data, - char* buf, size_t sizeof_buf); +void setting_get_string_representation(void *data, char *s, size_t len); /** * setting_action_setting: @@ -299,17 +298,16 @@ rarch_setting_t setting_string_setting_options(enum setting_type type, /** * setting_get_description: * @label : identifier label of setting - * @msg : output message - * @sizeof_msg : size of @msg + * @s : output message + * @len : size of @s * - * Writes a 'Help' description message to @msg if there is + * Writes a 'Help' description message to @s if there is * one available based on the identifier label of the setting * (@label). * * Returns: 0 (always for now). TODO: make it handle -1 as well. **/ -int setting_get_description(const char *label, char *msg, - size_t msg_sizeof); +int setting_get_description(const char *label, char *s, size_t len); #ifdef HAVE_MENU /** diff --git a/settings_list.h b/settings_list.h index 093416ec6e..0904b0825c 100644 --- a/settings_list.h +++ b/settings_list.h @@ -102,7 +102,7 @@ typedef int (*action_start_handler_t )(void *data); typedef int (*action_iterate_handler_t )(unsigned action); typedef int (*action_cancel_handler_t )(void *data, unsigned action); typedef int (*action_ok_handler_t )(void *data, unsigned action); -typedef void (*get_string_representation_t )(void *data, char *buf, size_t sizeof_buf); +typedef void (*get_string_representation_t )(void *data, char *s, size_t len); typedef struct rarch_setting_info { diff --git a/tasks/tasks.h b/tasks/tasks.h index c2840f50dd..f7ae231c98 100644 --- a/tasks/tasks.h +++ b/tasks/tasks.h @@ -60,7 +60,7 @@ void rarch_main_data_overlay_iterate(bool is_thread, void *data); void rarch_main_data_nbio_iterate(bool is_thread, void *runloop); -void data_runloop_osd_msg(const char *msg, size_t sizeof_msg); +void data_runloop_osd_msg(const char *s, size_t len); #ifdef __cplusplus }