aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/mds-message.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-06 00:53:10 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-06 00:53:10 +0200
commit89b0559e1980a1065094a9c2f88cc4ce9ecdb457 (patch)
treed7a3796c2f469b29e3855efd5910a414bbaa56eb /src/libmdsserver/mds-message.c
parentkill all threads (diff)
downloadmds-89b0559e1980a1065094a9c2f88cc4ce9ecdb457.tar.gz
mds-89b0559e1980a1065094a9c2f88cc4ce9ecdb457.tar.bz2
mds-89b0559e1980a1065094a9c2f88cc4ce9ecdb457.tar.xz
add buf_set/get_next macros
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver/mds-message.c')
-rw-r--r--src/libmdsserver/mds-message.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c
index 7a7cda2..5f17ec7 100644
--- a/src/libmdsserver/mds-message.c
+++ b/src/libmdsserver/mds-message.c
@@ -327,22 +327,19 @@ void mds_message_marshal(mds_message_t* this, char* data, int include_buffer)
{
size_t i, n;
- buf_set(data, int, 0, MDS_MESSAGE_T_VERSION);
- buf_next(data, int, 1);
+ buf_set_next(data, int, MDS_MESSAGE_T_VERSION);
- buf_set(data, size_t, 0, this->header_count);
- buf_set(data, size_t, 1, this->payload_size);
+ buf_set_next(data, size_t, this->header_count);
+ buf_set_next(data, size_t, this->payload_size);
if (include_buffer)
{
- buf_set(data, size_t, 2, this->payload_ptr);
- buf_set(data, size_t, 3, this->buffer_ptr);
+ buf_set_next(data, size_t, this->payload_ptr);
+ buf_set_next(data, size_t, this->buffer_ptr);
}
- buf_next(data, size_t, include_buffer ? 4 : 2);
if (include_buffer)
{
- buf_set(data, int, 0, this->stage);
- buf_next(data, int, 1);
+ buf_set_next(data, int, this->stage);
}
for (i = 0; i < this->header_count; i++)
@@ -378,11 +375,10 @@ int mds_message_unmarshal(mds_message_t* this, char* data)
buf_next(data, int, 1);
this->header_count = 0;
- buf_get(data, size_t, 0, header_count);
- buf_get(data, size_t, 1, this->payload_size);
- buf_get(data, size_t, 2, this->payload_ptr);
- buf_get(data, size_t, 3, this->buffer_size = this->buffer_ptr);
- buf_next(data, size_t, 4);
+ buf_get_next(data, size_t, header_count);
+ buf_get_next(data, size_t, this->payload_size);
+ buf_get_next(data, size_t, this->payload_ptr);
+ buf_get_next(data, size_t, this->buffer_size = this->buffer_ptr);
/* Make sure that the pointers are NULL so that they are
not freed without being allocated when the message is
@@ -391,8 +387,7 @@ int mds_message_unmarshal(mds_message_t* this, char* data)
this->payload = NULL;
this->buffer = NULL;
- buf_get(data, int, 0, this->stage);
- buf_next(data, int, 1);
+ buf_get_next(data, int, this->stage);
/* To 2-power-multiple of 128 bytes. */
this->buffer_size >>= 7;