1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
30 typedef enum ConditionType {
31 CONDITION_ARCHITECTURE,
32 CONDITION_VIRTUALIZATION,
34 CONDITION_KERNEL_COMMAND_LINE,
39 CONDITION_NEEDS_UPDATE,
42 CONDITION_PATH_EXISTS,
43 CONDITION_PATH_EXISTS_GLOB,
44 CONDITION_PATH_IS_DIRECTORY,
45 CONDITION_PATH_IS_SYMBOLIC_LINK,
46 CONDITION_PATH_IS_MOUNT_POINT,
47 CONDITION_PATH_IS_READ_WRITE,
48 CONDITION_DIRECTORY_NOT_EMPTY,
49 CONDITION_FILE_NOT_EMPTY,
50 CONDITION_FILE_IS_EXECUTABLE,
55 _CONDITION_TYPE_INVALID = -1
58 typedef enum ConditionResult {
63 _CONDITION_RESULT_MAX,
64 _CONDITION_RESULT_INVALID = -1
67 typedef struct Condition {
73 ConditionResult result:6;
77 LIST_FIELDS(struct Condition, conditions);
80 Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate);
81 void condition_free(Condition *c);
82 Condition* condition_free_list(Condition *c);
84 int condition_test(Condition *c);
86 void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t));
87 void condition_dump_list(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t));
89 const char* condition_type_to_string(ConditionType t) _const_;
90 ConditionType condition_type_from_string(const char *s) _pure_;
92 const char* assert_type_to_string(ConditionType t) _const_;
93 ConditionType assert_type_from_string(const char *s) _pure_;
95 const char* condition_result_to_string(ConditionResult r) _const_;
96 ConditionResult condition_result_from_string(const char *s) _pure_;