summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-14 03:20:12 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-14 03:20:23 +0200
commit77930f11207ef6ec1f9284a1179fdd78c3364cba (patch)
treed51be38f37d13f32e6d1bffc01fabbec2d0e63d7 /src/libsystemd-bus/bus-message.c
parent75722f1d48cf1a93cc4a24e332c9871808c0e641 (diff)
kdbus: also parse cmdline message attribute
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index bae0812fac..e970d093cb 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -70,6 +70,8 @@ static void message_free(sd_bus_message *m) {
free(m->fds);
}
+ free(m->cmdline_array);
+
reset_containers(m);
free(m->root_container.signature);
@@ -752,6 +754,38 @@ const char *sd_bus_message_get_exe(sd_bus_message *m) {
return m->exe;
}
+int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline) {
+ size_t n, i;
+ const char *p;
+ bool first;
+
+ if (!m)
+ return -EINVAL;
+
+ if (!m->cmdline)
+ return -ENOENT;
+
+ for (p = m->cmdline, n = 0; p < m->cmdline + m->cmdline_length; p++)
+ if (*p == 0)
+ n++;
+
+ m->cmdline_array = new(char*, n + 1);
+ if (!m->cmdline_array)
+ return -ENOMEM;
+
+ for (p = m->cmdline, i = 0, first = true; p < m->cmdline + m->cmdline_length; p++) {
+ if (first)
+ m->cmdline_array[i++] = (char*) p;
+
+ first = *p == 0;
+ }
+
+ m->cmdline_array[i] = NULL;
+ *cmdline = m->cmdline_array;
+
+ return 0;
+}
+
int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member) {
if (!m)
return -EINVAL;
@@ -2928,6 +2962,7 @@ int sd_bus_message_set_destination(sd_bus_message *m, const char *destination) {
}
int bus_message_dump(sd_bus_message *m) {
+ char **cmdline = NULL;
unsigned level = 1;
int r;
@@ -2995,6 +3030,20 @@ int bus_message_dump(sd_bus_message *m) {
if (m->label)
printf("\tlabel=[%s]\n", m->label);
+ if (sd_bus_message_get_cmdline(m, &cmdline) >= 0) {
+ char **c;
+
+ fputs("\tcmdline=[", stdout);
+ STRV_FOREACH(c, cmdline) {
+ if (c != cmdline)
+ putchar(' ');
+
+ fputs(*c, stdout);
+ }
+
+ fputs("]\n", stdout);
+ }
+
r = sd_bus_message_rewind(m, true);
if (r < 0) {
log_error("Failed to rewind: %s", strerror(-r));