aqhome: started rewriting message code, start using new event2 lib.
This commit is contained in:
72
aqhome/ipc2/message.h
Normal file
72
aqhome/ipc2/message.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2025 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 AQH_MESSAGE_H
|
||||
#define AQH_MESSAGE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/inherit.h>
|
||||
|
||||
|
||||
|
||||
typedef struct AQH_MESSAGE AQH_MESSAGE;
|
||||
GWEN_LIST_FUNCTION_LIB_DEFS(AQH_MESSAGE, AQH_Message, AQHOME_API)
|
||||
GWEN_INHERIT_FUNCTION_LIB_DEFS(AQH_MESSAGE, AQHOME_API)
|
||||
|
||||
|
||||
|
||||
AQHOME_API AQH_MESSAGE *AQH_Message_new(void);
|
||||
AQHOME_API void AQH_Message_IncRef(AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_free(AQH_MESSAGE *msg);
|
||||
|
||||
|
||||
/* unparsed data */
|
||||
AQHOME_API uint8_t *AQH_Message_GetMsgPointer(const AQH_MESSAGE *msg);
|
||||
AQHOME_API uint32_t AQH_Message_GetMsgSize(const AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_SetData(AQH_MESSAGE *msg, const uint8_t *msgPtr, uint32_t msgSize);
|
||||
|
||||
AQHOME_API uint32_t AQH_Message_GetUsedSize(const AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_SetUsedSize(AQH_MESSAGE *msg, uint32_t i);
|
||||
AQHOME_API void AQH_Message_IncUsedSize(AQH_MESSAGE *msg, uint32_t i);
|
||||
|
||||
/* parsed header data */
|
||||
AQHOME_API int AQH_Message_GetMsgType(const AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_SetMsgType(AQH_MESSAGE *msg, int i);
|
||||
|
||||
AQHOME_API int AQH_Message_GetMsgProtoId(const AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_SetMsgProtoId(AQH_MESSAGE *msg, int i);
|
||||
|
||||
AQHOME_API int AQH_Message_GetMsgProtoVer(const AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_SetMsgProtoVer(AQH_MESSAGE *msg, int i);
|
||||
|
||||
AQHOME_API int AQH_Message_GetMsgCommand(const AQH_MESSAGE *msg);
|
||||
AQHOME_API void AQH_Message_SetMsgCommand(AQH_MESSAGE *msg, int i);
|
||||
|
||||
/* helper functions for parsing */
|
||||
AQHOME_API void AQH_Message_WriteUint8At(AQH_MESSAGE *msg, uint32_t pos, uint8_t d);
|
||||
AQHOME_API uint8_t AQH_Message_ReadUint8At(const AQH_MESSAGE *msg, uint32_t pos, uint8_t defaultValue);
|
||||
|
||||
AQHOME_API void AQH_Message_WriteUint16At(AQH_MESSAGE *msg, uint32_t pos, uint16_t d);
|
||||
AQHOME_API uint16_t AQH_Message_ReadUint16At(const AQH_MESSAGE *msg, uint32_t pos, uint16_t defaultValue);
|
||||
|
||||
AQHOME_API void AQH_Message_WriteUint32At(AQH_MESSAGE *msg, uint32_t pos, uint32_t d);
|
||||
AQHOME_API uint32_t AQH_Message_ReadUint32At(const AQH_MESSAGE *msg, uint32_t pos, uint32_t defaultValue);
|
||||
|
||||
AQHOME_API void AQH_Message_WriteUint64At(AQH_MESSAGE *msg, uint32_t pos, uint64_t d);
|
||||
AQHOME_API uint64_t AQH_Message_ReadUint64At(const AQH_MESSAGE *msg, uint32_t pos, uint64_t defaultValue);
|
||||
|
||||
AQHOME_API void AQH_Message_WriteBytesAt(AQH_MESSAGE *msg, uint32_t pos, const uint8_t *bufferPtr, uint32_t bufferLen);
|
||||
AQHOME_API int AQH_Message_WriteStringAt(AQH_MESSAGE *msg, uint32_t pos, uint32_t maxSize, int filler, const char *s);
|
||||
AQHOME_API int AQH_Message_WriteStringWithTrailingNullAt(AQH_MESSAGE *msg, uint32_t pos, uint32_t maxSize, int filler, const char *s);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user