-// **********************************************************************
-// The Cheat - A universal game cheater for Mac OS X
-// (C) 2003-2005 Chaz McGarvey (BrokenZipper)
-//
-// 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
-// the Free Software Foundation; either version 1, or (at your option)
-// any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// 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.
-//
+/*
+ * The Cheat - The legendary universal game trainer for Mac OS X.
+ * http://www.brokenzipper.com/trac/wiki/TheCheat
+ *
+ * Copyright (c) 2003-2011, Charles McGarvey et al.
+ *
+ * Distributable under the terms and conditions of the 2-clause BSD
+ * license; see the file COPYING for the legal text of the license.
+ */
#import "MySocket.h"
addr.sin_family = AF_INET;
addr.sin_port = htons( (short)port );
addr.sin_addr.s_addr = INADDR_ANY;
- memset( &(addr.sin_zero), NULL, 8 );
+ // Use 0 replace NULL
+ memset( &(addr.sin_zero), 0, 8 );
err = bind( _sockfd, (struct sockaddr *)(&addr), sizeof(addr) );
if ( err == -1 ) {
if ( err == -1 ) {
return @"";
}
- return [NSString stringWithCString:host];
+ return [NSString stringWithCString:host encoding:NSUTF8StringEncoding];
}
- (int)localPort
{
int err;
struct sockaddr_in addr;
- int len = sizeof(addr);
+ unsigned int len = sizeof(addr);
err = getpeername( _sockfd, (struct sockaddr *)(&addr), &len );
if ( err == -1 ) {
return @"Unknown";
}
- return [NSString stringWithCString:inet_ntoa(addr.sin_addr)];
+ return [NSString stringWithCString:inet_ntoa(addr.sin_addr) encoding:NSUTF8StringEncoding];
}
- (int)remotePort
{
int err;
struct sockaddr_in addr;
- int len = sizeof(addr);
+ unsigned int len = sizeof(addr);
err = getpeername( _sockfd, (struct sockaddr *)(&addr), &len );
if ( err == -1 ) {
struct sockaddr_in addr;
// resolve the host
- h = gethostbyname( [host lossyCString] );
+ h = gethostbyname( [host cStringUsingEncoding:NSUTF8StringEncoding] );
if ( h == NULL ) {
// host not found
return nil;
addr.sin_family = AF_INET;
addr.sin_port = htons( (short)port );
memcpy( &(addr.sin_addr), h->h_addr, sizeof(struct in_addr) );
- memset( &(addr.sin_zero), NULL, 8 );
+ // Use 0 replace NULL
+ memset( &(addr.sin_zero), 0, 8 );
return [NSData dataWithBytes:&addr length:sizeof(addr)];
}
MySocket *newSocket;
int newsockfd;
struct sockaddr addr;
- int addrlen = sizeof(addr);
+ unsigned int addrlen = sizeof(addr);
newsockfd = accept( _sockfd, &addr, &addrlen );
if ( newsockfd >= 0 ) {
[_writeLock lock];
if ( [_writeQueue count] > 0 ) {
int buflen = 0;
- int len = sizeof(buflen);
+ unsigned int len = sizeof(buflen);
int err;
err = getsockopt( _sockfd, SOL_SOCKET, SO_SNDBUF, &buflen, &len );
// write data
NSMutableData *buffer;
unsigned packetLen = *len;
- if ( buffer = _unclaimedData ) {
+ if ( (buffer = _unclaimedData) ) {
// claim the bytes
int unclaimedLen = [_unclaimedData length];
if ( unclaimedLen > packetLen ) {