]> git.saurik.com Git - apple/security.git/blob - libsecurity_cdsa_plugin/lib/pluginspi.h
Security-55163.44.tar.gz
[apple/security.git] / libsecurity_cdsa_plugin / lib / pluginspi.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 // pluginspi - "roof" level entry points into a CSSM plugin.
21 //
22 // This file is meant to be included into the top-level source file
23 // for a CSSM plugin written to the C++ alternate interface.
24 // It contains actual code that defines the four required entry points.
25 //
26 #include <security_cdsa_utilities/cssmbridge.h>
27
28
29 //
30 // Provide some flexibility for the includer
31 //
32 #if !defined(SPIPREFIX)
33 # define SPIPREFIX extern "C" CSSMSPI
34 #endif
35
36 #if !defined(SPINAME)
37 # define SPINAME(s) s
38 #endif
39
40
41 SPIPREFIX CSSM_RETURN SPINAME(CSSM_SPI_ModuleLoad) (const CSSM_GUID *CssmGuid,
42 const CSSM_GUID *ModuleGuid,
43 CSSM_SPI_ModuleEventHandler CssmNotifyCallback,
44 void *CssmNotifyCallbackCtx)
45 {
46 BEGIN_API
47 plugin().moduleLoad(Guid::required(CssmGuid),
48 Guid::required(ModuleGuid),
49 ModuleCallback(CssmNotifyCallback, CssmNotifyCallbackCtx));
50 END_API(CSSM)
51 }
52
53 SPIPREFIX CSSM_RETURN SPINAME(CSSM_SPI_ModuleUnload) (const CSSM_GUID *CssmGuid,
54 const CSSM_GUID *ModuleGuid,
55 CSSM_SPI_ModuleEventHandler CssmNotifyCallback,
56 void *CssmNotifyCallbackCtx)
57 {
58 BEGIN_API
59 plugin().moduleUnload(Guid::required(CssmGuid),
60 Guid::required(ModuleGuid),
61 ModuleCallback(CssmNotifyCallback, CssmNotifyCallbackCtx));
62 END_API(CSSM)
63 }
64
65 SPIPREFIX CSSM_RETURN SPINAME(CSSM_SPI_ModuleAttach) (const CSSM_GUID *ModuleGuid,
66 const CSSM_VERSION *Version,
67 uint32 SubserviceID,
68 CSSM_SERVICE_TYPE SubServiceType,
69 CSSM_ATTACH_FLAGS AttachFlags,
70 CSSM_MODULE_HANDLE ModuleHandle,
71 CSSM_KEY_HIERARCHY KeyHierarchy,
72 const CSSM_GUID *CssmGuid,
73 const CSSM_GUID *ModuleManagerGuid,
74 const CSSM_GUID *CallerGuid,
75 const CSSM_UPCALLS *Upcalls,
76 CSSM_MODULE_FUNCS_PTR *FuncTbl)
77 {
78 BEGIN_API
79 plugin().moduleAttach(ModuleHandle,
80 Guid::required(CssmGuid),
81 Guid::required(ModuleGuid),
82 Guid::required(ModuleManagerGuid),
83 Guid::required(CallerGuid),
84 *Version,
85 SubserviceID,
86 SubServiceType,
87 AttachFlags,
88 KeyHierarchy,
89 Required(Upcalls),
90 Required(FuncTbl));
91 END_API(CSSM)
92 }
93
94 SPIPREFIX CSSM_RETURN SPINAME(CSSM_SPI_ModuleDetach) (CSSM_MODULE_HANDLE ModuleHandle)
95 {
96 BEGIN_API
97 plugin().moduleDetach(ModuleHandle);
98 END_API(CSSM)
99 }