diff --git a/Headers/Additions/GNUstepBase/Additions.h b/Headers/Additions/GNUstepBase/Additions.h index 5d5700e77..8a237bdc9 100644 --- a/Headers/Additions/GNUstepBase/Additions.h +++ b/Headers/Additions/GNUstepBase/Additions.h @@ -50,6 +50,7 @@ #import #import #import +#import #import #import #import diff --git a/Headers/Additions/GNUstepBase/NSStream+GNUstepBase.h b/Headers/Additions/GNUstepBase/NSStream+GNUstepBase.h new file mode 100644 index 000000000..ac78b617e --- /dev/null +++ b/Headers/Additions/GNUstepBase/NSStream+GNUstepBase.h @@ -0,0 +1,121 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSStream_GNUstepBase_h +#define INCLUDED_NSStream_GNUstepBase_h + +#import +#import + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +/** + * The additionalinterface defined for GNUstep.
+ * Currently NOT implemented when using the Apple Foundation!
+ * Please contribute an Apple implementation. + */ +@interface NSStream (GNUstepBase) + +/** + * Creates and returns by reference an NSInputStream object and + * NSOutputStream object for a local socket or named pipe connection + * with the specified path. To use them you need to open them and wait + * on the NSStreamEventOpenCompleted event on one of them. + */ ++ (void) getLocalStreamsToPath: (NSString *)path + inputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream; +/** + * Creates and returns by reference an NSInputStream object and NSOutputStream + * object for a anonymous local socket or pipe. Although you still need to + * open them, the open will be instantaneous, and no NSStreamEventOpenCompleted + * event will be delivered. + */ ++ (void) pipeWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream; +@end + +/** + * GSServerStream is a subclass of NSStream that encapsulate a "server" + * stream; * that is a stream that binds to a socket and accepts incoming + * connections.
+ * Currently NOT implemented when using the Apple Foundation!
+ * Please contribute an Apple implementation. + */ +@interface GSServerStream : NSStream + +/** + * Createe a ip (ipv6) server stream + */ ++ (id) serverStreamToAddr: (NSString*)addr port: (NSInteger)port; + +/** + * Create a local (unix domain or named pipe) server stream + */ ++ (id) serverStreamToAddr: (NSString*)addr; + +/** + * This is the method that accepts a connection and generates two streams + * as the server side inputStream and OutputStream. + * Although you still need to open them, the open will be + * instantanious, and no NSStreamEventOpenCompleted event will be delivered. + */ +- (void) acceptWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream; + +/** + * the designated initializer for a ip (ipv6) server stream + */ +- (id) initToAddr: (NSString*)addr port: (NSInteger)port; + +/** + * the designated initializer for a local (unix domain or named pipe) + * server stream + */ +- (id) initToAddr: (NSString*)addr; + +@end + +/** May be used to read the local IP address of a tcp/ip network stream. */ +GS_EXPORT NSString * const GSStreamLocalAddressKey; +/** May be used to read the local port of a tcp/ip network stream. */ +GS_EXPORT NSString * const GSStreamLocalPortKey; +/** May be used to read the remote IP address of a tcp/ip network stream. */ +GS_EXPORT NSString * const GSStreamRemoteAddressKey; +/** May be used to read the remote port of a tcp/ip network stream. */ +GS_EXPORT NSString * const GSStreamRemotePortKey; + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSStream_GNUstepBase_h */ + diff --git a/Headers/Foundation/NSStream.h b/Headers/Foundation/NSStream.h index 8ad6e4564..0b49413c4 100644 --- a/Headers/Foundation/NSStream.h +++ b/Headers/Foundation/NSStream.h @@ -249,67 +249,6 @@ typedef NSUInteger NSStreamEvent; @end -/** - * the additional interface defined for gnustep - */ -@interface NSStream (GNUstepExtensions) - -/** - * Creates and returns by reference an NSInputStream object and - * NSOutputStream object for a local socket or named pipe connection - * with the specified path. To use them you need to open them and wait - * on the NSStreamEventOpenCompleted event on one of them. - */ -+ (void) getLocalStreamsToPath: (NSString *)path - inputStream: (NSInputStream **)inputStream - outputStream: (NSOutputStream **)outputStream; -/** - * Creates and returns by reference an NSInputStream object and NSOutputStream - * object for a anonymous local socket or pipe. Although you still need to - * open them, the open will be instantaneous, and no NSStreamEventOpenCompleted - * event will be delivered. - */ -+ (void) pipeWithInputStream: (NSInputStream **)inputStream - outputStream: (NSOutputStream **)outputStream; -@end - -/** - * GSServerStream is a subclass of NSStream that encapsulate a "server" stream; - * that is a stream that binds to a socket and accepts incoming connections - */ -@interface GSServerStream : NSStream - -/** - * Createe a ip (ipv6) server stream - */ -+ (id) serverStreamToAddr: (NSString*)addr port: (NSInteger)port; - -/** - * Create a local (unix domain or named pipe) server stream - */ -+ (id) serverStreamToAddr: (NSString*)addr; - -/** - * This is the method that accepts a connection and generates two streams - * as the server side inputStream and OutputStream. - * Although you still need to open them, the open will be - * instantanious, and no NSStreamEventOpenCompleted event will be delivered. - */ -- (void) acceptWithInputStream: (NSInputStream **)inputStream - outputStream: (NSOutputStream **)outputStream; - -/** - * the designated initializer for a ip (ipv6) server stream - */ -- (id) initToAddr: (NSString*)addr port: (NSInteger)port; - -/** - * the designated initializer for a local (unix domain or named pipe) - * server stream - */ -- (id) initToAddr: (NSString*)addr; - -@end GS_EXPORT NSString * const NSStreamDataWrittenToMemoryStreamKey; GS_EXPORT NSString * const NSStreamFileCurrentOffsetKey; @@ -331,15 +270,6 @@ GS_EXPORT NSString * const NSStreamSOCKSProxyVersion4; GS_EXPORT NSString * const NSStreamSOCKSProxyVersion5; GS_EXPORT NSString * const NSStreamSOCKSProxyVersionKey; -/** May be used to read the local IP address of a tcp/ip network stream. */ -GS_EXPORT NSString * const GSStreamLocalAddressKey; -/** May be used to read the local port of a tcp/ip network stream. */ -GS_EXPORT NSString * const GSStreamLocalPortKey; -/** May be used to read the remote IP address of a tcp/ip network stream. */ -GS_EXPORT NSString * const GSStreamRemoteAddressKey; -/** May be used to read the remote port of a tcp/ip network stream. */ -GS_EXPORT NSString * const GSStreamRemotePortKey; - /** * Informal protocol for delegates of instance of the [NSStream] class. */ @@ -351,6 +281,10 @@ GS_EXPORT NSString * const GSStreamRemotePortKey; } #endif +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import +#endif + #endif /* 100200 */ #endif /* __NSStream_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Source/Additions/GNUmakefile b/Source/Additions/GNUmakefile index af5a8d257..27bf814b7 100644 --- a/Source/Additions/GNUmakefile +++ b/Source/Additions/GNUmakefile @@ -54,6 +54,7 @@ Additions_OBJC_FILES =\ NSNumber+GNUstepBase.m \ NSObject+GNUstepBase.m \ NSProcessInfo+GNUstepBase.m \ + NSStream+GNUstepBase.m \ NSString+GNUstepBase.m \ NSTask+GNUstepBase.m \ NSThread+GNUstepBase.m \ diff --git a/Source/Additions/NSStream+GNUstepBase.m b/Source/Additions/NSStream+GNUstepBase.m new file mode 100644 index 000000000..a225a94c2 --- /dev/null +++ b/Source/Additions/NSStream+GNUstepBase.m @@ -0,0 +1,95 @@ +/* Implementation of extension methods to base additions + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#import "common.h" +#import "GNUstepBase/NSStream+GNUstepBase.h" + +/* Code used in GNUstepBase + */ +NSString * const GSStreamLocalAddressKey + = @"GSStreamLocalAddressKey"; +NSString * const GSStreamLocalPortKey + = @"GSStreamLocalPortKey"; +NSString * const GSStreamRemoteAddressKey + = @"GSStreamRemoteAddressKey"; +NSString * const GSStreamRemotePortKey + = @"GSStreamRemotePortKey"; + + +/* The remaining code is specific to the Apple Foundation + */ +#if !defined(GNUSTEP) +@implementation NSStream (GNUstepBase) + ++ (void) getLocalStreamsToPath: (NSString *)path + inputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + [self notImplemented: _cmd]; +} + ++ (void) pipeWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + [self notImplemented: _cmd]; +} +@end + +@implememntation GSServerStream + ++ (id) allocWithZone: (NSZone*)z +{ + return [self notImplemented: _cmd]; +} + ++ (id) serverStreamToAddr: (NSString*)addr port: (NSInteger)port +{ + return [self notImplemented: _cmd]; +} + ++ (id) serverStreamToAddr: (NSString*)addr +{ + return [self notImplemented: _cmd]; +} + +- (void) acceptWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + return [self notImplemented: _cmd]; +} + +- (id) initToAddr: (NSString*)addr port: (NSInteger)port +{ + return [self notImplemented: _cmd]; +} + +- (id) initToAddr: (NSString*)addr +{ + return [self notImplemented: _cmd]; +} + +@end +#endif + diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 5a72260d8..32c6770ac 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -131,6 +131,7 @@ NSMutableString+GNUstepBase.h \ NSNumber+GNUstepBase.h \ NSObject+GNUstepBase.h \ NSProcessInfo+GNUstepBase.h \ +NSStream+GNUstepBase.h \ NSString+GNUstepBase.h \ NSTask+GNUstepBase.h \ NSThread+GNUstepBase.h \ diff --git a/Source/GSSocketStream.h b/Source/GSSocketStream.h index 0ac105f08..5572f5e40 100644 --- a/Source/GSSocketStream.h +++ b/Source/GSSocketStream.h @@ -98,7 +98,7 @@ SOCKIVARS - (void) _setSock: (SOCKET)sock; /* - * Set the socket addres from string information. + * Set the socket address from string information. */ - (BOOL) _setSocketAddress: (NSString*)address port: (NSInteger)port diff --git a/Source/GSStream.h b/Source/GSStream.h index 54147e6af..d87c4fe51 100644 --- a/Source/GSStream.h +++ b/Source/GSStream.h @@ -56,9 +56,10 @@ `-- GSLocalServerStream (gnu/linux) */ -#include -#include -#include +#import "Foundation/NSStream.h" +#import "Foundation/NSRunLoop.h" +#import "Foundation/NSMapTable.h" +#import "GNUstepBase/NSStream+GNUstepBase.h" /** * Convenience methods used to add streams to the run loop. diff --git a/Source/GSStream.m b/Source/GSStream.m index d33dd78f7..ff35a970a 100644 --- a/Source/GSStream.m +++ b/Source/GSStream.m @@ -77,15 +77,6 @@ NSString * const NSStreamSOCKSProxyVersion5 NSString * const NSStreamSOCKSProxyVersionKey = @"NSStreamSOCKSProxyVersionKey"; -NSString * const GSStreamLocalAddressKey - = @"GSStreamLocalAddressKey"; -NSString * const GSStreamLocalPortKey - = @"GSStreamLocalPortKey"; -NSString * const GSStreamRemoteAddressKey - = @"GSStreamRemoteAddressKey"; -NSString * const GSStreamRemotePortKey - = @"GSStreamRemotePortKey"; - /* * Determine the type of event to use when adding a stream to the run loop.