chiark / gitweb /
Cope with various header files being missing.
[disorder] / lib / configuration.h
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004-2011, 2013 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 #if HAVE_PCRE_H
26 # include <pcre.h>
27 #endif
28
29 #include "speaker-protocol.h"
30 #include "rights.h"
31 #include "addr.h"
32
33 struct uaudio;
34
35 /* Configuration is kept in a @struct config@; the live configuration
36  * is always pointed to by @config@.  Values in @config@ are UTF-8 encoded.
37  */
38
39 /** @brief A list of strings */
40 struct stringlist {
41   /** @brief Number of strings */
42   int n;
43   /** @brief Array of strings */
44   char **s;
45 };
46
47 /** @brief A list of list of strings */
48 struct stringlistlist {
49   /** @brief Number of string lists */
50   int n;
51   /** @brief Array of string lists */
52   struct stringlist *s;
53 };
54
55 /** @brief A collection of tracks */
56 struct collection {
57   /** @brief Module that supports this collection */
58   char *module;
59   /** @brief Filename encoding */
60   char *encoding;
61   /** @brief Root directory */
62   char *root;
63 };
64
65 /** @brief A list of collections */
66 struct collectionlist {
67   /** @brief Number of collections */
68   int n;
69   /** @brief Array of collections */
70   struct collection *s;
71 };
72
73 #if HAVE_PCRE_H
74 /** @brief A track name part */
75 struct namepart {
76   char *part;                           /* part */
77   pcre *re;                             /* compiled regexp */
78   char *res;                            /* regexp as a string */
79   char *replace;                        /* replacement string */
80   char *context;                        /* context glob */
81   unsigned reflags;                     /* regexp flags */
82 };
83
84 /** @brief A list of track name parts */
85 struct namepartlist {
86   int n;
87   struct namepart *s;
88 };
89
90 /** @brief A track name transform */
91 struct transform {
92   char *type;                           /* track or dir */
93   char *context;                        /* sort or choose */
94   char *replace;                        /* substitution string */
95   pcre *re;                             /* compiled re */
96   unsigned flags;                       /* regexp flags */
97 };
98
99 /** @brief A list of track name transforms */
100 struct transformlist {
101   int n;
102   struct transform *t;
103 };
104 #endif
105
106 /** @brief System configuration */
107 struct config {
108   /* server config */
109
110   /** @brief Authorization algorithm */
111   char *authorization_algorithm;
112   
113   /** @brief All players */
114   struct stringlistlist player;
115
116   /** @brief All tracklength plugins */
117   struct stringlistlist tracklength;
118
119   /** @brief Scratch tracks */
120   struct stringlist scratch;
121
122   /** @brief Maximum number of recent tracks to record in history */
123   long history;
124
125   /** @brief Expiry limit for noticed.db */
126   long noticed_history;
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 */
144   long checkpoint_kbyte;
145
146   /** @brief Databsase checkpoint minimum */
147   long checkpoint_min;
148
149   /** @brief Path to mixer device */
150   char *mixer;
151
152   /** @brief Mixer channel to use */
153   char *channel;
154
155   /** @brief Secondary listen address */
156   struct netaddress listen;
157
158   /** @brief Alias format string */
159   const char *alias;
160
161   /** @brief Nice value for server */
162   long nice_server;
163
164   /** @brief Nice value for speaker */
165   long nice_speaker;
166
167   /** @brief Command execute by speaker to play audio */
168   const char *speaker_command;
169
170   /** @brief Pause mode for command backend */
171   const char *pause_mode;
172   
173   /** @brief Target sample format */
174   struct stream_header sample_format;
175
176   /** @brief Sox syntax generation */
177   long sox_generation;
178
179   /** @brief API used to play sound */
180   const char *api;
181
182   /** @brief Maximum size of a playlist */
183   long playlist_max;
184
185   /** @brief Maximum lifetime of a playlist lock */
186   long playlist_lock_timeout;
187
188   /** @brief Home directory for state files */
189   const char *home;
190
191   /** @brief Login username */
192   char *username;
193
194   /** @brief Login password */
195   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 Minimum refresh interval for web interface (seconds) */
213   long refresh_min;
214
215   /** @brief Target queue length */
216   long queue_pad;
217
218   /** @brief Minimum time between a track being played again */
219   long replay_min;
220   
221 #if HAVE_PCRE_H
222   struct namepartlist namepart;         /* transformations */
223 #endif
224
225   /** @brief Termination signal for subprocesses */
226   int signal;
227
228   /** @brief ALSA output device */
229   const char *device;
230
231 #if HAVE_PCRE_H
232   struct transformlist transform;       /* path name transformations */
233 #endif
234
235   /** @brief Address to send audio data to */
236   struct netaddress broadcast;
237
238   /** @brief Source address for network audio transmission */
239   struct netaddress broadcast_from;
240
241   /** @brief RTP delay threshold */
242   long rtp_delay_threshold;
243
244   /** @brief Verbose RTP transmission logging */
245   int rtp_verbose;
246   
247   /** @brief TTL for multicast packets */
248   long multicast_ttl;
249
250   /** @brief Whether to loop back multicast packets */
251   int multicast_loop;
252
253   /** @brief Login lifetime in seconds */
254   long cookie_login_lifetime;
255
256   /** @brief Signing key lifetime in seconds */
257   long cookie_key_lifetime;
258
259   /** @brief Default rights for a new user */
260   char *default_rights;
261
262   /** @brief Path to sendmail executable */
263   char *sendmail;
264
265   /** @brief SMTP server for sending mail */
266   char *smtp_server;
267
268   /** @brief Origin address for outbound mail */
269   char *mail_sender;
270
271   /** @brief Maximum number of tracks in response to 'new' */
272   long new_max;
273
274   /** @brief Minimum interval between password reminder emails */
275   long reminder_interval;
276
277   /** @brief Whether to allow user management over TCP */
278   int remote_userman;
279
280   /** @brief Maximum age of biased-up tracks */
281   long new_bias_age;
282
283   /** @brief Maximum bias */
284   long new_bias;
285
286   /** @brief Rescan on (un)mount */
287   int mount_rescan;
288
289   /** @brief RTP mode */
290   const char *rtp_mode;
291
292   /* derived values: */
293   int nparts;                           /* number of distinct name parts */
294   char **parts;                         /* name part list  */
295
296   /* undocumented, for testing only */
297   long dbversion;
298 };
299
300 extern struct config *config;
301 /* the current configuration */
302
303 int config_read(int server,
304                 const struct config *oldconfig);
305 /* re-read config, return 0 on success or non-0 on error.
306  * Only updates @config@ if the new configuration is valid. */
307
308 char *config_get_file2(struct config *c, const char *name);
309 char *config_get_file(const char *name);
310 /* get a filename within the home directory */
311
312 struct passwd;
313
314 char *config_userconf(const char *home, const struct passwd *pw);
315 /* get the user's own private conffile, assuming their home dir is
316  * @home@ if not null and using @pw@ otherwise */
317
318 char *config_usersysconf(const struct passwd *pw );
319 /* get the user's conffile in /etc */
320
321 char *config_private(void);
322 /* get the private config file */
323
324 int config_verify(void);
325
326 void config_free(struct config *c);
327
328 extern char *configfile;
329 extern int config_per_user;
330
331 extern const struct uaudio *const *config_uaudio_apis;
332
333 #endif /* CONFIGURATION_H */
334
335 /*
336 Local Variables:
337 c-basic-offset:2
338 comment-column:40
339 End:
340 */