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
5986e3a7
Commit
5986e3a7
authored
Oct 08, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added wine_get_argv0_path() to retrieve the path of the wine binary.
parent
af192f83
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
5 deletions
+50
-5
library.h
include/wine/library.h
+1
-0
config.c
libs/wine/config.c
+45
-0
loader.c
libs/wine/loader.c
+4
-5
No files found.
include/wine/library.h
View file @
5986e3a7
...
...
@@ -32,6 +32,7 @@
extern
const
char
*
wine_get_config_dir
(
void
);
extern
const
char
*
wine_get_server_dir
(
void
);
extern
const
char
*
wine_get_user_name
(
void
);
extern
const
char
*
wine_get_argv0_path
(
void
);
/* dll loading */
...
...
libs/wine/config.c
View file @
5986e3a7
...
...
@@ -25,6 +25,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
...
...
@@ -40,6 +41,7 @@ static const char * const server_dir_prefix = "/server-"; /* prefix for ser
static
char
*
config_dir
;
static
char
*
server_dir
;
static
char
*
user_name
;
static
char
*
argv0_path
;
#ifdef __GNUC__
static
void
fatal_error
(
const
char
*
err
,
...
)
__attribute__
((
noreturn
,
format
(
printf
,
1
,
2
)));
...
...
@@ -178,6 +180,43 @@ static void init_paths(void)
sprintf
(
server_dir
+
strlen
(
server_dir
),
"%lx"
,
(
unsigned
long
)
st
.
st_ino
);
}
/* initialize the argv0 path */
void
init_argv0_path
(
const
char
*
argv0
)
{
size_t
size
,
len
;
const
char
*
p
;
char
*
cwd
;
if
(
!
(
p
=
strrchr
(
argv0
,
'/'
)))
return
;
/* if argv0 doesn't contain a path, don't do anything */
len
=
p
-
argv0
+
1
;
if
(
argv0
[
0
]
==
'/'
)
/* absolute path */
{
argv0_path
=
xmalloc
(
len
+
1
);
memcpy
(
argv0_path
,
argv0
,
len
);
argv0_path
[
len
]
=
0
;
return
;
}
/* relative path, make it absolute */
for
(
size
=
256
+
len
;
;
size
*=
2
)
{
if
(
!
(
cwd
=
malloc
(
size
)))
break
;
if
(
getcwd
(
cwd
,
size
-
len
))
{
argv0_path
=
cwd
;
cwd
+=
strlen
(
cwd
);
*
cwd
++
=
'/'
;
memcpy
(
cwd
,
argv0
,
len
);
cwd
[
len
]
=
0
;
return
;
}
free
(
cwd
);
if
(
errno
!=
ERANGE
)
break
;
}
}
/* return the configuration directory ($WINEPREFIX or $HOME/.wine) */
const
char
*
wine_get_config_dir
(
void
)
{
...
...
@@ -198,3 +237,9 @@ const char *wine_get_user_name(void)
if
(
!
user_name
)
init_paths
();
return
user_name
;
}
/* return the path of argv[0], including a trailing slash */
const
char
*
wine_get_argv0_path
(
void
)
{
return
argv0_path
;
}
libs/wine/loader.c
View file @
5986e3a7
...
...
@@ -46,6 +46,8 @@ int __wine_main_argc = 0;
char
**
__wine_main_argv
=
NULL
;
WCHAR
**
__wine_main_wargv
=
NULL
;
extern
void
init_argv0_path
(
const
char
*
argv0
);
/* config.c */
#define MAX_DLLS 100
static
struct
...
...
@@ -63,7 +65,6 @@ static load_dll_callback_t load_dll_callback;
static
const
char
**
dll_paths
;
static
int
nb_dll_paths
;
static
int
dll_path_maxlen
;
static
int
init_done
;
/* build the dll load path from the WINEDLLPATH variable */
...
...
@@ -73,8 +74,6 @@ static void build_dll_path(void)
int
len
,
count
=
0
;
char
*
p
,
*
path
=
getenv
(
"WINEDLLPATH"
);
init_done
=
1
;
if
(
path
)
{
/* count how many path elements we need */
...
...
@@ -132,8 +131,6 @@ static void *dlopen_dll( const char *name, char *error, int errorsize,
char
*
buffer
,
*
p
;
void
*
ret
=
NULL
;
if
(
!
init_done
)
build_dll_path
();
buffer
=
malloc
(
dll_path_maxlen
+
namelen
+
5
);
/* store the name at the end of the buffer, followed by .so */
...
...
@@ -421,6 +418,8 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
void
*
kernel
;
void
(
*
init_func
)(
int
,
char
**
);
build_dll_path
();
init_argv0_path
(
argv
[
0
]
);
if
(
!
dlopen_dll
(
"ntdll.dll"
,
error
,
error_size
,
0
,
&
file_exists
))
return
;
/* make sure kernel32 is loaded too */
if
(
!
(
kernel
=
dlopen_dll
(
"kernel32.dll"
,
error
,
error_size
,
0
,
&
file_exists
)))
return
;
...
...
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