aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/oscar/chatnav.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/chatnav.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/chatnav.c')
-rw-r--r--protocols/oscar/chatnav.c219
1 files changed, 128 insertions, 91 deletions
diff --git a/protocols/oscar/chatnav.c b/protocols/oscar/chatnav.c
index 1aefd6e7..56d7ef73 100644
--- a/protocols/oscar/chatnav.c
+++ b/protocols/oscar/chatnav.c
@@ -2,7 +2,7 @@
* Handle ChatNav.
*
* [The ChatNav(igation) service does various things to keep chat
- * alive. It provides room information, room searching and creating,
+ * alive. It provides room information, room searching and creating,
* as well as giving users the right ("permission") to use chat.]
*
*/
@@ -20,15 +20,16 @@ int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn)
int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, guint16 exchange)
{
- static const char ck[] = {"create"};
- static const char lang[] = {"en"};
- static const char charset[] = {"us-ascii"};
+ static const char ck[] = { "create" };
+ static const char lang[] = { "en" };
+ static const char charset[] = { "us-ascii" };
aim_frame_t *fr;
aim_snacid_t snacid;
aim_tlvlist_t *tl = NULL;
- 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, 0x000d, 0x0008, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x000d, 0x0008, 0x0000, snacid);
@@ -39,7 +40,7 @@ int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *na
/*
* This looks to be a big hack. You'll note that this entire
* SNAC is just a room info structure, but the hard room name,
- * here, is set to "create".
+ * here, is set to "create".
*
* Either this goes on the "list of questions concerning
* why-the-hell-did-you-do-that", or this value is completly
@@ -48,11 +49,11 @@ int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *na
* the value of the room name in create requests is ignored.
*/
aimbs_put8(&fr->data, strlen(ck));
- aimbs_putraw(&fr->data, (guint8 *)ck, strlen(ck));
+ aimbs_putraw(&fr->data, (guint8 *) ck, strlen(ck));
- /*
+ /*
* instance
- *
+ *
* Setting this to 0xffff apparently assigns the last instance.
*
*/
@@ -61,9 +62,9 @@ int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *na
/* detail level */
aimbs_put8(&fr->data, 0x01);
- aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), (guint8 *)name);
- aim_addtlvtochain_raw(&tl, 0x00d6, strlen(charset), (guint8 *)charset);
- aim_addtlvtochain_raw(&tl, 0x00d7, strlen(lang), (guint8 *)lang);
+ aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), (guint8 *) name);
+ aim_addtlvtochain_raw(&tl, 0x00d6, strlen(charset), (guint8 *) charset);
+ aim_addtlvtochain_raw(&tl, 0x00d7, strlen(lang), (guint8 *) lang);
/* tlvcount */
aimbs_put16(&fr->data, aim_counttlvchain(&tl));
@@ -76,7 +77,8 @@ int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *na
return 0;
}
-static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs, aim_snac_t *snac2)
+static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs, aim_snac_t *snac2)
{
aim_rxcallback_t userfunc;
int ret = 0;
@@ -88,20 +90,21 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
tlvlist = aim_readtlvchain(bs);
- /*
+ /*
* Type 0x0002: Maximum concurrent rooms.
- */
- if (aim_gettlv(tlvlist, 0x0002, 1))
+ */
+ if (aim_gettlv(tlvlist, 0x0002, 1)) {
maxrooms = aim_gettlv8(tlvlist, 0x0002, 1);
+ }
- /*
+ /*
* Type 0x0003: Exchange information
*
* There can be any number of these, each one
- * representing another exchange.
- *
+ * representing another exchange.
+ *
*/
- for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1))); ) {
+ for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange + 1))); ) {
aim_bstream_t tbs;
aim_bstream_init(&tbs, exchangetlv->value, exchangetlv->length);
@@ -111,35 +114,39 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
exchanges = g_realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo));
/* exchange number */
- exchanges[curexchange-1].number = aimbs_get16(&tbs);
+ exchanges[curexchange - 1].number = aimbs_get16(&tbs);
innerlist = aim_readtlvchain(&tbs);
- /*
+ /*
* Type 0x000a: Unknown.
*
* Usually three bytes: 0x0114 (exchange 1) or 0x010f (others).
*
*/
- if (aim_gettlv(innerlist, 0x000a, 1))
+ if (aim_gettlv(innerlist, 0x000a, 1)) {
;
+ }
- /*
+ /*
* Type 0x000d: Unknown.
*/
- if (aim_gettlv(innerlist, 0x000d, 1))
+ if (aim_gettlv(innerlist, 0x000d, 1)) {
;
+ }
- /*
+ /*
* Type 0x0004: Unknown
*/
- if (aim_gettlv(innerlist, 0x0004, 1))
+ if (aim_gettlv(innerlist, 0x0004, 1)) {
;
+ }
- /*
+ /*
* Type 0x0002: Unknown
*/
- if (aim_gettlv(innerlist, 0x0002, 1))
+ if (aim_gettlv(innerlist, 0x0002, 1)) {
;
+ }
/*
* Type 0x00c9: Flags
@@ -149,47 +156,54 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
* 4 Instancing Allowed
* 8 Occupant Peek Allowed
*
- */
- if (aim_gettlv(innerlist, 0x00c9, 1))
- exchanges[curexchange-1].flags = aim_gettlv16(innerlist, 0x00c9, 1);
-
+ */
+ if (aim_gettlv(innerlist, 0x00c9, 1)) {
+ exchanges[curexchange - 1].flags = aim_gettlv16(innerlist, 0x00c9, 1);
+ }
+
/*
- * Type 0x00ca: Creation Date
+ * Type 0x00ca: Creation Date
*/
- if (aim_gettlv(innerlist, 0x00ca, 1))
+ if (aim_gettlv(innerlist, 0x00ca, 1)) {
;
-
+ }
+
/*
* Type 0x00d0: Mandatory Channels?
*/
- if (aim_gettlv(innerlist, 0x00d0, 1))
+ if (aim_gettlv(innerlist, 0x00d0, 1)) {
;
+ }
/*
* Type 0x00d1: Maximum Message length
*/
- if (aim_gettlv(innerlist, 0x00d1, 1))
+ if (aim_gettlv(innerlist, 0x00d1, 1)) {
;
+ }
/*
* Type 0x00d2: Maximum Occupancy?
*/
- if (aim_gettlv(innerlist, 0x00d2, 1))
+ if (aim_gettlv(innerlist, 0x00d2, 1)) {
;
+ }
/*
* Type 0x00d3: Exchange Description
*/
- if (aim_gettlv(innerlist, 0x00d3, 1))
- exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1);
- else
- exchanges[curexchange-1].name = NULL;
+ if (aim_gettlv(innerlist, 0x00d3, 1)) {
+ exchanges[curexchange - 1].name = aim_gettlv_str(innerlist, 0x00d3, 1);
+ } else {
+ exchanges[curexchange - 1].name = NULL;
+ }
/*
* Type 0x00d4: Exchange Description URL
*/
- if (aim_gettlv(innerlist, 0x00d4, 1))
+ if (aim_gettlv(innerlist, 0x00d4, 1)) {
;
+ }
/*
* Type 0x00d5: Creation Permissions
@@ -197,7 +211,7 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
* 0 Creation not allowed
* 1 Room creation allowed
* 2 Exchange creation allowed
- *
+ *
*/
if (aim_gettlv(innerlist, 0x00d5, 1)) {
aim_gettlv8(innerlist, 0x00d5, 1); /* createperms */
@@ -205,41 +219,46 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
/*
* Type 0x00d6: Character Set (First Time)
- */
- if (aim_gettlv(innerlist, 0x00d6, 1))
- exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1);
- else
- exchanges[curexchange-1].charset1 = NULL;
-
+ */
+ if (aim_gettlv(innerlist, 0x00d6, 1)) {
+ exchanges[curexchange - 1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1);
+ } else {
+ exchanges[curexchange - 1].charset1 = NULL;
+ }
+
/*
* Type 0x00d7: Language (First Time)
- */
- if (aim_gettlv(innerlist, 0x00d7, 1))
- exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1);
- else
- exchanges[curexchange-1].lang1 = NULL;
+ */
+ if (aim_gettlv(innerlist, 0x00d7, 1)) {
+ exchanges[curexchange - 1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1);
+ } else {
+ exchanges[curexchange - 1].lang1 = NULL;
+ }
/*
* Type 0x00d8: Character Set (Second Time)
- */
- if (aim_gettlv(innerlist, 0x00d8, 1))
- exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1);
- else
- exchanges[curexchange-1].charset2 = NULL;
+ */
+ if (aim_gettlv(innerlist, 0x00d8, 1)) {
+ exchanges[curexchange - 1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1);
+ } else {
+ exchanges[curexchange - 1].charset2 = NULL;
+ }
/*
* Type 0x00d9: Language (Second Time)
- */
- if (aim_gettlv(innerlist, 0x00d9, 1))
- exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1);
- else
- exchanges[curexchange-1].lang2 = NULL;
-
+ */
+ if (aim_gettlv(innerlist, 0x00d9, 1)) {
+ exchanges[curexchange - 1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1);
+ } else {
+ exchanges[curexchange - 1].lang2 = NULL;
+ }
+
/*
* Type 0x00da: Unknown
*/
- if (aim_gettlv(innerlist, 0x00da, 1))
+ if (aim_gettlv(innerlist, 0x00da, 1)) {
;
+ }
aim_freetlvchain(&innerlist);
}
@@ -247,8 +266,9 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
/*
* Call client.
*/
- 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, snac2->type, maxrooms, curexchange, exchanges);
+ }
for (curexchange--; curexchange >= 0; curexchange--) {
g_free(exchanges[curexchange].name);
@@ -263,7 +283,8 @@ static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *
return ret;
}
-static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs, aim_snac_t *snac2)
+static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs, aim_snac_t *snac2)
{
aim_rxcallback_t userfunc;
aim_tlvlist_t *tlvlist, *innerlist;
@@ -280,7 +301,7 @@ static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t
if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) {
imcb_error(sess->aux_data, "no bigblock in top tlv in create room response");
-
+
aim_freetlvchain(&tlvlist);
return 0;
}
@@ -304,29 +325,37 @@ static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t
innerlist = aim_readtlvchain(&bbbs);
- if (aim_gettlv(innerlist, 0x006a, 1))
+ if (aim_gettlv(innerlist, 0x006a, 1)) {
fqcn = aim_gettlv_str(innerlist, 0x006a, 1);
+ }
- if (aim_gettlv(innerlist, 0x00c9, 1))
+ if (aim_gettlv(innerlist, 0x00c9, 1)) {
flags = aim_gettlv16(innerlist, 0x00c9, 1);
+ }
- if (aim_gettlv(innerlist, 0x00ca, 1))
+ if (aim_gettlv(innerlist, 0x00ca, 1)) {
createtime = aim_gettlv32(innerlist, 0x00ca, 1);
+ }
- if (aim_gettlv(innerlist, 0x00d1, 1))
+ if (aim_gettlv(innerlist, 0x00d1, 1)) {
maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1);
+ }
- if (aim_gettlv(innerlist, 0x00d2, 1))
+ if (aim_gettlv(innerlist, 0x00d2, 1)) {
maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1);
+ }
- if (aim_gettlv(innerlist, 0x00d3, 1))
+ if (aim_gettlv(innerlist, 0x00d3, 1)) {
name = aim_gettlv_str(innerlist, 0x00d3, 1);
+ }
- if (aim_gettlv(innerlist, 0x00d5, 1))
+ if (aim_gettlv(innerlist, 0x00d5, 1)) {
createperms = aim_gettlv8(innerlist, 0x00d5, 1);
+ }
if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
- ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck);
+ ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen,
+ maxoccupancy, createperms, unknown, name, ck);
}
g_free(ck);
@@ -339,7 +368,7 @@ static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t
}
/*
- * Since multiple things can trigger this callback, we must lookup the
+ * Since multiple things can trigger this callback, we must lookup the
* snacid to determine the original snac subtype that was called.
*
* XXX This isn't really how this works. But this is: Every d/9 response
@@ -349,7 +378,7 @@ static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t
* Instance Info = 4
* Nav Short Desc = 8
* Nav Instance Info = 16
- * And then everything is really asynchronous. There is no specific
+ * And then everything is really asynchronous. There is no specific
* attachment of a response to a create room request, for example. Creating
* the room yields no different a response than requesting the room's info.
*
@@ -372,20 +401,27 @@ static int parseinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, ai
/*
* We now know what the original SNAC subtype was.
*/
- if (snac2->type == 0x0002) /* request chat rights */
+ if (snac2->type == 0x0002) { /* request chat rights */
ret = parseinfo_perms(sess, mod, rx, snac, bs, snac2);
- else if (snac2->type == 0x0003) {} /* request exchange info */
- else if (snac2->type == 0x0004) {} /* request room info */
- else if (snac2->type == 0x0005) {} /* request more room info */
- else if (snac2->type == 0x0006) {} /* request occupant list */
- else if (snac2->type == 0x0007) {} /* search for a room */
- else if (snac2->type == 0x0008) /* create room */
+ } else if (snac2->type == 0x0003) {
+ } /* request exchange info */
+ else if (snac2->type == 0x0004) {
+ } /* request room info */
+ else if (snac2->type == 0x0005) {
+ } /* request more room info */
+ else if (snac2->type == 0x0006) {
+ } /* request occupant list */
+ else if (snac2->type == 0x0007) {
+ } /* search for a room */
+ else if (snac2->type == 0x0008) { /* create room */
ret = parseinfo_create(sess, mod, rx, snac, bs, snac2);
- else
+ } else {
imcb_error(sess->aux_data, "unknown request subtype");
+ }
- if (snac2)
+ if (snac2) {
g_free(snac2->data);
+ }
g_free(snac2);
return ret;
@@ -394,8 +430,9 @@ static int parseinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, ai
static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
{
- if (snac->subtype == 0x0009)
+ if (snac->subtype == 0x0009) {
return parseinfo(sess, mod, rx, snac, bs);
+ }
return 0;
}