13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
27
27
#include <boost/program_options.hpp>
29
#include "drizzled/option.h"
30
#include "drizzled/internal/m_string.h"
29
#include <drizzled/option.h>
30
#include <drizzled/internal/m_string.h>
32
#include "drizzled/plugin.h"
33
#include "drizzled/module/load_list.h"
34
#include "drizzled/module/library.h"
35
#include "drizzled/module/registry.h"
36
#include "drizzled/module/option_context.h"
37
#include "drizzled/sql_parse.h"
38
#include "drizzled/show.h"
39
#include "drizzled/cursor.h"
40
#include "drizzled/set_var.h"
41
#include "drizzled/session.h"
42
#include "drizzled/item/null.h"
43
#include "drizzled/error.h"
44
#include "drizzled/gettext.h"
45
#include "drizzled/errmsg_print.h"
46
#include "drizzled/strfunc.h"
47
#include "drizzled/pthread_globals.h"
48
#include "drizzled/util/tokenize.h"
32
#include <drizzled/plugin.h>
33
#include <drizzled/module/load_list.h>
34
#include <drizzled/module/library.h>
35
#include <drizzled/module/registry.h>
36
#include <drizzled/module/option_context.h>
37
#include <drizzled/sql_parse.h>
38
#include <drizzled/show.h>
39
#include <drizzled/cursor.h>
40
#include <drizzled/set_var.h>
41
#include <drizzled/session.h>
42
#include <drizzled/item/null.h>
43
#include <drizzled/error.h>
44
#include <drizzled/gettext.h>
45
#include <drizzled/errmsg_print.h>
46
#include <drizzled/pthread_globals.h>
47
#include <drizzled/util/tokenize.h>
48
#include <drizzled/system_variables.h>
50
50
#include <boost/foreach.hpp>
126
typedef boost::unordered_map<string, Bookmark> bookmark_unordered_map;
127
static bookmark_unordered_map bookmark_hash;
132
static void plugin_prune_list(vector<string> &plugin_list,
133
const vector<string> &plugins_to_remove);
111
static void plugin_prune_list(vector<string> &plugin_list, const vector<string> &plugins_to_remove);
134
112
static bool plugin_load_list(module::Registry ®istry,
135
113
memory::Root *tmp_root,
136
114
const set<string> &plugin_list,
137
115
po::options_description &long_options,
138
116
bool builtin= false);
139
static int test_plugin_options(memory::Root *, module::Module *,
140
po::options_description &long_options);
117
static int test_plugin_options(memory::Root*, module::Module*, po::options_description&long_options);
141
118
static void unlock_variables(Session *session, drizzle_system_variables *vars);
142
119
static void cleanup_variables(drizzle_system_variables *vars);
184
tmp= new (std::nothrow) module::Module(manifest, library);
160
module::Module* tmp= new module::Module(manifest, library);
188
162
if (!test_plugin_options(tmp_root, tmp, long_options))
199
173
static void reap_plugins(module::Registry ®istry)
201
std::map<std::string, module::Module *>::const_iterator modules=
202
registry.getModulesMap().begin();
204
while (modules != registry.getModulesMap().end())
206
module::Module *module= (*modules).second;
175
BOOST_FOREACH(module::Registry::ModuleMap::const_reference module, registry.getModulesMap())
176
delete module.second;
229
196
module->isInited= true;
236
inline static void dashes_to_underscores(std::string &name_in,
237
char from= '-', char to= '_')
239
for (string::iterator p= name_in.begin();
250
inline static void underscores_to_dashes(std::string &name_in)
252
return dashes_to_underscores(name_in, '_', '-');
255
200
static void compose_plugin_options(vector<string> &target,
256
201
vector<string> options)
258
for (vector<string>::iterator it= options.begin();
262
tokenize(*it, target, ",", true);
264
for (vector<string>::iterator it= target.begin();
268
dashes_to_underscores(*it);
203
BOOST_FOREACH(vector<string>::reference it, options)
204
tokenize(it, target, ",", true);
205
BOOST_FOREACH(vector<string>::reference it, target)
206
std::replace(it.begin(), it.end(), '-', '_');
272
209
void compose_plugin_add(vector<string> options)
294
231
bool plugin_init(module::Registry ®istry,
295
232
po::options_description &long_options)
297
memory::Root tmp_root(4096);
304
239
PluginOptions builtin_load_list;
305
240
tokenize(builtin_load_plugins, builtin_load_list, ",", true);
371
306
Now we initialize all remaining plugins
373
module::Registry::ModuleList module_list= registry.getList();
374
module::Registry::ModuleList::iterator modules= module_list.begin();
376
while (modules != module_list.end())
308
BOOST_FOREACH(module::Registry::ModuleList::const_reference module, registry.getList())
378
module::Module *module= *modules;
380
if (module->isInited == false)
310
if (not module->isInited && plugin_initialize(registry, module))
382
if (plugin_initialize(registry, module))
384
registry.remove(module);
312
registry.remove(module);
392
317
BOOST_FOREACH(plugin::Plugin::map::value_type value, registry.getPluginsMap())
394
319
value.second->prime();
448
372
po::options_description &long_options,
451
module::Library *library= NULL;
453
for (set<string>::const_iterator iter= plugin_list.begin();
454
iter != plugin_list.end();
375
BOOST_FOREACH(const string& plugin_name, plugin_list)
457
const string plugin_name(*iter);
459
library= registry.addLibrary(plugin_name, builtin);
377
module::Library* library= registry.addLibrary(plugin_name, builtin);
460
378
if (library == NULL)
462
380
errmsg_printf(error::ERROR,