]>
Commit | Line | Data |
---|---|---|
03467c88 | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
9e2f7c11 | 2 | |
c2f1db8f | 3 | #pragma once |
9e2f7c11 LP |
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 | |
5430f7f2 LP |
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 | |
9e2f7c11 LP |
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 | |
5430f7f2 | 18 | Lesser General Public License for more details. |
9e2f7c11 | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
9e2f7c11 LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
71fad675 | 24 | #include <stdbool.h> |
9e2f7c11 | 25 | |
44a6b1b6 ZJS |
26 | #include "macro.h" |
27 | ||
71fad675 | 28 | #define UNIT_NAME_MAX 256 |
9e2f7c11 | 29 | |
0a9f8ed0 | 30 | typedef enum UnitType UnitType; |
f69614f8 | 31 | typedef enum UnitLoadState UnitLoadState; |
cb87a73b | 32 | typedef enum UnitDependency UnitDependency; |
0a9f8ed0 ZJS |
33 | |
34 | enum UnitType { | |
35 | UNIT_SERVICE = 0, | |
36 | UNIT_SOCKET, | |
e821075a | 37 | UNIT_BUSNAME, |
0a9f8ed0 | 38 | UNIT_TARGET, |
e821075a | 39 | UNIT_SNAPSHOT, |
0a9f8ed0 ZJS |
40 | UNIT_DEVICE, |
41 | UNIT_MOUNT, | |
42 | UNIT_AUTOMOUNT, | |
0a9f8ed0 | 43 | UNIT_SWAP, |
e821075a | 44 | UNIT_TIMER, |
0a9f8ed0 | 45 | UNIT_PATH, |
a016b922 | 46 | UNIT_SLICE, |
6c12b52e | 47 | UNIT_SCOPE, |
0a9f8ed0 ZJS |
48 | _UNIT_TYPE_MAX, |
49 | _UNIT_TYPE_INVALID = -1 | |
50 | }; | |
51 | ||
f69614f8 | 52 | enum UnitLoadState { |
45c0c61d | 53 | UNIT_STUB = 0, |
f69614f8 | 54 | UNIT_LOADED, |
c2756a68 | 55 | UNIT_NOT_FOUND, |
f69614f8 ZJS |
56 | UNIT_ERROR, |
57 | UNIT_MERGED, | |
58 | UNIT_MASKED, | |
59 | _UNIT_LOAD_STATE_MAX, | |
60 | _UNIT_LOAD_STATE_INVALID = -1 | |
61 | }; | |
62 | ||
cb87a73b LN |
63 | enum UnitDependency { |
64 | /* Positive dependencies */ | |
65 | UNIT_REQUIRES, | |
66 | UNIT_REQUIRES_OVERRIDABLE, | |
67 | UNIT_REQUISITE, | |
68 | UNIT_REQUISITE_OVERRIDABLE, | |
69 | UNIT_WANTS, | |
70 | UNIT_BINDS_TO, | |
71 | UNIT_PART_OF, | |
72 | ||
73 | /* Inverse of the above */ | |
74 | UNIT_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */ | |
75 | UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */ | |
76 | UNIT_WANTED_BY, /* inverse of 'wants' */ | |
77 | UNIT_BOUND_BY, /* inverse of 'binds_to' */ | |
78 | UNIT_CONSISTS_OF, /* inverse of 'part_of' */ | |
79 | ||
80 | /* Negative dependencies */ | |
81 | UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */ | |
82 | UNIT_CONFLICTED_BY, | |
83 | ||
84 | /* Order */ | |
85 | UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */ | |
86 | UNIT_AFTER, | |
87 | ||
88 | /* On Failure */ | |
89 | UNIT_ON_FAILURE, | |
90 | ||
91 | /* Triggers (i.e. a socket triggers a service) */ | |
92 | UNIT_TRIGGERS, | |
93 | UNIT_TRIGGERED_BY, | |
94 | ||
95 | /* Propagate reloads */ | |
96 | UNIT_PROPAGATES_RELOAD_TO, | |
97 | UNIT_RELOAD_PROPAGATED_FROM, | |
98 | ||
99 | /* Joins namespace of */ | |
100 | UNIT_JOINS_NAMESPACE_OF, | |
101 | ||
102 | /* Reference information for GC logic */ | |
103 | UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */ | |
104 | UNIT_REFERENCED_BY, | |
105 | ||
106 | _UNIT_DEPENDENCY_MAX, | |
107 | _UNIT_DEPENDENCY_INVALID = -1 | |
108 | }; | |
109 | ||
44a6b1b6 ZJS |
110 | const char *unit_type_to_string(UnitType i) _const_; |
111 | UnitType unit_type_from_string(const char *s) _pure_; | |
0a9f8ed0 | 112 | |
44a6b1b6 ZJS |
113 | const char *unit_load_state_to_string(UnitLoadState i) _const_; |
114 | UnitLoadState unit_load_state_from_string(const char *s) _pure_; | |
f69614f8 | 115 | |
9e2f7c11 LP |
116 | int unit_name_to_instance(const char *n, char **instance); |
117 | char* unit_name_to_prefix(const char *n); | |
118 | char* unit_name_to_prefix_and_instance(const char *n); | |
119 | ||
f78e6385 ZJS |
120 | enum template_valid { |
121 | TEMPLATE_INVALID, | |
122 | TEMPLATE_VALID, | |
123 | }; | |
124 | ||
125 | bool unit_name_is_valid(const char *n, enum template_valid template_ok) _pure_; | |
44a6b1b6 ZJS |
126 | bool unit_prefix_is_valid(const char *p) _pure_; |
127 | bool unit_instance_is_valid(const char *i) _pure_; | |
9e2f7c11 | 128 | |
44a6b1b6 | 129 | UnitType unit_name_to_type(const char *n) _pure_; |
5f739699 | 130 | |
9e2f7c11 LP |
131 | char *unit_name_change_suffix(const char *n, const char *suffix); |
132 | ||
133 | char *unit_name_build(const char *prefix, const char *instance, const char *suffix); | |
9e2f7c11 LP |
134 | |
135 | char *unit_name_escape(const char *f); | |
136 | char *unit_name_unescape(const char *f); | |
35eb6b12 | 137 | char *unit_name_path_escape(const char *f); |
9fc50704 LP |
138 | char *unit_name_path_unescape(const char *f); |
139 | ||
44a6b1b6 ZJS |
140 | bool unit_name_is_template(const char *n) _pure_; |
141 | bool unit_name_is_instance(const char *n) _pure_; | |
9e2f7c11 LP |
142 | |
143 | char *unit_name_replace_instance(const char *f, const char *i); | |
144 | ||
145 | char *unit_name_template(const char *f); | |
146 | ||
a16e1123 | 147 | char *unit_name_from_path(const char *path, const char *suffix); |
9fff8a1f | 148 | char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix); |
a16e1123 LP |
149 | char *unit_name_to_path(const char *name); |
150 | ||
48899192 | 151 | char *unit_dbus_path_from_name(const char *name); |
ede3a796 | 152 | int unit_name_from_dbus_path(const char *path, char **name); |
48899192 | 153 | |
f78e6385 ZJS |
154 | enum unit_name_mangle { |
155 | MANGLE_NOGLOB, | |
156 | MANGLE_GLOB, | |
157 | }; | |
158 | ||
f78e6385 | 159 | char *unit_name_mangle_with_suffix(const char *name, enum unit_name_mangle allow_globs, const char *suffix); |
5e03c6e3 ZJS |
160 | static inline char *unit_name_mangle(const char *name, enum unit_name_mangle allow_globs) { |
161 | return unit_name_mangle_with_suffix(name, allow_globs, ".service"); | |
162 | } | |
fb6becb4 LP |
163 | |
164 | int build_subslice(const char *slice, const char*name, char **subslice); | |
cb87a73b LN |
165 | |
166 | const char *unit_dependency_to_string(UnitDependency i) _const_; | |
167 | UnitDependency unit_dependency_from_string(const char *s) _pure_; |