changeset 5556:8ab1875e6d09

[gaim-migrate @ 5957] This is mostly some small changes to oscar to make it faster and more portable (like, to 64 bit platforms). It's pretty much all from The Ryan McCabe (odin). He's the man. I didn't actually test this, but CVS is probably broken right now anyway. Fear not--if it doesn't work I'll be sure to fix it real good now, ya hear. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 30 May 2003 02:35:44 +0000
parents 6503d24fda09
children bf12d4634950
files src/protocols/oscar/aim.h src/protocols/oscar/im.c src/protocols/oscar/oscar.c src/protocols/oscar/util.c
diffstat 4 files changed, 52 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h	Fri May 30 00:02:42 2003 +0000
+++ b/src/protocols/oscar/aim.h	Fri May 30 02:35:44 2003 +0000
@@ -38,7 +38,7 @@
 /* XXX adjust these based on autoconf-detected platform */
 typedef unsigned char fu8_t;
 typedef unsigned short fu16_t;
-typedef unsigned long fu32_t;
+typedef unsigned int fu32_t;
 typedef fu32_t aim_snacid_t;
 typedef fu16_t flap_seqnum_t;
 
@@ -342,7 +342,7 @@
 } aim_frame_t;
 
 typedef struct aim_msgcookie_s {
-	unsigned char cookie[8];
+	fu8_t cookie[8];
 	int type;
 	void *data;
 	time_t addtime;
@@ -524,7 +524,7 @@
 faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn);
 faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn);
 faim_export int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key);
-faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest);
+faim_export int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest);
 faim_export void aim_purge_rxqueue(aim_session_t *);
 faim_export void aim_cleansnacs(aim_session_t *, int maxage);
 
@@ -554,7 +554,7 @@
 
 typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
 faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t);
-faim_export void aim_session_init(aim_session_t *, unsigned long flags, int debuglevel);
+faim_export void aim_session_init(aim_session_t *, fu32_t flags, int debuglevel);
 faim_export void aim_session_kill(aim_session_t *);
 faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
 faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type);
@@ -596,7 +596,7 @@
 #define AIM_CLIENTTYPE_WINAIM   0x0002
 #define AIM_CLIENTTYPE_WINAIM41 0x0003
 #define AIM_CLIENTTYPE_AOL_TOC  0x0004
-faim_export unsigned short aim_im_fingerprint(unsigned char *msghdr, int len);
+faim_export unsigned short aim_im_fingerprint(const fu8_t *msghdr, int len);
 
 #define AIM_RATE_CODE_CHANGE     0x0001
 #define AIM_RATE_CODE_WARNING    0x0002
@@ -647,9 +647,9 @@
 };
 
 struct aim_chat_roominfo {
-	unsigned short exchange;
+	fu16_t exchange;
 	char *name;
-	unsigned short instance;
+	fu16_t instance;
 };
 
 #define AIM_IMFLAGS_AWAY		0x0001 /* mark as an autoreply */
@@ -831,7 +831,7 @@
 /* 0x0002 */ faim_export int aim_im_setparams(aim_session_t *sess, struct aim_icbmparameters *params);
 /* 0x0004 */ faim_export int aim_im_reqparams(aim_session_t *sess);
 /* 0x0006 */ faim_export int aim_im_sendch1_ext(aim_session_t *sess, struct aim_sendimext_args *args);
-/* 0x0006 */ faim_export int aim_im_sendch1(aim_session_t *, const char *destsn, unsigned short flags, const char *msg);
+/* 0x0006 */ faim_export int aim_im_sendch1(aim_session_t *, const char *destsn, fu16_t flags, const char *msg);
 /* 0x0006 */ faim_export int aim_im_sendch2_icon(aim_session_t *sess, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum);
 /* 0x0006 */ faim_export int aim_im_sendch2_rtfmsg(aim_session_t *sess, struct aim_sendrtfmsg_args *args);
 /* 0x0006 */ faim_export int aim_im_sendch2_odcrequest(aim_session_t *sess, fu8_t *cookie, const char *sn, const fu8_t *ip, fu16_t port);
