Global.cxx 1.71 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * http://www.musicpd.org
 *
 * This program 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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.
 */

#include "config.h"
21
#include "Global.hxx"
22
#include "Migrate.hxx"
23
#include "Data.hxx"
24
#include "Block.hxx"
25 26 27
#include "File.hxx"
#include "Path.hxx"
#include "Domain.hxx"
28
#include "fs/Path.hxx"
29
#include "util/RuntimeError.hxx"
30
#include "Log.hxx"
31 32 33 34 35

static ConfigData config_data;

void config_global_finish(void)
{
36
	config_data.Clear();
37 38 39 40 41 42
}

void config_global_init(void)
{
}

43 44 45 46 47 48
const ConfigData &
GetGlobalConfig() noexcept
{
	return config_data;
}

49 50
void
ReadConfigFile(Path path)
51
{
52 53
	ReadConfigFile(config_data, path);
	Migrate(config_data);
54 55 56
}

const char *
57
config_get_string(ConfigOption option, const char *default_value) noexcept
58
{
59
	return config_data.GetString(option, default_value);
60 61 62 63 64
}

unsigned
config_get_positive(ConfigOption option, unsigned default_value)
{
65
	return config_data.GetPositive(option, default_value);
66 67 68 69 70
}

bool
config_get_bool(ConfigOption option, bool default_value)
{
71
	return config_data.GetBool(option, default_value);
72
}