2 * This file is part of DisOrder.
3 * Copyright (C) 2004-2008 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 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, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 /** @file lib/configuration.h
21 * @brief Configuration file support
24 #ifndef CONFIGURATION_H
25 #define CONFIGURATION_H
27 #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 */
71 char *part; /* part */
72 struct real_pcre *re; /* regexp */
73 char *replace; /* replacement string */
74 char *context; /* context glob */
75 unsigned reflags; /* regexp flags */
84 char *type; /* track or dir */
85 char *context; /* sort or choose */
86 char *replace; /* substitution string */
87 struct real_pcre *re; /* compiled re */
88 unsigned flags; /* regexp flags */
91 struct transformlist {
96 /** @brief System configuration */
100 /** @brief Authorization algorithm */
101 char *authorization_algorithm;
103 /** @brief All players */
104 struct stringlistlist player;
106 /** @brief All tracklength plugins */
107 struct stringlistlist tracklength;
109 /** @brief Allowed users */
110 struct stringlistlist allow;
112 /** @brief Scratch tracks */
113 struct stringlist scratch;
115 /** @brief Gap between tracks in seconds */
118 /** @brief Maximum number of recent tracks to record in history */
121 /** @brief Expiry limit for noticed.db */
122 long noticed_history;
124 /** @brief Trusted users */
125 struct stringlist trust;
127 /** @brief User for server to run as */
130 /** @brief Nice value for rescan subprocess */
133 /** @brief Paths to search for plugins */
134 struct stringlist plugins;
136 /** @brief List of stopwords */
137 struct stringlist stopword;
139 /** @brief List of collections */
140 struct collectionlist collection;
142 /** @brief Database checkpoint byte limit */
143 long checkpoint_kbyte;
145 /** @brief Databsase checkpoint minimum */
148 /** @brief Path to mixer device */
151 /** @brief Mixer channel to use */
154 long prefsync; /* preflog sync interval */
156 /** @brief Secondary listen address */
157 struct stringlist listen;
159 /** @brief Alias format string */
162 /** @brief Enable server locking */
165 /** @brief Nice value for server */
168 /** @brief Nice value for speaker */
171 /** @brief Command execute by speaker to play audio */
172 const char *speaker_command;
174 /** @brief Target sample format */
175 struct stream_header sample_format;
177 /** @brief Sox syntax generation */
180 /** @brief API used to play sound
182 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
186 #define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
187 #define BACKEND_COMMAND 1 /**< Execute a command */
188 #define BACKEND_NETWORK 2 /**< Transmit RTP */
189 #define BACKEND_COREAUDIO 3 /**< Use Core Audio (Mac only) */
190 #define BACKEND_OSS 4 /**< Use OSS */
192 #if HAVE_ALSA_ASOUNDLIB_H
193 # define DEFAULT_BACKEND BACKEND_ALSA
194 #elif HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
195 # define DEFAULT_BACKEND BACKEND_OSS
196 #elif HAVE_COREAUDIO_AUDIOHARDWARE_H
197 # define DEFAULT_BACKEND BACKEND_COREAUDIO
199 # error Cannot choose a default backend
202 /** @brief Home directory for state files */
205 /** @brief Login username */
206 const char *username;
208 /** @brief Login password */
209 const char *password;
211 /** @brief Address to connect to */
212 struct stringlist connect;
214 /** @brief Directories to search for web templates */
215 struct stringlist templates;
217 /** @brief Canonical URL of web interface */
220 /** @brief Short display limit */
223 /** @brief Maximum refresh interval for web interface (seconds) */
226 /** @brief Facilities restricted to trusted users
228 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
231 unsigned restrictions; /* restrictions */
232 #define RESTRICT_SCRATCH 1 /**< Restrict scratching */
233 #define RESTRICT_REMOVE 2 /**< Restrict removal */
234 #define RESTRICT_MOVE 4 /**< Restrict rearrangement */
236 /** @brief Target queue length */
239 /** @brief Minimum time between a track being played again */
242 struct namepartlist namepart; /* transformations */
244 /** @brief Termination signal for subprocesses */
247 /** @brief ALSA output device */
249 struct transformlist transform; /* path name transformations */
251 /** @brief Address to send audio data to */
252 struct stringlist broadcast;
254 /** @brief Source address for network audio transmission */
255 struct stringlist broadcast_from;
257 /** @brief TTL for multicast packets */
260 /** @brief Whether to loop back multicast packets */
263 /** @brief Login lifetime in seconds */
264 long cookie_login_lifetime;
266 /** @brief Signing key lifetime in seconds */
267 long cookie_key_lifetime;
269 /** @brief Default rights for a new user */
270 char *default_rights;
272 /** @brief SMTP server for sending mail */
275 /** @brief Origin address for outbound mail */
278 /** @brief Maximum number of tracks in response to 'new' */
281 /** @brief Minimum interval between password reminder emails */
282 long reminder_interval;
284 /** @brief Whether to allow user management over TCP */
287 /* derived values: */
288 int nparts; /* number of distinct name parts */
289 char **parts; /* name part list */
291 /* undocumented, for testing only */
295 extern struct config *config;
296 /* the current configuration */
298 int config_read(int server);
299 /* re-read config, return 0 on success or non-0 on error.
300 * Only updates @config@ if the new configuration is valid. */
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 extern char *configfile;
318 extern int config_per_user;
320 #endif /* CONFIGURATION_H */