@@ -841,7 +841,7 @@
 /* 0x0006 */ faim_export int aim_im_sendch2_geticqaway(aim_session_t *sess, const char *sn, int type);
 /* 0x0006 */ faim_export int aim_im_sendch4(aim_session_t *sess, char *sn, fu16_t type, fu8_t *message);
 /* 0x0008 */ faim_export int aim_im_warn(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu32_t flags);
-/* 0x000b */ faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, unsigned short code);
+/* 0x000b */ faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code);
 /* 0x0014 */ faim_export int aim_im_sendmtn(aim_session_t *sess, fu16_t type1, char *sn, fu16_t type2);
 
 
@@ -999,7 +999,7 @@
 #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST  0
 #define AIM_SENDMEMBLOCK_FLAG_ISHASH     1
 
-faim_export int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, unsigned long offset, unsigned long len, const unsigned char *buf, unsigned char flag);
+faim_export int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, fu32_t offset, fu32_t len, const fu8_t *buf, fu8_t flag);
 
 #define AIM_GETINFO_GENERALINFO 0x00001
 #define AIM_GETINFO_AWAYMESSAGE 0x00003
@@ -1029,7 +1029,7 @@
 #define AIM_COOKIETYPE_OFTIMAGE 0x14
 #define AIM_COOKIETYPE_OFTICON  0x15
 
-/* 0x0005 */ faim_export int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short);
+/* 0x0005 */ faim_export int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, fu16_t);
 
 
 
@@ -1380,24 +1380,24 @@
 
 /* Little-endian versions (damn ICQ) */
 #define aimutil_putle8(buf, data) ( \
-		(*(buf) = (unsigned char)(data) & 0xff), \
+		(*(buf) = (fu8_t)(data) & 0xff), \
 		1)
 #define aimutil_getle8(buf) ( \
 		(*(buf)) & 0xff \
 		)
 #define aimutil_putle16(buf, data) ( \
