chiark / gitweb /
new disorder-rtp deb
[disorder] / lib / configuration.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
e83d0967 3 * Copyright (C) 2004, 2005, 2006, 2007 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 */
20
21#ifndef CONFIGURATION_H
22#define CONFIGURATION_H
23
9d5da576 24#include <ao/ao.h>
25
460b9539 26struct real_pcre;
27
28/* Configuration is kept in a @struct config@; the live configuration
29 * is always pointed to by @config@. Values in @config@ are UTF-8 encoded.
30 */
31
3f3bb97b 32/** @brief A list of strings */
460b9539 33struct stringlist {
3f3bb97b 34 /** @brief Number of strings */
460b9539 35 int n;
3f3bb97b 36 /** @brief Array of strings */
460b9539 37 char **s;
38};
39
3f3bb97b 40/** @brief A list of list of strings */
460b9539 41struct stringlistlist {
3f3bb97b 42 /** @brief Number of string lists */
460b9539 43 int n;
3f3bb97b 44 /** @brief Array of string lists */
460b9539 45 struct stringlist *s;
46};
47
3f3bb97b 48/** @brief A collection of tracks */
460b9539 49struct collection {
3f3bb97b 50 /** @brief Module that supports this collection */
460b9539 51 char *module;
3f3bb97b 52 /** @brief Filename encoding */
460b9539 53 char *encoding;
3f3bb97b 54 /** @brief Root directory */
460b9539 55 char *root;
56};
57
3f3bb97b 58/** @brief A list of collections */
460b9539 59struct collectionlist {
3f3bb97b 60 /** @brief Number of collections */
460b9539 61 int n;
3f3bb97b 62 /** @brief Array of collections */
460b9539 63 struct collection *s;
64};
65
66struct namepart {
67 char *part; /* part */
68 struct real_pcre *re; /* regexp */
69 char *replace; /* replacement string */
70 char *context; /* context glob */
71 unsigned reflags; /* regexp flags */
72};
73
74struct namepartlist {
75 int n;
76 struct namepart *s;
77};
78
79struct transform {
80 char *type; /* track or dir */
81 char *context; /* sort or choose */
82 char *replace; /* substitution string */
83 struct real_pcre *re; /* compiled re */
84 unsigned flags; /* regexp flags */
85};
86
87struct transformlist {
88 int n;
89 struct transform *t;
90};
91
3f3bb97b 92/** @brief System configuration */
460b9539 93struct config {
94 /* server config */
3f3bb97b
RK
95
96 /** @brief All players */
97 struct stringlistlist player;
98
99 /** @brief Allowed users */
100 struct stringlistlist allow;
101
102 /** @brief Scratch tracks */
103 struct stringlist scratch;
104
105 /** @brief Gap between tracks in seconds */
106 long gap;
107
108 /** @brief Maximum number of recent tracks to record in history */
109 long history;
110
111 /** @brief Trusted users */
112 struct stringlist trust;
113
114 /** @brief User for server to run as */
115 const char *user;
116
117 /** @brief Nice value for rescan subprocess */
118 long nice_rescan;
119
120 /** @brief Paths to search for plugins */
121 struct stringlist plugins;
122
123 /** @brief List of stopwords */
124 struct stringlist stopword;
125
126 /** @brief List of collections */
127 struct collectionlist collection;
128
129 /** @brief Database checkpoint byte limit */
460b9539 130 long checkpoint_kbyte;
3f3bb97b
RK
131
132 /** @brief Databsase checkpoint minimum */
460b9539 133 long checkpoint_min;
3f3bb97b
RK
134
135 /** @brief Path to mixer device */
136 char *mixer;
137
138 /** @brief Mixer channel to use */
139 char *channel;
140
141 long prefsync; /* preflog sync interval */
142
143 /** @brief Secondary listen address */
144 struct stringlist listen;
145
146 /** @brief Alias format string */
147 const char *alias;
148
149 /** @brief Enable server locking */
150 int lock;
151
152 /** @brief Nice value for server */
153 long nice_server;
154
155 /** @brief Nice value for speaker */
156 long nice_speaker;
157
158 /** @brief Command execute by speaker to play audio */
159 const char *speaker_command;
160
161 /** @brief Target sample format */
162 ao_sample_format sample_format;
163
164 /** @brief Sox syntax generation */
165 long sox_generation;
166
167 /** @brief Speaker backend
168 *
169 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
170 * BACKEND_NETWORK.
171 */
172 int speaker_backend;
173#define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
174#define BACKEND_COMMAND 1 /**< Execute a command */
175#define BACKEND_NETWORK 2 /**< Transmit RTP */
176
177 /** @brief Home directory for state files */
178 const char *home;
179
180 /** @brief Login username */
181 const char *username;
182
183 /** @brief Login password */
184 const char *password;
185
186 /** @brief Address to connect to */
187 struct stringlist connect;
188
189 /** @brief Directories to search for web templates */
190 struct stringlist templates;
191
192 /** @brief Canonical URL of web interface */
193 const char *url;
194
195 /** @brief Maximum refresh interval for web interface (seconds) */
196 long refresh;
197
198 /** @brief Facilities restricted to trusted users
199 *
200 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
201 * RESTRICT_MOVE.
202 */
460b9539 203 unsigned restrictions; /* restrictions */
3f3bb97b
RK
204#define RESTRICT_SCRATCH 1 /**< Restrict scratching */
205#define RESTRICT_REMOVE 2 /**< Restrict removal */
206#define RESTRICT_MOVE 4 /**< Restrict rearrangement */
207
208 /** @brief Target queue length */
209 long queue_pad;
210
460b9539 211 struct namepartlist namepart; /* transformations */
3f3bb97b
RK
212
213 /** @brief Termination signal for subprocesses */
214 int signal;
215
216 /** @brief ALSA output device */
217 const char *device;
460b9539 218 struct transformlist transform; /* path name transformations */
219
e83d0967
RK
220 struct stringlist broadcast; /* audio broadcast address */
221 struct stringlist broadcast_from; /* audio broadcast source address */
222
460b9539 223 /* derived values: */
224 int nparts; /* number of distinct name parts */
225 char **parts; /* name part list */
226};
227
228extern struct config *config;
229/* the current configuration */
230
231int config_read(void);
232/* re-read config, return 0 on success or non-0 on error.
233 * Only updates @config@ if the new configuration is valid. */
234
235char *config_get_file(const char *name);
236/* get a filename within the home directory */
237
238struct passwd;
239
240char *config_userconf(const char *home, const struct passwd *pw);
241/* get the user's own private conffile, assuming their home dir is
242 * @home@ if not null and using @pw@ otherwise */
243
244char *config_usersysconf(const struct passwd *pw );
245/* get the user's conffile in /etc */
246
247char *config_private(void);
248/* get the private config file */
249
250extern char *configfile;
251
252#endif /* CONFIGURATION_H */
253
254/*
255Local Variables:
256c-basic-offset:2
257comment-column:40
258End:
259*/