diff src/core.c @ 2438:5cbe86a444d9

[gaim-migrate @ 2451] more updates to core. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 06 Oct 2001 00:10:29 +0000
parents b4f2a53c0ee5
children 932adc1ac9ed
line wrap: on
line diff
--- a/src/core.c	Fri Oct 05 22:23:27 2001 +0000
+++ b/src/core.c	Sat Oct 06 00:10:29 2001 +0000
@@ -67,7 +67,7 @@
 	}
 }
 
-static gint gaim_recv(GIOChannel *source, guchar *buf, gint len)
+static gint gaim_recv(GIOChannel *source, void *buf, gint len)
 {
 	gint total = 0;
 	gint cur;
@@ -87,25 +87,14 @@
 {
 	struct UI *ui = data;
 
-	guchar buf[2] = {0, 0};
+	guchar type;
+	guchar subtype;
 	guint32 len;
 
 	guchar *in;
 
-	gushort type;
-
-	/* buf[0] is to specify gaim, buf[1] is for protocol version */
-	if ((gaim_recv(source, buf, 2) != 2) || (buf[0] != 102) || (buf[1] != 1)) { 
-		debug_printf("UI has abandoned us! (%d %d)\n", buf[0], buf[1]);
-		uis = g_slist_remove(uis, ui);
-		g_io_channel_close(ui->channel);
-		g_source_remove(ui->inpa);
-		g_free(ui);
-		return FALSE;
-	}
-
 	/* no byte order worries! this'll change if we go to TCP */
-	if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) {
+	if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) {
 		debug_printf("UI has abandoned us!\n");
 		uis = g_slist_remove(uis, ui);
 		g_io_channel_close(ui->channel);
@@ -114,10 +103,34 @@
 		return FALSE;
 	}
 
-	in = g_new0(guchar, len + 1);
-	gaim_recv(source, in, len);
+	if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) {
+		debug_printf("UI has abandoned us!\n");
+		uis = g_slist_remove(uis, ui);
+		g_io_channel_close(ui->channel);
+		g_source_remove(ui->inpa);
+		g_free(ui);
+		return FALSE;
+	}
 
-	memcpy(&type, in, sizeof(type));
+	if (gaim_recv(source, &len, sizeof(len)) != sizeof(len)) {
+		debug_printf("UI has abandoned us!\n");
+		uis = g_slist_remove(uis, ui);
+		g_io_channel_close(ui->channel);
+		g_source_remove(ui->inpa);
+		g_free(ui);
+		return FALSE;
+	}
+
+	in = g_new0(guchar, len);
+	if (gaim_recv(source, in, len) != len) {
+		debug_printf("UI has abandoned us!\n");
+		uis = g_slist_remove(uis, ui);
+		g_io_channel_close(ui->channel);
+		g_source_remove(ui->inpa);
+		g_free(ui);
+		return FALSE;
+	}
+
 	switch (type) {
 			/*
 		case CUI_TYPE_META: