Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
cca89d7c | 3 | * Copyright (C) 2004-2011, 2013 Richard Kettlewell |
460b9539 | 4 | * |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
460b9539 | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
460b9539 | 8 | * (at your option) any later version. |
e7eb3a27 RK |
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 | * | |
460b9539 | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
460b9539 | 17 | */ |
0e4472a0 | 18 | /** @file lib/configuration.h |
19 | * @brief Configuration file support | |
20 | */ | |
460b9539 | 21 | |
22 | #ifndef CONFIGURATION_H | |
23 | #define CONFIGURATION_H | |
24 | ||
6d2d327c | 25 | #include "speaker-protocol.h" |
a2e9d147 | 26 | #include "regexp.h" |
04e1fa7c | 27 | #include "rights.h" |
76e72f65 | 28 | #include "addr.h" |
9d5da576 | 29 | |
b50cfb8a RK |
30 | struct uaudio; |
31 | ||
460b9539 | 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. | |
34 | */ | |
35 | ||
3f3bb97b | 36 | /** @brief A list of strings */ |
460b9539 | 37 | struct stringlist { |
3f3bb97b | 38 | /** @brief Number of strings */ |
460b9539 | 39 | int n; |
3f3bb97b | 40 | /** @brief Array of strings */ |
460b9539 | 41 | char **s; |
42 | }; | |
43 | ||
3f3bb97b | 44 | /** @brief A list of list of strings */ |
460b9539 | 45 | struct stringlistlist { |
3f3bb97b | 46 | /** @brief Number of string lists */ |
460b9539 | 47 | int n; |
3f3bb97b | 48 | /** @brief Array of string lists */ |
460b9539 | 49 | struct stringlist *s; |
50 | }; | |
51 | ||
3f3bb97b | 52 | /** @brief A collection of tracks */ |
460b9539 | 53 | struct collection { |
3f3bb97b | 54 | /** @brief Module that supports this collection */ |
460b9539 | 55 | char *module; |
3f3bb97b | 56 | /** @brief Filename encoding */ |
460b9539 | 57 | char *encoding; |
3f3bb97b | 58 | /** @brief Root directory */ |
460b9539 | 59 | char *root; |
60 | }; | |
61 | ||
3f3bb97b | 62 | /** @brief A list of collections */ |
460b9539 | 63 | struct collectionlist { |
3f3bb97b | 64 | /** @brief Number of collections */ |
460b9539 | 65 | int n; |
3f3bb97b | 66 | /** @brief Array of collections */ |
460b9539 | 67 | struct collection *s; |
68 | }; | |
69 | ||
598b07b7 | 70 | /** @brief A track name part */ |
460b9539 | 71 | struct namepart { |
72 | char *part; /* part */ | |
a2e9d147 | 73 | regexp *re; /* compiled regexp */ |
9417e1a3 | 74 | char *res; /* regexp as a string */ |
460b9539 | 75 | char *replace; /* replacement string */ |
76 | char *context; /* context glob */ | |
77 | unsigned reflags; /* regexp flags */ | |
78 | }; | |
79 | ||
598b07b7 | 80 | /** @brief A list of track name parts */ |
460b9539 | 81 | struct namepartlist { |
82 | int n; | |
83 | struct namepart *s; | |
84 | }; | |
85 | ||
598b07b7 | 86 | /** @brief A track name transform */ |
460b9539 | 87 | struct transform { |
88 | char *type; /* track or dir */ | |
89 | char *context; /* sort or choose */ | |
90 | char *replace; /* substitution string */ | |
a2e9d147 | 91 | regexp *re; /* compiled re */ |
460b9539 | 92 | unsigned flags; /* regexp flags */ |
93 | }; | |
94 | ||
598b07b7 | 95 | /** @brief A list of track name transforms */ |
460b9539 | 96 | struct transformlist { |
97 | int n; | |
98 | struct transform *t; | |
99 | }; | |
100 | ||
3f3bb97b | 101 | /** @brief System configuration */ |
460b9539 | 102 | struct config { |
103 | /* server config */ | |
3f3bb97b | 104 | |
637fdea3 RK |
105 | /** @brief Authorization algorithm */ |
106 | char *authorization_algorithm; | |
107 | ||
3f3bb97b RK |
108 | /** @brief All players */ |
109 | struct stringlistlist player; | |
110 | ||
62dc3748 RK |
111 | /** @brief All tracklength plugins */ |
112 | struct stringlistlist tracklength; | |
113 | ||
3f3bb97b RK |
114 | /** @brief Scratch tracks */ |
115 | struct stringlist scratch; | |
116 | ||
3f3bb97b RK |
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 User for server to run as */ |
124 | const char *user; | |
125 | ||
126 | /** @brief Nice value for rescan subprocess */ | |
127 | long nice_rescan; | |
128 | ||
129 | /** @brief Paths to search for plugins */ | |
130 | struct stringlist plugins; | |
131 | ||
132 | /** @brief List of stopwords */ | |
133 | struct stringlist stopword; | |
134 | ||
135 | /** @brief List of collections */ | |
136 | struct collectionlist collection; | |
137 | ||
138 | /** @brief Database checkpoint byte limit */ | |
460b9539 | 139 | long checkpoint_kbyte; |
3f3bb97b RK |
140 | |
141 | /** @brief Databsase checkpoint minimum */ | |
460b9539 | 142 | long checkpoint_min; |
3f3bb97b RK |
143 | |
144 | /** @brief Path to mixer device */ | |
145 | char *mixer; | |
146 | ||
147 | /** @brief Mixer channel to use */ | |
148 | char *channel; | |
149 | ||
3f3bb97b | 150 | /** @brief Secondary listen address */ |
80dc2c5f | 151 | struct netaddress listen; |
3f3bb97b RK |
152 | |
153 | /** @brief Alias format string */ | |
154 | const char *alias; | |
155 | ||
3f3bb97b RK |
156 | /** @brief Nice value for server */ |
157 | long nice_server; | |
158 | ||
159 | /** @brief Nice value for speaker */ | |
160 | long nice_speaker; | |
161 | ||
162 | /** @brief Command execute by speaker to play audio */ | |
163 | const char *speaker_command; | |
164 | ||
f75ab9d3 RK |
165 | /** @brief Pause mode for command backend */ |
166 | const char *pause_mode; | |
167 | ||
3f3bb97b | 168 | /** @brief Target sample format */ |
6d2d327c | 169 | struct stream_header sample_format; |
3f3bb97b RK |
170 | |
171 | /** @brief Sox syntax generation */ | |
172 | long sox_generation; | |
173 | ||
b50cfb8a RK |
174 | /** @brief API used to play sound */ |
175 | const char *api; | |
3c499fe7 | 176 | |
2563dc1f RK |
177 | /** @brief Maximum size of a playlist */ |
178 | long playlist_max; | |
179 | ||
ddbf05c8 RK |
180 | /** @brief Maximum lifetime of a playlist lock */ |
181 | long playlist_lock_timeout; | |
182 | ||
9e42afcd | 183 | #if !_WIN32 |
3f3bb97b RK |
184 | /** @brief Home directory for state files */ |
185 | const char *home; | |
9e42afcd | 186 | #endif |
3f3bb97b RK |
187 | |
188 | /** @brief Login username */ | |
47854c5f | 189 | char *username; |
3f3bb97b RK |
190 | |
191 | /** @brief Login password */ | |
47854c5f | 192 | char *password; |
3f3bb97b RK |
193 | |
194 | /** @brief Address to connect to */ | |
e41a9999 | 195 | struct netaddress connect; |
3f3bb97b RK |
196 | |
197 | /** @brief Directories to search for web templates */ | |
198 | struct stringlist templates; | |
199 | ||
200 | /** @brief Canonical URL of web interface */ | |
b64c2805 | 201 | char *url; |
3f3bb97b | 202 | |
61507e3c RK |
203 | /** @brief Short display limit */ |
204 | long short_display; | |
205 | ||
3f3bb97b RK |
206 | /** @brief Maximum refresh interval for web interface (seconds) */ |
207 | long refresh; | |
208 | ||
533272be RK |
209 | /** @brief Minimum refresh interval for web interface (seconds) */ |
210 | long refresh_min; | |
211 | ||
3f3bb97b RK |
212 | /** @brief Target queue length */ |
213 | long queue_pad; | |
214 | ||
cebe3127 RK |
215 | /** @brief Minimum time between a track being played again */ |
216 | long replay_min; | |
217 | ||
460b9539 | 218 | struct namepartlist namepart; /* transformations */ |
3f3bb97b RK |
219 | |
220 | /** @brief Termination signal for subprocesses */ | |
221 | int signal; | |
222 | ||
223 | /** @brief ALSA output device */ | |
224 | const char *device; | |
cca89d7c | 225 | |
460b9539 | 226 | struct transformlist transform; /* path name transformations */ |
227 | ||
23205f9c | 228 | /** @brief Address to send audio data to */ |
76e72f65 | 229 | struct netaddress broadcast; |
23205f9c RK |
230 | |
231 | /** @brief Source address for network audio transmission */ | |
76e72f65 | 232 | struct netaddress broadcast_from; |
23205f9c | 233 | |
ba70caca RK |
234 | /** @brief RTP delay threshold */ |
235 | long rtp_delay_threshold; | |
87864f77 | 236 | |
14b5913c MW |
237 | /** @brief Whether to ignore the server's suggested RTP arrangement and |
238 | * always request a unicast stream */ | |
239 | int rtp_always_request; | |
240 | ||
241 | /** @brief RTP buffer low-water mark */ | |
242 | long rtp_minbuffer; | |
243 | ||
244 | /** @brief RTP buffer maximum size */ | |
245 | long rtp_maxbuffer; | |
246 | ||
53a4a6fd | 247 | /** @brief RTP receive buffer size */ |
14b5913c MW |
248 | long rtp_rcvbuf; |
249 | ||
250 | /** @brief Fixed RTP listening address */ | |
251 | struct netaddress rtp_request_address; | |
252 | ||
53a4a6fd MW |
253 | /** @brief @c disorder-playrtp instance name (for naming sockets etc.) */ |
254 | char *rtp_instance_name; | |
255 | ||
87864f77 RK |
256 | /** @brief Verbose RTP transmission logging */ |
257 | int rtp_verbose; | |
ba70caca | 258 | |
23205f9c RK |
259 | /** @brief TTL for multicast packets */ |
260 | long multicast_ttl; | |
e83d0967 | 261 | |
61941295 RK |
262 | /** @brief Whether to loop back multicast packets */ |
263 | int multicast_loop; | |
b12be54a | 264 | |
2a2b84aa MW |
265 | /** @brief Maximum size of RTP payload to send |
266 | * | |
267 | * This is the maximum number of bytes we pass to write(2); to determine | |
268 | * actual packet sizes, add a UDP header and an IP header (and a link layer | |
269 | * header if it's the link layer size you care about). | |
270 | * | |
271 | * Don't make this too big or arithmetic will start to overflow. | |
272 | */ | |
273 | long rtp_max_payload; | |
274 | ||
10511fad MW |
275 | /** @brief Whether to allow MTU discovery |
276 | * | |
277 | * This is `yes' to force it on, `no' to force it off, or `default' to do | |
278 | * whatever the system is configured to do. Note that this only has a | |
279 | * useful effect in IPv4, since IPv6 doesn't permit hop-by-hop | |
280 | * fragmentation. | |
281 | */ | |
282 | char *rtp_mtu_discovery; | |
283 | ||
b12be54a RK |
284 | /** @brief Login lifetime in seconds */ |
285 | long cookie_login_lifetime; | |
286 | ||
287 | /** @brief Signing key lifetime in seconds */ | |
288 | long cookie_key_lifetime; | |
04e1fa7c RK |
289 | |
290 | /** @brief Default rights for a new user */ | |
0f55e905 | 291 | char *default_rights; |
bb6ae3fb | 292 | |
2eee4b0c RK |
293 | /** @brief Path to sendmail executable */ |
294 | char *sendmail; | |
295 | ||
bb6ae3fb | 296 | /** @brief SMTP server for sending mail */ |
297 | char *smtp_server; | |
298 | ||
299 | /** @brief Origin address for outbound mail */ | |
300 | char *mail_sender; | |
d742bb47 RK |
301 | |
302 | /** @brief Maximum number of tracks in response to 'new' */ | |
303 | long new_max; | |
6207d2f3 | 304 | |
305 | /** @brief Minimum interval between password reminder emails */ | |
306 | long reminder_interval; | |
810b8083 RK |
307 | |
308 | /** @brief Whether to allow user management over TCP */ | |
309 | int remote_userman; | |
05dcfac6 RK |
310 | |
311 | /** @brief Maximum age of biased-up tracks */ | |
312 | long new_bias_age; | |
313 | ||
314 | /** @brief Maximum bias */ | |
315 | long new_bias; | |
8488cf7d RK |
316 | |
317 | /** @brief Rescan on (un)mount */ | |
318 | int mount_rescan; | |
319 | ||
b0116b5c RK |
320 | /** @brief RTP mode */ |
321 | const char *rtp_mode; | |
322 | ||
460b9539 | 323 | /* derived values: */ |
324 | int nparts; /* number of distinct name parts */ | |
325 | char **parts; /* name part list */ | |
8818b7fc RK |
326 | |
327 | /* undocumented, for testing only */ | |
328 | long dbversion; | |
460b9539 | 329 | }; |
330 | ||
331 | extern struct config *config; | |
332 | /* the current configuration */ | |
333 | ||
02ba7921 RK |
334 | int config_read(int server, |
335 | const struct config *oldconfig); | |
460b9539 | 336 | /* re-read config, return 0 on success or non-0 on error. |
337 | * Only updates @config@ if the new configuration is valid. */ | |
338 | ||
319d7107 | 339 | char *config_get_file2(struct config *c, const char *name); |
460b9539 | 340 | char *config_get_file(const char *name); |
341 | /* get a filename within the home directory */ | |
342 | ||
343 | struct passwd; | |
344 | ||
460b9539 | 345 | char *config_usersysconf(const struct passwd *pw ); |
346 | /* get the user's conffile in /etc */ | |
347 | ||
348 | char *config_private(void); | |
349 | /* get the private config file */ | |
350 | ||
2a1c84fb RK |
351 | int config_verify(void); |
352 | ||
47854c5f RK |
353 | void config_free(struct config *c); |
354 | ||
5dba54ab | 355 | extern char *configfile, *userconfigfile; |
63ad732f | 356 | extern int config_per_user; |
460b9539 | 357 | |
b50cfb8a RK |
358 | extern const struct uaudio *const *config_uaudio_apis; |
359 | ||
460b9539 | 360 | #endif /* CONFIGURATION_H */ |
361 | ||
362 | /* | |
363 | Local Variables: | |
364 | c-basic-offset:2 | |
365 | comment-column:40 | |
366 | End: | |
367 | */ |