Index: protocols/oscar/conn.c
===================================================================
--- protocols/oscar/conn.c	(revision 25c4c78e2ddad482dfc9d5a104f76325fcc2f8e5)
+++ protocols/oscar/conn.c	(revision 5ebff60479fc7a9f7f50ac03b124c91d4e6ebe11)
@@ -7,5 +7,5 @@
  */
 
-#include <aim.h> 
+#include <aim.h>
 #include "sock.h"
 
@@ -15,9 +15,9 @@
  * In OSCAR, every connection has a set of SNAC groups associated
  * with it.  These are the groups that you can send over this connection
- * without being guarenteed a "Not supported" SNAC error.  
- *
- * The grand theory of things says that these associations transcend 
+ * without being guarenteed a "Not supported" SNAC error.
+ *
+ * The grand theory of things says that these associations transcend
  * what libfaim calls "connection types" (conn->type).  You can probably
- * see the elegance here, but since I want to revel in it for a bit, you 
+ * see the elegance here, but since I want to revel in it for a bit, you
  * get to hear it all spelled out.
  *
@@ -25,5 +25,5 @@
  * of your modules has just given you a SNAC of the group 0x0004 to send
  * you.  Maybe an IM destined for some twit in Greenland.  So you start
- * at the top of your connection list, looking for a connection that 
+ * at the top of your connection list, looking for a connection that
  * claims to support group 0x0004.  You find one.  Why, that neat BOS
  * connection of yours can do that.  So you send it on its way.
@@ -43,6 +43,6 @@
  * that connection.  One of the first things you get from this new server
  * is a message saying that indeed it does support the group you were looking
- * for.  So you continue and send rate confirmation and all that.  
- * 
+ * for.  So you continue and send rate confirmation and all that.
+ *
  * Then you remember you had that SNAC to send, and now you have a means to
  * do it, and you do, and everyone is happy.  Except the Greenlander, who is
@@ -57,5 +57,5 @@
  * to make libfaim work that way.  It would take a fair amount of effort,
  * and probably some client API changes as well.  (Whenever I don't want
- * to do something, I just say it would change the client API.  Then I 
+ * to do something, I just say it would change the client API.  Then I
  * instantly have a couple of supporters of not doing it.)
  *
