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