Moved default file search paths to gwdirs.h which is configured by CMake from gwdirs.h.in.

This commit is contained in:
Markus Makela
2015-04-27 04:48:50 +03:00
parent 17a7b2addb
commit c500d23d04
20 changed files with 198 additions and 221 deletions

View File

@ -505,15 +505,9 @@ static bool resolve_maxscale_conf_fname(
* directory.
* '-f MaxScale.cnf'
*/
home_etc_dir = (char*)malloc(strlen(home_dir)+strlen("/etc")+1);
snprintf(home_etc_dir,
strlen(home_dir)+strlen("/etc")+1,
"%s/etc",
home_dir);
*cnf_full_path = get_expanded_pathname(NULL,
home_etc_dir,
home_dir,
cnf_file_arg);
free(home_etc_dir);
if (*cnf_full_path != NULL)
{
@ -1026,11 +1020,11 @@ static void usage(void)
" -L|--logdir=... path to log file directory\n"
" (default: /var/log/maxscale)\n"
" -D|--datadir=... path to data directory\n"
" (default: /var/lib/maxscale)\n"
" (default: /usr/lib64/maxscale)\n"
" -C|--configdir=... path to configuration file directory\n"
" (default: /etc/)\n"
" -B|--libdir=... path to module directory\n"
" (default: /var/lib/maxscale)\n"
" -B|--libdir=... path to module directory\n"
" (default: /usr/lib64/maxscale)\n"
" -A|--cachedir=... path to cache directory\n"
" (default: /var/cache/maxscale)\n"
" -s|--syslog= log messages to syslog.\n"
@ -1588,63 +1582,6 @@ int main(int argc, char **argv)
sprintf(mysql_home, "%s/mysql", cachedir);
setenv("MYSQL_HOME", mysql_home, 1);
/*<
* If MaxScale home directory wasn't set by command-line argument.
* Next, resolve it from environment variable and further on,
* try to use default.
*/
/*
if (home_dir == NULL)
{
if (!resolve_maxscale_homedir(&home_dir))
{
ss_dassert(home_dir != NULL);
rc = MAXSCALE_HOMELESS;
goto return_main;
}
}
else
{
char* log_context = strdup("Home directory command-line argument");
char* errstr;
errstr = check_dir_access(home_dir,true,true);
if (errstr != NULL)
{
char* logstr = (char*)malloc(strlen(log_context)+
1+
strlen(errstr)+
1);
snprintf(logstr,
strlen(log_context)+
1+
strlen(errstr)+1,
"%s: %s",
log_context,
errstr);
print_log_n_stderr(true, true, logstr, logstr, 0);
free(errstr);
free(logstr);
rc = MAXSCALE_HOMELESS;
goto return_main;
}
else if (!daemon_mode)
{
fprintf(stderr,
"Using %s as MAXSCALE_HOME = %s\n",
log_context,
home_dir);
}
free(log_context);
}
*/
/**
* Resolve the full pathname for configuration file and check for
* read accessibility.

View File

@ -1,5 +1,25 @@
#ifndef _GW_HG
#define _GW_HG
/*
* This file is distributed as part of the MariaDB Corporation MaxScale. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright MariaDB Corporation Ab 2013-2014
*/
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
@ -19,17 +39,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdbool.h>
/** Default file locations */
static const char* default_cnf_fname = "MaxScale.cnf";
static const char* default_configdir = "/etc/";
static const char* default_logdir = "/var/log/maxscale/";
static const char* default_datadir = "/var/cache/maxscale/";
static const char* default_libdir = "/lib64/maxscale/";
static const char* default_cachedir = "/var/cache/maxscale/";
static const char* default_langdir = "/usr/share/mysql/english/"; /*< This is where the MariaDB
* server installs errmsg.sys */
static const char* default_piddir = "/var/run/maxscale/";
#include <gwdirs.h>
#define EXIT_FAILURE 1

View File

@ -0,0 +1,33 @@
#ifndef _GW_DIRS_HG
#define _GW_DIRS_HG
/*
* This file is distributed as part of the MariaDB Corporation MaxScale. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright MariaDB Corporation Ab 2015
*/
/** Default file locations, configured by CMake */
static const char* default_cnf_fname = "MaxScale.cnf";
static const char* default_configdir = "/etc/";
static const char* default_piddir = "/var/run/maxscale/";
static const char* default_logdir = "/var/log/maxscale/";
static const char* default_datadir = "/var/cache/maxscale/";
static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@";
static const char* default_cachedir = "/var/cache/maxscale/";
static const char* default_langdir = "/usr/share/mysql/english/"; /*< This is where the MariaDB
* server installs errmsg.sys */
#endif