2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2010-01-01 05:55:13 +01:00
|
|
|
* Copyright (C) 2003-2010 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
|
|
|
|
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
|
|
|
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_MUSIC_DIR "music_directory"
|
|
|
|
#define CONF_PLAYLIST_DIR "playlist_directory"
|
2008-11-28 10:57:39 +01:00
|
|
|
#define CONF_FOLLOW_INSIDE_SYMLINKS "follow_inside_symlinks"
|
|
|
|
#define CONF_FOLLOW_OUTSIDE_SYMLINKS "follow_outside_symlinks"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_DB_FILE "db_file"
|
2009-01-19 18:51:57 +01:00
|
|
|
#define CONF_STICKER_FILE "sticker_file"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_LOG_FILE "log_file"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_PID_FILE "pid_file"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_STATE_FILE "state_file"
|
|
|
|
#define CONF_USER "user"
|
2009-07-19 08:17:55 +02:00
|
|
|
#define CONF_GROUP "group"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_BIND_TO_ADDRESS "bind_to_address"
|
|
|
|
#define CONF_PORT "port"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_LOG_LEVEL "log_level"
|
2007-01-11 21:41:17 +01:00
|
|
|
#define CONF_ZEROCONF_NAME "zeroconf_name"
|
2007-06-03 20:08:51 +02:00
|
|
|
#define CONF_ZEROCONF_ENABLED "zeroconf_enabled"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_PASSWORD "password"
|
|
|
|
#define CONF_DEFAULT_PERMS "default_permissions"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_AUDIO_OUTPUT "audio_output"
|
2009-12-13 22:49:39 +01:00
|
|
|
#define CONF_AUDIO_FILTER "filter"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_AUDIO_OUTPUT_FORMAT "audio_output_format"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_MIXER_TYPE "mixer_type"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_REPLAYGAIN "replaygain"
|
|
|
|
#define CONF_REPLAYGAIN_PREAMP "replaygain_preamp"
|
2009-06-19 09:02:12 +02:00
|
|
|
#define CONF_REPLAYGAIN_MISSING_PREAMP "replaygain_missing_preamp"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_VOLUME_NORMALIZATION "volume_normalization"
|
2007-02-02 04:51:07 +01:00
|
|
|
#define CONF_SAMPLERATE_CONVERTER "samplerate_converter"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_AUDIO_BUFFER_SIZE "audio_buffer_size"
|
|
|
|
#define CONF_BUFFER_BEFORE_PLAY "buffer_before_play"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_HTTP_PROXY_HOST "http_proxy_host"
|
|
|
|
#define CONF_HTTP_PROXY_PORT "http_proxy_port"
|
|
|
|
#define CONF_HTTP_PROXY_USER "http_proxy_user"
|
|
|
|
#define CONF_HTTP_PROXY_PASSWORD "http_proxy_password"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_CONN_TIMEOUT "connection_timeout"
|
|
|
|
#define CONF_MAX_CONN "max_connections"
|
|
|
|
#define CONF_MAX_PLAYLIST_LENGTH "max_playlist_length"
|
|
|
|
#define CONF_MAX_COMMAND_LIST_SIZE "max_command_list_size"
|
|
|
|
#define CONF_MAX_OUTPUT_BUFFER_SIZE "max_output_buffer_size"
|
|
|
|
#define CONF_FS_CHARSET "filesystem_charset"
|
2006-07-27 21:10:08 +02:00
|
|
|
#define CONF_ID3V1_ENCODING "id3v1_encoding"
|
2006-08-28 22:47:50 +02:00
|
|
|
#define CONF_METADATA_TO_USE "metadata_to_use"
|
|
|
|
#define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists"
|
2009-02-15 18:35:19 +01:00
|
|
|
#define CONF_DECODER "decoder"
|
2009-03-02 23:08:17 +01:00
|
|
|
#define CONF_INPUT "input"
|
2006-12-23 19:00:15 +01:00
|
|
|
#define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback"
|
2009-10-13 16:19:21 +02:00
|
|
|
#define CONF_PLAYLIST_PLUGIN "playlist_plugin"
|
2009-10-26 19:14:40 +01:00
|
|
|
#define CONF_AUTO_UPDATE "auto_update"
|
2004-02-24 00:41:20 +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
|
|
|
|
|
2009-01-17 20:23:27 +01:00
|
|
|
struct block_param {
|
2006-07-20 18:02:40 +02:00
|
|
|
char *name;
|
|
|
|
char *value;
|
2004-10-28 07:14:55 +02:00
|
|
|
int line;
|
2009-06-19 09:02:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This flag is false when nobody has queried the value of
|
|
|
|
* this option yet.
|
|
|
|
*/
|
|
|
|
bool used;
|
2009-01-17 20:23:27 +01:00
|
|
|
};
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-01-17 20:23:27 +01:00
|
|
|
struct config_param {
|
2006-07-20 18:02:40 +02:00
|
|
|
char *value;
|
2004-10-28 07:14:55 +02:00
|
|
|
unsigned int line;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-01-17 20:23:27 +01:00
|
|
|
struct block_param *block_params;
|
2009-06-03 06:55:09 +02:00
|
|
|
unsigned num_block_params;
|
2009-06-19 09:02:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This flag is false when nobody has queried the value of
|
|
|
|
* this option yet.
|
|
|
|
*/
|
|
|
|
bool used;
|
2009-01-17 20:23:27 +01:00
|
|
|
};
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-03 01:01:50 +02:00
|
|
|
/**
|
|
|
|
* A GQuark for GError instances, resulting from malformed
|
|
|
|
* configuration.
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
2009-09-24 21:40:07 +02:00
|
|
|
bool
|
|
|
|
config_read_file(const char *file, GError **error_r);
|
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
|
2009-01-17 20:23:27 +01:00
|
|
|
struct config_param *
|
2009-01-25 16:03:49 +01:00
|
|
|
config_get_next_param(const char *name, const struct config_param *last);
|
2004-10-28 07:14:55 +02:00
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-17 20:23:27 +01:00
|
|
|
static inline struct config_param *
|
|
|
|
config_get_param(const char *name)
|
|
|
|
{
|
|
|
|
return config_get_next_param(name, NULL);
|
|
|
|
}
|
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 *
|
|
|
|
config_get_string(const char *name, 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
|
|
|
|
* absolute path. If there is a tilde prefix, it is expanded. Aborts
|
|
|
|
* MPD if the path is not a valid absolute path.
|
|
|
|
*/
|
2009-07-19 08:18:08 +02:00
|
|
|
/* We lie here really. This function is not pure as it has side
|
|
|
|
effects -- it parse the value and creates new string freeing
|
|
|
|
previous one. However, because this works the very same way each
|
|
|
|
time (ie. from the outside it appears as if function had no side
|
|
|
|
effects) we should be in the clear declaring it pure. */
|
|
|
|
G_GNUC_PURE
|
2009-01-18 17:54:46 +01:00
|
|
|
const char *
|
|
|
|
config_get_path(const char *name);
|
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-21 08:46:59 +01:00
|
|
|
unsigned
|
|
|
|
config_get_positive(const char *name, unsigned default_value);
|
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-17 20:23:27 +01:00
|
|
|
struct block_param *
|
2009-06-03 06:55:04 +02:00
|
|
|
config_get_block_param(const struct config_param *param, const char *name);
|
2004-10-28 07:14:55 +02:00
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2008-11-27 19:19:34 +01:00
|
|
|
bool config_get_bool(const char *name, bool default_value);
|
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-18 19:37:27 +01:00
|
|
|
const char *
|
2009-01-25 16:03:49 +01:00
|
|
|
config_get_block_string(const struct config_param *param, const char *name,
|
2009-01-18 19:37:27 +01:00
|
|
|
const char *default_value);
|
|
|
|
|
|
|
|
static inline char *
|
2009-01-25 16:03:49 +01:00
|
|
|
config_dup_block_string(const struct config_param *param, const char *name,
|
2009-01-18 19:37:27 +01:00
|
|
|
const char *default_value)
|
|
|
|
{
|
|
|
|
return g_strdup(config_get_block_string(param, name, default_value));
|
|
|
|
}
|
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-18 19:45:51 +01:00
|
|
|
unsigned
|
2009-01-25 16:03:49 +01:00
|
|
|
config_get_block_unsigned(const struct config_param *param, const char *name,
|
2009-01-18 19:45:51 +01:00
|
|
|
unsigned default_value);
|
|
|
|
|
2009-07-19 08:18:08 +02:00
|
|
|
G_GNUC_PURE
|
2009-01-17 20:23:56 +01:00
|
|
|
bool
|
2009-01-25 16:03:49 +01:00
|
|
|
config_get_block_bool(const struct config_param *param, const char *name,
|
2009-01-17 20:23:56 +01:00
|
|
|
bool default_value);
|
2007-09-06 01:59:33 +02:00
|
|
|
|
2009-01-17 20:23:27 +01:00
|
|
|
struct config_param *
|
2009-06-03 06:55:04 +02:00
|
|
|
config_new_param(const char *value, int line);
|
2008-12-31 15:10:53 +01:00
|
|
|
|
2009-09-24 21:40:07 +02:00
|
|
|
bool
|
|
|
|
config_add_block_param(struct config_param * param, const char *name,
|
|
|
|
const char *value, int line, GError **error_r);
|
2008-12-31 15:10:53 +01:00
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|