summaryrefslogtreecommitdiffabout
path: root/pumpkin/IPTransformer.m
authorMichael Krelin <hacker@klever.net>2012-12-08 21:19:17 (UTC)
committer Michael Krelin <hacker@klever.net>2012-12-11 21:59:29 (UTC)
commit8808689fe340bec6e90ab13dd502292b0579cf1f (patch) (unidiff)
tree45b7c863151341f687b74e40bffcbd7ab5468783 /pumpkin/IPTransformer.m
parent6e7e413ca364d79673e523c09767c18e7cff1bec (diff)
downloadpumpkin-osx/0.0.zip
pumpkin-osx/0.0.tar.gz
pumpkin-osx/0.0.tar.bz2
initial osx portosx/0.0
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'pumpkin/IPTransformer.m') (more/less context) (ignore whitespace changes)
-rw-r--r--pumpkin/IPTransformer.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/pumpkin/IPTransformer.m b/pumpkin/IPTransformer.m
new file mode 100644
index 0000000..2307b05
--- a/dev/null
+++ b/pumpkin/IPTransformer.m
@@ -0,0 +1,21 @@
1
2#import "IPTransformer.h"
3
4#include <arpa/inet.h>
5
6@implementation IPTransformer
7
8+(Class)transformedValueClass { return [NSString class]; }
9+(BOOL)allowsReverseTransformation { return YES; }
10-(id)transformedValue:(id)value {
11 if(value &&
12 [value respondsToSelector:@selector(UTF8String)]
13 && inet_addr([value UTF8String])!=INADDR_NONE )
14 return value;
15 return nil;
16}
17-(id)reverseTransformedValue:(id)value {
18 return [self transformedValue:value];
19}
20
21@end \ No newline at end of file