doc: Remove superfluous comment already described in footnotes.
[mpd-mk.git] / src / conf.h
bloba153b7157eb4f3114599f0e4c4231f2ab2d87d4e
1 /*
2 * Copyright (C) 2003-2009 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MPD_CONF_H
21 #define MPD_CONF_H
23 #include <stdbool.h>
24 #include <glib.h>
26 #define CONF_MUSIC_DIR "music_directory"
27 #define CONF_PLAYLIST_DIR "playlist_directory"
28 #define CONF_FOLLOW_INSIDE_SYMLINKS "follow_inside_symlinks"
29 #define CONF_FOLLOW_OUTSIDE_SYMLINKS "follow_outside_symlinks"
30 #define CONF_DB_FILE "db_file"
31 #define CONF_STICKER_FILE "sticker_file"
32 #define CONF_LOG_FILE "log_file"
33 #define CONF_PID_FILE "pid_file"
34 #define CONF_STATE_FILE "state_file"
35 #define CONF_USER "user"
36 #define CONF_GROUP "group"
37 #define CONF_BIND_TO_ADDRESS "bind_to_address"
38 #define CONF_PORT "port"
39 #define CONF_LOG_LEVEL "log_level"
40 #define CONF_ZEROCONF_NAME "zeroconf_name"
41 #define CONF_ZEROCONF_ENABLED "zeroconf_enabled"
42 #define CONF_PASSWORD "password"
43 #define CONF_DEFAULT_PERMS "default_permissions"
44 #define CONF_AUDIO_OUTPUT "audio_output"
45 #define CONF_AUDIO_OUTPUT_FORMAT "audio_output_format"
46 #define CONF_MIXER_TYPE "mixer_type"
47 #define CONF_REPLAYGAIN "replaygain"
48 #define CONF_REPLAYGAIN_PREAMP "replaygain_preamp"
49 #define CONF_REPLAYGAIN_MISSING_PREAMP "replaygain_missing_preamp"
50 #define CONF_VOLUME_NORMALIZATION "volume_normalization"
51 #define CONF_SAMPLERATE_CONVERTER "samplerate_converter"
52 #define CONF_AUDIO_BUFFER_SIZE "audio_buffer_size"
53 #define CONF_BUFFER_BEFORE_PLAY "buffer_before_play"
54 #define CONF_HTTP_PROXY_HOST "http_proxy_host"
55 #define CONF_HTTP_PROXY_PORT "http_proxy_port"
56 #define CONF_HTTP_PROXY_USER "http_proxy_user"
57 #define CONF_HTTP_PROXY_PASSWORD "http_proxy_password"
58 #define CONF_CONN_TIMEOUT "connection_timeout"
59 #define CONF_MAX_CONN "max_connections"
60 #define CONF_MAX_PLAYLIST_LENGTH "max_playlist_length"
61 #define CONF_MAX_COMMAND_LIST_SIZE "max_command_list_size"
62 #define CONF_MAX_OUTPUT_BUFFER_SIZE "max_output_buffer_size"
63 #define CONF_FS_CHARSET "filesystem_charset"
64 #define CONF_ID3V1_ENCODING "id3v1_encoding"
65 #define CONF_METADATA_TO_USE "metadata_to_use"
66 #define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists"
67 #define CONF_DECODER "decoder"
68 #define CONF_INPUT "input"
69 #define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback"
71 #define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
72 #define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS false
74 struct block_param {
75 char *name;
76 char *value;
77 int line;
79 /**
80 * This flag is false when nobody has queried the value of
81 * this option yet.
83 bool used;
86 struct config_param {
87 char *value;
88 unsigned int line;
90 struct block_param *block_params;
91 unsigned num_block_params;
93 /**
94 * This flag is false when nobody has queried the value of
95 * this option yet.
97 bool used;
101 * A GQuark for GError instances, resulting from malformed
102 * configuration.
104 static inline GQuark
105 config_quark(void)
107 return g_quark_from_static_string("config");
110 void config_global_init(void);
111 void config_global_finish(void);
114 * Call this function after all configuration has been evaluated. It
115 * checks for unused parameters, and logs warnings.
117 void config_global_check(void);
119 void config_read_file(const char *file);
121 /* don't free the returned value
122 set _last_ to NULL to get first entry */
123 G_GNUC_PURE
124 struct config_param *
125 config_get_next_param(const char *name, const struct config_param *last);
127 G_GNUC_PURE
128 static inline struct config_param *
129 config_get_param(const char *name)
131 return config_get_next_param(name, NULL);
134 /* Note on G_GNUC_PURE: Some of the functions declared pure are not
135 really pure in strict sense. They have side effect such that they
136 validate parameter's value and signal an error if it's invalid.
137 However, if the argument was already validated or we don't care
138 about the argument at all, this may be ignored so in the end, we
139 should be fine with calling those functions pure. */
141 G_GNUC_PURE
142 const char *
143 config_get_string(const char *name, const char *default_value);
146 * Returns an optional configuration variable which contains an
147 * absolute path. If there is a tilde prefix, it is expanded. Aborts
148 * MPD if the path is not a valid absolute path.
150 /* We lie here really. This function is not pure as it has side
151 effects -- it parse the value and creates new string freeing
152 previous one. However, because this works the very same way each
153 time (ie. from the outside it appears as if function had no side
154 effects) we should be in the clear declaring it pure. */
155 G_GNUC_PURE
156 const char *
157 config_get_path(const char *name);
159 G_GNUC_PURE
160 unsigned
161 config_get_positive(const char *name, unsigned default_value);
163 G_GNUC_PURE
164 struct block_param *
165 config_get_block_param(const struct config_param *param, const char *name);
167 G_GNUC_PURE
168 bool config_get_bool(const char *name, bool default_value);
170 G_GNUC_PURE
171 const char *
172 config_get_block_string(const struct config_param *param, const char *name,
173 const char *default_value);
175 static inline char *
176 config_dup_block_string(const struct config_param *param, const char *name,
177 const char *default_value)
179 return g_strdup(config_get_block_string(param, name, default_value));
182 G_GNUC_PURE
183 unsigned
184 config_get_block_unsigned(const struct config_param *param, const char *name,
185 unsigned default_value);
187 G_GNUC_PURE
188 bool
189 config_get_block_bool(const struct config_param *param, const char *name,
190 bool default_value);
192 struct config_param *
193 config_new_param(const char *value, int line);
195 void
196 config_add_block_param(struct config_param *param, const char *name,
197 const char *value, int line);
199 #endif