2 * This file is part of DisOrder.
3 * Copyright (C) 2004-2010 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
27 #include "speaker-protocol.h"
33 /* Configuration is kept in a @struct config@; the live configuration
34 * is always pointed to by @config@. Values in @config@ are UTF-8 encoded.
37 /** @brief A list of strings */
39 /** @brief Number of strings */
41 /** @brief Array of strings */
45 /** @brief A list of list of strings */
46 struct stringlistlist {
47 /** @brief Number of string lists */
49 /** @brief Array of string lists */
53 /** @brief A collection of tracks */
55 /** @brief Module that supports this collection */
57 /** @brief Filename encoding */
59 /** @brief Root directory */
63 /** @brief A list of collections */
64 struct collectionlist {
65 /** @brief Number of collections */
67 /** @brief Array of collections */
71 /** @brief A track name part */
73 char *part; /* part */
74 pcre *re; /* compiled regexp */
75 char *res; /* regexp as a string */
76 char *replace; /* replacement string */
77 char *context; /* context glob */
78 unsigned reflags; /* regexp flags */
81 /** @brief A list of track name parts */
87 /** @brief A track name transform */
89 char *type; /* track or dir */
90 char *context; /* sort or choose */
91 char *replace; /* substitution string */
92 pcre *re; /* compiled re */
93 unsigned flags; /* regexp flags */
96 /** @brief A list of track name transforms */
97 struct transformlist {
102 /** @brief System configuration */
106 /** @brief Authorization algorithm */
107 char *authorization_algorithm;
109 /** @brief All players */
110 struct stringlistlist player;
112 /** @brief All tracklength plugins */
113 struct stringlistlist tracklength;
115 /** @brief Allowed users */
116 struct stringlistlist allow;
118 /** @brief Scratch tracks */
119 struct stringlist scratch;
121 /** @brief Gap between tracks in seconds */
124 /** @brief Maximum number of recent tracks to record in history */
127 /** @brief Expiry limit for noticed.db */
128 long noticed_history;
130 /** @brief Trusted users */
131 struct stringlist trust;
133 /** @brief User for server to run as */
136 /** @brief Nice value for rescan subprocess */
139 /** @brief Paths to search for plugins */
140 struct stringlist plugins;
142 /** @brief List of stopwords */
143 struct stringlist stopword;
145 /** @brief List of collections */
146 struct collectionlist collection;
148 /** @brief Database checkpoint byte limit */
149 long checkpoint_kbyte;
151 /** @brief Databsase checkpoint minimum */
154 /** @brief Path to mixer device */
157 /** @brief Mixer channel to use */
160 long prefsync; /* preflog sync interval */
162 /** @brief Secondary listen address */
163 struct netaddress listen;
165 /** @brief Alias format string */
168 /** @brief Enable server locking */
171 /** @brief Nice value for server */
174 /** @brief Nice value for speaker */
177 /** @brief Command execute by speaker to play audio */
178 const char *speaker_command;
180 /** @brief Pause mode for command backend */
181 const char *pause_mode;
183 /** @brief Target sample format */
184 struct stream_header sample_format;
186 /** @brief Sox syntax generation */
189 /** @brief API used to play sound */
192 /** @brief Maximum size of a playlist */
195 /** @brief Maximum lifetime of a playlist lock */
196 long playlist_lock_timeout;
198 /** @brief Home directory for state files */
201 /** @brief Login username */
204 /** @brief Login password */
207 /** @brief Address to connect to */
208 struct netaddress connect;
210 /** @brief Directories to search for web templates */
211 struct stringlist templates;
213 /** @brief Canonical URL of web interface */
216 /** @brief Short display limit */
219 /** @brief Maximum refresh interval for web interface (seconds) */
222 /** @brief Minimum refresh interval for web interface (seconds) */
225 /** @brief Facilities restricted to trusted users
227 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
230 unsigned restrictions; /* restrictions */
231 #define RESTRICT_SCRATCH 1 /**< Restrict scratching */
232 #define RESTRICT_REMOVE 2 /**< Restrict removal */
233 #define RESTRICT_MOVE 4 /**< Restrict rearrangement */
235 /** @brief Target queue length */
238 /** @brief Minimum time between a track being played again */
241 struct namepartlist namepart; /* transformations */
243 /** @brief Termination signal for subprocesses */
246 /** @brief ALSA output device */
248 struct transformlist transform; /* path name transformations */
250 /** @brief Address to send audio data to */
251 struct netaddress broadcast;
253 /** @brief Source address for network audio transmission */
254 struct netaddress broadcast_from;
256 /** @brief RTP delay threshold */
257 long rtp_delay_threshold;
259 /** @brief Verbose RTP transmission logging */
262 /** @brief TTL for multicast packets */
265 /** @brief Whether to loop back multicast packets */
268 /** @brief Login lifetime in seconds */
269 long cookie_login_lifetime;
271 /** @brief Signing key lifetime in seconds */
272 long cookie_key_lifetime;
274 /** @brief Default rights for a new user */
275 char *default_rights;
277 /** @brief Path to sendmail executable */
280 /** @brief SMTP server for sending mail */
283 /** @brief Origin address for outbound mail */
286 /** @brief Maximum number of tracks in response to 'new' */
289 /** @brief Minimum interval between password reminder emails */
290 long reminder_interval;
292 /** @brief Whether to allow user management over TCP */
295 /** @brief Maximum age of biased-up tracks */
298 /** @brief Maximum bias */
301 /** @brief Rescan on (un)mount */
304 /* derived values: */
305 int nparts; /* number of distinct name parts */
306 char **parts; /* name part list */
308 /* undocumented, for testing only */
312 extern struct config *config;
313 /* the current configuration */
315 int config_read(int server,
316 const struct config *oldconfig);
317 /* re-read config, return 0 on success or non-0 on error.
318 * Only updates @config@ if the new configuration is valid. */
320 char *config_get_file2(struct config *c, const char *name);
321 char *config_get_file(const char *name);
322 /* get a filename within the home directory */
326 char *config_userconf(const char *home, const struct passwd *pw);
327 /* get the user's own private conffile, assuming their home dir is
328 * @home@ if not null and using @pw@ otherwise */
330 char *config_usersysconf(const struct passwd *pw );
331 /* get the user's conffile in /etc */
333 char *config_private(void);
334 /* get the private config file */
336 int config_verify(void);
338 void config_free(struct config *c);
340 extern char *configfile;
341 extern int config_per_user;
343 extern const struct uaudio *const *config_uaudio_apis;
345 #endif /* CONFIGURATION_H */