3 * This file is part of DisOrder.
4 * Copyright (C) 2004-2008 Richard Kettlewell
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 /** @file lib/configuration.h
20 * @brief Configuration file support
23 #ifndef CONFIGURATION_H
24 #define CONFIGURATION_H
28 #include "speaker-protocol.h"
31 /* Configuration is kept in a @struct config@; the live configuration
32 * is always pointed to by @config@. Values in @config@ are UTF-8 encoded.
35 /** @brief A list of strings */
37 /** @brief Number of strings */
39 /** @brief Array of strings */
43 /** @brief A list of list of strings */
44 struct stringlistlist
{
45 /** @brief Number of string lists */
47 /** @brief Array of string lists */
51 /** @brief A collection of tracks */
53 /** @brief Module that supports this collection */
55 /** @brief Filename encoding */
57 /** @brief Root directory */
61 /** @brief A list of collections */
62 struct collectionlist
{
63 /** @brief Number of collections */
65 /** @brief Array of collections */
70 char *part
; /* part */
71 pcre
*re
; /* regexp */
72 char *replace
; /* replacement string */
73 char *context
; /* context glob */
74 unsigned reflags
; /* regexp flags */
83 char *type
; /* track or dir */
84 char *context
; /* sort or choose */
85 char *replace
; /* substitution string */
86 pcre
*re
; /* compiled re */
87 unsigned flags
; /* regexp flags */
90 struct transformlist
{
95 /** @brief System configuration */
99 /** @brief Authorization algorithm */
100 char *authorization_algorithm
;
102 /** @brief All players */
103 struct stringlistlist player
;
105 /** @brief All tracklength plugins */
106 struct stringlistlist tracklength
;
108 /** @brief Allowed users */
109 struct stringlistlist allow
;
111 /** @brief Scratch tracks */
112 struct stringlist scratch
;
114 /** @brief Gap between tracks in seconds */
117 /** @brief Maximum number of recent tracks to record in history */
120 /** @brief Expiry limit for noticed.db */
121 long noticed_history
;
123 /** @brief Trusted users */
124 struct stringlist trust
;
126 /** @brief User for server to run as */
129 /** @brief Nice value for rescan subprocess */
132 /** @brief Paths to search for plugins */
133 struct stringlist plugins
;
135 /** @brief List of stopwords */
136 struct stringlist stopword
;
138 /** @brief List of collections */
139 struct collectionlist collection
;
141 /** @brief Database checkpoint byte limit */
142 long checkpoint_kbyte
;
144 /** @brief Databsase checkpoint minimum */
147 /** @brief Path to mixer device */
150 /** @brief Mixer channel to use */
153 long prefsync
; /* preflog sync interval */
155 /** @brief Secondary listen address */
156 struct stringlist listen
;
158 /** @brief Alias format string */
161 /** @brief Enable server locking */
164 /** @brief Nice value for server */
167 /** @brief Nice value for speaker */
170 /** @brief Command execute by speaker to play audio */
171 const char *speaker_command
;
173 /** @brief Target sample format */
174 struct stream_header sample_format
;
176 /** @brief Sox syntax generation */
179 /** @brief API used to play sound
181 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
186 /** @brief Maximum size of a playlist */
189 /** @brief Maximum lifetime of a playlist lock */
190 long playlist_lock_timeout
;
192 /* These values had better be non-negative */
193 #define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
194 #define BACKEND_COMMAND 1 /**< Execute a command */
195 #define BACKEND_NETWORK 2 /**< Transmit RTP */
196 #define BACKEND_COREAUDIO 3 /**< Use Core Audio (Mac only) */
197 #define BACKEND_OSS 4 /**< Use OSS */
199 #if HAVE_ALSA_ASOUNDLIB_H
200 # define DEFAULT_BACKEND BACKEND_ALSA
201 #elif HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
202 # define DEFAULT_BACKEND BACKEND_OSS
203 #elif HAVE_COREAUDIO_AUDIOHARDWARE_H
204 # define DEFAULT_BACKEND BACKEND_COREAUDIO
206 # error Cannot choose a default backend
209 /** @brief Home directory for state files */
212 /** @brief Login username */
213 const char *username
;
215 /** @brief Login password */
216 const char *password
;
218 /** @brief Address to connect to */
219 struct stringlist connect
;
221 /** @brief Directories to search for web templates */
222 struct stringlist templates
;
224 /** @brief Canonical URL of web interface */
227 /** @brief Short display limit */
230 /** @brief Maximum refresh interval for web interface (seconds) */
233 /** @brief Facilities restricted to trusted users
235 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
238 unsigned restrictions
; /* restrictions */
239 #define RESTRICT_SCRATCH 1 /**< Restrict scratching */
240 #define RESTRICT_REMOVE 2 /**< Restrict removal */
241 #define RESTRICT_MOVE 4 /**< Restrict rearrangement */
243 /** @brief Target queue length */
246 /** @brief Minimum time between a track being played again */
249 struct namepartlist namepart
; /* transformations */
251 /** @brief Termination signal for subprocesses */
254 /** @brief ALSA output device */
256 struct transformlist transform
; /* path name transformations */
258 /** @brief Address to send audio data to */
259 struct stringlist broadcast
;
261 /** @brief Source address for network audio transmission */
262 struct stringlist broadcast_from
;
264 /** @brief TTL for multicast packets */
267 /** @brief Whether to loop back multicast packets */
270 /** @brief Login lifetime in seconds */
271 long cookie_login_lifetime
;
273 /** @brief Signing key lifetime in seconds */
274 long cookie_key_lifetime
;
276 /** @brief Default rights for a new user */
277 char *default_rights
;
279 /** @brief Path to sendmail executable */
282 /** @brief SMTP server for sending mail */
285 /** @brief Origin address for outbound mail */
288 /** @brief Maximum number of tracks in response to 'new' */
291 /** @brief Minimum interval between password reminder emails */
292 long reminder_interval
;
294 /** @brief Whether to allow user management over TCP */
297 /** @brief Maximum age of biased-up tracks */
300 /** @brief Maximum bias */
303 /* derived values: */
304 int nparts
; /* number of distinct name parts */
305 char **parts
; /* name part list */
307 /* undocumented, for testing only */
311 extern struct config
*config
;
312 /* the current configuration */
314 int config_read(int server
);
315 /* re-read config, return 0 on success or non-0 on error.
316 * Only updates @config@ if the new configuration is valid. */
318 char *config_get_file2(struct config
*c
, const char *name
);
319 char *config_get_file(const char *name
);
320 /* get a filename within the home directory */
324 char *config_userconf(const char *home
, const struct passwd
*pw
);
325 /* get the user's own private conffile, assuming their home dir is
326 * @home@ if not null and using @pw@ otherwise */
328 char *config_usersysconf(const struct passwd
*pw
);
329 /* get the user's conffile in /etc */
331 char *config_private(void);
332 /* get the private config file */
334 extern char *configfile
;
335 extern int config_per_user
;
337 #endif /* CONFIGURATION_H */