1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems, Inc.
4
* Copyright (C) 2009 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
78
78
size_t found= plugin_name.find(FN_LIBCHAR);
79
79
if (found != string::npos)
81
errmsg_printf(error::ERROR, "%s",ER(ER_PLUGIN_NO_PATHS));
81
errmsg_printf(ERRMSG_LVL_ERROR, "%s",ER(ER_PLUGIN_NO_PATHS));
85
void *dl_handle= NULL;
90
90
dlpath.assign("<builtin>");
91
dl_handle= dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
92
if (dl_handle == NULL)
91
handle= dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
94
94
const char *errmsg= dlerror();
95
errmsg_printf(error::ERROR, ER(ER_CANT_OPEN_LIBRARY),
95
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_OPEN_LIBRARY),
96
96
dlpath.c_str(), errno, errmsg);
104
104
/* Open new dll handle */
105
105
dlpath.assign(Library::getLibraryPath(plugin_name).file_string());
106
dl_handle= dlopen(dlpath.c_str(), RTLD_NOW|RTLD_GLOBAL);
107
if (dl_handle == NULL)
106
handle= dlopen(dlpath.c_str(), RTLD_NOW|RTLD_GLOBAL);
109
109
const char *errmsg= dlerror();
110
110
uint32_t dlpathlen= dlpath.length();
114
114
if (*errmsg == ':') errmsg++;
115
115
if (*errmsg == ' ') errmsg++;
117
errmsg_printf(error::ERROR, ER(ER_CANT_OPEN_LIBRARY),
117
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_OPEN_LIBRARY),
118
118
dlpath.c_str(), errno, errmsg);
120
120
// This, in theory, should cause dlerror() to deallocate the error
130
130
plugin_decl_sym.append("_plugin_");
132
132
/* Find plugin declarations */
133
void *sym= dlsym(dl_handle, plugin_decl_sym.c_str());
133
void *sym= dlsym(handle, plugin_decl_sym.c_str());
136
136
const char* errmsg= dlerror();
137
errmsg_printf(error::ERROR, errmsg);
138
errmsg_printf(error::ERROR, ER(ER_CANT_FIND_DL_ENTRY),
137
errmsg_printf(ERRMSG_LVL_ERROR, errmsg);
138
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY),
139
139
plugin_decl_sym.c_str(), dlpath.c_str());
145
const Manifest *module_manifest= static_cast<module::Manifest *>(sym);
146
if (module_manifest->drizzle_version != DRIZZLE_VERSION_ID)
145
const Manifest *manifest= static_cast<module::Manifest *>(sym);
146
if (manifest->drizzle_version != DRIZZLE_VERSION_ID)
148
errmsg_printf(error::ERROR,
148
errmsg_printf(ERRMSG_LVL_ERROR,
149
149
_("Plugin module %s was compiled for version %" PRIu64 ", "
150
150
"which does not match the current running version of "
151
151
"Drizzle: %" PRIu64"."),
152
dlpath.c_str(), module_manifest->drizzle_version,
153
static_cast<uint64_t>(DRIZZLE_VERSION_ID));
152
dlpath.c_str(), manifest->drizzle_version,
157
return new (nothrow) module::Library(plugin_name, dl_handle, module_manifest);
157
return new (nothrow) module::Library(plugin_name, handle, manifest);
160
160
} /* namespace drizzled */