# HG changeset patch # User Mark Huetsch # Date 1158941109 0 # Node ID 473b225e73520db6514cffcca42b97e8f84790a8 # Parent 36ededd6e064a4a5f22bb1b11fcae20b537e4407 [gaim-migrate @ 17338] Eliminate a dependency in crypt.c by replacing ntohl() (etc) with g_ntohl() (etc). Also replace those calls in the rest of the QQ prpl, to be consistent. committer: Tailor Script diff -r 36ededd6e064 -r 473b225e7352 libgaim/protocols/qq/crypt.c --- a/libgaim/protocols/qq/crypt.c Fri Sep 22 06:45:01 2006 +0000 +++ b/libgaim/protocols/qq/crypt.c Fri Sep 22 16:05:09 2006 +0000 @@ -38,12 +38,6 @@ 0x61C88647 is what we can track on the ASM codes.!! */ -#ifdef _WIN32 -#include "win32dep.h" -#else -#include -#endif - #include #include "crypt.h" @@ -56,12 +50,12 @@ /* Tiny Encryption Algorithm (TEA) */ static void qq_encipher(guint32 *const v, const guint32 *const k, guint32 *const w) { - register guint32 y = ntohl(v[0]), - z = ntohl(v[1]), - a = ntohl(k[0]), - b = ntohl(k[1]), - c = ntohl(k[2]), - d = ntohl(k[3]), + register guint32 y = g_ntohl(v[0]), + z = g_ntohl(v[1]), + a = g_ntohl(k[0]), + b = g_ntohl(k[1]), + c = g_ntohl(k[2]), + d = g_ntohl(k[3]), n = 0x10, sum = 0, delta = 0x9E3779B9; /* 0x9E3779B9 - 0x100000000 = -0x61C88647 */ @@ -72,8 +66,8 @@ z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); } - w[0] = htonl(y); - w[1] = htonl(z); + w[0] = g_htonl(y); + w[1] = g_htonl(z); } static gint rand(void) { /* it can be the real random seed function */ @@ -175,12 +169,12 @@ static void qq_decipher(guint32 *const v, const guint32 *const k, guint32 *const w) { - register guint32 y = ntohl(v[0]), - z = ntohl(v[1]), - a = ntohl(k[0]), - b = ntohl(k[1]), - c = ntohl(k[2]), - d = ntohl(k[3]), + register guint32 y = g_ntohl(v[0]), + z = g_ntohl(v[1]), + a = g_ntohl(k[0]), + b = g_ntohl(k[1]), + c = g_ntohl(k[2]), + d = g_ntohl(k[3]), n = 0x10, sum = 0xE3779B90, /* why this ? must be related with n value */ delta = 0x9E3779B9; @@ -192,8 +186,8 @@ sum -= delta; } - w[0] = htonl(y); - w[1] = htonl(z); + w[0] = g_htonl(y); + w[1] = g_htonl(z); } static gint decrypt_block(const guint8 **crypt_buff, const gint instrlen, diff -r 36ededd6e064 -r 473b225e7352 libgaim/protocols/qq/packet_parse.c --- a/libgaim/protocols/qq/packet_parse.c Fri Sep 22 06:45:01 2006 +0000 +++ b/libgaim/protocols/qq/packet_parse.c Fri Sep 22 16:05:09 2006 +0000 @@ -20,12 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WIN32 -#include -#else -#include "win32dep.h" -#endif - #include #include "packet_parse.h" @@ -48,7 +42,7 @@ gint read_packet_w(guint8 *buf, guint8 **cursor, gint buflen, guint16 *w) { if (*cursor <= buf + buflen - sizeof(*w)) { - *w = ntohs(**(guint16 **) cursor); + *w = g_ntohs(**(guint16 **) cursor); *cursor += sizeof(*w); return sizeof(*w); } else { @@ -61,7 +55,7 @@ gint read_packet_dw(guint8 *buf, guint8 **cursor, gint buflen, guint32 *dw) { if (*cursor <= buf + buflen - sizeof(*dw)) { - *dw = ntohl(**(guint32 **) cursor); + *dw = g_ntohl(**(guint32 **) cursor); *cursor += sizeof(*dw); return sizeof(*dw); } else { @@ -99,7 +93,7 @@ gint create_packet_w(guint8 *buf, guint8 **cursor, guint16 w) { if (*cursor <= buf + MAX_PACKET_SIZE - sizeof(guint16)) { - **(guint16 **) cursor = htons(w); + **(guint16 **) cursor = g_htons(w); *cursor += sizeof(guint16); return sizeof(guint16); } else { @@ -112,7 +106,7 @@ gint create_packet_dw(guint8 *buf, guint8 **cursor, guint32 dw) { if (*cursor <= buf + MAX_PACKET_SIZE - sizeof(guint32)) { - **(guint32 **) cursor = htonl(dw); + **(guint32 **) cursor = g_htonl(dw); *cursor += sizeof(guint32); return sizeof(guint32); } else { diff -r 36ededd6e064 -r 473b225e7352 libgaim/protocols/qq/qq_proxy.c --- a/libgaim/protocols/qq/qq_proxy.c Fri Sep 22 06:45:01 2006 +0000 +++ b/libgaim/protocols/qq/qq_proxy.c Fri Sep 22 16:05:09 2006 +0000 @@ -50,7 +50,7 @@ socklen_t len = sizeof(sin); getsockname(fd, (struct sockaddr *)&sin, &len); gaim_debug(GAIM_DEBUG_INFO, desc, "%s:%d\n", - inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); + inet_ntoa(sin.sin_addr), g_ntohs(sin.sin_port)); } */ diff -r 36ededd6e064 -r 473b225e7352 libgaim/protocols/qq/send_file.c --- a/libgaim/protocols/qq/send_file.c Fri Sep 22 06:45:01 2006 +0000 +++ b/libgaim/protocols/qq/send_file.c Fri Sep 22 16:05:09 2006 +0000 @@ -67,11 +67,11 @@ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; if (!_qq_in_same_lan(info)) { - sin.sin_port = htons(info->remote_major_port); - sin.sin_addr.s_addr = htonl(info->remote_internet_ip); + sin.sin_port = g_htons(info->remote_major_port); + sin.sin_addr.s_addr = g_htonl(info->remote_internet_ip); } else { - sin.sin_port = htons(info->remote_minor_port); - sin.sin_addr.s_addr = htonl(info->remote_real_ip); + sin.sin_port = g_htons(info->remote_minor_port); + sin.sin_addr.s_addr = g_htonl(info->remote_real_ip); } return 0; } @@ -89,7 +89,7 @@ r = recvfrom(info->recv_fd, buf, len, 0, (struct sockaddr *) &sin, &sinlen); gaim_debug(GAIM_DEBUG_INFO, "QQ", "==> recv %d bytes from File UDP Channel, remote ip[%s], remote port[%d]\n", - r, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); + r, inet_ntoa(sin.sin_addr), g_ntohs(sin.sin_port)); return r; } @@ -111,21 +111,21 @@ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; if (!_qq_in_same_lan(info)) { - sin.sin_port = htons(info->remote_major_port); - sin.sin_addr.s_addr = htonl(info->remote_internet_ip); + sin.sin_port = g_htons(info->remote_major_port); + sin.sin_addr.s_addr = g_htonl(info->remote_internet_ip); } else if (info->use_major) { - sin.sin_port = htons(info->remote_major_port); - sin.sin_addr.s_addr = htonl(info->remote_real_ip); + sin.sin_port = g_htons(info->remote_major_port); + sin.sin_addr.s_addr = g_htonl(info->remote_real_ip); } else { - sin.sin_port = htons(info->remote_minor_port); - sin.sin_addr.s_addr = htonl(info->remote_real_ip); + sin.sin_port = g_htons(info->remote_minor_port); + sin.sin_addr.s_addr = g_htonl(info->remote_real_ip); } gaim_debug(GAIM_DEBUG_INFO, "QQ", "sending to channel: %d.%d.%d.%d:%d\n", sin.sin_addr.s_addr & 0xff, (sin.sin_addr.s_addr >> 8) & 0xff, (sin.sin_addr.s_addr >> 16) & 0xff, sin.sin_addr.s_addr >> 24, - ntohs(sin.sin_port) + g_ntohs(sin.sin_port) ); return sendto(info->sender_fd, buf, len, 0, (struct sockaddr *) &sin, sizeof(sin)); } @@ -230,9 +230,9 @@ gchar *internet_ip_str, *real_ip_str; guint32 ip; - ip = htonl(info->remote_real_ip); + ip = g_htonl(info->remote_real_ip); real_ip_str = gen_ip_str((guint8 *) &ip); - ip = htonl(info->remote_internet_ip); + ip = g_htonl(info->remote_internet_ip); internet_ip_str = gen_ip_str((guint8 *) &ip); gaim_debug(GAIM_DEBUG_INFO, "QQ", "remote internet ip[%s:%d], major port[%d], real ip[%s], minor port[%d]\n", internet_ip_str, info->remote_internet_port, @@ -369,7 +369,7 @@ if (ioctl(fd, SIOCGIFADDR, (char *) &buf[i]) >= 0) { ret = (((struct sockaddr_in *)(&buf[i].ifr_addr))->sin_addr).s_addr; - if (ret == ntohl(0x7f000001)) continue; + if (ret == g_ntohl(0x7f000001)) continue; return ret; } } @@ -391,7 +391,7 @@ /* debug info->local_real_ip = 0x7f000001; */ - info->local_real_ip = ntohl(inet_addr(gaim_network_get_my_ip(-1))); + info->local_real_ip = g_ntohl(inet_addr(gaim_network_get_my_ip(-1))); gaim_debug(GAIM_DEBUG_INFO, "QQ", "local real ip is %x", info->local_real_ip); for (i = 0; i < 2; i++) { @@ -405,7 +405,7 @@ sin_len = sizeof(sin); bind(sockfd, (struct sockaddr *) &sin, sin_len); getsockname(sockfd, (struct sockaddr *) &sin, &sin_len); - listen_port = ntohs(sin.sin_port); + listen_port = g_ntohs(sin.sin_port); switch (i) { case 0: @@ -445,7 +445,7 @@ info = g_new0(ft_info, 1); info->to_uid = to_uid; info->send_seq = qd->send_seq; - info->local_internet_ip = ntohl(inet_addr(qd->my_ip)); + info->local_internet_ip = g_ntohl(inet_addr(qd->my_ip)); info->local_internet_port = qd->my_port; info->local_real_ip = 0x00000000; info->conn_method = 0x00; @@ -800,7 +800,7 @@ } info = g_new0(ft_info, 1); - info->local_internet_ip = ntohl(inet_addr(qd->my_ip)); + info->local_internet_ip = g_ntohl(inet_addr(qd->my_ip)); info->local_internet_port = qd->my_port; info->local_real_ip = 0x00000000; info->to_uid = sender_uid; diff -r 36ededd6e064 -r 473b225e7352 libgaim/protocols/qq/udp_proxy_s5.c --- a/libgaim/protocols/qq/udp_proxy_s5.c Fri Sep 22 06:45:01 2006 +0000 +++ b/libgaim/protocols/qq/udp_proxy_s5.c Fri Sep 22 16:05:09 2006 +0000 @@ -134,11 +134,11 @@ fcntl(phb->udpsock, F_SETFL, O_NONBLOCK); - port = ntohs(ctlsin.sin_port) + 1; + port = g_ntohs(ctlsin.sin_port) + 1; while (1) { inet_aton("0.0.0.0", &(sin.sin_addr)); sin.sin_family = AF_INET; - sin.sin_port = htons(port); + sin.sin_port = g_htons(port); if (bind(phb->udpsock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { port++; if (port > 65500) {