From 93529d8c5db599a45171942c4510f1b84ed09e6a Mon Sep 17 00:00:00 2001 From: Chuck Remes Date: Sun, 6 Nov 2011 14:03:51 +0100 Subject: Add zmq_getmsgopt to the API The new function allows to retrieve options (flags) from zmq_msg_t. Signed-off-by: Chuck Remes Renamed from zmq_msg_flags to zmq_getmsgopt Signed-off-by: Martin Sustrik --- src/zmq.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/zmq.cpp') diff --git a/src/zmq.cpp b/src/zmq.cpp index b06b122..84dcdd1 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -340,6 +340,25 @@ size_t zmq_msg_size (zmq_msg_t *msg_) return ((zmq::msg_t*) msg_)->size (); } +int zmq_getmsgopt (zmq_msg_t *msg_, int option_, void *optval_, + size_t *optvallen_) +{ + switch (option_) { + case ZMQ_MORE: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = + (((zmq::msg_t*) msg_)->flags () & zmq::msg_t::more) ? 1 : 0; + *optvallen_ = sizeof (int); + return 0; + default: + errno = EINVAL; + return -1; + } +} + int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) { #if defined ZMQ_POLL_BASED_ON_POLL -- cgit v1.2.3