Commit | Line | Data |
---|---|---|
05dcfac6 | 1 | |
460b9539 | 2 | /* |
3 | * This file is part of DisOrder. | |
964e027d | 4 | * Copyright (C) 2004-2008 Richard Kettlewell |
460b9539 | 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 | */ | |
0e4472a0 | 21 | /** @file lib/configuration.h |
22 | * @brief Configuration file support | |
23 | */ | |
460b9539 | 24 | |
25 | #ifndef CONFIGURATION_H | |
26 | #define CONFIGURATION_H | |
27 | ||
05b75f8d RK |
28 | #include <pcre.h> |
29 | ||
6d2d327c | 30 | #include "speaker-protocol.h" |
04e1fa7c | 31 | #include "rights.h" |
9d5da576 | 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 */ | |
05b75f8d | 73 | pcre *re; /* regexp */ |
460b9539 | 74 | char *replace; /* replacement string */ |
75 | char *context; /* context glob */ | |
76 | unsigned reflags; /* regexp flags */ | |
77 | }; | |
78 | ||
79 | struct namepartlist { | |
80 | int n; | |
81 | struct namepart *s; | |
82 | }; | |
83 | ||
84 | struct transform { | |
85 | char *type; /* track or dir */ | |
86 | char *context; /* sort or choose */ | |
87 | char *replace; /* substitution string */ | |
05b75f8d | 88 | pcre *re; /* compiled re */ |
460b9539 | 89 | unsigned flags; /* regexp flags */ |
90 | }; | |
91 | ||
92 | struct transformlist { | |
93 | int n; | |
94 | struct transform *t; | |
95 | }; | |
96 | ||
3f3bb97b | 97 | /** @brief System configuration */ |
460b9539 | 98 | struct config { |
99 | /* server config */ | |
3f3bb97b | 100 | |
637fdea3 RK |
101 | /** @brief Authorization algorithm */ |
102 | char *authorization_algorithm; | |
103 | ||
3f3bb97b RK |
104 | /** @brief All players */ |
105 | struct stringlistlist player; | |
106 | ||
62dc3748 RK |
107 | /** @brief All tracklength plugins */ |
108 | struct stringlistlist tracklength; | |
109 | ||
3f3bb97b RK |
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 | ||
2a10b70b RK |
122 | /** @brief Expiry limit for noticed.db */ |
123 | long noticed_history; | |
124 | ||
3f3bb97b RK |
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 */ | |
460b9539 | 144 | long checkpoint_kbyte; |
3f3bb97b RK |
145 | |
146 | /** @brief Databsase checkpoint minimum */ | |
460b9539 | 147 | long checkpoint_min; |
3f3bb97b RK |
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 */ | |
6d2d327c | 176 | struct stream_header sample_format; |
3f3bb97b RK |
177 | |
178 | /** @brief Sox syntax generation */ | |
179 | long sox_generation; | |
180 | ||
bd8895a8 | 181 | /** @brief API used to play sound |
3f3bb97b RK |
182 | * |
183 | * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref | |
184 | * BACKEND_NETWORK. | |
185 | */ | |
bd8895a8 | 186 | int api; |
8aae240b RK |
187 | |
188 | /* These values had better be non-negative */ | |
3f3bb97b RK |
189 | #define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */ |
190 | #define BACKEND_COMMAND 1 /**< Execute a command */ | |
191 | #define BACKEND_NETWORK 2 /**< Transmit RTP */ | |
937be4c0 | 192 | #define BACKEND_COREAUDIO 3 /**< Use Core Audio (Mac only) */ |
e99d42b1 | 193 | #define BACKEND_OSS 4 /**< Use OSS */ |
3f3bb97b | 194 | |
3c499fe7 RK |
195 | #if HAVE_ALSA_ASOUNDLIB_H |
196 | # define DEFAULT_BACKEND BACKEND_ALSA | |
197 | #elif HAVE_SYS_SOUNDCARD_H || EMPEG_HOST | |
198 | # define DEFAULT_BACKEND BACKEND_OSS | |
199 | #elif HAVE_COREAUDIO_AUDIOHARDWARE_H | |
200 | # define DEFAULT_BACKEND BACKEND_COREAUDIO | |
201 | #else | |
202 | # error Cannot choose a default backend | |
203 | #endif | |
204 | ||
3f3bb97b RK |
205 | /** @brief Home directory for state files */ |
206 | const char *home; | |
207 | ||
208 | /** @brief Login username */ | |
209 | const char *username; | |
210 | ||
211 | /** @brief Login password */ | |
212 | const char *password; | |
213 | ||
214 | /** @brief Address to connect to */ | |
215 | struct stringlist connect; | |
216 | ||
217 | /** @brief Directories to search for web templates */ | |
218 | struct stringlist templates; | |
219 | ||
220 | /** @brief Canonical URL of web interface */ | |
b64c2805 | 221 | char *url; |
3f3bb97b | 222 | |
61507e3c RK |
223 | /** @brief Short display limit */ |
224 | long short_display; | |
225 | ||
3f3bb97b RK |
226 | /** @brief Maximum refresh interval for web interface (seconds) */ |
227 | long refresh; | |
228 | ||
229 | /** @brief Facilities restricted to trusted users | |
230 | * | |
231 | * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref | |
232 | * RESTRICT_MOVE. | |
233 | */ | |
460b9539 | 234 | unsigned restrictions; /* restrictions */ |
3f3bb97b RK |
235 | #define RESTRICT_SCRATCH 1 /**< Restrict scratching */ |
236 | #define RESTRICT_REMOVE 2 /**< Restrict removal */ | |
237 | #define RESTRICT_MOVE 4 /**< Restrict rearrangement */ | |
238 | ||
239 | /** @brief Target queue length */ | |
240 | long queue_pad; | |
241 | ||
cebe3127 RK |
242 | /** @brief Minimum time between a track being played again */ |
243 | long replay_min; | |
244 | ||
460b9539 | 245 | struct namepartlist namepart; /* transformations */ |
3f3bb97b RK |
246 | |
247 | /** @brief Termination signal for subprocesses */ | |
248 | int signal; | |
249 | ||
250 | /** @brief ALSA output device */ | |
251 | const char *device; | |
460b9539 | 252 | struct transformlist transform; /* path name transformations */ |
253 | ||
23205f9c RK |
254 | /** @brief Address to send audio data to */ |
255 | struct stringlist broadcast; | |
256 | ||
257 | /** @brief Source address for network audio transmission */ | |
258 | struct stringlist broadcast_from; | |
259 | ||
260 | /** @brief TTL for multicast packets */ | |
261 | long multicast_ttl; | |
e83d0967 | 262 | |
61941295 RK |
263 | /** @brief Whether to loop back multicast packets */ |
264 | int multicast_loop; | |
b12be54a RK |
265 | |
266 | /** @brief Login lifetime in seconds */ | |
267 | long cookie_login_lifetime; | |
268 | ||
269 | /** @brief Signing key lifetime in seconds */ | |
270 | long cookie_key_lifetime; | |
04e1fa7c RK |
271 | |
272 | /** @brief Default rights for a new user */ | |
0f55e905 | 273 | char *default_rights; |
bb6ae3fb | 274 | |
2eee4b0c RK |
275 | /** @brief Path to sendmail executable */ |
276 | char *sendmail; | |
277 | ||
bb6ae3fb | 278 | /** @brief SMTP server for sending mail */ |
279 | char *smtp_server; | |
280 | ||
281 | /** @brief Origin address for outbound mail */ | |
282 | char *mail_sender; | |
d742bb47 RK |
283 | |
284 | /** @brief Maximum number of tracks in response to 'new' */ | |
285 | long new_max; | |
6207d2f3 | 286 | |
287 | /** @brief Minimum interval between password reminder emails */ | |
288 | long reminder_interval; | |
810b8083 RK |
289 | |
290 | /** @brief Whether to allow user management over TCP */ | |
291 | int remote_userman; | |
05dcfac6 RK |
292 | |
293 | /** @brief Maximum age of biased-up tracks */ | |
294 | long new_bias_age; | |
295 | ||
296 | /** @brief Maximum bias */ | |
297 | long new_bias; | |
61941295 | 298 | |
460b9539 | 299 | /* derived values: */ |
300 | int nparts; /* number of distinct name parts */ | |
301 | char **parts; /* name part list */ | |
8818b7fc RK |
302 | |
303 | /* undocumented, for testing only */ | |
304 | long dbversion; | |
460b9539 | 305 | }; |
306 | ||
307 | extern struct config *config; | |
308 | /* the current configuration */ | |
309 | ||
c00fce3a | 310 | int config_read(int server); |
460b9539 | 311 | /* re-read config, return 0 on success or non-0 on error. |
312 | * Only updates @config@ if the new configuration is valid. */ | |
313 | ||
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 | ||
329 | extern char *configfile; | |
63ad732f | 330 | extern int config_per_user; |
460b9539 | 331 | |
332 | #endif /* CONFIGURATION_H */ | |
333 | ||
334 | /* | |
335 | Local Variables: | |
336 | c-basic-offset:2 | |
337 | comment-column:40 | |
338 | End: | |
339 | */ |