[Mplayer-cvslog] CVS: main mplayer.c,1.23,1.24
Szabolcs Berecz
szabii at users.sourceforge.net
Wed Mar 21 01:14:15 CET 2001
Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv31113
Modified Files:
mplayer.c
Log Message:
get_path()
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** mplayer.c 2001/03/20 22:11:38 1.23
--- mplayer.c 2001/03/21 00:14:13 1.24
***************
*** 100,103 ****
--- 100,125 ----
}
+ char *get_path(char *filename){
+ char *homedir;
+ char *buff;
+ static char *config_dir = "/.mplayer";
+ int len;
+
+ if ((homedir = getenv("HOME")) == NULL)
+ return NULL;
+ len = strlen(homedir) + strlen(config_dir) + 1;
+ if (filename == NULL) {
+ if ((buff = (char *) malloc(len)) == NULL)
+ return NULL;
+ sprintf(buff, "%s%s", homedir, config_dir);
+ } else {
+ len += strlen(filename) + 1;
+ if ((buff = (char *) malloc(len)) == NULL)
+ return NULL;
+ sprintf(buff, "%s%s/%s", homedir, config_dir, filename);
+ }
+ return buff;
+ }
+
static int max_framesize=0;
***************
*** 386,392 ****
char *dsp="/dev/dsp";
int force_ni=0;
! char *homedir;
! char conffile[100];
! char confdir[100];
int conffile_fd;
#include "cfg-mplayer.h"
--- 408,412 ----
char *dsp="/dev/dsp";
int force_ni=0;
! char *conffile;
int conffile_fd;
#include "cfg-mplayer.h"
***************
*** 396,411 ****
if (parse_config_file(conf, "/etc/mplayer.conf") < 0)
exit(1);
! if ((homedir = getenv("HOME")) == NULL) {
printf("Can't find HOME dir\n");
} else {
! snprintf(confdir, 100, "%s/.mplayer", homedir);
! mkdir(confdir, 0777);
! snprintf(conffile, 100, "%s/config", confdir);
! if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0644)) != -1) {
! write(conffile_fd, default_config, strlen(default_config));
! close(conffile_fd);
}
- if (parse_config_file(conf, conffile) < 0)
- exit(1);
}
if (parse_command_line(conf, argc, argv, envp, &filename) < 0)
--- 416,436 ----
if (parse_config_file(conf, "/etc/mplayer.conf") < 0)
exit(1);
! if ((conffile = get_path("")) == NULL) {
printf("Can't find HOME dir\n");
} else {
! mkdir(conffile, 0777);
! free(conffile);
! if ((conffile = get_path("config")) == NULL) {
! printf("get_path(\"config\") sziiiivas\n");
! } else {
! if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) {
! printf("Creating config file: %s\n", conffile);
! write(conffile_fd, default_config, strlen(default_config));
! close(conffile_fd);
! }
! if (parse_config_file(conf, conffile) < 0)
! exit(1);
! free(conffile);
}
}
if (parse_command_line(conf, argc, argv, envp, &filename) < 0)
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
More information about the MPlayer-cvslog
mailing list