1997-03-03 19:40:50 +00:00
|
|
|
/* Interface for host class
|
|
|
|
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Luke Howard <lukeh@xedoc.com.au>
|
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1997-03-03 19:40:50 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
1997-03-03 19:40:50 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1997-03-03 19:40:50 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
1997-03-03 19:40:50 +00:00
|
|
|
*/
|
1999-04-15 10:29:21 +00:00
|
|
|
#ifndef __NSHost_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSHost_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
1997-03-03 19:40:50 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
1997-03-03 19:40:50 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
@class NSString, NSArray, NSSet;
|
1997-03-03 19:40:50 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Instances of this class encapsulate host information. Constructors based
|
|
|
|
* on host name or numeric address are provided.
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
@interface NSHost : NSObject
|
|
|
|
{
|
2010-02-14 10:48:10 +00:00
|
|
|
#if GS_EXPOSE(NSHost)
|
1997-03-03 19:40:50 +00:00
|
|
|
@private
|
2000-08-07 22:00:31 +00:00
|
|
|
NSSet *_names;
|
|
|
|
NSSet *_addresses;
|
2010-03-02 09:51:12 +00:00
|
|
|
#endif
|
2011-02-16 05:49:45 +00:00
|
|
|
#if GS_NONFRAGILE
|
|
|
|
#else
|
2011-02-14 06:37:45 +00:00
|
|
|
/* Pointer to private additional data used to avoid breaking ABI
|
|
|
|
* when we don't have the non-fragile ABI available.
|
2011-02-16 05:49:45 +00:00
|
|
|
* Use this mechanism rather than changing the instance variable
|
|
|
|
* layout (see Source/GSInternal.h for details).
|
2011-02-14 06:37:45 +00:00
|
|
|
*/
|
2011-03-05 18:12:55 +00:00
|
|
|
@private id _internal GS_UNUSED_IVAR;
|
2011-02-14 06:37:45 +00:00
|
|
|
#endif
|
1997-03-03 19:40:50 +00:00
|
|
|
}
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Get current host object.
|
1997-03-03 19:40:50 +00:00
|
|
|
*/
|
|
|
|
+ (NSHost*) currentHost;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get info for host with given DNS name.
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
+ (NSHost*) hostWithName: (NSString*)name;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a host object. Hosts are cached for efficiency. The address
|
|
|
|
* must be an IPV4 "dotted decimal" string, e.g.
|
|
|
|
<example>
|
|
|
|
NSHost aHost = [NSHost hostWithAddress:@"192.42.172.1"];
|
|
|
|
</example>
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
+ (NSHost*) hostWithAddress: (NSString*)address;
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Set host cache management.
|
1997-03-03 19:40:50 +00:00
|
|
|
* If enabled, only one object representing each host will be created, and
|
|
|
|
* a shared instance will be returned by all methods that return a host.
|
|
|
|
*/
|
|
|
|
+ (void) setHostCacheEnabled: (BOOL)flag;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return host cache management.
|
|
|
|
* If enabled, only one object representing each host will be created, and
|
|
|
|
* a shared instance will be returned by all methods that return a host.
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
+ (BOOL) isHostCacheEnabled;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear cache of host info instances.
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
+ (void) flushHostCache;
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Compare hosts.
|
1997-03-03 19:40:50 +00:00
|
|
|
* Hosts are equal if they share at least one address
|
|
|
|
*/
|
|
|
|
- (BOOL) isEqualToHost: (NSHost*) aHost;
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Return host name. Chosen arbitrarily if a host has more than one.
|
1997-03-03 19:40:50 +00:00
|
|
|
*/
|
|
|
|
- (NSString*) name;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all known names for host.
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
- (NSArray*) names;
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Return host address in "dotted decimal" notation, e.g. "192.42.172.1".
|
|
|
|
* Chosen arbitrarily if a host has more than one.
|
1997-03-03 19:40:50 +00:00
|
|
|
*/
|
|
|
|
- (NSString*) address;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all known addresses for host in "dotted decimal" notation,
|
|
|
|
* e.g. "192.42.172.1".
|
|
|
|
*/
|
1997-03-03 19:40:50 +00:00
|
|
|
- (NSArray*) addresses;
|
|
|
|
|
|
|
|
@end
|
1999-04-15 10:29:21 +00:00
|
|
|
|
2008-06-10 18:20:23 +00:00
|
|
|
#if GS_API_VERSION(GS_API_NONE,011700)
|
2008-06-10 11:17:13 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Adds synonym for +currentHost.
|
|
|
|
*/
|
2000-08-07 22:00:31 +00:00
|
|
|
@interface NSHost (GNUstep)
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Synonym for +currentHost.
|
|
|
|
*/
|
2000-08-07 22:00:31 +00:00
|
|
|
+ (NSHost*) localHost; /* All local IP addresses */
|
|
|
|
@end
|
2008-06-10 11:17:13 +00:00
|
|
|
#endif
|
2000-08-07 22:00:31 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-04-15 10:29:21 +00:00
|
|
|
#endif
|
|
|
|
|