mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[CMD]: Small refactoring:
- Moving ConGetDefaultAttributes() in console.h; - Moving some SDK inclusions into precomp.h; - Removing extern HANDLE hIn; and localize the SHORT maxx/y variables; - Comment fix; - Whitespace fixes for screen.c. svn path=/trunk/; revision=76009
This commit is contained in:
parent
d7bbf5ad8a
commit
11f7d225c8
8 changed files with 71 additions and 71 deletions
|
@ -311,10 +311,11 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
|
|||
{
|
||||
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));
|
||||
|
||||
|
@ -1762,33 +1763,6 @@ GetCmdLineCommand(TCHAR *commandline, TCHAR *ptr, BOOL AlwaysStrip)
|
|||
}
|
||||
|
||||
|
||||
#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
|
||||
*/
|
||||
|
@ -1997,7 +1971,6 @@ static VOID Cleanup(VOID)
|
|||
if (IsExistingFile(_T("cmdexit.bat")))
|
||||
{
|
||||
ConErrResPuts(STRING_CMD_ERROR5);
|
||||
|
||||
ParseCommandLine(_T("cmdexit.bat"));
|
||||
}
|
||||
else if (IsExistingFile(_T("\\cmdexit.bat")))
|
||||
|
|
|
@ -25,12 +25,6 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <winnls.h>
|
||||
#include <winreg.h>
|
||||
#include <winuser.h>
|
||||
#include <wincon.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "cmdver.h"
|
||||
#include "cmddbg.h"
|
||||
|
||||
|
@ -43,7 +37,6 @@
|
|||
#define D_ON _T("on")
|
||||
#define D_OFF _T("off")
|
||||
|
||||
|
||||
/* command line buffer length */
|
||||
#define CMDLINE_LENGTH 8192
|
||||
|
||||
|
@ -51,7 +44,6 @@
|
|||
#define BUFF_SIZE 16384
|
||||
|
||||
/* Global variables */
|
||||
extern HANDLE hIn;
|
||||
extern LPTSTR lpOriginalEnvironment;
|
||||
extern WORD wColor;
|
||||
extern WORD wDefColor;
|
||||
|
@ -62,8 +54,6 @@ extern BOOL bDisableBatchEcho;
|
|||
extern BOOL bEnableExtensions;
|
||||
extern BOOL bDelayedExpansion;
|
||||
extern INT nErrorLevel;
|
||||
extern SHORT maxx;
|
||||
extern SHORT maxy;
|
||||
extern BOOL bUnicodeOutput;
|
||||
|
||||
|
||||
|
|
|
@ -507,6 +507,33 @@ VOID GetScreenSize(PSHORT maxx, PSHORT maxy)
|
|||
|
||||
|
||||
|
||||
#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 */
|
||||
|
|
|
@ -72,6 +72,11 @@ VOID GetScreenSize (PSHORT, PSHORT);
|
|||
VOID SetCursorType (BOOL, BOOL);
|
||||
|
||||
|
||||
#ifdef INCLUDE_CMD_COLOR
|
||||
BOOL ConGetDefaultAttributes(PWORD pwDefAttr);
|
||||
#endif
|
||||
|
||||
|
||||
BOOL ConSetTitle(IN LPCTSTR lpConsoleTitle);
|
||||
|
||||
#ifdef INCLUDE_CMD_BEEP
|
||||
|
|
|
@ -1052,7 +1052,7 @@ DirPrintOldList(PDIRFINDINFO ptrFiles[], /* [IN] Files' Info */
|
|||
/* 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>"));
|
||||
}
|
||||
|
|
|
@ -7,15 +7,20 @@
|
|||
#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>
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
#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;
|
||||
|
@ -29,72 +29,71 @@ INT CommandScreen (LPTSTR param)
|
|||
|
||||
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;
|
||||
|
|
|
@ -45,7 +45,7 @@ INT cmd_start (LPTSTR Rest)
|
|||
BOOL bWait = FALSE;
|
||||
BOOL bBat = FALSE;
|
||||
BOOL bCreate = FALSE;
|
||||
TCHAR szFullCmdLine [CMDLINE_LENGTH];
|
||||
TCHAR szFullCmdLine[CMDLINE_LENGTH];
|
||||
PROCESS_INFORMATION prci;
|
||||
STARTUPINFO stui;
|
||||
#ifdef UNICODE
|
||||
|
@ -303,6 +303,7 @@ INT cmd_start (LPTSTR Rest)
|
|||
nErrorLevel = (INT)dwExitCode;
|
||||
}
|
||||
CloseHandle (prci.hProcess);
|
||||
|
||||
/* Get New code page if it has change */
|
||||
InputCodePage= GetConsoleCP();
|
||||
OutputCodePage = GetConsoleOutputCP();
|
||||
|
|
Loading…
Reference in a new issue