Merge pull request #8968 from yuwata/bus-macro-2
bus-util: add several macros for defining functions of getting dbus properties
This commit is contained in:
commit
9d728570e7
|
@ -57,6 +57,9 @@ static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_exec_keyring_mode, exec_keyring
|
|||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_home, protect_home, ProtectHome);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_system, protect_system, ProtectSystem);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_personality, personality, unsigned long);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_ioprio, "i", ExecContext, exec_context_get_effective_ioprio);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_class, "i", ExecContext, exec_context_get_effective_ioprio, IOPRIO_PRIO_CLASS);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_priority, "i", ExecContext, exec_context_get_effective_ioprio, IOPRIO_PRIO_DATA);
|
||||
|
||||
static int property_get_environment_files(
|
||||
sd_bus *bus,
|
||||
|
@ -147,60 +150,6 @@ static int property_get_nice(
|
|||
return sd_bus_message_append(reply, "i", n);
|
||||
}
|
||||
|
||||
static int property_get_ioprio(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
ExecContext *c = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(c);
|
||||
|
||||
return sd_bus_message_append(reply, "i", exec_context_get_effective_ioprio(c));
|
||||
}
|
||||
|
||||
static int property_get_ioprio_class(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
ExecContext *c = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(c);
|
||||
|
||||
return sd_bus_message_append(reply, "i", IOPRIO_PRIO_CLASS(exec_context_get_effective_ioprio(c)));
|
||||
}
|
||||
|
||||
static int property_get_ioprio_priority(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
ExecContext *c = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(c);
|
||||
|
||||
return sd_bus_message_append(reply, "i", IOPRIO_PRIO_DATA(exec_context_get_effective_ioprio(c)));
|
||||
}
|
||||
|
||||
static int property_get_cpu_sched_policy(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
|
|
@ -46,35 +46,12 @@ static UnitFileFlags unit_file_bools_to_flags(bool runtime, bool force) {
|
|||
(force ? UNIT_FILE_FORCE : 0);
|
||||
}
|
||||
|
||||
static int property_get_version(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
return sd_bus_message_append(reply, "s", PACKAGE_VERSION);
|
||||
}
|
||||
|
||||
static int property_get_features(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
return sd_bus_message_append(reply, "s", SYSTEMD_FEATURES);
|
||||
}
|
||||
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_version, "s", PACKAGE_VERSION);
|
||||
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_features, "s", SYSTEMD_FEATURES);
|
||||
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_architecture, "s", architecture_to_string(uname_architecture()));
|
||||
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_log_target, "s", log_target_to_string(log_get_target()));
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_system_state, "s", Manager, manager_state, manager_state_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_timer_slack_nsec, "t", (uint64_t) prctl(PR_GET_TIMERSLACK));
|
||||
|
||||
static int property_get_virtualization(
|
||||
sd_bus *bus,
|
||||
|
@ -102,21 +79,6 @@ static int property_get_virtualization(
|
|||
v == VIRTUALIZATION_NONE ? NULL : virtualization_to_string(v));
|
||||
}
|
||||
|
||||
static int property_get_architecture(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
return sd_bus_message_append(reply, "s", architecture_to_string(uname_architecture()));
|
||||
}
|
||||
|
||||
static int property_get_tainted(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -140,21 +102,6 @@ static int property_get_tainted(
|
|||
return sd_bus_message_append(reply, "s", s);
|
||||
}
|
||||
|
||||
static int property_get_log_target(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
return sd_bus_message_append(reply, "s", log_target_to_string(log_get_target()));
|
||||
}
|
||||
|
||||
static int property_set_log_target(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -224,7 +171,7 @@ static int property_set_log_level(
|
|||
return r;
|
||||
}
|
||||
|
||||
static int property_get_n_names(
|
||||
static int property_get_hashmap_size(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
|
@ -233,16 +180,16 @@ static int property_get_n_names(
|
|||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
Hashmap **h = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
assert(h);
|
||||
|
||||
return sd_bus_message_append(reply, "u", (uint32_t) hashmap_size(m->units));
|
||||
return sd_bus_message_append(reply, "u", (uint32_t) hashmap_size(*h));
|
||||
}
|
||||
|
||||
static int property_get_n_failed_units(
|
||||
static int property_get_set_size(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
|
@ -251,31 +198,13 @@ static int property_get_n_failed_units(
|
|||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
Set **s = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "u", (uint32_t) set_size(m->failed_units));
|
||||
}
|
||||
|
||||
static int property_get_n_jobs(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
return sd_bus_message_append(reply, "u", (uint32_t) hashmap_size(m->jobs));
|
||||
return sd_bus_message_append(reply, "u", (uint32_t) set_size(*s));
|
||||
}
|
||||
|
||||
static int property_get_progress(
|
||||
|
@ -302,24 +231,6 @@ static int property_get_progress(
|
|||
return sd_bus_message_append(reply, "d", d);
|
||||
}
|
||||
|
||||
static int property_get_system_state(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
return sd_bus_message_append(reply, "s", manager_state_to_string(manager_state(m)));
|
||||
}
|
||||
|
||||
static int property_set_runtime_watchdog(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -344,21 +255,6 @@ static int property_set_runtime_watchdog(
|
|||
return watchdog_set_timeout(t);
|
||||
}
|
||||
|
||||
static int property_get_timer_slack_nsec(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
return sd_bus_message_append(reply, "t", (uint64_t) prctl(PR_GET_TIMERSLACK));
|
||||
}
|
||||
|
||||
static int bus_get_unit_by_name(Manager *m, sd_bus_message *message, const char *name, Unit **ret_unit, sd_bus_error *error) {
|
||||
Unit *u;
|
||||
int r;
|
||||
|
@ -2519,9 +2415,9 @@ const sd_bus_vtable bus_manager_vtable[] = {
|
|||
BUS_PROPERTY_DUAL_TIMESTAMP("UnitsLoadFinishTimestamp", offsetof(Manager, timestamps[MANAGER_TIMESTAMP_UNITS_LOAD_FINISH]), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_WRITABLE_PROPERTY("LogLevel", "s", property_get_log_level, property_set_log_level, 0, 0),
|
||||
SD_BUS_WRITABLE_PROPERTY("LogTarget", "s", property_get_log_target, property_set_log_target, 0, 0),
|
||||
SD_BUS_PROPERTY("NNames", "u", property_get_n_names, 0, 0),
|
||||
SD_BUS_PROPERTY("NFailedUnits", "u", property_get_n_failed_units, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("NJobs", "u", property_get_n_jobs, 0, 0),
|
||||
SD_BUS_PROPERTY("NNames", "u", property_get_hashmap_size, offsetof(Manager, units), 0),
|
||||
SD_BUS_PROPERTY("NFailedUnits", "u", property_get_set_size, offsetof(Manager, failed_units), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("NJobs", "u", property_get_hashmap_size, offsetof(Manager, jobs), 0),
|
||||
SD_BUS_PROPERTY("NInstalledJobs", "u", bus_property_get_unsigned, offsetof(Manager, n_installed_jobs), 0),
|
||||
SD_BUS_PROPERTY("NFailedJobs", "u", bus_property_get_unsigned, offsetof(Manager, n_failed_jobs), 0),
|
||||
SD_BUS_PROPERTY("Progress", "d", property_get_progress, 0, 0),
|
||||
|
|
|
@ -15,78 +15,33 @@
|
|||
#include "string-util.h"
|
||||
#include "unit.h"
|
||||
|
||||
static int property_get_what(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Mount *m = userdata;
|
||||
const char *d = NULL;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
static const char *mount_get_what(const Mount *m) {
|
||||
if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what)
|
||||
d = m->parameters_proc_self_mountinfo.what;
|
||||
else if (m->from_fragment && m->parameters_fragment.what)
|
||||
d = m->parameters_fragment.what;
|
||||
|
||||
return sd_bus_message_append(reply, "s", d);
|
||||
return m->parameters_proc_self_mountinfo.what;
|
||||
if (m->from_fragment && m->parameters_fragment.what)
|
||||
return m->parameters_fragment.what;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int property_get_options(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Mount *m = userdata;
|
||||
const char *d = NULL;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
static const char *mount_get_options(const Mount *m) {
|
||||
if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.options)
|
||||
d = m->parameters_proc_self_mountinfo.options;
|
||||
else if (m->from_fragment && m->parameters_fragment.options)
|
||||
d = m->parameters_fragment.options;
|
||||
|
||||
return sd_bus_message_append(reply, "s", d);
|
||||
return m->parameters_proc_self_mountinfo.options;
|
||||
if (m->from_fragment && m->parameters_fragment.options)
|
||||
return m->parameters_fragment.options;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int property_get_type(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
const char *fstype = NULL;
|
||||
Mount *m = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(m);
|
||||
|
||||
static const char *mount_get_fstype(const Mount *m) {
|
||||
if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.fstype)
|
||||
fstype = m->parameters_proc_self_mountinfo.fstype;
|
||||
return m->parameters_proc_self_mountinfo.fstype;
|
||||
else if (m->from_fragment && m->parameters_fragment.fstype)
|
||||
fstype = m->parameters_fragment.fstype;
|
||||
|
||||
return sd_bus_message_append(reply, "s", fstype);
|
||||
return m->parameters_fragment.fstype;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_what, "s", Mount, mount_get_what);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Mount, mount_get_options);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_type, "s", Mount, mount_get_fstype);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, mount_result, MountResult);
|
||||
|
||||
const sd_bus_vtable bus_mount_vtable[] = {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, socket_result, SocketResult);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_fdname, "s", Socket, socket_fdname);
|
||||
|
||||
static int property_get_listen(
|
||||
sd_bus *bus,
|
||||
|
@ -78,24 +79,6 @@ static int property_get_listen(
|
|||
return sd_bus_message_close_container(reply);
|
||||
}
|
||||
|
||||
static int property_get_fdname(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Socket *s = SOCKET(userdata);
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return sd_bus_message_append(reply, "s", socket_fdname(s));
|
||||
}
|
||||
|
||||
const sd_bus_vtable bus_socket_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
SD_BUS_PROPERTY("BindIPv6Only", "s", property_get_bind_ipv6_only, offsetof(Socket, bind_ipv6_only), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
|
|
|
@ -14,54 +14,22 @@
|
|||
#include "swap.h"
|
||||
#include "unit.h"
|
||||
|
||||
static int property_get_priority(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Swap *s = SWAP(userdata);
|
||||
int p;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
static int swap_get_priority(Swap *s) {
|
||||
if (s->from_proc_swaps)
|
||||
p = s->parameters_proc_swaps.priority;
|
||||
else if (s->from_fragment)
|
||||
p = s->parameters_fragment.priority;
|
||||
else
|
||||
p = -1;
|
||||
|
||||
return sd_bus_message_append(reply, "i", p);
|
||||
}
|
||||
|
||||
static int property_get_options(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Swap *s = SWAP(userdata);
|
||||
const char *options = NULL;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(s);
|
||||
|
||||
return s->parameters_proc_swaps.priority;
|
||||
if (s->from_fragment)
|
||||
options = s->parameters_fragment.options;
|
||||
|
||||
return sd_bus_message_append(reply, "s", options);
|
||||
return s->parameters_fragment.priority;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *swap_get_options(Swap *s) {
|
||||
if (s->from_fragment)
|
||||
return s->parameters_fragment.options;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_priority, "i", Swap, swap_get_priority);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Swap, swap_get_options);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, swap_result, SwapResult);
|
||||
|
||||
const sd_bus_vtable bus_swap_vtable[] = {
|
||||
|
|
|
@ -33,6 +33,12 @@ static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_collect_mode, collect_mode, Col
|
|||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_load_state, unit_load_state, UnitLoadState);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_job_mode, job_mode, JobMode);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_emergency_action, emergency_action, EmergencyAction);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_description, "s", Unit, unit_description);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_active_state, "s", Unit, unit_active_state, unit_active_state_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_sub_state, "s", Unit, unit_sub_state_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_unit_file_state, "s", Unit, unit_get_unit_file_state, unit_file_state_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_can_reload, "b", Unit, unit_can_reload);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_need_daemon_reload, "b", Unit, unit_need_daemon_reload);
|
||||
|
||||
static int property_get_names(
|
||||
sd_bus *bus,
|
||||
|
@ -93,7 +99,7 @@ static int property_get_dependencies(
|
|||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Hashmap *h = *(Hashmap**) userdata;
|
||||
Hashmap **h = userdata;
|
||||
Iterator j;
|
||||
Unit *u;
|
||||
void *v;
|
||||
|
@ -101,12 +107,13 @@ static int property_get_dependencies(
|
|||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(h);
|
||||
|
||||
r = sd_bus_message_open_container(reply, 'a', "s");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
HASHMAP_FOREACH_KEY(v, u, h, j) {
|
||||
HASHMAP_FOREACH_KEY(v, u, *h, j) {
|
||||
r = sd_bus_message_append(reply, "s", u->id);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -140,7 +147,7 @@ static int property_get_requires_mounts_for(
|
|||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Hashmap *h = *(Hashmap**) userdata;
|
||||
Hashmap **h = userdata;
|
||||
const char *p;
|
||||
Iterator j;
|
||||
void *v;
|
||||
|
@ -148,12 +155,13 @@ static int property_get_requires_mounts_for(
|
|||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(h);
|
||||
|
||||
r = sd_bus_message_open_container(reply, 'a', "s");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
HASHMAP_FOREACH_KEY(v, p, h, j) {
|
||||
HASHMAP_FOREACH_KEY(v, p, *h, j) {
|
||||
r = sd_bus_message_append(reply, "s", p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -162,60 +170,6 @@ static int property_get_requires_mounts_for(
|
|||
return sd_bus_message_close_container(reply);
|
||||
}
|
||||
|
||||
static int property_get_description(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "s", unit_description(u));
|
||||
}
|
||||
|
||||
static int property_get_active_state(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "s", unit_active_state_to_string(unit_active_state(u)));
|
||||
}
|
||||
|
||||
static int property_get_sub_state(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "s", unit_sub_state_to_string(u));
|
||||
}
|
||||
|
||||
static int property_get_unit_file_preset(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -239,24 +193,6 @@ static int property_get_unit_file_preset(
|
|||
r > 0 ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
static int property_get_unit_file_state(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "s", unit_file_state_to_string(unit_get_unit_file_state(u)));
|
||||
}
|
||||
|
||||
static int property_get_can_start(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -293,24 +229,6 @@ static int property_get_can_stop(
|
|||
return sd_bus_message_append(reply, "b", unit_can_stop(u) && !u->refuse_manual_stop);
|
||||
}
|
||||
|
||||
static int property_get_can_reload(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "b", unit_can_reload(u));
|
||||
}
|
||||
|
||||
static int property_get_can_isolate(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
@ -355,24 +273,6 @@ static int property_get_job(
|
|||
return sd_bus_message_append(reply, "(uo)", u->job->id, p);
|
||||
}
|
||||
|
||||
static int property_get_need_daemon_reload(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = userdata;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
assert(u);
|
||||
|
||||
return sd_bus_message_append(reply, "b", unit_need_daemon_reload(u));
|
||||
}
|
||||
|
||||
static int property_get_conditions(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
|
|
@ -122,6 +122,44 @@ assert_cc(sizeof(mode_t) == sizeof(uint32_t));
|
|||
int bus_log_parse_error(int r);
|
||||
int bus_log_create_error(int r);
|
||||
|
||||
#define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val) \
|
||||
int function(sd_bus *bus, \
|
||||
const char *path, \
|
||||
const char *interface, \
|
||||
const char *property, \
|
||||
sd_bus_message *reply, \
|
||||
void *userdata, \
|
||||
sd_bus_error *error) { \
|
||||
\
|
||||
assert(bus); \
|
||||
assert(reply); \
|
||||
\
|
||||
return sd_bus_message_append(reply, bus_type, val); \
|
||||
}
|
||||
|
||||
#define BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, get2) \
|
||||
int function(sd_bus *bus, \
|
||||
const char *path, \
|
||||
const char *interface, \
|
||||
const char *property, \
|
||||
sd_bus_message *reply, \
|
||||
void *userdata, \
|
||||
sd_bus_error *error) { \
|
||||
\
|
||||
data_type *data = userdata; \
|
||||
\
|
||||
assert(bus); \
|
||||
assert(reply); \
|
||||
assert(data); \
|
||||
\
|
||||
return sd_bus_message_append(reply, bus_type, \
|
||||
get2(get1(data))); \
|
||||
}
|
||||
|
||||
#define ident(x) (x)
|
||||
#define BUS_DEFINE_PROPERTY_GET(function, bus_type, data_type, get1) \
|
||||
BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, ident)
|
||||
|
||||
#define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \
|
||||
int function(sd_bus *bus, \
|
||||
const char *path, \
|
||||
|
|
Loading…
Reference in New Issue