Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
2a1c84fb | 3 | * Copyright (C) 2004-2010 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 | ||
05b75f8d RK |
25 | #include <pcre.h> |
26 | ||
6d2d327c | 27 | #include "speaker-protocol.h" |
04e1fa7c | 28 | #include "rights.h" |
76e72f65 | 29 | #include "addr.h" |
9d5da576 | 30 | |
b50cfb8a RK |
31 | struct uaudio; |
32 | ||
460b9539 | 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 | ||
3f3bb97b | 37 | /** @brief A list of strings */ |
460b9539 | 38 | struct stringlist { |
3f3bb97b | 39 | /** @brief Number of strings */ |
460b9539 | 40 | int n; |
3f3bb97b | 41 | /** @brief Array of strings */ |
460b9539 | 42 | char **s; |
43 | }; | |
44 | ||
3f3bb97b | 45 | /** @brief A list of list of strings */ |
460b9539 | 46 | struct stringlistlist { |
3f3bb97b | 47 | /** @brief Number of string lists */ |
460b9539 | 48 | int n; |
3f3bb97b | 49 | /** @brief Array of string lists */ |
460b9539 | 50 | struct stringlist *s; |
51 | }; | |
52 | ||
3f3bb97b | 53 | /** @brief A collection of tracks */ |
460b9539 | 54 | struct collection { |
3f3bb97b | 55 | /** @brief Module that supports this collection */ |
460b9539 | 56 | char *module; |
3f3bb97b | 57 | /** @brief Filename encoding */ |
460b9539 | 58 | char *encoding; |
3f3bb97b | 59 | /** @brief Root directory */ |
460b9539 | 60 | char *root; |
61 | }; | |
62 | ||
3f3bb97b | 63 | /** @brief A list of collections */ |
460b9539 | 64 | struct collectionlist { |
3f3bb97b | 65 | /** @brief Number of collections */ |
460b9539 | 66 | int n; |
3f3bb97b | 67 | /** @brief Array of collections */ |
460b9539 | 68 | struct collection *s; |
69 | }; | |
70 | ||
71 | struct namepart { | |
72 | char *part; /* part */ | |
9417e1a3 RK |
73 | pcre *re; /* compiled regexp */ |
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 | ||
80 | struct namepartlist { | |
81 | int n; | |
82 | struct namepart *s; | |
83 | }; | |
84 | ||
85 | struct transform { | |
86 | char *type; /* track or dir */ | |
87 | char *context; /* sort or choose */ | |
88 | char *replace; /* substitution string */ | |
05b75f8d | 89 | pcre *re; /* compiled re */ |
460b9539 | 90 | unsigned flags; /* regexp flags */ |
91 | }; | |
92 | ||
93 | struct transformlist { | |
94 | int n; | |
95 | struct transform *t; | |
96 | }; | |
97 | ||
3f3bb97b | 98 | /** @brief System configuration */ |
460b9539 | 99 | struct config { |
100 | /* server config */ | |
3f3bb97b | 101 | |
637fdea3 RK |
102 | /** @brief Authorization algorithm */ |
103 | char *authorization_algorithm; | |
104 | ||
3f3bb97b RK |
105 | /** @brief All players */ |
106 | struct stringlistlist player; | |
107 | ||
62dc3748 RK |
108 | /** @brief All tracklength plugins */ |
109 | struct stringlistlist tracklength; | |
110 | ||
3f3bb97b RK |
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 | ||
2a10b70b RK |
123 | /** @brief Expiry limit for noticed.db */ |
124 | long noticed_history; | |
125 | ||
3f3bb97b RK |
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 */ | |
460b9539 | 145 | long checkpoint_kbyte; |
3f3bb97b RK |
146 | |
147 | /** @brief Databsase checkpoint minimum */ | |
460b9539 | 148 | long checkpoint_min; |
3f3bb97b RK |
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 */ | |
80dc2c5f | 159 | struct netaddress listen; |
3f3bb97b RK |
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 | ||
f75ab9d3 RK |
176 | /** @brief Pause mode for command backend */ |
177 | const char *pause_mode; | |
178 | ||
3f3bb97b | 179 | /** @brief Target sample format */ |
6d2d327c | 180 | struct stream_header sample_format; |
3f3bb97b RK |
181 | |
182 | /** @brief Sox syntax generation */ | |
183 | long sox_generation; | |
184 | ||
b50cfb8a RK |
185 | /** @brief API used to play sound */ |
186 | const char *api; | |
3c499fe7 | 187 | |
2563dc1f RK |
188 | /** @brief Maximum size of a playlist */ |
189 | long playlist_max; | |
190 | ||
ddbf05c8 RK |
191 | /** @brief Maximum lifetime of a playlist lock */ |
192 | long playlist_lock_timeout; | |
193 | ||
3f3bb97b RK |
194 | /** @brief Home directory for state files */ |
195 | const char *home; | |
196 | ||
197 | /** @brief Login username */ | |
198 | const char *username; | |
199 | ||
200 | /** @brief Login password */ | |
201 | const char *password; | |
202 | ||
203 | /** @brief Address to connect to */ | |
e41a9999 | 204 | struct netaddress connect; |
3f3bb97b RK |
205 | |
206 | /** @brief Directories to search for web templates */ | |
207 | struct stringlist templates; | |
208 | ||
209 | /** @brief Canonical URL of web interface */ | |
b64c2805 | 210 | char *url; |
3f3bb97b | 211 | |
61507e3c RK |
212 | /** @brief Short display limit */ |
213 | long short_display; | |
214 | ||
3f3bb97b RK |
215 | /** @brief Maximum refresh interval for web interface (seconds) */ |
216 | long refresh; | |
217 | ||
533272be RK |
218 | /** @brief Minimum refresh interval for web interface (seconds) */ |
219 | long refresh_min; | |
220 | ||
3f3bb97b RK |
221 | /** @brief Facilities restricted to trusted users |
222 | * | |
223 | * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref | |
224 | * RESTRICT_MOVE. | |
225 | */ | |
460b9539 | 226 | unsigned restrictions; /* restrictions */ |
3f3bb97b RK |
227 | #define RESTRICT_SCRATCH 1 /**< Restrict scratching */ |
228 | #define RESTRICT_REMOVE 2 /**< Restrict removal */ | |
229 | #define RESTRICT_MOVE 4 /**< Restrict rearrangement */ | |
230 | ||
231 | /** @brief Target queue length */ | |
232 | long queue_pad; | |
233 | ||
cebe3127 RK |
234 | /** @brief Minimum time between a track being played again */ |
235 | long replay_min; | |
236 | ||
460b9539 | 237 | struct namepartlist namepart; /* transformations */ |
3f3bb97b RK |
238 | |
239 | /** @brief Termination signal for subprocesses */ | |
240 | int signal; | |
241 | ||
242 | /** @brief ALSA output device */ | |
243 | const char *device; | |
460b9539 | 244 | struct transformlist transform; /* path name transformations */ |
245 | ||
23205f9c | 246 | /** @brief Address to send audio data to */ |
76e72f65 | 247 | struct netaddress broadcast; |
23205f9c RK |
248 | |
249 | /** @brief Source address for network audio transmission */ | |
76e72f65 | 250 | struct netaddress broadcast_from; |
23205f9c | 251 | |
ba70caca RK |
252 | /** @brief RTP delay threshold */ |
253 | long rtp_delay_threshold; | |
254 | ||
23205f9c RK |
255 | /** @brief TTL for multicast packets */ |
256 | long multicast_ttl; | |
e83d0967 | 257 | |
61941295 RK |
258 | /** @brief Whether to loop back multicast packets */ |
259 | int multicast_loop; | |
b12be54a RK |
260 | |
261 | /** @brief Login lifetime in seconds */ | |
262 | long cookie_login_lifetime; | |
263 | ||
264 | /** @brief Signing key lifetime in seconds */ | |
265 | long cookie_key_lifetime; | |
04e1fa7c RK |
266 | |
267 | /** @brief Default rights for a new user */ | |
0f55e905 | 268 | char *default_rights; |
bb6ae3fb | 269 | |
2eee4b0c RK |
270 | /** @brief Path to sendmail executable */ |
271 | char *sendmail; | |
272 | ||
bb6ae3fb | 273 | /** @brief SMTP server for sending mail */ |
274 | char *smtp_server; | |
275 | ||
276 | /** @brief Origin address for outbound mail */ | |
277 | char *mail_sender; | |
d742bb47 RK |
278 | |
279 | /** @brief Maximum number of tracks in response to 'new' */ | |
280 | long new_max; | |
6207d2f3 | 281 | |
282 | /** @brief Minimum interval between password reminder emails */ | |
283 | long reminder_interval; | |
810b8083 RK |
284 | |
285 | /** @brief Whether to allow user management over TCP */ | |
286 | int remote_userman; | |
05dcfac6 RK |
287 | |
288 | /** @brief Maximum age of biased-up tracks */ | |
289 | long new_bias_age; | |
290 | ||
291 | /** @brief Maximum bias */ | |
292 | long new_bias; | |
8488cf7d RK |
293 | |
294 | /** @brief Rescan on (un)mount */ | |
295 | int mount_rescan; | |
296 | ||
460b9539 | 297 | /* derived values: */ |
298 | int nparts; /* number of distinct name parts */ | |
299 | char **parts; /* name part list */ | |
8818b7fc RK |
300 | |
301 | /* undocumented, for testing only */ | |
302 | long dbversion; | |
460b9539 | 303 | }; |
304 | ||
305 | extern struct config *config; | |
306 | /* the current configuration */ | |
307 | ||
02ba7921 RK |
308 | int config_read(int server, |
309 | const struct config *oldconfig); | |
460b9539 | 310 | /* re-read config, return 0 on success or non-0 on error. |
311 | * Only updates @config@ if the new configuration is valid. */ | |
312 | ||
319d7107 | 313 | char *config_get_file2(struct config *c, const char *name); |
460b9539 | 314 | char *config_get_file(const char *name); |
315 | /* get a filename within the home directory */ | |
316 | ||
317 | struct passwd; | |
318 | ||
319 | char *config_userconf(const char *home, const struct passwd *pw); | |
320 | /* get the user's own private conffile, assuming their home dir is | |
321 | * @home@ if not null and using @pw@ otherwise */ | |
322 | ||
323 | char *config_usersysconf(const struct passwd *pw ); | |
324 | /* get the user's conffile in /etc */ | |
325 | ||
326 | char *config_private(void); | |
327 | /* get the private config file */ | |
328 | ||
2a1c84fb RK |
329 | int config_verify(void); |
330 | ||
460b9539 | 331 | extern char *configfile; |
63ad732f | 332 | extern int config_per_user; |
460b9539 | 333 | |
b50cfb8a RK |
334 | extern const struct uaudio *const *config_uaudio_apis; |
335 | ||
460b9539 | 336 | #endif /* CONFIGURATION_H */ |
337 | ||
338 | /* | |
339 | Local Variables: | |
340 | c-basic-offset:2 | |
341 | comment-column:40 | |
342 | End: | |
343 | */ |