]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/dbus-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 #include "dissect-image.h"
9 int bus_property_get_triggered_unit(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);
11 #define BUS_DEFINE_SET_TRANSIENT(function, bus_type, type, cast_type, fmt) \
12 int bus_set_transient_##function( \
16 sd_bus_message *message, \
17 UnitWriteFlags flags, \
18 sd_bus_error *error) { \
25 r = sd_bus_message_read(message, bus_type, &v); \
29 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
31 unit_write_settingf(u, flags, name, \
32 "%s=" fmt, name, v); \
38 #define BUS_DEFINE_SET_TRANSIENT_IS_VALID(function, bus_type, type, cast_type, fmt, check) \
39 int bus_set_transient_##function( \
43 sd_bus_message *message, \
44 UnitWriteFlags flags, \
45 sd_bus_error *error) { \
52 r = sd_bus_message_read(message, bus_type, &v); \
57 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
58 "Invalid %s setting: " fmt, name, v); \
60 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
62 unit_write_settingf(u, flags, name, \
63 "%s=" fmt, name, v); \
69 #define BUS_DEFINE_SET_TRANSIENT_TO_STRING(function, bus_type, type, cast_type, fmt, to_string) \
70 int bus_set_transient_##function( \
74 sd_bus_message *message, \
75 UnitWriteFlags flags, \
76 sd_bus_error *error) { \
84 r = sd_bus_message_read(message, bus_type, &v); \
90 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
91 "Invalid %s setting: " fmt, name, v); \
93 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
95 unit_write_settingf(u, flags, name, \
102 #define BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(function, bus_type, type, cast_type, fmt, to_string) \
103 int bus_set_transient_##function( \
107 sd_bus_message *message, \
108 UnitWriteFlags flags, \
109 sd_bus_error *error) { \
111 _cleanup_free_ char *s = NULL; \
117 r = sd_bus_message_read(message, bus_type, &v); \
121 r = to_string(v, &s); \
123 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
124 "Invalid %s setting: " fmt, name, v); \
128 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
129 *p = (cast_type) v; \
130 unit_write_settingf(u, flags, name, \
132 name, strempty(s)); \
138 #define BUS_DEFINE_SET_TRANSIENT_PARSE(function, type, parse) \
139 int bus_set_transient_##function( \
143 sd_bus_message *message, \
144 UnitWriteFlags flags, \
145 sd_bus_error *error) { \
153 r = sd_bus_message_read(message, "s", &s); \
159 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
160 "Invalid %s setting: %s", name, s); \
162 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
164 unit_write_settingf(u, flags, name, \
171 #define BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(function, type, parse) \
172 int bus_set_transient_##function( \
176 sd_bus_message *message, \
177 UnitWriteFlags flags, \
178 sd_bus_error *error) { \
186 r = sd_bus_message_read(message, "s", &s); \
192 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
193 "Invalid %s setting: %s", name, s); \
195 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
197 unit_write_settingf(u, flags, name, \
198 "%s=%s", name, strempty(s)); \
204 #define BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(function, check) \
205 int bus_set_transient_##function( \
209 sd_bus_message *message, \
210 UnitWriteFlags flags, \
211 sd_bus_error *error) { \
218 r = sd_bus_message_read(message, "s", &v); \
222 if (!isempty(v) && !check(v)) \
223 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
224 "Invalid %s setting: %s", name, v); \
226 if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
227 r = free_and_strdup(p, empty_to_null(v)); \
231 unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, \
232 "%s=%s", name, strempty(v)); \
238 int bus_set_transient_mode_t(Unit
*u
, const char *name
, mode_t
*p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
239 int bus_set_transient_unsigned(Unit
*u
, const char *name
, unsigned *p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
240 int bus_set_transient_user_relaxed(Unit
*u
, const char *name
, char **p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
241 int bus_set_transient_path(Unit
*u
, const char *name
, char **p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
242 int bus_set_transient_string(Unit
*u
, const char *name
, char **p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
243 int bus_set_transient_bool(Unit
*u
, const char *name
, bool *p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
244 int bus_set_transient_tristate(Unit
*u
, const char *name
, int *p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
245 int bus_set_transient_usec_internal(Unit
*u
, const char *name
, usec_t
*p
, bool fix_0
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
);
246 static inline int bus_set_transient_usec(Unit
*u
, const char *name
, usec_t
*p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
) {
247 return bus_set_transient_usec_internal(u
, name
, p
, false, message
, flags
, error
);
249 static inline int bus_set_transient_usec_fix_0(Unit
*u
, const char *name
, usec_t
*p
, sd_bus_message
*message
, UnitWriteFlags flags
, sd_bus_error
*error
) {
250 return bus_set_transient_usec_internal(u
, name
, p
, true, message
, flags
, error
);
252 int bus_verify_manage_units_async_full(Unit
*u
, const char *verb
, const char *polkit_message
, sd_bus_message
*call
, sd_bus_error
*error
);
254 int bus_read_mount_options(sd_bus_message
*message
, sd_bus_error
*error
, MountOptions
**ret_options
, char **ret_format_str
, const char *separator
);
256 int bus_property_get_activation_details(sd_bus
*bus
, const char *path
, const char *interface
, const char *property
, sd_bus_message
*reply
, void *userdata
, sd_bus_error
*error
);