Index: protocols/oscar/service.c
===================================================================
--- protocols/oscar/service.c	(revision 6042a54e827b36770e8989d9a8ba49a66ec6f846)
+++ protocols/oscar/service.c	(revision 90adf8463b03a5b7116b36f2a4293807a9e2768c)
@@ -11,14 +11,16 @@
 int aim_clientready(aim_session_t *sess, aim_conn_t *conn)
 {
-	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;
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
 
-	if (!ins)
+	if (!ins) {
 		return -EINVAL;
-
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
+	}
+
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) {
 		return -ENOMEM;
+	}
 
 	snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
@@ -27,5 +29,5 @@
 	/*
 	 * Send only the tool versions that the server cares about (that it
-	 * marked as supporting in the server ready SNAC).  
+	 * marked as supporting in the server ready SNAC).
 	 */
 	for (sg = ins->groups; sg; sg = sg->next) {
@@ -37,5 +39,5 @@
 			aimbs_put16(&fr->data, mod->toolid);
 			aimbs_put16(&fr->data, mod->toolversion);
-		} 
+		}
 	}
 
@@ -47,5 +49,5 @@
 /*
  * Host Online (group 1, type 3)
- * 
+ *
  * See comments in conn.c about how the group associations are supposed
  * to work, and how they really work.
@@ -55,7 +57,7 @@
  * We don't actually call the client here.  This starts off the connection
  * initialization routine required by all AIM connections.  The next time
- * the client is called is the CONNINITDONE callback, which should be 
+ * the client is called is the CONNINITDONE callback, which should be
  * shortly after the rate information is acknowledged.
- * 
+ *
  */
 static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
@@ -65,6 +67,7 @@
 
 
-	if (!(families = g_malloc(aim_bstream_empty(bs))))
+	if (!(families = g_malloc(aim_bstream_empty(bs)))) {
 		return 0;
+	}
 
 	for (famcount = 0; aim_bstream_empty(bs); famcount++) {
@@ -86,5 +89,5 @@
 	aim_setversions(sess, rx->conn);
 
-	return 1; 
+	return 1;
 }
 
@@ -109,6 +112,6 @@
 
 	if (!aim_gettlv(tlvlist, 0x000d, 1) ||
-			!aim_gettlv(tlvlist, 0x0005, 1) ||
-			!aim_gettlv(tlvlist, 0x0006, 1)) {
+	    !aim_gettlv(tlvlist, 0x0005, 1) ||
+	    !aim_gettlv(tlvlist, 0x0006, 1)) {
 		aim_freetlvchain(&tlvlist);
 		return 0;
@@ -117,5 +120,5 @@
 	redir.group = aim_gettlv16(tlvlist, 0x000d, 1);
 	redir.ip = aim_gettlv_str(tlvlist, 0x0005, 1);
-	redir.cookie = (guint8 *)aim_gettlv_str(tlvlist, 0x0006, 1);
+	redir.cookie = (guint8 *) aim_gettlv_str(tlvlist, 0x0006, 1);
 
 	/* Fetch original SNAC so we can get csi if needed */
@@ -123,5 +126,5 @@
 
 	if ((redir.group == AIM_CONN_TYPE_CHAT) && origsnac) {
-		struct chatsnacinfo *csi = (struct chatsnacinfo *)origsnac->data;
+		struct chatsnacinfo *csi = (struct chatsnacinfo *) origsnac->data;
 
 		redir.chat.exchange = csi->exchange;
@@ -130,12 +133,14 @@
 	}
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		ret = userfunc(sess, rx, &redir);
-
-	g_free((void *)redir.ip);
-	g_free((void *)redir.cookie);
-
-	if (origsnac)
+	}
+
+	g_free((void *) redir.ip);
+	g_free((void *) redir.cookie);
+
+	if (origsnac) {
 		g_free(origsnac->data);
+	}
 	g_free(origsnac);
 
@@ -157,5 +162,5 @@
  * it.  The rate classes, their limiting properties, and the definitions
  * of which SNACs are belong to which class, are defined in the
- * Rate Response packet at login to each host.  
+ * Rate Response packet at login to each host.
  *
  * Logically, all rate offenses within one class count against further
@@ -171,8 +176,8 @@
  *
  *  Rate class 0x0001:
- *  	- Everything thats not in any of the other classes
+ *      - Everything thats not in any of the other classes
  *
  *  Rate class 0x0002:
