From 8808689fe340bec6e90ab13dd502292b0579cf1f Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sat, 08 Dec 2012 21:19:17 +0000 Subject: initial osx port Signed-off-by: Michael Krelin --- (limited to 'pumpkin/IPFormatter.m') diff --git a/pumpkin/IPFormatter.m b/pumpkin/IPFormatter.m new file mode 100644 index 0000000..78a51b4 --- a/dev/null +++ b/pumpkin/IPFormatter.m @@ -0,0 +1,21 @@ + +#import "IPFormatter.h" +#include + +@implementation IPFormatter + +-(NSString *)stringForObjectValue:(id)obj { + if(![obj isKindOfClass:[NSString class]]) return nil; + return obj; +} + +-(BOOL)getObjectValue:(id*)anObject forString:(NSString*)string errorDescription:(NSString**)error { + if(inet_addr(string.UTF8String)==INADDR_NONE) { + if(error) *error=@"Doesn't look like an IP address to me"; + return NO; + } + *anObject = [NSString stringWithString:string]; + return YES; +} + +@end -- cgit v0.9.0.2