* Start getting rid of strncpy

* steam.c - cleanups:
  * Use string_to_lower from libretro-common/stdstring.c instead of
    its own version
  * Some stylistic changes
  * Rewrite strncpy calls into strlcpy/strlcat/manual assignment
  * Make it C89 compliant
  * Some unused variables
This commit is contained in:
LibretroAdmin 2022-08-25 06:51:39 +02:00
parent 8017410098
commit 88187e7ef2
4 changed files with 237 additions and 167 deletions

View File

@ -271,7 +271,7 @@ static int mount_hdd_partition(void)
if (bootDeviceID == BOOT_DEVICE_HDD || bootDeviceID == BOOT_DEVICE_HDD0) if (bootDeviceID == BOOT_DEVICE_HDD || bootDeviceID == BOOT_DEVICE_HDD0)
{ {
/* If we're booting from HDD, we must update the cwd variable and add : to the mount point */ /* If we're booting from HDD, we must update the cwd variable and add : to the mount point */
strncpy(cwd, new_cwd, sizeof(cwd)); strlcpy(cwd, new_cwd, sizeof(cwd));
strlcat(mountPoint, ":", sizeof(mountPoint)); strlcat(mountPoint, ":", sizeof(mountPoint));
} }
else else

View File

@ -1490,14 +1490,13 @@ static bool wiiu_gfx_set_shader(void *data,
for (i = 0; i < wiiu->shader_preset->passes; i++) for (i = 0; i < wiiu->shader_preset->passes; i++)
{ {
unsigned j; unsigned j;
char *ptr;
char gfdpath[PATH_MAX_LENGTH]; char gfdpath[PATH_MAX_LENGTH];
struct video_shader_pass *pass = &wiiu->shader_preset->pass[i]; struct video_shader_pass *pass = &wiiu->shader_preset->pass[i];
strncpy(gfdpath, pass->source.path, PATH_MAX_LENGTH); strlcpy(gfdpath, pass->source.path, sizeof(gfdpath));
char *ptr = strrchr(gfdpath, '.'); if (!(ptr = strrchr(gfdpath, '.')))
if (!ptr)
ptr = gfdpath + strlen(gfdpath); ptr = gfdpath + strlen(gfdpath);
*ptr++ = '.'; *ptr++ = '.';

View File

@ -1,9 +1,12 @@
#include <ctype.h> #include <ctype.h>
#include <mist.h> #include <mist.h>
#include <retro_timers.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <retro_timers.h>
#include <compat/strl.h>
#include <string/stdstring.h>
#include "../input/input_driver.h" #include "../input/input_driver.h"
#include "../menu/menu_driver.h" #include "../menu/menu_driver.h"
#include "../menu/menu_entries.h" #include "../menu/menu_entries.h"
@ -14,24 +17,14 @@
#include "steam.h" #include "steam.h"
static bool mist_initialized = false; static bool mist_initialized = false;
static bool mist_showing_osk = false; static bool mist_showing_osk = false;
static steam_core_dlc_list_t *mist_dlc_list = NULL; static steam_core_dlc_list_t *mist_dlc_list = NULL;
static enum presence last_presence = PRESENCE_NONE; static enum presence last_presence = PRESENCE_NONE;
void str_to_lower(char *str)
{
for (size_t i = 0; str[i] != '\0'; i++)
{
str[i] = tolower(str[i]);
}
}
void steam_init(void) void steam_init(void)
{ {
MistResult result; MistResult result = mist_subprocess_init();
result = mist_subprocess_init();
if (MIST_IS_SUCCESS(result)) if (MIST_IS_SUCCESS(result))
mist_initialized = true; mist_initialized = true;
@ -41,18 +34,17 @@ void steam_init(void)
void steam_poll(void) void steam_poll(void)
{ {
MistResult result;
MistCallbackMsg callback; MistCallbackMsg callback;
steam_core_dlc_list_t *core_dlc_list; steam_core_dlc_list_t *core_dlc_list;
bool has_callback = false; bool has_callback = false;
settings_t* settings = config_get_ptr(); settings_t* settings = config_get_ptr();
static bool has_poll_errored = false; static bool has_poll_errored = false;
static bool has_rich_presence_enabled = false; static bool has_rich_presence_enabled = false;
MistResult result = mist_poll();
result = mist_poll();
if (MIST_IS_ERROR(result)) if (MIST_IS_ERROR(result))
{ {
if(has_poll_errored) return; if (has_poll_errored)
return;
RARCH_ERR("[Steam]: Error polling (%d-%d)\n", MIST_UNPACK_RESULT(result)); RARCH_ERR("[Steam]: Error polling (%d-%d)\n", MIST_UNPACK_RESULT(result));
@ -60,7 +52,8 @@ void steam_poll(void)
} }
result = mist_next_callback(&has_callback, &callback); result = mist_next_callback(&has_callback, &callback);
if(MIST_IS_ERROR(result)) return; if (MIST_IS_ERROR(result))
return;
while (has_callback && MIST_IS_SUCCESS(result)) while (has_callback && MIST_IS_SUCCESS(result))
{ {
@ -85,7 +78,7 @@ void steam_poll(void)
} }
/* Ensure rich presence state is correct */ /* Ensure rich presence state is correct */
if(settings->bools.steam_rich_presence_enable != has_rich_presence_enabled) if (settings->bools.steam_rich_presence_enable != has_rich_presence_enabled)
{ {
steam_update_presence(last_presence, true); steam_update_presence(last_presence, true);
has_rich_presence_enabled = settings->bools.steam_rich_presence_enable; has_rich_presence_enabled = settings->bools.steam_rich_presence_enable;
@ -97,9 +90,8 @@ steam_core_dlc_list_t *steam_core_dlc_list_new(size_t count)
steam_core_dlc_list_t *core_dlc_list = (steam_core_dlc_list_t*) steam_core_dlc_list_t *core_dlc_list = (steam_core_dlc_list_t*)
malloc(sizeof(*core_dlc_list)); malloc(sizeof(*core_dlc_list));
core_dlc_list->list = (steam_core_dlc_t*) core_dlc_list->list = (steam_core_dlc_t*)
malloc(count * sizeof(*core_dlc_list->list)); malloc(count * sizeof(*core_dlc_list->list));
core_dlc_list->count = 0; /* This is incremented inside the setup function */ core_dlc_list->count = 0; /* This is incremented inside the setup function */
return core_dlc_list; return core_dlc_list;
@ -107,13 +99,15 @@ steam_core_dlc_list_t *steam_core_dlc_list_new(size_t count)
void steam_core_dlc_list_free(steam_core_dlc_list_t *list) void steam_core_dlc_list_free(steam_core_dlc_list_t *list)
{ {
if (list == NULL) return; size_t i;
if (!list)
return;
for (size_t i = 0; list->count > i; i++) for (i = 0; list->count > i; i++)
{ {
if (list->list[i].name != NULL) if (list->list[i].name)
free(list->list[i].name); free(list->list[i].name);
if (list->list[i].name_lower != NULL) if (list->list[i].name_lower)
free(list->list[i].name_lower); free(list->list[i].name_lower);
} }
@ -142,33 +136,34 @@ static int dlc_core_qsort_cmp(const void *a_, const void *b_)
* TODO: This currently only uses core info for cores that are installed */ * TODO: This currently only uses core info for cores that are installed */
core_info_t* steam_find_core_info_for_dlc(const char* name) core_info_t* steam_find_core_info_for_dlc(const char* name)
{ {
size_t name_len = strlen(name); int i;
core_info_list_t *core_info_list = NULL; core_info_list_t *core_info_list = NULL;
core_info_get_list(&core_info_list); core_info_get_list(&core_info_list);
if (core_info_list == NULL) return NULL; if (!core_info_list)
return NULL;
for (int i = 0; core_info_list->count > i; i++) for (i = 0; core_info_list->count > i; i++)
{ {
core_info_t *core_info = core_info_get(core_info_list, i); char *start, *end;
char core_info_name[256];
char core_info_name[256] = {0}; core_info_t *core_info = core_info_get(core_info_list, i);
/* Find the opening parenthesis for the core name */ /* Find the opening parenthesis for the core name */
char *start = strchr(core_info->display_name, '('); if (!(start = strchr(core_info->display_name, '('))))
if (start == NULL) continue; continue;
/* Skip the first parenthesis and copy it to the stack */ /* Skip the first parenthesis and copy it to the stack */
strncpy(core_info_name, start + 1, sizeof(core_info_name) - 1); strlcpy(core_info_name, start + 1, sizeof(core_info_name));
/* Null terminate at the closing parenthesis. */ /* Null terminate at the closing parenthesis. */
char *end = strchr((const char*)&core_info_name, ')'); if (!(end = strchr((const char*)&core_info_name, ')'))
if (end == NULL) continue; continue;
else *end = '\0';
*end = '\0';
/* Make it lowercase */ /* Make it lowercase */
str_to_lower((char*)&core_info_name); string_to_lower((char*)&core_info_name);
/* Check if it matches */ /* Check if it matches */
if (strcasecmp(core_info_name, name) == 0) if (strcasecmp(core_info_name, name) == 0)
@ -182,22 +177,22 @@ core_info_t* steam_find_core_info_for_dlc(const char* name)
* Needs to be called after initializion because it uses core info */ * Needs to be called after initializion because it uses core info */
MistResult steam_generate_core_dlcs_list(steam_core_dlc_list_t **list) MistResult steam_generate_core_dlcs_list(steam_core_dlc_list_t **list)
{ {
MistResult result; int count, i;
int count;
steam_core_dlc_list_t *dlc_list = NULL; steam_core_dlc_list_t *dlc_list = NULL;
char dlc_name[PATH_MAX_LENGTH] = { 0 }; char dlc_name[PATH_MAX_LENGTH] = { 0 };
bool avaliable; bool available = false;
MistResult result = mist_steam_apps_get_dlc_count(&count);
result = mist_steam_apps_get_dlc_count(&count); if (MIST_IS_ERROR(result))
if (MIST_IS_ERROR(result)) goto error; goto error;
dlc_list = steam_core_dlc_list_new(count); dlc_list = steam_core_dlc_list_new(count);
for (int i = 0; count > i; i++) for (i = 0; count > i; i++)
{ {
steam_core_dlc_t core_dlc; steam_core_dlc_t core_dlc;
result = mist_steam_apps_get_dlc_data_by_index(i, &core_dlc.app_id, &avaliable, (char*)&dlc_name, PATH_MAX_LENGTH); result = mist_steam_apps_get_dlc_data_by_index(i, &core_dlc.app_id, &available, (char*)&dlc_name, PATH_MAX_LENGTH);
if (MIST_IS_ERROR(result)) goto error; if (MIST_IS_ERROR(result))
goto error;
/* Strip away the "RetroArch - " prefix if present */ /* Strip away the "RetroArch - " prefix if present */
if (strncmp(dlc_name, "RetroArch - ", sizeof("RetroArch - ") - 1) == 0) if (strncmp(dlc_name, "RetroArch - ", sizeof("RetroArch - ") - 1) == 0)
@ -207,7 +202,7 @@ MistResult steam_generate_core_dlcs_list(steam_core_dlc_list_t **list)
/* Make a lower case version */ /* Make a lower case version */
core_dlc.name_lower = strdup(core_dlc.name); core_dlc.name_lower = strdup(core_dlc.name);
str_to_lower(core_dlc.name_lower); string_to_lower(core_dlc.name_lower);
core_dlc.core_info = steam_find_core_info_for_dlc(core_dlc.name_lower); core_dlc.core_info = steam_find_core_info_for_dlc(core_dlc.name_lower);
@ -223,39 +218,47 @@ MistResult steam_generate_core_dlcs_list(steam_core_dlc_list_t **list)
return MistResult_Success; return MistResult_Success;
error: error:
if (dlc_list != NULL) steam_core_dlc_list_free(dlc_list); if (dlc_list)
steam_core_dlc_list_free(dlc_list);
return result; return result;
} }
MistResult steam_get_core_dlcs(steam_core_dlc_list_t **list, bool cached) { MistResult steam_get_core_dlcs(steam_core_dlc_list_t **list, bool cached)
{
MistResult result; MistResult result;
steam_core_dlc_list_t *new_list = NULL; steam_core_dlc_list_t *new_list = NULL;
if (cached && mist_dlc_list != NULL) if (cached && mist_dlc_list)
{ {
*list = mist_dlc_list; *list = mist_dlc_list;
return MistResult_Success; return MistResult_Success;
} }
result = steam_generate_core_dlcs_list(&new_list); result = steam_generate_core_dlcs_list(&new_list);
if (MIST_IS_ERROR(result)) return result; if (MIST_IS_ERROR(result))
return result;
if (mist_dlc_list != NULL) steam_core_dlc_list_free(mist_dlc_list); if (mist_dlc_list)
steam_core_dlc_list_free(mist_dlc_list);
mist_dlc_list = new_list; mist_dlc_list = new_list;
*list = new_list; *list = new_list;
return MistResult_Success; return MistResult_Success;
} }
steam_core_dlc_t* steam_get_core_dlc_by_name(steam_core_dlc_list_t *list, const char *name) { steam_core_dlc_t* steam_get_core_dlc_by_name(
steam_core_dlc_list_t *list, const char *name)
{
int i;
steam_core_dlc_t *core_info; steam_core_dlc_t *core_info;
for (int i = 0; list->count > i; i++) for (i = 0; list->count > i; i++)
{ {
core_info = steam_core_dlc_list_get(list, i); core_info = steam_core_dlc_list_get(list, i);
if (strcasecmp(core_info->name, name) == 0) return core_info; if (strcasecmp(core_info->name, name) == 0)
return core_info;
} }
return NULL; return NULL;
@ -263,46 +266,44 @@ steam_core_dlc_t* steam_get_core_dlc_by_name(steam_core_dlc_list_t *list, const
void steam_install_core_dlc(steam_core_dlc_t *core_dlc) void steam_install_core_dlc(steam_core_dlc_t *core_dlc)
{ {
MistResult result;
char msg[PATH_MAX_LENGTH] = { 0 }; char msg[PATH_MAX_LENGTH] = { 0 };
bool downloading = false;
bool downloading = false; bool installed = false;
bool installed = false;
uint64_t bytes_downloaded = 0; uint64_t bytes_downloaded = 0;
uint64_t bytes_total = 0; uint64_t bytes_total = 0;
/* Check if the core is already being downloaded */ /* Check if the core is already being downloaded */
result = mist_steam_apps_get_dlc_download_progress(core_dlc->app_id, &downloading, &bytes_downloaded, &bytes_total); MistResult result = mist_steam_apps_get_dlc_download_progress(core_dlc->app_id, &downloading, &bytes_downloaded, &bytes_total);
if (MIST_IS_ERROR(result)) goto error; if (MIST_IS_ERROR(result))
goto error;
/* Check if the core is already installed */ /* Check if the core is already installed */
result = mist_steam_apps_is_dlc_installed(core_dlc->app_id, &installed); result = mist_steam_apps_is_dlc_installed(core_dlc->app_id, &installed);
if (MIST_IS_ERROR(result)) goto error; if (MIST_IS_ERROR(result))
goto error;
if (downloading || installed) if (downloading || installed)
{ {
runloop_msg_queue_push(msg_hash_to_str(MSG_CORE_STEAM_CURRENTLY_DOWNLOADING), 1, 180, true, NULL, runloop_msg_queue_push(msg_hash_to_str(MSG_CORE_STEAM_CURRENTLY_DOWNLOADING), 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR); MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
return; return;
} }
result = mist_steam_apps_install_dlc(core_dlc->app_id); result = mist_steam_apps_install_dlc(core_dlc->app_id);
if (MIST_IS_ERROR(result)) goto error; if (MIST_IS_ERROR(result))
goto error;
task_push_steam_core_dlc_install(core_dlc->app_id, core_dlc->name); task_push_steam_core_dlc_install(core_dlc->app_id, core_dlc->name);
return; return;
error: error:
snprintf(msg, sizeof(msg), "%s: (%d-%d)", snprintf(msg, sizeof(msg), "%s: (%d-%d)",
msg_hash_to_str(MSG_ERROR), msg_hash_to_str(MSG_ERROR),
MIST_UNPACK_RESULT(result)); MIST_UNPACK_RESULT(result));
runloop_msg_queue_push(msg, 1, 180, true, NULL, runloop_msg_queue_push(msg, 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR); MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
RARCH_ERR("[Steam]: Error installing DLC %d (%d-%d)\n", core_dlc->app_id, MIST_UNPACK_RESULT(result)); RARCH_ERR("[Steam]: Error installing DLC %d (%d-%d)\n", core_dlc->app_id, MIST_UNPACK_RESULT(result));
return;
} }
void steam_uninstall_core_dlc(steam_core_dlc_t *core_dlc) void steam_uninstall_core_dlc(steam_core_dlc_t *core_dlc)
@ -311,36 +312,35 @@ void steam_uninstall_core_dlc(steam_core_dlc_t *core_dlc)
MistResult result = mist_steam_apps_uninstall_dlc(core_dlc->app_id); MistResult result = mist_steam_apps_uninstall_dlc(core_dlc->app_id);
if (MIST_IS_ERROR(result)) goto error; if (MIST_IS_ERROR(result))
goto error;
runloop_msg_queue_push(msg_hash_to_str(MSG_CORE_STEAM_UNINSTALLED), 1, 180, true, NULL, runloop_msg_queue_push(msg_hash_to_str(MSG_CORE_STEAM_UNINSTALLED), 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
bool refresh = false;
return; return;
error: error:
snprintf(msg, sizeof(msg), "%s: (%d-%d)", snprintf(msg, sizeof(msg), "%s: (%d-%d)",
msg_hash_to_str(MSG_ERROR), msg_hash_to_str(MSG_ERROR),
MIST_UNPACK_RESULT(result)); MIST_UNPACK_RESULT(result));
runloop_msg_queue_push(msg, 1, 180, true, NULL, runloop_msg_queue_push(msg, 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR); MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
RARCH_ERR("[Steam]: Error uninstalling DLC %d (%d-%d)\n", core_dlc->app_id, MIST_UNPACK_RESULT(result)); RARCH_ERR("[Steam]: Error uninstalling DLC %d (%d-%d)\n", core_dlc->app_id, MIST_UNPACK_RESULT(result));
return;
} }
bool steam_open_osk(void) bool steam_open_osk(void)
{ {
bool shown = false; bool shown = false;
bool on_deck = false; bool on_deck = false;
video_driver_state_t *video_st = video_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr();
/* Only open the Steam OSK if running on a Steam Deck, /* Only open the Steam OSK if running on a Steam Deck,
as currently the Big Picture OSK seems to be semi-broken */ as currently the Big Picture OSK seems to be semi-broken */
mist_steam_utils_is_steam_running_on_steam_deck(&on_deck); mist_steam_utils_is_steam_running_on_steam_deck(&on_deck);
if(!on_deck) return false; if (!on_deck)
return false;
mist_steam_utils_show_floating_gamepad_text_input( mist_steam_utils_show_floating_gamepad_text_input(
MistFloatingGamepadTextInputMode_SingleLine, MistFloatingGamepadTextInputMode_SingleLine,
@ -374,7 +374,7 @@ void steam_update_presence(enum presence presence, bool force)
last_presence = presence; last_presence = presence;
/* Ensure rich presence is enabled */ /* Ensure rich presence is enabled */
if(!settings->bools.steam_rich_presence_enable) if (!settings->bools.steam_rich_presence_enable)
{ {
mist_steam_friends_clear_rich_presence(); mist_steam_friends_clear_rich_presence();
return; return;
@ -382,88 +382,159 @@ void steam_update_presence(enum presence presence, bool force)
switch (presence) switch (presence)
{ {
case PRESENCE_MENU: case PRESENCE_MENU:
mist_steam_friends_set_rich_presence("steam_display", "#Status_InMenu"); mist_steam_friends_set_rich_presence("steam_display", "#Status_InMenu");
break; break;
case PRESENCE_GAME_PAUSED: case PRESENCE_GAME_PAUSED:
mist_steam_friends_set_rich_presence("steam_display", "#Status_Paused"); mist_steam_friends_set_rich_presence("steam_display", "#Status_Paused");
break; break;
case PRESENCE_GAME: case PRESENCE_GAME:
{ {
const char *label = NULL; size_t _len;
const struct playlist_entry *entry = NULL; char content[PATH_MAX_LENGTH];
core_info_t *core_info = NULL; const char *label = NULL;
playlist_t *current_playlist = playlist_get_cached(); const struct playlist_entry *entry = NULL;
char content[PATH_MAX_LENGTH] = {0}; core_info_t *core_info = NULL;
playlist_t *current_playlist = playlist_get_cached();
core_info_get_current_core(&core_info); core_info_get_current_core(&core_info);
if (current_playlist) if (current_playlist)
{ {
playlist_get_index_by_path( playlist_get_index_by_path(
current_playlist, current_playlist,
path_get(RARCH_PATH_CONTENT), path_get(RARCH_PATH_CONTENT),
&entry); &entry);
if (entry && !string_is_empty(entry->label)) if (entry && !string_is_empty(entry->label))
label = entry->label; label = entry->label;
} }
if (!label) if (!label)
label = path_basename(path_get(RARCH_PATH_BASENAME)); label = path_basename(path_get(RARCH_PATH_BASENAME));
switch(settings->uints.steam_rich_presence_format) switch(settings->uints.steam_rich_presence_format)
{ {
case STEAM_RICH_PRESENCE_FORMAT_CONTENT: case STEAM_RICH_PRESENCE_FORMAT_CONTENT:
strncpy(content, label, sizeof(content) - 1); strlcpy(content, label, sizeof(content));
break; break;
case STEAM_RICH_PRESENCE_FORMAT_CORE: case STEAM_RICH_PRESENCE_FORMAT_CORE:
strncpy(content, core_info ? core_info->core_name : "N/A", sizeof(content) - 1); if (core_info)
break; strlcpy(content, core_info->core_name, sizeof(content));
case STEAM_RICH_PRESENCE_FORMAT_SYSTEM: else
strncpy(content, core_info ? core_info->systemname : "N/A", sizeof(content) - 1); {
break; content[0] = 'N';
case STEAM_RICH_PRESENCE_FORMAT_CONTENT_SYSTEM: content[1] = '/';
snprintf(content, sizeof(content) - 1, "%s (%s)", content[2] = 'A';
label, content[3] = '\0';
core_info ? core_info->systemname : "N/A"); }
break; break;
case STEAM_RICH_PRESENCE_FORMAT_CONTENT_CORE: case STEAM_RICH_PRESENCE_FORMAT_SYSTEM:
snprintf(content, sizeof(content) - 1, "%s (%s)", if (core_info)
label, strlcpy(content, core_info->systemname, sizeof(content));
core_info ? core_info->core_name : "N/A"); else
break; {
case STEAM_RICH_PRESENCE_FORMAT_CONTENT_SYSTEM_CORE: content[0] = 'N';
snprintf(content, sizeof(content) - 1, "%s (%s - %s)", content[1] = '/';
label, content[2] = 'A';
core_info ? core_info->systemname : "N/A", content[3] = '\0';
core_info ? core_info->core_name : "N/A"); }
break; break;
case STEAM_RICH_PRESENCE_FORMAT_NONE: case STEAM_RICH_PRESENCE_FORMAT_CONTENT_SYSTEM:
default: _len = strlcpy(content, label, sizeof(content));
break; content[_len ] = ' ';
} content[_len+1] = '(';
content[_len+2] = '\0';
if (core_info)
{
_len = strlcat(content, core_info->systemname);
content[_len ] = ')';
content[_len+1] = '\0';
}
else
{
content[_len+2] = 'N';
content[_len+3] = '/';
content[_len+4] = 'A';
content[_len+5] = ')';
content[_len+6] = '\0';
}
break;
case STEAM_RICH_PRESENCE_FORMAT_CONTENT_CORE:
_len = strlcpy(content, label, sizeof(content));
content[_len ] = ' ';
content[_len+1] = '(';
content[_len+2] = '\0';
if (core_info)
{
_len = strlcat(content, core_info->core_name);
content[_len ] = ')';
content[_len+1] = '\0';
}
else
{
content[_len+2] = 'N';
content[_len+3] = '/';
content[_len+4] = 'A';
content[_len+5] = ')';
content[_len+6] = '\0';
}
break;
case STEAM_RICH_PRESENCE_FORMAT_CONTENT_SYSTEM_CORE:
_len = strlcpy(content, label, sizeof(content));
content[_len ] = ' ';
content[_len+1] = '(';
content[_len+2] = '\0';
if (core_info)
{
_len = strlcat(content, core_info->systemname);
content[_len ] = ' ';
content[_len+1] = '-';
content[_len+2] = ' ';
_len = strlcat(content, core_info->core_name);
content[_len ] = ')';
content[_len+1] = '\0';
}
else
{
content[_len+2] = 'N';
content[_len+3] = '/';
content[_len+4] = 'A';
content[_len+5] = ' ';
content[_len+6] = '-';
content[_len+7] = ' ';
content[_len+8] = 'N';
content[_len+9] = '/';
content[_len+10] = 'A';
content[_len+11] = ')';
content[_len+12] = '\0';
}
break;
case STEAM_RICH_PRESENCE_FORMAT_NONE:
default:
content[0] = '\0';
break;
}
mist_steam_friends_set_rich_presence("content", content); mist_steam_friends_set_rich_presence("content", content);
mist_steam_friends_set_rich_presence("steam_display", mist_steam_friends_set_rich_presence("steam_display",
settings->uints.steam_rich_presence_format != STEAM_RICH_PRESENCE_FORMAT_NONE settings->uints.steam_rich_presence_format != STEAM_RICH_PRESENCE_FORMAT_NONE
? "#Status_RunningContent" : "#Status_Running" ); ? "#Status_RunningContent" : "#Status_Running" );
} }
break; break;
default: default:
break; break;
} }
} }
void steam_deinit(void) void steam_deinit(void)
{ {
MistResult result; MistResult result = mist_subprocess_deinit();
result = mist_subprocess_deinit();
/* Free the cached dlc list */ /* Free the cached dlc list */
if (mist_dlc_list != NULL) steam_core_dlc_list_free(mist_dlc_list); if (mist_dlc_list)
steam_core_dlc_list_free(mist_dlc_list);
if (MIST_IS_SUCCESS(result)) if (MIST_IS_SUCCESS(result))
mist_initialized = false; mist_initialized = false;

View File

@ -494,7 +494,7 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename)
/** process raw serial to a pre serial without spaces **/ /** process raw serial to a pre serial without spaces **/
string_remove_all_whitespace(pre_game_id, raw_game_id); /** rule: remove all spaces from the raw serial globally **/ string_remove_all_whitespace(pre_game_id, raw_game_id); /** rule: remove all spaces from the raw serial globally **/
/** disect this pre serial into parts **/ /** Dissect this pre serial into parts **/
length = strlen(pre_game_id); length = strlen(pre_game_id);
lengthref = length - 2; lengthref = length - 2;
strncpy(check_prefix_t_hyp, pre_game_id, 2); strncpy(check_prefix_t_hyp, pre_game_id, 2);
@ -613,7 +613,7 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
string_trim_whitespace(raw_game_id); string_trim_whitespace(raw_game_id);
/** disect this raw serial into parts **/ /** Dissect this raw serial into parts **/
strncpy(check_prefix_t_hyp, raw_game_id, 2); strncpy(check_prefix_t_hyp, raw_game_id, 2);
check_prefix_t_hyp[2] = '\0'; check_prefix_t_hyp[2] = '\0';
strncpy(check_prefix_mk_hyp, raw_game_id, 3); strncpy(check_prefix_mk_hyp, raw_game_id, 3);
@ -717,7 +717,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
length = strlen(raw_game_id); length = strlen(raw_game_id);
total_hyphens = string_count_occurrences_single_character(raw_game_id, '-'); total_hyphens = string_count_occurrences_single_character(raw_game_id, '-');
/** disect this raw serial into parts **/ /** Dissect this raw serial into parts **/
strncpy(check_prefix_t_hyp, raw_game_id, 2); strncpy(check_prefix_t_hyp, raw_game_id, 2);
check_prefix_t_hyp[2] = '\0'; check_prefix_t_hyp[2] = '\0';
strncpy(check_prefix_t, raw_game_id, 1); strncpy(check_prefix_t, raw_game_id, 1);