- * 	- Buddy list add/remove
+ *      - Buddy list add/remove
  *	- Permit list add/remove
  *	- Deny list add/remove
@@ -190,5 +195,5 @@
  *
  * The only other thing of note is that class 5 (chat) has slightly looser
- * limiting properties than class 3 (normal messages).  But thats just a 
+ * limiting properties than class 3 (normal messages).  But thats just a
  * small bit of trivia for you.
  *
@@ -196,5 +201,5 @@
  * system is how the actual numbers relate to the passing of time.  This
  * seems to be a big mystery.
- * 
+ *
  */
 
@@ -203,17 +208,20 @@
 	struct rateclass *rc, *rc2;
 
-	if (!(rc = g_malloc(sizeof(struct rateclass))))
+	if (!(rc = g_malloc(sizeof(struct rateclass)))) {
 		return;
+	}
 
 	memcpy(rc, inrc, sizeof(struct rateclass));
 	rc->next = NULL;
 
-	for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next)
+	for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next) {
 		;
-
-	if (!rc2)
+	}
+
+	if (!rc2) {
 		*head = rc;
-	else
+	} else {
 		rc2->next = rc;
+	}
 
 	return;
@@ -225,6 +233,7 @@
 
 	for (rc = *head; rc; rc = rc->next) {
-		if (rc->classid == id)
+		if (rc->classid == id) {
 			return rc;
+		}
 	}
 
@@ -236,6 +245,7 @@
 	struct snacpair *sp, *sp2;
 
-	if (!(sp = g_new0(struct snacpair, 1)))
+	if (!(sp = g_new0(struct snacpair, 1))) {
 		return;
+	}
 
 	sp->group = group;
@@ -243,11 +253,13 @@
 	sp->next = NULL;
 
-	for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next)
+	for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next) {
 		;
-
-	if (!sp2)
+	}
+
+	if (!sp2) {
 		rc->members = sp;
-	else
+	} else {
 		sp2->next = sp;
+	}
 
 	return;
@@ -257,5 +269,5 @@
 static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
 {
-	aim_conn_inside_t *ins = (aim_conn_inside_t *)rx->conn->inside;
+	aim_conn_inside_t *ins = (aim_conn_inside_t *) rx->conn->inside;
 	guint16 numclasses, i;
 	aim_rxcallback_t userfunc;
@@ -284,9 +296,10 @@
 		 * depending on the version we advertised in 1/17.  If we
 		 * didn't send 1/17 (evil!), then this will crash and you
-		 * die, as it will default to the old version but we have 
-		 * the new version hardcoded here. 
+		 * die, as it will default to the old version but we have
+		 * the new version hardcoded here.
 		 */
-		if (mod->version >= 3)
+		if (mod->version >= 3) {
 			aimbs_getrawbuf(bs, rc.unknown, sizeof(rc.unknown));
+		}
 
 		rc_addclass(&ins->rates, &rc);
@@ -312,6 +325,7 @@
 			subtype = aimbs_get16(bs);
 
-			if (rc)
+			if (rc) {
 				rc_addpair(rc, group, subtype);
+			}
 		}
 	}
@@ -332,6 +346,7 @@
 	 * Finally, tell the client it's ready to go...
 	 */
-	if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE))) {
 		userfunc(sess, rx);
+	}
 
 
@@ -342,17 +357,19 @@
 int aim_rates_addparam(aim_session_t *sess, aim_conn_t *conn)
 {
-	aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
-	aim_frame_t *fr;	
+	aim_conn_inside_t *ins = (aim_conn_inside_t *) conn->inside;
+	aim_frame_t *fr;
 	aim_snacid_t snacid;
 	struct rateclass *rc;
 
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512)))
-		return -ENOMEM; 
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) {
+		return -ENOMEM;
+	}
 
 	snacid = aim_cachesnac(sess, 0x0001, 0x0008, 0x0000, NULL, 0);
 	aim_putsnac(&fr->data, 0x0001, 0x0008, 0x0000, snacid);
 
-	for (rc = ins->rates; rc; rc = rc->next)
+	for (rc = ins->rates; rc; rc = rc->next) {
 		aimbs_put16(&fr->data, rc->classid);
+	}
 
 	aim_tx_enqueue(sess, fr);
