summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CommandLine.cxx20
-rw-r--r--src/CommandLine.hxx7
-rw-r--r--src/Main.cxx10
3 files changed, 22 insertions, 15 deletions
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index f1d6d0020..d501d56e2 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 The Music Player Daemon Project
+ * Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
#include "ls.hxx"
#include "LogInit.hxx"
#include "Log.hxx"
-#include "config/Global.hxx"
+#include "config/File.hxx"
#include "decoder/DecoderList.hxx"
#include "decoder/DecoderPlugin.hxx"
#include "output/Registry.hxx"
@@ -292,7 +292,12 @@ static void help(void)
class ConfigLoader
{
+ ConfigData &config;
+
public:
+ explicit ConfigLoader(ConfigData &_config) noexcept
+ :config(_config) {}
+
bool TryFile(const Path path);
bool TryFile(const AllocatedPath &base_path, Path path);
};
@@ -300,7 +305,7 @@ public:
bool ConfigLoader::TryFile(Path path)
{
if (FileExists(path)) {
- ReadConfigFile(path);
+ ReadConfigFile(config, path);
return true;
}
return false;
@@ -315,7 +320,8 @@ bool ConfigLoader::TryFile(const AllocatedPath &base_path, Path path)
}
void
-ParseCommandLine(int argc, char **argv, struct options &options)
+ParseCommandLine(int argc, char **argv, struct options &options,
+ ConfigData &config)
{
bool use_config_file = true;
@@ -383,16 +389,16 @@ ParseCommandLine(int argc, char **argv, struct options &options)
if (result <= 0)
throw MakeLastError("MultiByteToWideChar() failed");
- ReadConfigFile(Path::FromFS(buffer));
+ ReadConfigFile(config, Path::FromFS(buffer));
#else
- ReadConfigFile(Path::FromFS(config_file));
+ ReadConfigFile(config, Path::FromFS(config_file));
#endif
return;
}
/* use default configuration file path */
- ConfigLoader loader;
+ ConfigLoader loader(config);
bool found =
#ifdef _WIN32
diff --git a/src/CommandLine.hxx b/src/CommandLine.hxx
index 2db067988..1a64aa7ef 100644
--- a/src/CommandLine.hxx
+++ b/src/CommandLine.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2017 The Music Player Daemon Project
+ * Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,8 @@
#ifndef MPD_COMMAND_LINE_HXX
#define MPD_COMMAND_LINE_HXX
+struct ConfigData;
+
struct options {
bool kill = false;
bool daemon = true;
@@ -28,6 +30,7 @@ struct options {
};
void
-ParseCommandLine(int argc, char **argv, struct options &options);
+ParseCommandLine(int argc, char **argv, struct options &options,
+ ConfigData &config);
#endif
diff --git a/src/Main.cxx b/src/Main.cxx
index 58eb328b4..ad160b2ae 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -52,7 +52,7 @@
#include "thread/Slack.hxx"
#include "net/Init.hxx"
#include "lib/icu/Init.hxx"
-#include "config/Global.hxx"
+#include "config/File.hxx"
#include "config/Check.hxx"
#include "config/Data.hxx"
#include "config/Param.hxx"
@@ -475,7 +475,7 @@ MainOrThrow(int argc, char *argv[])
const ODBus::ScopeInit dbus_init;
#endif
- config_global_init();
+ ConfigData raw_config;
#ifdef ANDROID
(void)argc;
@@ -486,13 +486,12 @@ MainOrThrow(int argc, char *argv[])
const auto config_path =
sdcard / Path::FromFS("mpd.conf");
if (FileExists(config_path))
- ReadConfigFile(config_path);
+ ReadConfigFile(raw_config, config_path);
}
#else
- ParseCommandLine(argc, argv, options);
+ ParseCommandLine(argc, argv, options, raw_config);
#endif
- const auto &raw_config = GetGlobalConfig();
InitPathParser(raw_config);
const auto config = LoadConfig(raw_config);
@@ -714,7 +713,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
#ifdef ENABLE_ARCHIVE
archive_plugin_deinit_all();
#endif
- config_global_finish();
instance->rtio_thread.Stop();
instance->io_thread.Stop();
#ifndef ANDROID