]> git.saurik.com Git - apple/security.git/blob - Keychain/Schema.m4
Security-30.1.tar.gz
[apple/security.git] / Keychain / Schema.m4
1 divert(-1)
2 changecom(/*, */)
3 /*
4 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
5 *
6 * The contents of this file constitute Original Code as defined in and are
7 * subject to the Apple Public Source License Version 1.2 (the 'License').
8 * You may not use this file except in compliance with the License. Please obtain
9 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
14 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
15 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
17 * specific language governing rights and limitations under the License.
18 */
19
20 define(`startClass',
21 `define(`arrayIndex', 0)dnl
22 define(`class', $1)dnl
23 divert(0)dnl
24 // $1 password attributes
25 static const CSSM_DB_ATTRIBUTE_INFO $1Attributes[] =
26 {
27 divert(1)dnl
28 // $1 password indices
29 static const CSSM_DB_INDEX_INFO $1Indices[] =
30 {')
31
32 define(`endClass',
33 `divert(0)dnl
34 };
35
36 divert(1)dnl
37 ` // Unique (primary) index'
38 undivert(3)
39 ` // Secondary indices'
40 undivert(4)dnl
41 };
42
43 divert(-1)')
44
45 define(`attributeBody',
46 ` {
47 ifelse(index(`$1',`s'),-1,
48 ` CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER,
49 {(char *)$3},',
50 ` CSSM_DB_ATTRIBUTE_NAME_AS_STRING,
51 {$4},')
52 CSSM_DB_ATTRIBUTE_FORMAT_$7
53 }')
54
55 define(`simpleAttribute',
56 `const CSSM_DB_ATTRIBUTE_INFO $2 =
57 attributeBody($*);
58 ')
59
60 define(`attribute',
61 `ifelse(index(`$1',`U'),-1,`',
62 `divert(3)dnl
63 {
64 CSSM_DB_INDEX_UNIQUE,
65 CSSM_DB_INDEX_ON_ATTRIBUTE,
66 attributeBody($*)
67 },
68 ')dnl
69 ifelse(index(`$1',`I'),-1,`',
70 `divert(4)dnl
71 {
72 CSSM_DB_INDEX_NONUNIQUE,
73 CSSM_DB_INDEX_ON_ATTRIBUTE,
74 attributeBody($*)
75 },
76 ')dnl
77 divert(2)dnl
78 dnl const CSSM_DB_ATTRIBUTE_INFO &`k'class()$2 = class()Attributes[arrayIndex()];
79 `#define k'class()$2 class()Attributes[arrayIndex()];
80 divert(0)dnl
81 attributeBody($*),dnl
82 define(`arrayIndex', incr(arrayIndex))dnl
83 ')
84
85 define(`attrInfo',
86 `{
87 $1,
88 sizeof($2Attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO),
89 const_cast<CSSM_DB_ATTRIBUTE_INFO_PTR>($2Attributes)
90 }')
91
92 define(`indexInfo',
93 `{
94 $1,
95 sizeof($2Indices) / sizeof(CSSM_DB_INDEX_INFO),
96 const_cast<CSSM_DB_INDEX_INFO_PTR>($2Indices)
97 }')
98
99 define(`parseInfo',
100 `{
101 CSSM_DB_RECORDTYPE_APP_DEFINED_START,
102 {
103 {0,0,0,{0}},
104 {0,0},
105 0,
106 0
107 }
108 }')
109
110 /* Start of actual output */
111 divert(0)dnl
112 /*
113 * Generated by m4 from Schema.m4 please do not edit this file.
114 */
115
116 `#include <Security/Schema.h>'
117
118 `#include <Security/SecKeychainAPIPriv.h>'
119 `#include <Security/cssmapple.h>'
120 `#include <Security/utilities.h>'
121
122 namespace Security {
123
124 namespace KeychainCore {
125
126 namespace Schema {
127
128 // Meta attributes
129 simpleAttribute(` s', RelationID, 0, "RelationID", 0, NULL, UINT32)
130 simpleAttribute(` s', RelationName, 1, "RelationName", 0, NULL, STRING)
131 simpleAttribute(` s', AttributeID, 1, "AttributeID", 0, NULL, UINT32)
132 simpleAttribute(` s', AttributeNameFormat, 2, "AttributeNameFormat", 0, NULL, UINT32)
133 simpleAttribute(` s', AttributeName, 3, "AttributeName", 0, NULL, STRING)
134 simpleAttribute(` s', AttributeNameID, 4, "AttributeNameID", 0, NULL, BLOB)
135 simpleAttribute(` s', AttributeFormat, 5, "AttributeFormat", 0, NULL, UINT32)
136 simpleAttribute(` s', IndexType, 3, "IndexType", 0, NULL, UINT32)
137
138 divert(-1)
139 startClass(Generic)
140 attribute(` i', CreationDate, kSecCreationDateItemAttr, "CreationDate", 0, NULL, TIME_DATE)
141 attribute(` i', ModDate, kSecModDateItemAttr, "ModDate", 0, NULL, TIME_DATE)
142 attribute(` i', Description, kSecDescriptionItemAttr, "Description", 0, NULL, BLOB)
143 attribute(` i', Comment, kSecCommentItemAttr, "Comment", 0, NULL, BLOB)
144 attribute(` i', Creator, kSecCreatorItemAttr, "Creator", 0, NULL, UINT32)
145 attribute(` i', Type, kSecTypeItemAttr, "Type", 0, NULL, UINT32)
146 attribute(` i', ScriptCode, kSecScriptCodeItemAttr, "ScriptCode", 0, NULL, SINT32)
147 attribute(` s', PrintName, kSecLabelItemAttr, "PrintName", 0, NULL, BLOB)
148 attribute(` s', Alias, kSecAliasItemAttr, "Alias", 0, NULL, BLOB)
149 attribute(` i', Invisible, kSecInvisibleItemAttr, "Invisible", 0, NULL, SINT32)
150 attribute(` i', Negative, kSecNegativeItemAttr, "Negative", 0, NULL, SINT32)
151 attribute(` i', CustomIcon, kSecCustomIconItemAttr, "CustomIcon", 0, NULL, SINT32)
152 attribute(` i', Protected, kSecProtectedDataItemAttr, "Protected", 0, NULL, BLOB)
153 attribute(`UIi', Account, kSecAccountItemAttr, "Account", 0, NULL, BLOB)
154 attribute(`UIi', Service, kSecServiceItemAttr, "Service", 0, NULL, BLOB)
155 attribute(` i', Generic, kSecGenericItemAttr, "Generic", 0, NULL, BLOB)
156 endClass()
157
158 startClass(Appleshare)
159 attribute(` i', CreationDate, kSecCreationDateItemAttr, "CreationDate", 0, NULL, TIME_DATE)
160 attribute(` i', ModDate, kSecModDateItemAttr, "ModDate", 0, NULL, TIME_DATE)
161 attribute(` i', Description, kSecDescriptionItemAttr, "Description", 0, NULL, BLOB)
162 attribute(` i', Comment, kSecCommentItemAttr, "Comment", 0, NULL, BLOB)
163 attribute(` i', Creator, kSecCreatorItemAttr, "Creator", 0, NULL, UINT32)
164 attribute(` i', Type, kSecTypeItemAttr, "Type", 0, NULL, UINT32)
165 attribute(` i', ScriptCode, kSecScriptCodeItemAttr, "ScriptCode", 0, NULL, SINT32)
166 attribute(` s', PrintName, kSecLabelItemAttr, "PrintName", 0, NULL, BLOB)
167 attribute(` s', Alias, kSecAliasItemAttr, "Alias", 0, NULL, BLOB)
168 attribute(` i', Invisible, kSecInvisibleItemAttr, "Invisible", 0, NULL, SINT32)
169 attribute(` i', Negative, kSecNegativeItemAttr, "Negative", 0, NULL, SINT32)
170 attribute(` i', CustomIcon, kSecCustomIconItemAttr, "CustomIcon", 0, NULL, SINT32)
171 attribute(` i', Protected, kSecProtectedDataItemAttr, "Protected", 0, NULL, BLOB)
172 attribute(`UIi', Account, kSecAccountItemAttr, "Account", 0, NULL, BLOB)
173 attribute(`UIi', Volume, kSecVolumeItemAttr, "Volume", 0, NULL, BLOB)
174 attribute(` i', Server, kSecServerItemAttr, "Server", 0, NULL, BLOB)
175 attribute(` i', Protocol, kSecProtocolItemAttr, "Protocol", 0, NULL, UINT32)
176 attribute(`UIi', Address, kSecAddressItemAttr, "Address", 0, NULL, BLOB)
177 attribute(`UIi', Signature, kSecSignatureItemAttr, "Signature", 0, NULL, BLOB)
178 endClass()
179
180 startClass(Internet)
181 attribute(` i', CreationDate, kSecCreationDateItemAttr, "CreationDate", 0, NULL, TIME_DATE)
182 attribute(` i', ModDate, kSecModDateItemAttr, "ModDate", 0, NULL, TIME_DATE)
183 attribute(` i', Description, kSecDescriptionItemAttr, "Description", 0, NULL, BLOB)
184 attribute(` i', Comment, kSecCommentItemAttr, "Comment", 0, NULL, BLOB)
185 attribute(` i', Creator, kSecCreatorItemAttr, "Creator", 0, NULL, UINT32)
186 attribute(` i', Type, kSecTypeItemAttr, "Type", 0, NULL, UINT32)
187 attribute(` i', ScriptCode, kSecScriptCodeItemAttr, "ScriptCode", 0, NULL, SINT32)
188 attribute(` s', PrintName, kSecLabelItemAttr, "PrintName", 0, NULL, BLOB)
189 attribute(` s', Alias, kSecAliasItemAttr, "Alias", 0, NULL, BLOB)
190 attribute(` i', Invisible, kSecInvisibleItemAttr, "Invisible", 0, NULL, SINT32)
191 attribute(` i', Negative, kSecNegativeItemAttr, "Negative", 0, NULL, SINT32)
192 attribute(` i', CustomIcon, kSecCustomIconItemAttr, "CustomIcon", 0, NULL, SINT32)
193 attribute(` i', Protected, kSecProtectedDataItemAttr, "Protected", 0, NULL, BLOB)
194 attribute(`UIi', Account, kSecAccountItemAttr, "Account", 0, NULL, BLOB)
195 attribute(`UIi', SecurityDomain, kSecSecurityDomainItemAttr, "SecurityDomain", 0, NULL, BLOB)
196 attribute(`UIi', Server, kSecServerItemAttr, "Server", 0, NULL, BLOB)
197 attribute(`UIi', Protocol, kSecProtocolItemAttr, "Protocol", 0, NULL, UINT32)
198 attribute(`UIi', AuthType, kSecAuthTypeItemAttr, "AuthType", 0, NULL, BLOB)
199 attribute(`UIi', Port, kSecPortItemAttr, "Port", 0, NULL, UINT32)
200 attribute(`UIi', Path, kSecPathItemAttr, "Path", 0, NULL, BLOB)
201 endClass()
202
203 divert(3)
204 static const CSSM_DB_RECORD_ATTRIBUTE_INFO Attributes[] =
205 {
206 attrInfo(CSSM_DL_DB_RECORD_GENERIC_PASSWORD, Generic),
207 attrInfo(CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD, Appleshare),
208 attrInfo(CSSM_DL_DB_RECORD_INTERNET_PASSWORD, Internet)
209 };
210
211 static const CSSM_DB_RECORD_INDEX_INFO Indices[] =
212 {
213 indexInfo(CSSM_DL_DB_RECORD_GENERIC_PASSWORD, Generic),
214 indexInfo(CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD, Appleshare),
215 indexInfo(CSSM_DL_DB_RECORD_INTERNET_PASSWORD, Internet)
216 };
217
218 static const CSSM_DB_PARSING_MODULE_INFO ParseInfos[] =
219 {
220 parseInfo(),
221 parseInfo(),
222 parseInfo()
223 };
224
225 //
226 // Public stuff
227 //
228 const CSSM_DBINFO DBInfo =
229 {
230 sizeof(Attributes) / sizeof(CSSM_DB_RECORD_ATTRIBUTE_INFO),
231 const_cast<CSSM_DB_PARSING_MODULE_INFO_PTR>(ParseInfos),
232 const_cast<CSSM_DB_RECORD_ATTRIBUTE_INFO_PTR>(Attributes),
233 const_cast<CSSM_DB_RECORD_INDEX_INFO_PTR>(Indices),
234 CSSM_TRUE,
235 NULL,
236 NULL
237 };
238
239 //
240 // Schema methods
241 //
242 CSSM_DB_RECORDTYPE
243 recordTypeFor(SecItemClass itemClass)
244 {
245 switch (itemClass)
246 {
247 case kSecGenericPasswordItemClass: return CSSM_DL_DB_RECORD_GENERIC_PASSWORD;
248 case kSecInternetPasswordItemClass: return CSSM_DL_DB_RECORD_INTERNET_PASSWORD;
249 case kSecAppleSharePasswordItemClass: return CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD;
250 default: MacOSError::throwMe(errSecNoSuchClass);
251 }
252 }
253
254 SecItemClass
255 itemClassFor(CSSM_DB_RECORDTYPE recordType)
256 {
257 switch (recordType)
258 {
259 case CSSM_DL_DB_RECORD_GENERIC_PASSWORD: return kSecGenericPasswordItemClass;
260 case CSSM_DL_DB_RECORD_INTERNET_PASSWORD: return kSecInternetPasswordItemClass;
261 case CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD: return kSecAppleSharePasswordItemClass;
262 default: return 0; // MacOSError::throwMe(errSecNoSuchClass);
263 }
264 }
265
266 const CSSM_DB_ATTRIBUTE_INFO &
267 attributeInfo(SecKeychainAttrType attrType)
268 {
269 switch (attrType)
270 {
271 case kSecCreationDateItemAttr: return kGenericCreationDate;
272 case kSecModDateItemAttr: return kGenericModDate;
273 case kSecDescriptionItemAttr: return kGenericDescription;
274 case kSecCommentItemAttr: return kGenericComment;
275 case kSecCreatorItemAttr: return kGenericCreator;
276 case kSecTypeItemAttr: return kGenericType;
277 case kSecScriptCodeItemAttr: return kGenericScriptCode;
278 case kSecLabelItemAttr: return kGenericPrintName;
279 case kSecAliasItemAttr: return kGenericAlias;
280 case kSecInvisibleItemAttr: return kGenericInvisible;
281 case kSecNegativeItemAttr: return kGenericNegative;
282 case kSecCustomIconItemAttr: return kGenericCustomIcon;
283 /* Unique Generic password attributes */
284 case kSecAccountItemAttr: return kGenericAccount;
285 case kSecServiceItemAttr: return kGenericService;
286 case kSecGenericItemAttr: return kGenericGeneric;
287 /* Unique Appleshare password attributes */
288 case kSecVolumeItemAttr: return kAppleshareVolume;
289 case kSecAddressItemAttr: return kAppleshareAddress;
290 case kSecSignatureItemAttr: return kAppleshareSignature;
291 /* Unique AppleShare and Internet attributes */
292 case kSecServerItemAttr: return kAppleshareServer;
293 case kSecProtocolItemAttr: return kAppleshareProtocol;
294 /* Unique Internet password attributes */
295 case kSecSecurityDomainItemAttr: return kInternetSecurityDomain;
296 case kSecAuthTypeItemAttr: return kInternetAuthType;
297 case kSecPortItemAttr: return kInternetPort;
298 case kSecPathItemAttr: return kInternetPath;
299 default: MacOSError::throwMe(errSecNoSuchAttr); // @@@ Not really but whatever.
300 }
301 }
302
303 } // end namespace Schema
304
305 } // end namespace KeychainCore
306
307 } // end namespace Security