endpoint.h
Go to the documentation of this file.
/****************************************************************************
* This file is part of the project Gwenhywfar.
* Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef GWEN_MSG_ENDPOINT_H
#define GWEN_MSG_ENDPOINT_H
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/tree2.h>
#include <gwenhywfar/inetsocket.h>
#define GWEN_MSG_ENDPOINT_FLAGS_DELETE 0x80000000u
#define GWEN_MSG_ENDPOINT_FLAGS_NOIO 0x40000000u
#define GWEN_MSG_ENDPOINT_STATE_UNCONNECTED 0
#define GWEN_MSG_ENDPOINT_STATE_CONNECTING 1
#define GWEN_MSG_ENDPOINT_STATE_CONNECTED 2
#ifdef __cplusplus
extern "C" {
#endif
typedef struct GWEN_MSG_ENDPOINT GWEN_MSG_ENDPOINT;
GWEN_INHERIT_FUNCTION_LIB_DEFS(GWEN_MSG_ENDPOINT, GWENHYWFAR_API)
GWEN_TREE2_FUNCTION_LIB_DEFS(GWEN_MSG_ENDPOINT, GWEN_MsgEndpoint, GWENHYWFAR_API)
#ifdef __cplusplus
}
#endif
#include <gwenhywfar/msg.h>
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*GWEN_MSG_ENDPOINT_ADDSOCKETS_FN)(GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKETSET *readSet,
GWEN_SOCKETSET *writeSet,
GWEN_SOCKETSET *xSet);
typedef void (*GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN)(GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKETSET *readSet,
GWEN_SOCKETSET *writeSet,
GWEN_SOCKETSET *xSet);
GWENHYWFAR_API GWEN_MSG_ENDPOINT *GWEN_MsgEndpoint_new(const char *name, int groupId);
GWENHYWFAR_API void GWEN_MsgEndpoint_Attach(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_free(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API const char *GWEN_MsgEndpoint_GetName(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API int GWEN_MsgEndpoint_GetGroupId(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API GWEN_SOCKET *GWEN_MsgEndpoint_GetSocket(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_SetSocket(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKET *sk);
GWENHYWFAR_API int GWEN_MsgEndpoint_GetState(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_SetState(GWEN_MSG_ENDPOINT *ep, int m);
GWENHYWFAR_API time_t GWEN_MsgEndpoint_GetTimeOfLastStateChange(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API uint32_t GWEN_MsgEndpoint_GetFlags(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_SetFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f);
GWENHYWFAR_API void GWEN_MsgEndpoint_AddFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f);
GWENHYWFAR_API void GWEN_MsgEndpoint_DelFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f);
GWENHYWFAR_API int GWEN_MsgEndpoint_GetDefaultMessageSize(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_SetDefaultMessageSize(GWEN_MSG_ENDPOINT *ep, int i);
GWENHYWFAR_API uint32_t GWEN_MsgEndpoint_GetNextMessageId(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API GWEN_MSG_LIST *GWEN_MsgEndpoint_GetReceivedMessageList(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API GWEN_MSG_LIST *GWEN_MsgEndpoint_GetSendMessageList(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_AddReceivedMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m);
GWENHYWFAR_API GWEN_MSG *GWEN_MsgEndpoint_GetFirstReceivedMessage(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API GWEN_MSG *GWEN_MsgEndpoint_TakeFirstReceivedMessage(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_AddSendMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m);
GWENHYWFAR_API GWEN_MSG *GWEN_MsgEndpoint_GetFirstSendMessage(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API int GWEN_MsgEndpoint_HaveMessageToSend(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API GWEN_MSG *GWEN_MsgEndpoint_GetCurrentlyReceivedMsg(const GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API void GWEN_MsgEndpoint_SetCurrentlyReceivedMsg(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m);
GWENHYWFAR_API void GWEN_MsgEndpoint_AddSockets(GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKETSET *readSet,
GWEN_SOCKETSET *writeSet,
GWEN_SOCKETSET *xSet);
GWENHYWFAR_API void GWEN_MsgEndpoint_CheckSockets(GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKETSET *readSet,
GWEN_SOCKETSET *writeSet,
GWEN_SOCKETSET *xSet);
GWENHYWFAR_API void GWEN_MsgEndpoint_IoLoop(GWEN_MSG_ENDPOINT *ep, int timeout);
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenAddSockets(GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKETSET *readSet,
GWEN_SOCKETSET *writeSet,
GWEN_SOCKETSET *xSet);
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenCheckSockets(GWEN_MSG_ENDPOINT *ep,
GWEN_SOCKETSET *readSet,
GWEN_SOCKETSET *writeSet,
GWEN_SOCKETSET *xSet);
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenIoLoop(GWEN_MSG_ENDPOINT *ep, int timeout);
GWENHYWFAR_API void GWEN_MsgEndpoint_RemoveUnconnectedAndEmptyChildren(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API int GWEN_MsgEndpoint_ReadFromSocket(GWEN_MSG_ENDPOINT *ep, uint8_t *bufferPtr, uint32_t bufferLen);
GWENHYWFAR_API int GWEN_MsgEndpoint_WriteToSocket(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr, uint32_t bufferLen);
GWENHYWFAR_API void GWEN_MsgEndpoint_Disconnect(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API int GWEN_MsgEndpoint_DiscardInput(GWEN_MSG_ENDPOINT *ep);
GWENHYWFAR_API GWEN_MSG_ENDPOINT_ADDSOCKETS_FN GWEN_MsgEndpoint_SetAddSocketsFn(GWEN_MSG_ENDPOINT *ep,
GWEN_MSG_ENDPOINT_ADDSOCKETS_FN fn);
GWENHYWFAR_API GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN GWEN_MsgEndpoint_SetCheckSocketsFn(GWEN_MSG_ENDPOINT *ep,
GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN fn);
#ifdef __cplusplus
}
#endif
#endif
GWEN_MsgEndpoint_DiscardInput
GWENHYWFAR_API int GWEN_MsgEndpoint_DiscardInput(GWEN_MSG_ENDPOINT *ep)
GWEN_MSG_ENDPOINT
struct GWEN_MSG_ENDPOINT GWEN_MSG_ENDPOINT
Object which can send and receive messages (base class).
Definition endpoint.h:37
GWEN_MsgEndpoint_GetSocket
GWENHYWFAR_API GWEN_SOCKET * GWEN_MsgEndpoint_GetSocket(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_CheckSockets
GWENHYWFAR_API void GWEN_MsgEndpoint_CheckSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
GWEN_MsgEndpoint_AddSockets
GWENHYWFAR_API void GWEN_MsgEndpoint_AddSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
GWEN_MsgEndpoint_GetDefaultMessageSize
GWENHYWFAR_API int GWEN_MsgEndpoint_GetDefaultMessageSize(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_SetFlags
GWENHYWFAR_API void GWEN_MsgEndpoint_SetFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f)
GWEN_MsgEndpoint_RemoveUnconnectedAndEmptyChildren
GWENHYWFAR_API void GWEN_MsgEndpoint_RemoveUnconnectedAndEmptyChildren(GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_GetTimeOfLastStateChange
GWENHYWFAR_API time_t GWEN_MsgEndpoint_GetTimeOfLastStateChange(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_new
GWENHYWFAR_API GWEN_MSG_ENDPOINT * GWEN_MsgEndpoint_new(const char *name, int groupId)
GWEN_MSG_ENDPOINT_ADDSOCKETS_FN
void(* GWEN_MSG_ENDPOINT_ADDSOCKETS_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition endpoint.h:183
GWEN_MsgEndpoint_HaveMessageToSend
GWENHYWFAR_API int GWEN_MsgEndpoint_HaveMessageToSend(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_free
GWENHYWFAR_API void GWEN_MsgEndpoint_free(GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_Attach
GWENHYWFAR_API void GWEN_MsgEndpoint_Attach(GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_SetState
GWENHYWFAR_API void GWEN_MsgEndpoint_SetState(GWEN_MSG_ENDPOINT *ep, int m)
GWEN_MsgEndpoint_GetName
GWENHYWFAR_API const char * GWEN_MsgEndpoint_GetName(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_ReadFromSocket
GWENHYWFAR_API int GWEN_MsgEndpoint_ReadFromSocket(GWEN_MSG_ENDPOINT *ep, uint8_t *bufferPtr, uint32_t bufferLen)
GWEN_MsgEndpoint_IoLoop
GWENHYWFAR_API void GWEN_MsgEndpoint_IoLoop(GWEN_MSG_ENDPOINT *ep, int timeout)
GWEN_MsgEndpoint_SetCheckSocketsFn
GWENHYWFAR_API GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN GWEN_MsgEndpoint_SetCheckSocketsFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN fn)
GWEN_MsgEndpoint_ChildrenCheckSockets
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenCheckSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
GWEN_MsgEndpoint_WriteToSocket
GWENHYWFAR_API int GWEN_MsgEndpoint_WriteToSocket(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr, uint32_t bufferLen)
GWEN_MsgEndpoint_SetCurrentlyReceivedMsg
GWENHYWFAR_API void GWEN_MsgEndpoint_SetCurrentlyReceivedMsg(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
GWEN_MsgEndpoint_GetGroupId
GWENHYWFAR_API int GWEN_MsgEndpoint_GetGroupId(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_SetAddSocketsFn
GWENHYWFAR_API GWEN_MSG_ENDPOINT_ADDSOCKETS_FN GWEN_MsgEndpoint_SetAddSocketsFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT_ADDSOCKETS_FN fn)
GWEN_MsgEndpoint_ChildrenIoLoop
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenIoLoop(GWEN_MSG_ENDPOINT *ep, int timeout)
GWEN_MsgEndpoint_GetReceivedMessageList
GWENHYWFAR_API GWEN_MSG_LIST * GWEN_MsgEndpoint_GetReceivedMessageList(const GWEN_MSG_ENDPOINT *ep)
GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN
void(* GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition endpoint.h:188
GWEN_MsgEndpoint_SetDefaultMessageSize
GWENHYWFAR_API void GWEN_MsgEndpoint_SetDefaultMessageSize(GWEN_MSG_ENDPOINT *ep, int i)
GWEN_MsgEndpoint_GetFirstSendMessage
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_GetFirstSendMessage(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_GetSendMessageList
GWENHYWFAR_API GWEN_MSG_LIST * GWEN_MsgEndpoint_GetSendMessageList(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_SetSocket
GWENHYWFAR_API void GWEN_MsgEndpoint_SetSocket(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKET *sk)
GWEN_MsgEndpoint_GetNextMessageId
GWENHYWFAR_API uint32_t GWEN_MsgEndpoint_GetNextMessageId(GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_AddFlags
GWENHYWFAR_API void GWEN_MsgEndpoint_AddFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f)
GWEN_MsgEndpoint_AddReceivedMessage
GWENHYWFAR_API void GWEN_MsgEndpoint_AddReceivedMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
GWEN_MsgEndpoint_GetState
GWENHYWFAR_API int GWEN_MsgEndpoint_GetState(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_GetFirstReceivedMessage
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_GetFirstReceivedMessage(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_DelFlags
GWENHYWFAR_API void GWEN_MsgEndpoint_DelFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f)
GWEN_MsgEndpoint_GetCurrentlyReceivedMsg
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_GetCurrentlyReceivedMsg(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_AddSendMessage
GWENHYWFAR_API void GWEN_MsgEndpoint_AddSendMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
GWEN_MsgEndpoint_ChildrenAddSockets
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenAddSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
GWEN_MsgEndpoint_GetFlags
GWENHYWFAR_API uint32_t GWEN_MsgEndpoint_GetFlags(const GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_Disconnect
GWENHYWFAR_API void GWEN_MsgEndpoint_Disconnect(GWEN_MSG_ENDPOINT *ep)
GWEN_MsgEndpoint_TakeFirstReceivedMessage
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_TakeFirstReceivedMessage(GWEN_MSG_ENDPOINT *ep)
GWENHYWFAR_API
#define GWENHYWFAR_API
Definition gwenhywfarapi.h:67
inetsocket.h
This file contains sockets and socket sets.
GWEN_SOCKETSET
struct GWEN_SOCKETSETSTRUCT GWEN_SOCKETSET
Definition inetsocket.h:45
GWEN_SOCKET
struct GWEN_SOCKET GWEN_SOCKET
Definition inetsocket.h:44
inherit.h
GWEN_INHERIT_FUNCTION_LIB_DEFS
#define GWEN_INHERIT_FUNCTION_LIB_DEFS(t, decl)
Definition inherit.h:125
msg.h
GWEN_MSG
struct GWEN_MSG GWEN_MSG
Definition msg.h:24
GWEN_MSG_LIST
Definition listdoc.h:5766
tree2.h
GWEN_TREE2_FUNCTION_LIB_DEFS
#define GWEN_TREE2_FUNCTION_LIB_DEFS(t, pr, decl)
Definition tree2.h:336