@@ -22,11 +22,13 @@ /* Work around __block being used by glibc */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif -#ifndef _WIN32 +#include "platform.h" + +#ifndef OF_WINDOWS # include # include # include #endif @@ -44,20 +46,20 @@ #import "OFInitializationFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" -#ifdef _WIN32 +#ifdef OF_WINDOWS # include #endif -#ifndef __MACH__ +#if !defined(OF_WINDOWS) && !defined(HAVE_POSIX_SPAWNP) extern char **environ; #endif @interface OFProcess (OF_PRIVATE_CATEGORY) -#ifndef _WIN32 +#ifndef OF_WINDOWS - (void)OF_getArgV: (char***)argv forProgramName: (OFString*)programName andArguments: (OFArray*)arguments; - (char**)OF_environmentForDictionary: (OFDictionary*)dictionary; #else @@ -136,11 +138,11 @@ environment: (OFDictionary*)environment { self = [super init]; @try { -#ifndef _WIN32 +#ifndef OF_WINDOWS void *pool = objc_autoreleasePoolPush(); const char *path; char **argv; if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0) @@ -337,11 +339,11 @@ [self close]; [super dealloc]; } -#ifndef _WIN32 +#ifndef OF_WINDOWS - (void)OF_getArgV: (char***)argv forProgramName: (OFString*)programName andArguments: (OFArray*)arguments { OFString *const *objects = [arguments objects]; @@ -435,11 +437,11 @@ } #endif - (bool)lowlevelIsAtEndOfStream { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_readPipe[0] == -1) #else if (_readPipe[0] == NULL) #endif return true; @@ -448,26 +450,24 @@ } - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length { -#ifndef _WIN32 +#ifndef OF_WINDOWS ssize_t ret; -#else - DWORD ret; -#endif -#ifndef _WIN32 if (_readPipe[0] == -1 || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; if ((ret = read(_readPipe[0], buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; #else + DWORD ret; + if (length > UINT32_MAX) @throw [OFOutOfRangeException exception]; if (_readPipe[0] == NULL || _atEndOfStream) @throw [OFReadFailedException exceptionWithObject: self @@ -491,11 +491,11 @@ } - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_writePipe[1] == -1 || _atEndOfStream) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; if (length > SSIZE_MAX) @@ -529,29 +529,29 @@ #endif } - (int)fileDescriptorForReading { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _readPipe[0]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (int)fileDescriptorForWriting { -#ifndef _WIN32 +#ifndef OF_WINDOWS return _writePipe[1]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)closeForWriting { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_writePipe[1] != -1) close(_writePipe[1]); _writePipe[1] = -1; #else @@ -562,11 +562,11 @@ #endif } - (void)close { -#ifndef _WIN32 +#ifndef OF_WINDOWS if (_readPipe[0] != -1) close(_readPipe[0]); if (_writePipe[1] != -1) close(_writePipe[1]);