From 566054194d82b4bfabaaca44d14008a073e29a6b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 15 May 2014 15:45:13 +0200 Subject: m + fix message sending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/mds-message.h | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'src/libmdsserver/mds-message.h') diff --git a/src/libmdsserver/mds-message.h b/src/libmdsserver/mds-message.h index 885dd03..6f0a61d 100644 --- a/src/libmdsserver/mds-message.h +++ b/src/libmdsserver/mds-message.h @@ -83,7 +83,7 @@ typedef struct mds_message /** - * Initialsie a message slot so that it can + * Initialise a message slot so that it can * be used by `mds_message_read` * * @param this Memory slot in which to store the new message @@ -119,25 +119,21 @@ int mds_message_read(mds_message_t* restrict this, int fd); * Get the required allocation size for `data` of the * function `mds_message_marshal` * - * @param this The message - * @param include_buffer Whether buffer should be marshalled (state serialisation, not communication) - * @return The size of the message when marshalled + * @param this The message + * @return The size of the message when marshalled */ -size_t mds_message_marshal_size(const mds_message_t* restrict this, int include_buffer) __attribute__((pure)); +size_t mds_message_marshal_size(const mds_message_t* restrict this) __attribute__((pure)); /** - * Marshal a message, this can be used both when serialising - * the servers state or to get the byte stream to send to - * the recipient of the message + * Marshal a message for state serialisation * - * @param this The message - * @param data Output buffer for the marshalled data - * @param include_buffer Whether buffer should be marshalled (state serialisation, not communication) + * @param this The message + * @param data Output buffer for the marshalled data */ -void mds_message_marshal(const mds_message_t* restrict this, char* restrict data, int include_buffer); +void mds_message_marshal(const mds_message_t* restrict this, char* restrict data); /** - * Unmarshal a message, it is assumed that the buffer is marshalled + * Unmarshal a message for state deserialisation * * @param this Memory slot in which to store the new message * @param data In buffer with the marshalled data @@ -146,6 +142,23 @@ void mds_message_marshal(const mds_message_t* restrict this, char* restrict data */ int mds_message_unmarshal(mds_message_t* restrict this, char* restrict data); +/** + * Get the required allocation size for `data` of the + * function `mds_message_compose` + * + * @param this The message + * @return The size of the message when marshalled + */ +size_t mds_message_compose_size(const mds_message_t* restrict this) __attribute__((pure)); + +/** + * Marshal a message for communication + * + * @param this The message + * @param data Output buffer for the marshalled data + */ +void mds_message_compose(const mds_message_t* restrict this, char* restrict data); + #endif -- cgit v1.2.3-70-g09d2