ac9fa1ac |
1 | --- aumix-2.1/doc/aumix.1 Mon Jan 31 23:30:12 2000 |
2 | +++ aumix-2.1.pius/doc/aumix.1 Fri Feb 4 00:50:48 2000 |
3 | @@ -115,7 +115,8 @@ |
7476d76d |
4 | go into interactive mode after doing things non-interactively. |
5 | .It Fl L |
ac9fa1ac |
6 | load settings from |
7 | -.Pa $HOME/.aumixrc , |
8 | -or |
9 | +.Pa $CONFIG_DIR/aumixrc , |
10 | +.Pa $HOME/.aumixrc |
11 | +(depreciated), or |
12 | .Pa /etc/aumixrc |
13 | if the former is inaccessible |
14 | @@ -123,7 +125,10 @@ |
7476d76d |
15 | query all devices and print their settings |
16 | .It Fl S |
ac9fa1ac |
17 | save settings to |
18 | -.Pa $HOME/.aumixrc |
19 | +.Pa $CONFIG_DIR/aumixrc |
20 | +or |
21 | +.Pa $HOME/.aumixrc |
22 | +(depreciated) |
7476d76d |
23 | .El |
7476d76d |
24 | .Sh EXAMPLE |
ac9fa1ac |
25 | The command |
26 | @@ -179,7 +184,10 @@ |
7476d76d |
27 | show a description of the functions of keys |
ac9fa1ac |
28 | .It L or l |
29 | load settings from |
30 | -.Pa $HOME/.aumixrc , |
31 | +.Pa $CONFIG_DIR/aumixrc , |
32 | +or |
33 | +.Pa $HOME/.aumixrc |
34 | +(depreciated), |
35 | falling back to |
36 | .Pa /etc/aumixrc |
37 | .It M or m |
38 | @@ -247,8 +255,11 @@ |
39 | Saved settings for the mixer are kept in the |
40 | .Pa /etc/aumixrc |
41 | and |
42 | -.Pa $HOME/.aumixrc |
43 | -files, but can be kept anywhere if specified explicitly. |
44 | +.Pa $CONFIG_DIR/aumixrc |
45 | +files, ( |
46 | +.Pa $HOME/.aumixrc |
47 | +is now obsolete, though it still works), |
48 | +but can be kept anywhere if specified explicitly. |
49 | Color schemes are normally kept in the directory given |
50 | by |
51 | .Ev DATADIRNAME |
52 | --- aumix-2.1/src/Makefile.am Sat Dec 25 17:53:54 1999 |
53 | +++ aumix-2.1.pius/src/Makefile.am Thu Feb 3 16:26:12 2000 |
54 | @@ -1,8 +1,8 @@ |
55 | bin_PROGRAMS = aumix |
56 | bin_SCRIPTS = xaumix |
57 | -aumix_SOURCES = common.c curses.c dummy.c gpm-xterm.c gtk.c interactive.c \ |
58 | - mouse.c common.h curses.h gpm-xterm.h gtk.h interactive.h \ |
59 | - mouse.h |
60 | +aumix_SOURCES = userdir.c common.c curses.c dummy.c gpm-xterm.c gtk.c \ |
61 | + interactive.c mouse.c userdir.h common.h curses.h gpm-xterm.h \ |
62 | + gtk.h interactive.h mouse.h |
63 | localedir = $(datadir)/locale |
64 | INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@ |
65 | CFLAGS = @CFLAGS@ @GLIB_CFLAGS@ @GTK_CFLAGS@ |
66 | --- aumix-2.1/src/Makefile.in Mon Jan 31 23:19:53 2000 |
67 | +++ aumix-2.1.pius/src/Makefile.in Thu Feb 3 16:25:03 2000 |
68 | @@ -84,7 +84,7 @@ |
69 | |
70 | bin_PROGRAMS = aumix |
71 | bin_SCRIPTS = xaumix |
72 | -aumix_SOURCES = common.c curses.c dummy.c gpm-xterm.c gtk.c interactive.c mouse.c common.h curses.h gpm-xterm.h gtk.h interactive.h mouse.h |
73 | +aumix_SOURCES = userdir.c common.c curses.c dummy.c gpm-xterm.c gtk.c interactive.c mouse.c userdir.h common.h curses.h gpm-xterm.h gtk.h interactive.h mouse.h |
74 | |
75 | localedir = $(datadir)/locale |
76 | INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@ |
77 | @@ -99,7 +99,7 @@ |
78 | |
79 | CPPFLAGS = @CPPFLAGS@ |
80 | LDFLAGS = @LDFLAGS@ |
81 | -aumix_OBJECTS = common.o curses.o dummy.o gpm-xterm.o gtk.o \ |
82 | +aumix_OBJECTS = userdir.o common.o curses.o dummy.o gpm-xterm.o gtk.o \ |
83 | interactive.o mouse.o |
84 | aumix_LDADD = $(LDADD) |
85 | aumix_DEPENDENCIES = |
86 | --- aumix-2.1/src/common.c Mon Jan 31 23:30:12 2000 |
87 | +++ aumix-2.1.pius/src/common.c Thu Feb 3 23:51:47 2000 |
88 | @@ -24,6 +24,7 @@ |
89 | #include "gtk.h" |
90 | #endif |
91 | #include "interactive.h" |
92 | +#include "userdir.h" |
93 | |
94 | void ExitIfError(int error); |
95 | int InitializeMixer(char *device_file); |
96 | @@ -536,7 +537,8 @@ |
97 | { |
98 | /* Open the settings file for reading or writing. |
7476d76d |
99 | |
ac9fa1ac |
100 | - Try first ${HOME}/.AUMIXRC, then AUMIXRC_PATH/AUMIXRC; |
101 | + Try first ${CONFIG_DIR}/AUMIXRC, then ${HOME}/.AUMIXRC |
102 | + and eventually AUMIXRC_PATH/AUMIXRC; |
103 | become an error generator if neither can be opened. |
104 | |
105 | Input: |
106 | @@ -548,22 +550,34 @@ |
107 | Success: pointer to the default settings file structure |
108 | Failure: NULL |
109 | */ |
110 | - FILE *setfile; |
111 | + FILE *setfile = NULL; |
112 | char *home; |
113 | char filename[FILENAME_MAX]; |
114 | + struct cfv etcfile; |
115 | + |
116 | if (save_filename == NULL) { |
117 | - home = getenv("HOME"); |
118 | - sprintf(filename, "%s/.%s", home, AUMIXRC); |
119 | - setfile = fopen(filename, mode); |
120 | - if (setfile == NULL) { |
121 | - sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC); |
122 | - setfile = fopen(filename, mode); |
123 | - } |
124 | - if (setfile == NULL) { |
125 | - return NULL; |
126 | - } |
127 | + etcfile.variable = "CONFIG_DIR"; |
128 | + etcfile.home_dir = NULL; |
129 | + etcfile.home_scd = NULL; |
130 | + etcfile.subname = AUMIXRC; |
131 | + etcfile.prefix = "."; |
132 | + etcfile.suffix = ""; |
133 | + etcfile.mode = M_REGULAR_FILE; |
134 | + |
135 | + if ((usercfv (&etcfile)) == -1) |
136 | + setfile = notnullfopencfv(&etcfile, mode); |
137 | + else |
138 | + setfile = fopen(etcfile.result, mode); |
139 | + |
140 | + if (setfile == NULL) { |
141 | + sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC); |
142 | + setfile = fopen(filename, mode); |
143 | + } |
144 | + if (setfile == NULL) |
145 | + return NULL; |
146 | + |
147 | } else |
148 | - setfile = fopen(save_filename, mode); |
149 | + setfile = fopen(save_filename, mode); |
150 | return setfile; |
151 | } |
152 | |
153 | @@ -649,7 +663,7 @@ |
154 | other options:\n\ |
155 | d: adjust a device besides /dev/mixer\n\ |
156 | f: specify file for saving and loading settings (defaults to\n\ |
157 | - ~ /.aumixrc or /etc/aumixrc)\n\ |
158 | + $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n\ |
159 | C: specify color scheme\n\ |
160 | h: this helpful message\n")); |
161 | #ifdef HAVE_CURSES |
162 | --- aumix-2.1/src/userdir.c Thu Jan 1 01:00:00 1970 |
163 | +++ aumix-2.1.pius/src/userdir.c Thu Feb 3 01:24:28 2000 |
164 | @@ -0,0 +1,146 @@ |
165 | +// $Id$ |
166 | +#include "userdir.h" |
167 | + |
168 | +static char *nonulhome = ""; |
169 | + |
170 | +/******************************************************************************/ |
171 | + |
172 | +int getusercfv (char *variable, |
173 | + char *home_dir, |
174 | + char *user_dir, |
175 | + size_t stringsize) |
176 | +{ |
177 | + struct stat st; |
178 | + char *d; |
179 | + |
180 | + bzero (user_dir, stringsize); |
181 | + if (variable == NULL || *variable == '\0') return (-1); |
182 | + if (home_dir == NULL) home_dir = nonulhome; |
183 | + d = getenv (variable); |
184 | + if (d == NULL || *d == '\0') return (-1); |
185 | + if (*d == '/') |
186 | + { |
187 | + strncpy (user_dir, d, stringsize-1); |
188 | + } |
189 | + else |
190 | + { |
191 | + snprintf (user_dir, stringsize-1, "%s/%s", home_dir, d); |
192 | + } |
193 | + |
194 | + if (stat(user_dir,&st) != -1 && S_ISDIR(st.st_mode)) |
195 | + { |
196 | + return (0); |
197 | + } |
198 | + |
199 | + return (-1); |
200 | +} |
201 | + |
202 | +/******************************************************************************/ |
203 | + |
204 | +int detectcfv(struct cfv *CFV) { |
205 | + if (CFV->subname == NULL) CFV->subname = nonulhome; |
206 | + if (CFV->home_dir == NULL) CFV->home_dir = getenv ("HOME"); |
207 | + if (CFV->home_dir == NULL) CFV->home_dir = CFV->home_scd; |
208 | + if (CFV->home_dir == NULL) return (-1); |
209 | + return 0; |
210 | +} |
211 | + |
212 | +int preparemain(struct cfv *CFV) { |
213 | + char *p; |
214 | + struct stat st; |
215 | + if ((p = strrchr(CFV->result, '/')) && *(p+1) == '\0') |
216 | + p = '\0'; |
217 | + snprintf ((rindex(CFV->result,'\0')), MAXPATHLEN-1, "/%s", |
218 | + CFV->subname); |
219 | + if (stat( CFV->result,&st) != -1 |
220 | + && CFV->mode ? |
221 | + S_ISDIR(st.st_mode) : |
222 | + S_ISREG(st.st_mode)) /* have file or dir */ |
223 | + return (1); |
224 | + return 0; |
225 | +} |
226 | + |
227 | +int preparehome(struct cfv *CFV) { |
228 | + struct stat st; |
229 | + if (CFV->home_dir == NULL || *(CFV->home_dir) == '\0') return (-1); |
230 | + if (CFV->prefix == NULL && CFV->suffix == NULL) return (-1); |
231 | + snprintf (CFV->result, MAXPATHLEN-1, "%s/%s%s%s", |
232 | + CFV->home_dir, |
233 | + CFV->prefix? CFV->prefix:"", |
234 | + CFV->subname, |
235 | + CFV->suffix? CFV->suffix:""); |
236 | + if (stat(CFV->result,&st) != -1 |
237 | + && CFV->mode ? |
238 | + S_ISDIR(st.st_mode) : |
239 | + S_ISREG(st.st_mode)) /* have file or dir */ |
240 | + return (2); |
241 | + return (-1); |
242 | +} |
243 | + |
244 | +int usercfv (struct cfv *CFV) { |
245 | + int gr; |
246 | + gr = detectcfv(CFV); |
247 | + if (gr) return gr; |
248 | + /* get environment variable */ |
249 | + gr = getusercfv (CFV->variable, |
250 | + CFV->home_dir, |
251 | + CFV->result, |
252 | + MAXPATHLEN); |
253 | + if (gr != -1) /* have main directory */ |
254 | + { |
255 | + gr = preparemain(CFV); |
256 | + if (gr) return gr; |
257 | + } |
258 | + /* don't have main directory or a proper variable set */ |
259 | + gr = preparehome(CFV); |
260 | + return gr; |
261 | +} |
262 | + |
263 | +/******************************************************************************/ |
264 | + |
265 | +/* If directory or file doesn't exist returns the best one wich may be created*/ |
266 | +int notnullusercfv (struct cfv *CFV) { |
267 | + int gr; |
268 | + if ((usercfv(CFV)) == -1) { |
269 | + gr = detectcfv(CFV); |
270 | + if (gr) return gr; |
271 | + /* get environment variable */ |
272 | + gr = getusercfv (CFV->variable, |
273 | + CFV->home_dir, |
274 | + CFV->result, |
275 | + MAXPATHLEN); |
276 | + if (gr != -1) /* have main directory */ |
277 | + { |
278 | + gr = preparemain(CFV); |
279 | + return 0; |
280 | + } |
281 | + /* don't have main directory or a proper variable set */ |
282 | + gr = preparehome(CFV); |
283 | + return 0; |
284 | + } |
285 | + return 0; |
286 | +} |
287 | + |
288 | +/******************************************************************************/ |
289 | + |
290 | +FILE *fopencfv (struct cfv *CFV, const char *mode) |
291 | + { |
292 | + FILE *cfvfile = NULL; |
293 | + |
294 | + CFV->mode = M_REGULAR_FILE; |
295 | + if ((usercfv (CFV)) == -1) return (NULL); |
296 | + cfvfile = fopen (CFV->result, mode); |
297 | + return (cfvfile); |
298 | + } |
299 | +/******************************************************************************/ |
300 | + |
301 | +FILE *notnullfopencfv (struct cfv *CFV, const char *mode) |
302 | + { |
303 | + FILE *cfvfile = NULL; |
304 | + |
305 | + CFV->mode = M_REGULAR_FILE; |
306 | + if ((notnullusercfv (CFV)) == -1) return (NULL); |
307 | + cfvfile = fopen (CFV->result, mode); |
308 | + return (cfvfile); |
309 | + } |
310 | + |
311 | --- aumix-2.1/src/userdir.h Thu Jan 1 01:00:00 1970 |
312 | +++ aumix-2.1.pius/src/userdir.h Thu Feb 3 01:58:57 2000 |
313 | @@ -0,0 +1,55 @@ |
314 | +// $Id$ |
315 | +#ifndef USERDIR__H |
316 | +#define USERDIR__H |
317 | + |
318 | +#include <unistd.h> |
319 | +#include <string.h> |
320 | +#include <stdio.h> |
321 | +#include <stdlib.h> |
322 | +#include <sys/types.h> |
323 | +#include <sys/stat.h> |
324 | +#include <sys/param.h> |
325 | + |
326 | +#define M_REGULAR_FILE 0 |
327 | +#define M_DIRECTORY 1 |
328 | + |
329 | +struct cfv { |
330 | + char result[MAXPATHLEN]; /* our result */ |
331 | + char *variable; /* name of an environment variable */ |
332 | + char *home_dir; /* home directory or NULL for autodetect */ |
333 | + char *home_scd; /* directory if home_dir==NULL and no result */ |
334 | + char *subname; /* core name of a file/directory */ |
335 | + char *prefix; /* prefix when using directly home_dir */ |
336 | + char *suffix; /* suffix when using directly home_dir */ |
337 | + int mode; /* expected: M_REGULAR_FILE or M_DIRECTORY */ |
338 | + }; |
339 | + |
340 | +/* reads environment variable. if the path isn't absolute will add $HOME/ |
341 | + * at the beginning |
342 | + * return: 0 - directory exists |
343 | + * -1 - directory doesn't exist |
344 | + */ |
345 | +int getusercfv (char *variable, |
346 | + char *home_dir, |
347 | + char *user_dir, |
348 | + size_t stringsize); |
349 | +/* reads the $HOME variable */ |
350 | +int detectcfv(struct cfv *CFV); |
351 | + |
352 | +/* looks for the config/data file/dir. |
353 | + * result: -1 - error - cannot find file/dir |
354 | + * 0 - ok |
355 | + * CFV.result set |
356 | + */ |
357 | +int usercfv (struct cfv *CFV); |
358 | +/* looks for the config/data file/dir. |
359 | + * result: -1 - error - cannot read $HOME |
360 | + * 0 - ok - if the CFV.result exists, read it. If not create it. |
361 | + * CFV.result set |
362 | + */ |
363 | +int notnullusercfv (struct cfv *CFV); |
364 | + |
365 | +FILE *fopencfv (struct cfv *CFV, const char *mode); |
366 | +FILE *notnullfopencfv (struct cfv *CFV, const char *mode); |
367 | + |
368 | +#endif |
369 | --- aumix-2.1/po/aumix.pot Mon Jan 31 23:30:12 2000 |
370 | +++ aumix-2.1.pius/po/aumix.pot Fri Feb 4 01:11:42 2000 |
371 | @@ -175,7 +175,7 @@ |
7476d76d |
372 | "other options:\n" |
373 | " d: adjust a device besides /dev/mixer\n" |
374 | " f: specify file for saving and loading settings (defaults to\n" |
375 | -" ~ /.aumixrc or /etc/aumixrc)\n" |
ac9fa1ac |
376 | +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n" |
7476d76d |
377 | " C: specify color scheme\n" |
378 | " h: this helpful message\n" |
379 | msgstr "" |
ac9fa1ac |
380 | --- aumix-2.1/po/de.po Sun Nov 28 07:35:18 1999 |
381 | +++ aumix-2.1.pius/po/de.po Fri Feb 4 01:10:08 2000 |
7476d76d |
382 | @@ -81,7 +81,7 @@ |
383 | "other options:\n" |
384 | " d: adjust a device besides /dev/mixer\n" |
385 | " f: specify file for saving and loading settings (defaults to\n" |
386 | -" ~ /.aumixrc or /etc/aumixrc)\n" |
ac9fa1ac |
387 | +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n" |
7476d76d |
388 | " C: specify color scheme\n" |
389 | " h: this helpful message\n" |
390 | msgstr "" |
391 | @@ -99,7 +99,7 @@ |
392 | "Weitere Optionen:\n" |
393 |