]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/unit-name.h
systemctl: allow globbing in commands which take multiple unit names
[thirdparty/systemd.git] / src / shared / unit-name.h
CommitLineData
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 30typedef enum UnitType UnitType;
f69614f8 31typedef enum UnitLoadState UnitLoadState;
0a9f8ed0
ZJS
32
33enum UnitType {
34 UNIT_SERVICE = 0,
35 UNIT_SOCKET,
e821075a 36 UNIT_BUSNAME,
0a9f8ed0 37 UNIT_TARGET,
e821075a 38 UNIT_SNAPSHOT,
0a9f8ed0
ZJS
39 UNIT_DEVICE,
40 UNIT_MOUNT,
41 UNIT_AUTOMOUNT,
0a9f8ed0 42 UNIT_SWAP,
e821075a 43 UNIT_TIMER,
0a9f8ed0 44 UNIT_PATH,
a016b922 45 UNIT_SLICE,
6c12b52e 46 UNIT_SCOPE,
0a9f8ed0
ZJS
47 _UNIT_TYPE_MAX,
48 _UNIT_TYPE_INVALID = -1
49};
50
f69614f8 51enum UnitLoadState {
45c0c61d 52 UNIT_STUB = 0,
f69614f8 53 UNIT_LOADED,
c2756a68 54 UNIT_NOT_FOUND,
f69614f8
ZJS
55 UNIT_ERROR,
56 UNIT_MERGED,
57 UNIT_MASKED,
58 _UNIT_LOAD_STATE_MAX,
59 _UNIT_LOAD_STATE_INVALID = -1
60};
61
44a6b1b6
ZJS
62const char *unit_type_to_string(UnitType i) _const_;
63UnitType unit_type_from_string(const char *s) _pure_;
0a9f8ed0 64
44a6b1b6
ZJS
65const char *unit_load_state_to_string(UnitLoadState i) _const_;
66UnitLoadState unit_load_state_from_string(const char *s) _pure_;
f69614f8 67
9e2f7c11
LP
68int unit_name_to_instance(const char *n, char **instance);
69char* unit_name_to_prefix(const char *n);
70char* unit_name_to_prefix_and_instance(const char *n);
71
44a6b1b6
ZJS
72bool unit_name_is_valid(const char *n, bool template_ok) _pure_;
73bool unit_prefix_is_valid(const char *p) _pure_;
74bool unit_instance_is_valid(const char *i) _pure_;
9e2f7c11 75
44a6b1b6 76UnitType unit_name_to_type(const char *n) _pure_;
5f739699 77
9e2f7c11
LP
78char *unit_name_change_suffix(const char *n, const char *suffix);
79
80char *unit_name_build(const char *prefix, const char *instance, const char *suffix);
9e2f7c11
LP
81
82char *unit_name_escape(const char *f);
83char *unit_name_unescape(const char *f);
35eb6b12 84char *unit_name_path_escape(const char *f);
9fc50704
LP
85char *unit_name_path_unescape(const char *f);
86
44a6b1b6
ZJS
87bool unit_name_is_template(const char *n) _pure_;
88bool unit_name_is_instance(const char *n) _pure_;
9e2f7c11
LP
89
90char *unit_name_replace_instance(const char *f, const char *i);
91
92char *unit_name_template(const char *f);
93
a16e1123 94char *unit_name_from_path(const char *path, const char *suffix);
9fff8a1f 95char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix);
a16e1123
LP
96char *unit_name_to_path(const char *name);
97
48899192 98char *unit_dbus_path_from_name(const char *name);
ede3a796 99int unit_name_from_dbus_path(const char *path, char **name);
48899192 100
e3e0314b
ZJS
101char *unit_name_mangle(const char *name, bool allow_globs);
102char *unit_name_mangle_with_suffix(const char *name, bool allow_globs, const char *suffix);
fb6becb4
LP
103
104int build_subslice(const char *slice, const char*name, char **subslice);