2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2006 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.
37 struct stringlistlist
{
48 struct collectionlist
{
54 char *part
; /* part */
55 struct real_pcre
*re
; /* regexp */
56 char *replace
; /* replacement string */
57 char *context
; /* context glob */
58 unsigned reflags
; /* regexp flags */
67 char *type
; /* track or dir */
68 char *context
; /* sort or choose */
69 char *replace
; /* substitution string */
70 struct real_pcre
*re
; /* compiled re */
71 unsigned flags
; /* regexp flags */
74 struct transformlist
{
81 struct stringlistlist player
; /* players */
82 struct stringlistlist allow
; /* allowed users */
83 struct stringlist scratch
; /* scratch tracks */
84 long gap
; /* gap between tracks */
85 long history
; /* length of history */
86 struct stringlist trust
; /* trusted users */
87 const char *user
; /* user to run as */
88 long nice_rescan
; /* rescan subprocess niceness */
89 struct stringlist plugins
; /* plugin path */
90 struct stringlist stopword
; /* stopwords for track search */
91 struct collectionlist collection
; /* track collections */
92 long checkpoint_kbyte
;
94 char *mixer
; /* mixer device file */
95 char *channel
; /* mixer channel */
96 long prefsync
; /* preflog sync intreval */
97 struct stringlist listen
; /* secondary listen address */
98 const char *alias
; /* alias format */
99 int lock
; /* server takes a lock */
100 long nice_server
; /* nice value for server */
101 long nice_speaker
; /* nice value for speaker */
102 const char *speaker_command
; /* command for speaker to run */
103 ao_sample_format sample_format
; /* sample format to enforce */
104 /* shared client/server config */
105 const char *home
; /* home directory for state files */
107 const char *username
, *password
; /* our own username and password */
108 struct stringlist connect
; /* connect address */
110 struct stringlist templates
; /* template path */
111 const char *url
; /* canonical URL */
112 long refresh
; /* maximum refresh period */
113 unsigned restrictions
; /* restrictions */
114 #define RESTRICT_SCRATCH 1
115 #define RESTRICT_REMOVE 2
116 #define RESTRICT_MOVE 4
117 struct namepartlist namepart
; /* transformations */
118 int signal
; /* termination signal */
119 const char *device
; /* ALSA output device */
120 struct transformlist transform
; /* path name transformations */
122 /* derived values: */
123 int nparts
; /* number of distinct name parts */
124 char **parts
; /* name part list */
127 extern struct config
*config
;
128 /* the current configuration */
130 int config_read(void);
131 /* re-read config, return 0 on success or non-0 on error.
132 * Only updates @config@ if the new configuration is valid. */
134 char *config_get_file(const char *name
);
135 /* get a filename within the home directory */
139 char *config_userconf(const char *home
, const struct passwd
*pw
);
140 /* get the user's own private conffile, assuming their home dir is
141 * @home@ if not null and using @pw@ otherwise */
143 char *config_usersysconf(const struct passwd
*pw
);
144 /* get the user's conffile in /etc */
146 char *config_private(void);
147 /* get the private config file */
149 extern char *configfile
;
151 #endif /* CONFIGURATION_H */