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
cdfcef24
Commit
cdfcef24
authored
Mar 04, 2003
by
Eric Pouech
Committed by
Alexandre Julliard
Mar 04, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added ability to use --backend=(curses|user) as wineconsole parameter
- rewrote wineconsole command line option parsing
parent
c7b5d0aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
43 deletions
+76
-43
wineconsole.c
programs/wineconsole/wineconsole.c
+76
-43
No files found.
programs/wineconsole/wineconsole.c
View file @
cdfcef24
...
...
@@ -661,16 +661,54 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
return
done
;
}
struct
wc_init
{
LPCSTR
ptr
;
enum
{
from_event
,
from_process_name
}
mode
;
BOOL
(
*
backend
)(
struct
inner_data
*
);
HANDLE
event
;
};
/******************************************************************
* WINECON_
HasEvent
* WINECON_
ParseOptions
*
*
*/
static
BOOL
WINECON_
HasEvent
(
LPCSTR
ptr
,
unsigned
*
evt
)
static
BOOL
WINECON_
ParseOptions
(
const
char
*
lpCmdLine
,
struct
wc_init
*
wci
)
{
while
(
*
ptr
==
' '
||
*
ptr
==
'\t'
)
ptr
++
;
if
(
strncmp
(
ptr
,
"--use-event="
,
12
))
return
FALSE
;
return
sscanf
(
ptr
+
12
,
"%d"
,
evt
)
==
1
;
memset
(
wci
,
0
,
sizeof
(
*
wci
));
wci
->
ptr
=
lpCmdLine
;
wci
->
mode
=
from_process_name
;
wci
->
backend
=
WCCURSES_InitBackend
;
for
(;;)
{
while
(
*
wci
->
ptr
==
' '
||
*
wci
->
ptr
==
'\t'
)
wci
->
ptr
++
;
if
(
wci
->
ptr
[
0
]
!=
'-'
)
break
;
if
(
strncmp
(
wci
->
ptr
,
"--use-event="
,
12
)
==
0
)
{
char
*
end
;
wci
->
event
=
(
HANDLE
)
strtol
(
wci
->
ptr
+
12
,
&
end
,
10
);
if
(
end
==
wci
->
ptr
+
12
)
return
FALSE
;
wci
->
mode
=
from_event
;
wci
->
ptr
=
end
;
}
else
if
(
strncmp
(
wci
->
ptr
,
"--backend="
,
10
)
==
0
)
{
if
(
strncmp
(
wci
->
ptr
+
10
,
"user"
,
4
)
==
0
)
{
wci
->
backend
=
WCUSER_InitBackend
;
wci
->
ptr
+=
14
;
}
else
if
(
strncmp
(
wci
->
ptr
+
10
,
"curses"
,
6
)
==
0
)
{
wci
->
ptr
+=
16
;
}
else
return
FALSE
;
}
}
return
TRUE
;
}
/******************************************************************
...
...
@@ -680,52 +718,48 @@ static BOOL WINECON_HasEvent(LPCSTR ptr, unsigned* evt)
* wineconsole --use-event=<int> used when a new console is created (AllocConsole)
* wineconsole <pgm> <arguments> used to start the program <pgm> from the command line in
* a freshly created console
* --backend=(curses|user) can also be used to select the desired backend
*/
int
PASCAL
WinMain
(
HINSTANCE
hInst
,
HINSTANCE
hPrev
,
LPSTR
lpCmdLine
,
INT
nCmdShow
)
{
struct
inner_data
*
data
;
int
ret
=
1
;
unsigned
evt
;
struct
wc_init
wci
;
/* case of wineconsole <evt>, signal process that created us that we're up and running */
if
(
WINECON_HasEvent
(
lpCmdLine
,
&
evt
))
if
(
!
WINECON_ParseOptions
(
lpCmdLine
,
&
wci
))
{
if
(
!
(
data
=
WINECON_Init
(
hInst
,
0
,
NULL
,
WCUSER_InitBackend
)))
return
0
;
ret
=
SetEvent
((
HANDLE
)
evt
);
if
(
!
ret
)
{
WINE_ERR
(
"SetEvent failed.
\n
"
);
goto
cleanup
;
}
WINE_ERR
(
"Wrong command line options
\n
"
);
return
0
;
}
else
{
LPWSTR
wcmdLine
=
GetCommandLine
()
/* we're unicode... */
;
LPWSTR
src
,
dst
;
WCHAR
buffer
[
256
];
/* remove wineconsole from commandline...
* we could have several ' ' in process command line... so try first space...
*/
/* FIXME:
* the correct way would be to check the existence of the left part of ptr
* (to be a file)
*/
/* FIXME: could also add an option to choose another backend if needed */
while
(
*
wcmdLine
&&
*
wcmdLine
++
!=
' '
);
/* FIXME: see above */
src
=
wcmdLine
;
dst
=
buffer
;
while
(
*
src
&&
*
src
!=
' '
)
*
dst
++
=
*
src
++
;
*
dst
=
0
;
if
(
!
(
data
=
WINECON_Init
(
hInst
,
GetCurrentProcessId
(),
buffer
,
WCCURSES_InitBackend
)))
return
0
;
ret
=
WINECON_Spawn
(
data
,
wcmdLine
);
if
(
!
ret
)
{
WINE_MESSAGE
(
"wineconsole: spawning client program failed. Invalid/missing command line arguments ?
\n
"
);
goto
cleanup
;
}
switch
(
wci
.
mode
)
{
case
from_event
:
/* case of wineconsole <evt>, signal process that created us that we're up and running */
if
(
!
(
data
=
WINECON_Init
(
hInst
,
0
,
NULL
,
wci
.
backend
)))
return
0
;
ret
=
SetEvent
(
wci
.
event
);
if
(
!
ret
)
WINE_ERR
(
"SetEvent failed.
\n
"
);
break
;
case
from_process_name
:
{
const
char
*
src
;
LPWSTR
dst
;
WCHAR
buffer
[
256
];
src
=
wci
.
ptr
;
dst
=
buffer
;
while
(
*
src
&&
*
src
!=
' '
&&
(
dst
-
buffer
<
sizeof
(
buffer
)
/
sizeof
(
WCHAR
)
-
1
))
*
dst
++
=
*
src
++
;
*
dst
=
0
;
if
(
!
(
data
=
WINECON_Init
(
hInst
,
GetCurrentProcessId
(),
buffer
,
wci
.
backend
)))
return
0
;
ret
=
WINECON_Spawn
(
data
,
buffer
);
if
(
!
ret
)
WINE_MESSAGE
(
"wineconsole: spawning client program failed (%s), invalid/missing command line arguments ?
\n
"
,
wine_dbgstr_w
(
buffer
));
}
break
;
default:
return
0
;
}
if
(
ret
)
...
...
@@ -734,7 +768,6 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
ret
=
data
->
fnMainLoop
(
data
);
}
cleanup:
WINECON_Delete
(
data
);
return
ret
;
...
...
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