From 36a576370ccfed3c104850b5b95a6ed3870edbea Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 12 Feb 2010 15:57:54 +0100 Subject: Multi-hop REQ/REP, part I., tracerouting switched on on XREP socket --- src/zmq_decoder.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/zmq_decoder.cpp') diff --git a/src/zmq_decoder.cpp b/src/zmq_decoder.cpp index cc4f846..f502ffd 100644 --- a/src/zmq_decoder.cpp +++ b/src/zmq_decoder.cpp @@ -25,24 +25,14 @@ #include "wire.hpp" #include "err.hpp" -zmq::zmq_decoder_t::zmq_decoder_t (size_t bufsize_, - void *prefix_, size_t prefix_size_) : +zmq::zmq_decoder_t::zmq_decoder_t (size_t bufsize_) : decoder_t (bufsize_), - destination (NULL) + destination (NULL), + prefix (NULL), + prefix_size (0) { zmq_msg_init (&in_progress); - if (!prefix_) { - prefix = NULL; - prefix_size = 0; - } - else { - prefix = malloc (prefix_size_); - zmq_assert (prefix); - memcpy (prefix, prefix_, prefix_size_); - prefix_size = prefix_size_; - } - // At the beginning, read one byte and go to one_byte_size_ready state. next_step (tmpbuf, 1, &zmq_decoder_t::one_byte_size_ready); } @@ -60,6 +50,15 @@ void zmq::zmq_decoder_t::set_inout (i_inout *destination_) destination = destination_; } +void zmq::zmq_decoder_t::add_prefix (unsigned char *prefix_, + size_t prefix_size_) +{ + prefix = malloc (prefix_size_); + zmq_assert (prefix); + memcpy (prefix, prefix_, prefix_size_); + prefix_size = prefix_size_; +} + bool zmq::zmq_decoder_t::one_byte_size_ready () { // First byte of size is read. If it is 0xff read 8-byte size. -- cgit v1.2.3