15 zmq::v1_decoder_t::v1_decoder_t (
size_t bufsize_, int64_t maxmsgsize_) :
16 decoder_base_t<v1_decoder_t> (bufsize_), _max_msg_size (maxmsgsize_)
18 int rc = _in_progress.init ();
22 next_step (_tmpbuf, 1, &v1_decoder_t::one_byte_size_ready);
25 zmq::v1_decoder_t::~v1_decoder_t ()
27 const int rc = _in_progress.close ();
31 int zmq::v1_decoder_t::one_byte_size_ready (
unsigned char const *)
36 if (*_tmpbuf == UCHAR_MAX)
37 next_step (_tmpbuf, 8, &v1_decoder_t::eight_byte_size_ready);
45 if (_max_msg_size >= 0
46 &&
static_cast<int64_t
> (*_tmpbuf - 1) > _max_msg_size) {
51 int rc = _in_progress.close ();
53 rc = _in_progress.init_size (*_tmpbuf - 1);
56 rc = _in_progress.init ();
62 next_step (_tmpbuf, 1, &v1_decoder_t::flags_ready);
67 int zmq::v1_decoder_t::eight_byte_size_ready (
unsigned char const *)
71 const uint64_t payload_length =
get_uint64 (_tmpbuf);
74 if (payload_length == 0) {
80 if (_max_msg_size >= 0
81 && payload_length - 1 >
static_cast<uint64_t
> (_max_msg_size)) {
88 if (payload_length - 1 > std::numeric_limits<size_t>::max ()) {
94 const size_t msg_size =
static_cast<size_t> (payload_length - 1);
96 int rc = _in_progress.close ();
98 rc = _in_progress.init_size (msg_size);
101 rc = _in_progress.init ();
107 next_step (_tmpbuf, 1, &v1_decoder_t::flags_ready);
111 int zmq::v1_decoder_t::flags_ready (
unsigned char const *)
114 _in_progress.set_flags (_tmpbuf[0] & msg_t::more);
116 next_step (_in_progress.data (), _in_progress.size (),
117 &v1_decoder_t::message_ready);
122 int zmq::v1_decoder_t::message_ready (
unsigned char const *)
126 next_step (_tmpbuf, 1, &v1_decoder_t::one_byte_size_ready);