41
41
#include "drizzled/plugin/library.h"
42
42
#include "drizzled/strfunc.h"
43
43
#include "drizzled/pthread_globals.h"
44
#include "drizzled/util/tokenize.h"
45
46
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
64
65
static vector<sys_var_pluginvar *> plugin_sysvar_vec;
66
67
char *opt_plugin_add= NULL;
68
char *opt_plugin_remove= NULL;
67
69
char *opt_plugin_load= NULL;
68
70
char *opt_plugin_dir_ptr;
69
71
char opt_plugin_dir[FN_REFLEN];
153
static void plugin_prune_list(vector<string> &plugin_list,
154
const vector<string> &plugins_to_remove);
151
155
static bool plugin_load_list(plugin::Registry ®istry,
152
156
memory::Root *tmp_root, int *argc, char **argv,
157
const vector<string> &plugin_list);
154
158
static int test_plugin_options(memory::Root *, plugin::Module *,
156
160
static void unlock_variables(Session *session, struct system_variables *vars);
434
438
bool load_failed= false;
439
vector<string> plugin_list;
442
tokenize(opt_plugin_load, plugin_list, ",", true);
446
tokenize(opt_plugin_load_default, plugin_list, ",", true);
450
tokenize(opt_plugin_add, plugin_list, ",", true);
453
if (opt_plugin_remove)
455
vector<string> plugins_to_remove;
456
tokenize(opt_plugin_remove, plugins_to_remove, ",", true);
457
plugin_prune_list(plugin_list, plugins_to_remove);
435
460
/* Register all dynamic plugins */
438
load_failed= plugin_load_list(registry, &tmp_root, argc, argv,
443
string tmp_plugin_list(opt_plugin_load_default);
446
tmp_plugin_list.push_back(',');
447
tmp_plugin_list.append(opt_plugin_add);
449
load_failed= plugin_load_list(registry, &tmp_root, argc, argv,
461
load_failed= plugin_load_list(registry, &tmp_root, argc, argv,
454
465
free_root(&tmp_root, MYF(0));
501
public unary_function<string, bool>
503
const string to_match;
505
PrunePlugin& operator=(const PrunePlugin&);
507
explicit PrunePlugin(const string &match_in) :
511
result_type operator()(const string &match_against)
513
return match_against == to_match;
517
static void plugin_prune_list(vector<string> &plugin_list,
518
const vector<string> &plugins_to_remove)
520
for (vector<string>::const_iterator iter= plugins_to_remove.begin();
521
iter != plugins_to_remove.end();
524
plugin_list.erase(remove_if(plugin_list.begin(),
492
532
called only by plugin_init()
494
534
static bool plugin_load_list(plugin::Registry ®istry,
495
535
memory::Root *tmp_root, int *argc, char **argv,
536
const vector<string> &plugin_list)
498
538
plugin::Library *library= NULL;
500
const string DELIMITER(",");
501
string::size_type last_pos= plugin_list.find_first_not_of(DELIMITER);
502
string::size_type pos= plugin_list.find_first_of(DELIMITER, last_pos);
503
while (string::npos != pos || string::npos != last_pos)
540
for (vector<string>::const_iterator iter= plugin_list.begin();
541
iter != plugin_list.end();
505
const string plugin_name(plugin_list.substr(last_pos, pos - last_pos));
544
const string plugin_name(*iter);
507
545
library= registry.addLibrary(plugin_name);
508
546
if (library == NULL)