mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 17:51:01 +00:00
Porting changes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12770 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fd78def904
commit
fecc8c6843
8 changed files with 367 additions and 354 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2002-02-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSTcpPort.m: Fixes to work on mingw.
|
||||||
|
* Source/NSHost.m: Update for current winsock on mingw.
|
||||||
|
* Source/NSPortNameServer.m: Update for current winsock on mingw.
|
||||||
|
* Source/WindowsFileHandle.m: Fix to work for basic socket I/O.
|
||||||
|
* Tools/gdomap.c: many changes ... several fixes to work on mingw
|
||||||
|
rewrite some clumsy inefficient code, make variables and functions
|
||||||
|
local. etc.
|
||||||
|
|
||||||
Mon Feb 25 15:26:38 2002 Nicola Pero <nicola@brainstorm.co.uk>
|
Mon Feb 25 15:26:38 2002 Nicola Pero <nicola@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSBundle.m ([-initWithPath:]): Return nil if the path
|
* Source/NSBundle.m ([-initWithPath:]): Return nil if the path
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
#include <ctype.h> /* for strchr() */
|
#include <ctype.h> /* for strchr() */
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef __MINGW__
|
#ifdef __MINGW__
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#include <wininet.h>
|
#include <wininet.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include <Foundation/NSByteOrder.h>
|
#include <Foundation/NSByteOrder.h>
|
||||||
|
|
||||||
#if defined(__MINGW__)
|
#if defined(__MINGW__)
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
|
|
||||||
#if defined(__MINGW__)
|
#if defined(__MINGW__)
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#if HAVE_UNISTD_H
|
#if HAVE_UNISTD_H
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include <Foundation/NSPortNameServer.h>
|
#include <Foundation/NSPortNameServer.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
#ifdef __MINGW__
|
#ifdef __MINGW__
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#include <wininet.h>
|
#include <wininet.h>
|
||||||
#else
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include <Foundation/NSByteOrder.h>
|
#include <Foundation/NSByteOrder.h>
|
||||||
|
|
||||||
#if defined(__MINGW__)
|
#if defined(__MINGW__)
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <Foundation/NSHost.h>
|
#include <Foundation/NSHost.h>
|
||||||
#include <Foundation/NSByteOrder.h>
|
#include <Foundation/NSByteOrder.h>
|
||||||
|
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
@ -202,6 +202,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
self = [self initWithFileDescriptor: net closeOnDealloc: YES];
|
self = [self initWithFileDescriptor: net closeOnDealloc: YES];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
|
[self setNonBlocking: NO];
|
||||||
if (connect(net, (struct sockaddr*)&sin, sizeof(sin)) < 0)
|
if (connect(net, (struct sockaddr*)&sin, sizeof(sin)) < 0)
|
||||||
{
|
{
|
||||||
NSLog(@"unable to make connection to %s:%d - %s",
|
NSLog(@"unable to make connection to %s:%d - %s",
|
||||||
|
@ -256,7 +257,8 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
|
|
||||||
[self setNonBlocking: YES];
|
[self setNonBlocking: YES];
|
||||||
if (connect(net, (struct sockaddr*)&sin, sizeof(sin)) < 0)
|
if (connect(net, (struct sockaddr*)&sin, sizeof(sin)) < 0)
|
||||||
if (WSAGetLastError() == WSAEINPROGRESS)
|
{
|
||||||
|
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
||||||
{
|
{
|
||||||
NSLog(@"unable to make connection to %s:%d - %s",
|
NSLog(@"unable to make connection to %s:%d - %s",
|
||||||
inet_ntoa(sin.sin_addr),
|
inet_ntoa(sin.sin_addr),
|
||||||
|
@ -264,6 +266,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
[self release];
|
[self release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
info = [[NSMutableDictionary dictionaryWithCapacity: 4] retain];
|
info = [[NSMutableDictionary dictionaryWithCapacity: 4] retain];
|
||||||
[info setObject: address forKey: NSFileHandleNotificationDataItem];
|
[info setObject: address forKey: NSFileHandleNotificationDataItem];
|
||||||
|
@ -465,11 +468,14 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
|
||||||
|
// FIXME
|
||||||
if (fstat(desc, &sbuf) < 0)
|
if (fstat(desc, &sbuf) < 0)
|
||||||
{
|
{
|
||||||
NSLog(@"unable to get status of descriptor - %s", GSLastErrorStr(errno));
|
NSLog(@"unable to get status of descriptor - %s",
|
||||||
|
GSLastErrorStr(errno));
|
||||||
[self release];
|
[self release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -477,18 +483,18 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
isStandardFile = YES;
|
isStandardFile = YES;
|
||||||
else
|
else
|
||||||
isStandardFile = NO;
|
isStandardFile = NO;
|
||||||
|
#else
|
||||||
dummy = 1;
|
isStandardFile = NO;
|
||||||
#if 0
|
|
||||||
if (ioctlsocket(desc, FIONBIO, &dummy) >= 0)
|
|
||||||
{
|
|
||||||
if (e & NBLK_OPT)
|
|
||||||
wasNonBlocking = YES;
|
|
||||||
else
|
|
||||||
wasNonBlocking = NO;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
dummy = 0;
|
||||||
|
if (ioctlsocket(desc, FIONBIO, &dummy) < 0)
|
||||||
|
{
|
||||||
|
NSLog(@"unable to get blocking mode - %s", GSLastErrorStr(errno));
|
||||||
|
wasNonBlocking = (dummy == 0) ? NO : YES;
|
||||||
|
ioctlsocket(desc, FIONBIO, &dummy); // Reset
|
||||||
|
}
|
||||||
|
|
||||||
isNonBlocking = wasNonBlocking;
|
isNonBlocking = wasNonBlocking;
|
||||||
descriptor = desc;
|
descriptor = desc;
|
||||||
closeOnDealloc = flag;
|
closeOnDealloc = flag;
|
||||||
|
@ -638,7 +644,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((len = read(descriptor, buf, sizeof(buf))) > 0)
|
if ((len = recv(descriptor, buf, sizeof(buf), 0)) > 0)
|
||||||
{
|
{
|
||||||
[d appendBytes: buf length: len];
|
[d appendBytes: buf length: len];
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1220,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
item = [readInfo objectForKey: NSFileHandleNotificationDataItem];
|
item = [readInfo objectForKey: NSFileHandleNotificationDataItem];
|
||||||
length = [item length];
|
length = [item length];
|
||||||
|
|
||||||
received = read(descriptor, buf, sizeof(buf));
|
received = recv(descriptor, buf, sizeof(buf), 0);
|
||||||
if (received == 0)
|
if (received == 0)
|
||||||
{ // Read up to end of file.
|
{ // Read up to end of file.
|
||||||
[self postReadNotification];
|
[self postReadNotification];
|
||||||
|
@ -1261,7 +1267,16 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
{
|
{
|
||||||
int written;
|
int written;
|
||||||
|
|
||||||
written = write(descriptor, (char*)ptr+writePos, length-writePos);
|
if (isStandardFile)
|
||||||
|
{
|
||||||
|
written = write(descriptor, (char*)ptr+writePos,
|
||||||
|
length-writePos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
written = send(descriptor, (char*)ptr+writePos,
|
||||||
|
length-writePos, 0);
|
||||||
|
}
|
||||||
if (written <= 0)
|
if (written <= 0)
|
||||||
{
|
{
|
||||||
if (written < 0 && errno != EAGAIN && errno != EINTR)
|
if (written < 0 && errno != EAGAIN && errno != EINTR)
|
||||||
|
@ -1336,17 +1351,22 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
if (isStandardFile)
|
if (isStandardFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isNonBlocking == flag)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dummy = 1;
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
|
dummy = 1;
|
||||||
if (ioctlsocket(descriptor, FIONBIO, &dummy) < 0)
|
if (ioctlsocket(descriptor, FIONBIO, &dummy) < 0)
|
||||||
{
|
{
|
||||||
NSLog(@"unable to set non-blocking mode - %s", GSLastErrorStr(errno));
|
NSLog(@"unable to set non-blocking mode - %s", GSLastErrorStr(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dummy = 0;
|
||||||
|
if (ioctlsocket(descriptor, FIONBIO, &dummy) < 0)
|
||||||
|
{
|
||||||
|
NSLog(@"unable to set blocking mode - %s", GSLastErrorStr(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) socketAddress
|
- (NSString*) socketAddress
|
||||||
|
|
569
Tools/gdomap.c
569
Tools/gdomap.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue