chiark / gitweb /
core/smack: downgrade info to debug
[elogind.git] / src / core / condition.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2010 Lennart Poettering
9
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.
14
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.
19
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/>.
22 ***/
23
24 #include <stdbool.h>
25
26 #include "list.h"
27
28 typedef enum ConditionType {
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,
38         CONDITION_KERNEL_COMMAND_LINE,
39         CONDITION_VIRTUALIZATION,
40         CONDITION_SECURITY,
41         CONDITION_CAPABILITY,
42         CONDITION_HOST,
43         CONDITION_AC_POWER,
44         CONDITION_NULL,
45         _CONDITION_TYPE_MAX,
46         _CONDITION_TYPE_INVALID = -1
47 } ConditionType;
48
49 typedef struct Condition {
50         ConditionType type;
51         char *parameter;
52
53         bool trigger:1;
54         bool negate:1;
55
56         LIST_FIELDS(struct Condition, conditions);
57 } Condition;
58
59 Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate);
60 void condition_free(Condition *c);
61 void condition_free_list(Condition *c);
62
63 bool condition_test(Condition *c);
64 bool condition_test_list(Condition *c);
65
66 void condition_dump(Condition *c, FILE *f, const char *prefix);
67 void condition_dump_list(Condition *c, FILE *f, const char *prefix);
68
69 const char* condition_type_to_string(ConditionType t);
70 int condition_type_from_string(const char *s);