chiark / gitweb /
socket: introduce SELinuxLabelViaNet option
[elogind.git] / src / shared / install.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2011 Lennart Poettering
9
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.
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
18   Lesser General Public License for more details.
19
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/>.
22 ***/
23
24 #include "hashmap.h"
25
26 typedef enum UnitFileScope {
27         UNIT_FILE_SYSTEM,
28         UNIT_FILE_GLOBAL,
29         UNIT_FILE_USER,
30         _UNIT_FILE_SCOPE_MAX,
31         _UNIT_FILE_SCOPE_INVALID = -1
32 } UnitFileScope;
33
34 typedef enum UnitFileState {
35         UNIT_FILE_ENABLED,
36         UNIT_FILE_ENABLED_RUNTIME,
37         UNIT_FILE_LINKED,
38         UNIT_FILE_LINKED_RUNTIME,
39         UNIT_FILE_MASKED,
40         UNIT_FILE_MASKED_RUNTIME,
41         UNIT_FILE_STATIC,
42         UNIT_FILE_DISABLED,
43         UNIT_FILE_INVALID,
44         _UNIT_FILE_STATE_MAX,
45         _UNIT_FILE_STATE_INVALID = -1
46 } UnitFileState;
47
48 typedef enum UnitFilePresetMode {
49         UNIT_FILE_PRESET_FULL,
50         UNIT_FILE_PRESET_ENABLE_ONLY,
51         UNIT_FILE_PRESET_DISABLE_ONLY,
52         _UNIT_FILE_PRESET_MAX,
53         _UNIT_FILE_PRESET_INVALID = -1
54 } UnitFilePresetMode;
55
56 typedef enum UnitFileChangeType {
57         UNIT_FILE_SYMLINK,
58         UNIT_FILE_UNLINK,
59         _UNIT_FILE_CHANGE_TYPE_MAX,
60         _UNIT_FILE_CHANGE_TYPE_INVALID = -1
61 } UnitFileChangeType;
62
63 typedef struct UnitFileChange {
64         UnitFileChangeType type;
65         char *path;
66         char *source;
67 } UnitFileChange;
68
69 typedef struct UnitFileList {
70         char *path;
71         UnitFileState state;
72 } UnitFileList;
73
74 typedef struct {
75         char *name;
76         char *path;
77         char *user;
78
79         char **aliases;
80         char **wanted_by;
81         char **required_by;
82
83         char *default_instance;
84 } InstallInfo;
85
86 int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
87 int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
88 int unit_file_reenable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
89 int unit_file_link(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
90 int unit_file_preset(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
91 int unit_file_preset_all(UnitFileScope scope, bool runtime, const char *root_dir, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
92 int unit_file_mask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
93 int unit_file_unmask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
94 int unit_file_set_default(UnitFileScope scope, const char *root_dir, const char *file, bool force, UnitFileChange **changes, unsigned *n_changes);
95 int unit_file_get_default(UnitFileScope scope, const char *root_dir, char **name);
96
97 UnitFileState unit_file_get_state(UnitFileScope scope, const char *root_dir, const char *filename);
98
99 int unit_file_get_list(UnitFileScope scope, const char *root_dir, Hashmap *h);
100
101 void unit_file_list_free(Hashmap *h);
102 void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes);
103
104 int unit_file_query_preset(UnitFileScope scope, const char *root_dir, const char *name);
105
106 const char *unit_file_state_to_string(UnitFileState s) _const_;
107 UnitFileState unit_file_state_from_string(const char *s) _pure_;
108
109 const char *unit_file_change_type_to_string(UnitFileChangeType s) _const_;
110 UnitFileChangeType unit_file_change_type_from_string(const char *s) _pure_;
111
112 const char *unit_file_preset_mode_to_string(UnitFilePresetMode m) _const_;
113 UnitFilePresetMode unit_file_preset_mode_from_string(const char *s) _pure_;