Commits

Jeff Laing committed cf02fa6

64-bit compilation now works

Comments (0)

Files changed (2)

MobileDeviceAccess.h

 /// Read \p n
 /// bytes from the file into the nominated buffer (which must be at
 /// least \p n bytes long).  Returns the number of bytes actually read.
-- (size_t)readN:(size_t)n bytes:(char *)buff;
+- (uint32_t)readN:(uint32_t)n bytes:(char *)buff;
 
 /// Write \p n bytes to the file.  Returns \p true if the write was
 /// successful and \p false otherwise.
-- (bool)writeN:(size_t)n bytes:(const char *)buff;
+- (bool)writeN:(uint32_t)n bytes:(const char *)buff;
 
 /// Write the contents of an NSData to the file.  Returns \p true if the
 /// write was successful and \p false otherwise
 /// Set the size of the file
 ///
 /// Truncates the file to the specified size.
-- (bool)setFileSize:(off_t)size;
+- (bool)setFileSize:(uint64_t)size;
 
 @end
 

MobileDeviceAccess.m

 	if (messageAsXML) {
 		CFIndex xmlLength = CFDataGetLength(messageAsXML);
 		uint32_t sz;
-		int sock = (int)((ssize_t)_service);
+		int sock = (int)((uint32_t)_service);
 		sz = htonl(xmlLength);
 		if (send(sock, &sz, sizeof(sz), 0) != sizeof(sz)) {
 			[self setLastError:@"Can't send message size"];
 - (id)readXMLReply
 {
 	id result = nil;
-	int sock = (int)((ssize_t)_service);
-	size_t sz;
+	int sock = (int)((uint32_t)_service);
+	uint32_t sz;
 
 	/* now wait for the reply */
 
-	if (sizeof(long) != recv(sock, &sz, sizeof(sz), 0)) {
+	if (sizeof(uint32_t) != recv(sock, &sz, sizeof(sz), 0)) {
 		[self setLastError:@"Can't receive reply size"];
 	} else {
 		sz = ntohl(sz);
 			// recv() until we recieve the complete reply.
 			unsigned char *buff = malloc(sz);
 			unsigned char *p = buff;
-			size_t left = sz;
+			uint32_t left = sz;
 			while (left) {
-				size_t rc =recv(sock, p, left,0);
+				uint32_t rc =recv(sock, p, left,0);
 				if (rc==0) {
 					[self setLastError:[NSString stringWithFormat:@"Reply was truncated, expected %d more bytes",left]];
 					free(buff);
 - (NSInputStream*)inputStreamFromSocket
 {
 	CFReadStreamRef s;
-	int sock = (int)((ssize_t)_service);
+	int sock = (int)((uint32_t)_service);
 
 	CFStreamCreatePairWithSocket(
 		kCFAllocatorDefault, (CFSocketNativeHandle)sock, &s, NULL);
 	return [self checkStatus:AFCFileRefTell(_afc, _ref, offset) from:"AFCFileRefTell"];
 }
 
-- (size_t)readN:(size_t)n bytes:(char *)buff
+- (uint32_t)readN:(uint32_t)n bytes:(char *)buff
 {
 	if (![self ensureFileIsOpen]) return NO;
-	unsigned int afcSize = n;
+	uint32_t afcSize = n;
 	if (![self checkStatus:AFCFileRefRead(_afc, _ref, buff, &afcSize) from:"AFCFileRefRead"]) return 0;
 	return afcSize;
 }
 
-- (bool)writeN:(size_t)n bytes:(const char *)buff
+- (bool)writeN:(uint32_t)n bytes:(const char *)buff
 {
 	if (![self ensureFileIsOpen]) return NO;
 	if (n>0) {
-		return [self checkStatus:AFCFileRefWrite(_afc, _ref, buff, (unsigned long)n) from:"AFCFileRefWrite"];
+		return [self checkStatus:AFCFileRefWrite(_afc, _ref, buff, n) from:"AFCFileRefWrite"];
 	}
 	return YES;
 }
 	return [self writeN:[data length] bytes:[data bytes]];
 }
 
-- (bool)setFileSize:(off_t)size
+- (bool)setFileSize:(uint64_t)size
 {
 	if (![self ensureFileIsOpen]) return NO;
 	return [self checkStatus:AFCFileRefSetFileSize(_afc, _ref, size) from:"AFCFileRefSetFileSize"];
 				AFCFileReference *out = [self openForWrite:path2];
 				if (out) {
 					// copy all content across 10K at a time
-					const size_t bufsz = 10240;
+					const uint32_t bufsz = 10240;
 					uint32_t done = 0;
 					while (1) {
 						[info setObject:[NSNumber numberWithInt:done] forKey:@"Done"];
 						[nc postNotificationName:@"AFCFileCopyProgress" object:self userInfo:info];
 						NSData *nextblock = [in readDataOfLength:bufsz];
-						size_t n = [nextblock length];
+						uint32_t n = [nextblock length];
 						if (n==0) break;
 						[out writeNSData:nextblock];
 						done += n;
 					[self setLastError:@"Can't open output file"];
 				} else {
 					// copy all content across 10K at a time...
-					const size_t bufsz = 10240;
+					const uint32_t bufsz = 10240;
 					NSMutableData *buff = [[NSMutableData alloc] initWithLength:bufsz];
 					while (1) {
-						size_t n = [in readN:bufsz bytes:[buff mutableBytes]];
+						uint32_t n = [in readN:bufsz bytes:[buff mutableBytes]];
 						if (n==0) break;
 						[out writeData:[NSData dataWithBytesNoCopy:[buff mutableBytes] length:n freeWhenDone:NO]];
 					}
 	if (self = [super initWithName:@"com.apple.syslog_relay" onDevice:device]) {
 		_listener = listener;
 		_message = message;
-		int sock = (int)((ssize_t)_service);
+		int sock = (int)((uint32_t)_service);
 		CFSocketNativeHandle s = (CFSocketNativeHandle)sock;
 		CFStreamCreatePairWithSocket ( 0, s, &_readstream, NULL);
 		if (_readstream) {