]> git.saurik.com Git - apple/security.git/blob - libsecurity_transform/lib/SecExternalSourceTransform.cpp
Security-55178.0.1.tar.gz
[apple/security.git] / libsecurity_transform / lib / SecExternalSourceTransform.cpp
1 /*
2 * SecExternalSourceTransform.cpp
3 * libsecurity_transform
4 *
5 * Created by J Osborne on 8/17/10.
6 * Copyright 2010 Apple. All rights reserved.
7 *
8 */
9
10 #include "SecTransform.h"
11 #include "SecCustomTransform.h"
12 #include "SecExternalSourceTransform.h"
13 #include <dispatch/dispatch.h>
14
15 CFStringRef external_source_name = CFSTR("com.apple.security.external_source");
16
17 static SecTransformInstanceBlock SecExternalSourceTransformCreateBlock(CFStringRef name, SecTransformRef newTransform, SecTransformImplementationRef ref)
18 {
19 return Block_copy(^{
20 SecTransformCustomSetAttribute(ref, kSecTransformInputAttributeName, kSecTransformMetaAttributeRequired, kCFBooleanFalse);
21
22 SecTransformAttributeRef out = SecTranformCustomGetAttribute(ref, kSecTransformOutputAttributeName, kSecTransformMetaAttributeRef);
23
24 SecTransformSetAttributeAction(ref, kSecTransformActionAttributeNotification, kSecTransformInputAttributeName, ^(SecTransformAttributeRef attribute, CFTypeRef value) {
25 SecTransformCustomSetAttribute(ref, out, kSecTransformMetaAttributeValue, value);
26 return (CFTypeRef)NULL;
27 });
28
29 return (CFErrorRef)NULL;
30 });
31 }
32
33 SecTransformRef SecExternalSourceTransformCreate(CFErrorRef* error)
34 {
35 static dispatch_once_t once;
36 dispatch_once(&once, ^{
37 SecTransformRegister(external_source_name, SecExternalSourceTransformCreateBlock, error);
38 });
39
40 return SecTransformCreate(external_source_name, error);
41 }