2 * Copyright (c) 2000-2004,2011,2014 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 // mdsclient - friendly interface to CDSA MDS API
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.
29 #ifndef _H_CDSA_CLIENT_MDSCLIENT
30 #define _H_CDSA_CLIENT_MDSCLIENT
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>
47 // import query sublanguage classes into MDSClient namespace
48 using CssmClient::Attribute
;
49 using CssmClient::Query
;
50 using CssmClient::Record
;
51 using CssmClient::Table
;
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.
60 class Directory
: public MDS_FUNCS
, public CssmClient::DLAccess
{
65 MDS_HANDLE
mds() const { return mCDSA
.DLHandle
; }
66 const MDS_DB_HANDLE
&cdsa() const;
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();
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
);
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
96 extern ModuleNexus
<Directory
> mds
;
99 } // end namespace MDSClient
100 } // end namespace Security
102 #endif // _H_CDSA_CLIENT_MDSCLIENT