summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-introspect.c
diff options
context:
space:
mode:
authorGiacinto Cifelli <gciofono@gmail.com>2019-01-08 12:14:37 +0100
committerGiacinto Cifelli <gciofono@gmail.com>2019-02-26 12:55:02 +0100
commit856ad2a86bd9b3e264a090fcf4b0d05bfaa91030 (patch)
tree478ab7fafbe63489b5238452bc0a9e48c55d5f89 /src/libsystemd/sd-bus/bus-introspect.c
parent3f1af087a99ee3d96cb4e6cacee6370ee76b81fd (diff)
downloadsystemd-856ad2a86bd9b3e264a090fcf4b0d05bfaa91030.tar.gz
sd-bus: add methods and signals parameter names. Fixes: #1564
Diffstat (limited to 'src/libsystemd/sd-bus/bus-introspect.c')
-rw-r--r--src/libsystemd/sd-bus/bus-introspect.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/libsystemd/sd-bus/bus-introspect.c b/src/libsystemd/sd-bus/bus-introspect.c
index f623dd9ce0..bde97483e8 100644
--- a/src/libsystemd/sd-bus/bus-introspect.c
+++ b/src/libsystemd/sd-bus/bus-introspect.c
@@ -4,6 +4,7 @@
#include "bus-internal.h"
#include "bus-introspect.h"
+#include "bus-objects.h"
#include "bus-protocol.h"
#include "bus-signature.h"
#include "fd-util.h"
@@ -86,7 +87,9 @@ static void introspect_write_flags(struct introspect *i, int type, uint64_t flag
fputs(" <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f);
}
-static int introspect_write_arguments(struct introspect *i, const char *signature, const char *direction) {
+/* Note that "names" is both an input and an output parameter. It initially points to the first argument name in a
+ NULL-separated list of strings, and is then advanced with each argument, and the resulting pointer is returned. */
+static int introspect_write_arguments(struct introspect *i, const char *signature, const char **names, const char *direction) {
int r;
for (;;) {
@@ -101,6 +104,11 @@ static int introspect_write_arguments(struct introspect *i, const char *signatur
fprintf(i->f, " <arg type=\"%.*s\"", (int) l, signature);
+ if (**names != '\0') {
+ fprintf(i->f, " name=\"%s\"", *names);
+ *names += strlen(*names) + 1;
+ }
+
if (direction)
fprintf(i->f, " direction=\"%s\"/>\n", direction);
else
@@ -111,10 +119,13 @@ static int introspect_write_arguments(struct introspect *i, const char *signatur
}
int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
+ const sd_bus_vtable *vtable = v;
+ const char *names = "";
+
assert(i);
assert(v);
- for (; v->type != _SD_BUS_VTABLE_END; v++) {
+ for (; v->type != _SD_BUS_VTABLE_END; v = bus_vtable_next(vtable, v)) {
/* Ignore methods, signals and properties that are
* marked "hidden", but do show the interface
@@ -132,8 +143,10 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
case _SD_BUS_VTABLE_METHOD:
fprintf(i->f, " <method name=\"%s\">\n", v->x.method.member);
- introspect_write_arguments(i, strempty(v->x.method.signature), "in");
- introspect_write_arguments(i, strempty(v->x.method.result), "out");
+ if (bus_vtable_has_names(vtable))
+ names = strempty(v->x.method.names);
+ introspect_write_arguments(i, strempty(v->x.method.signature), &names, "in");
+ introspect_write_arguments(i, strempty(v->x.method.result), &names, "out");
introspect_write_flags(i, v->type, v->flags);
fputs(" </method>\n", i->f);
break;
@@ -150,7 +163,9 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
case _SD_BUS_VTABLE_SIGNAL:
fprintf(i->f, " <signal name=\"%s\">\n", v->x.signal.member);
- introspect_write_arguments(i, strempty(v->x.signal.signature), NULL);
+ if (bus_vtable_has_names(vtable))
+ names = strempty(v->x.method.names);
+ introspect_write_arguments(i, strempty(v->x.signal.signature), &names, NULL);
introspect_write_flags(i, v->type, v->flags);
fputs(" </signal>\n", i->f);
break;