MPD

src/conf.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2010 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #ifndef MPD_CONF_H
00021 #define MPD_CONF_H
00022 
00023 #include <stdbool.h>
00024 #include <glib.h>
00025 
00026 #define CONF_MUSIC_DIR                  "music_directory"
00027 #define CONF_PLAYLIST_DIR               "playlist_directory"
00028 #define CONF_FOLLOW_INSIDE_SYMLINKS     "follow_inside_symlinks"
00029 #define CONF_FOLLOW_OUTSIDE_SYMLINKS    "follow_outside_symlinks"
00030 #define CONF_DB_FILE                    "db_file"
00031 #define CONF_STICKER_FILE               "sticker_file"
00032 #define CONF_LOG_FILE                   "log_file"
00033 #define CONF_PID_FILE                   "pid_file"
00034 #define CONF_STATE_FILE                 "state_file"
00035 #define CONF_USER                       "user"
00036 #define CONF_GROUP                      "group"
00037 #define CONF_BIND_TO_ADDRESS            "bind_to_address"
00038 #define CONF_PORT                       "port"
00039 #define CONF_LOG_LEVEL                  "log_level"
00040 #define CONF_ZEROCONF_NAME              "zeroconf_name"
00041 #define CONF_ZEROCONF_ENABLED           "zeroconf_enabled"
00042 #define CONF_PASSWORD                   "password"
00043 #define CONF_DEFAULT_PERMS              "default_permissions"
00044 #define CONF_AUDIO_OUTPUT               "audio_output"
00045 #define CONF_AUDIO_FILTER               "filter"
00046 #define CONF_AUDIO_OUTPUT_FORMAT        "audio_output_format"
00047 #define CONF_MIXER_TYPE                 "mixer_type"
00048 #define CONF_REPLAYGAIN                 "replaygain"
00049 #define CONF_REPLAYGAIN_PREAMP          "replaygain_preamp"
00050 #define CONF_REPLAYGAIN_MISSING_PREAMP  "replaygain_missing_preamp"
00051 #define CONF_REPLAYGAIN_LIMIT           "replaygain_limit"
00052 #define CONF_VOLUME_NORMALIZATION       "volume_normalization"
00053 #define CONF_SAMPLERATE_CONVERTER       "samplerate_converter"
00054 #define CONF_AUDIO_BUFFER_SIZE          "audio_buffer_size"
00055 #define CONF_BUFFER_BEFORE_PLAY         "buffer_before_play"
00056 #define CONF_HTTP_PROXY_HOST            "http_proxy_host"
00057 #define CONF_HTTP_PROXY_PORT            "http_proxy_port"
00058 #define CONF_HTTP_PROXY_USER            "http_proxy_user"
00059 #define CONF_HTTP_PROXY_PASSWORD        "http_proxy_password"
00060 #define CONF_CONN_TIMEOUT               "connection_timeout"
00061 #define CONF_MAX_CONN                   "max_connections"
00062 #define CONF_MAX_PLAYLIST_LENGTH        "max_playlist_length"
00063 #define CONF_MAX_COMMAND_LIST_SIZE      "max_command_list_size"
00064 #define CONF_MAX_OUTPUT_BUFFER_SIZE     "max_output_buffer_size"
00065 #define CONF_FS_CHARSET                 "filesystem_charset"
00066 #define CONF_ID3V1_ENCODING             "id3v1_encoding"
00067 #define CONF_METADATA_TO_USE            "metadata_to_use"
00068 #define CONF_SAVE_ABSOLUTE_PATHS        "save_absolute_paths_in_playlists"
00069 #define CONF_DECODER                    "decoder"
00070 #define CONF_INPUT                      "input"
00071 #define CONF_GAPLESS_MP3_PLAYBACK       "gapless_mp3_playback"
00072 #define CONF_PLAYLIST_PLUGIN            "playlist_plugin"
00073 #define CONF_AUTO_UPDATE                "auto_update"
00074 #define CONF_AUTO_UPDATE_DEPTH          "auto_update_depth"
00075 
00076 #define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16)
00077 #define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS false
00078 
00079 #define MAX_FILTER_CHAIN_LENGTH 255
00080 
00081 struct block_param {
00082         char *name;
00083         char *value;
00084         int line;
00085 
00090         bool used;
00091 };
00092 
00093 struct config_param {
00094         char *value;
00095         unsigned int line;
00096 
00097         struct block_param *block_params;
00098         unsigned num_block_params;
00099 
00104         bool used;
00105 };
00106 
00111 static inline GQuark
00112 config_quark(void)
00113 {
00114         return g_quark_from_static_string("config");
00115 }
00116 
00117 void config_global_init(void);
00118 void config_global_finish(void);
00119 
00124 void config_global_check(void);
00125 
00126 bool
00127 config_read_file(const char *file, GError **error_r);
00128 
00129 /* don't free the returned value
00130    set _last_ to NULL to get first entry */
00131 G_GNUC_PURE
00132 struct config_param *
00133 config_get_next_param(const char *name, const struct config_param *last);
00134 
00135 G_GNUC_PURE
00136 static inline struct config_param *
00137 config_get_param(const char *name)
00138 {
00139         return config_get_next_param(name, NULL);
00140 }
00141 
00142 /* Note on G_GNUC_PURE: Some of the functions declared pure are not
00143    really pure in strict sense.  They have side effect such that they
00144    validate parameter's value and signal an error if it's invalid.
00145    However, if the argument was already validated or we don't care
00146    about the argument at all, this may be ignored so in the end, we
00147    should be fine with calling those functions pure.  */
00148 
00149 G_GNUC_PURE
00150 const char *
00151 config_get_string(const char *name, const char *default_value);
00152 
00158 /* We lie here really.  This function is not pure as it has side
00159    effects -- it parse the value and creates new string freeing
00160    previous one.  However, because this works the very same way each
00161    time (ie. from the outside it appears as if function had no side
00162    effects) we should be in the clear declaring it pure. */
00163 G_GNUC_PURE
00164 const char *
00165 config_get_path(const char *name);
00166 
00167 G_GNUC_PURE
00168 unsigned
00169 config_get_unsigned(const char *name, unsigned default_value);
00170 
00171 G_GNUC_PURE
00172 unsigned
00173 config_get_positive(const char *name, unsigned default_value);
00174 
00175 G_GNUC_PURE
00176 struct block_param *
00177 config_get_block_param(const struct config_param *param, const char *name);
00178 
00179 G_GNUC_PURE
00180 bool config_get_bool(const char *name, bool default_value);
00181 
00182 G_GNUC_PURE
00183 const char *
00184 config_get_block_string(const struct config_param *param, const char *name,
00185                         const char *default_value);
00186 
00187 static inline char *
00188 config_dup_block_string(const struct config_param *param, const char *name,
00189                         const char *default_value)
00190 {
00191         return g_strdup(config_get_block_string(param, name, default_value));
00192 }
00193 
00194 G_GNUC_PURE
00195 unsigned
00196 config_get_block_unsigned(const struct config_param *param, const char *name,
00197                           unsigned default_value);
00198 
00199 G_GNUC_PURE
00200 bool
00201 config_get_block_bool(const struct config_param *param, const char *name,
00202                       bool default_value);
00203 
00204 struct config_param *
00205 config_new_param(const char *value, int line);
00206 
00207 bool
00208 config_add_block_param(struct config_param * param, const char *name,
00209                        const char *value, int line, GError **error_r);
00210 
00211 #endif