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 typedef enum UnitLoadState UnitLoadState;
32 typedef enum UnitDependency UnitDependency;
49 _UNIT_TYPE_INVALID = -1
60 _UNIT_LOAD_STATE_INVALID = -1
64 /* Positive dependencies */
66 UNIT_REQUIRES_OVERRIDABLE,
68 UNIT_REQUISITE_OVERRIDABLE,
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' */
80 /* Negative dependencies */
81 UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
85 UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
91 /* Triggers (i.e. a socket triggers a service) */
95 /* Propagate reloads */
96 UNIT_PROPAGATES_RELOAD_TO,
97 UNIT_RELOAD_PROPAGATED_FROM,
99 /* Joins namespace of */
100 UNIT_JOINS_NAMESPACE_OF,
102 /* Reference information for GC logic */
103 UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
106 _UNIT_DEPENDENCY_MAX,
107 _UNIT_DEPENDENCY_INVALID = -1
110 const char *unit_type_to_string(UnitType i) _const_;
111 UnitType unit_type_from_string(const char *s) _pure_;
113 const char *unit_load_state_to_string(UnitLoadState i) _const_;
114 UnitLoadState unit_load_state_from_string(const char *s) _pure_;
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);
120 enum template_valid {
125 bool unit_name_is_valid(const char *n, enum template_valid template_ok) _pure_;
126 bool unit_prefix_is_valid(const char *p) _pure_;
127 bool unit_instance_is_valid(const char *i) _pure_;
129 UnitType unit_name_to_type(const char *n) _pure_;
131 char *unit_name_change_suffix(const char *n, const char *suffix);
133 char *unit_name_build(const char *prefix, const char *instance, const char *suffix);
135 char *unit_name_escape(const char *f);
136 char *unit_name_unescape(const char *f);
137 char *unit_name_path_escape(const char *f);
138 char *unit_name_path_unescape(const char *f);
140 bool unit_name_is_template(const char *n) _pure_;
141 bool unit_name_is_instance(const char *n) _pure_;
143 char *unit_name_replace_instance(const char *f, const char *i);
145 char *unit_name_template(const char *f);
147 char *unit_name_from_path(const char *path, const char *suffix);
148 char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix);
149 char *unit_name_to_path(const char *name);
151 char *unit_dbus_path_from_name(const char *name);
152 int unit_name_from_dbus_path(const char *path, char **name);
154 enum unit_name_mangle {
159 char *unit_name_mangle_with_suffix(const char *name, enum unit_name_mangle allow_globs, const char *suffix);
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");
164 int build_subslice(const char *slice, const char*name, char **subslice);
166 const char *unit_dependency_to_string(UnitDependency i) _const_;
167 UnitDependency unit_dependency_from_string(const char *s) _pure_;