changeset 14045:3cefea0bf4a2

[gaim-migrate @ 16657] Took care of some signedness issues. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Sun, 06 Aug 2006 21:03:10 +0000
parents 16b05033f5ee
children eb1a7d176149
files src/protocols/qq/char_conv.c src/protocols/qq/file_trans.c src/protocols/qq/im.c src/protocols/qq/im.h src/protocols/qq/qq_proxy.c src/protocols/qq/qq_proxy.h src/protocols/qq/send_file.c src/protocols/qq/udp_proxy_s5.c
diffstat 8 files changed, 37 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/qq/char_conv.c	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/char_conv.c	Sun Aug 06 21:03:10 2006 +0000
@@ -38,7 +38,7 @@
 #define QQ_NULL_SMILEY        "(SM)"	/* return this if smiley conversion fails */
 
 /* a debug function */
-void _qq_show_packet(gchar * desc, gchar * buf, gint len);
+void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len);
 
 const gchar qq_smiley_map[QQ_SMILEY_AMOUNT] = {
 	0x41, 0x43, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48,
--- a/src/protocols/qq/file_trans.c	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/file_trans.c	Sun Aug 06 21:03:10 2006 +0000
@@ -282,7 +282,7 @@
 	return bytes;
 }
 
-extern gchar *_gen_session_md5(gint uid, gchar *session_key);
+extern gchar *_gen_session_md5(gint uid, guint8 *session_key);
 
 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */
 void qq_send_file_ctl_packet(GaimConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte)
--- a/src/protocols/qq/im.c	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/im.c	Sun Aug 06 21:03:10 2006 +0000
@@ -45,7 +45,7 @@
 #define DEFAULT_FONT_NAME_LEN 	  4
 
 /* a debug function */
-void _qq_show_packet(gchar *desc, gchar *buf, gint len);
+void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len);
 
 enum
 {
@@ -94,7 +94,7 @@
 	guint8 is_there_font_attr;
 	guint8 unknown3[4];
 	guint8 msg_type;
-	guint8 *msg;		/* no fixed length, ends with 0x00 */
+	gchar *msg;		/* no fixed length, ends with 0x00 */
 	guint8 *font_attr;
 	gint font_attr_len;
 };
@@ -121,11 +121,11 @@
 guint8 *qq_get_send_im_tail(const gchar *font_color,
 			    const gchar *font_size,
 			    const gchar *font_name,
-			    gboolean is_bold, gboolean is_italic, gboolean is_underline, guint tail_len)
+			    gboolean is_bold, gboolean is_italic, gboolean is_underline, gint tail_len)
 {
 	gchar *s1, *s2;
 	unsigned char *rgb;
-	guint font_name_len;
+	gint font_name_len;
 	guint8 *send_im_tail;
 	const guint8 simsun[] = { 0xcb, 0xce, 0xcc, 0xe5 };
 
@@ -133,14 +133,14 @@
 		font_name_len = strlen(font_name);
 	} else {
 		font_name_len = DEFAULT_FONT_NAME_LEN;
-		font_name = simsun;
+		font_name = (const gchar *) simsun;
 	}
 
 	send_im_tail = g_new0(guint8, tail_len);
 
-	g_strlcpy(send_im_tail + QQ_SEND_IM_AFTER_MSG_HEADER_LEN,
+	g_strlcpy((gchar *) (send_im_tail + QQ_SEND_IM_AFTER_MSG_HEADER_LEN),
 		  font_name, tail_len - QQ_SEND_IM_AFTER_MSG_HEADER_LEN);
-	send_im_tail[tail_len - 1] = tail_len;
+	send_im_tail[tail_len - 1] = (guint8) tail_len;
 
 	send_im_tail[0] = 0x00;
 	if (font_size) {
@@ -210,14 +210,13 @@
 }
 
 /* generate a md5 key using uid and session_key */
-gchar *_gen_session_md5(gint uid, gchar *session_key)
+gchar *_gen_session_md5(gint uid, guint8 *session_key)
 {
-	gchar *src, md5_str[QQ_KEY_LENGTH];
-	guint8 *cursor;
+	guint8 *src, md5_str[QQ_KEY_LENGTH], *cursor;
 	GaimCipher *cipher;
         GaimCipherContext *context;
 
-	src = g_newa(gchar, 20);
+	src = g_newa(guint8, 20);
 	cursor = src;
 	create_packet_dw(src, &cursor, uid);
 	create_packet_data(src, &cursor, session_key, QQ_KEY_LENGTH);
@@ -309,15 +308,15 @@
 	 * even the is_there_font_attr shows 0x01, and msg does not ends with 0x00 */
 	if (im_text->msg_type == QQ_IM_AUTO_REPLY) {
 		im_text->is_there_font_attr = 0x00;	/* indeed there is no this flag */
-		im_text->msg = g_strndup(*cursor, data + len - *cursor);
+		im_text->msg = g_strndup(*(gchar **) cursor, data + len - *cursor);
 	} else {		/* it is normal mesasge */
 		if (im_text->is_there_font_attr) {
-			im_text->msg = g_strdup(*cursor);
+			im_text->msg = g_strdup(*(gchar **) cursor);
 			*cursor += strlen(im_text->msg) + 1;
 			im_text->font_attr_len = data + len - *cursor;
 			im_text->font_attr = g_memdup(*cursor, im_text->font_attr_len);
 		} else		/* not im_text->is_there_font_attr */
-			im_text->msg = g_strndup(*cursor, data + len - *cursor);
+			im_text->msg = g_strndup(*(gchar **) cursor, data + len - *cursor);
 	}			/* if im_text->msg_type */
 	_qq_show_packet("QQ_MESG recv", data, *cursor - data);
 
@@ -450,9 +449,9 @@
 void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type)
 {
 	qq_data *qd;
-	guint8 *cursor, *raw_data;
+	guint8 *cursor, *raw_data, *send_im_tail;
 	guint16 client_tag, normal_im_type;
-	gint msg_len, raw_len, bytes;
+	gint msg_len, raw_len, font_name_len, tail_len, bytes;
 	time_t now;
 	gchar *md5, *msg_filtered;
 	GData *attribs;
@@ -512,7 +511,6 @@
 	now = time(NULL);
 	md5 = _gen_session_md5(qd->uid, qd->session_key);
 
-	guint font_name_len, tail_len;
 	font_name_len = (font_name) ? strlen(font_name) : DEFAULT_FONT_NAME_LEN;
 	tail_len = font_name_len + QQ_SEND_IM_AFTER_MSG_HEADER_LEN + 1;
 
@@ -553,11 +551,11 @@
 	/* 052-052: text message type (normal/auto-reply) */
 	bytes += create_packet_b(raw_data, &cursor, type);
 	/* 053-   : msg ends with 0x00 */
-	bytes += create_packet_data(raw_data, &cursor, msg_filtered, msg_len);
-	guint8 *send_im_tail = qq_get_send_im_tail(font_color, font_size, font_name, is_bold,
+	bytes += create_packet_data(raw_data, &cursor, (guint8 *) msg_filtered, msg_len);
+	send_im_tail = qq_get_send_im_tail(font_color, font_size, font_name, is_bold,
 						   is_italic, is_underline, tail_len);
 	_qq_show_packet("QQ_MESG debug", send_im_tail, tail_len);
-	bytes += create_packet_data(raw_data, &cursor, (gchar *) send_im_tail, tail_len);
+	bytes += create_packet_data(raw_data, &cursor, send_im_tail, tail_len);
 
 	_qq_show_packet("QQ_MESG raw", raw_data, cursor - raw_data);
 
--- a/src/protocols/qq/im.h	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/im.h	Sun Aug 06 21:03:10 2006 +0000
@@ -54,7 +54,7 @@
 guint8 *qq_get_send_im_tail(const gchar *font_color,
 			    const gchar *font_size,
 			    const gchar *font_name,
-			    gboolean is_bold, gboolean is_italic, gboolean is_underline, guint len);
+			    gboolean is_bold, gboolean is_italic, gboolean is_underline, gint len);
 
 void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type);
 void qq_process_recv_im(guint8 *buf, gint buf_len, guint16 seq, GaimConnection *gc);
--- a/src/protocols/qq/qq_proxy.c	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/qq_proxy.c	Sun Aug 06 21:03:10 2006 +0000
@@ -54,7 +54,7 @@
 }
 */
 
