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
21 #ifndef CONFIGURATION_H
22 #define CONFIGURATION_H
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.
32 /** @brief A list of strings */
34 /** @brief Number of strings */
36 /** @brief Array of strings */
40 /** @brief A list of list of strings */
41 struct stringlistlist {
42 /** @brief Number of string lists */
44 /** @brief Array of string lists */
48 /** @brief A collection of tracks */
50 /** @brief Module that supports this collection */
52 /** @brief Filename encoding */
54 /** @brief Root directory */
58 /** @brief A list of collections */
59 struct collectionlist {
60 /** @brief Number of collections */
62 /** @brief Array of collections */
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 */
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 */
87 struct transformlist {
92 /** @brief System configuration */
96 /** @brief All players */
97 struct stringlistlist player;
99 /** @brief Allowed users */
100 struct stringlistlist allow;
102 /** @brief Scratch tracks */
103 struct stringlist scratch;
105 /** @brief Gap between tracks in seconds */
108 /** @brief Maximum number of recent tracks to record in history */
111 /** @brief Trusted users */
112 struct stringlist trust;
114 /** @brief User for server to run as */
117 /** @brief Nice value for rescan subprocess */
120 /** @brief Paths to search for plugins */
121 struct stringlist plugins;
123 /** @brief List of stopwords */
124 struct stringlist stopword;
126 /** @brief List of collections */
127 struct collectionlist collection;
129 /** @brief Database checkpoint byte limit */
130 long checkpoint_kbyte;
132 /** @brief Databsase checkpoint minimum */
135 /** @brief Path to mixer device */
138 /** @brief Mixer channel to use */
141 long prefsync; /* preflog sync interval */
143 /** @brief Secondary listen address */
144 struct stringlist listen;
146 /** @brief Alias format string */
149 /** @brief Enable server locking */
152 /** @brief Nice value for server */
155 /** @brief Nice value for speaker */
158 /** @brief Command execute by speaker to play audio */
159 const char *speaker_command;
161 /** @brief Target sample format */
162 ao_sample_format sample_format;
164 /** @brief Sox syntax generation */
167 /** @brief Speaker backend
169 * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
173 #define BACKEND_ALSA 0 /**< Use ALSA (Linux only) */
174 #define BACKEND_COMMAND 1 /**< Execute a command */
175 #define BACKEND_NETWORK 2 /**< Transmit RTP */
177 /** @brief Home directory for state files */
180 /** @brief Login username */
181 const char *username;
183 /** @brief Login password */
184 const char *password;
186 /** @brief Address to connect to */
187 struct stringlist connect;
189 /** @brief Directories to search for web templates */
190 struct stringlist templates;
192 /** @brief Canonical URL of web interface */
195 /** @brief Maximum refresh interval for web interface (seconds) */
198 /** @brief Facilities restricted to trusted users
200 * A bitmap of @ref RESTRICT_SCRATCH, @ref RESTRICT_REMOVE and @ref
203 unsigned restrictions; /* restrictions */
204 #define RESTRICT_SCRATCH 1 /**< Restrict scratching */
205 #define RESTRICT_REMOVE 2 /**< Restrict removal */
206 #define RESTRICT_MOVE 4 /**< Restrict rearrangement */
208 /** @brief Target queue length */
211 struct namepartlist namepart; /* transformations */
213 /** @brief Termination signal for subprocesses */
216 /** @brief ALSA output device */
218 struct transformlist transform; /* path name transformations */
220 struct stringlist broadcast; /* audio broadcast address */
221 struct stringlist broadcast_from; /* audio broadcast source address */
223 /* derived values: */
224 int nparts; /* number of distinct name parts */
225 char **parts; /* name part list */
228 extern struct config *config;
229 /* the current configuration */
231 int 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. */
235 char *config_get_file(const char *name);
236 /* get a filename within the home directory */
240 char *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 */
244 char *config_usersysconf(const struct passwd *pw );
245 /* get the user's conffile in /etc */
247 char *config_private(void);
248 /* get the private config file */
250 extern char *configfile;
252 #endif /* CONFIGURATION_H */