]> Dogcows Code - chaz/thecheat/blobdiff - MySocket.m
Remove support of Mac OS X 10.3 and earlier system, change codes for Mac OS X 10.7.
[chaz/thecheat] / MySocket.m
index 5a31c89e5ceb1a690c2ce26e70e3416a31bf9e95..091e30db5ca6bd0b017c299576512a315551518c 100644 (file)
@@ -1,22 +1,13 @@
 
-// **********************************************************************
-// 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"
@@ -231,7 +222,8 @@ struct _mySocketGlobals {
        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 ) {
@@ -403,7 +395,7 @@ struct _mySocketGlobals {
        if ( err == -1 ) {
                return @"";
        }
-       return [NSString stringWithCString:host];
+       return [NSString stringWithCString:host encoding:NSUTF8StringEncoding];
 }
 
 - (int)localPort
@@ -415,20 +407,20 @@ struct _mySocketGlobals {
 {
        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 ) {
@@ -455,7 +447,7 @@ struct _mySocketGlobals {
        struct sockaddr_in addr;
        
        // resolve the host
-       h = gethostbyname( [host lossyCString] );
+       h = gethostbyname( [host cStringUsingEncoding:NSUTF8StringEncoding] );
        if ( h == NULL ) {
                // host not found
                return nil;
@@ -465,7 +457,8 @@ struct _mySocketGlobals {
        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)];
 }
@@ -812,7 +805,7 @@ DONE:;
        MySocket *newSocket;
        int newsockfd;
        struct sockaddr addr;
-       int addrlen = sizeof(addr);
+       unsigned int addrlen = sizeof(addr);
        
        newsockfd = accept( _sockfd, &addr, &addrlen );
        if ( newsockfd >= 0 ) {
@@ -875,7 +868,7 @@ DONE:;
        [_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
@@ -1022,7 +1015,7 @@ DONE:;
        NSMutableData *buffer;
        unsigned packetLen = *len;
        
-       if ( buffer = _unclaimedData ) {
+       if ( (buffer = _unclaimedData) ) {
                // claim the bytes
                int unclaimedLen = [_unclaimedData length];
                if ( unclaimedLen > packetLen ) {
This page took 0.027025 seconds and 4 git commands to generate.