1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2010 Lennart Poettering
16 typedef enum ConditionType
{
17 CONDITION_ARCHITECTURE
,
18 CONDITION_VIRTUALIZATION
,
20 CONDITION_KERNEL_COMMAND_LINE
,
21 CONDITION_KERNEL_VERSION
,
26 CONDITION_NEEDS_UPDATE
,
29 CONDITION_PATH_EXISTS
,
30 CONDITION_PATH_EXISTS_GLOB
,
31 CONDITION_PATH_IS_DIRECTORY
,
32 CONDITION_PATH_IS_SYMBOLIC_LINK
,
33 CONDITION_PATH_IS_MOUNT_POINT
,
34 CONDITION_PATH_IS_READ_WRITE
,
35 CONDITION_DIRECTORY_NOT_EMPTY
,
36 CONDITION_FILE_NOT_EMPTY
,
37 CONDITION_FILE_IS_EXECUTABLE
,
44 CONDITION_CONTROL_GROUP_CONTROLLER
,
47 _CONDITION_TYPE_INVALID
= -1
50 typedef enum ConditionResult
{
55 _CONDITION_RESULT_MAX
,
56 _CONDITION_RESULT_INVALID
= -1
59 typedef struct Condition
{
65 ConditionResult result
:6;
69 LIST_FIELDS(struct Condition
, conditions
);
72 Condition
* condition_new(ConditionType type
, const char *parameter
, bool trigger
, bool negate
);
73 void condition_free(Condition
*c
);
74 Condition
* condition_free_list(Condition
*c
);
76 int condition_test(Condition
*c
);
78 void condition_dump(Condition
*c
, FILE *f
, const char *prefix
, const char *(*to_string
)(ConditionType t
));
79 void condition_dump_list(Condition
*c
, FILE *f
, const char *prefix
, const char *(*to_string
)(ConditionType t
));
81 const char* condition_type_to_string(ConditionType t
) _const_
;
82 ConditionType
condition_type_from_string(const char *s
) _pure_
;
84 const char* assert_type_to_string(ConditionType t
) _const_
;
85 ConditionType
assert_type_from_string(const char *s
) _pure_
;
87 const char* condition_result_to_string(ConditionResult r
) _const_
;
88 ConditionResult
condition_result_from_string(const char *s
) _pure_
;
90 static inline bool condition_takes_path(ConditionType t
) {
92 CONDITION_PATH_EXISTS
,
93 CONDITION_PATH_EXISTS_GLOB
,
94 CONDITION_PATH_IS_DIRECTORY
,
95 CONDITION_PATH_IS_SYMBOLIC_LINK
,
96 CONDITION_PATH_IS_MOUNT_POINT
,
97 CONDITION_PATH_IS_READ_WRITE
,
98 CONDITION_DIRECTORY_NOT_EMPTY
,
99 CONDITION_FILE_NOT_EMPTY
,
100 CONDITION_FILE_IS_EXECUTABLE
,
101 CONDITION_NEEDS_UPDATE
);