Initial work on playlists window. Doesn't do much of use.
[disorder] / lib / configuration.h
CommitLineData
05dcfac6 1
460b9539 2/*
3 * This file is part of DisOrder.
964e027d 4 * Copyright (C) 2004-2008 Richard Kettlewell
460b9539 5 *
e7eb3a27 6 * This program is free software: you can redistribute it and/or modify
460b9539 7 * it under the terms of the GNU General Public License as published by
e7eb3a27 8 * the Free Software Foundation, either version 3 of the License, or
460b9539 9 * (at your option) any later version.
e7eb3a27
RK
10 *
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.
15 *
460b9539 16 * You should have received a copy of the GNU General Public License
e7eb3a27 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 18 */
0e4472a0 19/** @file lib/configuration.h
20 * @brief Configuration file support
21 */
460b9539 22
23#ifndef CONFIGURATION_H
24#define CONFIGURATION_H
25
05b75f8d
RK
26#include <pcre.h>
27
6d2d327c 28#include "speaker-protocol.h"
04e1fa7c 29#include "rights.h"
9d5da576 30
460b9539 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.
33 */
34
3f3bb97b 35/** @brief A list of strings */
460b9539 36struct stringlist {
3f3bb97b 37 /** @brief Number of strings */
460b9539 38 int n;
3f3bb97b 39 /** @brief Array of strings */
460b9539 40 char **s;
41};
42
3f3bb97b 43/** @brief A list of list of strings */
460b9539 44struct stringlistlist {
3f3bb97b 45 /** @brief Number of string lists */
460b9539 46 int n;
3f3bb97b 47 /** @brief Array of string lists */
460b9539 48 struct stringlist *s;
49};
50
3f3bb97b 51/** @brief A collection of tracks */
460b9539 52struct collection {
3f3bb97b 53 /** @brief Module that supports this collection */
460b9539 54 char *module;
3f3bb97b 55 /** @brief Filename encoding */
460b9539 56 char *encoding;
3f3bb97b 57 /** @brief Root directory */
460b9539 58 char *root;
59};
60
3f3bb97b 61/** @brief A list of collections */
460b9539 62struct collectionlist {
3f3bb97b 63 /** @brief Number of collections */
460b9539 64 int n;
3f3bb97b 65 /** @brief Array of collections */
460b9539 66 struct collection *s;
67};
68
69struct namepart {
70 char *part; /* part */
05b75f8d 71 pcre *re; /* regexp */
460b9539 72 char *replace; /* replacement string */
73 char *context; /* context glob */
74 unsigned reflags; /* regexp flags */
75};
76
77struct namepartlist {
78 int n;
79 struct namepart *s;
80};
81
82struct transform {
83 char *type; /* track or dir */
84 char *context; /* sort or choose */
85 char *replace; /* substitution string */
05b75f8d 86 pcre *re; /* compiled re */
460b9539 87 unsigned flags; /* regexp flags */
88};
89
90struct transformlist {
91 int n;
92 struct transform *t;
93};
94
3f3bb97b 95/** @brief System configuration */
460b9539 96struct config {
97 /* server config */
3f3bb97b 98
637fdea3
RK
99 /** @brief Authorization algorithm */
100 char *authorization_algorithm;
101
3f3bb97b
RK
102 /** @brief All players */
103 struct stringlistlist player;
104
62dc3748
RK
105 /** @brief All tracklength plugins */
106 struct stringlistlist tracklength;
107
3f3bb97b
RK
108 /** @brief Allowed users */
109 struct stringlistlist allow;
110
111 /** @brief Scratch tracks */
112 struct stringlist scratch;
113
114 /** @brief Gap between tracks in seconds */
115 long gap;
116
117 /** @brief Maximum number of recent tracks to record in history */
118 long history;
119
2a10b70b
RK
120 /** @brief Expiry limit for noticed.db */
121 long noticed_history;
122
3f3bb97b
RK
123 /** @brief Trusted users */
124 struct stringlist trust;
125
126 /** @brief User for server to run as */
127 const char *user;
128
129 /** @brief Nice value for rescan subprocess */
130 long nice_rescan;
131
132 /** @brief Paths to search for plugins */
133 struct stringlist plugins;
134
135 /** @brief List of stopwords */
136 struct stringlist stopword;
137
138 /** @brief List of collections */
139 struct collectionlist collection;
140
141 /** @brief Database checkpoint byte limit */
460b9539 142 long checkpoint_kbyte;
3f3bb97b
RK
143
144 /** @brief Databsase checkpoint minimum */
460b9539 145 long checkpoint_min;
3f3bb97b
RK
146
147 /** @brief Path to mixer device */
148 char *mixer;
149
150 /** @brief Mixer channel to use */
151 char *channel;
152
153 long prefsync; /* preflog sync interval */
154
155 /** @brief Secondary listen address */
156 struct stringlist listen;
157
158 /** @brief Alias format string */
159 const char *alias;
160
161 /** @brief Enable server locking */
162 int lock;
163
164 /** @brief Nice value for server */
165 long nice_server;
166
167 /** @brief Nice value for speaker */
168 long nice_speaker;
169
170 /** @brief Command execute by speaker to play audio */
171 const char *speaker_command;
172
173 /** @brief Target sample format */
6d2d327c 174 struct stream_header sample_format;
3f3bb97b
RK
175
176 /** @brief Sox syntax generation */
177 long sox_generation;
178
bd8895a8 179 /** @brief API used to play sound
3f3bb97b
RK
180 *
181 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
182 * BACKEND_NETWORK.
183 */
bd8895a8 184 int api;
8aae240b 185
2563dc1f
RK
186 /** @brief Maximum size of a playlist */
187 long playlist_max;
188
ddbf05c8
RK
189 /** @brief Maximum lifetime of a playlist lock */
190 long playlist_lock_timeout;
191
8aae240b 192/* These values had better be non-negative */
3f3bb97b
RK
193#define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
194#define BACKEND_COMMAND 1 /**< Execute a command */
195#define BACKEND_NETWORK 2 /**< Transmit RTP */
937be4c0 196#define BACKEND_COREAUDIO 3 /**< Use Core Audio (Mac only) */
e99d42b1 197#define BACKEND_OSS 4 /**< Use OSS */
3f3bb97b 198
3c499fe7
RK
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
205#else
206# error Cannot choose a default backend
207#endif
208
3f3bb97b
RK
209 /** @brief Home directory for state files */
210 const char *home;
211
212 /** @brief Login username */
213 const char *username;
214
215 /** @brief Login password */
216 const char *password;
217
218 /** @brief Address to connect to */
219 struct stringlist connect;
220
221 /** @brief Directories to search for web templates */
222 struct stringlist templates;
223
224 /** @brief Canonical URL of web interface */
b64c2805 225 char *url;
3f3bb97b 226
61507e3c
RK
227 /** @brief Short display limit */
228 long short_display;
229
3f3bb97b
RK
230 /** @brief Maximum refresh interval for web interface (seconds) */
231 long refresh;
232
233 /** @brief Facilities restricted to trusted users
234 *
235 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
236 * RESTRICT_MOVE.
237 */
460b9539 238 unsigned restrictions; /* restrictions */
3f3bb97b
RK
239#define RESTRICT_SCRATCH 1 /**< Restrict scratching */
240#define RESTRICT_REMOVE 2 /**< Restrict removal */
241#define RESTRICT_MOVE 4 /**< Restrict rearrangement */
242
243 /** @brief Target queue length */
244 long queue_pad;
245
cebe3127
RK
246 /** @brief Minimum time between a track being played again */
247 long replay_min;
248
460b9539 249 struct namepartlist namepart; /* transformations */
3f3bb97b
RK
250
251 /** @brief Termination signal for subprocesses */
252 int signal;
253
254 /** @brief ALSA output device */
255 const char *device;
460b9539 256 struct transformlist transform; /* path name transformations */
257
23205f9c
RK
258 /** @brief Address to send audio data to */
259 struct stringlist broadcast;
260
261 /** @brief Source address for network audio transmission */
262 struct stringlist broadcast_from;
263
264 /** @brief TTL for multicast packets */
265 long multicast_ttl;
e83d0967 266
61941295
RK
267 /** @brief Whether to loop back multicast packets */
268 int multicast_loop;
b12be54a
RK
269
270 /** @brief Login lifetime in seconds */
271 long cookie_login_lifetime;
272
273 /** @brief Signing key lifetime in seconds */
274 long cookie_key_lifetime;
04e1fa7c
RK
275
276 /** @brief Default rights for a new user */
0f55e905 277 char *default_rights;
bb6ae3fb 278
2eee4b0c
RK
279 /** @brief Path to sendmail executable */
280 char *sendmail;
281
bb6ae3fb 282 /** @brief SMTP server for sending mail */
283 char *smtp_server;
284
285 /** @brief Origin address for outbound mail */
286 char *mail_sender;
d742bb47
RK
287
288 /** @brief Maximum number of tracks in response to 'new' */
289 long new_max;
6207d2f3 290
291 /** @brief Minimum interval between password reminder emails */
292 long reminder_interval;
810b8083
RK
293
294 /** @brief Whether to allow user management over TCP */
295 int remote_userman;
05dcfac6
RK
296
297 /** @brief Maximum age of biased-up tracks */
298 long new_bias_age;
299
300 /** @brief Maximum bias */
301 long new_bias;
61941295 302
460b9539 303 /* derived values: */
304 int nparts; /* number of distinct name parts */
305 char **parts; /* name part list */
8818b7fc
RK
306
307 /* undocumented, for testing only */
308 long dbversion;
460b9539 309};
310
311extern struct config *config;
312/* the current configuration */
313
c00fce3a 314int config_read(int server);
460b9539 315/* re-read config, return 0 on success or non-0 on error.
316 * Only updates @config@ if the new configuration is valid. */
317
319d7107 318char *config_get_file2(struct config *c, const char *name);
460b9539 319char *config_get_file(const char *name);
320/* get a filename within the home directory */
321
322struct passwd;
323
324char *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 */
327
328char *config_usersysconf(const struct passwd *pw );
329/* get the user's conffile in /etc */
330
331char *config_private(void);
332/* get the private config file */
333
334extern char *configfile;
63ad732f 335extern int config_per_user;
460b9539 336
337#endif /* CONFIGURATION_H */
338
339/*
340Local Variables:
341c-basic-offset:2
342comment-column:40
343End:
344*/