mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-08-26 02:18:17 +00:00
Further deduplication (get_process_name, file_exists)
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
@@ -84,6 +84,20 @@ char *lsi_get_steam_dir()
|
||||
return strdup(resolv);
|
||||
}
|
||||
|
||||
char *lsi_get_process_name(void)
|
||||
{
|
||||
autofree(char) *realp = NULL;
|
||||
char *basep = NULL;
|
||||
|
||||
realp = realpath("/proc/self/exe", NULL);
|
||||
if (!realp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
basep = basename(realp);
|
||||
return strdup(basep);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
@@ -36,6 +36,11 @@ char *lsi_get_steam_dir(void);
|
||||
*/
|
||||
bool lsi_file_exists(const char *path);
|
||||
|
||||
/**
|
||||
* Determine the basename'd process
|
||||
*/
|
||||
char *lsi_get_process_name(void);
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
+2
-24
@@ -18,14 +18,9 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "../common/files.h"
|
||||
#include "nica/util.h"
|
||||
|
||||
static inline bool lsi_file_exists(const char *path)
|
||||
{
|
||||
struct stat st = { .st_ino = 0 };
|
||||
return (lstat(path, &st) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* What's the known process name?
|
||||
*/
|
||||
@@ -128,23 +123,6 @@ static const char *vendor_blacklist[] = {
|
||||
"libssl.so.1.0.0",
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine the basename'd process
|
||||
*/
|
||||
static inline char *get_process_name(void)
|
||||
{
|
||||
autofree(char) *realp = NULL;
|
||||
char *basep = NULL;
|
||||
|
||||
realp = realpath("/proc/self/exe", NULL);
|
||||
if (!realp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
basep = basename(realp);
|
||||
return strdup(basep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we're in a given process set, i.e. the process name matches
|
||||
* the given table
|
||||
@@ -176,7 +154,7 @@ static void check_is_intercept_candidate(void)
|
||||
{
|
||||
autofree(char) *nom = NULL;
|
||||
|
||||
nom = get_process_name();
|
||||
nom = lsi_get_process_name();
|
||||
if (!nom) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-18
@@ -59,23 +59,6 @@ typedef struct LsiRedirectTable {
|
||||
*/
|
||||
static LsiRedirectTable lsi_table = { 0 };
|
||||
|
||||
/**
|
||||
* Determine the basename'd process
|
||||
*/
|
||||
static inline char *get_process_name(void)
|
||||
{
|
||||
autofree(char) *realp = NULL;
|
||||
char *basep = NULL;
|
||||
|
||||
realp = realpath("/proc/self/exe", NULL);
|
||||
if (!realp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
basep = basename(realp);
|
||||
return strdup(basep);
|
||||
}
|
||||
|
||||
/**
|
||||
* We'll only perform teardown code if the process doesn't `abort()` or `_exit()`
|
||||
*/
|
||||
@@ -150,7 +133,7 @@ __attribute__((constructor)) static void lsi_redirect_init(void)
|
||||
/* Ensure we're open. */
|
||||
lsi_redirect_init_tables();
|
||||
|
||||
autofree(char) *process_name = get_process_name();
|
||||
autofree(char) *process_name = lsi_get_process_name();
|
||||
|
||||
if (!process_name) {
|
||||
fprintf(stderr, "Failure to allocate memory! %s\n", strerror(errno));
|
||||
|
||||
Reference in New Issue
Block a user