size_t before;
int r;
- if (!m)
- return -EINVAL;
- if (!m->sealed)
- return -EPERM;
- if (!contents)
- return -EINVAL;
+ assert_return(m, -EINVAL);
+ assert_return(m->sealed, -EPERM);
+ assert_return(type != 0 || !contents, -EINVAL);
+
+ if (type == 0 || !contents) {
+ const char *cc;
+ char tt;
+
+ /* Allow entering into anonymous containers */
+ r = sd_bus_message_peek_type(m, &tt, &cc);
+ if (r <= 0)
+ return r;
+
+ if (type != 0 && type != tt)
+ return -ENXIO;
+
+ if (contents && !streq(contents, cc))
+ return -ENXIO;
+
+ type = tt;
+ contents = cc;
+ }
/*
* We enforce a global limit on container depth, that is much
assert(l);
r = sd_bus_message_enter_container(m, 'a', "s");
- if (r < 0)
+ if (r <= 0)
return r;
for (;;) {
return 0;
}
+int sd_bus_message_read_strv(sd_bus_message *m, char ***l) {
+ char **strv = NULL;
+ int r;
+
+ assert_return(m, -EINVAL);
+ assert_return(m->sealed, -EPERM);
+ assert_return(l, -EINVAL);
+
+ r = bus_message_read_strv_extend(m, &strv);
+ if (r <= 0) {
+ strv_free(strv);
+ return r;
+ }
+
+ *l = strv;
+ return 1;
+}
+
const char* bus_message_get_arg(sd_bus_message *m, unsigned i) {
int r;
const char *t = NULL;