diff options
Diffstat (limited to 'src/shared/condition-util.c')
-rw-r--r-- | src/shared/condition-util.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/shared/condition-util.c b/src/shared/condition-util.c index 640a931ff5..ee9d11ee87 100644 --- a/src/shared/condition-util.c +++ b/src/shared/condition-util.c @@ -447,7 +447,7 @@ int condition_test(Condition *c) { return b; } -void condition_dump(Condition *c, FILE *f, const char *prefix) { +void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) { assert(c); assert(f); @@ -457,18 +457,18 @@ void condition_dump(Condition *c, FILE *f, const char *prefix) { fprintf(f, "%s\t%s: %s%s%s %s\n", prefix, - condition_type_to_string(c->type), + to_string(c->type), c->trigger ? "|" : "", c->negate ? "!" : "", c->parameter, condition_result_to_string(c->result)); } -void condition_dump_list(Condition *first, FILE *f, const char *prefix) { +void condition_dump_list(Condition *first, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) { Condition *c; LIST_FOREACH(conditions, c, first) - condition_dump(c, f, prefix); + condition_dump(c, f, prefix, to_string); } static const char* const condition_type_table[_CONDITION_TYPE_MAX] = { @@ -495,6 +495,30 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = { DEFINE_STRING_TABLE_LOOKUP(condition_type, ConditionType); +static const char* const assert_type_table[_CONDITION_TYPE_MAX] = { + [CONDITION_PATH_EXISTS] = "AssertPathExists", + [CONDITION_PATH_EXISTS_GLOB] = "AssertPathExistsGlob", + [CONDITION_PATH_IS_DIRECTORY] = "AssertPathIsDirectory", + [CONDITION_PATH_IS_SYMBOLIC_LINK] = "AssertPathIsSymbolicLink", + [CONDITION_PATH_IS_MOUNT_POINT] = "AssertPathIsMountPoint", + [CONDITION_PATH_IS_READ_WRITE] = "AssertPathIsReadWrite", + [CONDITION_DIRECTORY_NOT_EMPTY] = "AssertDirectoryNotEmpty", + [CONDITION_FILE_NOT_EMPTY] = "AssertFileNotEmpty", + [CONDITION_FILE_IS_EXECUTABLE] = "AssertFileIsExecutable", + [CONDITION_KERNEL_COMMAND_LINE] = "AssertKernelCommandLine", + [CONDITION_VIRTUALIZATION] = "AssertVirtualization", + [CONDITION_SECURITY] = "AssertSecurity", + [CONDITION_CAPABILITY] = "AssertCapability", + [CONDITION_HOST] = "AssertHost", + [CONDITION_AC_POWER] = "AssertACPower", + [CONDITION_ARCHITECTURE] = "AssertArchitecture", + [CONDITION_NEEDS_UPDATE] = "AssertNeedsUpdate", + [CONDITION_FIRST_BOOT] = "AssertFirstBoot", + [CONDITION_NULL] = "AssertNull" +}; + +DEFINE_STRING_TABLE_LOOKUP(assert_type, ConditionType); + static const char* const condition_result_table[_CONDITION_RESULT_MAX] = { [CONDITION_UNTESTED] = "untested", [CONDITION_SUCCEEDED] = "succeeded", |