1 --- aumix-2.1/doc/aumix.1 Mon Jan 31 23:30:12 2000
2 +++ aumix-2.1.pius/doc/aumix.1 Tue Feb 8 02:09:41 2000
4 go into interactive mode after doing things non-interactively.
9 +.Pa $CONFIG_DIR/aumixrc ,
13 if the former is inaccessible
15 query all devices and print their settings
18 +.Pa $CONFIG_DIR/aumixrc
26 show a description of the functions of keys
30 +.Pa $CONFIG_DIR/aumixrc ,
38 Saved settings for the mixer are kept in the
42 -files, but can be kept anywhere if specified explicitly.
43 +.Pa $CONFIG_DIR/aumixrc
46 +is now obsolete, though it still works),
47 +but can be kept anywhere if specified explicitly.
48 Color schemes are normally kept in the directory given
51 --- aumix-2.1/po/aumix.pot Mon Jan 31 23:30:12 2000
52 +++ aumix-2.1.pius/po/aumix.pot Tue Feb 8 02:09:41 2000
55 " d: adjust a device besides /dev/mixer\n"
56 " f: specify file for saving and loading settings (defaults to\n"
57 -" ~ /.aumixrc or /etc/aumixrc)\n"
58 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
59 " C: specify color scheme\n"
60 " h: this helpful message\n"
62 --- aumix-2.1/po/de.po Sun Nov 28 07:35:18 1999
63 +++ aumix-2.1.pius/po/de.po Tue Feb 8 02:09:41 2000
66 " d: adjust a device besides /dev/mixer\n"
67 " f: specify file for saving and loading settings (defaults to\n"
68 -" ~ /.aumixrc or /etc/aumixrc)\n"
69 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
70 " C: specify color scheme\n"
71 " h: this helpful message\n"
75 " d: Anderes Gerät als /dev/mixer benutzen\n"
76 " f: spezifizieren Sie Datei für Einsparung- und Ladeneinstellungen\n"
77 -" (Rückstellungen zum ~ /.aumixrc or /etc/aumixrc)\n"
78 +" (Rückstellungen zum $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
79 " h: Diese nützlichen Informationen\n"
82 --- aumix-2.1/po/es.po Mon Dec 6 16:41:47 1999
83 +++ aumix-2.1.pius/po/es.po Tue Feb 8 02:09:41 2000
86 " d: adjust a device besides /dev/mixer\n"
87 " f: specify file for saving and loading settings (defaults to\n"
88 -" ~ /.aumixrc or /etc/aumixrc)\n"
89 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
90 " C: specify color scheme\n"
91 " h: this helpful message\n"
95 " d: ajustar dispositivos además de /dev/mixer\n"
96 " f: indicar el fichero para guardar y cargar las preferencias (por\n"
97 -" defecto es ~/.aumixrc o /etc/aumixrc\n"
98 +" defecto es $CONFIG_DIR/aumixrc, ~/.aumixrc o /etc/aumixrc\n"
99 " C: indicar el esquema de color\n"
100 " h: este mensaje de ayuda\n"
102 --- aumix-2.1/po/gl.po Mon Dec 6 16:41:47 1999
103 +++ aumix-2.1.pius/po/gl.po Tue Feb 8 02:09:41 2000
106 " d: adjust a device besides /dev/mixer\n"
107 " f: specify file for saving and loading settings (defaults to\n"
108 -" ~ /.aumixrc or /etc/aumixrc)\n"
109 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
110 " C: specify color scheme\n"
111 " h: this helpful message\n"
115 " d: axustar outro dispositivo que non sexa /dev/mixer\n"
116 " f: especificar ficheiro para gardar e cargar parámetros (por omisión é\n"
117 -" ~/.aumixrc ou /etc/aumixrc)\n"
118 +" $CONFIG_DIR/aumixrc, ~/.aumixrc ou /etc/aumixrc)\n"
119 " C: especifica-lo esquema de cor\n"
120 " h: amosar esta mensaxe de axuda\n"
122 --- aumix-2.1/po/pl.po Tue Feb 8 02:15:54 2000
123 +++ aumix-2.1.pius/po/pl.po Tue Feb 8 02:09:41 2000
126 " d: adjust a device besides /dev/mixer\n"
127 " f: specify file for saving and loading settings (defaults to\n"
128 -" ~/.aumixrc or /etc/aumixrc)\n"
129 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
130 " C: specify color scheme\n"
131 " h: this helpful message\n"
135 " d: dostosowuje urz±dzenie inne ni¿ /dev/mixer\n"
136 " f: okre¶la plik do zapisywania i ³adowania ustawieñ (domy¶lnie jest to\n"
137 -" ~/.aumixrc lub /etc/aumixrc)\n"
138 +" $CONFIG_DIR/aumixrc, ~/.aumixrc lub /etc/aumixrc)\n"
139 " C: okre¶la plik zawieraj±cy schemat u¿ycia kolorów\n"
140 " h: ta pomocna informacja\n"
142 --- aumix-2.1/po/pt_BR.po Sun Nov 28 07:35:18 1999
143 +++ aumix-2.1.pius/po/pt_BR.po Tue Feb 8 02:09:41 2000
146 " d: adjust a device besides /dev/mixer\n"
147 " f: specify file for saving and loading settings (defaults to\n"
148 -" ~ /.aumixrc or /etc/aumixrc)\n"
149 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
150 " C: specify color scheme\n"
151 " h: this helpful message\n"
155 " d: usar outro dispositivo que não o /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: esta mensagem de ajuda\n"
162 --- aumix-2.1/po/ru.po Mon Dec 20 02:13:11 1999
163 +++ aumix-2.1.pius/po/ru.po Tue Feb 8 02:09:41 2000
166 " d: adjust a device besides /dev/mixer\n"
167 " f: specify file for saving and loading settings (defaults to\n"
168 -" ~ /.aumixrc or /etc/aumixrc)\n"
169 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
170 " C: specify color scheme\n"
171 " h: this helpful message\n"
175 " d: ÒÅÇÕÌÉÒÏ×ÁÔØ ÕÓÔÒÏÊÓÔ×Á ËÒÏÍÅ /dev/mixer\n"
176 " f: ÕËÁÚÁÎÉÅ ÉÍÅÎÉ ÆÁÊÌÁ ÄÌÑ ÈÒÁÎÅÎÉÑ ÕÓÔÁÎÏ×ÏË (ÐÏ ÕÍÏÌÞÁÎÉÀ\n"
177 -" ~ /.aumixrc ÉÌÉ /etc/aumixrc)\n"
178 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc ÉÌÉ /etc/aumixrc)\n"
179 " C: ×ÙÂÏÒ Ã×ÅÔÏ×ÏÊ ÓÈÅÍÙ\n"
182 --- aumix-2.1/po/uk.po Sun Nov 28 07:35:18 1999
183 +++ aumix-2.1.pius/po/uk.po Tue Feb 8 02:09:41 2000
186 " d: adjust a device besides /dev/mixer\n"
187 " f: specify file for saving and loading settings (defaults to\n"
188 -" ~ /.aumixrc or /etc/aumixrc)\n"
189 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc or /etc/aumixrc)\n"
190 " C: specify color scheme\n"
191 " h: this helpful message\n"
195 " d: ÒÅÇÕÌÀ×ÁÔÉ ÐÒÉÓÔÒϧ ÏËÒ¦Í /dev/mixer\n"
196 " f: ×ËÁÚÁÎÎÑ ¦ÍÅΦ ÆÁÊÌÕ ÄÌÑ ÚÂÅÒ¦ÇÁÎÎÑ Ò¦×Î¦× (ÚÁ ÚÁÍÏ×ÞÁÎÎÑÍ\n"
197 -" ~ /.aumixrc ÞÉ /etc/aumixrc)\n"
198 +" $CONFIG_DIR/aumixrc, ~ /.aumixrc ÞÉ /etc/aumixrc)\n"
199 " C: SPECIFY COLOR SCHEME\n"
202 --- aumix-2.1/src/Makefile.am Sat Dec 25 17:53:54 1999
203 +++ aumix-2.1.pius/src/Makefile.am Tue Feb 8 02:09:41 2000
207 -aumix_SOURCES = common.c curses.c dummy.c gpm-xterm.c gtk.c interactive.c \
208 - mouse.c common.h curses.h gpm-xterm.h gtk.h interactive.h \
210 +aumix_SOURCES = userdir.c common.c curses.c dummy.c gpm-xterm.c gtk.c \
211 + interactive.c mouse.c userdir.h common.h curses.h gpm-xterm.h \
212 + gtk.h interactive.h mouse.h
213 localedir = $(datadir)/locale
214 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
215 CFLAGS = @CFLAGS@ @GLIB_CFLAGS@ @GTK_CFLAGS@
216 --- aumix-2.1/src/Makefile.in Mon Jan 31 23:19:53 2000
217 +++ aumix-2.1.pius/src/Makefile.in Tue Feb 8 02:09:41 2000
222 -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
223 +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
225 localedir = $(datadir)/locale
226 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
229 CPPFLAGS = @CPPFLAGS@
231 -aumix_OBJECTS = common.o curses.o dummy.o gpm-xterm.o gtk.o \
232 +aumix_OBJECTS = userdir.o common.o curses.o dummy.o gpm-xterm.o gtk.o \
233 interactive.o mouse.o
234 aumix_LDADD = $(LDADD)
236 --- aumix-2.1/src/common.c Mon Jan 31 23:30:12 2000
237 +++ aumix-2.1.pius/src/common.c Tue Feb 8 02:14:43 2000
241 #include "interactive.h"
242 +#include "userdir.h"
244 void ExitIfError(int error);
245 int InitializeMixer(char *device_file);
248 /* Open the settings file for reading or writing.
250 - Try first ${HOME}/.AUMIXRC, then AUMIXRC_PATH/AUMIXRC;
251 + Try first ${CONFIG_DIR}/AUMIXRC, then ${HOME}/.AUMIXRC
252 + and eventually AUMIXRC_PATH/AUMIXRC;
253 become an error generator if neither can be opened.
256 @@ -551,19 +553,25 @@
259 char filename[FILENAME_MAX];
260 + struct cfv etcfile;
262 if (save_filename == NULL) {
263 - home = getenv("HOME");
264 - sprintf(filename, "%s/.%s", home, AUMIXRC);
265 - setfile = fopen(filename, mode);
266 - if (setfile == NULL) {
267 - sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC);
268 - setfile = fopen(filename, mode);
270 - if (setfile == NULL) {
273 + etcfile.variable = "CONFIG_DIR";
274 + etcfile.home_dir = NULL;
275 + etcfile.home_scd = NULL;
276 + etcfile.subname = AUMIXRC;
277 + etcfile.prefix = ".";
278 + etcfile.suffix = "";
279 + etcfile.mode = M_REGULAR_FILE;
281 + setfile = fopencfv(&etcfile, mode);
283 + if (setfile == NULL) {
284 + sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC);
285 + setfile = fopen(filename, mode);
288 - setfile = fopen(save_filename, mode);
289 + setfile = fopen(save_filename, mode);
295 d: adjust a device besides /dev/mixer\n\
296 f: specify file for saving and loading settings (defaults to\n\
297 - ~ /.aumixrc or /etc/aumixrc)\n\
298 + $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n\
299 C: specify color scheme\n\
300 h: this helpful message\n"));
302 --- aumix-2.1/src/userdir.c Thu Jan 1 01:00:00 1970
303 +++ aumix-2.1.pius/src/userdir.c Sat Feb 5 21:19:17 2000
306 +#include "userdir.h"
308 +static char *nonulhome = "";
310 +/******************************************************************************/
312 +int getusercfv (char *variable,
320 + bzero (user_dir, stringsize);
321 + if (variable == NULL || *variable == '\0') return (-1);
322 + if (home_dir == NULL) home_dir = nonulhome;
323 + d = getenv (variable);
324 + if (d == NULL || *d == '\0') return (-1);
327 + strncpy (user_dir, d, stringsize-1);
331 + snprintf (user_dir, stringsize-1, "%s/%s", home_dir, d);
334 + if (stat(user_dir,&st) != -1 && S_ISDIR(st.st_mode))
342 +/******************************************************************************/
344 +int detectcfv(struct cfv *CFV) {
345 + if (CFV->subname == NULL) CFV->subname = nonulhome;
346 + if (CFV->home_dir == NULL) CFV->home_dir = getenv ("HOME");
347 + if (CFV->home_dir == NULL) CFV->home_dir = CFV->home_scd;
348 + if (CFV->home_dir == NULL) return (-1);
352 +/******************************************************************************/
354 +int preparemain(struct cfv *CFV) {
357 + if ((p = strrchr(CFV->result, '/')) && *(p+1) == '\0')
359 + snprintf ((rindex(CFV->result,'\0')), MAXPATHLEN-1, "/%s",
361 + if (stat( CFV->result,&st) != -1
363 + S_ISDIR(st.st_mode) :
364 + S_ISREG(st.st_mode)) /* have file or dir */
369 +/******************************************************************************/
371 +int preparehome(struct cfv *CFV) {
373 + if (CFV->home_dir == NULL || *(CFV->home_dir) == '\0') return (-1);
374 + if (CFV->prefix == NULL && CFV->suffix == NULL) return (-1);
375 + snprintf (CFV->result, MAXPATHLEN-1, "%s/%s%s%s",
377 + CFV->prefix? CFV->prefix:"",
379 + CFV->suffix? CFV->suffix:"");
380 + if (stat(CFV->result,&st) != -1
382 + S_ISDIR(st.st_mode) :
383 + S_ISREG(st.st_mode)) /* have file or dir */
388 +/******************************************************************************/
390 +int usercfv (struct cfv *CFV) {
392 + gr = detectcfv(CFV);
394 + /* get environment variable */
395 + gr = getusercfv (CFV->variable,
399 + if (gr != -1) /* have main directory */
401 + gr = preparemain(CFV);
404 + /* don't have main directory or a proper variable set */
405 + gr = preparehome(CFV);
409 +/******************************************************************************/
411 +/* If directory or file doesn't exist returns the best one wich may be created */
412 +int notnullusercfv (struct cfv *CFV) {
414 + if ((usercfv(CFV)) == -1) {
415 + gr = detectcfv(CFV);
416 + if (gr) return gr; /* remember, it works for errors! */
417 + /* get the environment variable */
418 + gr = getusercfv (CFV->variable,
422 + if (gr != -1) /* have main directory */
424 + gr = preparemain(CFV);
427 + /* don't have main directory or a proper variable set */
428 + gr = preparehome(CFV);
434 +/******************************************************************************/
436 +FILE *maynullfopencfv (struct cfv *CFV, const char *mode)
438 + FILE *cfvfile = NULL;
440 + CFV->mode = M_REGULAR_FILE;
441 + if ((usercfv (CFV)) == -1) return (NULL);
442 + cfvfile = fopen (CFV->result, mode);
445 +/******************************************************************************/
447 +FILE *notnullfopencfv (struct cfv *CFV, const char *mode)
449 + FILE *cfvfile = NULL;
451 + CFV->mode = M_REGULAR_FILE;
452 + if ((notnullusercfv (CFV)) == -1) return (NULL);
453 + cfvfile = fopen (CFV->result, mode);
457 +/******************************************************************************/
459 +FILE *fopencfv (struct cfv *CFV, const char *mode)
461 + FILE *cfvfile = NULL;
463 + if (cfvfile == NULL && (strpbrk(mode, "wa")) != NULL) /* create in best location */
464 + cfvfile = notnullfopencfv (CFV, mode);
466 + cfvfile = maynullfopencfv (CFV, mode);
471 +/******************************************************************************/
472 \ No newline at end of file
473 --- aumix-2.1/src/userdir.h Thu Jan 1 01:00:00 1970
474 +++ aumix-2.1.pius/src/userdir.h Sat Feb 5 21:19:17 2000
484 +#include <sys/types.h>
485 +#include <sys/stat.h>
486 +#include <sys/param.h>
488 +#define M_REGULAR_FILE 0
489 +#define M_DIRECTORY 1
492 + char result[MAXPATHLEN]; /* our result */
493 + char *variable; /* name of an environment variable */
494 + char *home_dir; /* home directory or NULL for autodetect */
495 + char *home_scd; /* directory if home_dir==NULL and no result */
496 + char *subname; /* core name of a file/directory */
497 + char *prefix; /* prefix when using directly home_dir */
498 + char *suffix; /* suffix when using directly home_dir */
499 + int mode; /* expected: M_REGULAR_FILE or M_DIRECTORY */
502 +/* reads environment variable. if the path isn't absolute will add $HOME/
504 + * return: 0 - directory exists
505 + * -1 - directory doesn't exist
507 +int getusercfv (char *variable,
510 + size_t stringsize);
511 +/* reads the $HOME variable */
512 +int detectcfv(struct cfv *CFV);
514 +/* looks for the config/data file/dir.
515 + * result: -1 - error - cannot find file/dir
519 +int usercfv (struct cfv *CFV);
520 +/* looks for the config/data file/dir.
521 + * result: -1 - error - cannot read $HOME
522 + * 0 - ok - if the CFV.result exists, read it. If not create it.
525 +int notnullusercfv (struct cfv *CFV);
527 +FILE *fopencfv (struct cfv *CFV, const char *mode);
528 +FILE *maynullfopencfv (struct cfv *CFV, const char *mode);
529 +FILE *notnullfopencfv (struct cfv *CFV, const char *mode);