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