{
TCHAR szFullName[MAX_PATH];
TCHAR *first, *rest, *dot;
- TCHAR szWindowTitle[MAX_PATH], szNewTitle[MAX_PATH*2];
+ TCHAR szWindowTitle[MAX_PATH];
+ TCHAR szNewTitle[MAX_PATH*2];
DWORD dwExitCode = 0;
TCHAR *FirstEnd;
- TCHAR szFullCmdLine [CMDLINE_LENGTH];
+ TCHAR szFullCmdLine[CMDLINE_LENGTH];
TRACE ("Execute: \'%s\' \'%s\'\n", debugstr_aw(First), debugstr_aw(Rest));
}
-#ifdef INCLUDE_CMD_COLOR
-
-BOOL ConGetDefaultAttributes(PWORD pwDefAttr)
-{
- BOOL Success;
- HANDLE hConsole;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- /* Do not modify *pwDefAttr if we fail, in which case use default attributes */
-
- hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, 0, NULL);
- if (hConsole == INVALID_HANDLE_VALUE)
- return FALSE; // No default console
-
- Success = GetConsoleScreenBufferInfo(hConsole, &csbi);
- if (Success)
- *pwDefAttr = csbi.wAttributes;
-
- CloseHandle(hConsole);
- return Success;
-}
-
-#endif
-
-
/*
* Set up global initializations and process parameters
*/
if (IsExistingFile(_T("cmdexit.bat")))
{
ConErrResPuts(STRING_CMD_ERROR5);
-
ParseCommandLine(_T("cmdexit.bat"));
}
else if (IsExistingFile(_T("\\cmdexit.bat")))
#include <config.h>
-#include <winnls.h>
-#include <winreg.h>
-#include <winuser.h>
-#include <wincon.h>
-#include <tchar.h>
-
#include "cmdver.h"
#include "cmddbg.h"
#define D_ON _T("on")
#define D_OFF _T("off")
-
/* command line buffer length */
#define CMDLINE_LENGTH 8192
#define BUFF_SIZE 16384
/* Global variables */
-extern HANDLE hIn;
extern LPTSTR lpOriginalEnvironment;
extern WORD wColor;
extern WORD wDefColor;
extern BOOL bEnableExtensions;
extern BOOL bDelayedExpansion;
extern INT nErrorLevel;
-extern SHORT maxx;
-extern SHORT maxy;
extern BOOL bUnicodeOutput;
+#ifdef INCLUDE_CMD_COLOR
+
+BOOL ConGetDefaultAttributes(PWORD pwDefAttr)
+{
+ BOOL Success;
+ HANDLE hConsole;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ /* Do not modify *pwDefAttr if we fail, in which case use default attributes */
+
+ hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, 0, NULL);
+ if (hConsole == INVALID_HANDLE_VALUE)
+ return FALSE; // No default console
+
+ Success = GetConsoleScreenBufferInfo(hConsole, &csbi);
+ if (Success)
+ *pwDefAttr = csbi.wAttributes;
+
+ CloseHandle(hConsole);
+ return Success;
+}
+
+#endif
+
+
BOOL ConSetTitle(IN LPCTSTR lpConsoleTitle)
{
/* Now really set the console title */
VOID SetCursorType (BOOL, BOOL);
+#ifdef INCLUDE_CMD_COLOR
+BOOL ConGetDefaultAttributes(PWORD pwDefAttr);
+#endif
+
+
BOOL ConSetTitle(IN LPCTSTR lpConsoleTitle);
#ifdef INCLUDE_CMD_BEEP
/* Calculate size */
if (ptrFiles[i]->stFindInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
- /* Directory, no size it's a directory*/
+ /* Directory, no size it's a directory */
iSizeFormat = -17;
_tcscpy(szSize, _T("<DIR>"));
}
#define _CRT_SECURE_NO_DEPRECATE
#endif /*_MSC_VER */
+#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <malloc.h>
+#include <tchar.h>
#define WIN32_NO_STATUS
-#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
+#include <winnls.h>
+#include <winreg.h>
+#include <winuser.h>
+#include <wincon.h>
#include <shellapi.h>
-#include <stdio.h>
#define NTOS_MODE_USER
#include <ndk/rtlfuncs.h>
#ifdef INCLUDE_CMD_SCREEN
-
-INT CommandScreen (LPTSTR param)
+INT CommandScreen(LPTSTR param)
{
- SHORT x,y;
+ SHORT x, y;
+ SHORT maxx, maxy;
BOOL bSkipText = FALSE;
- if (_tcsncmp (param, _T("/?"), 2) == 0)
+ if (_tcsncmp(param, _T("/?"), 2) == 0)
{
ConOutResPaging(TRUE,STRING_SCREEN_HELP);
return 0;
nErrorLevel = 0;
- //get row
- while(_istspace(*param))
+ /* Retrieve the screen dimensions */
+ GetScreenSize(&maxx, &maxy);
+
+ /* Get row */
+ while (_istspace(*param))
param++;
- if (!(*param))
+ if (!*param)
{
- error_req_param_missing ();
+ error_req_param_missing();
return 1;
}
y = _ttoi(param);
- if (y<0 || y>(maxy-1))
+ if (y < 0 || y > (maxy-1))
{
ConOutResPuts(STRING_SCREEN_ROW);
-
return 1;
}
- //get col
- if (!(param = _tcschr(param,_T(' '))))
+ /* Get column */
+ if (!(param = _tcschr(param, _T(' '))))
{
- error_req_param_missing ();
+ error_req_param_missing();
return 1;
}
- while(_istspace(*param))
+ while (_istspace(*param))
param++;
- if (!(*param))
+ if (!*param)
{
- error_req_param_missing ();
+ error_req_param_missing();
return 1;
}
x = _ttoi(param);
- if (x<0 || x>(maxx-1))
+ if (x < 0 || x > (maxx-1))
{
ConErrResPuts(STRING_SCREEN_COL);
return 1;
}
- //get text
- if (!(param = _tcschr(param,_T(' '))))
+ /* Get text */
+ if (!(param = _tcschr(param, _T(' '))))
{
bSkipText = TRUE;
}
else
{
- while(_istspace(*param))
+ while (_istspace(*param))
param++;
- if (!(*param))
- {
+ if (!*param)
bSkipText = TRUE;
- }
}
bIgnoreEcho = TRUE;
if (bSkipText)
- x=0;
-
+ x = 0;
- SetCursorXY(x,y);
+ SetCursorXY(x, y);
- if (!(bSkipText))
+ if (!bSkipText)
ConOutPuts(param);
return 0;
BOOL bWait = FALSE;
BOOL bBat = FALSE;
BOOL bCreate = FALSE;
- TCHAR szFullCmdLine [CMDLINE_LENGTH];
+ TCHAR szFullCmdLine[CMDLINE_LENGTH];
PROCESS_INFORMATION prci;
STARTUPINFO stui;
#ifdef UNICODE
nErrorLevel = (INT)dwExitCode;
}
CloseHandle (prci.hProcess);
+
/* Get New code page if it has change */
InputCodePage= GetConsoleCP();
OutputCodePage = GetConsoleOutputCP();