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 | */ | |
20 | ||
21 | #ifndef CONFIGURATION_H | |
22 | #define CONFIGURATION_H | |
23 | ||
9d5da576 | 24 | #include <ao/ao.h> |
25 | ||
460b9539 | 26 | struct 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 | ||
32 | struct stringlist { | |
33 | int n; | |
34 | char **s; | |
35 | }; | |
36 | ||
37 | struct stringlistlist { | |
38 | int n; | |
39 | struct stringlist *s; | |
40 | }; | |
41 | ||
42 | struct collection { | |
43 | char *module; | |
44 | char *encoding; | |
45 | char *root; | |
46 | }; | |
47 | ||
48 | struct collectionlist { | |
49 | int n; | |
50 | struct collection *s; | |
51 | }; | |
52 | ||
53 | struct namepart { | |
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 */ | |
59 | }; | |
60 | ||
61 | struct namepartlist { | |
62 | int n; | |
63 | struct namepart *s; | |
64 | }; | |
65 | ||
66 | struct transform { | |
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 */ | |
72 | }; | |
73 | ||
74 | struct transformlist { | |
75 | int n; | |
76 | struct transform *t; | |
77 | }; | |
78 | ||
79 | struct config { | |
80 | /* server config */ | |
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; | |
93 | long checkpoint_min; | |
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 */ | |
9d5da576 | 102 | const char *speaker_command; /* command for speaker to run */ |
103 | ao_sample_format sample_format; /* sample format to enforce */ | |
5330d674 | 104 | long sox_generation; /* sox syntax generation */ |
e83d0967 RK |
105 | int speaker_backend; /* speaker backend */ |
106 | #define BACKEND_ALSA 0 | |
107 | #define BACKEND_COMMAND 1 | |
108 | #define BACKEND_NETWORK 2 | |
460b9539 | 109 | /* shared client/server config */ |
110 | const char *home; /* home directory for state files */ | |
111 | /* client config */ | |
112 | const char *username, *password; /* our own username and password */ | |
113 | struct stringlist connect; /* connect address */ | |
114 | /* web config */ | |
115 | struct stringlist templates; /* template path */ | |
116 | const char *url; /* canonical URL */ | |
117 | long refresh; /* maximum refresh period */ | |
118 | unsigned restrictions; /* restrictions */ | |
459d4402 | 119 | long queue_pad; /* how far to pad queue with |
120 | * random tracks */ | |
460b9539 | 121 | #define RESTRICT_SCRATCH 1 |
122 | #define RESTRICT_REMOVE 2 | |
123 | #define RESTRICT_MOVE 4 | |
124 | struct namepartlist namepart; /* transformations */ | |
125 | int signal; /* termination signal */ | |
126 | const char *device; /* ALSA output device */ | |
127 | struct transformlist transform; /* path name transformations */ | |
128 | ||
e83d0967 RK |
129 | struct stringlist broadcast; /* audio broadcast address */ |
130 | struct stringlist broadcast_from; /* audio broadcast source address */ | |
131 | ||
460b9539 | 132 | /* derived values: */ |
133 | int nparts; /* number of distinct name parts */ | |
134 | char **parts; /* name part list */ | |
135 | }; | |
136 | ||
137 | extern struct config *config; | |
138 | /* the current configuration */ | |
139 | ||
140 | int config_read(void); | |
141 | /* re-read config, return 0 on success or non-0 on error. | |
142 | * Only updates @config@ if the new configuration is valid. */ | |
143 | ||
144 | char *config_get_file(const char *name); | |
145 | /* get a filename within the home directory */ | |
146 | ||
147 | struct passwd; | |
148 | ||
149 | char *config_userconf(const char *home, const struct passwd *pw); | |
150 | /* get the user's own private conffile, assuming their home dir is | |
151 | * @home@ if not null and using @pw@ otherwise */ | |
152 | ||
153 | char *config_usersysconf(const struct passwd *pw ); | |
154 | /* get the user's conffile in /etc */ | |
155 | ||
156 | char *config_private(void); | |
157 | /* get the private config file */ | |
158 | ||
159 | extern char *configfile; | |
160 | ||
161 | #endif /* CONFIGURATION_H */ | |
162 | ||
163 | /* | |
164 | Local Variables: | |
165 | c-basic-offset:2 | |
166 | comment-column:40 | |
167 | End: | |
168 | */ |