diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-09-23 10:53:51 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-09-23 10:53:51 +0200 |
commit | d1fac4d941aaa9dbf9e72540f97d928af241cb5e (patch) | |
tree | fd360bbafbc5b90bbc088671d0306b38043622a1 /src/messages.c | |
parent | e50020020c9770e180735361182e9968249cbfa2 (diff) | |
download | cmumble-d1fac4d941aaa9dbf9e72540f97d928af241cb5e.tar.gz cmumble-d1fac4d941aaa9dbf9e72540f97d928af241cb5e.tar.bz2 cmumble-d1fac4d941aaa9dbf9e72540f97d928af241cb5e.zip |
Store callbacks in context
Diffstat (limited to 'src/messages.c')
-rw-r--r-- | src/messages.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/messages.c b/src/messages.c index 8807166..98b53e3 100644 --- a/src/messages.c +++ b/src/messages.c @@ -71,16 +71,17 @@ send_msg(struct context *ctx, ProtobufCMessage *msg) } int -recv_msg(struct context *ctx, const struct mumble_callbacks *cbs) +recv_msg(struct context *ctx) { uint8_t preamble[PREAMBLE_SIZE]; ProtobufCMessage *msg; gchar *data; int type, len; gssize ret; - const callback_t *callbacks = (const callback_t *) cbs; GError *error = NULL; + g_assert(ctx->callbacks); + ret = g_pollable_input_stream_read_nonblocking(ctx->con.input, preamble, PREAMBLE_SIZE, NULL, &error); @@ -121,8 +122,8 @@ recv_msg(struct context *ctx, const struct mumble_callbacks *cbs) udptunnel.packet.len = len; udptunnel.packet.data = (uint8_t *) data; - if (callbacks[UDPTunnel]) - callbacks[UDPTunnel](&udptunnel.base, ctx); + if (ctx->callbacks[UDPTunnel]) + ctx->callbacks[UDPTunnel](&udptunnel.base, ctx); g_free(data); return 0; @@ -136,8 +137,8 @@ recv_msg(struct context *ctx, const struct mumble_callbacks *cbs) } g_print("debug: received message: %s type:%d, len:%d\n", messages[type].name, type, len); - if (callbacks[type]) - callbacks[type](msg, ctx); + if (ctx->callbacks[type]) + ctx->callbacks[type](msg, ctx); protobuf_c_message_free_unpacked(msg, NULL); g_free(data); |