mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 22:55:41 +00:00
fix formatting
svn path=/trunk/; revision=41661
This commit is contained in:
parent
a291ebef7a
commit
593091354a
1 changed files with 98 additions and 100 deletions
|
@ -1,20 +1,20 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: lib/crt/??????
|
* FILE: lib/crt/??????
|
||||||
* PURPOSE: Unknown
|
* PURPOSE: Unknown
|
||||||
* PROGRAMER: Unknown
|
* PROGRAMER: Unknown
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* 25/11/05: Created
|
* 25/11/05: Created
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <precomp.h>
|
#include <precomp.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#define sT "S"
|
#define sT "S"
|
||||||
#else
|
#else
|
||||||
#define sT "s"
|
#define sT "s"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MK_STR(s) #s
|
#define MK_STR(s) #s
|
||||||
|
@ -27,104 +27,102 @@ unsigned split_oflags(unsigned oflags); //FIXME: Remove
|
||||||
*/
|
*/
|
||||||
FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */
|
FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */
|
||||||
{
|
{
|
||||||
_TCHAR *szCmdLine=NULL;
|
_TCHAR *szCmdLine=NULL;
|
||||||
_TCHAR *szComSpec=NULL;
|
_TCHAR *szComSpec=NULL;
|
||||||
_TCHAR *s;
|
_TCHAR *s;
|
||||||
FILE *pf;
|
FILE *pf;
|
||||||
HANDLE hReadPipe, hWritePipe;
|
HANDLE hReadPipe, hWritePipe;
|
||||||
BOOL result;
|
BOOL result;
|
||||||
STARTUPINFO StartupInfo;
|
STARTUPINFO StartupInfo;
|
||||||
PROCESS_INFORMATION ProcessInformation;
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
|
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
|
||||||
|
|
||||||
TRACE(MK_STR(_tpopen)"('%"sT"', '%"sT"')\n", cm, md);
|
TRACE(MK_STR(_tpopen)"('%"sT"', '%"sT"')\n", cm, md);
|
||||||
|
|
||||||
if (cm == NULL)
|
if (cm == NULL)
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
szComSpec = _tgetenv(_T("COMSPEC"));
|
szComSpec = _tgetenv(_T("COMSPEC"));
|
||||||
if (szComSpec == NULL)
|
if (szComSpec == NULL)
|
||||||
{
|
{
|
||||||
szComSpec = _T("cmd.exe");
|
szComSpec = _T("cmd.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
s = max(_tcsrchr(szComSpec, '\\'), _tcsrchr(szComSpec, '/'));
|
s = max(_tcsrchr(szComSpec, '\\'), _tcsrchr(szComSpec, '/'));
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
s = szComSpec;
|
s = szComSpec;
|
||||||
else
|
else
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
szCmdLine = malloc((_tcslen(s) + 4 + _tcslen(cm) + 1) * sizeof(_TCHAR));
|
szCmdLine = malloc((_tcslen(s) + 4 + _tcslen(cm) + 1) * sizeof(_TCHAR));
|
||||||
if (szCmdLine == NULL)
|
if (szCmdLine == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tcscpy(szCmdLine, s);
|
_tcscpy(szCmdLine, s);
|
||||||
s = _tcsrchr(szCmdLine, '.');
|
s = _tcsrchr(szCmdLine, '.');
|
||||||
if (s)
|
if (s)
|
||||||
*s = 0;
|
*s = 0;
|
||||||
_tcscat(szCmdLine, _T(" /C "));
|
_tcscat(szCmdLine, _T(" /C "));
|
||||||
_tcscat(szCmdLine, cm);
|
_tcscat(szCmdLine, cm);
|
||||||
|
|
||||||
if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024))
|
if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024))
|
||||||
{
|
{
|
||||||
|
free (szCmdLine);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&StartupInfo, 0, sizeof(STARTUPINFO));
|
||||||
|
StartupInfo.cb = sizeof(STARTUPINFO);
|
||||||
|
|
||||||
|
if (*md == 'r' ) {
|
||||||
|
StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
StartupInfo.hStdOutput = hWritePipe;
|
||||||
|
StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
|
}
|
||||||
|
else if ( *md == 'w' ) {
|
||||||
|
StartupInfo.hStdInput = hReadPipe;
|
||||||
|
StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StartupInfo.dwFlags & STARTF_USESTDHANDLES)
|
||||||
|
StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
|
||||||
|
result = CreateProcess(szComSpec,
|
||||||
|
szCmdLine,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
TRUE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&StartupInfo,
|
||||||
|
&ProcessInformation);
|
||||||
free (szCmdLine);
|
free (szCmdLine);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&StartupInfo, 0, sizeof(STARTUPINFO));
|
if (result == FALSE)
|
||||||
StartupInfo.cb = sizeof(STARTUPINFO);
|
|
||||||
|
|
||||||
if (*md == 'r' ) {
|
|
||||||
StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
|
||||||
StartupInfo.hStdOutput = hWritePipe;
|
|
||||||
StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
|
||||||
}
|
|
||||||
else if ( *md == 'w' ) {
|
|
||||||
StartupInfo.hStdInput = hReadPipe;
|
|
||||||
StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StartupInfo.dwFlags & STARTF_USESTDHANDLES)
|
|
||||||
StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
|
||||||
|
|
||||||
result = CreateProcess(szComSpec,
|
|
||||||
szCmdLine,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&StartupInfo,
|
|
||||||
&ProcessInformation);
|
|
||||||
free (szCmdLine);
|
|
||||||
|
|
||||||
if (result == FALSE)
|
|
||||||
{
|
|
||||||
CloseHandle(hReadPipe);
|
|
||||||
CloseHandle(hWritePipe);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(ProcessInformation.hThread);
|
|
||||||
|
|
||||||
if ( *md == 'r' )
|
|
||||||
{
|
{
|
||||||
pf = _tfdopen(alloc_fd(hReadPipe, split_oflags(_fmode)) , _T("r"));
|
CloseHandle(hReadPipe);
|
||||||
CloseHandle(hWritePipe);
|
CloseHandle(hWritePipe);
|
||||||
}
|
return NULL;
|
||||||
else
|
|
||||||
{
|
|
||||||
pf = _tfdopen( alloc_fd(hWritePipe, split_oflags(_fmode)) , _T("w"));
|
|
||||||
CloseHandle(hReadPipe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//pf->_tmpfname = ProcessInformation.hProcess;
|
CloseHandle(ProcessInformation.hThread);
|
||||||
|
|
||||||
return( pf );
|
if ( *md == 'r' )
|
||||||
|
{
|
||||||
|
pf = _tfdopen(alloc_fd(hReadPipe, split_oflags(_fmode)) , _T("r"));
|
||||||
|
CloseHandle(hWritePipe);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pf = _tfdopen( alloc_fd(hWritePipe, split_oflags(_fmode)) , _T("w"));
|
||||||
|
CloseHandle(hReadPipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
return( pf );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _UNICODE
|
#ifndef _UNICODE
|
||||||
|
@ -134,12 +132,12 @@ FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */
|
||||||
*/
|
*/
|
||||||
int _pclose (FILE *pp)
|
int _pclose (FILE *pp)
|
||||||
{
|
{
|
||||||
TRACE("_pclose(%x)",pp);
|
TRACE("_pclose(%x)",pp);
|
||||||
|
|
||||||
fclose(pp);
|
fclose(pp);
|
||||||
//if (!TerminateProcess(pp->_tmpfname ,0))
|
//if (!TerminateProcess(pp->_tmpfname ,0))
|
||||||
// return( -1 );
|
// return( -1 );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue