summaryrefslogtreecommitdiff
path: root/src/core/dbus-execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-25 16:59:51 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-25 17:40:53 +0100
commit4d4c80d073f26368d123f8cebff5b4c36a6beace (patch)
treec055ac7634be9932a63b54286886d7f12ae2ab0d /src/core/dbus-execute.c
parent290837072b136624f1f3d941c7274e4b1b275021 (diff)
core: fix serialization of exec command structs
Diffstat (limited to 'src/core/dbus-execute.c')
-rw-r--r--src/core/dbus-execute.c85
1 files changed, 60 insertions, 25 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 90556274d..12523999d 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -428,6 +428,42 @@ const sd_bus_vtable bus_exec_vtable[] = {
SD_BUS_VTABLE_END
};
+static int append_exec_command(sd_bus_message *reply, ExecCommand *c) {
+ int r;
+
+ assert(reply);
+ assert(c);
+
+ if (!c->path)
+ return 0;
+
+ r = sd_bus_message_open_container(reply, 'r', "sasbttttuii");
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_append(reply, "s", c->path);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_append_strv(reply, c->argv);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_append(reply, "bttttuii",
+ c->ignore,
+ c->exec_status.start_timestamp.realtime,
+ c->exec_status.start_timestamp.monotonic,
+ c->exec_status.exit_timestamp.realtime,
+ c->exec_status.exit_timestamp.monotonic,
+ (uint32_t) c->exec_status.pid,
+ (int32_t) c->exec_status.code,
+ (int32_t) c->exec_status.status);
+ if (r < 0)
+ return r;
+
+ return sd_bus_message_close_container(reply);
+}
+
int bus_property_get_exec_command(
sd_bus *bus,
const char *path,
@@ -437,7 +473,7 @@ int bus_property_get_exec_command(
void *userdata,
sd_bus_error *ret_error) {
- ExecCommand *c = *(ExecCommand**) userdata;
+ ExecCommand *c = (ExecCommand*) userdata;
int r;
assert(bus);
@@ -447,35 +483,34 @@ int bus_property_get_exec_command(
if (r < 0)
return r;
- LIST_FOREACH(command, c, c) {
- if (!c->path)
- continue;
+ r = append_exec_command(reply, c);
+ if (r < 0)
+ return r;
- r = sd_bus_message_open_container(reply, 'r', "sasbttttuii");
- if (r < 0)
- return r;
+ return sd_bus_message_close_container(reply);
+}
- r = sd_bus_message_append(reply, "s", c->path);
- if (r < 0)
- return r;
+int bus_property_get_exec_command_list(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *ret_error) {
- r = sd_bus_message_append_strv(reply, c->argv);
- if (r < 0)
- return r;
+ ExecCommand *c = *(ExecCommand**) userdata;
+ int r;
- r = sd_bus_message_append(reply, "bttttuii",
- c->ignore,
- c->exec_status.start_timestamp.realtime,
- c->exec_status.start_timestamp.monotonic,
- c->exec_status.exit_timestamp.realtime,
- c->exec_status.exit_timestamp.monotonic,
- (uint32_t) c->exec_status.pid,
- (int32_t) c->exec_status.code,
- (int32_t) c->exec_status.status);
- if (r < 0)
- return r;
+ assert(bus);
+ assert(reply);
+
+ r = sd_bus_message_open_container(reply, 'a', "(sasbttttuii)");
+ if (r < 0)
+ return r;
- r = sd_bus_message_close_container(reply);
+ LIST_FOREACH(command, c, c) {
+ r = append_exec_command(reply, c);
if (r < 0)
return r;
}