aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/oscar/rxhandlers.c
diff options
context:
space:
mode:
authorIndent <please@skip.me>2015-02-19 02:47:20 -0300
committerdequis <dx@dxzone.com.ar>2015-02-20 19:50:54 -0300
commit5ebff60479fc7a9f7f50ac03b124c91d4e6ebe11 (patch)
tree9fc0d50cb1f4bc9768d9f00de94eafd876bb55b0 /protocols/oscar/rxhandlers.c
parentaf359b4316f9d392c6b752495a1b2ed631576ed8 (diff)
Reindent everything to K&R style with tabs
Used uncrustify, with the configuration file in ./doc/uncrustify.cfg Commit author set to "Indent <please@skip.me>" so that it's easier to skip while doing git blame.
Diffstat (limited to 'protocols/oscar/rxhandlers.c')
-rw-r--r--protocols/oscar/rxhandlers.c143
1 files changed, 86 insertions, 57 deletions
diff --git a/protocols/oscar/rxhandlers.c b/protocols/oscar/rxhandlers.c
index bd071505..9ca2764a 100644
--- a/protocols/oscar/rxhandlers.c
+++ b/protocols/oscar/rxhandlers.c
@@ -21,9 +21,10 @@ aim_module_t *aim__findmodulebygroup(aim_session_t *sess, guint16 group)
{
aim_module_t *cur;
- for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) {
- if (cur->family == group)
+ for (cur = (aim_module_t *) sess->modlistv; cur; cur = cur->next) {
+ if (cur->family == group) {
return cur;
+ }
}
return NULL;
@@ -33,9 +34,10 @@ static aim_module_t *aim__findmodule(aim_session_t *sess, const char *name)
{
aim_module_t *cur;
- for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) {
- if (strcmp(name, cur->name) == 0)
+ for (cur = (aim_module_t *) sess->modlistv; cur; cur = cur->next) {
+ if (strcmp(name, cur->name) == 0) {
return cur;
+ }
}
return NULL;
@@ -45,11 +47,13 @@ int aim__registermodule(aim_session_t *sess, int (*modfirst)(aim_session_t *, ai
{
aim_module_t *mod;
- if (!sess || !modfirst)
+ if (!sess || !modfirst) {
return -1;
+ }
- if (!(mod = g_new0(aim_module_t,1)))
+ if (!(mod = g_new0(aim_module_t, 1))) {
return -1;
+ }
if (modfirst(sess, mod) == -1) {
g_free(mod);
@@ -57,13 +61,14 @@ int aim__registermodule(aim_session_t *sess, int (*modfirst)(aim_session_t *, ai
}
if (aim__findmodule(sess, mod->name)) {
- if (mod->shutdown)
+ if (mod->shutdown) {
mod->shutdown(sess, mod);
+ }
g_free(mod);
return -1;
}
- mod->next = (aim_module_t *)sess->modlistv;
+ mod->next = (aim_module_t *) sess->modlistv;
sess->modlistv = mod;
@@ -74,13 +79,14 @@ void aim__shutdownmodules(aim_session_t *sess)
{
aim_module_t *cur;
- for (cur = (aim_module_t *)sess->modlistv; cur; ) {
+ for (cur = (aim_module_t *) sess->modlistv; cur; ) {
aim_module_t *tmp;
tmp = cur->next;
- if (cur->shutdown)
+ if (cur->shutdown) {
cur->shutdown(sess, cur);
+ }
g_free(cur);
@@ -97,8 +103,9 @@ static int consumesnac(aim_session_t *sess, aim_frame_t *rx)
aim_module_t *cur;
aim_modsnac_t snac;
- if (aim_bstream_empty(&rx->data) < 10)
+ if (aim_bstream_empty(&rx->data) < 10) {
return 0;
+ }
snac.family = aimbs_get16(&rx->data);
snac.subtype = aimbs_get16(&rx->data);
@@ -106,20 +113,22 @@ static int consumesnac(aim_session_t *sess, aim_frame_t *rx)
snac.id = aimbs_get32(&rx->data);
/* Contains TLV(s) in the FNAC header */
- if(snac.flags & 0x8000) {
+ if (snac.flags & 0x8000) {
aim_bstream_advance(&rx->data, aimbs_get16(&rx->data));
- } else if(snac.flags & 0x0001) {
+ } else if (snac.flags & 0x0001) {
/* Following SNAC will be related */
}
- for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) {
+ for (cur = (aim_module_t *) sess->modlistv; cur; cur = cur->next) {
- if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) &&
- (cur->family != snac.family))
+ if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) &&
+ (cur->family != snac.family)) {
continue;
+ }
- if (cur->snachandler(sess, cur, rx, &snac, &rx->data))
+ if (cur->snachandler(sess, cur, rx, &snac, &rx->data)) {
return 1;
+ }
}
@@ -135,14 +144,16 @@ static int consumenonsnac(aim_session_t *sess, aim_frame_t *rx, guint16 family,
snac.subtype = subtype;
snac.flags = snac.id = 0;
- for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) {
+ for (cur = (aim_module_t *) sess->modlistv; cur; cur = cur->next) {
- if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) &&
- (cur->family != snac.family))
+ if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) &&
+ (cur->family != snac.family)) {
continue;
+ }
- if (cur->snachandler(sess, cur, rx, &snac, &rx->data))
+ if (cur->snachandler(sess, cur, rx, &snac, &rx->data)) {
return 1;
+ }
}
@@ -164,19 +175,23 @@ static int negchan_middle(aim_session_t *sess, aim_frame_t *fr)
/* Used only by the older login protocol */
/* XXX remove this special case? */
- if (fr->conn->type == AIM_CONN_TYPE_AUTH)
+ if (fr->conn->type == AIM_CONN_TYPE_AUTH) {
return consumenonsnac(sess, fr, 0x0017, 0x0003);
+ }
tlvlist = aim_readtlvchain(&fr->data);
- if (aim_gettlv(tlvlist, 0x0009, 1))
+ if (aim_gettlv(tlvlist, 0x0009, 1)) {
code = aim_gettlv16(tlvlist, 0x0009, 1);
+ }
- if (aim_gettlv(tlvlist, 0x000b, 1))
+ if (aim_gettlv(tlvlist, 0x000b, 1)) {
msg = aim_gettlv_str(tlvlist, 0x000b, 1);
+ }
- if ((userfunc = aim_callhandler(sess, fr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR)))
+ if ((userfunc = aim_callhandler(sess, fr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR))) {
ret = userfunc(sess, fr, code, msg);
+ }
aim_freetlvchain(&tlvlist);
@@ -194,39 +209,43 @@ static int checkdisallowed(guint16 group, guint16 type)
guint16 group;
guint16 type;
} dontuse[] = {
- {0x0001, 0x0002},
- {0x0001, 0x0003},
- {0x0001, 0x0006},
- {0x0001, 0x0007},
- {0x0001, 0x0008},
- {0x0001, 0x0017},
- {0x0001, 0x0018},
- {0x0000, 0x0000}
+ { 0x0001, 0x0002 },
+ { 0x0001, 0x0003 },
+ { 0x0001, 0x0006 },
+ { 0x0001, 0x0007 },
+ { 0x0001, 0x0008 },
+ { 0x0001, 0x0017 },
+ { 0x0001, 0x0018 },
+ { 0x0000, 0x0000 }
};
int i;
for (i = 0; dontuse[i].group != 0x0000; i++) {
- if ((dontuse[i].group == group) && (dontuse[i].type == type))
+ if ((dontuse[i].group == group) && (dontuse[i].type == type)) {
return 1;
+ }
}
return 0;
}
-int aim_conn_addhandler(aim_session_t *sess, aim_conn_t *conn, guint16 family, guint16 type, aim_rxcallback_t newhandler, guint16 flags)
+int aim_conn_addhandler(aim_session_t *sess, aim_conn_t *conn, guint16 family, guint16 type,
+ aim_rxcallback_t newhandler, guint16 flags)
{
struct aim_rxcblist_s *newcb;
- if (!conn)
+ if (!conn) {
return -1;
+ }
if (checkdisallowed(family, type)) {
g_assert(0);
return -1;
}
- if (!(newcb = (struct aim_rxcblist_s *)g_new0(struct aim_rxcblist_s, 1)))
+ if (!(newcb = (struct aim_rxcblist_s *) g_new0(struct aim_rxcblist_s, 1))) {
return -1;
+ }
newcb->family = family;
newcb->type = type;
@@ -234,13 +253,14 @@ int aim_conn_addhandler(aim_session_t *sess, aim_conn_t *conn, guint16 family, g
newcb->handler = newhandler;
newcb->next = NULL;
- if (!conn->handlerlist)
- conn->handlerlist = (void *)newcb;
- else {
+ if (!conn->handlerlist) {
+ conn->handlerlist = (void *) newcb;
+ } else {
struct aim_rxcblist_s *cur;
- for (cur = (struct aim_rxcblist_s *)conn->handlerlist; cur->next; cur = cur->next)
+ for (cur = (struct aim_rxcblist_s *) conn->handlerlist; cur->next; cur = cur->next) {
;
+ }
cur->next = newcb;
}
@@ -251,10 +271,11 @@ int aim_clearhandlers(aim_conn_t *conn)
{
struct aim_rxcblist_s *cur;
- if (!conn)
+ if (!conn) {
return -1;
+ }
- for (cur = (struct aim_rxcblist_s *)conn->handlerlist; cur; ) {
+ for (cur = (struct aim_rxcblist_s *) conn->handlerlist; cur; ) {
struct aim_rxcblist_s *tmp;
tmp = cur->next;
@@ -270,12 +291,14 @@ aim_rxcallback_t aim_callhandler(aim_session_t *sess, aim_conn_t *conn, guint16
{
struct aim_rxcblist_s *cur;
- if (!conn)
+ if (!conn) {
return NULL;
+ }
- for (cur = (struct aim_rxcblist_s *)conn->handlerlist; cur; cur = cur->next) {
- if ((cur->family == family) && (cur->type == type))
+ for (cur = (struct aim_rxcblist_s *) conn->handlerlist; cur; cur = cur->next) {
+ if ((cur->family == family) && (cur->type == type)) {
return cur->handler;
+ }
}
if (type == AIM_CB_SPECIAL_DEFAULT) {
@@ -285,12 +308,14 @@ aim_rxcallback_t aim_callhandler(aim_session_t *sess, aim_conn_t *conn, guint16
return aim_callhandler(sess, conn, family, AIM_CB_SPECIAL_DEFAULT);
}
-static int aim_callhandler_noparam(aim_session_t *sess, aim_conn_t *conn,guint16 family, guint16 type, aim_frame_t *ptr)
+static int aim_callhandler_noparam(aim_session_t *sess, aim_conn_t *conn, guint16 family, guint16 type,
+ aim_frame_t *ptr)
{
aim_rxcallback_t userfunc;
- if ((userfunc = aim_callhandler(sess, conn, family, type)))
+ if ((userfunc = aim_callhandler(sess, conn, family, type))) {
return userfunc(sess, ptr);
+ }
return 1; /* XXX */
}
@@ -321,35 +346,39 @@ void aim_rxdispatch(aim_session_t *sess)
* XXX: This is still fairly ugly.
*/
- if (cur->handled)
+ if (cur->handled) {
continue;
+ }
if (cur->hdr.flap.type == 0x01) {
-
- cur->handled = aim_callhandler_noparam(sess, cur->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, cur); /* XXX use consumenonsnac */
-
+
+ cur->handled = aim_callhandler_noparam(sess, cur->conn, AIM_CB_FAM_SPECIAL,
+ AIM_CB_SPECIAL_FLAPVER, cur); /* XXX use consumenonsnac */
+
continue;
-
+
} else if (cur->hdr.flap.type == 0x02) {
- if ((cur->handled = consumesnac(sess, cur)))
+ if ((cur->handled = consumesnac(sess, cur))) {
continue;
+ }
} else if (cur->hdr.flap.type == 0x04) {
cur->handled = negchan_middle(sess, cur);
continue;
- } else if (cur->hdr.flap.type == 0x05)
+ } else if (cur->hdr.flap.type == 0x05) {
;
-
+ }
+
if (!cur->handled) {
consumenonsnac(sess, cur, 0xffff, 0xffff); /* last chance! */
cur->handled = 1;
}
}
- /*
+ /*
* This doesn't have to be called here. It could easily be done
* by a seperate thread or something. It's an administrative operation,
* and can take a while. Though the less you call it the less memory