~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_plugin.cc

  • Committer: Monty Taylor
  • Date: 2008-10-21 23:41:34 UTC
  • Revision ID: monty@inaugust.com-20081021234134-1md1um9m7fh9jxex
Removed stxnmov. Also deleted strstr which had already been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <configvar.h>
23
23
#include <qcache.h>
24
24
 
 
25
#include <string>
 
26
 
25
27
#include <drizzled/drizzled_error_messages.h>
26
28
 
27
29
#define REPORT_TO_LOG  1
30
32
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
31
33
#define plugin_int_to_ref(A) &(A)
32
34
 
 
35
using namespace std;
 
36
 
33
37
extern struct st_mysql_plugin *mysqld_builtins[];
34
38
 
35
39
char *opt_plugin_load= NULL;
324
328
 
325
329
static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
326
330
{
327
 
  char dlpath[FN_REFLEN];
328
 
  uint32_t plugin_dir_len, dummy_errors, dlpathlen;
 
331
  string dlpath;
 
332
  uint32_t plugin_dir_len, dummy_errors;
329
333
  struct st_plugin_dl *tmp, plugin_dl;
330
334
  void *sym;
331
335
  plugin_dir_len= strlen(opt_plugin_dir);
 
336
  dlpath.reserve(FN_REFLEN);
332
337
  /*
333
338
    Ensure that the dll doesn't have a path.
334
339
    This is done to ensure that only approved libraries from the
353
358
  }
354
359
  memset(&plugin_dl, 0, sizeof(plugin_dl));
355
360
  /* Compile dll path */
356
 
  dlpathlen=
357
 
    strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
358
 
    dlpath;
 
361
  dlpath.append(opt_plugin_dir);
 
362
  dlpath.append("/");
 
363
  dlpath.append(dl->str);
359
364
  plugin_dl.ref_count= 1;
360
365
  /* Open new dll handle */
361
 
  if (!(plugin_dl.handle= dlopen(dlpath, RTLD_LAZY|RTLD_GLOBAL)))
 
366
  if (!(plugin_dl.handle= dlopen(dlpath.c_str(), RTLD_LAZY|RTLD_GLOBAL)))
362
367
  {
363
368
    const char *errmsg=dlerror();
364
 
    if (!strncmp(dlpath, errmsg, dlpathlen))
 
369
    uint32_t dlpathlen= dlpath.length();
 
370
    if (!dlpath.compare(0, dlpathlen, errmsg))
365
371
    { // if errmsg starts from dlpath, trim this prefix.
366
372
      errmsg+=dlpathlen;
367
373
      if (*errmsg == ':') errmsg++;
368
374
      if (*errmsg == ' ') errmsg++;
369
375
    }
370
376
    if (report & REPORT_TO_USER)
371
 
      my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, errno, errmsg);
 
377
      my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath.c_str(), errno, errmsg);
372
378
    if (report & REPORT_TO_LOG)
373
 
      sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
 
379
      sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath.c_str(), errno, errmsg);
374
380
    return(0);
375
381
  }
376
382