2 * Copyright (c) 2000-2001 Apple Computer, 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 // modload_plugin - loader interface for dynamically loaded plugin modules
22 #ifndef _H_MODLOAD_PLUGIN
23 #define _H_MODLOAD_PLUGIN
25 #include "modloader.h"
32 // A LoadablePlugin implements itself as a LoadableBundle
34 class LoadablePlugin
: public Plugin
, public CodeSigning::LoadableBundle
{
36 LoadablePlugin(const char *path
);
40 bool isLoaded() const;
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
); }
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
); }
54 CSSM_RETURN
CSSM_SPI_ModuleAttach (const CSSM_GUID
*ModuleGuid
,
55 const CSSM_VERSION
*Version
,
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
)
67 return fAttach(ModuleGuid
, Version
, SubserviceID
, SubServiceType
,
68 AttachFlags
, ModuleHandle
, KeyHierarchy
, CssmGuid
,
69 ModuleManagerGuid
, CallerGuid
, Upcalls
, FuncTbl
);
72 CSSM_RETURN
CSSM_SPI_ModuleDetach (CSSM_MODULE_HANDLE ModuleHandle
)
73 { return fDetach(ModuleHandle
); }
76 CSSM_SPI_ModuleLoadFunction
*fLoad
;
77 CSSM_SPI_ModuleAttachFunction
*fAttach
;
78 CSSM_SPI_ModuleDetachFunction
*fDetach
;
79 CSSM_SPI_ModuleUnloadFunction
*fUnload
;
81 template <class FunctionType
>
82 void findFunction(FunctionType
* &func
, const char *name
)
83 { func
= (FunctionType
*)lookupSymbol(name
); }
87 } // end namespace Security
90 #endif //_H_MODLOAD_PLUGIN