Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
27254d84
Commit
27254d84
authored
Nov 28, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libwine: Add a helper function to read a symlink.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ece6dfe5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
config.c
libs/wine/config.c
+23
-17
No files found.
libs/wine/config.c
View file @
27254d84
...
...
@@ -54,9 +54,11 @@ static void fatal_perror( const char *err, ... ) __attribute__((noreturn,format
#endif
#if defined(__linux__) || defined(__FreeBSD_kernel__ )
#define EXE_LINK "/proc/self/exe"
static
const
char
exe_link
[]
=
"/proc/self/exe"
;
#elif defined (__FreeBSD__) || defined(__DragonFly__)
#define EXE_LINK "/proc/curproc/file"
static
const
char
exe_link
[]
=
"/proc/curproc/file"
;
#else
static
const
char
exe_link
[]
=
""
;
#endif
/* die on a fatal error */
...
...
@@ -151,30 +153,34 @@ static char *get_runtime_libdir(void)
return
NULL
;
}
/* re
turn the directory that contains the main exe at run-time
*/
static
char
*
get_runtime_exedir
(
void
)
/* re
ad a symlink and return its directory
*/
static
char
*
symlink_dirname
(
const
char
*
name
)
{
#ifdef EXE_LINK
char
*
p
,
*
bindir
;
int
size
;
char
*
p
,
*
buffer
;
int
ret
,
size
;
for
(
size
=
256
;
;
size
*=
2
)
{
int
ret
;
if
(
!
(
bindir
=
malloc
(
size
)))
return
NULL
;
if
((
ret
=
readlink
(
EXE_LINK
,
bindir
,
size
))
==
-
1
)
break
;
if
(
!
(
buffer
=
malloc
(
size
)))
return
NULL
;
if
((
ret
=
readlink
(
name
,
buffer
,
size
))
==
-
1
)
break
;
if
(
ret
!=
size
)
{
b
indi
r
[
ret
]
=
0
;
if
(
!
(
p
=
strrchr
(
b
indi
r
,
'/'
)))
break
;
if
(
p
==
b
indi
r
)
p
++
;
b
uffe
r
[
ret
]
=
0
;
if
(
!
(
p
=
strrchr
(
b
uffe
r
,
'/'
)))
break
;
if
(
p
==
b
uffe
r
)
p
++
;
*
p
=
0
;
return
b
indi
r
;
return
b
uffe
r
;
}
free
(
b
indi
r
);
free
(
b
uffe
r
);
}
free
(
bindir
);
#endif
free
(
buffer
);
return
NULL
;
}
/* return the directory that contains the main exe at run-time */
static
char
*
get_runtime_exedir
(
void
)
{
if
(
exe_link
[
0
])
return
symlink_dirname
(
exe_link
);
return
NULL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment