simple: Fix search for message headers.

Sun, 17 May 2020 05:34:38 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sun, 17 May 2020 05:34:38 -0400
changeset 40415
f38b64939ecb
parent 40414
744c1e9d80f1
child 40416
54c050e07348

simple: Fix search for message headers.

The list contains key-value pairs (of `PurpleKeyValuePair` type now, but
`struct siphdrelement` before) so using `g_ascii_strcasecmp` directly
does not work.

libpurple/protocols/simple/sipmsg.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/simple/sipmsg.c	Sun May 17 05:00:02 2020 -0400
+++ b/libpurple/protocols/simple/sipmsg.c	Sun May 17 05:34:38 2020 -0400
@@ -191,21 +191,32 @@
 	g_free(msg);
 }
 
-void sipmsg_remove_header(struct sipmsg *msg, const gchar *name) {
-	GSList *tmp = g_slist_find_custom(msg->headers, name, (GCompareFunc)g_ascii_strcasecmp);
-	if(tmp) {
+static gint
+compare_header_names(gconstpointer a, gconstpointer b)
+{
+	const PurpleKeyValuePair *kvpa = a;
+	const gchar *name = b;
+	return g_ascii_strcasecmp(kvpa->key, name);
+}
+
+void
+sipmsg_remove_header(struct sipmsg *msg, const gchar *name)
+{
+	GSList *tmp = g_slist_find_custom(msg->headers, name, compare_header_names);
+	if (tmp) {
 		PurpleKeyValuePair *elem = tmp->data;
 		msg->headers = g_slist_delete_link(msg->headers, tmp);
 		purple_key_value_pair_free(elem);
 	}
 }
 
-const gchar *sipmsg_find_header(struct sipmsg *msg, const gchar *name) {
-	GSList *tmp = g_slist_find_custom(msg->headers, name, (GCompareFunc)g_ascii_strcasecmp);
-	if(tmp) {
+const gchar *
+sipmsg_find_header(struct sipmsg *msg, const gchar *name)
+{
+	GSList *tmp = g_slist_find_custom(msg->headers, name, compare_header_names);
+	if (tmp) {
 		PurpleKeyValuePair *elem = tmp->data;
 		return elem->value;
 	}
 	return NULL;
 }
-

mercurial