]> git.saurik.com Git - apple/security.git/blob - cdsa/cssm/modload_plugin.h
Security-54.1.tar.gz
[apple/security.git] / cdsa / cssm / modload_plugin.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 // modload_plugin - loader interface for dynamically loaded plugin modules
21 //
22 #ifndef _H_MODLOAD_PLUGIN
23 #define _H_MODLOAD_PLUGIN
24
25 #include "modloader.h"
26
27
28 namespace Security {
29
30
31 //
32 // A LoadablePlugin implements itself as a LoadableBundle
33 //
34 class LoadablePlugin : public Plugin, public CodeSigning::LoadableBundle {
35 public:
36 LoadablePlugin(const char *path);
37
38 void load();
39 void unload();
40 bool isLoaded() const;
41
42 CSSM_RETURN CSSM_SPI_ModuleLoad (const CSSM_GUID *CssmGuid,
43 const CSSM_GUID *ModuleGuid,
44 CSSM_SPI_ModuleEventHandler CssmNotifyCallback,
45 void *CssmNotifyCallbackCtx)
46 { return fLoad(CssmGuid, ModuleGuid, CssmNotifyCallback, CssmNotifyCallbackCtx); }
47
48 CSSM_RETURN CSSM_SPI_ModuleUnload (const CSSM_GUID *CssmGuid,
49 const CSSM_GUID *ModuleGuid,
50 CSSM_SPI_ModuleEventHandler CssmNotifyCallback,
51 void *CssmNotifyCallbackCtx)
52 { return fUnload(CssmGuid, ModuleGuid, CssmNotifyCallback, CssmNotifyCallbackCtx); }
53
54 CSSM_RETURN CSSM_SPI_ModuleAttach (const CSSM_GUID *ModuleGuid,
55 const CSSM_VERSION *Version,
56 uint32 SubserviceID,
57 CSSM_SERVICE_TYPE SubServiceType,
58 CSSM_ATTACH_FLAGS AttachFlags,
59 CSSM_MODULE_HANDLE ModuleHandle,
60 CSSM_KEY_HIERARCHY KeyHierarchy,
61 const CSSM_GUID *CssmGuid,
62 const CSSM_GUID *ModuleManagerGuid,
63 const CSSM_GUID *CallerGuid,
64 const CSSM_UPCALLS *Upcalls,
65 CSSM_MODULE_FUNCS_PTR *FuncTbl)
66 {
67 return fAttach(ModuleGuid, Version, SubserviceID, SubServiceType,
68 AttachFlags, ModuleHandle, KeyHierarchy, CssmGuid,
69 ModuleManagerGuid, CallerGuid, Upcalls, FuncTbl);
70 }
71
72 CSSM_RETURN CSSM_SPI_ModuleDetach (CSSM_MODULE_HANDLE ModuleHandle)
73 { return fDetach(ModuleHandle); }
74
75 private:
76 CSSM_SPI_ModuleLoadFunction *fLoad;
77 CSSM_SPI_ModuleAttachFunction *fAttach;
78 CSSM_SPI_ModuleDetachFunction *fDetach;
79 CSSM_SPI_ModuleUnloadFunction *fUnload;
80
81 template <class FunctionType>
82 void findFunction(FunctionType * &func, const char *name)
83 { func = (FunctionType *)lookupSymbol(name); }
84 };
85
86
87 } // end namespace Security
88
89
90 #endif //_H_MODLOAD_PLUGIN