--- sourceforge.net/trunk/rdesktop/tcp.c 2002/09/24 07:59:14 192 +++ sourceforge.net/trunk/rdesktop/tcp.c 2003/06/06 10:44:20 408 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. Protocol services - TCP layer - Copyright (C) Matthew Chapman 1999-2001 + Copyright (C) Matthew Chapman 1999-2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -28,6 +28,10 @@ #include /* errno */ #include "rdesktop.h" +#ifndef INADDR_NONE +#define INADDR_NONE ((unsigned long) -1) +#endif + static int sock; static struct stream in; static struct stream out; @@ -35,11 +39,11 @@ /* Initialise TCP transport data packet */ STREAM -tcp_init(int maxlen) +tcp_init(uint32 maxlen) { if (maxlen > out.size) { - out.data = xrealloc(out.data, maxlen); + out.data = (uint8 *) xrealloc(out.data, maxlen); out.size = maxlen; } @@ -70,13 +74,13 @@ /* Receive a message on the TCP layer */ STREAM -tcp_recv(int length) +tcp_recv(uint32 length) { int rcvd = 0; if (length > in.size) { - in.data = xrealloc(in.data, length); + in.data = (uint8 *) xrealloc(in.data, length); in.size = length; } @@ -84,7 +88,9 @@ while (length > 0) { - ui_select(sock); + if (!ui_select(sock)) + /* User quit */ + return NULL; rcvd = recv(sock, in.end, length, 0); if (rcvd == -1) @@ -106,13 +112,13 @@ { struct hostent *nslookup; struct sockaddr_in servaddr; - int true = 1; + int true_value = 1; if ((nslookup = gethostbyname(server)) != NULL) { memcpy(&servaddr.sin_addr, nslookup->h_addr, sizeof(servaddr.sin_addr)); } - else if (!(servaddr.sin_addr.s_addr = inet_addr(server))) + else if ((servaddr.sin_addr.s_addr = inet_addr(server)) == INADDR_NONE) { error("%s: unable to resolve host\n", server); return False; @@ -134,13 +140,13 @@ return False; } - setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &true, sizeof(true)); + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &true_value, sizeof(true_value)); in.size = 4096; - in.data = xmalloc(in.size); + in.data = (uint8 *) xmalloc(in.size); out.size = 4096; - out.data = xmalloc(out.size); + out.data = (uint8 *) xmalloc(out.size); return True; }