]> git.saurik.com Git - apple/security.git/blob - OSX/include/security_cdsa_client/mdsclient.h
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / include / security_cdsa_client / mdsclient.h
1 /*
2 * Copyright (c) 2000-2004,2011,2014 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 // mdsclient - friendly interface to CDSA MDS API
21 //
22 // It is useful to think of the mdsclient interface as "slightly below" the
23 // rest of the cdsa_client layer. It does not actually call into CSSM (we
24 // consider MDS as a separate facility, "slightly lower" than CSSM as well).
25 // This means that you can use mdsclient without creating a binary dependency
26 // on CSSM, and thus Security.framework.
27 //
28
29 #ifndef _H_CDSA_CLIENT_MDSCLIENT
30 #define _H_CDSA_CLIENT_MDSCLIENT
31
32 #include <security_utilities/threading.h>
33 #include <security_utilities/globalizer.h>
34 #include <security_utilities/refcount.h>
35 #include <security_cdsa_utilities/cssmalloc.h>
36 #include <security_cdsa_utilities/cssmpods.h>
37 #include <security_cdsa_utilities/cssmerrors.h>
38 #include <security_cdsa_utilities/cssmdb.h>
39 #include <security_cdsa_client/dliterators.h>
40 #include <Security/mdspriv.h>
41 #include <Security/mds_schema.h>
42
43
44 namespace Security {
45 namespace MDSClient {
46
47 // import query sublanguage classes into MDSClient namespace
48 using CssmClient::Attribute;
49 using CssmClient::Query;
50 using CssmClient::Record;
51 using CssmClient::Table;
52
53
54 //
55 // A singleton for the MDS itself.
56 // This is automatically created as a ModuleNexus when needed.
57 // You can reset() it to release resources.
58 // Don't make your own.
59 //
60 class Directory : public MDS_FUNCS, public CssmClient::DLAccess {
61 public:
62 Directory();
63 virtual ~Directory();
64
65 MDS_HANDLE mds() const { return mCDSA.DLHandle; }
66 const MDS_DB_HANDLE &cdsa() const;
67
68 public:
69 CSSM_HANDLE dlGetFirst(const CSSM_QUERY &query,
70 CSSM_DB_RECORD_ATTRIBUTE_DATA &attributes, CSSM_DATA *data,
71 CSSM_DB_UNIQUE_RECORD *&id);
72 bool dlGetNext(CSSM_HANDLE handle,
73 CSSM_DB_RECORD_ATTRIBUTE_DATA &attributes, CSSM_DATA *data,
74 CSSM_DB_UNIQUE_RECORD *&id);
75 void dlAbortQuery(CSSM_HANDLE handle);
76 void dlFreeUniqueId(CSSM_DB_UNIQUE_RECORD *id);
77 void dlDeleteRecord(CSSM_DB_UNIQUE_RECORD *id);
78 Allocator &allocator();
79
80 public:
81 // not for ordinary use - system administration only
82 void install(); // system default install/regenerate
83 void install(const MDS_InstallDefaults *defaults, // defaults
84 const char *path, // path to bundle (NULL -> main)
85 const char *subdir = NULL, // subdirectory in Resources (NULL -> all)
86 const char *file = NULL); // individual file (NULL -> all)
87 void uninstall(const char *guid, uint32 ssid);
88
89 private:
90 mutable MDS_DB_HANDLE mCDSA; // CDSA database handle
91 mutable Mutex mInitLock; // interlock for lazy DB open
92 CssmAllocatorMemoryFunctions mMemoryFunctions;
93 Guid mCallerGuid; //@@@ fake/unused
94 };
95
96 extern ModuleNexus<Directory> mds;
97
98
99 } // end namespace MDSClient
100 } // end namespace Security
101
102 #endif // _H_CDSA_CLIENT_MDSCLIENT