2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2011-01-29 10:13:54 +01:00
|
|
|
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_CONF_H
|
|
|
|
#define MPD_CONF_H
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-30 17:52:51 +01:00
|
|
|
#include "ConfigOption.hxx"
|
2013-01-30 18:52:14 +01:00
|
|
|
#include "ConfigData.hxx"
|
2013-01-30 17:52:51 +01:00
|
|
|
#include "gcc.h"
|
|
|
|
|
2008-11-27 19:19:34 +01:00
|
|
|
#include <stdbool.h>
|
2009-01-10 21:33:38 +01:00
|
|
|
#include <glib.h>
|
2008-11-27 19:19:34 +01:00
|
|
|
|
2009-01-25 13:53:16 +01:00
|
|
|
#define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
|
|
|
|
#define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS false
|
|
|
|
|
2009-12-13 22:49:39 +01:00
|
|
|
#define MAX_FILTER_CHAIN_LENGTH 255
|
|
|
|
|
2013-01-29 17:23:35 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
class Path;
|
|
|
|
#endif
|
|
|
|
|
2009-07-03 01:01:50 +02:00
|
|
|
/**
|
|
|
|
* A GQuark for GError instances, resulting from malformed
|
|
|
|
* configuration.
|
|
|
|
*/
|
2011-09-09 21:01:10 +02:00
|
|
|
G_GNUC_CONST
|
2009-07-03 01:01:50 +02:00
|
|
|
static inline GQuark
|
|
|
|
config_quark(void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string("config");
|
|
|
|
}
|
|
|
|
|
2009-01-17 20:23:27 +01:00
|
|
|
void config_global_init(void);
|
|
|
|
void config_global_finish(void);
|
|
|
|
|
2009-06-19 09:02:14 +02:00
|
|
|
/**
|
|
|
|
* Call this function after all configuration has been evaluated. It
|
|
|
|
* checks for unused parameters, and logs warnings.
|
|
|
|
*/
|
|
|
|
void config_global_check(void);
|
|
|
|
|
2013-01-29 17:23:35 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2009-09-24 21:40:07 +02:00
|
|
|
bool
|
2013-01-29 17:23:35 +01:00
|
|
|
ReadConfigFile(const Path &path, GError **error_r);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
2004-10-28 07:14:55 +02:00
|
|
|
|
|
|
|
/* don't free the returned value
|
|
|
|
set _last_ to NULL to get first entry */
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2011-09-09 23:59:43 +02:00
|
|
|
const struct config_param *
|
2013-01-30 17:52:51 +01:00
|
|
|
config_get_next_param(enum ConfigOption option,
|
|
|
|
const struct config_param *last);
|
2004-10-28 07:14:55 +02:00
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2011-09-09 23:59:43 +02:00
|
|
|
static inline const struct config_param *
|
2013-01-30 17:52:51 +01:00
|
|
|
config_get_param(enum ConfigOption option)
|
2009-01-17 20:23:27 +01:00
|
|
|
{
|
2013-01-30 17:52:51 +01:00
|
|
|
return config_get_next_param(option, NULL);
|
2009-01-17 20:23:27 +01:00
|
|
|
}
|
2004-10-28 07:14:55 +02:00
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
/* Note on G_GNUC_PURE: Some of the functions declared pure are not
|
|
|
|
really pure in strict sense. They have side effect such that they
|
|
|
|
validate parameter's value and signal an error if it's invalid.
|
|
|
|
However, if the argument was already validated or we don't care
|
|
|
|
about the argument at all, this may be ignored so in the end, we
|
|
|
|
should be fine with calling those functions pure. */
|
|
|
|
|
|
|
|
G_GNUC_PURE
|
2009-01-17 20:23:58 +01:00
|
|
|
const char *
|
2013-01-30 17:52:51 +01:00
|
|
|
config_get_string(enum ConfigOption option, const char *default_value);
|
2004-10-28 07:14:55 +02:00
|
|
|
|
2009-01-18 17:54:46 +01:00
|
|
|
/**
|
|
|
|
* Returns an optional configuration variable which contains an
|
2011-09-09 21:32:12 +02:00
|
|
|
* absolute path. If there is a tilde prefix, it is expanded.
|
|
|
|
* Returns NULL if the value is not present. If the path could not be
|
|
|
|
* parsed, returns NULL and sets the error.
|
|
|
|
*
|
|
|
|
* The return value must be freed with g_free().
|
2009-01-18 17:54:46 +01:00
|
|
|
*/
|
2011-09-09 21:32:12 +02:00
|
|
|
G_GNUC_MALLOC
|
|
|
|
char *
|
2013-01-30 17:52:51 +01:00
|
|
|
config_dup_path(enum ConfigOption option, GError **error_r);
|
2009-01-18 17:54:46 +01:00
|
|
|
|
2010-04-13 21:19:07 +02:00
|
|
|
G_GNUC_PURE
|
|
|
|
unsigned
|
2013-01-30 17:52:51 +01:00
|
|
|
config_get_unsigned(enum ConfigOption option, unsigned default_value);
|
2010-04-13 21:19:07 +02:00
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-21 08:46:59 +01:00
|
|
|
unsigned
|
2013-01-30 17:52:51 +01:00
|
|
|
config_get_positive(enum ConfigOption option, unsigned default_value);
|
2009-01-21 08:46:59 +01:00
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2013-01-30 17:52:51 +01:00
|
|
|
bool config_get_bool(enum ConfigOption option, bool default_value);
|
2008-11-27 19:19:34 +01:00
|
|
|
|
2013-01-07 09:38:02 +01:00
|
|
|
G_END_DECLS
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|