chiark / gitweb /
bus: update PORTING-DBUS1
[elogind.git] / src / libsystemd-bus / bus-message.h
index b862cb9443b60cde358d2b7d91faab032ee22585..5322375ef1c576eb596e13bf7d009b85fa6143d5 100644 (file)
 
 struct bus_container {
         char enclosing;
+        bool need_offsets:1;
 
+        /* Indexes into the signature  string */
         unsigned index, saved_index;
-
         char *signature;
 
+        size_t before, begin, end;
+
+        /* dbus1: pointer to the array size value, if this is a value */
         uint32_t *array_size;
-        size_t before, begin;
 
-        size_t *offsets;
-        size_t n_offsets, n_allocated;
+        /* gvariant: list of offsets to end of children if this is struct/dict entry/array */
+        size_t *offsets, n_offsets, offsets_allocated, offset_index;
+        size_t item_size;
 
-        bool need_offsets;
+        char *peeked_signature;
 };
 
 struct bus_header {
@@ -54,6 +58,10 @@ struct bus_header {
         uint8_t flags;
         uint8_t version;
         uint32_t body_size;
+
+        /* Note that what the bus spec calls "serial" we'll call
+        "cookie" instead, because we don't want to imply that the
+        cookie was in any way monotonically increasing. */
         uint32_t serial;
         uint32_t fields_size;
 } _packed_;
@@ -63,6 +71,7 @@ struct bus_body_part {
         void *data;
         size_t size;
         size_t mapped;
+        size_t allocated;
         int memfd;
         bool free_this:1;
         bool munmap_this:1;
@@ -75,7 +84,7 @@ struct sd_bus_message {
 
         sd_bus *bus;
 
-        uint32_t reply_serial;
+        uint32_t reply_cookie;
 
         const char *path;
         const char *interface;
@@ -98,7 +107,6 @@ struct sd_bus_message {
         bool free_fds:1;
         bool release_kdbus:1;
         bool poisoned:1;
-        bool is_gvariant:1;
 
         struct bus_header *header;
         struct bus_body_part body;
@@ -114,6 +122,7 @@ struct sd_bus_message {
 
         struct bus_container root_container, *containers;
         unsigned n_containers;
+        size_t containers_allocated;
 
         struct iovec *iovec;
         struct iovec iovec_fixed[2];
@@ -151,7 +160,7 @@ static inline uint64_t BUS_MESSAGE_BSWAP64(sd_bus_message *m, uint64_t u) {
         return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_64(u) : u;
 }
 
-static inline uint32_t BUS_MESSAGE_SERIAL(sd_bus_message *m) {
+static inline uint32_t BUS_MESSAGE_COOKIE(sd_bus_message *m) {
         return BUS_MESSAGE_BSWAP32(m, m->header->serial);
 }
 
@@ -180,7 +189,11 @@ static inline void* BUS_MESSAGE_FIELDS(sd_bus_message *m) {
         return (uint8_t*) m->header + sizeof(struct bus_header);
 }
 
-int bus_message_seal(sd_bus_message *m, uint64_t serial);
+static inline bool BUS_MESSAGE_IS_GVARIANT(sd_bus_message *m) {
+        return m->header->version == 2;
+}
+
+int bus_message_seal(sd_bus_message *m, uint64_t serial, usec_t timeout);
 int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz);
 int bus_message_read_strv_extend(sd_bus_message *m, char ***l);
 
@@ -225,3 +238,7 @@ void bus_body_part_unmap(struct bus_body_part *part);
 int bus_message_to_errno(sd_bus_message *m);
 
 int bus_message_new_synthetic_error(sd_bus *bus, uint64_t serial, const sd_bus_error *e, sd_bus_message **m);
+
+int bus_message_remarshal(sd_bus *bus, sd_bus_message **m);
+
+int bus_message_append_sender(sd_bus_message *m, const char *sender);