changeset 24925:1300601041ac

g_strsplit_set is new in glib 2.4 g_strv_length is new in glib 2.6 This is one reason I didn't get around to making RPMs for 2.5.3, I don't (yet) know if there are other glib version dependencies to deal with...
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 07 Jan 2009 01:15:36 +0000
parents 380e7149a777
children ee9b00cc4298
files libpurple/protocols/qq/im.c libpurple/protocols/qq/qq_network.c libpurple/protocols/qq/qq_process.c libpurple/protocols/qq/utils.c
diffstat 4 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/qq/im.c	Wed Jan 07 01:13:27 2009 +0000
+++ b/libpurple/protocols/qq/im.c	Wed Jan 07 01:15:36 2009 +0000
@@ -467,7 +467,10 @@
 	/* qq_show_packet("text", (guint8 *)text, strlen(text)); */
 	g_return_val_if_fail(text != NULL && strlen(text) != 0, g_strdup(""));
 
-	segments = g_strsplit_set(text, "\x14\x15", 0);
+	while ((cur = strchr(text, '\x14')) != NULL)
+		*cur = '\x15';
+
+	segments = g_strsplit(text, "\x15", 0);
 	if(segments == NULL) {
 		return g_strdup("");
 	}
--- a/libpurple/protocols/qq/qq_network.c	Wed Jan 07 01:13:27 2009 +0000
+++ b/libpurple/protocols/qq/qq_network.c	Wed Jan 07 01:15:36 2009 +0000
@@ -214,7 +214,7 @@
 		qd->connect_retry = QQ_CONNECT_MAX;
 	}
 
-	segments = g_strsplit_set(qd->curr_server, ":", 0);
+	segments = g_strsplit(qd->curr_server, ":", 0);
 	tmp_server = g_strdup(segments[0]);
 	if (NULL != segments[1]) {
 		port = atoi(segments[1]);
--- a/libpurple/protocols/qq/qq_process.c	Wed Jan 07 01:13:27 2009 +0000
+++ b/libpurple/protocols/qq/qq_process.c	Wed Jan 07 01:15:36 2009 +0000
@@ -435,8 +435,8 @@
 static void process_server_msg(PurpleConnection *gc, guint8 *data, gint data_len, guint16 seq)
 {
 	qq_data *qd;
-	guint8 *data_str;
-	gchar **segments;
+	guint8 *data_str, i = 0;
+	gchar **segments, **seg;
 	gchar *funct_str, *from, *to;
 	gint bytes, funct;
 
@@ -448,9 +448,11 @@
 	g_memmove(data_str, data, data_len);
 	data_str[data_len] = 0x00;
 
-	segments = g_strsplit_set((gchar *) data_str, "\x1f", 0);
+	segments = g_strsplit((gchar *) data_str, "\x1f", 0);
 	g_return_if_fail(segments != NULL);
-	if (g_strv_length(segments) < 3) {
+	for (seg = segments; *seg != NULL; seg++)
+		i++;
+	if (i < 3) {
 		purple_debug_warning("QQ", "Server message segments is less than 3\n");
 		g_strfreev(segments);
 		return;
--- a/libpurple/protocols/qq/utils.c	Wed Jan 07 01:13:27 2009 +0000
+++ b/libpurple/protocols/qq/utils.c	Wed Jan 07 01:15:36 2009 +0000
@@ -95,8 +95,8 @@
 gchar **split_data(guint8 *data, gint len, const gchar *delimit, gint expected_fields)
 {
 	guint8 *input;
-	gchar **segments;
-	gint count, j;
+	gchar **segments, **seg;
+	gint count = 0, j;
 
 	g_return_val_if_fail(data != NULL && len != 0 && delimit != 0, NULL);
 
@@ -106,11 +106,12 @@
 	g_memmove(input, data, len);
 	input[len] = 0x00;
 
-	segments = g_strsplit_set((gchar *) input, delimit, 0);
+	segments = g_strsplit((gchar *) input, delimit, 0);
 	if (expected_fields <= 0)
 		return segments;
 
-	count = g_strv_length(segments);
+	for (seg = segments; *seg != NULL; seg++)
+		count++;
 	if (count < expected_fields) {	/* not enough fields */
 		purple_debug_error("QQ", "Less fields %d then %d\n", count, expected_fields);
 		return NULL;