+ codec_t *cd = Memory_safeMalloc(1, sizeof(codec_t));
+ init_list_entry(&cd->node);
+ cd->codec = codec;
+ list_add_tail(&cd->node, &client->codecs);
+}
+
+void Client_codec_free(client_t *client)
+{
+ struct dlist *itr, *save;
+ list_iterate_safe(itr, save, &client->codecs) {
+ list_del(&list_get_entry(itr, codec_t, node)->node);
+ free(list_get_entry(itr, codec_t, node));
+ }
+}
+
+codec_t *Client_codec_iterate(client_t *client, codec_t **codec_itr)
+{
+ codec_t *cd = *codec_itr;
+
+ if (list_empty(&client->codecs))
+ return NULL;
+
+ if (cd == NULL) {
+ cd = list_get_entry(list_get_first(&client->codecs), codec_t, node);
+ } else {
+ if (list_get_next(&cd->node) == &client->codecs)
+ cd = NULL;
+ else
+ cd = list_get_entry(list_get_next(&cd->node), codec_t, node);
+ }
+ *codec_itr = cd;
+ return cd;
+}
+
+void Client_token_add(client_t *client, char *token_string)
+{
+ token_t *token;
+
+ if (client->tokencount >= MAX_TOKENS)
+ return;
+ token = Memory_safeMalloc(1, sizeof(token_t));
+ init_list_entry(&token->node);
+ token->token = strdup(token_string);
+ if (token->token == NULL)
+ Log_fatal("Out of memory");
+ list_add_tail(&token->node, &client->tokens);
+ client->tokencount++;
+}
+
+bool_t Client_token_match(client_t *client, char const *str)
+{
+ token_t *token;
+ struct dlist *itr;
+
+ if (list_empty(&client->tokens))
+ return false;
+ list_iterate(itr, &client->tokens) {
+ token = list_get_entry(itr, token_t, node);
+ if (strncasecmp(token->token, str, MAX_TOKENSIZE) == 0)
+ return true;
+ }
+ return false;
+}
+
+void Client_token_free(client_t *client)
+{
+ struct dlist *itr, *save;
+ token_t *token;
+
+ list_iterate_safe(itr, save, &client->tokens) {
+ token = list_get_entry(itr, token_t, node);
+ list_del(&token->node);
+ free(token->token);
+ free(token);
+ }
+ client->tokencount = 0;
+}
+
+
+#define OPUS_WARN_USING "<strong>WARNING:</strong> Your client doesn't support the Opus codec the server is using, you won't be able to talk or hear anyone. Please upgrade your Mumble client."
+#define OPUS_WARN_SWITCHING "<strong>WARNING:</strong> Your client doesn't support the Opus codec the server is switching to, you won't be able to talk or hear anyone. Please upgrade your Mumble client."
+void recheckCodecVersions(client_t *connectingClient)
+{
+ client_t *client_itr = NULL;
+ int max = 0, version, current_version;
+ int users = 0, opus = 0;