-void _qq_show_packet(gchar *desc, gchar *buf, gint len)
+void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len)
 {
 	char buf1[8*len+2], buf2[10];
 	int i;
@@ -73,11 +73,11 @@
         GaimCipher *cipher;
         GaimCipherContext *context;
 
-	gchar pwkey_tmp[QQ_KEY_LENGTH];
+	guchar pwkey_tmp[QQ_KEY_LENGTH];
 
 	cipher = gaim_ciphers_find_cipher("md5");
 	context = gaim_cipher_context_new(cipher, NULL);
-	gaim_cipher_context_append(context, pwd, strlen(pwd));
+	gaim_cipher_context_append(context, (guchar *) pwd, strlen(pwd));
 	gaim_cipher_context_digest(context, sizeof(pwkey_tmp), pwkey_tmp, NULL);
 	gaim_cipher_context_destroy(context);
 	context = gaim_cipher_context_new(cipher, NULL);
--- a/src/protocols/qq/qq_proxy.h	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/qq_proxy.h	Sun Aug 06 21:03:10 2006 +0000
@@ -46,8 +46,10 @@
 gint qq_proxy_write(qq_data *qd, guint8 *data, gint len);
 
 gint qq_connect(GaimAccount *account, const gchar *host, guint16 port, gboolean use_tcp, gboolean is_redirect);
+void qq_disconnect(GaimConnection *gc);
 
-void qq_disconnect(GaimConnection *gc);
-void _qq_show_packet(gchar *des, gchar *buf, gint len);
+gint _qq_fill_host(struct sockaddr_in *addr, const gchar *host, guint16 port);
+
+void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len);
 
 #endif
--- a/src/protocols/qq/send_file.c	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/send_file.c	Sun Aug 06 21:03:10 2006 +0000
@@ -269,7 +269,7 @@
 }
 
 
-extern gchar *_gen_session_md5(gint uid, gchar *session_key);
+extern gchar *_gen_session_md5(gint uid, guint8 *session_key);
 
 /* fill in the common information of file transfer */
 static gint _qq_create_packet_file_header
--- a/src/protocols/qq/udp_proxy_s5.c	Sun Aug 06 18:19:36 2006 +0000
+++ b/src/protocols/qq/udp_proxy_s5.c	Sun Aug 06 21:03:10 2006 +0000
@@ -33,7 +33,7 @@
 	unsigned char buf[512];
 	struct PHB *phb = data;
 	struct sockaddr_in sin;
-	int len;
+	int len, error;
 
 	gaim_input_remove(phb->inpa);
 	gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read again.\n");
@@ -82,7 +82,7 @@
 		return;
 	}
 
-	int error = ETIMEDOUT;
+	error = ETIMEDOUT;
 	gaim_debug(GAIM_DEBUG_INFO, "QQ", "Connect didn't block\n");
 	len = sizeof(error);
 	if (getsockopt(phb->udpsock, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
@@ -209,12 +209,15 @@
 static void _qq_s5_canread(gpointer data, gint source, GaimInputCondition cond)
 {
 	unsigned char buf[512];
-	struct PHB *phb = data;
+	struct PHB *phb;
+	int ret;
+
+	phb = data;
 
 	gaim_input_remove(phb->inpa);
 	gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read.\n");
 
-	int ret = read(source, buf, 2);
+	ret = read(source, buf, 2);
 	if (ret < 2) {
 		gaim_debug(GAIM_DEBUG_INFO, "s5_canread", "packet smaller than 2 octet\n");
 		close(source);
@@ -275,7 +278,7 @@
 	}
 }
 
-void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond)
+static void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond)
 {
 	unsigned char buf[512];
 	int i;