mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
Make NSHost more tolerant of bad system setups.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8673 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b987758597
commit
d9e20073d0
3 changed files with 43 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2001-01-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSHost.m: New method ([-_addName:]) to add a name to a host.
|
||||||
|
Use it to add the local hostname to the 127.0.0.1 host if there is
|
||||||
|
no IP address set up for the local machine.
|
||||||
|
|
||||||
2001-01-17 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
2001-01-17 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||||
|
|
||||||
* Source/GSXML.m|.h ([GSXMLDocument -stringValue]): dump document in a
|
* Source/GSXML.m|.h ([GSXMLDocument -stringValue]): dump document in a
|
||||||
|
|
|
@ -242,15 +242,15 @@ loadEntityFunction(const char *url, const char *eid, xmlParserCtxtPtr *ctxt);
|
||||||
xmlSaveFile([filename cString], lib);
|
xmlSaveFile([filename cString], lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) stringValue
|
- (NSString*) stringValue
|
||||||
{
|
{
|
||||||
NSString *string = nil;
|
NSString *string = nil;
|
||||||
xmlChar *buf = NULL;
|
xmlChar *buf = NULL;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
xmlDocDumpMemory(lib, &buf, &length);
|
xmlDocDumpMemory(lib, &buf, &length);
|
||||||
|
|
||||||
if(buf && length)
|
if (buf != 0 && length > 0)
|
||||||
{
|
{
|
||||||
string = [NSString_class stringWithCString: buf length: length];
|
string = [NSString_class stringWithCString: buf length: length];
|
||||||
xmlFree(buf);
|
xmlFree(buf);
|
||||||
|
|
|
@ -57,6 +57,7 @@ static NSString *myHostName = nil;
|
||||||
|
|
||||||
|
|
||||||
@interface NSHost (Private)
|
@interface NSHost (Private)
|
||||||
|
- (void) _addName: (NSString*)name;
|
||||||
+ (struct hostent*) _entryForAddress: (NSString*)address;
|
+ (struct hostent*) _entryForAddress: (NSString*)address;
|
||||||
- (id) _initWithHostEntry: (struct hostent*)entry key: (NSString*)key;
|
- (id) _initWithHostEntry: (struct hostent*)entry key: (NSString*)key;
|
||||||
+ (NSMutableSet*) _localAddresses;
|
+ (NSMutableSet*) _localAddresses;
|
||||||
|
@ -64,6 +65,21 @@ static NSString *myHostName = nil;
|
||||||
|
|
||||||
@implementation NSHost (Private)
|
@implementation NSHost (Private)
|
||||||
|
|
||||||
|
- (void) _addName: (NSString*)name
|
||||||
|
{
|
||||||
|
NSMutableSet *s = [_names mutableCopy];
|
||||||
|
|
||||||
|
name = [name copy];
|
||||||
|
[s addObject: name];
|
||||||
|
ASSIGNCOPY(_names, s);
|
||||||
|
RELEASE(s);
|
||||||
|
if (_hostCacheEnabled == YES)
|
||||||
|
{
|
||||||
|
[_hostCache setObject: self forKey: name];
|
||||||
|
}
|
||||||
|
RELEASE(name);
|
||||||
|
}
|
||||||
|
|
||||||
+ (struct hostent*) _entryForAddress: (NSString*)address
|
+ (struct hostent*) _entryForAddress: (NSString*)address
|
||||||
{
|
{
|
||||||
struct hostent *h = 0;
|
struct hostent *h = 0;
|
||||||
|
@ -287,9 +303,22 @@ static NSString *myHostName = nil;
|
||||||
h = gethostbyname((char*)[name cString]);
|
h = gethostbyname((char*)[name cString]);
|
||||||
if (h == 0)
|
if (h == 0)
|
||||||
{
|
{
|
||||||
NSLog(@"Host '%@' not found using 'gethostbyname()' - perhaps "
|
if ([name isEqualToString: myHostName] == YES)
|
||||||
@"the hostname is wrong or networking is not set up on your "
|
{
|
||||||
@"machine", name);
|
NSLog(@"No network address appears to be available "
|
||||||
|
@"for this machine (%@) - using loopback address "
|
||||||
|
@"(127.0.0.1)", name);
|
||||||
|
NSLog(@"You probably need a line like '"
|
||||||
|
@"127.0.0.1 %@ localhost' in your /etc/hosts file");
|
||||||
|
host = [self hostWithAddress: @"127.0.0.1"];
|
||||||
|
[host _addName: name];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Host '%@' not found using 'gethostbyname()' - "
|
||||||
|
@"perhaps the hostname is wrong or networking is not "
|
||||||
|
@"set up on your machine", name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue