mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00:00
Extend conditional load support with if:<cond> and if:<!cond>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
b65773d508
commit
c4dcf568c8
2 files changed
+30
-4
No files matched your search
@@ -694,6 +694,32 @@ int svc_ifthen(const char *ident, const char *stmt)
|
||||
if (!stmt || !stmt[0])
|
||||
return 1;
|
||||
|
||||
if (stmt[0] == '<') {
|
||||
enum cond_state cond;
|
||||
char *ptr = ++stmt;
|
||||
int i = 0;
|
||||
|
||||
if (stmt[0] == '!') {
|
||||
stmt++;
|
||||
not++;
|
||||
}
|
||||
|
||||
while (ptr[i] != '>' && ptr[i] != 0)
|
||||
i++;
|
||||
ptr[i] = 0;
|
||||
|
||||
cond = cond_get(stmt);
|
||||
if (not && cond == COND_ON) {
|
||||
dbg("skipping %s, cond %s is on", ident, stmt);
|
||||
return 0;
|
||||
}
|
||||
if (!not && cond == COND_OFF) {
|
||||
dbg("skipping %s, cond %s is off", ident, stmt);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stmt[0] == '!') {
|
||||
stmt++;
|
||||
not++;
|
||||
|
||||
Reference in new issue
Block a user