I'm trapped in a situation of argument passing in libev.
Usually, libev receives packages in a function like *receive_callback*, that's OK, but in practice, we need to dispatch a relative *write_callback* to deal with specific jobs according to the received package. For example:
S_RECV_MSG* pstRecvMsg = (S_RECV_MSG*) recv_buff;
switch(pstRecvMsg->wMsgType) {
case 1:
ev_io_init(w, write_callback1, w->fd, EV_WRITE);
break;
case 2:
ev_io_init(w, write_callback2, w->fd, EV_WRITE);
break;
case 3:
// .......
}
My question is, if the write_callbackX
also has to read the specific content in the recv_buff, how can we pass the recv_buff argument to the callbackX? Must we bear the burden and ugliness of global variables here?