Less string intermediary copies

This commit is contained in:
libretroadmin 2024-12-24 18:46:22 +01:00
parent 6a85844b41
commit 2cfdccc085
9 changed files with 278 additions and 468 deletions

156
command.c
View File

@ -408,7 +408,8 @@ bool command_get_config_param(command_t *cmd, const char* arg)
input_driver_state_t *input_st = input_state_get_ptr(); input_driver_state_t *input_st = input_state_get_ptr();
value = value_dynamic; value = value_dynamic;
value_dynamic[0] = '\0'; value_dynamic[0] = '\0';
if(input_st->bsv_movie_state_handle) { if (input_st->bsv_movie_state_handle)
{
bsv_movie_t *movie = input_st->bsv_movie_state_handle; bsv_movie_t *movie = input_st->bsv_movie_state_handle;
snprintf(value_dynamic, sizeof(value_dynamic), "%lld %u %lld", snprintf(value_dynamic, sizeof(value_dynamic), "%lld %u %lld",
(long long)(movie->identifier), (long long)(movie->identifier),
@ -741,7 +742,7 @@ bool command_play_replay_slot(command_t *cmd, const char *arg)
{ {
input_driver_state_t *input_st = input_state_get_ptr(); input_driver_state_t *input_st = input_state_get_ptr();
task_queue_wait(NULL,NULL); task_queue_wait(NULL,NULL);
if(input_st->bsv_movie_state_next_handle) if (input_st->bsv_movie_state_next_handle)
snprintf(reply, sizeof(reply) - 1, "PLAY_REPLAY_SLOT %lld", (long long)(input_st->bsv_movie_state_next_handle->identifier)); snprintf(reply, sizeof(reply) - 1, "PLAY_REPLAY_SLOT %lld", (long long)(input_st->bsv_movie_state_next_handle->identifier));
else else
snprintf(reply, sizeof(reply) - 1, "PLAY_REPLAY_SLOT 0"); snprintf(reply, sizeof(reply) - 1, "PLAY_REPLAY_SLOT 0");
@ -827,7 +828,6 @@ bool command_version(command_t *cmd, const char* arg)
reply[ _len] = '\n'; reply[ _len] = '\n';
reply[++_len] = '\0'; reply[++_len] = '\0';
cmd->replier(cmd, reply, _len); cmd->replier(cmd, reply, _len);
return true; return true;
} }
@ -883,24 +883,21 @@ static const rarch_memory_descriptor_t* command_memory_get_descriptor(const rarc
static uint8_t *command_memory_get_pointer( static uint8_t *command_memory_get_pointer(
const rarch_system_info_t* sys_info, const rarch_system_info_t* sys_info,
unsigned address, unsigned address, unsigned int* max_bytes,
unsigned int* max_bytes, int for_write, char *s, size_t len)
int for_write,
char *reply_at,
size_t len)
{ {
if (!sys_info || sys_info->mmaps.num_descriptors == 0) if (!sys_info || sys_info->mmaps.num_descriptors == 0)
strlcpy(reply_at, " -1 no memory map defined\n", len); strlcpy(s, " -1 no memory map defined\n", len);
else else
{ {
size_t offset; size_t offset;
const rarch_memory_descriptor_t* desc = command_memory_get_descriptor(&sys_info->mmaps, address, &offset); const rarch_memory_descriptor_t* desc = command_memory_get_descriptor(&sys_info->mmaps, address, &offset);
if (!desc) if (!desc)
strlcpy(reply_at, " -1 no descriptor for address\n", len); strlcpy(s, " -1 no descriptor for address\n", len);
else if (!desc->core.ptr) else if (!desc->core.ptr)
strlcpy(reply_at, " -1 no data for descriptor\n", len); strlcpy(s, " -1 no data for descriptor\n", len);
else if (for_write && (desc->core.flags & RETRO_MEMDESC_CONST)) else if (for_write && (desc->core.flags & RETRO_MEMDESC_CONST))
strlcpy(reply_at, " -1 descriptor data is readonly\n", len); strlcpy(s, " -1 descriptor data is readonly\n", len);
else else
{ {
*max_bytes = (unsigned int)(desc->core.len - offset); *max_bytes = (unsigned int)(desc->core.len - offset);
@ -921,30 +918,28 @@ bool command_get_status(command_t *cmd, const char* arg)
if (flags & CONTENT_ST_FLAG_IS_INITED) if (flags & CONTENT_ST_FLAG_IS_INITED)
{ {
/* add some content info */ /* add some content info */
runloop_state_t *runloop_st = runloop_state_get_ptr();
const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */
int content_crc32 = content_get_crc();
const char* system_id = NULL;
core_info_t *core_info = NULL; core_info_t *core_info = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
reply[0] = '\0';
core_info_get_current_core(&core_info); core_info_get_current_core(&core_info);
if (core_info)
system_id = core_info->system_id;
if (!system_id)
system_id = runloop_st->system.info.library_name;
_len = strlcpy(reply, "GET_STATUS ", sizeof(reply)); _len = strlcpy(reply, "GET_STATUS ", sizeof(reply));
if (runloop_st->flags & RUNLOOP_FLAG_PAUSED) if (runloop_st->flags & RUNLOOP_FLAG_PAUSED)
_len += strlcpy(reply + _len, "PAUSED", sizeof(reply) - _len); _len += strlcpy(reply + _len, "PAUSED", sizeof(reply) - _len);
else else
_len += strlcpy(reply + _len, "PLAYING", sizeof(reply) - _len); _len += strlcpy(reply + _len, "PLAYING", sizeof(reply) - _len);
_len += strlcpy(reply + _len, " ", sizeof(reply) - _len); _len += strlcpy(reply + _len, " ", sizeof(reply) - _len);
_len += strlcpy(reply + _len, system_id, sizeof(reply) - _len); if (core_info)
_len += strlcpy(reply + _len, core_info->system_id,
sizeof(reply) - _len);
else
_len += strlcpy(reply + _len, runloop_st->system.info.library_name,
sizeof(reply) - _len);
_len += strlcpy(reply + _len, ",", sizeof(reply) - _len); _len += strlcpy(reply + _len, ",", sizeof(reply) - _len);
_len += strlcpy(reply + _len, content_name, sizeof(reply) - _len); _len += strlcpy(reply + _len,
_len += snprintf(reply + _len, sizeof(reply) - _len, ",crc32=%x\n", content_crc32); path_basename(path_get(RARCH_PATH_BASENAME)), sizeof(reply) - _len);
_len += snprintf(reply + _len, sizeof(reply) - _len,
",crc32=%x\n", content_get_crc());
} }
else else
_len = strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply)); _len = strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
@ -1167,8 +1162,7 @@ void command_event_init_controllers(rarch_system_info_t *sys_info,
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
bool command_event_save_config( bool command_event_save_config(
const char *config_path, const char *config_path, char *s, size_t len)
char *s, size_t len)
{ {
bool path_exists = !string_is_empty(config_path); bool path_exists = !string_is_empty(config_path);
const char *str = path_exists ? config_path : const char *str = path_exists ? config_path :
@ -1289,8 +1283,7 @@ bool command_event_save_auto_state(void)
_len = strlcpy(savestate_name_auto, _len = strlcpy(savestate_name_auto,
runloop_st->name.savestate, runloop_st->name.savestate,
sizeof(savestate_name_auto)); sizeof(savestate_name_auto));
strlcpy(savestate_name_auto + _len, strlcpy(savestate_name_auto + _len, ".auto",
".auto",
sizeof(savestate_name_auto) - _len); sizeof(savestate_name_auto) - _len);
if (content_auto_save_state((const char*)savestate_name_auto)) if (content_auto_save_state((const char*)savestate_name_auto))
@ -1401,8 +1394,7 @@ void command_event_load_auto_state(void)
_len = strlcpy(savestate_name_auto, _len = strlcpy(savestate_name_auto,
runloop_st->name.savestate, runloop_st->name.savestate,
sizeof(savestate_name_auto)); sizeof(savestate_name_auto));
strlcpy(savestate_name_auto + _len, strlcpy(savestate_name_auto + _len, ".auto",
".auto",
sizeof(savestate_name_auto) - _len); sizeof(savestate_name_auto) - _len);
if (!path_is_valid(savestate_name_auto)) if (!path_is_valid(savestate_name_auto))
@ -1429,11 +1421,16 @@ void command_event_load_auto_state(void)
* *
* @param settings The usual RetroArch settings ptr. * @param settings The usual RetroArch settings ptr.
* @param last_index Return value for load slot. * @param last_index Return value for load slot.
* @param file_to_delete Return value for file name that should be removed. * @param @s Return value for file name that should be removed.
*/ */
static void scan_states(settings_t *settings, static void scan_states(settings_t *settings,
unsigned *last_index, char *file_to_delete) unsigned *last_index, char *s)
{ {
/* Base name of 128 may be too short for some (<<1%) of the
tosec-based file names, but in practice truncating will not
lead to mismatch */
char state_base[128];
char state_dir[DIR_MAX_LENGTH];
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
bool show_hidden_files = settings->bools.show_hidden_files; bool show_hidden_files = settings->bools.show_hidden_files;
unsigned savestate_max_keep = settings->uints.savestate_max_keep; unsigned savestate_max_keep = settings->uints.savestate_max_keep;
@ -1452,19 +1449,12 @@ static void scan_states(settings_t *settings,
size_t i, cnt = 0; size_t i, cnt = 0;
size_t cnt_in_range = 0; size_t cnt_in_range = 0;
char state_dir[DIR_MAX_LENGTH];
/* Base name of 128 may be too short for some (<<1%) of the
tosec-based file names, but in practice truncating will not
lead to mismatch */
char state_base[128];
fill_pathname_basedir(state_dir, runloop_st->name.savestate, fill_pathname_basedir(state_dir, runloop_st->name.savestate,
sizeof(state_dir)); sizeof(state_dir));
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL, if (!(dir_list = dir_list_new_special(state_dir,
show_hidden_files); DIR_LIST_PLAIN, NULL, show_hidden_files)))
if (!dir_list)
return; return;
fill_pathname_base(state_base, runloop_st->name.savestate, fill_pathname_base(state_base, runloop_st->name.savestate,
@ -1473,7 +1463,7 @@ static void scan_states(settings_t *settings,
for (i = 0; i < dir_list->size; i++) for (i = 0; i < dir_list->size; i++)
{ {
unsigned idx; unsigned idx;
char elem_base[128] = {0}; char elem_base[128];
const char *ext = NULL; const char *ext = NULL;
const char *end = NULL; const char *end = NULL;
const char *dir_elem = dir_list->elems[i].data; const char *dir_elem = dir_list->elems[i].data;
@ -1486,8 +1476,8 @@ static void scan_states(settings_t *settings,
/* Only consider files with a '.state' extension /* Only consider files with a '.state' extension
* > i.e. Ignore '.state.auto', '.state.bak', etc. */ * > i.e. Ignore '.state.auto', '.state.bak', etc. */
ext = path_get_extension(elem_base); ext = path_get_extension(elem_base);
if (string_is_empty(ext) || if ( string_is_empty(ext)
!string_starts_with_size(ext, "state", STRLEN_CONST("state"))) || !string_starts_with_size(ext, "state", STRLEN_CONST("state")))
continue; continue;
/* Check whether this file is associated with /* Check whether this file is associated with
@ -1521,30 +1511,28 @@ static void scan_states(settings_t *settings,
cnt_in_range++; cnt_in_range++;
/* Maintain a 2x512 bit map of occupied save states */ /* Maintain a 2x512 bit map of occupied save states */
if (idx<512) if (idx < 512)
BIT512_SET(slot_mapping_low,idx); BIT512_SET(slot_mapping_low,idx);
else if (idx<1024) else if (idx < 1024)
BIT512_SET(slot_mapping_high,idx-512); BIT512_SET(slot_mapping_high,idx-512);
} }
/* Next loop on the bitmap, since the file system may have presented the files in any order above */ /* Next loop on the bitmap, since the file system may have presented the files in any order above */
for(i=0 ; i <= savestate_max_keep ; i++) for (i = 0; i <= savestate_max_keep; i++)
{ {
/* Unoccupied save slots */ /* Unoccupied save slots */
if ((i < 512 && !BIT512_GET(slot_mapping_low, i)) || if ( (i < 512 && !BIT512_GET(slot_mapping_low, i))
(i > 511 && !BIT512_GET(slot_mapping_high, i-512)) ) || (i > 511 && !BIT512_GET(slot_mapping_high, i-512)))
{ {
/* Gap index: lowest free slot in the wraparound range */ /* Gap index: lowest free slot in the wraparound range */
if (gap_idx == UINT_MAX) if (gap_idx == UINT_MAX)
gap_idx = (unsigned)i; gap_idx = (unsigned)i;
} }
/* Occupied save slots */ else /* Occupied save slots */
else
{ {
/* Del index: first occupied slot in the wraparound range, /* Del index: first occupied slot in the wraparound range,
after gap index */ after gap index */
if (gap_idx < UINT_MAX && if ( gap_idx < UINT_MAX && del_idx == UINT_MAX)
del_idx == UINT_MAX)
del_idx = (unsigned)i; del_idx = (unsigned)i;
} }
} }
@ -1593,12 +1581,10 @@ static void scan_states(settings_t *settings,
else else
{ {
/* No candidate to delete */ /* No candidate to delete */
if (del_idx == UINT_MAX)
{
/* Either gap is at the end of the range: wraparound. /* Either gap is at the end of the range: wraparound.
or there is no better idea than the lowest index */ or there is no better idea than the lowest index */
if (del_idx == UINT_MAX)
del_idx = 0; del_idx = 0;
}
/* Adjust load index */ /* Adjust load index */
if (gap_idx == 0) if (gap_idx == 0)
loa_idx = savestate_max_keep; loa_idx = savestate_max_keep;
@ -1610,16 +1596,16 @@ static void scan_states(settings_t *settings,
"%d (%d), max:%d, load index %d, gap index %d, delete index %d\n", "%d (%d), max:%d, load index %d, gap index %d, delete index %d\n",
cnt, cnt_in_range, max_idx, loa_idx, gap_idx, del_idx); cnt, cnt_in_range, max_idx, loa_idx, gap_idx, del_idx);
if (last_index != NULL) if (last_index)
{
*last_index = loa_idx; *last_index = loa_idx;
}
if (file_to_delete != NULL && cnt_in_range >= savestate_max_keep) if ( s
&& cnt_in_range >= savestate_max_keep)
{ {
strlcpy(file_to_delete, savefile_root, savefile_root_length + 1); strlcpy(s, savefile_root, savefile_root_length + 1);
/* ".state0" is just ".state" instead, so don't print that. */ /* ".state0" is just ".state" instead, so don't print that. */
if (del_idx > 0) if (del_idx > 0)
snprintf(file_to_delete+savefile_root_length, 5, "%d", del_idx); snprintf(s + savefile_root_length, 5, "%d", del_idx);
} }
dir_list_free(dir_list); dir_list_free(dir_list);
@ -1638,12 +1624,11 @@ int command_event_get_next_savestate_auto_index(settings_t *settings)
{ {
unsigned savestate_max_keep = settings->uints.savestate_max_keep; unsigned savestate_max_keep = settings->uints.savestate_max_keep;
int new_state_slot = settings->ints.state_slot + 1; int new_state_slot = settings->ints.state_slot + 1;
/* If previous save was above the wraparound range, or it overflows, /* If previous save was above the wraparound range, or it overflows,
return to the start of the range. */ return to the start of the range. */
if( savestate_max_keep > 0 && (unsigned)new_state_slot > savestate_max_keep) if ( (savestate_max_keep > 0)
new_state_slot = 0; && (unsigned)new_state_slot > savestate_max_keep)
return 0;
return new_state_slot; return new_state_slot;
} }
@ -1657,13 +1642,10 @@ void command_event_set_savestate_auto_index(settings_t *settings)
{ {
unsigned max_idx = 0; unsigned max_idx = 0;
bool savestate_auto_index = settings->bools.savestate_auto_index; bool savestate_auto_index = settings->bools.savestate_auto_index;
if (!savestate_auto_index) if (!savestate_auto_index)
return; return;
scan_states(settings, &max_idx, NULL); scan_states(settings, &max_idx, NULL);
configuration_set_int(settings, settings->ints.state_slot, max_idx); configuration_set_int(settings, settings->ints.state_slot, max_idx);
RARCH_LOG("[State]: %s: #%d\n", RARCH_LOG("[State]: %s: #%d\n",
msg_hash_to_str(MSG_FOUND_LAST_STATE_SLOT), msg_hash_to_str(MSG_FOUND_LAST_STATE_SLOT),
max_idx); max_idx);
@ -1676,9 +1658,8 @@ void command_event_set_savestate_auto_index(settings_t *settings)
*/ */
static void command_event_set_savestate_garbage_collect(settings_t *settings) static void command_event_set_savestate_garbage_collect(settings_t *settings)
{ {
char state_to_delete[PATH_MAX_LENGTH] = {0};
size_t i; size_t i;
char state_to_delete[PATH_MAX_LENGTH] = {0};
scan_states(settings, NULL, state_to_delete); scan_states(settings, NULL, state_to_delete);
/* Only delete one save state per save action /* Only delete one save state per save action
* > Conservative behaviour, designed to minimise * > Conservative behaviour, designed to minimise
@ -1720,10 +1701,8 @@ void command_event_set_replay_auto_index(settings_t *settings)
fill_pathname_basedir(state_dir, runloop_st->name.replay, fill_pathname_basedir(state_dir, runloop_st->name.replay,
sizeof(state_dir)); sizeof(state_dir));
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL, if (!(dir_list = dir_list_new_special(state_dir,
show_hidden_files); DIR_LIST_PLAIN, NULL, show_hidden_files)))
if (!dir_list)
return; return;
fill_pathname_base(state_base, runloop_st->name.replay, fill_pathname_base(state_base, runloop_st->name.replay,
@ -1768,8 +1747,8 @@ void command_event_set_replay_garbage_collect(
{ {
/* TODO: debugme */ /* TODO: debugme */
size_t i, cnt = 0; size_t i, cnt = 0;
char state_dir[DIR_MAX_LENGTH];
char state_base[128]; char state_base[128];
char state_dir[DIR_MAX_LENGTH];
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
struct string_list *dir_list = NULL; struct string_list *dir_list = NULL;
@ -1781,10 +1760,8 @@ void command_event_set_replay_garbage_collect(
fill_pathname_basedir(state_dir, runloop_st->name.replay, fill_pathname_basedir(state_dir, runloop_st->name.replay,
sizeof(state_dir)); sizeof(state_dir));
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL, if (!(dir_list = dir_list_new_special(state_dir,
show_hidden_files); DIR_LIST_PLAIN, NULL, show_hidden_files)))
if (!dir_list)
return; return;
fill_pathname_base(state_base, runloop_st->name.replay, fill_pathname_base(state_base, runloop_st->name.replay,
@ -1806,8 +1783,8 @@ void command_event_set_replay_garbage_collect(
/* Only consider files with a '.replayXX' extension /* Only consider files with a '.replayXX' extension
* > i.e. Ignore '.replay.auto', '.replay.bak', etc. */ * > i.e. Ignore '.replay.auto', '.replay.bak', etc. */
ext = path_get_extension(elem_base); ext = path_get_extension(elem_base);
if (string_is_empty(ext) || if ( string_is_empty(ext)
!string_starts_with_size(ext, "replay", STRLEN_CONST("REPLAY"))) || !string_starts_with_size(ext, "replay", STRLEN_CONST("REPLAY")))
continue; continue;
/* Check whether this file is associated with /* Check whether this file is associated with
@ -1879,9 +1856,9 @@ bool command_event_save_core_config(
const char *rarch_path_config) const char *rarch_path_config)
{ {
char msg[128]; char msg[128];
char config_dir[DIR_MAX_LENGTH];
char config_path[PATH_MAX_LENGTH]; char config_path[PATH_MAX_LENGTH];
char config_name[NAME_MAX_LENGTH]; char config_name[NAME_MAX_LENGTH];
char config_dir[DIR_MAX_LENGTH];
bool new_path_available = false; bool new_path_available = false;
bool overrides_active = false; bool overrides_active = false;
const char *core_path = NULL; const char *core_path = NULL;
@ -2002,10 +1979,8 @@ void command_event_save_current_config(enum override_type type)
case OVERRIDE_CORE: case OVERRIDE_CORE:
case OVERRIDE_CONTENT_DIR: case OVERRIDE_CONTENT_DIR:
{ {
int8_t ret = config_save_overrides(type, &runloop_st->system, false, NULL);
char msg[256]; char msg[256];
int8_t ret = config_save_overrides(type, &runloop_st->system, false, NULL);
msg[0] = '\0';
switch (ret) switch (ret)
{ {
@ -2053,17 +2028,14 @@ void command_event_remove_current_config(enum override_type type)
case OVERRIDE_CONTENT_DIR: case OVERRIDE_CONTENT_DIR:
{ {
char msg[256]; char msg[256];
msg[0] = '\0';
if (config_save_overrides(type, &runloop_st->system, true, NULL)) if (config_save_overrides(type, &runloop_st->system, true, NULL))
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_REMOVED_SUCCESSFULLY), sizeof(msg)); strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_REMOVED_SUCCESSFULLY), sizeof(msg));
else else
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_REMOVING), sizeof(msg)); strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_REMOVING), sizeof(msg));
RARCH_LOG("[Overrides]: %s\n", msg); RARCH_LOG("[Overrides]: %s\n", msg);
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(msg, 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
#ifdef HAVE_MENU #ifdef HAVE_MENU
{ {
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();

View File

@ -1471,31 +1471,27 @@ const char *config_get_all_timezones(void)
return char_list_new_special(STRING_LIST_TIMEZONES, NULL); return char_list_new_special(STRING_LIST_TIMEZONES, NULL);
} }
static void load_timezone(char *s) static void load_timezone(char *s, size_t len)
{ {
char haystack[TIMEZONE_LENGTH+32]; char haystack[TIMEZONE_LENGTH+32];
static char *needle = "TIMEZONE=";
RFILE *tzfp = filestream_open(LAKKA_TIMEZONE_PATH, RFILE *tzfp = filestream_open(LAKKA_TIMEZONE_PATH,
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE); RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (tzfp) if (tzfp)
{ {
static char *needle = "TIMEZONE=";
char *start = NULL; char *start = NULL;
filestream_gets(tzfp, haystack, sizeof(haystack)-1); filestream_gets(tzfp, haystack, sizeof(haystack)-1);
filestream_close(tzfp); filestream_close(tzfp);
if ((start = strstr(haystack, needle))) if ((start = strstr(haystack, needle)))
{ strlcpy(s, start + STRLEN_CONST("TIMEZONE="), len);
size_t needle_len = STRLEN_CONST("TIMEZONE="); else
strlcpy(s, start + needle_len, TIMEZONE_LENGTH); strlcpy(s, DEFAULT_TIMEZONE, len);
} }
else else
strlcpy(s, DEFAULT_TIMEZONE, TIMEZONE_LENGTH); strlcpy(s, DEFAULT_TIMEZONE, len);
}
else
strlcpy(s, DEFAULT_TIMEZONE, TIMEZONE_LENGTH);
config_set_timezone(s); config_set_timezone(s);
} }
#endif #endif
@ -1547,19 +1543,10 @@ static struct config_array_setting *populate_settings_array(
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
{ {
size_t _len;
char formatted_number[4];
char prefix[16];
char key[32]; char key[32];
size_t _len = strlcpy(key, "input_player", sizeof(key));
formatted_number[0] = '\0'; _len += snprintf(key + _len, sizeof(key) - _len, "%u", i + 1);
snprintf(formatted_number, sizeof(formatted_number), "%u", i + 1);
_len = strlcpy(prefix, "input_player", sizeof(prefix));
strlcpy(prefix + _len, formatted_number, sizeof(prefix) - _len);
_len = strlcpy(key, prefix, sizeof(key));
strlcpy(key + _len, "_reserved_device", sizeof(key) - _len); strlcpy(key + _len, "_reserved_device", sizeof(key) - _len);
SETTING_ARRAY(strdup(key), settings->arrays.input_reserved_devices[i], false, NULL, true); SETTING_ARRAY(strdup(key), settings->arrays.input_reserved_devices[i], false, NULL, true);
} }
@ -2947,7 +2934,7 @@ void config_set_defaults(void *data)
configuration_set_bool(settings, configuration_set_bool(settings,
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH)); settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
configuration_set_bool(settings, settings->bools.localap_enable, false); configuration_set_bool(settings, settings->bools.localap_enable, false);
load_timezone(settings->arrays.timezone); load_timezone(settings->arrays.timezone, TIMEZONE_LENGTH);
#endif #endif
#if __APPLE__ #if __APPLE__
@ -4393,7 +4380,7 @@ bool config_load_override(void *data)
/* Create a new config file from core_path */ /* Create a new config file from core_path */
if (path_is_valid(core_path)) if (path_is_valid(core_path))
{ {
char tmp_path[PATH_MAX_LENGTH + 1]; char tmp_path[PATH_MAX_LENGTH];
RARCH_LOG("[Overrides]: Core-specific overrides found at \"%s\".\n", RARCH_LOG("[Overrides]: Core-specific overrides found at \"%s\".\n",
core_path); core_path);
@ -4423,7 +4410,7 @@ bool config_load_override(void *data)
/* Create a new config file from content_path */ /* Create a new config file from content_path */
if (path_is_valid(content_path)) if (path_is_valid(content_path))
{ {
char tmp_path[PATH_MAX_LENGTH + 1]; char tmp_path[PATH_MAX_LENGTH];
RARCH_LOG("[Overrides]: Content dir-specific overrides found at \"%s\".\n", RARCH_LOG("[Overrides]: Content dir-specific overrides found at \"%s\".\n",
content_path); content_path);
@ -4451,7 +4438,7 @@ bool config_load_override(void *data)
/* Create a new config file from game_path */ /* Create a new config file from game_path */
if (path_is_valid(game_path)) if (path_is_valid(game_path))
{ {
char tmp_path[PATH_MAX_LENGTH + 1]; char tmp_path[PATH_MAX_LENGTH];
RARCH_LOG("[Overrides]: Game-specific overrides found at \"%s\".\n", RARCH_LOG("[Overrides]: Game-specific overrides found at \"%s\".\n",
game_path); game_path);
@ -4659,12 +4646,14 @@ bool config_load_remap(const char *directory_input_remapping,
) )
{ {
/* Ensure directory does not contain special chars */ /* Ensure directory does not contain special chars */
const char *inp_dev_dir = sanitize_path_part(inp_dev_name, strlen(inp_dev_name)); const char *inp_dev_dir = sanitize_path_part(
inp_dev_name, strlen(inp_dev_name));
/* Build the new path with the controller name */ /* Build the new path with the controller name */
size_t _len = strlcpy(remap_path, core_name, sizeof(remap_path)); size_t _len = strlcpy(remap_path, core_name, sizeof(remap_path));
_len += strlcpy(remap_path + _len, PATH_DEFAULT_SLASH(), sizeof(remap_path) - _len); _len += strlcpy(remap_path + _len, PATH_DEFAULT_SLASH(),
_len += strlcpy(remap_path + _len, inp_dev_dir, sizeof(remap_path) - _len); sizeof(remap_path) - _len);
_len += strlcpy(remap_path + _len, inp_dev_dir,
sizeof(remap_path) - _len);
/* Deallocate as we no longer this */ /* Deallocate as we no longer this */
free((char*)inp_dev_dir); free((char*)inp_dev_dir);
inp_dev_dir = NULL; inp_dev_dir = NULL;
@ -5103,13 +5092,9 @@ void config_get_autoconf_profile_filename(
/* Driver specific autoconf dir may not exist, if autoconfs are not downloaded. */ /* Driver specific autoconf dir may not exist, if autoconfs are not downloaded. */
if (!path_is_directory(buf)) if (!path_is_directory(buf))
{
len = strlcpy(buf, sanitised_name, len_buf); len = strlcpy(buf, sanitised_name, len_buf);
}
else else
{
len = fill_pathname_join_special(buf, joypad_driver, sanitised_name, len_buf); len = fill_pathname_join_special(buf, joypad_driver, sanitised_name, len_buf);
}
strlcpy(buf + len, ".cfg", len_buf - len); strlcpy(buf + len, ".cfg", len_buf - len);
end: end:
@ -6047,8 +6032,8 @@ bool input_remapping_save_file(const char *path)
return false; return false;
/* Create output directory, if required */ /* Create output directory, if required */
_len = strlcpy(remap_file_dir, path, sizeof(remap_file_dir)); fill_pathname_parent_dir(remap_file_dir, path,
path_parent_dir(remap_file_dir, _len); sizeof(remap_file_dir));
if ( !string_is_empty(remap_file_dir) if ( !string_is_empty(remap_file_dir)
&& !path_is_directory(remap_file_dir) && !path_is_directory(remap_file_dir)

View File

@ -2617,27 +2617,18 @@ bool core_info_database_supports_content_path(
return false; return false;
} }
bool core_info_list_get_display_name( size_t core_info_list_get_display_name(
core_info_list_t *core_info_list, core_info_list_t *core_info_list,
const char *core_path, char *s, size_t len) const char *core_path, char *s, size_t len)
{ {
core_info_t *info; if (core_info_list)
if (!core_info_list)
return false;
info = core_info_find_internal(
core_info_list, core_path);
if ( s
&& info
&& !string_is_empty(info->display_name))
{ {
strlcpy(s, info->display_name, len); core_info_t *info = core_info_find_internal(
return true; core_info_list, core_path);
if (s && info && !string_is_empty(info->display_name))
return strlcpy(s, info->display_name, len);
} }
return 0;
return false;
} }
/* Returns core_info parameters required for /* Returns core_info parameters required for

View File

@ -155,7 +155,7 @@ typedef struct core_info_state core_info_state_t;
void core_info_list_get_supported_cores(core_info_list_t *list, void core_info_list_get_supported_cores(core_info_list_t *list,
const char *path, const core_info_t **infos, size_t *num_infos); const char *path, const core_info_t **infos, size_t *num_infos);
bool core_info_list_get_display_name(core_info_list_t *list, size_t core_info_list_get_display_name(core_info_list_t *list,
const char *core_path, char *s, size_t len); const char *core_path, char *s, size_t len);
/* Returns core_info parameters required for /* Returns core_info parameters required for

View File

@ -42,15 +42,15 @@ typedef struct
enum manual_content_scan_system_name_type system_name_type; enum manual_content_scan_system_name_type system_name_type;
enum manual_content_scan_core_type core_type; enum manual_content_scan_core_type core_type;
char core_name[NAME_MAX_LENGTH];
char system_name_database[NAME_MAX_LENGTH];
char system_name_custom[NAME_MAX_LENGTH];
char content_dir[DIR_MAX_LENGTH];
char system_name_content_dir[DIR_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH];
char file_exts_core[PATH_MAX_LENGTH]; char file_exts_core[PATH_MAX_LENGTH];
char file_exts_custom[PATH_MAX_LENGTH]; char file_exts_custom[PATH_MAX_LENGTH];
char dat_file_path[PATH_MAX_LENGTH]; char dat_file_path[PATH_MAX_LENGTH];
char content_dir[DIR_MAX_LENGTH];
char system_name_content_dir[DIR_MAX_LENGTH];
char system_name_database[NAME_MAX_LENGTH];
char system_name_custom[NAME_MAX_LENGTH];
char core_name[NAME_MAX_LENGTH];
bool search_recursively; bool search_recursively;
bool search_archives; bool search_archives;
@ -200,10 +200,8 @@ static void manual_content_scan_scrub_file_exts(char *file_exts)
void manual_content_scan_scrub_system_name_custom(void) void manual_content_scan_scrub_system_name_custom(void)
{ {
char *scrub_char_pointer = NULL; char *scrub_char_pointer = NULL;
if (string_is_empty(scan_settings.system_name_custom)) if (string_is_empty(scan_settings.system_name_custom))
return; return;
/* Scrub characters that are not cross-platform /* Scrub characters that are not cross-platform
* and/or violate the No-Intro filename standard: * and/or violate the No-Intro filename standard:
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip * http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
@ -293,14 +291,11 @@ bool manual_content_scan_set_menu_content_dir(const char *content_dir)
if (!path_is_directory(content_dir)) if (!path_is_directory(content_dir))
goto error; goto error;
/* Copy directory path to settings struct */ /* Copy directory path to settings struct.
_len = strlcpy( * Remove trailing slash, if required */
scan_settings.content_dir, if ((_len = strlcpy(
content_dir, scan_settings.content_dir, content_dir,
sizeof(scan_settings.content_dir)); sizeof(scan_settings.content_dir))) <= 0)
/* Remove trailing slash, if required */
if (_len <= 0)
goto error; goto error;
if (scan_settings.content_dir[_len - 1] == PATH_DEFAULT_SLASH_C()) if (scan_settings.content_dir[_len - 1] == PATH_DEFAULT_SLASH_C())
@ -407,10 +402,10 @@ bool manual_content_scan_set_menu_core_name(
} }
else else
{ {
size_t i;
core_info_list_t *core_info_list = NULL; core_info_list_t *core_info_list = NULL;
core_info_t *core_info = NULL; core_info_t *core_info = NULL;
bool core_found = false; bool core_found = false;
size_t i;
/* We are using a manually set core... */ /* We are using a manually set core... */
if (string_is_empty(core_name)) if (string_is_empty(core_name))
@ -524,8 +519,6 @@ enum manual_content_scan_playlist_refresh_status
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK; playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK;
char system_name[NAME_MAX_LENGTH]; char system_name[NAME_MAX_LENGTH];
system_name[0] = '\0';
if (!playlist_scan_refresh_enabled(playlist)) if (!playlist_scan_refresh_enabled(playlist))
{ {
playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG; playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG;
@ -587,25 +580,15 @@ enum manual_content_scan_playlist_refresh_status
/* Loop over database files */ /* Loop over database files */
for (i = 0; i < rdb_list->size; i++) for (i = 0; i < rdb_list->size; i++)
{ {
const char *rdb_path = rdb_list->elems[i].data;
const char *rdb_file = NULL;
char rdb_name[NAME_MAX_LENGTH]; char rdb_name[NAME_MAX_LENGTH];
const char *rdb_path = rdb_list->elems[i].data;
/* Sanity check */ /* Sanity check */
if (string_is_empty(rdb_path)) if (string_is_empty(rdb_path))
continue; continue;
fill_pathname(rdb_name, path_basename(rdb_path), "",
rdb_file = path_basename(rdb_path);
if (string_is_empty(rdb_file))
continue;
fill_pathname(rdb_name, rdb_file, "",
sizeof(rdb_name)); sizeof(rdb_name));
if (string_is_empty(rdb_name)) if (string_is_empty(rdb_name))
continue; continue;
/* Check whether playlist system name /* Check whether playlist system name
* matches current database file */ * matches current database file */
if (string_is_equal(system_name, rdb_name)) if (string_is_equal(system_name, rdb_name))
@ -726,12 +709,9 @@ bool manual_content_scan_get_menu_content_dir(const char **content_dir)
{ {
if (!content_dir) if (!content_dir)
return false; return false;
if (string_is_empty(scan_settings.content_dir)) if (string_is_empty(scan_settings.content_dir))
return false; return false;
*content_dir = scan_settings.content_dir; *content_dir = scan_settings.content_dir;
return true; return true;
} }
@ -847,25 +827,15 @@ struct string_list *manual_content_scan_get_menu_system_name_list(
/* Loop over database files */ /* Loop over database files */
for (i = 0; i < rdb_list->size; i++) for (i = 0; i < rdb_list->size; i++)
{ {
const char *rdb_path = rdb_list->elems[i].data;
const char *rdb_file = NULL;
char rdb_name[NAME_MAX_LENGTH]; char rdb_name[NAME_MAX_LENGTH];
const char *rdb_path = rdb_list->elems[i].data;
/* Sanity check */ /* Sanity check */
if (string_is_empty(rdb_path)) if (string_is_empty(rdb_path))
continue; continue;
fill_pathname(rdb_name, path_basename(rdb_path), "",
rdb_file = path_basename(rdb_path);
if (string_is_empty(rdb_file))
continue;
fill_pathname(rdb_name, rdb_file, "",
sizeof(rdb_name)); sizeof(rdb_name));
if (string_is_empty(rdb_name)) if (string_is_empty(rdb_name))
continue; continue;
/* Add database name to list */ /* Add database name to list */
if (!string_list_append(name_list, rdb_name, attr)) if (!string_list_append(name_list, rdb_name, attr))
goto error; goto error;
@ -893,13 +863,13 @@ error:
* > Returned string list must be free()'d */ * > Returned string list must be free()'d */
struct string_list *manual_content_scan_get_menu_core_name_list(void) struct string_list *manual_content_scan_get_menu_core_name_list(void)
{ {
union string_list_elem_attr attr;
struct string_list *name_list = string_list_new(); struct string_list *name_list = string_list_new();
core_info_list_t *core_info_list = NULL; core_info_list_t *core_info_list = NULL;
union string_list_elem_attr attr;
/* Sanity check */ /* Sanity check */
if (!name_list) if (!name_list)
goto error; return NULL;
attr.i = 0; attr.i = 0;
@ -926,7 +896,6 @@ struct string_list *manual_content_scan_get_menu_core_name_list(void)
{ {
if (string_is_empty(core_info->display_name)) if (string_is_empty(core_info->display_name))
continue; continue;
/* Add core name to list */ /* Add core name to list */
if (!string_list_append(name_list, core_info->display_name, attr)) if (!string_list_append(name_list, core_info->display_name, attr))
goto error; goto error;
@ -952,8 +921,7 @@ error:
* Returns false if current settings are invalid. */ * Returns false if current settings are invalid. */
bool manual_content_scan_get_task_config( bool manual_content_scan_get_task_config(
manual_content_scan_task_config_t *task_config, manual_content_scan_task_config_t *task_config,
const char *path_dir_playlist const char *path_dir_playlist)
)
{ {
size_t len; size_t len;
if (!task_config) if (!task_config)
@ -1094,7 +1062,6 @@ bool manual_content_scan_get_task_config(
{ {
if (!logiqx_dat_path_is_valid(scan_settings.dat_file_path, NULL)) if (!logiqx_dat_path_is_valid(scan_settings.dat_file_path, NULL))
return false; return false;
strlcpy( strlcpy(
task_config->dat_file_path, task_config->dat_file_path,
scan_settings.dat_file_path, scan_settings.dat_file_path,
@ -1129,7 +1096,6 @@ struct string_list *manual_content_scan_get_content_list(
/* Sanity check */ /* Sanity check */
if (!task_config) if (!task_config)
goto error; goto error;
if (string_is_empty(task_config->content_dir)) if (string_is_empty(task_config->content_dir))
goto error; goto error;
@ -1160,10 +1126,7 @@ struct string_list *manual_content_scan_get_content_list(
); );
/* Sanity check */ /* Sanity check */
if (!dir_list) if (!dir_list || dir_list->size < 1)
goto error;
if (dir_list->size < 1)
goto error; goto error;
/* Ensure list is in alphabetical order /* Ensure list is in alphabetical order
@ -1191,18 +1154,14 @@ static bool manual_content_scan_get_playlist_content_path(
{ {
size_t _len; size_t _len;
struct string_list *archive_list = NULL; struct string_list *archive_list = NULL;
/* Sanity check */ /* Sanity check */
if (!task_config || string_is_empty(content_path)) if (!task_config || string_is_empty(content_path))
return false; return false;
if (!path_is_valid(content_path)) if (!path_is_valid(content_path))
return false; return false;
/* In all cases, base content path must be /* In all cases, base content path must be
* copied to @s */ * copied to @s */
_len = strlcpy(s, content_path, len); _len = strlcpy(s, content_path, len);
/* Check whether this is an archive file /* Check whether this is an archive file
* requiring special attention... */ * requiring special attention... */
if ( (content_type == RARCH_COMPRESSED_ARCHIVE) if ( (content_type == RARCH_COMPRESSED_ARCHIVE)
@ -1276,7 +1235,7 @@ error:
static bool manual_content_scan_get_playlist_content_label( static bool manual_content_scan_get_playlist_content_label(
const char *content_path, logiqx_dat_t *dat_file, const char *content_path, logiqx_dat_t *dat_file,
bool filter_dat_content, bool filter_dat_content,
char *content_label, size_t len) char *s, size_t len)
{ {
/* Sanity check */ /* Sanity check */
if (string_is_empty(content_path)) if (string_is_empty(content_path))
@ -1284,45 +1243,41 @@ static bool manual_content_scan_get_playlist_content_label(
/* In most cases, content label is just the /* In most cases, content label is just the
* filename without extension */ * filename without extension */
fill_pathname(content_label, path_basename(content_path), fill_pathname(s, path_basename(content_path),
"", len); "", len);
if (string_is_empty(content_label)) if (string_is_empty(s))
return false; return false;
/* Check if a DAT file has been specified */ /* Check if a DAT file has been specified */
if (dat_file) if (dat_file)
{ {
bool content_found = false;
logiqx_dat_game_info_t game_info; logiqx_dat_game_info_t game_info;
/* Search for current content /* Search for current content
* > If content is not listed in DAT file, * > If content is not listed in DAT file,
* use existing filename without extension */ * use existing filename without extension */
if (logiqx_dat_search(dat_file, content_label, &game_info)) if (logiqx_dat_search(dat_file, s, &game_info))
{ {
/* BIOS files should always be skipped */ /* BIOS files should always be skipped */
if (game_info.is_bios) if (game_info.is_bios)
return false; return false;
/* Only include 'runnable' content */ /* Only include 'runnable' content */
if (!game_info.is_runnable) if (!game_info.is_runnable)
return false; return false;
/* Copy game description */ /* Copy game description */
if (!string_is_empty(game_info.description)) if (!string_is_empty(game_info.description))
{ {
strlcpy(content_label, game_info.description, len); strlcpy(s, game_info.description, len);
content_found = true; return true;
} }
} }
/* If we are applying a DAT file filter, /* If we are applying a DAT file filter,
* unlisted content should be skipped */ * unlisted content should be skipped */
if (!content_found && filter_dat_content) if (filter_dat_content)
return false; return false;
} }
return true; return true;
} }
@ -1349,8 +1304,8 @@ void manual_content_scan_add_content_to_playlist(
* in playlist */ * in playlist */
if (!playlist_entry_exists(playlist, playlist_content_path)) if (!playlist_entry_exists(playlist, playlist_content_path))
{ {
struct playlist_entry entry = {0};
char label[NAME_MAX_LENGTH]; char label[NAME_MAX_LENGTH];
struct playlist_entry entry = {0};
label[0] = '\0'; label[0] = '\0';

View File

@ -508,7 +508,8 @@ static int filebrowser_parse(
else else
{ {
size_t _len = fill_pathname_home_dir(dir, sizeof(dir)); size_t _len = fill_pathname_home_dir(dir, sizeof(dir));
if (string_ends_with(full_path, "/") && !string_ends_with(dir, "/")) if ( string_ends_with(full_path, "/")
&& !string_ends_with(dir, "/"))
strlcpy(dir + _len, "/", sizeof(dir) - _len); strlcpy(dir + _len, "/", sizeof(dir) - _len);
if (string_is_equal(dir, full_path)) if (string_is_equal(dir, full_path))
allow_parent_directory = false; allow_parent_directory = false;
@ -1812,10 +1813,8 @@ static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t *
static unsigned menu_displaylist_parse_system_info(file_list_t *list) static unsigned menu_displaylist_parse_system_info(file_list_t *list)
{ {
char tmp[128];
char entry[NAME_MAX_LENGTH]; char entry[NAME_MAX_LENGTH];
unsigned count = 0; unsigned count = 0;
/* RetroArch Version */ /* RetroArch Version */
size_t _len = strlcpy(entry, size_t _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RETROARCH_VERSION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_RETROARCH_VERSION),
@ -1872,7 +1871,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
perms perms
? msg_hash_to_str(MSG_READ_WRITE) ? msg_hash_to_str(MSG_READ_WRITE)
: msg_hash_to_str(MSG_READ_ONLY), : msg_hash_to_str(MSG_READ_ONLY),
sizeof(tmp)); sizeof(entry));
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -1903,14 +1902,13 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
} }
/* CPU Features */ /* CPU Features */
retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, tmp, sizeof(tmp));
_len = strlcpy(entry, _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_CPU_FEATURES), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_CPU_FEATURES),
sizeof(entry)); sizeof(entry));
entry[ _len] = ':'; entry[ _len] = ':';
entry[++_len] = ' '; entry[++_len] = ' ';
entry[++_len] = '\0'; entry[++_len] = '\0';
strlcpy(entry + _len, tmp, sizeof(entry) - _len); retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, entry + _len, sizeof(entry) - _len);
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -2128,41 +2126,38 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
/* Power Source */ /* Power Source */
if (frontend->get_powerstate) if (frontend->get_powerstate)
{ {
size_t _len;
int seconds = 0; int seconds = 0;
int percent = 0; int percent = 0;
enum frontend_powerstate state = enum frontend_powerstate state =
frontend->get_powerstate(&seconds, &percent); frontend->get_powerstate(&seconds, &percent);
/* N/A */
if (state == FRONTEND_POWERSTATE_NONE)
strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(tmp));
/* n% (No Source) */
else if (state == FRONTEND_POWERSTATE_NO_SOURCE)
snprintf(tmp, sizeof(tmp), "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_NO_SOURCE));
/* n% (Charging) */
else if (state == FRONTEND_POWERSTATE_CHARGING)
snprintf(tmp, sizeof(tmp), "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGING));
/* n% (Charged) */
else if (state == FRONTEND_POWERSTATE_CHARGED)
snprintf(tmp, sizeof(tmp), "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGED));
/* n% (Discharging) */
else if (state == FRONTEND_POWERSTATE_ON_POWER_SOURCE)
snprintf(tmp, sizeof(tmp), "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_DISCHARGING));
/* Power Source */ /* Power Source */
_len = strlcpy(entry, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE), size_t _len = strlcpy(entry,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE),
sizeof(entry)); sizeof(entry));
entry[ _len] = ':'; entry[ _len] = ':';
entry[++_len] = ' '; entry[++_len] = ' ';
entry[++_len] = '\0'; entry[++_len] = '\0';
strlcpy(entry + _len, tmp, sizeof(entry) - _len); /* N/A */
if (state == FRONTEND_POWERSTATE_NONE)
strlcpy(entry + _len,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(entry) - _len);
/* n% (No Source) */
else if (state == FRONTEND_POWERSTATE_NO_SOURCE)
snprintf(entry + _len, sizeof(entry) - _len, "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_NO_SOURCE));
/* n% (Charging) */
else if (state == FRONTEND_POWERSTATE_CHARGING)
snprintf(entry + _len, sizeof(entry) - _len, "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGING));
/* n% (Charged) */
else if (state == FRONTEND_POWERSTATE_CHARGED)
snprintf(entry + _len, sizeof(entry) - _len, "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGED));
/* n% (Discharging) */
else if (state == FRONTEND_POWERSTATE_ON_POWER_SOURCE)
snprintf(entry + _len, sizeof(entry) - _len, "%d%% (%s)", percent,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_DISCHARGING));
if (menu_entries_append(list, entry, "", if (menu_entries_append(list, entry, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE,
0, 0, NULL)) 0, 0, NULL))
@ -2653,24 +2648,15 @@ static int create_string_list_rdb_entry_string(
size_t path_len, size_t path_len,
file_list_t *list) file_list_t *list)
{ {
size_t _len;
char tmp[128]; char tmp[128];
char *out_lbl = NULL; char out_lbl[NAME_MAX_LENGTH];
size_t str_len = (strlen(label) + 1) size_t _len = strlcpy(out_lbl, label, sizeof(out_lbl));
+ (strlen(actual_string) + 1)
+ (path_len + 1);
if (!(out_lbl = (char*)calloc(str_len, sizeof(char))))
return -1;
_len = strlcpy(out_lbl, label, str_len);
out_lbl[ _len] = '|'; out_lbl[ _len] = '|';
out_lbl[++_len] = '\0'; out_lbl[++_len] = '\0';
_len += strlcpy(out_lbl + _len, actual_string, str_len - _len); _len += strlcpy(out_lbl + _len, actual_string, sizeof(out_lbl) - _len);
out_lbl[ _len] = '|'; out_lbl[ _len] = '|';
out_lbl[++_len] = '\0'; out_lbl[++_len] = '\0';
strlcpy(out_lbl + _len, path, str_len - _len); strlcpy(out_lbl + _len, path, sizeof(out_lbl) - _len);
_len = strlcpy(tmp, desc, sizeof(tmp)); _len = strlcpy(tmp, desc, sizeof(tmp));
tmp[ _len] = ':'; tmp[ _len] = ':';
tmp[++_len] = ' '; tmp[++_len] = ' ';
@ -2679,9 +2665,6 @@ static int create_string_list_rdb_entry_string(
menu_entries_append(list, tmp, out_lbl, menu_entries_append(list, tmp, out_lbl,
enum_idx, enum_idx,
0, 0, 0, NULL); 0, 0, 0, NULL);
free(out_lbl);
return 0; return 0;
} }
@ -2697,10 +2680,7 @@ static int create_string_list_rdb_entry_int(
char tmp[128]; char tmp[128];
char out_lbl[NAME_MAX_LENGTH]; char out_lbl[NAME_MAX_LENGTH];
str[0] = '\0'; str[0] = '\0';
out_lbl[0] = '\0';
snprintf(str, sizeof(str), "%d", actual_int); snprintf(str, sizeof(str), "%d", actual_int);
_len = strlcpy(out_lbl, label, sizeof(out_lbl)); _len = strlcpy(out_lbl, label, sizeof(out_lbl));
out_lbl[ _len] = '|'; out_lbl[ _len] = '|';
out_lbl[++_len] = '\0'; out_lbl[++_len] = '\0';
@ -2708,7 +2688,6 @@ static int create_string_list_rdb_entry_int(
out_lbl[ _len] = '|'; out_lbl[ _len] = '|';
out_lbl[++_len] = '\0'; out_lbl[++_len] = '\0';
strlcpy(out_lbl + _len, path, sizeof(out_lbl) - _len); strlcpy(out_lbl + _len, path, sizeof(out_lbl) - _len);
_len = strlcpy(tmp, desc, sizeof(tmp)); _len = strlcpy(tmp, desc, sizeof(tmp));
tmp[ _len] = ':'; tmp[ _len] = ':';
tmp[++_len] = ' '; tmp[++_len] = ' ';
@ -2717,7 +2696,6 @@ static int create_string_list_rdb_entry_int(
menu_entries_append(list, tmp, out_lbl, menu_entries_append(list, tmp, out_lbl,
enum_idx, enum_idx,
0, 0, 0, NULL); 0, 0, 0, NULL);
return 0; return 0;
} }
@ -4724,12 +4702,9 @@ static unsigned menu_displaylist_parse_cores(
{ {
char core_path[PATH_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH];
char display_name[NAME_MAX_LENGTH]; char display_name[NAME_MAX_LENGTH];
display_name[0] = '\0';
fill_pathname_join_special(core_path, dir, path, sizeof(core_path)); fill_pathname_join_special(core_path, dir, path, sizeof(core_path));
if (core_info_list_get_display_name(list, if (core_info_list_get_display_name(list,
core_path, display_name, sizeof(display_name))) core_path, display_name, sizeof(display_name)) > 0)
file_list_set_alt_at_offset(info->list, i, display_name); file_list_set_alt_at_offset(info->list, i, display_name);
} }
} }
@ -5271,10 +5246,10 @@ static unsigned menu_displaylist_parse_content_information(
} }
/* Runtime */ /* Runtime */
if (((settings->uints.playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_PER_CORE) && if ( ((settings->uints.playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_PER_CORE)
settings->bools.content_runtime_log) || && settings->bools.content_runtime_log)
((settings->uints.playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_AGGREGATE) && || ((settings->uints.playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_AGGREGATE)
!settings->bools.content_runtime_log_aggregate)) && !settings->bools.content_runtime_log_aggregate))
{ {
runtime_log_t *runtime_log = runtime_log_init( runtime_log_t *runtime_log = runtime_log_init(
content_path, content_path,
@ -5311,7 +5286,6 @@ static unsigned menu_displaylist_parse_content_information(
0, 0, 0, NULL)) 0, 0, 0, NULL))
count++; count++;
} }
free(runtime_log); free(runtime_log);
} }
} }
@ -5710,7 +5684,7 @@ static int menu_displaylist_parse_input_select_reserved_device_list(
strlcpy(reserved_device_name, settings->arrays.input_reserved_devices[enum_idx - MENU_ENUM_LABEL_INPUT_DEVICE_RESERVED_DEVICE_NAME], sizeof(reserved_device_name)); strlcpy(reserved_device_name, settings->arrays.input_reserved_devices[enum_idx - MENU_ENUM_LABEL_INPUT_DEVICE_RESERVED_DEVICE_NAME], sizeof(reserved_device_name));
/* List elements: none/disabled, all existing reservations, all existing devices */ /* List elements: none/disabled, all existing reservations, all existing devices */
for (i = MAX_INPUT_DEVICES+MAX_USERS; i >= 0; --i) for (i = MAX_INPUT_DEVICES + MAX_USERS; i >= 0; --i)
{ {
device_label[0] = '\0'; device_label[0] = '\0';
@ -6614,8 +6588,6 @@ static unsigned menu_displaylist_populate_subsystem(
{ {
char star_char[16]; char star_char[16];
unsigned count = 0; unsigned count = 0;
const char *menu_driver = menu_driver_ident();
bool menu_show_sublabels = settings->bools.menu_show_sublabels;
/* Note: Create this string here explicitly (rather than /* Note: Create this string here explicitly (rather than
* using a #define elsewhere) since we need to be aware of * using a #define elsewhere) since we need to be aware of
* its length... */ * its length... */
@ -6628,6 +6600,9 @@ static unsigned menu_displaylist_populate_subsystem(
static const char utf8_star_char[] = "\xE2\x98\x85"; static const char utf8_star_char[] = "\xE2\x98\x85";
#endif #endif
int i = 0; int i = 0;
#if defined(HAVE_RGUI)
bool menu_show_sublabels = settings->bools.menu_show_sublabels;
const char *menu_driver = menu_driver_ident();
bool is_rgui = string_is_equal(menu_driver, "rgui"); bool is_rgui = string_is_equal(menu_driver, "rgui");
/* Select appropriate 'star' marker for subsystem menu entries /* Select appropriate 'star' marker for subsystem menu entries
@ -6639,6 +6614,7 @@ static unsigned menu_displaylist_populate_subsystem(
star_char[1] = '\0'; star_char[1] = '\0';
} }
else else
#endif
strlcpy(star_char, utf8_star_char, sizeof(star_char)); strlcpy(star_char, utf8_star_char, sizeof(star_char));
if (menu_displaylist_has_subsystems()) if (menu_displaylist_has_subsystems())
@ -6697,6 +6673,7 @@ static unsigned menu_displaylist_populate_subsystem(
s[++_len] = '\0'; s[++_len] = '\0';
_len += strlcpy(s + _len, star_char, sizeof(s) - _len); _len += strlcpy(s + _len, star_char, sizeof(s) - _len);
#ifdef HAVE_RGUI
/* If using RGUI with sublabels disabled, add the /* If using RGUI with sublabels disabled, add the
* appropriate text to the menu entry itself... */ * appropriate text to the menu entry itself... */
if (is_rgui && !menu_show_sublabels) if (is_rgui && !menu_show_sublabels)
@ -6721,6 +6698,7 @@ static unsigned menu_displaylist_populate_subsystem(
strlcpy(s + _len, "]", sizeof(s) - _len); strlcpy(s + _len, "]", sizeof(s) - _len);
} }
} }
#endif
if (menu_entries_append(list, if (menu_entries_append(list,
s, s,
@ -6738,6 +6716,7 @@ static unsigned menu_displaylist_populate_subsystem(
s[++_len] = '\0'; s[++_len] = '\0';
_len += strlcpy(s + _len, subsystem->desc, sizeof(s) - _len); _len += strlcpy(s + _len, subsystem->desc, sizeof(s) - _len);
#ifdef HAVE_RGUI
/* If using RGUI with sublabels disabled, add the /* If using RGUI with sublabels disabled, add the
* appropriate text to the menu entry itself... */ * appropriate text to the menu entry itself... */
if (is_rgui && !menu_show_sublabels) if (is_rgui && !menu_show_sublabels)
@ -6756,6 +6735,7 @@ static unsigned menu_displaylist_populate_subsystem(
strlcpy(s + _len, "]", sizeof(s) - _len); strlcpy(s + _len, "]", sizeof(s) - _len);
} }
} }
#endif
if (menu_entries_append(list, if (menu_entries_append(list,
s, s,
@ -6774,9 +6754,7 @@ static unsigned menu_displaylist_populate_subsystem(
static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
{ {
int i, j; int i, j;
char buf[256]; char s[256];
char passworded[64];
char country[8];
const char *room_type; const char *room_type;
const char *cnc_netplay_room = NULL; const char *cnc_netplay_room = NULL;
const char *msg_int_nc = NULL; const char *msg_int_nc = NULL;
@ -6863,7 +6841,7 @@ static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
for (i = 0; i < net_st->room_count; i++) for (i = 0; i < net_st->room_count; i++)
{ {
size_t _len; size_t _len = 0;
struct netplay_room *room = &net_st->room_list[i]; struct netplay_room *room = &net_st->room_list[i];
/* Get rid of any room that is not running RetroArch. */ /* Get rid of any room that is not running RetroArch. */
@ -6910,34 +6888,23 @@ static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
{ {
if (!show_passworded) if (!show_passworded)
continue; continue;
_len = strlcpy(passworded, "[", _len += strlcpy(s, "[", sizeof(s) - _len);
sizeof(passworded)); _len += strlcpy(s + _len, msg_room_pwd, sizeof(s) - _len);
_len += strlcpy(passworded + _len, _len += strlcpy(s + _len, "] ", sizeof(s) - _len);
msg_room_pwd,
sizeof(passworded) - _len);
strlcpy(passworded + _len, "] ",
sizeof(passworded) - _len);
} }
else
*passworded = '\0';
_len = strlcpy(buf, passworded, sizeof(buf)); _len += strlcpy(s + _len, room_type, sizeof(s) - _len);
_len += strlcpy(buf + _len, room_type, sizeof(buf) - _len); _len += strlcpy(s + _len, ": ", sizeof(s) - _len);
_len += strlcpy(buf + _len, ": ", sizeof(buf) - _len); _len += strlcpy(s + _len, room->nickname, sizeof(s) - _len);
_len += strlcpy(buf + _len, room->nickname, sizeof(buf) - _len);
if (!room->lan && !string_is_empty(room->country)) if (!room->lan && !string_is_empty(room->country))
{ {
size_t _len2 = strlcpy(country, " (", sizeof(country)); _len += strlcpy(s + _len, " (", sizeof(s) - _len);
_len2 += strlcpy(country + _len2, room->country, sizeof(country) - _len2); _len += strlcpy(s + _len, room->country, sizeof(s) - _len);
strlcpy(country + _len2, ")", sizeof(country) - _len2); _len += strlcpy(s + _len, ")", sizeof(s) - _len);
strlcpy(buf + _len, country, sizeof(buf) - _len);
} }
else
*country = '\0';
if (menu_entries_append(list, buf, if (menu_entries_append(list, s, cnc_netplay_room,
cnc_netplay_room,
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
(unsigned)MENU_SETTINGS_NETPLAY_ROOMS_START + i, 0, 0, NULL)) (unsigned)MENU_SETTINGS_NETPLAY_ROOMS_START + i, 0, 0, NULL))
count++; count++;
@ -8416,7 +8383,6 @@ unsigned menu_displaylist_build_list(
for (i = 0; i < num_cheats; i++) for (i = 0; i < num_cheats; i++)
{ {
const char *cheat_description = cheat_manager_get_desc(i); const char *cheat_description = cheat_manager_get_desc(i);
snprintf(cheat_label + _len, sizeof(cheat_label) - _len, " #%u: ", i); snprintf(cheat_label + _len, sizeof(cheat_label) - _len, " #%u: ", i);
if (!string_is_empty(cheat_description)) if (!string_is_empty(cheat_description))
strlcat(cheat_label, cheat_description, sizeof(cheat_label)); strlcat(cheat_label, cheat_description, sizeof(cheat_label));
@ -12314,7 +12280,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
{ {
unsigned max_users = settings->uints.input_max_users; unsigned max_users = settings->uints.input_max_users;
const char *menu_driver = menu_driver_ident(); const char *menu_driver = menu_driver_ident();
#ifdef HAVE_RGUI
bool is_rgui = string_is_equal(menu_driver, "rgui"); bool is_rgui = string_is_equal(menu_driver, "rgui");
#endif
file_list_t *list = info->list; file_list_t *list = info->list;
unsigned port = string_to_unsigned(info->path); unsigned port = string_to_unsigned(info->path);
unsigned mapped_port = settings->uints.input_remap_ports[port]; unsigned mapped_port = settings->uints.input_remap_ports[port];
@ -12383,16 +12351,22 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
desc_len = strlcpy(descriptor, desc_lbl, sizeof(descriptor)); desc_len = strlcpy(descriptor, desc_lbl, sizeof(descriptor));
} }
#ifdef HAVE_RGUI
/* Add user index when display driver == rgui and sublabels /* Add user index when display driver == rgui and sublabels
* are disabled, but only if there is more than one user */ * are disabled, but only if there is more than one user */
if ( (is_rgui) if (
&& (max_users > 1) (is_rgui) &&
(max_users > 1)
&& !settings->bools.menu_show_sublabels) && !settings->bools.menu_show_sublabels)
{ {
desc_len += strlcpy(descriptor + desc_len, " [", sizeof(descriptor) - desc_len); desc_len += strlcpy(descriptor + desc_len,
snprintf(descriptor + desc_len, sizeof(descriptor) - desc_len, "%s %u]", " [", sizeof(descriptor) - desc_len);
msg_val_port, port + 1); desc_len += strlcpy(descriptor + desc_len,
msg_val_port, sizeof(descriptor) - desc_len);
snprintf(descriptor + desc_len,
sizeof(descriptor) - desc_len," %u]", port + 1);
} }
#endif
/* Note: 'physical' port is passed as label */ /* Note: 'physical' port is passed as label */
if (menu_entries_append(list, descriptor, info->path, if (menu_entries_append(list, descriptor, info->path,
@ -12436,6 +12410,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
desc_len = strlcpy(descriptor, desc_lbl, sizeof(descriptor)); desc_len = strlcpy(descriptor, desc_lbl, sizeof(descriptor));
} }
#ifdef HAVE_RGUI
/* Add user index when display driver == rgui and sublabels /* Add user index when display driver == rgui and sublabels
* are disabled, but only if there is more than one user */ * are disabled, but only if there is more than one user */
if ( (is_rgui) if ( (is_rgui)
@ -12446,6 +12421,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
snprintf(descriptor + desc_len, sizeof(descriptor) - desc_len, "%s %u]", snprintf(descriptor + desc_len, sizeof(descriptor) - desc_len, "%s %u]",
val_port, port + 1); val_port, port + 1);
} }
#endif
/* Note: 'physical' port is passed as label */ /* Note: 'physical' port is passed as label */
if (menu_entries_append(list, descriptor, info->path, if (menu_entries_append(list, descriptor, info->path,
@ -12885,10 +12861,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
for (i = 0; i < profiles_count; i++) for (i = 0; i < profiles_count; i++)
{ {
char title[NAME_MAX_LENGTH]; char title[NAME_MAX_LENGTH];
char* profile = SWITCH_CPU_PROFILES[i]; size_t _len = strlcpy(title, SWITCH_CPU_PROFILES[i],
char* speed = SWITCH_CPU_SPEEDS[i]; sizeof(title));
size_t _len = strlcpy(title, profile, sizeof(title)); _len += strlcpy(title + _len, " (", sizeof(title) - _len);
snprintf(title + _len, sizeof(title) - _len, " (%s)", speed); _len += strlcpy(title + _len, SWITCH_CPU_SPEEDS[i],
sizeof(title) - _len);
_len += strlcpy(title + _len, ")", sizeof(title) - _len);
if (menu_entries_append(info->list, title, "", 0, if (menu_entries_append(info->list, title, "", 0,
MENU_SET_SWITCH_CPU_PROFILE, 0, i, NULL)) MENU_SET_SWITCH_CPU_PROFILE, 0, i, NULL))
count++; count++;

View File

@ -1128,161 +1128,90 @@ size_t midi_driver_get_event_size(uint8_t status)
* Returns: NULL if no driver based on @label found, otherwise * Returns: NULL if no driver based on @label found, otherwise
* pointer to driver. * pointer to driver.
**/ **/
static const void *find_driver_nonempty( static size_t find_driver_nonempty(
const char *label, int i, const char *label, int i, char *s, size_t len)
char *s, size_t len)
{ {
if (string_is_equal(label, "camera_driver")) if (string_is_equal(label, "camera_driver"))
{ {
if (camera_drivers[i]) if (camera_drivers[i])
{ return strlcpy(s, camera_drivers[i]->ident, len);
const char *ident = camera_drivers[i]->ident;
strlcpy(s, ident, len);
return camera_drivers[i];
}
} }
else if (string_is_equal(label, "location_driver")) else if (string_is_equal(label, "location_driver"))
{ {
if (location_drivers[i]) if (location_drivers[i])
{ return strlcpy(s, location_drivers[i]->ident, len);
const char *ident = location_drivers[i]->ident;
strlcpy(s, ident, len);
return location_drivers[i];
}
} }
#ifdef HAVE_MENU #ifdef HAVE_MENU
else if (string_is_equal(label, "menu_driver")) else if (string_is_equal(label, "menu_driver"))
{ {
if (menu_ctx_drivers[i]) if (menu_ctx_drivers[i])
{ return strlcpy(s, menu_ctx_drivers[i]->ident, len);
const char *ident = menu_ctx_drivers[i]->ident;
strlcpy(s, ident, len);
return menu_ctx_drivers[i];
}
} }
#endif #endif
else if (string_is_equal(label, "input_driver")) else if (string_is_equal(label, "input_driver"))
{ {
if (input_drivers[i]) if (input_drivers[i])
{ return strlcpy(s, input_drivers[i]->ident, len);
const char *ident = input_drivers[i]->ident;
strlcpy(s, ident, len);
return input_drivers[i];
}
} }
else if (string_is_equal(label, "input_joypad_driver")) else if (string_is_equal(label, "input_joypad_driver"))
{ {
if (joypad_drivers[i]) if (joypad_drivers[i])
{ return strlcpy(s, joypad_drivers[i]->ident, len);
const char *ident = joypad_drivers[i]->ident;
strlcpy(s, ident, len);
return joypad_drivers[i];
}
} }
else if (string_is_equal(label, "video_driver")) else if (string_is_equal(label, "video_driver"))
{ {
if (video_drivers[i]) if (video_drivers[i])
{ return strlcpy(s, video_drivers[i]->ident, len);
const char *ident = video_drivers[i]->ident;
strlcpy(s, ident, len);
return video_drivers[i];
}
} }
else if (string_is_equal(label, "audio_driver")) else if (string_is_equal(label, "audio_driver"))
{ {
if (audio_drivers[i]) if (audio_drivers[i])
{ return strlcpy(s, audio_drivers[i]->ident, len);
const char *ident = audio_drivers[i]->ident;
strlcpy(s, ident, len);
return audio_drivers[i];
}
} }
#ifdef HAVE_MICROPHONE #ifdef HAVE_MICROPHONE
else if (string_is_equal(label, "microphone_driver")) else if (string_is_equal(label, "microphone_driver"))
{ {
if (microphone_drivers[i]) if (microphone_drivers[i])
{ return strlcpy(s, microphone_drivers[i]->ident, len);
const char *ident = microphone_drivers[i]->ident;
strlcpy(s, ident, len);
return microphone_drivers[i];
}
} }
#endif #endif
else if (string_is_equal(label, "record_driver")) else if (string_is_equal(label, "record_driver"))
{ {
if (record_drivers[i]) if (record_drivers[i])
{ return strlcpy(s, record_drivers[i]->ident, len);
const char *ident = record_drivers[i]->ident;
strlcpy(s, ident, len);
return record_drivers[i];
}
} }
else if (string_is_equal(label, "midi_driver")) else if (string_is_equal(label, "midi_driver"))
{ {
if (midi_driver_find_handle(i)) if (midi_driver_find_handle(i))
{ return strlcpy(s, midi_drivers[i]->ident, len);
const char *ident = midi_drivers[i]->ident;
strlcpy(s, ident, len);
return midi_drivers[i];
}
} }
else if (string_is_equal(label, "audio_resampler_driver")) else if (string_is_equal(label, "audio_resampler_driver"))
{ {
if (audio_resampler_driver_find_handle(i)) if (audio_resampler_driver_find_handle(i))
{ return strlcpy(s, audio_resampler_driver_find_ident(i), len);
const char *ident = audio_resampler_driver_find_ident(i);
strlcpy(s, ident, len);
return audio_resampler_driver_find_handle(i);
}
} }
#ifdef HAVE_BLUETOOTH #ifdef HAVE_BLUETOOTH
else if (string_is_equal(label, "bluetooth_driver")) else if (string_is_equal(label, "bluetooth_driver"))
{ {
if (bluetooth_drivers[i]) if (bluetooth_drivers[i])
{ return strlcpy(s, bluetooth_drivers[i]->ident, len);
const char *ident = bluetooth_drivers[i]->ident;
strlcpy(s, ident, len);
return bluetooth_drivers[i];
}
} }
#endif #endif
#ifdef HAVE_WIFI #ifdef HAVE_WIFI
else if (string_is_equal(label, "wifi_driver")) else if (string_is_equal(label, "wifi_driver"))
{ {
if (wifi_drivers[i]) if (wifi_drivers[i])
{ return strlcpy(s, wifi_drivers[i]->ident, len);
const char *ident = wifi_drivers[i]->ident;
strlcpy(s, ident, len);
return wifi_drivers[i];
}
} }
#endif #endif
#ifdef HAVE_CLOUDSYNC #ifdef HAVE_CLOUDSYNC
else if (string_is_equal(label, "cloud_sync_driver")) else if (string_is_equal(label, "cloud_sync_driver"))
{ {
if (cloud_sync_drivers[i]) if (cloud_sync_drivers[i])
{ return strlcpy(s, cloud_sync_drivers[i]->ident, len);
const char *ident = cloud_sync_drivers[i]->ident;
strlcpy(s, ident, len);
return cloud_sync_drivers[i];
}
} }
#endif #endif
return NULL; return 0;
} }
int driver_find_index(const char *label, const char *drv) int driver_find_index(const char *label, const char *drv)
@ -1293,7 +1222,7 @@ int driver_find_index(const char *label, const char *drv)
str[0] = '\0'; str[0] = '\0';
for (i = 0; for (i = 0;
find_driver_nonempty(label, i, str, sizeof(str)) != NULL; i++) find_driver_nonempty(label, i, str, sizeof(str)) > 0; i++)
{ {
if (string_is_empty(str)) if (string_is_empty(str))
break; break;
@ -1317,7 +1246,7 @@ static void driver_find_last(const char *label, char *s, size_t len)
unsigned i; unsigned i;
for (i = 0; for (i = 0;
find_driver_nonempty(label, i, s, len) != NULL; i++) { } find_driver_nonempty(label, i, s, len) > 0; i++) { }
if (i) if (i)
i = i - 1; i = i - 1;
@ -8259,8 +8188,8 @@ bool retroarch_override_setting_is_set(
return false; return false;
} }
int retroarch_get_capabilities(enum rarch_capabilities type, size_t retroarch_get_capabilities(enum rarch_capabilities type,
char *str_out, size_t str_len) char *s, size_t len)
{ {
size_t _len = 0; size_t _len = 0;
switch (type) switch (type)
@ -8269,80 +8198,79 @@ int retroarch_get_capabilities(enum rarch_capabilities type,
{ {
uint64_t cpu = cpu_features_get(); uint64_t cpu = cpu_features_get();
if (cpu & RETRO_SIMD_MMX) if (cpu & RETRO_SIMD_MMX)
_len += strlcpy(str_out + _len, "MMX ", str_len - _len); _len += strlcpy(s + _len, "MMX ", len - _len);
if (cpu & RETRO_SIMD_MMXEXT) if (cpu & RETRO_SIMD_MMXEXT)
_len += strlcpy(str_out + _len, "MMXEXT ", str_len - _len); _len += strlcpy(s + _len, "MMXEXT ", len - _len);
if (cpu & RETRO_SIMD_SSE) if (cpu & RETRO_SIMD_SSE)
_len += strlcpy(str_out + _len, "SSE ", str_len - _len); _len += strlcpy(s + _len, "SSE ", len - _len);
if (cpu & RETRO_SIMD_SSE2) if (cpu & RETRO_SIMD_SSE2)
_len += strlcpy(str_out + _len, "SSE2 ", str_len - _len); _len += strlcpy(s + _len, "SSE2 ", len - _len);
if (cpu & RETRO_SIMD_SSE3) if (cpu & RETRO_SIMD_SSE3)
_len += strlcpy(str_out + _len, "SSE3 ", str_len - _len); _len += strlcpy(s + _len, "SSE3 ", len - _len);
if (cpu & RETRO_SIMD_SSSE3) if (cpu & RETRO_SIMD_SSSE3)
_len += strlcpy(str_out + _len, "SSSE3 ", str_len - _len); _len += strlcpy(s + _len, "SSSE3 ", len - _len);
if (cpu & RETRO_SIMD_SSE4) if (cpu & RETRO_SIMD_SSE4)
_len += strlcpy(str_out + _len, "SSE4 ", str_len - _len); _len += strlcpy(s + _len, "SSE4 ", len - _len);
if (cpu & RETRO_SIMD_SSE42) if (cpu & RETRO_SIMD_SSE42)
_len += strlcpy(str_out + _len, "SSE42 ", str_len - _len); _len += strlcpy(s + _len, "SSE42 ", len - _len);
if (cpu & RETRO_SIMD_AES) if (cpu & RETRO_SIMD_AES)
_len += strlcpy(str_out + _len, "AES ", str_len - _len); _len += strlcpy(s + _len, "AES ", len - _len);
if (cpu & RETRO_SIMD_AVX) if (cpu & RETRO_SIMD_AVX)
_len += strlcpy(str_out + _len, "AVX ", str_len - _len); _len += strlcpy(s + _len, "AVX ", len - _len);
if (cpu & RETRO_SIMD_AVX2) if (cpu & RETRO_SIMD_AVX2)
_len += strlcpy(str_out + _len, "AVX2 ", str_len - _len); _len += strlcpy(s + _len, "AVX2 ", len - _len);
if (cpu & RETRO_SIMD_NEON) if (cpu & RETRO_SIMD_NEON)
_len += strlcpy(str_out + _len, "NEON ", str_len - _len); _len += strlcpy(s + _len, "NEON ", len - _len);
if (cpu & RETRO_SIMD_VFPV3) if (cpu & RETRO_SIMD_VFPV3)
_len += strlcpy(str_out + _len, "VFPV3 ", str_len - _len); _len += strlcpy(s + _len, "VFPV3 ", len - _len);
if (cpu & RETRO_SIMD_VFPV4) if (cpu & RETRO_SIMD_VFPV4)
_len += strlcpy(str_out + _len, "VFPV4 ", str_len - _len); _len += strlcpy(s + _len, "VFPV4 ", len - _len);
if (cpu & RETRO_SIMD_VMX) if (cpu & RETRO_SIMD_VMX)
_len += strlcpy(str_out + _len, "VMX ", str_len - _len); _len += strlcpy(s + _len, "VMX ", len - _len);
if (cpu & RETRO_SIMD_VMX128) if (cpu & RETRO_SIMD_VMX128)
_len += strlcpy(str_out + _len, "VMX128 ", str_len - _len); _len += strlcpy(s + _len, "VMX128 ", len - _len);
if (cpu & RETRO_SIMD_VFPU) if (cpu & RETRO_SIMD_VFPU)
_len += strlcpy(str_out + _len, "VFPU ", str_len - _len); _len += strlcpy(s + _len, "VFPU ", len - _len);
if (cpu & RETRO_SIMD_PS) if (cpu & RETRO_SIMD_PS)
_len += strlcpy(str_out + _len, "PS ", str_len - _len); _len += strlcpy(s + _len, "PS ", len - _len);
if (cpu & RETRO_SIMD_ASIMD) if (cpu & RETRO_SIMD_ASIMD)
_len += strlcpy(str_out + _len, "ASIMD ", str_len - _len); _len += strlcpy(s + _len, "ASIMD ", len - _len);
break; break;
} }
break; break;
case RARCH_CAPABILITIES_COMPILER: case RARCH_CAPABILITIES_COMPILER:
#if defined(_MSC_VER) #if defined(_MSC_VER)
_len = strlcpy(str_out, msg_hash_to_str(MSG_COMPILER), str_len); _len += strlcpy (s + _len, msg_hash_to_str(MSG_COMPILER), len - _len);
_len += snprintf(str_out + _len, str_len - _len, ": MSVC (%d)", _len += snprintf(s + _len, len - _len, ": MSVC (%d)",
_MSC_VER); _MSC_VER);
#elif defined(__SNC__) #elif defined(__SNC__)
_len = strlcpy(str_out, msg_hash_to_str(MSG_COMPILER), str_len); _len += strlcpy (s + _len, msg_hash_to_str(MSG_COMPILER), len - _len);
_len += snprintf(str_out + _len, str_len - _len, ": SNC (%d)", _len += snprintf(s + _len, len - _len, ": SNC (%d)",
__SN_VER__); __SN_VER__);
#elif defined(_WIN32) && defined(__GNUC__) #elif defined(_WIN32) && defined(__GNUC__)
_len = strlcpy(str_out, msg_hash_to_str(MSG_COMPILER), str_len); _len += strlcpy (s + _len, msg_hash_to_str(MSG_COMPILER), len - _len);
_len += snprintf(str_out + _len, str_len - _len, ": MinGW (%d.%d.%d)", _len += snprintf(s + _len, len - _len, ": MinGW (%d.%d.%d)",
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#elif defined(__clang__) #elif defined(__clang__)
_len = strlcpy(str_out, msg_hash_to_str(MSG_COMPILER), str_len); _len += strlcpy(s + _len, msg_hash_to_str(MSG_COMPILER), len - _len);
_len += strlcpy(str_out + _len, ": Clang/LLVM (", str_len - _len); _len += strlcpy(s + _len, ": Clang/LLVM (", len - _len);
_len += strlcpy(str_out + _len, __clang_version__, str_len - _len); _len += strlcpy(s + _len, __clang_version__, len - _len);
_len += strlcpy(str_out + _len, ")", str_len - _len); _len += strlcpy(s + _len, ")", len - _len);
#elif defined(__GNUC__) #elif defined(__GNUC__)
_len = strlcpy(str_out, msg_hash_to_str(MSG_COMPILER), str_len); _len += strlcpy (s + _len, msg_hash_to_str(MSG_COMPILER), len - _len);
_len += snprintf(str_out + _len, str_len - _len, ": GCC (%d.%d.%d)", _len += snprintf(s + _len, len - _len, ": GCC (%d.%d.%d)",
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#else #else
_len = strlcpy(str_out, msg_hash_to_str(MSG_UNKNOWN_COMPILER), str_len); _len += strlcpy(s + _len, msg_hash_to_str(MSG_UNKNOWN_COMPILER), len - _len);
#endif #endif
snprintf(str_out + _len, str_len - _len, " %u-bit", _len += snprintf(s + _len, len - _len, " %u-bit",
(unsigned)(CHAR_BIT * sizeof(size_t))); (unsigned)(CHAR_BIT * sizeof(size_t)));
break; break;
default: default:
case RARCH_CAPABILITIES_NONE: case RARCH_CAPABILITIES_NONE:
break; break;
} }
return _len;
return 0;
} }
void retroarch_fail(int error_code, const char *error) void retroarch_fail(int error_code, const char *error)

View File

@ -112,7 +112,7 @@ enum rarch_state_flags
bool retroarch_ctl(enum rarch_ctl_state state, void *data); bool retroarch_ctl(enum rarch_ctl_state state, void *data);
int retroarch_get_capabilities(enum rarch_capabilities type, size_t retroarch_get_capabilities(enum rarch_capabilities type,
char *s, size_t len); char *s, size_t len);
void retroarch_override_setting_set(enum rarch_override_setting enum_idx, void *data); void retroarch_override_setting_set(enum rarch_override_setting enum_idx, void *data);

View File

@ -1266,7 +1266,6 @@ static void runloop_init_core_options_path(
if (per_core_options) if (per_core_options)
{ {
strlcpy(s, per_core_options_path, len); strlcpy(s, per_core_options_path, len);
if (!per_core_options_exist) if (!per_core_options_exist)
strlcpy(src_path, global_options_path, src_len); strlcpy(src_path, global_options_path, src_len);
} }
@ -1957,8 +1956,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
RARCH_WARN("[Environ]: SYSTEM DIR is empty, assume CONTENT DIR %s\n", RARCH_WARN("[Environ]: SYSTEM DIR is empty, assume CONTENT DIR %s\n",
fullpath); fullpath);
strlcpy(tmp_path, fullpath, sizeof(tmp_path)); fill_pathname_basedir(tmp_path, fullpath, sizeof(tmp_path));
path_basedir(tmp_path);
/* Removes trailing slash (unless root dir) */ /* Removes trailing slash (unless root dir) */
len = strlen(tmp_path); len = strlen(tmp_path);
@ -7903,7 +7901,8 @@ void runloop_path_set_redirect(settings_t *settings,
sizeof(content_dir_name)); sizeof(content_dir_name));
/* Set savefile directory if empty to content directory */ /* Set savefile directory if empty to content directory */
if (string_is_empty(intermediate_savefile_dir) || savefiles_in_content_dir) if ( string_is_empty(intermediate_savefile_dir)
|| savefiles_in_content_dir)
{ {
strlcpy(intermediate_savefile_dir, strlcpy(intermediate_savefile_dir,
runloop_st->runtime_content_path_basename, runloop_st->runtime_content_path_basename,
@ -7915,7 +7914,7 @@ void runloop_path_set_redirect(settings_t *settings,
} }
/* Set savestate directory if empty based on content directory */ /* Set savestate directory if empty based on content directory */
if (string_is_empty(intermediate_savestate_dir) if ( string_is_empty(intermediate_savestate_dir)
|| savestates_in_content_dir) || savestates_in_content_dir)
{ {
strlcpy(intermediate_savestate_dir, strlcpy(intermediate_savestate_dir,
@ -8013,11 +8012,12 @@ void runloop_path_set_redirect(settings_t *settings,
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) && !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL)
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL)) && !netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{ {
fill_pathname_join(new_savefile_dir, new_savefile_dir, ".netplay", fill_pathname_join(new_savefile_dir,
new_savefile_dir, ".netplay",
sizeof(new_savefile_dir)); sizeof(new_savefile_dir));
if (!path_is_directory(new_savefile_dir) && if ( !path_is_directory(new_savefile_dir)
!path_mkdir(new_savefile_dir)) && !path_mkdir(new_savefile_dir))
path_basedir(new_savefile_dir); path_basedir(new_savefile_dir);
} }
#endif #endif
@ -8038,7 +8038,8 @@ void runloop_path_set_redirect(settings_t *settings,
sizeof(runloop_st->name.savestate)); sizeof(runloop_st->name.savestate));
strlcpy(runloop_st->name.replay, new_savestate_dir, strlcpy(runloop_st->name.replay, new_savestate_dir,
sizeof(runloop_st->name.replay)); sizeof(runloop_st->name.replay));
} else }
else
savestate_is_dir = path_is_directory(runloop_st->name.savestate); savestate_is_dir = path_is_directory(runloop_st->name.savestate);
if (savefile_is_dir) if (savefile_is_dir)