diff options
Diffstat (limited to 'src/message.h')
-rw-r--r-- | src/message.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/message.h b/src/message.h index 0186192..b34bed7 100644 --- a/src/message.h +++ b/src/message.h @@ -10,6 +10,28 @@ enum cmumble_message { #undef MUMBLE_MSG }; +#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 + + struct cmumble; void @@ -18,4 +40,20 @@ cmumble_send_msg(struct cmumble *cm, ProtobufCMessage *msg); int cmumble_recv_msg(struct cmumble *cm); + +#define MUMBLE_MSG(cname, name) \ + static inline void \ + cmumble_init_##name(struct mumble_##name *msg) \ + { \ + mumble_proto__##name##__init(&msg->m); \ + } \ + \ + static inline void \ + cmumble_send_##name(struct cmumble *cm, struct mumble_##name *msg) \ + { \ + cmumble_send_msg(cm, &msg->m.base); \ + } +MUMBLE_MSGS +#undef MUMBLE_MSG + #endif /* _MESSAGE_H_ */ |