@@ -370,5 +387,5 @@
 	code = aimbs_get16(bs);
 	rateclass = aimbs_get16(bs);
-	
+
 	windowsize = aimbs_get32(bs);
 	clear = aimbs_get32(bs);
@@ -379,6 +396,8 @@
 	maxavg = aimbs_get32(bs);
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
-		return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg);
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
+		return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg,
+		                maxavg);
+	}
 
 	return 0;
@@ -386,10 +405,10 @@
 
 /*
- * How Migrations work.  
- *
- * The server sends a Server Pause message, which the client should respond to 
- * with a Server Pause Ack, which contains the families it needs on this 
- * connection. The server will send a Migration Notice with an IP address, and 
- * then disconnect. Next the client should open the connection and send the 
+ * How Migrations work.
+ *
+ * The server sends a Server Pause message, which the client should respond to
+ * with a Server Pause Ack, which contains the families it needs on this
+ * connection. The server will send a Migration Notice with an IP address, and
+ * then disconnect. Next the client should open the connection and send the
  * cookie.  Repeat the normal login process and pretend this never happened.
  *
@@ -403,6 +422,7 @@
 	aim_rxcallback_t userfunc;
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		return userfunc(sess, rx);
+	}
 
 	return 0;
@@ -414,6 +434,7 @@
 	aim_rxcallback_t userfunc;
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		return userfunc(sess, rx);
+	}
 
 	return 0;
@@ -434,6 +455,7 @@
 	aim_extractuserinfo(sess, bs, &userinfo);
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		return userfunc(sess, rx, &userinfo);
+	}
 
 	return 0;
@@ -448,12 +470,14 @@
 
 	memset(&userinfo, 0, sizeof(aim_userinfo_t));
-	
+
 	newevil = aimbs_get16(bs);
 
-	if (aim_bstream_empty(bs))
+	if (aim_bstream_empty(bs)) {
 		aim_extractuserinfo(sess, bs, &userinfo);
-
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	}
+
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		return userfunc(sess, rx, newevil, &userinfo);
+	}
 
 	return 0;
@@ -464,5 +488,5 @@
  *
  * This is the final SNAC sent on the original connection during a migration.
- * It contains the IP and cookie used to connect to the new server, and 
+ * It contains the IP and cookie used to connect to the new server, and
  * optionally a list of the SNAC groups being migrated.
  *
@@ -482,5 +506,5 @@
 	 * moves to the new server.  When not all the groups for a connection
 	 * are migrated, or they are all migrated but some groups are moved
-	 * to a different server than others, it is called a bifurcated 
+	 * to a different server than others, it is called a bifurcated
 	 * migration.
 	 *
@@ -497,11 +521,13 @@
 	tl = aim_readtlvchain(bs);
 
-	if (aim_gettlv(tl, 0x0005, 1))
+	if (aim_gettlv(tl, 0x0005, 1)) {
 		ip = aim_gettlv_str(tl, 0x0005, 1);
+	}
 
 	cktlv = aim_gettlv(tl, 0x0006, 1);
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		ret = userfunc(sess, rx, ip, cktlv ? cktlv->value : NULL);
+	}
 
 	aim_freetlvchain(&tl);
@@ -528,11 +554,11 @@
 	 *   3 System bulletin
 	 *   4 Nothing's wrong ("top o the world" -- normal)
-	 *   5 Lets-break-something. 
+	 *   5 Lets-break-something.
 	 *
 	 */
 	id = aimbs_get16(bs);
 
-	/* 
-	 * TLVs follow 
+	/*
+	 * TLVs follow
 	 */
 	tlvlist = aim_readtlvchain(bs);
@@ -540,6 +566,7 @@
 	msg = aim_gettlv_str(tlvlist, 0x000b, 1);
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		ret = userfunc(sess, rx, id, msg);
+	}
 
 	g_free(msg);
@@ -550,5 +577,5 @@
 }
 
