chiark / gitweb /
condition: internalize condition test functions
[elogind.git] / src / shared / condition-util.h
index 63d945e..44f672b 100644 (file)
@@ -44,11 +44,23 @@ typedef enum ConditionType {
         CONDITION_HOST,
         CONDITION_AC_POWER,
         CONDITION_ARCHITECTURE,
+        CONDITION_NEEDS_UPDATE,
+        CONDITION_FIRST_BOOT,
         CONDITION_NULL,
         _CONDITION_TYPE_MAX,
         _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;
 
@@ -56,7 +68,6 @@ typedef struct Condition {
         bool negate:1;
 
         char *parameter;
-
         int state;
 
         LIST_FIELDS(struct Condition, conditions);
@@ -66,11 +77,7 @@ 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(Condition *c);
 
 void condition_dump(Condition *c, FILE *f, const char *prefix);
 void condition_dump_list(Condition *c, FILE *f, const char *prefix);