Change context monitor_event prototype to accept a va_list instead

This commit is contained in:
Lourens Naudé 2012-05-21 21:22:16 +01:00
parent 4767159f39
commit f27c02d01e
2 changed files with 22 additions and 25 deletions

View File

@ -353,59 +353,56 @@ zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_)
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) {
va_list args;
zmq_event_data_t data;
memset(&data, 0, sizeof (zmq_event_data_t));
va_start (args, event_);
switch (event_) {
case ZMQ_EVENT_CONNECTED:
data.connected.addr = va_arg (args, char*);
data.connected.fd = va_arg (args, int);
data.connected.addr = va_arg (args_, char*);
data.connected.fd = va_arg (args_, int);
break;
case ZMQ_EVENT_CONNECT_DELAYED:
data.connect_delayed.addr = va_arg (args, char*);
data.connect_delayed.err = va_arg (args, int);
data.connect_delayed.addr = va_arg (args_, char*);
data.connect_delayed.err = va_arg (args_, int);
break;
case ZMQ_EVENT_CONNECT_RETRIED:
data.connect_retried.addr = va_arg (args, char*);
data.connect_retried.interval = va_arg (args, int);
data.connect_retried.addr = va_arg (args_, char*);
data.connect_retried.interval = va_arg (args_, int);
break;
case ZMQ_EVENT_LISTENING:
data.listening.addr = va_arg (args, char*);
data.listening.fd = va_arg (args, int);
data.listening.addr = va_arg (args_, char*);
data.listening.fd = va_arg (args_, int);
break;
case ZMQ_EVENT_BIND_FAILED:
data.bind_failed.addr = va_arg (args, char*);
data.bind_failed.err = va_arg (args, int);
data.bind_failed.addr = va_arg (args_, char*);
data.bind_failed.err = va_arg (args_, int);
break;
case ZMQ_EVENT_ACCEPTED:
data.accepted.addr = va_arg (args, char*);
data.accepted.fd = va_arg (args, int);
data.accepted.addr = va_arg (args_, char*);
data.accepted.fd = va_arg (args_, int);
break;
case ZMQ_EVENT_ACCEPT_FAILED:
data.accept_failed.addr = va_arg (args, char*);
data.accept_failed.err = va_arg (args, int);
data.accept_failed.addr = va_arg (args_, char*);
data.accept_failed.err = va_arg (args_, int);
break;
case ZMQ_EVENT_CLOSED:
data.closed.addr = va_arg (args, char*);
data.closed.fd = va_arg (args, int);
data.closed.addr = va_arg (args_, char*);
data.closed.fd = va_arg (args_, int);
break;
case ZMQ_EVENT_CLOSE_FAILED:
data.close_failed.addr = va_arg (args, char*);
data.close_failed.err = va_arg (args, int);
data.close_failed.addr = va_arg (args_, char*);
data.close_failed.err = va_arg (args_, int);
break;
case ZMQ_EVENT_DISCONNECTED:
data.disconnected.addr = va_arg (args, char*);
data.disconnected.fd = va_arg (args, int);
data.disconnected.addr = va_arg (args_, char*);
data.disconnected.fd = va_arg (args_, int);
break;
default:
zmq_assert (false);
}
monitor_fn ((void *)socket_, event_, &data);
va_end (args);
}
}

View File

@ -97,7 +97,7 @@ namespace zmq
// Monitoring specific
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 {
term_tid = 0,