]> git.saurik.com Git - apple/security.git/blob - cdsa/cssm/cssmmds.h
Security-28.tar.gz
[apple/security.git] / cdsa / cssm / cssmmds.h
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 // cssmmds - MDS interface for CSSM & friends
21 //
22 #ifndef _H_CSSMMDS
23 #define _H_CSSMMDS
24
25 #include "cssmint.h"
26 #include <Security/globalizer.h>
27 #include <string>
28 #include <stdio.h> // @@@ for temporary MDS interface only
29
30 #ifdef _CPP_CSSMMDS
31 # pragma export on
32 #endif
33
34
35 class MdsComponent {
36 public:
37 MdsComponent(const Guid &guid);
38 virtual ~MdsComponent();
39
40 const Guid &myGuid() const { return mMyGuid; }
41
42 CSSM_SERVICE_MASK services() const { update(); return mServices; }
43 bool supportsService(CSSM_SERVICE_TYPE t) const { update(); return t & mServices; }
44 bool isThreadSafe() const { update(); return mIsThreadSafe; }
45 const char *path() const { update(); return mPath.c_str(); }
46
47 private:
48 const Guid mMyGuid; // GUID of the component
49
50 // information obtained about the component
51 mutable bool mIsValid; // information is valid
52 mutable string mPath; // module location
53 mutable CSSM_SERVICE_TYPE mServices; // service types provided
54 mutable bool mIsThreadSafe; // is the module thread safe?
55
56 void getInfo() const; // retrieve MDS information
57 void update() const { if (!mIsValid) getInfo(); }
58
59 private:
60 struct MDS {
61 MDS();
62 ~MDS();
63 FILE *config;
64 };
65 static ModuleNexus<MDS> mds;
66 };
67
68 #ifdef _CPP_CSSMMDS
69 # pragma export off
70 #endif
71
72
73 #endif //_H_CSSMMDS