summaryrefslogtreecommitdiff
path: root/src/cmumble.c
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-16 14:35:25 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-16 14:40:49 +0200
commitb396ee26febb003374f877af841814940fefd034 (patch)
tree094e3de7abb9eef478fbff3be0795df0c105218c /src/cmumble.c
parent35670247b159dd65c174988a3d4ce3e105356d3a (diff)
downloadcmumble-b396ee26febb003374f877af841814940fefd034.tar.gz
cmumble-b396ee26febb003374f877af841814940fefd034.tar.bz2
cmumble-b396ee26febb003374f877af841814940fefd034.zip
Typesafe callback initialization
Diffstat (limited to 'src/cmumble.c')
-rw-r--r--src/cmumble.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/cmumble.c b/src/cmumble.c
index c72ba25..dea9a55 100644
--- a/src/cmumble.c
+++ b/src/cmumble.c
@@ -202,34 +202,33 @@ recv_user_state(MumbleProto__UserState *state, struct context *ctx)
ctx->users = g_list_prepend(ctx->users, user);
}
-
-static const callback_t callbacks[] = {
- [Version] = (callback_t) recv_version,
- [UDPTunnel] = (callback_t) recv_udp_tunnel,
- [Authenticate] = (callback_t) NULL,
- [Ping] = (callback_t) NULL,
- [Reject] = (callback_t) NULL,
- [ServerSync] = (callback_t) recv_server_sync,
- [ChannelRemove] = (callback_t) NULL,
- [ChannelState] = (callback_t) recv_channel_state,
- [UserRemove] = (callback_t) recv_user_remove,
- [UserState] = (callback_t) recv_user_state,
- [BanList] = (callback_t) NULL,
- [TextMessage] = (callback_t) NULL,
- [PermissionDenied] = (callback_t) NULL,
- [ACL] = (callback_t) NULL,
- [QueryUsers] = (callback_t) NULL,
- [CryptSetup] = (callback_t) recv_crypt_setup,
- [ContextActionModify] = (callback_t) NULL,
- [ContextAction] = (callback_t) NULL,
- [UserList] = (callback_t) NULL,
- [VoiceTarget] = (callback_t) NULL,
- [PermissionQuery] = (callback_t) NULL,
- [CodecVersion] = (callback_t) recv_codec_version,
- [UserStats] = (callback_t) NULL,
- [RequestBlob] = (callback_t) NULL,
- [ServerConfig] = (callback_t) NULL,
- [SuggestConfig] = (callback_t) NULL,
+static struct mumble_callbacks callbacks = {
+ .Version = recv_version,
+ .UDPTunnel = recv_udp_tunnel,
+ .Authenticate = NULL,
+ .Ping = NULL,
+ .Reject = NULL,
+ .ServerSync = recv_server_sync,
+ .ChannelRemove = NULL,
+ .ChannelState = recv_channel_state,
+ .UserRemove = recv_user_remove,
+ .UserState = recv_user_state,
+ .BanList = NULL,
+ .TextMessage = NULL,
+ .PermissionDenied = NULL,
+ .ACL = NULL,
+ .QueryUsers = NULL,
+ .CryptSetup = recv_crypt_setup,
+ .ContextActionModify = NULL,
+ .ContextAction = NULL,
+ .UserList = NULL,
+ .VoiceTarget = NULL,
+ .PermissionQuery = NULL,
+ .CodecVersion = recv_codec_version,
+ .UserStats = NULL,
+ .RequestBlob = NULL,
+ .ServerConfig = NULL,
+ .SuggestConfig = NULL,
};
static gboolean
@@ -254,7 +253,7 @@ read_cb(GSocket *socket, GIOCondition condition, gpointer data)
GInputStream *input = g_io_stream_get_input_stream(ctx->iostream);
do {
- recv_msg(ctx, callbacks, G_N_ELEMENTS(callbacks));
+ recv_msg(ctx, &callbacks);
} while (g_input_stream_has_pending(input));
/* FIXME */