1 diff -Nru aumix-2.6/doc/aumix.1 aumix-2.6.new/doc/aumix.1
2 --- aumix-2.6/doc/aumix.1 Fri Apr 14 06:47:08 2000
3 +++ aumix-2.6.new/doc/aumix.1 Fri Apr 14 06:46:17 2000
5 go into interactive mode after doing things non-interactively.
10 +.Pa $CONFIG_DIR/aumixrc ,
14 if the former is inaccessible
16 query all devices and print their settings
19 +.Pa $CONFIG_DIR/aumixrc
27 show a description of the functions of keys
31 +.Pa $CONFIG_DIR/aumixrc ,
39 Saved settings for the mixer are kept in the
43 -files, but can be kept anywhere if specified explicitly.
44 +.Pa $CONFIG_DIR/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
52 diff -Nru aumix-2.6/po/aumix.pot aumix-2.6.new/po/aumix.pot
53 --- aumix-2.6/po/aumix.pot Fri Apr 14 06:47:08 2000
54 +++ aumix-2.6.new/po/aumix.pot Fri Apr 14 06:46:17 2000
57 " d: adjust a device besides /dev/mixer\n"
58 " f: specify file for saving and loading settings (defaults to\n"
59 -" ~/.aumixrc or /etc/aumixrc)\n"
60 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
61 " C: specify color scheme\n"
62 " h: this helpful message\n"
64 diff -Nru aumix-2.6/po/de.po aumix-2.6.new/po/de.po
65 --- aumix-2.6/po/de.po Fri Apr 14 06:47:08 2000
66 +++ aumix-2.6.new/po/de.po Fri Apr 14 06:48:27 2000
69 " d: adjust a device besides /dev/mixer\n"
70 " f: specify file for saving and loading settings (defaults to\n"
71 -" ~/.aumixrc or /etc/aumixrc)\n"
72 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc) or /etc/aumixrc)\n"
73 " C: specify color scheme\n"
74 " h: this helpful message\n"
78 " d: Anderes Gerät als /dev/mixer benutzen\n"
79 " f: Spezifizieren Sie die Datei zum Speichern und Laden von Einstellungen\n"
80 -" (Standard sind ~/.aumixrc oder /etc/aumixrc)\n"
81 +" (Standard sind ~/.aumixrc oder /etc/aumixrc) or /etc/aumixrc)\n"
82 " h: Diese nützlichen Informationen\n"
85 diff -Nru aumix-2.6/po/es.po aumix-2.6.new/po/es.po
86 --- aumix-2.6/po/es.po Fri Apr 14 06:47:08 2000
87 +++ aumix-2.6.new/po/es.po Fri Apr 14 06:46:17 2000
90 " d: adjust a device besides /dev/mixer\n"
91 " f: specify file for saving and loading settings (defaults to\n"
92 -" ~/.aumixrc or /etc/aumixrc)\n"
93 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
94 " C: specify color scheme\n"
95 " h: this helpful message\n"
99 " d: ajustar dispositivos además de /dev/mixer\n"
100 " f: indicar el fichero para guardar y cargar las preferencias (por\n"
101 -" defecto es ~/.aumixrc o /etc/aumixrc\n"
102 +" defecto es $CONFIG_DIR/aumixrc, ~/.aumixrc o /etc/aumixrc\n"
103 " C: indicar el esquema de color\n"
104 " h: este mensaje de ayuda\n"
106 diff -Nru aumix-2.6/po/fr.po aumix-2.6.new/po/fr.po
107 --- aumix-2.6/po/fr.po Fri Apr 14 06:47:08 2000
108 +++ aumix-2.6.new/po/fr.po Fri Apr 14 06:46:17 2000
111 " d: adjust a device besides /dev/mixer\n"
112 " f: specify file for saving and loading settings (defaults to\n"
113 -" ~/.aumixrc or /etc/aumixrc)\n"
114 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
115 " C: specify color scheme\n"
116 " h: this helpful message\n"
120 " d: ajuster un périphérique autre que /dev/mixer\n"
121 " f: spécifier le fichier de sauvegarde/chargement des paramètres\n"
122 -" (par défaut il s'agit de ~/.aumixrc ou /etc/aumixrc)\n"
123 +" (par défaut il s'agit de $CONFIG_DIR/aumixrc, ~/.aumixrc ou /etc/aumixrc)\n"
124 " C: spécifier le modèle de couleurs\n"
125 " h: ce message d'aide\n"
127 diff -Nru aumix-2.6/po/gl.po aumix-2.6.new/po/gl.po
128 --- aumix-2.6/po/gl.po Fri Apr 14 06:47:08 2000
129 +++ aumix-2.6.new/po/gl.po Fri Apr 14 06:46:17 2000
132 " d: adjust a device besides /dev/mixer\n"
133 " f: specify file for saving and loading settings (defaults to\n"
134 -" ~/.aumixrc or /etc/aumixrc)\n"
135 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
136 " C: specify color scheme\n"
137 " h: this helpful message\n"
141 " d: axustar outro dispositivo que non sexa /dev/mixer\n"
142 " f: especificar ficheiro para gardar e cargar parámetros (por omisión é\n"
143 -" ~/.aumixrc ou /etc/aumixrc)\n"
144 +" $CONFIG_DIR/aumixrc, ~/.aumixrc ou /etc/aumixrc)\n"
145 " C: especifica-lo esquema de cor\n"
146 " h: amosar esta mensaxe de axuda\n"
148 diff -Nru aumix-2.6/po/pl.po aumix-2.6.new/po/pl.po
149 --- aumix-2.6/po/pl.po Fri Apr 14 06:47:08 2000
150 +++ aumix-2.6.new/po/pl.po Fri Apr 14 06:46:17 2000
153 " d: adjust a device besides /dev/mixer\n"
154 " f: specify file for saving and loading settings (defaults to\n"
155 -" ~/.aumixrc or /etc/aumixrc)\n"
156 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
157 " C: specify color scheme\n"
158 " h: this helpful message\n"
162 " d: dostosowuje urz±dzenie inne ni¿ /dev/mixer\n"
163 " f: okre¶la plik do zapisywania i ³adowania ustawieñ (domy¶lnie jest to\n"
164 -" ~/.aumixrc lub /etc/aumixrc)\n"
165 +" $CONFIG_DIR/aumixrc, ~/.aumixrc lub /etc/aumixrc)\n"
166 " C: okre¶la plik zawieraj±cy schemat u¿ycia kolorów\n"
167 " h: ta pomocna informacja\n"
169 diff -Nru aumix-2.6/po/pt_BR.po aumix-2.6.new/po/pt_BR.po
170 --- aumix-2.6/po/pt_BR.po Fri Apr 14 06:47:08 2000
171 +++ aumix-2.6.new/po/pt_BR.po Fri Apr 14 06:46:17 2000
174 " d: adjust a device besides /dev/mixer\n"
175 " f: specify file for saving and loading settings (defaults to\n"
176 -" ~/.aumixrc or /etc/aumixrc)\n"
177 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
178 " C: specify color scheme\n"
179 " h: this helpful message\n"
183 " d: usar outro dispositivo que não o /dev/mixer\n"
184 " f: SPECIFY FILE FOR SAVING AND LOADING SETTINGS (DEFAULTS TO\n"
185 -" ~/.aumixrc or /etc/aumixrc)\n"
186 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
187 " C: SPECIFY COLOR SCHEME\n"
188 " h: esta mensagem de ajuda\n"
190 diff -Nru aumix-2.6/po/ru.po aumix-2.6.new/po/ru.po
191 --- aumix-2.6/po/ru.po Fri Apr 14 06:47:08 2000
192 +++ aumix-2.6.new/po/ru.po Fri Apr 14 06:46:17 2000
195 " d: adjust a device besides /dev/mixer\n"
196 " f: specify file for saving and loading settings (defaults to\n"
197 -" ~/.aumixrc or /etc/aumixrc)\n"
198 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
199 " C: specify color scheme\n"
200 " h: this helpful message\n"
204 " d: ÒÅÇÕÌÉÒÏ×ÁÔØ ÕÓÔÒÏÊÓÔ×Á ËÒÏÍÅ /dev/mixer\n"
205 " f: ÕËÁÚÁÎÉÅ ÉÍÅÎÉ ÆÁÊÌÁ ÄÌÑ ÈÒÁÎÅÎÉÑ ÕÓÔÁÎÏ×ÏË (ÐÏ ÕÍÏÌÞÁÎÉÀ\n"
206 -" ~/.aumixrc ÉÌÉ /etc/aumixrc)\n"
207 +" $CONFIG_DIR/aumixrc, ~/.aumixrc ÉÌÉ /etc/aumixrc)\n"
208 " C: ×ÙÂÏÒ Ã×ÅÔÏ×ÏÊ ÓÈÅÍÙ\n"
211 diff -Nru aumix-2.6/po/uk.po aumix-2.6.new/po/uk.po
212 --- aumix-2.6/po/uk.po Fri Apr 14 06:47:08 2000
213 +++ aumix-2.6.new/po/uk.po Fri Apr 14 06:46:17 2000
216 " d: adjust a device besides /dev/mixer\n"
217 " f: specify file for saving and loading settings (defaults to\n"
218 -" ~/.aumixrc or /etc/aumixrc)\n"
219 +" $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n"
220 " C: specify color scheme\n"
221 " h: this helpful message\n"
225 " d: ÒÅÇÕÌÀ×ÁÔÉ ÐÒÉÓÔÒϧ ÏËÒ¦Í /dev/mixer\n"
226 " f: ×ËÁÚÁÎÎÑ ¦ÍÅΦ ÆÁÊÌÕ ÄÌÑ ÚÂÅÒ¦ÇÁÎÎÑ Ò¦×Î¦× (ÚÁ ÚÁÍÏ×ÞÁÎÎÑÍ\n"
227 -" ~/.aumixrc ÞÉ /etc/aumixrc)\n"
228 +" $CONFIG_DIR/aumixrc, ~/.aumixrc ÞÉ /etc/aumixrc)\n"
229 " C: SPECIFY COLOR SCHEME\n"
232 diff -Nru aumix-2.6/src/Makefile.am aumix-2.6.new/src/Makefile.am
233 --- aumix-2.6/src/Makefile.am Fri Apr 14 06:47:08 2000
234 +++ aumix-2.6.new/src/Makefile.am Fri Apr 14 06:46:17 2000
238 -aumix_SOURCES = common.c curses.c dummy.c gpm-xterm.c gtk.c interactive.c \
239 - mouse.c common.h curses.h gpm-xterm.h gtk.h interactive.h \
240 +aumix_SOURCES = userdir.c common.c curses.c dummy.c gpm-xterm.c gtk.c interactive.c \
241 + mouse.c userdir.h common.h curses.h gpm-xterm.h gtk.h interactive.h \
242 mouse.h play.xpm record.xpm
243 localedir = $(datadir)/locale
244 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
245 diff -Nru aumix-2.6/src/Makefile.in aumix-2.6.new/src/Makefile.in
246 --- aumix-2.6/src/Makefile.in Fri Apr 14 06:47:08 2000
247 +++ aumix-2.6.new/src/Makefile.in Fri Apr 14 06:46:17 2000
252 -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 play.xpm record.xpm
253 +aumix_SOURCES = userdir.c 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 play.xpm record.xpm
255 localedir = $(datadir)/locale
256 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
259 CPPFLAGS = @CPPFLAGS@
261 -aumix_OBJECTS = common.o curses.o dummy.o gpm-xterm.o gtk.o \
262 +aumix_OBJECTS = userdir.o common.o curses.o dummy.o gpm-xterm.o gtk.o \
263 interactive.o mouse.o
264 aumix_LDADD = $(LDADD)
266 diff -Nru aumix-2.6/src/common.c aumix-2.6.new/src/common.c
267 --- aumix-2.6/src/common.c Fri Apr 14 06:47:08 2000
268 +++ aumix-2.6.new/src/common.c Fri Apr 14 06:46:17 2000
271 #endif /* HAVE_GTK */
272 #include "interactive.h"
273 +#include "userdir.h"
275 FILE *OpenDefaultFile(char *mode);
279 /* Open the settings file for reading or writing.
281 - Try first ${HOME}/.AUMIXRC, then AUMIXRC_PATH/AUMIXRC;
282 + Try first ${HOME}/.AUMIXRC, then then ${HOME}/.AUMIXRC
283 + and eventualy AUMIXRC_PATH/AUMIXRC;
284 become an error generator if neither can be opened.
287 @@ -571,19 +573,24 @@
290 char filename[FILENAME_MAX];
291 + struct cfv etcfile;
293 if (save_filename == NULL) {
294 - home = getenv("HOME");
295 - sprintf(filename, "%s/.%s", home, AUMIXRC);
296 - setfile = fopen(filename, mode);
297 - if (setfile == NULL) {
298 - sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC);
299 - setfile = fopen(filename, mode);
301 - if (setfile == NULL) {
304 + etcfile.variable = "CONFIG_DIR";
305 + etcfile.home_dir = NULL;
306 + etcfile.home_scd = NULL;
307 + etcfile.subname = AUMIXRC;
308 + etcfile.prefix = ".";
309 + etcfile.suffix = "";
310 + etcfile.mode = M_REGULAR_FILE;
312 + setfile = fopencfv(&etcfile, mode);
313 + if (setfile == NULL) {
314 + sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC);
315 + setfile = fopen(filename, mode);
318 - setfile = fopen(save_filename, mode);
319 + setfile = fopen(save_filename, mode);
325 d: adjust a device besides /dev/mixer\n\
326 f: specify file for saving and loading settings (defaults to\n\
327 - ~/.aumixrc or /etc/aumixrc)\n\
328 + $CONFIG_DIR/aumixrc, ~/.aumixrc or /etc/aumixrc)\n\
329 C: specify color scheme\n\
330 h: this helpful message\n"));
332 diff -Nru aumix-2.6/src/userdir.c aumix-2.6.new/src/userdir.c
333 --- aumix-2.6/src/userdir.c Thu Jan 1 01:00:00 1970
334 +++ aumix-2.6.new/src/userdir.c Fri Apr 14 06:46:17 2000
337 +#include "userdir.h"
339 +static char *nonulhome = "";
341 +/******************************************************************************/
343 +int getusercfv (char *variable,
351 + bzero (user_dir, stringsize);
352 + if (variable == NULL || *variable == '\0') return (-1);
353 + if (home_dir == NULL) home_dir = nonulhome;
354 + d = getenv (variable);
355 + if (d == NULL || *d == '\0') return (-1);
358 + strncpy (user_dir, d, stringsize-1);
362 + snprintf (user_dir, stringsize-1, "%s/%s", home_dir, d);
365 + if (stat(user_dir,&st) != -1 && S_ISDIR(st.st_mode))
373 +/******************************************************************************/
375 +int detectcfv(struct cfv *CFV) {
376 + if (CFV->subname == NULL) CFV->subname = nonulhome;
377 + if (CFV->home_dir == NULL) CFV->home_dir = getenv ("HOME");
378 + if (CFV->home_dir == NULL) CFV->home_dir = CFV->home_scd;
379 + if (CFV->home_dir == NULL) return (-1);
383 +/******************************************************************************/
385 +int preparemain(struct cfv *CFV) {
388 + if ((p = strrchr(CFV->result, '/')) && *(p+1) == '\0')
390 + snprintf ((rindex(CFV->result,'\0')), MAXPATHLEN-1, "/%s",
392 + if (stat( CFV->result,&st) != -1
394 + S_ISDIR(st.st_mode) :
395 + S_ISREG(st.st_mode)) /* have file or dir */
400 +/******************************************************************************/
402 +int preparehome(struct cfv *CFV) {
404 + if (CFV->home_dir == NULL || *(CFV->home_dir) == '\0') return (-1);
405 + if (CFV->prefix == NULL && CFV->suffix == NULL) return (-1);
406 + snprintf (CFV->result, MAXPATHLEN-1, "%s/%s%s%s",
408 + CFV->prefix? CFV->prefix:"",
410 + CFV->suffix? CFV->suffix:"");
411 + if (stat(CFV->result,&st) != -1
413 + S_ISDIR(st.st_mode) :
414 + S_ISREG(st.st_mode)) /* have file or dir */
419 +/******************************************************************************/
421 +int usercfv (struct cfv *CFV) {
423 + gr = detectcfv(CFV);
425 + /* get environment variable */
426 + gr = getusercfv (CFV->variable,
430 + if (gr != -1) /* have main directory */
432 + gr = preparemain(CFV);
435 + /* don't have main directory or a proper variable set */
436 + gr = preparehome(CFV);
440 +/******************************************************************************/
442 +/* If directory or file doesn't exist returns the best one wich may be created */
443 +int notnullusercfv (struct cfv *CFV) {
445 + if ((usercfv(CFV)) == -1) {
446 + gr = detectcfv(CFV);
447 + if (gr) return gr; /* remember, it works for errors! */
448 + /* get the environment variable */
449 + gr = getusercfv (CFV->variable,
453 + if (gr != -1) /* have main directory */
455 + gr = preparemain(CFV);
458 + /* don't have main directory or a proper variable set */
459 + gr = preparehome(CFV);
465 +/******************************************************************************/
467 +FILE *maynullfopencfv (struct cfv *CFV, const char *mode)
469 + FILE *cfvfile = NULL;
471 + CFV->mode = M_REGULAR_FILE;
472 + if ((usercfv (CFV)) == -1) return (NULL);
473 + cfvfile = fopen (CFV->result, mode);
476 +/******************************************************************************/
478 +FILE *notnullfopencfv (struct cfv *CFV, const char *mode)
480 + FILE *cfvfile = NULL;
482 + CFV->mode = M_REGULAR_FILE;
483 + if ((notnullusercfv (CFV)) == -1) return (NULL);
484 + cfvfile = fopen (CFV->result, mode);
488 +/******************************************************************************/
490 +FILE *fopencfv (struct cfv *CFV, const char *mode)
492 + FILE *cfvfile = NULL;
494 + if (cfvfile == NULL && (strpbrk(mode, "wa")) != NULL) /* create in best location */
495 + cfvfile = notnullfopencfv (CFV, mode);
497 + cfvfile = maynullfopencfv (CFV, mode);
502 +/******************************************************************************/
503 \ No newline at end of file
504 diff -Nru aumix-2.6/src/userdir.h aumix-2.6.new/src/userdir.h
505 --- aumix-2.6/src/userdir.h Thu Jan 1 01:00:00 1970
506 +++ aumix-2.6.new/src/userdir.h Fri Apr 14 06:46:17 2000
516 +#include <sys/types.h>
517 +#include <sys/stat.h>
518 +#include <sys/param.h>
520 +#define M_REGULAR_FILE 0
521 +#define M_DIRECTORY 1
524 + char result[MAXPATHLEN]; /* our result */
525 + char *variable; /* name of an environment variable */
526 + char *home_dir; /* home directory or NULL for autodetect */
527 + char *home_scd; /* directory if home_dir==NULL and no result */
528 + char *subname; /* core name of a file/directory */
529 + char *prefix; /* prefix when using directly home_dir */
530 + char *suffix; /* suffix when using directly home_dir */
531 + int mode; /* expected: M_REGULAR_FILE or M_DIRECTORY */
534 +/* reads environment variable. if the path isn't absolute will add $HOME/
536 + * return: 0 - directory exists
537 + * -1 - directory doesn't exist
539 +int getusercfv (char *variable,
542 + size_t stringsize);
543 +/* reads the $HOME variable */
544 +int detectcfv(struct cfv *CFV);
546 +/* looks for the config/data file/dir.
547 + * result: -1 - error - cannot find file/dir
551 +int usercfv (struct cfv *CFV);
552 +/* looks for the config/data file/dir.
553 + * result: -1 - error - cannot read $HOME
554 + * 0 - ok - if the CFV.result exists, read it. If not create it.
557 +int notnullusercfv (struct cfv *CFV);
559 +FILE *fopencfv (struct cfv *CFV, const char *mode);
560 +FILE *maynullfopencfv (struct cfv *CFV, const char *mode);
561 +FILE *notnullfopencfv (struct cfv *CFV, const char *mode);