diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-11-06 00:49:44 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-11-06 14:21:10 +0100 |
commit | 592fd144ae313855f48d0ca52a103013b41e5d59 (patch) | |
tree | 45f239ffa2dc6fb375785d8e8a3ddbda78c829e4 /src/shared/condition-util.h | |
parent | 58f2fab16da947052756b7f9ace40f6ee7fa1519 (diff) |
condition: properly allow passing back errors from condition checks
Diffstat (limited to 'src/shared/condition-util.h')
-rw-r--r-- | src/shared/condition-util.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/shared/condition-util.h b/src/shared/condition-util.h index 047fdbfd86..fbb8150083 100644 --- a/src/shared/condition-util.h +++ b/src/shared/condition-util.h @@ -51,6 +51,16 @@ typedef enum ConditionType { _CONDITION_TYPE_INVALID = -1 } ConditionType; +#define CONDITION_STATE_IS_SUCCEEDED(state) ((state) > 0) +#define CONDITION_STATE_IS_UNKNOWN(state) ((state) == 0) +#define CONDITION_STATE_IS_FAILED(state) ((state) < 0) + +enum { + CONDITION_STATE_SUCCEEDED = -1, + CONDITION_STATE_UNKNOWN = 0, + CONDITION_STATE_FAILED = 1 +}; + typedef struct Condition { ConditionType type; @@ -58,7 +68,6 @@ typedef struct Condition { bool negate:1; char *parameter; - int state; LIST_FIELDS(struct Condition, conditions); @@ -68,11 +77,11 @@ Condition* condition_new(ConditionType type, const char *parameter, bool trigger void condition_free(Condition *c); void condition_free_list(Condition *c); -bool condition_test_kernel_command_line(Condition *c); -bool condition_test_virtualization(Condition *c); -bool condition_test_architecture(Condition *c); -bool condition_test_host(Condition *c); -bool condition_test_ac_power(Condition *c); +int condition_test_kernel_command_line(Condition *c); +int condition_test_virtualization(Condition *c); +int condition_test_architecture(Condition *c); +int condition_test_host(Condition *c); +int condition_test_ac_power(Condition *c); void condition_dump(Condition *c, FILE *f, const char *prefix); void condition_dump_list(Condition *c, FILE *f, const char *prefix); |