chiark / gitweb /
Further macro tests
[disorder] / lib / configuration.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
964e027d 3 * Copyright (C) 2004-2008 Richard Kettlewell
460b9539 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 2 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, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
0e4472a0 20/** @file lib/configuration.h
21 * @brief Configuration file support
22 */
460b9539 23
24#ifndef CONFIGURATION_H
25#define CONFIGURATION_H
26
6d2d327c 27#include "speaker-protocol.h"
04e1fa7c 28#include "rights.h"
9d5da576 29
460b9539 30struct real_pcre;
31
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 37struct 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 45struct 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 53struct 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 63struct collectionlist {
3f3bb97b 64 /** @brief Number of collections */
460b9539 65 int n;
3f3bb97b 66 /** @brief Array of collections */
460b9539 67 struct collection *s;
68};
69
70struct namepart {
71 char *part; /* part */
72 struct real_pcre *re; /* regexp */
73 char *replace; /* replacement string */
74 char *context; /* context glob */
75 unsigned reflags; /* regexp flags */
76};
77
78struct namepartlist {
79 int n;
80 struct namepart *s;
81};
82
83struct transform {
84 char *type; /* track or dir */
85 char *context; /* sort or choose */
86 char *replace; /* substitution string */
87 struct real_pcre *re; /* compiled re */
88 unsigned flags; /* regexp flags */
89};
90
91struct transformlist {
92 int n;
93 struct transform *t;
94};
95
3f3bb97b 96/** @brief System configuration */
460b9539 97struct config {
98 /* server config */
3f3bb97b 99
637fdea3
RK
100 /** @brief Authorization algorithm */
101 char *authorization_algorithm;
102
3f3bb97b
RK
103 /** @brief All players */
104 struct stringlistlist player;
105
62dc3748
RK
106 /** @brief All tracklength plugins */
107 struct stringlistlist tracklength;
108
3f3bb97b
RK
109 /** @brief Allowed users */
110 struct stringlistlist allow;
111
112 /** @brief Scratch tracks */
113 struct stringlist scratch;
114
115 /** @brief Gap between tracks in seconds */
116 long gap;
117
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 Trusted users */
125 struct stringlist trust;
126
127 /** @brief User for server to run as */
128 const char *user;
129
130 /** @brief Nice value for rescan subprocess */
131 long nice_rescan;
132
133 /** @brief Paths to search for plugins */
134 struct stringlist plugins;
135
136 /** @brief List of stopwords */
137 struct stringlist stopword;
138
139 /** @brief List of collections */
140 struct collectionlist collection;
141
142 /** @brief Database checkpoint byte limit */
460b9539 143 long checkpoint_kbyte;
3f3bb97b
RK
144
145 /** @brief Databsase checkpoint minimum */
460b9539 146 long checkpoint_min;
3f3bb97b
RK
147
148 /** @brief Path to mixer device */
149 char *mixer;
150
151 /** @brief Mixer channel to use */
152 char *channel;
153
154 long prefsync; /* preflog sync interval */
155
156 /** @brief Secondary listen address */
157 struct stringlist listen;
158
159 /** @brief Alias format string */
160 const char *alias;
161
162 /** @brief Enable server locking */
163 int lock;
164
165 /** @brief Nice value for server */
166 long nice_server;
167
168 /** @brief Nice value for speaker */
169 long nice_speaker;
170
171 /** @brief Command execute by speaker to play audio */
172 const char *speaker_command;
173
174 /** @brief Target sample format */
6d2d327c 175 struct stream_header sample_format;
3f3bb97b
RK
176
177 /** @brief Sox syntax generation */
178 long sox_generation;
179
bd8895a8 180 /** @brief API used to play sound
3f3bb97b
RK
181 *
182 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
183 * BACKEND_NETWORK.
184 */
bd8895a8 185 int api;
8aae240b
RK
186
187/* These values had better be non-negative */
3f3bb97b
RK
188#define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
189#define BACKEND_COMMAND 1 /**< Execute a command */
190#define BACKEND_NETWORK 2 /**< Transmit RTP */
937be4c0 191#define BACKEND_COREAUDIO 3 /**< Use Core Audio (Mac only) */
e99d42b1 192#define BACKEND_OSS 4 /**< Use OSS */
3f3bb97b 193
3c499fe7
RK
194#if HAVE_ALSA_ASOUNDLIB_H
195# define DEFAULT_BACKEND BACKEND_ALSA
196#elif HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
197# define DEFAULT_BACKEND BACKEND_OSS
198#elif HAVE_COREAUDIO_AUDIOHARDWARE_H
199# define DEFAULT_BACKEND BACKEND_COREAUDIO
200#else
201# error Cannot choose a default backend
202#endif
203
3f3bb97b
RK
204 /** @brief Home directory for state files */
205 const char *home;
206
207 /** @brief Login username */
208 const char *username;
209
210 /** @brief Login password */
211 const char *password;
212
213 /** @brief Address to connect to */
214 struct stringlist connect;
215
216 /** @brief Directories to search for web templates */
217 struct stringlist templates;
218
219 /** @brief Canonical URL of web interface */
b64c2805 220 char *url;
3f3bb97b 221
61507e3c
RK
222 /** @brief Short display limit */
223 long short_display;
224
3f3bb97b
RK
225 /** @brief Maximum refresh interval for web interface (seconds) */
226 long refresh;
227
228 /** @brief Facilities restricted to trusted users
229 *
230 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
231 * RESTRICT_MOVE.
232 */
460b9539 233 unsigned restrictions; /* restrictions */
3f3bb97b
RK
234#define RESTRICT_SCRATCH 1 /**< Restrict scratching */
235#define RESTRICT_REMOVE 2 /**< Restrict removal */
236#define RESTRICT_MOVE 4 /**< Restrict rearrangement */
237
238 /** @brief Target queue length */
239 long queue_pad;
240
cebe3127
RK
241 /** @brief Minimum time between a track being played again */
242 long replay_min;
243
460b9539 244 struct namepartlist namepart; /* transformations */
3f3bb97b
RK
245
246 /** @brief Termination signal for subprocesses */
247 int signal;
248
249 /** @brief ALSA output device */
250 const char *device;
460b9539 251 struct transformlist transform; /* path name transformations */
252
23205f9c
RK
253 /** @brief Address to send audio data to */
254 struct stringlist broadcast;
255
256 /** @brief Source address for network audio transmission */
257 struct stringlist broadcast_from;
258
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
RK
264
265 /** @brief Login lifetime in seconds */
266 long cookie_login_lifetime;
267
268 /** @brief Signing key lifetime in seconds */
269 long cookie_key_lifetime;
04e1fa7c
RK
270
271 /** @brief Default rights for a new user */
0f55e905 272 char *default_rights;
bb6ae3fb 273
274 /** @brief SMTP server for sending mail */
275 char *smtp_server;
276
277 /** @brief Origin address for outbound mail */
278 char *mail_sender;
d742bb47
RK
279
280 /** @brief Maximum number of tracks in response to 'new' */
281 long new_max;
6207d2f3 282
283 /** @brief Minimum interval between password reminder emails */
284 long reminder_interval;
810b8083
RK
285
286 /** @brief Whether to allow user management over TCP */
287 int remote_userman;
61941295 288
460b9539 289 /* derived values: */
290 int nparts; /* number of distinct name parts */
291 char **parts; /* name part list */
8818b7fc
RK
292
293 /* undocumented, for testing only */
294 long dbversion;
460b9539 295};
296
297extern struct config *config;
298/* the current configuration */
299
c00fce3a 300int config_read(int server);
460b9539 301/* re-read config, return 0 on success or non-0 on error.
302 * Only updates @config@ if the new configuration is valid. */
303
304char *config_get_file(const char *name);
305/* get a filename within the home directory */
306
307struct passwd;
308
309char *config_userconf(const char *home, const struct passwd *pw);
310/* get the user's own private conffile, assuming their home dir is
311 * @home@ if not null and using @pw@ otherwise */
312
313char *config_usersysconf(const struct passwd *pw );
314/* get the user's conffile in /etc */
315
316char *config_private(void);
317/* get the private config file */
318
319extern char *configfile;
63ad732f 320extern int config_per_user;
460b9539 321
322#endif /* CONFIGURATION_H */
323
324/*
325Local Variables:
326c-basic-offset:2
327comment-column:40
328End:
329*/