-/* 
+/*
  * Set privacy flags (group 1, type 0x14)
  *
@@ -565,12 +592,12 @@
 
 
-/* 
- * Set client versions (group 1, subtype 0x17) 
- *
- * If you've seen the clientonline/clientready SNAC you're probably 
+/*
+ * Set client versions (group 1, subtype 0x17)
+ *
+ * If you've seen the clientonline/clientready SNAC you're probably
  * wondering what the point of this one is.  And that point seems to be
  * that the versions in the client online SNAC are sent too late for the
  * server to be able to use them to change the protocol for the earlier
- * login packets (client versions are sent right after Host Online is 
+ * login packets (client versions are sent right after Host Online is
  * received, but client online versions aren't sent until quite a bit later).
  * We can see them already making use of this by changing the format of
@@ -580,14 +607,16 @@
 int aim_setversions(aim_session_t *sess, aim_conn_t *conn)
 {
-	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;
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
 
-	if (!ins)
+	if (!ins) {
 		return -EINVAL;
-
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
+	}
+
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) {
 		return -ENOMEM;
+	}
 
 	snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
@@ -596,5 +625,5 @@
 	/*
 	 * Send only the versions that the server cares about (that it
-	 * marked as supporting in the server ready SNAC).  
+	 * marked as supporting in the server ready SNAC).
 	 */
 	for (sg = ins->groups; sg; sg = sg->next) {
@@ -630,10 +659,10 @@
 }
 
-/* 
+/*
  * Subtype 0x001e - Extended Status
  *
  * Sets your ICQ status (available, away, do not disturb, etc.)
  *
- * These are the same TLVs seen in user info.  You can 
+ * These are the same TLVs seen in user info.  You can
  * also set 0x0008 and 0x000c.
  */
@@ -647,19 +676,21 @@
 
 	data = AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */
-	
-	if (ic && set_getbool(&ic->acc->set, "web_aware"))
+
+	if (ic && set_getbool(&ic->acc->set, "web_aware")) {
 		data |= AIM_ICQ_STATE_WEBAWARE;
+	}
 
 	aim_addtlvtochain32(&tl, 0x0006, data); /* tlvlen */
 
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8)))
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8))) {
 		return -ENOMEM;
+	}
 
 	snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0);
 	aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid);
-	
+
 	aim_writetlvchain(&fr->data, &tl);
 	aim_freetlvchain(&tl);
-	
+
 	aim_tx_enqueue(sess, fr);
 
@@ -688,12 +719,12 @@
  * the data that the specific client should have, the client will get the
  * following message from "AOL Instant Messenger":
- *    "You have been disconnected from the AOL Instant Message Service (SM) 
+ *    "You have been disconnected from the AOL Instant Message Service (SM)
  *     for accessing the AOL network using unauthorized software.  You can
- *     download a FREE, fully featured, and authorized client, here 
+ *     download a FREE, fully featured, and authorized client, here
  *     http://www.aol.com/aim/download2.html"
  * The connection is then closed, recieving disconnect code 1, URL
- * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html.  
- *
- * Note, however, that numerous inconsistencies can cause the above error, 
+ * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html.
+ *
+ * Note, however, that numerous inconsistencies can cause the above error,
  * not just sending back a bad hash.  Do not immediatly suspect this code
  * if you get disconnected.  AOL and the open/free software community have
@@ -718,6 +749,7 @@
 	modname = aim_gettlv_str(list, 0x0001, 1);
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
 		return userfunc(sess, rx, offset, len, modname);
+	}
 
 	g_free(modname);
@@ -730,28 +762,29 @@
 {
 
-	if (snac->subtype == 0x0003)
+	if (snac->subtype == 0x0003) {
 		return hostonline(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x0005)
+	} else if (snac->subtype == 0x0005) {
 		return redirect(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x0007)
+	} else if (snac->subtype == 0x0007) {
 		return rateresp(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x000a)
+	} else if (snac->subtype == 0x000a) {
 		return ratechange(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x000b)
+	} else if (snac->subtype == 0x000b) {
 		return serverpause(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x000d)
+	} else if (snac->subtype == 0x000d) {
 		return serverresume(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x000f)
+	} else if (snac->subtype == 0x000f) {
 		return selfinfo(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x0010)
+	} else if (snac->subtype == 0x0010) {
 		return evilnotify(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x0012)
+	} else if (snac->subtype == 0x0012) {
 		return migrate(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x0013)
+	} else if (snac->subtype == 0x0013) {
 		return motd(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x0018)
+	} else if (snac->subtype == 0x0018) {
 		return hostversions(sess, mod, rx, snac, bs);
-	else if (snac->subtype == 0x001f)
+	} else if (snac->subtype == 0x001f) {
 		return memrequest(sess, mod, rx, snac, bs);
+	}
 
 	return 0;
