/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo 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, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "common.h"
self->isHostFilled = YES;
}
-- (void)_fillAddress {
+- (NSException *)_fillAddress {
/*
Fill up the INET address based on the host and port ivars.
*/
if (self->isAddressFilled)
/* address is already filled .. */
- return;
+ return nil;
#if DEBUG
NSAssert(self->isHostFilled, @"either host or address must be filled ...");
break;
}
}
- [[[NGCouldNotResolveHostNameException alloc]
- initWithHostName:[self hostName] reason:reason] raise];
+ return [[[NGCouldNotResolveHostNameException alloc]
+ initWithHostName:[self hostName] reason:reason] autorelease];
}
self->isAddressFilled = YES;
}
}
+ return nil;
}
/* constructors */
return nil;
if (!self->isAddressFilled)
- [self _fillAddress];
+ [[self _fillAddress] raise];
{
char *ptr = NULL;
- (int)port {
/* how to do ? */
if (!self->isAddressFilled)
- [self _fillAddress];
+ [[self _fillAddress] raise];
return ntohs(((struct sockaddr_in *)self->address)->sin_port);
}
// NGCouldNotResolveHostNameException when a DNS lookup fails
if (!self->isAddressFilled)
- [self _fillAddress];
+ [[self _fillAddress] raise];
return self->address;
}
/* description */
- (NSString *)stringValue {
- NSString *name = [self hostName];
- if (name == nil) name = @"*";
+ NSString *name;
+
+ if ((name = [self hostName]) == nil)
+ name = @"*";
+
return [NSString stringWithFormat:@"%@:%i", name, [self port]];
}
- (NSString *)description {
- NSString *name = [self hostName];
+ NSMutableString *ms;
+ id tmp;
- if (name == nil) name = @"*";
+ ms = [NSMutableString stringWithCapacity:128];
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+
+ if ((tmp = [self hostName]) != nil)
+ [ms appendFormat:@" host=%@", tmp];
+ else
+ [ms appendString:@" *host"];
+
+ if (!self->isAddressFilled)
+ [ms appendString:@" not-filled"];
+ else
+ [ms appendFormat:@" port=%d", [self port]];
- return [NSString stringWithFormat:@"<InetSocketAddress: %@:%i>",
- name, [self port]];
+ [ms appendString:@">"];
+ return ms;
}
@end /* NGInternetSocketAddress */
- (NSString *)description {
NSMutableString *ms;
+ id tmp;
ms = [NSMutableString stringWithCapacity:128];
[ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
- [ms appendFormat:@" socket=%@", [self socket]];
+
+ if (self->login != nil)
+ [ms appendFormat:@" login=%@%s", self->login, self->password?"(pwd)":""];
+
+ if ((tmp = [self socket]) != nil)
+ [ms appendFormat:@" socket=%@", tmp];
+ else if (self->address)
+ [ms appendFormat:@" address=%@", self->address];
+
[ms appendString:@">"];
return ms;
}