mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 12:40:33 +00:00
msvc6 compatibility and small performance improvement in filename completion
svn path=/trunk/; revision=17819
This commit is contained in:
parent
811a8addb8
commit
5fbac4d9e6
11 changed files with 52 additions and 53 deletions
|
@ -148,9 +148,9 @@
|
||||||
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
|
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef NTSTATUS (STDCALL *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
|
typedef NTSTATUS (WINAPI *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
|
||||||
PVOID, ULONG, PULONG);
|
PVOID, ULONG, PULONG);
|
||||||
typedef NTSTATUS (STDCALL *NtReadVirtualMemoryProc)(HANDLE, PVOID, PVOID, ULONG, PULONG);
|
typedef NTSTATUS (WINAPI *NtReadVirtualMemoryProc)(HANDLE, PVOID, PVOID, ULONG, PULONG);
|
||||||
|
|
||||||
BOOL bExit = FALSE; /* indicates EXIT was typed */
|
BOOL bExit = FALSE; /* indicates EXIT was typed */
|
||||||
BOOL bCanExit = TRUE; /* indicates if this shell is exitable */
|
BOOL bCanExit = TRUE; /* indicates if this shell is exitable */
|
||||||
|
@ -356,7 +356,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INT i = 0;
|
UINT i = 0;
|
||||||
BOOL bInside = FALSE;
|
BOOL bInside = FALSE;
|
||||||
rest[0] = _T('\0');
|
rest[0] = _T('\0');
|
||||||
full[0] = _T('\0');
|
full[0] = _T('\0');
|
||||||
|
@ -1392,12 +1392,10 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
INT x;
|
|
||||||
|
|
||||||
DebugPrintf (_T("[command args:\n"));
|
DebugPrintf (_T("[command args:\n"));
|
||||||
for (x = 0; x < argc; x++)
|
for (i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
DebugPrintf (_T("%d. %s\n"), x, argv[x]);
|
DebugPrintf (_T("%d. %s\n"), i, argv[i]);
|
||||||
}
|
}
|
||||||
DebugPrintf (_T("]\n"));
|
DebugPrintf (_T("]\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -224,11 +224,11 @@ VOID msg_pause (VOID);
|
||||||
|
|
||||||
/* Prototypes for FILECOMP.C */
|
/* Prototypes for FILECOMP.C */
|
||||||
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
|
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
|
||||||
VOID CompleteFilename (LPTSTR, INT);
|
VOID CompleteFilename (LPTSTR, UINT);
|
||||||
INT ShowCompletionMatches (LPTSTR, INT);
|
INT ShowCompletionMatches (LPTSTR, INT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_4NT_FILENAME_COMPLETION
|
#ifdef FEATURE_4NT_FILENAME_COMPLETION
|
||||||
VOID CompleteFilename (LPTSTR, BOOL, LPTSTR, INT);
|
VOID CompleteFilename (LPTSTR, BOOL, LPTSTR, UINT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
WORD wLastKey = 0;
|
WORD wLastKey = 0;
|
||||||
TCHAR ch;
|
TCHAR ch;
|
||||||
BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/
|
BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/
|
||||||
|
TCHAR szPath[MAX_PATH];
|
||||||
|
|
||||||
/* get screen size */
|
/* get screen size */
|
||||||
GetScreenSize (&maxx, &maxy);
|
GetScreenSize (&maxx, &maxy);
|
||||||
|
@ -366,7 +367,6 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
|
|
||||||
/* used to later see if we went down to the next line */
|
/* used to later see if we went down to the next line */
|
||||||
tempscreen = charcount;
|
tempscreen = charcount;
|
||||||
TCHAR szPath[MAX_PATH];
|
|
||||||
szPath[0]=_T('\0');
|
szPath[0]=_T('\0');
|
||||||
|
|
||||||
/* str is the whole things that is on the current line
|
/* str is the whole things that is on the current line
|
||||||
|
@ -404,7 +404,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if(((charcount + orgx) / maxx) + orgy > maxy - 1)
|
if(((charcount + orgx) / maxx) + orgy > maxy - 1)
|
||||||
orgy += maxy - ((charcount + orgx) / maxx + orgy + 1);
|
orgy += maxy - ((charcount + orgx) / maxx + orgy + 1);
|
||||||
}
|
}
|
||||||
SetCursorXY((orgx + current) % maxx, orgy + (orgx + current) / maxx);
|
SetCursorXY((short)(((int)orgx + current) % maxx), (short)((int)orgy + ((int)orgx + current) / maxx));
|
||||||
GetCursorXY(&curx, &cury);
|
GetCursorXY(&curx, &cury);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,12 +94,12 @@ INT CommandColor (LPTSTR first, LPTSTR rest)
|
||||||
}
|
}
|
||||||
else if ( (_tcscmp(&rest[0], _T("a")) >=0 ) && (_tcscmp(&rest[0], _T("f")) <=0 ) )
|
else if ( (_tcscmp(&rest[0], _T("a")) >=0 ) && (_tcscmp(&rest[0], _T("f")) <=0 ) )
|
||||||
{
|
{
|
||||||
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10) - _T('a') );
|
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10 - _T('a')) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if ( (_tcscmp(&rest[0], _T("A")) >=0 ) && (_tcscmp(&rest[0], _T("F")) <=0 ) )
|
else if ( (_tcscmp(&rest[0], _T("A")) >=0 ) && (_tcscmp(&rest[0], _T("F")) <=0 ) )
|
||||||
{
|
{
|
||||||
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10) - _T('A') );
|
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10 - _T('A')) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ConErrResPuts(STRING_COLOR_ERROR2);
|
ConErrResPuts(STRING_COLOR_ERROR2);
|
||||||
|
|
|
@ -130,7 +130,7 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA* f)
|
||||||
|
|
||||||
HANDLE file;
|
HANDLE file;
|
||||||
DWORD temp;
|
DWORD temp;
|
||||||
LONG BufferSize = 65536;
|
#define BufferSize 65536
|
||||||
BYTE buffer[BufferSize];
|
BYTE buffer[BufferSize];
|
||||||
LONGLONG i;
|
LONGLONG i;
|
||||||
LARGE_INTEGER FileSize;
|
LARGE_INTEGER FileSize;
|
||||||
|
@ -150,7 +150,7 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA* f)
|
||||||
WriteFile (file, buffer, BufferSize, &temp, NULL);
|
WriteFile (file, buffer, BufferSize, &temp, NULL);
|
||||||
ConOutPrintf (_T("%I64d%% %s\r"),(i * (LONGLONG)100)/FileSize.QuadPart,szDeleteWipe);
|
ConOutPrintf (_T("%I64d%% %s\r"),(i * (LONGLONG)100)/FileSize.QuadPart,szDeleteWipe);
|
||||||
}
|
}
|
||||||
WriteFile (file, buffer, FileSize.QuadPart - i, &temp, NULL);
|
WriteFile (file, buffer, (DWORD)(FileSize.QuadPart - i), &temp, NULL);
|
||||||
ConOutPrintf (_T("100%% %s\n"),szDeleteWipe);
|
ConOutPrintf (_T("100%% %s\n"),szDeleteWipe);
|
||||||
CloseHandle (file);
|
CloseHandle (file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,8 +199,8 @@ typedef struct _DIRFINDLISTNODE
|
||||||
} DIRFINDLISTNODE, *PDIRFINDLISTNODE;
|
} DIRFINDLISTNODE, *PDIRFINDLISTNODE;
|
||||||
|
|
||||||
|
|
||||||
typedef BOOL STDCALL
|
typedef BOOL
|
||||||
(*PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
|
(WINAPI *PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
|
||||||
|
|
||||||
|
|
||||||
/* Globally save the # of dirs, files and bytes,
|
/* Globally save the # of dirs, files and bytes,
|
||||||
|
@ -1294,7 +1294,7 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
||||||
{
|
{
|
||||||
/* Calculate the lines that will be printed */
|
/* Calculate the lines that will be printed */
|
||||||
// iLines = ceil((float)dwCount/(float)iColumns);
|
// iLines = ceil((float)dwCount/(float)iColumns);
|
||||||
iLines = dwCount / iColumns;
|
iLines = (USHORT)(dwCount / iColumns);
|
||||||
|
|
||||||
for (i = 0;i < iLines;i++)
|
for (i = 0;i < iLines;i++)
|
||||||
{
|
{
|
||||||
|
@ -1982,22 +1982,25 @@ INT CommandDir(LPTSTR first, LPTSTR rest)
|
||||||
/* <Debug :>
|
/* <Debug :>
|
||||||
Uncomment this to show the final state of switch flags*/
|
Uncomment this to show the final state of switch flags*/
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
ConOutPrintf("Attributes mask/value %x/%x\n",stFlags.stAttribs.dwAttribMask,stFlags.stAttribs.dwAttribVal );
|
{
|
||||||
ConOutPrintf("(B) Bare format : %i\n", stFlags.bBareFormat );
|
int i;
|
||||||
ConOutPrintf("(C) Thousand : %i\n", stFlags.bTSeperator );
|
ConOutPrintf(_T("Attributes mask/value %x/%x\n"),stFlags.stAttribs.dwAttribMask,stFlags.stAttribs.dwAttribVal );
|
||||||
ConOutPrintf("(W) Wide list : %i\n", stFlags.bWideList );
|
ConOutPrintf(_T("(B) Bare format : %i\n"), stFlags.bBareFormat );
|
||||||
ConOutPrintf("(D) Wide list sort by column : %i\n", stFlags.bWideListColSort );
|
ConOutPrintf(_T("(C) Thousand : %i\n"), stFlags.bTSeperator );
|
||||||
ConOutPrintf("(L) Lowercase : %i\n", stFlags.bLowerCase );
|
ConOutPrintf(_T("(W) Wide list : %i\n"), stFlags.bWideList );
|
||||||
ConOutPrintf("(N) New : %i\n", stFlags.bNewLongList );
|
ConOutPrintf(_T("(D) Wide list sort by column : %i\n"), stFlags.bWideListColSort );
|
||||||
ConOutPrintf("(O) Order : %i\n", stFlags.stOrderBy.sCriteriaCount );
|
ConOutPrintf(_T("(L) Lowercase : %i\n"), stFlags.bLowerCase );
|
||||||
|
ConOutPrintf(_T("(N) New : %i\n"), stFlags.bNewLongList );
|
||||||
|
ConOutPrintf(_T("(O) Order : %i\n"), stFlags.stOrderBy.sCriteriaCount );
|
||||||
for (i =0;i<stFlags.stOrderBy.sCriteriaCount;i++)
|
for (i =0;i<stFlags.stOrderBy.sCriteriaCount;i++)
|
||||||
ConOutPrintf(" Order Criteria [%i]: %i (Reversed: %i)\n",i, stFlags.stOrderBy.eCriteria[i], stFlags.stOrderBy.bCriteriaRev[i] );
|
ConOutPrintf(_T(" Order Criteria [%i]: %i (Reversed: %i)\n"),i, stFlags.stOrderBy.eCriteria[i], stFlags.stOrderBy.bCriteriaRev[i] );
|
||||||
ConOutPrintf("(P) Pause : %i\n", stFlags.bPause );
|
ConOutPrintf(_T("(P) Pause : %i\n"), stFlags.bPause );
|
||||||
ConOutPrintf("(Q) Owner : %i\n", stFlags.bUser );
|
ConOutPrintf(_T("(Q) Owner : %i\n"), stFlags.bUser );
|
||||||
ConOutPrintf("(S) Recursive : %i\n", stFlags.bRecursive );
|
ConOutPrintf(_T("(S) Recursive : %i\n"), stFlags.bRecursive );
|
||||||
ConOutPrintf("(T) Time field : %i\n", stFlags.stTimeField.eTimeField );
|
ConOutPrintf(_T("(T) Time field : %i\n"), stFlags.stTimeField.eTimeField );
|
||||||
ConOutPrintf("(X) Short names : %i\n", stFlags.bShortName );
|
ConOutPrintf(_T("(X) Short names : %i\n"), stFlags.bShortName );
|
||||||
ConOutPrintf("Parameter : %s\n", param );
|
ConOutPrintf(_T("Parameter : %s\n"), param );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* print the header */
|
/* print the header */
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
INT CommandEcho (LPTSTR cmd, LPTSTR param)
|
INT CommandEcho (LPTSTR cmd, LPTSTR param)
|
||||||
{
|
{
|
||||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||||
INT i = 0;
|
UINT i = 0;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param);
|
DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
|
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
|
||||||
|
|
||||||
VOID CompleteFilename (LPTSTR str, INT charcount)
|
VOID CompleteFilename (LPTSTR str, UINT charcount)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
@ -376,7 +376,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
|
||||||
/* number of quotes in the string */
|
/* number of quotes in the string */
|
||||||
INT nQuotes = 0;
|
INT nQuotes = 0;
|
||||||
/* used in for loops */
|
/* used in for loops */
|
||||||
INT i;
|
UINT i;
|
||||||
/* Char number to break the string at */
|
/* Char number to break the string at */
|
||||||
INT PBreak = 0;
|
INT PBreak = 0;
|
||||||
INT SBreak = 0;
|
INT SBreak = 0;
|
||||||
|
@ -509,7 +509,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
|
VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
|
||||||
{
|
{
|
||||||
/* Length of string before we complete it */
|
/* Length of string before we complete it */
|
||||||
INT StartLength;
|
INT StartLength;
|
||||||
|
@ -534,16 +534,17 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
|
||||||
/* Number of files */
|
/* Number of files */
|
||||||
INT FileListSize = 0;
|
INT FileListSize = 0;
|
||||||
/* Used for loops */
|
/* Used for loops */
|
||||||
INT i;
|
UINT i;
|
||||||
/* Editable string of what was passed in */
|
/* Editable string of what was passed in */
|
||||||
TCHAR str[MAX_PATH];
|
TCHAR str[MAX_PATH];
|
||||||
/* Keeps track of what element was last selected */
|
/* Keeps track of what element was last selected */
|
||||||
static INT Sel;
|
static INT Sel;
|
||||||
BOOL NeededQuote = FALSE;
|
BOOL NeededQuote = FALSE;
|
||||||
strOut[0] = _T('\0');
|
|
||||||
BOOL ShowAll = TRUE;
|
BOOL ShowAll = TRUE;
|
||||||
|
|
||||||
TCHAR * line = strIN;
|
TCHAR * line = strIN;
|
||||||
|
|
||||||
|
strOut[0] = _T('\0');
|
||||||
|
|
||||||
while (_istspace (*line))
|
while (_istspace (*line))
|
||||||
line++;
|
line++;
|
||||||
if(!_tcsncmp (line, _T("rd "), 3) || !_tcsncmp (line, _T("cd "), 3))
|
if(!_tcsncmp (line, _T("rd "), 3) || !_tcsncmp (line, _T("cd "), 3))
|
||||||
|
@ -708,14 +709,9 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
|
||||||
/* insert the quoation and move things around */
|
/* insert the quoation and move things around */
|
||||||
if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
|
if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
|
||||||
{
|
{
|
||||||
/* add another char or you will lose a null char ending */
|
memmove ( &szPrefix[LastSpace+1], &szPrefix[LastSpace], (_tcslen(szPrefix)-LastSpace+1) * sizeof(TCHAR) );
|
||||||
_tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1);
|
|
||||||
for(i = _tcslen(szPrefix) - 1; i > LastSpace; i--)
|
|
||||||
{
|
|
||||||
szPrefix[i] = szPrefix[i - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(LastSpace + 1 == _tcslen(szPrefix))
|
if((UINT)(LastSpace + 1) == _tcslen(szPrefix))
|
||||||
{
|
{
|
||||||
_tcscat(szPrefix,_T("\""));
|
_tcscat(szPrefix,_T("\""));
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,8 @@ VOID del(LPHIST_ENTRY item)
|
||||||
if (item==NULL || item==Top || item==Bottom)
|
if (item==NULL || item==Top || item==Bottom)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf(_T("del in " __FILE__ ": retrning\n"
|
DebugPrintf(_T("del in ") _T(__FILE__) _T(": retrning\n")
|
||||||
"item is 0x%08x (Bottom is0x%08x)\n"),
|
_T("item is 0x%08x (Bottom is0x%08x)\n"),
|
||||||
item, Bottom);
|
item, Bottom);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -276,7 +276,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
|
||||||
TCHAR * tmpPath;
|
TCHAR * tmpPath;
|
||||||
TCHAR szCurrent[MAX_PATH];
|
TCHAR szCurrent[MAX_PATH];
|
||||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||||
INT i;
|
UINT i;
|
||||||
|
|
||||||
|
|
||||||
/* Filter out special cases first */
|
/* Filter out special cases first */
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#include <winternl.h>
|
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
@ -14,6 +13,9 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#include <ndk/ntndk.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
Loading…
Reference in a new issue