2 * Copyright (c) 2000-2001,2004,2008 Apple Inc. All Rights Reserved.
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
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.
20 // MDSSchema.h - COPIED FROM libsecurity_mds since this is not exported from
24 // Declarations of structures which define the schema, including attributes
25 // and indexes, for the standard tables that are part of the MDS database.
31 #include <Security/cssmtype.h>
33 // Structure used to store information which is needed to create
34 // a relation with indexes. The info in one of these structs maps to one
35 // record type in a CSSM_DBINFO - both record attribute info and index info.
36 // The nameValues field refers to an array of MDSNameValuePair array pointers
37 // which are used to convert attribute values from strings to uint32s via
38 // MDS_StringToUint32. The nameValues array is parallel to the AttributeInfo
41 CSSM_DB_RECORDTYPE DataRecordType
;
42 const char *relationName
;
43 uint32 NumberOfAttributes
;
44 const CSSM_DB_ATTRIBUTE_INFO
*AttributeInfo
;
45 uint32 NumberOfIndexes
;
46 const CSSM_DB_INDEX_INFO
*IndexInfo
;
49 // Macros used to simplify declarations of attributes and indexes.
51 // declare a CSSM_DB_ATTRIBUTE_INFO
52 #define DB_ATTRIBUTE(name, type) \
53 { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \
55 CSSM_DB_ATTRIBUTE_FORMAT_ ## type \
58 // declare a CSSM_DB_INDEX_INFO
59 #define UNIQUE_INDEX_ATTRIBUTE(name, type) \
60 { CSSM_DB_INDEX_UNIQUE, \
61 CSSM_DB_INDEX_ON_ATTRIBUTE, \
62 { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \
64 CSSM_DB_ATTRIBUTE_FORMAT_ ## type \
68 // declare a RelationInfo
69 #define RELATION_INFO(relationId, attributes, indexes) \
72 sizeof(attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO), \
74 sizeof(indexes) / sizeof(CSSM_DB_INDEX_INFO), \
77 // Object directory DB - one built-in schema.
78 extern const RelationInfo kObjectRelation
;
80 // list of all built-in schema for the CDSA Directory DB.
81 extern const RelationInfo kMDSRelationInfo
[];
82 extern const unsigned kNumMdsRelations
; // size of kMDSRelationInfo[]
84 // special case "subschema" for parsing CSPCapabilities.
85 extern const RelationInfo CSPCapabilitiesDict1RelInfo
;
86 extern const RelationInfo CSPCapabilitiesDict2RelInfo
;
87 extern const RelationInfo CSPCapabilitiesDict3RelInfo
;
89 // special case "subschema" for parsing TPPolicyOids.
90 extern const RelationInfo TpPolicyOidsDict1RelInfo
;
91 extern const RelationInfo TpPolicyOidsDict2RelInfo
;
93 // Map a CSSM_DB_RECORDTYPE to a RelationInfo *.
94 extern const RelationInfo
*MDSRecordTypeToRelation(
95 CSSM_DB_RECORDTYPE recordType
);
97 // same as above, based on record type as string.
98 extern const RelationInfo
*MDSRecordTypeNameToRelation(
99 const char *recordTypeName
);
101 #endif // _MDSSCHEMA_H