From 1faa9b61ec273c32ee8d5093c3af45d4edee644e Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Tue, 20 Oct 2015 20:31:47 +0200 Subject: [PATCH] Various function signature fixes --- include/tr/comm_manager.h | 2 +- include/tr/interface/protocol.h | 5 +++-- src/comm_manager.c | 7 +++--- src/comm_manager_epoll.c | 36 +++++++++++++++++++++++-------- src/comm_manager_poll.c | 32 +++++++++++++++++++-------- src/comm_manager_shutdown.c | 3 ++- src/comm_manager_shutdown_read.c | 3 ++- src/comm_manager_shutdown_write.c | 3 ++- src/datagram_service.c | 2 +- src/i_protocol.c | 17 ++++++++++++--- src/protocol_raw.c | 8 +++---- 11 files changed, 83 insertions(+), 35 deletions(-) diff --git a/include/tr/comm_manager.h b/include/tr/comm_manager.h index 9acf049..f8111ee 100644 --- a/include/tr/comm_manager.h +++ b/include/tr/comm_manager.h @@ -46,7 +46,7 @@ TR_CLASSVARS_DECL(TR_CommManager) { TR_CV_EXTENDS(TR_EventHandler); }; -TR_EventDone TR_commManagerShutdown(TR_CommManager, TR_Event event); +TR_EventDone TR_commManagerShutdown(void *, TR_Event event); #endif // __TR_COMM_MANAGER_H__ diff --git a/include/tr/interface/protocol.h b/include/tr/interface/protocol.h index 480f607..86b251d 100644 --- a/include/tr/interface/protocol.h +++ b/include/tr/interface/protocol.h @@ -31,7 +31,7 @@ #include "tr/protocol.h" #include "tr/proto_message.h" -typedef TR_ProtoMessage (* fptr_TR_protoCreateMessage)(void *); +typedef TR_ProtoMessage (* fptr_TR_protoCreateMessage)(void *, va_list *); typedef TR_ProtoMessage (* fptr_TR_protoCreateRequest)(void *, va_list *); typedef TR_ProtoMessage (* fptr_TR_protoCreateResponse)(void *, va_list *); typedef TR_RemoteData (* fptr_TR_protoCompose)(void *, TR_ProtoMessage); @@ -47,7 +47,8 @@ TR_INTERFACE(TR_Protocol) { fptr_TR_protoCompose compose; }; -TR_ProtoMessage TR_protoCreateMessage(void *, TR_Socket); +TR_ProtoMessage TR_vprotoCreateMessage(void *, TR_Socket, va_list*); +TR_ProtoMessage TR_protoCreateMessage(void *, TR_Socket, ...); TR_ProtoMessage TR_vprotoCreateRequest(void *, TR_Socket, va_list*); TR_ProtoMessage TR_protoCreateRequest(void *, TR_Socket, ...); TR_ProtoMessage TR_vprotoCreateResponse(void *, TR_Socket, va_list*); diff --git a/src/comm_manager.c b/src/comm_manager.c index 61fbd4d..9988bc3 100644 --- a/src/comm_manager.c +++ b/src/comm_manager.c @@ -83,8 +83,9 @@ TR_commManagerEnableWrite(void * _this, TR_Event event) static TR_EventDone -TR_commManagerAddEndpointEvt(TR_CommManager this, TR_Event event) +TR_commManagerAddEndpointEvt(void * _this, TR_Event event) { + TR_CommManager this = _this; TR_commManagerAddEndpoint(this, (TR_CommEndPoint)event->subject); return TR_EVENT_DONE; @@ -96,8 +97,8 @@ TR_EventDone TR_commManagerPollRead(void *, TR_Event); TR_EventDone TR_commManagerDisableRead(void *, TR_Event); TR_EventDone TR_commManagerDisableWrite(void *, TR_Event); TR_EventDone TR_commManagerClose(void *, TR_Event); -TR_EventDone TR_commManagerShutdownRead(TR_CommManager, TR_Event); -TR_EventDone TR_commManagerShutdownWrite(TR_CommManager, TR_Event); +TR_EventDone TR_commManagerShutdownRead(void *, TR_Event); +TR_EventDone TR_commManagerShutdownWrite(void *, TR_Event); static void diff --git a/src/comm_manager_epoll.c b/src/comm_manager_epoll.c index 72cdfe8..add5124 100644 --- a/src/comm_manager_epoll.c +++ b/src/comm_manager_epoll.c @@ -66,7 +66,7 @@ commManagerEpollDtor(void * _this) } static -void +TR_EventDone TR_commManagerEpollAddEndpoint(void * _this, TR_CommEndPoint endpoint) { TR_CommManagerEpoll this = _this; @@ -79,10 +79,12 @@ TR_commManagerEpollAddEndpoint(void * _this, TR_CommEndPoint endpoint) event.events = this->events[handle]; epoll_ctl(this->handle, EPOLL_CTL_ADD, handle, &event); + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerEpollSelect(void * _this, TR_Event event, unsigned long timeout) { TR_CommManagerEpoll this = _this; @@ -131,11 +133,13 @@ TR_commManagerEpollSelect(void * _this, TR_Event event, unsigned long timeout) NULL)); } } + + return TR_EVENT_DONE; } static inline -void +TR_EventDone TR_commManagerEpollDisable(void * _this, uint32_t mask, TR_Event event) { TR_CommManagerEpoll this = _this; @@ -148,11 +152,13 @@ TR_commManagerEpollDisable(void * _this, uint32_t mask, TR_Event event) _event.events = this->events[handle]; epoll_ctl(this->handle, EPOLL_CTL_MOD, handle, &_event); + + return TR_EVENT_DONE; } static inline -void +TR_EventDone TR_commManagerEpollEnable(void * _this, uint32_t mask, TR_Event event) { TR_CommManagerEpoll this = _this; @@ -165,48 +171,60 @@ TR_commManagerEpollEnable(void * _this, uint32_t mask, TR_Event event) _event.events = this->events[handle]; epoll_ctl(this->handle, EPOLL_CTL_MOD, handle, &_event); + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerEpollEnableWrite(void * _this, TR_Event event) { if (! TR_socketFinWr(((TR_CommEndPoint)event->subject)->transport)) { TR_commManagerEpollEnable(_this, EPOLLOUT, event); } + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerEpollEnableRead(void * _this, TR_Event event) { if (! TR_socketFinRd(((TR_CommEndPoint)event->subject)->transport)) { TR_commManagerEpollEnable(_this, EPOLLIN, event); } + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerEpollDisableWrite(void * _this, TR_Event event) { TR_commManagerEpollDisable(_this, EPOLLOUT, event); + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerEpollDisableRead(void * _this, TR_Event event) { TR_commManagerEpollDisable(_this, EPOLLIN, event); + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerEpollClose(void * _this, TR_Event event) { TR_CommManagerEpoll this = _this; TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; epoll_ctl(this->handle, EPOLL_CTL_DEL, endpoint->transport->handle, NULL); + + return TR_EVENT_DONE; } static diff --git a/src/comm_manager_poll.c b/src/comm_manager_poll.c index e5bcb16..5c31aa7 100644 --- a/src/comm_manager_poll.c +++ b/src/comm_manager_poll.c @@ -65,17 +65,19 @@ commManagerPollDtor(void * _this) } static -void +TR_EventDone TR_commManagerPollAddEndpoint(void * _this, TR_CommEndPoint endpoint) { TR_CommManagerPoll this = _this; - this->fds[endpoint->transport->handle].fd = endpoint->transport->handle; + this->fds[endpoint->transport->handle].fd = endpoint->transport->handle; this->fds[endpoint->transport->handle].events = 0; + + return TR_EVENT_DONE; } - + static -void +TR_EventDone TR_commManagerPollSelect(void * _this, TR_Event event, unsigned long timeout) { TR_CommManagerPoll this = _this; @@ -126,10 +128,12 @@ TR_commManagerPollSelect(void * _this, TR_Event event, unsigned long timeout) } } } + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerPollEnableWrite(void * _this, TR_Event event) { TR_CommManagerPoll this = _this; @@ -138,10 +142,12 @@ TR_commManagerPollEnableWrite(void * _this, TR_Event event) if (! TR_socketFinWr(endpoint->transport)) { this->fds[endpoint->transport->handle].events |= POLLOUT|POLLHUP; } + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerPollEnableRead(void * _this, TR_Event event) { TR_CommManagerPoll this = _this; @@ -150,30 +156,36 @@ TR_commManagerPollEnableRead(void * _this, TR_Event event) if (! TR_socketFinRd(endpoint->transport)) { this->fds[endpoint->transport->handle].events |= POLLIN; } + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerPollDisableWrite(void * _this, TR_Event event) { TR_CommManagerPoll this = _this; TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; this->fds[endpoint->transport->handle].events &= ~(POLLOUT|POLLHUP); + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerPollDisableRead(void * _this, TR_Event event) { TR_CommManagerPoll this = _this; TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; this->fds[endpoint->transport->handle].events &= ~POLLIN; + + return TR_EVENT_DONE; } static -void +TR_EventDone TR_commManagerPollClose(void * _this, TR_Event event) { TR_CommManagerPoll this = _this; @@ -181,6 +193,8 @@ TR_commManagerPollClose(void * _this, TR_Event event) this->fds[endpoint->transport->handle].events = 0; this->fds[endpoint->transport->handle].fd = -1; + + return TR_EVENT_DONE; } static diff --git a/src/comm_manager_shutdown.c b/src/comm_manager_shutdown.c index 7126312..e05a55f 100644 --- a/src/comm_manager_shutdown.c +++ b/src/comm_manager_shutdown.c @@ -30,8 +30,9 @@ #include "tr/_comm_manager.h" TR_EventDone -TR_commManagerShutdown(TR_CommManager this, TR_Event event) +TR_commManagerShutdown(void * _this, TR_Event event) { + TR_CommManager this = _this; nfds_t i; for (i=0; i<=this->max_handle; i++) { diff --git a/src/comm_manager_shutdown_read.c b/src/comm_manager_shutdown_read.c index 29eab94..f3866d4 100644 --- a/src/comm_manager_shutdown_read.c +++ b/src/comm_manager_shutdown_read.c @@ -29,8 +29,9 @@ #include "tr/_comm_manager.h" TR_EventDone -TR_commManagerShutdownRead(TR_CommManager this, TR_Event event) +TR_commManagerShutdownRead(void * _this, TR_Event event) { + TR_CommManager this = _this; TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; if (! TR_socketFinRd(endpoint->transport)) { diff --git a/src/comm_manager_shutdown_write.c b/src/comm_manager_shutdown_write.c index 6fcfc58..4ba2f41 100644 --- a/src/comm_manager_shutdown_write.c +++ b/src/comm_manager_shutdown_write.c @@ -28,8 +28,9 @@ #include "tr/_comm_manager.h" TR_EventDone -TR_commManagerShutdownWrite(TR_CommManager this, TR_Event event) +TR_commManagerShutdownWrite(void * _this, TR_Event event) { + TR_CommManager this = _this; TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; if (! TR_socketFinWr(endpoint->transport)) { diff --git a/src/datagram_service.c b/src/datagram_service.c index 55852ce..11a694e 100644 --- a/src/datagram_service.c +++ b/src/datagram_service.c @@ -86,7 +86,7 @@ datagramServiceNextMessage(void * _this, TR_RemoteData * data) } static -int +size_t datagramServiceCompose(void * _this, TR_ProtoMessage message) { TR_RemoteData data = diff --git a/src/i_protocol.c b/src/i_protocol.c index c6329d6..6d09afe 100644 --- a/src/i_protocol.c +++ b/src/i_protocol.c @@ -31,16 +31,27 @@ TR_CREATE_INTERFACE(TR_Protocol, 5); TR_ProtoMessage -TR_protoCreateMessage(void * _this, TR_Socket remote) +TR_vprotoCreateMessage(void * _this, TR_Socket remote, va_list * params) { TR_ProtoMessage callret; - TR_RETCALL(_this, TR_Protocol, createMessage, callret); + TR_RETCALL(_this, TR_Protocol, createMessage, callret, params); if (callret != NULL) { callret->remote = remote; } return callret; } +TR_ProtoMessage +TR_protoCreateMessage(void * _this, TR_Socket remote, ...) +{ + TR_ProtoMessage callret; + va_list params; + va_start(params, remote); + callret = TR_vprotoCreateMessage(_this, remote, ¶ms); + va_end(params); + return callret; +} + TR_ProtoMessage TR_vprotoCreateRequest(void * _this, TR_Socket remote, va_list * params) { @@ -67,7 +78,7 @@ TR_ProtoMessage TR_vprotoCreateResponse(void * _this, TR_Socket remote, va_list * params) { TR_ProtoMessage callret; - TR_RETCALL(_this, TR_Protocol, createResponse, callret, ¶ms); + TR_RETCALL(_this, TR_Protocol, createResponse, callret, params); if (callret != NULL) { callret->remote = remote; } diff --git a/src/protocol_raw.c b/src/protocol_raw.c index c5b4169..ff77e32 100644 --- a/src/protocol_raw.c +++ b/src/protocol_raw.c @@ -45,9 +45,9 @@ static void protocolRawDtor(void * _this) {} static TR_ProtoMessage -protocolRawCreateMessage(void * _this, TR_Socket remote) +protocolRawCreateMessage(void * _this, va_list * args) { - return (TR_ProtoMessage)TR_new(TR_ProtoMessageRaw, remote); + return (TR_ProtoMessage)TR_new(TR_ProtoMessageRaw); } static @@ -110,9 +110,9 @@ protocolRawCompose(void * _this, TR_ProtoMessage _message) { TR_ProtoMessageRaw message = (TR_ProtoMessageRaw)_message; TR_SizedData data; - + data = (TR_SizedData)TR_new(TR_RemoteData, NULL, 0, _message->remote); - + data->size = message->size + 2; data->data = TR_malloc(data->size); *(uint16_t *)data->data = htons(message->size);