diff options
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 |