configure.ac: Don't allow UNIX IPC to be configured for a native Windows build.
[mpd-mk.git] / src / conf.h
blobd79a673cc100b76b9001625b59e9231b89a27449
1 /*
2 * Copyright (C) 2003-2010 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_FILTER "filter"
46 #define CONF_AUDIO_OUTPUT_FORMAT "audio_output_format"
47 #define CONF_MIXER_TYPE "mixer_type"
48 #define CONF_REPLAYGAIN "replaygain"
49 #define CONF_REPLAYGAIN_PREAMP "replaygain_preamp"
50 #define CONF_REPLAYGAIN_MISSING_PREAMP "replaygain_missing_preamp"
51 #define CONF_VOLUME_NORMALIZATION "volume_normalization"
52 #define CONF_SAMPLERATE_CONVERTER "samplerate_converter"
53 #define CONF_AUDIO_BUFFER_SIZE "audio_buffer_size"
54 #define CONF_BUFFER_BEFORE_PLAY "buffer_before_play"
55 #define CONF_HTTP_PROXY_HOST "http_proxy_host"
56 #define CONF_HTTP_PROXY_PORT "http_proxy_port"
57 #define CONF_HTTP_PROXY_USER "http_proxy_user"
58 #define CONF_HTTP_PROXY_PASSWORD "http_proxy_password"
59 #define CONF_CONN_TIMEOUT "connection_timeout"
60 #define CONF_MAX_CONN "max_connections"
61 #define CONF_MAX_PLAYLIST_LENGTH "max_playlist_length"
62 #define CONF_MAX_COMMAND_LIST_SIZE "max_command_list_size"
63 #define CONF_MAX_OUTPUT_BUFFER_SIZE "max_output_buffer_size"
64 #define CONF_FS_CHARSET "filesystem_charset"
65 #define CONF_ID3V1_ENCODING "id3v1_encoding"
66 #define CONF_METADATA_TO_USE "metadata_to_use"
67 #define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists"
68 #define CONF_DECODER "decoder"
69 #define CONF_INPUT "input"
70 #define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback"
71 #define CONF_PLAYLIST_PLUGIN "playlist_plugin"
72 #define CONF_AUTO_UPDATE "auto_update"
73 #define CONF_AUTO_UPDATE_DEPTH "auto_update_depth"
75 #define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
76 #define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS false
78 #define MAX_FILTER_CHAIN_LENGTH 255
80 struct block_param {
81 char *name;
82 char *value;
83 int line;
85 /**
86 * This flag is false when nobody has queried the value of
87 * this option yet.
89 bool used;
92 struct config_param {
93 char *value;
94 unsigned int line;
96 struct block_param *block_params;
97 unsigned num_block_params;
99 /**
100 * This flag is false when nobody has queried the value of
101 * this option yet.
103 bool used;
107 * A GQuark for GError instances, resulting from malformed
108 * configuration.
110 static inline GQuark
111 config_quark(void)
113 return g_quark_from_static_string("config");
116 void config_global_init(void);
117 void config_global_finish(void);
120 * Call this function after all configuration has been evaluated. It
121 * checks for unused parameters, and logs warnings.
123 void config_global_check(void);
125 bool
126 config_read_file(const char *file, GError **error_r);
128 /* don't free the returned value
129 set _last_ to NULL to get first entry */
130 G_GNUC_PURE
131 struct config_param *
132 config_get_next_param(const char *name, const struct config_param *last);
134 G_GNUC_PURE
135 static inline struct config_param *
136 config_get_param(const char *name)
138 return config_get_next_param(name, NULL);
141 /* Note on G_GNUC_PURE: Some of the functions declared pure are not
142 really pure in strict sense. They have side effect such that they
143 validate parameter's value and signal an error if it's invalid.
144 However, if the argument was already validated or we don't care
145 about the argument at all, this may be ignored so in the end, we
146 should be fine with calling those functions pure. */
148 G_GNUC_PURE
149 const char *
150 config_get_string(const char *name, const char *default_value);
153 * Returns an optional configuration variable which contains an
154 * absolute path. If there is a tilde prefix, it is expanded. Aborts
155 * MPD if the path is not a valid absolute path.
157 /* We lie here really. This function is not pure as it has side
158 effects -- it parse the value and creates new string freeing
159 previous one. However, because this works the very same way each
160 time (ie. from the outside it appears as if function had no side
161 effects) we should be in the clear declaring it pure. */
162 G_GNUC_PURE
163 const char *
164 config_get_path(const char *name);
166 G_GNUC_PURE
167 unsigned
168 config_get_unsigned(const char *name, unsigned default_value);
170 G_GNUC_PURE
171 unsigned
172 config_get_positive(const char *name, unsigned default_value);
174 G_GNUC_PURE
175 struct block_param *
176 config_get_block_param(const struct config_param *param, const char *name);
178 G_GNUC_PURE
179 bool config_get_bool(const char *name, bool default_value);
181 G_GNUC_PURE
182 const char *
183 config_get_block_string(const struct config_param *param, const char *name,
184 const char *default_value);
186 static inline char *
187 config_dup_block_string(const struct config_param *param, const char *name,
188 const char *default_value)
190 return g_strdup(config_get_block_string(param, name, default_value));
193 G_GNUC_PURE
194 unsigned
195 config_get_block_unsigned(const struct config_param *param, const char *name,
196 unsigned default_value);
198 G_GNUC_PURE
199 bool
200 config_get_block_bool(const struct config_param *param, const char *name,
201 bool default_value);
203 struct config_param *
204 config_new_param(const char *value, int line);
206 bool
207 config_add_block_param(struct config_param * param, const char *name,
208 const char *value, int line, GError **error_r);
210 #endif