Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoann Laissus
wine
Commits
eeaae3ca
Commit
eeaae3ca
authored
24 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Make child processes inherit command-line options through the
WINEOPTIONS environment variable.
parent
b8774f95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/options.c
+114
-40
114 additions, 40 deletions
misc/options.c
with
114 additions
and
40 deletions
misc/options.c
+
114
−
40
View file @
eeaae3ca
...
...
@@ -6,6 +6,7 @@
#include
"config.h"
#include
<string.h>
#include
<stdlib.h>
#include
"winbase.h"
#include
"main.h"
...
...
@@ -18,6 +19,7 @@ struct option
const
char
*
longname
;
char
shortname
;
int
has_arg
;
int
inherit
;
void
(
*
func
)(
const
char
*
arg
);
const
char
*
usage
;
};
...
...
@@ -41,6 +43,22 @@ struct options Options =
const
char
*
argv0
;
static
char
*
inherit_str
;
/* options to pass to child processes */
static
void
out_of_memory
(
void
)
WINE_NORETURN
;
static
void
out_of_memory
(
void
)
{
MESSAGE
(
"Virtual memory exhausted
\n
"
);
ExitProcess
(
1
);
}
static
char
*
xstrdup
(
const
char
*
str
)
{
char
*
ret
=
strdup
(
str
);
if
(
!
ret
)
out_of_memory
();
return
ret
;
}
static
void
do_config
(
const
char
*
arg
);
static
void
do_desktop
(
const
char
*
arg
);
static
void
do_display
(
const
char
*
arg
);
...
...
@@ -52,30 +70,30 @@ static void do_version( const char *arg );
static
const
struct
option
option_table
[]
=
{
{
"config"
,
0
,
1
,
do_config
,
{
"config"
,
0
,
1
,
0
,
do_config
,
"--config name Specify config file to use"
},
{
"debugmsg"
,
0
,
1
,
MAIN_ParseDebugOptions
,
{
"debugmsg"
,
0
,
1
,
1
,
MAIN_ParseDebugOptions
,
"--debugmsg name Turn debugging-messages on or off"
},
{
"desktop"
,
0
,
1
,
do_desktop
,
{
"desktop"
,
0
,
1
,
1
,
do_desktop
,
"--desktop geom Use a desktop window of the given geometry"
},
{
"display"
,
0
,
1
,
do_display
,
{
"display"
,
0
,
1
,
0
,
do_display
,
"--display name Use the specified display"
},
{
"dll"
,
0
,
1
,
do_dll
,
{
"dll"
,
0
,
1
,
1
,
do_dll
,
"--dll name Enable or disable built-in DLLs"
},
{
"dosver"
,
0
,
1
,
VERSION_ParseDosVersion
,
{
"dosver"
,
0
,
1
,
1
,
VERSION_ParseDosVersion
,
"--dosver x.xx DOS version to imitate (e.g. 6.22). Only valid with --winver win31"
},
{
"help"
,
'h'
,
0
,
do_help
,
{
"help"
,
'h'
,
0
,
0
,
do_help
,
"--help,-h Show this help message"
},
{
"language"
,
0
,
1
,
MAIN_ParseLanguageOption
,
"--language xx Set the language (one of Br,Ca,Cs,Cy,Da,De,En,Eo,Es,Fi,Fr,Ga,Gd,Gv
\n
"
" Hu,It,Ja,Ko,Kw,Nl,No,Pl,Pt,Sk,Sv,Ru,Wa)"
},
{
"managed"
,
0
,
0
,
do_managed
,
{
"language"
,
0
,
1
,
1
,
MAIN_ParseLanguageOption
,
"--language xx Set the language (one of Br,Ca,Cs,Cy,Da,De,En,Eo,Es,Fi,Fr,Ga,Gd,Gv
,
\n
"
"
Hr,
Hu,It,Ja,Ko,Kw,Nl,No,Pl,Pt,Sk,Sv,Ru,Wa)"
},
{
"managed"
,
0
,
0
,
0
,
do_managed
,
"--managed Allow the window manager to manage created windows"
},
{
"synchronous"
,
0
,
0
,
do_synchronous
,
{
"synchronous"
,
0
,
0
,
1
,
do_synchronous
,
"--synchronous Turn on synchronous display mode"
},
{
"version"
,
'v'
,
0
,
do_version
,
{
"version"
,
'v'
,
0
,
0
,
do_version
,
"--version,-v Display the Wine version"
},
{
"winver"
,
0
,
1
,
VERSION_ParseWinVersion
,
{
"winver"
,
0
,
1
,
1
,
VERSION_ParseWinVersion
,
"--winver Version to imitate (one of win31,win95,nt351,nt40)"
},
{
NULL
,
}
/* terminator */
};
...
...
@@ -99,12 +117,12 @@ static void do_synchronous( const char *arg )
static
void
do_desktop
(
const
char
*
arg
)
{
Options
.
desktopGeometry
=
strdup
(
arg
);
Options
.
desktopGeometry
=
x
strdup
(
arg
);
}
static
void
do_display
(
const
char
*
arg
)
{
Options
.
display
=
strdup
(
arg
);
Options
.
display
=
x
strdup
(
arg
);
}
static
void
do_dll
(
const
char
*
arg
)
...
...
@@ -117,7 +135,7 @@ static void do_dll( const char *arg )
MESSAGE
(
"Only one -dll flag is allowed. Use ',' between multiple DLLs
\n
"
);
ExitProcess
(
1
);
}
Options
.
dllFlags
=
strdup
(
arg
);
Options
.
dllFlags
=
x
strdup
(
arg
);
}
static
void
do_managed
(
const
char
*
arg
)
...
...
@@ -127,35 +145,42 @@ static void do_managed( const char *arg )
static
void
do_config
(
const
char
*
arg
)
{
Options
.
configFileName
=
strdup
(
arg
);
Options
.
configFileName
=
x
strdup
(
arg
);
}
static
inline
void
remove_options
(
char
*
argv
[],
int
pos
,
int
count
)
static
void
remove_options
(
char
*
argv
[],
int
pos
,
int
count
,
int
inherit
)
{
if
(
inherit
)
{
int
i
,
len
=
0
;
for
(
i
=
0
;
i
<
count
;
i
++
)
len
+=
strlen
(
argv
[
pos
+
i
])
+
1
;
if
(
inherit_str
)
{
if
(
!
(
inherit_str
=
realloc
(
inherit_str
,
strlen
(
inherit_str
)
+
len
)))
out_of_memory
();
strcat
(
inherit_str
,
" "
);
}
else
{
if
(
!
(
inherit_str
=
malloc
(
len
)))
out_of_memory
();
inherit_str
[
0
]
=
0
;
}
for
(
i
=
0
;
i
<
count
;
i
++
)
{
strcat
(
inherit_str
,
argv
[
pos
+
i
]
);
if
(
i
<
count
-
1
)
strcat
(
inherit_str
,
" "
);
}
}
while
((
argv
[
pos
]
=
argv
[
pos
+
count
]))
pos
++
;
}
/***********************************************************************
* OPTIONS_Usage
*/
void
OPTIONS_Usage
(
void
)
{
const
struct
option
*
opt
;
MESSAGE
(
"Usage: %s [options] program_name [arguments]
\n\n
"
,
argv0
);
MESSAGE
(
"Options:
\n
"
);
for
(
opt
=
option_table
;
opt
->
longname
;
opt
++
)
MESSAGE
(
" %s
\n
"
,
opt
->
usage
);
ExitProcess
(
0
);
}
/***********************************************************************
* OPTIONS_ParseOptions
*/
void
OPTIONS_ParseOptions
(
char
*
argv
[]
)
/* parse options from the argv array and remove all the recognized ones */
static
void
parse_options
(
char
*
argv
[]
)
{
const
struct
option
*
opt
;
int
i
;
for
(
i
=
1
;
argv
[
i
];
i
++
)
for
(
i
=
0
;
argv
[
i
];
i
++
)
{
char
*
p
=
argv
[
i
];
if
(
*
p
++
!=
'-'
)
continue
;
/* not an option */
...
...
@@ -176,27 +201,76 @@ void OPTIONS_ParseOptions( char *argv[] )
if
(
opt
->
has_arg
&&
argv
[
i
+
1
])
{
opt
->
func
(
argv
[
i
+
1
]
);
remove_options
(
argv
,
i
,
2
);
remove_options
(
argv
,
i
,
2
,
opt
->
inherit
);
}
else
{
opt
->
func
(
""
);
remove_options
(
argv
,
i
,
1
);
remove_options
(
argv
,
i
,
1
,
opt
->
inherit
);
}
i
--
;
}
}
/* inherit options from WINEOPTIONS variable */
static
void
inherit_options
(
char
*
buffer
)
{
char
*
argv
[
256
];
int
i
;
char
*
p
=
strtok
(
buffer
,
"
\t
"
);
for
(
i
=
0
;
i
<
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])
-
1
&&
p
;
i
++
)
{
argv
[
i
]
=
p
;
p
=
strtok
(
NULL
,
"
\t
"
);
}
argv
[
i
]
=
NULL
;
parse_options
(
argv
);
if
(
argv
[
0
])
/* an option remains */
{
MESSAGE
(
"Unknown option '%s' in WINEOPTIONS variable
\n\n
"
,
argv
[
0
]
);
OPTIONS_Usage
();
}
}
/***********************************************************************
* OPTIONS_Usage
*/
void
OPTIONS_Usage
(
void
)
{
const
struct
option
*
opt
;
MESSAGE
(
"Usage: %s [options] program_name [arguments]
\n\n
"
,
argv0
);
MESSAGE
(
"Options:
\n
"
);
for
(
opt
=
option_table
;
opt
->
longname
;
opt
++
)
MESSAGE
(
" %s
\n
"
,
opt
->
usage
);
ExitProcess
(
0
);
}
/***********************************************************************
* OPTIONS_ParseOptions
*/
void
OPTIONS_ParseOptions
(
char
*
argv
[]
)
{
char
buffer
[
1024
];
int
i
;
if
(
GetEnvironmentVariableA
(
"WINEOPTIONS"
,
buffer
,
sizeof
(
buffer
)
)
&&
buffer
[
0
])
inherit_options
(
buffer
);
parse_options
(
argv
+
1
);
SetEnvironmentVariableA
(
"WINEOPTIONS"
,
inherit_str
);
/* check if any option remains */
for
(
i
=
1
;
argv
[
i
];
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"--"
))
{
remove_options
(
argv
,
i
,
1
);
remove_options
(
argv
,
i
,
1
,
0
);
break
;
}
if
(
argv
[
i
][
0
]
==
'-'
)
{
MESSAGE
(
"Unknown option '%s'
\n
"
,
argv
[
i
]
);
MESSAGE
(
"Unknown option '%s'
\n
\n
"
,
argv
[
i
]
);
OPTIONS_Usage
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment