msvc6 compatibility and small performance improvement in filename completion
Modified: trunk/reactos/subsys/system/cmd/cmd.c
Modified: trunk/reactos/subsys/system/cmd/cmd.h
Modified: trunk/reactos/subsys/system/cmd/cmdinput.c
Modified: trunk/reactos/subsys/system/cmd/color.c
Modified: trunk/reactos/subsys/system/cmd/del.c
Modified: trunk/reactos/subsys/system/cmd/dir.c
Modified: trunk/reactos/subsys/system/cmd/echo.c
Modified: trunk/reactos/subsys/system/cmd/filecomp.c
Modified: trunk/reactos/subsys/system/cmd/history.c
Modified: trunk/reactos/subsys/system/cmd/internal.c
Modified: trunk/reactos/subsys/system/cmd/precomp.h

Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/cmd.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -148,9 +148,9 @@
 #define NT_SUCCESS(StatCode)  ((NTSTATUS)(StatCode) >= 0)
 #endif
 
-typedef NTSTATUS (STDCALL *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
+typedef NTSTATUS (WINAPI *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
                                                           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 bCanExit = TRUE;     /* indicates if this shell is exitable */
@@ -356,7 +356,7 @@
 	}
 	else
 	{
-		INT i = 0;		
+		UINT i = 0;		
 		BOOL bInside = FALSE;
 		rest[0] = _T('\0');
 		full[0] = _T('\0');
@@ -1392,12 +1392,10 @@
 
 
 #ifdef _DEBUG
-	INT x;
-
 	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"));
 #endif

Modified: trunk/reactos/subsys/system/cmd/cmd.h
--- trunk/reactos/subsys/system/cmd/cmd.h	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/cmd.h	2005-09-12 16:06:53 UTC (rev 17819)
@@ -224,11 +224,11 @@
 
 /* Prototypes for FILECOMP.C */
 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
-VOID CompleteFilename (LPTSTR, INT);
+VOID CompleteFilename (LPTSTR, UINT);
 INT  ShowCompletionMatches (LPTSTR, INT);
 #endif
 #ifdef FEATURE_4NT_FILENAME_COMPLETION
-VOID CompleteFilename (LPTSTR, BOOL, LPTSTR, INT);
+VOID CompleteFilename (LPTSTR, BOOL, LPTSTR, UINT);
 #endif
 
 

Modified: trunk/reactos/subsys/system/cmd/cmdinput.c
--- trunk/reactos/subsys/system/cmd/cmdinput.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/cmdinput.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -138,6 +138,7 @@
 	WORD   wLastKey = 0;
 	TCHAR  ch;
 	BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/
+	TCHAR szPath[MAX_PATH];
 
 	/* get screen size */
 	GetScreenSize (&maxx, &maxy);
@@ -366,8 +367,7 @@
 				
 				/* used to later see if we went down to the next line */
 				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 
 				   that is and and out.  arg 2 is weather it goes back
@@ -404,7 +404,7 @@
 					if(((charcount + orgx) / maxx) + orgy > maxy - 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);
 
 #endif

Modified: trunk/reactos/subsys/system/cmd/color.c
--- trunk/reactos/subsys/system/cmd/color.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/color.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -94,12 +94,12 @@
 	  }	 
 	  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;
 	  }
       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;
 	  }
 	  ConErrResPuts(STRING_COLOR_ERROR2);

Modified: trunk/reactos/subsys/system/cmd/del.c
--- trunk/reactos/subsys/system/cmd/del.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/del.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -130,7 +130,7 @@
 
 	        HANDLE file;
 	        DWORD temp;
-	        LONG BufferSize = 65536;
+#define BufferSize 65536
 	        BYTE buffer[BufferSize];
 	        LONGLONG i;
 	        LARGE_INTEGER FileSize;
@@ -150,7 +150,7 @@
 			        WriteFile (file, buffer, BufferSize, &temp, NULL);
 			        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);
 		        CloseHandle (file);
                 }

Modified: trunk/reactos/subsys/system/cmd/dir.c
--- trunk/reactos/subsys/system/cmd/dir.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/dir.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -199,8 +199,8 @@
 } DIRFINDLISTNODE, *PDIRFINDLISTNODE;
 
 
-typedef BOOL STDCALL
-(*PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
+typedef BOOL
+(WINAPI *PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
 
 
 /* Globally save the # of dirs, files and bytes,
@@ -1294,7 +1294,7 @@
   {
     /* Calculate the lines that will be printed */
 //    iLines = ceil((float)dwCount/(float)iColumns);
-    iLines = dwCount / iColumns;
+    iLines = (USHORT)(dwCount / iColumns);
 
     for (i = 0;i < iLines;i++)
     {
@@ -1982,22 +1982,25 @@
 /* <Debug :>
    Uncomment this to show the final state of switch flags*/
 #ifdef _DEBUG
-	ConOutPrintf("Attributes mask/value %x/%x\n",stFlags.stAttribs.dwAttribMask,stFlags.stAttribs.dwAttribVal  );
-	ConOutPrintf("(B) Bare format : %i\n", stFlags.bBareFormat );
-	ConOutPrintf("(C) Thousand : %i\n", stFlags.bTSeperator );
-	ConOutPrintf("(W) Wide list : %i\n", stFlags.bWideList );
-	ConOutPrintf("(D) Wide list sort by column : %i\n", stFlags.bWideListColSort );
-	ConOutPrintf("(L) Lowercase : %i\n", stFlags.bLowerCase );
-	ConOutPrintf("(N) New : %i\n", stFlags.bNewLongList );
-	ConOutPrintf("(O) Order : %i\n", stFlags.stOrderBy.sCriteriaCount );
-	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("(P) Pause : %i\n", stFlags.bPause  );
-	ConOutPrintf("(Q) Owner : %i\n", stFlags.bUser );
-	ConOutPrintf("(S) Recursive : %i\n", stFlags.bRecursive );
-	ConOutPrintf("(T) Time field : %i\n", stFlags.stTimeField.eTimeField );
-	ConOutPrintf("(X) Short names : %i\n", stFlags.bShortName );
-	ConOutPrintf("Parameter : %s\n", param );
+	{
+		int i;
+		ConOutPrintf(_T("Attributes mask/value %x/%x\n"),stFlags.stAttribs.dwAttribMask,stFlags.stAttribs.dwAttribVal  );
+		ConOutPrintf(_T("(B) Bare format : %i\n"), stFlags.bBareFormat );
+		ConOutPrintf(_T("(C) Thousand : %i\n"), stFlags.bTSeperator );
+		ConOutPrintf(_T("(W) Wide list : %i\n"), stFlags.bWideList );
+		ConOutPrintf(_T("(D) Wide list sort by column : %i\n"), stFlags.bWideListColSort );
+		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++)
+			ConOutPrintf(_T(" Order Criteria [%i]: %i (Reversed: %i)\n"),i, stFlags.stOrderBy.eCriteria[i], stFlags.stOrderBy.bCriteriaRev[i] );
+		ConOutPrintf(_T("(P) Pause : %i\n"), stFlags.bPause  );
+		ConOutPrintf(_T("(Q) Owner : %i\n"), stFlags.bUser );
+		ConOutPrintf(_T("(S) Recursive : %i\n"), stFlags.bRecursive );
+		ConOutPrintf(_T("(T) Time field : %i\n"), stFlags.stTimeField.eTimeField );
+		ConOutPrintf(_T("(X) Short names : %i\n"), stFlags.bShortName );
+		ConOutPrintf(_T("Parameter : %s\n"), param );
+	}
 #endif
 
 	/* print the header  */

Modified: trunk/reactos/subsys/system/cmd/echo.c
--- trunk/reactos/subsys/system/cmd/echo.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/echo.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -33,7 +33,7 @@
 INT CommandEcho (LPTSTR cmd, LPTSTR param)
 {
 	TCHAR szMsg[RC_STRING_MAX_SIZE];
-	INT i = 0;
+	UINT i = 0;
 
 #ifdef _DEBUG
 	DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param);

Modified: trunk/reactos/subsys/system/cmd/filecomp.c
--- trunk/reactos/subsys/system/cmd/filecomp.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/filecomp.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -25,7 +25,7 @@
 
 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
 
-VOID CompleteFilename (LPTSTR str, INT charcount)
+VOID CompleteFilename (LPTSTR str, UINT charcount)
 {
 	WIN32_FIND_DATA file;
 	HANDLE hFile;
@@ -376,7 +376,7 @@
 	/* number of quotes in the string */
 	INT nQuotes = 0;
 	/* used in for loops */
-	INT i;
+	UINT i;
 	/* Char number to break the string at */
 	INT PBreak = 0;
 	INT SBreak = 0;
@@ -509,7 +509,7 @@
 	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 */
 	INT StartLength;
@@ -534,16 +534,17 @@
 	/* Number of files */
 	INT FileListSize = 0;
 	/* Used for loops */
-	INT i;
+	UINT i;
 	/* Editable string of what was passed in */
 	TCHAR str[MAX_PATH];
 	/* Keeps track of what element was last selected */
 	static INT Sel;
 	BOOL NeededQuote = FALSE;
-	strOut[0] = _T('\0');
 	BOOL ShowAll = TRUE;
-
 	TCHAR * line = strIN; 
+
+	strOut[0] = _T('\0');
+
 	while (_istspace (*line))
 			line++;	
 	if(!_tcsncmp (line, _T("rd "), 3) || !_tcsncmp (line, _T("cd "), 3))
@@ -708,14 +709,9 @@
 		/* insert the quoation and move things around */
 		if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
 		{
-			/* add another char or you will lose a null char ending */
-			_tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1);
-			for(i = _tcslen(szPrefix) - 1; i > LastSpace; i--)
-			{
-				szPrefix[i] = szPrefix[i - 1];
-			}
+			memmove ( &szPrefix[LastSpace+1], &szPrefix[LastSpace], (_tcslen(szPrefix)-LastSpace+1) * sizeof(TCHAR) );
 			
-			if(LastSpace + 1 == _tcslen(szPrefix))
+			if((UINT)(LastSpace + 1) == _tcslen(szPrefix))
 			{
 				_tcscat(szPrefix,_T("\""));
 			}

Modified: trunk/reactos/subsys/system/cmd/history.c
--- trunk/reactos/subsys/system/cmd/history.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/history.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -193,8 +193,8 @@
 	if (item==NULL || item==Top || item==Bottom)
 	{
 #ifdef _DEBUG
-		DebugPrintf(_T("del in " __FILE__  ": retrning\n"
-			    "item is 0x%08x (Bottom is0x%08x)\n"),
+		DebugPrintf(_T("del in ") _T(__FILE__)  _T(": retrning\n")
+			    _T("item is 0x%08x (Bottom is0x%08x)\n"),
 			    item, Bottom);
 #endif
 		return;

Modified: trunk/reactos/subsys/system/cmd/internal.c
--- trunk/reactos/subsys/system/cmd/internal.c	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/internal.c	2005-09-12 16:06:53 UTC (rev 17819)
@@ -276,7 +276,7 @@
 	TCHAR * tmpPath;
 	TCHAR szCurrent[MAX_PATH];
 	TCHAR szMsg[RC_STRING_MAX_SIZE];
-	INT i;
+	UINT i;
  
  
 	/* Filter out special cases first */

Modified: trunk/reactos/subsys/system/cmd/precomp.h
--- trunk/reactos/subsys/system/cmd/precomp.h	2005-09-12 14:55:55 UTC (rev 17818)
+++ trunk/reactos/subsys/system/cmd/precomp.h	2005-09-12 16:06:53 UTC (rev 17819)
@@ -1,6 +1,5 @@
 #include <windows.h>
 #include <winnt.h>
-#include <winternl.h>
 #include <shellapi.h>
 
 #include <tchar.h>
@@ -14,6 +13,9 @@
 #include <math.h>
 #include <time.h>
 
+#define NTOS_MODE_USER
+#include <ndk/ntndk.h>
+
 #include "cmd.h"
 #include "config.h"
 #include "batch.h"