chiark / gitweb /
Warn on attempts to change nice_server during server lifetime.
[disorder] / lib / configuration.h
... / ...
CommitLineData
1/*
2 * This file is part of DisOrder.
3 * Copyright (C) 2004-2009 Richard Kettlewell
4 *
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.
9 *
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.
14 *
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/>.
17 */
18/** @file lib/configuration.h
19 * @brief Configuration file support
20 */
21
22#ifndef CONFIGURATION_H
23#define CONFIGURATION_H
24
25#include <pcre.h>
26
27#include "speaker-protocol.h"
28#include "rights.h"
29#include "addr.h"
30
31struct uaudio;
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; /* compiled regexp */
74 char *res; /* regexp as a string */
75 char *replace; /* replacement string */
76 char *context; /* context glob */
77 unsigned reflags; /* regexp flags */
78};
79
80struct namepartlist {
81 int n;
82 struct namepart *s;
83};
84
85struct transform {
86 char *type; /* track or dir */
87 char *context; /* sort or choose */
88 char *replace; /* substitution string */
89 pcre *re; /* compiled re */
90 unsigned flags; /* regexp flags */
91};
92
93struct transformlist {
94 int n;
95 struct transform *t;
96};
97
98/** @brief System configuration */
99struct config {
100 /* server config */
101
102 /** @brief Authorization algorithm */
103 char *authorization_algorithm;
104
105 /** @brief All players */
106 struct stringlistlist player;
107
108 /** @brief All tracklength plugins */
109 struct stringlistlist tracklength;
110
111 /** @brief Allowed users */
112 struct stringlistlist allow;
113
114 /** @brief Scratch tracks */
115 struct stringlist scratch;
116
117 /** @brief Gap between tracks in seconds */
118 long gap;
119
120 /** @brief Maximum number of recent tracks to record in history */
121 long history;
122
123 /** @brief Expiry limit for noticed.db */
124 long noticed_history;
125
126 /** @brief Trusted users */
127 struct stringlist trust;
128
129 /** @brief User for server to run as */
130 const char *user;
131
132 /** @brief Nice value for rescan subprocess */
133 long nice_rescan;
134
135 /** @brief Paths to search for plugins */
136 struct stringlist plugins;
137
138 /** @brief List of stopwords */
139 struct stringlist stopword;
140
141 /** @brief List of collections */
142 struct collectionlist collection;
143
144 /** @brief Database checkpoint byte limit */
145 long checkpoint_kbyte;
146
147 /** @brief Databsase checkpoint minimum */
148 long checkpoint_min;
149
150 /** @brief Path to mixer device */
151 char *mixer;
152
153 /** @brief Mixer channel to use */
154 char *channel;
155
156 long prefsync; /* preflog sync interval */
157
158 /** @brief Secondary listen address */
159 struct netaddress listen;
160
161 /** @brief Alias format string */
162 const char *alias;
163
164 /** @brief Enable server locking */
165 int lock;
166
167 /** @brief Nice value for server */
168 long nice_server;
169
170 /** @brief Nice value for speaker */
171 long nice_speaker;
172
173 /** @brief Command execute by speaker to play audio */
174 const char *speaker_command;
175
176 /** @brief Pause mode for command backend */
177 const char *pause_mode;
178
179 /** @brief Target sample format */
180 struct stream_header sample_format;
181
182 /** @brief Sox syntax generation */
183 long sox_generation;
184
185 /** @brief API used to play sound */
186 const char *api;
187
188 /** @brief Home directory for state files */
189 const char *home;
190
191 /** @brief Login username */
192 const char *username;
193
194 /** @brief Login password */
195 const char *password;
196
197 /** @brief Address to connect to */
198 struct netaddress connect;
199
200 /** @brief Directories to search for web templates */
201 struct stringlist templates;
202
203 /** @brief Canonical URL of web interface */
204 char *url;
205
206 /** @brief Short display limit */
207 long short_display;
208
209 /** @brief Maximum refresh interval for web interface (seconds) */
210 long refresh;
211
212 /** @brief Facilities restricted to trusted users
213 *
214 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
215 * RESTRICT_MOVE.
216 */
217 unsigned restrictions; /* restrictions */
218#define RESTRICT_SCRATCH 1 /**< Restrict scratching */
219#define RESTRICT_REMOVE 2 /**< Restrict removal */
220#define RESTRICT_MOVE 4 /**< Restrict rearrangement */
221
222 /** @brief Target queue length */
223 long queue_pad;
224
225 /** @brief Minimum time between a track being played again */
226 long replay_min;
227
228 struct namepartlist namepart; /* transformations */
229
230 /** @brief Termination signal for subprocesses */
231 int signal;
232
233 /** @brief ALSA output device */
234 const char *device;
235 struct transformlist transform; /* path name transformations */
236
237 /** @brief Address to send audio data to */
238 struct netaddress broadcast;
239
240 /** @brief Source address for network audio transmission */
241 struct netaddress broadcast_from;
242
243 /** @brief RTP delay threshold */
244 long rtp_delay_threshold;
245
246 /** @brief TTL for multicast packets */
247 long multicast_ttl;
248
249 /** @brief Whether to loop back multicast packets */
250 int multicast_loop;
251
252 /** @brief Login lifetime in seconds */
253 long cookie_login_lifetime;
254
255 /** @brief Signing key lifetime in seconds */
256 long cookie_key_lifetime;
257
258 /** @brief Default rights for a new user */
259 char *default_rights;
260
261 /** @brief Path to sendmail executable */
262 char *sendmail;
263
264 /** @brief SMTP server for sending mail */
265 char *smtp_server;
266
267 /** @brief Origin address for outbound mail */
268 char *mail_sender;
269
270 /** @brief Maximum number of tracks in response to 'new' */
271 long new_max;
272
273 /** @brief Minimum interval between password reminder emails */
274 long reminder_interval;
275
276 /** @brief Whether to allow user management over TCP */
277 int remote_userman;
278
279 /** @brief Maximum age of biased-up tracks */
280 long new_bias_age;
281
282 /** @brief Maximum bias */
283 long new_bias;
284
285 /* derived values: */
286 int nparts; /* number of distinct name parts */
287 char **parts; /* name part list */
288
289 /* undocumented, for testing only */
290 long dbversion;
291};
292
293extern struct config *config;
294/* the current configuration */
295
296int config_read(int server,
297 const struct config *oldconfig);
298/* re-read config, return 0 on success or non-0 on error.
299 * Only updates @config@ if the new configuration is valid. */
300
301char *config_get_file2(struct config *c, const char *name);
302char *config_get_file(const char *name);
303/* get a filename within the home directory */
304
305struct passwd;
306
307char *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 */
310
311char *config_usersysconf(const struct passwd *pw );
312/* get the user's conffile in /etc */
313
314char *config_private(void);
315/* get the private config file */
316
317extern char *configfile;
318extern int config_per_user;
319
320extern const struct uaudio *const *config_uaudio_apis;
321
322#endif /* CONFIGURATION_H */
323
324/*
325Local Variables:
326c-basic-offset:2
327comment-column:40
328End:
329*/