Replace more strlcats

This commit is contained in:
libretroadmin 2024-06-16 19:42:32 +02:00
parent d3c14a6e3e
commit 3f0d3ec393
3 changed files with 92 additions and 87 deletions

View File

@ -1899,12 +1899,13 @@ static void core_info_list_resolve_all_extensions(
for (i = 0; i < core_info_list->count; i++)
{
size_t _len;
if (!core_info_list->list[i].supported_extensions)
continue;
strlcat(core_info_list->all_ext,
_len = strlcat(core_info_list->all_ext,
core_info_list->list[i].supported_extensions, all_ext_len);
strlcat(core_info_list->all_ext, "|", all_ext_len);
strlcpy(core_info_list->all_ext + _len, "|", all_ext_len - _len);
}
#ifdef HAVE_7ZIP
strlcat(core_info_list->all_ext, "7z|", all_ext_len);

View File

@ -1523,9 +1523,9 @@ static int action_bind_sublabel_subsystem_load(
for (j = 0; j < content_get_subsystem_rom_id(); j++)
{
strlcat(buf, path_basename(content_get_subsystem_rom(j)), sizeof(buf));
size_t _len = strlcat(buf, path_basename(content_get_subsystem_rom(j)), sizeof(buf));
if (j != content_get_subsystem_rom_id() - 1)
strlcat(buf, "\n", sizeof(buf));
_len += strlcpy(buf + _len, "\n", sizeof(buf) - _len);
}
if (!string_is_empty(buf))

View File

@ -6185,6 +6185,7 @@ static void retroarch_print_version(void)
static void retroarch_print_help(const char *arg0)
{
char buf[2048];
size_t _len = 0;
buf[0] = '\0';
frontend_driver_attach_console();
@ -6196,7 +6197,7 @@ static void retroarch_print_help(const char *arg0)
fprintf(stdout, "Usage: %s [OPTIONS]... [FILE]\n\n", arg0);
strlcat(buf,
_len = strlcpy(buf + _len,
" -h, --help "
"Show this help message.\n"
" -v, --verbose "
@ -6207,29 +6208,29 @@ static void retroarch_print_help(const char *arg0)
"Show version.\n"
" --features "
"Print available features compiled into program.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#ifdef HAVE_MENU
strlcat(buf,
_len += strlcpy(buf + _len,
" --menu "
"Do not require content or libretro core to be loaded,\n"
" "
" starts directly in menu. If no arguments are passed to\n"
" "
" the program, it is equivalent to using --menu as only argument.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
#ifdef HAVE_CONFIGFILE
strlcat(buf, " -c, --config=FILE "
"Path for config file.\n", sizeof(buf));
_len += strlcpy(buf + _len, " -c, --config=FILE "
"Path for config file.\n", sizeof(buf) - _len);
#ifdef _WIN32
strlcat(buf, " "
_len += strlcpy(buf + _len, " "
" Defaults to retroarch.cfg in same directory as retroarch.exe.\n"
" "
" If a default config is not found, the program will attempt to create one.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#else
strlcat(buf,
_len += strlcpy(buf + _len,
" "
" By default looks for config in\n"
" "
@ -6242,22 +6243,32 @@ static void retroarch_print_help(const char *arg0)
" If a default config is not found, the program will attempt to create one\n"
" "
" based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg).\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
strlcat(buf, " --appendconfig=FILE "
_len += strlcpy(buf + _len, " --appendconfig=FILE "
"Extra config files are loaded in, and take priority over\n"
" "
" config selected in -c (or default). Multiple configs are\n"
" "
" delimited by '|'.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
fputs(buf, stdout);
buf[0] = '\0';
_len = 0;
_len += strlcpy(buf + _len,
" --subsystem=NAME "
"Use a subsystem of the libretro core. Multiple content\n"
" "
" files are loaded as multiple arguments. If a content\n"
" "
" file is skipped, use a blank (\"\") command line argument.\n"
, sizeof(buf) - _len);
#ifdef HAVE_DYNAMIC
strlcat(buf,
_len += strlcpy(buf + _len,
" -L, --libretro=FILE "
"Path to libretro implementation. Overrides any config setting.\n"
" "
@ -6266,42 +6277,34 @@ static void retroarch_print_help(const char *arg0)
" 1. The full path to a core shared object library: path/to/<core_name>_libretro.<lib_ext>\n"
" "
" 2. A core shared object library 'file name' (*): <core_name>_libretro.<lib_ext>\n"
, sizeof(buf));
strlcat(buf,
, sizeof(buf) - _len);
_len += strlcpy(buf + _len,
" "
" 3. A core 'short name' (*): <core_name>_libretro OR <core_name>\n"
" "
" (*) If 'file name' or 'short name' do not correspond to an existing full file path,\n"
" "
" the configured frontend 'cores' directory will be searched for a match.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
strlcat(buf,
" --subsystem=NAME "
"Use a subsystem of the libretro core. Multiple content\n"
" "
" files are loaded as multiple arguments. If a content\n"
" "
" file is skipped, use a blank (\"\") command line argument.\n"
, sizeof(buf));
strlcat(buf,
_len += strlcpy(buf + _len,
" "
" Content must be loaded in an order which depends on the\n"
" "
" particular subsystem used. See verbose log output to learn\n"
" "
" how a particular subsystem wants content to be loaded.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#ifdef HAVE_LIBRETRODB
strlcat(buf,
_len += strlcpy(buf + _len,
" --scan=PATH|FILE "
"Import content from path.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
strlcat(buf,
_len = strlcpy(buf + _len,
" -f, --fullscreen "
"Start the program in fullscreen regardless of config setting.\n"
" --set-shader=PATH "
@ -6310,18 +6313,20 @@ static void retroarch_print_help(const char *arg0)
" Effectively overrides automatic shader presets.\n"
" "
" An empty argument \"\" will disable automatic shader presets.\n"
, sizeof(buf));
, sizeof(buf) - _len);
fputs(buf, stdout);
buf[0] = '\0';
_len = 0;
printf( " -N, --nodevice=PORT "
_len += snprintf(buf + _len, sizeof(buf) - _len," -N, --nodevice=PORT "
"Disconnects controller device connected to PORT (1 to %d).\n", MAX_USERS);
printf( " -A, --dualanalog=PORT "
_len += snprintf(buf + _len, sizeof(buf) - _len," -A, --dualanalog=PORT "
"Connect a DualAnalog controller to PORT (1 to %d).\n", MAX_USERS);
printf( " -d, --device=PORT:ID "
_len += snprintf(buf + _len, sizeof(buf) - _len," -d, --device=PORT:ID "
"Connect a generic device into PORT of the device (1 to %d).\n", MAX_USERS);
strlcat(buf,
_len += strlcpy(buf + _len,
" "
" Format is PORT:ID, where ID is a number corresponding to the particular device.\n"
" -M, --sram-mode=MODE "
@ -6330,10 +6335,10 @@ static void retroarch_print_help(const char *arg0)
" 'noload-nosave', 'noload-save', 'load-nosave' or 'load-save'.\n"
" "
" Note: 'noload-save' implies that save files *WILL BE OVERWRITTEN*.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#ifdef HAVE_NETWORKING
strlcat(buf,
_len += strlcpy(buf + _len,
" -H, --host "
"Host netplay as user 1.\n"
" -C, --connect=HOST "
@ -6346,87 +6351,86 @@ static void retroarch_print_help(const char *arg0)
"Picks a username (for use with netplay). Not mandatory.\n"
" --check-frames=NUMBER "
"Check frames when using netplay.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#ifdef HAVE_NETWORK_CMD
strlcat(buf,
_len += strlcpy(buf + _len,
" --command "
"Sends a command over UDP to an already running program process.\n"
" "
" Available commands are listed if command is invalid.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
#endif
#ifdef HAVE_BSV_MOVIE
strlcat(buf,
_len += strlcpy(buf + _len,
" -P, --play-replay=FILE "
"Playback a replay file.\n"
" -R, --record-replay=FILE "
"Start recording a replay file from the beginning.\n"
" --eof-exit "
"Exit upon reaching the end of the replay file.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
strlcat(buf,
_len += strlcpy(buf + _len,
" -r, --record=FILE "
"Path to record video file. Using mkv extension is recommended.\n"
" --recordconfig "
"Path to settings used during recording.\n"
" --size=WIDTHxHEIGHT "
"Overrides output video size when recording.\n"
, sizeof(buf));
, sizeof(buf) - _len);
fputs(buf, stdout);
buf[0] = '\0';
_len = 0;
strlcat(buf,
_len = strlcpy(buf + _len,
" -D, --detach "
"Detach program from the running console. Not relevant for all platforms.\n"
" --max-frames=NUMBER "
"Runs for the specified number of frames, then exits.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#ifdef HAVE_PATCH
strlcat(buf,
_len += strlcpy(buf + _len,
" -U, --ups=FILE "
"Specifies path for UPS patch that will be applied to content.\n"
" --bps=FILE "
"Specifies path for BPS patch that will be applied to content.\n"
" --ips=FILE "
"Specifies path for IPS patch that will be applied to content.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#ifdef HAVE_XDELTA
strlcat(buf,
_len += strlcpy(buf + _len,
" --xdelta=FILE "
"Specifies path for Xdelta patch that will be applied to content.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif /* HAVE_XDELTA */
strlcat(buf,
_len += strlcpy(buf + _len,
" --no-patch "
"Disables all forms of content patching.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif /* HAVE_PATCH */
#ifdef HAVE_SCREENSHOTS
strlcat(buf,
_len += strlcpy(buf + _len,
" --max-frames-ss "
"Takes a screenshot at the end of max-frames.\n"
" --max-frames-ss-path=FILE "
"Path to save the screenshot to at the end of max-frames.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
#ifdef HAVE_ACCESSIBILITY
strlcat(buf,
_len += strlcpy(buf + _len,
" --accessibility "
"Enables accessibilty for blind users using text-to-speech.\n"
, sizeof(buf));
, sizeof(buf) - _len);
#endif
strlcat(buf,
_len += strlcpy(buf + _len,
" --load-menu-on-error "
"Open menu instead of quitting if specified core or content fails to load.\n"
" -e, --entryslot=NUMBER "
@ -6435,7 +6439,7 @@ static void retroarch_print_help(const char *arg0)
"Path for save files (*.srm). (DEPRECATED, use --appendconfig and savefile_directory)\n"
" -S, --savestate=PATH "
"Path for the save state files (*.state). (DEPRECATED, use --appendconfig and savestate_directory)\n"
, sizeof(buf));
, sizeof(buf) - _len);
fputs(buf, stdout);
}