mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-08-25 09:27:52 +00:00
Fix logging, start fleshing out redirect profile API
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
+11
-4
@@ -19,6 +19,13 @@
|
||||
#include "log.h"
|
||||
#include "nica/util.h"
|
||||
|
||||
static const char *_log_id = "__init__";
|
||||
|
||||
void lsi_log_set_id(const char *id)
|
||||
{
|
||||
_log_id = id;
|
||||
}
|
||||
|
||||
void lsi_log_debug(const char *format, ...)
|
||||
{
|
||||
if (!getenv("LSI_DEBUG")) {
|
||||
@@ -35,7 +42,7 @@ void lsi_log_debug(const char *format, ...)
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\033[32;1m[lsi:debug]\033[0m %s\n", p);
|
||||
fprintf(stderr, "\033[32;1m[lsi:%s]\033[0m %s\n", _log_id, p);
|
||||
|
||||
end:
|
||||
va_end(va);
|
||||
@@ -53,7 +60,7 @@ void lsi_log_info(const char *format, ...)
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\033[34;1m[lsi:info]\033[0m %s\n", p);
|
||||
fprintf(stderr, "\033[34;1m[lsi:%s]\033[0m %s\n", _log_id, p);
|
||||
|
||||
end:
|
||||
va_end(va);
|
||||
@@ -71,7 +78,7 @@ void lsi_log_warn(const char *format, ...)
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\033[33;1m[lsi:warn]\033[0m %s\n", p);
|
||||
fprintf(stderr, "\033[33;1m[lsi:%s]\033[0m %s\n", _log_id, p);
|
||||
|
||||
end:
|
||||
va_end(va);
|
||||
@@ -89,7 +96,7 @@ void lsi_log_error(const char *format, ...)
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\033[31;1m[lsi:error]\033[0m %s\n", p);
|
||||
fprintf(stderr, "\033[31;1m[lsi:%s]\033[0m %s\n", _log_id, p);
|
||||
|
||||
end:
|
||||
va_end(va);
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Set the ID used in all log output
|
||||
*/
|
||||
void lsi_log_set_id(const char *id);
|
||||
|
||||
/**
|
||||
* Emit some debug information if LSI_DEBUG is set
|
||||
*/
|
||||
|
||||
@@ -161,6 +161,7 @@ static void check_is_intercept_candidate(void)
|
||||
work_mode = INTERCEPT_MODE_VENDOR_OFFENDER;
|
||||
matched_process = "vendor_offender";
|
||||
}
|
||||
lsi_log_set_id(matched_process);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -153,6 +153,7 @@ __attribute__((constructor)) static void lsi_redirect_init(void)
|
||||
|
||||
/* Temporary hack, we'll make this more generic later */
|
||||
if (strcmp(process_name, "ShooterGame") == 0) {
|
||||
lsi_log_set_id("ShooterGame");
|
||||
lsi_profile = lsi_redirect_profile_new("ARK Survival Evolved");
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/log.h"
|
||||
#include "redirect.h"
|
||||
|
||||
LsiRedirectProfile *lsi_redirect_profile_new(const char *name)
|
||||
@@ -41,6 +42,27 @@ void lsi_redirect_profile_free(LsiRedirectProfile *self)
|
||||
free(self);
|
||||
}
|
||||
|
||||
void lsi_redirect_profile_insert_rule(LsiRedirectProfile *self, LsiRedirect *redirect)
|
||||
{
|
||||
LsiRedirectOperation op;
|
||||
|
||||
switch (redirect->type) {
|
||||
case LSI_REDIRECT_PATH:
|
||||
op = LSI_OPERATION_OPEN;
|
||||
break;
|
||||
default:
|
||||
lsi_log_error("Attempted insert of unknown rule into '%s'", self->name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set head or prepend the rule */
|
||||
if (self->op_table[op]) {
|
||||
self->op_table[op] = redirect->next = self->op_table[op];
|
||||
} else {
|
||||
self->op_table[op] = redirect;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
@@ -71,6 +71,14 @@ LsiRedirectProfile *lsi_redirect_profile_new(const char *name);
|
||||
*/
|
||||
void lsi_redirect_profile_free(LsiRedirectProfile *profile);
|
||||
|
||||
/**
|
||||
* Attempt insert of a redirect rule into this profile
|
||||
*
|
||||
* @param profile Pointer to a valid LsiRedirectProfile
|
||||
* @param redirect Pointer to an allocated LsiRedirect
|
||||
*/
|
||||
void lsi_redirect_profile_insert_rule(LsiRedirectProfile *self, LsiRedirect *redirect);
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user