2 * This file is part of DisOrder.
3 * Copyright (C) 2004-2011, 2013 Richard Kettlewell
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 3 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
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file lib/configuration.h
19 * @brief Configuration file support
22 #ifndef CONFIGURATION_H
23 #define CONFIGURATION_H
25 #include "speaker-protocol.h"
32 /* Configuration is kept in a @struct config@; the live configuration
33 * is always pointed to by @config@. Values in @config@ are UTF-8 encoded.
36 /** @brief A list of strings */
38 /** @brief Number of strings */
40 /** @brief Array of strings */
44 /** @brief A list of list of strings */
45 struct stringlistlist {
46 /** @brief Number of string lists */
48 /** @brief Array of string lists */
52 /** @brief A collection of tracks */
54 /** @brief Module that supports this collection */
56 /** @brief Filename encoding */
58 /** @brief Root directory */
62 /** @brief A list of collections */
63 struct collectionlist {
64 /** @brief Number of collections */
66 /** @brief Array of collections */
70 /** @brief A track name part */
72 char *part; /* part */
73 regexp *re; /* compiled regexp */
74 char *res; /* regexp as a string */
75 char *replace; /* replacement string */
76 char *context; /* context glob */
77 unsigned reflags; /* regexp flags */
80 /** @brief A list of track name parts */
86 /** @brief A track name transform */
88 char *type; /* track or dir */
89 char *context; /* sort or choose */
90 char *replace; /* substitution string */
91 regexp *re; /* compiled re */
92 unsigned flags; /* regexp flags */
95 /** @brief A list of track name transforms */
96 struct transformlist {
101 /** @brief System configuration */
105 /** @brief Authorization algorithm */
106 char *authorization_algorithm;
108 /** @brief All players */
109 struct stringlistlist player;
111 /** @brief All tracklength plugins */
112 struct stringlistlist tracklength;
114 /** @brief Scratch tracks */
115 struct stringlist scratch;
117 /** @brief Maximum number of recent tracks to record in history */
120 /** @brief Expiry limit for noticed.db */
121 long noticed_history;
123 /** @brief User for server to run as */
126 /** @brief Nice value for rescan subprocess */
129 /** @brief Paths to search for plugins */
130 struct stringlist plugins;
132 /** @brief List of stopwords */
133 struct stringlist stopword;
135 /** @brief List of collections */
136 struct collectionlist collection;
138 /** @brief Database checkpoint byte limit */
139 long checkpoint_kbyte;
141 /** @brief Databsase checkpoint minimum */
144 /** @brief Path to mixer device */
147 /** @brief Mixer channel to use */
150 /** @brief Secondary listen address */
151 struct netaddress listen;
153 /** @brief Alias format string */
156 /** @brief Nice value for server */
159 /** @brief Nice value for speaker */
162 /** @brief Command execute by speaker to play audio */
163 const char *speaker_command;
165 /** @brief Pause mode for command backend */
166 const char *pause_mode;
168 /** @brief Target sample format */
169 struct stream_header sample_format;
171 /** @brief Sox syntax generation */
174 /** @brief API used to play sound */
177 /** @brief Maximum size of a playlist */
180 /** @brief Maximum lifetime of a playlist lock */
181 long playlist_lock_timeout;
184 /** @brief Home directory for state files */
188 /** @brief Login username */
191 /** @brief Login password */
194 /** @brief Address to connect to */
195 struct netaddress connect;
197 /** @brief Directories to search for web templates */
198 struct stringlist templates;
200 /** @brief Canonical URL of web interface */
203 /** @brief Short display limit */
206 /** @brief Maximum refresh interval for web interface (seconds) */
209 /** @brief Minimum refresh interval for web interface (seconds) */
212 /** @brief Target queue length */
215 /** @brief Minimum time between a track being played again */
218 struct namepartlist namepart; /* transformations */
220 /** @brief Termination signal for subprocesses */
223 /** @brief ALSA output device */
226 struct transformlist transform; /* path name transformations */
228 /** @brief Address to send audio data to */
229 struct netaddress broadcast;
231 /** @brief Source address for network audio transmission */
232 struct netaddress broadcast_from;
234 /** @brief RTP delay threshold */
235 long rtp_delay_threshold;
237 /** @brief Verbose RTP transmission logging */
240 /** @brief TTL for multicast packets */
243 /** @brief Whether to loop back multicast packets */
246 /** @brief Login lifetime in seconds */
247 long cookie_login_lifetime;
249 /** @brief Signing key lifetime in seconds */
250 long cookie_key_lifetime;
252 /** @brief Default rights for a new user */
253 char *default_rights;
255 /** @brief Path to sendmail executable */
258 /** @brief SMTP server for sending mail */
261 /** @brief Origin address for outbound mail */
264 /** @brief Maximum number of tracks in response to 'new' */
267 /** @brief Minimum interval between password reminder emails */
268 long reminder_interval;
270 /** @brief Whether to allow user management over TCP */
273 /** @brief Maximum age of biased-up tracks */
276 /** @brief Maximum bias */
279 /** @brief Rescan on (un)mount */
282 /** @brief RTP mode */
283 const char *rtp_mode;
285 /* derived values: */
286 int nparts; /* number of distinct name parts */
287 char **parts; /* name part list */
289 /* undocumented, for testing only */
293 extern struct config *config;
294 /* the current configuration */
296 int config_read(int server,
297 const struct config *oldconfig);
298 /* re-read config, return 0 on success or non-0 on error.
299 * Only updates @config@ if the new configuration is valid. */
301 char *config_get_file2(struct config *c, const char *name);
302 char *config_get_file(const char *name);
303 /* get a filename within the home directory */
307 char *config_userconf(const char *home, const struct passwd *pw);
308 /* get the user's own private conffile, assuming their home dir is
309 * @home@ if not null and using @pw@ otherwise */
311 char *config_usersysconf(const struct passwd *pw );
312 /* get the user's conffile in /etc */
314 char *config_private(void);
315 /* get the private config file */
317 int config_verify(void);
319 void config_free(struct config *c);
321 extern char *configfile;
322 extern int config_per_user;
324 extern const struct uaudio *const *config_uaudio_apis;
326 #endif /* CONFIGURATION_H */