--- trunk/reactos/subsys/system/cmd/cmd.c 2005-09-19 21:11:41 UTC (rev 17936)
+++ trunk/reactos/subsys/system/cmd/cmd.c 2005-09-19 22:00:01 UTC (rev 17937)
@@ -137,7 +137,7 @@
*
* 06-jul-2005 (Magnus Olsen <magnus@greatlord.com>)
* translate '%errorlevel%' to the internal value.
- * Add proper memmory alloc ProcessInput, the error
+ * Add proper memmory alloc ProcessInput, the error
* handling for memmory handling need to be improve
*/
@@ -199,8 +199,9 @@
return TRUE;
}
- Status = NtQueryInformationProcessPtr(Process, ProcessBasicInformation,
- &Info, sizeof(PROCESS_BASIC_INFORMATION), NULL);
+ Status = NtQueryInformationProcessPtr (
+ Process, ProcessBasicInformation,
+ &Info, sizeof(PROCESS_BASIC_INFORMATION), NULL);
if (! NT_SUCCESS(Status))
{
#ifdef _DEBUG
@@ -208,8 +209,9 @@
#endif
return TRUE;
}
- Status = NtReadVirtualMemoryPtr(Process, Info.PebBaseAddress, &ProcessPeb,
- sizeof(PEB), &BytesRead);
+ Status = NtReadVirtualMemoryPtr (
+ Process, Info.PebBaseAddress, &ProcessPeb,
+ sizeof(PEB), &BytesRead);
if (! NT_SUCCESS(Status) || sizeof(PEB) != BytesRead)
{
#ifdef _DEBUG
@@ -230,24 +232,24 @@
#endif
typedef HINSTANCE (WINAPI *MYEX)(
- HWND hwnd,
- LPCTSTR lpOperation,
- LPCTSTR lpFile,
- LPCTSTR lpParameters,
- LPCTSTR lpDirectory,
- INT nShowCmd
+ HWND hwnd,
+ LPCTSTR lpOperation,
+ LPCTSTR lpFile,
+ LPCTSTR lpParameters,
+ LPCTSTR lpDirectory,
+ INT nShowCmd
);
static BOOL RunFile(LPTSTR filename)
{
- HMODULE hShell32;
- MYEX hShExt;
- HINSTANCE ret;
+ HMODULE hShell32;
+ MYEX hShExt;
+ HINSTANCE ret;
#ifdef _DEBUG
- DebugPrintf (_T("RunFile(%s)\n"), filename);
+ DebugPrintf (_T("RunFile(%s)\n"), filename);
#endif
hShell32 = LoadLibrary(_T("SHELL32.DLL"));
if (!hShell32)
@@ -297,9 +299,9 @@
{
TCHAR *szFullName=NULL;
TCHAR *first = NULL;
- TCHAR *rest = NULL;
- TCHAR *full = NULL;
- TCHAR *dot = NULL;
+ TCHAR *rest = NULL;
+ TCHAR *full = NULL;
+ TCHAR *dot = NULL;
TCHAR szWindowTitle[MAX_PATH];
DWORD dwExitCode = 0;
@@ -307,56 +309,56 @@
DebugPrintf (_T("Execute: \'%s\' \'%s\'\n"), first, rest);
#endif
- /* we need biger buffer that First, Rest, Full are already
- need rewrite some code to use realloc when it need instead
+ /* we need biger buffer that First, Rest, Full are already
+ need rewrite some code to use realloc when it need instead
of add 512bytes extra */
- first = malloc ( (_tcslen(First) + 512) * sizeof(TCHAR));
+ first = malloc ( (_tcslen(First) + 512) * sizeof(TCHAR));
if (first == NULL)
{
- error_out_of_memory();
- return ;
+ error_out_of_memory();
+ return ;
}
- rest = malloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR));
+ rest = malloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR));
if (rest == NULL)
{
- free (first);
- error_out_of_memory();
- return ;
+ free (first);
+ error_out_of_memory();
+ return ;
}
- full = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
+ full = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
if (full == NULL)
{
- free (first);
- free (rest);
- error_out_of_memory();
- return ;
+ free (first);
+ free (rest);
+ error_out_of_memory();
+ return ;
}
szFullName = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
if (full == NULL)
{
- free (first);
- free (rest);
- free (full);
- error_out_of_memory();
- return ;
+ free (first);
+ free (rest);
+ free (full);
+ error_out_of_memory();
+ return ;
}
/* Though it was already parsed once, we have a different set of rules
for parsing before we pass to CreateProccess */
if(!_tcschr(Full,_T('\"')))
- {
+ {
_tcscpy(first,First);
_tcscpy(rest,Rest);
_tcscpy(full,Full);
}
else
{
- UINT i = 0;
+ UINT i = 0;
BOOL bInside = FALSE;
rest[0] = _T('\0');
full[0] = _T('\0');
@@ -409,8 +411,8 @@
if (!working) ConErrResPuts (STRING_FREE_ERROR1);
free (first);
- free (rest);
- free (full);
+ free (rest);
+ free (full);
free (szFullName);
return;
@@ -435,7 +437,7 @@
GetConsoleTitle (szWindowTitle, MAX_PATH);
/* check if this is a .BAT or .CMD file */
- dot = _tcsrchr (szFullName, _T('.'));
+ dot = _tcsrchr (szFullName, _T('.'));
if (dot && (!_tcsicmp (dot, _T(".bat")) || !_tcsicmp (dot, _T(".cmd"))))
{
#ifdef _DEBUG
@@ -507,19 +509,20 @@
}
}
// restore console mode
- SetConsoleMode( GetStdHandle( STD_INPUT_HANDLE ),
- ENABLE_PROCESSED_INPUT );
+ SetConsoleMode (
+ GetStdHandle( STD_INPUT_HANDLE ),
+ ENABLE_PROCESSED_INPUT );
}
/* Get code page if it has been change */
InputCodePage= GetConsoleCP();
- OutputCodePage = GetConsoleOutputCP();
- SetConsoleTitle (szWindowTitle);
+ OutputCodePage = GetConsoleOutputCP();
+ SetConsoleTitle (szWindowTitle);
- free(first);
- free(rest);
- free(full);
- free (szFullName);
+ free(first);
+ free(rest);
+ free(full);
+ free (szFullName);
}
@@ -549,11 +552,11 @@
com = malloc( (_tcslen(line) +512)*sizeof(TCHAR) );
if (com == NULL)
{
- error_out_of_memory();
- return;
+ error_out_of_memory();
+ return;
}
- cp = com;
+ cp = com;
/* Skip over initial white space */
while (_istspace (*line))
line++;
@@ -589,9 +592,9 @@
/*
if(_tcslen(com) > MAX_PATH)
{
- error_bad_command();
- free(com);
- return;
+ error_bad_command();
+ free(com);
+ return;
}
*/
@@ -641,7 +644,7 @@
}
}
}
- free(com);
+ free(com);
}
@@ -732,8 +735,8 @@
nRedirFlags |= ERROR_APPEND;
_tcscpy(err, bc->Err);
}
-
+
/* Set up the initial conditions ... */
/* preserve STDIN, STDOUT and STDERR handles */
hOldConIn = GetStdHandle (STD_INPUT_HANDLE);
@@ -746,10 +749,10 @@
HANDLE hFile;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
- /* we need make sure the LastError msg is zero before calling CreateFile */
- SetLastError(0);
+ /* we need make sure the LastError msg is zero before calling CreateFile */
+ SetLastError(0);
- /* Set up pipe for the standard input handler */
+ /* Set up pipe for the standard input handler */
hFile = CreateFile (in, GENERIC_READ, FILE_SHARE_READ, &sa, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
@@ -760,7 +763,7 @@
}
if (!SetStdHandle (STD_INPUT_HANDLE, hFile))
- {
+ {
LoadString(CMD_ModuleHandle, STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE);
ConErrPrintf(szMsg, in);
return;
@@ -777,19 +780,19 @@
while (num-- > 1)
{
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
-
- /* Create unique temporary file name */
+
+ /* Create unique temporary file name */
GetTempFileName (szTempPath, _T("CMD"), 0, szFileName[1]);
- /* we need make sure the LastError msg is zero before calling CreateFile */
- SetLastError(0);
+ /* we need make sure the LastError msg is zero before calling CreateFile */
+ SetLastError(0);
/* Set current stdout to temporary file */
hFile[1] = CreateFile (szFileName[1], GENERIC_WRITE, 0, &sa,
TRUNCATE_EXISTING, FILE_ATTRIBUTE_TEMPORARY, NULL);
-
- if (hFile[1] == INVALID_HANDLE_VALUE)
- {
+
+ if (hFile[1] == INVALID_HANDLE_VALUE)
+ {
LoadString(CMD_ModuleHandle, STRING_CMD_ERROR2, szMsg, RC_STRING_MAX_SIZE);
ConErrPrintf(szMsg);
return;
@@ -822,8 +825,8 @@
_tcscpy (szFileName[0], szFileName[1]);
*szFileName[1] = _T('\0');
- /* we need make sure the LastError msg is zero before calling CreateFile */
- SetLastError(0);
+ /* we need make sure the LastError msg is zero before calling CreateFile */
+ SetLastError(0);
/* open new stdin file */
hFile[0] = CreateFile (szFileName[0], GENERIC_READ, 0, &sa,
@@ -840,37 +843,37 @@
/* Final output to here */
HANDLE hFile;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
-
- /* we need make sure the LastError msg is zero before calling CreateFile */
- SetLastError(0);
- hFile = CreateFile (out, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, &sa,
+ /* we need make sure the LastError msg is zero before calling CreateFile */
+ SetLastError(0);
+
+ hFile = CreateFile (out, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, &sa,
(nRedirFlags & OUTPUT_APPEND) ? OPEN_ALWAYS : CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL);
-
- if (hFile == INVALID_HANDLE_VALUE)
+
+ if (hFile == INVALID_HANDLE_VALUE)
{
- INT size = _tcslen(out)-1;
-
- if (out[size] != _T(':'))
- {
- LoadString(CMD_ModuleHandle, STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE);
- ConErrPrintf(szMsg, out);
- return;
- }
-
- out[size]=_T('\0');
- hFile = CreateFile (out, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, &sa,
- (nRedirFlags & OUTPUT_APPEND) ? OPEN_ALWAYS : CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL);
+ INT size = _tcslen(out)-1;
- if (hFile == INVALID_HANDLE_VALUE)
- {
- LoadString(CMD_ModuleHandle, STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE);
- ConErrPrintf(szMsg, out);
- return;
- }
-
+ if (out[size] != _T(':'))
+ {
+ LoadString(CMD_ModuleHandle, STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE);
+ ConErrPrintf(szMsg, out);
+ return;
+ }
+
+ out[size]=_T('\0');
+ hFile = CreateFile (out, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, &sa,
+ (nRedirFlags & OUTPUT_APPEND) ? OPEN_ALWAYS : CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ LoadString(CMD_ModuleHandle, STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE);
+ ConErrPrintf(szMsg, out);
+ return;
+ }
+
}
if (!SetStdHandle (STD_OUTPUT_HANDLE, hFile))
@@ -1074,7 +1077,7 @@
LPTSTR cp;
BOOL bEchoThisLine;
-
+
do
{
/* if no batch input then... */
@@ -1091,7 +1094,7 @@
cp = commandline;
while (*ip)
{
- if (*ip == _T('%'))
+ if (*ip == _T('%'))
{
switch (*++ip)
{
@@ -1128,134 +1131,131 @@
if ((tp != NULL) &&
(tp <= _tcschr(ip, _T(' ')) - 1))
{
- INT size = 512;
+ INT size = 512;
TCHAR *evar;
*tp = _T('\0');
- /* FIXME: Correct error handling when it can not alloc memmory */
-
- /* %CD% */
- if (_tcsicmp(ip,_T("cd")) ==0)
- {
- TCHAR szPath[MAX_PATH];
- GetCurrentDirectory (MAX_PATH, szPath);
- cp = _stpcpy (cp, szPath);
- }
- /* %TIME% */
- else if (_tcsicmp(ip,_T("time")) ==0)
- {
- TCHAR szTime[40];
- SYSTEMTIME t;
- GetSystemTime(&t);
+ /* FIXME: Correct error handling when it can not alloc memmory */
- _sntprintf(szTime ,40,_T("%02d%c%02d%c%02d%c%02d"), t.wHour, cTimeSeparator,t.wMinute , cTimeSeparator,t.wSecond , cDecimalSeparator, t.wMilliseconds );
- cp = _stpcpy (cp, szTime);
- }
-
- /* %DATE% */
- else if (_tcsicmp(ip,_T("date")) ==0)
- {
- TCHAR szDate[40];
+ /* %CD% */
+ if (_tcsicmp(ip,_T("cd")) ==0)
+ {
+ TCHAR szPath[MAX_PATH];
+ GetCurrentDirectory (MAX_PATH, szPath);
+ cp = _stpcpy (cp, szPath);
+ }
+ /* %TIME% */
+ else if (_tcsicmp(ip,_T("time")) ==0)
+ {
+ TCHAR szTime[40];
+ SYSTEMTIME t;
+ GetSystemTime(&t);
+
+ _sntprintf(szTime ,40,_T("%02d%c%02d%c%02d%c%02d"), t.wHour, cTimeSeparator,t.wMinute , cTimeSeparator,t.wSecond , cDecimalSeparator, t.wMilliseconds );
+ cp = _stpcpy (cp, szTime);
+ }
- GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("ddd"), szDate, sizeof (szDate));
- cp = _stpcpy (cp, szDate);
- cp = _stpcpy (cp, _T(" "));
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szDate, sizeof (szDate));
- cp = _stpcpy (cp, szDate);
- }
+ /* %DATE% */
+ else if (_tcsicmp(ip,_T("date")) ==0)
+ {
+ TCHAR szDate[40];
- /* %RANDOM% */
- else if (_tcsicmp(ip,_T("random")) ==0)
- {
- TCHAR szRand[40];
- /* Get random number */
- _itot(rand(),szRand,10);
- cp = _stpcpy (cp, szRand);
- }
-
- /* %CMDCMDLINE% */
- else if (_tcsicmp(ip,_T("cmdcmdline")) ==0)
- {
- TCHAR *pargv;
- /* Get random number */
- pargv = GetCommandLine();
- cp = _stpcpy (cp, pargv);
- }
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("ddd"), szDate, sizeof (szDate));
+ cp = _stpcpy (cp, szDate);
+ cp = _stpcpy (cp, _T(" "));
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szDate, sizeof (szDate));
+ cp = _stpcpy (cp, szDate);
+ }
- /* %CMDEXTVERSION% */
- else if (_tcsicmp(ip,_T("cmdextversion")) ==0)
- {
- TCHAR szVER[40];
- /* Set version number to 2 */
- _itot(2,szVER,10);
- cp = _stpcpy (cp, szVER);
- }
-
- /* %ERRORLEVEL% */
- else if (_tcsicmp(ip,_T("errorlevel")) ==0)
- {
- evar = malloc ( size * sizeof(TCHAR));
- if (evar==NULL)
- return 1;
+ /* %RANDOM% */
+ else if (_tcsicmp(ip,_T("random")) ==0)
+ {
+ TCHAR szRand[40];
+ /* Get random number */
+ _itot(rand(),szRand,10);
+ cp = _stpcpy (cp, szRand);
+ }
- memset(evar,0,512 * sizeof(TCHAR));
- _itot(nErrorLevel,evar,10);
- cp = _stpcpy (cp, evar);
+ /* %CMDCMDLINE% */
+ else if (_tcsicmp(ip,_T("cmdcmdline")) ==0)
+ {
+ TCHAR *pargv;
+ /* Get random number */
+ pargv = GetCommandLine();
+ cp = _stpcpy (cp, pargv);
+ }
- free(evar);
- }
- else
- {
- evar = malloc ( 512 * sizeof(TCHAR));
- if (evar==NULL)
- return 1;
- SetLastError(0);
- size = GetEnvironmentVariable (ip, evar, 512);
- if(GetLastError() == ERROR_ENVVAR_NOT_FOUND)
- {
- /* if no env var is found you must
- continue with what was input*/
- cp = _stpcpy (cp, _T("%"));
- cp = _stpcpy (cp, ip);
- cp = _stpcpy (cp, _T("%"));
- }
- else
- {
- if (size > 512)
- {
- evar = realloc(evar,size * sizeof(TCHAR) );
- if (evar==NULL)
- {
- return 1;
- }
- size = GetEnvironmentVariable (ip, evar, size);
- }
+ /* %CMDEXTVERSION% */
+ else if (_tcsicmp(ip,_T("cmdextversion")) ==0)
+ {
+ TCHAR szVER[40];
+ /* Set version number to 2 */
+ _itot(2,szVER,10);
+ cp = _stpcpy (cp, szVER);
+ }
- if (size)
- {
- cp = _stpcpy (cp, evar);
- }
- }
+ /* %ERRORLEVEL% */
+ else if (_tcsicmp(ip,_T("errorlevel")) ==0)
+ {
+ evar = malloc ( size * sizeof(TCHAR));
+ if (evar==NULL)
+ return 1;
- free(evar);
- }
-
+ memset(evar,0,512 * sizeof(TCHAR));
+ _itot(nErrorLevel,evar,10);
+ cp = _stpcpy (cp, evar);
+
+ free(evar);
+ }
+ else
+ {
+ evar = malloc ( 512 * sizeof(TCHAR));
+ if (evar==NULL)
+ return 1;
+ SetLastError(0);
+ size = GetEnvironmentVariable (ip, evar, 512);
+ if(GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+ {
+ /* if no env var is found you must
+ continue with what was input*/
+ cp = _stpcpy (cp, _T("%"));
+ cp = _stpcpy (cp, ip);
+ cp = _stpcpy (cp, _T("%"));
+ }
+ else
+ {
+ if (size > 512)
+ {
+ evar = realloc(evar,size * sizeof(TCHAR) );
+ if (evar==NULL)
+ {
+ return 1;
+ }
+ size = GetEnvironmentVariable (ip, evar, size);
+ }
+
+ if (size)
+ {
+ cp = _stpcpy (cp, evar);
+ }
+ }
+
+ free(evar);
+ }
+
ip = tp + 1;
}
else
{
*cp++ = _T('%');
- }
-
+ }
+
break;
}
continue;
}
-
-
-
if (_istcntrl (*ip))
*ip = _T(' ');
*cp++ = *ip++;
@@ -1264,10 +1264,10 @@
*cp = _T('\0');
/* strip trailing spaces */
- while ((--cp >= commandline) && _istspace (*cp));
+ while ((--cp >= commandline) && _istspace (*cp));
*(cp + 1) = _T('\0');
-
+
/* JPP 19980807 */
/* Echo batch file line */
if (bEchoThisLine)
@@ -1379,7 +1379,7 @@
//INT len;
//TCHAR *ptr, *cmdLine;
-
+
/* get version information */
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx (&osvi);
@@ -1421,11 +1421,11 @@
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
hIn = GetStdHandle (STD_INPUT_HANDLE);
- /* Set EnvironmentVariable PROMPT if it does not exists any env value.
- for you can change the EnvirommentVariable for prompt before cmd start
+ /* Set EnvironmentVariable PROMPT if it does not exists any env value.
+ for you can change the EnvirommentVariable for prompt before cmd start
this patch are not 100% right, if it does not exists a PROMPT value cmd should use
$P$G as defualt not set EnvirommentVariable PROMPT to $P$G if it does not exists */
- if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, 2 * sizeof(TCHAR)) == 0)
+ if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, 2 * sizeof(TCHAR)) == 0)
SetEnvironmentVariable (_T("PROMPT"), _T("$P$G"));
@@ -1636,45 +1636,45 @@
#ifdef _UNICODE
PWCHAR * _CommandLineToArgvW(PWCHAR lpCmdLine, int *pNumArgs)
{
- PWCHAR * argvw = NULL;
- PWCHAR ptr = lpCmdLine;
- PWCHAR str;
- int len;
- int NumArgs;
+ PWCHAR * argvw = NULL;
+ PWCHAR ptr = lpCmdLine;
+ PWCHAR str;
+ int len;
+ int NumArgs;
- NumArgs = 0;
+ NumArgs = 0;
- while(lpCmdLine && *lpCmdLine)
- {
- while (iswspace(*lpCmdLine)) lpCmdLine++;
- if (*lpCmdLine)
- {
- if ((NumArgs % 10)==0)
- {
- PWCHAR * old_argvw = argvw;
- argvw = malloc((NumArgs + 10) * sizeof(PWCHAR));
- memcpy(argvw, old_argvw, NumArgs * sizeof(PWCHAR));
- free(old_argvw);
- }
- ptr = wcschr(lpCmdLine, L' ');
- if (ptr)
- {
- len = ptr - lpCmdLine;
- }
- else
- {
- len = wcslen(lpCmdLine);
- }
- str = malloc((len + 1) * sizeof(WCHAR));
- memcpy(str, lpCmdLine, len * sizeof(WCHAR));
- str[len] = 0;
- argvw[NumArgs]=str;
- NumArgs++;
- lpCmdLine = ptr;
- }
- }
- *pNumArgs = NumArgs;
- return argvw;
+ while(lpCmdLine && *lpCmdLine)
+ {
+ while (iswspace(*lpCmdLine)) lpCmdLine++;
+ if (*lpCmdLine)
+ {
+ if ((NumArgs % 10)==0)
+ {
+ PWCHAR * old_argvw = argvw;
+ argvw = malloc((NumArgs + 10) * sizeof(PWCHAR));
+ memcpy(argvw, old_argvw, NumArgs * sizeof(PWCHAR));
+ free(old_argvw);
+ }
+ ptr = wcschr(lpCmdLine, L' ');
+ if (ptr)
+ {
+ len = ptr - lpCmdLine;
+ }
+ else
+ {
+ len = wcslen(lpCmdLine);
+ }
+ str = malloc((len + 1) * sizeof(WCHAR));
+ memcpy(str, lpCmdLine, len * sizeof(WCHAR));
+ str[len] = 0;
+ argvw[NumArgs]=str;
+ NumArgs++;
+ lpCmdLine = ptr;
+ }
+ }
+ *pNumArgs = NumArgs;
+ return argvw;
}
#endif
#endif
@@ -1688,53 +1688,51 @@
int _main (int argc, char *argv[])
#endif
{
- TCHAR startPath[MAX_PATH];
- CONSOLE_SCREEN_BUFFER_INFO Info;
- INT nExitCode;
+ TCHAR startPath[MAX_PATH];
+ CONSOLE_SCREEN_BUFFER_INFO Info;
+ INT nExitCode;
#ifdef _UNICODE
- PWCHAR * argv;
- int argc=0;
+ PWCHAR * argv;
+ int argc=0;
#ifdef __REACTOS__
- argv = _CommandLineToArgvW(GetCommandLineW(), &argc);
+ argv = _CommandLineToArgvW(GetCommandLineW(), &argc);
#else
- argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+ argv = CommandLineToArgvW(GetCommandLineW(), &argc);
#endif
#endif
-
- GetCurrentDirectory(MAX_PATH,startPath);
- _tchdir(startPath);
- SetFileApisToOEM();
- InputCodePage= 0;
- OutputCodePage = 0;
+ GetCurrentDirectory(MAX_PATH,startPath);
+ _tchdir(startPath);
- hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, 0, NULL);
- if (GetConsoleScreenBufferInfo(hConsole, &Info) == FALSE)
- {
- ConErrFormatMessage(GetLastError());
- return(1);
- }
- wColor = Info.wAttributes;
- wDefColor = wColor;
+ SetFileApisToOEM();
+ InputCodePage= 0;
+ OutputCodePage = 0;
- InputCodePage= GetConsoleCP();
- OutputCodePage = GetConsoleOutputCP();
- CMD_ModuleHandle = GetModuleHandle(NULL);
-
- /* check switches on command-line */
- Initialize(argc, argv);
+ hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, 0, NULL);
+ if (GetConsoleScreenBufferInfo(hConsole, &Info) == FALSE)
+ {
+ ConErrFormatMessage(GetLastError());
+ return(1);
+ }
+ wColor = Info.wAttributes;
+ wDefColor = wColor;
- /* call prompt routine */
- nExitCode = ProcessInput(FALSE);
+ InputCodePage= GetConsoleCP();
+ OutputCodePage = GetConsoleOutputCP();
+ CMD_ModuleHandle = GetModuleHandle(NULL);
-
- /* do the cleanup */
- Cleanup(argc, argv);
+ /* check switches on command-line */
+ Initialize(argc, argv);
-
- return(nExitCode);
+ /* call prompt routine */
+ nExitCode = ProcessInput(FALSE);
+
+ /* do the cleanup */
+ Cleanup(argc, argv);
+
+ return(nExitCode);
}
/* EOF */