]>
Commit | Line | Data |
---|---|---|
83096483 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
c2f1db8f | 3 | #pragma once |
83096483 LP |
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 | |
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 | |
83096483 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. |
83096483 | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
83096483 LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
cab6235f LP |
24 | typedef enum UnitFileScope UnitFileScope; |
25 | typedef enum UnitFileState UnitFileState; | |
26 | typedef enum UnitFilePresetMode UnitFilePresetMode; | |
27 | typedef enum UnitFileChangeType UnitFileChangeType; | |
28 | typedef struct UnitFileChange UnitFileChange; | |
29 | typedef struct UnitFileList UnitFileList; | |
30 | typedef struct UnitFileInstallInfo UnitFileInstallInfo; | |
31 | ||
83096483 | 32 | #include "hashmap.h" |
e94937df | 33 | #include "unit-name.h" |
a8ffe6fb | 34 | #include "path-lookup.h" |
83096483 | 35 | |
cab6235f | 36 | enum UnitFileScope { |
83096483 LP |
37 | UNIT_FILE_SYSTEM, |
38 | UNIT_FILE_GLOBAL, | |
39 | UNIT_FILE_USER, | |
40 | _UNIT_FILE_SCOPE_MAX, | |
41 | _UNIT_FILE_SCOPE_INVALID = -1 | |
cab6235f | 42 | }; |
83096483 | 43 | |
cab6235f | 44 | enum UnitFileState { |
83096483 LP |
45 | UNIT_FILE_ENABLED, |
46 | UNIT_FILE_ENABLED_RUNTIME, | |
47 | UNIT_FILE_LINKED, | |
48 | UNIT_FILE_LINKED_RUNTIME, | |
49 | UNIT_FILE_MASKED, | |
50 | UNIT_FILE_MASKED_RUNTIME, | |
51 | UNIT_FILE_STATIC, | |
52 | UNIT_FILE_DISABLED, | |
aedd4012 | 53 | UNIT_FILE_INDIRECT, |
b5b46d59 | 54 | UNIT_FILE_INVALID, |
83096483 LP |
55 | _UNIT_FILE_STATE_MAX, |
56 | _UNIT_FILE_STATE_INVALID = -1 | |
cab6235f | 57 | }; |
83096483 | 58 | |
cab6235f | 59 | enum UnitFilePresetMode { |
d309c1c3 LP |
60 | UNIT_FILE_PRESET_FULL, |
61 | UNIT_FILE_PRESET_ENABLE_ONLY, | |
62 | UNIT_FILE_PRESET_DISABLE_ONLY, | |
86bbe5bf | 63 | _UNIT_FILE_PRESET_MAX, |
d309c1c3 | 64 | _UNIT_FILE_PRESET_INVALID = -1 |
cab6235f | 65 | }; |
d309c1c3 | 66 | |
cab6235f | 67 | enum UnitFileChangeType { |
83096483 LP |
68 | UNIT_FILE_SYMLINK, |
69 | UNIT_FILE_UNLINK, | |
70 | _UNIT_FILE_CHANGE_TYPE_MAX, | |
71 | _UNIT_FILE_CHANGE_TYPE_INVALID = -1 | |
cab6235f | 72 | }; |
83096483 | 73 | |
cab6235f | 74 | struct UnitFileChange { |
83096483 LP |
75 | UnitFileChangeType type; |
76 | char *path; | |
77 | char *source; | |
cab6235f | 78 | }; |
83096483 | 79 | |
cab6235f | 80 | struct UnitFileList { |
83096483 LP |
81 | char *path; |
82 | UnitFileState state; | |
cab6235f | 83 | }; |
83096483 | 84 | |
cab6235f | 85 | struct UnitFileInstallInfo { |
7584d236 ZJS |
86 | char *name; |
87 | char *path; | |
3f0b2f0f | 88 | char *user; |
7584d236 ZJS |
89 | |
90 | char **aliases; | |
91 | char **wanted_by; | |
92 | char **required_by; | |
aedd4012 | 93 | char **also; |
d54c4993 LP |
94 | |
95 | char *default_instance; | |
cab6235f | 96 | }; |
7584d236 | 97 | |
7195aa42 ZJS |
98 | int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes); |
99 | int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes); | |
100 | int unit_file_reenable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes); | |
101 | int unit_file_link(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes); | |
d309c1c3 LP |
102 | int unit_file_preset(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes); |
103 | int unit_file_preset_all(UnitFileScope scope, bool runtime, const char *root_dir, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes); | |
7195aa42 ZJS |
104 | int unit_file_mask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes); |
105 | int unit_file_unmask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes); | |
718db961 | 106 | int unit_file_set_default(UnitFileScope scope, const char *root_dir, const char *file, bool force, UnitFileChange **changes, unsigned *n_changes); |
99504dd4 | 107 | int unit_file_get_default(UnitFileScope scope, const char *root_dir, char **name); |
e94937df | 108 | int unit_file_add_dependency(UnitFileScope scope, bool runtime, const char *root_dir, char **files, char *target, UnitDependency dep, bool force, UnitFileChange **changes, unsigned *n_changes); |
83096483 | 109 | |
a8ffe6fb ZJS |
110 | UnitFileState unit_file_lookup_state( |
111 | UnitFileScope scope, | |
112 | const char *root_dir, | |
113 | const LookupPaths *paths, | |
114 | const char *name); | |
115 | UnitFileState unit_file_get_state( | |
116 | UnitFileScope scope, | |
117 | const char *root_dir, | |
118 | const char *filename); | |
83096483 LP |
119 | |
120 | int unit_file_get_list(UnitFileScope scope, const char *root_dir, Hashmap *h); | |
121 | ||
122 | void unit_file_list_free(Hashmap *h); | |
123 | void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes); | |
124 | ||
c2a8d7b0 | 125 | int unit_file_query_preset(UnitFileScope scope, const char *root_dir, const char *name); |
83096483 | 126 | |
44a6b1b6 ZJS |
127 | const char *unit_file_state_to_string(UnitFileState s) _const_; |
128 | UnitFileState unit_file_state_from_string(const char *s) _pure_; | |
83096483 | 129 | |
44a6b1b6 ZJS |
130 | const char *unit_file_change_type_to_string(UnitFileChangeType s) _const_; |
131 | UnitFileChangeType unit_file_change_type_from_string(const char *s) _pure_; | |
d309c1c3 LP |
132 | |
133 | const char *unit_file_preset_mode_to_string(UnitFilePresetMode m) _const_; | |
134 | UnitFilePresetMode unit_file_preset_mode_from_string(const char *s) _pure_; |