summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-31 16:16:37 +0200
committerLennart Poettering <lennart@poettering.net>2013-03-31 16:16:37 +0200
commit392d5b378ceae5e1fd7c91ca545fcf4cd105744a (patch)
treee231fe77155323de76b535cd509ee5677f1bf28f /src/libsystemd-bus/bus-message.c
parent11c4c2492083325531aeb3eeb9b041c929677890 (diff)
bus: parse matches locally and allow registration of callbacks for them
This includes code to parse and split up match strings which will also be useful to calculate bloom filter masks when the time comes.
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 845e2c0040..85b9cbaae0 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -3002,3 +3002,38 @@ int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
return 0;
}
+
+const char* bus_message_get_arg(sd_bus_message *m, unsigned i) {
+ int r;
+ const char *t;
+ char type;
+
+ assert(m);
+
+ r = sd_bus_message_rewind(m, true);
+ if (r < 0)
+ return NULL;
+
+ while (i > 0) {
+ r = sd_bus_message_peek_type(m, &type, NULL);
+ if (r < 0)
+ return NULL;
+
+ if (type != SD_BUS_TYPE_STRING &&
+ type != SD_BUS_TYPE_OBJECT_PATH &&
+ type != SD_BUS_TYPE_SIGNATURE)
+ return NULL;
+
+ r = sd_bus_message_read_basic(m, type, &t);
+ if (r < 0)
+ return NULL;
+
+ i--;
+ }
+
+ r = sd_bus_message_rewind(m, true);
+ if (r < 0)
+ return NULL;
+
+ return t;
+}