mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Gradually get rid of strcpy_literal
Reasons: 1 - Just a macro for strcpy 1.2 - doesn't have a return type unlike strlcpy, can't be used for string concatenation 1.3 - unsafe compared to strlcpy Do either manual string assignment per character or strlcpy, no inbetween by resorting to strcpy
This commit is contained in:
parent
5a036de53c
commit
6f738d4fbd
@ -799,7 +799,7 @@ bool command_get_status(command_t *cmd, const char* arg)
|
||||
content_get_status(&contentless, &is_inited);
|
||||
|
||||
if (!is_inited)
|
||||
strcpy_literal(reply, "GET_STATUS CONTENTLESS");
|
||||
strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
|
||||
else
|
||||
{
|
||||
/* add some content info */
|
||||
|
@ -5429,7 +5429,7 @@ static bool config_file_salamander_get_path(char *s, size_t len)
|
||||
FILE_PATH_SALAMANDER_CONFIG,
|
||||
len);
|
||||
else
|
||||
strcpy_literal(s, FILE_PATH_SALAMANDER_CONFIG);
|
||||
strlcpy(s, FILE_PATH_SALAMANDER_CONFIG, len);
|
||||
|
||||
return !string_is_empty(s);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ static void get_first_valid_core(char* path_return, size_t len)
|
||||
if (strlen(ent->d_name) > strlen(extension)
|
||||
&& !strcmp(ent->d_name + strlen(ent->d_name) - strlen(extension), extension))
|
||||
{
|
||||
strcpy_literal(path_return, "sdmc:/retroarch/cores/");
|
||||
strlcpy(path_return, "sdmc:/retroarch/cores/", len);
|
||||
strlcat(path_return, ent->d_name, len);
|
||||
break;
|
||||
}
|
||||
@ -610,7 +610,7 @@ static void frontend_ctr_get_os(char* s, size_t len, int* major, int* minor)
|
||||
OS_VersionBin cver;
|
||||
OS_VersionBin nver;
|
||||
|
||||
strcpy_literal(s, "3DS OS");
|
||||
strlcpy(s, "3DS OS", len);
|
||||
Result data_invalid = osGetSystemVersionData(&nver, &cver);
|
||||
if (data_invalid == 0)
|
||||
{
|
||||
@ -635,26 +635,26 @@ static void frontend_ctr_get_name(char* s, size_t len)
|
||||
switch (device_model)
|
||||
{
|
||||
case 0:
|
||||
strcpy_literal(s, "Old 3DS");
|
||||
strlcpy(s, "Old 3DS", len);
|
||||
break;
|
||||
case 1:
|
||||
strcpy_literal(s, "Old 3DS XL");
|
||||
strlcpy(s, "Old 3DS XL", len);
|
||||
break;
|
||||
case 2:
|
||||
strcpy_literal(s, "New 3DS");
|
||||
strlcpy(s, "New 3DS", len);
|
||||
break;
|
||||
case 3:
|
||||
strcpy_literal(s, "Old 2DS");
|
||||
strlcpy(s, "Old 2DS", len);
|
||||
break;
|
||||
case 4:
|
||||
strcpy_literal(s, "New 3DS XL");
|
||||
strlcpy(s, "New 3DS XL", len);
|
||||
break;
|
||||
case 5:
|
||||
strcpy_literal(s, "New 2DS XL");
|
||||
strlcpy(s, "New 2DS XL", len);
|
||||
break;
|
||||
|
||||
default:
|
||||
strcpy_literal(s, "Unknown Device");
|
||||
strlcpy(s, "Unknown Device", len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,10 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor)
|
||||
{
|
||||
#if defined(IOS)
|
||||
get_ios_version(major, minor);
|
||||
strcpy_literal(s, "iOS");
|
||||
s[0] = 'i';
|
||||
s[1] = 'O';
|
||||
s[2] = 'S';
|
||||
s[3] = '\0';
|
||||
#elif defined(OSX)
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 // MAC_OS_X_VERSION_10_13
|
||||
@ -319,7 +322,10 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor)
|
||||
Gestalt(gestaltSystemVersionMajor, (SInt32*)major);
|
||||
}
|
||||
#endif
|
||||
strcpy_literal(s, "OSX");
|
||||
s[0] = 'O';
|
||||
s[1] = 'S';
|
||||
s[2] = 'X';
|
||||
s[3] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -460,7 +466,7 @@ static void frontend_darwin_get_env(int *argc, char *argv[],
|
||||
int major, minor;
|
||||
get_ios_version(&major, &minor);
|
||||
if (major > 8)
|
||||
strcpy_literal(g_defaults.path_buildbot_server_url, "http://buildbot.libretro.com/nightly/apple/ios9/latest/");
|
||||
strlcpy(g_defaults.path_buildbot_server_url, "http://buildbot.libretro.com/nightly/apple/ios9/latest/", sizeof(g_defaults.path_buildbot_server_url));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -94,8 +94,8 @@ static void frontend_psp_get_env_settings(int *argc, char *argv[],
|
||||
#endif
|
||||
|
||||
#ifdef VITA
|
||||
strcpy_literal(eboot_path, "app0:/");
|
||||
strcpy_literal(user_path, "ux0:/data/retroarch/");
|
||||
strlcpy(eboot_path, "app0:/", sizeof(eboot_path));
|
||||
strlcpy(user_path, "ux0:/data/retroarch/", sizeof(user_path));
|
||||
|
||||
strlcpy(g_defaults.dirs[DEFAULT_DIR_PORT], eboot_path,
|
||||
sizeof(g_defaults.dirs[DEFAULT_DIR_PORT]));
|
||||
@ -149,7 +149,7 @@ static void frontend_psp_get_env_settings(int *argc, char *argv[],
|
||||
strlcpy(eboot_path, argv[0], sizeof(eboot_path));
|
||||
/* for PSP, use uppercase directories, and no trailing slashes
|
||||
otherwise mkdir fails */
|
||||
strcpy_literal(user_path, "ms0:/PSP/RETROARCH");
|
||||
strlcpy(user_path, "ms0:/PSP/RETROARCH", sizeof(user_path));
|
||||
|
||||
fill_pathname_basedir(g_defaults.dirs[DEFAULT_DIR_PORT], argv[0],
|
||||
sizeof(g_defaults.dirs[DEFAULT_DIR_PORT]));
|
||||
|
@ -164,8 +164,7 @@ static void get_first_valid_core(char *path_return, size_t len)
|
||||
|
||||
path_return[0] = '\0';
|
||||
|
||||
dir = opendir(SD_PREFIX "/retroarch/cores");
|
||||
if (dir)
|
||||
if ((dir = opendir(SD_PREFIX "/retroarch/cores")))
|
||||
{
|
||||
while ((ent = readdir(dir)))
|
||||
{
|
||||
@ -173,7 +172,7 @@ static void get_first_valid_core(char *path_return, size_t len)
|
||||
break;
|
||||
if (strlen(ent->d_name) > strlen(extension) && !strcmp(ent->d_name + strlen(ent->d_name) - strlen(extension), extension))
|
||||
{
|
||||
strcpy_literal(path_return, SD_PREFIX "/retroarch/cores");
|
||||
strlcpy(path_return, SD_PREFIX "/retroarch/cores", len);
|
||||
strlcat(path_return, "/", len);
|
||||
strlcat(path_return, ent->d_name, len);
|
||||
break;
|
||||
@ -692,7 +691,7 @@ static void frontend_switch_get_os(
|
||||
ipc_request_t rq;
|
||||
#endif
|
||||
|
||||
strcpy_literal(s, "Horizon OS");
|
||||
strlcpy(s, "Horizon OS", len);
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
*major = 0;
|
||||
@ -730,8 +729,8 @@ fail:
|
||||
|
||||
static void frontend_switch_get_name(char *s, size_t len)
|
||||
{
|
||||
/* TODO: Add Mariko at some point */
|
||||
strcpy_literal(s, "Nintendo Switch");
|
||||
/* TODO/FIXME: Add Mariko at some point */
|
||||
strlcpy(s, "Nintendo Switch", len);
|
||||
}
|
||||
|
||||
void frontend_switch_process_args(int *argc, char *argv[])
|
||||
|
@ -1269,7 +1269,7 @@ static void frontend_unix_get_os(char *s,
|
||||
int rel;
|
||||
frontend_android_get_version(major, minor, &rel);
|
||||
|
||||
strcpy_literal(s, "Android");
|
||||
strlcpy(s, "Android", len);
|
||||
#else
|
||||
char *ptr;
|
||||
struct utsname buffer;
|
||||
@ -1280,19 +1280,19 @@ static void frontend_unix_get_os(char *s,
|
||||
*major = (int)strtol(buffer.release, &ptr, 10);
|
||||
*minor = (int)strtol(++ptr, NULL, 10);
|
||||
#if defined(__FreeBSD__)
|
||||
strcpy_literal(s, "FreeBSD");
|
||||
strlcpy(s, "FreeBSD", len);
|
||||
#elif defined(__NetBSD__)
|
||||
strcpy_literal(s, "NetBSD");
|
||||
strlcpy(s, "NetBSD", len);
|
||||
#elif defined(__OpenBSD__)
|
||||
strcpy_literal(s, "OpenBSD");
|
||||
strlcpy(s, "OpenBSD", len);
|
||||
#elif defined(__DragonFly__)
|
||||
strcpy_literal(s, "DragonFly BSD");
|
||||
strlcpy(s, "DragonFly BSD", len);
|
||||
#elif defined(BSD)
|
||||
strcpy_literal(s, "BSD");
|
||||
strlcpy(s, "BSD", len);
|
||||
#elif defined(__HAIKU__)
|
||||
strcpy_literal(s, "Haiku");
|
||||
strlcpy(s, "Haiku", len);
|
||||
#else
|
||||
strcpy_literal(s, "Linux");
|
||||
strlcpy(s, "Linux", len);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -105,81 +105,41 @@ static void frontend_uwp_get_os(char *s, size_t len, int *major, int *minor)
|
||||
{
|
||||
case 10:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2016");
|
||||
strlcpy(s, "Windows Server 2016", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 10");
|
||||
strlcpy(s, "Windows 10", len);
|
||||
break;
|
||||
case 6:
|
||||
switch (vi.dwMinorVersion)
|
||||
{
|
||||
case 3:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2012 R2");
|
||||
strlcpy(s, "Windows Server 2012 R2", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 8.1");
|
||||
strlcpy(s, "Windows 8.1", len);
|
||||
break;
|
||||
case 2:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2012");
|
||||
strlcpy(s, "Windows Server 2012", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 8");
|
||||
strlcpy(s, "Windows 8", len);
|
||||
break;
|
||||
case 1:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2008 R2");
|
||||
strlcpy(s, "Windows Server 2008 R2", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 7");
|
||||
strlcpy(s, "Windows 7", len);
|
||||
break;
|
||||
case 0:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2008");
|
||||
strlcpy(s, "Windows Server 2008", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows Vista");
|
||||
strlcpy(s, "Windows Vista", len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
switch (vi.dwMinorVersion)
|
||||
{
|
||||
case 2:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2003");
|
||||
else
|
||||
{
|
||||
/* Yes, XP Pro x64 is a higher version number than XP x86 */
|
||||
if (string_is_equal(arch, "x64"))
|
||||
strcpy_literal(s, "Windows XP");
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
strcpy_literal(s, "Windows XP");
|
||||
break;
|
||||
case 0:
|
||||
strcpy_literal(s, "Windows 2000");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch (vi.dwMinorVersion)
|
||||
{
|
||||
case 0:
|
||||
if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
||||
strcpy_literal(s, "Windows 95");
|
||||
else if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
strcpy_literal(s, "Windows NT 4.0");
|
||||
else
|
||||
strcpy_literal(s, "Unknown");
|
||||
break;
|
||||
case 90:
|
||||
strcpy_literal(s, "Windows ME");
|
||||
break;
|
||||
case 10:
|
||||
strcpy_literal(s, "Windows 98");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
snprintf(s, len, "Windows %i.%i", *major, *minor);
|
||||
break;
|
||||
|
@ -330,38 +330,38 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor)
|
||||
{
|
||||
case 10:
|
||||
if (atoi(buildStr) >= 21996)
|
||||
strcpy_literal(s, "Windows 11");
|
||||
strlcpy(s, "Windows 11", len);
|
||||
else if (server)
|
||||
strcpy_literal(s, "Windows Server 2016");
|
||||
strlcpy(s, "Windows Server 2016", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 10");
|
||||
strlcpy(s, "Windows 10", len);
|
||||
break;
|
||||
case 6:
|
||||
switch (vi.dwMinorVersion)
|
||||
{
|
||||
case 3:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2012 R2");
|
||||
strlcpy(s, "Windows Server 2012 R2", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 8.1");
|
||||
strlcpy(s, "Windows 8.1", len);
|
||||
break;
|
||||
case 2:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2012");
|
||||
strlcpy(s, "Windows Server 2012", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 8");
|
||||
strlcpy(s, "Windows 8", len);
|
||||
break;
|
||||
case 1:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2008 R2");
|
||||
strlcpy(s, "Windows Server 2008 R2", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows 7");
|
||||
strlcpy(s, "Windows 7", len);
|
||||
break;
|
||||
case 0:
|
||||
if (server)
|
||||
strcpy_literal(s, "Windows Server 2008");
|
||||
strlcpy(s, "Windows Server 2008", len);
|
||||
else
|
||||
strcpy_literal(s, "Windows Vista");
|
||||
strlcpy(s, "Windows Vista", len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -373,7 +373,7 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor)
|
||||
case 2:
|
||||
if (server)
|
||||
{
|
||||
strcpy_literal(s, "Windows Server 2003");
|
||||
strlcpy(s, "Windows Server 2003", len);
|
||||
if (GetSystemMetrics(SM_SERVERR2))
|
||||
strlcat(s, " R2", len);
|
||||
}
|
||||
@ -381,14 +381,14 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor)
|
||||
{
|
||||
/* Yes, XP Pro x64 is a higher version number than XP x86 */
|
||||
if (string_is_equal(arch, "x64"))
|
||||
strcpy_literal(s, "Windows XP");
|
||||
strlcpy(s, "Windows XP", len);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
strcpy_literal(s, "Windows XP");
|
||||
strlcpy(s, "Windows XP", len);
|
||||
break;
|
||||
case 0:
|
||||
strcpy_literal(s, "Windows 2000");
|
||||
strlcpy(s, "Windows 2000", len);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -397,17 +397,17 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor)
|
||||
{
|
||||
case 0:
|
||||
if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
||||
strcpy_literal(s, "Windows 95");
|
||||
strlcpy(s, "Windows 95", len);
|
||||
else if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
strcpy_literal(s, "Windows NT 4.0");
|
||||
strlcpy(s, "Windows NT 4.0", len);
|
||||
else
|
||||
strcpy_literal(s, "Unknown");
|
||||
strlcpy(s, "Unknown", len);
|
||||
break;
|
||||
case 90:
|
||||
strcpy_literal(s, "Windows ME");
|
||||
strlcpy(s, "Windows ME", len);
|
||||
break;
|
||||
case 10:
|
||||
strcpy_literal(s, "Windows 98");
|
||||
strlcpy(s, "Windows 98", len);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -180,59 +180,98 @@ bool frontend_driver_get_core_extension(char *s, size_t len)
|
||||
#ifdef HAVE_DYNAMIC
|
||||
|
||||
#ifdef _WIN32
|
||||
strcpy_literal(s, "dll");
|
||||
s[0] = 'd';
|
||||
s[1] = 'l';
|
||||
s[2] = 'l';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
strcpy_literal(s, "dylib");
|
||||
s[0] = 'd';
|
||||
s[1] = 'y';
|
||||
s[2] = 'l';
|
||||
s[3] = 'i';
|
||||
s[4] = 'b';
|
||||
s[5] = '\0';
|
||||
return true;
|
||||
#else
|
||||
strcpy_literal(s, "so");
|
||||
s[0] = 's';
|
||||
s[1] = 'o';
|
||||
s[2] = '\0';
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined(PSP)
|
||||
strcpy_literal(s, "pbp");
|
||||
s[0] = 'p';
|
||||
s[1] = 'b';
|
||||
s[2] = 'p';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(ORBIS)
|
||||
#elif defined(ORBIS) || defined(VITA) || defined(__PS3__)
|
||||
strlcpy(s, "self|bin", len);
|
||||
return true;
|
||||
#elif defined(VITA)
|
||||
strcpy_literal(s, "self|bin");
|
||||
return true;
|
||||
#elif defined(PS2)
|
||||
strcpy_literal(s, "elf");
|
||||
return true;
|
||||
#elif defined(__PS3__)
|
||||
strcpy_literal(s, "self|bin");
|
||||
s[0] = 'e';
|
||||
s[1] = 'l';
|
||||
s[2] = 'f';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(_XBOX1)
|
||||
strcpy_literal(s, "xbe");
|
||||
s[0] = 'x';
|
||||
s[1] = 'b';
|
||||
s[2] = 'e';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(_XBOX360)
|
||||
strcpy_literal(s, "xex");
|
||||
s[0] = 'x';
|
||||
s[1] = 'e';
|
||||
s[2] = 'x';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(GEKKO)
|
||||
strcpy_literal(s, "dol");
|
||||
s[0] = 'd';
|
||||
s[1] = 'o';
|
||||
s[2] = 'l';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(HW_WUP)
|
||||
strcpy_literal(s, "rpx|elf");
|
||||
strlcpy(s, "rpx|elf", len);
|
||||
return true;
|
||||
#elif defined(__linux__)
|
||||
strcpy_literal(s, "elf");
|
||||
s[0] = 'e';
|
||||
s[1] = 'l';
|
||||
s[2] = 'f';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(HAVE_LIBNX)
|
||||
strcpy_literal(s, "nro");
|
||||
s[0] = 'n';
|
||||
s[1] = 'r';
|
||||
s[2] = 'o';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(DJGPP)
|
||||
strcpy_literal(s, "exe");
|
||||
s[0] = 'e';
|
||||
s[1] = 'x';
|
||||
s[2] = 'e';
|
||||
s[3] = '\0';
|
||||
return true;
|
||||
#elif defined(_3DS)
|
||||
if (envIsHomebrew())
|
||||
strcpy_literal(s, "3dsx");
|
||||
{
|
||||
s[0] = '3';
|
||||
s[1] = 'd';
|
||||
s[2] = 's';
|
||||
s[3] = 'x';
|
||||
s[4] = '\0';
|
||||
}
|
||||
else
|
||||
strcpy_literal(s, "cia");
|
||||
{
|
||||
s[0] = 'c';
|
||||
s[1] = 'i';
|
||||
s[2] = 'a';
|
||||
s[3] = '\0';
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@ -248,40 +287,40 @@ bool frontend_driver_get_salamander_basename(char *s, size_t len)
|
||||
#else
|
||||
|
||||
#if defined(PSP)
|
||||
strcpy_literal(s, "EBOOT.PBP");
|
||||
strlcpy(s, "EBOOT.PBP", len);
|
||||
return true;
|
||||
#elif defined(ORBIS)
|
||||
strlcpy(s, "eboot.bin", len);
|
||||
return true;
|
||||
#elif defined(VITA)
|
||||
strcpy_literal(s, "eboot.bin");
|
||||
strlcpy(s, "eboot.bin", len);
|
||||
return true;
|
||||
#elif defined(PS2)
|
||||
strcpy_literal(s, "raboot.elf");
|
||||
strlcpy(s, "raboot.elf", len);
|
||||
return true;
|
||||
#elif defined(__PSL1GHT__) || defined(__PS3__)
|
||||
strcpy_literal(s, "EBOOT.BIN");
|
||||
strlcpy(s, "EBOOT.BIN", len);
|
||||
return true;
|
||||
#elif defined(_XBOX1)
|
||||
strcpy_literal(s, "default.xbe");
|
||||
strlcpy(s, "default.xbe", len);
|
||||
return true;
|
||||
#elif defined(_XBOX360)
|
||||
strcpy_literal(s, "default.xex");
|
||||
strlcpy(s, "default.xex", len);
|
||||
return true;
|
||||
#elif defined(HW_RVL)
|
||||
strcpy_literal(s, "boot.dol");
|
||||
strlcpy(s, "boot.dol", len);
|
||||
return true;
|
||||
#elif defined(HW_WUP)
|
||||
strcpy_literal(s, "retroarch.rpx");
|
||||
strlcpy(s, "retroarch.rpx", len);
|
||||
return true;
|
||||
#elif defined(_3DS)
|
||||
strcpy_literal(s, "retroarch.core");
|
||||
strlcpy(s, "retroarch.core", len);
|
||||
return true;
|
||||
#elif defined(DJGPP)
|
||||
strcpy_literal(s, "retrodos.exe");
|
||||
strlcpy(s, "retrodos.exe", len);
|
||||
return true;
|
||||
#elif defined(SWITCH)
|
||||
strcpy_literal(s, "retroarch_switch.nro");
|
||||
strlcpy(s, "retroarch_switch.nro", len);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@ -412,7 +451,7 @@ enum frontend_architecture frontend_driver_get_cpu_architecture(void)
|
||||
}
|
||||
|
||||
const void *frontend_driver_get_cpu_architecture_str(
|
||||
char *architecture, size_t size)
|
||||
char *s, size_t len)
|
||||
{
|
||||
frontend_state_t *frontend_st = &frontend_driver_st;
|
||||
frontend_ctx_driver_t *frontend = frontend_st->current_frontend_ctx;
|
||||
@ -421,32 +460,67 @@ const void *frontend_driver_get_cpu_architecture_str(
|
||||
switch (arch)
|
||||
{
|
||||
case FRONTEND_ARCH_X86:
|
||||
strcpy_literal(architecture, "x86");
|
||||
s[0] = 'x';
|
||||
s[1] = '8';
|
||||
s[2] = '6';
|
||||
s[3] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_X86_64:
|
||||
strcpy_literal(architecture, "x64");
|
||||
s[0] = 'x';
|
||||
s[1] = '6';
|
||||
s[2] = '4';
|
||||
s[3] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_PPC:
|
||||
strcpy_literal(architecture, "PPC");
|
||||
s[0] = 'P';
|
||||
s[1] = 'P';
|
||||
s[2] = 'C';
|
||||
s[3] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_ARM:
|
||||
strcpy_literal(architecture, "ARM");
|
||||
s[0] = 'A';
|
||||
s[1] = 'R';
|
||||
s[2] = 'M';
|
||||
s[3] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_ARMV7:
|
||||
strcpy_literal(architecture, "ARMv7");
|
||||
s[0] = 'A';
|
||||
s[1] = 'R';
|
||||
s[2] = 'M';
|
||||
s[3] = 'v';
|
||||
s[4] = '7';
|
||||
s[5] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_ARMV8:
|
||||
strcpy_literal(architecture, "ARMv8");
|
||||
s[0] = 'A';
|
||||
s[1] = 'R';
|
||||
s[2] = 'M';
|
||||
s[3] = 'v';
|
||||
s[4] = '8';
|
||||
s[5] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_MIPS:
|
||||
strcpy_literal(architecture, "MIPS");
|
||||
s[0] = 'M';
|
||||
s[1] = 'I';
|
||||
s[2] = 'P';
|
||||
s[3] = 'S';
|
||||
s[4] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_TILE:
|
||||
strcpy_literal(architecture, "Tilera");
|
||||
s[0] = 'T';
|
||||
s[1] = 'i';
|
||||
s[2] = 'l';
|
||||
s[3] = 'e';
|
||||
s[4] = 'r';
|
||||
s[5] = 'a';
|
||||
s[6] = '\0';
|
||||
break;
|
||||
case FRONTEND_ARCH_NONE:
|
||||
default:
|
||||
strcpy_literal(architecture, "N/A");
|
||||
s[0] = 'N';
|
||||
s[1] = '/';
|
||||
s[2] = 'A';
|
||||
s[3] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1167,9 +1167,9 @@ static void gfx_widgets_draw_task_msg(
|
||||
float *msg_queue_current_background;
|
||||
float *msg_queue_current_bar;
|
||||
|
||||
char task_percentage[256];
|
||||
bool draw_msg_new = false;
|
||||
unsigned task_percentage_offset = 0;
|
||||
char task_percentage[256] = {0};
|
||||
|
||||
if (msg->msg_new)
|
||||
draw_msg_new = !string_is_equal(msg->msg_new, msg->msg);
|
||||
@ -1182,13 +1182,19 @@ static void gfx_widgets_draw_task_msg(
|
||||
if (msg->task_finished)
|
||||
{
|
||||
if (msg->task_error)
|
||||
strcpy_literal(task_percentage, "Task failed");
|
||||
strlcpy(task_percentage, "Task failed", sizeof(task_percentage));
|
||||
else
|
||||
strcpy_literal(task_percentage, " ");
|
||||
{
|
||||
task_percentage[0] = ' ';
|
||||
task_percentage[1] = '\0';
|
||||
}
|
||||
}
|
||||
else if (msg->task_progress >= 0 && msg->task_progress <= 100)
|
||||
{
|
||||
task_percentage[0] = '\0';
|
||||
snprintf(task_percentage, sizeof(task_percentage),
|
||||
"%i%%", msg->task_progress);
|
||||
}
|
||||
|
||||
rect_width = p_dispwidget->simple_widget_padding
|
||||
+ msg->width
|
||||
|
@ -434,7 +434,8 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
sizeof(state->system_name));
|
||||
/* Otherwise, just use 'RetroArch' as a fallback */
|
||||
else
|
||||
strcpy_literal(state->system_name, "RetroArch");
|
||||
strlcpy(state->system_name, "RetroArch",
|
||||
sizeof(state->system_name));
|
||||
}
|
||||
|
||||
/* > Content name has been determined
|
||||
|
@ -344,9 +344,6 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
{
|
||||
const char *title_pos = NULL;
|
||||
const char *serial_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
/* All discs currently in Redump for MCD start with SEGADISCSYSTEM. There are other strings mentioned elsewhere online,
|
||||
* but I have not seen any real examples of them. */
|
||||
@ -362,7 +359,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title[0] = 'N';
|
||||
info->title[1] = '/';
|
||||
info->title[2] = 'A';
|
||||
info->title[3] = '\0';
|
||||
}
|
||||
|
||||
serial_pos = buf + offset + 0x183;
|
||||
|
||||
@ -372,7 +374,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->serial, sizeof(info->serial));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->serial, "N/A");
|
||||
{
|
||||
info->serial[0] = 'N';
|
||||
info->serial[1] = '/';
|
||||
info->serial[2] = 'A';
|
||||
info->serial[3] = '\0';
|
||||
}
|
||||
}
|
||||
else if (!memcmp(buf + offset, "SEGA SEGASATURN",
|
||||
STRLEN_CONST("SEGA SEGASATURN")))
|
||||
@ -381,9 +388,6 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
const char *serial_pos = NULL;
|
||||
const char *version_pos = NULL;
|
||||
const char *release_date_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
info->system_id = MEDIA_CD_SYSTEM_SATURN;
|
||||
|
||||
@ -397,7 +401,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title [0] = 'N';
|
||||
info->title [1] = '/';
|
||||
info->title [2] = 'A';
|
||||
info->title [3] = '\0';
|
||||
}
|
||||
|
||||
serial_pos = buf + offset + 0x20;
|
||||
|
||||
@ -407,7 +416,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->serial, sizeof(info->serial));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->serial, "N/A");
|
||||
{
|
||||
info->serial[0] = 'N';
|
||||
info->serial[1] = '/';
|
||||
info->serial[2] = 'A';
|
||||
info->serial[3] = '\0';
|
||||
}
|
||||
|
||||
version_pos = buf + offset + 0x2a;
|
||||
|
||||
@ -417,7 +431,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->version, sizeof(info->version));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->version, "N/A");
|
||||
{
|
||||
info->version[0] = 'N';
|
||||
info->version[1] = '/';
|
||||
info->version[2] = 'A';
|
||||
info->version[3] = '\0';
|
||||
}
|
||||
|
||||
release_date_pos = buf + offset + 0x30;
|
||||
|
||||
@ -427,7 +446,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->release_date, sizeof(info->release_date));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->release_date, "N/A");
|
||||
{
|
||||
info->release_date[0] = 'N';
|
||||
info->release_date[1] = '/';
|
||||
info->release_date[2] = 'A';
|
||||
info->release_date[3] = '\0';
|
||||
}
|
||||
}
|
||||
else if (!memcmp(buf + offset, "SEGA SEGAKATANA", STRLEN_CONST("SEGA SEGAKATANA")))
|
||||
{
|
||||
@ -435,9 +459,6 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
const char *serial_pos = NULL;
|
||||
const char *version_pos = NULL;
|
||||
const char *release_date_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
info->system_id = MEDIA_CD_SYSTEM_DREAMCAST;
|
||||
|
||||
@ -451,7 +472,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title [0] = 'N';
|
||||
info->title [1] = '/';
|
||||
info->title [2] = 'A';
|
||||
info->title [3] = '\0';
|
||||
}
|
||||
|
||||
serial_pos = buf + offset + 0x40;
|
||||
|
||||
@ -461,7 +487,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->serial, sizeof(info->serial));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->serial, "N/A");
|
||||
{
|
||||
info->serial [0] = 'N';
|
||||
info->serial [1] = '/';
|
||||
info->serial [2] = 'A';
|
||||
info->serial [3] = '\0';
|
||||
}
|
||||
|
||||
version_pos = buf + offset + 0x4a;
|
||||
|
||||
@ -471,7 +502,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->version, sizeof(info->version));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->version, "N/A");
|
||||
{
|
||||
info->version [0] = 'N';
|
||||
info->version [1] = '/';
|
||||
info->version [2] = 'A';
|
||||
info->version [3] = '\0';
|
||||
}
|
||||
|
||||
release_date_pos = buf + offset + 0x50;
|
||||
|
||||
@ -481,15 +517,17 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->release_date, sizeof(info->release_date));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->release_date, "N/A");
|
||||
{
|
||||
info->release_date[0] = 'N';
|
||||
info->release_date[1] = '/';
|
||||
info->release_date[2] = 'A';
|
||||
info->release_date[3] = '\0';
|
||||
}
|
||||
}
|
||||
/* Primary Volume Descriptor fields of ISO9660 */
|
||||
else if (!memcmp(buf + offset + (16 * sector_size), "\1CD001\1\0PLAYSTATION", 19))
|
||||
{
|
||||
const char *title_pos = NULL;
|
||||
#if 0
|
||||
bool title_found = false;
|
||||
#endif
|
||||
|
||||
info->system_id = MEDIA_CD_SYSTEM_PSX;
|
||||
|
||||
@ -503,7 +541,12 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
media_zero_trailing_spaces(info->title, sizeof(info->title));
|
||||
}
|
||||
else
|
||||
strcpy_literal(info->title, "N/A");
|
||||
{
|
||||
info->title [0] = 'N';
|
||||
info->title [1] = '/';
|
||||
info->title [2] = 'A';
|
||||
info->title [3] = '\0';
|
||||
}
|
||||
}
|
||||
else if (!memcmp(buf + offset, "\x01\x5a\x5a\x5a\x5a\x5a\x01\x00\x00\x00\x00\x00", 12))
|
||||
{
|
||||
|
@ -446,7 +446,10 @@ static struct buffer query_parse_string(
|
||||
|
||||
if (!value->val.string.buff)
|
||||
{
|
||||
strcpy_literal(s, "Out of memory");
|
||||
s[0] = 'O';
|
||||
s[1] = 'O';
|
||||
s[2] = 'M';
|
||||
s[3] = '\0';
|
||||
*error = s;
|
||||
}
|
||||
else if (is_binstr)
|
||||
@ -717,7 +720,10 @@ static struct buffer query_parse_method_call(
|
||||
|
||||
if (!invocation->argv)
|
||||
{
|
||||
strcpy_literal(s, "Out of memory");
|
||||
s[0] = 'O';
|
||||
s[1] = 'O';
|
||||
s[2] = 'M';
|
||||
s[3] = '\0';
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
@ -891,7 +897,10 @@ static struct buffer query_parse_table(
|
||||
|
||||
if (!invocation->argv)
|
||||
{
|
||||
strcpy_literal(s, "Out of memory");
|
||||
s[0] = 'O';
|
||||
s[1] = 'O';
|
||||
s[2] = 'M';
|
||||
s[3] = '\0';
|
||||
*error = s;
|
||||
goto clean;
|
||||
}
|
||||
|
@ -5064,7 +5064,7 @@ static int action_ok_download_generic(const char *path,
|
||||
path = "shaders_cg.zip";
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CB_CORE_THUMBNAILS_DOWNLOAD:
|
||||
strcpy_literal(s, "http://thumbnailpacks.libretro.com");
|
||||
strlcpy(s, "http://thumbnailpacks.libretro.com", sizeof(s));
|
||||
break;
|
||||
default:
|
||||
strlcpy(s, network_buildbot_url, sizeof(s));
|
||||
@ -5465,8 +5465,8 @@ static int action_ok_add_to_favorites(const char *path,
|
||||
|
||||
if (string_is_empty(core_path) || string_is_empty(core_name))
|
||||
{
|
||||
strcpy_literal(core_path, FILE_PATH_DETECT);
|
||||
strcpy_literal(core_name, FILE_PATH_DETECT);
|
||||
strlcpy(core_path, FILE_PATH_DETECT, sizeof(core_path));
|
||||
strlcpy(core_name, FILE_PATH_DETECT, sizeof(core_name));
|
||||
}
|
||||
|
||||
/* > crc32 + db_name */
|
||||
|
@ -3883,7 +3883,7 @@ bool menu_shader_manager_operate_auto_preset(
|
||||
switch (type)
|
||||
{
|
||||
case SHADER_PRESET_GLOBAL:
|
||||
strcpy_literal(file, "global");
|
||||
strlcpy(file, "global", sizeof(file));
|
||||
break;
|
||||
case SHADER_PRESET_CORE:
|
||||
fill_pathname_join_special(file, core_name, core_name, sizeof(file));
|
||||
|
@ -1233,7 +1233,10 @@ int setting_generic_action_start_default(rarch_setting_t *setting)
|
||||
static void setting_get_string_representation_default(rarch_setting_t *setting,
|
||||
char *s, size_t len)
|
||||
{
|
||||
strcpy_literal(s, "...");
|
||||
s[0] = '.';
|
||||
s[1] = '.';
|
||||
s[2] = '.';
|
||||
s[3] = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3015,13 +3018,13 @@ static void setting_get_string_representation_streaming_mode(
|
||||
switch (*setting->value.target.unsigned_integer)
|
||||
{
|
||||
case STREAMING_MODE_TWITCH:
|
||||
strcpy_literal(s, "Twitch");
|
||||
strlcpy(s, "Twitch", len);
|
||||
break;
|
||||
case STREAMING_MODE_YOUTUBE:
|
||||
strcpy_literal(s, "YouTube");
|
||||
strlcpy(s, "YouTube", len);
|
||||
break;
|
||||
case STREAMING_MODE_FACEBOOK:
|
||||
strcpy_literal(s, "Facebook Gaming");
|
||||
strlcpy(s, "Facebook Gaming", len);
|
||||
break;
|
||||
case STREAMING_MODE_LOCAL:
|
||||
strlcpy(s, "Local", len);
|
||||
@ -3147,12 +3150,18 @@ static void setting_get_string_representation_cheevos_password(
|
||||
return;
|
||||
|
||||
if (!string_is_empty(setting->value.target.string))
|
||||
strcpy_literal(s, "********");
|
||||
{
|
||||
s[0] = s[1] = s[2] = s[3] = s[4] = s[5] = s[6] = s[7] = '*';
|
||||
s[8] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (settings->arrays.cheevos_token[0])
|
||||
strcpy_literal(s, "********");
|
||||
{
|
||||
s[0] = s[1] = s[2] = s[3] = s[4] = s[5] = s[6] = s[7] = '*';
|
||||
s[8] = '\0';
|
||||
}
|
||||
else
|
||||
*setting->value.target.string = '\0';
|
||||
}
|
||||
@ -3173,13 +3182,13 @@ static void setting_get_string_representation_uint_keyboard_gamepad_mapping_type
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE), len);
|
||||
break;
|
||||
case 1:
|
||||
strcpy_literal(s, "iPega PG-9017");
|
||||
strlcpy(s, "iPega PG-9017", len);
|
||||
break;
|
||||
case 2:
|
||||
strcpy_literal(s, "8-bitty");
|
||||
strlcpy(s, "8-bitty", len);
|
||||
break;
|
||||
case 3:
|
||||
strcpy_literal(s, "SNES30 8bitdo");
|
||||
strlcpy(s, "SNES30 8bitdo", len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3664,13 +3673,13 @@ static void setting_get_string_representation_uint_menu_timedate_date_separator(
|
||||
switch (*setting->value.target.unsigned_integer)
|
||||
{
|
||||
case MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN:
|
||||
strcpy_literal(s, "'-'");
|
||||
strlcpy(s, "'-'", len);
|
||||
break;
|
||||
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
|
||||
strcpy_literal(s, "'/'");
|
||||
strlcpy(s, "'/'", len);
|
||||
break;
|
||||
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
|
||||
strcpy_literal(s, "'.'");
|
||||
strlcpy(s, "'.'", len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4283,13 +4292,13 @@ static void setting_get_string_representation_uint_menu_xmb_animation_horizontal
|
||||
switch (*setting->value.target.unsigned_integer)
|
||||
{
|
||||
case 0:
|
||||
strcpy_literal(s, "Easing Out Quad");
|
||||
strlcpy(s, "Easing Out Quad", len);
|
||||
break;
|
||||
case 1:
|
||||
strcpy_literal(s, "Easing In Sine");
|
||||
strlcpy(s, "Easing In Sine", len);
|
||||
break;
|
||||
case 2:
|
||||
strcpy_literal(s, "Easing Out Bounce");
|
||||
strlcpy(s, "Easing Out Bounce", len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4394,13 +4403,13 @@ static void setting_get_string_representation_uint_xmb_layout(
|
||||
switch (*setting->value.target.unsigned_integer)
|
||||
{
|
||||
case 0:
|
||||
strcpy_literal(s, "Auto");
|
||||
strlcpy(s, "Auto", len);
|
||||
break;
|
||||
case 1:
|
||||
strcpy_literal(s, "Console");
|
||||
strlcpy(s, "Console", len);
|
||||
break;
|
||||
case 2:
|
||||
strcpy_literal(s, "Handheld");
|
||||
strlcpy(s, "Handheld", len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -480,8 +480,14 @@ void discord_init(const char *discord_app_id, char *args)
|
||||
strlcat(command, args, sizeof(command));
|
||||
}
|
||||
#else
|
||||
strcpy_literal(command, "sh -c ");
|
||||
strlcat(command, args, sizeof(command));
|
||||
command[0] = 's';
|
||||
command[1] = 'h';
|
||||
command[2] = ' ';
|
||||
command[3] = '-';
|
||||
command[4] = 'c';
|
||||
command[5] = ' ';
|
||||
command[6] = '\0';
|
||||
strlcat(command, args, sizeof(command));
|
||||
#endif
|
||||
Discord_Register(discord_app_id, command);
|
||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||
|
Loading…
Reference in New Issue
Block a user