aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-08-26 21:18:28 +0000
committerstuconnolly <stuart02@gmail.com>2009-08-26 21:18:28 +0000
commit63c47d26eeed7e2602e0925cae8e7386963ce695 (patch)
tree99529d48c972af8348f5478930a4116e0cc608b0 /Frameworks/MCPKit/MCPFoundationKit
parent082332ed69b7cfb2d11d1d45b848cb1fc393b3ca (diff)
downloadsequelpro-63c47d26eeed7e2602e0925cae8e7386963ce695.tar.gz
sequelpro-63c47d26eeed7e2602e0925cae8e7386963ce695.tar.bz2
sequelpro-63c47d26eeed7e2602e0925cae8e7386963ce695.zip
Make the MCPkit framework truly 64 bit compatible by using the appropriate data types.
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h51
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m70
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h4
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h22
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h2
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m2
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m24
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPResult.h20
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPResult.m61
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h2
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m10
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m6
12 files changed, 139 insertions, 135 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
index 5b8aefba..edb71ee4 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
@@ -32,12 +32,13 @@
#import "mysql.h"
-enum mcp_query_streaming_types
+enum
{
MCP_NO_STREAMING = 0,
MCP_FAST_STREAMING = 1,
MCP_LOWMEM_STREAMING = 2
};
+typedef NSUInteger mcp_query_streaming_types;
@class MCPResult, MCPStreamingResult;
@protocol MCPConnectionProxy;
@@ -45,9 +46,9 @@ enum mcp_query_streaming_types
/**
* NSStringDataUsingLossyEncoding(aStr, enc, lossy) := [aStr dataUsingEncoding:enc allowLossyConversion:lossy]
*/
-static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encoding, int lossy)
+static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger encoding, NSInteger lossy)
{
- typedef NSData* (*SPStringDataUsingLossyEncodingMethodPtr)(NSString*, SEL, int, int);
+ typedef NSData* (*SPStringDataUsingLossyEncodingMethodPtr)(NSString*, SEL, NSInteger, NSInteger);
static SPStringDataUsingLossyEncodingMethodPtr SPNSStringDataUsingLossyEncoding;
if (!SPNSStringDataUsingLossyEncoding) SPNSStringDataUsingLossyEncoding = (SPStringDataUsingLossyEncodingMethodPtr)[self methodForSelector:@selector(dataUsingEncoding:allowLossyConversion:)];
NSData* to_return = SPNSStringDataUsingLossyEncoding(self, @selector(dataUsingEncoding:allowLossyConversion:), encoding, lossy);
@@ -73,30 +74,30 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
BOOL mConnected; /* Reflect the fact that the connection is already in place or not. */
NSStringEncoding mEncoding; /* The encoding used by MySQL server, to ISO-1 default. */
NSTimeZone *mTimeZone; /* The time zone of the session. */
- unsigned int mConnectionFlags; /* The flags to be used for the connection to the database. */
+ NSUInteger mConnectionFlags; /* The flags to be used for the connection to the database. */
id delegate; /* Connection delegate */
NSLock *queryLock; /* Anything that performs a mysql_net_read is not thread-safe: mysql queries, pings */
BOOL useKeepAlive;
- int connectionTimeout;
- float keepAliveInterval;
+ NSInteger connectionTimeout;
+ CGFloat keepAliveInterval;
id <MCPConnectionProxy> connectionProxy;
NSString *connectionLogin;
NSString *connectionPassword;
NSString *connectionHost;
- int connectionPort;
+ NSInteger connectionPort;
NSString *connectionSocket;
- int maxAllowedPacketSize;
+ NSInteger maxAllowedPacketSize;
unsigned long connectionThreadId;
- int currentProxyState;
+ NSInteger currentProxyState;
double lastQueryExecutionTime;
double lastQueryExecutedAtTime;
NSString *lastQueryErrorMessage;
- unsigned int lastQueryErrorId;
+ NSUInteger lastQueryErrorId;
my_ulonglong lastQueryAffectedRows;
BOOL isMaxAllowedPacketEditable;
@@ -128,11 +129,11 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
@property (readwrite, assign) BOOL useKeepAlive;
@property (readwrite, assign) BOOL delegateQueryLogging;
-@property (readwrite, assign) int connectionTimeout;
-@property (readwrite, assign) float keepAliveInterval;
+@property (readwrite, assign) NSInteger connectionTimeout;
+@property (readwrite, assign) CGFloat keepAliveInterval;
// Initialisation
-- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(int)port;
+- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSInteger)port;
- (id)initToSocket:(NSString *)socket withLogin:(NSString *)login;
// Delegate
@@ -140,7 +141,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
- (void)setDelegate:(id)connectionDelegate;
// Connection details
-- (BOOL)setPort:(int)thePort;
+- (BOOL)setPort:(NSInteger)thePort;
- (BOOL)setPassword:(NSString *)thePassword;
// Proxy
@@ -163,29 +164,29 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
- (double)timeConnected;
// Server versions
-- (int)serverMajorVersion;
-- (int)serverMinorVersion;
-- (int)serverReleaseVersion;
+- (NSInteger)serverMajorVersion;
+- (NSInteger)serverMinorVersion;
+- (NSInteger)serverReleaseVersion;
// MySQL defaults
+ (NSDictionary *)getMySQLLocales;
+ (NSStringEncoding)encodingForMySQLEncoding:(const char *)mysqlEncoding;
+ (NSStringEncoding)defaultMySQLEncoding;
-+ (BOOL)isErrorNumberConnectionError:(int)theErrorNumber;
++ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber;
// Class maintenance
+ (void)setTruncateLongFieldInLogs:(BOOL)iTruncFlag;
+ (BOOL)truncateLongField;
-- (BOOL)setConnectionOption:(int)option toValue:(BOOL)value;
-- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(int)port socket:(NSString *)socket;
+- (BOOL)setConnectionOption:(NSInteger)option toValue:(BOOL)value;
+- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSInteger)port socket:(NSString *)socket;
- (BOOL)selectDB:(NSString *)dbName;
// Error information
- (NSString *)getLastErrorMessage;
- (void)setLastErrorMessage:(NSString *)theErrorMessage;
-- (unsigned int)getLastErrorID;
-+ (BOOL)isErrorNumberConnectionError:(int)theErrorNumber;
+- (NSUInteger)getLastErrorID;
++ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber;
// Queries
- (NSString *)prepareBinaryData:(NSData *)theData;
@@ -194,7 +195,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
- (MCPResult *)queryString:(NSString *)query;
- (MCPStreamingResult *)streamingQueryString:(NSString *)query;
- (MCPStreamingResult *)streamingQueryString:(NSString *)query useLowMemoryBlockingStreaming:(BOOL)fullStream;
-- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(int) streamResult;
+- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(NSInteger) streamResult;
- (double)lastQueryExecutionTime;
- (my_ulonglong)affectedRows;
- (my_ulonglong)insertId;
@@ -230,9 +231,9 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
// Packet size
- (BOOL)fetchMaxAllowedPacket;
-- (int)getMaxAllowedPacket;
+- (NSInteger)getMaxAllowedPacket;
- (BOOL)isMaxAllowedPacketEditable;
-- (int)setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset;
+- (NSInteger)setMaxAllowedPacketTo:(NSInteger)newSize resetSize:(BOOL)reset;
// Data conversion
- (const char *)cStringFromString:(NSString *)theString;
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 2463041a..06a8a757 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -38,12 +38,12 @@
#include <mach/mach_time.h>
static jmp_buf pingTimeoutJumpLocation;
-static void forcePingTimeout(int signalNumber);
+static void forcePingTimeout(NSInteger signalNumber);
-const unsigned int kMCPConnectionDefaultOption = CLIENT_COMPRESS | CLIENT_REMEMBER_OPTIONS ;
+const NSUInteger kMCPConnectionDefaultOption = CLIENT_COMPRESS | CLIENT_REMEMBER_OPTIONS ;
const char *kMCPConnectionDefaultSocket = MYSQL_UNIX_ADDR;
-const unsigned int kMCPConnection_Not_Inited = 1000;
-const unsigned int kLengthOfTruncationForLog = 100;
+const NSUInteger kMCPConnection_Not_Inited = 1000;
+const NSUInteger kLengthOfTruncationForLog = 100;
static BOOL sTruncateLongFieldInLogs = YES;
@@ -99,7 +99,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
connectionProxy = nil;
lastKeepAliveSuccess = nil;
connectionStartTime = -1;
- lastQueryExecutedAtTime = INT_MAX;
+ lastQueryExecutedAtTime = CGFLOAT_MAX;
// Initialize ivar defaults
connectionTimeout = 10;
@@ -137,7 +137,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
/**
* Inialize connection using the supplied host details.
*/
-- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(int)port
+- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSInteger)port
{
if ((self = [self init])) {
if (!host) host = @"";
@@ -203,7 +203,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
/**
* Sets or updates the connection port - for use with tunnels.
*/
-- (BOOL)setPort:(int)thePort
+- (BOOL)setPort:(NSInteger)thePort
{
connectionPort = thePort;
@@ -249,7 +249,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
*/
- (void)connectionProxyStateChange:(id <MCPConnectionProxy>)proxy
{
- int newState = [proxy state];
+ NSInteger newState = [proxy state];
// Restart the tunnel if it dies
if (mConnected && newState == PROXY_STATE_IDLE && currentProxyState == PROXY_STATE_CONNECTED) {
@@ -614,7 +614,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
* This function is paired with pingConnection, and provides a method of enforcing the connection
* timeout when mysql_ping does not respect the specified limits.
*/
-static void forcePingTimeout(int signalNumber)
+static void forcePingTimeout(NSInteger signalNumber)
{
longjmp(pingTimeoutJumpLocation, 1);
}
@@ -744,7 +744,7 @@ static void forcePingTimeout(int signalNumber)
/**
* rReturn the server major version or -1 on fail
*/
-- (int)serverMajorVersion
+- (NSInteger)serverMajorVersion
{
if (mConnected) {
@@ -753,7 +753,7 @@ static void forcePingTimeout(int signalNumber)
}
if (serverVersionString != nil) {
- return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
+ return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:0] integerValue];
}
}
@@ -763,7 +763,7 @@ static void forcePingTimeout(int signalNumber)
/**
* Return the server minor version or -1 on fail
*/
-- (int)serverMinorVersion
+- (NSInteger)serverMinorVersion
{
if (mConnected) {
@@ -772,7 +772,7 @@ static void forcePingTimeout(int signalNumber)
}
if(serverVersionString != nil) {
- return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:1] intValue];
+ return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:1] integerValue];
}
}
@@ -782,7 +782,7 @@ static void forcePingTimeout(int signalNumber)
/**
* Return the server release version or -1 on fail
*/
-- (int)serverReleaseVersion
+- (NSInteger)serverReleaseVersion
{
if (mConnected) {
if (serverVersionString == nil) {
@@ -791,7 +791,7 @@ static void forcePingTimeout(int signalNumber)
if (serverVersionString != nil) {
NSString *s = [[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:2];
- return [[[s componentsSeparatedByString:@"-"] objectAtIndex:0] intValue];
+ return [[[s componentsSeparatedByString:@"-"] objectAtIndex:0] integerValue];
}
}
@@ -964,7 +964,7 @@ static void forcePingTimeout(int signalNumber)
* [theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0];
*
*/
-- (BOOL)setConnectionOption:(int)option toValue:(BOOL)value
+- (BOOL)setConnectionOption:(NSInteger)option toValue:(BOOL)value
{
// So far do nothing except for testing if it's proper time for setting option
// What about if some option where setted and a connection is made again with connectTo...
@@ -994,7 +994,7 @@ static void forcePingTimeout(int signalNumber)
* The socket is used if the host is set to !{@"localhost"}, to an empty or a !{nil} string
* For the moment the implementation might not be safe if you have a nil pointer to one of the NSString* variables (underestand: I don't know what the result will be).
*/
-- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(int)port socket:(NSString *)socket
+- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSInteger)port socket:(NSString *)socket
{
const char *theLogin = [self cStringFromString:login];
const char *theHost = [self cStringFromString:host];
@@ -1105,7 +1105,7 @@ static void forcePingTimeout(int signalNumber)
/**
* Returns the ErrorID of the last MySQL error on the connection.
*/
-- (unsigned int)getLastErrorID
+- (NSUInteger)getLastErrorID
{
return lastQueryErrorId;
}
@@ -1113,7 +1113,7 @@ static void forcePingTimeout(int signalNumber)
/**
* Determines whether a supplied error number can be classed as a connection error.
*/
-+ (BOOL)isErrorNumberConnectionError:(int)theErrorNumber
++ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber
{
switch (theErrorNumber) {
@@ -1264,16 +1264,16 @@ static void forcePingTimeout(int signalNumber)
* and the result can be returned or the connection and document have been closed.
* If using streamingResult, the caller is responsible for releasing the result set.
*/
-- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(int) streamResultType
+- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(NSInteger) streamResultType
{
MCPResult *theResult = nil;
double queryStartTime, queryExecutionTime;
const char *theCQuery;
unsigned long theCQueryLength;
- int queryResultCode;
- int queryErrorId = 0;
+ NSInteger queryResultCode;
+ NSInteger queryErrorId = 0;
my_ulonglong queryAffectedRows = 0;
- int currentMaxAllowedPacket = -1;
+ NSInteger currentMaxAllowedPacket = -1;
BOOL isQueryRetry = NO;
NSString *queryErrorMessage = nil;
@@ -1322,9 +1322,9 @@ static void forcePingTimeout(int signalNumber)
} else {
- NSString *errorMessage = [NSString stringWithFormat:NSLocalizedString(@"The query length of %d bytes is larger than max_allowed_packet size (%d).",
+ NSString *errorMessage = [NSString stringWithFormat:NSLocalizedString(@"The query length of %ld bytes is larger than max_allowed_packet size (%ld).",
@"error message if max_allowed_packet < query size"),
- theCQueryLength, maxAllowedPacketSize];
+ (unsigned long)theCQueryLength, maxAllowedPacketSize];
// Write a log entry and update the connection error messages for those uses that check it
if ([delegate respondsToSelector:@selector(queryGaveError:connection:)]) [delegate queryGaveError:errorMessage connection:self];
@@ -1687,7 +1687,7 @@ static void forcePingTimeout(int signalNumber)
*/
- (NSNumber *)protoInfo
{
- return [MCPNumber numberWithUnsignedInt:mysql_get_proto_info(mConnection)];
+ return [MCPNumber numberWithUnsignedInteger:mysql_get_proto_info(mConnection)];
}
/**
@@ -1720,7 +1720,7 @@ static void forcePingTimeout(int signalNumber)
*/
- (BOOL)killProcess:(unsigned long)pid
{
- int theErrorCode = mysql_kill(mConnection, pid);
+ NSInteger theErrorCode = mysql_kill(mConnection, pid);
return (theErrorCode) ? NO : YES;
}
@@ -1745,7 +1745,7 @@ static void forcePingTimeout(int signalNumber)
@"/Applications/MAMP/tmp/mysql/mysql.sock", // MAMP default location
nil];
- for (int i = 0; i < [possibleSocketLocations count]; i++)
+ for (NSInteger i = 0; i < [possibleSocketLocations count]; i++)
{
if ([fileManager fileExistsAtPath:[possibleSocketLocations objectAtIndex:i]])
return [possibleSocketLocations objectAtIndex:i];
@@ -1881,7 +1881,7 @@ static void forcePingTimeout(int signalNumber)
[r autorelease];
if([a count]) {
[queryLock unlock];
- maxAllowedPacketSize = [[a objectAtIndex:([self serverMajorVersion] == 3)?1:0] intValue];
+ maxAllowedPacketSize = [[a objectAtIndex:([self serverMajorVersion] == 3)?1:0] integerValue];
return true;
}
}
@@ -1895,7 +1895,7 @@ static void forcePingTimeout(int signalNumber)
* Retrieves max_allowed_packet size set as global variable.
* It returns -1 if it fails.
*/
-- (int)getMaxAllowedPacket
+- (NSInteger)getMaxAllowedPacket
{
MCPResult *r;
r = [self queryString:@"SELECT @@global.max_allowed_packet" usingEncoding:mEncoding streamingResult:NO];
@@ -1906,7 +1906,7 @@ static void forcePingTimeout(int signalNumber)
}
NSArray *a = [r fetchRowAsArray];
if([a count])
- return [[a objectAtIndex:0] intValue];
+ return [[a objectAtIndex:0] integerValue];
return -1;
}
@@ -1917,20 +1917,20 @@ static void forcePingTimeout(int signalNumber)
* if the maximal size was reached (e.g. set it to 4GB it'll return 1GB up to now).
* If something failed it return -1;
*/
-- (int)setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset
+- (NSInteger)setMaxAllowedPacketTo:(NSInteger)newSize resetSize:(BOOL)reset
{
if(![self isMaxAllowedPacketEditable] || newSize < 1024) return maxAllowedPacketSize;
[queryLock lock];
- mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %d", newSize] UTF8String]);
+ mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %ld", newSize] UTF8String]);
[queryLock unlock];
// Inform the user via a log entry about that change according to reset value
if(delegate && [delegate respondsToSelector:@selector(queryGaveError:connection:)])
if(reset)
- [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %d for new session", newSize] connection:self];
+ [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %ld for new session", newSize] connection:self];
else
- [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %d for the current session to allow query to succeed", newSize] connection:self];
+ [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %ld for the current session to allow query to succeed", newSize] connection:self];
return maxAllowedPacketSize;
}
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h
index a4d1989e..6d03137c 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h
@@ -55,12 +55,12 @@ enum PROXY_TUNNEL_STATES
/**
* Get the current state of the proxy.
*/
-- (int)state;
+- (NSInteger)state;
/**
* Get the local port being used by the proxy.
*/
-- (int)localPort;
+- (NSInteger)localPort;
/**
* Sets the method the proxy should call whenever the state of the connection changes.
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h
index d696dad7..816d68ca 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h
@@ -27,38 +27,40 @@
// More info at <http://code.google.com/p/sequel-pro/>
// Result type constants
-typedef enum {
+enum {
MCPTypeArray = 1,
MCPTypeDictionary = 2,
MCPTypeFlippedArray = 3,
MCPTypeFlippedDictionary = 4
-} MCPReturnType;
+};
+typedef NSUInteger MCPReturnType;
// Connection check constants
-typedef enum {
+enum {
MCPConnectionCheckRetry = 0,
MCPConnectionCheckReconnect = 1,
MCPConnectionCheckDisconnect = 2
-} MCPConnectionCheck;
+};
+typedef NSUInteger MCPConnectionCheck;
// Charcater set mapping constants
typedef struct _OUR_CHARSET
{
- unsigned int nr;
+ NSUInteger nr;
const char *name;
const char *collation;
- unsigned int char_minlen;
- unsigned int char_maxlen;
+ NSUInteger char_minlen;
+ NSUInteger char_maxlen;
} OUR_CHARSET;
// Deafult connection option
-extern const unsigned int kMCPConnectionDefaultOption;
+extern const NSUInteger kMCPConnectionDefaultOption;
// Default socket (from the mysql.h used at compile time)
extern const char *kMCPConnectionDefaultSocket;
// Added to MySQL error code
-extern const unsigned int kMCPConnectionNotInited;
+extern const NSUInteger kMCPConnectionNotInited;
// The length of the truncation if required
-extern const unsigned int kLengthOfTruncationForLog;
+extern const NSUInteger kLengthOfTruncationForLog;
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h
index 5e80d470..e9ced5a0 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h
@@ -40,7 +40,7 @@
- (id)getFirstFieldFromQuery:(NSString *)query;
- (id)getFirstRowFromQuery:(NSString *)query asType:(MCPReturnType)type;
- (id)getAllRowsFromQuery:(NSString *)query asType:(MCPReturnType)type;
-- (NSArray *)getQuery:(NSString *)query colWithIndex:(unsigned int)col;
+- (NSArray *)getQuery:(NSString *)query colWithIndex:(NSUInteger)col;
- (NSArray *)getQuery:(NSString *)query colWithName:(NSString *)colName;
@end
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m
index 6dcc2a17..c5f4d361 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m
@@ -97,7 +97,7 @@
* Get a column (as an NSArray) of the result from the query aQuery. The column is choosen from it's index,
* starting from 0.
*/
-- (NSArray *)getQuery:(NSString *)query colWithIndex:(unsigned int)col
+- (NSArray *)getQuery:(NSString *)query colWithIndex:(NSUInteger)col
{
return [[self queryString:query] fetchColAtIndex:col];
}
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m b/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m
index bab493c3..3dab0e07 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m
@@ -55,12 +55,12 @@
+ (MCPNumber *)numberWithInt:(int)value
{
- return [[[MCPNumber alloc] initWithInt:value] autorelease];
+ return [[[MCPNumber alloc] initWithInteger:value] autorelease];
}
+ (MCPNumber *)numberWithUnsignedInt:(unsigned int)value
{
- return [[[MCPNumber alloc] initWithUnsignedInt:value] autorelease];
+ return [[[MCPNumber alloc] initWithUnsignedInteger:value] autorelease];
}
+ (MCPNumber *)numberWithLong:(long)value
@@ -85,7 +85,7 @@
+ (MCPNumber *)numberWithFloat:(float)value
{
- return [[[MCPNumber alloc] initWithFloat:value] autorelease];
+ return [[[MCPNumber alloc] initWithDouble:value] autorelease];
}
+ (MCPNumber *)numberWithDouble:(double)value
@@ -135,16 +135,16 @@
- (id)initWithInt:(int)value
{
- typeCode = @encode(int);
- number = [[NSNumber alloc] initWithInt:value];
+ typeCode = @encode(NSInteger);
+ number = [[NSNumber alloc] initWithInteger:value];
return self;
}
- (id)initWithUnsignedInt:(unsigned int)value
{
- typeCode = @encode(unsigned int);
- number = [[NSNumber alloc] initWithUnsignedInt:value];
+ typeCode = @encode(NSUInteger);
+ number = [[NSNumber alloc] initWithUnsignedInteger:value];
return self;
}
@@ -183,8 +183,8 @@
- (id)initWithFloat:(float)value
{
- typeCode = @encode(float);
- number = [[NSNumber alloc] initWithFloat:value];
+ typeCode = @encode(CGFloat);
+ number = [[NSNumber alloc] initWithDouble:value];
return self;
}
@@ -246,12 +246,12 @@
- (int)intValue
{
- return [number intValue];
+ return [number integerValue];
}
- (unsigned int)unsignedIntValue
{
- return [number unsignedIntValue];
+ return [number unsignedIntegerValue];
}
- (long)longValue
@@ -276,7 +276,7 @@
- (float)floatValue
{
- return [number floatValue];
+ return [number doubleValue];
}
- (double)doubleValue
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h
index cb66a6cf..4f0d1f80 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h
@@ -38,7 +38,7 @@
MYSQL_RES *mResult; /* The MYSQL_RES structure of the C API. */
NSArray *mNames; /* An NSArray holding the name of the columns. */
NSStringEncoding mEncoding; /* The encoding used by MySQL server, to ISO-1 default. */
- unsigned int mNumOfFields; /* The number of fields in the result. */
+ NSUInteger mNumOfFields; /* The number of fields in the result. */
NSTimeZone *mTimeZone; /* The time zone of the connection when the query was made. */
}
@@ -48,7 +48,7 @@
// Result info
- (my_ulonglong)numOfRows;
-- (unsigned int)numOfFields;
+- (NSUInteger)numOfFields;
// Rows
- (void)dataSeek:(my_ulonglong)row;
@@ -63,10 +63,10 @@
- (NSDictionary *)fetchTypesAsDictionary;
- (NSArray *)fetchResultFieldsStructure;
-- (unsigned int)fetchFlagsAtIndex:(unsigned int)index;
-- (unsigned int)fetchFlagsForKey:(NSString *)key;
+- (NSUInteger)fetchFlagsAtIndex:(NSUInteger)index;
+- (NSUInteger)fetchFlagsForKey:(NSString *)key;
-- (BOOL)isBlobAtIndex:(unsigned int)index;
+- (BOOL)isBlobAtIndex:(NSUInteger)index;
- (BOOL)isBlobForKey:(NSString *)key;
// Conversion
@@ -75,10 +75,10 @@
- (NSString *)stringWithCString:(const char *)theCString;
// Other
-- (NSString *)mysqlTypeToStringForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags withLength:(unsigned long long)length;
-- (NSString *)mysqlTypeToGroupForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags;
-- (NSString *)findCharsetName:(unsigned int)charsetnr;
-- (NSString *)findCharsetCollation:(unsigned int)charsetnr;
-- (unsigned int)findCharsetMaxByteLengthPerChar:(unsigned int)charsetnr;
+- (NSString *)mysqlTypeToStringForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags withLength:(unsigned long long)length;
+- (NSString *)mysqlTypeToGroupForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags;
+- (NSString *)findCharsetName:(NSUInteger)charsetnr;
+- (NSString *)findCharsetCollation:(NSUInteger)charsetnr;
+- (NSUInteger)findCharsetMaxByteLengthPerChar:(NSUInteger)charsetnr;
@end
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
index f3edd9a5..bb7bef5e 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
@@ -345,7 +345,7 @@ const OUR_CHARSET our_charsets60[] =
/**
* Return the number of fields selected by the query. As a side effect it forces an update of the number of fields.
*/
-- (unsigned int)numOfFields
+- (NSUInteger)numOfFields
{
if (mResult) {
return mNumOfFields = mysql_num_fields(mResult);
@@ -375,7 +375,7 @@ const OUR_CHARSET our_charsets60[] =
MYSQL_ROW theRow;
unsigned long *theLengths;
MYSQL_FIELD *theField;
- int i;
+ NSInteger i;
id theReturn;
if (mResult == NULL) {
@@ -461,7 +461,7 @@ const OUR_CHARSET our_charsets60[] =
break;
default:
- NSLog (@"in fetchRowAsType : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i);
+ NSLog (@"in fetchRowAsType : Unknown type : %ld for column %ld, send back a NSData object", (NSInteger)theField[i].type, (NSInteger)i);
theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]];
break;
}
@@ -529,8 +529,8 @@ const OUR_CHARSET our_charsets60[] =
*/
- (NSArray *)fetchFieldNames
{
- int i;
- unsigned int theNumFields;
+ NSInteger i;
+ NSUInteger theNumFields;
NSMutableArray *theNamesArray;
MYSQL_FIELD *theField;
@@ -553,7 +553,7 @@ const OUR_CHARSET our_charsets60[] =
[theNamesArray addObject:theName];
}
else {
- [theNamesArray addObject:[NSString stringWithFormat:@"Column %d", i]];
+ [theNamesArray addObject:[NSString stringWithFormat:@"Column %ld", i]];
}
}
@@ -568,7 +568,7 @@ const OUR_CHARSET our_charsets60[] =
*/
- (id)fetchTypesAsType:(MCPReturnType)aType
{
- int i;
+ NSInteger i;
id theTypes;
MYSQL_FIELD *theField;
@@ -670,7 +670,7 @@ const OUR_CHARSET our_charsets60[] =
break;
default:
theType = @"unknown";
- NSLog (@"in fetchTypesAsArray : Unknown type for column %d of the MCPResult, type = %d", (int)i, (int)theField[i].type);
+ NSLog (@"in fetchTypesAsArray : Unknown type for column %ld of the MCPResult, type = %ld", (NSInteger)i, (NSInteger)theField[i].type);
break;
}
@@ -723,8 +723,8 @@ const OUR_CHARSET our_charsets60[] =
NSMutableArray *structureResult = [NSMutableArray array];
- unsigned int i;
- unsigned int numFields = mysql_num_fields(mResult);
+ NSUInteger i;
+ NSUInteger numFields = mysql_num_fields(mResult);
if (mResult == NULL) return nil;
@@ -735,7 +735,7 @@ const OUR_CHARSET our_charsets60[] =
NSMutableDictionary *fieldStructure = [NSMutableDictionary dictionaryWithCapacity:39];
/* Original column position */
- [fieldStructure setObject:[NSNumber numberWithInt:i] forKey:@"datacolumnindex"];
+ [fieldStructure setObject:[NSNumber numberWithInteger:i] forKey:@"datacolumnindex"];
/* Name of column */
[fieldStructure setObject:[self stringWithCString:theField[i].name] forKey:@"name"];
@@ -796,10 +796,10 @@ const OUR_CHARSET our_charsets60[] =
// [fieldStructure setObject:[NSNumber numberWithInt:(theField[i].flags & BINCMP_FLAG) ? 1 : 0] forKey:@"BINCMP_FLAG"];
/* Number of decimals in field */
- [fieldStructure setObject:[NSNumber numberWithUnsignedInt:theField[i].decimals] forKey:@"decimals"];
+ [fieldStructure setObject:[NSNumber numberWithUnsignedInteger:theField[i].decimals] forKey:@"decimals"];
/* Character set */
- [fieldStructure setObject:[NSNumber numberWithUnsignedInt:theField[i].charsetnr] forKey:@"charsetnr"];
+ [fieldStructure setObject:[NSNumber numberWithUnsignedInteger:theField[i].charsetnr] forKey:@"charsetnr"];
[fieldStructure setObject:[self findCharsetName:theField[i].charsetnr] forKey:@"charset_name"];
[fieldStructure setObject:[self findCharsetCollation:theField[i].charsetnr] forKey:@"charset_collation"];
@@ -827,10 +827,10 @@ const OUR_CHARSET our_charsets60[] =
/**
* Return the MySQL flags of the column at the given index... Can be used to check if a number is signed or not...
*/
-- (unsigned int)fetchFlagsAtIndex:(unsigned int)index
+- (NSUInteger)fetchFlagsAtIndex:(NSUInteger)index
{
- unsigned int theRet;
- unsigned int theNumFields;
+ NSUInteger theRet;
+ NSUInteger theNumFields;
MYSQL_FIELD *theField;
if (mResult == NULL) {
@@ -855,10 +855,10 @@ const OUR_CHARSET our_charsets60[] =
/**
*
*/
-- (unsigned int)fetchFlagsForKey:(NSString *)key
+- (NSUInteger)fetchFlagsForKey:(NSString *)key
{
- unsigned int theRet;
- unsigned int theNumFields, index;
+ NSUInteger theRet;
+ NSUInteger theNumFields, index;
MYSQL_FIELD *theField;
if (mResult == NULL) {
@@ -896,10 +896,10 @@ const OUR_CHARSET our_charsets60[] =
* #{NOTE} That the current version handles properly TEXT, and returns those as NSString (and not NSData as
* it used to be).
*/
-- (BOOL)isBlobAtIndex:(unsigned int)index
+- (BOOL)isBlobAtIndex:(NSUInteger)index
{
BOOL theRet;
- unsigned int theNumFields;
+ NSUInteger theNumFields;
MYSQL_FIELD *theField;
if (mResult == NULL) {
@@ -944,7 +944,7 @@ const OUR_CHARSET our_charsets60[] =
- (BOOL)isBlobForKey:(NSString *)key
{
BOOL theRet;
- unsigned int theNumFields, index;
+ NSUInteger theNumFields, index;
MYSQL_FIELD *theField;
if (mResult == NULL) {
@@ -1016,13 +1016,14 @@ const OUR_CHARSET our_charsets60[] =
}
else {
NSMutableString *theString = [NSMutableString stringWithCapacity:0];
- int i;
+ NSInteger i;
NSArray *theRow;
MYSQL_ROW_OFFSET thePosition;
BOOL trunc = [MCPConnection truncateLongField];
// First line, saying we are displaying a MCPResult
- [theString appendFormat:@"MCPResult: (encoding : %d, dim %d x %d)\n", (long)mEncoding, (long)mNumOfFields, (long)[self numOfRows]];
+ [theString appendFormat:@"MCPResult: (encoding : %ld, dim %ld x %ld)\n", (long)mEncoding, (long)mNumOfFields, (long)[self numOfRows]];
+
// Second line: the field names, tab separated
[self fetchFieldNames];
@@ -1097,7 +1098,7 @@ const OUR_CHARSET our_charsets60[] =
/**
* Convert a mysql_type to a string
*/
-- (NSString *)mysqlTypeToStringForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags withLength:(unsigned long long)length
+- (NSString *)mysqlTypeToStringForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags withLength:(unsigned long long)length
{
// BOOL isUnsigned = (flags & UNSIGNED_FLAG) != 0;
// BOOL isZerofill = (flags & ZEROFILL_FLAG) != 0;
@@ -1146,7 +1147,7 @@ const OUR_CHARSET our_charsets60[] =
case MYSQL_TYPE_BLOB:
{
BOOL isBlob = (charsetnr == MAGIC_BINARY_CHARSET_NR);
- switch ((int)length/[self findCharsetMaxByteLengthPerChar:charsetnr]) {
+ switch ((NSInteger)length/[self findCharsetMaxByteLengthPerChar:charsetnr]) {
case 255: return isBlob? @"TINYBLOB":@"TINYTEXT";
case 65535: return isBlob? @"BLOB":@"TEXT";
case 16777215: return isBlob? @"MEDIUMBLOB":@"MEDIUMTEXT";
@@ -1202,7 +1203,7 @@ const OUR_CHARSET our_charsets60[] =
/**
* Merge mysql_types into type groups
*/
-- (NSString *)mysqlTypeToGroupForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags
+- (NSString *)mysqlTypeToGroupForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags
{
switch(type){
case FIELD_TYPE_BIT:
@@ -1268,7 +1269,7 @@ const OUR_CHARSET our_charsets60[] =
/**
* Convert a mysql_charsetnr into a charset name as string
*/
-- (NSString *)findCharsetName:(unsigned int)charsetnr
+- (NSString *)findCharsetName:(NSUInteger)charsetnr
{
const OUR_CHARSET * c = our_charsets60;
@@ -1284,7 +1285,7 @@ const OUR_CHARSET our_charsets60[] =
/**
* Convert a mysql_charsetnr into a collation name as string
*/
-- (NSString *)findCharsetCollation:(unsigned int)charsetnr
+- (NSString *)findCharsetCollation:(NSUInteger)charsetnr
{
const OUR_CHARSET * c = our_charsets60;
@@ -1301,7 +1302,7 @@ const OUR_CHARSET our_charsets60[] =
* Return the max byte length to store a char by using
* a specific mysql_charsetnr
*/
-- (unsigned int)findCharsetMaxByteLengthPerChar:(unsigned int)charsetnr
+- (NSUInteger)findCharsetMaxByteLengthPerChar:(NSUInteger)charsetnr
{
const OUR_CHARSET * c = our_charsets60;
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h
index f4539522..f161bd0c 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h
@@ -33,7 +33,7 @@
@interface MCPResult (MCPResultPlus)
// Getting a complete column as an array
-- (NSArray *)fetchColAtIndex:(unsigned int)col;
+- (NSArray *)fetchColAtIndex:(NSUInteger)col;
- (NSArray *)fetchColWithName:(NSString *)colName;
// Getting the complete result as 2D array
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m
index 53b1846d..c171dc7f 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m
@@ -40,7 +40,7 @@
* The index 0 of the returned array always correspond to the first row (ie: returned NSArray is indexed
* by row number), the read position is restored after to it's initial position after the read.
*/
-- (NSArray *)fetchColAtIndex:(unsigned int)col
+- (NSArray *)fetchColAtIndex:(NSUInteger)col
{
NSMutableArray *theCol = [NSMutableArray arrayWithCapacity:[self numOfRows]];
MYSQL_ROW_OFFSET thePosition;
@@ -52,7 +52,7 @@
}
if (col >= mNumOfFields) {
// Bad column number
- NSLog (@"The index : %d is not within the range 0 - %d\n", (long)col, (long)mNumOfFields);
+ NSLog (@"The index : %ld is not within the range 0 - %ld\n", (long)col, (long)mNumOfFields);
return nil;
}
@@ -78,7 +78,7 @@
*/
- (NSArray *)fetchColWithName:(NSString *)colName
{
- unsigned int theCol;
+ NSUInteger theCol;
if (mResult == NULL) {
// If there is no results, returns nil.
@@ -117,7 +117,7 @@
{
id theTable, theVect;
MYSQL_ROW_OFFSET thePosition;
- unsigned int i;
+ NSUInteger i;
if (mResult == NULL) {
// If there is no results, returns nil.
@@ -175,7 +175,7 @@
theTable = [NSDictionary dictionaryWithDictionary:theTable];
break;
default :
- NSLog (@"Unknown MCPReturnType : %d; return nil\n", (int)type);
+ NSLog (@"Unknown MCPReturnType : %ld; return nil\n", (NSInteger)type);
theTable = nil;
break;
}
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
index c63a9f0b..58bd7399 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
@@ -142,7 +142,7 @@
MYSQL_ROW theRow;
char *theRowData;
unsigned long *fieldLengths;
- int i, copiedDataLength;
+ NSInteger i, copiedDataLength;
NSMutableArray *returnArray;
// Retrieve the next row according to the mode this result set is in.
@@ -257,7 +257,7 @@
break;
default:
- NSLog(@"in fetchNextRowAsArray : Unknown type : %d for column %d, sending back a NSData object", (int)fieldDefinitions[i].type, (int)i);
+ NSLog(@"in fetchNextRowAsArray : Unknown type : %ld for column %ld, sending back a NSData object", (NSInteger)fieldDefinitions[i].type, (NSInteger)i);
cellData = [NSData dataWithBytes:theData length:fieldLengths[i]];
break;
}
@@ -355,7 +355,7 @@
NSAutoreleasePool *downloadPool = [[NSAutoreleasePool alloc] init];
MYSQL_ROW theRow;
unsigned long *fieldLengths;
- int i, dataCopiedLength, rowDataLength;
+ NSInteger i, dataCopiedLength, rowDataLength;
LOCAL_ROW_DATA *newRowStore;
size_t sizeOfLocalRowData = sizeof(LOCAL_ROW_DATA);