~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Lee Bieber
  • Date: 2011-02-19 20:47:11 UTC
  • mfrom: (2184.1.2 build)
  • Revision ID: kalebral@gmail.com-20110219204711-qk96sijgwdt03kyq
Merge Marisa - adds logo references to the include file
Merge Monty - some randome clean up stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
308
308
fs::path system_config_dir(SYSCONFDIR);
309
309
 
310
310
 
311
 
DRIZZLED_API char glob_hostname[FN_REFLEN];
312
 
 
313
311
char *opt_tc_log_file;
314
312
const key_map key_map_empty(0);
315
313
key_map key_map_full(0);                        // Will be initialized later
371
369
 
372
370
fs::path base_plugin_dir(PKGPLUGINDIR);
373
371
 
374
 
po::options_description config_options("Config File Options");
375
 
po::options_description long_options("Kernel Options");
376
 
po::options_description plugin_load_options("Plugin Loading Options");
377
 
po::options_description plugin_options("Plugin Options");
378
 
po::options_description initial_options("Config and Plugin Loading");
379
 
po::options_description full_options("Kernel and Plugin Loading and Plugin");
 
372
po::options_description config_options(_("Config File Options"));
 
373
po::options_description long_options(_("Kernel Options"));
 
374
po::options_description plugin_load_options(_("Plugin Loading Options"));
 
375
po::options_description plugin_options(_("Plugin Options"));
 
376
po::options_description initial_options(_("Config and Plugin Loading"));
 
377
po::options_description full_options(_("Kernel and Plugin Loading and Plugin"));
380
378
vector<string> unknown_options;
381
379
vector<string> defaults_file_list;
382
380
po::variables_map vm;
386
384
  return vm;
387
385
}
388
386
 
 
387
namespace
 
388
{
 
389
 
 
390
std::string &getGlobHostname()
 
391
{
 
392
  static std::string glob_hostname("localhost");
 
393
  return glob_hostname;
 
394
}
 
395
 
 
396
void setServerHostname(const std::string &hostname)
 
397
{
 
398
  getGlobHostname()= hostname;
 
399
}
 
400
}
 
401
 
 
402
const std::string &getServerHostname()
 
403
{
 
404
  return getGlobHostname();
 
405
}
389
406
 
390
407
/****************************************************************************
391
408
** Code to end drizzled
651
668
 
652
669
static void find_plugin_dir(string progname)
653
670
{
654
 
  if (progname[0] != FN_LIBCHAR)
655
 
  {
656
 
    /* We have a relative path and need to find the absolute */
657
 
    char working_dir[FN_REFLEN];
658
 
    char *working_dir_ptr= working_dir;
659
 
    working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
660
 
    string new_path(working_dir);
661
 
    if (*(new_path.end()-1) != '/')
662
 
      new_path.push_back('/');
663
 
    if (progname[0] == '.' && progname[1] == '/')
664
 
      new_path.append(progname.substr(2));
665
 
    else
666
 
      new_path.append(progname);
667
 
    progname.swap(new_path);
668
 
  }
669
 
 
670
 
  /* Now, trim off the exe name */
671
 
  string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
672
 
  if (progdir.rfind(".libs/") != string::npos)
673
 
  {
674
 
    progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
675
 
  }
676
 
  string testlofile(progdir);
677
 
  testlofile.append("drizzled.lo");
678
 
  string testofile(progdir);
679
 
  testofile.append("drizzled.o");
680
 
  struct stat testfile_stat;
681
 
  if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
 
671
  fs::path full_progname(fs::system_complete(progname));
 
672
 
 
673
  fs::path progdir(full_progname.parent_path());
 
674
  if (progdir.filename() == ".libs")
 
675
  {
 
676
    progdir= progdir.parent_path();
 
677
  }
 
678
 
 
679
  if (fs::exists(progdir / "drizzled.lo") || fs::exists(progdir / "drizzled.o"))
682
680
  {
683
681
    /* We are in a source dir! Plugin dir is ../plugin/.libs */
684
 
    size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
685
 
    base_plugin_dir= progdir.substr(0,last_libchar_pos);
 
682
    base_plugin_dir= progdir.parent_path();
686
683
    base_plugin_dir /= "plugin";
687
684
    base_plugin_dir /= ".libs";
688
685
  }
1106
1103
  */
1107
1104
  global_system_variables.time_zone= my_tz_SYSTEM;
1108
1105
 
1109
 
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
 
1106
  char ret_hostname[FN_REFLEN];
 
1107
  if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
1110
1108
  {
1111
 
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1112
 
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
1113
 
                  glob_hostname);
 
1109
    errmsg_printf(error::WARN,
 
1110
                  _("gethostname failed, using '%s' as hostname"),
 
1111
                  getServerHostname().c_str());
1114
1112
    pid_file= "drizzle";
1115
1113
  }
1116
1114
  else
1117
1115
  {
1118
 
    pid_file= glob_hostname;
 
1116
    setServerHostname(ret_hostname);
 
1117
    pid_file= getServerHostname();
1119
1118
  }
1120
1119
  pid_file.replace_extension(".pid");
1121
1120