mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Cut down on some snprintf calls
This commit is contained in:
parent
c022e4e624
commit
e279592ce6
18
command.c
18
command.c
@ -413,7 +413,7 @@ bool command_get_config_param(command_t *cmd, const char* arg)
|
|||||||
(long long)(input_st->bsv_movie_state_handle->identifier),
|
(long long)(input_st->bsv_movie_state_handle->identifier),
|
||||||
input_st->bsv_movie_state.flags);
|
input_st->bsv_movie_state.flags);
|
||||||
else
|
else
|
||||||
snprintf(value_dynamic, sizeof(value_dynamic), "0 0");
|
strlcpy(value_dynamic, "0 0", sizeof(value_dynamic));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* TODO: query any string */
|
/* TODO: query any string */
|
||||||
@ -919,7 +919,6 @@ bool command_get_status(command_t *cmd, const char* arg)
|
|||||||
{
|
{
|
||||||
/* add some content info */
|
/* add some content info */
|
||||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||||
const char *status = "PLAYING";
|
|
||||||
const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */
|
const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */
|
||||||
int content_crc32 = content_get_crc();
|
int content_crc32 = content_get_crc();
|
||||||
const char* system_id = NULL;
|
const char* system_id = NULL;
|
||||||
@ -929,15 +928,20 @@ bool command_get_status(command_t *cmd, const char* arg)
|
|||||||
|
|
||||||
core_info_get_current_core(&core_info);
|
core_info_get_current_core(&core_info);
|
||||||
|
|
||||||
if (runloop_st->flags & RUNLOOP_FLAG_PAUSED)
|
|
||||||
status = "PAUSED";
|
|
||||||
if (core_info)
|
if (core_info)
|
||||||
system_id = core_info->system_id;
|
system_id = core_info->system_id;
|
||||||
if (!system_id)
|
if (!system_id)
|
||||||
system_id = runloop_st->system.info.library_name;
|
system_id = runloop_st->system.info.library_name;
|
||||||
|
_len = strlcpy(reply, "GET_STATUS ", sizeof(reply));
|
||||||
_len = snprintf(reply, sizeof(reply), "GET_STATUS %s %s,%s,crc32=%x\n",
|
if (runloop_st->flags & RUNLOOP_FLAG_PAUSED)
|
||||||
status, system_id, content_name, content_crc32);
|
_len += strlcpy(reply + _len, "PAUSED", sizeof(reply) - _len);
|
||||||
|
else
|
||||||
|
_len += strlcpy(reply + _len, "PLAYING", sizeof(reply) - _len);
|
||||||
|
_len += strlcpy(reply + _len, " ", sizeof(reply) - _len);
|
||||||
|
_len += strlcpy(reply + _len, system_id, sizeof(reply) - _len);
|
||||||
|
_len += strlcpy(reply + _len, ",", sizeof(reply) - _len);
|
||||||
|
_len += strlcpy(reply + _len, content_name, sizeof(reply) - _len);
|
||||||
|
_len += snprintf(reply + _len, sizeof(reply) - _len, ",crc32=%x\n", content_crc32);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_len = strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
|
_len = strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
|
||||||
|
@ -572,8 +572,16 @@ static bool netplay_lan_ad_server(netplay_t *netplay)
|
|||||||
frontend_driver_get_cpu_architecture_str(frontend_architecture_tmp,
|
frontend_driver_get_cpu_architecture_str(frontend_architecture_tmp,
|
||||||
sizeof(frontend_architecture_tmp));
|
sizeof(frontend_architecture_tmp));
|
||||||
if (frontend_drv)
|
if (frontend_drv)
|
||||||
snprintf(ad_packet_buffer.frontend, sizeof(ad_packet_buffer.frontend),
|
{
|
||||||
"%s %s", frontend_drv->ident, frontend_architecture_tmp);
|
size_t _len = strlcpy(ad_packet_buffer.frontend, frontend_drv->ident,
|
||||||
|
sizeof(ad_packet_buffer.frontend));
|
||||||
|
_len += strlcpy(ad_packet_buffer.frontend + _len,
|
||||||
|
" ",
|
||||||
|
sizeof(ad_packet_buffer.frontend) - _len);
|
||||||
|
strlcpy(ad_packet_buffer.frontend + _len,
|
||||||
|
frontend_architecture_tmp,
|
||||||
|
sizeof(ad_packet_buffer.frontend) - _len);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
strlcpy(ad_packet_buffer.frontend, "N/A",
|
strlcpy(ad_packet_buffer.frontend, "N/A",
|
||||||
sizeof(ad_packet_buffer.frontend));
|
sizeof(ad_packet_buffer.frontend));
|
||||||
@ -1152,9 +1160,12 @@ static void netplay_handshake_ready(netplay_t *netplay,
|
|||||||
netplay->force_send_savestate = true;
|
netplay->force_send_savestate = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(msg, sizeof(msg), "%s: \"%s\"",
|
{
|
||||||
msg_hash_to_str(MSG_CONNECTED_TO),
|
size_t _len = strlcpy(msg, msg_hash_to_str(MSG_CONNECTED_TO),
|
||||||
connection->nick);
|
sizeof(msg));
|
||||||
|
snprintf(msg + _len, sizeof(msg) - _len, ": \"%s\"",
|
||||||
|
connection->nick);
|
||||||
|
}
|
||||||
|
|
||||||
RARCH_LOG("[Netplay] %s\n", msg);
|
RARCH_LOG("[Netplay] %s\n", msg);
|
||||||
/* Useful notification to the client in figuring out
|
/* Useful notification to the client in figuring out
|
||||||
@ -4206,8 +4217,8 @@ static void netplay_hangup(netplay_t *netplay,
|
|||||||
|
|
||||||
if (netplay->modus != NETPLAY_MODUS_CORE_PACKET_INTERFACE)
|
if (netplay->modus != NETPLAY_MODUS_CORE_PACKET_INTERFACE)
|
||||||
{
|
{
|
||||||
/* This special mode keeps the connection object
|
/* This special mode keeps the connection object
|
||||||
alive long enough to send the disconnection
|
alive long enough to send the disconnection
|
||||||
message at the correct time */
|
message at the correct time */
|
||||||
connection->mode = NETPLAY_CONNECTION_DELAYED_DISCONNECT;
|
connection->mode = NETPLAY_CONNECTION_DELAYED_DISCONNECT;
|
||||||
connection->delay_frame = netplay->read_frame_count[client_num];
|
connection->delay_frame = netplay->read_frame_count[client_num];
|
||||||
|
@ -122,8 +122,9 @@ static void task_database_scan_console_output(const char *label, const char *db_
|
|||||||
unsigned green = FOREGROUND_GREEN;
|
unsigned green = FOREGROUND_GREEN;
|
||||||
unsigned yellow = FOREGROUND_RED | FOREGROUND_GREEN;
|
unsigned yellow = FOREGROUND_RED | FOREGROUND_GREEN;
|
||||||
unsigned reset = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
unsigned reset = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||||
|
size_t _len = strlcpy(string, " ", sizeof(string));
|
||||||
snprintf(string, sizeof(string), " %s ", prefix);
|
_len += strlcpy(string + _len, prefix, sizeof(string) - _len);
|
||||||
|
strlcpy(string + _len, " ", sizeof(string) - _len);
|
||||||
SetConsoleTextAttribute(con, (add) ? green : (db_name) ? yellow : red);
|
SetConsoleTextAttribute(con, (add) ? green : (db_name) ? yellow : red);
|
||||||
WriteConsole(con, string, strlen(string), NULL, NULL);
|
WriteConsole(con, string, strlen(string), NULL, NULL);
|
||||||
SetConsoleTextAttribute(con, reset);
|
SetConsoleTextAttribute(con, reset);
|
||||||
@ -135,14 +136,23 @@ static void task_database_scan_console_output(const char *label, const char *db_
|
|||||||
const char *green = "\x1B[32m";
|
const char *green = "\x1B[32m";
|
||||||
const char *yellow = "\x1B[33m";
|
const char *yellow = "\x1B[33m";
|
||||||
const char *reset = "\x1B[0m";
|
const char *reset = "\x1B[0m";
|
||||||
|
size_t _len = 0;
|
||||||
snprintf(string, sizeof(string), "%s %s %s", (add) ? green : (db_name) ? yellow : red, prefix, reset);
|
if (add)
|
||||||
|
_len += strlcpy(string + _len, green, sizeof(string) - _len);
|
||||||
|
else
|
||||||
|
_len += strlcpy(string + _len, (db_name) ? yellow : red, sizeof(string) - _len);
|
||||||
|
_len += strlcpy(string + _len, " ", sizeof(string) - _len);
|
||||||
|
_len += strlcpy(string + _len, prefix, sizeof(string) - _len);
|
||||||
|
_len += strlcpy(string + _len, " ", sizeof(string) - _len);
|
||||||
|
strlcpy(string + _len, reset, sizeof(string) - _len);
|
||||||
fputs(string, stdout);
|
fputs(string, stdout);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(string, sizeof(string), " %s ", prefix);
|
size_t _len = strlcpy(string, " ", sizeof(string));
|
||||||
|
_len += strlcpy(string + _len, prefix, sizeof(string) - _len);
|
||||||
|
strlcpy(string + _len, " ", sizeof(string) - _len);
|
||||||
fputs(string, stdout);
|
fputs(string, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user