]> git.saurik.com Git - apple/security.git/blobdiff - libsecurity_transform/lib/SecExternalSourceTransform.cpp
Security-55163.44.tar.gz
[apple/security.git] / libsecurity_transform / lib / SecExternalSourceTransform.cpp
diff --git a/libsecurity_transform/lib/SecExternalSourceTransform.cpp b/libsecurity_transform/lib/SecExternalSourceTransform.cpp
new file mode 100644 (file)
index 0000000..6a0b082
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  SecExternalSourceTransform.cpp
+ *  libsecurity_transform
+ *
+ *  Created by J Osborne on 8/17/10.
+ *  Copyright 2010 Apple. All rights reserved.
+ *
+ */
+
+#include "SecTransform.h"
+#include "SecCustomTransform.h"
+#include "SecExternalSourceTransform.h"
+#include <dispatch/dispatch.h>
+
+CFStringRef external_source_name = CFSTR("com.apple.security.external_source");
+
+static SecTransformInstanceBlock SecExternalSourceTransformCreateBlock(CFStringRef name, SecTransformRef newTransform, SecTransformImplementationRef ref)
+{
+       return Block_copy(^{ 
+               SecTransformCustomSetAttribute(ref, kSecTransformInputAttributeName, kSecTransformMetaAttributeRequired, kCFBooleanFalse);
+               
+               SecTransformAttributeRef out = SecTranformCustomGetAttribute(ref, kSecTransformOutputAttributeName, kSecTransformMetaAttributeRef);
+               
+               SecTransformSetAttributeAction(ref, kSecTransformActionAttributeNotification, kSecTransformInputAttributeName, ^(SecTransformAttributeRef attribute, CFTypeRef value) {
+                       SecTransformCustomSetAttribute(ref, out, kSecTransformMetaAttributeValue, value);
+                       return (CFTypeRef)NULL;
+               });
+               
+               return (CFErrorRef)NULL;
+       });
+}
+
+SecTransformRef SecExternalSourceTransformCreate(CFErrorRef* error)
+{
+       static dispatch_once_t once;
+       dispatch_once(&once, ^{
+               SecTransformRegister(external_source_name, SecExternalSourceTransformCreateBlock, error);
+       });
+       
+       return SecTransformCreate(external_source_name, error);
+}
\ No newline at end of file