mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Rationalised and cleaned up error reporting, fixing a couple of bugs along the way.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/mswin-ng@23783 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
80e69de2a6
commit
1d9ddad989
32 changed files with 613 additions and 538 deletions
48
ChangeLog
48
ChangeLog
|
@ -1,9 +1,55 @@
|
|||
2006-10-06 Sheldon Gill <sheldon@westnet.net.au>
|
||||
|
||||
* Headers/Foundation/NSError.h
|
||||
* Source/NSError.m
|
||||
Updated to Tiger specifications
|
||||
|
||||
2006-10-03 Sheldon Gill <sheldon@westnet.net.au>
|
||||
|
||||
* Source\GSFileHandle.m
|
||||
* Source\GSFormat.m
|
||||
* Source\GSFTPURLHandle.m
|
||||
* Source\GSHTTPURLHandle.m
|
||||
* Source\GSStream.m
|
||||
* Source\NSData.m
|
||||
* Source\NSDistributedLock.m
|
||||
* Source\NSFileManager.m
|
||||
* Source\NSMessagePort.m
|
||||
* Source\NSPipe.m
|
||||
* Source\NSSocketPort.m
|
||||
* Source\NSTask.m
|
||||
* Source\NSThread.m
|
||||
|
||||
* Source\win32\GSFileHandleWin32.m
|
||||
* Source\win32\GSRunLoopCtxt.m
|
||||
* Source\win32\NSMessagePortNameServerWin32.m
|
||||
* Source\win32\NSMessagePortWin32.m
|
||||
* Source\win32\NSStreamWin32.m
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSObjCRuntime.h
|
||||
* Headers/Additions/GNUstepBase/GSFunctions.h
|
||||
* Additions\GSCompatibility.
|
||||
* Additions\GSObjCRuntime.m
|
||||
* Additions\GSFunctions.m
|
||||
|
||||
Moved GSPrintf() and GSLastErrorStr() to GSFunctions
|
||||
Altered GSLastErrorStr(long) to GSLastError(void)
|
||||
Fixed bug preventing GSLastErrorStr() returning net errors
|
||||
* Headers/Additions/GNUstepBase/Win32_Utilities.h
|
||||
* Source/win32/Win32_Utilities.m:
|
||||
Clean up and rationalise a little
|
||||
|
||||
2006-10-03 Sheldon Gill <sheldon@westnet.net.au>
|
||||
|
||||
* Source/NSLog.m
|
||||
Better output on Win32. Cleaner module.
|
||||
|
||||
2006-09-20 Sheldon Gill <sheldon@westnet.net.au>
|
||||
|
||||
* Headers/Foundation/NSProcessInfo.h
|
||||
* Source/NSProcessInfo.m:
|
||||
Add operatingSystemVersionString
|
||||
Change return of operatingSystem to useful
|
||||
Change return of operatingSystem to be more useful
|
||||
* Headers/Foundation/NSObjCRuntime.h:
|
||||
* Source/NSLog.m:
|
||||
Remove _NSLogDescriptor customisation
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/** Additional functions for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Created: 2005
|
||||
Written by: Sheldon Gill
|
||||
Date: 2005
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
|
@ -38,7 +38,58 @@ extern "C" {
|
|||
@class NSArray;
|
||||
@class NSString;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Returns the system error message for the given error number
|
||||
*/
|
||||
GS_EXPORT NSString *GSErrorString(long errorNumber);
|
||||
|
||||
/**
|
||||
* <p>Returns the error message for the last system error.</p>
|
||||
* On *nix, this is equivalent to strerror(errno).
|
||||
* On MS-Windows this is the message for GetLastError().
|
||||
*/
|
||||
static inline NSString *GSLastError(void)
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
return GSErrorString(GetLastError());
|
||||
#else
|
||||
return GSErrorString(errno);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the error message for the last sockets library
|
||||
* error.</p>
|
||||
* On *nix, this is equivalent to strerror(errno).
|
||||
* On MS-Windows this is the message for WSAGetLastError().
|
||||
*/
|
||||
static inline NSString *GSLastSocketError(void)
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
return GSErrorString(WSAGetLastError());
|
||||
#else
|
||||
return GSErrorString(errno);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prints a message to fptr using the format string provided and any
|
||||
* additional arguments. The format string is interpreted as by
|
||||
* the NSString formatted initialisers, and understands the '%@' syntax
|
||||
* for printing an object.
|
||||
* </p>
|
||||
* <p>The data is written to the file pointer in the default CString
|
||||
* encoding if possible, as a UTF8 string otherwise.
|
||||
* </p>
|
||||
* <p>This function is recommended for printing general log messages.
|
||||
* For debug messages use NSDebugLog() and friends. For error logging
|
||||
* use NSLog(), and for warnings you might consider NSWarnLog().
|
||||
* </p>
|
||||
*/
|
||||
GS_EXPORT BOOL GSPrintf (FILE *fptr, NSString *format, ...);
|
||||
|
||||
/**
|
||||
* Try to locate file/directory (aName).(anExtension) in paths.
|
||||
* Will return the first found or nil if nothing is found.
|
||||
*/
|
||||
|
|
|
@ -673,28 +673,6 @@ GSAutoreleasedBuffer(unsigned size);
|
|||
GS_EXPORT void
|
||||
GSAllocateMutexAt(objc_mutex_t *request);
|
||||
|
||||
/** Returns a system error message on a variety of systems
|
||||
*/
|
||||
GS_EXPORT const char *
|
||||
GSLastErrorStr(long error_id);
|
||||
|
||||
/**
|
||||
* <p>Prints a message to fptr using the format string provided and any
|
||||
* additional arguments. The format string is interpreted as by
|
||||
* the NSString formatted initialisers, and understands the '%@' syntax
|
||||
* for printing an object.
|
||||
* </p>
|
||||
* <p>The data is written to the file pointer in the default CString
|
||||
* encoding if possible, as a UTF8 string otherwise.
|
||||
* </p>
|
||||
* <p>This function is recommended for printing general log messages.
|
||||
* For debug messages use NSDebugLog() and friends. For error logging
|
||||
* use NSLog(), and for warnings you might consider NSWarnLog().
|
||||
* </p>
|
||||
*/
|
||||
GS_EXPORT BOOL
|
||||
GSPrintf (FILE *fptr, NSString *format, ...);
|
||||
|
||||
|
||||
|
||||
#ifndef NO_DEPRECATED
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/** Win32 Utility support functions for GNUStep
|
||||
/** Win32 Utility support functions for GNUStep
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Sheldon Gill <address@hidden>
|
||||
|
@ -37,11 +37,6 @@ extern "C" {
|
|||
#include "Foundation/NSValue.h"
|
||||
#endif
|
||||
|
||||
/* TODO:
|
||||
-Win32NSDataFromRegistry()
|
||||
NOT IMPLEMENTED YET!
|
||||
*/
|
||||
|
||||
/* Useful strings for Registry Keys */
|
||||
extern NSString *curWindowsKey; // "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
|
||||
extern NSString *curWinNTKey; // "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\"
|
||||
|
@ -50,8 +45,10 @@ extern NSString *curWinNTKey; // "SOFTWARE\\Microsoft\\Windows NT\\CurrentVers
|
|||
void Win32_Utilities_init(void);
|
||||
void Win32_Utilities_fini(void);
|
||||
|
||||
/* ---- General ---- */
|
||||
NSString *Win32ErrorString( DWORD ErrorCode );
|
||||
|
||||
/* ---- Environment ---- */
|
||||
NSString *Win32NSStringFromEnvironmentVariable(const WCHAR *envVar);
|
||||
//NSString *Win32OperatingSystemName(void);
|
||||
//unsigned int Win32OperatingSystemVersion(void);
|
||||
|
||||
|
@ -68,8 +65,7 @@ NSString *Win32FullUserName( NSString *userName );
|
|||
NSString *Win32GetUserHomeDirectory(NSString *userName);
|
||||
|
||||
/* ---- Path discovery ---- */
|
||||
NSString *Win32SystemDirectory(void );
|
||||
NSString *Win32TemporaryDirectory(void );
|
||||
NSString *Win32WindowsDirectory(void );
|
||||
|
||||
#endif /* defined(__WIN32__) */
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastSocketError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -277,8 +277,8 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr),
|
||||
NSSwapBigShortToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
|
||||
NSSwapBigShortToHost(sin.sin_port), GSLastSocketError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -286,7 +286,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (listen(net, 5) < 0)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to listen on port - %@", GSLastSocketError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -294,7 +294,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (getsockname(net, (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -323,7 +323,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* Extension functions for GNUstep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
||||
Date: Nov 2002
|
||||
Written by: Sheldon Gill
|
||||
Date: 2005
|
||||
|
||||
|
@ -29,6 +31,77 @@
|
|||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
#include "Foundation/Foundation.h"
|
||||
#include "GNUstepBase/Win32_Utilities.h"
|
||||
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
const char *
|
||||
strerror(int eno)
|
||||
{
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
if (eno < 0 || eno >= sys_nerr)
|
||||
{
|
||||
return("unknown error number");
|
||||
}
|
||||
return(sys_errlist[eno]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Gets the last error from the system libraries...
|
||||
*/
|
||||
NSString *
|
||||
GSErrorString(long error_id)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
return Win32ErrorString(error_id);
|
||||
#else
|
||||
return [NSString stringWithCString: strerror(error_id)
|
||||
encoding: NSUTF8StringEncoding];
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL
|
||||
GSPrintf (FILE *fptr, NSString* format, ...)
|
||||
{
|
||||
static Class stringClass = 0;
|
||||
static NSStringEncoding enc;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
va_list ap;
|
||||
NSString *message;
|
||||
NSData *data;
|
||||
BOOL ok = NO;
|
||||
|
||||
if (stringClass == 0)
|
||||
{
|
||||
stringClass = [NSString class];
|
||||
enc = [stringClass defaultCStringEncoding];
|
||||
}
|
||||
message = [stringClass allocWithZone: NSDefaultMallocZone()];
|
||||
va_start (ap, format);
|
||||
message = [message initWithFormat: format locale: nil arguments: ap];
|
||||
va_end (ap);
|
||||
data = [message dataUsingEncoding: enc];
|
||||
if (data == nil)
|
||||
{
|
||||
data = [message dataUsingEncoding: NSUTF8StringEncoding];
|
||||
}
|
||||
RELEASE(message);
|
||||
|
||||
if (data != nil)
|
||||
{
|
||||
unsigned int length = [data length];
|
||||
|
||||
if (length == 0 || fwrite([data bytes], 1, length, fptr) == length)
|
||||
{
|
||||
ok = YES;
|
||||
}
|
||||
}
|
||||
RELEASE(arp);
|
||||
return ok;
|
||||
}
|
||||
|
||||
NSString *
|
||||
GSFindNamedFile(NSArray *paths, NSString *aName, NSString *anExtension)
|
||||
|
@ -62,4 +135,3 @@ GSFindNamedFile(NSArray *paths, NSString *aName, NSString *anExtension)
|
|||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -2233,96 +2233,4 @@ GSAutoreleasedBuffer(unsigned size)
|
|||
return ((void*)&o[1]) + offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Getting a system error message on a variety of systems.
|
||||
* Currently 8bit string ... perhaps we should move to unicode.
|
||||
*/
|
||||
#ifdef __MINGW32__
|
||||
|
||||
const char *GetErrorMsg(DWORD msgId)
|
||||
{
|
||||
void *lpMsgBuf = 0;
|
||||
|
||||
FormatMessageA(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
msgId,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPSTR)&lpMsgBuf,
|
||||
(DWORD)0,
|
||||
NULL);
|
||||
|
||||
return (const char*)lpMsgBuf;
|
||||
}
|
||||
#else
|
||||
#ifndef HAVE_STRERROR
|
||||
const char *
|
||||
strerror(int eno)
|
||||
{
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
if (eno < 0 || eno >= sys_nerr)
|
||||
{
|
||||
return("unknown error number");
|
||||
}
|
||||
return(sys_errlist[eno]);
|
||||
}
|
||||
#endif
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
const char *
|
||||
GSLastErrorStr(long error_id)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
return GetErrorMsg(GetLastError());
|
||||
#else
|
||||
return strerror(error_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL
|
||||
GSPrintf (FILE *fptr, NSString* format, ...)
|
||||
{
|
||||
static Class stringClass = 0;
|
||||
static NSStringEncoding enc;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
va_list ap;
|
||||
NSString *message;
|
||||
NSData *data;
|
||||
BOOL ok = NO;
|
||||
|
||||
if (stringClass == 0)
|
||||
{
|
||||
stringClass = [NSString class];
|
||||
enc = [stringClass defaultCStringEncoding];
|
||||
}
|
||||
message = [stringClass allocWithZone: NSDefaultMallocZone()];
|
||||
va_start (ap, format);
|
||||
message = [message initWithFormat: format locale: nil arguments: ap];
|
||||
va_end (ap);
|
||||
data = [message dataUsingEncoding: enc];
|
||||
if (data == nil)
|
||||
{
|
||||
data = [message dataUsingEncoding: NSUTF8StringEncoding];
|
||||
}
|
||||
RELEASE(message);
|
||||
|
||||
if (data != nil)
|
||||
{
|
||||
unsigned int length = [data length];
|
||||
|
||||
if (length == 0 || fwrite([data bytes], 1, length, fptr) == length)
|
||||
{
|
||||
ok = YES;
|
||||
}
|
||||
}
|
||||
RELEASE(arp);
|
||||
return ok;
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@
|
|||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
/* libxml headers */
|
||||
#include <libxml/tree.h>
|
||||
|
@ -125,6 +126,7 @@ UTF8StrLen(const unsigned char *bytes, unsigned length)
|
|||
unsigned char *buf = NSZoneMalloc(NSDefaultMallocZone(), length+1);
|
||||
NSString *str;
|
||||
|
||||
// FIXME: Should make the string using the given buffer, NoCopy! -SG
|
||||
memcpy(buf, bytes, length);
|
||||
buf[length] = '\0';
|
||||
str = UTF8Str(buf);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "Foundation/NSFileHandle.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GNUstepBase/GSMime.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
GS_EXPORT NSString * const GSTelnetNotification;
|
||||
GS_EXPORT NSString * const GSTelnetErrorKey;
|
||||
|
@ -972,14 +973,12 @@ static NSLock *urlLock = nil;
|
|||
protocol: @"tcp"];
|
||||
if (sock == nil)
|
||||
{
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
* Tell superclass that the load failed - let it do housekeeping.
|
||||
*/
|
||||
[self backgroundLoadDidFailWithReason: [NSString stringWithFormat:
|
||||
@"Unable to connect to %@:%@ ... %s",
|
||||
host, port, GSLastErrorStr(errno)]];
|
||||
@"Unable to connect to %@:%@ ... %@",
|
||||
host, port, GSLastSocketError()]];
|
||||
return;
|
||||
}
|
||||
cHandle = [[GSTelnetHandle alloc] initWithHandle: sock isConnected: NO];
|
||||
|
|
|
@ -797,7 +797,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -811,8 +811,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == -1)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(lsin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -830,9 +830,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
if (errno != EINPROGRESS)
|
||||
{
|
||||
NSLog(@"unable to make connection to %s:%d - %s",
|
||||
NSLog(@"unable to make connection to %s:%d - %@",
|
||||
inet_ntoa(sin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -896,7 +896,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -913,8 +913,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == -1)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -922,7 +922,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (listen(net, 256) == -1)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to listen on port - %@", GSLastError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -930,7 +930,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (getsockname(net, (struct sockaddr*)&sin, &size) == -1)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -1095,8 +1095,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (fstat(desc, &sbuf) < 0)
|
||||
{
|
||||
NSLog(@"unable to get status of descriptor %d - %s",
|
||||
desc, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get status of descriptor %d - %@",
|
||||
desc, GSLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1317,8 +1317,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (len < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
@ -1342,8 +1342,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (len < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
@ -1368,8 +1368,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (got < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
[d setLength: got];
|
||||
}
|
||||
|
@ -1391,8 +1391,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
else if (got < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
}
|
||||
while (len > 0 && got > 0);
|
||||
|
@ -1437,8 +1437,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (rval < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to write to descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to write to descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1543,8 +1543,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (result < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"failed to move to offset in file - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"failed to move to offset in file - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return (unsigned long long)result;
|
||||
}
|
||||
|
@ -1567,8 +1567,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (result < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"failed to move to offset in file - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"failed to move to offset in file - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return (unsigned long long)result;
|
||||
}
|
||||
|
@ -1591,8 +1591,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (result < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"failed to move to offset in file - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"failed to move to offset in file - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1927,8 +1927,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Accept attempt failed - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
s = [NSString stringWithFormat: @"Accept attempt failed - %@",
|
||||
GSLastError()];
|
||||
[readInfo setObject: s forKey: GSFileHandleNotificationError];
|
||||
}
|
||||
else
|
||||
|
@ -1995,8 +1995,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Read attempt failed - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
s = [NSString stringWithFormat: @"Read attempt failed - %@",
|
||||
GSLastError()];
|
||||
[readInfo setObject: s forKey: GSFileHandleNotificationError];
|
||||
[self postReadNotification];
|
||||
}
|
||||
|
@ -2031,8 +2031,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Connect attempt failed - %s",
|
||||
GSLastErrorStr(result)];
|
||||
s = [NSString stringWithFormat: @"Connect attempt failed - %@",
|
||||
GSErrorString(result)];
|
||||
[info setObject: s forKey: GSFileHandleNotificationError];
|
||||
}
|
||||
else
|
||||
|
@ -2065,7 +2065,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat:
|
||||
@"Write attempt failed - %s", GSLastErrorStr(errno)];
|
||||
@"Write attempt failed - %@", GSLastError()];
|
||||
[info setObject: s forKey: GSFileHandleNotificationError];
|
||||
[self postWriteNotification];
|
||||
}
|
||||
|
@ -2141,8 +2141,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
}
|
||||
if (fcntl(descriptor, F_SETFL, e) < 0)
|
||||
{
|
||||
NSLog(@"unable to set non-blocking mode for %d - %s",
|
||||
descriptor, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set non-blocking mode for %d - %@",
|
||||
descriptor, GSLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2151,8 +2151,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"unable to get non-blocking mode for %d - %s",
|
||||
descriptor, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get non-blocking mode for %d - %@",
|
||||
descriptor, GSLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2170,7 +2170,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2187,7 +2187,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -73,6 +73,8 @@
|
|||
#include "Foundation/NSZone.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GNUstepBase/GSLocale.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSFormat.h"
|
||||
|
||||
#include <string.h> // for strstr()
|
||||
|
@ -1691,7 +1693,7 @@ NSDictionary *locale)
|
|||
LABEL (form_strerror):
|
||||
/* Print description of error ERRNO. */
|
||||
string =
|
||||
(unichar *) GSLastErrorStr(save_errno);
|
||||
(unichar *) GSErrorString(save_errno);
|
||||
is_long = 0; /* This is no wide-char string. */
|
||||
goto LABEL (print_string);
|
||||
LABEL (form_character):
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "NSCallBacks.h"
|
||||
#include "GSURLPrivate.h"
|
||||
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
|
@ -1260,8 +1262,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
* Tell superclass that the load failed - let it do housekeeping.
|
||||
*/
|
||||
[self backgroundLoadDidFailWithReason:
|
||||
[NSString stringWithFormat: @"Unable to connect to %@:%@ ... %s",
|
||||
host, port, GSLastErrorStr(errno)]];
|
||||
[NSString stringWithFormat: @"Unable to connect to %@:%@ ... %@",
|
||||
host, port, GSLastSocketError()]];
|
||||
return;
|
||||
}
|
||||
RETAIN(sock);
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <Foundation/NSHost.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSStream.h"
|
||||
|
||||
NSString * const NSStreamDataWrittenToMemoryStreamKey
|
||||
|
@ -359,12 +361,18 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
NSError *theError;
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
errno = GetLastError();
|
||||
errno = GetLastError(); // FIXME: Make this NSWin32ErrorDomain -SG
|
||||
/*
|
||||
theError = [NSError errorWithDomain: NSMSWindowsErrorDomain
|
||||
code: GetLastError()
|
||||
userInfo: nil];
|
||||
#else
|
||||
*/
|
||||
#endif
|
||||
theError = [NSError errorWithDomain: NSPOSIXErrorDomain
|
||||
code: errno
|
||||
userInfo: nil];
|
||||
NSLog(@"%@ error(%d): - %s", self, errno, GSLastErrorStr(errno));
|
||||
NSLog(@"%@ error(%d): - %@", self, errno, GSLastError());
|
||||
ASSIGN(_lastError, theError);
|
||||
_currentStatus = NSStreamStatusError;
|
||||
}
|
||||
|
|
127
Source/NSData.m
127
Source/NSData.m
|
@ -80,6 +80,7 @@
|
|||
#include "Foundation/NSRange.h"
|
||||
#include "Foundation/NSURL.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* for memset() */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
|
@ -163,8 +164,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
|
||||
if (theFile == 0) /* We failed to open the file. */
|
||||
{
|
||||
NSWarnFLog(@"Open (%@) attempt failed - %s", path,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnFLog(@"Open (%@) attempt failed - %@", path,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -174,8 +175,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
c = fseek(theFile, 0L, SEEK_END);
|
||||
if (c != 0)
|
||||
{
|
||||
NSWarnFLog(@"Seek to end of file (%@) failed - %s", path,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnFLog(@"Seek to end of file (%@) failed - %@", path,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -186,8 +187,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
fileLength = ftell(theFile);
|
||||
if (fileLength == -1)
|
||||
{
|
||||
NSWarnFLog(@"Ftell on %@ failed - %s", path,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnFLog(@"Ftell on %@ failed - %@", path,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -198,8 +199,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
c = fseek(theFile, 0L, SEEK_SET);
|
||||
if (c != 0)
|
||||
{
|
||||
NSWarnFLog(@"Fseek to start of file (%@) failed - %s", path,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnFLog(@"Fseek to start of file (%@) failed - %@", path,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -224,8 +225,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
}
|
||||
if (tmp == 0)
|
||||
{
|
||||
NSLog(@"Malloc failed for file (%@) of length %d - %s", path,
|
||||
fileLength + c, GSLastErrorStr(errno));
|
||||
NSLog(@"Malloc failed for file (%@) of length %d - %@", path,
|
||||
fileLength + c, GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
memcpy(tmp + fileLength, buf, c);
|
||||
|
@ -237,16 +238,16 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
tmp = NSZoneMalloc(zone, fileLength);
|
||||
if (tmp == 0)
|
||||
{
|
||||
NSLog(@"Malloc failed for file (%@) of length %d - %s", path,
|
||||
fileLength, GSLastErrorStr(errno));
|
||||
NSLog(@"Malloc failed for file (%@) of length %d - %@", path,
|
||||
fileLength, GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
||||
c = fread(tmp, 1, fileLength, theFile);
|
||||
if (c != (int)fileLength)
|
||||
{
|
||||
NSWarnFLog(@"read of file (%@) contents failed - %s", path,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnFLog(@"read of file (%@) contents failed - %@", path,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -852,8 +853,8 @@ failure:
|
|||
strcat(thePath, "XXXXXX");
|
||||
if ((desc = mkstemp(thePath)) < 0)
|
||||
{
|
||||
NSWarnMLog(@"mkstemp (%s) failed - %s", thePath,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"mkstemp (%s) failed - %@", thePath,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
mask = umask(0);
|
||||
|
@ -880,9 +881,9 @@ failure:
|
|||
wcscat(wthePath, L"XXXXXX");
|
||||
if (_wmktemp(wthePath) == 0)
|
||||
{
|
||||
NSWarnMLog(@"mktemp (%@) failed - %s",
|
||||
NSWarnMLog(@"mktemp (%@) failed - %@",
|
||||
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
#else
|
||||
|
@ -890,8 +891,8 @@ failure:
|
|||
strcat(thePath, "XXXXXX");
|
||||
if (mktemp(thePath) == 0)
|
||||
{
|
||||
NSWarnMLog(@"mktemp (%s) failed - %s", thePath,
|
||||
GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"mktemp (%s) failed - %@", thePath,
|
||||
GSLastError());
|
||||
goto failure;
|
||||
}
|
||||
#endif
|
||||
|
@ -918,11 +919,11 @@ failure:
|
|||
/* Something went wrong; we weren't
|
||||
* even able to open the file. */
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Open (%@) failed - %s",
|
||||
NSWarnMLog(@"Open (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
#else
|
||||
NSWarnMLog(@"Open (%s) failed - %s", thePath, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"Open (%s) failed - %@", thePath, GSLastError());
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
@ -936,11 +937,11 @@ failure:
|
|||
* some reason. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Fwrite (%@) failed - %s",
|
||||
NSWarnMLog(@"Fwrite (%@) failed - %@",
|
||||
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
#else
|
||||
NSWarnMLog(@"Fwrite (%s) failed - %s", thePath, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"Fwrite (%s) failed - %@", thePath, GSLastError());
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
@ -953,11 +954,11 @@ failure:
|
|||
* so we need to deal with it. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Fclose (%@) failed - %s",
|
||||
NSWarnMLog(@"Fclose (%@) failed - %@",
|
||||
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
#else
|
||||
NSWarnMLog(@"Fclose (%s) failed - %s", thePath, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"Fclose (%s) failed - %@", thePath, GSLastError());
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
@ -1038,14 +1039,14 @@ failure:
|
|||
if (c != 0) /* Many things could go wrong, I guess. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Rename ('%@' to '%@') failed - %s",
|
||||
NSWarnMLog(@"Rename ('%@' to '%@') failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length:wcslen(wthePath)],
|
||||
[NSString stringWithCharacters:
|
||||
wtheRealPath length:wcslen(wtheRealPath)],
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
#else
|
||||
NSWarnMLog(@"Rename ('%s' to '%s') failed - %s",
|
||||
thePath, theRealPath, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"Rename ('%s' to '%s') failed - %@",
|
||||
thePath, theRealPath, GSLastError());
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
@ -2897,14 +2898,14 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
- (id) initWithContentsOfMappedFile: (NSString*)path
|
||||
{
|
||||
int fd;
|
||||
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
const unichar *thePath = (const unichar*)[path filesystemRepresentation];
|
||||
#else
|
||||
const char *thePath = [path fileSystemRepresentation];
|
||||
#endif
|
||||
|
||||
if (thePath == 0)
|
||||
if (thePath == 0)
|
||||
{
|
||||
NSWarnMLog(@"Open (%@) attempt failed - bad path", path);
|
||||
RELEASE(self);
|
||||
|
@ -2918,7 +2919,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
#endif
|
||||
if (fd < 0)
|
||||
{
|
||||
NSWarnMLog(@"unable to open %@ - %s", path, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"unable to open %@ - %@", path, GSLastError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -2926,7 +2927,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
length = lseek(fd, 0, SEEK_END);
|
||||
if (length < 0)
|
||||
{
|
||||
NSWarnMLog(@"unable to seek to eof %@ - %s", path, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"unable to seek to eof %@ - %@", path, GSLastError());
|
||||
close(fd);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -2934,7 +2935,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
/* Position at start of file. */
|
||||
if (lseek(fd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
NSWarnMLog(@"unable to seek to sof %@ - %s", path, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"unable to seek to sof %@ - %@", path, GSLastError());
|
||||
close(fd);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -2942,7 +2943,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (bytes == MAP_FAILED)
|
||||
{
|
||||
NSWarnMLog(@"mapping failed for %s - %s", path, GSLastErrorStr(errno));
|
||||
NSWarnMLog(@"mapping failed for %s - %@", path, GSLastError());
|
||||
close(fd);
|
||||
RELEASE(self);
|
||||
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
|
@ -2970,14 +2971,14 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
|
||||
if (shmctl(shmid, IPC_STAT, &buf) < 0)
|
||||
NSLog(@"[NSDataShared -dealloc] shared memory control failed - %s",
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
else if (buf.shm_nattch == 1)
|
||||
if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */
|
||||
NSLog(@"[NSDataShared -dealloc] shared memory delete failed - %s",
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
if (shmdt(bytes) < 0)
|
||||
NSLog(@"[NSDataShared -dealloc] shared memory detach failed - %s",
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
bytes = 0;
|
||||
length = 0;
|
||||
shmid = -1;
|
||||
|
@ -2993,8 +2994,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_RDONLY);
|
||||
if (shmid == -1) /* Created memory? */
|
||||
{
|
||||
NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %s",
|
||||
bufferSize, GSLastErrorStr(errno));
|
||||
NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %@",
|
||||
bufferSize, GSLastError());
|
||||
RELEASE(self);
|
||||
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithBytes: aBuffer length: bufferSize];
|
||||
|
@ -3003,8 +3004,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
bytes = shmat(shmid, 0, 0);
|
||||
if (bytes == (void*)-1)
|
||||
{
|
||||
NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %s",
|
||||
bufferSize, GSLastErrorStr(errno));
|
||||
NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %@",
|
||||
bufferSize, GSLastError());
|
||||
bytes = 0;
|
||||
RELEASE(self);
|
||||
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
|
@ -3022,7 +3023,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
shmid = anId;
|
||||
if (shmctl(shmid, IPC_STAT, &buf) < 0)
|
||||
{
|
||||
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory control failed - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory control failed - %@", GSLastError());
|
||||
RELEASE(self); /* Unable to access memory. */
|
||||
return nil;
|
||||
}
|
||||
|
@ -3035,8 +3036,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
bytes = shmat(shmid, 0, 0);
|
||||
if (bytes == (void*)-1)
|
||||
{
|
||||
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory attach failed - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory attach failed - %@",
|
||||
GSLastError());
|
||||
bytes = 0;
|
||||
RELEASE(self); /* Unable to attach to memory. */
|
||||
return nil;
|
||||
|
@ -3162,7 +3163,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (bytes == 0)
|
||||
{
|
||||
NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory "
|
||||
@"for %u bytes - %s", size, GSLastErrorStr(errno));
|
||||
@"for %u bytes - %@", size, GSLastError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -3658,20 +3659,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (shmctl(shmid, IPC_STAT, &buf) < 0)
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -dealloc] shared memory "
|
||||
@"control failed - %s", GSLastErrorStr(errno));
|
||||
@"control failed - %@", GSLastError());
|
||||
}
|
||||
else if (buf.shm_nattch == 1)
|
||||
{
|
||||
if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -dealloc] shared memory "
|
||||
@"delete failed - %s", GSLastErrorStr(errno));
|
||||
@"delete failed - %@", GSLastError());
|
||||
}
|
||||
}
|
||||
if (shmdt(bytes) < 0)
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -dealloc] shared memory "
|
||||
@"detach failed - %s", GSLastErrorStr(errno));
|
||||
@"detach failed - %@", GSLastError());
|
||||
}
|
||||
bytes = 0;
|
||||
length = 0;
|
||||
|
@ -3701,7 +3702,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (shmid == -1) /* Created memory? */
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory "
|
||||
@"get failed for %u - %s", bufferSize, GSLastErrorStr(errno));
|
||||
@"get failed for %u - %@", bufferSize, GSLastError());
|
||||
RELEASE(self);
|
||||
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithCapacity: bufferSize];
|
||||
|
@ -3712,7 +3713,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (bytes == (void*)-1)
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory "
|
||||
@"attach failed for %u - %s", bufferSize, GSLastErrorStr(e));
|
||||
@"attach failed for %u - %@", bufferSize, GSLastError());
|
||||
bytes = 0;
|
||||
RELEASE(self);
|
||||
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
|
@ -3732,7 +3733,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (shmctl(shmid, IPC_STAT, &buf) < 0)
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory "
|
||||
@"control failed - %s", GSLastErrorStr(errno));
|
||||
@"control failed - %@", GSLastError());
|
||||
RELEASE(self); /* Unable to access memory. */
|
||||
return nil;
|
||||
}
|
||||
|
@ -3747,7 +3748,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (bytes == (void*)-1)
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory "
|
||||
@"attach failed - %s", GSLastErrorStr(errno));
|
||||
@"attach failed - %@", GSLastError());
|
||||
bytes = 0;
|
||||
RELEASE(self); /* Unable to attach to memory. */
|
||||
return nil;
|
||||
|
@ -3769,8 +3770,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (newid == -1) /* Created memory? */
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"Unable to create shared memory segment (size:%u) - %s.",
|
||||
size, GSLastErrorStr(errno)];
|
||||
format: @"Unable to create shared memory segment (size:%u) - %@.",
|
||||
size, GSLastError()];
|
||||
}
|
||||
tmp = shmat(newid, 0, 0);
|
||||
if ((intptr_t)tmp == -1) /* Attached memory? */
|
||||
|
@ -3786,20 +3787,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (shmctl(shmid, IPC_STAT, &buf) < 0)
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -setCapacity:] shared memory "
|
||||
@"control failed - %s", GSLastErrorStr(errno));
|
||||
@"control failed - %@", GSLastError());
|
||||
}
|
||||
else if (buf.shm_nattch == 1)
|
||||
{
|
||||
if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -setCapacity:] shared memory "
|
||||
@"delete failed - %s", GSLastErrorStr(errno));
|
||||
@"delete failed - %@", GSLastError());
|
||||
}
|
||||
}
|
||||
if (shmdt(bytes) < 0) /* Detach memory. */
|
||||
{
|
||||
NSLog(@"[NSMutableDataShared -setCapacity:] shared memory "
|
||||
@"detach failed - %s", GSLastErrorStr(errno));
|
||||
@"detach failed - %@", GSLastError());
|
||||
}
|
||||
}
|
||||
bytes = tmp;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@ -76,14 +77,12 @@ static NSFileManager *mgr = nil;
|
|||
|
||||
if ([mgr removeFileAtPath: _lockPath handler: nil] == NO)
|
||||
{
|
||||
const char *err = GSLastErrorStr(errno);
|
||||
|
||||
attributes = [mgr fileAttributesAtPath: _lockPath traverseLink: YES];
|
||||
if ([modDate isEqual: [attributes fileModificationDate]] == YES)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Failed to remove lock directory '%@' - %s",
|
||||
_lockPath, err];
|
||||
format: @"Failed to remove lock directory '%@' - %@",
|
||||
_lockPath, GSLastError()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,8 +200,8 @@ static NSFileManager *mgr = nil;
|
|||
attributes: attributesToSet];
|
||||
if (locked == NO)
|
||||
{
|
||||
NSLog(@"Failed to create lock directory '%@' - %s",
|
||||
_lockPath, GSLastErrorStr(errno));
|
||||
NSLog(@"Failed to create lock directory '%@' - %@",
|
||||
_lockPath, GSLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,8 +256,8 @@ static NSFileManager *mgr = nil;
|
|||
if ([mgr removeFileAtPath: _lockPath handler: nil] == NO)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Failed to remove lock directory '%@' - %s",
|
||||
_lockPath, GSLastErrorStr(errno)];
|
||||
format: @"Failed to remove lock directory '%@' - %@",
|
||||
_lockPath, GSLastError()];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#include "Foundation/NSEnumerator.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#include "Foundation/NSBundle.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -199,6 +201,8 @@
|
|||
|
||||
#define _NUL L'\0'
|
||||
|
||||
#define lasterr GetLastError()
|
||||
|
||||
#else
|
||||
|
||||
#define _CHMOD(A,B) chmod(A,B)
|
||||
|
@ -218,6 +222,8 @@
|
|||
|
||||
#define _NUL '\0'
|
||||
|
||||
#define lasterr errno
|
||||
|
||||
#endif
|
||||
|
||||
#define _CCP const _CHAR*
|
||||
|
@ -401,8 +407,8 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
allOk = NO;
|
||||
str = [NSString stringWithFormat:
|
||||
@"Unable to change NSFileOwnerAccountID to '%u' - %s",
|
||||
num, GSLastErrorStr(errno)];
|
||||
@"Unable to change NSFileOwnerAccountID to '%u' - %@",
|
||||
num, GSLastError()];
|
||||
ASSIGN(_lastError, str);
|
||||
}
|
||||
}
|
||||
|
@ -425,8 +431,8 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
allOk = NO;
|
||||
str = [NSString stringWithFormat:
|
||||
@"Unable to change NSFileOwnerAccountName to '%@' - %s",
|
||||
str, GSLastErrorStr(errno)];
|
||||
@"Unable to change NSFileOwnerAccountName to '%@' - %@",
|
||||
str, GSLastError()];
|
||||
ASSIGN(_lastError, str);
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +446,7 @@ static NSStringEncoding defaultEncoding;
|
|||
allOk = NO;
|
||||
str = [NSString stringWithFormat:
|
||||
@"Unable to change NSFileGroupOwnerAccountID to '%u' - %s",
|
||||
num, GSLastErrorStr(errno)];
|
||||
num, GSLastError()];
|
||||
ASSIGN(_lastError, str);
|
||||
}
|
||||
}
|
||||
|
@ -462,11 +468,11 @@ static NSStringEncoding defaultEncoding;
|
|||
allOk = NO;
|
||||
str = [NSString stringWithFormat:
|
||||
@"Unable to change NSFileGroupOwnerAccountName to '%@' - %s",
|
||||
str, GSLastErrorStr(errno)];
|
||||
str, GSLastError()];
|
||||
ASSIGN(_lastError, str);
|
||||
}
|
||||
}
|
||||
#endif /* __MINGW32__ */
|
||||
#endif /* !__MINGW32__ */
|
||||
|
||||
num = [attributes filePosixPermissions];
|
||||
if (num != NSNotFound)
|
||||
|
@ -475,8 +481,8 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
allOk = NO;
|
||||
str = [NSString stringWithFormat:
|
||||
@"Unable to change NSFilePosixPermissions to '%o' - %s",
|
||||
num, GSLastErrorStr(errno)];
|
||||
@"Unable to change NSFilePosixPermissions to '%o' - %@",
|
||||
num, GSLastError()];
|
||||
ASSIGN(_lastError, str);
|
||||
}
|
||||
}
|
||||
|
@ -519,8 +525,8 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
allOk = NO;
|
||||
str = [NSString stringWithFormat:
|
||||
@"Unable to change NSFileModificationDate to '%@' - %s",
|
||||
date, GSLastErrorStr(errno)];
|
||||
@"Unable to change NSFileModificationDate to '%@' - %@",
|
||||
date, GSLastError()];
|
||||
ASSIGN(_lastError, str);
|
||||
}
|
||||
}
|
||||
|
@ -747,8 +753,8 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Could not create '%s' - '%s'",
|
||||
dirpath, GSLastErrorStr(errno)];
|
||||
s = [NSString stringWithFormat: @"Could not create '%s' - '%@'",
|
||||
dirpath, GSLastError()];
|
||||
ASSIGN(_lastError, s);
|
||||
return NO;
|
||||
}
|
||||
|
@ -1278,7 +1284,7 @@ static NSStringEncoding defaultEncoding;
|
|||
#endif
|
||||
{
|
||||
return [self _proceedAccordingToHandler: handler
|
||||
forError: [NSString stringWithCString: GSLastErrorStr (errno)]
|
||||
forError: GSLastError()
|
||||
inPath: path];
|
||||
}
|
||||
else
|
||||
|
@ -1312,7 +1318,7 @@ static NSStringEncoding defaultEncoding;
|
|||
if (_RMDIR([self fileSystemRepresentationWithPath: path]) < 0)
|
||||
{
|
||||
return [self _proceedAccordingToHandler: handler
|
||||
forError: [NSString stringWithCString: GSLastErrorStr (errno)]
|
||||
forError: GSLastError()
|
||||
inPath: path];
|
||||
}
|
||||
else
|
||||
|
@ -2031,8 +2037,8 @@ inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to recurse into directory '%@' - %s", path,
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"Failed to recurse into directory '%@' - %@", path,
|
||||
GSLastError());
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -2198,8 +2204,8 @@ inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to recurse into directory '%@' - %s",
|
||||
_currentFilePath, GSLastErrorStr(errno));
|
||||
NSLog(@"Failed to recurse into directory '%@' - %@",
|
||||
_currentFilePath, GSLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ extern NSThread *GSCurrentThread(); // why isn't this in GSPrivate.h ?? -SG
|
|||
|
||||
// From "Win32Support.h"
|
||||
#define UNISTR(X) \
|
||||
((const unichar*)[(X) cStringUsingEncoding: NSUnicodeStringEncoding])
|
||||
((WCHAR *)[(X) cStringUsingEncoding: NSUnicodeStringEncoding])
|
||||
|
||||
// From private base shared functions
|
||||
void crash(char *description);
|
||||
|
@ -91,20 +91,39 @@ void crash(char *description)
|
|||
*/
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
static void
|
||||
send_event_to_eventlog(WORD eventtype, LPCWSTR msgbuffer)
|
||||
{
|
||||
static HANDLE eventloghandle = 0;
|
||||
/* A mechanism for a more descriptive event source registration -SG */
|
||||
static WCHAR *_source_name = NULL;
|
||||
static HANDLE _eventloghandle = NULL;
|
||||
|
||||
if (!eventloghandle)
|
||||
/**
|
||||
* Windows applications which log to the EventLog should set a source
|
||||
* name appropriate for the local and app.
|
||||
* This must be called early, before any logging takes place
|
||||
*/
|
||||
void SGSetEventSource(WCHAR *aName)
|
||||
{
|
||||
_source_name = aName;
|
||||
if (_eventloghandle)
|
||||
CloseHandle(_eventloghandle);
|
||||
_eventloghandle = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
send_event_to_eventlog(WORD eventtype, NSString *message)
|
||||
{
|
||||
LPCWSTR msgbuffer = UNISTR(message);
|
||||
|
||||
if (!_eventloghandle)
|
||||
{
|
||||
// FIXME: Need a mechanism for a more descriptive registration -SG
|
||||
eventloghandle = RegisterEventSourceW(NULL,
|
||||
UNISTR([[NSProcessInfo processInfo] processName]));
|
||||
if (_source_name == NULL)
|
||||
{
|
||||
_source_name = UNISTR([[NSProcessInfo processInfo] processName]);
|
||||
}
|
||||
_eventloghandle = RegisterEventSourceW(NULL, _source_name);
|
||||
}
|
||||
if (eventloghandle)
|
||||
if (_eventloghandle)
|
||||
{
|
||||
ReportEventW(eventloghandle, // event log handle
|
||||
ReportEventW(_eventloghandle, // event log handle
|
||||
eventtype, // event type
|
||||
0, // category zero
|
||||
0, // event identifier
|
||||
|
@ -125,12 +144,10 @@ static void
|
|||
_GSLog_standard_printf_handler(NSString* message)
|
||||
{
|
||||
static HANDLE hStdErr = NULL;
|
||||
LPCWSTR null_terminated_buf = UNISTR(message);
|
||||
DWORD bytes_out;
|
||||
|
||||
#ifndef RELEASE_VERSION
|
||||
if (IsDebuggerPresent())
|
||||
OutputDebugStringW(null_terminated_buf);
|
||||
OutputDebugStringW(UNISTR(message));
|
||||
#endif
|
||||
|
||||
if (hStdErr == NULL)
|
||||
|
@ -138,15 +155,32 @@ _GSLog_standard_printf_handler(NSString* message)
|
|||
|
||||
if ((GSUserDefaultsFlag(GSLogSyslog) == YES) || (hStdErr == NULL))
|
||||
{
|
||||
send_event_to_eventlog(EVENTLOG_ERROR_TYPE, null_terminated_buf);
|
||||
send_event_to_eventlog(EVENTLOG_ERROR_TYPE, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!WriteFile(hStdErr, null_terminated_buf,
|
||||
wcslen(null_terminated_buf)*2,
|
||||
&bytes_out, NULL))
|
||||
DWORD bytes_out;
|
||||
|
||||
if (GetFileType(hStdErr) == FILE_TYPE_CHAR)
|
||||
{
|
||||
send_event_to_eventlog(EVENTLOG_ERROR_TYPE, null_terminated_buf);
|
||||
unichar *buffer = UNISTR(message);
|
||||
if (!WriteConsoleW(hStdErr, buffer+1,
|
||||
wcslen(buffer+1),
|
||||
&bytes_out, NULL))
|
||||
{
|
||||
send_event_to_eventlog(EVENTLOG_ERROR_TYPE, message);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
char *buffer = (char *)[message UTF8String];
|
||||
if (!WriteFile(hStdErr, buffer,
|
||||
strlen(buffer),
|
||||
&bytes_out, NULL))
|
||||
{
|
||||
send_event_to_eventlog(EVENTLOG_ERROR_TYPE, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,12 +264,8 @@ NSLog(NSString* format, ...)
|
|||
* The function generates a standard log entry by prepending
|
||||
* process ID and date/time information to your message, and
|
||||
* ensuring that a newline is present at the end of the message.
|
||||
* </p>
|
||||
* <p>
|
||||
* In GNUstep, the GSLogThread user default may be set to YES in
|
||||
* order to instruct this function to include the internal ID of
|
||||
* the current thread after the process ID. This can help you
|
||||
* to track the behavior of a multi-threaded program.
|
||||
* If your application is multithreaded, it will also report the
|
||||
* thread ID as well.
|
||||
* </p>
|
||||
* <p>
|
||||
* The resulting message is then passed to a handler function to
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSProcessInfo.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSPortPrivate.h"
|
||||
|
||||
|
@ -302,15 +303,15 @@ static Class runLoopClass;
|
|||
e |= NBLK_OPT;
|
||||
if (fcntl(d, F_SETFL, e) < 0)
|
||||
{
|
||||
NSLog(@"unable to set non-blocking mode on %d - %s",
|
||||
d, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set non-blocking mode on %d - %@",
|
||||
d, GSLastError());
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"unable to get non-blocking mode on %d - %s",
|
||||
d, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get non-blocking mode on %d - %@",
|
||||
d, GSLastError());
|
||||
return nil;
|
||||
}
|
||||
handle = (GSMessageHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||
|
@ -379,9 +380,9 @@ static Class runLoopClass;
|
|||
{
|
||||
if (errno != EINPROGRESS)
|
||||
{
|
||||
NSLog(@"unable to make connection to %s - %s",
|
||||
NSLog(@"unable to make connection to %s - %@",
|
||||
sockAddr.sun_path,
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
M_UNLOCK(myLock);
|
||||
return NO;
|
||||
}
|
||||
|
@ -607,7 +608,7 @@ static Class runLoopClass;
|
|||
else if (errno != EINTR && errno != EAGAIN)
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort",
|
||||
@"read failed - %s on 0x%x", GSLastErrorStr(errno), self);
|
||||
@"read failed - %s on 0x%x", GSLastError(), self);
|
||||
M_UNLOCK(myLock);
|
||||
[self invalidate];
|
||||
return;
|
||||
|
@ -906,7 +907,7 @@ static Class runLoopClass;
|
|||
&& res != 0)
|
||||
{
|
||||
state = GS_H_UNCON;
|
||||
NSLog(@"connect attempt failed - %s", GSLastErrorStr(res));
|
||||
NSLog(@"connect attempt failed - %@", GSErrorString(res));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -922,8 +923,8 @@ static Class runLoopClass;
|
|||
else
|
||||
{
|
||||
state = GS_H_UNCON;
|
||||
NSLog(@"connect write attempt failed - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"connect write attempt failed - %@",
|
||||
GSLastError());
|
||||
}
|
||||
RELEASE(d);
|
||||
}
|
||||
|
@ -957,7 +958,7 @@ static Class runLoopClass;
|
|||
{
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
{
|
||||
NSLog(@"write attempt failed - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"write attempt failed - %@", GSLastError());
|
||||
M_UNLOCK(myLock);
|
||||
[self invalidate];
|
||||
return;
|
||||
|
@ -1249,7 +1250,7 @@ typedef struct {
|
|||
sizeof(sockAddr.sun_path));
|
||||
if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastError());
|
||||
desc = -1;
|
||||
}
|
||||
else if (bind(desc, (struct sockaddr *)&sockAddr,
|
||||
|
@ -1263,23 +1264,23 @@ typedef struct {
|
|||
close(desc);
|
||||
if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@",
|
||||
GSLastError());
|
||||
desc = -1;
|
||||
}
|
||||
else if (bind(desc, (struct sockaddr *)&sockAddr,
|
||||
SUN_LEN(&sockAddr)) < 0)
|
||||
{
|
||||
NSLog(@"unable to bind to %s - %s",
|
||||
sockAddr.sun_path, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to %s - %@",
|
||||
sockAddr.sun_path, GSLastSocketError());
|
||||
(void) close(desc);
|
||||
desc = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"unable to bind to %s - %s",
|
||||
sockAddr.sun_path, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to %s - %@",
|
||||
sockAddr.sun_path, GSLastSocketError());
|
||||
(void) close(desc);
|
||||
desc = -1;
|
||||
}
|
||||
|
@ -1291,13 +1292,13 @@ typedef struct {
|
|||
}
|
||||
else if (listen(desc, 128) < 0)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to listen on port - %@", GSLastSocketError());
|
||||
(void) close(desc);
|
||||
DESTROY(port);
|
||||
}
|
||||
else if (getsockname(desc, (struct sockaddr*)&sockAddr, &i) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
(void) close(desc);
|
||||
DESTROY(port);
|
||||
}
|
||||
|
@ -1492,7 +1493,7 @@ typedef struct {
|
|||
sock = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC);
|
||||
if (sock < 0)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastSocketError());
|
||||
}
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
|
@ -1505,13 +1506,13 @@ typedef struct {
|
|||
sizeof(opt)) < 0)
|
||||
{
|
||||
(void)close(sock);
|
||||
NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set reuse on socket - %@", GSLastSocketError());
|
||||
}
|
||||
#endif
|
||||
else if ((handle = [GSMessageHandle handleWithDescriptor: sock]) == nil)
|
||||
{
|
||||
(void)close(sock);
|
||||
NSLog(@"unable to create GSMessageHandle - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create GSMessageHandle - %@", GSLastSocketError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "Foundation/NSObject.h"
|
||||
#include "Foundation/NSFileHandle.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -77,7 +78,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to create pipe ... %s", GSLastErrorStr(errno));
|
||||
NSLog(@"Failed to create pipe ... %@", GSLastError());
|
||||
DESTROY(self);
|
||||
}
|
||||
#else
|
||||
|
@ -95,6 +96,11 @@
|
|||
writeHandle = [[NSFileHandle alloc] initWithNativeHandle: writeh
|
||||
closeOnDealloc: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to create pipe ... %@", GSLastError());
|
||||
DESTROY(self);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return self;
|
||||
|
|
|
@ -67,6 +67,9 @@
|
|||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_UTSNAME_H
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KVM_ENV
|
||||
#include <kvm.h>
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "Foundation/NSThread.h"
|
||||
#include "Foundation/NSConnection.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSPortPrivate.h"
|
||||
#include "GSPrivate.h"
|
||||
|
@ -54,17 +55,21 @@
|
|||
|
||||
#ifdef __MINGW32__
|
||||
#define close closesocket
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/param.h> /* for MAXHOSTNAMELEN */
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h> /* for inet_ntoa() */
|
||||
#endif /* !__MINGW32__ */
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <string.h> /* for strchr() */
|
||||
#include <ctype.h> /* for strchr() */
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <winsock2.h>
|
||||
#include <wininet.h>
|
||||
|
@ -390,8 +395,8 @@ static Class runLoopClass;
|
|||
dummy = 1;
|
||||
if (ioctlsocket(d, FIONBIO, &dummy) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to set non-blocking mode on %d - %s",
|
||||
d, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set non-blocking mode on %d - %@",
|
||||
d, GSLastSocketError());
|
||||
return nil;
|
||||
}
|
||||
#else /* !__MINGW32__ */
|
||||
|
@ -400,15 +405,15 @@ static Class runLoopClass;
|
|||
e |= NBLK_OPT;
|
||||
if (fcntl(d, F_SETFL, e) < 0)
|
||||
{
|
||||
NSLog(@"unable to set non-blocking mode on %d - %s",
|
||||
d, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set non-blocking mode on %d - %@",
|
||||
d, GSLastSocketError());
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"unable to get non-blocking mode on %d - %s",
|
||||
d, GSLastErrorStr(errno));
|
||||
d, GSLastSocketError());
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
@ -545,9 +550,9 @@ static Class runLoopClass;
|
|||
if (errno != EINPROGRESS)
|
||||
#endif
|
||||
{
|
||||
NSLog(@"unable to make connection to %s:%d - %s",
|
||||
NSLog(@"unable to make connection to %s:%d - %@",
|
||||
inet_ntoa(sockAddr.sin_addr),
|
||||
GSSwapBigI16ToHost(sockAddr.sin_port), GSLastErrorStr(errno));
|
||||
GSSwapBigI16ToHost(sockAddr.sin_port), GSLastSocketError());
|
||||
if (addrNum < [addrs count])
|
||||
{
|
||||
BOOL result;
|
||||
|
@ -817,7 +822,7 @@ static Class runLoopClass;
|
|||
#endif /* !__MINGW32__ */
|
||||
{
|
||||
NSDebugMLLog(@"GSTcpHandle",
|
||||
@"read failed - %s on 0x%x", GSLastErrorStr(errno), self);
|
||||
@"read failed - %@ on 0x%x", GSLastSocketError(), self);
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
|
@ -1108,7 +1113,7 @@ static Class runLoopClass;
|
|||
&& res != 0)
|
||||
{
|
||||
state = GS_H_UNCON;
|
||||
NSLog(@"connect attempt failed - %s", GSLastErrorStr(res));
|
||||
NSLog(@"connect attempt failed - %@", GSErrorString(res));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1127,8 +1132,8 @@ static Class runLoopClass;
|
|||
else
|
||||
{
|
||||
state = GS_H_UNCON;
|
||||
NSLog(@"connect write attempt failed - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"connect write attempt failed - %@",
|
||||
GSLastError());
|
||||
}
|
||||
RELEASE(d);
|
||||
}
|
||||
|
@ -1166,7 +1171,7 @@ static Class runLoopClass;
|
|||
if (errno != EINTR && errno != EAGAIN)
|
||||
#endif /* !__MINGW32__ */
|
||||
{
|
||||
NSLog(@"write attempt failed - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"write attempt failed - %@", GSLastError());
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
|
@ -1635,7 +1640,7 @@ static Class tcpPortClass;
|
|||
else if ((desc = socket(AF_INET, SOCK_STREAM, PF_UNSPEC))
|
||||
== INVALID_SOCKET)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastSocketError());
|
||||
DESTROY(port);
|
||||
}
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
|
@ -1649,29 +1654,29 @@ static Class tcpPortClass;
|
|||
sizeof(reuse)) < 0)
|
||||
{
|
||||
(void) close(desc);
|
||||
NSLog(@"unable to set reuse on socket - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set reuse on socket - %@",
|
||||
GSLastSocketError());
|
||||
DESTROY(port);
|
||||
}
|
||||
#endif
|
||||
else if (bind(desc, (struct sockaddr *)&sockaddr,
|
||||
sizeof(sockaddr)) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %s",
|
||||
inet_ntoa(sockaddr.sin_addr), number, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to port %s:%d - %@",
|
||||
inet_ntoa(sockaddr.sin_addr), number, GSLastSocketError());
|
||||
(void) close(desc);
|
||||
DESTROY(port);
|
||||
}
|
||||
else if (listen(desc, 128) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to listen on port - %@", GSLastSocketError());
|
||||
(void) close(desc);
|
||||
DESTROY(port);
|
||||
}
|
||||
else if (getsockname(desc, (struct sockaddr*)&sockaddr, &i)
|
||||
== SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
(void) close(desc);
|
||||
DESTROY(port);
|
||||
}
|
||||
|
@ -1971,7 +1976,7 @@ static Class tcpPortClass;
|
|||
handle = nil;
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastSocketError());
|
||||
}
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
|
@ -1984,13 +1989,13 @@ static Class tcpPortClass;
|
|||
sizeof(opt)) < 0)
|
||||
{
|
||||
(void)close(sock);
|
||||
NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set reuse on socket - %@", GSLastSocketError());
|
||||
}
|
||||
#endif
|
||||
else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil)
|
||||
{
|
||||
(void)close(sock);
|
||||
NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create GSTcpHandle - %@", GSLastSocketError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1562,8 +1562,8 @@ GSCheckTasks()
|
|||
result = waitpid(_taskId, &_terminationStatus, WNOHANG);
|
||||
if (result < 0)
|
||||
{
|
||||
NSLog(@"waitpid %d, result %d, error %s",
|
||||
_taskId, result, GSLastErrorStr(errno));
|
||||
NSLog(@"waitpid %d, result %d, error %@",
|
||||
_taskId, result, GSLastError());
|
||||
[self _terminatedChild: -1];
|
||||
}
|
||||
else if (result == _taskId || (result > 0 && errno == 0))
|
||||
|
@ -1595,8 +1595,8 @@ GSCheckTasks()
|
|||
#ifdef WAITDEBUG
|
||||
else
|
||||
{
|
||||
NSLog(@"waitpid %d, result %d, error %s",
|
||||
_taskId, result, GSLastErrorStr(errno));
|
||||
NSLog(@"waitpid %d, result %d, error %@",
|
||||
_taskId, result, GSLastError());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
#include "Foundation/NSConnection.h"
|
||||
#include "Foundation/NSInvocation.h"
|
||||
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSRunLoopCtxt.h"
|
||||
|
||||
@interface NSAutoreleasePool (NSThread)
|
||||
|
@ -889,12 +891,12 @@ static NSDate *theFuture;
|
|||
#if defined(__MINGW32__)
|
||||
if (SetEvent(event) == 0)
|
||||
{
|
||||
NSLog(@"Set event failed - %@", GSLastErrorStr(errno));
|
||||
NSLog(@"Set event failed - %@", GSLastError());
|
||||
}
|
||||
#else
|
||||
if (write(outputFd, "0", 1) != 1)
|
||||
{
|
||||
NSLog(@"Write to pipe failed - %@", GSLastErrorStr(errno));
|
||||
NSLog(@"Write to pipe failed - %@", GSLastError());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -918,12 +920,12 @@ static NSDate *theFuture;
|
|||
#if defined(__MINGW32__)
|
||||
if (ResetEvent(event) == 0)
|
||||
{
|
||||
NSLog(@"Reset event failed - %@", GSLastErrorStr(errno));
|
||||
NSLog(@"Reset event failed - %@", GSLastError());
|
||||
}
|
||||
#else
|
||||
if (read(inputFd, &c, 1) != 1)
|
||||
{
|
||||
NSLog(@"Read pipe failed - %@", GSLastErrorStr(errno));
|
||||
NSLog(@"Read pipe failed - %@", GSLastError());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <Foundation/NSXMLParser.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
#include <GNUstepBase/GSFunctions.h>
|
||||
|
||||
NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain";
|
||||
|
||||
|
|
|
@ -408,8 +408,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
/* Some exceptional condition happened. */
|
||||
/* xxx We can do something with exception_fds, instead of
|
||||
aborting here. */
|
||||
NSLog (@"poll() error in -acceptInputForMode:beforeDate: '%s'",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog (@"poll() error in -acceptInputForMode:beforeDate: '%@'",
|
||||
GSLastError());
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
@ -789,8 +789,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
|
|||
/* Some exceptional condition happened. */
|
||||
/* xxx We can do something with exception_fds, instead of
|
||||
aborting here. */
|
||||
NSLog (@"select() error in -acceptInputForMode:beforeDate: '%s'",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog (@"select() error in -acceptInputForMode:beforeDate: '%@'",
|
||||
GSLastError());
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "Foundation/NSProcessInfo.h"
|
||||
#include "Foundation/NSUserDefaults.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "../Tools/gdomap.h"
|
||||
#include "../GSPrivate.h"
|
||||
|
@ -792,7 +793,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastSocketError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -806,8 +807,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(lsin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastSocketError());
|
||||
(void) closesocket(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -825,9 +826,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
||||
{
|
||||
NSLog(@"unable to make connection to %s:%d - %s",
|
||||
NSLog(@"unable to make connection to %s:%d - %@",
|
||||
inet_ntoa(sin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastSocketError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -891,7 +892,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET)
|
||||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create socket - %@", GSLastSocketError());
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -908,8 +909,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
|
||||
GSSwapBigI16ToHost(sin.sin_port), GSLastSocketError());
|
||||
(void) closesocket(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -917,7 +918,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (listen(net, 256) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to listen on port - %@", GSLastSocketError());
|
||||
(void) closesocket(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -925,7 +926,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (getsockname(net, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
(void) closesocket(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -1092,8 +1093,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (_fstat(desc, &sbuf) != 0)
|
||||
{
|
||||
NSLog(@"unable to get status of descriptor %d - %s",
|
||||
desc, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get status of descriptor %d - %@",
|
||||
desc, GSLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1142,7 +1143,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
event = CreateEvent(NULL, NO, NO, NULL);
|
||||
if (event == WSA_INVALID_EVENT)
|
||||
{
|
||||
NSLog(@"Invalid Event - '%d'", WSAGetLastError());
|
||||
NSLog(@"Invalid Event - '%@'", GSLastSocketError());
|
||||
return nil;
|
||||
}
|
||||
WSAEventSelect(_get_osfhandle(descriptor), event, FD_ALL_EVENTS);
|
||||
|
@ -1293,8 +1294,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (len < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
@ -1318,8 +1319,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (len < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
@ -1344,8 +1345,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (got < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
[d setLength: got];
|
||||
}
|
||||
|
@ -1367,8 +1368,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
else if (got < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to read from descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to read from descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
}
|
||||
while (len > 0 && got > 0);
|
||||
|
@ -1414,8 +1415,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (rval < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"unable to write to descriptor - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"unable to write to descriptor - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1520,8 +1521,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (result < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"failed to move to offset in file - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"failed to move to offset in file - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return (unsigned long long)result;
|
||||
}
|
||||
|
@ -1544,8 +1545,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (result < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"failed to move to offset in file - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"failed to move to offset in file - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
return (unsigned long long)result;
|
||||
}
|
||||
|
@ -1568,8 +1569,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (result < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"failed to move to offset in file - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
format: @"failed to move to offset in file - %@",
|
||||
GSLastError()];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1927,8 +1928,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Accept attempt failed - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
s = [NSString stringWithFormat: @"Accept attempt failed - %@",
|
||||
GSLastSocketError()];
|
||||
[readInfo setObject: s forKey: GSFileHandleNotificationError];
|
||||
}
|
||||
else
|
||||
|
@ -1996,8 +1997,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Read attempt failed - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
s = [NSString stringWithFormat: @"Read attempt failed - %@",
|
||||
GSLastSocketError()];
|
||||
[readInfo setObject: s forKey: GSFileHandleNotificationError];
|
||||
[self postReadNotification];
|
||||
}
|
||||
|
@ -2005,8 +2006,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Read attempt failed - %s",
|
||||
GSLastErrorStr(errno)];
|
||||
s = [NSString stringWithFormat: @"Read attempt failed - %@",
|
||||
GSLastError()];
|
||||
[readInfo setObject: s forKey: GSFileHandleNotificationError];
|
||||
[self postReadNotification];
|
||||
}
|
||||
|
@ -2045,8 +2046,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"Connect attempt failed - %s",
|
||||
GSLastErrorStr(result)];
|
||||
s = [NSString stringWithFormat: @"Connect attempt failed - %@",
|
||||
GSErrorString(result)];
|
||||
[info setObject: s forKey: GSFileHandleNotificationError];
|
||||
}
|
||||
else
|
||||
|
@ -2080,7 +2081,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat:
|
||||
@"Write attempt failed - %s", GSLastErrorStr(errno)];
|
||||
@"Write attempt failed - %@", GSLastSocketError()];
|
||||
[info setObject: s forKey: GSFileHandleNotificationError];
|
||||
[self postWriteNotification];
|
||||
}
|
||||
|
@ -2227,8 +2228,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (SetNamedPipeHandleState((HANDLE)_get_osfhandle(descriptor), &mode, NULL, NULL)) {
|
||||
isNonBlocking = flag;
|
||||
} else {
|
||||
NSLog(@"unable to set pipe non-blocking mode - %d",
|
||||
GetLastError());
|
||||
NSLog(@"unable to set pipe non-blocking mode - %@",
|
||||
GSLastError());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2239,8 +2240,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy)
|
||||
== SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to set non-blocking mode - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set non-blocking mode - %@",
|
||||
GSLastError());
|
||||
}
|
||||
else
|
||||
isNonBlocking = flag;
|
||||
|
@ -2251,8 +2252,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy)
|
||||
== SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to set blocking mode - %s",
|
||||
GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set blocking mode - %@",
|
||||
GSLastError());
|
||||
}
|
||||
else
|
||||
isNonBlocking = flag;
|
||||
|
@ -2273,7 +2274,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2290,7 +2291,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2350,4 +2351,3 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
return NO;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <Foundation/NSNotificationQueue.h>
|
||||
#include <Foundation/NSPort.h>
|
||||
#include <Foundation/NSStream.h>
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
extern BOOL GSCheckTasks();
|
||||
|
||||
|
@ -399,7 +400,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
/*
|
||||
* Wait for signalled events or window messages.
|
||||
*/
|
||||
wait_return = MsgWaitForMultipleObjects(num_handles, handleArray,
|
||||
wait_return = MsgWaitForMultipleObjects(num_handles, handleArray,
|
||||
NO, wait_timeout, QS_ALLINPUT);
|
||||
}
|
||||
else if (num_handles > 0)
|
||||
|
@ -408,7 +409,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
* We are not interested in windows messages ... just wait for
|
||||
* signalled events.
|
||||
*/
|
||||
wait_return = WaitForMultipleObjects(num_handles, handleArray,
|
||||
wait_return = WaitForMultipleObjects(num_handles, handleArray,
|
||||
NO, wait_timeout);
|
||||
}
|
||||
else
|
||||
|
@ -425,8 +426,8 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
BOOL found = NO;
|
||||
|
||||
NSDebugMLLog(@"NSRunLoop", @"WaitForMultipleObjects() error in "
|
||||
@"-acceptInputForMode:beforeDate: %s",
|
||||
GSLastErrorStr(GetLastError()));
|
||||
@"-acceptInputForMode:beforeDate: %@",
|
||||
GSLastError());
|
||||
/*
|
||||
* Check each handle in turn until either we find one which has an
|
||||
* event signalled, or we find the one which caused the original
|
||||
|
@ -447,8 +448,8 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
if (found == NO)
|
||||
{
|
||||
NSLog(@"WaitForMultipleObjects() error in "
|
||||
@"-acceptInputForMode:beforeDate: %s",
|
||||
GSLastErrorStr(GetLastError()));
|
||||
@"-acceptInputForMode:beforeDate: %@",
|
||||
GSLastError());
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,14 @@
|
|||
#include "Foundation/NSUserDefaults.h"
|
||||
|
||||
#include "GNUstepBase/GSMime.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSPortPrivate.h"
|
||||
|
||||
#define UNISTR(X) \
|
||||
((const unichar*)[(X) cStringUsingEncoding: NSUnicodeStringEncoding])
|
||||
|
||||
extern int errno;
|
||||
// extern int errno; NOT USED -SG
|
||||
|
||||
static NSRecursiveLock *serverLock = nil;
|
||||
static NSMessagePortNameServer *defaultServer = nil;
|
||||
|
@ -105,7 +106,7 @@ static void clean_up_names(void)
|
|||
security.lpSecurityDescriptor = 0; // Default
|
||||
security.bInheritHandle = TRUE;
|
||||
|
||||
registry = @"Software\\GNUstepNSMessagePort";
|
||||
registry = @"Software\\GNUstepNSMessagePort"; //FIXME: GNUstep\\MessagePorts
|
||||
rc = RegCreateKeyExW(
|
||||
HKEY_CURRENT_USER,
|
||||
UNISTR(registry),
|
||||
|
@ -312,7 +313,7 @@ OutputDebugStringW(L"");
|
|||
else
|
||||
{
|
||||
NSLog(@"Failed to insert HKEY_CURRENT_USER\\%@\\%@ (%x) %s",
|
||||
registry, n, rc, GSLastErrorStr(rc));
|
||||
registry, n, rc, GSLastError());
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSProcessInfo.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "GSPortPrivate.h"
|
||||
|
||||
|
@ -206,8 +207,8 @@ static Class messagePortClass = 0;
|
|||
M_UNLOCK(messagePortLock);
|
||||
if ([p _setupSendPort] == NO)
|
||||
{
|
||||
NSLog(@"unable to access mailslot '%@' - %s",
|
||||
[p name], GSLastErrorStr(errno));
|
||||
NSLog(@"unable to access mailslot '%@' - %@",
|
||||
[p name], GSLastError());
|
||||
DESTROY(p);
|
||||
}
|
||||
return p;
|
||||
|
@ -334,8 +335,8 @@ static Class messagePortClass = 0;
|
|||
|
||||
if (this->rHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
NSLog(@"unable to create mailslot '%@' - %s",
|
||||
this->name, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to create mailslot '%@' - %@",
|
||||
this->name, GSLastError());
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
|
@ -507,7 +508,7 @@ static Class messagePortClass = 0;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"GetOverlappedResult failed ...%s", GSLastErrorStr(errno));
|
||||
NSLog(@"GetOverlappedResult failed ...%s", GSLastError());
|
||||
this->rState = RS_NONE;
|
||||
this->rLength = 0;
|
||||
}
|
||||
|
@ -529,8 +530,8 @@ static Class messagePortClass = 0;
|
|||
0,
|
||||
0) == 0)
|
||||
{
|
||||
NSLog(@"unable to get info from mailslot '%@' - %s",
|
||||
this->name, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to get info from mailslot '%@' - %@",
|
||||
this->name, GSLastError());
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
|
@ -546,16 +547,16 @@ static Class messagePortClass = 0;
|
|||
&this->rSize,
|
||||
NULL) == 0)
|
||||
{
|
||||
NSLog(@"unable to read from mailslot '%@' - %s",
|
||||
this->name, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to read from mailslot '%@' - %@",
|
||||
this->name, GSLastError());
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
if (this->rSize != this->rWant)
|
||||
{
|
||||
NSLog(@"only read %d of %d bytes from mailslot '%@' - %s",
|
||||
NSLog(@"only read %d of %d bytes from mailslot '%@' - %@",
|
||||
this->rSize, this->rWant, this->name,
|
||||
GSLastErrorStr(errno));
|
||||
GSLastError());
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
|
@ -749,8 +750,8 @@ static Class messagePortClass = 0;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"unable to read from mailslot '%@' - %s",
|
||||
this->name, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to read from mailslot '%@' - %@",
|
||||
this->name, GSLastError());
|
||||
[self invalidate];
|
||||
}
|
||||
}
|
||||
|
@ -804,7 +805,7 @@ static Class messagePortClass = 0;
|
|||
&this->wSize,
|
||||
TRUE) == 0)
|
||||
{
|
||||
NSLog(@"GetOverlappedResult failed ...%s", GSLastErrorStr(errno));
|
||||
NSLog(@"GetOverlappedResult failed ...%@", GSLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -856,8 +857,8 @@ again:
|
|||
}
|
||||
else if ((errno = GetLastError()) != ERROR_IO_PENDING)
|
||||
{
|
||||
NSLog(@"unable to write to mailslot '%@' - %s",
|
||||
this->name, GSLastErrorStr(errno));
|
||||
NSLog(@"unable to write to mailslot '%@' - %@",
|
||||
this->name, GSLastError());
|
||||
[self invalidate];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
|
||||
#include "../GSStream.h"
|
||||
|
||||
#define BUFFERSIZE (BUFSIZ*64)
|
||||
|
@ -269,7 +271,7 @@ static void setNonblocking(SOCKET fd)
|
|||
unsigned long dummy = 1;
|
||||
|
||||
if (ioctlsocket(fd, FIONBIO, &dummy) == SOCKET_ERROR)
|
||||
NSLog(@"unable to set non-blocking mode - %s",GSLastErrorStr(errno));
|
||||
NSLog(@"unable to set non-blocking mode - %@",GSLastSocketError());
|
||||
}
|
||||
|
||||
@implementation GSFileInputStream
|
||||
|
@ -1866,8 +1868,8 @@ static void setNonblocking(SOCKET fd)
|
|||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to open named pipe '%@'... %s",
|
||||
path, GSLastErrorStr(GetLastError())];
|
||||
format: @"Unable to open named pipe '%@'... %@",
|
||||
path, GSLastError()];
|
||||
}
|
||||
|
||||
// the type of the stream does not matter, since we are only using the fd
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include <lm.h>
|
||||
|
||||
/* Use this definition to hand an NSString to a Win32 API call */
|
||||
#define UniBuf( nsstr_ptr ) ((WCHAR *)[nsstr_ptr unicharString])
|
||||
#define UniBuf( nsstr_ptr ) ((WCHAR *)[nsstr_ptr cStringUsingEncoding: NSUnicodeStringEncoding])
|
||||
#define UniBufLen( nsstr_ptr ) ([nsstr_ptr length])
|
||||
|
||||
/* ------------------ */
|
||||
|
@ -97,20 +97,26 @@ void Win32_Utilities_fini()
|
|||
return; // Nothing to do yet...
|
||||
}
|
||||
|
||||
/* ------+---------+---------+---------+---------+---------+---------+---------+
|
||||
*** -<General utility functions>-
|
||||
---------+---------+---------+---------+---------+---------+---------+------- */
|
||||
|
||||
/**
|
||||
* Translates a Win32 error into a text equivalent
|
||||
*
|
||||
* Translates a Win32 error code into a text equivalent
|
||||
*/
|
||||
void Win32PrintError( DWORD ErrorCode )
|
||||
NSString *Win32ErrorString( DWORD ErrorCode )
|
||||
{
|
||||
NSString *message;
|
||||
LPVOID lpMsgBuf;
|
||||
|
||||
FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, ErrorCode,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR) &lpMsgBuf, 0, NULL );
|
||||
wprintf(L"WinERROR: %s\n", lpMsgBuf );
|
||||
message = [NSString stringWithCharacters: lpMsgBuf
|
||||
length: wcslen(lpMsgBuf)];
|
||||
LocalFree( lpMsgBuf );
|
||||
return message;
|
||||
}
|
||||
|
||||
/* ------+---------+---------+---------+---------+---------+---------+---------+
|
||||
|
@ -149,8 +155,7 @@ Win32NSStringFromRegistry(HKEY regkey, NSString *regValue)
|
|||
NSCParameterAssert( regkey != NULL );
|
||||
NSCParameterAssert( regValue != nil );
|
||||
|
||||
// if (ERROR_SUCCESS==RegQueryValueExW(regkey, [regValue unicharString], 0,
|
||||
if (ERROR_SUCCESS==RegQueryValueExW(regkey, UniBuf(regValue), 0,
|
||||
if (ERROR_SUCCESS == RegQueryValueExW(regkey, UniBuf(regValue), 0,
|
||||
&type, (LPBYTE)buf, &bufsize))
|
||||
{
|
||||
/* Check type is correct! */
|
||||
|
@ -180,7 +185,7 @@ Win32NSNumberFromRegistry(HKEY regkey, NSString *regValue)
|
|||
NSCParameterAssert( regkey != NULL );
|
||||
NSCParameterAssert( regValue != nil );
|
||||
|
||||
if (ERROR_SUCCESS==RegQueryValueExW(regkey, UniBuf(regValue), 0,
|
||||
if (ERROR_SUCCESS == RegQueryValueExW(regkey, UniBuf(regValue), 0,
|
||||
&type, (LPBYTE)&buf, &bufsize))
|
||||
{
|
||||
/* Check type is correct! */
|
||||
|
@ -198,52 +203,30 @@ Win32NSNumberFromRegistry(HKEY regkey, NSString *regValue)
|
|||
NSData *
|
||||
Win32NSDataFromRegistry(HKEY regkey, NSString *regValue)
|
||||
{
|
||||
DWORD *buf = NULL;
|
||||
DWORD bufsize = 0;
|
||||
DWORD type;
|
||||
|
||||
NSCParameterAssert( regkey != NULL );
|
||||
NSCParameterAssert( regValue != nil );
|
||||
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Not implemented! Can't read binary data from the registry.."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* ------+---------+---------+---------+---------+---------+---------+---------+
|
||||
*** -<Environment functions>-
|
||||
---------+---------+---------+---------+---------+---------+---------+------- */
|
||||
|
||||
/**
|
||||
* Obtains an NSString for the environment variable named envVar.
|
||||
*/
|
||||
NSString *
|
||||
Win32NSStringFromEnvironmentVariable(const WCHAR *envVar)
|
||||
{
|
||||
WCHAR buf[1024], *nb;
|
||||
DWORD n;
|
||||
NSString *s = nil;
|
||||
|
||||
NSCParameterAssert( envVar != NULL );
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
n = GetEnvironmentVariableW(envVar, buf, 1024);
|
||||
if (n > 1024)
|
||||
if (ERROR_SUCCESS == RegQueryValueExW(regkey, UniBuf(regValue), 0,
|
||||
&type, NULL, &bufsize))
|
||||
{
|
||||
/* Buffer not big enough, so dynamically allocate it */
|
||||
nb = (WCHAR *)NSZoneMalloc(NSDefaultMallocZone(), sizeof(WCHAR)*(n+1));
|
||||
if (nb != NULL)
|
||||
if (type != REG_BINARY)
|
||||
return nil;
|
||||
|
||||
buf = objc_malloc(bufsize);
|
||||
if (ERROR_SUCCESS == RegQueryValueExW(regkey, UniBuf(regValue),
|
||||
0, &type, (LPBYTE)buf, &bufsize))
|
||||
{
|
||||
n = GetEnvironmentVariableW(envVar, nb, n+1);
|
||||
nb[n] = '\0';
|
||||
s = [NSString stringWithCharacters: nb length: n];
|
||||
NSZoneFree(NSDefaultMallocZone(), nb);
|
||||
return [NSData dataWithBytesNoCopy: buf
|
||||
length: bufsize
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
objc_free(buf);
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
/* null terminate it and return the string */
|
||||
buf[n] = '\0';
|
||||
s = [NSString stringWithCharacters: buf length: n];
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
return s;
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* ------+---------+---------+---------+---------+---------+---------+---------+
|
||||
|
@ -261,18 +244,21 @@ Win32GetUserHomeDirectory(NSString *loginName)
|
|||
if ([loginName isEqual: NSUserName()] == YES)
|
||||
{
|
||||
/*
|
||||
* The environment variable HOMEPATH holds the home directory
|
||||
* The environment variables are easiest
|
||||
* for the user on Windows NT;
|
||||
*/
|
||||
s = Win32NSStringFromEnvironmentVariable(L"USERPROFILE");
|
||||
s = [[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: @"USERPROFILE"];
|
||||
if (s == nil)
|
||||
{
|
||||
s = Win32NSStringFromEnvironmentVariable(L"HOMEPATH");
|
||||
s = [[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: @"HOMEPATH"];
|
||||
}
|
||||
if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':'))
|
||||
{
|
||||
s = [Win32NSStringFromEnvironmentVariable(L"HOMEDRIVE")
|
||||
stringByAppendingString: s];
|
||||
s = [[[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: @"HOMEPATH"]
|
||||
stringByAppendingString: s];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +316,7 @@ Win32UserName(void)
|
|||
{
|
||||
return [NSString stringWithCharacters: buf length: (n-1)];
|
||||
}
|
||||
return Win32NSStringFromEnvironmentVariable(L"LOGNAME");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,7 +331,7 @@ Win32FullUserName( NSString *userName )
|
|||
|
||||
if (NetUserGetInfo( NULL, UniBuf(userName), 2, (LPBYTE*)&user_info))
|
||||
{
|
||||
/* FIXME: Issue warning */
|
||||
NSLog(@"Couldn't get user information for %@",userName);
|
||||
return nil;
|
||||
}
|
||||
return [NSString stringWithCharacters: user_info->usri2_full_name
|
||||
|
@ -357,35 +343,16 @@ Win32FullUserName( NSString *userName )
|
|||
---------+---------+---------+---------+---------+---------+---------+------- */
|
||||
|
||||
/**
|
||||
* Returns the Windows system directory. eg C:\WinNT\System32
|
||||
* Returns the Windows directory. eg C:\WinNT
|
||||
*/
|
||||
NSString *
|
||||
Win32SystemDirectory( void )
|
||||
Win32WindowsDirectory( void )
|
||||
{
|
||||
WCHAR buf[MAX_PATH+1];
|
||||
DWORD bufsize = MAX_PATH+1;
|
||||
DWORD len;
|
||||
|
||||
len = GetSystemDirectoryW(buf,bufsize);
|
||||
if ((len == 0)||(len > MAX_PATH))
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [NSString stringWithCharacters: buf length: len];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the temporary directory on windows. This is the per-user
|
||||
* temporary directory on OS versions which support it.
|
||||
*/
|
||||
NSString *
|
||||
Win32TemporaryDirectory( void )
|
||||
{
|
||||
WCHAR buf[MAX_PATH+1];
|
||||
DWORD bufsize = MAX_PATH+1;
|
||||
DWORD len;
|
||||
|
||||
len = GetTempPathW(bufsize,buf);
|
||||
len = GetWindowsDirectoryW(buf,bufsize);
|
||||
if ((len == 0)||(len > MAX_PATH))
|
||||
{
|
||||
return nil;
|
||||
|
|
39
configure.ac
39
configure.ac
|
@ -731,7 +731,7 @@ AC_TYPE_SIZE_T
|
|||
AC_C_INLINE
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Following header checks needed for bzero in Storage.m and other places
|
||||
# Following header checks needed string.h for many places
|
||||
#--------------------------------------------------------------------
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(string.h memory.h)
|
||||
|
@ -764,10 +764,10 @@ LIBS="$saved_LIBS"
|
|||
#--------------------------------------------------------------------
|
||||
# These two headers (functions) needed by Time.m
|
||||
#--------------------------------------------------------------------
|
||||
dnl AC_REPLACE_FUNCS(getrusage gettimeofday)
|
||||
dnl AC_REPLACE_FUNCS(gettimeofday)
|
||||
|
||||
AC_CHECK_HEADERS(time.h sys/time.h tzfile.h sys/rusage.h ucbinclude/sys/resource.h)
|
||||
AC_CHECK_FUNCS(time ctime tzset)
|
||||
AC_CHECK_HEADERS(time.h sys/time.h tzfile.h ucbinclude/sys/resource.h)
|
||||
AC_CHECK_FUNCS(tzset)
|
||||
|
||||
# Check if tzfile contains the proper definitions
|
||||
if test $ac_cv_header_tzfile_h = yes; then
|
||||
|
@ -824,27 +824,6 @@ if test $ac_cv_header_pthread_h = yes ; then
|
|||
fi
|
||||
AC_SUBST(HAVE_PTHREAD_H)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This function needed by StdioStream.m
|
||||
#--------------------------------------------------------------------
|
||||
AC_CHECK_FUNCS(vsprintf vasprintf)
|
||||
if test $ac_cv_func_vsprintf = yes ; then
|
||||
AC_TRY_RUN([#include "$srcdir/config/config.vsprintf.c"],
|
||||
VSPRINTF_RETURNS_LENGTH=1,
|
||||
VSPRINTF_RETURNS_LENGTH=0,
|
||||
VSPRINTF_RETURNS_LENGTH=1)
|
||||
AC_DEFINE_UNQUOTED(VSPRINTF_RETURNS_LENGTH, $VSPRINTF_RETURNS_LENGTH,
|
||||
[Define if vsprintf returns the length printed])
|
||||
fi
|
||||
if test $ac_cv_func_vasprintf = yes ; then
|
||||
AC_TRY_RUN([#include "$srcdir/config/config.vasprintf.c"],
|
||||
VASPRINTF_RETURNS_LENGTH=1,
|
||||
VASPRINTF_RETURNS_LENGTH=0,
|
||||
VASPRINTF_RETURNS_LENGTH=1)
|
||||
AC_DEFINE_UNQUOTED(VASPRINTF_RETURNS_LENGTH, $VASPRINTF_RETURNS_LENGTH,
|
||||
[Define if vasprintf returns the length printed])
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This function needed by NSFileManager.m
|
||||
#--------------------------------------------------------------------
|
||||
|
@ -967,7 +946,7 @@ AC_SUBST(HAVE_INET_PTON)
|
|||
AC_CHECK_FUNCS(nanosleep usleep)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This function needed by NSDebug.m and NSProcessInfo.m
|
||||
# This function needed by GSFormat.m and GSFunctions.m
|
||||
#--------------------------------------------------------------------
|
||||
AC_CHECK_FUNCS(strerror)
|
||||
|
||||
|
@ -1083,9 +1062,15 @@ else
|
|||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check for uname() for NSProcessInfo.m
|
||||
#--------------------------------------------------------------------
|
||||
AC_CHECK_HEADERS(sys/utsname.h)
|
||||
AC_CHECK_FUNCS(uname)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Defines HAVE_PROCFS if the kernel supports the /proc filesystem.
|
||||
# Needed by NSProcessInfo.m
|
||||
# Used by NSProcessInfo.m when available (eg GNU/Linux)
|
||||
#--------------------------------------------------------------------
|
||||
AC_CHECK_HEADERS(procfs.h)
|
||||
AC_SYS_PROCFS
|
||||
|
|
Loading…
Reference in a new issue