2002-06-06 14:02:59 +00:00
|
|
|
|
/** Interface for NSFileHandle for GNUStep
|
1997-09-01 21:59:51 +00:00
|
|
|
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Date: 1997
|
|
|
|
|
|
|
|
|
|
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 Library 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 Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
2002-06-06 14:02:59 +00:00
|
|
|
|
|
|
|
|
|
AutogsdocSource: NSFileHandle.m
|
|
|
|
|
AutogsdocSource: NSPipe.m
|
1997-09-01 21:59:51 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NSFileHandle_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
#define __NSFileHandle_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
|
|
|
|
|
|
@interface NSFileHandle : NSObject
|
|
|
|
|
|
|
|
|
|
// Allocating and Initializing a FileHandle Object
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) fileHandleForReadingAtPath: (NSString*)path;
|
|
|
|
|
+ (id) fileHandleForWritingAtPath: (NSString*)path;
|
|
|
|
|
+ (id) fileHandleForUpdatingAtPath: (NSString*)path;
|
|
|
|
|
+ (id) fileHandleWithStandardError;
|
|
|
|
|
+ (id) fileHandleWithStandardInput;
|
|
|
|
|
+ (id) fileHandleWithStandardOutput;
|
|
|
|
|
+ (id) fileHandleWithNullDevice;
|
|
|
|
|
|
|
|
|
|
- (id) initWithFileDescriptor: (int)desc;
|
|
|
|
|
- (id) initWithFileDescriptor: (int)desc closeOnDealloc: (BOOL)flag;
|
|
|
|
|
- (id) initWithNativeHandle: (void*)hdl;
|
|
|
|
|
- (id) initWithNativeHandle: (void*)hdl closeOnDealloc: (BOOL)flag;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Returning file handles
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (int) fileDescriptor;
|
|
|
|
|
- (void*) nativeHandle;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Synchronous I/O operations
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (NSData*) availableData;
|
|
|
|
|
- (NSData*) readDataToEndOfFile;
|
|
|
|
|
- (NSData*) readDataOfLength: (unsigned int)len;
|
|
|
|
|
- (void) writeData: (NSData*)item;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Asynchronous I/O operations
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) acceptConnectionInBackgroundAndNotify;
|
2002-06-23 19:53:15 +00:00
|
|
|
|
- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) readInBackgroundAndNotify;
|
2002-06-23 19:53:15 +00:00
|
|
|
|
- (void) readInBackgroundAndNotifyForModes: (NSArray*)modes;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) readToEndOfFileInBackgroundAndNotify;
|
2002-06-23 19:53:15 +00:00
|
|
|
|
- (void) readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) waitForDataInBackgroundAndNotify;
|
2002-06-23 19:53:15 +00:00
|
|
|
|
- (void) waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Seeking within a file
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (unsigned long long) offsetInFile;
|
|
|
|
|
- (unsigned long long) seekToEndOfFile;
|
|
|
|
|
- (void) seekToFileOffset: (unsigned long long)pos;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Operations on file
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) closeFile;
|
|
|
|
|
- (void) synchronizeFile;
|
|
|
|
|
- (void) truncateFileAtOffset: (unsigned long long)pos;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// Notification names.
|
|
|
|
|
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const NSFileHandleConnectionAcceptedNotification;
|
|
|
|
|
GS_EXPORT NSString * const NSFileHandleDataAvailableNotification;
|
|
|
|
|
GS_EXPORT NSString * const NSFileHandleReadCompletionNotification;
|
|
|
|
|
GS_EXPORT NSString * const NSFileHandleReadToEndOfFileCompletionNotification;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Keys for accessing userInfo dictionary in notification handlers.
|
|
|
|
|
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const NSFileHandleNotificationDataItem;
|
|
|
|
|
GS_EXPORT NSString * const NSFileHandleNotificationFileHandleItem;
|
|
|
|
|
GS_EXPORT NSString * const NSFileHandleNotificationMonitorModes;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Exceptions
|
|
|
|
|
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const NSFileHandleOperationException;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
@interface NSPipe : NSObject
|
|
|
|
|
{
|
|
|
|
|
NSFileHandle* readHandle;
|
|
|
|
|
NSFileHandle* writeHandle;
|
|
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) pipe;
|
|
|
|
|
- (NSFileHandle*) fileHandleForReading;
|
|
|
|
|
- (NSFileHandle*) fileHandleForWriting;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
2000-11-15 14:32:18 +00:00
|
|
|
|
|
|
|
|
|
#ifndef NO_GNUSTEP
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
// GNUstep class extensions
|
|
|
|
|
|
|
|
|
|
@interface NSFileHandle (GNUstepExtensions)
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) fileHandleAsServerAtAddress: (NSString*)address
|
|
|
|
|
service: (NSString*)service
|
|
|
|
|
protocol: (NSString*)protocol;
|
|
|
|
|
+ (id) fileHandleAsClientAtAddress: (NSString*)address
|
|
|
|
|
service: (NSString*)service
|
|
|
|
|
protocol: (NSString*)protocol;
|
|
|
|
|
+ (id) fileHandleAsClientInBackgroundAtAddress: (NSString*)address
|
|
|
|
|
service: (NSString*)service
|
|
|
|
|
protocol: (NSString*)protocol;
|
|
|
|
|
+ (id) fileHandleAsClientInBackgroundAtAddress: (NSString*)address
|
|
|
|
|
service: (NSString*)service
|
|
|
|
|
protocol: (NSString*)protocol
|
|
|
|
|
forModes: (NSArray*)modes;
|
2002-06-23 19:53:15 +00:00
|
|
|
|
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len;
|
|
|
|
|
- (void) readDataInBackgroundAndNotifyLength: (unsigned)len
|
|
|
|
|
forModes: (NSArray*)modes;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (BOOL) readInProgress;
|
|
|
|
|
- (NSString*) socketAddress;
|
|
|
|
|
- (NSString*) socketService;
|
|
|
|
|
- (NSString*) socketProtocol;
|
2001-10-24 16:34:00 +00:00
|
|
|
|
- (BOOL) useCompression;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes;
|
|
|
|
|
- (void) writeInBackgroundAndNotify: (NSData*)item;
|
|
|
|
|
- (BOOL) writeInProgress;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/**
|
2001-12-04 14:59:09 +00:00
|
|
|
|
* Where OpenSSL is available, you can use the subclass returned by +sslClass
|
2000-11-15 14:32:18 +00:00
|
|
|
|
* to handle SSL connections.
|
2003-11-05 18:26:09 +00:00
|
|
|
|
* The -sslAccept method is used to do SSL handlshake and start an
|
|
|
|
|
* encrypted session on a channel where the connection was initiated
|
|
|
|
|
* from the far end.
|
2000-11-15 14:32:18 +00:00
|
|
|
|
* The -sslConnect method is used to do SSL handlshake and start an
|
2003-11-05 18:26:09 +00:00
|
|
|
|
* encrypted session on a channel where the connection was initiated
|
|
|
|
|
* from the near end..
|
2000-11-15 14:32:18 +00:00
|
|
|
|
* The -sslDisconnect method is used to end the encrypted session.
|
|
|
|
|
* The -sslSetCertificate:privateKey:PEMpasswd: method is used to
|
|
|
|
|
* establish a client certificate before starting an encrypted session.
|
|
|
|
|
*/
|
|
|
|
|
@interface NSFileHandle (GNUstepOpenSSL)
|
2001-12-04 14:59:09 +00:00
|
|
|
|
+ (Class) sslClass;
|
2003-11-05 18:26:09 +00:00
|
|
|
|
- (BOOL) sslAccept;
|
2000-11-15 14:41:15 +00:00
|
|
|
|
- (BOOL) sslConnect;
|
2000-11-15 14:32:18 +00:00
|
|
|
|
- (void) sslDisconnect;
|
|
|
|
|
- (void) sslSetCertificate: (NSString*)certFile
|
|
|
|
|
privateKey: (NSString*)privateKey
|
|
|
|
|
PEMpasswd: (NSString*)PEMpasswd;
|
|
|
|
|
@end
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
// GNUstep Notification names.
|
|
|
|
|
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const GSFileHandleConnectCompletionNotification;
|
|
|
|
|
GS_EXPORT NSString * const GSFileHandleWriteCompletionNotification;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
// Message describing error in async accept,read,write operation.
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const GSFileHandleNotificationError;
|
2000-11-15 14:32:18 +00:00
|
|
|
|
#endif
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
#endif /* __NSFileHandle_h_GNUSTEP_BASE_INCLUDE */
|