#include "util.h"
#include "utf8.h"
+#include "strv.h"
#include "sd-bus.h"
#include "bus-message.h"
if (!t)
return -ENOMEM;
+ t->header->flags |= SD_BUS_MESSAGE_NO_REPLY_EXPECTED;
+
r = message_append_field_string(t, SD_BUS_MESSAGE_HEADER_PATH, SD_BUS_TYPE_OBJECT_PATH, path, &t->path);
if (r < 0)
goto fail;
if (!call)
return -EINVAL;
+ if (!call->sealed)
+ return -EPERM;
if (call->header->type != SD_BUS_MESSAGE_TYPE_METHOD_CALL)
return -EINVAL;
if (!m)
if (!t)
return -ENOMEM;
+ t->header->flags |= SD_BUS_MESSAGE_NO_REPLY_EXPECTED;
t->reply_serial = BUS_MESSAGE_SERIAL(call);
r = message_append_field_uint32(t, SD_BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_serial);
t->dont_send = !!(call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED);
*m = t;
+ return 0;
fail:
message_free(t);
sd_bus_message *t;
int r;
- if (!e)
- return -EINVAL;
- if (!e->name)
+ if (!sd_bus_error_is_set(e))
return -EINVAL;
if (!m)
return -EINVAL;
return 0;
}
-int sd_bus_message_rewind(sd_bus_message *m, bool complete) {
+int sd_bus_message_rewind(sd_bus_message *m, int complete) {
struct bus_container *c;
if (!m)
} else if (bus_type_is_basic(t)) {
size_t align, k;
- align = bus_type_get_alignment(align);
- k = bus_type_get_size(align);
+ align = bus_type_get_alignment(t);
+ k = bus_type_get_size(t);
r = message_peek_fields(m, ri, align, k, NULL);
if (r < 0)
break;
}
+ /* Try to read the error message, but if we can't it's a non-issue */
+ if (m->header->type == SD_BUS_MESSAGE_TYPE_METHOD_ERROR)
+ sd_bus_message_read(m, "s", &m->error.message);
+
return 0;
}
assert(m->sealed);
m->n_iovec = 0;
+ m->size = 0;
m->iovec[m->n_iovec].iov_base = m->header;
m->iovec[m->n_iovec].iov_len = sizeof(*m->header);
+ m->size += m->iovec[m->n_iovec].iov_len;
m->n_iovec++;
if (m->fields) {
m->iovec[m->n_iovec].iov_base = m->fields;
m->iovec[m->n_iovec].iov_len = m->header->fields_size;
+ m->size += m->iovec[m->n_iovec].iov_len;
m->n_iovec++;
if (m->header->fields_size % 8 != 0) {
m->iovec[m->n_iovec].iov_base = (void*) padding;
m->iovec[m->n_iovec].iov_len = 8 - m->header->fields_size % 8;
+ m->size += m->iovec[m->n_iovec].iov_len;
m->n_iovec++;
}
}
if (m->body) {
m->iovec[m->n_iovec].iov_base = m->body;
m->iovec[m->n_iovec].iov_len = m->header->body_size;
+ m->size += m->iovec[m->n_iovec].iov_len;
m->n_iovec++;
}
}
return 0;
}
+
+int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
+ int r;
+
+ assert(m);
+ assert(l);
+
+ r = sd_bus_message_enter_container(m, 'a', "s");
+ if (r < 0)
+ return r;
+
+ for (;;) {
+ const char *s;
+
+ r = sd_bus_message_read_basic(m, 's', &s);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ break;
+
+ r = strv_extend(l, s);
+ if (r < 0)
+ return r;
+ }
+
+ r = sd_bus_message_exit_container(m);
+ if (r < 0)
+ return r;
+
+ return 0;
+}