]> git.saurik.com Git - apple/security.git/blob - Keychain/SecCFTypes.cpp
eaa73b851dc66544503ed837983a9aa6aa17575f
[apple/security.git] / Keychain / SecCFTypes.cpp
1 /*
2 * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18 //
19 // SecCFTypes.cpp - CF runtime interface
20 //
21
22 #include <Security/SecCFTypes.h>
23 #include <Security/SecRuntime.h>
24
25 namespace Security
26 {
27
28 namespace KeychainCore
29 {
30
31 SecCFTypes &
32 gTypes()
33 {
34 static ModuleNexus<SecCFTypes> nexus;
35
36 return nexus();
37 }
38
39 } // end namespace KeychainCore
40
41 } // end namespace Security
42
43 using namespace KeychainCore;
44
45 SecCFTypes::SecCFTypes() :
46 Access("SecAccess"),
47 ACL("SecACL"),
48 Certificate("SecCertificate"),
49 CertificateRequest("SecCertificateRequest"),
50 Identity("SecIdentity"),
51 IdentityCursor("SecIdentitySearch"),
52 ItemImpl("SecKeychainItem"),
53 KCCursorImpl("SecKeychainSearch"),
54 KeychainImpl("SecKeychain"),
55 KeyItem("SecKey"),
56 Policy("SecPolicy"),
57 PolicyCursor("SecPolicySearch"),
58 Trust("SecTrust"),
59 TrustedApplication("SecTrustedApplication")
60 {
61 }
62
63 //
64 // CFClass
65 //
66 CFClass::CFClass(const char *name)
67 {
68 // initialize the CFRuntimeClass structure
69 version = 0;
70 className = name;
71 init = NULL;
72 copy = NULL;
73 finalize = finalizeType;
74 equal = equalType;
75 hash = hashType;
76 copyFormattingDesc = copyFormattingDescType;
77 copyDebugDesc = copyDebugDescType;
78
79 // register
80 typeID = _CFRuntimeRegisterClass(this);
81 assert(typeID != _kCFRuntimeNotATypeID);
82 }
83
84 void
85 CFClass::finalizeType(CFTypeRef cf)
86 {
87 SecCFObject *obj = SecCFObject::optional(cf);
88 if (!obj->isNew())
89 obj->~SecCFObject();
90 }
91
92 Boolean
93 CFClass::equalType(CFTypeRef cf1, CFTypeRef cf2)
94 {
95 // CF checks for pointer equality and ensures type equality already
96 return SecCFObject::optional(cf1)->equal(*SecCFObject::optional(cf2));
97 }
98
99 CFHashCode
100 CFClass::hashType(CFTypeRef cf)
101 {
102 return SecCFObject::optional(cf)->hash();
103 }
104
105 CFStringRef
106 CFClass::copyFormattingDescType(CFTypeRef cf, CFDictionaryRef dict)
107 {
108 return SecCFObject::optional(cf)->copyFormattingDesc(dict);
109 }
110
111 CFStringRef
112 CFClass::copyDebugDescType(CFTypeRef cf)
113 {
114 return SecCFObject::optional(cf)->copyDebugDesc();
115 }