From 8da315b5836c738216a1cdc677de5f5a3e1f89c6 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Sat, 23 Apr 2011 16:51:46 +0200 Subject: [PATCH 1/2] function definitions for creating packet & modifier structs --- include/psyc.h | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/include/psyc.h b/include/psyc.h index 53c1cf3..c25f9e7 100644 --- a/include/psyc.h +++ b/include/psyc.h @@ -79,18 +79,20 @@ typedef enum PSYC_LIST_BINARY = 2, } PSYC_ListType; -typedef enum { +typedef enum +{ PSYC_MODIFIER_CHECK_LENGTH = 0, PSYC_MODIFIER_NEED_LENGTH = 1, PSYC_MODIFIER_NO_LENGTH = 2, PSYC_MODIFIER_ROUTING = 3, -} PSYC_ModifierType; +} PSYC_ModifierFlag; -typedef enum { - PSYC_CONTENT_CHECK_LENGTH = 0, - PSYC_CONTENT_NEED_LENGTH = 1, - PSYC_CONTENT_NO_LENGTH = 2, -} PSYC_ContentType; +typedef enum +{ + PSYC_PACKET_CHECK_LENGTH = 0, + PSYC_PACKET_NEED_LENGTH = 1, + PSYC_PACKET_NO_LENGTH = 2, +} PSYC_PacketFlag; typedef struct { @@ -99,23 +101,32 @@ typedef struct } PSYC_Array; /* intermediate struct for a PSYC variable modification */ -typedef struct { +typedef struct +{ char oper; // not call it 'operator' as C++ may not like that..? PSYC_Array name; PSYC_Array value; - PSYC_ModifierType type; + PSYC_ModifierFlag flag; } PSYC_Modifier; /* intermediate struct for a PSYC packet */ -typedef struct { - PSYC_Modifier **routing; // Header - PSYC_Modifier **entity; // Header +typedef struct +{ + PSYC_Modifier** routing; // Routing header + PSYC_Modifier** entity; // Entitiy header PSYC_Array method; PSYC_Array data; - PSYC_ContentType contentType; - size_t contentLength; + size_t length; /// Length of content part + PSYC_PacketFlag flag; } PSYC_Packet; +PSYC_Modifier PSYC_newModifier(char* oper, PSYC_Array* name, PSYC_Array* value, PSYC_ModifierFlag flag); + +PSYC_Modifier PSYC_newModifier2(char* oper, char* name, size_t namelen, char* value, size_t valuelen, PSYC_ModifierFlag flag); + +PSYC_Packet PSYC_newPacket(PSYC_Modifier** routing, PSYC_Modifier **entity, PSYC_Array* method, PSYC_Array* data, PSYC_PacketFlag flag) + +PSYC_Packet PSYC_newPacket2(PSYC_Modifier** routing, PSYC_Modifier **entity, char* method, size_t methodlen, char* data, size_t datalen, PSYC_PacketFlag flag) /// Routing vars in alphabetical order. extern const PSYC_Array PSYC_routingVars[]; From 1a34b50dbf70c8ff2daeb191ed71b99c521ff38d Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Sat, 23 Apr 2011 16:58:02 +0200 Subject: [PATCH 2/2] added missing ; --- include/psyc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/psyc.h b/include/psyc.h index c25f9e7..640416f 100644 --- a/include/psyc.h +++ b/include/psyc.h @@ -124,9 +124,9 @@ PSYC_Modifier PSYC_newModifier(char* oper, PSYC_Array* name, PSYC_Array* value, PSYC_Modifier PSYC_newModifier2(char* oper, char* name, size_t namelen, char* value, size_t valuelen, PSYC_ModifierFlag flag); -PSYC_Packet PSYC_newPacket(PSYC_Modifier** routing, PSYC_Modifier **entity, PSYC_Array* method, PSYC_Array* data, PSYC_PacketFlag flag) +PSYC_Packet PSYC_newPacket(PSYC_Modifier** routing, PSYC_Modifier **entity, PSYC_Array* method, PSYC_Array* data, PSYC_PacketFlag flag); -PSYC_Packet PSYC_newPacket2(PSYC_Modifier** routing, PSYC_Modifier **entity, char* method, size_t methodlen, char* data, size_t datalen, PSYC_PacketFlag flag) +PSYC_Packet PSYC_newPacket2(PSYC_Modifier** routing, PSYC_Modifier **entity, char* method, size_t methodlen, char* data, size_t datalen, PSYC_PacketFlag flag); /// Routing vars in alphabetical order. extern const PSYC_Array PSYC_routingVars[];