]> git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/mdsdump/MDSSchema.h
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / cspxutils / mdsdump / MDSSchema.h
1 /*
2 * Copyright (c) 2000-2001,2004,2008 Apple 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 //
20 // MDSSchema.h - COPIED FROM libsecurity_mds since this is not exported from
21 // Security.framework
22
23 //
24 // Declarations of structures which define the schema, including attributes
25 // and indexes, for the standard tables that are part of the MDS database.
26 //
27
28 #ifndef _MDSSCHEMA_H
29 #define _MDSSCHEMA_H
30
31 #include <Security/cssmtype.h>
32
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
39 // array.
40 struct RelationInfo {
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;
47 };
48
49 // Macros used to simplify declarations of attributes and indexes.
50
51 // declare a CSSM_DB_ATTRIBUTE_INFO
52 #define DB_ATTRIBUTE(name, type) \
53 { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \
54 {(char *)#name}, \
55 CSSM_DB_ATTRIBUTE_FORMAT_ ## type \
56 }
57
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, \
63 {(char *)#name}, \
64 CSSM_DB_ATTRIBUTE_FORMAT_ ## type \
65 } \
66 }
67
68 // declare a RelationInfo
69 #define RELATION_INFO(relationId, attributes, indexes) \
70 { relationId, \
71 #relationId, \
72 sizeof(attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO), \
73 attributes, \
74 sizeof(indexes) / sizeof(CSSM_DB_INDEX_INFO), \
75 indexes }
76
77 // Object directory DB - one built-in schema.
78 extern const RelationInfo kObjectRelation;
79
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[]
83
84 // special case "subschema" for parsing CSPCapabilities.
85 extern const RelationInfo CSPCapabilitiesDict1RelInfo;
86 extern const RelationInfo CSPCapabilitiesDict2RelInfo;
87 extern const RelationInfo CSPCapabilitiesDict3RelInfo;
88
89 // special case "subschema" for parsing TPPolicyOids.
90 extern const RelationInfo TpPolicyOidsDict1RelInfo;
91 extern const RelationInfo TpPolicyOidsDict2RelInfo;
92
93 // Map a CSSM_DB_RECORDTYPE to a RelationInfo *.
94 extern const RelationInfo *MDSRecordTypeToRelation(
95 CSSM_DB_RECORDTYPE recordType);
96
97 // same as above, based on record type as string.
98 extern const RelationInfo *MDSRecordTypeNameToRelation(
99 const char *recordTypeName);
100
101 #endif // _MDSSCHEMA_H