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 | ||
598b07b7 | 71 | /** @brief A track name part */ |
460b9539 | 72 | struct namepart { |
73 | char *part; /* part */ | |
9417e1a3 RK |
74 | pcre *re; /* compiled regexp */ |
75 | char *res; /* regexp as a string */ | |
460b9539 | 76 | char *replace; /* replacement string */ |
77 | char *context; /* context glob */ | |
78 | unsigned reflags; /* regexp flags */ | |
79 | }; | |
80 | ||
598b07b7 | 81 | /** @brief A list of track name parts */ |
460b9539 | 82 | struct namepartlist { |
83 | int n; | |
84 | struct namepart *s; | |
85 | }; | |
86 | ||
598b07b7 | 87 | /** @brief A track name transform */ |
460b9539 | 88 | struct transform { |
89 | char *type; /* track or dir */ | |
90 | char *context; /* sort or choose */ | |
91 | char *replace; /* substitution string */ | |
05b75f8d | 92 | pcre *re; /* compiled re */ |
460b9539 | 93 | unsigned flags; /* regexp flags */ |
94 | }; | |
95 | ||
598b07b7 | 96 | /** @brief A list of track name transforms */ |
460b9539 | 97 | struct transformlist { |
98 | int n; | |
99 | struct transform *t; | |
100 | }; | |
101 | ||
3f3bb97b | 102 | /** @brief System configuration */ |
460b9539 | 103 | struct config { |
104 | /* server config */ | |
3f3bb97b | 105 | |
637fdea3 RK |
106 | /** @brief Authorization algorithm */ |
107 | char *authorization_algorithm; | |
108 | ||
3f3bb97b RK |
109 | /** @brief All players */ |
110 | struct stringlistlist player; | |
111 | ||
62dc3748 RK |
112 | /** @brief All tracklength plugins */ |
113 | struct stringlistlist tracklength; | |
114 | ||
3f3bb97b RK |
115 | /** @brief Scratch tracks */ |
116 | struct stringlist scratch; | |
117 | ||
3f3bb97b RK |
118 | /** @brief Maximum number of recent tracks to record in history */ |
119 | long history; | |
120 | ||
2a10b70b RK |
121 | /** @brief Expiry limit for noticed.db */ |
122 | long noticed_history; | |
123 | ||
3f3bb97b RK |
124 | /** @brief User for server to run as */ |
125 | const char *user; | |
126 | ||
127 | /** @brief Nice value for rescan subprocess */ | |
128 | long nice_rescan; | |
129 | ||
130 | /** @brief Paths to search for plugins */ | |
131 | struct stringlist plugins; | |
132 | ||
133 | /** @brief List of stopwords */ | |
134 | struct stringlist stopword; | |
135 | ||
136 | /** @brief List of collections */ | |
137 | struct collectionlist collection; | |
138 | ||
139 | /** @brief Database checkpoint byte limit */ | |
460b9539 | 140 | long checkpoint_kbyte; |
3f3bb97b RK |
141 | |
142 | /** @brief Databsase checkpoint minimum */ | |
460b9539 | 143 | long checkpoint_min; |
3f3bb97b RK |
144 | |
145 | /** @brief Path to mixer device */ | |
146 | char *mixer; | |
147 | ||
148 | /** @brief Mixer channel to use */ | |
149 | char *channel; | |
150 | ||
3f3bb97b | 151 | /** @brief Secondary listen address */ |
80dc2c5f | 152 | struct netaddress listen; |
3f3bb97b RK |
153 | |
154 | /** @brief Alias format string */ | |
155 | const char *alias; | |
156 | ||
3f3bb97b RK |
157 | /** @brief Nice value for server */ |
158 | long nice_server; | |
159 | ||
160 | /** @brief Nice value for speaker */ | |
161 | long nice_speaker; | |
162 | ||
163 | /** @brief Command execute by speaker to play audio */ | |
164 | const char *speaker_command; | |
165 | ||
f75ab9d3 RK |
166 | /** @brief Pause mode for command backend */ |
167 | const char *pause_mode; | |
168 | ||
3f3bb97b | 169 | /** @brief Target sample format */ |
6d2d327c | 170 | struct stream_header sample_format; |
3f3bb97b RK |
171 | |
172 | /** @brief Sox syntax generation */ | |
173 | long sox_generation; | |
174 | ||
b50cfb8a RK |
175 | /** @brief API used to play sound */ |
176 | const char *api; | |
3c499fe7 | 177 | |
2563dc1f RK |
178 | /** @brief Maximum size of a playlist */ |
179 | long playlist_max; | |
180 | ||
ddbf05c8 RK |
181 | /** @brief Maximum lifetime of a playlist lock */ |
182 | long playlist_lock_timeout; | |
183 | ||
3f3bb97b RK |
184 | /** @brief Home directory for state files */ |
185 | const char *home; | |
186 | ||
187 | /** @brief Login username */ | |
47854c5f | 188 | char *username; |
3f3bb97b RK |
189 | |
190 | /** @brief Login password */ | |
47854c5f | 191 | char *password; |
3f3bb97b RK |
192 | |
193 | /** @brief Address to connect to */ | |
e41a9999 | 194 | struct netaddress connect; |
3f3bb97b RK |
195 | |
196 | /** @brief Directories to search for web templates */ | |
197 | struct stringlist templates; | |
198 | ||
199 | /** @brief Canonical URL of web interface */ | |
b64c2805 | 200 | char *url; |
3f3bb97b | 201 | |
61507e3c RK |
202 | /** @brief Short display limit */ |
203 | long short_display; | |
204 | ||
3f3bb97b RK |
205 | /** @brief Maximum refresh interval for web interface (seconds) */ |
206 | long refresh; | |
207 | ||
533272be RK |
208 | /** @brief Minimum refresh interval for web interface (seconds) */ |
209 | long refresh_min; | |
210 | ||
3f3bb97b RK |
211 | /** @brief Target queue length */ |
212 | long queue_pad; | |
213 | ||
cebe3127 RK |
214 | /** @brief Minimum time between a track being played again */ |
215 | long replay_min; | |
216 | ||
460b9539 | 217 | struct namepartlist namepart; /* transformations */ |
3f3bb97b RK |
218 | |
219 | /** @brief Termination signal for subprocesses */ | |
220 | int signal; | |
221 | ||
222 | /** @brief ALSA output device */ | |
223 | const char *device; | |
460b9539 | 224 | struct transformlist transform; /* path name transformations */ |
225 | ||
23205f9c | 226 | /** @brief Address to send audio data to */ |
76e72f65 | 227 | struct netaddress broadcast; |
23205f9c RK |
228 | |
229 | /** @brief Source address for network audio transmission */ | |
76e72f65 | 230 | struct netaddress broadcast_from; |
23205f9c | 231 | |
ba70caca RK |
232 | /** @brief RTP delay threshold */ |
233 | long rtp_delay_threshold; | |
87864f77 RK |
234 | |
235 | /** @brief Verbose RTP transmission logging */ | |
236 | int rtp_verbose; | |
ba70caca | 237 | |
23205f9c RK |
238 | /** @brief TTL for multicast packets */ |
239 | long multicast_ttl; | |
e83d0967 | 240 | |
61941295 RK |
241 | /** @brief Whether to loop back multicast packets */ |
242 | int multicast_loop; | |
b12be54a RK |
243 | |
244 | /** @brief Login lifetime in seconds */ | |
245 | long cookie_login_lifetime; | |
246 | ||
247 | /** @brief Signing key lifetime in seconds */ | |
248 | long cookie_key_lifetime; | |
04e1fa7c RK |
249 | |
250 | /** @brief Default rights for a new user */ | |
0f55e905 | 251 | char *default_rights; |
bb6ae3fb | 252 | |
2eee4b0c RK |
253 | /** @brief Path to sendmail executable */ |
254 | char *sendmail; | |
255 | ||
bb6ae3fb | 256 | /** @brief SMTP server for sending mail */ |
257 | char *smtp_server; | |
258 | ||
259 | /** @brief Origin address for outbound mail */ | |
260 | char *mail_sender; | |
d742bb47 RK |
261 | |
262 | /** @brief Maximum number of tracks in response to 'new' */ | |
263 | long new_max; | |
6207d2f3 | 264 | |
265 | /** @brief Minimum interval between password reminder emails */ | |
266 | long reminder_interval; | |
810b8083 RK |
267 | |
268 | /** @brief Whether to allow user management over TCP */ | |
269 | int remote_userman; | |
05dcfac6 RK |
270 | |
271 | /** @brief Maximum age of biased-up tracks */ | |
272 | long new_bias_age; | |
273 | ||
274 | /** @brief Maximum bias */ | |
275 | long new_bias; | |
8488cf7d RK |
276 | |
277 | /** @brief Rescan on (un)mount */ | |
278 | int mount_rescan; | |
279 | ||
460b9539 | 280 | /* derived values: */ |
281 | int nparts; /* number of distinct name parts */ | |
282 | char **parts; /* name part list */ | |
8818b7fc RK |
283 | |
284 | /* undocumented, for testing only */ | |
285 | long dbversion; | |
460b9539 | 286 | }; |
287 | ||
288 | extern struct config *config; | |
289 | /* the current configuration */ | |
290 | ||
02ba7921 RK |
291 | int config_read(int server, |
292 | const struct config *oldconfig); | |
460b9539 | 293 | /* re-read config, return 0 on success or non-0 on error. |
294 | * Only updates @config@ if the new configuration is valid. */ | |
295 | ||
319d7107 | 296 | char *config_get_file2(struct config *c, const char *name); |
460b9539 | 297 | char *config_get_file(const char *name); |
298 | /* get a filename within the home directory */ | |
299 | ||
300 | struct passwd; | |
301 | ||
302 | char *config_userconf(const char *home, const struct passwd *pw); | |
303 | /* get the user's own private conffile, assuming their home dir is | |
304 | * @home@ if not null and using @pw@ otherwise */ | |
305 | ||
306 | char *config_usersysconf(const struct passwd *pw ); | |
307 | /* get the user's conffile in /etc */ | |
308 | ||
309 | char *config_private(void); | |
310 | /* get the private config file */ | |
311 | ||
2a1c84fb RK |
312 | int config_verify(void); |
313 | ||
47854c5f RK |
314 | void config_free(struct config *c); |
315 | ||
460b9539 | 316 | extern char *configfile; |
63ad732f | 317 | extern int config_per_user; |
460b9539 | 318 | |
b50cfb8a RK |
319 | extern const struct uaudio *const *config_uaudio_apis; |
320 | ||
460b9539 | 321 | #endif /* CONFIGURATION_H */ |
322 | ||
323 | /* | |
324 | Local Variables: | |
325 | c-basic-offset:2 | |
326 | comment-column:40 | |
327 | End: | |
328 | */ |