]> git.pld-linux.org Git - packages/aumix-gtk.git/blob - aumix-home_etc.patch
- updated to 2.6.1.
[packages/aumix-gtk.git] / aumix-home_etc.patch
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
4 @@ -115,15 +115,19 @@
5  go into interactive mode after doing things non-interactively.
6  .It Fl L
7  load settings from
8 -.Pa $HOME/.aumixrc ,
9 -or
10 +.Pa $CONFIG_DIR/aumixrc ,
11 +.Pa $HOME/.aumixrc
12 +(depreciated), or
13  .Pa /etc/aumixrc
14  if the former is inaccessible
15  .It Fl q
16  query all devices and print their settings
17  .It Fl S
18  save settings to
19 +.Pa $CONFIG_DIR/aumixrc
20 +or
21  .Pa $HOME/.aumixrc
22 +(depreciated)
23  .El
24  .Sh EXAMPLES
25  The command
26 @@ -189,7 +193,10 @@
27  show a description of the functions of keys
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 @@ -257,8 +264,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 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
55 @@ -180,7 +180,7 @@
56  "other options:\n"
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"
63  msgstr ""
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
67 @@ -188,7 +188,7 @@
68  "other options:\n"
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"
75  msgstr ""
76 @@ -206,7 +206,7 @@
77  "Weitere Optionen:\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"
83  
84  #: src/common.c:675
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
88 @@ -187,7 +187,7 @@
89  "other options:\n"
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"
96  msgstr ""
97 @@ -205,7 +205,7 @@
98  "Otras opciones:\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"
105  
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
109 @@ -190,7 +190,7 @@
110  "other options:\n"
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"
117  msgstr ""
118 @@ -208,7 +208,7 @@
119  "autres options:\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"
126  
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
130 @@ -193,7 +193,7 @@
131  "other options:\n"
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"
138  msgstr ""
139 @@ -211,7 +211,7 @@
140  "outras opcións:\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"
147  
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
151 @@ -187,7 +187,7 @@
152  "other options:\n"
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"
159  msgstr ""
160 @@ -205,7 +205,7 @@
161  "inne opcje:\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"
168  
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
172 @@ -190,7 +190,7 @@
173  "other options:\n"
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"
180  msgstr ""
181 @@ -208,7 +208,7 @@
182  "outras opções:\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"
189  
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
193 @@ -194,7 +194,7 @@
194  "other options:\n"
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"
201  msgstr ""
202 @@ -213,7 +213,7 @@
203  "äÒÕÇÉÅ ÏÐÃÉÉ:\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"
209  "  h:  ÜÔÁ ÐÏÍÏÝØ\n"
210  
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
214 @@ -189,7 +189,7 @@
215  "other options:\n"
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"
222  msgstr ""
223 @@ -208,7 +208,7 @@
224  "¶ÎÛ¦ ÏÐæ§:\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"
230  "  h:  ÃÑ ÄÏÐÏÍÏÇÁ\n"
231  
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
235 @@ -1,7 +1,7 @@
236  bin_PROGRAMS   = aumix
237  bin_SCRIPTS    = xaumix
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
248 @@ -84,7 +84,7 @@
249  
250  bin_PROGRAMS = aumix
251  bin_SCRIPTS = xaumix
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
254  
255  localedir = $(datadir)/locale
256  INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
257 @@ -99,7 +99,7 @@
258  
259  CPPFLAGS = @CPPFLAGS@
260  LDFLAGS = @LDFLAGS@
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)
265  aumix_DEPENDENCIES = 
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
269 @@ -26,6 +26,7 @@
270  #include "gtk.h"
271  #endif                         /* HAVE_GTK */
272  #include "interactive.h"
273 +#include "userdir.h"
274  
275  FILE           *OpenDefaultFile(char *mode);
276  FILE           *setfile;
277 @@ -556,7 +557,8 @@
278  {
279  /* Open the settings file for reading or writing.
280  
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.
285  
286     Input:
287 @@ -571,19 +573,24 @@
288         FILE           *setfile;
289         char           *home;
290         char            filename[FILENAME_MAX];
291 +       struct cfv     etcfile;
292 +       
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);
300 -               }
301 -               if (setfile == NULL) {
302 -                       return NULL;
303 -               }
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;
311 +
312 +            setfile = fopencfv(&etcfile, mode);
313 +            if (setfile == NULL) {
314 +               sprintf(filename, "%s/%s", AUMIXRC_PATH, AUMIXRC);
315 +                setfile = fopen(filename, mode);
316 +            }
317         } else
318 -               setfile = fopen(save_filename, mode);
319 +           setfile = fopen(save_filename, mode);
320         return setfile;
321  }
322  
323 @@ -668,7 +675,7 @@
324  other options:\n\
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"));
331  #ifdef HAVE_CURSES
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
335 @@ -0,0 +1,167 @@
336 +// $Id$
337 +#include "userdir.h"
338 +    
339 +static char *nonulhome = "";
340 +
341 +/******************************************************************************/
342 +    
343 +int getusercfv (char *variable, 
344 +                   char *home_dir, 
345 +                   char *user_dir, 
346 +                   size_t stringsize)
347 +{
348 +       struct stat st;
349 +       char *d;
350 +       
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);
356 +       if (*d == '/') 
357 +           {
358 +           strncpy (user_dir, d, stringsize-1);
359 +           }
360 +       else
361 +           {
362 +           snprintf (user_dir, stringsize-1, "%s/%s", home_dir, d);
363 +           }
364 +           
365 +       if (stat(user_dir,&st) != -1 && S_ISDIR(st.st_mode)) 
366 +           {
367 +           return (0);
368 +           }
369 +       
370 +       return (-1);
371 +}
372 +
373 +/******************************************************************************/
374 +
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);
380 +       return 0;
381 +}
382 +
383 +/******************************************************************************/
384 +
385 +int preparemain(struct cfv *CFV) {
386 +       char *p;
387 +       struct stat st;
388 +       if ((p = strrchr(CFV->result, '/')) && *(p+1) == '\0') 
389 +           p = '\0';
390 +       snprintf ((rindex(CFV->result,'\0')), MAXPATHLEN-1, "/%s", 
391 +                 CFV->subname);
392 +       if (stat( CFV->result,&st) != -1 
393 +            && CFV->mode ? 
394 +               S_ISDIR(st.st_mode) : 
395 +               S_ISREG(st.st_mode)) /* have file or dir */
396 +           return (1);
397 +       return 0;
398 +}
399 +
400 +/******************************************************************************/
401 +
402 +int preparehome(struct cfv *CFV) {
403 +       struct stat st;
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", 
407 +                      CFV->home_dir, 
408 +                      CFV->prefix? CFV->prefix:"",
409 +                      CFV->subname,
410 +                      CFV->suffix? CFV->suffix:"");
411 +       if (stat(CFV->result,&st) != -1 
412 +                && CFV->mode ? 
413 +                   S_ISDIR(st.st_mode) : 
414 +                   S_ISREG(st.st_mode)) /* have file or dir */
415 +               return (2);
416 +       return (-1);
417 +}
418 +
419 +/******************************************************************************/
420 +
421 +int usercfv (struct cfv *CFV) {
422 +       int gr;
423 +       gr = detectcfv(CFV);
424 +       if (gr) return gr;
425 +       /* get environment variable */
426 +       gr = getusercfv (CFV->variable, 
427 +                       CFV->home_dir, 
428 +                       CFV->result,
429 +                       MAXPATHLEN);
430 +       if (gr != -1)   /* have main directory */
431 +           {
432 +               gr = preparemain(CFV);
433 +               if (gr) return gr;
434 +           }
435 +       /* don't have main directory or a proper variable set */
436 +       gr = preparehome(CFV);
437 +       return gr;
438 +}
439 +       
440 +/******************************************************************************/
441 +
442 +/* If directory or file doesn't exist returns the best one wich may be created */
443 +int notnullusercfv (struct cfv *CFV) {
444 +       int gr;
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, 
450 +                           CFV->home_dir, 
451 +                           CFV->result,
452 +                           MAXPATHLEN);
453 +           if (gr != -1)       /* have main directory */
454 +               {
455 +                   gr = preparemain(CFV);
456 +                   return 0;
457 +               }
458 +           /* don't have main directory or a proper variable set */
459 +           gr = preparehome(CFV);
460 +           return 0;
461 +       }
462 +       return 0;       
463 +}
464 +    
465 +/******************************************************************************/
466 +
467 +FILE *maynullfopencfv (struct cfv *CFV, const char *mode)
468 +    {
469 +    FILE *cfvfile = NULL;
470 +    
471 +    CFV->mode = M_REGULAR_FILE;
472 +    if ((usercfv (CFV)) == -1) return (NULL);  
473 +    cfvfile = fopen (CFV->result, mode);
474 +    return (cfvfile);
475 +    }
476 +/******************************************************************************/
477 +
478 +FILE *notnullfopencfv (struct cfv *CFV, const char *mode)
479 +    {
480 +    FILE *cfvfile = NULL;
481 +    
482 +    CFV->mode = M_REGULAR_FILE;
483 +    if ((notnullusercfv (CFV)) == -1) return (NULL);   
484 +    cfvfile = fopen (CFV->result, mode);
485 +    return (cfvfile);
486 +    }
487 +
488 +/******************************************************************************/
489 +    
490 +FILE *fopencfv (struct cfv *CFV, const char *mode)
491 +    {
492 +    FILE *cfvfile = NULL;
493 +
494 +    if (cfvfile == NULL && (strpbrk(mode, "wa")) != NULL) /* create in best location */
495 +       cfvfile = notnullfopencfv (CFV, mode);
496 +    else 
497 +       cfvfile = maynullfopencfv (CFV, mode);
498 +    
499 +    return (cfvfile);
500 +    }
501 +
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
507 @@ -0,0 +1,56 @@
508 +// $Id$
509 +#ifndef USERDIR__H
510 +#define USERDIR__H
511 +
512 +#include <unistd.h>
513 +#include <string.h>
514 +#include <stdio.h>
515 +#include <stdlib.h>
516 +#include <sys/types.h>
517 +#include <sys/stat.h>
518 +#include <sys/param.h>
519 +
520 +#define        M_REGULAR_FILE  0
521 +#define        M_DIRECTORY     1
522 +
523 +struct cfv {
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      */
532 +       };
533 +
534 +/* reads environment variable. if the path isn't absolute will add $HOME/
535 + * at the beginning
536 + * return: 0 - directory exists
537 + *         -1 - directory doesn't exist
538 + */
539 +int getusercfv (char *variable, 
540 +                   char *home_dir, 
541 +                   char *user_dir,
542 +                   size_t stringsize);
543 +/* reads the $HOME variable */
544 +int detectcfv(struct cfv *CFV);
545 +
546 +/* looks for the config/data file/dir.
547 + * result: -1 - error - cannot find file/dir 
548 + *         0 - ok
549 + *         CFV.result set
550 + */
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.
555 + *              CFV.result set
556 + */              
557 +int notnullusercfv (struct cfv *CFV);
558 +
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);
562 +
563 +#endif
This page took 0.089048 seconds and 3 git commands to generate.