diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-11-21 23:11:36 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-11-22 08:25:04 +0100 |
commit | 19250ba1e16857c70cbbfe15b9e939b95e009896 (patch) | |
tree | 2bfd6228b1e65cefe584196566bbc40de6321d5b /src/message.h | |
parent | 68992dfac34263d8da2ba9523342d92cbd6f6f98 (diff) | |
download | cmumble-19250ba1e16857c70cbbfe15b9e939b95e009896.tar.gz cmumble-19250ba1e16857c70cbbfe15b9e939b95e009896.tar.bz2 cmumble-19250ba1e16857c70cbbfe15b9e939b95e009896.zip |
Pass message type implicity in cmumble_send_*
This also removes the unneeded "struct mumble_*" which is ugly in use.
Diffstat (limited to 'src/message.h')
-rw-r--r-- | src/message.h | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/message.h b/src/message.h index b34bed7..a665301 100644 --- a/src/message.h +++ b/src/message.h @@ -5,29 +5,12 @@ #include "mumble.pb-c.h" enum cmumble_message { -#define MUMBLE_MSG(a,b) a, +#define MUMBLE_MSG(a,b) CMUMBLE_MESSAGE_##a, MUMBLE_MSGS #undef MUMBLE_MSG + CMUMBLE_MESSAGE_COUNT }; -#define PREAMBLE_SIZE 6 -struct mumble_msg_base { - uint8_t preamble[PREAMBLE_SIZE]; -}; - -struct __attribute__ ((__packed__)) mumble_message { - struct mumble_msg_base base; - ProtobufCMessage msg; -}; - -#define MUMBLE_MSG(cname, name) \ - struct __attribute__ ((__packed__)) mumble_##name { \ - struct mumble_msg_base base; \ - MumbleProto__##cname m; \ - }; -MUMBLE_MSGS -#undef MUMBLE_MSG - /* Makro to hide ugly protobuf-c constat names. */ #define MUMBLE_REJECT_TYPE(type) MUMBLE_PROTO__REJECT__REJECT_TYPE__##type @@ -35,23 +18,26 @@ MUMBLE_MSGS struct cmumble; void -cmumble_send_msg(struct cmumble *cm, ProtobufCMessage *msg); +cmumble_send_msg(struct cmumble *cm, ProtobufCMessage *msg, + enum cmumble_message type); int cmumble_recv_msg(struct cmumble *cm); #define MUMBLE_MSG(cname, name) \ + typedef MumbleProto__##cname mumble_##name##_t; \ + \ static inline void \ - cmumble_init_##name(struct mumble_##name *msg) \ + cmumble_init_##name(mumble_##name##_t *msg) \ { \ - mumble_proto__##name##__init(&msg->m); \ + mumble_proto__##name##__init(msg); \ } \ \ static inline void \ - cmumble_send_##name(struct cmumble *cm, struct mumble_##name *msg) \ + cmumble_send_##name(struct cmumble *cm, mumble_##name##_t *msg) \ { \ - cmumble_send_msg(cm, &msg->m.base); \ + cmumble_send_msg(cm, &msg->base, CMUMBLE_MESSAGE_##cname); \ } MUMBLE_MSGS #undef MUMBLE_MSG |