#pragma once
/*
 * Copyright (c) 2016 MariaDB Corporation Ab
 *
 * Use of this software is governed by the Business Source License included
 * in the LICENSE.TXT file and at www.mariadb.com/bsl11.
 *
 * Change Date: 2020-01-01
 *
 * On the date above, in accordance with the Business Source License, use
 * of this software will be governed by version 2 or later of the General
 * Public License.
 */

#include <maxscale/cdefs.h>
#include <stdlib.h>
#include <string.h>

MXS_BEGIN_DECLS

/**
 * All of the following DEFAULT_* variables are defined in cmake/install_layout.cmake
 */
#define MXS_DEFAULT_PID_SUBPATH    "@DEFAULT_PID_SUBPATH@"
#define MXS_DEFAULT_LOG_SUBPATH    "@DEFAULT_LOG_SUBPATH@"
#define MXS_DEFAULT_DATA_SUBPATH   "@DEFAULT_DATA_SUBPATH@"
#define MXS_DEFAULT_LIB_SUBPATH    "@DEFAULT_LIB_SUBPATH@"
#define MXS_DEFAULT_CACHE_SUBPATH  "@DEFAULT_CACHE_SUBPATH@"
#define MXS_DEFAULT_LANG_SUBPATH   "@DEFAULT_LANG_SUBPATH@"
#define MXS_DEFAULT_EXEC_SUBPATH   "@DEFAULT_EXEC_SUBPATH@"
#define MXS_DEFAULT_CONFIG_SUBPATH "@DEFAULT_CONFIG_SUBPATH@"
#define MXS_DEFAULT_CONFIG_PERSIST_SUBPATH "@DEFAULT_CONFIG_PERSIST_SUBPATH@"
#define MXS_DEFAULT_MODULE_CONFIG_SUBPATH "@DEFAULT_MODULE_CONFIG_SUBPATH@"
#define MXS_DEFAULT_CONNECTOR_PLUGIN_SUBPATH "@DEFAULT_CONNECTOR_PLUGIN_SUBPATH@"

/** Default file locations, configured by CMake */
#define MXS_DEFAULT_CONFIGDIR         "@DEFAULT_CONFIGDIR@"
#define MXS_DEFAULT_PIDDIR            "@DEFAULT_PIDDIR@"
#define MXS_DEFAULT_LOGDIR            "@DEFAULT_LOGDIR@"
#define MXS_DEFAULT_DATADIR           "@DEFAULT_DATADIR@"
#define MXS_DEFAULT_LIBDIR            "@DEFAULT_LIBDIR@"
#define MXS_DEFAULT_CACHEDIR          "@DEFAULT_CACHEDIR@"
#define MXS_DEFAULT_LANGDIR           "@DEFAULT_LANGDIR@"
#define MXS_DEFAULT_EXECDIR           "@DEFAULT_EXECDIR@"
#define MXS_DEFAULT_CONFIG_PERSISTDIR "@DEFAULT_CONFIG_PERSISTDIR@"
#define MXS_DEFAULT_MODULE_CONFIGDIR  "@DEFAULT_MODULE_CONFIGDIR@"
#define MXS_DEFAULT_CONNECTOR_PLUGINDIR "@DEFAULT_CONNECTOR_PLUGINDIR@"

static const char* default_cnf_fname = "maxscale.cnf";
static const char* default_configdir = MXS_DEFAULT_CONFIGDIR;

/*< This should be changed to just /run eventually,
 * the /var/run folder is an old standard and the newer FSH 3.0
 * uses /run for PID files.*/
static const char* default_piddir   = MXS_DEFAULT_PIDDIR;
static const char* default_logdir   = MXS_DEFAULT_LOGDIR;
static const char* default_datadir  = MXS_DEFAULT_DATADIR;
static const char* default_libdir   = MXS_DEFAULT_LIBDIR;
static const char* default_cachedir = MXS_DEFAULT_CACHEDIR;
static const char* default_langdir  = MXS_DEFAULT_LANGDIR;
static const char* default_execdir  = MXS_DEFAULT_EXECDIR;
static const char* default_config_persistdir = MXS_DEFAULT_CONFIG_PERSISTDIR;
static const char* default_module_configdir = MXS_DEFAULT_MODULE_CONFIGDIR;
static const char* default_connector_plugindir  = MXS_DEFAULT_CONNECTOR_PLUGINDIR;

static char* configdir = NULL; /*< Where the config file is found e.g. /etc/ */
static char* config_persistdir = NULL;/*< Persisted configs e.g. /var/lib/maxscale/maxscale.cnf.d/ */
static char* module_configdir = NULL;/*< Module specific configs e.g. /var/lib/maxscale/ */
static char* logdir = NULL;
static char* libdir = NULL;
static char* cachedir = NULL;
static char* maxscaledatadir = NULL; /*< The data directory */
static char* processdatadir = NULL; /*< Process specific data directory */
static char* langdir = NULL;
static char* piddir = NULL;
static char* execdir = NULL;
static char* connector_plugindir = NULL;

void set_libdir(char* param);
void set_datadir(char* param);
void set_process_datadir(char* param);
void set_cachedir(char* param);
void set_configdir(char* param);
void set_config_persistdir(char* param);
void set_module_configdir(char* param);
void set_logdir(char* param);
void set_langdir(char* param);
void set_piddir(char* param);
void set_execdir(char* param);
void set_connector_plugindir(char* param);
char* get_libdir();
char* get_datadir();
char* get_process_datadir();
char* get_cachedir();
char* get_configdir();
char* get_config_persistdir();
char* get_module_configdir();
char* get_piddir();
char* get_logdir();
char* get_langdir();
char* get_execdir();
char* get_connector_plugindir();

MXS_END_DECLS
