2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
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.
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.
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
20 /** @file lib/configuration.h
21 * @brief Configuration file support
24 #ifndef CONFIGURATION_H
25 #define CONFIGURATION_H
27 #include "speaker-protocol.h"
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.
35 /** @brief A list of strings */
37 /** @brief Number of strings */
39 /** @brief Array of strings */
43 /** @brief A list of list of strings */
44 struct stringlistlist
{
45 /** @brief Number of string lists */
47 /** @brief Array of string lists */
51 /** @brief A collection of tracks */
53 /** @brief Module that supports this collection */
55 /** @brief Filename encoding */
57 /** @brief Root directory */
61 /** @brief A list of collections */
62 struct collectionlist
{
63 /** @brief Number of collections */
65 /** @brief Array of collections */
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 */
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 */
90 struct transformlist
{
95 /** @brief System configuration */
99 /** @brief Authorization algorithm */
100 char *authorization_algorithm
;
102 /** @brief All players */
103 struct stringlistlist player
;
105 /** @brief Allowed users */
106 struct stringlistlist allow
;
108 /** @brief Scratch tracks */
109 struct stringlist scratch
;
111 /** @brief Gap between tracks in seconds */
114 /** @brief Maximum number of recent tracks to record in history */
117 /** @brief Expiry limit for noticed.db */
118 long noticed_history
;
120 /** @brief Trusted users */
121 struct stringlist trust
;
123 /** @brief User for server to run as */
126 /** @brief Nice value for rescan subprocess */
129 /** @brief Paths to search for plugins */
130 struct stringlist plugins
;
132 /** @brief List of stopwords */
133 struct stringlist stopword
;
135 /** @brief List of collections */
136 struct collectionlist collection
;
138 /** @brief Database checkpoint byte limit */
139 long checkpoint_kbyte
;
141 /** @brief Databsase checkpoint minimum */
144 /** @brief Path to mixer device */
147 /** @brief Mixer channel to use */
150 long prefsync
; /* preflog sync interval */
152 /** @brief Secondary listen address */
153 struct stringlist listen
;
155 /** @brief Alias format string */
158 /** @brief Enable server locking */
161 /** @brief Nice value for server */
164 /** @brief Nice value for speaker */
167 /** @brief Command execute by speaker to play audio */
168 const char *speaker_command
;
170 /** @brief Target sample format */
171 struct stream_header sample_format
;
173 /** @brief Sox syntax generation */
176 /** @brief Speaker backend
178 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
182 #define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
183 #define BACKEND_COMMAND 1 /**< Execute a command */
184 #define BACKEND_NETWORK 2 /**< Transmit RTP */
186 /** @brief Home directory for state files */
189 /** @brief Login username */
190 const char *username
;
192 /** @brief Login password */
193 const char *password
;
195 /** @brief Address to connect to */
196 struct stringlist connect
;
198 /** @brief Directories to search for web templates */
199 struct stringlist templates
;
201 /** @brief Canonical URL of web interface */
204 /** @brief Maximum refresh interval for web interface (seconds) */
207 /** @brief Facilities restricted to trusted users
209 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
212 unsigned restrictions
; /* restrictions */
213 #define RESTRICT_SCRATCH 1 /**< Restrict scratching */
214 #define RESTRICT_REMOVE 2 /**< Restrict removal */
215 #define RESTRICT_MOVE 4 /**< Restrict rearrangement */
217 /** @brief Target queue length */
220 struct namepartlist namepart
; /* transformations */
222 /** @brief Termination signal for subprocesses */
225 /** @brief ALSA output device */
227 struct transformlist transform
; /* path name transformations */
229 /** @brief Address to send audio data to */
230 struct stringlist broadcast
;
232 /** @brief Source address for network audio transmission */
233 struct stringlist broadcast_from
;
235 /** @brief TTL for multicast packets */
238 /* derived values: */
239 int nparts
; /* number of distinct name parts */
240 char **parts
; /* name part list */
243 extern struct config
*config
;
244 /* the current configuration */
246 int config_read(int server
);
247 /* re-read config, return 0 on success or non-0 on error.
248 * Only updates @config@ if the new configuration is valid. */
250 char *config_get_file(const char *name
);
251 /* get a filename within the home directory */
255 char *config_userconf(const char *home
, const struct passwd
*pw
);
256 /* get the user's own private conffile, assuming their home dir is
257 * @home@ if not null and using @pw@ otherwise */
259 char *config_usersysconf(const struct passwd
*pw
);
260 /* get the user's conffile in /etc */
262 char *config_private(void);
263 /* get the private config file */
265 extern char *configfile
;
267 #endif /* CONFIGURATION_H */