@@ -69,9 +69,10 @@
 void aim_conn_addgroup(aim_conn_t *conn, guint16 group)
 {
-	aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
+	aim_conn_inside_t *ins = (aim_conn_inside_t *) conn->inside;
 	struct snacgroup *sg;
 
-	if (!(sg = g_malloc(sizeof(struct snacgroup))))
+	if (!(sg = g_malloc(sizeof(struct snacgroup)))) {
 		return;
+	}
 
 	sg->group = group;
@@ -88,10 +89,11 @@
 
 	for (cur = sess->connlist; cur; cur = cur->next) {
-		aim_conn_inside_t *ins = (aim_conn_inside_t *)cur->inside;
+		aim_conn_inside_t *ins = (aim_conn_inside_t *) cur->inside;
 		struct snacgroup *sg;
 
 		for (sg = ins->groups; sg; sg = sg->next) {
-			if (sg->group == group)
+			if (sg->group == group) {
 				return cur;
+			}
 		}
 	}
@@ -150,6 +152,7 @@
 	aim_tx_cleanqueue(sess, *deadconn);
 
-	if ((*deadconn)->fd != -1) 
+	if ((*deadconn)->fd != -1) {
 		aim_conn_close(*deadconn);
+	}
 
 	/*
@@ -158,15 +161,17 @@
 	 * ->internal instead.
 	 */
-	if ((*deadconn)->priv)
+	if ((*deadconn)->priv) {
 		g_free((*deadconn)->priv);
+	}
 
 	/*
 	 * This will free ->internal if it necessary...
 	 */
-	if ((*deadconn)->type == AIM_CONN_TYPE_CHAT)
+	if ((*deadconn)->type == AIM_CONN_TYPE_CHAT) {
 		aim_conn_kill_chat(sess, *deadconn);
+	}
 
 	if ((*deadconn)->inside) {
-		aim_conn_inside_t *inside = (aim_conn_inside_t *)(*deadconn)->inside;
+		aim_conn_inside_t *inside = (aim_conn_inside_t *) (*deadconn)->inside;
 
 		connkill_snacgroups(&inside->groups);
@@ -218,6 +223,7 @@
 {
 
-	if (!deadconn)
+	if (!deadconn) {
 		return;
+	}
 
 	deadconn->fd = -1;
@@ -245,8 +251,9 @@
 	aim_conn_t *newconn;
 
-	if (!(newconn = g_new0(aim_conn_t,1))) 	
+	if (!(newconn = g_new0(aim_conn_t, 1))) {
 		return NULL;
-
-	if (!(newconn->inside = g_new0(aim_conn_inside_t,1))) {
+	}
+
+	if (!(newconn->inside = g_new0(aim_conn_inside_t, 1))) {
 		g_free(newconn);
 		return NULL;
@@ -274,6 +281,7 @@
 	aim_conn_t *cur, **prev;
 
-	if (!deadconn || !*deadconn)	
+	if (!deadconn || !*deadconn) {
 		return;
+	}
 
 	for (prev = &sess->connlist; (cur = *prev); ) {
@@ -285,7 +293,8 @@
 	}
 
-	if (!cur)
+	if (!cur) {
 		return; /* oops */
 
+	}
 	connkill_real(sess, &cur);
 
@@ -299,5 +308,5 @@
  * Close (but not free) a connection.
  *
- * This leaves everything untouched except for clearing the 
+ * This leaves everything untouched except for clearing the
  * handler list and setting the fd to -1 (used to recognize
  * dead connections).  It will also remove cookies if necessary.
@@ -307,9 +316,11 @@
 {
 
-	if (deadconn->fd >= 3)
+	if (deadconn->fd >= 3) {
 		closesocket(deadconn->fd);
+	}
 	deadconn->fd = -1;
-	if (deadconn->handlerlist)
+	if (deadconn->handlerlist) {
 		aim_clearhandlers(deadconn);
+	}
 
 	return;
@@ -321,5 +332,5 @@
  * @type: Type of connection to look for
  *
- * Searches for a connection of the specified type in the 
+ * Searches for a connection of the specified type in the
  * specified session.  Returns the first connection of that
  * type found.
@@ -333,7 +344,8 @@
 
 	for (cur = sess->connlist; cur; cur = cur->next) {
-		if ((cur->type == type) && 
-				!(cur->status & AIM_CONN_STATUS_INPROGRESS))
+		if ((cur->type == type) &&
+		    !(cur->status & AIM_CONN_STATUS_INPROGRESS)) {
 			break;
+		}
 	}
 
@@ -346,6 +358,7 @@
 
 	for (cur = sess->connlist; cur; cur = cur->next) {
-		if (cur->type == type)
+		if (cur->type == type) {
 			break;
+		}
 	}
 
@@ -361,5 +374,5 @@
  * Opens a new connection to the specified dest host of specified
  * type, using the proxy settings if available.  If @host is %NULL,
- * the connection is allocated and returned, but no connection 
+ * the connection is allocated and returned, but no connection
  * is made.
  *
@@ -374,8 +387,9 @@
 	int i;
 
-	if (!(connstruct = aim_conn_getnext(sess)))
+	if (!(connstruct = aim_conn_getnext(sess))) {
 		return NULL;
-
-	connstruct->sessv = (void *)sess;
+	}
+
+	connstruct->sessv = (void *) sess;
 	connstruct->type = type;
 
@@ -386,21 +400,21 @@
 	}
 
-	/* 
-	 * As of 23 Jul 1999, AOL now sends the port number, preceded by a 
-	 * colon, in the BOS redirect.  This fatally breaks all previous 
+	/*
+	 * As of 23 Jul 1999, AOL now sends the port number, preceded by a
+	 * colon, in the BOS redirect.  This fatally breaks all previous
 	 * libfaims.  Bad, bad AOL.
 	 *
-	 * We put this here to catch every case. 
+	 * We put this here to catch every case.
 	 *
 	 */
 
-	for(i = 0; i < (int)strlen(dest); i++) {
+	for (i = 0; i < (int) strlen(dest); i++) {
 		if (dest[i] == ':') {
-			port = atoi(&(dest[i+1]));
+			port = atoi(&(dest[i + 1]));
 			break;
 		}
 	}
 
-	host = (char *)g_malloc(i+1);
+	host = (char *) g_malloc(i + 1);
 	strncpy(host, dest, i);
 	host[i] = '\0';
@@ -421,5 +435,5 @@
  *
  * This is my lame attempt at overcoming not understanding the rate
- * limiting. 
+ * limiting.
  *
  * XXX: This should really be replaced with something that scales and
@@ -430,6 +444,7 @@
 {
 
-	if (!conn)
+	if (!conn) {
 		return -1;
+	}
 
 	conn->forcedlatency = newval;
@@ -451,6 +466,7 @@
 {
 
-	if (!sess)
+	if (!sess) {
 		return;
+	}
 
 	memset(sess, 0, sizeof(aim_session_t));
@@ -471,5 +487,5 @@
 	sess->ssi.revision = 0;
 	sess->ssi.items = NULL;
-	sess->ssi.timestamp = (time_t)0;
+	sess->ssi.timestamp = (time_t) 0;
 
 	sess->locate.userinfo = NULL;
@@ -487,11 +503,12 @@
 	 * Default to SNAC login unless XORLOGIN is explicitly set.
 	 */
-	if (!(flags & AIM_SESS_FLAGS_XORLOGIN))
+	if (!(flags & AIM_SESS_FLAGS_XORLOGIN)) {
 		sess->flags |= AIM_SESS_FLAGS_SNACLOGIN;
+	}
 	sess->flags |= flags;
 
 	/*
 	 * This must always be set.  Default to the queue-based
-	 * version for back-compatibility.  
+	 * version for back-compatibility.
 	 */
 	aim_tx_setenqueue(sess, AIM_TX_QUEUED, NULL);
@@ -548,9 +565,11 @@
 	aim_rxcallback_t userfunc;
 
-	if (!conn || (conn->fd == -1))
+	if (!conn || (conn->fd == -1)) {
 		return -1;
-
-	if (!(conn->status & AIM_CONN_STATUS_INPROGRESS))
+	}
+
+	if (!(conn->status & AIM_CONN_STATUS_INPROGRESS)) {
 		return -1;
+	}
 
 	FD_ZERO(&fds);
@@ -561,5 +580,5 @@
 	tv.tv_usec = 0;
 
-	if ((res = select(conn->fd+1, &fds, &wfds, NULL, &tv)) == -1) {
+	if ((res = select(conn->fd + 1, &fds, &wfds, NULL, &tv)) == -1) {
 		error = errno;
 		aim_conn_close(conn);
@@ -568,11 +587,12 @@
 	} else if (res == 0) {
 		return 0; /* hasn't really completed yet... */
-	} 
+	}
 
 	if (FD_ISSET(conn->fd, &fds) || FD_ISSET(conn->fd, &wfds)) {
 		socklen_t len = sizeof(error);
 
-		if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
+		if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
 			error = errno;
+		}
 	}
 
@@ -587,6 +607,7 @@
 	conn->status &= ~AIM_CONN_STATUS_INPROGRESS;
 
-	if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE)))
+	if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE))) {
 		userfunc(sess, NULL, conn);
+	}
 
 	/* Flush out the queues if there was something waiting for this conn  */
@@ -599,8 +620,9 @@
 {
 
-	if (!conn)
+	if (!conn) {
 		return NULL;
-
-	return (aim_session_t *)conn->sessv;
+	}
+
+	return (aim_session_t *) conn->sessv;
 }
 
@@ -624,5 +646,5 @@
  *
  * No-op.  WinAIM 4.x sends these _every minute_ to keep
- * the connection alive.  
+ * the connection alive.
  */
 int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn)
@@ -630,6 +652,7 @@
 	aim_frame_t *fr;
 
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x05, 0)))
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x05, 0))) {
 		return -ENOMEM;
+	}
 
 	aim_tx_enqueue(sess, fr);
