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
118bee86
Commit
118bee86
authored
Jan 07, 2008
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 08, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Implement _wpopen and forward _popen to it.
parent
3debf282
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
26 deletions
+44
-26
msvcrt.h
dlls/msvcrt/msvcrt.h
+1
-0
process.c
dlls/msvcrt/process.c
+43
-26
No files found.
dlls/msvcrt/msvcrt.h
View file @
118bee86
...
...
@@ -623,6 +623,7 @@ MSVCRT_clock_t MSVCRT_clock(void);
double
MSVCRT_difftime
(
MSVCRT_time_t
time1
,
MSVCRT_time_t
time2
);
MSVCRT_time_t
MSVCRT_time
(
MSVCRT_time_t
*
);
MSVCRT_FILE
*
MSVCRT__fdopen
(
int
,
const
char
*
);
MSVCRT_FILE
*
MSVCRT__wfdopen
(
int
,
const
MSVCRT_wchar_t
*
);
int
MSVCRT_vsnprintf
(
char
*
str
,
unsigned
int
len
,
const
char
*
format
,
va_list
valist
);
int
MSVCRT_vsnwprintf
(
MSVCRT_wchar_t
*
str
,
unsigned
int
len
,
const
MSVCRT_wchar_t
*
format
,
va_list
valist
);
...
...
dlls/msvcrt/process.c
View file @
118bee86
...
...
@@ -721,22 +721,21 @@ MSVCRT_intptr_t CDECL _wspawnvp(int flags, const MSVCRT_wchar_t* name, const MSV
}
/*********************************************************************
* _popen (MSVCRT.@)
* FIXME: convert to _wpopen and call that from here instead? But it
* would have to convert the command back to ANSI to call msvcrt_spawn,
* less than ideal.
* _wpopen (MSVCRT.@)
*
* Unicode version of _popen
*/
MSVCRT_FILE
*
CDECL
MSVCRT__
popen
(
const
char
*
command
,
const
char
*
mode
)
MSVCRT_FILE
*
CDECL
MSVCRT__
wpopen
(
const
MSVCRT_wchar_t
*
command
,
const
MSVCRT_wchar_t
*
mode
)
{
static
const
char
wcmd
[]
=
"cmd"
,
cmdFlag
[]
=
" /C "
,
comSpec
[]
=
"COMSPEC"
;
MSVCRT_FILE
*
ret
;
BOOL
readPipe
=
TRUE
;
int
textmode
,
fds
[
2
],
fdToDup
,
fdToOpen
,
fdStdHandle
=
-
1
,
fdStdErr
=
-
1
;
const
char
*
p
;
char
*
cmdcopy
;
DWORD
comSpecLen
;
const
MSVCRT_wchar_t
*
p
;
MSVCRT_wchar_t
*
comspec
,
*
fullcmd
;
unsigned
int
len
;
static
const
MSVCRT_wchar_t
flag
[]
=
{
' '
,
'/'
,
'c'
,
' '
,
0
};
TRACE
(
"(command=%s, mode=%s)
\n
"
,
debugstr_
a
(
command
),
debugstr_a
(
mode
));
TRACE
(
"(command=%s, mode=%s)
\n
"
,
debugstr_
w
(
command
),
debugstr_w
(
mode
));
if
(
!
command
||
!
mode
)
return
NULL
;
...
...
@@ -782,27 +781,27 @@ MSVCRT_FILE* CDECL MSVCRT__popen(const char* command, const char* mode)
MSVCRT__close
(
fds
[
fdToDup
]);
comSpecLen
=
GetEnvironmentVariableA
(
comSpec
,
NULL
,
0
)
;
if
(
!
comSpecLen
)
comSpecLen
=
strlen
(
wcmd
)
+
1
;
cmdcopy
=
HeapAlloc
(
GetProcessHeap
(),
0
,
comSpecLen
+
strlen
(
cmdFlag
)
+
strlen
(
command
)
);
if
(
!
GetEnvironmentVariableA
(
comSpec
,
cmdcopy
,
comSpecLen
))
strcpy
(
cmdcopy
,
wcm
d
);
strcat
(
cmdcopy
,
cmdFlag
);
strcat
(
cmdcopy
,
command
);
if
(
msvcrt_spawn
(
MSVCRT__P_NOWAIT
,
NULL
,
cmdcopy
,
NULL
)
==
-
1
)
if
(
!
(
comspec
=
msvcrt_get_comspec
()))
goto
error
;
len
=
strlenW
(
comspec
)
+
strlenW
(
flag
)
+
strlenW
(
command
)
+
1
;
if
(
!
(
fullcmd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
MSVCRT_wchar_t
))))
goto
error
;
strcpyW
(
fullcmd
,
comspec
);
strcatW
(
fullcmd
,
flag
);
strcatW
(
fullcmd
,
comman
d
);
HeapFree
(
GetProcessHeap
(),
0
,
comspec
);
if
(
msvcrt_spawn
_wide
(
MSVCRT__P_NOWAIT
,
NULL
,
fullcmd
,
NULL
)
==
-
1
)
{
MSVCRT__close
(
fds
[
fdToOpen
]);
ret
=
NULL
;
}
else
{
ret
=
MSVCRT__fdopen
(
fds
[
fdToOpen
],
mode
);
ret
=
MSVCRT__
w
fdopen
(
fds
[
fdToOpen
],
mode
);
if
(
!
ret
)
MSVCRT__close
(
fds
[
fdToOpen
]);
}
HeapFree
(
GetProcessHeap
(),
0
,
cmdcopy
);
HeapFree
(
GetProcessHeap
(),
0
,
fullcmd
);
MSVCRT__dup2
(
fdStdHandle
,
fdToDup
);
MSVCRT__close
(
fdStdHandle
);
if
(
readPipe
)
...
...
@@ -821,12 +820,30 @@ error:
}
/*********************************************************************
*
_w
popen (MSVCRT.@)
*
_
popen (MSVCRT.@)
*/
MSVCRT_FILE
*
CDECL
MSVCRT__
wpopen
(
const
MSVCRT_wchar_t
*
command
,
const
MSVCRT_wchar_t
*
mode
)
MSVCRT_FILE
*
CDECL
MSVCRT__
popen
(
const
char
*
command
,
const
char
*
mode
)
{
FIXME
(
"(command=%s, mode=%s): stub
\n
"
,
debugstr_w
(
command
),
debugstr_w
(
mode
));
return
NULL
;
MSVCRT_FILE
*
ret
;
MSVCRT_wchar_t
*
cmdW
,
*
modeW
;
TRACE
(
"(command=%s, mode=%s)
\n
"
,
debugstr_a
(
command
),
debugstr_a
(
mode
));
if
(
!
command
||
!
mode
)
return
NULL
;
if
(
!
(
cmdW
=
msvcrt_wstrdupa
(
command
)))
return
NULL
;
if
(
!
(
modeW
=
msvcrt_wstrdupa
(
mode
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
cmdW
);
return
NULL
;
}
ret
=
MSVCRT__wpopen
(
cmdW
,
modeW
);
HeapFree
(
GetProcessHeap
(),
0
,
cmdW
);
HeapFree
(
GetProcessHeap
(),
0
,
modeW
);
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