Commit f27c02d0 authored by Lourens Naudé's avatar Lourens Naudé

Change context monitor_event prototype to accept a va_list instead

parent 4767159f
...@@ -353,59 +353,56 @@ zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_) ...@@ -353,59 +353,56 @@ zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_)
return endpoint; return endpoint;
} }
void zmq::ctx_t::monitor_event (zmq::socket_base_t *socket_, int event_, ...) void zmq::ctx_t::monitor_event (zmq::socket_base_t *socket_, int event_, va_list args_)
{ {
if (monitor_fn != NULL) { if (monitor_fn != NULL) {
va_list args;
zmq_event_data_t data; zmq_event_data_t data;
memset(&data, 0, sizeof (zmq_event_data_t)); memset(&data, 0, sizeof (zmq_event_data_t));
va_start (args, event_);
switch (event_) { switch (event_) {
case ZMQ_EVENT_CONNECTED: case ZMQ_EVENT_CONNECTED:
data.connected.addr = va_arg (args, char*); data.connected.addr = va_arg (args_, char*);
data.connected.fd = va_arg (args, int); data.connected.fd = va_arg (args_, int);
break; break;
case ZMQ_EVENT_CONNECT_DELAYED: case ZMQ_EVENT_CONNECT_DELAYED:
data.connect_delayed.addr = va_arg (args, char*); data.connect_delayed.addr = va_arg (args_, char*);
data.connect_delayed.err = va_arg (args, int); data.connect_delayed.err = va_arg (args_, int);
break; break;
case ZMQ_EVENT_CONNECT_RETRIED: case ZMQ_EVENT_CONNECT_RETRIED:
data.connect_retried.addr = va_arg (args, char*); data.connect_retried.addr = va_arg (args_, char*);
data.connect_retried.interval = va_arg (args, int); data.connect_retried.interval = va_arg (args_, int);
break; break;
case ZMQ_EVENT_LISTENING: case ZMQ_EVENT_LISTENING:
data.listening.addr = va_arg (args, char*); data.listening.addr = va_arg (args_, char*);
data.listening.fd = va_arg (args, int); data.listening.fd = va_arg (args_, int);
break; break;
case ZMQ_EVENT_BIND_FAILED: case ZMQ_EVENT_BIND_FAILED:
data.bind_failed.addr = va_arg (args, char*); data.bind_failed.addr = va_arg (args_, char*);
data.bind_failed.err = va_arg (args, int); data.bind_failed.err = va_arg (args_, int);
break; break;
case ZMQ_EVENT_ACCEPTED: case ZMQ_EVENT_ACCEPTED:
data.accepted.addr = va_arg (args, char*); data.accepted.addr = va_arg (args_, char*);
data.accepted.fd = va_arg (args, int); data.accepted.fd = va_arg (args_, int);
break; break;
case ZMQ_EVENT_ACCEPT_FAILED: case ZMQ_EVENT_ACCEPT_FAILED:
data.accept_failed.addr = va_arg (args, char*); data.accept_failed.addr = va_arg (args_, char*);
data.accept_failed.err = va_arg (args, int); data.accept_failed.err = va_arg (args_, int);
break; break;
case ZMQ_EVENT_CLOSED: case ZMQ_EVENT_CLOSED:
data.closed.addr = va_arg (args, char*); data.closed.addr = va_arg (args_, char*);
data.closed.fd = va_arg (args, int); data.closed.fd = va_arg (args_, int);
break; break;
case ZMQ_EVENT_CLOSE_FAILED: case ZMQ_EVENT_CLOSE_FAILED:
data.close_failed.addr = va_arg (args, char*); data.close_failed.addr = va_arg (args_, char*);
data.close_failed.err = va_arg (args, int); data.close_failed.err = va_arg (args_, int);
break; break;
case ZMQ_EVENT_DISCONNECTED: case ZMQ_EVENT_DISCONNECTED:
data.disconnected.addr = va_arg (args, char*); data.disconnected.addr = va_arg (args_, char*);
data.disconnected.fd = va_arg (args, int); data.disconnected.fd = va_arg (args_, int);
break; break;
default: default:
zmq_assert (false); zmq_assert (false);
} }
monitor_fn ((void *)socket_, event_, &data); monitor_fn ((void *)socket_, event_, &data);
va_end (args);
} }
} }
......
...@@ -97,7 +97,7 @@ namespace zmq ...@@ -97,7 +97,7 @@ namespace zmq
// Monitoring specific // Monitoring specific
int monitor (zmq_monitor_fn *monitor_); int monitor (zmq_monitor_fn *monitor_);
void monitor_event (zmq::socket_base_t *socket_, int event_, ...); void monitor_event (zmq::socket_base_t *socket_, int event_, va_list args_);
enum { enum {
term_tid = 0, term_tid = 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment