]> git.saurik.com Git - apple/security.git/blame - cdsa/cssm/modloader.cpp
Security-177.tar.gz
[apple/security.git] / cdsa / cssm / modloader.cpp
CommitLineData
bac41a7b
A
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// cssm module loader interface - MACOS X (CFBundle/DYLD) version.
21//
22// This file provides a C++-style interface to CFBundles as managed by the CF-style
23// system interfaces. The implementation looks a bit, well, hybrid - but the visible
24// interfaces are pure C++.
25//
26#include "modloader.h"
27#include "modload_plugin.h"
28
29#if defined(BUILTIN_PLUGINS)
30# include "modload_static.h"
31# include "AppleCSP/AppleCSP/AppleCSP.h"
32# include "AppleCSPDL/CSPDLPlugin.h"
33# include "AppleDL/AppleFileDL.h"
34# include "AppleX509CL/AppleX509CL.h"
35# include "AppleX509TP/AppleTP.h"
36#endif //BUILTIN_PLUGINS
37
38
39namespace Security {
40
41
42//
43// Construct a ModuleLoader object.
44//
45ModuleLoader::ModuleLoader()
46{
47#if defined(BUILTIN_PLUGINS)
48 mPlugins["*AppleCSP"] = new StaticPlugin<AppleCSPPlugin>;
49 mPlugins["*AppleDL"] = new StaticPlugin<AppleFileDL>;
50 mPlugins["*AppleCSPDL"] = new StaticPlugin<CSPDLPlugin>;
51 mPlugins["*AppleX509CL"] = new StaticPlugin<AppleX509CL>;
52 mPlugins["*AppleX509TP"] = new StaticPlugin<AppleTP>;
53#endif //BUILTIN_PLUGINS
54}
55
56
57//
58// "Load" a plugin, given its MDS path. At this layer, we are performing
59// a purely physical load operation. No code in the plugin is called.
60// If "built-in plugins" are enabled, the moduleTable will come pre-initialized
61// with certain paths. Since we consult this table before going to disk, this
62// means that we'll pick these up first *as long as the paths match exactly*.
63// There is nothing magical in the path strings themselves, other than by
64// convention.
65//
66Plugin *ModuleLoader::operator () (const char *path)
67{
68 Plugin * &plugin = mPlugins[path];
69 if (!plugin)
70 plugin = new LoadablePlugin(path);
71 return plugin;
72}
73
74
75} // end namespace Security