460b9539 |
1 | /* |
2 | * This file is part of DisOrder. |
3 | * Copyright (C) 2004, 2005, 2006 Richard Kettlewell |
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 | |
24 | struct real_pcre; |
25 | |
26 | /* Configuration is kept in a @struct config@; the live configuration |
27 | * is always pointed to by @config@. Values in @config@ are UTF-8 encoded. |
28 | */ |
29 | |
30 | struct stringlist { |
31 | int n; |
32 | char **s; |
33 | }; |
34 | |
35 | struct stringlistlist { |
36 | int n; |
37 | struct stringlist *s; |
38 | }; |
39 | |
40 | struct collection { |
41 | char *module; |
42 | char *encoding; |
43 | char *root; |
44 | }; |
45 | |
46 | struct collectionlist { |
47 | int n; |
48 | struct collection *s; |
49 | }; |
50 | |
51 | struct namepart { |
52 | char *part; /* part */ |
53 | struct real_pcre *re; /* regexp */ |
54 | char *replace; /* replacement string */ |
55 | char *context; /* context glob */ |
56 | unsigned reflags; /* regexp flags */ |
57 | }; |
58 | |
59 | struct namepartlist { |
60 | int n; |
61 | struct namepart *s; |
62 | }; |
63 | |
64 | struct transform { |
65 | char *type; /* track or dir */ |
66 | char *context; /* sort or choose */ |
67 | char *replace; /* substitution string */ |
68 | struct real_pcre *re; /* compiled re */ |
69 | unsigned flags; /* regexp flags */ |
70 | }; |
71 | |
72 | struct transformlist { |
73 | int n; |
74 | struct transform *t; |
75 | }; |
76 | |
77 | struct config { |
78 | /* server config */ |
79 | struct stringlistlist player; /* players */ |
80 | struct stringlistlist allow; /* allowed users */ |
81 | struct stringlist scratch; /* scratch tracks */ |
82 | long gap; /* gap between tracks */ |
83 | long history; /* length of history */ |
84 | struct stringlist trust; /* trusted users */ |
85 | const char *user; /* user to run as */ |
86 | long nice_rescan; /* rescan subprocess niceness */ |
87 | struct stringlist plugins; /* plugin path */ |
88 | struct stringlist stopword; /* stopwords for track search */ |
89 | struct collectionlist collection; /* track collections */ |
90 | long checkpoint_kbyte; |
91 | long checkpoint_min; |
92 | char *mixer; /* mixer device file */ |
93 | char *channel; /* mixer channel */ |
94 | long prefsync; /* preflog sync intreval */ |
95 | struct stringlist listen; /* secondary listen address */ |
96 | const char *alias; /* alias format */ |
97 | int lock; /* server takes a lock */ |
98 | long nice_server; /* nice value for server */ |
99 | long nice_speaker; /* nice value for speaker */ |
100 | /* shared client/server config */ |
101 | const char *home; /* home directory for state files */ |
102 | /* client config */ |
103 | const char *username, *password; /* our own username and password */ |
104 | struct stringlist connect; /* connect address */ |
105 | /* web config */ |
106 | struct stringlist templates; /* template path */ |
107 | const char *url; /* canonical URL */ |
108 | long refresh; /* maximum refresh period */ |
109 | unsigned restrictions; /* restrictions */ |
110 | #define RESTRICT_SCRATCH 1 |
111 | #define RESTRICT_REMOVE 2 |
112 | #define RESTRICT_MOVE 4 |
113 | struct namepartlist namepart; /* transformations */ |
114 | int signal; /* termination signal */ |
115 | const char *device; /* ALSA output device */ |
116 | struct transformlist transform; /* path name transformations */ |
117 | |
118 | /* derived values: */ |
119 | int nparts; /* number of distinct name parts */ |
120 | char **parts; /* name part list */ |
121 | }; |
122 | |
123 | extern struct config *config; |
124 | /* the current configuration */ |
125 | |
126 | int config_read(void); |
127 | /* re-read config, return 0 on success or non-0 on error. |
128 | * Only updates @config@ if the new configuration is valid. */ |
129 | |
130 | char *config_get_file(const char *name); |
131 | /* get a filename within the home directory */ |
132 | |
133 | struct passwd; |
134 | |
135 | char *config_userconf(const char *home, const struct passwd *pw); |
136 | /* get the user's own private conffile, assuming their home dir is |
137 | * @home@ if not null and using @pw@ otherwise */ |
138 | |
139 | char *config_usersysconf(const struct passwd *pw ); |
140 | /* get the user's conffile in /etc */ |
141 | |
142 | char *config_private(void); |
143 | /* get the private config file */ |
144 | |
145 | extern char *configfile; |
146 | |
147 | #endif /* CONFIGURATION_H */ |
148 | |
149 | /* |
150 | Local Variables: |
151 | c-basic-offset:2 |
152 | comment-column:40 |
153 | End: |
154 | */ |