Mercurial > mplayer.hg
annotate get_path.c @ 10730:67449e5936f3
fix 10l (computation based on uninitialized data which led to
incorrect field matching) and greatly improve selection logic. the
pullup core should be very accurate now, so try throwing tough samples
at it and report any failures! :)
author | rfelker |
---|---|
date | Sun, 31 Aug 2003 17:46:32 +0000 |
parents | b8780122e043 |
children | 133e0ebde74d |
rev | line source |
---|---|
2557 | 1 |
2 char *get_path(char *filename){ | |
3 char *homedir; | |
4 char *buff; | |
10026
b8780122e043
Cygwin should behave like a Unix environment, i.e. config files should be
diego
parents:
9929
diff
changeset
|
5 #if defined(__MINGW32__) |
9926
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
6 static char *config_dir = "/mplayer"; |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
7 #else |
2557 | 8 static char *config_dir = "/.mplayer"; |
9926
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
9 #endif |
2557 | 10 int len; |
11 | |
12 if ((homedir = getenv("HOME")) == NULL) | |
9926
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
13 #if defined(__MINGW32__)||defined(__CYGWIN__) /*hack to get fonts etc. loaded outside of cygwin environment*/ |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
14 { |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
15 int __stdcall GetModuleFileNameA(void* hModule,char* lpFilename,int nSize); |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
16 int i,imax=0; |
9929 | 17 char exedir[260]; |
18 GetModuleFileNameA(NULL, exedir, 260); | |
9926
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
19 for(i=0; i< strlen(exedir);i++)if(exedir[i] =='\\'){exedir[i]='/';imax=i;} |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
20 exedir[imax]='\0'; |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
21 homedir = exedir; |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
22 } |
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
23 #else |
2557 | 24 return NULL; |
9926
ad429d617df4
allow config file loading outside of cygwin environment
faust3
parents:
3746
diff
changeset
|
25 #endif |
2557 | 26 len = strlen(homedir) + strlen(config_dir) + 1; |
27 if (filename == NULL) { | |
28 if ((buff = (char *) malloc(len)) == NULL) | |
29 return NULL; | |
30 sprintf(buff, "%s%s", homedir, config_dir); | |
31 } else { | |
32 len += strlen(filename) + 1; | |
33 if ((buff = (char *) malloc(len)) == NULL) | |
34 return NULL; | |
35 sprintf(buff, "%s%s/%s", homedir, config_dir, filename); | |
36 } | |
3746 | 37 mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); |
2557 | 38 return buff; |
39 } |