aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/oscar
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
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')
-rw-r--r--protocols/oscar/admin.c58
-rw-r--r--protocols/oscar/admin.h2
-rw-r--r--protocols/oscar/aim.h266
-rw-r--r--protocols/oscar/aim_internal.h16
-rw-r--r--protocols/oscar/auth.c175
-rw-r--r--protocols/oscar/bos.c20
-rw-r--r--protocols/oscar/bos.h2
-rw-r--r--protocols/oscar/buddylist.c25
-rw-r--r--protocols/oscar/buddylist.h2
-rw-r--r--protocols/oscar/chat.c250
-rw-r--r--protocols/oscar/chat.h2
-rw-r--r--protocols/oscar/chatnav.c219
-rw-r--r--protocols/oscar/chatnav.h2
-rw-r--r--protocols/oscar/conn.c131
-rw-r--r--protocols/oscar/icq.c356
-rw-r--r--protocols/oscar/icq.h94
-rw-r--r--protocols/oscar/im.c688
-rw-r--r--protocols/oscar/im.h33
-rw-r--r--protocols/oscar/info.c273
-rw-r--r--protocols/oscar/info.h6
-rw-r--r--protocols/oscar/misc.c66
-rw-r--r--protocols/oscar/msgcookie.c48
-rw-r--r--protocols/oscar/oscar.c1511
-rw-r--r--protocols/oscar/oscar_util.c33
-rw-r--r--protocols/oscar/rxhandlers.c143
-rw-r--r--protocols/oscar/rxqueue.c192
-rw-r--r--protocols/oscar/search.c30
-rw-r--r--protocols/oscar/service.c229
-rw-r--r--protocols/oscar/snac.c43
-rw-r--r--protocols/oscar/ssi.c556
-rw-r--r--protocols/oscar/ssi.h6
-rw-r--r--protocols/oscar/stats.c9
-rw-r--r--protocols/oscar/tlv.c120
-rw-r--r--protocols/oscar/txqueue.c103
34 files changed, 3219 insertions, 2490 deletions
diff --git a/protocols/oscar/admin.c b/protocols/oscar/admin.c
index 09082c5b..b317529b 100644
--- a/protocols/oscar/admin.c
+++ b/protocols/oscar/admin.c
@@ -27,17 +27,20 @@ static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
type = aimbs_get16(bs);
len = aimbs_get16(bs);
- if ((type == 0x0011) || (type == 0x0004))
+ if ((type == 0x0011) || (type == 0x0004)) {
str = 1;
+ }
- if (str)
- val = (guint8 *)aimbs_getstr(bs, len);
- else
+ if (str) {
+ val = (guint8 *) aimbs_getstr(bs, len);
+ } else {
val = aimbs_getraw(bs, len);
+ }
/* XXX fix so its only called once for the entire packet */
- if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
userfunc(sess, rx, (snac->subtype == 0x0005) ? 1 : 0, perms, type, len, val, str);
+ }
g_free(val);
@@ -48,15 +51,17 @@ static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
return 1;
}
-static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
+static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs)
{
aim_rxcallback_t userfunc;
guint16 status;
status = aimbs_get16(bs);
- 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, status);
+ }
return 0;
}
@@ -64,10 +69,11 @@ static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
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 == 0x0003) || (snac->subtype == 0x0005))
+ if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005)) {
return infochange(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0007)
+ } else if (snac->subtype == 0x0007) {
return accountconfirm(sess, mod, rx, snac, bs);
+ }
return 0;
}
@@ -78,7 +84,7 @@ int admin_modfirst(aim_session_t *sess, aim_module_t *mod)
mod->family = AIM_CB_FAM_ADM;
mod->version = 0x0001;
mod->toolid = AIM_TOOL_NEWWIN;
- mod->toolversion = 0x0629;
+ mod->toolversion = 0x0629;
mod->flags = 0;
strncpy(mod->name, "admin", sizeof(mod->name));
mod->snachandler = snachandler;
@@ -92,17 +98,18 @@ int aim_admin_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *ne
aim_tlvlist_t *tl = NULL;
aim_snacid_t snacid;
- if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw))))
+ if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + strlen(curpw) + 4 + strlen(newpw)))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
/* new password TLV t(0002) */
- aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), (guint8 *)newpw);
+ aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), (guint8 *) newpw);
/* current password TLV t(0012) */
- aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), (guint8 *)curpw);
+ aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), (guint8 *) curpw);
aim_writetlvchain(&tx->data, &tl);
aim_freetlvchain(&tl);
@@ -113,7 +120,7 @@ int aim_admin_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *ne
}
/*
- * Request account confirmation.
+ * Request account confirmation.
*
* This will cause an email to be sent to the address associated with
* the account. By following the instructions in the mail, you can
@@ -130,14 +137,15 @@ int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn)
*
* The only known valid tag is 0x0011 (email address).
*
- */
+ */
int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, guint16 info)
{
aim_frame_t *tx;
aim_snacid_t snacid;
- if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14)))
+ if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);
aim_putsnac(&tx->data, 0x0007, 0x0002, 0x0000, snacid);
@@ -156,17 +164,18 @@ int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newema
aim_snacid_t snacid;
aim_tlvlist_t *tl = NULL;
- if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail))))
+ if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 2 + 2 + strlen(newemail)))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
- aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), (guint8 *)newemail);
-
+ aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), (guint8 *) newemail);
+
aim_writetlvchain(&tx->data, &tl);
aim_freetlvchain(&tl);
-
+
aim_tx_enqueue(sess, tx);
return 0;
@@ -178,17 +187,18 @@ int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick
aim_snacid_t snacid;
aim_tlvlist_t *tl = NULL;
- if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newnick))))
+ if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 2 + 2 + strlen(newnick)))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
- aim_addtlvtochain_raw(&tl, 0x0001, strlen(newnick), (guint8 *)newnick);
-
+ aim_addtlvtochain_raw(&tl, 0x0001, strlen(newnick), (guint8 *) newnick);
+
aim_writetlvchain(&tx->data, &tl);
aim_freetlvchain(&tl);
-
+
aim_tx_enqueue(sess, tx);
diff --git a/protocols/oscar/admin.h b/protocols/oscar/admin.h
index f9d74cae..38a362bb 100644
--- a/protocols/oscar/admin.h
+++ b/protocols/oscar/admin.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Administrative Services.
- */
+ */
#define AIM_CB_ADM_ERROR 0x0001
#define AIM_CB_ADM_INFOCHANGE_REPLY 0x0005
#define AIM_CB_ADM_DEFAULT 0xffff
diff --git a/protocols/oscar/aim.h b/protocols/oscar/aim.h
index 3f26b392..265cd19b 100644
--- a/protocols/oscar/aim.h
+++ b/protocols/oscar/aim.h
@@ -1,4 +1,4 @@
-/*
+/*
* Main libfaim header. Must be included in client for prototypes/macros.
*
* "come on, i turned a chick lesbian; i think this is the hackish equivalent"
@@ -28,11 +28,11 @@ typedef guint16 flap_seqnum_t;
/* Portability stuff (DMP) */
#if defined(mach) && defined(__APPLE__)
-#define gethostbyname(x) gethostbyname2(x, AF_INET)
+#define gethostbyname(x) gethostbyname2(x, AF_INET)
#endif
-/*
- * Current Maximum Length for Screen Names (not including NULL)
+/*
+ * Current Maximum Length for Screen Names (not including NULL)
*
* Currently only names up to 16 characters can be registered
* however it is aparently legal for them to be larger.
@@ -52,7 +52,7 @@ typedef guint16 flap_seqnum_t;
* with utterly oversized instant messages!
*
* XXX: the real limit is the total SNAC size at 8192. Fix this.
- *
+ *
*/
#define MAXMSGLEN 7987
@@ -66,7 +66,7 @@ typedef guint16 flap_seqnum_t;
* Current Maximum Length for Chat Room Messages
*
* This is actually defined by the protocol to be
- * dynamic, but I have yet to see due cause to
+ * dynamic, but I have yet to see due cause to
* define it dynamically here. Maybe later.
*
*/
@@ -80,10 +80,10 @@ typedef guint16 flap_seqnum_t;
#define AIM_MD5_STRING "AOL Instant Messenger (SM)"
/*
- * Default Authorizer server name and TCP port for the OSCAR farm.
+ * Default Authorizer server name and TCP port for the OSCAR farm.
*
* You shouldn't need to change this unless you're writing
- * your own server.
+ * your own server.
*
* Note that only one server is needed to start the whole
* AIM process. The later server addresses come from
@@ -106,7 +106,7 @@ typedef guint16 flap_seqnum_t;
#define AIM_SNAC_HASH_SIZE 16
/*
- * Client info. Filled in by the client and passed in to
+ * Client info. Filled in by the client and passed in to
* aim_send_login(). The information ends up getting passed to OSCAR
* through the initial login command.
*
@@ -123,44 +123,44 @@ struct client_info_s {
};
#define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \
- "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
- 0x0004, \
- 0x0003, \
- 0x0005, \
- 0x0000, \
- 0x0686, \
- "us", \
- "en", \
+ "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
+ 0x0004, \
+ 0x0003, \
+ 0x0005, \
+ 0x0000, \
+ 0x0686, \
+ "us", \
+ "en", \
}
#define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \
- "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
- 0x0004, \
- 0x0004, \
- 0x0001, \
- 0x0000, \
- 0x07da, \
- "us", \
- "en", \
+ "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
+ 0x0004, \
+ 0x0004, \
+ 0x0001, \
+ 0x0000, \
+ 0x07da, \
+ "us", \
+ "en", \
}
#define AIM_CLIENTINFO_KNOWNGOOD_5_1_3036 { \
- "AOL Instant Messenger, version 5.1.3036/WIN32", \
- 0x0109, \
- 0x0005, \
- 0x0001, \
- 0x0000, \
- 0x0bdc, \
- "us", \
- "en", \
+ "AOL Instant Messenger, version 5.1.3036/WIN32", \
+ 0x0109, \
+ 0x0005, \
+ 0x0001, \
+ 0x0000, \
+ 0x0bdc, \
+ "us", \
+ "en", \
}
/*
* I would make 4.1.2010 the default, but they seem to have found
- * an alternate way of breaking that one.
+ * an alternate way of breaking that one.
*
* 3.5.1670 should work fine, however, you will be subjected to the
- * memory test, which may require you to have a WinAIM binary laying
+ * memory test, which may require you to have a WinAIM binary laying
* around. (see login.c::memrequest())
*/
#define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_5_1_3036
@@ -170,8 +170,8 @@ struct client_info_s {
#define FALSE 0
#endif
-/*
- * These could be arbitrary, but its easier to use the actual AIM values
+/*
+ * These could be arbitrary, but its easier to use the actual AIM values
*/
#define AIM_CONN_TYPE_AUTH 0x0007
#define AIM_CONN_TYPE_ADS 0x0005
@@ -206,11 +206,11 @@ struct client_info_s {
#define AIM_MTYPE_EEXPRESS 0x0E
#define AIM_MTYPE_CONTACTS 0x13
#define AIM_MTYPE_PLUGIN 0x1A
-#define AIM_MTYPE_AUTOAWAY 0xE8
-#define AIM_MTYPE_AUTOBUSY 0xE9
-#define AIM_MTYPE_AUTONA 0xEA
-#define AIM_MTYPE_AUTODND 0xEB
-#define AIM_MTYPE_AUTOFFC 0xEC
+#define AIM_MTYPE_AUTOAWAY 0xE8
+#define AIM_MTYPE_AUTOBUSY 0xE9
+#define AIM_MTYPE_AUTONA 0xEA
+#define AIM_MTYPE_AUTODND 0xEB
+#define AIM_MTYPE_AUTOFFC 0xEC
typedef struct aim_conn_s {
int fd;
@@ -221,7 +221,7 @@ typedef struct aim_conn_s {
void *priv; /* misc data the client may want to store */
void *internal; /* internal conn-specific libfaim data */
time_t lastactivity; /* time of last transmit */
- int forcedlatency;
+ int forcedlatency;
void *handlerlist;
void *sessv; /* pointer to parent session */
void *inside; /* only accessible from inside libfaim */
@@ -251,14 +251,14 @@ typedef struct aim_bstream_s {
typedef struct aim_frame_s {
guint8 hdrtype; /* defines which piece of the union to use */
union {
- struct {
+ struct {
guint8 type;
- flap_seqnum_t seqnum;
+ flap_seqnum_t seqnum;
} flap;
} hdr;
- aim_bstream_t data; /* payload stream */
- guint8 handled; /* 0 = new, !0 = been handled */
- guint8 nofree; /* 0 = free data on purge, 1 = only unlink */
+ aim_bstream_t data; /* payload stream */
+ guint8 handled; /* 0 = new, !0 = been handled */
+ guint8 nofree; /* 0 = free data on purge, 1 = only unlink */
aim_conn_t *conn; /* the connection it came in on... */
struct aim_frame_s *next;
} aim_frame_t;
@@ -272,7 +272,7 @@ typedef struct aim_msgcookie_s {
} aim_msgcookie_t;
/*
- * AIM Session: The main client-data interface.
+ * AIM Session: The main client-data interface.
*
*/
typedef struct aim_session_s {
@@ -280,10 +280,10 @@ typedef struct aim_session_s {
/* ---- Client Accessible ------------------------ */
/* Our screen name. */
- char sn[MAXSNLEN+1];
+ char sn[MAXSNLEN + 1];
/*
- * Pointer to anything the client wants to
+ * Pointer to anything the client wants to
* explicitly associate with this session.
*
* This is for use in the callbacks mainly. In any
@@ -313,10 +313,10 @@ typedef struct aim_session_s {
* These are only used when you don't use your own lowlevel
* I/O. I don't suggest that you use libfaim's internal I/O.
* Its really bad and the API/event model is quirky at best.
- *
+ *
*/
- aim_frame_t *queue_outgoing;
- aim_frame_t *queue_incoming;
+ aim_frame_t *queue_outgoing;
+ aim_frame_t *queue_incoming;
/*
* Tx Enqueuing function.
@@ -329,7 +329,7 @@ typedef struct aim_session_s {
int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *);
/*
- * Outstanding snac handling
+ * Outstanding snac handling
*
* XXX: Should these be per-connection? -mid
*/
@@ -383,13 +383,13 @@ typedef struct aim_session_s {
* AIM User Info, Standard Form.
*/
typedef struct {
- char sn[MAXSNLEN+1];
+ char sn[MAXSNLEN + 1];
guint16 warnlevel;
guint16 idletime;
guint16 flags;
guint32 membersince;
guint32 onlinesince;
- guint32 sessionlen;
+ guint32 sessionlen;
guint32 capabilities;
struct {
guint32 status;
@@ -409,21 +409,21 @@ typedef struct {
#define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
#define AIM_USERINFO_PRESENT_SESSIONLEN 0x00000100
-#define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */
-#define AIM_FLAG_ADMINISTRATOR 0x0002
-#define AIM_FLAG_AOL 0x0004
-#define AIM_FLAG_OSCAR_PAY 0x0008
-#define AIM_FLAG_FREE 0x0010
-#define AIM_FLAG_AWAY 0x0020
-#define AIM_FLAG_ICQ 0x0040
-#define AIM_FLAG_WIRELESS 0x0080
-#define AIM_FLAG_UNKNOWN100 0x0100
-#define AIM_FLAG_UNKNOWN200 0x0200
+#define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */
+#define AIM_FLAG_ADMINISTRATOR 0x0002
+#define AIM_FLAG_AOL 0x0004
+#define AIM_FLAG_OSCAR_PAY 0x0008
+#define AIM_FLAG_FREE 0x0010
+#define AIM_FLAG_AWAY 0x0020
+#define AIM_FLAG_ICQ 0x0040
+#define AIM_FLAG_WIRELESS 0x0080
+#define AIM_FLAG_UNKNOWN100 0x0100
+#define AIM_FLAG_UNKNOWN200 0x0200
#define AIM_FLAG_ACTIVEBUDDY 0x0400
-#define AIM_FLAG_UNKNOWN800 0x0800
+#define AIM_FLAG_UNKNOWN800 0x0800
#define AIM_FLAG_ABINTERNAL 0x1000
-#define AIM_FLAG_ALLUSERS 0x001f
+#define AIM_FLAG_ALLUSERS 0x001f
/*
* TLV handling
@@ -467,7 +467,8 @@ int aim_addtlvtochain32(aim_tlvlist_t **list, const guint16 type, const guint32
int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l, const guint8 *v);
int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps);
int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type);
-int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
+int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname,
+ guint16 instance);
int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui);
int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl);
int aim_counttlvchain(aim_tlvlist_t **list);
@@ -542,7 +543,8 @@ int aim_conn_setlatency(aim_conn_t *conn, int newval);
void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn);
-int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags);
+int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler,
+ u_short flags);
int aim_clearhandlers(aim_conn_t *conn);
aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, guint16 group);
@@ -557,7 +559,7 @@ int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn);
int aim_conn_isconnecting(aim_conn_t *conn);
typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
-int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t);
+int aim_setdebuggingcb(aim_session_t * sess, faim_debugging_callback_t);
void aim_session_init(aim_session_t *, guint32 flags, int debuglevel);
void aim_session_kill(aim_session_t *);
void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
@@ -617,7 +619,8 @@ int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn);
/* aim_im.c */
-aim_conn_t *aim_sendfile_initiate(aim_session_t *, const char *destsn, const char *filename, guint16 numfiles, guint32 totsize);
+aim_conn_t *aim_sendfile_initiate(aim_session_t *, const char *destsn, const char *filename, guint16 numfiles,
+ guint32 totsize);
aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn);
int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size);
@@ -652,29 +655,31 @@ int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur);
#define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
#define AIM_TRANSFER_DENY_DECLINE 0x0001
#define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
-aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const guint8 *cookie, const guint8 *ip, guint16 listingfiles, guint16 listingtotsize, guint16 listingsize, guint32 listingchecksum, guint16 rendid);
+aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const guint8 *cookie,
+ const guint8 *ip, guint16 listingfiles, guint16 listingtotsize, guint16 listingsize,
+ guint32 listingchecksum, guint16 rendid);
int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short);
-#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001
-#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002
+#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001
+#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002
/* This is what the server will give you if you don't set them yourself. */
#define AIM_IMPARAM_DEFAULTS { \
- 0, \
- AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
- 512, /* !! Note how small this is. */ \
- (99.9)*10, (99.9)*10, \
- 1000 /* !! And how large this is. */ \
+ 0, \
+ AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
+ 512, /* !! Note how small this is. */ \
+ (99.9) * 10, (99.9) * 10, \
+ 1000 /* !! And how large this is. */ \
}
/* This is what most AIM versions use. */
#define AIM_IMPARAM_REASONABLE { \
- 0, \
- AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
- 8000, \
- (99.9)*10, (99.9)*10, \
- 0 \
+ 0, \
+ AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
+ 8000, \
+ (99.9) * 10, (99.9) * 10, \
+ 0 \
}
@@ -715,17 +720,18 @@ struct aim_chat_exchangeinfo {
char *lang2;
};
-#define AIM_CHATFLAGS_NOREFLECT 0x0001
-#define AIM_CHATFLAGS_AWAY 0x0002
-#define AIM_CHATFLAGS_UNICODE 0x0004
-#define AIM_CHATFLAGS_ISO_8859_1 0x0008
+#define AIM_CHATFLAGS_NOREFLECT 0x0001
+#define AIM_CHATFLAGS_AWAY 0x0002
+#define AIM_CHATFLAGS_UNICODE 0x0004
+#define AIM_CHATFLAGS_ISO_8859_1 0x0008
int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen);
int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance);
int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn);
-int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange, const char *roomname, guint16 instance);
+int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange,
+ const char *roomname, guint16 instance);
int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, guint16 exchange);
@@ -737,50 +743,50 @@ int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *na
* their use.
*
*/
-#define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1)
-#define aimutil_get8(buf) ((*(buf))&0xff)
+#define aimutil_put8(buf, data) ((*(buf) = (u_char) (data) & 0xff), 1)
+#define aimutil_get8(buf) ((*(buf)) & 0xff)
#define aimutil_put16(buf, data) ( \
- (*(buf) = (u_char)((data)>>8)&0xff), \
- (*((buf)+1) = (u_char)(data)&0xff), \
- 2)
-#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
+ (*(buf) = (u_char) ((data) >> 8) & 0xff), \
+ (*((buf) + 1) = (u_char) (data) & 0xff), \
+ 2)
+#define aimutil_get16(buf) ((((*(buf)) << 8) & 0xff00) + ((*((buf) + 1)) & 0xff))
#define aimutil_put32(buf, data) ( \
- (*((buf)) = (u_char)((data)>>24)&0xff), \
- (*((buf)+1) = (u_char)((data)>>16)&0xff), \
- (*((buf)+2) = (u_char)((data)>>8)&0xff), \
- (*((buf)+3) = (u_char)(data)&0xff), \
- 4)
-#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
- (((*((buf)+1))<<16)&0x00ff0000) + \
- (((*((buf)+2))<< 8)&0x0000ff00) + \
- (((*((buf)+3) )&0x000000ff)))
+ (*((buf)) = (u_char) ((data) >> 24) & 0xff), \
+ (*((buf) + 1) = (u_char) ((data) >> 16) & 0xff), \
+ (*((buf) + 2) = (u_char) ((data) >> 8) & 0xff), \
+ (*((buf) + 3) = (u_char) (data) & 0xff), \
+ 4)
+#define aimutil_get32(buf) ((((*(buf)) << 24) & 0xff000000) + \
+ (((*((buf) + 1)) << 16) & 0x00ff0000) + \
+ (((*((buf) + 2)) << 8) & 0x0000ff00) + \
+ (((*((buf) + 3)) & 0x000000ff)))
/* Little-endian versions (damn ICQ) */
#define aimutil_putle8(buf, data) ( \
- (*(buf) = (unsigned char)(data) & 0xff), \
- 1)
+ (*(buf) = (unsigned char) (data) & 0xff), \
+ 1)
#define aimutil_getle8(buf) ( \
- (*(buf)) & 0xff \
- )
+ (*(buf)) & 0xff \
+ )
#define aimutil_putle16(buf, data) ( \
- (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff), \
- (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \
- 2)
+ (*((buf) + 0) = (unsigned char) ((data) >> 0) & 0xff), \
+ (*((buf) + 1) = (unsigned char) ((data) >> 8) & 0xff), \
+ 2)
#define aimutil_getle16(buf) ( \
- (((*((buf)+0)) << 0) & 0x00ff) + \
- (((*((buf)+1)) << 8) & 0xff00) \
- )
+ (((*((buf) + 0)) << 0) & 0x00ff) + \
+ (((*((buf) + 1)) << 8) & 0xff00) \
+ )
#define aimutil_putle32(buf, data) ( \
- (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff), \
- (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \
- (*((buf)+2) = (unsigned char)((data) >> 16) & 0xff), \
- (*((buf)+3) = (unsigned char)((data) >> 24) & 0xff), \
- 4)
+ (*((buf) + 0) = (unsigned char) ((data) >> 0) & 0xff), \
+ (*((buf) + 1) = (unsigned char) ((data) >> 8) & 0xff), \
+ (*((buf) + 2) = (unsigned char) ((data) >> 16) & 0xff), \
+ (*((buf) + 3) = (unsigned char) ((data) >> 24) & 0xff), \
+ 4)
#define aimutil_getle32(buf) ( \
- (((*((buf)+0)) << 0) & 0x000000ff) + \
- (((*((buf)+1)) << 8) & 0x0000ff00) + \
- (((*((buf)+2)) << 16) & 0x00ff0000) + \
- (((*((buf)+3)) << 24) & 0xff000000))
+ (((*((buf) + 0)) << 0) & 0x000000ff) + \
+ (((*((buf) + 1)) << 8) & 0x0000ff00) + \
+ (((*((buf) + 2)) << 16) & 0x00ff0000) + \
+ (((*((buf) + 3)) << 24) & 0xff000000))
int aim_sncmp(const char *a, const char *b);
@@ -796,7 +802,7 @@ int aim_sncmp(const char *a, const char *b);
/*
* SNAC Family: Ack.
- *
+ *
* Not really a family, but treating it as one really
* helps it fit into the libfaim callback structure better.
*
@@ -805,7 +811,7 @@ int aim_sncmp(const char *a, const char *b);
/*
* SNAC Family: General.
- */
+ */
#define AIM_CB_GEN_ERROR 0x0001
#define AIM_CB_GEN_CLIENTREADY 0x0002
#define AIM_CB_GEN_SERVERREADY 0x0003
@@ -830,7 +836,7 @@ int aim_sncmp(const char *a, const char *b);
/*
* SNAC Family: Advertisement Services
- */
+ */
#define AIM_CB_ADS_ERROR 0x0001
#define AIM_CB_ADS_DEFAULT 0xffff
@@ -839,7 +845,7 @@ int aim_sncmp(const char *a, const char *b);
*
* See non-SNAC note below.
*/
-#define AIM_CB_OFT_DIRECTIMCONNECTREQ 0x0001/* connect request -- actually an OSCAR CAP*/
+#define AIM_CB_OFT_DIRECTIMCONNECTREQ 0x0001 /* connect request -- actually an OSCAR CAP*/
#define AIM_CB_OFT_DIRECTIMINCOMING 0x0002
#define AIM_CB_OFT_DIRECTIMDISCONNECT 0x0003
#define AIM_CB_OFT_DIRECTIMTYPING 0x0004
@@ -868,7 +874,7 @@ int aim_sncmp(const char *a, const char *b);
* these, we can integrated non-SNAC services into
* the SNAC-centered libfaim callback structure.
*
- */
+ */
#define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001
#define AIM_CB_SPECIAL_AUTHOTHER 0x0002
#define AIM_CB_SPECIAL_CONNERR 0x0003
diff --git a/protocols/oscar/aim_internal.h b/protocols/oscar/aim_internal.h
index e4cdd0a2..4c1be740 100644
--- a/protocols/oscar/aim_internal.h
+++ b/protocols/oscar/aim_internal.h
@@ -21,8 +21,9 @@ typedef struct aim_module_s {
guint16 toolid;
guint16 toolversion;
guint16 flags;
- char name[AIM_MODULENAME_MAXLEN+1];
- int (*snachandler)(aim_session_t *sess, struct aim_module_s *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs);
+ char name[AIM_MODULENAME_MAXLEN + 1];
+ int (*snachandler)(aim_session_t *sess, struct aim_module_s *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs);
void (*shutdown)(aim_session_t *sess, struct aim_module_s *mod);
void *priv;
struct aim_module_s *next;
@@ -106,12 +107,13 @@ typedef struct aim_snac_s {
} aim_snac_t;
void aim_initsnachash(aim_session_t *sess);
-aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags, const void *data, const int datalen);
+aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags,
+ const void *data, const int datalen);
aim_snac_t *aim_remsnac(aim_session_t *, aim_snacid_t id);
void aim_cleansnacs(aim_session_t *, int maxage);
int aim_putsnac(aim_bstream_t *, guint16 family, guint16 type, guint16 flags, aim_snacid_t id);
-int aim_oft_buildheader(unsigned char *,struct aim_fileheader_t *);
+int aim_oft_buildheader(unsigned char *, struct aim_fileheader_t *);
int aim_parse_unknown(aim_session_t *, aim_frame_t *, ...);
@@ -137,7 +139,7 @@ struct aim_tool_version {
guint16 toolversion;
};
-/*
+/*
* In SNACland, the terms 'family' and 'group' are synonymous -- the former
* is my term, the latter is AOL's.
*/
@@ -169,9 +171,9 @@ struct rateclass {
/*
* This is inside every connection. But it is a void * to anything
* outside of libfaim. It should remain that way. It's called data
- * abstraction. Maybe you've heard of it. (Probably not if you're a
+ * abstraction. Maybe you've heard of it. (Probably not if you're a
* libfaim user.)
- *
+ *
*/
typedef struct aim_conn_inside_s {
struct snacgroup *groups;
diff --git a/protocols/oscar/auth.c b/protocols/oscar/auth.c
index 7a6b05d4..5e1dc4ec 100644
--- a/protocols/oscar/auth.c
+++ b/protocols/oscar/auth.c
@@ -3,13 +3,13 @@
*
*/
-#include <aim.h>
+#include <aim.h>
#include "md5.h"
static int aim_encode_password(const char *password, unsigned char *encoded);
-/*
+/*
* This just pushes the passed cookie onto the passed connection, without
* the SNAC header or any of that.
*
@@ -22,11 +22,12 @@ int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const guint8 *chipsaho
aim_frame_t *fr;
aim_tlvlist_t *tl = NULL;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4+2+2+AIM_COOKIELEN)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4 + 2 + 2 + AIM_COOKIELEN))) {
return -ENOMEM;
+ }
aimbs_put32(&fr->data, 0x00000001);
- aim_addtlvtochain_raw(&tl, 0x0006, AIM_COOKIELEN, chipsahoy);
+ aim_addtlvtochain_raw(&tl, 0x0006, AIM_COOKIELEN, chipsahoy);
aim_writetlvchain(&fr->data, &tl);
aim_freetlvchain(&tl);
@@ -47,8 +48,9 @@ int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn)
{
aim_frame_t *fr;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4))) {
return -ENOMEM;
+ }
aimbs_put32(&fr->data, 0x00000001);
@@ -94,24 +96,25 @@ static int goddamnicq(aim_session_t *sess, aim_conn_t *conn, const char *sn)
{
aim_frame_t fr;
aim_rxcallback_t userfunc;
-
+
sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN;
sess->flags |= AIM_SESS_FLAGS_XORLOGIN;
fr.conn = conn;
-
- if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007)))
+
+ if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007))) {
userfunc(sess, &fr, "");
+ }
return 0;
}
/*
- * In AIM 3.5 protocol, the first stage of login is to request login from the
- * Authorizer, passing it the screen name for verification. If the name is
- * invalid, a 0017/0003 is spit back, with the standard error contents. If
- * valid, a 0017/0007 comes back, which is the signal to send it the main
- * login command (0017/0002).
+ * In AIM 3.5 protocol, the first stage of login is to request login from the
+ * Authorizer, passing it the screen name for verification. If the name is
+ * invalid, a 0017/0003 is spit back, with the standard error contents. If
+ * valid, a 0017/0007 comes back, which is the signal to send it the main
+ * login command (0017/0002).
*
*/
int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn)
@@ -120,24 +123,27 @@ int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn)
aim_snacid_t snacid;
aim_tlvlist_t *tl = NULL;
struct im_connection *ic = sess->aux_data;
-
- if (!sess || !conn || !sn)
+
+ if (!sess || !conn || !sn) {
return -EINVAL;
+ }
- if (g_ascii_isdigit(sn[0]) && set_getbool(&ic->acc->set, "old_icq_auth"))
+ if (g_ascii_isdigit(sn[0]) && set_getbool(&ic->acc->set, "old_icq_auth")) {
return goddamnicq(sess, conn, sn);
+ }
sess->flags |= AIM_SESS_FLAGS_SNACLOGIN;
aim_sendflapver(sess, conn);
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(sn))))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 2 + 2 + strlen(sn)))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0017, 0x0006, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x0017, 0x0006, 0x0000, snacid);
- aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *)sn);
+ aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *) sn);
aim_writetlvchain(&fr->data, &tl);
aim_freetlvchain(&tl);
@@ -151,15 +157,16 @@ int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn)
*/
static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password)
{
- static const char clientstr[] = {"ICQ Inc. - Product of ICQ (TM) 2001b.5.17.1.3642.85"};
- static const char lang[] = {"en"};
- static const char country[] = {"us"};
+ static const char clientstr[] = { "ICQ Inc. - Product of ICQ (TM) 2001b.5.17.1.3642.85" };
+ static const char lang[] = { "en" };
+ static const char country[] = { "us" };
aim_frame_t *fr;
aim_tlvlist_t *tl = NULL;
guint8 *password_encoded;
- if (!(password_encoded = (guint8 *) g_malloc(strlen(password))))
+ if (!(password_encoded = (guint8 *) g_malloc(strlen(password)))) {
return -ENOMEM;
+ }
if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) {
g_free(password_encoded);
@@ -169,17 +176,17 @@ static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, co
aim_encode_password(password, password_encoded);
aimbs_put32(&fr->data, 0x00000001);
- aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *)sn);
+ aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *) sn);
aim_addtlvtochain_raw(&tl, 0x0002, strlen(password), password_encoded);
- aim_addtlvtochain_raw(&tl, 0x0003, strlen(clientstr), (guint8 *)clientstr);
+ aim_addtlvtochain_raw(&tl, 0x0003, strlen(clientstr), (guint8 *) clientstr);
aim_addtlvtochain16(&tl, 0x0016, 0x010a); /* cliend ID */
aim_addtlvtochain16(&tl, 0x0017, 0x0005); /* major version */
aim_addtlvtochain16(&tl, 0x0018, 0x0011); /* minor version */
aim_addtlvtochain16(&tl, 0x0019, 0x0001); /* point version */
aim_addtlvtochain16(&tl, 0x001a, 0x0e3a); /* build */
aim_addtlvtochain32(&tl, 0x0014, 0x00000055); /* distribution chan */
- aim_addtlvtochain_raw(&tl, 0x000f, strlen(lang), (guint8 *)lang);
- aim_addtlvtochain_raw(&tl, 0x000e, strlen(country), (guint8 *)country);
+ aim_addtlvtochain_raw(&tl, 0x000f, strlen(lang), (guint8 *) lang);
+ aim_addtlvtochain_raw(&tl, 0x000e, strlen(country), (guint8 *) country);
aim_writetlvchain(&fr->data, &tl);
@@ -193,7 +200,7 @@ static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, co
/*
* send_login(int socket, char *sn, char *password)
- *
+ *
* This is the initial login request packet.
*
* NOTE!! If you want/need to make use of the aim_sendmemblock() function,
@@ -248,7 +255,7 @@ static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, co
* point = (not sent)
* build = 0x0013
* unknown= (not sent)
- *
+ *
* AIM for Linux 1.1.112:
* clientstring = "AOL Instant Messenger (SM)"
* clientid = 0x1d09
@@ -260,32 +267,36 @@ static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, co
* serverstore = 0x01
*
*/
-int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci, const char *key)
+int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password,
+ struct client_info_s *ci, const char *key)
{
aim_frame_t *fr;
aim_tlvlist_t *tl = NULL;
guint8 digest[16];
aim_snacid_t snacid;
- if (!ci || !sn || !password)
+ if (!ci || !sn || !password) {
return -EINVAL;
+ }
/*
* What the XORLOGIN flag _really_ means is that its an ICQ login,
* which is really stupid and painful, so its not done here.
*
*/
- if (sess->flags & AIM_SESS_FLAGS_XORLOGIN)
+ if (sess->flags & AIM_SESS_FLAGS_XORLOGIN) {
return goddamnicq2(sess, conn, sn, password);
+ }
- 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, 0x0017, 0x0002, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid);
- aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *)sn);
+ aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *) sn);
aim_encode_password_md5(password, key, digest);
aim_addtlvtochain_raw(&tl, 0x0025, 16, digest);
@@ -294,15 +305,16 @@ int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
* Newer versions of winaim have an empty type x004c TLV here.
*/
- if (ci->clientstring)
- aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), (guint8 *)ci->clientstring);
- aim_addtlvtochain16(&tl, 0x0016, (guint16)ci->clientid);
- aim_addtlvtochain16(&tl, 0x0017, (guint16)ci->major);
- aim_addtlvtochain16(&tl, 0x0018, (guint16)ci->minor);
- aim_addtlvtochain16(&tl, 0x0019, (guint16)ci->point);
- aim_addtlvtochain16(&tl, 0x001a, (guint16)ci->build);
- aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), (guint8 *)ci->country);
- aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), (guint8 *)ci->lang);
+ if (ci->clientstring) {
+ aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), (guint8 *) ci->clientstring);
+ }
+ aim_addtlvtochain16(&tl, 0x0016, (guint16) ci->clientid);
+ aim_addtlvtochain16(&tl, 0x0017, (guint16) ci->major);
+ aim_addtlvtochain16(&tl, 0x0018, (guint16) ci->minor);
+ aim_addtlvtochain16(&tl, 0x0019, (guint16) ci->point);
+ aim_addtlvtochain16(&tl, 0x001a, (guint16) ci->build);
+ aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), (guint8 *) ci->country);
+ aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), (guint8 *) ci->lang);
/*
* If set, old-fashioned buddy lists will not work. You will need
@@ -313,7 +325,7 @@ int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
aim_writetlvchain(&fr->data, &tl);
aim_freetlvchain(&tl);
-
+
aim_tx_enqueue(sess, fr);
return 0;
@@ -323,11 +335,11 @@ int aim_encode_password_md5(const char *password, const char *key, guint8 *diges
{
md5_state_t state;
- md5_init(&state);
- md5_append(&state, (const md5_byte_t *)key, strlen(key));
- md5_append(&state, (const md5_byte_t *)password, strlen(password));
- md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
- md5_finish(&state, (md5_byte_t *)digest);
+ md5_init(&state);
+ md5_append(&state, (const md5_byte_t *) key, strlen(key));
+ md5_append(&state, (const md5_byte_t *) password, strlen(password));
+ md5_append(&state, (const md5_byte_t *) AIM_MD5_STRING, strlen(AIM_MD5_STRING));
+ md5_finish(&state, (md5_byte_t *) digest);
return 0;
}
@@ -344,7 +356,7 @@ int aim_encode_password_md5(const char *password, const char *key, guint8 *diges
* the null. The encoded password buffer /is not %NULL terminated/.
*
* The encoding_table seems to be a fixed set of values. We'll
- * hope it doesn't change over time!
+ * hope it doesn't change over time!
*
* This is only used for the XOR method, not the better MD5 method.
*
@@ -352,7 +364,7 @@ int aim_encode_password_md5(const char *password, const char *key, guint8 *diges
static int aim_encode_password(const char *password, guint8 *encoded)
{
guint8 encoding_table[] = {
- /* v2.1 table, also works for ICQ */
+ /* v2.1 table, also works for ICQ */
0xf3, 0x26, 0x81, 0xc4,
0x39, 0x86, 0xdb, 0x92,
0x71, 0xa3, 0xb9, 0xe6,
@@ -360,8 +372,9 @@ static int aim_encode_password(const char *password, guint8 *encoded)
};
int i;
- for (i = 0; i < strlen(password); i++)
+ for (i = 0; i < strlen(password); i++) {
encoded[i] = (password[i] ^ encoding_table[i]);
+ }
return 0;
}
@@ -369,7 +382,7 @@ static int aim_encode_password(const char *password, guint8 *encoded)
/*
* This is sent back as a general response to the login command.
* It can be either an error or a success, depending on the
- * precense of certain TLVs.
+ * precense of certain TLVs.
*
* The client should check the value passed as errorcode. If
* its nonzero, there was an error.
@@ -403,16 +416,19 @@ static int parse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mo
* Check for an error code. If so, we should also
* have an error url.
*/
- if (aim_gettlv(tlvlist, 0x0008, 1))
+ if (aim_gettlv(tlvlist, 0x0008, 1)) {
info.errorcode = aim_gettlv16(tlvlist, 0x0008, 1);
- if (aim_gettlv(tlvlist, 0x0004, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0004, 1)) {
info.errorurl = aim_gettlv_str(tlvlist, 0x0004, 1);
+ }
/*
* BOS server address.
*/
- if (aim_gettlv(tlvlist, 0x0005, 1))
+ if (aim_gettlv(tlvlist, 0x0005, 1)) {
info.bosip = aim_gettlv_str(tlvlist, 0x0005, 1);
+ }
/*
* Authorization cookie.
@@ -429,8 +445,9 @@ static int parse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mo
* The email address attached to this account
* Not available for ICQ logins.
*/
- if (aim_gettlv(tlvlist, 0x0011, 1))
+ if (aim_gettlv(tlvlist, 0x0011, 1)) {
info.email = aim_gettlv_str(tlvlist, 0x0011, 1);
+ }
/*
* The registration status. (Not real sure what it means.)
@@ -444,34 +461,46 @@ static int parse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mo
* to other users or not. AFAIK, this feature is no longer used.
*
*/
- if (aim_gettlv(tlvlist, 0x0013, 1))
+ if (aim_gettlv(tlvlist, 0x0013, 1)) {
info.regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
+ }
- if (aim_gettlv(tlvlist, 0x0040, 1))
+ if (aim_gettlv(tlvlist, 0x0040, 1)) {
info.latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1);
- if (aim_gettlv(tlvlist, 0x0041, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0041, 1)) {
info.latestbeta.url = aim_gettlv_str(tlvlist, 0x0041, 1);
- if (aim_gettlv(tlvlist, 0x0042, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0042, 1)) {
info.latestbeta.info = aim_gettlv_str(tlvlist, 0x0042, 1);
- if (aim_gettlv(tlvlist, 0x0043, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0043, 1)) {
info.latestbeta.name = aim_gettlv_str(tlvlist, 0x0043, 1);
- if (aim_gettlv(tlvlist, 0x0048, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0048, 1)) {
; /* no idea what this is */
- if (aim_gettlv(tlvlist, 0x0044, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0044, 1)) {
info.latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1);
- if (aim_gettlv(tlvlist, 0x0045, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0045, 1)) {
info.latestrelease.url = aim_gettlv_str(tlvlist, 0x0045, 1);
- if (aim_gettlv(tlvlist, 0x0046, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0046, 1)) {
info.latestrelease.info = aim_gettlv_str(tlvlist, 0x0046, 1);
- if (aim_gettlv(tlvlist, 0x0047, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0047, 1)) {
info.latestrelease.name = aim_gettlv_str(tlvlist, 0x0047, 1);
- if (aim_gettlv(tlvlist, 0x0049, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0049, 1)) {
; /* no idea what this is */
- if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003)))
+ }
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) {
ret = userfunc(sess, rx, &info);
+ }
g_free(info.sn);
g_free(info.bosip);
@@ -505,10 +534,11 @@ static int keyparse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
keylen = aimbs_get16(bs);
keystr = aimbs_getstr(bs, keylen);
- 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, keystr);
+ }
- g_free(keystr);
+ g_free(keystr);
return ret;
}
@@ -516,10 +546,11 @@ static int keyparse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
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 == 0x0003)
+ if (snac->subtype == 0x0003) {
return parse(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0007)
+ } else if (snac->subtype == 0x0007) {
return keyparse(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/bos.c b/protocols/oscar/bos.c
index 4a1c5036..8d5fc12a 100644
--- a/protocols/oscar/bos.c
+++ b/protocols/oscar/bos.c
@@ -15,32 +15,35 @@ static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
guint16 maxpermits = 0, maxdenies = 0;
int ret = 0;
- /*
- * TLVs follow
+ /*
+ * TLVs follow
*/
tlvlist = aim_readtlvchain(bs);
/*
* TLV type 0x0001: Maximum number of buddies on permit list.
*/
- if (aim_gettlv(tlvlist, 0x0001, 1))
+ if (aim_gettlv(tlvlist, 0x0001, 1)) {
maxpermits = aim_gettlv16(tlvlist, 0x0001, 1);
+ }
/*
* TLV type 0x0002: Maximum number of buddies on deny list.
*/
- if (aim_gettlv(tlvlist, 0x0002, 1))
+ if (aim_gettlv(tlvlist, 0x0002, 1)) {
maxdenies = aim_gettlv16(tlvlist, 0x0002, 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, maxpermits, maxdenies);
+ }
aim_freetlvchain(&tlvlist);
- return ret;
+ return ret;
}
-/*
+/*
* Set group permisson mask (group 9, type 4)
*
* Normally 0x1f (all classes).
@@ -58,8 +61,9 @@ int aim_bos_setgroupperm(aim_session_t *sess, aim_conn_t *conn, guint32 mask)
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 == 0x0003)
+ if (snac->subtype == 0x0003) {
return rights(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/bos.h b/protocols/oscar/bos.h
index e7c2cbcd..a8cabf8b 100644
--- a/protocols/oscar/bos.h
+++ b/protocols/oscar/bos.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Misc BOS Services.
- */
+ */
#define AIM_CB_BOS_ERROR 0x0001
#define AIM_CB_BOS_RIGHTSQUERY 0x0002
#define AIM_CB_BOS_RIGHTS 0x0003
diff --git a/protocols/oscar/buddylist.c b/protocols/oscar/buddylist.c
index 3335c5ab..8fa7ac01 100644
--- a/protocols/oscar/buddylist.c
+++ b/protocols/oscar/buddylist.c
@@ -17,8 +17,9 @@ static int buddychange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
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;
}
@@ -30,16 +31,17 @@ static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
guint16 maxbuddies = 0, maxwatchers = 0;
int ret = 0;
- /*
- * TLVs follow
+ /*
+ * TLVs follow
*/
tlvlist = aim_readtlvchain(bs);
/*
* TLV type 0x0001: Maximum number of buddies.
*/
- if (aim_gettlv(tlvlist, 0x0001, 1))
+ if (aim_gettlv(tlvlist, 0x0001, 1)) {
maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1);
+ }
/*
* TLV type 0x0002: Maximum number of watchers.
@@ -47,10 +49,11 @@ static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
* Watchers are other users who have you on their buddy
* list. (This is called the "reverse list" by a certain
* other IM protocol.)
- *
+ *
*/
- if (aim_gettlv(tlvlist, 0x0002, 1))
+ if (aim_gettlv(tlvlist, 0x0002, 1)) {
maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1);
+ }
/*
* TLV type 0x0003: Unknown.
@@ -58,21 +61,23 @@ static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
* ICQ only?
*/
- 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, maxbuddies, maxwatchers);
+ }
aim_freetlvchain(&tlvlist);
- return ret;
+ return ret;
}
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 == 0x0003)
+ if (snac->subtype == 0x0003) {
return rights(sess, mod, rx, snac, bs);
- else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c))
+ } else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c)) {
return buddychange(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/buddylist.h b/protocols/oscar/buddylist.h
index 55189581..268bc81a 100644
--- a/protocols/oscar/buddylist.h
+++ b/protocols/oscar/buddylist.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Buddy List Management Services.
- */
+ */
#define AIM_CB_BUD_ERROR 0x0001
#define AIM_CB_BUD_REQRIGHTS 0x0002
#define AIM_CB_BUD_RIGHTSINFO 0x0003
diff --git a/protocols/oscar/chat.c b/protocols/oscar/chat.c
index 6c8d8998..a902ce64 100644
--- a/protocols/oscar/chat.c
+++ b/protocols/oscar/chat.c
@@ -5,7 +5,7 @@
*
*/
-#include <aim.h>
+#include <aim.h>
#include <glib.h>
#include "info.h"
@@ -18,10 +18,11 @@ struct chatconnpriv {
void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn)
{
- struct chatconnpriv *ccp = (struct chatconnpriv *)conn->priv;
+ struct chatconnpriv *ccp = (struct chatconnpriv *) conn->priv;
- if (ccp)
+ if (ccp) {
g_free(ccp->name);
+ }
g_free(ccp);
return;
@@ -37,10 +38,10 @@ void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn)
* (Note that WinAIM does not honor this,
* and displays the message as normal.)
*
- * XXX convert this to use tlvchains
+ * XXX convert this to use tlvchains
*/
int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen)
-{
+{
int i;
aim_frame_t *fr;
aim_msgcookie_t *cookie;
@@ -48,38 +49,42 @@ int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const
guint8 ckstr[8];
aim_tlvlist_t *otl = NULL, *itl = NULL;
- if (!sess || !conn || !msg || (msglen <= 0))
+ if (!sess || !conn || !msg || (msglen <= 0)) {
return 0;
+ }
- 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, 0x000e, 0x0005, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x000e, 0x0005, 0x0000, snacid);
- /*
+ /*
* Generate a random message cookie.
*
* XXX mkcookie should generate the cookie and cache it in one
* operation to preserve uniqueness.
*
*/
- for (i = 0; i < sizeof(ckstr); i++)
- (void) aimutil_put8(ckstr+i, (guint8) rand());
-
+ for (i = 0; i < sizeof(ckstr); i++) {
+ (void) aimutil_put8(ckstr + i, (guint8) rand());
+ }
+
cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_CHAT, NULL);
cookie->data = NULL; /* XXX store something useful here */
aim_cachecookie(sess, cookie);
- for (i = 0; i < sizeof(ckstr); i++)
+ for (i = 0; i < sizeof(ckstr); i++) {
aimbs_put8(&fr->data, ckstr[i]);
+ }
/*
- * Channel ID.
+ * Channel ID.
*/
aimbs_put16(&fr->data, 0x0003);
@@ -92,57 +97,59 @@ int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const
/*
* Type 6: Reflect
*/
- if (!(flags & AIM_CHATFLAGS_NOREFLECT))
+ if (!(flags & AIM_CHATFLAGS_NOREFLECT)) {
aim_addtlvtochain_noval(&otl, 0x0006);
+ }
/*
* Type 7: Autoresponse
*/
- if (flags & AIM_CHATFLAGS_AWAY)
+ if (flags & AIM_CHATFLAGS_AWAY) {
aim_addtlvtochain_noval(&otl, 0x0007);
-
+ }
+
/* [WvG] This wasn't there originally, but we really should send
the right charset flags, as we also do with normal
messages. Hope this will work. :-) */
/*
if (flags & AIM_CHATFLAGS_UNICODE)
- aimbs_put16(&fr->data, 0x0002);
+ aimbs_put16(&fr->data, 0x0002);
else if (flags & AIM_CHATFLAGS_ISO_8859_1)
- aimbs_put16(&fr->data, 0x0003);
+ aimbs_put16(&fr->data, 0x0003);
else
- aimbs_put16(&fr->data, 0x0000);
-
+ aimbs_put16(&fr->data, 0x0000);
+
aimbs_put16(&fr->data, 0x0000);
*/
-
+
/*
* SubTLV: Type 1: Message
*/
- aim_addtlvtochain_raw(&itl, 0x0001, strlen(msg), (guint8 *)msg);
+ aim_addtlvtochain_raw(&itl, 0x0001, strlen(msg), (guint8 *) msg);
/*
* Type 5: Message block. Contains more TLVs.
*
* This could include other information... We just
- * put in a message TLV however.
- *
+ * put in a message TLV however.
+ *
*/
aim_addtlvtochain_frozentlvlist(&otl, 0x0005, &itl);
aim_writetlvchain(&fr->data, &otl);
-
+
aim_freetlvchain(&itl);
aim_freetlvchain(&otl);
-
+
aim_tx_enqueue(sess, fr);
return 0;
}
/*
- * Join a room of name roomname. This is the first step to joining an
- * already created room. It's basically a Service Request for
- * family 0x000e, with a little added on to specify the exchange and room
+ * Join a room of name roomname. This is the first step to joining an
+ * already created room. It's basically a Service Request for
+ * family 0x000e, with a little added on to specify the exchange and room
* name.
*/
int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance)
@@ -151,12 +158,14 @@ int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const
aim_snacid_t snacid;
aim_tlvlist_t *tl = NULL;
struct chatsnacinfo csi;
-
- if (!sess || !conn || !roomname || !strlen(roomname))
+
+ if (!sess || !conn || !roomname || !strlen(roomname)) {
return -EINVAL;
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) {
return -ENOMEM;
+ }
memset(&csi, 0, sizeof(csi));
csi.exchange = exchange;
@@ -177,15 +186,16 @@ int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const
aim_tx_enqueue(sess, fr);
- return 0;
+ return 0;
}
int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo)
{
int namelen;
- if (!bs || !outinfo)
+ if (!bs || !outinfo) {
return 0;
+ }
outinfo->exchange = aimbs_get16(bs);
namelen = aimbs_get8(bs);
@@ -198,7 +208,8 @@ int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo)
/*
* conn must be a BOS connection!
*/
-int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange, const char *roomname, guint16 instance)
+int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange,
+ const char *roomname, guint16 instance)
{
int i;
aim_frame_t *fr;
@@ -210,25 +221,31 @@ int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
guint8 *hdr;
int hdrlen;
aim_bstream_t hdrbs;
-
- if (!sess || !conn || !sn || !msg || !roomname)
+
+ if (!sess || !conn || !sn || !msg || !roomname) {
return -EINVAL;
+ }
- if (conn->type != AIM_CONN_TYPE_BOS)
+ if (conn->type != AIM_CONN_TYPE_BOS) {
return -EINVAL;
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152+strlen(sn)+strlen(roomname)+strlen(msg))))
+ if (!(fr =
+ aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152 + strlen(sn) + strlen(roomname) +
+ strlen(msg)))) {
return -ENOMEM;
+ }
- snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, sn, strlen(sn)+1);
+ snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, sn, strlen(sn) + 1);
aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
/*
* Cookie
*/
- for (i = 0; i < sizeof(ckstr); i++)
+ for (i = 0; i < sizeof(ckstr); i++) {
(void) aimutil_put8(ckstr, (guint8) rand());
+ }
/* XXX should be uncached by an unwritten 'invite accept' handler */
if ((priv = g_malloc(sizeof(struct aim_invite_priv)))) {
@@ -238,13 +255,15 @@ int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
priv->instance = instance;
}
- if ((cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_INVITE, priv)))
+ if ((cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_INVITE, priv))) {
aim_cachecookie(sess, cookie);
- else
+ } else {
g_free(priv);
+ }
- for (i = 0; i < sizeof(ckstr); i++)
+ for (i = 0; i < sizeof(ckstr); i++) {
aimbs_put8(&fr->data, ckstr[i]);
+ }
/*
@@ -256,7 +275,7 @@ int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
* Dest sn
*/
aimbs_put8(&fr->data, strlen(sn));
- aimbs_putraw(&fr->data, (guint8 *)sn, strlen(sn));
+ aimbs_putraw(&fr->data, (guint8 *) sn, strlen(sn));
/*
* TLV t(0005)
@@ -265,23 +284,23 @@ int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
*
* Sigh. AOL was rather inconsistent right here. So we have
* to play some minor tricks. Right inside the type 5 is some
- * raw data, followed by a series of TLVs.
+ * raw data, followed by a series of TLVs.
*
*/
- hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2;
+ hdrlen = 2 + 8 + 16 + 6 + 4 + 4 + strlen(msg) + 4 + 2 + 1 + strlen(roomname) + 2;
hdr = g_malloc(hdrlen);
aim_bstream_init(&hdrbs, hdr, hdrlen);
-
+
aimbs_put16(&hdrbs, 0x0000); /* Unknown! */
aimbs_putraw(&hdrbs, ckstr, sizeof(ckstr)); /* I think... */
aim_putcap(&hdrbs, AIM_CAPS_CHAT);
aim_addtlvtochain16(&itl, 0x000a, 0x0001);
aim_addtlvtochain_noval(&itl, 0x000f);
- aim_addtlvtochain_raw(&itl, 0x000c, strlen(msg), (guint8 *)msg);
+ aim_addtlvtochain_raw(&itl, 0x000c, strlen(msg), (guint8 *) msg);
aim_addtlvtochain_chatroom(&itl, 0x2711, exchange, roomname, instance);
aim_writetlvchain(&hdrbs, &itl);
-
+
aim_addtlvtochain_raw(&otl, 0x0005, aim_bstream_curpos(&hdrbs), hdr);
aim_writetlvchain(&fr->data, &otl);
@@ -289,7 +308,7 @@ int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const
g_free(hdr);
aim_freetlvchain(&itl);
aim_freetlvchain(&otl);
-
+
aim_tx_enqueue(sess, fr);
return 0;
@@ -333,25 +352,27 @@ static int infoupdate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
/*
* Everything else are TLVs.
- */
+ */
tlvlist = aim_readtlvchain(bs);
/*
* TLV type 0x006a is the room name in Human Readable Form.
*/
- if (aim_gettlv(tlvlist, 0x006a, 1))
+ if (aim_gettlv(tlvlist, 0x006a, 1)) {
roomname = aim_gettlv_str(tlvlist, 0x006a, 1);
+ }
/*
* Type 0x006f: Number of occupants.
*/
- if (aim_gettlv(tlvlist, 0x006f, 1))
+ if (aim_gettlv(tlvlist, 0x006f, 1)) {
usercount = aim_gettlv16(tlvlist, 0x006f, 1);
+ }
/*
* Type 0x0073: Occupant list.
*/
- if (aim_gettlv(tlvlist, 0x0073, 1)) {
+ if (aim_gettlv(tlvlist, 0x0073, 1)) {
int curoccupant = 0;
aim_tlv_t *tmptlv;
aim_bstream_t occbs;
@@ -363,97 +384,110 @@ static int infoupdate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
aim_bstream_init(&occbs, tmptlv->value, tmptlv->length);
- while (curoccupant < usercount)
+ while (curoccupant < usercount) {
aim_extractuserinfo(sess, &occbs, &userinfo[curoccupant++]);
+ }
}
- /*
+ /*
* Type 0x00c9: Flags. (AIM_CHATROOM_FLAG)
*/
- if (aim_gettlv(tlvlist, 0x00c9, 1))
+ if (aim_gettlv(tlvlist, 0x00c9, 1)) {
flags = aim_gettlv16(tlvlist, 0x00c9, 1);
+ }
- /*
+ /*
* Type 0x00ca: Creation time (4 bytes)
*/
- if (aim_gettlv(tlvlist, 0x00ca, 1))
+ if (aim_gettlv(tlvlist, 0x00ca, 1)) {
creationtime = aim_gettlv32(tlvlist, 0x00ca, 1);
+ }
- /*
+ /*
* Type 0x00d1: Maximum Message Length
*/
- if (aim_gettlv(tlvlist, 0x00d1, 1))
+ if (aim_gettlv(tlvlist, 0x00d1, 1)) {
maxmsglen = aim_gettlv16(tlvlist, 0x00d1, 1);
+ }
- /*
+ /*
* Type 0x00d2: Unknown. (2 bytes)
*/
- if (aim_gettlv(tlvlist, 0x00d2, 1))
+ if (aim_gettlv(tlvlist, 0x00d2, 1)) {
unknown_d2 = aim_gettlv16(tlvlist, 0x00d2, 1);
+ }
- /*
+ /*
* Type 0x00d3: Room Description
*/
- if (aim_gettlv(tlvlist, 0x00d3, 1))
+ if (aim_gettlv(tlvlist, 0x00d3, 1)) {
roomdesc = aim_gettlv_str(tlvlist, 0x00d3, 1);
+ }
/*
* Type 0x000d4: Unknown (flag only)
*/
- if (aim_gettlv(tlvlist, 0x000d4, 1))
+ if (aim_gettlv(tlvlist, 0x000d4, 1)) {
;
+ }
- /*
+ /*
* Type 0x00d5: Unknown. (1 byte)
*/
- if (aim_gettlv(tlvlist, 0x00d5, 1))
+ if (aim_gettlv(tlvlist, 0x00d5, 1)) {
unknown_d5 = aim_gettlv8(tlvlist, 0x00d5, 1);
+ }
/*
* Type 0x00d6: Encoding 1 ("us-ascii")
*/
- if (aim_gettlv(tlvlist, 0x000d6, 1))
+ if (aim_gettlv(tlvlist, 0x000d6, 1)) {
;
-
+ }
+
/*
* Type 0x00d7: Language 1 ("en")
*/
- if (aim_gettlv(tlvlist, 0x000d7, 1))
+ if (aim_gettlv(tlvlist, 0x000d7, 1)) {
;
+ }
/*
* Type 0x00d8: Encoding 2 ("us-ascii")
*/
- if (aim_gettlv(tlvlist, 0x000d8, 1))
+ if (aim_gettlv(tlvlist, 0x000d8, 1)) {
;
-
+ }
+
/*
* Type 0x00d9: Language 2 ("en")
*/
- if (aim_gettlv(tlvlist, 0x000d9, 1))
+ if (aim_gettlv(tlvlist, 0x000d9, 1)) {
;
+ }
/*
* Type 0x00da: Maximum visible message length
*/
- if (aim_gettlv(tlvlist, 0x000da, 1))
+ if (aim_gettlv(tlvlist, 0x000da, 1)) {
maxvisiblemsglen = aim_gettlv16(tlvlist, 0x00da, 1);
+ }
if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
ret = userfunc(sess,
- rx,
- &roominfo,
- roomname,
- usercount,
- userinfo,
- roomdesc,
- flags,
- creationtime,
- maxmsglen,
- unknown_d2,
- unknown_d5,
- maxvisiblemsglen);
+ rx,
+ &roominfo,
+ roomname,
+ usercount,
+ userinfo,
+ roomdesc,
+ flags,
+ creationtime,
+ maxmsglen,
+ unknown_d2,
+ unknown_d5,
+ maxvisiblemsglen);
}
g_free(roominfo.name);
@@ -465,7 +499,8 @@ static int infoupdate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
return ret;
}
-static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
+static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs)
{
aim_userinfo_t *userinfo = NULL;
aim_rxcallback_t userfunc;
@@ -474,11 +509,12 @@ static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
while (aim_bstream_empty(bs)) {
curcount++;
userinfo = g_realloc(userinfo, curcount * sizeof(aim_userinfo_t));
- aim_extractuserinfo(sess, bs, &userinfo[curcount-1]);
+ aim_extractuserinfo(sess, bs, &userinfo[curcount - 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, curcount, userinfo);
+ }
g_free(userinfo);
@@ -486,7 +522,7 @@ static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
}
/*
- * We could probably include this in the normal ICBM parsing
+ * We could probably include this in the normal ICBM parsing
* code as channel 0x0003, however, since only the start
* would be the same, we might as well do it here.
*
@@ -506,12 +542,12 @@ static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
* message tlv
* message string
* possibly others
- *
+ *
*/
static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
{
aim_userinfo_t userinfo;
- aim_rxcallback_t userfunc;
+ aim_rxcallback_t userfunc;
int ret = 0;
guint8 *cookie;
guint16 channel;
@@ -548,7 +584,7 @@ static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
}
/*
- * Start parsing TLVs right away.
+ * Start parsing TLVs right away.
*/
otl = aim_readtlvchain(bs);
@@ -566,11 +602,12 @@ static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
}
/*
- * Type 0x0001: If present, it means it was a message to the
+ * Type 0x0001: If present, it means it was a message to the
* room (as opposed to a whisper).
*/
- if (aim_gettlv(otl, 0x0001, 1))
+ if (aim_gettlv(otl, 0x0001, 1)) {
;
+ }
/*
* Type 0x0005: Message Block. Conains more TLVs.
@@ -584,17 +621,19 @@ static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
aim_bstream_init(&tbs, msgblock->value, msgblock->length);
itl = aim_readtlvchain(&tbs);
- /*
+ /*
* Type 0x0001: Message.
- */
- if (aim_gettlv(itl, 0x0001, 1))
+ */
+ if (aim_gettlv(itl, 0x0001, 1)) {
msg = aim_gettlv_str(itl, 0x0001, 1);
+ }
- aim_freetlvchain(&itl);
+ aim_freetlvchain(&itl);
}
- 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, &userinfo, msg);
+ }
g_free(cookie);
g_free(msg);
@@ -606,12 +645,13 @@ static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
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 == 0x0002)
+ if (snac->subtype == 0x0002) {
return infoupdate(sess, mod, rx, snac, bs);
- else if ((snac->subtype == 0x0003) || (snac->subtype == 0x0004))
+ } else if ((snac->subtype == 0x0003) || (snac->subtype == 0x0004)) {
return userlistchange(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0006)
+ } else if (snac->subtype == 0x0006) {
return incomingmsg(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/chat.h b/protocols/oscar/chat.h
index 6b360326..714f6b74 100644
--- a/protocols/oscar/chat.h
+++ b/protocols/oscar/chat.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Chat Services
- */
+ */
#define AIM_CB_CHT_ERROR 0x0001
#define AIM_CB_CHT_ROOMINFOUPDATE 0x0002
#define AIM_CB_CHT_USERJOIN 0x0003
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;
}
diff --git a/protocols/oscar/chatnav.h b/protocols/oscar/chatnav.h
index 285decad..a37a6e31 100644
--- a/protocols/oscar/chatnav.h
+++ b/protocols/oscar/chatnav.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Chat Navigation Services
- */
+ */
#define AIM_CB_CTN_ERROR 0x0001
#define AIM_CB_CTN_CREATE 0x0008
#define AIM_CB_CTN_INFO 0x0009
diff --git a/protocols/oscar/conn.c b/protocols/oscar/conn.c
index 16b6ac07..3cfc38e9 100644
--- a/protocols/oscar/conn.c
+++ b/protocols/oscar/conn.c
@@ -6,7 +6,7 @@
*
*/
-#include <aim.h>
+#include <aim.h>
#include "sock.h"
static int aim_logoff(aim_session_t *sess);
@@ -14,17 +14,17 @@ static int aim_logoff(aim_session_t *sess);
/*
* 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.
+ * without being guarenteed a "Not supported" SNAC error.
*
- * The grand theory of things says that these associations transcend
+ * 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.
*
* So let us say that you have your core BOS connection running. One
* 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.
*
@@ -42,8 +42,8 @@ static int aim_logoff(aim_session_t *sess);
* it. Great, you say. Now I have something to do. Off you go, making
* 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
* still stuck in the bitter cold.
@@ -56,7 +56,7 @@ static int aim_logoff(aim_session_t *sess);
* scheme for quite some time now. But I still haven't convinced myself
* 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.)
*
* Generally, addgroup is only called by the internal handling of the
@@ -68,11 +68,12 @@ static int aim_logoff(aim_session_t *sess);
*/
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;
@@ -87,12 +88,13 @@ aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, guint16 group)
aim_conn_t *cur;
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;
+ }
}
}
@@ -149,25 +151,28 @@ static void connkill_real(aim_session_t *sess, aim_conn_t **deadconn)
aim_rxqueue_cleanbyconn(sess, *deadconn);
aim_tx_cleanqueue(sess, *deadconn);
- if ((*deadconn)->fd != -1)
+ if ((*deadconn)->fd != -1) {
aim_conn_close(*deadconn);
+ }
/*
* XXX ->priv should never be touched by the library. I know
* it used to be, but I'm getting rid of all that. Use
* ->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);
connkill_rates(&inside->rates);
@@ -217,8 +222,9 @@ static void aim_connrst(aim_session_t *sess)
static void aim_conn_init(aim_conn_t *deadconn)
{
- if (!deadconn)
+ if (!deadconn) {
return;
+ }
deadconn->fd = -1;
deadconn->subtype = -1;
@@ -244,10 +250,11 @@ static aim_conn_t *aim_conn_getnext(aim_session_t *sess)
{
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;
}
@@ -273,8 +280,9 @@ void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn)
{
aim_conn_t *cur, **prev;
- if (!deadconn || !*deadconn)
+ if (!deadconn || !*deadconn) {
return;
+ }
for (prev = &sess->connlist; (cur = *prev); ) {
if (cur == *deadconn) {
@@ -284,9 +292,10 @@ void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn)
prev = &cur->next;
}
- if (!cur)
+ if (!cur) {
return; /* oops */
+ }
connkill_real(sess, &cur);
return;
@@ -298,7 +307,7 @@ void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn)
*
* 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.
*
@@ -306,11 +315,13 @@ void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn)
void aim_conn_close(aim_conn_t *deadconn)
{
- if (deadconn->fd >= 3)
+ if (deadconn->fd >= 3) {
closesocket(deadconn->fd);
+ }
deadconn->fd = -1;
- if (deadconn->handlerlist)
+ if (deadconn->handlerlist) {
aim_clearhandlers(deadconn);
+ }
return;
}
@@ -320,7 +331,7 @@ void aim_conn_close(aim_conn_t *deadconn)
* @sess: Session to search
* @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.
*
@@ -332,9 +343,10 @@ aim_conn_t *aim_getconn_type(aim_session_t *sess, int type)
aim_conn_t *cur;
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;
+ }
}
return cur;
@@ -345,8 +357,9 @@ aim_conn_t *aim_getconn_type_all(aim_session_t *sess, int type)
aim_conn_t *cur;
for (cur = sess->connlist; cur; cur = cur->next) {
- if (cur->type == type)
+ if (cur->type == type) {
break;
+ }
}
return cur;
@@ -360,7 +373,7 @@ aim_conn_t *aim_getconn_type_all(aim_session_t *sess, int type)
*
* 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.
*
* FIXME: Return errors in a more sane way.
@@ -373,10 +386,11 @@ aim_conn_t *aim_newconn(aim_session_t *sess, int type, const char *dest)
char *host;
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;
if (!dest) { /* just allocate a struct */
@@ -385,23 +399,23 @@ aim_conn_t *aim_newconn(aim_session_t *sess, int type, const char *dest)
return connstruct;
}
- /*
- * 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';
@@ -420,7 +434,7 @@ aim_conn_t *aim_newconn(aim_session_t *sess, int type, const char *dest)
* Causes @newval seconds to be spent between transmits on a connection.
*
* This is my lame attempt at overcoming not understanding the rate
- * limiting.
+ * limiting.
*
* XXX: This should really be replaced with something that scales and
* backs off like the real rate limiting does.
@@ -429,8 +443,9 @@ aim_conn_t *aim_newconn(aim_session_t *sess, int type, const char *dest)
int aim_conn_setlatency(aim_conn_t *conn, int newval)
{
- if (!conn)
+ if (!conn) {
return -1;
+ }
conn->forcedlatency = newval;
conn->lastactivity = 0; /* reset this just to make sure */
@@ -450,8 +465,9 @@ int aim_conn_setlatency(aim_conn_t *conn, int newval)
void aim_session_init(aim_session_t *sess, guint32 flags, int debuglevel)
{
- if (!sess)
+ if (!sess) {
return;
+ }
memset(sess, 0, sizeof(aim_session_t));
aim_connrst(sess);
@@ -470,7 +486,7 @@ void aim_session_init(aim_session_t *sess, guint32 flags, int debuglevel)
sess->ssi.holding_queue = NULL;
sess->ssi.revision = 0;
sess->ssi.items = NULL;
- sess->ssi.timestamp = (time_t)0;
+ sess->ssi.timestamp = (time_t) 0;
sess->locate.userinfo = NULL;
sess->locate.torequest = NULL;
@@ -486,13 +502,14 @@ void aim_session_init(aim_session_t *sess, guint32 flags, int debuglevel)
/*
* 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);
@@ -547,11 +564,13 @@ int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn)
int res, error = ETIMEDOUT;
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);
FD_SET(conn->fd, &fds);
@@ -560,20 +579,21 @@ int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn)
tv.tv_sec = 0;
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);
errno = error;
return -1;
} 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;
+ }
}
if (error) {
@@ -586,8 +606,9 @@ int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn)
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 */
aim_tx_flushqueue(sess);
@@ -598,10 +619,11 @@ int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn)
aim_session_t *aim_conn_getsess(aim_conn_t *conn)
{
- if (!conn)
+ if (!conn) {
return NULL;
+ }
- return (aim_session_t *)conn->sessv;
+ return (aim_session_t *) conn->sessv;
}
/*
@@ -623,14 +645,15 @@ static int aim_logoff(aim_session_t *sess)
* aim_flap_nop()
*
* 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)
{
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);
diff --git a/protocols/oscar/icq.c b/protocols/oscar/icq.c
index bd1ba1d1..0f3933f5 100644
--- a/protocols/oscar/icq.c
+++ b/protocols/oscar/icq.c
@@ -13,13 +13,15 @@ int aim_icq_reqofflinemsgs(aim_session_t *sess)
aim_snacid_t snacid;
int bslen;
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015)))
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) {
return -EINVAL;
+ }
bslen = 2 + 4 + 2 + 2;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid);
@@ -45,13 +47,15 @@ int aim_icq_ackofflinemsgs(aim_session_t *sess)
aim_snacid_t snacid;
int bslen;
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015)))
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) {
return -EINVAL;
+ }
bslen = 2 + 4 + 2 + 2;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid);
@@ -72,82 +76,89 @@ int aim_icq_ackofflinemsgs(aim_session_t *sess)
int aim_icq_getallinfo(aim_session_t *sess, const char *uin)
{
- aim_conn_t *conn;
- aim_frame_t *fr;
- aim_snacid_t snacid;
- int bslen;
- struct aim_icq_info *info;
+ aim_conn_t *conn;
+ aim_frame_t *fr;
+ aim_snacid_t snacid;
+ int bslen;
+ struct aim_icq_info *info;
- if (!uin || uin[0] < '0' || uin[0] > '9')
- return -EINVAL;
+ if (!uin || uin[0] < '0' || uin[0] > '9') {
+ return -EINVAL;
+ }
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015)))
- return -EINVAL;
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) {
+ return -EINVAL;
+ }
- bslen = 2 + 4 + 2 + 2 + 2 + 4;
+ bslen = 2 + 4 + 2 + 2 + 2 + 4;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen)))
- return -ENOMEM;
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) {
+ return -ENOMEM;
+ }
- snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0);
- aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid);
+ snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0);
+ aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid);
- /* For simplicity, don't bother using a tlvlist */
- aimbs_put16(&fr->data, 0x0001);
- aimbs_put16(&fr->data, bslen);
+ /* For simplicity, don't bother using a tlvlist */
+ aimbs_put16(&fr->data, 0x0001);
+ aimbs_put16(&fr->data, bslen);
- aimbs_putle16(&fr->data, bslen - 2);
- aimbs_putle32(&fr->data, atoi(sess->sn));
- aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */
- aimbs_putle16(&fr->data, snacid); /* eh. */
- aimbs_putle16(&fr->data, 0x04b2); /* shrug. */
- aimbs_putle32(&fr->data, atoi(uin));
+ aimbs_putle16(&fr->data, bslen - 2);
+ aimbs_putle32(&fr->data, atoi(sess->sn));
+ aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */
+ aimbs_putle16(&fr->data, snacid); /* eh. */
+ aimbs_putle16(&fr->data, 0x04b2); /* shrug. */
+ aimbs_putle32(&fr->data, atoi(uin));
- aim_tx_enqueue(sess, fr);
+ aim_tx_enqueue(sess, fr);
- /* Keep track of this request and the ICQ number and request ID */
- info = g_new0(struct aim_icq_info, 1);
- info->reqid = snacid;
- info->uin = atoi(uin);
- info->next = sess->icq_info;
- sess->icq_info = info;
+ /* Keep track of this request and the ICQ number and request ID */
+ info = g_new0(struct aim_icq_info, 1);
+ info->reqid = snacid;
+ info->uin = atoi(uin);
+ info->next = sess->icq_info;
+ sess->icq_info = info;
- return 0;
+ return 0;
}
-static void aim_icq_freeinfo(struct aim_icq_info *info) {
- int i;
-
- if (!info)
- return;
- g_free(info->nick);
- g_free(info->first);
- g_free(info->last);
- g_free(info->email);
- g_free(info->homecity);
- g_free(info->homestate);
- g_free(info->homephone);
- g_free(info->homefax);
- g_free(info->homeaddr);
- g_free(info->mobile);
- g_free(info->homezip);
- g_free(info->personalwebpage);
- if (info->email2)
- for (i = 0; i < info->numaddresses; i++)
- g_free(info->email2[i]);
- g_free(info->email2);
- g_free(info->workcity);
- g_free(info->workstate);
- g_free(info->workphone);
- g_free(info->workfax);
- g_free(info->workaddr);
- g_free(info->workzip);
- g_free(info->workcompany);
- g_free(info->workdivision);
- g_free(info->workposition);
- g_free(info->workwebpage);
- g_free(info->info);
- g_free(info);
+static void aim_icq_freeinfo(struct aim_icq_info *info)
+{
+ int i;
+
+ if (!info) {
+ return;
+ }
+ g_free(info->nick);
+ g_free(info->first);
+ g_free(info->last);
+ g_free(info->email);
+ g_free(info->homecity);
+ g_free(info->homestate);
+ g_free(info->homephone);
+ g_free(info->homefax);
+ g_free(info->homeaddr);
+ g_free(info->mobile);
+ g_free(info->homezip);
+ g_free(info->personalwebpage);
+ if (info->email2) {
+ for (i = 0; i < info->numaddresses; i++) {
+ g_free(info->email2[i]);
+ }
+ }
+ g_free(info->email2);
+ g_free(info->workcity);
+ g_free(info->workstate);
+ g_free(info->workphone);
+ g_free(info->workfax);
+ g_free(info->workaddr);
+ g_free(info->workzip);
+ g_free(info->workcompany);
+ g_free(info->workdivision);
+ g_free(info->workposition);
+ g_free(info->workwebpage);
+ g_free(info->info);
+ g_free(info);
}
/**
@@ -191,16 +202,18 @@ static int icqresponse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
msglen = aimbs_getle16(&qbs);
msg.msg = aimbs_getstr(&qbs, msglen);
- if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG)))
+ if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG))) {
ret = userfunc(sess, rx, &msg);
+ }
g_free(msg.msg);
} else if (cmd == 0x0042) {
aim_rxcallback_t userfunc;
- if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE)))
+ if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE))) {
ret = userfunc(sess, rx);
+ }
} else if (cmd == 0x07da) { /* information */
guint16 subtype;
struct aim_icq_info *info;
@@ -210,7 +223,9 @@ static int icqresponse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
aim_bstream_advance(&qbs, 1); /* 0x0a */
/* find another data from the same request */
- for (info = sess->icq_info; info && (info->reqid != reqid); info = info->next);
+ for (info = sess->icq_info; info && (info->reqid != reqid); info = info->next) {
+ ;
+ }
if (!info) {
info = g_new0(struct aim_icq_info, 1);
@@ -220,115 +235,121 @@ static int icqresponse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
}
switch (subtype) {
- case 0x00a0: { /* hide ip status */
- /* nothing */
- } break;
- case 0x00aa: { /* password change status */
- /* nothing */
- } break;
- case 0x00c8: { /* general and "home" information */
- info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homecity = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homestate = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homephone = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homefax = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homeaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->mobile = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homezip = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->homecountry = aimbs_getle16(&qbs);
- /* 0x0a 00 02 00 */
- /* 1 byte timezone? */
- /* 1 byte hide email flag? */
- } break;
- case 0x00dc: { /* personal information */
- info->age = aimbs_getle8(&qbs);
- info->unknown = aimbs_getle8(&qbs);
- info->gender = aimbs_getle8(&qbs);
- info->personalwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->birthyear = aimbs_getle16(&qbs);
- info->birthmonth = aimbs_getle8(&qbs);
- info->birthday = aimbs_getle8(&qbs);
- info->language1 = aimbs_getle8(&qbs);
- info->language2 = aimbs_getle8(&qbs);
- info->language3 = aimbs_getle8(&qbs);
- /* 0x00 00 01 00 00 01 00 00 00 00 00 */
- } break;
- case 0x00d2: { /* work information */
- info->workcity = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workstate = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workphone = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workfax = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workzip = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workcountry = aimbs_getle16(&qbs);
- info->workcompany = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workdivision = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->workposition = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- aim_bstream_advance(&qbs, 2); /* 0x01 00 */
- info->workwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- } break;
- case 0x00e6: { /* additional personal information */
- info->info = aimbs_getstr(&qbs, aimbs_getle16(&qbs)-1);
- } break;
- case 0x00eb: { /* email address(es) */
- int i;
- info->numaddresses = aimbs_getle16(&qbs);
- info->email2 = g_new0(char *, info->numaddresses);
- for (i = 0; i < info->numaddresses; i++) {
- info->email2[i] = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- if (i+1 != info->numaddresses)
- aim_bstream_advance(&qbs, 1); /* 0x00 */
- }
- } break;
- case 0x00f0: { /* personal interests */
- } break;
- case 0x00fa: { /* past background and current organizations */
- } break;
- case 0x0104: { /* alias info */
- info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- aim_bstream_advance(&qbs, aimbs_getle16(&qbs));
- /* email address? */
- /* Then 0x00 02 00 */
- } break;
- case 0x010e: { /* unknown */
- /* 0x00 00 */
- } break;
-
- case 0x019a: { /* simple info */
- aim_bstream_advance(&qbs, 2);
- info->uin = aimbs_getle32(&qbs);
- info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
- /* Then 0x00 02 00 00 00 00 00 */
- } break;
+ case 0x00a0: { /* hide ip status */
+ /* nothing */
+ } break;
+ case 0x00aa: { /* password change status */
+ /* nothing */
+ } break;
+ case 0x00c8: { /* general and "home" information */
+ info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homecity = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homestate = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homephone = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homefax = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homeaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->mobile = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homezip = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->homecountry = aimbs_getle16(&qbs);
+ /* 0x0a 00 02 00 */
+ /* 1 byte timezone? */
+ /* 1 byte hide email flag? */
+ } break;
+ case 0x00dc: { /* personal information */
+ info->age = aimbs_getle8(&qbs);
+ info->unknown = aimbs_getle8(&qbs);
+ info->gender = aimbs_getle8(&qbs);
+ info->personalwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->birthyear = aimbs_getle16(&qbs);
+ info->birthmonth = aimbs_getle8(&qbs);
+ info->birthday = aimbs_getle8(&qbs);
+ info->language1 = aimbs_getle8(&qbs);
+ info->language2 = aimbs_getle8(&qbs);
+ info->language3 = aimbs_getle8(&qbs);
+ /* 0x00 00 01 00 00 01 00 00 00 00 00 */
+ } break;
+ case 0x00d2: { /* work information */
+ info->workcity = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workstate = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workphone = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workfax = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workzip = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workcountry = aimbs_getle16(&qbs);
+ info->workcompany = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workdivision = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->workposition = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ aim_bstream_advance(&qbs, 2); /* 0x01 00 */
+ info->workwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ } break;
+ case 0x00e6: { /* additional personal information */
+ info->info = aimbs_getstr(&qbs, aimbs_getle16(&qbs) - 1);
+ } break;
+ case 0x00eb: { /* email address(es) */
+ int i;
+ info->numaddresses = aimbs_getle16(&qbs);
+ info->email2 = g_new0(char *, info->numaddresses);
+ for (i = 0; i < info->numaddresses; i++) {
+ info->email2[i] = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ if (i + 1 != info->numaddresses) {
+ aim_bstream_advance(&qbs, 1); /* 0x00 */
+ }
+ }
+ } break;
+ case 0x00f0: { /* personal interests */
+ } break;
+ case 0x00fa: { /* past background and current organizations */
+ } break;
+ case 0x0104: { /* alias info */
+ info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ aim_bstream_advance(&qbs, aimbs_getle16(&qbs));
+ /* email address? */
+ /* Then 0x00 02 00 */
+ } break;
+ case 0x010e: { /* unknown */
+ /* 0x00 00 */
+ } break;
+
+ case 0x019a: { /* simple info */
+ aim_bstream_advance(&qbs, 2);
+ info->uin = aimbs_getle32(&qbs);
+ info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs));
+ /* Then 0x00 02 00 00 00 00 00 */
+ } break;
} /* End switch statement */
if (!(snac->flags & 0x0001)) {
- if (subtype != 0x0104)
- if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO)))
+ if (subtype != 0x0104) {
+ if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO))) {
ret = userfunc(sess, rx, info);
+ }
+ }
- /* Bitlbee - not supported, yet
+ /* Bitlbee - not supported, yet
if (info->uin && info->nick)
- if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS)))
- ret = userfunc(sess, rx, info);
+ if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS)))
+ ret = userfunc(sess, rx, info);
*/
if (sess->icq_info == info) {
sess->icq_info = info->next;
} else {
struct aim_icq_info *cur;
- for (cur=sess->icq_info; (cur->next && (cur->next!=info)); cur=cur->next);
- if (cur->next)
+ for (cur = sess->icq_info; (cur->next && (cur->next != info)); cur = cur->next) {
+ ;
+ }
+ if (cur->next) {
cur->next = cur->next->next;
+ }
}
aim_icq_freeinfo(info);
}
@@ -342,8 +363,9 @@ static int icqresponse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
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 == 0x0003)
+ if (snac->subtype == 0x0003) {
return icqresponse(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/icq.h b/protocols/oscar/icq.h
index 41b3efb9..009f5913 100644
--- a/protocols/oscar/icq.h
+++ b/protocols/oscar/icq.h
@@ -7,7 +7,7 @@
* SNAC Family: ICQ
*
* Most of these are actually special.
- */
+ */
#define AIM_CB_ICQ_ERROR 0x0001
#define AIM_CB_ICQ_OFFLINEMSG 0x00f0
#define AIM_CB_ICQ_OFFLINEMSGCOMPLETE 0x00f1
@@ -32,61 +32,61 @@ struct aim_icq_simpleinfo {
};
struct aim_icq_info {
- gushort reqid;
+ gushort reqid;
- /* simple */
- guint32 uin;
+ /* simple */
+ guint32 uin;
- /* general and "home" information (0x00c8) */
- char *nick;
- char *first;
- char *last;
- char *email;
- char *homecity;
- char *homestate;
- char *homephone;
- char *homefax;
- char *homeaddr;
- char *mobile;
- char *homezip;
- gushort homecountry;
+ /* general and "home" information (0x00c8) */
+ char *nick;
+ char *first;
+ char *last;
+ char *email;
+ char *homecity;
+ char *homestate;
+ char *homephone;
+ char *homefax;
+ char *homeaddr;
+ char *mobile;
+ char *homezip;
+ gushort homecountry;
/* guchar timezone;
guchar hideemail; */
- /* personal (0x00dc) */
- guchar age;
- guchar unknown;
- guchar gender;
- char *personalwebpage;
- gushort birthyear;
- guchar birthmonth;
- guchar birthday;
- guchar language1;
- guchar language2;
- guchar language3;
+ /* personal (0x00dc) */
+ guchar age;
+ guchar unknown;
+ guchar gender;
+ char *personalwebpage;
+ gushort birthyear;
+ guchar birthmonth;
+ guchar birthday;
+ guchar language1;
+ guchar language2;
+ guchar language3;
- /* work (0x00d2) */
- char *workcity;
- char *workstate;
- char *workphone;
- char *workfax;
- char *workaddr;
- char *workzip;
- gushort workcountry;
- char *workcompany;
- char *workdivision;
- char *workposition;
- char *workwebpage;
+ /* work (0x00d2) */
+ char *workcity;
+ char *workstate;
+ char *workphone;
+ char *workfax;
+ char *workaddr;
+ char *workzip;
+ gushort workcountry;
+ char *workcompany;
+ char *workdivision;
+ char *workposition;
+ char *workwebpage;
- /* additional personal information (0x00e6) */
- char *info;
+ /* additional personal information (0x00e6) */
+ char *info;
- /* email (0x00eb) */
- gushort numaddresses;
- char **email2;
+ /* email (0x00eb) */
+ gushort numaddresses;
+ char **email2;
- /* we keep track of these in a linked list because we're 1337 */
- struct aim_icq_info *next;
+ /* we keep track of these in a linked list because we're 1337 */
+ struct aim_icq_info *next;
};
diff --git a/protocols/oscar/im.c b/protocols/oscar/im.c
index 05e06e91..2ddf35ed 100644
--- a/protocols/oscar/im.c
+++ b/protocols/oscar/im.c
@@ -24,7 +24,7 @@
#include "info.h"
/*
- * Send an ICBM (instant message).
+ * Send an ICBM (instant message).
*
*
* Possible flags:
@@ -38,12 +38,12 @@
* this, you'd better be damn sure you know
* what you're doing.
* AIM_IMFLAGS_ISO_8859_1 -- The message contains the ASCII8 subset
- * known as ISO-8859-1.
+ * known as ISO-8859-1.
*
* Generally, you should use the lowest encoding possible to send
* your message. If you only use basic punctuation and the generic
* Latin alphabet, use ASCII7 (no flags). If you happen to use non-ASCII7
- * characters, but they are all clearly defined in ISO-8859-1, then
+ * characters, but they are all clearly defined in ISO-8859-1, then
* use that. Keep in mind that not all characters in the PC ASCII8
* character set are defined in the ISO standard. For those cases (most
* notably when the (r) symbol is used), you must use the full UNICODE
@@ -55,16 +55,16 @@
* I strongly discourage the use of UNICODE mode, mainly because none
* of the clients I use can parse those messages (and besides that,
* wchars are difficult and non-portable to handle in most UNIX environments).
- * If you really need to include special characters, use the HTML UNICODE
- * entities. These are of the form &#2026; where 2026 is the hex
- * representation of the UNICODE index (in this case, UNICODE
+ * If you really need to include special characters, use the HTML UNICODE
+ * entities. These are of the form &#2026; where 2026 is the hex
+ * representation of the UNICODE index (in this case, UNICODE
* "Horizontal Ellipsis", or 133 in in ASCII8).
*
* Implementation note: Since this is one of the most-used functions
* in all of libfaim, it is written with performance in mind. As such,
* it is not as clear as it could be in respect to how this message is
- * supposed to be layed out. Most obviously, tlvlists should be used
- * instead of writing out the bytes manually.
+ * supposed to be layed out. Most obviously, tlvlists should be used
+ * instead of writing out the bytes manually.
*
* XXX more precise verification that we never send SNACs larger than 8192
* XXX check SNAC size for multipart
@@ -80,30 +80,36 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) {
return -EINVAL;
+ }
- if (!args)
+ if (!args) {
return -EINVAL;
+ }
if (args->flags & AIM_IMFLAGS_MULTIPART) {
- if (args->mpmsg->numparts <= 0)
+ if (args->mpmsg->numparts <= 0) {
return -EINVAL;
+ }
} else {
- if (!args->msg || (args->msglen <= 0))
+ if (!args->msg || (args->msglen <= 0)) {
return -EINVAL;
+ }
- if (args->msglen >= MAXMSGLEN)
+ if (args->msglen >= MAXMSGLEN) {
return -E2BIG;
+ }
}
/* Painfully calculate the size of the message TLV */
msgtlvlen = 1 + 1; /* 0501 */
- if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES)
+ if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) {
msgtlvlen += 2 + args->featureslen;
- else
+ } else {
msgtlvlen += 2 + sizeof(deffeatures);
+ }
if (args->flags & AIM_IMFLAGS_MULTIPART) {
aim_mpmsg_section_t *sec;
@@ -119,24 +125,26 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
}
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, msgtlvlen+128)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, msgtlvlen + 128))) {
return -ENOMEM;
+ }
- /* XXX should be optional */
- snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1);
+ /* XXX should be optional */
+ snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn) + 1);
aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
- /*
- * Generate a random message cookie
+ /*
+ * Generate a random message cookie
*
- * We could cache these like we do SNAC IDs. (In fact, it
- * might be a good idea.) In the message error functions,
- * the 8byte message cookie is returned as well as the
+ * We could cache these like we do SNAC IDs. (In fact, it
+ * might be a good idea.) In the message error functions,
+ * the 8byte message cookie is returned as well as the
* SNAC ID.
*
*/
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++) {
aimbs_put8(&fr->data, (guint8) rand());
+ }
/*
* Channel ID
@@ -147,7 +155,7 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
* Destination SN (prepended with byte length)
*/
aimbs_put8(&fr->data, strlen(args->destsn));
- aimbs_putraw(&fr->data, (guint8 *)args->destsn, strlen(args->destsn));
+ aimbs_putraw(&fr->data, (guint8 *) args->destsn, strlen(args->destsn));
/*
* Message TLV (type 2).
@@ -156,7 +164,7 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
aimbs_put16(&fr->data, msgtlvlen);
/*
- * Features
+ * Features
*
*/
aimbs_put8(&fr->data, 0x05);
@@ -185,7 +193,7 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
aimbs_put16(&fr->data, 0x0101);
- /*
+ /*
* Message block length.
*/
aimbs_put16(&fr->data, args->msglen + 0x04);
@@ -199,12 +207,13 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
aimbs_put16(&fr->data, args->charsubset);
} else {
- if (args->flags & AIM_IMFLAGS_UNICODE)
+ if (args->flags & AIM_IMFLAGS_UNICODE) {
aimbs_put16(&fr->data, 0x0002);
- else if (args->flags & AIM_IMFLAGS_ISO_8859_1)
+ } else if (args->flags & AIM_IMFLAGS_ISO_8859_1) {
aimbs_put16(&fr->data, 0x0003);
- else
+ } else {
aimbs_put16(&fr->data, 0x0000);
+ }
aimbs_put16(&fr->data, 0x0000);
}
@@ -212,11 +221,11 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
/*
* Message. Not terminated.
*/
- aimbs_putraw(&fr->data, (guint8 *)args->msg, args->msglen);
+ aimbs_putraw(&fr->data, (guint8 *) args->msg, args->msglen);
}
/*
- * Set the Request Acknowledge flag.
+ * Set the Request Acknowledge flag.
*/
if (args->flags & AIM_IMFLAGS_ACK) {
aimbs_put16(&fr->data, 0x0003);
@@ -258,14 +267,15 @@ int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
aim_tx_enqueue(sess, fr);
- if (!(sess->flags & AIM_SESS_FLAGS_DONTTIMEOUTONICBM))
+ if (!(sess->flags & AIM_SESS_FLAGS_DONTTIMEOUTONICBM)) {
aim_cleansnacs(sess, 60); /* clean out SNACs over 60sec old */
+ }
return 0;
}
/*
- * Simple wrapper for aim_send_im_ext()
+ * Simple wrapper for aim_send_im_ext()
*
* You cannot use aim_send_im if you need the HASICON flag. You must
* use aim_send_im_ext directly for that.
@@ -299,64 +309,66 @@ int aim_send_im(aim_session_t *sess, const char *destsn, guint16 flags, const ch
* @return 0 if no error
*/
int aim_send_im_ch2_statusmessage(aim_session_t *sess, const char *sender, const guint8 *cookie,
- const char *message, const guint8 state, const guint16 dc)
+ const char *message, const guint8 state, const guint16 dc)
{
- aim_conn_t *conn;
- aim_frame_t *fr;
- aim_snacid_t snacid;
-
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
- return -EINVAL;
-
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02,
- 10+8+2+1+strlen(sender)+2+0x1d+0x10+9+strlen(message)+1)))
- return -ENOMEM;
-
- snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0);
- aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid);
-
- aimbs_putraw(&fr->data, cookie, 8);
-
- aimbs_put16(&fr->data, 0x0002); /* channel */
- aimbs_put8(&fr->data, strlen(sender));
- aimbs_putraw(&fr->data, (guint8 *)sender, strlen(sender));
-
- aimbs_put16(&fr->data, 0x0003); /* reason: channel specific */
-
- aimbs_putle16(&fr->data, 0x001b); /* length of data SEQ1 */
- aimbs_putle16(&fr->data, 0x0008); /* protocol version */
-
- aimbs_putle32(&fr->data, 0x0000); /* no plugin -> 16 times 0x00 */
- aimbs_putle32(&fr->data, 0x0000);
- aimbs_putle32(&fr->data, 0x0000);
- aimbs_putle32(&fr->data, 0x0000);
-
- aimbs_putle16(&fr->data, 0x0000); /* unknown */
- aimbs_putle32(&fr->data, 0x0003); /* client features */
- aimbs_putle8(&fr->data, 0x00); /* unknown */
- aimbs_putle16(&fr->data, dc); /* Sequence number? XXX - This should decrement by 1 with each request */
- /* end of SEQ1 */
-
- aimbs_putle16(&fr->data, 0x000e); /* Length of SEQ2 */
- aimbs_putle16(&fr->data, dc); /* Sequence number? same as above
- * XXX - This should decrement by 1 with each request */
- aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
- aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
- aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
- /* end of SEQ2 */
-
- /* now for the real fun */
- aimbs_putle8(&fr->data, state); /* away state */
- aimbs_putle8(&fr->data, 0x03); /* msg-flag: 03 for states */
- aimbs_putle16(&fr->data, 0x0000); /* status code ? */
- aimbs_putle16(&fr->data, 0x0000); /* priority code */
- aimbs_putle16(&fr->data, strlen(message) + 1); /* message length + termination */
- aimbs_putraw(&fr->data, (guint8 *) message, strlen(message) + 1); /* null terminated string */
-
- aim_tx_enqueue(sess, fr);
-
-
- return 0;
+ aim_conn_t *conn;
+ aim_frame_t *fr;
+ aim_snacid_t snacid;
+
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) {
+ return -EINVAL;
+ }
+
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02,
+ 10 + 8 + 2 + 1 + strlen(sender) + 2 + 0x1d + 0x10 + 9 + strlen(message) + 1))) {
+ return -ENOMEM;
+ }
+
+ snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0);
+ aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid);
+
+ aimbs_putraw(&fr->data, cookie, 8);
+
+ aimbs_put16(&fr->data, 0x0002); /* channel */
+ aimbs_put8(&fr->data, strlen(sender));
+ aimbs_putraw(&fr->data, (guint8 *) sender, strlen(sender));
+
+ aimbs_put16(&fr->data, 0x0003); /* reason: channel specific */
+
+ aimbs_putle16(&fr->data, 0x001b); /* length of data SEQ1 */
+ aimbs_putle16(&fr->data, 0x0008); /* protocol version */
+
+ aimbs_putle32(&fr->data, 0x0000); /* no plugin -> 16 times 0x00 */
+ aimbs_putle32(&fr->data, 0x0000);
+ aimbs_putle32(&fr->data, 0x0000);
+ aimbs_putle32(&fr->data, 0x0000);
+
+ aimbs_putle16(&fr->data, 0x0000); /* unknown */
+ aimbs_putle32(&fr->data, 0x0003); /* client features */
+ aimbs_putle8(&fr->data, 0x00); /* unknown */
+ aimbs_putle16(&fr->data, dc); /* Sequence number? XXX - This should decrement by 1 with each request */
+ /* end of SEQ1 */
+
+ aimbs_putle16(&fr->data, 0x000e); /* Length of SEQ2 */
+ aimbs_putle16(&fr->data, dc); /* Sequence number? same as above
+ * XXX - This should decrement by 1 with each request */
+ aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
+ aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
+ aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
+ /* end of SEQ2 */
+
+ /* now for the real fun */
+ aimbs_putle8(&fr->data, state); /* away state */
+ aimbs_putle8(&fr->data, 0x03); /* msg-flag: 03 for states */
+ aimbs_putle16(&fr->data, 0x0000); /* status code ? */
+ aimbs_putle16(&fr->data, 0x0000); /* priority code */
+ aimbs_putle16(&fr->data, strlen(message) + 1); /* message length + termination */
+ aimbs_putraw(&fr->data, (guint8 *) message, strlen(message) + 1); /* null terminated string */
+
+ aim_tx_enqueue(sess, fr);
+
+
+ return 0;
}
@@ -374,8 +386,9 @@ static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
aim_tlv_t *msgblock;
/* ICBM Cookie. */
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++) {
aimbs_get8(bs);
+ }
/* Channel ID */
channel = aimbs_get16(bs);
@@ -390,10 +403,12 @@ static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
tlvlist = aim_readtlvchain(bs);
- if (aim_gettlv(tlvlist, 0x0003, 1))
+ if (aim_gettlv(tlvlist, 0x0003, 1)) {
icbmflags |= AIM_IMFLAGS_ACK;
- if (aim_gettlv(tlvlist, 0x0004, 1))
+ }
+ if (aim_gettlv(tlvlist, 0x0004, 1)) {
icbmflags |= AIM_IMFLAGS_AWAY;
+ }
if ((msgblock = aim_gettlv(tlvlist, 0x0002, 1))) {
aim_bstream_t mbs;
@@ -403,8 +418,9 @@ static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
aimbs_get8(&mbs);
aimbs_get8(&mbs);
- for (featurelen = aimbs_get16(&mbs); featurelen; featurelen--)
+ for (featurelen = aimbs_get16(&mbs); featurelen; featurelen--) {
aimbs_get8(&mbs);
+ }
aimbs_get8(&mbs);
aimbs_get8(&mbs);
@@ -416,8 +432,9 @@ static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
msg = aimbs_getstr(&mbs, msglen);
}
- 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, channel, sn, msg, icbmflags, flag1, flag2);
+ }
g_free(sn);
aim_freetlvchain(&tlvlist);
@@ -429,13 +446,13 @@ static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
* Ahh, the joys of nearly ridiculous over-engineering.
*
* Not only do AIM ICBM's support multiple channels. Not only do they
- * support multiple character sets. But they support multiple character
+ * support multiple character sets. But they support multiple character
* sets / encodings within the same ICBM.
*
* These multipart messages allow for complex space savings techniques, which
* seem utterly unnecessary by today's standards. In fact, there is only
* one client still in popular use that still uses this method: AOL for the
- * Macintosh, Version 5.0. Obscure, yes, I know.
+ * Macintosh, Version 5.0. Obscure, yes, I know.
*
* In modern (non-"legacy") clients, if the user tries to send a character
* that is not ISO-8859-1 or ASCII, the client will send the entire message
@@ -443,7 +460,7 @@ static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
* full 16 bit UNICODE field, even if the high order byte would be zero.
* Multipart messages prevent this wasted space by allowing the client to
* only send the characters in UNICODE that need to be sent that way, and
- * the rest of the message can be sent in whatever the native character
+ * the rest of the message can be sent in whatever the native character
* set is (probably ASCII).
*
* An important note is that sections will be displayed in the order that
@@ -470,12 +487,14 @@ int aim_mpmsg_init(aim_session_t *sess, aim_mpmsg_t *mpm)
return 0;
}
-static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, guint16 charset, guint16 charsubset, guint8 *data, guint16 datalen)
+static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, guint16 charset, guint16 charsubset, guint8 *data,
+ guint16 datalen)
{
- aim_mpmsg_section_t *sec;
-
- if (!(sec = g_new0(aim_mpmsg_section_t,1)))
+ aim_mpmsg_section_t *sec;
+
+ if (!(sec = g_new0(aim_mpmsg_section_t, 1))) {
return -1;
+ }
sec->charset = charset;
sec->charsubset = charsubset;
@@ -483,13 +502,14 @@ static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, guint16 chars
sec->datalen = datalen;
sec->next = NULL;
- if (!mpm->parts)
+ if (!mpm->parts) {
mpm->parts = sec;
- else {
+ } else {
aim_mpmsg_section_t *cur;
- for (cur = mpm->parts; cur->next; cur = cur->next)
+ for (cur = mpm->parts; cur->next; cur = cur->next) {
;
+ }
cur->next = sec;
}
@@ -504,13 +524,13 @@ void aim_mpmsg_free(aim_session_t *sess, aim_mpmsg_t *mpm)
for (cur = mpm->parts; cur; ) {
aim_mpmsg_section_t *tmp;
-
+
tmp = cur->next;
g_free(cur->data);
g_free(cur);
cur = tmp;
}
-
+
mpm->numparts = 0;
mpm->parts = NULL;
@@ -518,7 +538,7 @@ void aim_mpmsg_free(aim_session_t *sess, aim_mpmsg_t *mpm)
}
/*
- * Start by building the multipart structures, then pick the first
+ * Start by building the multipart structures, then pick the first
* human-readable section and stuff it into args->msg so no one gets
* suspicious.
*
@@ -568,7 +588,7 @@ static int incomingim_ch1_parsemsgs(aim_session_t *sess, guint8 *data, int len,
*
*/
msgbuf = aimbs_getstr(&mbs, msglen);
- mpmsg_addsection(sess, &args->mpmsg, flag1, flag2, (guint8 *)msgbuf, (guint16) msglen);
+ mpmsg_addsection(sess, &args->mpmsg, flag1, flag2, (guint8 *) msgbuf, (guint16) msglen);
} /* while */
@@ -589,8 +609,9 @@ static int incomingim_ch1_parsemsgs(aim_session_t *sess, guint8 *data, int len,
for (i = 0; i < charsetpricount; i++) {
for (sec = args->mpmsg.parts; sec; sec = sec->next) {
- if (sec->charset != charsetpri[i])
+ if (sec->charset != charsetpri[i]) {
continue;
+ }
/* Great. We found one. Fill it in. */
args->charset = sec->charset;
@@ -598,35 +619,38 @@ static int incomingim_ch1_parsemsgs(aim_session_t *sess, guint8 *data, int len,
args->icbmflags |= AIM_IMFLAGS_CUSTOMCHARSET;
/* Set up the simple flags */
- if (args->charset == 0x0000)
+ if (args->charset == 0x0000) {
; /* ASCII */
- else if (args->charset == 0x0002)
+ } else if (args->charset == 0x0002) {
args->icbmflags |= AIM_IMFLAGS_UNICODE;
- else if (args->charset == 0x0003)
+ } else if (args->charset == 0x0003) {
args->icbmflags |= AIM_IMFLAGS_ISO_8859_1;
- else if (args->charset == 0xffff)
+ } else if (args->charset == 0xffff) {
; /* no encoding (yeep!) */
- if (args->charsubset == 0x0000)
+ }
+ if (args->charsubset == 0x0000) {
; /* standard subencoding? */
- else if (args->charsubset == 0x000b)
+ } else if (args->charsubset == 0x000b) {
args->icbmflags |= AIM_IMFLAGS_SUBENC_MACINTOSH;
- else if (args->charsubset == 0xffff)
+ } else if (args->charsubset == 0xffff) {
; /* no subencoding */
+ }
#if 0
- /* XXX this isn't really necesary... */
- if ( ((args.flag1 != 0x0000) &&
- (args.flag1 != 0x0002) &&
- (args.flag1 != 0x0003) &&
- (args.flag1 != 0xffff)) ||
- ((args.flag2 != 0x0000) &&
- (args.flag2 != 0x000b) &&
- (args.flag2 != 0xffff))) {
- faimdprintf(sess, 0, "icbm: **warning: encoding flags are being used! {%04x, %04x}\n", args.flag1, args.flag2);
+ /* XXX this isn't really necesary... */
+ if (((args.flag1 != 0x0000) &&
+ (args.flag1 != 0x0002) &&
+ (args.flag1 != 0x0003) &&
+ (args.flag1 != 0xffff)) ||
+ ((args.flag2 != 0x0000) &&
+ (args.flag2 != 0x000b) &&
+ (args.flag2 != 0xffff))) {
+ faimdprintf(sess, 0, "icbm: **warning: encoding flags are being used! {%04x, %04x}\n",
+ args.flag1, args.flag2);
}
#endif
- args->msg = (char *)sec->data;
+ args->msg = (char *) sec->data;
args->msglen = sec->datalen;
return 0;
@@ -641,7 +665,8 @@ static int incomingim_ch1_parsemsgs(aim_session_t *sess, guint8 *data, int len,
return 0;
}
-static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, guint16 channel, aim_userinfo_t *userinfo, aim_bstream_t *bs, guint8 *cookie)
+static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, guint16 channel,
+ aim_userinfo_t *userinfo, aim_bstream_t *bs, guint8 *cookie)
{
guint16 type, length;
aim_rxcallback_t userfunc;
@@ -689,7 +714,8 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
* The rest of the TLV contains one or more message
* blocks...
*/
- incomingim_ch1_parsemsgs(sess, bs->data + bs->offset /* XXX evil!!! */, length - 2 - 2 - args.featureslen, &args);
+ incomingim_ch1_parsemsgs(sess, bs->data + bs->offset /* XXX evil!!! */,
+ length - 2 - 2 - args.featureslen, &args);
} else if (type == 0x0003) { /* Server Ack Requested */
@@ -719,10 +745,11 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
*
* You really shouldn't advertise a zero-length icon
* anyway.
- *
+ *
*/
- if (args.iconlen)
+ if (args.iconlen) {
args.icbmflags |= AIM_IMFLAGS_HASICON;
+ }
} else if (type == 0x0009) {
@@ -749,8 +776,9 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
}
- 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, channel, userinfo, &args);
+ }
aim_mpmsg_free(sess, &args.mpmsg);
g_free(args.extdata);
@@ -768,16 +796,18 @@ static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_
return;
}
-static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
+static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
{
/*
* Chat room info.
*/
- if (servdata)
+ if (servdata) {
aim_chat_readroominfo(servdata, &args->info.chat.roominfo);
+ }
- args->destructor = (void *)incomingim_ch2_chat_free;
+ args->destructor = (void *) incomingim_ch2_chat_free;
return;
}
@@ -785,13 +815,13 @@ static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_fram
static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
{
- g_free((char *)args->info.rtfmsg.rtfmsg);
+ g_free((char *) args->info.rtfmsg.rtfmsg);
return;
}
/*
- * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is
+ * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is
* kind of odd. This sends the client ICQRTF since that is all that I've seen
* SERVERRELAY used for.
*
@@ -800,79 +830,84 @@ static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_i
* This cap is used for auto status message replies, too [ft]
*
*/
-static void incomingim_ch2_icqserverrelay(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
+static void incomingim_ch2_icqserverrelay(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args,
+ aim_bstream_t *servdata)
{
guint16 hdrlen, msglen, dc;
guint8 msgtype;
- guint8 *plugin;
- int i = 0, tmp = 0;
- struct im_connection *ic = sess->aux_data;
+ guint8 *plugin;
+ int i = 0, tmp = 0;
+ struct im_connection *ic = sess->aux_data;
- /* at the moment we just can deal with requests, not with cancel or accept */
- if (args->status != 0) return;
+ /* at the moment we just can deal with requests, not with cancel or accept */
+ if (args->status != 0) {
+ return;
+ }
hdrlen = aimbs_getle16(servdata);
- aim_bstream_advance(servdata, 0x02); /* protocol version */
- plugin = aimbs_getraw(servdata, 0x10); /* following data is a message or
- something plugin specific */
- /* as there is no plugin handling, just skip the rest */
- aim_bstream_advance(servdata, hdrlen - 0x12);
+ aim_bstream_advance(servdata, 0x02); /* protocol version */
+ plugin = aimbs_getraw(servdata, 0x10); /* following data is a message or
+ something plugin specific */
+ /* as there is no plugin handling, just skip the rest */
+ aim_bstream_advance(servdata, hdrlen - 0x12);
hdrlen = aimbs_getle16(servdata);
- dc = aimbs_getle16(servdata); /* save the sequence number */
+ dc = aimbs_getle16(servdata); /* save the sequence number */
aim_bstream_advance(servdata, hdrlen - 0x02);
- /* TODO is it a message or something for a plugin? */
- for (i = 0; i < 0x10; i++) {
- tmp |= plugin[i];
- }
+ /* TODO is it a message or something for a plugin? */
+ for (i = 0; i < 0x10; i++) {
+ tmp |= plugin[i];
+ }
- if (!tmp) { /* message follows */
+ if (!tmp) { /* message follows */
- msgtype = aimbs_getle8(servdata);
- aimbs_getle8(servdata); /* msgflags */
+ msgtype = aimbs_getle8(servdata);
+ aimbs_getle8(servdata); /* msgflags */
- aim_bstream_advance(servdata, 0x04); /* status code and priority code */
+ aim_bstream_advance(servdata, 0x04); /* status code and priority code */
- msglen = aimbs_getle16(servdata); /* message string length */
- args->info.rtfmsg.rtfmsg = aimbs_getstr(servdata, msglen);
+ msglen = aimbs_getle16(servdata); /* message string length */
+ args->info.rtfmsg.rtfmsg = aimbs_getstr(servdata, msglen);
- switch(msgtype) {
- case AIM_MTYPE_PLAIN:
+ switch (msgtype) {
+ case AIM_MTYPE_PLAIN:
- args->info.rtfmsg.fgcolor = aimbs_getle32(servdata);
- args->info.rtfmsg.bgcolor = aimbs_getle32(servdata);
+ args->info.rtfmsg.fgcolor = aimbs_getle32(servdata);
+ args->info.rtfmsg.bgcolor = aimbs_getle32(servdata);
- hdrlen = aimbs_getle32(servdata);
- aim_bstream_advance(servdata, hdrlen);
+ hdrlen = aimbs_getle32(servdata);
+ aim_bstream_advance(servdata, hdrlen);
- /* XXX This is such a hack. */
- args->reqclass = AIM_CAPS_ICQRTF;
- break;
+ /* XXX This is such a hack. */
+ args->reqclass = AIM_CAPS_ICQRTF;
+ break;
- case AIM_MTYPE_AUTOAWAY:
- case AIM_MTYPE_AUTOBUSY:
- case AIM_MTYPE_AUTONA:
- case AIM_MTYPE_AUTODND:
- case AIM_MTYPE_AUTOFFC:
- case 0x9c: /* ICQ 5 seems to send this */
- aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie,
- ic->away ? ic->away : "", sess->aim_icq_state, dc);
- break;
+ case AIM_MTYPE_AUTOAWAY:
+ case AIM_MTYPE_AUTOBUSY:
+ case AIM_MTYPE_AUTONA:
+ case AIM_MTYPE_AUTODND:
+ case AIM_MTYPE_AUTOFFC:
+ case 0x9c: /* ICQ 5 seems to send this */
+ aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie,
+ ic->away ? ic->away : "", sess->aim_icq_state, dc);
+ break;
- }
- } /* message or plugin specific */
+ }
+ } /* message or plugin specific */
- g_free(plugin);
- args->destructor = (void *)incomingim_ch2_icqserverrelay_free;
+ g_free(plugin);
+ args->destructor = (void *) incomingim_ch2_icqserverrelay_free;
return;
}
typedef void (*ch2_args_destructor_t)(aim_session_t *sess, struct aim_incomingim_ch2_args *args);
-static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, guint16 channel, aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, guint8 *cookie)
+static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, guint16 channel,
+ aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, guint8 *cookie)
{
aim_rxcallback_t userfunc;
aim_tlv_t *block1, *servdatatlv;
@@ -882,14 +917,14 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
guint8 *cookie2;
int ret = 0;
- char clientip1[30] = {""};
- char clientip2[30] = {""};
- char verifiedip[30] = {""};
+ char clientip1[30] = { "" };
+ char clientip2[30] = { "" };
+ char verifiedip[30] = { "" };
memset(&args, 0, sizeof(args));
/*
- * There's another block of TLVs embedded in the type 5 here.
+ * There's another block of TLVs embedded in the type 5 here.
*/
block1 = aim_gettlv(tlvlist, 0x0005, 1);
aim_bstream_init(&bbs, block1->value, block1->length);
@@ -898,15 +933,16 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
* First two bytes represent the status of the connection.
*
* 0 is a request, 1 is a deny (?), 2 is an accept
- */
+ */
args.status = aimbs_get16(&bbs);
/*
* Next comes the cookie. Should match the ICBM cookie.
*/
cookie2 = aimbs_getraw(&bbs, 8);
- if (memcmp(cookie, cookie2, 8) != 0)
+ if (memcmp(cookie, cookie2, 8) != 0) {
imcb_error(sess->aux_data, "rend: warning cookies don't match!");
+ }
memcpy(args.cookie, cookie2, 8);
g_free(cookie2);
@@ -916,7 +952,7 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
*/
args.reqclass = aim_getcap(sess, &bbs, 0x10);
- /*
+ /*
* What follows may be TLVs or nothing, depending on the
* purpose of the message.
*
@@ -933,10 +969,10 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
iptlv = aim_gettlv(list2, 0x0002, 1);
g_snprintf(clientip1, sizeof(clientip1), "%d.%d.%d.%d",
- aimutil_get8(iptlv->value+0),
- aimutil_get8(iptlv->value+1),
- aimutil_get8(iptlv->value+2),
- aimutil_get8(iptlv->value+3));
+ aimutil_get8(iptlv->value + 0),
+ aimutil_get8(iptlv->value + 1),
+ aimutil_get8(iptlv->value + 2),
+ aimutil_get8(iptlv->value + 3));
}
/*
@@ -948,10 +984,10 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
iptlv = aim_gettlv(list2, 0x0003, 1);
g_snprintf(clientip2, sizeof(clientip2), "%d.%d.%d.%d",
- aimutil_get8(iptlv->value+0),
- aimutil_get8(iptlv->value+1),
- aimutil_get8(iptlv->value+2),
- aimutil_get8(iptlv->value+3));
+ aimutil_get8(iptlv->value + 0),
+ aimutil_get8(iptlv->value + 1),
+ aimutil_get8(iptlv->value + 2),
+ aimutil_get8(iptlv->value + 3));
}
/*
@@ -965,56 +1001,66 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
iptlv = aim_gettlv(list2, 0x0004, 1);
g_snprintf(verifiedip, sizeof(verifiedip), "%d.%d.%d.%d",
- aimutil_get8(iptlv->value+0),
- aimutil_get8(iptlv->value+1),
- aimutil_get8(iptlv->value+2),
- aimutil_get8(iptlv->value+3));
+ aimutil_get8(iptlv->value + 0),
+ aimutil_get8(iptlv->value + 1),
+ aimutil_get8(iptlv->value + 2),
+ aimutil_get8(iptlv->value + 3));
}
/*
* Port number for something.
*/
- if (aim_gettlv(list2, 0x0005, 1))
+ if (aim_gettlv(list2, 0x0005, 1)) {
args.port = aim_gettlv16(list2, 0x0005, 1);
+ }
/*
* Error code.
*/
- if (aim_gettlv(list2, 0x000b, 1))
+ if (aim_gettlv(list2, 0x000b, 1)) {
args.errorcode = aim_gettlv16(list2, 0x000b, 1);
+ }
/*
* Invitation message / chat description.
*/
- if (aim_gettlv(list2, 0x000c, 1))
+ if (aim_gettlv(list2, 0x000c, 1)) {
args.msg = aim_gettlv_str(list2, 0x000c, 1);
+ }
/*
* Character set.
*/
- if (aim_gettlv(list2, 0x000d, 1))
+ if (aim_gettlv(list2, 0x000d, 1)) {
args.encoding = aim_gettlv_str(list2, 0x000d, 1);
-
+ }
+
/*
* Language.
*/
- if (aim_gettlv(list2, 0x000e, 1))
+ if (aim_gettlv(list2, 0x000e, 1)) {
args.language = aim_gettlv_str(list2, 0x000e, 1);
+ }
/* Unknown -- two bytes = 0x0001 */
- if (aim_gettlv(list2, 0x000a, 1))
+ if (aim_gettlv(list2, 0x000a, 1)) {
;
+ }
/* Unknown -- no value */
- if (aim_gettlv(list2, 0x000f, 1))
+ if (aim_gettlv(list2, 0x000f, 1)) {
;
+ }
- if (strlen(clientip1))
- args.clientip = (char *)clientip1;
- if (strlen(clientip2))
- args.clientip2 = (char *)clientip2;
- if (strlen(verifiedip))
- args.verifiedip = (char *)verifiedip;
+ if (strlen(clientip1)) {
+ args.clientip = (char *) clientip1;
+ }
+ if (strlen(clientip2)) {
+ args.clientip2 = (char *) clientip2;
+ }
+ if (strlen(verifiedip)) {
+ args.verifiedip = (char *) verifiedip;
+ }
/*
* This is must be present in PROPOSALs, but will probably not
@@ -1028,29 +1074,33 @@ static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
sdbsptr = &sdbs;
}
- if (args.reqclass & AIM_CAPS_ICQSERVERRELAY)
+ if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) {
incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr);
- else if (args.reqclass & AIM_CAPS_CHAT)
+ } else if (args.reqclass & AIM_CAPS_CHAT) {
incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr);
+ }
- 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, channel, userinfo, &args);
+ }
- if (args.destructor)
- ((ch2_args_destructor_t)args.destructor)(sess, &args);
+ if (args.destructor) {
+ ((ch2_args_destructor_t) args.destructor)(sess, &args);
+ }
- g_free((char *)args.msg);
- g_free((char *)args.encoding);
- g_free((char *)args.language);
+ g_free((char *) args.msg);
+ g_free((char *) args.encoding);
+ g_free((char *) args.language);
aim_freetlvchain(&list2);
return ret;
}
-static int incomingim_ch4(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, guint16 channel, aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, guint8 *cookie)
+static int incomingim_ch4(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, guint16 channel,
+ aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, guint8 *cookie)
{
aim_bstream_t meat;
aim_rxcallback_t userfunc;
@@ -1061,16 +1111,18 @@ static int incomingim_ch4(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
/*
* Make a bstream for the meaty part. Yum. Meat.
*/
- if (!(block = aim_gettlv(tlvlist, 0x0005, 1)))
+ if (!(block = aim_gettlv(tlvlist, 0x0005, 1))) {
return -1;
+ }
aim_bstream_init(&meat, block->value, block->length);
args.uin = aimbs_getle32(&meat);
args.type = aimbs_getle16(&meat);
- args.msg = (char *)aimbs_getraw(&meat, aimbs_getle16(&meat));
+ args.msg = (char *) aimbs_getraw(&meat, aimbs_getle16(&meat));
- 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, channel, userinfo, &args);
+ }
g_free(args.msg);
@@ -1100,22 +1152,23 @@ static int incomingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
/*
* Read ICBM Cookie. And throw away.
*/
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++) {
cookie[i] = aimbs_get8(bs);
+ }
/*
* Channel ID.
*
- * Channel 0x0001 is the message channel. There are
+ * Channel 0x0001 is the message channel. There are
* other channels for things called "rendevous"
* which represent chat and some of the other new
- * features of AIM2/3/3.5.
+ * features of AIM2/3/3.5.
*
* Channel 0x0002 is the Rendevous channel, which
* is where Chat Invitiations and various client-client
* connection negotiations come from.
*
- * Channel 0x0004 is used for ICQ authorization, or
+ * Channel 0x0004 is used for ICQ authorization, or
* possibly any system notice.
*
*/
@@ -1130,12 +1183,12 @@ static int incomingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
* information, the rest are not even though there is no seperation.
* aim_extractuserinfo() returns the number of bytes used by the
* userinfo tlvs, so you can start reading the rest of them right
- * afterward.
+ * afterward.
*
* That also means that TLV types can be duplicated between the
* userinfo block and the rest of the message, however there should
* never be two TLVs of the same type in one block.
- *
+ *
*/
aim_extractuserinfo(sess, bs, &userinfo);
@@ -1154,7 +1207,7 @@ static int incomingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
aim_tlvlist_t *tlvlist;
/*
- * Read block of TLVs (not including the userinfo data). All
+ * Read block of TLVs (not including the userinfo data). All
* further data is derived from what is parsed here.
*/
tlvlist = aim_readtlvchain(bs);
@@ -1190,8 +1243,9 @@ int aim_reqicbmparams(aim_session_t *sess)
{
aim_conn_t *conn;
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) {
return -EINVAL;
+ }
return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
}
@@ -1200,7 +1254,7 @@ int aim_reqicbmparams(aim_session_t *sess)
*
* I definitly recommend sending this. If you don't, you'll be stuck
* with the rather unreasonable defaults. You don't want those. Send this.
- *
+ *
*/
int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params)
{
@@ -1208,14 +1262,17 @@ int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params)
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) {
return -EINVAL;
+ }
- if (!params)
+ if (!params) {
return -EINVAL;
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+16)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 16))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x0004, 0x0002, 0x0000, snacid);
@@ -1224,10 +1281,10 @@ int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params)
aimbs_put16(&fr->data, 0x0000);
/* These are all read-write */
- aimbs_put32(&fr->data, params->flags);
+ aimbs_put32(&fr->data, params->flags);
aimbs_put16(&fr->data, params->maxmsglen);
- aimbs_put16(&fr->data, params->maxsenderwarn);
- aimbs_put16(&fr->data, params->maxrecverwarn);
+ aimbs_put16(&fr->data, params->maxsenderwarn);
+ aimbs_put16(&fr->data, params->maxrecverwarn);
aimbs_put32(&fr->data, params->minmsginterval);
aim_tx_enqueue(sess, fr);
@@ -1246,9 +1303,10 @@ static int paraminfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, ai
params.maxsenderwarn = aimbs_get16(bs);
params.maxrecverwarn = aimbs_get16(bs);
params.minmsginterval = aimbs_get32(bs);
-
- 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, &params);
+ }
return 0;
}
@@ -1260,25 +1318,27 @@ static int missedcall(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
guint16 channel, nummissed, reason;
aim_userinfo_t userinfo;
- while (aim_bstream_empty(bs)) {
+ while (aim_bstream_empty(bs)) {
channel = aimbs_get16(bs);
aim_extractuserinfo(sess, bs, &userinfo);
nummissed = aimbs_get16(bs);
reason = aimbs_get16(bs);
- if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
- ret = userfunc(sess, rx, channel, &userinfo, nummissed, reason);
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
+ ret = userfunc(sess, rx, channel, &userinfo, nummissed, reason);
+ }
}
return ret;
}
/*
- * Receive the response from an ICQ status message request. This contains the
+ * Receive the response from an ICQ status message request. This contains the
* ICQ status message. Go figure.
*/
-static int clientautoresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
+static int clientautoresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs)
{
int ret = 0;
aim_rxcallback_t userfunc;
@@ -1293,56 +1353,58 @@ static int clientautoresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
reason = aimbs_get16(bs);
switch (reason) {
- case 0x0003: { /* ICQ status message. Maybe other stuff too, you never know with these people. */
- guint8 statusmsgtype, *msg;
- guint16 len;
- guint32 state;
-
- len = aimbs_getle16(bs); /* Should be 0x001b */
- aim_bstream_advance(bs, len); /* Unknown */
-
- len = aimbs_getle16(bs); /* Should be 0x000e */
- aim_bstream_advance(bs, len); /* Unknown */
-
- statusmsgtype = aimbs_getle8(bs);
- switch (statusmsgtype) {
- case 0xe8:
- state = AIM_ICQ_STATE_AWAY;
- break;
- case 0xe9:
- state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY;
- break;
- case 0xea:
- state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_OUT;
- break;
- case 0xeb:
- state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY;
- break;
- case 0xec:
- state = AIM_ICQ_STATE_CHAT;
- break;
- default:
- state = 0;
- break;
- }
+ case 0x0003: { /* ICQ status message. Maybe other stuff too, you never know with these people. */
+ guint8 statusmsgtype, *msg;
+ guint16 len;
+ guint32 state;
+
+ len = aimbs_getle16(bs); /* Should be 0x001b */
+ aim_bstream_advance(bs, len); /* Unknown */
+
+ len = aimbs_getle16(bs); /* Should be 0x000e */
+ aim_bstream_advance(bs, len); /* Unknown */
+
+ statusmsgtype = aimbs_getle8(bs);
+ switch (statusmsgtype) {
+ case 0xe8:
+ state = AIM_ICQ_STATE_AWAY;
+ break;
+ case 0xe9:
+ state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY;
+ break;
+ case 0xea:
+ state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_OUT;
+ break;
+ case 0xeb:
+ state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY;
+ break;
+ case 0xec:
+ state = AIM_ICQ_STATE_CHAT;
+ break;
+ default:
+ state = 0;
+ break;
+ }
- aimbs_getle8(bs); /* Unknown - 0x03 Maybe this means this is an auto-reply */
- aimbs_getle16(bs); /* Unknown - 0x0000 */
- aimbs_getle16(bs); /* Unknown - 0x0000 */
+ aimbs_getle8(bs); /* Unknown - 0x03 Maybe this means this is an auto-reply */
+ aimbs_getle16(bs); /* Unknown - 0x0000 */
+ aimbs_getle16(bs); /* Unknown - 0x0000 */
- len = aimbs_getle16(bs);
- msg = aimbs_getraw(bs, len);
+ len = aimbs_getle16(bs);
+ msg = aimbs_getraw(bs, len);
- if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
- ret = userfunc(sess, rx, channel, sn, reason, state, msg);
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
+ ret = userfunc(sess, rx, channel, sn, reason, state, msg);
+ }
- g_free(msg);
- } break;
+ g_free(msg);
+ } break;
- default: {
- if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
- ret = userfunc(sess, rx, channel, sn, reason);
- } break;
+ default: {
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
+ ret = userfunc(sess, rx, channel, sn, reason);
+ }
+ } break;
} /* end switch */
g_free(ck);
@@ -1364,8 +1426,9 @@ static int msgack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
snlen = aimbs_get8(bs);
sn = aimbs_getstr(bs, snlen);
- 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, type, sn);
+ }
g_free(sn);
g_free(ck);
@@ -1376,7 +1439,7 @@ static int msgack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
/*
* Subtype 0x0014 - Send a mini typing notification (mtn) packet.
*
- * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
+ * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
* and Gaim 0.60 and newer.
*
*/
@@ -1386,14 +1449,17 @@ int aim_im_sendmtn(aim_session_t *sess, guint16 type1, const char *sn, guint16 t
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002)))
+ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002))) {
return -EINVAL;
+ }
- if (!sn)
+ if (!sn) {
return -EINVAL;
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+11+strlen(sn)+2)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11 + strlen(sn) + 2))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0004, 0x0014, 0x0000, NULL, 0);
aim_putsnac(&fr->data, 0x0004, 0x0014, 0x0000, snacid);
@@ -1416,7 +1482,7 @@ int aim_im_sendmtn(aim_session_t *sess, guint16 type1, const char *sn, guint16 t
* Dest sn
*/
aimbs_put8(&fr->data, strlen(sn));
- aimbs_putraw(&fr->data, (const guint8*)sn, strlen(sn));
+ aimbs_putraw(&fr->data, (const guint8 *) sn, strlen(sn));
/*
* Type 2 (should be 0x0000, 0x0001, or 0x0002 for mtn)
@@ -1431,7 +1497,7 @@ int aim_im_sendmtn(aim_session_t *sess, guint16 type1, const char *sn, guint16 t
/*
* Subtype 0x0014 - Receive a mini typing notification (mtn) packet.
*
- * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
+ * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
* and Gaim 0.60 and newer.
*
*/
@@ -1449,8 +1515,9 @@ static int mtn_receive(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
sn = aimbs_getstr(bs, snlen);
type2 = aimbs_get16(bs);
- 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, type1, sn, type2);
+ }
g_free(sn);
@@ -1460,20 +1527,21 @@ static int mtn_receive(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
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 == 0x0005)
+ if (snac->subtype == 0x0005) {
return paraminfo(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0006)
+ } else if (snac->subtype == 0x0006) {
return outgoingim(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0007)
+ } else if (snac->subtype == 0x0007) {
return incomingim(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x000a)
+ } else if (snac->subtype == 0x000a) {
return missedcall(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x000b)
+ } else if (snac->subtype == 0x000b) {
return clientautoresp(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x000c)
+ } else if (snac->subtype == 0x000c) {
return msgack(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0014)
+ } else if (snac->subtype == 0x0014) {
return mtn_receive(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/im.h b/protocols/oscar/im.h
index 34d5e238..54c68acd 100644
--- a/protocols/oscar/im.h
+++ b/protocols/oscar/im.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Messaging Services.
- */
+ */
#define AIM_CB_MSG_ERROR 0x0001
#define AIM_CB_MSG_PARAMINFO 0x0005
#define AIM_CB_MSG_INCOMING 0x0007
@@ -16,18 +16,18 @@
#define AIM_CB_MSG_MTN 0x0014
#define AIM_CB_MSG_DEFAULT 0xffff
-#define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
-#define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
-#define AIM_IMFLAGS_UNICODE 0x0004
-#define AIM_IMFLAGS_ISO_8859_1 0x0008
-#define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
-#define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
-#define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */
-#define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */
-#define AIM_IMFLAGS_EXTDATA 0x0100
-#define AIM_IMFLAGS_CUSTOMCHARSET 0x0200 /* charset fields set */
-#define AIM_IMFLAGS_MULTIPART 0x0400 /* ->mpmsg section valid */
-#define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */
+#define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
+#define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
+#define AIM_IMFLAGS_UNICODE 0x0004
+#define AIM_IMFLAGS_ISO_8859_1 0x0008
+#define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
+#define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
+#define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */
+#define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */
+#define AIM_IMFLAGS_EXTDATA 0x0100
+#define AIM_IMFLAGS_CUSTOMCHARSET 0x0200 /* charset fields set */
+#define AIM_IMFLAGS_MULTIPART 0x0400 /* ->mpmsg section valid */
+#define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */
/*
* Multipart message structures.
@@ -83,7 +83,7 @@ struct aim_sendimext_args {
/*
* This information is provided in the Incoming ICBM callback for
- * Channel 1 ICBM's.
+ * Channel 1 ICBM's.
*
* Note that although CUSTOMFEATURES and CUSTOMCHARSET say they
* are optional, both are always set by the current libfaim code.
@@ -99,7 +99,7 @@ struct aim_incomingim_ch1_args {
/* Always provided */
aim_mpmsg_t mpmsg;
guint32 icbmflags; /* some flags apply only to ->msg, not all mpmsg */
-
+
/* Only provided if message has a human-readable section */
char *msg;
int msglen;
@@ -178,6 +178,7 @@ aim_conn_t *aim_directim_initiate(aim_session_t *, const char *destsn);
aim_conn_t *aim_directim_connect(aim_session_t *, const char *sn, const char *addr, const guint8 *cookie);
int aim_im_sendmtn(aim_session_t *sess, guint16 type1, const char *sn, guint16 type2);
-int aim_send_im_ch2_statusmessage(aim_session_t *sess, const char *sender, const guint8 *cookie, const char *message, const guint8 state, const guint16 dc);
+int aim_send_im_ch2_statusmessage(aim_session_t *sess, const char *sender, const guint8 *cookie, const char *message,
+ const guint8 state, const guint16 dc);
#endif /* __OSCAR_IM_H__ */
diff --git a/protocols/oscar/info.c b/protocols/oscar/info.c
index a5a65147..6a929fc0 100644
--- a/protocols/oscar/info.c
+++ b/protocols/oscar/info.c
@@ -2,7 +2,7 @@
* aim_info.c
*
* The functions here are responsible for requesting and parsing information-
- * gathering SNACs. Or something like that.
+ * gathering SNACs. Or something like that.
*
*/
@@ -10,7 +10,7 @@
#include "info.h"
struct aim_priv_inforeq {
- char sn[MAXSNLEN+1];
+ char sn[MAXSNLEN + 1];
guint16 infotype;
};
@@ -20,20 +20,22 @@ int aim_getinfo(aim_session_t *sess, aim_conn_t *conn, const char *sn, guint16 i
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!sess || !conn || !sn)
+ if (!sess || !conn || !sn) {
return -EINVAL;
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12+1+strlen(sn))))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12 + 1 + strlen(sn)))) {
return -ENOMEM;
+ }
strncpy(privdata.sn, sn, sizeof(privdata.sn));
privdata.infotype = infotype;
snacid = aim_cachesnac(sess, 0x0002, 0x0005, 0x0000, &privdata, sizeof(struct aim_priv_inforeq));
-
+
aim_putsnac(&fr->data, 0x0002, 0x0005, 0x0000, snacid);
aimbs_put16(&fr->data, infotype);
aimbs_put8(&fr->data, strlen(sn));
- aimbs_putraw(&fr->data, (guint8 *)sn, strlen(sn));
+ aimbs_putraw(&fr->data, (guint8 *) sn, strlen(sn));
aim_tx_enqueue(sess, fr);
@@ -41,7 +43,7 @@ int aim_getinfo(aim_session_t *sess, aim_conn_t *conn, const char *sn, guint16 i
}
/*
- * Capability blocks.
+ * Capability blocks.
*
* These are CLSIDs. They should actually be of the form:
*
@@ -58,111 +60,111 @@ static const struct {
/*
* Chat is oddball.
*/
- {AIM_CAPS_CHAT,
- {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
+ { AIM_CAPS_CHAT,
+ { 0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
/*
* These are mostly in order.
*/
- {AIM_CAPS_VOICE,
- {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
+ { AIM_CAPS_VOICE,
+ { 0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
- {AIM_CAPS_SENDFILE,
- {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
+ { AIM_CAPS_SENDFILE,
+ { 0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
/*
* Advertised by the EveryBuddy client.
*/
- {AIM_CAPS_ICQ,
- {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_IMIMAGE,
- {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_BUDDYICON,
- {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_SAVESTOCKS,
- {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_GETFILE,
- {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- /*
- * Client supports channel 2 extended, TLV(0x2711) based messages.
- * Currently used only by ICQ clients. ICQ clients and clones use this GUID
- * as message format sign. Trillian client use another GUID in channel 2
- * messages to implement its own message format (trillian doesn't use
- * TLV(x2711) in SecureIM channel 2 messages!).
- */
- {AIM_CAPS_ICQSERVERRELAY,
- {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
+ { AIM_CAPS_ICQ,
+ { 0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_IMIMAGE,
+ { 0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_BUDDYICON,
+ { 0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_SAVESTOCKS,
+ { 0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_GETFILE,
+ { 0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ /*
+ * Client supports channel 2 extended, TLV(0x2711) based messages.
+ * Currently used only by ICQ clients. ICQ clients and clones use this GUID
+ * as message format sign. Trillian client use another GUID in channel 2
+ * messages to implement its own message format (trillian doesn't use
+ * TLV(x2711) in SecureIM channel 2 messages!).
+ */
+ { AIM_CAPS_ICQSERVERRELAY,
+ { 0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
/*
- * Indeed, there are two of these. The former appears to be correct,
- * but in some versions of winaim, the second one is set. Either they
- * forgot to fix endianness, or they made a typo. It really doesn't
+ * Indeed, there are two of these. The former appears to be correct,
+ * but in some versions of winaim, the second one is set. Either they
+ * forgot to fix endianness, or they made a typo. It really doesn't
* matter which.
*/
- {AIM_CAPS_GAMES,
- {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
- {AIM_CAPS_GAMES2,
- {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
- 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_SENDBUDDYLIST,
- {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_UTF8,
- {0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_ICQRTF,
- {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
- 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}},
-
- {AIM_CAPS_ICQUNKNOWN,
- {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
- 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}},
-
- {AIM_CAPS_EMPTY,
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
-
- {AIM_CAPS_TRILLIANCRYPT,
- {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
- 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}},
-
- {AIM_CAPS_APINFO,
- {0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6,
- 0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}},
-
- {AIM_CAPS_INTEROP,
- {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_ICHAT,
- {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
- 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
-
- {AIM_CAPS_LAST}
+ { AIM_CAPS_GAMES,
+ { 0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+ { AIM_CAPS_GAMES2,
+ { 0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_SENDBUDDYLIST,
+ { 0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_UTF8,
+ { 0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_ICQRTF,
+ { 0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
+ 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92 } },
+
+ { AIM_CAPS_ICQUNKNOWN,
+ { 0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
+ 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf } },
+
+ { AIM_CAPS_EMPTY,
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
+
+ { AIM_CAPS_TRILLIANCRYPT,
+ { 0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
+ 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00 } },
+
+ { AIM_CAPS_APINFO,
+ { 0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6,
+ 0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B } },
+
+ { AIM_CAPS_INTEROP,
+ { 0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_ICHAT,
+ { 0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
+ 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
+
+ { AIM_CAPS_LAST }
};
/*
* This still takes a length parameter even with a bstream because capabilities
* are not naturally bounded.
- *
+ *
*/
guint32 aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len)
{
@@ -189,12 +191,12 @@ guint32 aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len)
/*FIXME*/
/*REMOVEME :-)
g_strdup_printf("unknown capability: {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
- cap[0], cap[1], cap[2], cap[3],
- cap[4], cap[5],
- cap[6], cap[7],
- cap[8], cap[9],
- cap[10], cap[11], cap[12], cap[13],
- cap[14], cap[15]);
+ cap[0], cap[1], cap[2], cap[3],
+ cap[4], cap[5],
+ cap[6], cap[7],
+ cap[8], cap[9],
+ cap[10], cap[11], cap[12], cap[13],
+ cap[14], cap[15]);
*/
}
@@ -208,16 +210,19 @@ int aim_putcap(aim_bstream_t *bs, guint32 caps)
{
int i;
- if (!bs)
+ if (!bs) {
return -EINVAL;
+ }
for (i = 0; aim_bstream_empty(bs); i++) {
- if (aim_caps[i].flag == AIM_CAPS_LAST)
+ if (aim_caps[i].flag == AIM_CAPS_LAST) {
break;
+ }
- if (caps & aim_caps[i].flag)
+ if (caps & aim_caps[i].flag) {
aimbs_putraw(bs, aim_caps[i].data, 0x10);
+ }
}
@@ -225,7 +230,7 @@ int aim_putcap(aim_bstream_t *bs, guint32 caps)
}
/*
- * AIM is fairly regular about providing user info. This is a generic
+ * AIM is fairly regular about providing user info. This is a generic
* routine to extract it in its standard form.
*/
int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo)
@@ -233,18 +238,19 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
int curtlv, tlvcnt;
guint8 snlen;
- if (!bs || !outinfo)
+ if (!bs || !outinfo) {
return -EINVAL;
+ }
/* Clear out old data first */
memset(outinfo, 0x00, sizeof(aim_userinfo_t));
/*
- * Screen name. Stored as an unterminated string prepended with a
+ * Screen name. Stored as an unterminated string prepended with a
* byte containing its length.
*/
snlen = aimbs_get8(bs);
- aimbs_getrawbuf(bs, (guint8 *)outinfo->sn, snlen);
+ aimbs_getrawbuf(bs, (guint8 *) outinfo->sn, snlen);
/*
* Warning Level. Stored as an unsigned short.
@@ -252,12 +258,12 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
outinfo->warnlevel = aimbs_get16(bs);
/*
- * TLV Count. Unsigned short representing the number of
+ * TLV Count. Unsigned short representing the number of
* Type-Length-Value triples that follow.
*/
tlvcnt = aimbs_get16(bs);
- /*
+ /*
* Parse out the Type-Length-Value triples as they're found.
*/
for (curtlv = 0; curtlv < tlvcnt; curtlv++) {
@@ -272,13 +278,13 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
if (type == 0x0001) {
/*
* Type = 0x0001: User flags
- *
+ *
* Specified as any of the following ORed together:
* 0x0001 Trial (user less than 60days)
* 0x0002 Unknown bit 2
* 0x0004 AOL Main Service user
* 0x0008 Unknown bit 4
- * 0x0010 Free (AIM) user
+ * 0x0010 Free (AIM) user
* 0x0020 Away
* 0x0400 ActiveBuddy
*
@@ -288,7 +294,7 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
} else if (type == 0x0002) {
/*
- * Type = 0x0002: Member-Since date.
+ * Type = 0x0002: Member-Since date.
*
* The time/date that the user originally registered for
* the service, stored in time_t format.
@@ -300,7 +306,7 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
/*
* Type = 0x0003: On-Since date.
*
- * The time/date that the user started their current
+ * The time/date that the user started their current
* session, stored in time_t format.
*/
outinfo->onlinesince = aimbs_get32(bs);
@@ -310,11 +316,11 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
/*
* Type = 0x0004: Idle time.
*
- * Number of seconds since the user actively used the
+ * Number of seconds since the user actively used the
* service.
*
* Note that the client tells the server when to start
- * counting idle times, so this may or may not be
+ * counting idle times, so this may or may not be
* related to reality.
*/
outinfo->idletime = aimbs_get16(bs);
@@ -324,7 +330,7 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
/*
* Type = 0x0006: ICQ Online Status
*
- * ICQ's Away/DND/etc "enriched" status. Some decoding
+ * ICQ's Away/DND/etc "enriched" status. Some decoding
* of values done by Scott <darkagl@pcnet.com>
*/
aimbs_get16(bs);
@@ -342,7 +348,7 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
outinfo->present |= AIM_USERINFO_PRESENT_ICQIPADDR;
} else if (type == 0x000c) {
- /*
+ /*
* Type = 0x000c
*
* random crap containing the IP address,
@@ -378,7 +384,7 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
* Type = 0x000f: Session Length. (AIM)
* Type = 0x0010: Session Length. (AOL)
*
- * The duration, in seconds, of the user's current
+ * The duration, in seconds, of the user's current
* session.
*
* Which TLV type this comes in depends on the
@@ -392,7 +398,7 @@ int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *
/*
* Reaching here indicates that either AOL has
- * added yet another TLV for us to deal with,
+ * added yet another TLV for us to deal with,
* or the parsing has gone Terribly Wrong.
*
* Either way, inform the owner and attempt
@@ -428,11 +434,13 @@ static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_m
tlvlist = aim_readtlvchain(bs);
- if (aim_gettlv(tlvlist, 0x0001, 1))
+ if (aim_gettlv(tlvlist, 0x0001, 1)) {
maxsiglen = aim_gettlv16(tlvlist, 0x0001, 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, maxsiglen);
+ }
aim_freetlvchain(&tlvlist);
@@ -458,11 +466,11 @@ static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
return 0;
}
- inforeq = (struct aim_priv_inforeq *)origsnac->data;
+ inforeq = (struct aim_priv_inforeq *) origsnac->data;
if ((inforeq->infotype != AIM_GETINFO_GENERALINFO) &&
- (inforeq->infotype != AIM_GETINFO_AWAYMESSAGE) &&
- (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) {
+ (inforeq->infotype != AIM_GETINFO_AWAYMESSAGE) &&
+ (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) {
imcb_error(sess->aux_data, "unknown infotype in request!");
return 0;
}
@@ -471,7 +479,7 @@ static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
tlvlist = aim_readtlvchain(bs);
- /*
+ /*
* Depending on what informational text was requested, different
* TLVs will appear here.
*
@@ -480,14 +488,14 @@ static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
*/
if (inforeq->infotype == AIM_GETINFO_GENERALINFO) {
text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1);
- if((tlv = aim_gettlv(tlvlist, 0x0002, 1))) {
+ if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) {
text = g_new0(char, tlv->length);
memcpy(text, tlv->value, tlv->length);
text_length = tlv->length;
}
} else if (inforeq->infotype == AIM_GETINFO_AWAYMESSAGE) {
text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1);
- if((tlv = aim_gettlv(tlvlist, 0x0004, 1))) {
+ if ((tlv = aim_gettlv(tlvlist, 0x0004, 1))) {
text = g_new0(char, tlv->length);
memcpy(text, tlv->value, tlv->length);
text_length = tlv->length;
@@ -505,16 +513,18 @@ static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
}
}
- 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, &userinfo, inforeq->infotype, text_encoding, text, text_length);
+ }
g_free(text_encoding);
g_free(text);
aim_freetlvchain(&tlvlist);
- if (origsnac)
+ if (origsnac) {
g_free(origsnac->data);
+ }
g_free(origsnac);
return ret;
@@ -523,10 +533,11 @@ static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
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 == 0x0003)
+ if (snac->subtype == 0x0003) {
return rights(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0006)
+ } else if (snac->subtype == 0x0006) {
return userinfo(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/info.h b/protocols/oscar/info.h
index 5651f187..4ccd1fb7 100644
--- a/protocols/oscar/info.h
+++ b/protocols/oscar/info.h
@@ -5,7 +5,7 @@
/*
* SNAC Family: Location Services.
- */
+ */
#define AIM_CB_LOC_ERROR 0x0001
#define AIM_CB_LOC_REQRIGHTS 0x0002
#define AIM_CB_LOC_RIGHTSINFO 0x0003
@@ -28,8 +28,8 @@
#define AIM_CAPS_GAMES2 0x00000200
#define AIM_CAPS_ICQ 0x00000400
#define AIM_CAPS_APINFO 0x00000800
-#define AIM_CAPS_ICQRTF 0x00001000
-#define AIM_CAPS_EMPTY 0x00002000
+#define AIM_CAPS_ICQRTF 0x00001000
+#define AIM_CAPS_EMPTY 0x00002000
#define AIM_CAPS_ICQSERVERRELAY 0x00004000
#define AIM_CAPS_ICQUNKNOWN 0x00008000
#define AIM_CAPS_TRILLIANCRYPT 0x00010000
diff --git a/protocols/oscar/misc.c b/protocols/oscar/misc.c
index 950cd852..6d55e7fc 100644
--- a/protocols/oscar/misc.c
+++ b/protocols/oscar/misc.c
@@ -6,30 +6,30 @@
*
* Other things...
*
- * - Idle setting
- *
+ * - Idle setting
+ *
*
*/
-#include <aim.h>
+#include <aim.h>
-/*
+/*
* aim_bos_setprofile(profile)
*
* Gives BOS your profile.
- *
+ *
*/
int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, guint32 caps)
{
- static const char defencoding[] = {"text/aolrtf; charset=\"utf-8\""};
+ static const char defencoding[] = { "text/aolrtf; charset=\"utf-8\"" };
aim_frame_t *fr;
aim_tlvlist_t *tl = NULL;
aim_snacid_t snacid;
/* Build to packet first to get real length */
if (profile) {
- aim_addtlvtochain_raw(&tl, 0x0001, strlen(defencoding), (guint8 *)defencoding);
- aim_addtlvtochain_raw(&tl, 0x0002, strlen(profile), (guint8 *)profile);
+ aim_addtlvtochain_raw(&tl, 0x0001, strlen(defencoding), (guint8 *) defencoding);
+ aim_addtlvtochain_raw(&tl, 0x0002, strlen(profile), (guint8 *) profile);
}
/*
@@ -42,19 +42,21 @@ int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profil
*/
if (awaymsg) {
if (strlen(awaymsg)) {
- aim_addtlvtochain_raw(&tl, 0x0003, strlen(defencoding), (guint8 *)defencoding);
- aim_addtlvtochain_raw(&tl, 0x0004, strlen(awaymsg), (guint8 *)awaymsg);
- } else
+ aim_addtlvtochain_raw(&tl, 0x0003, strlen(defencoding), (guint8 *) defencoding);
+ aim_addtlvtochain_raw(&tl, 0x0004, strlen(awaymsg), (guint8 *) awaymsg);
+ } else {
aim_addtlvtochain_noval(&tl, 0x0004);
+ }
}
aim_addtlvtochain_caps(&tl, 0x0005, caps);
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl))))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl)))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, 0x0002, 0x0004, 0x0000, NULL, 0);
-
+
aim_putsnac(&fr->data, 0x0002, 0x004, 0x0000, snacid);
aim_writetlvchain(&fr->data, &tl);
aim_freetlvchain(&tl);
@@ -92,8 +94,9 @@ int aim_genericreq_n(aim_session_t *sess, aim_conn_t *conn, guint16 family, guin
aim_frame_t *fr;
aim_snacid_t snacid = 0x00000000;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10))) {
return -ENOMEM;
+ }
aim_putsnac(&fr->data, family, subtype, 0x0000, snacid);
@@ -107,8 +110,9 @@ int aim_genericreq_n_snacid(aim_session_t *sess, aim_conn_t *conn, guint16 famil
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
aim_putsnac(&fr->data, family, subtype, 0x0000, snacid);
@@ -123,11 +127,13 @@ int aim_genericreq_l(aim_session_t *sess, aim_conn_t *conn, guint16 family, guin
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!longdata)
+ if (!longdata) {
return aim_genericreq_n(sess, conn, family, subtype);
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4)))
- return -ENOMEM;
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4))) {
+ return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
@@ -144,11 +150,13 @@ int aim_genericreq_s(aim_session_t *sess, aim_conn_t *conn, guint16 family, guin
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!shortdata)
+ if (!shortdata) {
return aim_genericreq_n(sess, conn, family, subtype);
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2)))
- return -ENOMEM;
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 2))) {
+ return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
@@ -184,14 +192,17 @@ static int generror(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
snac2 = aim_remsnac(sess, snac->id);
- if (aim_bstream_empty(bs))
+ if (aim_bstream_empty(bs)) {
error = aimbs_get16(bs);
+ }
- 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, error, snac2 ? snac2->data : NULL);
+ }
- if (snac2)
+ if (snac2) {
g_free(snac2->data);
+ }
g_free(snac2);
return ret;
@@ -200,13 +211,14 @@ static int generror(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
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 == 0x0001)
+ if (snac->subtype == 0x0001) {
return generror(sess, mod, rx, snac, bs);
- else if ((snac->family == 0xffff) && (snac->subtype == 0xffff)) {
+ } else if ((snac->family == 0xffff) && (snac->subtype == 0xffff)) {
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;
diff --git a/protocols/oscar/msgcookie.c b/protocols/oscar/msgcookie.c
index efeb8cbf..1fcdd7c2 100644
--- a/protocols/oscar/msgcookie.c
+++ b/protocols/oscar/msgcookie.c
@@ -1,7 +1,7 @@
/*
* Cookie Caching stuff. Adam wrote this, apparently just some
* derivatives of n's SNAC work. I cleaned it up, added comments.
- *
+ *
*/
/*
@@ -25,24 +25,26 @@
*
* returns -1 on error, 0 on append, 1 on update. the cookie you pass
* in may be free'd, so don't count on its value after calling this!
- *
+ *
*/
int aim_cachecookie(aim_session_t *sess, aim_msgcookie_t *cookie)
{
aim_msgcookie_t *newcook;
- if (!sess || !cookie)
+ if (!sess || !cookie) {
return -EINVAL;
+ }
newcook = aim_checkcookie(sess, cookie->cookie, cookie->type);
-
+
if (newcook == cookie) {
newcook->addtime = time(NULL);
return 1;
- } else if (newcook)
+ } else if (newcook) {
aim_cookie_free(sess, newcook);
+ }
- cookie->addtime = time(NULL);
+ cookie->addtime = time(NULL);
cookie->next = sess->msgcookies;
sess->msgcookies = cookie;
@@ -64,12 +66,13 @@ aim_msgcookie_t *aim_uncachecookie(aim_session_t *sess, guint8 *cookie, int type
{
aim_msgcookie_t *cur, **prev;
- if (!cookie || !sess->msgcookies)
+ if (!cookie || !sess->msgcookies) {
return NULL;
+ }
for (prev = &sess->msgcookies; (cur = *prev); ) {
- if ((cur->type == type) &&
- (memcmp(cur->cookie, cookie, 8) == 0)) {
+ if ((cur->type == type) &&
+ (memcmp(cur->cookie, cookie, 8) == 0)) {
*prev = cur->next;
return cur;
}
@@ -89,15 +92,17 @@ aim_msgcookie_t *aim_uncachecookie(aim_session_t *sess, guint8 *cookie, int type
* success.
*
*/
-aim_msgcookie_t *aim_mkcookie(guint8 *c, int type, void *data)
+aim_msgcookie_t *aim_mkcookie(guint8 *c, int type, void *data)
{
aim_msgcookie_t *cookie;
- if (!c)
+ if (!c) {
return NULL;
+ }
- if (!(cookie = g_new0(aim_msgcookie_t,1)))
+ if (!(cookie = g_new0(aim_msgcookie_t, 1))) {
return NULL;
+ }
cookie->data = data;
cookie->type = type;
@@ -122,9 +127,10 @@ aim_msgcookie_t *aim_checkcookie(aim_session_t *sess, const guint8 *cookie, int
aim_msgcookie_t *cur;
for (cur = sess->msgcookies; cur; cur = cur->next) {
- if ((cur->type == type) &&
- (memcmp(cur->cookie, cookie, 8) == 0))
- return cur;
+ if ((cur->type == type) &&
+ (memcmp(cur->cookie, cookie, 8) == 0)) {
+ return cur;
+ }
}
return NULL;
@@ -143,22 +149,24 @@ aim_msgcookie_t *aim_checkcookie(aim_session_t *sess, const guint8 *cookie, int
* returns -1 on error, 0 on success.
*
*/
-int aim_cookie_free(aim_session_t *sess, aim_msgcookie_t *cookie)
+int aim_cookie_free(aim_session_t *sess, aim_msgcookie_t *cookie)
{
aim_msgcookie_t *cur, **prev;
- if (!sess || !cookie)
+ if (!sess || !cookie) {
return -EINVAL;
+ }
for (prev = &sess->msgcookies; (cur = *prev); ) {
- if (cur == cookie)
+ if (cur == cookie) {
*prev = cur->next;
- else
+ } else {
prev = &cur->next;
+ }
}
g_free(cookie->data);
g_free(cookie);
return 0;
-}
+}
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index 1c74e7a2..22244f6c 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -49,25 +49,25 @@
#define USEROPT_AUTH 0
#define USEROPT_AUTHPORT 1
-#define UC_AOL 0x02
-#define UC_ADMIN 0x04
-#define UC_UNCONFIRMED 0x08
-#define UC_NORMAL 0x10
-#define UC_AB 0x20
-#define UC_WIRELESS 0x40
+#define UC_AOL 0x02
+#define UC_ADMIN 0x04
+#define UC_UNCONFIRMED 0x08
+#define UC_NORMAL 0x10
+#define UC_AB 0x20
+#define UC_WIRELESS 0x40
#define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3"
#define OSCAR_GROUP "Friends"
#define BUF_LEN 2048
-#define BUF_LONG ( BUF_LEN * 2 )
+#define BUF_LONG (BUF_LEN * 2)
/* Don't know if support for UTF8 is really working. For now it's UTF16 here.
static int gaim_caps = AIM_CAPS_UTF8; */
static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT;
-static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02};
+static guint8 gaim_features[] = { 0x01, 0x01, 0x01, 0x02 };
struct oscar_data {
aim_session_t *sess;
@@ -93,7 +93,7 @@ struct oscar_data {
gboolean killme, no_reconnect;
gboolean icq;
GSList *evilhack;
-
+
GHashTable *ips;
struct {
@@ -138,13 +138,19 @@ struct icq_auth {
guint32 uin;
};
-static char *extract_name(const char *name) {
+static char *extract_name(const char *name)
+{
char *tmp;
int i, j;
char *x = strchr(name, '-');
- if (!x) return g_strdup(name);
+
+ if (!x) {
+ return g_strdup(name);
+ }
x = strchr(++x, '-');
- if (!x) return g_strdup(name);
+ if (!x) {
+ return g_strdup(name);
+ }
tmp = g_strdup(++x);
for (i = 0, j = 0; x[i]; i++) {
@@ -155,7 +161,7 @@ static char *extract_name(const char *name) {
}
strncpy(hex, x + ++i, 2); hex[2] = 0;
i++;
- tmp[j++] = (char)strtol(hex, NULL, 16);
+ tmp[j++] = (char) strtol(hex, NULL, 16);
}
tmp[j] = 0;
@@ -163,14 +169,16 @@ static char *extract_name(const char *name) {
}
static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic,
- aim_conn_t *conn) {
- GSList *g = ((struct oscar_data *)ic->proto_data)->oscar_chats;
+ aim_conn_t *conn)
+{
+ GSList *g = ((struct oscar_data *) ic->proto_data)->oscar_chats;
struct chat_connection *c = NULL;
while (g) {
- c = (struct chat_connection *)g->data;
- if (c->conn == conn)
+ c = (struct chat_connection *) g->data;
+ if (c->conn == conn) {
break;
+ }
g = g->next;
c = NULL;
}
@@ -178,41 +186,41 @@ static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic,
return c;
}
-static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_logout (aim_session_t *, aim_frame_t *, ...);
-static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_auth_resp(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_login(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_logout(aim_session_t *, aim_frame_t *, ...);
+static int gaim_handle_redirect(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_oncoming(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_offgoing(aim_session_t *, aim_frame_t *, ...);
static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...);
-static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...);
-static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...);
-static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...);
-static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_misses(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_motd(aim_session_t *, aim_frame_t *, ...);
+static int gaim_chatnav_info(aim_session_t *, aim_frame_t *, ...);
+static int gaim_chat_join(aim_session_t *, aim_frame_t *, ...);
+static int gaim_chat_leave(aim_session_t *, aim_frame_t *, ...);
+static int gaim_chat_info_update(aim_session_t *, aim_frame_t *, ...);
static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...);
-static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...);
-static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...);
-static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...);
-static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...);
-static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_ratechange(aim_session_t *, aim_frame_t *, ...);
+static int gaim_bosrights(aim_session_t *, aim_frame_t *, ...);
+static int conninitdone_bos(aim_session_t *, aim_frame_t *, ...);
+static int conninitdone_admin(aim_session_t *, aim_frame_t *, ...);
+static int conninitdone_chat(aim_session_t *, aim_frame_t *, ...);
+static int conninitdone_chatnav(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_msgerr(aim_session_t *, aim_frame_t *, ...);
static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...);
static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...);
-static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
-static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...);
-static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...);
-static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...);
-static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...);
-static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...);
-static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parsemtn (aim_session_t *, aim_frame_t *, ...);
-static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...);
-static int gaim_parseaiminfo (aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_locerr(aim_session_t *, aim_frame_t *, ...);
+static int gaim_icbm_param_info(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parse_genericerr(aim_session_t *, aim_frame_t *, ...);
+static int gaim_selfinfo(aim_session_t *, aim_frame_t *, ...);
+static int gaim_offlinemsg(aim_session_t *, aim_frame_t *, ...);
+static int gaim_offlinemsgdone(aim_session_t *, aim_frame_t *, ...);
+static int gaim_ssi_parserights(aim_session_t *, aim_frame_t *, ...);
+static int gaim_ssi_parselist(aim_session_t *, aim_frame_t *, ...);
+static int gaim_ssi_parseack(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parsemtn(aim_session_t *, aim_frame_t *, ...);
+static int gaim_icqinfo(aim_session_t *, aim_frame_t *, ...);
+static int gaim_parseaiminfo(aim_session_t *, aim_frame_t *, ...);
static char *msgerrreason[] = {
"Invalid error",
@@ -267,8 +275,9 @@ static char *normalize(const char *s)
}
static gboolean oscar_callback(gpointer data, gint source,
- b_input_condition condition) {
- aim_conn_t *conn = (aim_conn_t *)data;
+ b_input_condition condition)
+{
+ aim_conn_t *conn = (aim_conn_t *) data;
aim_session_t *sess = aim_conn_getsess(conn);
struct im_connection *ic = sess ? sess->aux_data : NULL;
struct oscar_data *odata;
@@ -277,50 +286,54 @@ static gboolean oscar_callback(gpointer data, gint source,
/* ic is null. we return, else we seg SIGSEG on next line. */
return FALSE;
}
-
+
if (!g_slist_find(get_connections(), ic)) {
- /* oh boy. this is probably bad. i guess the only thing we
+ /* oh boy. this is probably bad. i guess the only thing we
* can really do is return? */
return FALSE;
}
- odata = (struct oscar_data *)ic->proto_data;
+ odata = (struct oscar_data *) ic->proto_data;
if (condition & B_EV_IO_READ) {
if (aim_get_command(odata->sess, conn) >= 0) {
aim_rxdispatch(odata->sess);
- if (odata->killme)
- imc_logout(ic, !odata->no_reconnect);
+ if (odata->killme) {
+ imc_logout(ic, !odata->no_reconnect);
+ }
} else {
if ((conn->type == AIM_CONN_TYPE_BOS) ||
- !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
+ !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
imcb_error(ic, _("Disconnected."));
imc_logout(ic, TRUE);
} else if (conn->type == AIM_CONN_TYPE_CHAT) {
struct chat_connection *c = find_oscar_chat_by_conn(ic, conn);
c->conn = NULL;
- if (c->inpa > 0)
+ if (c->inpa > 0) {
b_event_remove(c->inpa);
+ }
c->inpa = 0;
c->fd = -1;
aim_conn_kill(odata->sess, &conn);
imcb_error(sess->aux_data, _("You have been disconnected from chat room %s."), c->name);
} else if (conn->type == AIM_CONN_TYPE_CHATNAV) {
- if (odata->cnpa > 0)
+ if (odata->cnpa > 0) {
b_event_remove(odata->cnpa);
+ }
odata->cnpa = 0;
while (odata->create_rooms) {
struct create_room *cr = odata->create_rooms->data;
g_free(cr->name);
odata->create_rooms =
- g_slist_remove(odata->create_rooms, cr);
+ g_slist_remove(odata->create_rooms, cr);
g_free(cr);
imcb_error(sess->aux_data, _("Chat is currently unavailable"));
}
aim_conn_kill(odata->sess, &conn);
} else if (conn->type == AIM_CONN_TYPE_AUTH) {
- if (odata->paspa > 0)
+ if (odata->paspa > 0) {
b_event_remove(odata->paspa);
+ }
odata->paspa = 0;
aim_conn_kill(odata->sess, &conn);
} else {
@@ -331,7 +344,7 @@ static gboolean oscar_callback(gpointer data, gint source,
/* WTF??? */
return FALSE;
}
-
+
return TRUE;
}
@@ -359,8 +372,8 @@ static gboolean oscar_login_connect(gpointer data, gint source, b_input_conditio
aim_conn_completeconnect(sess, conn);
ic->inpa = b_input_add(conn->fd, B_EV_IO_READ,
- oscar_callback, conn);
-
+ oscar_callback, conn);
+
return FALSE;
}
@@ -368,35 +381,37 @@ static void oscar_init(account_t *acc)
{
set_t *s;
gboolean icq = g_ascii_isdigit(acc->user[0]);
-
+
if (icq) {
set_add(&acc->set, "ignore_auth_requests", "false", set_eval_bool, acc);
set_add(&acc->set, "old_icq_auth", "false", set_eval_bool, acc);
}
-
+
s = set_add(&acc->set, "server",
icq ? AIM_DEFAULT_LOGIN_SERVER_ICQ
- : AIM_DEFAULT_LOGIN_SERVER_AIM, set_eval_account, acc);
+ : AIM_DEFAULT_LOGIN_SERVER_AIM, set_eval_account, acc);
s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
-
+
if (icq) {
s = set_add(&acc->set, "web_aware", "false", set_eval_bool, acc);
s->flags |= ACC_SET_OFFLINE_ONLY;
}
-
+
acc->flags |= ACC_FLAG_AWAY_MESSAGE;
}
-static void oscar_login(account_t *acc) {
+static void oscar_login(account_t *acc)
+{
aim_session_t *sess;
aim_conn_t *conn;
struct im_connection *ic = imcb_new(acc);
struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1);
- if (g_ascii_isdigit(acc->user[0]))
+ if (g_ascii_isdigit(acc->user[0])) {
odata->icq = TRUE;
- else
+ } else {
ic->flags |= OPT_DOES_HTML;
+ }
sess = g_new0(aim_session_t, 1);
@@ -414,7 +429,7 @@ static void oscar_login(account_t *acc) {
imc_logout(ic, TRUE);
return;
}
-
+
imcb_log(ic, _("Signon: %s"), ic->acc->user);
aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0);
@@ -431,13 +446,15 @@ static void oscar_login(account_t *acc) {
aim_request_login(sess, conn, ic->acc->user);
}
-static void oscar_logout(struct im_connection *ic) {
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
-
+static void oscar_logout(struct im_connection *ic)
+{
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
+
while (odata->oscar_chats) {
struct chat_connection *n = odata->oscar_chats->data;
- if (n->inpa > 0)
+ if (n->inpa > 0) {
b_event_remove(n->inpa);
+ }
g_free(n->name);
g_free(n->show);
odata->oscar_chats = g_slist_remove(odata->oscar_chats, n);
@@ -449,20 +466,27 @@ static void oscar_logout(struct im_connection *ic) {
odata->create_rooms = g_slist_remove(odata->create_rooms, cr);
g_free(cr);
}
- if (odata->ips)
+ if (odata->ips) {
g_hash_table_destroy(odata->ips);
- if (odata->email)
+ }
+ if (odata->email) {
g_free(odata->email);
- if (odata->newp)
+ }
+ if (odata->newp) {
g_free(odata->newp);
- if (odata->oldp)
+ }
+ if (odata->oldp) {
g_free(odata->oldp);
- if (ic->inpa > 0)
+ }
+ if (ic->inpa > 0) {
b_event_remove(ic->inpa);
- if (odata->cnpa > 0)
+ }
+ if (odata->cnpa > 0) {
b_event_remove(odata->cnpa);
- if (odata->paspa > 0)
+ }
+ if (odata->paspa > 0) {
b_event_remove(odata->paspa);
+ }
aim_session_kill(odata->sess);
g_free(odata->sess);
odata->sess = NULL;
@@ -470,7 +494,8 @@ static void oscar_logout(struct im_connection *ic) {
ic->proto_data = NULL;
}
-static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) {
+static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond)
+{
struct im_connection *ic = data;
struct oscar_data *odata;
aim_session_t *sess;
@@ -493,20 +518,22 @@ static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition
aim_conn_completeconnect(sess, bosconn);
ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ,
- oscar_callback, bosconn);
+ oscar_callback, bosconn);
imcb_log(ic, _("Connection established, cookie sent"));
-
+
return FALSE;
}
-static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
struct aim_authresp_info *info;
int i; char *host; int port;
aim_conn_t *bosconn;
struct im_connection *ic = sess->aux_data;
- struct oscar_data *od = ic->proto_data;
+ struct oscar_data *od = ic->proto_data;
+
port = AIM_LOGIN_PORT;
va_start(ap, fr);
@@ -520,11 +547,12 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
imcb_error(ic, _("Incorrect nickname or password."));
{
int max = od->icq ? 8 : 16;
- if (strlen(ic->acc->pass) > max)
+ if (strlen(ic->acc->pass) > max) {
imcb_log(ic, "Note that the maximum password "
"length supported by this protocol is "
"%d characters, try logging in using "
"a shorter password.", max);
+ }
}
// plugin_event(event_error, (void *)980, 0, 0, 0);
break;
@@ -535,7 +563,9 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
case 0x18:
/* connecting too frequently */
od->no_reconnect = TRUE;
- imcb_error(ic, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
+ imcb_error(ic,
+ _(
+ "You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
break;
case 0x1c:
/* client too old */
@@ -588,10 +618,10 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parsemtn, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_parse_logout, 0);
- ((struct oscar_data *)ic->proto_data)->conn = bosconn;
- for (i = 0; i < (int)strlen(info->bosip); i++) {
+ ((struct oscar_data *) ic->proto_data)->conn = bosconn;
+ for (i = 0; i < (int) strlen(info->bosip); i++) {
if (info->bosip[i] == ':') {
- port = atoi(&(info->bosip[i+1]));
+ port = atoi(&(info->bosip[i + 1]));
break;
}
}
@@ -613,9 +643,10 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
/* size of icbmui.ocm, the largest module in AIM 3.5 */
#define AIM_MAX_FILE_SIZE 98304
-static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...)
+{
#if 0
- struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b};
+ struct client_info_s info = { "gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b };
#else
struct client_info_s info = AIM_CLIENTINFO_KNOWNGOOD;
#endif
@@ -632,7 +663,8 @@ static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...)
+{
struct im_connection *ic = sess->aux_data;
struct oscar_data *odata = ic->proto_data;
int code;
@@ -641,22 +673,23 @@ static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) {
va_start(ap, fr);
code = va_arg(ap, int);
va_end(ap);
-
- imcb_error( ic, "Connection aborted by server: %s", code == 1 ?
- "someone else logged in with your account" :
- "unknown reason" );
-
+
+ imcb_error(ic, "Connection aborted by server: %s", code == 1 ?
+ "someone else logged in with your account" :
+ "unknown reason");
+
/* Tell BitlBee to disable auto_reconnect if code == 1, since that
means a concurrent login somewhere else. */
odata->no_reconnect = code == 1;
-
+
/* DO NOT log out here! Just tell the callback to do it. */
odata->killme = TRUE;
return 1;
}
-static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...)
+{
struct im_connection *ic = sess->aux_data;
struct chat_connection *chatcon;
struct groupchat *c = NULL;
@@ -672,18 +705,20 @@ static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
chatcon = find_oscar_chat_by_conn(ic, fr->conn);
chatcon->id = id;
-
+
c = bee_chat_by_title(ic->bee, ic, chatcon->show);
- if (c && !c->data)
+ if (c && !c->data) {
chatcon->cnv = c;
- else
+ } else {
chatcon->cnv = imcb_chat_new(ic, chatcon->show);
+ }
chatcon->cnv->data = chatcon;
return 1;
}
-static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...)
+{
aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_ERROR, gaim_parse_genericerr, 0);
aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0);
@@ -695,7 +730,8 @@ static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) {
+static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond)
+{
struct im_connection *ic = data;
struct oscar_data *odata;
aim_session_t *sess;
@@ -717,8 +753,8 @@ static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condit
aim_conn_completeconnect(sess, tstconn);
odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ,
- oscar_callback, tstconn);
-
+ oscar_callback, tstconn);
+
return FALSE;
}
@@ -745,8 +781,8 @@ static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition
aim_conn_completeconnect(sess, tstconn);
odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ,
- oscar_callback, tstconn);
-
+ oscar_callback, tstconn);
+
return FALSE;
}
@@ -780,15 +816,16 @@ static gboolean oscar_chat_connect(gpointer data, gint source, b_input_condition
aim_conn_completeconnect(sess, ccon->conn);
ccon->inpa = b_input_add(tstconn->fd,
- B_EV_IO_READ,
- oscar_callback, tstconn);
+ B_EV_IO_READ,
+ oscar_callback, tstconn);
odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon);
-
+
return FALSE;
}
/* Hrmph. I don't know how to make this look better. --mid */
-static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
struct aim_redirect_data *redir;
struct im_connection *ic = sess->aux_data;
@@ -802,22 +839,23 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
va_end(ap);
port = AIM_LOGIN_PORT;
- for (i = 0; i < (int)strlen(redir->ip); i++) {
+ for (i = 0; i < (int) strlen(redir->ip); i++) {
if (redir->ip[i] == ':') {
- port = atoi(&(redir->ip[i+1]));
+ port = atoi(&(redir->ip[i + 1]));
break;
}
}
host = g_strndup(redir->ip, i);
- switch(redir->group) {
+ switch (redir->group) {
case 0x7: /* Authorizer */
tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL);
if (tstconn == NULL) {
g_free(host);
return 1;
}
- aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0);
+ aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin,
+ 0);
// aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0);
// aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0);
// aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0);
@@ -837,7 +875,8 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
g_free(host);
return 1;
}
- aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0);
+ aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE,
+ conninitdone_chatnav, 0);
tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, ic);
@@ -849,7 +888,7 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
aim_sendcookie(sess, tstconn, redir->cookie);
break;
case 0xe: /* Chat */
- {
+ {
struct chat_connection *ccon;
tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL);
@@ -858,7 +897,8 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
- aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0);
+ aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat,
+ 0);
ccon = g_new0(struct chat_connection, 1);
ccon->conn = tstconn;
@@ -868,7 +908,7 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
ccon->exchange = redir->chat.exchange;
ccon->instance = redir->chat.instance;
ccon->show = extract_name(redir->chat.room);
-
+
ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS;
ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon);
if (ccon->conn->fd < 0) {
@@ -880,8 +920,8 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
aim_sendcookie(sess, tstconn, redir->cookie);
- }
- break;
+ }
+ break;
default: /* huh? */
break;
}
@@ -890,7 +930,8 @@ static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...)
+{
struct im_connection *ic = sess->aux_data;
struct oscar_data *od = ic->proto_data;
aim_userinfo_t *info;
@@ -899,51 +940,58 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
char *tmp, *state_string = NULL;
va_list ap;
+
va_start(ap, fr);
info = va_arg(ap, aim_userinfo_t *);
va_end(ap);
if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) {
- if (info->flags & AIM_FLAG_AWAY)
+ if (info->flags & AIM_FLAG_AWAY) {
flags |= OPT_AWAY;
+ }
}
-
+
/* Maybe this should be done just for AIM contacts, not sure. */
- if (info->flags & AIM_FLAG_WIRELESS)
+ if (info->flags & AIM_FLAG_WIRELESS) {
flags |= OPT_MOBILE;
-
+ }
+
if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) {
if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) &&
- (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
+ (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
flags |= OPT_AWAY;
}
-
- if( info->icqinfo.status & AIM_ICQ_STATE_DND )
+
+ if (info->icqinfo.status & AIM_ICQ_STATE_DND) {
state_string = "Do Not Disturb";
- else if( info->icqinfo.status & AIM_ICQ_STATE_OUT )
+ } else if (info->icqinfo.status & AIM_ICQ_STATE_OUT) {
state_string = "Not Available";
- else if( info->icqinfo.status & AIM_ICQ_STATE_BUSY )
+ } else if (info->icqinfo.status & AIM_ICQ_STATE_BUSY) {
state_string = "Occupied";
- else if( info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE )
+ } else if (info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE) {
state_string = "Invisible";
+ }
}
if (info->present & AIM_USERINFO_PRESENT_IDLE) {
time(&time_idle);
- time_idle -= info->idletime*60;
+ time_idle -= info->idletime * 60;
}
- if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
+ if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) {
signon = time(NULL) - info->sessionlen;
+ }
if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) {
uint32_t *uin = g_new0(uint32_t, 1);
-
- if (od->ips == NULL)
+
+ if (od->ips == NULL) {
od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
-
- if (sscanf(info->sn, "%d", uin) == 1)
+ }
+
+ if (sscanf(info->sn, "%d", uin) == 1) {
g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr);
+ }
}
tmp = normalize(info->sn);
@@ -954,7 +1002,8 @@ static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...)
+{
aim_userinfo_t *info;
va_list ap;
struct im_connection *ic = sess->aux_data;
@@ -963,42 +1012,46 @@ static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) {
info = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL );
+ imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL);
return 1;
}
-static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) {
+static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo,
+ struct aim_incomingim_ch1_args *args)
+{
char *tmp = g_malloc(BUF_LONG + 1);
struct im_connection *ic = sess->aux_data;
int flags = 0;
-
- if (args->icbmflags & AIM_IMFLAGS_AWAY)
+
+ if (args->icbmflags & AIM_IMFLAGS_AWAY) {
flags |= OPT_AWAY;
-
+ }
+
if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) {
char *src;
-
- if (args->icbmflags & AIM_IMFLAGS_UNICODE)
+
+ if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
src = "UCS-2BE";
- else
+ } else {
src = "ISO8859-1";
-
+ }
+
/* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */
if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) {
// Successfully converted!
} else if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
int i;
-
+
for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) {
unsigned short uni;
-
- uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff);
-
+
+ uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i + 1] & 0xff);
+
if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */
- g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "%c", uni);
+ g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "%c", uni);
} else { /* something else, do UNICODE entity */
- g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni);
+ g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "&#%04x;", uni);
}
}
} else {
@@ -1008,31 +1061,34 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_
g_snprintf(tmp, BUF_LONG, "%s", args->msg);
} else {
aim_mpmsg_section_t *part;
-
+
*tmp = 0;
for (part = args->mpmsg.parts; part; part = part->next) {
if (part->data) {
- g_strlcat(tmp, (char*) part->data, BUF_LONG);
+ g_strlcat(tmp, (char *) part->data, BUF_LONG);
g_strlcat(tmp, "\n", BUF_LONG);
}
}
}
-
+
strip_linefeed(tmp);
imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0);
g_free(tmp);
-
+
return 1;
}
void oscar_accept_chat(void *data);
void oscar_reject_chat(void *data);
-
-static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
+
+static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo,
+ struct aim_incomingim_ch2_args *args)
+{
struct im_connection *ic = sess->aux_data;
- if (args->status != AIM_RENDEZVOUS_PROPOSE)
+ if (args->status != AIM_RENDEZVOUS_PROPOSE) {
return 1;
+ }
if (args->reqclass & AIM_CAPS_CHAT) {
char *name = extract_name(args->info.chat.roominfo.name);
@@ -1050,14 +1106,15 @@ static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_
inv->ic = ic;
inv->exchange = *exch;
inv->name = g_strdup(name);
-
+
imcb_ask(ic, txt, inv, oscar_accept_chat, oscar_reject_chat);
-
- if (name)
+
+ if (name) {
g_free(name);
+ }
} else if (args->reqclass & AIM_CAPS_ICQRTF) {
// TODO: constify
- char text[strlen(args->info.rtfmsg.rtfmsg)+1];
+ char text[strlen(args->info.rtfmsg.rtfmsg) + 1];
strncpy(text, args->info.rtfmsg.rtfmsg, sizeof(text));
imcb_buddy_msg(ic, normalize(userinfo->sn), text, 0, 0);
}
@@ -1065,32 +1122,34 @@ static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_
return 1;
}
-static void gaim_icq_authgrant(void *data_) {
+static void gaim_icq_authgrant(void *data_)
+{
struct icq_auth *data = data_;
char *uin;
- struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
-
+ struct oscar_data *od = (struct oscar_data *) data->ic->proto_data;
+
uin = g_strdup_printf("%u", data->uin);
aim_ssi_auth_reply(od->sess, od->conn, uin, 1, "");
// char *message = 0;
// aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message);
imcb_ask_add(data->ic, uin, NULL);
-
+
g_free(uin);
g_free(data);
}
-static void gaim_icq_authdeny(void *data_) {
+static void gaim_icq_authdeny(void *data_)
+{
struct icq_auth *data = data_;
char *uin, *message;
- struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
-
+ struct oscar_data *od = (struct oscar_data *) data->ic->proto_data;
+
uin = g_strdup_printf("%u", data->uin);
message = g_strdup_printf("No reason given.");
aim_ssi_auth_reply(od->sess, od->conn, uin, 0, "");
// aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHDENIED, message);
g_free(message);
-
+
g_free(uin);
g_free(data);
}
@@ -1098,84 +1157,94 @@ static void gaim_icq_authdeny(void *data_) {
/*
* For when other people ask you for authorization
*/
-static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) {
+static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg)
+{
struct icq_auth *data;
char *reason = NULL;
char *dialog_msg;
- if (set_getbool(&ic->acc->set, "ignore_auth_requests"))
+ if (set_getbool(&ic->acc->set, "ignore_auth_requests")) {
return;
-
+ }
+
data = g_new(struct icq_auth, 1);
- if (strlen(msg) > 6)
+ if (strlen(msg) > 6) {
reason = msg + 6;
-
- dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given.");
+ }
+
+ dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s",
+ uin, reason ? reason : "No reason given.");
data->ic = ic;
data->uin = uin;
imcb_ask(ic, dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny);
g_free(dialog_msg);
}
-static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args) {
+static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo,
+ struct aim_incomingim_ch4_args *args)
+{
struct im_connection *ic = sess->aux_data;
switch (args->type) {
- case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */
- char *uin, *message;
- uin = g_strdup_printf("%u", args->uin);
- message = g_strdup(args->msg);
- strip_linefeed(message);
- imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
- g_free(uin);
- g_free(message);
- } break;
-
- case 0x0004: { /* Someone sent you a URL */
- char *uin, *message;
- char **m;
-
- uin = g_strdup_printf("%u", args->uin);
- m = g_strsplit(args->msg, "\376", 2);
-
- if ((strlen(m[0]) != 0)) {
- message = g_strjoinv(" -- ", m);
- } else {
- message = m[1];
- }
+ case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */
+ char *uin, *message;
+ uin = g_strdup_printf("%u", args->uin);
+ message = g_strdup(args->msg);
+ strip_linefeed(message);
+ imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
+ g_free(uin);
+ g_free(message);
+ } break;
+
+ case 0x0004: { /* Someone sent you a URL */
+ char *uin, *message;
+ char **m;
+
+ uin = g_strdup_printf("%u", args->uin);
+ m = g_strsplit(args->msg, "\376", 2);
+
+ if ((strlen(m[0]) != 0)) {
+ message = g_strjoinv(" -- ", m);
+ } else {
+ message = m[1];
+ }
+
+ strip_linefeed(message);
+ imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
+ g_free(uin);
+ g_free(m);
+ g_free(message);
+ } break;
- strip_linefeed(message);
- imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
- g_free(uin);
- g_free(m);
- g_free(message);
- } break;
-
- case 0x0006: { /* Someone requested authorization */
- gaim_icq_authask(ic, args->uin, args->msg);
- } break;
+ case 0x0006: { /* Someone requested authorization */
+ gaim_icq_authask(ic, args->uin, args->msg);
+ } break;
- case 0x0007: { /* Someone has denied you authorization */
- imcb_log(sess->aux_data, "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin, args->msg ? args->msg : _("No reason given.") );
- } break;
+ case 0x0007: { /* Someone has denied you authorization */
+ imcb_log(sess->aux_data,
+ "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin,
+ args->msg ? args->msg : _("No reason given."));
+ } break;
- case 0x0008: { /* Someone has granted you authorization */
- imcb_log(sess->aux_data, "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin, args->msg ? args->msg : _("No reason given.") );
- } break;
+ case 0x0008: { /* Someone has granted you authorization */
+ imcb_log(sess->aux_data,
+ "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin,
+ args->msg ? args->msg : _("No reason given."));
+ } break;
- case 0x0012: {
- /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
- } break;
+ case 0x0012: {
+ /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
+ } break;
- default: {;
- } break;
+ default: {; } break;
}
return 1;
}
-static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...)
+{
int channel, ret = 0;
aim_userinfo_t *userinfo;
va_list ap;
@@ -1185,26 +1254,25 @@ static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) {
userinfo = va_arg(ap, aim_userinfo_t *);
switch (channel) {
- case 1: { /* standard message */
- struct aim_incomingim_ch1_args *args;
- args = va_arg(ap, struct aim_incomingim_ch1_args *);
- ret = incomingim_chan1(sess, fr->conn, userinfo, args);
- } break;
+ case 1: { /* standard message */
+ struct aim_incomingim_ch1_args *args;
+ args = va_arg(ap, struct aim_incomingim_ch1_args *);
+ ret = incomingim_chan1(sess, fr->conn, userinfo, args);
+ } break;
- case 2: { /* rendevous */
- struct aim_incomingim_ch2_args *args;
- args = va_arg(ap, struct aim_incomingim_ch2_args *);
- ret = incomingim_chan2(sess, fr->conn, userinfo, args);
- } break;
+ case 2: { /* rendevous */
+ struct aim_incomingim_ch2_args *args;
+ args = va_arg(ap, struct aim_incomingim_ch2_args *);
+ ret = incomingim_chan2(sess, fr->conn, userinfo, args);
+ } break;
- case 4: { /* ICQ */
- struct aim_incomingim_ch4_args *args;
- args = va_arg(ap, struct aim_incomingim_ch4_args *);
- ret = incomingim_chan4(sess, fr->conn, userinfo, args);
- } break;
+ case 4: { /* ICQ */
+ struct aim_incomingim_ch4_args *args;
+ args = va_arg(ap, struct aim_incomingim_ch4_args *);
+ ret = incomingim_chan4(sess, fr->conn, userinfo, args);
+ } break;
- default: {;
- } break;
+ default: {; } break;
}
va_end(ap);
@@ -1212,7 +1280,8 @@ static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) {
return ret;
}
-static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
guint16 nummissed, reason;
aim_userinfo_t *userinfo;
@@ -1220,183 +1289,190 @@ static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) {
va_start(ap, fr);
va_arg(ap, unsigned int); /* chan */
userinfo = va_arg(ap, aim_userinfo_t *);
- nummissed = (guint16)va_arg(ap, unsigned int);
- reason = (guint16)va_arg(ap, unsigned int);
+ nummissed = (guint16) va_arg(ap, unsigned int);
+ reason = (guint16) va_arg(ap, unsigned int);
va_end(ap);
- switch(reason) {
- case 0:
- /* Invalid (0) */
- imcb_error(sess->aux_data,
- nummissed == 1 ?
- _("You missed %d message from %s because it was invalid.") :
- _("You missed %d messages from %s because they were invalid."),
- nummissed,
- userinfo->sn);
- break;
- case 1:
- /* Message too large */
- imcb_error(sess->aux_data,
- nummissed == 1 ?
- _("You missed %d message from %s because it was too large.") :
- _("You missed %d messages from %s because they were too large."),
- nummissed,
- userinfo->sn);
- break;
- case 2:
- /* Rate exceeded */
- imcb_error(sess->aux_data,
- nummissed == 1 ?
- _("You missed %d message from %s because the rate limit has been exceeded.") :
- _("You missed %d messages from %s because the rate limit has been exceeded."),
- nummissed,
- userinfo->sn);
- break;
- case 3:
- /* Evil Sender */
- imcb_error(sess->aux_data,
- nummissed == 1 ?
- _("You missed %d message from %s because it was too evil.") :
- _("You missed %d messages from %s because they are too evil."),
- nummissed,
- userinfo->sn);
- break;
- case 4:
- /* Evil Receiver */
- imcb_error(sess->aux_data,
- nummissed == 1 ?
- _("You missed %d message from %s because you are too evil.") :
- _("You missed %d messages from %s because you are too evil."),
- nummissed,
- userinfo->sn);
- break;
- default:
- imcb_error(sess->aux_data,
- nummissed == 1 ?
- _("You missed %d message from %s for unknown reasons.") :
- _("You missed %d messages from %s for unknown reasons."),
- nummissed,
- userinfo->sn);
- break;
+ switch (reason) {
+ case 0:
+ /* Invalid (0) */
+ imcb_error(sess->aux_data,
+ nummissed == 1 ?
+ _("You missed %d message from %s because it was invalid.") :
+ _("You missed %d messages from %s because they were invalid."),
+ nummissed,
+ userinfo->sn);
+ break;
+ case 1:
+ /* Message too large */
+ imcb_error(sess->aux_data,
+ nummissed == 1 ?
+ _("You missed %d message from %s because it was too large.") :
+ _("You missed %d messages from %s because they were too large."),
+ nummissed,
+ userinfo->sn);
+ break;
+ case 2:
+ /* Rate exceeded */
+ imcb_error(sess->aux_data,
+ nummissed == 1 ?
+ _("You missed %d message from %s because the rate limit has been exceeded.") :
+ _("You missed %d messages from %s because the rate limit has been exceeded."),
+ nummissed,
+ userinfo->sn);
+ break;
+ case 3:
+ /* Evil Sender */
+ imcb_error(sess->aux_data,
+ nummissed == 1 ?
+ _("You missed %d message from %s because it was too evil.") :
+ _("You missed %d messages from %s because they are too evil."),
+ nummissed,
+ userinfo->sn);
+ break;
+ case 4:
+ /* Evil Receiver */
+ imcb_error(sess->aux_data,
+ nummissed == 1 ?
+ _("You missed %d message from %s because you are too evil.") :
+ _("You missed %d messages from %s because you are too evil."),
+ nummissed,
+ userinfo->sn);
+ break;
+ default:
+ imcb_error(sess->aux_data,
+ nummissed == 1 ?
+ _("You missed %d message from %s for unknown reasons.") :
+ _("You missed %d messages from %s for unknown reasons."),
+ nummissed,
+ userinfo->sn);
+ break;
}
return 1;
}
-static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
guint16 reason;
va_start(ap, fr);
- reason = (guint16)va_arg(ap, unsigned int);
+ reason = (guint16) va_arg(ap, unsigned int);
va_end(ap);
imcb_error(sess->aux_data, _("SNAC threw error: %s"),
- reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error");
+ reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error");
return 1;
}
-static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
char *destn;
guint16 reason;
va_start(ap, fr);
- reason = (guint16)va_arg(ap, unsigned int);
+ reason = (guint16) va_arg(ap, unsigned int);
destn = va_arg(ap, char *);
va_end(ap);
imcb_error(sess->aux_data, _("Your message to %s did not get sent: %s"), destn,
- (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
+ (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
return 1;
}
-static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
char *destn;
guint16 reason;
va_start(ap, fr);
- reason = (guint16)va_arg(ap, unsigned int);
+ reason = (guint16) va_arg(ap, unsigned int);
destn = va_arg(ap, char *);
va_end(ap);
imcb_error(sess->aux_data, _("User information for %s unavailable: %s"), destn,
- (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
+ (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
return 1;
}
-static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...)
+{
guint16 id;
va_list ap;
va_start(ap, fr);
- id = (guint16)va_arg(ap, unsigned int);
+ id = (guint16) va_arg(ap, unsigned int);
va_arg(ap, char *); /* msg */
va_end(ap);
- if (id < 4)
+ if (id < 4) {
imcb_error(sess->aux_data, _("Your connection may be lost."));
+ }
return 1;
}
-static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
guint16 type;
struct im_connection *ic = sess->aux_data;
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
va_start(ap, fr);
- type = (guint16)va_arg(ap, unsigned int);
-
- switch(type) {
- case 0x0002: {
- va_arg(ap, unsigned int); /* maxrooms */
- va_arg(ap, int); /* exchangecount */
- va_arg(ap, struct aim_chat_exchangeinfo *); /* exchanges */
- va_end(ap);
-
- while (odata->create_rooms) {
- struct create_room *cr = odata->create_rooms->data;
- aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange);
- g_free(cr->name);
- odata->create_rooms = g_slist_remove(odata->create_rooms, cr);
- g_free(cr);
- }
- }
- break;
- case 0x0008: {
- char *ck;
- guint16 instance, exchange;
-
- va_arg(ap, char *); /* fqcn */
- instance = (guint16)va_arg(ap, unsigned int);
- exchange = (guint16)va_arg(ap, unsigned int);
- va_arg(ap, unsigned int); /* flags */
- va_arg(ap, guint32); /* createtime */
- va_arg(ap, unsigned int); /* maxmsglen */
- va_arg(ap, unsigned int); /* maxoccupancy */
- va_arg(ap, int); /* createperms */
- va_arg(ap, unsigned int); /* unknown */
- va_arg(ap, char *); /* name */
- ck = va_arg(ap, char *);
- va_end(ap);
-
- aim_chat_join(odata->sess, odata->conn, exchange, ck, instance);
- }
- break;
- default:
- va_end(ap);
- break;
+ type = (guint16) va_arg(ap, unsigned int);
+
+ switch (type) {
+ case 0x0002: {
+ va_arg(ap, unsigned int); /* maxrooms */
+ va_arg(ap, int); /* exchangecount */
+ va_arg(ap, struct aim_chat_exchangeinfo *); /* exchanges */
+ va_end(ap);
+
+ while (odata->create_rooms) {
+ struct create_room *cr = odata->create_rooms->data;
+ aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange);
+ g_free(cr->name);
+ odata->create_rooms = g_slist_remove(odata->create_rooms, cr);
+ g_free(cr);
+ }
+ }
+ break;
+ case 0x0008: {
+ char *ck;
+ guint16 instance, exchange;
+
+ va_arg(ap, char *); /* fqcn */
+ instance = (guint16) va_arg(ap, unsigned int);
+ exchange = (guint16) va_arg(ap, unsigned int);
+ va_arg(ap, unsigned int); /* flags */
+ va_arg(ap, guint32); /* createtime */
+ va_arg(ap, unsigned int); /* maxmsglen */
+ va_arg(ap, unsigned int); /* maxoccupancy */
+ va_arg(ap, int); /* createperms */
+ va_arg(ap, unsigned int); /* unknown */
+ va_arg(ap, char *); /* name */
+ ck = va_arg(ap, char *);
+ va_end(ap);
+
+ aim_chat_join(odata->sess, odata->conn, exchange, ck, instance);
+ }
+ break;
+ default:
+ va_end(ap);
+ break;
}
return 1;
}
-static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
int count, i;
aim_userinfo_t *info;
@@ -1410,16 +1486,19 @@ static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) {
va_end(ap);
c = find_oscar_chat_by_conn(g, fr->conn);
- if (!c)
+ if (!c) {
return 1;
+ }
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
imcb_chat_add_buddy(c->cnv, normalize(info[i].sn));
+ }
return 1;
}
-static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
int count, i;
aim_userinfo_t *info;
@@ -1433,16 +1512,19 @@ static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) {
va_end(ap);
c = find_oscar_chat_by_conn(g, fr->conn);
- if (!c)
+ if (!c) {
return 1;
+ }
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL);
+ }
return 1;
}
-static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
guint16 maxmsglen, maxvisiblemsglen;
struct im_connection *ic = sess->aux_data;
@@ -1456,10 +1538,10 @@ static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) {
va_arg(ap, char *); /* roomdesc */
va_arg(ap, int); /* unknown_c9 */
va_arg(ap, unsigned long); /* creationtime */
- maxmsglen = (guint16)va_arg(ap, int);
+ maxmsglen = (guint16) va_arg(ap, int);
va_arg(ap, int); /* unknown_d2 */
va_arg(ap, int); /* unknown_d5 */
- maxvisiblemsglen = (guint16)va_arg(ap, int);
+ maxvisiblemsglen = (guint16) va_arg(ap, int);
va_end(ap);
ccon->maxlen = maxmsglen;
@@ -1468,7 +1550,8 @@ static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
aim_userinfo_t *info;
char *msg;
@@ -1488,42 +1571,44 @@ static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...)
+{
#if 0
static const char *codes[5] = {
"invalid",
- "change",
- "warning",
- "limit",
- "limit cleared",
+ "change",
+ "warning",
+ "limit",
+ "limit cleared",
};
#endif
va_list ap;
guint16 code;
guint32 windowsize, clear, currentavg;
- va_start(ap, fr);
- code = (guint16)va_arg(ap, unsigned int);
+ va_start(ap, fr);
+ code = (guint16) va_arg(ap, unsigned int);
va_arg(ap, unsigned int); /* rateclass */
- windowsize = (guint32)va_arg(ap, unsigned long);
- clear = (guint32)va_arg(ap, unsigned long);
+ windowsize = (guint32) va_arg(ap, unsigned long);
+ clear = (guint32) va_arg(ap, unsigned long);
va_arg(ap, unsigned long); /* alert */
va_arg(ap, unsigned long); /* limit */
va_arg(ap, unsigned long); /* disconnect */
- currentavg = (guint32)va_arg(ap, unsigned long);
+ currentavg = (guint32) va_arg(ap, unsigned long);
va_arg(ap, unsigned long); /* maxavg */
va_end(ap);
/* XXX fix these values */
if (code == AIM_RATE_CODE_CHANGE) {
- if (currentavg >= clear)
+ if (currentavg >= clear) {
aim_conn_setlatency(fr->conn, 0);
+ }
} else if (code == AIM_RATE_CODE_WARNING) {
- aim_conn_setlatency(fr->conn, windowsize/4);
+ aim_conn_setlatency(fr->conn, windowsize / 4);
} else if (code == AIM_RATE_CODE_LIMIT) {
imcb_error(sess->aux_data, _("The last message was not sent because you are over the rate limit. "
- "Please wait 10 seconds and try again."));
- aim_conn_setlatency(fr->conn, windowsize/2);
+ "Please wait 10 seconds and try again."));
+ aim_conn_setlatency(fr->conn, windowsize / 2);
} else if (code == AIM_RATE_CODE_CLEARLIMIT) {
aim_conn_setlatency(fr->conn, 0);
}
@@ -1531,11 +1616,13 @@ static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...)
+{
return 1;
}
-static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...)
+{
aim_reqpersonalinfo(sess, fr->conn);
aim_bos_reqlocaterights(sess, fr->conn);
@@ -1546,12 +1633,13 @@ static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
aim_bos_reqrights(sess, fr->conn);
aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS);
aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE |
- AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
+ AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
return 1;
}
-static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...)
+{
struct im_connection *ic = sess->aux_data;
struct oscar_data *od = ic->proto_data;
@@ -1588,7 +1676,8 @@ static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...)
+{
struct aim_icbmparameters *params;
va_list ap;
@@ -1611,52 +1700,54 @@ static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...)
va_list ap;
guint16 maxsiglen;
struct im_connection *ic = sess->aux_data;
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
va_start(ap, fr);
maxsiglen = va_arg(ap, int);
va_end(ap);
- odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint)maxsiglen;
+ odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint) maxsiglen;
/* FIXME: It seems we're not really using this, and it broke now that
struct aim_user is dead.
aim_bos_setprofile(sess, fr->conn, ic->user->user_info, NULL, gaim_caps);
*/
-
+
return 1;
}
-static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
guint16 maxbuddies, maxwatchers;
struct im_connection *ic = sess->aux_data;
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
va_start(ap, fr);
- maxbuddies = (guint16)va_arg(ap, unsigned int);
- maxwatchers = (guint16)va_arg(ap, unsigned int);
+ maxbuddies = (guint16) va_arg(ap, unsigned int);
+ maxwatchers = (guint16) va_arg(ap, unsigned int);
va_end(ap);
- odata->rights.maxbuddies = (guint)maxbuddies;
- odata->rights.maxwatchers = (guint)maxwatchers;
+ odata->rights.maxbuddies = (guint) maxbuddies;
+ odata->rights.maxwatchers = (guint) maxwatchers;
return 1;
}
-static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...)
+{
guint16 maxpermits, maxdenies;
va_list ap;
struct im_connection *ic = sess->aux_data;
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
va_start(ap, fr);
- maxpermits = (guint16)va_arg(ap, unsigned int);
- maxdenies = (guint16)va_arg(ap, unsigned int);
+ maxpermits = (guint16) va_arg(ap, unsigned int);
+ maxdenies = (guint16) va_arg(ap, unsigned int);
va_end(ap);
- odata->rights.maxpermits = (guint)maxpermits;
- odata->rights.maxdenies = (guint)maxdenies;
+ odata->rights.maxpermits = (guint) maxpermits;
+ odata->rights.maxdenies = (guint) maxdenies;
aim_clientready(sess, fr->conn);
@@ -1668,7 +1759,8 @@ static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) {
return 1;
}
-static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...)
+{
va_list ap;
struct aim_icq_offlinemsg *msg;
struct im_connection *ic = sess->aux_data;
@@ -1678,56 +1770,59 @@ static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) {
va_end(ap);
switch (msg->type) {
- case 0x0001: { /* Basic offline message */
- char sender[32];
- char *dialog_msg = g_strdup(msg->msg);
- time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
- g_snprintf(sender, sizeof(sender), "%u", msg->sender);
- strip_linefeed(dialog_msg);
- imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
- g_free(dialog_msg);
- } break;
-
- case 0x0004: { /* Someone sent you a URL */
- char sender[32];
- char *dialog_msg;
- char **m;
-
- time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
- g_snprintf(sender, sizeof(sender), "%u", msg->sender);
-
- m = g_strsplit(msg->msg, "\376", 2);
-
- if ((strlen(m[0]) != 0)) {
- dialog_msg = g_strjoinv(" -- ", m);
- } else {
- dialog_msg = m[1];
- }
-
- strip_linefeed(dialog_msg);
- imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
- g_free(dialog_msg);
- g_free(m);
- } break;
-
- case 0x0006: { /* Authorization request */
- gaim_icq_authask(ic, msg->sender, msg->msg);
- } break;
-
- case 0x0007: { /* Someone has denied you authorization */
- imcb_log(sess->aux_data, "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender, msg->msg ? msg->msg : _("No reason given.") );
- } break;
-
- case 0x0008: { /* Someone has granted you authorization */
- imcb_log(sess->aux_data, "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender, msg->msg ? msg->msg : _("No reason given.") );
- } break;
-
- case 0x0012: {
- /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
- } break;
-
- default: {;
+ case 0x0001: { /* Basic offline message */
+ char sender[32];
+ char *dialog_msg = g_strdup(msg->msg);
+ time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
+ g_snprintf(sender, sizeof(sender), "%u", msg->sender);
+ strip_linefeed(dialog_msg);
+ imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
+ g_free(dialog_msg);
+ } break;
+
+ case 0x0004: { /* Someone sent you a URL */
+ char sender[32];
+ char *dialog_msg;
+ char **m;
+
+ time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
+ g_snprintf(sender, sizeof(sender), "%u", msg->sender);
+
+ m = g_strsplit(msg->msg, "\376", 2);
+
+ if ((strlen(m[0]) != 0)) {
+ dialog_msg = g_strjoinv(" -- ", m);
+ } else {
+ dialog_msg = m[1];
}
+
+ strip_linefeed(dialog_msg);
+ imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
+ g_free(dialog_msg);
+ g_free(m);
+ } break;
+
+ case 0x0006: { /* Authorization request */
+ gaim_icq_authask(ic, msg->sender, msg->msg);
+ } break;
+
+ case 0x0007: { /* Someone has denied you authorization */
+ imcb_log(sess->aux_data,
+ "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender,
+ msg->msg ? msg->msg : _("No reason given."));
+ } break;
+
+ case 0x0008: { /* Someone has granted you authorization */
+ imcb_log(sess->aux_data,
+ "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender,
+ msg->msg ? msg->msg : _("No reason given."));
+ } break;
+
+ case 0x0012: {
+ /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
+ } break;
+
+ default: {; }
}
return 1;
@@ -1739,27 +1834,34 @@ static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...)
return 1;
}
-static void oscar_keepalive(struct im_connection *ic) {
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
+static void oscar_keepalive(struct im_connection *ic)
+{
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
+
aim_flap_nop(odata->sess, odata->conn);
}
-static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags) {
- struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
+static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags)
+{
+ struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
int ret = 0, len = strlen(message);
+
if (imflags & OPT_AWAY) {
ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message);
} else {
struct aim_sendimext_args args;
char *s;
-
+
args.flags = AIM_IMFLAGS_ACK;
- if (odata->icq)
+ if (odata->icq) {
args.flags |= AIM_IMFLAGS_OFFLINE;
- for (s = message; *s; s++)
- if (*s & 128)
+ }
+ for (s = message; *s; s++) {
+ if (*s & 128) {
break;
-
+ }
+ }
+
/* Message contains high ASCII chars, time for some translation! */
if (*s) {
s = g_malloc(BUF_LONG);
@@ -1773,59 +1875,66 @@ static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message,
len = ret;
} else {
/* OOF, translation failed... Oh well.. */
- g_free( s );
+ g_free(s);
s = message;
}
} else {
s = message;
}
-
+
args.features = gaim_features;
args.featureslen = sizeof(gaim_features);
-
+
args.destsn = name;
args.msg = s;
args.msglen = len;
-
+
ret = aim_send_im_ext(odata->sess, &args);
-
+
if (s != message) {
g_free(s);
}
}
- if (ret >= 0)
+ if (ret >= 0) {
return 1;
+ }
return ret;
}
-static void oscar_get_info(struct im_connection *g, char *name) {
- struct oscar_data *odata = (struct oscar_data *)g->proto_data;
- if (odata->icq)
+static void oscar_get_info(struct im_connection *g, char *name)
+{
+ struct oscar_data *odata = (struct oscar_data *) g->proto_data;
+
+ if (odata->icq) {
aim_icq_getallinfo(odata->sess, name);
- else {
+ } else {
aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE);
aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO);
}
}
-static void oscar_get_away(struct im_connection *g, char *who) {
- struct oscar_data *odata = (struct oscar_data *)g->proto_data;
+static void oscar_get_away(struct im_connection *g, char *who)
+{
+ struct oscar_data *odata = (struct oscar_data *) g->proto_data;
+
if (odata->icq) {
/** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back?
struct buddy *budlight = imcb_find_buddy(g, who);
if (budlight)
- if ((budlight->uc & 0xff80) >> 7)
- if (budlight->caps & AIM_CAPS_ICQSERVERRELAY)
- aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7);
+ if ((budlight->uc & 0xff80) >> 7)
+ if (budlight->caps & AIM_CAPS_ICQSERVERRELAY)
+ aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7);
*/
- } else
+ } else {
aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE);
+ }
}
static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message)
{
- if (state == NULL)
+ if (state == NULL) {
state = "";
+ }
if (!g_strcasecmp(state, _("Visible"))) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
@@ -1837,8 +1946,9 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od,
message = state;
}
- if (od->rights.maxawaymsglen == 0)
+ if (od->rights.maxawaymsglen == 0) {
imcb_error(ic, "oscar_set_away_aim called before locate rights received");
+ }
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
@@ -1851,7 +1961,8 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od,
}
if (strlen(message) > od->rights.maxawaymsglen) {
- imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating", od->rights.maxawaymsglen);
+ imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating",
+ od->rights.maxawaymsglen);
}
ic->away = g_strndup(message, od->rights.maxawaymsglen);
@@ -1904,7 +2015,7 @@ static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od,
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE);
ic->away = g_strdup(msg);
} else {
- if (no_message) {
+ if (no_message) {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
} else {
aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY);
@@ -1918,36 +2029,48 @@ static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od,
static void oscar_set_away(struct im_connection *ic, char *state, char *message)
{
- struct oscar_data *od = (struct oscar_data *)ic->proto_data;
+ struct oscar_data *od = (struct oscar_data *) ic->proto_data;
oscar_set_away_aim(ic, od, state, message);
- if (od->icq)
+ if (od->icq) {
oscar_set_away_icq(ic, od, state, message);
+ }
return;
}
-static void oscar_add_buddy(struct im_connection *g, char *name, char *group) {
- struct oscar_data *odata = (struct oscar_data *)g->proto_data;
+static void oscar_add_buddy(struct im_connection *g, char *name, char *group)
+{
+ struct oscar_data *odata = (struct oscar_data *) g->proto_data;
bee_user_t *bu;
-
- if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group)
+
+ if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group) {
aim_ssi_movebuddy(odata->sess, odata->conn, bu->group->name, group, name);
- else
+ } else {
aim_ssi_addbuddies(odata->sess, odata->conn, group ? : OSCAR_GROUP, &name, 1, 0);
+ }
}
-static void oscar_remove_buddy(struct im_connection *g, char *name, char *group) {
- struct oscar_data *odata = (struct oscar_data *)g->proto_data;
+static void oscar_remove_buddy(struct im_connection *g, char *name, char *group)
+{
+ struct oscar_data *odata = (struct oscar_data *) g->proto_data;
struct aim_ssi_item *ssigroup;
- while ((ssigroup = aim_ssi_itemlist_findparent(odata->sess->ssi.items, name)) && !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1));
+
+ while ((ssigroup =
+ aim_ssi_itemlist_findparent(odata->sess->ssi.items,
+ name)) &&
+ !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)) {
+ ;
+ }
}
-static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...)
+{
return 1;
}
-static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...)
+{
struct im_connection *ic = sess->aux_data;
struct aim_ssi_item *curitem, *curgroup = NULL;
int tmp;
@@ -1955,172 +2078,185 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) {
/* Add from server list to local list */
tmp = 0;
- for (curitem=sess->ssi.items; curitem; curitem=curitem->next) {
+ for (curitem = sess->ssi.items; curitem; curitem = curitem->next) {
nrm = curitem->name ? normalize(curitem->name) : NULL;
-
+
switch (curitem->type) {
- case 0x0000: /* Buddy */
- if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) {
- char *realname = NULL;
-
- if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1))
- realname = aim_gettlv_str(curitem->data, 0x0131, 1);
-
- imcb_add_buddy(ic, nrm, curgroup ? (curgroup->gid == curitem->gid ? curgroup->name : NULL) : NULL);
-
- if (realname) {
- imcb_buddy_nick_hint(ic, nrm, realname);
- imcb_rename_buddy(ic, nrm, realname);
- g_free(realname);
- }
+ case 0x0000: /* Buddy */
+ if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) {
+ char *realname = NULL;
+
+ if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) {
+ realname = aim_gettlv_str(curitem->data, 0x0131, 1);
}
- break;
- case 0x0001: /* Group */
- curgroup = curitem;
- break;
+ imcb_add_buddy(ic, nrm,
+ curgroup ? (curgroup->gid ==
+ curitem->gid ? curgroup->name : NULL) : NULL);
- case 0x0002: /* Permit buddy */
- if (curitem->name) {
- GSList *list;
- for (list=ic->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
- if (!list) {
- char *name;
- name = g_strdup(nrm);
- ic->permit = g_slist_append(ic->permit, name);
- tmp++;
- }
+ if (realname) {
+ imcb_buddy_nick_hint(ic, nrm, realname);
+ imcb_rename_buddy(ic, nrm, realname);
+ g_free(realname);
}
- break;
+ }
+ break;
- case 0x0003: /* Deny buddy */
- if (curitem->name) {
- GSList *list;
- for (list=ic->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
- if (!list) {
- char *name;
- name = g_strdup(nrm);
- ic->deny = g_slist_append(ic->deny, name);
- tmp++;
- }
+ case 0x0001: /* Group */
+ curgroup = curitem;
+ break;
+
+ case 0x0002: /* Permit buddy */
+ if (curitem->name) {
+ GSList *list;
+ for (list = ic->permit; (list && aim_sncmp(curitem->name, list->data));
+ list = list->next) {
+ ;
}
- break;
+ if (!list) {
+ char *name;
+ name = g_strdup(nrm);
+ ic->permit = g_slist_append(ic->permit, name);
+ tmp++;
+ }
+ }
+ break;
- case 0x0004: /* Permit/deny setting */
- if (curitem->data) {
- guint8 permdeny;
- if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) {
- ic->permdeny = permdeny;
- tmp++;
- }
+ case 0x0003: /* Deny buddy */
+ if (curitem->name) {
+ GSList *list;
+ for (list = ic->deny;
+ (list && aim_sncmp(curitem->name, list->data)); list = list->next) {
+ ;
}
- break;
+ if (!list) {
+ char *name;
+ name = g_strdup(nrm);
+ ic->deny = g_slist_append(ic->deny, name);
+ tmp++;
+ }
+ }
+ break;
- case 0x0005: /* Presence setting */
- /* We don't want to change Gaim's setting because it applies to all accounts */
- break;
+ case 0x0004: /* Permit/deny setting */
+ if (curitem->data) {
+ guint8 permdeny;
+ if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) {
+ ic->permdeny = permdeny;
+ tmp++;
+ }
+ }
+ break;
+
+ case 0x0005: /* Presence setting */
+ /* We don't want to change Gaim's setting because it applies to all accounts */
+ break;
} /* End of switch on curitem->type */
} /* End of for loop */
aim_ssi_enable(sess, fr->conn);
-
+
/* Request offline messages, now that the buddy list is complete. */
aim_icq_reqofflinemsgs(sess);
-
+
/* Now that we have a buddy list, we can tell BitlBee that we're online. */
imcb_connected(ic);
-
+
return 1;
}
-static int gaim_ssi_parseack( aim_session_t *sess, aim_frame_t *fr, ... )
+static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...)
{
aim_snac_t *origsnac;
va_list ap;
- va_start( ap, fr );
- origsnac = va_arg( ap, aim_snac_t * );
- va_end( ap );
-
- if( origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data )
- {
- int i, st, count = aim_bstream_empty( &fr->data );
+ va_start(ap, fr);
+ origsnac = va_arg(ap, aim_snac_t *);
+ va_end(ap);
+
+ if (origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data) {
+ int i, st, count = aim_bstream_empty(&fr->data);
char *list;
-
- if( count & 1 )
- {
+
+ if (count & 1) {
/* Hmm, the length should be even... */
- imcb_error( sess->aux_data, "Received SSI ACK package with non-even length");
- return( 0 );
+ imcb_error(sess->aux_data, "Received SSI ACK package with non-even length");
+ return(0);
}
count >>= 1;
-
+
list = (char *) origsnac->data;
- for( i = 0; i < count; i ++ )
- {
- struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent( sess->ssi.items, list );
+ for (i = 0; i < count; i++) {
+ struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent(sess->ssi.items, list);
char *group = ssigroup ? ssigroup->name : NULL;
-
- st = aimbs_get16( &fr->data );
- if( st == 0x00 )
- {
- imcb_add_buddy( sess->aux_data, normalize(list), group );
- }
- else if( st == 0x0E )
- {
- imcb_log( sess->aux_data, "Buddy %s can't be added without authorization, requesting authorization", list );
-
- aim_ssi_auth_request( sess, fr->conn, list, "" );
- aim_ssi_addbuddies( sess, fr->conn, OSCAR_GROUP, &list, 1, 1 );
- }
- else if( st == 0x0A )
- {
- imcb_error( sess->aux_data, "Buddy %s is already in your list", list );
- }
- else
- {
- imcb_error( sess->aux_data, "Error while adding buddy: 0x%04x", st );
+
+ st = aimbs_get16(&fr->data);
+ if (st == 0x00) {
+ imcb_add_buddy(sess->aux_data, normalize(list), group);
+ } else if (st == 0x0E) {
+ imcb_log(sess->aux_data,
+ "Buddy %s can't be added without authorization, requesting authorization",
+ list);
+
+ aim_ssi_auth_request(sess, fr->conn, list, "");
+ aim_ssi_addbuddies(sess, fr->conn, OSCAR_GROUP, &list, 1, 1);
+ } else if (st == 0x0A) {
+ imcb_error(sess->aux_data, "Buddy %s is already in your list", list);
+ } else {
+ imcb_error(sess->aux_data, "Error while adding buddy: 0x%04x", st);
}
- list += strlen( list ) + 1;
+ list += strlen(list) + 1;
}
}
-
- return( 1 );
+
+ return(1);
}
-static void oscar_add_permit(struct im_connection *ic, char *who) {
- struct oscar_data *od = (struct oscar_data *)ic->proto_data;
+static void oscar_add_permit(struct im_connection *ic, char *who)
+{
+ struct oscar_data *od = (struct oscar_data *) ic->proto_data;
+
if (od->icq) {
aim_ssi_auth_reply(od->sess, od->conn, who, 1, "");
} else {
- if (od->sess->ssi.received_data)
+ if (od->sess->ssi.received_data) {
aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT);
+ }
}
}
-static void oscar_add_deny(struct im_connection *ic, char *who) {
- struct oscar_data *od = (struct oscar_data *)ic->proto_data;
+static void oscar_add_deny(struct im_connection *ic, char *who)
+{
+ struct oscar_data *od = (struct oscar_data *) ic->proto_data;
+
if (od->icq) {
aim_ssi_auth_reply(od->sess, od->conn, who, 0, "");
} else {
- if (od->sess->ssi.received_data)
+ if (od->sess->ssi.received_data) {
aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY);
+ }
}
}
-static void oscar_rem_permit(struct im_connection *ic, char *who) {
- struct oscar_data *od = (struct oscar_data *)ic->proto_data;
+static void oscar_rem_permit(struct im_connection *ic, char *who)
+{
+ struct oscar_data *od = (struct oscar_data *) ic->proto_data;
+
if (!od->icq) {
- if (od->sess->ssi.received_data)
+ if (od->sess->ssi.received_data) {
aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT);
+ }
}
}
-static void oscar_rem_deny(struct im_connection *ic, char *who) {
- struct oscar_data *od = (struct oscar_data *)ic->proto_data;
+static void oscar_rem_deny(struct im_connection *ic, char *who)
+{
+ struct oscar_data *od = (struct oscar_data *) ic->proto_data;
+
if (!od->icq) {
- if (od->sess->ssi.received_data)
+ if (od->sess->ssi.received_data) {
aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY);
+ }
}
}
@@ -2158,14 +2294,15 @@ static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
info = va_arg(ap, struct aim_icq_info *);
va_end(ap);
- if (!info->uin)
+ if (!info->uin) {
return 0;
+ }
str = g_string_sized_new(512);
g_snprintf(who, sizeof(who), "%u", info->uin);
- g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
- info->nick ? info->nick : "-");
+ g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
+ info->nick ? info->nick : "-");
g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first);
g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last);
g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email);
@@ -2180,15 +2317,16 @@ static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
(ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
}
g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile);
- if (info->gender != 0)
- g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
+ if (info->gender != 0) {
+ g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender == 1 ? _("Female") : _("Male"));
+ }
if (info->birthyear || info->birthmonth || info->birthday) {
char date[30];
struct tm tm;
memset(&tm, 0, sizeof(struct tm));
- tm.tm_mday = (int)info->birthday;
- tm.tm_mon = (int)info->birthmonth-1;
- tm.tm_year = (int)info->birthyear%100;
+ tm.tm_mday = (int) info->birthday;
+ tm.tm_mon = (int) info->birthmonth - 1;
+ tm.tm_year = (int) info->birthyear % 100;
strftime(date, sizeof(date), "%Y-%m-%d", &tm);
g_string_append_printf(str, "\n%s: %s", _("Birthday"), date);
}
@@ -2199,19 +2337,25 @@ static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
}
g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage);
if (info->info && info->info[0]) {
- g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
- info->info, _("End of Additional Information"));
+ g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
+ info->info, _("End of Additional Information"));
}
g_string_append_c(str, '\n');
- if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
+ if ((info->homeaddr &&
+ (info->homeaddr[0])) ||
+ (info->homecity &&
+ info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
g_string_append_printf(str, "%s:", _("Home Address"));
g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr);
g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity);
- g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
+ g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip);
g_string_append_c(str, '\n');
}
- if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
+ if ((info->workaddr &&
+ info->workaddr[0]) ||
+ (info->workcity &&
+ info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
g_string_append_printf(str, "%s:", _("Work Address"));
g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr);
g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity);
@@ -2219,7 +2363,11 @@ static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip);
g_string_append_c(str, '\n');
}
- if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
+ if ((info->workcompany &&
+ info->workcompany[0]) ||
+ (info->workdivision &&
+ info->workdivision[0]) ||
+ (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
g_string_append_printf(str, "%s:", _("Work Information"));
g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany);
g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision);
@@ -2246,19 +2394,19 @@ static char *oscar_encoding_extract(const char *encoding)
/* Make sure encoding begins with charset= */
if (strncmp(encoding, "text/plain; charset=", 20) &&
- strncmp(encoding, "text/aolrtf; charset=", 21) &&
- strncmp(encoding, "text/x-aolrtf; charset=", 23))
- {
+ strncmp(encoding, "text/aolrtf; charset=", 21) &&
+ strncmp(encoding, "text/x-aolrtf; charset=", 23)) {
return NULL;
}
begin = strchr(encoding, '"');
end = strrchr(encoding, '"');
- if ((begin == NULL) || (end == NULL) || (begin >= end))
+ if ((begin == NULL) || (end == NULL) || (begin >= end)) {
return NULL;
+ }
- ret = g_strndup(begin+1, (end-1) - begin);
+ ret = g_strndup(begin + 1, (end - 1) - begin);
return ret;
}
@@ -2287,7 +2435,7 @@ static char *oscar_encoding_to_utf8(char *encoding, char *text, int textlen)
* that was specified. So we assume it's UTF-8 and hope for the best.
*/
if (*utf8 == 0) {
- strncpy(utf8, text, textlen);
+ strncpy(utf8, text, textlen);
}
return utf8;
@@ -2311,13 +2459,14 @@ static int gaim_parseaiminfo(aim_session_t *sess, aim_frame_t *fr, ...)
text_length = va_arg(ap, int);
va_end(ap);
- if(text_encoding)
+ if (text_encoding) {
extracted_encoding = oscar_encoding_extract(text_encoding);
- if(infotype == AIM_GETINFO_GENERALINFO) {
+ }
+ if (infotype == AIM_GETINFO_GENERALINFO) {
/*Display idle time*/
char buff[256];
struct tm idletime;
- if(userinfo->idletime) {
+ if (userinfo->idletime) {
memset(&idletime, 0, sizeof(struct tm));
idletime.tm_mday = (userinfo->idletime / 60) / 24;
idletime.tm_hour = (userinfo->idletime / 60) % 24;
@@ -2326,20 +2475,20 @@ static int gaim_parseaiminfo(aim_session_t *sess, aim_frame_t *fr, ...)
strftime(buff, 256, _("%d days %H hours %M minutes"), &idletime);
imcb_log(ic, "%s: %s", _("Idle Time"), buff);
}
-
- if(text) {
+
+ if (text) {
utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length);
imcb_log(ic, "%s\n%s", _("User Info"), utf8);
} else {
imcb_log(ic, _("No user info available."));
}
- } else if(infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) {
+ } else if (infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) {
utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length);
imcb_log(ic, "%s\n%s", _("Away Message"), utf8);
}
g_free(utf8);
-
+
return 1;
}
@@ -2355,48 +2504,50 @@ int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...)
sn = va_arg(ap, char*);
type2 = va_arg(ap, int);
va_end(ap);
-
- if(type2 == 0x0002) {
+
+ if (type2 == 0x0002) {
/* User is typing */
imcb_buddy_typing(ic, normalize(sn), OPT_TYPING);
- }
- else if (type2 == 0x0001) {
+ } else if (type2 == 0x0001) {
/* User has typed something, but is not actively typing (stale) */
imcb_buddy_typing(ic, normalize(sn), OPT_THINKING);
- }
- else {
+ } else {
/* User has stopped typing */
imcb_buddy_typing(ic, normalize(sn), 0);
}
-
+
return 1;
}
int oscar_send_typing(struct im_connection *ic, char * who, int typing)
{
struct oscar_data *od = ic->proto_data;
- return( aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000) );
+
+ return(aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000));
}
void oscar_chat_msg(struct groupchat *c, char *message, int msgflags)
{
struct im_connection *ic = c->ic;
- struct oscar_data * od = (struct oscar_data*)ic->proto_data;
+ struct oscar_data * od = (struct oscar_data*) ic->proto_data;
struct chat_connection * ccon;
int ret;
guint8 len = strlen(message);
guint16 flags;
char *s;
-
- if (!(ccon = c->data))
+
+ if (!(ccon = c->data)) {
return;
-
- for (s = message; *s; s++)
- if (*s & 128)
+ }
+
+ for (s = message; *s; s++) {
+ if (*s & 128) {
break;
-
+ }
+ }
+
flags = AIM_CHATFLAGS_NOREFLECT;
-
+
/* Message contains high ASCII chars, time for some translation! */
if (*s) {
s = g_malloc(BUF_LONG);
@@ -2410,46 +2561,48 @@ void oscar_chat_msg(struct groupchat *c, char *message, int msgflags)
len = ret;
} else {
/* OOF, translation failed... Oh well.. */
- g_free( s );
+ g_free(s);
s = message;
}
} else {
s = message;
}
-
+
ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len);
-
- if (s != message) {
+
+ if (s != message) {
g_free(s);
- }
-
+ }
+
/* return (ret >= 0); */
}
void oscar_chat_invite(struct groupchat *c, char *who, char *message)
{
struct im_connection *ic = c->ic;
- struct oscar_data * od = (struct oscar_data *)ic->proto_data;
+ struct oscar_data * od = (struct oscar_data *) ic->proto_data;
struct chat_connection *ccon;
-
- if (!(ccon = c->data))
+
+ if (!(ccon = c->data)) {
return;
-
+ }
+
aim_chat_invite(od->sess, od->conn, who, message ? message : "",
- ccon->exchange, ccon->name, 0x0);
+ ccon->exchange, ccon->name, 0x0);
}
void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc)
{
- struct oscar_data *od = (struct oscar_data *)ic->proto_data;
+ struct oscar_data *od = (struct oscar_data *) ic->proto_data;
/* Notify the conversation window that we've left the chat */
imcb_chat_free(cc->cnv);
/* Destroy the chat_connection */
od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
- if (cc->inpa > 0)
+ if (cc->inpa > 0) {
b_event_remove(cc->inpa);
+ }
aim_conn_kill(od->sess, &cc->conn);
g_free(cc->name);
g_free(cc->show);
@@ -2458,66 +2611,69 @@ void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc)
void oscar_chat_leave(struct groupchat *c)
{
- if (!c->data)
+ if (!c->data) {
return;
+ }
oscar_chat_kill(c->ic, c->data);
}
struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char *room,
- const char *nick, const char *password, int exchange_number)
+ const char *nick, const char *password, int exchange_number)
{
- struct oscar_data * od = (struct oscar_data *)ic->proto_data;
+ struct oscar_data * od = (struct oscar_data *) ic->proto_data;
struct groupchat *ret = imcb_chat_new(ic, room);
aim_conn_t * cur;
- if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {
+ if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {
aim_chatnav_createroom(od->sess, cur, room, exchange_number);
-
+
return ret;
} else {
struct create_room * cr = g_new0(struct create_room, 1);
-
+
cr->exchange = exchange_number;
cr->name = g_strdup(room);
od->create_rooms = g_slist_append(od->create_rooms, cr);
aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV);
-
+
return ret;
}
}
struct groupchat *oscar_chat_join(struct im_connection *ic, const char *room,
- const char *nick, const char *password, set_t **sets)
+ const char *nick, const char *password, set_t **sets)
{
return oscar_chat_join_internal(ic, room, nick, password, set_getint(sets, "exchange_number"));
}
struct groupchat *oscar_chat_with(struct im_connection * ic, char *who)
{
- struct oscar_data * od = (struct oscar_data *)ic->proto_data;
+ struct oscar_data * od = (struct oscar_data *) ic->proto_data;
struct groupchat *ret;
static int chat_id = 0;
char * chatname, *s;
-
+
chatname = g_strdup_printf("%s%s%d", g_ascii_isdigit(*ic->acc->user) ? "icq" : "",
ic->acc->user, chat_id++);
-
- for (s = chatname; *s; s ++)
- if (!g_ascii_isalnum(*s))
+
+ for (s = chatname; *s; s++) {
+ if (!g_ascii_isalnum(*s)) {
*s = '0';
-
+ }
+ }
+
ret = oscar_chat_join_internal(ic, chatname, NULL, NULL, 4);
aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0);
g_free(chatname);
-
+
return ret;
}
void oscar_accept_chat(void *data)
{
struct aim_chat_invitation * inv = data;
-
+
oscar_chat_join_internal(inv->ic, inv->name, NULL, NULL, 4);
g_free(inv->name);
g_free(inv);
@@ -2526,7 +2682,7 @@ void oscar_accept_chat(void *data)
void oscar_reject_chat(void *data)
{
struct aim_chat_invitation * inv = data;
-
+
g_free(inv->name);
g_free(inv);
}
@@ -2541,11 +2697,12 @@ void oscar_chat_free_settings(account_t *acc, set_t **head)
set_del(head, "exchange_number");
}
-void oscar_initmodule()
+void oscar_initmodule()
{
struct prpl *ret = g_new0(struct prpl, 1);
+
ret->name = "oscar";
- ret->mms = 2343; /* this guess taken from libotr UPGRADING file */
+ ret->mms = 2343; /* this guess taken from libotr UPGRADING file */
ret->away_states = oscar_away_states;
ret->init = oscar_init;
ret->login = oscar_login;
@@ -2569,7 +2726,7 @@ void oscar_initmodule()
ret->rem_permit = oscar_rem_permit;
ret->rem_deny = oscar_rem_deny;
ret->send_typing = oscar_send_typing;
-
+
ret->handle_cmp = aim_sncmp;
register_protocol(ret);
diff --git a/protocols/oscar/oscar_util.c b/protocols/oscar/oscar_util.c
index 806632ff..c2ce8e4d 100644
--- a/protocols/oscar/oscar_util.c
+++ b/protocols/oscar/oscar_util.c
@@ -3,9 +3,9 @@
/*
* int snlen(const char *)
-*
+*
* This takes a screen name and returns its length without
-* spaces. If there are no spaces in the SN, then the
+* spaces. If there are no spaces in the SN, then the
* return is equal to that of strlen().
*
*/
@@ -14,13 +14,15 @@ static int aim_snlen(const char *sn)
int i = 0;
const char *curPtr = NULL;
- if (!sn)
+ if (!sn) {
return 0;
+ }
curPtr = sn;
- while ( (*curPtr) != (char) '\0') {
- if ((*curPtr) != ' ')
- i++;
+ while ((*curPtr) != (char) '\0') {
+ if ((*curPtr) != ' ') {
+ i++;
+ }
curPtr++;
}
@@ -44,28 +46,33 @@ int aim_sncmp(const char *sn1, const char *sn2)
{
const char *curPtr1 = NULL, *curPtr2 = NULL;
- if (aim_snlen(sn1) != aim_snlen(sn2))
+ if (aim_snlen(sn1) != aim_snlen(sn2)) {
return 1;
+ }
curPtr1 = sn1;
curPtr2 = sn2;
- while ( (*curPtr1 != (char) '\0') && (*curPtr2 != (char) '\0') ) {
- if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) {
- if (*curPtr1 == ' ')
+ while ((*curPtr1 != (char) '\0') && (*curPtr2 != (char) '\0')) {
+ if ((*curPtr1 == ' ') || (*curPtr2 == ' ')) {
+ if (*curPtr1 == ' ') {
curPtr1++;
- if (*curPtr2 == ' ')
+ }
+ if (*curPtr2 == ' ') {
curPtr2++;
+ }
} else {
- if ( g_ascii_toupper(*curPtr1) != g_ascii_toupper(*curPtr2))
+ if (g_ascii_toupper(*curPtr1) != g_ascii_toupper(*curPtr2)) {
return 1;
+ }
curPtr1++;
curPtr2++;
}
}
/* Should both be NULL */
- if (*curPtr1 != *curPtr2)
+ if (*curPtr1 != *curPtr2) {
return 1;
+ }
return 0;
}
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
diff --git a/protocols/oscar/rxqueue.c b/protocols/oscar/rxqueue.c
index 9ac8466e..e5c52376 100644
--- a/protocols/oscar/rxqueue.c
+++ b/protocols/oscar/rxqueue.c
@@ -6,7 +6,7 @@
* aim_rxhandlers.c.
*/
-#include <aim.h>
+#include <aim.h>
#include <sys/socket.h>
@@ -15,16 +15,17 @@
*/
int aim_recv(int fd, void *buf, size_t count)
{
- int left, cur;
+ int left, cur;
for (cur = 0, left = count; left; ) {
int ret;
-
- ret = recv(fd, ((unsigned char *)buf)+cur, left, 0);
+
+ ret = recv(fd, ((unsigned char *) buf) + cur, left, 0);
/* Of course EOF is an error, only morons disagree with that. */
- if (ret <= 0)
+ if (ret <= 0) {
return -1;
+ }
cur += ret;
left -= ret;
@@ -41,18 +42,21 @@ static int aim_bstream_recv(aim_bstream_t *bs, int fd, size_t count)
{
int red = 0;
- if (!bs || (fd < 0) || (count < 0))
+ if (!bs || (fd < 0) || (count < 0)) {
return -1;
-
- if (count > (bs->len - bs->offset))
+ }
+
+ if (count > (bs->len - bs->offset)) {
count = bs->len - bs->offset; /* truncate to remaining space */
+ }
if (count) {
red = aim_recv(fd, bs->data + bs->offset, count);
- if (red <= 0)
+ if (red <= 0) {
return -1;
+ }
}
bs->offset += red;
@@ -62,9 +66,10 @@ static int aim_bstream_recv(aim_bstream_t *bs, int fd, size_t count)
int aim_bstream_init(aim_bstream_t *bs, guint8 *data, int len)
{
-
- if (!bs)
+
+ if (!bs) {
return -1;
+ }
bs->data = data;
bs->len = len;
@@ -86,8 +91,9 @@ int aim_bstream_curpos(aim_bstream_t *bs)
int aim_bstream_setpos(aim_bstream_t *bs, int off)
{
- if (off > bs->len)
+ if (off > bs->len) {
return -1;
+ }
bs->offset = off;
@@ -105,9 +111,10 @@ void aim_bstream_rewind(aim_bstream_t *bs)
int aim_bstream_advance(aim_bstream_t *bs, int n)
{
- if (aim_bstream_empty(bs) < n)
+ if (aim_bstream_empty(bs) < n) {
return 0; /* XXX throw an exception */
+ }
bs->offset += n;
return n;
@@ -115,76 +122,83 @@ int aim_bstream_advance(aim_bstream_t *bs, int n)
guint8 aimbs_get8(aim_bstream_t *bs)
{
-
- if (aim_bstream_empty(bs) < 1)
+
+ if (aim_bstream_empty(bs) < 1) {
return 0; /* XXX throw an exception */
-
+
+ }
bs->offset++;
-
+
return aimutil_get8(bs->data + bs->offset - 1);
}
guint16 aimbs_get16(aim_bstream_t *bs)
{
-
- if (aim_bstream_empty(bs) < 2)
+
+ if (aim_bstream_empty(bs) < 2) {
return 0; /* XXX throw an exception */
-
+
+ }
bs->offset += 2;
-
+
return aimutil_get16(bs->data + bs->offset - 2);
}
guint32 aimbs_get32(aim_bstream_t *bs)
{
-
- if (aim_bstream_empty(bs) < 4)
+
+ if (aim_bstream_empty(bs) < 4) {
return 0; /* XXX throw an exception */
-
+
+ }
bs->offset += 4;
-
+
return aimutil_get32(bs->data + bs->offset - 4);
}
guint8 aimbs_getle8(aim_bstream_t *bs)
{
-
- if (aim_bstream_empty(bs) < 1)
+
+ if (aim_bstream_empty(bs) < 1) {
return 0; /* XXX throw an exception */
-
+
+ }
bs->offset++;
-
+
return aimutil_getle8(bs->data + bs->offset - 1);
}
guint16 aimbs_getle16(aim_bstream_t *bs)
{
-
- if (aim_bstream_empty(bs) < 2)
+
+ if (aim_bstream_empty(bs) < 2) {
return 0; /* XXX throw an exception */
-
+
+ }
bs->offset += 2;
-
+
return aimutil_getle16(bs->data + bs->offset - 2);
}
guint32 aimbs_getle32(aim_bstream_t *bs)
{
-
- if (aim_bstream_empty(bs) < 4)
+
+ if (aim_bstream_empty(bs) < 4) {
return 0; /* XXX throw an exception */
-
+
+ }
bs->offset += 4;
-
+
return aimutil_getle32(bs->data + bs->offset - 4);
}
int aimbs_put8(aim_bstream_t *bs, guint8 v)
{
- if (aim_bstream_empty(bs) < 1)
+ if (aim_bstream_empty(bs) < 1) {
return 0; /* XXX throw an exception */
+ }
bs->offset += aimutil_put8(bs->data + bs->offset, v);
return 1;
@@ -193,9 +207,10 @@ int aimbs_put8(aim_bstream_t *bs, guint8 v)
int aimbs_put16(aim_bstream_t *bs, guint16 v)
{
- if (aim_bstream_empty(bs) < 2)
+ if (aim_bstream_empty(bs) < 2) {
return 0; /* XXX throw an exception */
+ }
bs->offset += aimutil_put16(bs->data + bs->offset, v);
return 2;
@@ -204,9 +219,10 @@ int aimbs_put16(aim_bstream_t *bs, guint16 v)
int aimbs_put32(aim_bstream_t *bs, guint32 v)
{
- if (aim_bstream_empty(bs) < 4)
+ if (aim_bstream_empty(bs) < 4) {
return 0; /* XXX throw an exception */
+ }
bs->offset += aimutil_put32(bs->data + bs->offset, v);
return 1;
@@ -215,9 +231,10 @@ int aimbs_put32(aim_bstream_t *bs, guint32 v)
int aimbs_putle8(aim_bstream_t *bs, guint8 v)
{
- if (aim_bstream_empty(bs) < 1)
+ if (aim_bstream_empty(bs) < 1) {
return 0; /* XXX throw an exception */
+ }
bs->offset += aimutil_putle8(bs->data + bs->offset, v);
return 1;
@@ -226,9 +243,10 @@ int aimbs_putle8(aim_bstream_t *bs, guint8 v)
int aimbs_putle16(aim_bstream_t *bs, guint16 v)
{
- if (aim_bstream_empty(bs) < 2)
+ if (aim_bstream_empty(bs) < 2) {
return 0; /* XXX throw an exception */
+ }
bs->offset += aimutil_putle16(bs->data + bs->offset, v);
return 2;
@@ -237,9 +255,10 @@ int aimbs_putle16(aim_bstream_t *bs, guint16 v)
int aimbs_putle32(aim_bstream_t *bs, guint32 v)
{
- if (aim_bstream_empty(bs) < 4)
+ if (aim_bstream_empty(bs) < 4) {
return 0; /* XXX throw an exception */
+ }
bs->offset += aimutil_putle32(bs->data + bs->offset, v);
return 1;
@@ -248,8 +267,9 @@ int aimbs_putle32(aim_bstream_t *bs, guint32 v)
int aimbs_getrawbuf(aim_bstream_t *bs, guint8 *buf, int len)
{
- if (aim_bstream_empty(bs) < len)
+ if (aim_bstream_empty(bs) < len) {
return 0;
+ }
memcpy(buf, bs->data + bs->offset, len);
bs->offset += len;
@@ -261,8 +281,9 @@ guint8 *aimbs_getraw(aim_bstream_t *bs, int len)
{
guint8 *ob;
- if (!(ob = g_malloc(len)))
+ if (!(ob = g_malloc(len))) {
return NULL;
+ }
if (aimbs_getrawbuf(bs, ob, len) < len) {
g_free(ob);
@@ -276,25 +297,27 @@ char *aimbs_getstr(aim_bstream_t *bs, int len)
{
guint8 *ob;
- if (!(ob = g_malloc(len+1)))
+ if (!(ob = g_malloc(len + 1))) {
return NULL;
+ }
if (aimbs_getrawbuf(bs, ob, len) < len) {
g_free(ob);
return NULL;
}
-
+
ob[len] = '\0';
- return (char *)ob;
+ return (char *) ob;
}
int aimbs_putraw(aim_bstream_t *bs, const guint8 *v, int len)
{
- if (aim_bstream_empty(bs) < len)
+ if (aim_bstream_empty(bs) < len) {
return 0; /* XXX throw an exception */
+ }
memcpy(bs->data + bs->offset, v, len);
bs->offset += len;
@@ -304,12 +327,14 @@ int aimbs_putraw(aim_bstream_t *bs, const guint8 *v, int len)
int aimbs_putbs(aim_bstream_t *bs, aim_bstream_t *srcbs, int len)
{
- if (aim_bstream_empty(srcbs) < len)
+ if (aim_bstream_empty(srcbs) < len) {
return 0; /* XXX throw exception (underrun) */
- if (aim_bstream_empty(bs) < len)
+ }
+ if (aim_bstream_empty(bs) < len) {
return 0; /* XXX throw exception (overflow) */
+ }
memcpy(bs->data + bs->offset, srcbs->data + srcbs->offset, len);
bs->offset += len;
srcbs->offset += len;
@@ -318,10 +343,10 @@ int aimbs_putbs(aim_bstream_t *bs, aim_bstream_t *srcbs, int len)
}
/**
- * aim_frame_destroy - free aim_frame_t
- * @frame: the frame to free
+ * aim_frame_destroy - free aim_frame_t
+ * @frame: the frame to free
*
- * returns -1 on error; 0 on success.
+ * returns -1 on error; 0 on success.
*
*/
void aim_frame_destroy(aim_frame_t *frame)
@@ -330,7 +355,7 @@ void aim_frame_destroy(aim_frame_t *frame)
g_free(frame->data.data); /* XXX aim_bstream_free */
g_free(frame);
-}
+}
/*
@@ -343,34 +368,37 @@ int aim_get_command(aim_session_t *sess, aim_conn_t *conn)
aim_bstream_t flaphdr;
aim_frame_t *newrx;
guint16 payloadlen;
-
- if (!sess || !conn)
+
+ if (!sess || !conn) {
return 0;
+ }
- if (conn->fd == -1)
+ if (conn->fd == -1) {
return -1; /* its a aim_conn_close()'d connection */
+ }
/* KIDS, THIS IS WHAT HAPPENS IF YOU USE CODE WRITTEN FOR GUIS IN A DAEMON!
-
+
And wouldn't it make sense to return something that prevents this function
from being called again IMMEDIATELY (and making the program suck up all
CPU time)?...
-
+
if (conn->fd < 3)
- return 0;
+ return 0;
*/
- if (conn->status & AIM_CONN_STATUS_INPROGRESS)
+ if (conn->status & AIM_CONN_STATUS_INPROGRESS) {
return aim_conn_completeconnect(sess, conn);
+ }
aim_bstream_init(&flaphdr, flaphdr_raw, sizeof(flaphdr_raw));
/*
* Read FLAP header. Six bytes:
- *
+ *
* 0 char -- Always 0x2a
* 1 char -- Channel ID. Usually 2 -- 1 and 4 are used during login.
- * 2 short -- Sequence number
+ * 2 short -- Sequence number
* 4 short -- Number of data bytes that follow.
*/
if (aim_bstream_recv(&flaphdr, conn->fd, 6) < 6) {
@@ -390,15 +418,16 @@ int aim_get_command(aim_session_t *sess, aim_conn_t *conn)
imcb_error(sess->aux_data, "FLAP framing disrupted");
aim_conn_close(conn);
return -1;
- }
+ }
/* allocate a new struct */
- if (!(newrx = (aim_frame_t *)g_new0(aim_frame_t,1)))
+ if (!(newrx = (aim_frame_t *) g_new0(aim_frame_t, 1))) {
return -1;
+ }
/* we're doing FLAP if we're here */
newrx->hdrtype = AIM_FRAMETYPE_FLAP;
-
+
newrx->hdr.flap.type = aimbs_get8(&flaphdr);
newrx->hdr.flap.seqnum = aimbs_get16(&flaphdr);
payloadlen = aimbs_get16(&flaphdr);
@@ -421,8 +450,9 @@ int aim_get_command(aim_session_t *sess, aim_conn_t *conn)
aim_conn_close(conn);
return -1;
}
- } else
+ } else {
aim_bstream_init(&newrx->data, NULL, 0);
+ }
aim_bstream_rewind(&newrx->data);
@@ -431,27 +461,28 @@ int aim_get_command(aim_session_t *sess, aim_conn_t *conn)
newrx->next = NULL; /* this will always be at the bottom */
- if (!sess->queue_incoming)
+ if (!sess->queue_incoming) {
sess->queue_incoming = newrx;
- else {
+ } else {
aim_frame_t *cur;
- for (cur = sess->queue_incoming; cur->next; cur = cur->next)
+ for (cur = sess->queue_incoming; cur->next; cur = cur->next) {
;
+ }
cur->next = newrx;
}
newrx->conn->lastactivity = time(NULL);
- return 0;
+ return 0;
}
/*
* Purge recieve queue of all handled commands (->handled==1). Also
* allows for selective freeing using ->nofree so that the client can
- * keep the data for various purposes.
+ * keep the data for various purposes.
*
- * If ->nofree is nonzero, the frame will be delinked from the global list,
+ * If ->nofree is nonzero, the frame will be delinked from the global list,
* but will not be free'ed. The client _must_ keep a pointer to the
* data -- libfaim will not! If the client marks ->nofree but
* does not keep a pointer, it's lost forever.
@@ -465,12 +496,14 @@ void aim_purge_rxqueue(aim_session_t *sess)
if (cur->handled) {
*prev = cur->next;
-
- if (!cur->nofree)
+
+ if (!cur->nofree) {
aim_frame_destroy(cur);
+ }
- } else
+ } else {
prev = &cur->next;
+ }
}
return;
@@ -488,9 +521,10 @@ void aim_rxqueue_cleanbyconn(aim_session_t *sess, aim_conn_t *conn)
aim_frame_t *currx;
for (currx = sess->queue_incoming; currx; currx = currx->next) {
- if ((!currx->handled) && (currx->conn == conn))
+ if ((!currx->handled) && (currx->conn == conn)) {
currx->handled = 1;
- }
+ }
+ }
return;
}
diff --git a/protocols/oscar/search.c b/protocols/oscar/search.c
index 4e0d3858..30d392ae 100644
--- a/protocols/oscar/search.c
+++ b/protocols/oscar/search.c
@@ -21,12 +21,14 @@ static int error(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mo
return 0;
}
- 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->data /* address */);
+ }
/* XXX freesnac()? */
- if (snac2)
+ if (snac2) {
g_free(snac2->data);
+ }
g_free(snac2);
return ret;
@@ -41,30 +43,33 @@ static int reply(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mo
aim_snac_t *snac2;
char *searchaddr = NULL;
- if ((snac2 = aim_remsnac(sess, snac->id)))
- searchaddr = (char *)snac2->data;
+ if ((snac2 = aim_remsnac(sess, snac->id))) {
+ searchaddr = (char *) snac2->data;
+ }
tlvlist = aim_readtlvchain(bs);
m = aim_counttlvchain(&tlvlist);
/* XXX uhm. */
- while ((cur = aim_gettlv_str(tlvlist, 0x0001, j+1)) && j < m) {
- buf = g_realloc(buf, (j+1) * (MAXSNLEN+1));
+ while ((cur = aim_gettlv_str(tlvlist, 0x0001, j + 1)) && j < m) {
+ buf = g_realloc(buf, (j + 1) * (MAXSNLEN + 1));
- strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN);
+ strncpy(&buf[j * (MAXSNLEN + 1)], cur, MAXSNLEN);
g_free(cur);
- j++;
+ j++;
}
aim_freetlvchain(&tlvlist);
- 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, searchaddr, j, buf);
+ }
/* XXX freesnac()? */
- if (snac2)
+ if (snac2) {
g_free(snac2->data);
+ }
g_free(snac2);
g_free(buf);
@@ -75,10 +80,11 @@ static int reply(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mo
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 == 0x0001)
+ if (snac->subtype == 0x0001) {
return error(sess, mod, rx, snac, bs);
- else if (snac->subtype == 0x0003)
+ } else if (snac->subtype == 0x0003) {
return reply(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/service.c b/protocols/oscar/service.c
index a3b37c33..673cc5ad 100644
--- a/protocols/oscar/service.c
+++ b/protocols/oscar/service.c
@@ -10,23 +10,25 @@
/* Client Online (group 1, subtype 2) */
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);
aim_putsnac(&fr->data, 0x0001, 0x0002, 0x0000, snacid);
/*
* 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) {
aim_module_t *mod;
@@ -36,7 +38,7 @@ int aim_clientready(aim_session_t *sess, aim_conn_t *conn)
aimbs_put16(&fr->data, mod->version);
aimbs_put16(&fr->data, mod->toolid);
aimbs_put16(&fr->data, mod->toolversion);
- }
+ }
}
aim_tx_enqueue(sess, fr);
@@ -46,7 +48,7 @@ int aim_clientready(aim_session_t *sess, aim_conn_t *conn)
/*
* 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.
*
@@ -54,9 +56,9 @@ int aim_clientready(aim_session_t *sess, aim_conn_t *conn)
*
* 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)
{
@@ -64,8 +66,9 @@ static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
int famcount;
- 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++) {
families[famcount] = aimbs_get16(bs);
@@ -85,7 +88,7 @@ static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
*/
aim_setversions(sess, rx->conn);
- return 1;
+ return 1;
}
/* Service request (group 1, type 4) */
@@ -108,35 +111,37 @@ static int redirect(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
tlvlist = aim_readtlvchain(bs);
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;
}
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 */
origsnac = aim_remsnac(sess, snac->id);
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;
redir.chat.room = csi->name;
redir.chat.instance = csi->instance;
}
- 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);
+ g_free((void *) redir.ip);
+ g_free((void *) redir.cookie);
- if (origsnac)
+ if (origsnac) {
g_free(origsnac->data);
+ }
g_free(origsnac);
aim_freetlvchain(&tlvlist);
@@ -156,7 +161,7 @@ int aim_reqrates(aim_session_t *sess, aim_conn_t *conn)
* level, etc), and a set of SNAC family/type pairs associated with
* 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
* offenses for other SNACs in the same class (ie, sending messages
@@ -170,10 +175,10 @@ int aim_reqrates(aim_session_t *sess, aim_conn_t *conn)
* members as follows...
*
* 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
*
@@ -189,32 +194,35 @@ int aim_reqrates(aim_session_t *sess, aim_conn_t *conn)
* - Outgoing chat ICBMs
*
* 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.
*
* The last thing that needs to be learned about the rate limiting
* system is how the actual numbers relate to the passing of time. This
* seems to be a big mystery.
- *
+ *
*/
static void rc_addclass(struct rateclass **head, struct rateclass *inrc)
{
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;
}
@@ -224,8 +232,9 @@ static struct rateclass *rc_findclass(struct rateclass **head, guint16 id)
struct rateclass *rc;
for (rc = *head; rc; rc = rc->next) {
- if (rc->classid == id)
+ if (rc->classid == id) {
return rc;
+ }
}
return NULL;
@@ -235,20 +244,23 @@ static void rc_addpair(struct rateclass *rc, guint16 group, guint16 type)
{
struct snacpair *sp, *sp2;
- if (!(sp = g_new0(struct snacpair, 1)))
+ if (!(sp = g_new0(struct snacpair, 1))) {
return;
+ }
sp->group = group;
sp->subtype = type;
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;
}
@@ -256,7 +268,7 @@ static void rc_addpair(struct rateclass *rc, guint16 group, guint16 type)
/* Rate Parameters (group 1, type 7) */
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;
@@ -283,11 +295,12 @@ static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
* The server will send an extra five bytes of parameters
* 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);
}
@@ -311,8 +324,9 @@ static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
group = aimbs_get16(bs);
subtype = aimbs_get16(bs);
- if (rc)
+ if (rc) {
rc_addpair(rc, group, subtype);
+ }
}
}
@@ -331,8 +345,9 @@ static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
/*
* 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);
+ }
return 1;
@@ -341,19 +356,21 @@ static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
/* Add Rate Parameter (group 1, type 8) */
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);
@@ -369,7 +386,7 @@ static int ratechange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
code = aimbs_get16(bs);
rateclass = aimbs_get16(bs);
-
+
windowsize = aimbs_get32(bs);
clear = aimbs_get32(bs);
alert = aimbs_get32(bs);
@@ -378,19 +395,21 @@ static int ratechange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
currentavg = aimbs_get32(bs);
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;
}
/*
- * How Migrations work.
+ * 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
+ * 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.
*
* The Server Pause contains no data.
@@ -402,8 +421,9 @@ static int serverpause(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
{
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;
}
@@ -413,8 +433,9 @@ static int serverresume(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
{
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;
}
@@ -433,8 +454,9 @@ static int selfinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
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;
}
@@ -447,14 +469,16 @@ static int evilnotify(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
aim_userinfo_t userinfo;
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;
}
@@ -463,7 +487,7 @@ static int evilnotify(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
* Service Migrate (group 1, type 0x12)
*
* 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.
*
*/
@@ -481,7 +505,7 @@ static int migrate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_
* migration can actually be quite selective about what groups it
* 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.
*
* Let's play dumb and not support that.
@@ -496,13 +520,15 @@ static int migrate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_
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);
g_free(ip);
@@ -527,20 +553,21 @@ static int motd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mod
* 2 Advisory upgrade
* 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);
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);
@@ -549,7 +576,7 @@ static int motd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_mod
return ret;
}
-/*
+/*
* Set privacy flags (group 1, type 0x14)
*
* Normally 0x03.
@@ -564,14 +591,14 @@ int aim_bos_setprivacyflags(aim_session_t *sess, aim_conn_t *conn, guint32 flags
}
-/*
- * Set client versions (group 1, subtype 0x17)
+/*
+ * Set client versions (group 1, subtype 0x17)
*
- * If you've seen the clientonline/clientready SNAC you're probably
+ * 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
* the rate information based on what version of group 1 we advertise here.
@@ -579,23 +606,25 @@ int aim_bos_setprivacyflags(aim_session_t *sess, aim_conn_t *conn, guint32 flags
*/
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);
aim_putsnac(&fr->data, 0x0001, 0x0017, 0x0000, snacid);
/*
* 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) {
aim_module_t *mod;
@@ -629,12 +658,12 @@ static int hostversions(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
return 1;
}
-/*
+/*
* 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.
*/
int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status)
@@ -646,21 +675,23 @@ int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status)
struct im_connection *ic = sess ? sess->aux_data : NULL;
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);
return 0;
@@ -687,14 +718,14 @@ int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status)
* If the client does not send any data back, or the data does not match
* 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.
+ * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html.
*
- * Note, however, that numerous inconsistencies can cause the above error,
+ * 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
* played this game for a couple years now, generating the above message
@@ -717,8 +748,9 @@ static int memrequest(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
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);
aim_freetlvchain(&list);
@@ -729,30 +761,31 @@ static int memrequest(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, a
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 == 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;
}
diff --git a/protocols/oscar/snac.c b/protocols/oscar/snac.c
index 8a75b2a0..d5c4e053 100644
--- a/protocols/oscar/snac.c
+++ b/protocols/oscar/snac.c
@@ -1,10 +1,10 @@
/*
*
- * Various SNAC-related dodads...
+ * Various SNAC-related dodads...
*
* outstanding_snacs is a list of aim_snac_t structs. A SNAC should be added
* whenever a new SNAC is sent and it should remain in the list until the
- * response for it has been receieved.
+ * response for it has been receieved.
*
* cleansnacs() should be called periodically by the client in order
* to facilitate the aging out of unreplied-to SNACs. This can and does
@@ -23,13 +23,15 @@ void aim_initsnachash(aim_session_t *sess)
{
int i;
- for (i = 0; i < AIM_SNAC_HASH_SIZE; i++)
+ for (i = 0; i < AIM_SNAC_HASH_SIZE; i++) {
sess->snac_hash[i] = NULL;
+ }
return;
}
-aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags, const void *data, const int datalen)
+aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags,
+ const void *data, const int datalen)
{
aim_snac_t snac;
@@ -39,11 +41,13 @@ aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guin
snac.flags = flags;
if (datalen) {
- if (!(snac.data = g_malloc(datalen)))
+ if (!(snac.data = g_malloc(datalen))) {
return 0; /* er... */
+ }
memcpy(snac.data, data, datalen);
- } else
+ } else {
snac.data = NULL;
+ }
return aim_newsnac(sess, &snac);
}
@@ -57,42 +61,45 @@ static aim_snacid_t aim_newsnac(aim_session_t *sess, aim_snac_t *newsnac)
aim_snac_t *snac;
int index;
- if (!newsnac)
+ if (!newsnac) {
return 0;
+ }
- if (!(snac = g_malloc(sizeof(aim_snac_t))))
+ if (!(snac = g_malloc(sizeof(aim_snac_t)))) {
return 0;
+ }
memcpy(snac, newsnac, sizeof(aim_snac_t));
snac->issuetime = time(NULL);
index = snac->id % AIM_SNAC_HASH_SIZE;
- snac->next = (aim_snac_t *)sess->snac_hash[index];
- sess->snac_hash[index] = (void *)snac;
+ snac->next = (aim_snac_t *) sess->snac_hash[index];
+ sess->snac_hash[index] = (void *) snac;
return snac->id;
}
/*
- * Finds a snac structure with the passed SNAC ID,
+ * Finds a snac structure with the passed SNAC ID,
* removes it from the list/hash, and returns a pointer to it.
*
* The returned structure must be freed by the caller.
*
*/
-aim_snac_t *aim_remsnac(aim_session_t *sess, aim_snacid_t id)
+aim_snac_t *aim_remsnac(aim_session_t *sess, aim_snacid_t id)
{
aim_snac_t *cur, **prev;
int index;
index = id % AIM_SNAC_HASH_SIZE;
- for (prev = (aim_snac_t **)&sess->snac_hash[index]; (cur = *prev); ) {
+ for (prev = (aim_snac_t **) &sess->snac_hash[index]; (cur = *prev); ) {
if (cur->id == id) {
*prev = cur->next;
return cur;
- } else
+ } else {
prev = &cur->next;
+ }
}
return cur;
@@ -113,12 +120,13 @@ void aim_cleansnacs(aim_session_t *sess, int maxage)
aim_snac_t *cur, **prev;
time_t curtime;
- if (!sess->snac_hash[i])
+ if (!sess->snac_hash[i]) {
continue;
+ }
curtime = time(NULL); /* done here in case we waited for the lock */
- for (prev = (aim_snac_t **)&sess->snac_hash[i]; (cur = *prev); ) {
+ for (prev = (aim_snac_t **) &sess->snac_hash[i]; (cur = *prev); ) {
if ((curtime - cur->issuetime) > maxage) {
*prev = cur->next;
@@ -127,8 +135,9 @@ void aim_cleansnacs(aim_session_t *sess, int maxage)
g_free(cur->data);
g_free(cur);
- } else
+ } else {
prev = &cur->next;
+ }
}
}
diff --git a/protocols/oscar/ssi.c b/protocols/oscar/ssi.c
index e8502f68..7583114f 100644
--- a/protocols/oscar/ssi.c
+++ b/protocols/oscar/ssi.c
@@ -2,16 +2,16 @@
* Server-Side/Stored Information.
*
* Relatively new facility that allows storing of certain types of information,
- * such as a users buddy list, permit/deny list, and permit/deny preferences,
+ * such as a users buddy list, permit/deny list, and permit/deny preferences,
* to be stored on the server, so that they can be accessed from any client.
*
- * We keep a copy of the ssi data in sess->ssi, because the data needs to be
- * accessed for various reasons. So all the "aim_ssi_itemlist_bleh" functions
+ * We keep a copy of the ssi data in sess->ssi, because the data needs to be
+ * accessed for various reasons. So all the "aim_ssi_itemlist_bleh" functions
* near the top just manage the local data.
*
- * The SNAC sending and receiving functions are lower down in the file, and
- * they're simpler. They are in the order of the subtypes they deal with,
- * starting with the request rights function (subtype 0x0002), then parse
+ * The SNAC sending and receiving functions are lower down in the file, and
+ * they're simpler. They are in the order of the subtypes they deal with,
+ * starting with the request rights function (subtype 0x0002), then parse
* rights (subtype 0x0003), then--well, you get the idea.
*
* This is entirely too complicated.
@@ -29,50 +29,59 @@
* Locally add a new item to the given item list.
*
* @param list A pointer to a pointer to the current list of items.
- * @param parent A pointer to the parent group, or NULL if the item should have no
+ * @param parent A pointer to the parent group, or NULL if the item should have no
* parent group (ie. the group ID# should be 0).
- * @param name A null terminated string of the name of the new item, or NULL if the
+ * @param name A null terminated string of the name of the new item, or NULL if the
* item should have no name.
* @param type The type of the item, 0x0001 for a contact, 0x0002 for a group, etc.
* @return The newly created item.
*/
-static struct aim_ssi_item *aim_ssi_itemlist_add(struct aim_ssi_item **list, struct aim_ssi_item *parent, char *name, guint16 type)
+static struct aim_ssi_item *aim_ssi_itemlist_add(struct aim_ssi_item **list, struct aim_ssi_item *parent, char *name,
+ guint16 type)
{
int i;
struct aim_ssi_item *cur, *newitem;
- if (!(newitem = g_new0(struct aim_ssi_item, 1)))
+ if (!(newitem = g_new0(struct aim_ssi_item, 1))) {
return NULL;
+ }
/* Set the name */
if (name) {
- if (!(newitem->name = (char *)g_malloc((strlen(name)+1)*sizeof(char)))) {
+ if (!(newitem->name = (char *) g_malloc((strlen(name) + 1) * sizeof(char)))) {
g_free(newitem);
return NULL;
}
strcpy(newitem->name, name);
- } else
+ } else {
newitem->name = NULL;
+ }
/* Set the group ID# and the buddy ID# */
newitem->gid = 0x0000;
newitem->bid = 0x0000;
if (type == AIM_SSI_TYPE_GROUP) {
- if (name)
+ if (name) {
do {
newitem->gid += 0x0001;
- for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
- if ((cur->gid == newitem->gid) && (cur->gid == newitem->gid))
- i=1;
+ for (cur = *list, i = 0; ((cur) && (!i)); cur = cur->next) {
+ if ((cur->gid == newitem->gid) && (cur->gid == newitem->gid)) {
+ i = 1;
+ }
+ }
} while (i);
+ }
} else {
- if (parent)
+ if (parent) {
newitem->gid = parent->gid;
+ }
do {
newitem->bid += 0x0001;
- for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
- if ((cur->bid == newitem->bid) && (cur->gid == newitem->gid))
- i=1;
+ for (cur = *list, i = 0; ((cur) && (!i)); cur = cur->next) {
+ if ((cur->bid == newitem->bid) && (cur->gid == newitem->gid)) {
+ i = 1;
+ }
+ }
} while (i);
}
@@ -99,39 +108,48 @@ static int aim_ssi_itemlist_rebuildgroup(struct aim_ssi_item **list, struct aim_
/* Free the old additional data */
if (parentgroup->data) {
- aim_freetlvchain((aim_tlvlist_t **)&parentgroup->data);
+ aim_freetlvchain((aim_tlvlist_t **) &parentgroup->data);
parentgroup->data = NULL;
}
/* Find the length for the new additional data */
newlen = 0;
if (parentgroup->gid == 0x0000) {
- for (cur=*list; cur; cur=cur->next)
- if ((cur->gid != 0x0000) && (cur->type == AIM_SSI_TYPE_GROUP))
+ for (cur = *list; cur; cur = cur->next) {
+ if ((cur->gid != 0x0000) && (cur->type == AIM_SSI_TYPE_GROUP)) {
newlen += 2;
+ }
+ }
} else {
- for (cur=*list; cur; cur=cur->next)
- if ((cur->gid == parentgroup->gid) && (cur->type == AIM_SSI_TYPE_BUDDY))
+ for (cur = *list; cur; cur = cur->next) {
+ if ((cur->gid == parentgroup->gid) && (cur->type == AIM_SSI_TYPE_BUDDY)) {
newlen += 2;
+ }
+ }
}
/* Rebuild the additional data */
- if (newlen>0) {
+ if (newlen > 0) {
guint8 *newdata;
- if (!(newdata = (guint8 *)g_malloc((newlen)*sizeof(guint8))))
+ if (!(newdata = (guint8 *) g_malloc((newlen) * sizeof(guint8)))) {
return -ENOMEM;
+ }
newlen = 0;
if (parentgroup->gid == 0x0000) {
- for (cur=*list; cur; cur=cur->next)
- if ((cur->gid != 0x0000) && (cur->type == AIM_SSI_TYPE_GROUP))
- newlen += aimutil_put16(newdata+newlen, cur->gid);
+ for (cur = *list; cur; cur = cur->next) {
+ if ((cur->gid != 0x0000) && (cur->type == AIM_SSI_TYPE_GROUP)) {
+ newlen += aimutil_put16(newdata + newlen, cur->gid);
+ }
+ }
} else {
- for (cur=*list; cur; cur=cur->next)
- if ((cur->gid == parentgroup->gid) && (cur->type == AIM_SSI_TYPE_BUDDY))
- newlen += aimutil_put16(newdata+newlen, cur->bid);
+ for (cur = *list; cur; cur = cur->next) {
+ if ((cur->gid == parentgroup->gid) && (cur->type == AIM_SSI_TYPE_BUDDY)) {
+ newlen += aimutil_put16(newdata + newlen, cur->bid);
+ }
+ }
}
- aim_addtlvtochain_raw((aim_tlvlist_t **)&(parentgroup->data), 0x00c8, newlen, newdata);
+ aim_addtlvtochain_raw((aim_tlvlist_t **) &(parentgroup->data), 0x00c8, newlen, newdata);
g_free(newdata);
}
@@ -151,8 +169,12 @@ static int aim_ssi_freelist(aim_session_t *sess)
cur = sess->ssi.items;
while (cur) {
- if (cur->name) g_free(cur->name);
- if (cur->data) aim_freetlvchain((aim_tlvlist_t **)&cur->data);
+ if (cur->name) {
+ g_free(cur->name);
+ }
+ if (cur->data) {
+ aim_freetlvchain((aim_tlvlist_t **) &cur->data);
+ }
delitem = cur;
cur = cur->next;
g_free(delitem);
@@ -160,7 +182,7 @@ static int aim_ssi_freelist(aim_session_t *sess)
sess->ssi.items = NULL;
sess->ssi.revision = 0;
- sess->ssi.timestamp = (time_t)0;
+ sess->ssi.timestamp = (time_t) 0;
return 0;
}
@@ -176,14 +198,17 @@ static int aim_ssi_freelist(aim_session_t *sess)
struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gid, guint16 bid)
{
struct aim_ssi_item *cur;
- for (cur=list; cur; cur=cur->next)
- if ((cur->gid == gid) && (cur->bid == bid))
+
+ for (cur = list; cur; cur = cur->next) {
+ if ((cur->gid == gid) && (cur->bid == bid)) {
return cur;
+ }
+ }
return NULL;
}
/**
- * Locally find an item given a group name, screen name, and type. If group name
+ * Locally find an item given a group name, screen name, and type. If group name
* and screen name are null, then just return the first item of the given type.
*
* @param list A pointer to the current list of items.
@@ -195,27 +220,37 @@ struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gi
struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, char *gn, char *sn, guint16 type)
{
struct aim_ssi_item *cur;
- if (!list)
+
+ if (!list) {
return NULL;
+ }
if (gn && sn) { /* For finding buddies in groups */
- for (cur=list; cur; cur=cur->next)
+ for (cur = list; cur; cur = cur->next) {
if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn))) {
struct aim_ssi_item *curg;
- for (curg=list; curg; curg=curg->next)
- if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid) && (curg->name) && !(aim_sncmp(curg->name, gn)))
+ for (curg = list; curg; curg = curg->next) {
+ if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid) &&
+ (curg->name) && !(aim_sncmp(curg->name, gn))) {
return cur;
+ }
+ }
}
+ }
} else if (sn) { /* For finding groups, permits, denies, and ignores */
- for (cur=list; cur; cur=cur->next)
- if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn)))
+ for (cur = list; cur; cur = cur->next) {
+ if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn))) {
return cur;
+ }
+ }
- /* For stuff without names--permit deny setting, visibility mask, etc. */
- } else for (cur=list; cur; cur=cur->next) {
- if (cur->type == type)
- return cur;
+ /* For stuff without names--permit deny setting, visibility mask, etc. */
+ } else { for (cur = list; cur; cur = cur->next) {
+ if (cur->type == type) {
+ return cur;
+ }
+ }
}
return NULL;
@@ -231,13 +266,18 @@ struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, char *
struct aim_ssi_item *aim_ssi_itemlist_findparent(struct aim_ssi_item *list, char *sn)
{
struct aim_ssi_item *cur, *curg;
- if (!list || !sn)
+
+ if (!list || !sn) {
return NULL;
- if (!(cur = aim_ssi_itemlist_finditem(list, NULL, sn, AIM_SSI_TYPE_BUDDY)))
+ }
+ if (!(cur = aim_ssi_itemlist_finditem(list, NULL, sn, AIM_SSI_TYPE_BUDDY))) {
return NULL;
- for (curg=list; curg; curg=curg->next)
- if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid))
+ }
+ for (curg = list; curg; curg = curg->next) {
+ if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid)) {
return curg;
+ }
+ }
return NULL;
}
@@ -250,20 +290,22 @@ struct aim_ssi_item *aim_ssi_itemlist_findparent(struct aim_ssi_item *list, char
int aim_ssi_getpermdeny(struct aim_ssi_item *list)
{
struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, NULL, NULL, AIM_SSI_TYPE_PDINFO);
+
if (cur) {
aim_tlvlist_t *tlvlist = cur->data;
if (tlvlist) {
aim_tlv_t *tlv = aim_gettlv(tlvlist, 0x00ca, 1);
- if (tlv && tlv->value)
+ if (tlv && tlv->value) {
return aimutil_get8(tlv->value);
+ }
}
}
return 0;
}
/**
- * Add the given packet to the holding queue. We totally need to send SSI SNACs one at
- * a time, so we have a local queue where packets get put before they are sent, and
+ * Add the given packet to the holding queue. We totally need to send SSI SNACs one at
+ * a time, so we have a local queue where packets get put before they are sent, and
* then we send stuff one at a time, nice and orderly-like.
*
* @param sess The oscar session.
@@ -275,16 +317,20 @@ static int aim_ssi_enqueue(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *f
{
aim_frame_t *cur;
- if (!sess || !conn || !fr)
+ if (!sess || !conn || !fr) {
return -EINVAL;
+ }
fr->next = NULL;
if (sess->ssi.holding_queue == NULL) {
sess->ssi.holding_queue = fr;
- if (!sess->ssi.waiting_for_ack)
+ if (!sess->ssi.waiting_for_ack) {
aim_ssi_modbegin(sess, conn);
+ }
} else {
- for (cur = sess->ssi.holding_queue; cur->next; cur = cur->next) ;
+ for (cur = sess->ssi.holding_queue; cur->next; cur = cur->next) {
+ ;
+ }
cur->next = fr;
}
@@ -292,8 +338,8 @@ static int aim_ssi_enqueue(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *f
}
/**
- * Send the next SNAC from the holding queue. This is called
- * automatically when an ack from an add, mod, or del is received.
+ * Send the next SNAC from the holding queue. This is called
+ * automatically when an ack from an add, mod, or del is received.
* If the queue is empty, it sends the modend SNAC.
*
* @param sess The oscar session.
@@ -304,8 +350,9 @@ static int aim_ssi_dispatch(aim_session_t *sess, aim_conn_t *conn)
{
aim_frame_t *cur;
- if (!sess || !conn)
+ if (!sess || !conn) {
return -EINVAL;
+ }
if (!sess->ssi.waiting_for_ack) {
if (sess->ssi.holding_queue) {
@@ -314,8 +361,9 @@ static int aim_ssi_dispatch(aim_session_t *sess, aim_conn_t *conn)
sess->ssi.holding_queue->next = NULL;
aim_tx_enqueue(sess, sess->ssi.holding_queue);
sess->ssi.holding_queue = cur;
- } else
+ } else {
aim_ssi_modend(sess, conn);
+ }
}
return 0;
@@ -337,22 +385,25 @@ int aim_ssi_addbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
struct aim_ssi_item *parentgroup, **newitems;
guint16 i;
- if (!sess || !conn || !gn || !sn || !num)
+ if (!sess || !conn || !gn || !sn || !num) {
return -EINVAL;
+ }
/* Look up the parent group */
if (!(parentgroup = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, gn, AIM_SSI_TYPE_GROUP))) {
aim_ssi_addgroups(sess, conn, &gn, 1);
- if (!(parentgroup = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, gn, AIM_SSI_TYPE_GROUP)))
+ if (!(parentgroup = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, gn, AIM_SSI_TYPE_GROUP))) {
return -ENOMEM;
+ }
}
/* Allocate an array of pointers to each of the new items */
- if (!(newitems = g_new0(struct aim_ssi_item *, num)))
+ if (!(newitems = g_new0(struct aim_ssi_item *, num))) {
return -ENOMEM;
+ }
/* Add items to the local list, and index them in the array */
- for (i=0; i<num; i++)
+ for (i = 0; i < num; i++) {
if (!(newitems[i] = aim_ssi_itemlist_add(&sess->ssi.items, parentgroup, sn[i], AIM_SSI_TYPE_BUDDY))) {
g_free(newitems);
return -ENOMEM;
@@ -361,6 +412,7 @@ int aim_ssi_addbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
aim_addtlvtochain_noval(&tl, 0x66);
newitems[i]->data = tl;
}
+ }
/* Send the add item SNAC */
if ((i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD))) {
@@ -372,22 +424,25 @@ int aim_ssi_addbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
g_free(newitems);
/* Rebuild the additional data in the parent group */
- if ((i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup)))
+ if ((i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup))) {
return i;
+ }
/* Send the mod item SNAC */
- if ((i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD )))
+ if ((i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD))) {
return i;
+ }
/* Begin sending SSI SNACs */
- if (!(i = aim_ssi_dispatch(sess, conn)))
+ if (!(i = aim_ssi_dispatch(sess, conn))) {
return i;
+ }
return 0;
}
/**
- * Add the master group (the group containing all groups). This is called by
+ * Add the master group (the group containing all groups). This is called by
* aim_ssi_addgroups, if necessary.
*
* @param sess The oscar session.
@@ -398,12 +453,14 @@ int aim_ssi_addmastergroup(aim_session_t *sess, aim_conn_t *conn)
{
struct aim_ssi_item *newitem;
- if (!sess || !conn)
+ if (!sess || !conn) {
return -EINVAL;
+ }
/* Add the item to the local list, and keep a pointer to it */
- if (!(newitem = aim_ssi_itemlist_add(&sess->ssi.items, NULL, NULL, AIM_SSI_TYPE_GROUP)))
+ if (!(newitem = aim_ssi_itemlist_add(&sess->ssi.items, NULL, NULL, AIM_SSI_TYPE_GROUP))) {
return -ENOMEM;
+ }
/* If there are any existing groups (technically there shouldn't be, but */
/* just in case) then add their group ID#'s to the additional data */
@@ -432,26 +489,30 @@ int aim_ssi_addgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
struct aim_ssi_item *parentgroup, **newitems;
guint16 i;
- if (!sess || !conn || !gn || !num)
+ if (!sess || !conn || !gn || !num) {
return -EINVAL;
+ }
/* Look up the parent group */
if (!(parentgroup = aim_ssi_itemlist_find(sess->ssi.items, 0, 0))) {
aim_ssi_addmastergroup(sess, conn);
- if (!(parentgroup = aim_ssi_itemlist_find(sess->ssi.items, 0, 0)))
+ if (!(parentgroup = aim_ssi_itemlist_find(sess->ssi.items, 0, 0))) {
return -ENOMEM;
+ }
}
/* Allocate an array of pointers to each of the new items */
- if (!(newitems = g_new0(struct aim_ssi_item *, num)))
+ if (!(newitems = g_new0(struct aim_ssi_item *, num))) {
return -ENOMEM;
+ }
/* Add items to the local list, and index them in the array */
- for (i=0; i<num; i++)
+ for (i = 0; i < num; i++) {
if (!(newitems[i] = aim_ssi_itemlist_add(&sess->ssi.items, parentgroup, gn[i], AIM_SSI_TYPE_GROUP))) {
g_free(newitems);
return -ENOMEM;
}
+ }
/* Send the add item SNAC */
if ((i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD))) {
@@ -463,30 +524,33 @@ int aim_ssi_addgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
g_free(newitems);
/* Rebuild the additional data in the parent group */
- if ((i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup)))
+ if ((i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup))) {
return i;
+ }
/* Send the mod item SNAC */
- if ((i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD)))
+ if ((i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD))) {
return i;
+ }
/* Begin sending SSI SNACs */
- if (!(i = aim_ssi_dispatch(sess, conn)))
+ if (!(i = aim_ssi_dispatch(sess, conn))) {
return i;
+ }
return 0;
}
/**
- * Add an array of a certain type of item to the list. This can be used for
- * permit buddies, deny buddies, ICQ's ignore buddies, and probably other
+ * Add an array of a certain type of item to the list. This can be used for
+ * permit buddies, deny buddies, ICQ's ignore buddies, and probably other
* types, also.
*
* @param sess The oscar session.
* @param conn The bos connection for this session.
* @param sn An array of null terminated strings of the names you want to add.
* @param num The number of groups names you are adding (size of the sn array).
- * @param type The type of item you want to add. See the AIM_SSI_TYPE_BLEH
+ * @param type The type of item you want to add. See the AIM_SSI_TYPE_BLEH
* #defines in aim.h.
* @return Return 0 if no errors, otherwise return the error number.
*/
@@ -495,19 +559,22 @@ int aim_ssi_addpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned i
struct aim_ssi_item **newitems;
guint16 i;
- if (!sess || !conn || !sn || !num)
+ if (!sess || !conn || !sn || !num) {
return -EINVAL;
+ }
/* Allocate an array of pointers to each of the new items */
- if (!(newitems = g_new0(struct aim_ssi_item *, num)))
+ if (!(newitems = g_new0(struct aim_ssi_item *, num))) {
return -ENOMEM;
+ }
/* Add items to the local list, and index them in the array */
- for (i=0; i<num; i++)
+ for (i = 0; i < num; i++) {
if (!(newitems[i] = aim_ssi_itemlist_add(&sess->ssi.items, NULL, sn[i], type))) {
g_free(newitems);
return -ENOMEM;
}
+ }
/* Send the add item SNAC */
if ((i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD))) {
@@ -519,14 +586,15 @@ int aim_ssi_addpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned i
g_free(newitems);
/* Begin sending SSI SNACs */
- if (!(i = aim_ssi_dispatch(sess, conn)))
+ if (!(i = aim_ssi_dispatch(sess, conn))) {
return i;
+ }
return 0;
}
/**
- * Move a buddy from one group to another group. This basically just deletes the
+ * Move a buddy from one group to another group. This basically just deletes the
* buddy and re-adds it.
*
* @param sess The oscar session.
@@ -541,16 +609,19 @@ int aim_ssi_movebuddy(aim_session_t *sess, aim_conn_t *conn, char *oldgn, char *
struct aim_ssi_item **groups, *buddy, *cur;
guint16 i;
- if (!sess || !conn || !oldgn || !newgn || !sn)
+ if (!sess || !conn || !oldgn || !newgn || !sn) {
return -EINVAL;
+ }
/* Look up the buddy */
- if (!(buddy = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, sn, AIM_SSI_TYPE_BUDDY)))
+ if (!(buddy = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, sn, AIM_SSI_TYPE_BUDDY))) {
return -ENOMEM;
+ }
/* Allocate an array of pointers to the two groups */
- if (!(groups = g_new0(struct aim_ssi_item *, 2)))
+ if (!(groups = g_new0(struct aim_ssi_item *, 2))) {
return -ENOMEM;
+ }
/* Look up the old parent group */
if (!(groups[0] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, oldgn, AIM_SSI_TYPE_GROUP))) {
@@ -574,9 +645,12 @@ int aim_ssi_movebuddy(aim_session_t *sess, aim_conn_t *conn, char *oldgn, char *
buddy->bid = 0;
do {
buddy->bid += 0x0001;
- for (cur=sess->ssi.items, i=0; ((cur) && (!i)); cur=cur->next)
- if ((cur->bid == buddy->bid) && (cur->gid == buddy->gid) && (cur->type == AIM_SSI_TYPE_BUDDY) && (cur->name) && aim_sncmp(cur->name, buddy->name))
- i=1;
+ for (cur = sess->ssi.items, i = 0; ((cur) && (!i)); cur = cur->next) {
+ if ((cur->bid == buddy->bid) && (cur->gid == buddy->gid) && (cur->type == AIM_SSI_TYPE_BUDDY) &&
+ (cur->name) && aim_sncmp(cur->name, buddy->name)) {
+ i = 1;
+ }
+ }
} while (i);
/* Rebuild the additional data in the two parent groups */
@@ -613,18 +687,20 @@ int aim_ssi_delbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
struct aim_ssi_item *cur, *parentgroup, **delitems;
int i;
- if (!sess || !conn || !gn || !sn || !num)
+ if (!sess || !conn || !gn || !sn || !num) {
return -EINVAL;
+ }
/* Look up the parent group */
- if (!(parentgroup = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, gn, AIM_SSI_TYPE_GROUP)))
+ if (!(parentgroup = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, gn, AIM_SSI_TYPE_GROUP))) {
return -EINVAL;
+ }
/* Allocate an array of pointers to each of the items to be deleted */
delitems = g_new0(struct aim_ssi_item *, num);
/* Make the delitems array a pointer to the aim_ssi_item structs to be deleted */
- for (i=0; i<num; i++) {
+ for (i = 0; i < num; i++) {
if (!(delitems[i] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, sn[i], AIM_SSI_TYPE_BUDDY))) {
g_free(delitems);
return -EINVAL;
@@ -634,9 +710,12 @@ int aim_ssi_delbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
if (sess->ssi.items == delitems[i]) {
sess->ssi.items = sess->ssi.items->next;
} else {
- for (cur=sess->ssi.items; (cur->next && (cur->next!=delitems[i])); cur=cur->next);
- if (cur->next)
+ for (cur = sess->ssi.items; (cur->next && (cur->next != delitems[i])); cur = cur->next) {
+ ;
+ }
+ if (cur->next) {
cur->next = cur->next->next;
+ }
}
}
@@ -644,11 +723,13 @@ int aim_ssi_delbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
aim_ssi_addmoddel(sess, conn, delitems, num, AIM_CB_SSI_DEL);
/* Free the items */
- for (i=0; i<num; i++) {
- if (delitems[i]->name)
+ for (i = 0; i < num; i++) {
+ if (delitems[i]->name) {
g_free(delitems[i]->name);
- if (delitems[i]->data)
- aim_freetlvchain((aim_tlvlist_t **)&delitems[i]->data);
+ }
+ if (delitems[i]->data) {
+ aim_freetlvchain((aim_tlvlist_t **) &delitems[i]->data);
+ }
g_free(delitems[i]);
}
g_free(delitems);
@@ -660,8 +741,9 @@ int aim_ssi_delbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **s
aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD);
/* Delete the group, but only if it's empty */
- if (!parentgroup->data)
+ if (!parentgroup->data) {
aim_ssi_delgroups(sess, conn, &parentgroup->name, 1);
+ }
/* Begin sending SSI SNACs */
aim_ssi_dispatch(sess, conn);
@@ -681,30 +763,37 @@ int aim_ssi_delmastergroup(aim_session_t *sess, aim_conn_t *conn)
{
struct aim_ssi_item *cur, *delitem;
- if (!sess || !conn)
+ if (!sess || !conn) {
return -EINVAL;
+ }
/* Make delitem a pointer to the aim_ssi_item to be deleted */
- if (!(delitem = aim_ssi_itemlist_find(sess->ssi.items, 0, 0)))
+ if (!(delitem = aim_ssi_itemlist_find(sess->ssi.items, 0, 0))) {
return -EINVAL;
+ }
/* Remove delitem from the item list */
if (sess->ssi.items == delitem) {
sess->ssi.items = sess->ssi.items->next;
} else {
- for (cur=sess->ssi.items; (cur->next && (cur->next!=delitem)); cur=cur->next);
- if (cur->next)
+ for (cur = sess->ssi.items; (cur->next && (cur->next != delitem)); cur = cur->next) {
+ ;
+ }
+ if (cur->next) {
cur->next = cur->next->next;
+ }
}
/* Send the del item SNAC */
aim_ssi_addmoddel(sess, conn, &delitem, 1, AIM_CB_SSI_DEL);
/* Free the item */
- if (delitem->name)
+ if (delitem->name) {
g_free(delitem->name);
- if (delitem->data)
- aim_freetlvchain((aim_tlvlist_t **)&delitem->data);
+ }
+ if (delitem->data) {
+ aim_freetlvchain((aim_tlvlist_t **) &delitem->data);
+ }
g_free(delitem);
/* Begin sending SSI SNACs */
@@ -722,22 +811,25 @@ int aim_ssi_delmastergroup(aim_session_t *sess, aim_conn_t *conn)
* @param num The number of groups you are deleting (size of the gn array).
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned int num) {
+int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned int num)
+{
struct aim_ssi_item *cur, *parentgroup, **delitems;
int i;
- if (!sess || !conn || !gn || !num)
+ if (!sess || !conn || !gn || !num) {
return -EINVAL;
+ }
/* Look up the parent group */
- if (!(parentgroup = aim_ssi_itemlist_find(sess->ssi.items, 0, 0)))
+ if (!(parentgroup = aim_ssi_itemlist_find(sess->ssi.items, 0, 0))) {
return -EINVAL;
+ }
/* Allocate an array of pointers to each of the items to be deleted */
delitems = g_new0(struct aim_ssi_item *, num);
/* Make the delitems array a pointer to the aim_ssi_item structs to be deleted */
- for (i=0; i<num; i++) {
+ for (i = 0; i < num; i++) {
if (!(delitems[i] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, gn[i], AIM_SSI_TYPE_GROUP))) {
g_free(delitems);
return -EINVAL;
@@ -747,9 +839,12 @@ int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
if (sess->ssi.items == delitems[i]) {
sess->ssi.items = sess->ssi.items->next;
} else {
- for (cur=sess->ssi.items; (cur->next && (cur->next!=delitems[i])); cur=cur->next);
- if (cur->next)
+ for (cur = sess->ssi.items; (cur->next && (cur->next != delitems[i])); cur = cur->next) {
+ ;
+ }
+ if (cur->next) {
cur->next = cur->next->next;
+ }
}
}
@@ -757,11 +852,13 @@ int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
aim_ssi_addmoddel(sess, conn, delitems, num, AIM_CB_SSI_DEL);
/* Free the items */
- for (i=0; i<num; i++) {
- if (delitems[i]->name)
+ for (i = 0; i < num; i++) {
+ if (delitems[i]->name) {
g_free(delitems[i]->name);
- if (delitems[i]->data)
- aim_freetlvchain((aim_tlvlist_t **)&delitems[i]->data);
+ }
+ if (delitems[i]->data) {
+ aim_freetlvchain((aim_tlvlist_t **) &delitems[i]->data);
+ }
g_free(delitems[i]);
}
g_free(delitems);
@@ -773,8 +870,9 @@ int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD);
/* Delete the group, but only if it's empty */
- if (!parentgroup->data)
+ if (!parentgroup->data) {
aim_ssi_delmastergroup(sess, conn);
+ }
/* Begin sending SSI SNACs */
aim_ssi_dispatch(sess, conn);
@@ -783,8 +881,8 @@ int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
}
/**
- * Delete an array of a certain type of item from the list. This can be
- * used for permit buddies, deny buddies, ICQ's ignore buddies, and
+ * Delete an array of a certain type of item from the list. This can be
+ * used for permit buddies, deny buddies, ICQ's ignore buddies, and
* probably other types, also.
*
* @param sess The oscar session.
@@ -793,18 +891,20 @@ int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned
* @param num The number of items you are deleting (size of the sn array).
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_delpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned int num, guint16 type) {
+int aim_ssi_delpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned int num, guint16 type)
+{
struct aim_ssi_item *cur, **delitems;
int i;
- if (!sess || !conn || !sn || !num || (type!=AIM_SSI_TYPE_PERMIT && type!=AIM_SSI_TYPE_DENY))
+ if (!sess || !conn || !sn || !num || (type != AIM_SSI_TYPE_PERMIT && type != AIM_SSI_TYPE_DENY)) {
return -EINVAL;
+ }
/* Allocate an array of pointers to each of the items to be deleted */
delitems = g_new0(struct aim_ssi_item *, num);
/* Make the delitems array a pointer to the aim_ssi_item structs to be deleted */
- for (i=0; i<num; i++) {
+ for (i = 0; i < num; i++) {
if (!(delitems[i] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, sn[i], type))) {
g_free(delitems);
return -EINVAL;
@@ -814,9 +914,12 @@ int aim_ssi_delpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned i
if (sess->ssi.items == delitems[i]) {
sess->ssi.items = sess->ssi.items->next;
} else {
- for (cur=sess->ssi.items; (cur->next && (cur->next!=delitems[i])); cur=cur->next);
- if (cur->next)
+ for (cur = sess->ssi.items; (cur->next && (cur->next != delitems[i])); cur = cur->next) {
+ ;
+ }
+ if (cur->next) {
cur->next = cur->next->next;
+ }
}
}
@@ -824,11 +927,13 @@ int aim_ssi_delpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned i
aim_ssi_addmoddel(sess, conn, delitems, num, AIM_CB_SSI_DEL);
/* Free the items */
- for (i=0; i<num; i++) {
- if (delitems[i]->name)
+ for (i = 0; i < num; i++) {
+ if (delitems[i]->name) {
g_free(delitems[i]->name);
- if (delitems[i]->data)
- aim_freetlvchain((aim_tlvlist_t **)&delitems[i]->data);
+ }
+ if (delitems[i]->data) {
+ aim_freetlvchain((aim_tlvlist_t **) &delitems[i]->data);
+ }
g_free(delitems[i]);
}
g_free(delitems);
@@ -855,8 +960,9 @@ static int parserights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx,
int ret = 0;
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))) {
ret = userfunc(sess, rx);
+ }
return ret;
}
@@ -866,11 +972,13 @@ int aim_ssi_reqalldata(aim_session_t *sess, aim_conn_t *conn)
aim_frame_t *fr;
aim_snacid_t snacid;
- if (!sess || !conn)
+ if (!sess || !conn) {
return -EINVAL;
+ }
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10)))
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_REQFULLLIST, 0x0000, NULL, 0);
@@ -894,35 +1002,41 @@ static int parsedata(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, ai
guint32 timestamp;
/* When you set the version for the SSI family to 2-4, the beginning of this changes.
- * Instead of the version and then the revision, there is "0x0006" and then a type
- * 0x0001 TLV containing the 2 byte SSI family version that you sent earlier. Also,
- * the SNAC flags go from 0x0000 to 0x8000. I guess the 0x0006 is the length of the
- * TLV(s) that follow. The rights SNAC does the same thing, with the differing flag
+ * Instead of the version and then the revision, there is "0x0006" and then a type
+ * 0x0001 TLV containing the 2 byte SSI family version that you sent earlier. Also,
+ * the SNAC flags go from 0x0000 to 0x8000. I guess the 0x0006 is the length of the
+ * TLV(s) that follow. The rights SNAC does the same thing, with the differing flag
* and everything.
*/
fmtver = aimbs_get8(bs); /* Version of ssi data. Should be 0x00 */
revision = aimbs_get16(bs); /* # of times ssi data has been modified */
- if (revision != 0)
+ if (revision != 0) {
sess->ssi.revision = revision;
+ }
- for (cur = sess->ssi.items; cur && cur->next; cur=cur->next) ;
+ for (cur = sess->ssi.items; cur && cur->next; cur = cur->next) {
+ ;
+ }
while (aim_bstream_empty(bs) > 4) { /* last four bytes are stamp */
guint16 namelen, tbslen;
if (!sess->ssi.items) {
- if (!(sess->ssi.items = g_new0(struct aim_ssi_item, 1)))
+ if (!(sess->ssi.items = g_new0(struct aim_ssi_item, 1))) {
return -ENOMEM;
+ }
cur = sess->ssi.items;
} else {
- if (!(cur->next = g_new0(struct aim_ssi_item, 1)))
+ if (!(cur->next = g_new0(struct aim_ssi_item, 1))) {
return -ENOMEM;
+ }
cur = cur->next;
}
- if ((namelen = aimbs_get16(bs)))
+ if ((namelen = aimbs_get16(bs))) {
cur->name = aimbs_getstr(bs, namelen);
+ }
cur->gid = aimbs_get16(bs);
cur->bid = aimbs_get16(bs);
cur->type = aimbs_get16(bs);
@@ -931,18 +1045,20 @@ static int parsedata(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, ai
aim_bstream_t tbs;
aim_bstream_init(&tbs, bs->data + bs->offset /* XXX */, tbslen);
- cur->data = (void *)aim_readtlvchain(&tbs);
+ cur->data = (void *) aim_readtlvchain(&tbs);
aim_bstream_advance(bs, tbslen);
}
}
timestamp = aimbs_get32(bs);
- if (timestamp != 0)
+ if (timestamp != 0) {
sess->ssi.timestamp = timestamp;
+ }
sess->ssi.received_data = 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, fmtver, sess->ssi.revision, sess->ssi.timestamp, sess->ssi.items);
+ }
return ret;
}
@@ -954,7 +1070,7 @@ static int parsedata(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, ai
* are ready to begin using the list. It will promptly give you the
* presence information for everyone in your list and put your permit/deny
* settings into effect.
- *
+ *
*/
int aim_ssi_enable(aim_session_t *sess, aim_conn_t *conn)
{
@@ -976,29 +1092,30 @@ int aim_ssi_enable(aim_session_t *sess, aim_conn_t *conn)
* @param reason The reason string to send with the request.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_auth_request( aim_session_t *sess, aim_conn_t *conn, char *uin, char *reason )
+int aim_ssi_auth_request(aim_session_t *sess, aim_conn_t *conn, char *uin, char *reason)
{
aim_frame_t *fr;
aim_snacid_t snacid;
int snaclen;
-
- snaclen = 10 + 1 + strlen( uin ) + 2 + strlen( reason ) + 2;
-
- if( !( fr = aim_tx_new( sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen ) ) )
+
+ snaclen = 10 + 1 + strlen(uin) + 2 + strlen(reason) + 2;
+
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen))) {
return -ENOMEM;
+ }
+
+ snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREQ, 0x0000, NULL, 0);
+ aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREQ, 0x0000, snacid);
- snacid = aim_cachesnac( sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREQ, 0x0000, NULL, 0 );
- aim_putsnac( &fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREQ, 0x0000, snacid );
-
- aimbs_put8( &fr->data, strlen( uin ) );
- aimbs_putraw( &fr->data, (guint8 *)uin, strlen( uin ) );
- aimbs_put16( &fr->data, strlen( reason ) );
- aimbs_putraw( &fr->data, (guint8 *)reason, strlen( reason ) );
- aimbs_put16( &fr->data, 0 );
-
- aim_tx_enqueue( sess, fr );
-
- return( 0 );
+ aimbs_put8(&fr->data, strlen(uin));
+ aimbs_putraw(&fr->data, (guint8 *) uin, strlen(uin));
+ aimbs_put16(&fr->data, strlen(reason));
+ aimbs_putraw(&fr->data, (guint8 *) reason, strlen(reason));
+ aimbs_put16(&fr->data, 0);
+
+ aim_tx_enqueue(sess, fr);
+
+ return(0);
}
/**
@@ -1011,29 +1128,30 @@ int aim_ssi_auth_request( aim_session_t *sess, aim_conn_t *conn, char *uin, char
* @param reason The reason string to send with the request.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_auth_reply( aim_session_t *sess, aim_conn_t *conn, char *uin, int yesno, char *reason )
+int aim_ssi_auth_reply(aim_session_t *sess, aim_conn_t *conn, char *uin, int yesno, char *reason)
{
aim_frame_t *fr;
aim_snacid_t snacid;
int snaclen;
-
- snaclen = 10 + 1 + strlen( uin ) + 3 + strlen( reason );
-
- if( !( fr = aim_tx_new( sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen ) ) )
+
+ snaclen = 10 + 1 + strlen(uin) + 3 + strlen(reason);
+
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen))) {
return -ENOMEM;
-
- snacid = aim_cachesnac( sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREP, 0x0000, NULL, 0 );
- aim_putsnac( &fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREP, 0x0000, snacid );
-
- aimbs_put8( &fr->data, strlen( uin ) );
- aimbs_putraw( &fr->data, (guint8 *)uin, strlen( uin ) );
- aimbs_put8( &fr->data, yesno );
- aimbs_put16( &fr->data, strlen( reason ) );
- aimbs_putraw( &fr->data, (guint8 *)reason, strlen( reason ) );
-
- aim_tx_enqueue( sess, fr );
-
- return( 0 );
+ }
+
+ snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREP, 0x0000, NULL, 0);
+ aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREP, 0x0000, snacid);
+
+ aimbs_put8(&fr->data, strlen(uin));
+ aimbs_putraw(&fr->data, (guint8 *) uin, strlen(uin));
+ aimbs_put8(&fr->data, yesno);
+ aimbs_put16(&fr->data, strlen(reason));
+ aimbs_putraw(&fr->data, (guint8 *) reason, strlen(reason));
+
+ aim_tx_enqueue(sess, fr);
+
+ return(0);
}
@@ -1043,25 +1161,27 @@ int aim_ssi_auth_reply( aim_session_t *sess, aim_conn_t *conn, char *uin, int ye
* Sends the SNAC to add, modify, or delete an item from the server-stored
* information. These 3 SNACs all have an identical structure. The only
* difference is the subtype that is set for the SNAC.
- *
+ *
*/
-int aim_ssi_addmoddel(aim_session_t *sess, aim_conn_t *conn, struct aim_ssi_item **items, unsigned int num, guint16 subtype)
+int aim_ssi_addmoddel(aim_session_t *sess, aim_conn_t *conn, struct aim_ssi_item **items, unsigned int num,
+ guint16 subtype)
{
aim_frame_t *fr;
aim_snacid_t snacid;
int i, snaclen, listlen;
char *list = NULL;
- if (!sess || !conn || !items || !num)
+ if (!sess || !conn || !items || !num) {
return -EINVAL;
+ }
snaclen = 10; /* For family, subtype, flags, and SNAC ID */
listlen = 0;
- for (i=0; i<num; i++) {
+ for (i = 0; i < num; i++) {
snaclen += 10; /* For length, GID, BID, type, and length */
if (items[i]->name) {
snaclen += strlen(items[i]->name);
-
+
if (subtype == AIM_CB_SSI_ADD) {
list = g_realloc(list, listlen + strlen(items[i]->name) + 1);
strcpy(list + listlen, items[i]->name);
@@ -1071,31 +1191,35 @@ int aim_ssi_addmoddel(aim_session_t *sess, aim_conn_t *conn, struct aim_ssi_item
if (subtype == AIM_CB_SSI_ADD) {
list = g_realloc(list, listlen + 1);
list[listlen] = '\0';
- listlen ++;
+ listlen++;
}
}
- if (items[i]->data)
- snaclen += aim_sizetlvchain((aim_tlvlist_t **)&items[i]->data);
+ if (items[i]->data) {
+ snaclen += aim_sizetlvchain((aim_tlvlist_t **) &items[i]->data);
+ }
}
-
- if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen)))
+
+ if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen))) {
return -ENOMEM;
+ }
snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, subtype, 0x0000, list, list ? listlen : 0);
aim_putsnac(&fr->data, AIM_CB_FAM_SSI, subtype, 0x0000, snacid);
-
+
g_free(list);
- for (i=0; i<num; i++) {
+ for (i = 0; i < num; i++) {
aimbs_put16(&fr->data, items[i]->name ? strlen(items[i]->name) : 0);
- if (items[i]->name)
- aimbs_putraw(&fr->data, (guint8 *)items[i]->name, strlen(items[i]->name));
+ if (items[i]->name) {
+ aimbs_putraw(&fr->data, (guint8 *) items[i]->name, strlen(items[i]->name));
+ }
aimbs_put16(&fr->data, items[i]->gid);
aimbs_put16(&fr->data, items[i]->bid);
aimbs_put16(&fr->data, items[i]->type);
- aimbs_put16(&fr->data, items[i]->data ? aim_sizetlvchain((aim_tlvlist_t **)&items[i]->data) : 0);
- if (items[i]->data)
- aim_writetlvchain(&fr->data, (aim_tlvlist_t **)&items[i]->data);
+ aimbs_put16(&fr->data, items[i]->data ? aim_sizetlvchain((aim_tlvlist_t **) &items[i]->data) : 0);
+ if (items[i]->data) {
+ aim_writetlvchain(&fr->data, (aim_tlvlist_t **) &items[i]->data);
+ }
}
aim_ssi_enqueue(sess, conn, fr);
@@ -1117,17 +1241,18 @@ static int parseack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
sess->ssi.waiting_for_ack = 0;
aim_ssi_dispatch(sess, rx->conn);
-
+
origsnac = aim_remsnac(sess, snac->id);
-
- 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, origsnac);
-
+ }
+
if (origsnac) {
g_free(origsnac->data);
g_free(origsnac);
}
-
+
return ret;
}
@@ -1135,7 +1260,7 @@ static int parseack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim
* SSI Begin Data Modification.
*
* Tells the server you're going to start modifying data.
- *
+ *
*/
int aim_ssi_modbegin(aim_session_t *sess, aim_conn_t *conn)
{
@@ -1160,15 +1285,17 @@ int aim_ssi_modend(aim_session_t *sess, aim_conn_t *conn)
* posted local stamp/revision.
*
*/
-static int parsedataunchanged(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
+static int parsedataunchanged(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs)
{
int ret = 0;
aim_rxcallback_t userfunc;
sess->ssi.received_data = 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);
+ }
return ret;
}
@@ -1176,14 +1303,15 @@ static int parsedataunchanged(aim_session_t *sess, aim_module_t *mod, aim_frame_
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 == AIM_CB_SSI_RIGHTSINFO)
+ if (snac->subtype == AIM_CB_SSI_RIGHTSINFO) {
return parserights(sess, mod, rx, snac, bs);
- else if (snac->subtype == AIM_CB_SSI_LIST)
+ } else if (snac->subtype == AIM_CB_SSI_LIST) {
return parsedata(sess, mod, rx, snac, bs);
- else if (snac->subtype == AIM_CB_SSI_SRVACK)
+ } else if (snac->subtype == AIM_CB_SSI_SRVACK) {
return parseack(sess, mod, rx, snac, bs);
- else if (snac->subtype == AIM_CB_SSI_NOLIST)
+ } else if (snac->subtype == AIM_CB_SSI_NOLIST) {
return parsedataunchanged(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/ssi.h b/protocols/oscar/ssi.h
index 60d9faa5..7ee4df50 100644
--- a/protocols/oscar/ssi.h
+++ b/protocols/oscar/ssi.h
@@ -46,7 +46,8 @@ struct aim_ssi_item {
int aim_ssi_reqrights(aim_session_t *sess, aim_conn_t *conn);
int aim_ssi_reqalldata(aim_session_t *sess, aim_conn_t *conn);
int aim_ssi_enable(aim_session_t *sess, aim_conn_t *conn);
-int aim_ssi_addmoddel(aim_session_t *sess, aim_conn_t *conn, struct aim_ssi_item **items, unsigned int num, guint16 subtype);
+int aim_ssi_addmoddel(aim_session_t *sess, aim_conn_t *conn, struct aim_ssi_item **items, unsigned int num,
+ guint16 subtype);
int aim_ssi_modbegin(aim_session_t *sess, aim_conn_t *conn);
int aim_ssi_modend(aim_session_t *sess, aim_conn_t *conn);
@@ -57,7 +58,8 @@ struct aim_ssi_item *aim_ssi_itemlist_findparent(struct aim_ssi_item *list, char
int aim_ssi_getpermdeny(struct aim_ssi_item *list);
/* Send packets */
-int aim_ssi_addbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **sn, unsigned int num, unsigned int flags);
+int aim_ssi_addbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **sn, unsigned int num,
+ unsigned int flags);
int aim_ssi_addmastergroup(aim_session_t *sess, aim_conn_t *conn);
int aim_ssi_addgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned int num);
int aim_ssi_addpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned int num, guint16 type);
diff --git a/protocols/oscar/stats.c b/protocols/oscar/stats.c
index affd82fe..fb438412 100644
--- a/protocols/oscar/stats.c
+++ b/protocols/oscar/stats.c
@@ -1,15 +1,17 @@
#include <aim.h>
-static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
+static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac,
+ aim_bstream_t *bs)
{
guint16 interval;
aim_rxcallback_t userfunc;
interval = aimbs_get16(bs);
- 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, interval);
+ }
return 0;
}
@@ -17,8 +19,9 @@ static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r
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 == 0x0002)
+ if (snac->subtype == 0x0002) {
return reportinterval(sess, mod, rx, snac, bs);
+ }
return 0;
}
diff --git a/protocols/oscar/tlv.c b/protocols/oscar/tlv.c
index e7e3a7be..e01f728a 100644
--- a/protocols/oscar/tlv.c
+++ b/protocols/oscar/tlv.c
@@ -2,9 +2,10 @@
static void freetlv(aim_tlv_t **oldtlv)
{
- if (!oldtlv || !*oldtlv)
+ if (!oldtlv || !*oldtlv) {
return;
-
+ }
+
g_free((*oldtlv)->value);
g_free(*oldtlv);
*oldtlv = NULL;
@@ -21,7 +22,7 @@ static void freetlv(aim_tlv_t **oldtlv)
* be called to free the dynamic substructures.
*
* XXX There should be a flag setable here to have the tlvlist contain
- * bstream references, so that at least the ->value portion of each
+ * bstream references, so that at least the ->value portion of each
* element doesn't need to be malloc/memcpy'd. This could prove to be
* just as effecient as the in-place TLV parsing used in a couple places
* in libfaim.
@@ -41,8 +42,9 @@ aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs)
cur->tlv = g_new0(aim_tlv_t, 1);
cur->tlv->type = type;
- if ((cur->tlv->length = length))
- cur->tlv->value = aimbs_getraw(bs, length);
+ if ((cur->tlv->length = length)) {
+ cur->tlv->value = aimbs_getraw(bs, length);
+ }
cur->next = list;
list = cur;
@@ -64,12 +66,13 @@ void aim_freetlvchain(aim_tlvlist_t **list)
{
aim_tlvlist_t *cur;
- if (!list || !*list)
+ if (!list || !*list) {
return;
+ }
for (cur = *list; cur; ) {
aim_tlvlist_t *tmp;
-
+
freetlv(&cur->tlv);
tmp = cur->next;
@@ -94,11 +97,13 @@ int aim_counttlvchain(aim_tlvlist_t **list)
aim_tlvlist_t *cur;
int count;
- if (!list || !*list)
+ if (!list || !*list) {
return 0;
+ }
- for (cur = *list, count = 0; cur; cur = cur->next)
+ for (cur = *list, count = 0; cur; cur = cur->next) {
count++;
+ }
return count;
}
@@ -107,7 +112,7 @@ int aim_counttlvchain(aim_tlvlist_t **list)
* aim_sizetlvchain - Count the number of bytes in a TLV chain
* @list: Chain to be sized
*
- * Returns the number of bytes that would be needed to
+ * Returns the number of bytes that would be needed to
* write the passed TLV chain to a data buffer.
*
*/
@@ -116,11 +121,13 @@ int aim_sizetlvchain(aim_tlvlist_t **list)
aim_tlvlist_t *cur;
int size;
- if (!list || !*list)
+ if (!list || !*list) {
return 0;
+ }
- for (cur = *list, size = 0; cur; cur = cur->next)
+ for (cur = *list, size = 0; cur; cur = cur->next) {
size += (4 + cur->tlv->length);
+ }
return size;
}
@@ -140,11 +147,13 @@ int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l
{
aim_tlvlist_t *newtlv, *cur;
- if (!list)
+ if (!list) {
return 0;
+ }
- if (!(newtlv = g_new0(aim_tlvlist_t, 1)))
+ if (!(newtlv = g_new0(aim_tlvlist_t, 1))) {
return 0;
+ }
if (!(newtlv->tlv = g_new0(aim_tlv_t, 1))) {
g_free(newtlv);
@@ -152,15 +161,16 @@ int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l
}
newtlv->tlv->type = t;
if ((newtlv->tlv->length = l)) {
- newtlv->tlv->value = (guint8 *)g_malloc(newtlv->tlv->length);
+ newtlv->tlv->value = (guint8 *) g_malloc(newtlv->tlv->length);
memcpy(newtlv->tlv->value, v, newtlv->tlv->length);
}
- if (!*list)
+ if (!*list) {
*list = newtlv;
- else {
- for(cur = *list; cur->next; cur = cur->next)
+ } else {
+ for (cur = *list; cur->next; cur = cur->next) {
;
+ }
cur->next = newtlv;
}
@@ -233,12 +243,13 @@ int aim_addtlvtochain32(aim_tlvlist_t **list, const guint16 t, const guint32 v)
*/
int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps)
{
- guint8 buf[16*16]; /* XXX icky fixed length buffer */
+ guint8 buf[16 * 16]; /* XXX icky fixed length buffer */
aim_bstream_t bs;
- if (!caps)
+ if (!caps) {
return 0; /* nothing there anyway */
+ }
aim_bstream_init(&bs, buf, sizeof(buf));
aim_putcap(&bs, caps);
@@ -265,7 +276,7 @@ int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 t)
* made to this.
*
* XXX should probably support sublists for real.
- *
+ *
* This is so neat.
*
*/
@@ -277,11 +288,13 @@ int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvl
buflen = aim_sizetlvchain(tl);
- if (buflen <= 0)
+ if (buflen <= 0) {
return 0;
+ }
- if (!(buf = g_malloc(buflen)))
+ if (!(buf = g_malloc(buflen))) {
return 0;
+ }
aim_bstream_init(&bs, buf, buflen);
@@ -294,22 +307,24 @@ int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvl
return buflen;
}
-int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)
+int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname,
+ guint16 instance)
{
guint8 *buf;
int buflen;
aim_bstream_t bs;
buflen = 2 + 1 + strlen(roomname) + 2;
-
- if (!(buf = g_malloc(buflen)))
+
+ if (!(buf = g_malloc(buflen))) {
return 0;
+ }
aim_bstream_init(&bs, buf, buflen);
aimbs_put16(&bs, exchange);
aimbs_put8(&bs, strlen(roomname));
- aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname));
+ aimbs_putraw(&bs, (guint8 *) roomname, strlen(roomname));
aimbs_put16(&bs, instance);
aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf);
@@ -326,11 +341,11 @@ int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 excha
* @list: Source TLV chain
*
* Copies a TLV chain into a raw data buffer, writing only the number
- * of bytes specified. This operation does not free the chain;
+ * of bytes specified. This operation does not free the chain;
* aim_freetlvchain() must still be called to free up the memory used
* by the chain structures.
*
- * XXX clean this up, make better use of bstreams
+ * XXX clean this up, make better use of bstreams
*/
int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list)
{
@@ -343,15 +358,17 @@ int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list)
goodbuflen += cur->tlv->length;
}
- if (goodbuflen > aim_bstream_empty(bs))
+ if (goodbuflen > aim_bstream_empty(bs)) {
return 0; /* not enough buffer */
+ }
/* do the real write-out */
for (cur = *list; cur; cur = cur->next) {
aimbs_put16(bs, cur->tlv->type);
aimbs_put16(bs, cur->tlv->length);
- if (cur->tlv->length)
+ if (cur->tlv->length) {
aimbs_putraw(bs, cur->tlv->value, cur->tlv->length);
+ }
}
return 1; /* XXX this is a nonsensical return */
@@ -364,7 +381,7 @@ int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list)
* @type: Requested TLV type
* @nth: Index of TLV of type to get
*
- * Returns a pointer to an aim_tlv_t of the specified type;
+ * Returns a pointer to an aim_tlv_t of the specified type;
* %NULL on error. The @nth parameter is specified starting at %1.
* In most cases, there will be no more than one TLV of any type
* in a chain.
@@ -377,10 +394,12 @@ aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, const guint16 t, const int n)
for (cur = list, i = 0; cur; cur = cur->next) {
if (cur && cur->tlv) {
- if (cur->tlv->type == t)
+ if (cur->tlv->type == t) {
i++;
- if (i >= n)
+ }
+ if (i >= n) {
return cur->tlv;
+ }
}
}
@@ -394,7 +413,7 @@ aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, const guint16 t, const int n)
* @nth: Index of TLV to return
*
* Same as aim_gettlv(), except that the return value is a %NULL-
- * terminated string instead of an aim_tlv_t. This is a
+ * terminated string instead of an aim_tlv_t. This is a
* dynamic buffer and must be freed by the caller.
*
*/
@@ -403,8 +422,9 @@ char *aim_gettlv_str(aim_tlvlist_t *list, const guint16 t, const int n)
aim_tlv_t *tlv;
char *newstr;
- if (!(tlv = aim_gettlv(list, t, n)))
+ if (!(tlv = aim_gettlv(list, t, n))) {
return NULL;
+ }
newstr = (char *) g_malloc(tlv->length + 1);
memcpy(newstr, tlv->value, tlv->length);
@@ -419,16 +439,17 @@ char *aim_gettlv_str(aim_tlvlist_t *list, const guint16 t, const int n)
* @type: TLV type to search for
* @nth: Index of TLV to return
*
- * Same as aim_gettlv(), except that the return value is a
- * 8bit integer instead of an aim_tlv_t.
+ * Same as aim_gettlv(), except that the return value is a
+ * 8bit integer instead of an aim_tlv_t.
*
*/
guint8 aim_gettlv8(aim_tlvlist_t *list, const guint16 t, const int n)
{
aim_tlv_t *tlv;
- if (!(tlv = aim_gettlv(list, t, n)))
+ if (!(tlv = aim_gettlv(list, t, n))) {
return 0; /* erm */
+ }
return aimutil_get8(tlv->value);
}
@@ -438,16 +459,17 @@ guint8 aim_gettlv8(aim_tlvlist_t *list, const guint16 t, const int n)
* @type: TLV type to search for
* @nth: Index of TLV to return
*
- * Same as aim_gettlv(), except that the return value is a
- * 16bit integer instead of an aim_tlv_t.
+ * Same as aim_gettlv(), except that the return value is a
+ * 16bit integer instead of an aim_tlv_t.
*
*/
guint16 aim_gettlv16(aim_tlvlist_t *list, const guint16 t, const int n)
{
aim_tlv_t *tlv;
- if (!(tlv = aim_gettlv(list, t, n)))
+ if (!(tlv = aim_gettlv(list, t, n))) {
return 0; /* erm */
+ }
return aimutil_get16(tlv->value);
}
@@ -457,16 +479,17 @@ guint16 aim_gettlv16(aim_tlvlist_t *list, const guint16 t, const int n)
* @type: TLV type to search for
* @nth: Index of TLV to return
*
- * Same as aim_gettlv(), except that the return value is a
- * 32bit integer instead of an aim_tlv_t.
+ * Same as aim_gettlv(), except that the return value is a
+ * 32bit integer instead of an aim_tlv_t.
*
*/
guint32 aim_gettlv32(aim_tlvlist_t *list, const guint16 t, const int n)
{
aim_tlv_t *tlv;
- if (!(tlv = aim_gettlv(list, t, n)))
+ if (!(tlv = aim_gettlv(list, t, n))) {
return 0; /* erm */
+ }
return aimutil_get32(tlv->value);
}
@@ -543,9 +566,10 @@ int aim_puttlv_raw(guint8 *buf, const guint16 t, const guint16 l, const guint8 *
int i;
i = aimutil_put16(buf, t);
- i += aimutil_put16(buf+i, l);
- if (l)
- memcpy(buf+i, v, l);
+ i += aimutil_put16(buf + i, l);
+ if (l) {
+ memcpy(buf + i, v, l);
+ }
i += l;
return i;
diff --git a/protocols/oscar/txqueue.c b/protocols/oscar/txqueue.c
index e48511fa..7ad2a3dd 100644
--- a/protocols/oscar/txqueue.c
+++ b/protocols/oscar/txqueue.c
@@ -31,10 +31,11 @@ aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, guint8 framing, g
return NULL;
}
- if (!(fr = (aim_frame_t *)g_new0(aim_frame_t,1)))
+ if (!(fr = (aim_frame_t *) g_new0(aim_frame_t, 1))) {
return NULL;
+ }
- fr->conn = conn;
+ fr->conn = conn;
fr->hdrtype = framing;
@@ -42,13 +43,14 @@ aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, guint8 framing, g
fr->hdr.flap.type = chan;
- } else
+ } else {
imcb_error(sess->aux_data, "unknown framing");
+ }
if (datalen > 0) {
guint8 *data;
- if (!(data = (unsigned char *)g_malloc(datalen))) {
+ if (!(data = (unsigned char *) g_malloc(datalen))) {
aim_frame_destroy(fr);
return NULL;
}
@@ -89,13 +91,14 @@ static int aim_tx_enqueue__queuebased(aim_session_t *sess, aim_frame_t *fr)
fr->handled = 0; /* not sent yet */
/* see overhead note in aim_rxqueue counterpart */
- if (!sess->queue_outgoing)
+ if (!sess->queue_outgoing) {
sess->queue_outgoing = fr;
- else {
+ } else {
aim_frame_t *cur;
- for (cur = sess->queue_outgoing; cur->next; cur = cur->next)
+ for (cur = sess->queue_outgoing; cur->next; cur = cur->next) {
;
+ }
cur->next = fr;
}
@@ -110,8 +113,8 @@ static int aim_tx_enqueue__queuebased(aim_session_t *sess, aim_frame_t *fr)
*
* Basically the same as its __queuebased couterpart, however
* instead of doing a list append, it just calls aim_tx_sendframe()
- * right here.
- *
+ * right here.
+ *
*/
static int aim_tx_enqueue__immediate(aim_session_t *sess, aim_frame_t *fr)
{
@@ -122,8 +125,9 @@ static int aim_tx_enqueue__immediate(aim_session_t *sess, aim_frame_t *fr)
return 0;
}
- if (fr->hdrtype == AIM_FRAMETYPE_FLAP)
+ if (fr->hdrtype == AIM_FRAMETYPE_FLAP) {
fr->hdr.flap.seqnum = aim_get_next_txseqnum(fr->conn);
+ }
fr->handled = 0; /* not sent yet */
@@ -136,38 +140,40 @@ static int aim_tx_enqueue__immediate(aim_session_t *sess, aim_frame_t *fr)
int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *))
{
-
- if (what == AIM_TX_QUEUED)
+
+ if (what == AIM_TX_QUEUED) {
sess->tx_enqueue = &aim_tx_enqueue__queuebased;
- else if (what == AIM_TX_IMMEDIATE)
+ } else if (what == AIM_TX_IMMEDIATE) {
sess->tx_enqueue = &aim_tx_enqueue__immediate;
- else if (what == AIM_TX_USER) {
- if (!func)
+ } else if (what == AIM_TX_USER) {
+ if (!func) {
return -EINVAL;
+ }
sess->tx_enqueue = func;
- } else
+ } else {
return -EINVAL; /* unknown action */
+ }
return 0;
}
int aim_tx_enqueue(aim_session_t *sess, aim_frame_t *fr)
{
-
+
/*
* If we want to send a connection thats inprogress, we have to force
* them to use the queue based version. Otherwise, use whatever they
* want.
*/
- if (fr && fr->conn &&
- (fr->conn->status & AIM_CONN_STATUS_INPROGRESS)) {
+ if (fr && fr->conn &&
+ (fr->conn->status & AIM_CONN_STATUS_INPROGRESS)) {
return aim_tx_enqueue__queuebased(sess, fr);
}
return (*sess->tx_enqueue)(sess, fr);
}
-/*
+/*
* aim_get_next_txseqnum()
*
* This increments the tx command count, and returns the seqnum
@@ -179,7 +185,7 @@ int aim_tx_enqueue(aim_session_t *sess, aim_frame_t *fr)
flap_seqnum_t aim_get_next_txseqnum(aim_conn_t *conn)
{
flap_seqnum_t ret;
-
+
ret = ++conn->seqnum;
return ret;
@@ -192,11 +198,12 @@ static int aim_send(int fd, const void *buf, size_t count)
for (cur = 0, left = count; left; ) {
int ret;
- ret = send(fd, ((unsigned char *)buf)+cur, left, 0);
- if (ret == -1)
+ ret = send(fd, ((unsigned char *) buf) + cur, left, 0);
+ if (ret == -1) {
return -1;
- else if (ret == 0)
+ } else if (ret == 0) {
return cur;
+ }
cur += ret;
left -= ret;
@@ -208,22 +215,25 @@ static int aim_send(int fd, const void *buf, size_t count)
static int aim_bstream_send(aim_bstream_t *bs, aim_conn_t *conn, size_t count)
{
int wrote = 0;
- if (!bs || !conn || (count < 0))
+
+ if (!bs || !conn || (count < 0)) {
return -EINVAL;
+ }
- if (count > aim_bstream_empty(bs))
+ if (count > aim_bstream_empty(bs)) {
count = aim_bstream_empty(bs); /* truncate to remaining space */
+ }
if (count) {
if (count - wrote) {
wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, count - wrote);
}
-
+
}
-
+
bs->offset += wrote;
- return wrote;
+ return wrote;
}
static int sendframe_flap(aim_session_t *sess, aim_frame_t *fr)
@@ -234,8 +244,9 @@ static int sendframe_flap(aim_session_t *sess, aim_frame_t *fr)
payloadlen = aim_bstream_curpos(&fr->data);
- if (!(obs_raw = g_malloc(6 + payloadlen)))
+ if (!(obs_raw = g_malloc(6 + payloadlen))) {
return -ENOMEM;
+ }
aim_bstream_init(&obs, obs_raw, 6 + payloadlen);
@@ -251,9 +262,10 @@ static int sendframe_flap(aim_session_t *sess, aim_frame_t *fr)
obslen = aim_bstream_curpos(&obs);
aim_bstream_rewind(&obs);
- if (aim_bstream_send(&obs, fr->conn, obslen) != obslen)
+ if (aim_bstream_send(&obs, fr->conn, obslen) != obslen) {
err = -errno;
-
+ }
+
g_free(obs_raw); /* XXX aim_bstream_free */
fr->handled = 1;
@@ -264,8 +276,9 @@ static int sendframe_flap(aim_session_t *sess, aim_frame_t *fr)
int aim_tx_sendframe(aim_session_t *sess, aim_frame_t *fr)
{
- if (fr->hdrtype == AIM_FRAMETYPE_FLAP)
+ if (fr->hdrtype == AIM_FRAMETYPE_FLAP) {
return sendframe_flap(sess, fr);
+ }
return -1;
}
@@ -275,19 +288,21 @@ int aim_tx_flushqueue(aim_session_t *sess)
for (cur = sess->queue_outgoing; cur; cur = cur->next) {
- if (cur->handled)
- continue; /* already been sent */
+ if (cur->handled) {
+ continue; /* already been sent */
- if (cur->conn && (cur->conn->status & AIM_CONN_STATUS_INPROGRESS))
+ }
+ if (cur->conn && (cur->conn->status & AIM_CONN_STATUS_INPROGRESS)) {
continue;
+ }
/*
* And now for the meager attempt to force transmit
* latency and avoid missed messages.
*/
if ((cur->conn->lastactivity + cur->conn->forcedlatency) >= time(NULL)) {
- /*
- * XXX should be a break! we dont want to block the
+ /*
+ * XXX should be a break! we dont want to block the
* upper layers
*
* XXX or better, just do this right.
@@ -308,10 +323,10 @@ int aim_tx_flushqueue(aim_session_t *sess)
/*
* aim_tx_purgequeue()
- *
- * This is responsable for removing sent commands from the transmit
+ *
+ * This is responsable for removing sent commands from the transmit
* queue. This is not a required operation, but it of course helps
- * reduce memory footprint at run time!
+ * reduce memory footprint at run time!
*
*/
void aim_tx_purgequeue(aim_session_t *sess)
@@ -325,8 +340,9 @@ void aim_tx_purgequeue(aim_session_t *sess)
aim_frame_destroy(cur);
- } else
+ } else {
prev = &cur->next;
+ }
}
return;
@@ -346,8 +362,9 @@ void aim_tx_cleanqueue(aim_session_t *sess, aim_conn_t *conn)
aim_frame_t *cur;
for (cur = sess->queue_outgoing; cur; cur = cur->next) {
- if (cur->conn == conn)
+ if (cur->conn == conn) {
cur->handled = 1;
+ }
}
return;