Index: protocols/msn/ns.c
===================================================================
--- protocols/msn/ns.c	(revision 002fede4370b9bf059049093a97e782e449705f4)
+++ protocols/msn/ns.c	(revision 5fbf8152c7e760ca2c4140f54ba56c62bcd2571b)
@@ -38,7 +38,7 @@
 static void msn_ns_send_adl_start(struct im_connection *ic);
 static void msn_ns_send_adl(struct im_connection *ic);
-static void msn_ns_structured_message(struct msn_data *handler, char *msg, int msglen, char **cmd);
-static void msn_ns_sdg(struct msn_data *handler, char *who, char **parts, char *action);
-static void msn_ns_nfy(struct msn_data *handler, char *who, char **parts, char *action, gboolean is_put);
+static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd);
+static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action);
+static void msn_ns_nfy(struct msn_data *md, char *who, char **parts, char *action, gboolean is_put);
 
 int msn_ns_write(struct im_connection *ic, int fd, const char *fmt, ...)
@@ -83,17 +83,17 @@
 gboolean msn_ns_connect(struct im_connection *ic, const char *host, int port)
 {
-	struct msn_data *handler = ic->proto_data;
-
-	if (handler->fd >= 0) {
-		closesocket(handler->fd);
-	}
-
-	if (handler->is_http) {
-		handler->gw = msn_gw_new(handler);
-		handler->gw->callback = msn_ns_callback;
-		msn_ns_connected(handler, -1, B_EV_IO_READ);
+	struct msn_data *md = ic->proto_data;
+
+	if (md->fd >= 0) {
+		closesocket(md->fd);
+	}
+
+	if (md->is_http) {
+		md->gw = msn_gw_new(md);
+		md->gw->callback = msn_ns_callback;
+		msn_ns_connected(md, -1, B_EV_IO_READ);
 	} else {
-		handler->fd = proxy_connect(host, port, msn_ns_connected, handler);
-		if (handler->fd < 0) {
+		md->fd = proxy_connect(host, port, msn_ns_connected, md);
+		if (md->fd < 0) {
 			imcb_error(ic, "Could not connect to server");
 			imc_logout(ic, TRUE);
@@ -108,5 +108,4 @@
 {
 	struct msn_data *md = data;
-	struct msn_data *handler = md;
 	struct im_connection *ic = md->ic;
 
@@ -117,7 +116,7 @@
 	}
 
-	g_free(handler->rxq);
-	handler->rxlen = 0;
-	handler->rxq = g_new0(char, 1);
+	g_free(md->rxq);
+	md->rxlen = 0;
+	md->rxq = g_new0(char, 1);
 
 	if (md->uuid == NULL) {
@@ -137,6 +136,6 @@
 
 	if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) {
-		if (!handler->is_http) {
-			handler->inpa = b_input_add(handler->fd, B_EV_IO_READ, msn_ns_callback, handler);
+		if (!md->is_http) {
+			md->inpa = b_input_add(md->fd, B_EV_IO_READ, msn_ns_callback, md);
 		}
 		imcb_log(ic, "Connected to server, waiting for reply");
@@ -146,40 +145,40 @@
 }
 
-void msn_ns_close(struct msn_data *handler)
-{
-	if (handler->gw) {
-		if (handler->gw->waiting) {
+void msn_ns_close(struct msn_data *md)
+{
+	if (md->gw) {
+		if (md->gw->waiting) {
 			/* mark it as closed, let the request callback clean it */
-			handler->gw->open = FALSE;
+			md->gw->open = FALSE;
 		} else {
-			msn_gw_free(handler->gw);
-		}
-	}
-	if (handler->fd >= 0) {
-		closesocket(handler->fd);
-		b_event_remove(handler->inpa);
-	}
-
-	handler->fd = handler->inpa = -1;
-	g_free(handler->rxq);
-	g_free(handler->cmd_text);
-
-	handler->rxlen = 0;
-	handler->rxq = NULL;
-	handler->cmd_text = NULL;
+			msn_gw_free(md->gw);
+		}
+	}
+	if (md->fd >= 0) {
+		closesocket(md->fd);
+		b_event_remove(md->inpa);
+	}
+
+	md->fd = md->inpa = -1;
+	g_free(md->rxq);
+	g_free(md->cmd_text);
+
+	md->rxlen = 0;
+	md->rxq = NULL;
+	md->cmd_text = NULL;
 }
 
 static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition cond)
 {
-	struct msn_data *handler = data;
-	struct im_connection *ic = handler->ic;
+	struct msn_data *md = data;
+	struct im_connection *ic = md->ic;
 	char *bytes;
 	int st;
 
-	if (handler->is_http) {
-		st = msn_gw_read(handler->gw, &bytes);
+	if (md->is_http) {
+		st = msn_gw_read(md->gw, &bytes);
 	} else {
 		bytes = g_malloc(1024);
-		st = read(handler->fd, bytes, 1024);
+		st = read(md->fd, bytes, 1024);
 	}
 
@@ -190,10 +189,10 @@
 	}
 
-	msn_queue_feed(handler, bytes, st);
+	msn_queue_feed(md, bytes, st);
 
 	g_free(bytes);
 
 	/* Ignore ret == 0, it's already disconnected then. */
-	msn_handler(handler);
+	msn_handler(md);
 
 	return TRUE;
@@ -201,8 +200,7 @@
 }
 
-int msn_ns_command(struct msn_data *handler, char **cmd, int num_parts)
-{
-	struct im_connection *ic = handler->ic;
-	struct msn_data *md = handler;
+int msn_ns_command(struct msn_data *md, char **cmd, int num_parts)
+{
+	struct im_connection *ic = md->ic;
 
 	if (num_parts == 0) {
@@ -218,9 +216,9 @@
 		}
 
-		return(msn_ns_write(ic, handler->fd, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s VmVyc2lvbjogMQ0KWGZyQ291bnQ6IDINClhmclNlbnRVVENUaW1lOiA2MzU2MTQ3OTU5NzgzOTAwMDANCklzR2VvWGZyOiB0cnVlDQo=\r\n",
+		return(msn_ns_write(ic, md->fd, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s VmVyc2lvbjogMQ0KWGZyQ291bnQ6IDINClhmclNlbnRVVENUaW1lOiA2MzU2MTQ3OTU5NzgzOTAwMDANCklzR2VvWGZyOiB0cnVlDQo=\r\n",
 		                    ++md->trId, ic->acc->user));
 	} else if (strcmp(cmd[0], "CVR") == 0) {
 		/* We don't give a damn about the information we just received */
-		return msn_ns_write(ic, handler->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user);
+		return msn_ns_write(ic, md->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user);
 	} else if (strcmp(cmd[0], "XFR") == 0) {
 		char *server;
@@ -228,6 +226,6 @@
 
 		if (num_parts >= 6 && strcmp(cmd[2], "NS") == 0) {
-			b_event_remove(handler->inpa);
-			handler->inpa = -1;
+			b_event_remove(md->inpa);
+			md->inpa = -1;
 
 			server = strchr(cmd[3], ':');
@@ -276,7 +274,7 @@
 		}
 
-		handler->msglen = atoi(cmd[3]);
-
-		if (handler->msglen <= 0) {
+		md->msglen = atoi(cmd[3]);
+
+		if (md->msglen <= 0) {
 			imcb_error(ic, "Syntax error");
 			imc_logout(ic, TRUE);
@@ -288,5 +286,5 @@
 			return msn_ns_finish_login(ic);
 		} else if (num_parts >= 3) {
-			handler->msglen = atoi(cmd[2]);
+			md->msglen = atoi(cmd[2]);
 		}
 	} else if (strcmp(cmd[0], "CHL") == 0) {
@@ -327,16 +325,16 @@
 		/* Coming up is cmd[2] bytes of stuff we're supposed to
 		   censore. Meh. */
-		handler->msglen = atoi(cmd[2]);
+		md->msglen = atoi(cmd[2]);
 	} else if ((strcmp(cmd[0], "NFY") == 0) || (strcmp(cmd[0], "SDG") == 0)) {
 		if (num_parts >= 3) {
-			handler->msglen = atoi(cmd[2]);
+			md->msglen = atoi(cmd[2]);
 		}
 	} else if (strcmp(cmd[0], "PUT") == 0) {
 		if (num_parts >= 4) {
-			handler->msglen = atoi(cmd[3]);
+			md->msglen = atoi(cmd[3]);
 		}
 	} else if (strcmp(cmd[0], "NOT") == 0) {
 		if (num_parts >= 2) {
-			handler->msglen = atoi(cmd[1]);
+			md->msglen = atoi(cmd[1]);
 		}
 	} else if (strcmp(cmd[0], "QNG") == 0) {
@@ -355,5 +353,5 @@
 		/* Oh yes, errors can have payloads too now. Discard them for now. */
 		if (num_parts >= 3) {
-			handler->msglen = atoi(cmd[2]);
+			md->msglen = atoi(cmd[2]);
 		}
 	} else {
@@ -364,7 +362,7 @@
 }
 
-int msn_ns_message(struct msn_data *handler, char *msg, int msglen, char **cmd, int num_parts)
-{
-	struct im_connection *ic = handler->ic;
+int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts)
+{
+	struct im_connection *ic = md->ic;
 	char *body;
 	int blen = 0;
@@ -493,5 +491,5 @@
 		}
 	} else if ((strcmp(cmd[0], "SDG") == 0) || (strcmp(cmd[0], "NFY") == 0)) {
-		msn_ns_structured_message(handler, msg, msglen, cmd);
+		msn_ns_structured_message(md, msg, msglen, cmd);
 	}
 
@@ -499,5 +497,5 @@
 }
 
-static void msn_ns_structured_message(struct msn_data *handler, char *msg, int msglen, char **cmd)
+static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd)
 {
 	char **parts = NULL;
@@ -519,9 +517,9 @@
 
 	if ((strcmp(cmd[0], "SDG") == 0) && (action = get_rfc822_header(parts[2], "Message-Type", 0))) {
-		msn_ns_sdg(handler, who, parts, action);
+		msn_ns_sdg(md, who, parts, action);
 
 	} else if ((strcmp(cmd[0], "NFY") == 0) && (action = get_rfc822_header(parts[2], "Uri", 0))) {
 		gboolean is_put = (strcmp(cmd[1], "PUT") == 0);
-		msn_ns_nfy(handler, who, parts, action, is_put);
+		msn_ns_nfy(md, who, parts, action, is_put);
 	}
 
@@ -533,7 +531,7 @@
 }
 
-static void msn_ns_sdg(struct msn_data *handler, char *who, char **parts, char *action)
-{
-	struct im_connection *ic = handler->ic;
+static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action)
+{
+	struct im_connection *ic = md->ic;
 
 	if (strcmp(action, "Control/Typing") == 0) {
@@ -544,7 +542,7 @@
 }
 
-static void msn_ns_nfy(struct msn_data *handler, char *who, char **parts, char *action, gboolean is_put)
-{
-	struct im_connection *ic = handler->ic;
+static void msn_ns_nfy(struct msn_data *md, char *who, char **parts, char *action, gboolean is_put)
+{
+	struct im_connection *ic = md->ic;
 	struct xt_node *body = NULL;
 	struct xt_node *s = NULL;