-		(*((buf)+0) = (unsigned char)((data) >> 0) & 0xff),  \
-		(*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \
+		(*((buf)+0) = (fu8_t)((data) >> 0) & 0xff),  \
+		(*((buf)+1) = (fu8_t)((data) >> 8) & 0xff), \
 		2)
 #define aimutil_getle16(buf) ( \
 		(((*((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), \
+		(*((buf)+0) = (fu8_t)((data) >>  0) & 0xff), \
+		(*((buf)+1) = (fu8_t)((data) >>  8) & 0xff), \
+		(*((buf)+2) = (fu8_t)((data) >> 16) & 0xff), \
+		(*((buf)+3) = (fu8_t)((data) >> 24) & 0xff), \
 		4)
 #define aimutil_getle32(buf) ( \
 		(((*((buf)+0)) <<  0) & 0x000000ff) + \
--- a/src/protocols/oscar/im.c	Fri May 30 00:02:42 2003 +0000
+++ b/src/protocols/oscar/im.c	Fri May 30 02:35:44 2003 +0000
@@ -76,7 +76,7 @@
  * the rest will always be the same.
  *
  */
-faim_export fu16_t aim_im_fingerprint(fu8_t *msghdr, int len)
+faim_export fu16_t aim_im_fingerprint(const fu8_t *msghdr, int len)
 {
 	static const struct {
 		fu16_t clientid;
--- a/src/protocols/oscar/oscar.c	Fri May 30 00:02:42 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Fri May 30 02:35:44 2003 +0000
@@ -1291,7 +1291,7 @@
 	va_end(ap);
 
 	gaim_debug(GAIM_DEBUG_MISC, "oscar",
-			   "offset: %lu, len: %lu, file: %s\n",
+			   "offset: %u, len: %u, file: %s\n",
 			   offset, len, (modname ? modname : "aim.exe"));
 
 	if (len == 0) {
@@ -2563,7 +2563,7 @@
 	switch (args->type) {
 		case 0x01: { /* MacICQ message or basic offline message */
 			if (i >= 1) {
-				gchar *uin = g_strdup_printf("%lu", args->uin);
+				gchar *uin = g_strdup_printf("%u", args->uin);
 				if (t) { /* This is an offline message */
 					/* I think this timestamp is in UTC, or something */
 					serv_got_im(gc, uin, msg2[0], 0, t, -1);
@@ -2576,7 +2576,7 @@
 
 		case 0x04: { /* Someone sent you a URL */
 			if (i >= 2) {
-				gchar *uin = g_strdup_printf("%lu", args->uin);
+				gchar *uin = g_strdup_printf("%u", args->uin);
 				gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]);
 				serv_got_im(gc, uin, message, 0, time(NULL), -1);
 				g_free(uin);
@@ -2587,12 +2587,12 @@
 		case 0x06: { /* Someone requested authorization */
 			if (i >= 6) {
 				struct name_data *data = g_new(struct name_data, 1);
-				gchar *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given."));
+				gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given."));
 				gaim_debug(GAIM_DEBUG_INFO, "oscar",
-						   "Received an authorization request from UIN %lu\n",
+						   "Received an authorization request from UIN %u\n",
 						   args->uin);
 				data->gc = gc;
-				data->name = g_strdup_printf("%lu", args->uin);
+				data->name = g_strdup_printf("%u", args->uin);
 				data->nick = NULL;
 
 				gaim_request_action(gc, NULL, _("Authorization Request"),
@@ -2607,7 +2607,7 @@
 
 		case 0x07: { /* Someone has denied you authorization */
 			if (i >= 1) {
-				gchar *dialog_msg = g_strdup_printf(_("The user %lu has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given."));
+				gchar *dialog_msg = g_strdup_printf(_("The user %u has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given."));
 				gaim_notify_info(gc, NULL, _("ICQ authorization denied."),
 								 dialog_msg);
 				g_free(dialog_msg);
@@ -2615,7 +2615,7 @@
 		} break;
 
 		case 0x08: { /* Someone has granted you authorization */
-			gchar *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin);
+			gchar *dialog_msg = g_strdup_printf(_("The user %u has granted your request to add them to your contact list."), args->uin);
 			gaim_notify_info(gc, NULL, "ICQ authorization accepted.",
 							 dialog_msg);
 			g_free(dialog_msg);
@@ -2660,7 +2660,7 @@
 					num = num*10 + text[0][i]-48;
 				for (i=0; i<num; i++) {
 					struct name_data *data = g_new(struct name_data, 1);
-					gchar *message = g_strdup_printf(_("ICQ user %lu has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]);
+					gchar *message = g_strdup_printf(_("ICQ user %u has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]);
 					data->gc = gc;
 					data->name = g_strdup(text[i*2+1]);
 					data->nick = g_strdup(text[i*2+2]);
@@ -3162,12 +3162,12 @@
 
 	if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) {
 		onlinesince = g_strdup_printf(_("Online Since : <b>%s</b><br>\n"),
-					asctime(localtime(&info->onlinesince)));
+					asctime(localtime((time_t *)&info->onlinesince)));
 	}
 
 	if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) {
 		membersince = g_strdup_printf(_("Member Since : <b>%s</b><br>\n"),
-					asctime(localtime(&info->membersince)));
+					asctime(localtime((time_t *)&info->membersince)));
 	}
 
 	if (info->present & AIM_USERINFO_PRESENT_IDLE) {
@@ -3314,7 +3314,7 @@
 			ck = va_arg(ap, char *);
 
 			gaim_debug(GAIM_DEBUG_MISC, "oscar",
-					   "created room: %s %hu %hu %hu %lu %hu %hu %hhu %hu %s %s\n",
+					   "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n",
 					fqcn,
 					exchange, instance, flags,
 					createtime,
@@ -3594,8 +3594,8 @@
 	va_end(ap);
 
 	gaim_debug(GAIM_DEBUG_MISC, "oscar",
-			   "rate %s (param ID 0x%04hx): curavg = %lu, maxavg = %lu, alert at %lu, "
-		     "clear warning at %lu, limit at %lu, disconnect at %lu (window size = %lu)\n",
+			   "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, "
+		     "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n",
 		     (code < 5) ? codes[code] : codes[0],
 		     rateclass,
 		     currentavg, maxavg,
@@ -3758,7 +3758,7 @@
 
 	/* XXX - evidently this crashes on solaris. i have no clue why
 	gaim_debug(GAIM_DEBUG_MISC, "oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, "
-			"max sender evil = %f, max receiver evil = %f, min msg interval = %lu\n",
+			"max sender evil = %f, max receiver evil = %f, min msg interval = %u\n",
 			params->maxchan, params->flags, params->maxmsglen,
 			((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0,
 			params->minmsginterval);
@@ -3900,7 +3900,7 @@
 	if (!info->uin)
 		return 0;
 
-	g_snprintf(who, sizeof(who), "%lu", info->uin);
+	g_snprintf(who, sizeof(who), "%u", info->uin);
 	buf = g_strdup_printf("<b>%s</b> %s", _("UIN:"), who);
 	if (info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) {
 		tmp = buf;  buf = g_strconcat(tmp, "\n<br><b>", _("Nick:"), "</b> ", utf8, NULL);  g_free(tmp); g_free(utf8);
@@ -4017,7 +4017,7 @@
 	va_end(ap);
 
 	if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) {
-		g_snprintf(who, sizeof(who), "%lu", info->uin);
+		g_snprintf(who, sizeof(who), "%u", info->uin);
 		serv_got_alias(gc, who, utf8);
 		if ((b = gaim_find_buddy(gc->account, who))) {
 			gaim_buddy_set_setting(b, "servernick", utf8);
--- a/src/protocols/oscar/util.c	Fri May 30 00:02:42 2003 +0000
+++ b/src/protocols/oscar/util.c	Fri May 30 02:35:44 2003 +0000
@@ -168,16 +168,14 @@
 faim_export int aim_snlen(const char *sn)
 {
 	int i = 0;
-	const char *curPtr = NULL;
 
 	if (!sn)
 		return 0;
 
-	curPtr = sn;
-	while ( (*curPtr) != (char) NULL) {
-		if ((*curPtr) != ' ')
-		i++;
-		curPtr++;
+	while (*sn != '\0') {
+		if (*sn != ' ')
+			i++;
+		sn++;
 	}
 
 	return i;
@@ -197,29 +195,25 @@
 */
 faim_export int aim_sncmp(const char *sn1, const char *sn2)
 {
-	const char *curPtr1 = NULL, *curPtr2 = NULL;
 
 	if (aim_snlen(sn1) != aim_snlen(sn2))
 		return 1;
 
-	curPtr1 = sn1;
-	curPtr2 = sn2;
-	while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) ) {
-		if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) {
-			if (*curPtr1 == ' ')
-				curPtr1++;
-			if (*curPtr2 == ' ')
-				curPtr2++;
-		} else {
-			if ( toupper(*curPtr1) != toupper(*curPtr2))
-				return 1;
-			curPtr1++;
-			curPtr2++;
-		}
+	/* XXX - Should be able to only check if sn1 != '\0', right?  Is that faster? */
+	while ((*sn1 != '\0') && (*sn2 != '\0')) {
+		while (*sn2 == ' ')
+			*sn2++;
+		while (*sn1 == ' ')
+			*sn1++;
+		if (toupper(*sn1) != toupper(*sn2))
+			return 1;
+		sn1++;
+		sn2++;
 	}
 
 	/* Should both be NULL */
-	if (*curPtr1 != *curPtr2)
+	/* XXX - I think this check is not necessary, but I'm afeared to take it out */
+	if (*sn1 != *sn2)
 		return 1;
 
 	return 0;