chiark / gitweb /
c6c09dd31feb5136680594b649f1cb6d2e5c699d
[elogind.git] / src / shared / unit-name.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foounitnamehfoo
4 #define foounitnamehfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2010 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU Lesser General Public License as published by
13   the Free Software Foundation; either version 2.1 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <stdbool.h>
26
27 #define UNIT_NAME_MAX 256
28
29 typedef enum UnitType UnitType;
30 typedef enum UnitLoadState UnitLoadState;
31
32 enum UnitType {
33         UNIT_SERVICE = 0,
34         UNIT_SOCKET,
35         UNIT_TARGET,
36         UNIT_DEVICE,
37         UNIT_MOUNT,
38         UNIT_AUTOMOUNT,
39         UNIT_SNAPSHOT,
40         UNIT_TIMER,
41         UNIT_SWAP,
42         UNIT_PATH,
43         _UNIT_TYPE_MAX,
44         _UNIT_TYPE_INVALID = -1
45 };
46
47 enum UnitLoadState {
48         UNIT_STUB,
49         UNIT_LOADED,
50         UNIT_ERROR,
51         UNIT_MERGED,
52         UNIT_MASKED,
53         _UNIT_LOAD_STATE_MAX,
54         _UNIT_LOAD_STATE_INVALID = -1
55 };
56
57 const char *unit_type_to_string(UnitType i);
58 UnitType unit_type_from_string(const char *s);
59
60 const char *unit_load_state_to_string(UnitLoadState i);
61 UnitLoadState unit_load_state_from_string(const char *s);
62
63 int unit_name_to_instance(const char *n, char **instance);
64 char* unit_name_to_prefix(const char *n);
65 char* unit_name_to_prefix_and_instance(const char *n);
66
67 bool unit_name_is_valid(const char *n, bool template_ok);
68 bool unit_prefix_is_valid(const char *p);
69 bool unit_instance_is_valid(const char *i);
70
71 UnitType unit_name_to_type(const char *n);
72
73 char *unit_name_change_suffix(const char *n, const char *suffix);
74
75 char *unit_name_build(const char *prefix, const char *instance, const char *suffix);
76
77 char *unit_name_escape(const char *f);
78 char *unit_name_unescape(const char *f);
79 char *unit_name_path_escape(const char *f);
80 char *unit_name_path_unescape(const char *f);
81
82 bool unit_name_is_template(const char *n);
83
84 char *unit_name_replace_instance(const char *f, const char *i);
85
86 char *unit_name_template(const char *f);
87
88 char *unit_name_from_path(const char *path, const char *suffix);
89 char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix);
90 char *unit_name_to_path(const char *name);
91
92 char *unit_dbus_path_from_name(const char *name);
93
94 char *unit_name_mangle(const char *name);
95
96 #endif