mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-08-25 09:27:52 +00:00
redirect: Add API for creating and freeing chained LsiRedirects
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
@@ -38,6 +38,16 @@ void lsi_redirect_profile_free(LsiRedirectProfile *self)
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Free all chains */
|
||||
for (unsigned int i = 0; i < LSI_NUM_OPERATIONS; i++) {
|
||||
LsiRedirect *r = self->op_table[i];
|
||||
if (!r) {
|
||||
continue;
|
||||
}
|
||||
lsi_redirect_free(r);
|
||||
}
|
||||
|
||||
free(self->name);
|
||||
free(self);
|
||||
}
|
||||
@@ -63,6 +73,47 @@ void lsi_redirect_profile_insert_rule(LsiRedirectProfile *self, LsiRedirect *red
|
||||
}
|
||||
}
|
||||
|
||||
LsiRedirect *lsi_redirect_new_path_replacement(const char *source_path, const char *target_path)
|
||||
{
|
||||
LsiRedirect *ret = NULL;
|
||||
|
||||
ret = calloc(1, sizeof(LsiRedirect));
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
ret->type = LSI_REDIRECT_PATH;
|
||||
ret->path_source = strdup(source_path);
|
||||
ret->path_target = strdup(target_path);
|
||||
|
||||
if (!ret->path_source || !ret->path_target) {
|
||||
lsi_redirect_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void lsi_redirect_free(LsiRedirect *self)
|
||||
{
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Pass it along */
|
||||
if (self->next) {
|
||||
lsi_redirect_free(self->next);
|
||||
}
|
||||
|
||||
switch (self->type) {
|
||||
case LSI_REDIRECT_PATH:
|
||||
default:
|
||||
free(self->path_source);
|
||||
free(self->path_target);
|
||||
break;
|
||||
}
|
||||
|
||||
free(self);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
+16
-3
@@ -30,9 +30,8 @@ typedef struct LsiRedirect {
|
||||
union {
|
||||
/* Path replacement */
|
||||
struct {
|
||||
const char *path_source;
|
||||
const char *path_target;
|
||||
bool path_relative;
|
||||
char *path_source;
|
||||
char *path_target;
|
||||
};
|
||||
};
|
||||
struct LsiRedirect *next;
|
||||
@@ -79,6 +78,20 @@ void lsi_redirect_profile_free(LsiRedirectProfile *profile);
|
||||
*/
|
||||
void lsi_redirect_profile_insert_rule(LsiRedirectProfile *self, LsiRedirect *redirect);
|
||||
|
||||
/* LsiRedirect APIs follow */
|
||||
|
||||
/**
|
||||
* Construct a new LsiRedirect to perform path replacements
|
||||
*/
|
||||
LsiRedirect *lsi_redirect_new_path_replacement(const char *source_path, const char *target_path);
|
||||
|
||||
/**
|
||||
* Attempt to free this redirect
|
||||
*
|
||||
* @param redirect Pointer to allocated LsiRedirect
|
||||
*/
|
||||
void lsi_redirect_free(LsiRedirect *self);
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user