]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 A |
1 | /* |
2 | * Copyright (c) 2000-2001 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 | // | |
20 | // MDSSchema.h | |
21 | // | |
22 | // Declarations of structures which define the schema, including attributes | |
23 | // and indexes, for the standard tables that are part of the MDS database. | |
24 | // | |
25 | ||
26 | #ifndef _MDSSCHEMA_H | |
27 | #define _MDSSCHEMA_H | |
28 | ||
29 | #include <Security/cssmtype.h> | |
30 | #include "MDSAttrStrings.h" | |
31 | ||
32 | namespace Security | |
33 | { | |
34 | ||
35 | // Structure used to store information which is needed to create | |
36 | // a relation with indexes. The info in one of these structs maps to one | |
37 | // record type in a CSSM_DBINFO - both record attribute info and index info. | |
38 | // The nameValues field refers to an array of MDSNameValuePair array pointers | |
39 | // which are used to convert attribute values from strings to uint32s via | |
40 | // MDS_StringToUint32. The nameValues array is parallel to the AttributeInfo | |
41 | // array. | |
42 | struct RelationInfo { | |
43 | CSSM_DB_RECORDTYPE DataRecordType; | |
44 | const char *relationName; | |
45 | uint32 NumberOfAttributes; | |
46 | const CSSM_DB_ATTRIBUTE_INFO *AttributeInfo; | |
47 | const MDSNameValuePair **nameValues; | |
48 | uint32 NumberOfIndexes; | |
49 | const CSSM_DB_INDEX_INFO *IndexInfo; | |
50 | }; | |
51 | ||
52 | // Macros used to simplify declarations of attributes and indexes. | |
53 | ||
54 | // declare a CSSM_DB_ATTRIBUTE_INFO | |
55 | #define DB_ATTRIBUTE(name, type) \ | |
56 | { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \ | |
57 | {(char*) #name}, \ | |
58 | CSSM_DB_ATTRIBUTE_FORMAT_ ## type \ | |
59 | } | |
60 | ||
61 | // declare a CSSM_DB_INDEX_INFO | |
62 | #define UNIQUE_INDEX_ATTRIBUTE(name, type) \ | |
63 | { CSSM_DB_INDEX_UNIQUE, \ | |
64 | CSSM_DB_INDEX_ON_ATTRIBUTE, \ | |
65 | { CSSM_DB_ATTRIBUTE_NAME_AS_STRING, \ | |
66 | {(char*) #name}, \ | |
67 | CSSM_DB_ATTRIBUTE_FORMAT_ ## type \ | |
68 | } \ | |
69 | } | |
70 | ||
71 | // declare a RelationInfo | |
72 | #define RELATION_INFO(relationId, attributes, nameValues, indexes) \ | |
73 | { relationId, \ | |
74 | #relationId, \ | |
75 | sizeof(attributes) / sizeof(CSSM_DB_ATTRIBUTE_INFO), \ | |
76 | attributes, \ | |
77 | nameValues, \ | |
78 | sizeof(indexes) / sizeof(CSSM_DB_INDEX_INFO), \ | |
79 | indexes } | |
80 | ||
81 | // Object directory DB - one built-in schema. | |
82 | extern const RelationInfo kObjectRelation; | |
83 | ||
84 | // list of all built-in schema for the CDSA Directory DB. | |
85 | extern const RelationInfo kMDSRelationInfo[]; | |
86 | extern const unsigned kNumMdsRelations; // size of kMDSRelationInfo[] | |
87 | ||
88 | // special case "subschema" for parsing CSPCapabilities. | |
89 | extern const RelationInfo CSPCapabilitiesDict1RelInfo; | |
90 | extern const RelationInfo CSPCapabilitiesDict2RelInfo; | |
91 | extern const RelationInfo CSPCapabilitiesDict3RelInfo; | |
92 | ||
93 | // special case "subschema" for parsing TPPolicyOids. | |
94 | extern const RelationInfo TpPolicyOidsDict1RelInfo; | |
95 | extern const RelationInfo TpPolicyOidsDict2RelInfo; | |
96 | ||
97 | // Map a CSSM_DB_RECORDTYPE to a RelationInfo *. | |
98 | extern const RelationInfo *MDSRecordTypeToRelation( | |
99 | CSSM_DB_RECORDTYPE recordType); | |
100 | ||
101 | // same as above, based on record type as string. | |
102 | extern const RelationInfo *MDSRecordTypeNameToRelation( | |
103 | const char *recordTypeName); | |
104 | ||
105 | } // end namespace Security | |
106 | ||
107 | #endif // _MDSSCHEMA_H |