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/>.
28 #define UNIT_NAME_MAX 256
30 typedef enum UnitType UnitType;
31 // UNNEEDED typedef enum UnitLoadState UnitLoadState;
32 // UNNNEEDED typedef enum UnitDependency UnitDependency;
49 _UNIT_TYPE_INVALID = -1
52 /// UNNEEDED by elogind
62 _UNIT_LOAD_STATE_INVALID = -1
66 /* Positive dependencies */
68 UNIT_REQUIRES_OVERRIDABLE,
70 UNIT_REQUISITE_OVERRIDABLE,
75 /* Inverse of the above */
76 UNIT_REQUIRED_BY, /* inverse of 'requires' is 'required_by' */
77 UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' is 'required_by_overridable' */
78 UNIT_REQUISITE_OF, /* inverse of 'requisite' is 'requisite_of' */
79 UNIT_REQUISITE_OF_OVERRIDABLE,/* inverse of 'requisite_overridable' is 'requisite_of_overridable' */
80 UNIT_WANTED_BY, /* inverse of 'wants' */
81 UNIT_BOUND_BY, /* inverse of 'binds_to' */
82 UNIT_CONSISTS_OF, /* inverse of 'part_of' */
84 /* Negative dependencies */
85 UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
89 UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
95 /* Triggers (i.e. a socket triggers a service) */
99 /* Propagate reloads */
100 UNIT_PROPAGATES_RELOAD_TO,
101 UNIT_RELOAD_PROPAGATED_FROM,
103 /* Joins namespace of */
104 UNIT_JOINS_NAMESPACE_OF,
106 /* Reference information for GC logic */
107 UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
110 _UNIT_DEPENDENCY_MAX,
111 _UNIT_DEPENDENCY_INVALID = -1
115 typedef enum UnitNameFlags {
116 UNIT_NAME_PLAIN = 1, /* Allow foo.service */
117 UNIT_NAME_INSTANCE = 2, /* Allow foo@bar.service */
118 UNIT_NAME_TEMPLATE = 4, /* Allow foo@.service */
119 UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE,
122 bool unit_name_is_valid(const char *n, UnitNameFlags flags) _pure_;
123 bool unit_prefix_is_valid(const char *p) _pure_;
124 bool unit_instance_is_valid(const char *i) _pure_;
125 bool unit_suffix_is_valid(const char *s) _pure_;
127 /// UNNEEDED by elogind
129 static inline int unit_prefix_and_instance_is_valid(const char *p) {
130 /* For prefix+instance and instance the same rules apply */
131 return unit_instance_is_valid(p);
135 // UNNEEDED int unit_name_to_prefix(const char *n, char **prefix);
136 // UNNEEDED int unit_name_to_instance(const char *n, char **instance);
137 // UNNEEDED int unit_name_to_prefix_and_instance(const char *n, char **ret);
139 // UNNEEDED UnitType unit_name_to_type(const char *n) _pure_;
141 // UNNEEDED int unit_name_change_suffix(const char *n, const char *suffix, char **ret);
143 int unit_name_build(const char *prefix, const char *instance, const char *suffix, char **ret);
145 // UNNEEDED char *unit_name_escape(const char *f);
146 // UNNEEDED int unit_name_unescape(const char *f, char **ret);
147 // UNNEEDED int unit_name_path_escape(const char *f, char **ret);
148 // UNNEEDED int unit_name_path_unescape(const char *f, char **ret);
150 // UNNEEDED int unit_name_replace_instance(const char *f, const char *i, char **ret);
152 // UNNEEDED int unit_name_template(const char *f, char **ret);
154 // UNNEEDED int unit_name_from_path(const char *path, const char *suffix, char **ret);
155 // UNNEEDED int unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix, char **ret);
156 // UNNEEDED int unit_name_to_path(const char *name, char **ret);
158 // UNNEEDED char *unit_dbus_path_from_name(const char *name);
159 // UNNEEDED int unit_name_from_dbus_path(const char *path, char **name);
161 // UNNEEDED const char* unit_dbus_interface_from_type(UnitType t);
162 // UNNEEDED const char *unit_dbus_interface_from_name(const char *name);
164 /// UNNEEDED by elogind
166 typedef enum UnitNameMangle {
171 int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, const char *suffix, char **ret);
173 static inline int unit_name_mangle(const char *name, UnitNameMangle allow_globs, char **ret) {
174 return unit_name_mangle_with_suffix(name, allow_globs, ".service", ret);
178 // UNNEEDED int slice_build_parent_slice(const char *slice, char **ret);
179 int slice_build_subslice(const char *slice, const char*name, char **subslice);
180 bool slice_name_is_valid(const char *name);
182 const char *unit_type_to_string(UnitType i) _const_;
183 UnitType unit_type_from_string(const char *s) _pure_;
185 // UNNEEDED const char *unit_load_state_to_string(UnitLoadState i) _const_;
186 // UNNEEDED UnitLoadState unit_load_state_from_string(const char *s) _pure_;
188 // UNNEEDED const char *unit_dependency_to_string(UnitDependency i) _const_;
189 // UNNEEDED UnitDependency unit_dependency_from_string(const char *s) _pure_;