~jaypipes/drizzle/bugs

« back to all changes in this revision

Viewing changes to drizzled/plugin/library.cc

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "drizzled/global.h"
 
20
#include "config.h"
21
21
 
22
22
#include <dlfcn.h>
23
23
 
 
24
#include <cerrno>
24
25
#include <string>
25
26
 
26
27
#include "drizzled/plugin.h"
34
35
namespace drizzled
35
36
{
36
37
 
37
 
static const char *plugin_declarations_sym= "_drizzled_plugin_declaration_";
38
 
 
39
38
plugin::Library::Library(const std::string &name_arg,
40
39
                         void *handle_arg,
41
40
                         const Manifest *manifest_arg)
94
93
  }
95
94
 
96
95
 
 
96
  string plugin_decl_sym("_drizzled_");
 
97
  plugin_decl_sym.append(plugin_name);
 
98
  plugin_decl_sym.append("_plugin_");
 
99
 
97
100
  /* Find plugin declarations */
98
 
  void *sym= dlsym(handle, plugin_declarations_sym);
 
101
  void *sym= dlsym(handle, plugin_decl_sym.c_str());
99
102
  if (sym == NULL)
100
103
  {
101
104
    const char* errmsg= dlerror();
102
105
    errmsg_printf(ERRMSG_LVL_ERROR, errmsg);
103
106
    errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY),
104
 
                  plugin_declarations_sym, dlpath.c_str());
 
107
                  plugin_decl_sym.c_str(), dlpath.c_str());
105
108
    (void)dlerror();
106
109
    dlclose(handle);
107
110
    return NULL;
108
111
  }
109
112
 
110
 
  const Manifest *manifest= reinterpret_cast<plugin::Manifest *>(sym); 
 
113
  const Manifest *manifest= static_cast<plugin::Manifest *>(sym); 
 
114
  if (manifest->drizzle_version != DRIZZLE_VERSION_ID)
 
115
  {
 
116
    errmsg_printf(ERRMSG_LVL_ERROR,
 
117
                  _("Plugin module %s was compiled for version %" PRIu64 ", "
 
118
                    "which does not match the current running version of "
 
119
                    "Drizzle: %" PRIu64"."),
 
120
                 dlpath.c_str(), manifest->drizzle_version,
 
121
                 DRIZZLE_VERSION_ID);
 
122
    return NULL;
 
123
  }
 
124
 
111
125
  return new (nothrow) plugin::Library(plugin_name, handle, manifest);
112
126
}
113
127