From 731f19e9b1a119ffa0a6d680984f4cc48a44e0eb Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 14 Apr 1999 23:48:27 +0000 Subject: [PATCH] several changes to make cmd compile and link again svn path=/trunk/; revision=384 --- reactos/apps/utils/cmd/cmd.c | 28 ++++++++++++++++++---------- reactos/apps/utils/cmd/cmd.h | 2 ++ reactos/apps/utils/cmd/config.h | 2 +- reactos/apps/utils/cmd/console.c | 11 +++++++---- reactos/apps/utils/cmd/copy.c | 2 +- reactos/apps/utils/cmd/del.c | 4 +++- reactos/apps/utils/cmd/dir.c | 9 +++++---- reactos/apps/utils/cmd/filecomp.c | 3 ++- reactos/apps/utils/cmd/makefile | 9 +++++++-- reactos/apps/utils/cmd/time.c | 2 +- rosapps/cmd/cmd.c | 28 ++++++++++++++++++---------- rosapps/cmd/cmd.h | 2 ++ rosapps/cmd/config.h | 2 +- rosapps/cmd/console.c | 11 +++++++---- rosapps/cmd/copy.c | 2 +- rosapps/cmd/del.c | 4 +++- rosapps/cmd/dir.c | 9 +++++---- rosapps/cmd/filecomp.c | 3 ++- rosapps/cmd/makefile | 9 +++++++-- rosapps/cmd/time.c | 2 +- 20 files changed, 94 insertions(+), 50 deletions(-) diff --git a/reactos/apps/utils/cmd/cmd.c b/reactos/apps/utils/cmd/cmd.c index 966c5d798af..4ace3a339b8 100644 --- a/reactos/apps/utils/cmd/cmd.c +++ b/reactos/apps/utils/cmd/cmd.c @@ -112,6 +112,7 @@ #include #include #include +#include #include "cmd.h" #include "batch.h" @@ -199,7 +200,7 @@ Execute (LPTSTR first, LPTSTR rest) TCHAR szFullCmdLine [1024]; PROCESS_INFORMATION prci; STARTUPINFO stui; - DWORD dwError = 0; +// DWORD dwError = 0; #ifdef _DEBUG DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest); @@ -697,7 +698,7 @@ ProcessInput (BOOL bFlag) break; case _T('?'): - cp += wsprintf (cp, _T("%u"), nErrorLevel); + cp += _stprintf (cp, _T("%u"), nErrorLevel); ip++; break; @@ -815,7 +816,7 @@ ShowCommands (VOID) #ifdef FEATURE_REDIRECTION ConOutPuts (" [redirections and piping]"); #endif - ConOutChar ('\n'); + ConOutChar ('\n'); } @@ -931,8 +932,10 @@ static VOID Initialize (int argc, char *argv[]) ShowCommands (); /* Set COMSPEC environment variable */ - if (argv) - SetEnvironmentVariable (_T("COMSPEC"), argv[0]); +#ifndef __REACTOS__ + if (argv) + SetEnvironmentVariable (_T("COMSPEC"), argv[0]); +#endif /* add ctrl handler */ #if 0 @@ -969,18 +972,23 @@ int main (int argc, char *argv[]) AllocConsole (); #ifndef __REACTOS__ - SetFileApisToOEM (); + SetFileApisToOEM (); +#endif + +#ifdef __REACTOS__ + SetCurrentDirectory (_T("C:\\")); #endif /* check switches on command-line */ Initialize (argc, argv); /* call prompt routine */ - nExitCode = ProcessInput (FALSE); + nExitCode = ProcessInput (FALSE); /* do the cleanup */ - Cleanup (); - FreeConsole (); + Cleanup (); + FreeConsole (); - return nExitCode; + return nExitCode; +// return 0; } diff --git a/reactos/apps/utils/cmd/cmd.h b/reactos/apps/utils/cmd/cmd.h index 7ce80014f6c..84a76ee95cc 100644 --- a/reactos/apps/utils/cmd/cmd.h +++ b/reactos/apps/utils/cmd/cmd.h @@ -65,6 +65,8 @@ #define D_OFF "off" +#define CHECKPOINT ConErrPrintf("%s:%d\n",__FILE__,__LINE__); + /* Prototypes for CMD.C */ extern HANDLE hOut; diff --git a/reactos/apps/utils/cmd/config.h b/reactos/apps/utils/cmd/config.h index 9ed6362c77f..12edbe5bfc6 100644 --- a/reactos/apps/utils/cmd/config.h +++ b/reactos/apps/utils/cmd/config.h @@ -20,7 +20,7 @@ /* JPP 20 Jul 1998 - define DEBUG to add debugging code */ -/*#define DEBUG */ +#define DEBUG /* Define to enable the alias command, and aliases.*/ diff --git a/reactos/apps/utils/cmd/console.c b/reactos/apps/utils/cmd/console.c index 37d028440d0..d5a68b9cae1 100644 --- a/reactos/apps/utils/cmd/console.c +++ b/reactos/apps/utils/cmd/console.c @@ -37,7 +37,8 @@ VOID DebugPrintf (LPTSTR szFormat, ...) _vstprintf (szOut, szFormat, arg_ptr); va_end (arg_ptr); - OutputDebugString (szOut); + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL); +// OutputDebugString (szOut); } #endif /* _DEBUG */ @@ -124,7 +125,8 @@ VOID ConOutPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); - WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +// WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -155,7 +157,8 @@ VOID ConErrPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_ERROR_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); - WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +// WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); + WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -236,5 +239,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible) cci.dwSize = bInsert ? 10 : 100; cci.bVisible = bVisible; - SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); +// SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); } diff --git a/reactos/apps/utils/cmd/copy.c b/reactos/apps/utils/cmd/copy.c index eac53d4d4de..e2e825fa1f7 100644 --- a/reactos/apps/utils/cmd/copy.c +++ b/reactos/apps/utils/cmd/copy.c @@ -205,7 +205,7 @@ AddFiles (LPFILES f, char *arg, int *source, int *dest, static BOOL GetDestination (LPFILES f, LPFILES dest) { - LPFILES p; + LPFILES p = NULL; LPFILES start = f; while (f->next != NULL) diff --git a/reactos/apps/utils/cmd/del.c b/reactos/apps/utils/cmd/del.c index 9b581ff1b63..91324f50ad2 100644 --- a/reactos/apps/utils/cmd/del.c +++ b/reactos/apps/utils/cmd/del.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "cmd.h" @@ -92,6 +93,7 @@ static BOOL ConfirmDeleteAll (VOID) } +#if 0 static INT Prompt (LPTSTR str) { TCHAR inp[10]; @@ -118,7 +120,7 @@ static INT Prompt (LPTSTR str) return PROMPT_NO; } - +#endif static BOOL RemoveFile (LPTSTR lpFileName, DWORD dwFlags) diff --git a/reactos/apps/utils/cmd/dir.c b/reactos/apps/utils/cmd/dir.c index b1830444c73..74ce10c3579 100644 --- a/reactos/apps/utils/cmd/dir.c +++ b/reactos/apps/utils/cmd/dir.c @@ -118,6 +118,7 @@ #include #include #include +#include #include #include "cmd.h" @@ -786,17 +787,17 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (file.cAlternateFileName[0] == _T('\0')) - wsprintf (buffer, _T("[%s]"), file.cFileName); + _stprintf (buffer, _T("[%s]"), file.cFileName); else - wsprintf (buffer, _T("[%s]"), file.cAlternateFileName); + _stprintf (buffer, _T("[%s]"), file.cAlternateFileName); dircount++; } else { if (file.cAlternateFileName[0] == _T('\0')) - wsprintf (buffer, _T("%s"), file.cFileName); + _stprintf (buffer, _T("%s"), file.cFileName); else - wsprintf (buffer, _T("%s"), file.cAlternateFileName); + _stprintf (buffer, _T("%s"), file.cAlternateFileName); filecount++; } diff --git a/reactos/apps/utils/cmd/filecomp.c b/reactos/apps/utils/cmd/filecomp.c index deb43818c70..3232570c366 100644 --- a/reactos/apps/utils/cmd/filecomp.c +++ b/reactos/apps/utils/cmd/filecomp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "cmd.h" @@ -222,7 +223,7 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount) continue; if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - wsprintf (fname,"[%s]", file.cFileName); + _stprintf (fname, _T("[%s]"), file.cFileName); else _tcscpy (fname, file.cFileName); diff --git a/reactos/apps/utils/cmd/makefile b/reactos/apps/utils/cmd/makefile index 20244043e95..1041824a658 100644 --- a/reactos/apps/utils/cmd/makefile +++ b/reactos/apps/utils/cmd/makefile @@ -15,9 +15,14 @@ OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \ pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \ ver.o verify.o vol.o where.o -LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a +LIBS= ../../lib/kernel32/kernel32.a ../../lib/crtdll/crtdll.a -CLEAN_FILES = $(OBJECTS) cmd.exe cmd.sym +CLEAN_FILES = cmd.o attrib.o alias.o batch.o beep.o call.o \ + chcp.o cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o \ + del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o \ + history.o if.o internal.o label.o locale.o misc.o move.o path.o \ + pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \ + ver.o verify.o vol.o where.o cmd.exe cmd.sym clean: $(CLEAN_FILES:%=%_clean) diff --git a/reactos/apps/utils/cmd/time.c b/reactos/apps/utils/cmd/time.c index 08d70bc18f4..d2d64c9e458 100644 --- a/reactos/apps/utils/cmd/time.c +++ b/reactos/apps/utils/cmd/time.c @@ -237,7 +237,7 @@ INT cmd_time (LPTSTR cmd, LPTSTR param) return 0; } - // force input the next time around. + /* force input the next time around. */ nTimeString == -1; } ConErrPuts (_T("Invalid time.")); diff --git a/rosapps/cmd/cmd.c b/rosapps/cmd/cmd.c index 966c5d798af..4ace3a339b8 100644 --- a/rosapps/cmd/cmd.c +++ b/rosapps/cmd/cmd.c @@ -112,6 +112,7 @@ #include #include #include +#include #include "cmd.h" #include "batch.h" @@ -199,7 +200,7 @@ Execute (LPTSTR first, LPTSTR rest) TCHAR szFullCmdLine [1024]; PROCESS_INFORMATION prci; STARTUPINFO stui; - DWORD dwError = 0; +// DWORD dwError = 0; #ifdef _DEBUG DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest); @@ -697,7 +698,7 @@ ProcessInput (BOOL bFlag) break; case _T('?'): - cp += wsprintf (cp, _T("%u"), nErrorLevel); + cp += _stprintf (cp, _T("%u"), nErrorLevel); ip++; break; @@ -815,7 +816,7 @@ ShowCommands (VOID) #ifdef FEATURE_REDIRECTION ConOutPuts (" [redirections and piping]"); #endif - ConOutChar ('\n'); + ConOutChar ('\n'); } @@ -931,8 +932,10 @@ static VOID Initialize (int argc, char *argv[]) ShowCommands (); /* Set COMSPEC environment variable */ - if (argv) - SetEnvironmentVariable (_T("COMSPEC"), argv[0]); +#ifndef __REACTOS__ + if (argv) + SetEnvironmentVariable (_T("COMSPEC"), argv[0]); +#endif /* add ctrl handler */ #if 0 @@ -969,18 +972,23 @@ int main (int argc, char *argv[]) AllocConsole (); #ifndef __REACTOS__ - SetFileApisToOEM (); + SetFileApisToOEM (); +#endif + +#ifdef __REACTOS__ + SetCurrentDirectory (_T("C:\\")); #endif /* check switches on command-line */ Initialize (argc, argv); /* call prompt routine */ - nExitCode = ProcessInput (FALSE); + nExitCode = ProcessInput (FALSE); /* do the cleanup */ - Cleanup (); - FreeConsole (); + Cleanup (); + FreeConsole (); - return nExitCode; + return nExitCode; +// return 0; } diff --git a/rosapps/cmd/cmd.h b/rosapps/cmd/cmd.h index 7ce80014f6c..84a76ee95cc 100644 --- a/rosapps/cmd/cmd.h +++ b/rosapps/cmd/cmd.h @@ -65,6 +65,8 @@ #define D_OFF "off" +#define CHECKPOINT ConErrPrintf("%s:%d\n",__FILE__,__LINE__); + /* Prototypes for CMD.C */ extern HANDLE hOut; diff --git a/rosapps/cmd/config.h b/rosapps/cmd/config.h index 9ed6362c77f..12edbe5bfc6 100644 --- a/rosapps/cmd/config.h +++ b/rosapps/cmd/config.h @@ -20,7 +20,7 @@ /* JPP 20 Jul 1998 - define DEBUG to add debugging code */ -/*#define DEBUG */ +#define DEBUG /* Define to enable the alias command, and aliases.*/ diff --git a/rosapps/cmd/console.c b/rosapps/cmd/console.c index 37d028440d0..d5a68b9cae1 100644 --- a/rosapps/cmd/console.c +++ b/rosapps/cmd/console.c @@ -37,7 +37,8 @@ VOID DebugPrintf (LPTSTR szFormat, ...) _vstprintf (szOut, szFormat, arg_ptr); va_end (arg_ptr); - OutputDebugString (szOut); + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL); +// OutputDebugString (szOut); } #endif /* _DEBUG */ @@ -124,7 +125,8 @@ VOID ConOutPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); - WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +// WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -155,7 +157,8 @@ VOID ConErrPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_ERROR_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); - WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +// WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); + WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -236,5 +239,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible) cci.dwSize = bInsert ? 10 : 100; cci.bVisible = bVisible; - SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); +// SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); } diff --git a/rosapps/cmd/copy.c b/rosapps/cmd/copy.c index eac53d4d4de..e2e825fa1f7 100644 --- a/rosapps/cmd/copy.c +++ b/rosapps/cmd/copy.c @@ -205,7 +205,7 @@ AddFiles (LPFILES f, char *arg, int *source, int *dest, static BOOL GetDestination (LPFILES f, LPFILES dest) { - LPFILES p; + LPFILES p = NULL; LPFILES start = f; while (f->next != NULL) diff --git a/rosapps/cmd/del.c b/rosapps/cmd/del.c index 9b581ff1b63..91324f50ad2 100644 --- a/rosapps/cmd/del.c +++ b/rosapps/cmd/del.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "cmd.h" @@ -92,6 +93,7 @@ static BOOL ConfirmDeleteAll (VOID) } +#if 0 static INT Prompt (LPTSTR str) { TCHAR inp[10]; @@ -118,7 +120,7 @@ static INT Prompt (LPTSTR str) return PROMPT_NO; } - +#endif static BOOL RemoveFile (LPTSTR lpFileName, DWORD dwFlags) diff --git a/rosapps/cmd/dir.c b/rosapps/cmd/dir.c index b1830444c73..74ce10c3579 100644 --- a/rosapps/cmd/dir.c +++ b/rosapps/cmd/dir.c @@ -118,6 +118,7 @@ #include #include #include +#include #include #include "cmd.h" @@ -786,17 +787,17 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (file.cAlternateFileName[0] == _T('\0')) - wsprintf (buffer, _T("[%s]"), file.cFileName); + _stprintf (buffer, _T("[%s]"), file.cFileName); else - wsprintf (buffer, _T("[%s]"), file.cAlternateFileName); + _stprintf (buffer, _T("[%s]"), file.cAlternateFileName); dircount++; } else { if (file.cAlternateFileName[0] == _T('\0')) - wsprintf (buffer, _T("%s"), file.cFileName); + _stprintf (buffer, _T("%s"), file.cFileName); else - wsprintf (buffer, _T("%s"), file.cAlternateFileName); + _stprintf (buffer, _T("%s"), file.cAlternateFileName); filecount++; } diff --git a/rosapps/cmd/filecomp.c b/rosapps/cmd/filecomp.c index deb43818c70..3232570c366 100644 --- a/rosapps/cmd/filecomp.c +++ b/rosapps/cmd/filecomp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "cmd.h" @@ -222,7 +223,7 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount) continue; if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - wsprintf (fname,"[%s]", file.cFileName); + _stprintf (fname, _T("[%s]"), file.cFileName); else _tcscpy (fname, file.cFileName); diff --git a/rosapps/cmd/makefile b/rosapps/cmd/makefile index 20244043e95..1041824a658 100644 --- a/rosapps/cmd/makefile +++ b/rosapps/cmd/makefile @@ -15,9 +15,14 @@ OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \ pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \ ver.o verify.o vol.o where.o -LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a +LIBS= ../../lib/kernel32/kernel32.a ../../lib/crtdll/crtdll.a -CLEAN_FILES = $(OBJECTS) cmd.exe cmd.sym +CLEAN_FILES = cmd.o attrib.o alias.o batch.o beep.o call.o \ + chcp.o cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o \ + del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o \ + history.o if.o internal.o label.o locale.o misc.o move.o path.o \ + pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \ + ver.o verify.o vol.o where.o cmd.exe cmd.sym clean: $(CLEAN_FILES:%=%_clean) diff --git a/rosapps/cmd/time.c b/rosapps/cmd/time.c index 08d70bc18f4..d2d64c9e458 100644 --- a/rosapps/cmd/time.c +++ b/rosapps/cmd/time.c @@ -237,7 +237,7 @@ INT cmd_time (LPTSTR cmd, LPTSTR param) return 0; } - // force input the next time around. + /* force input the next time around. */ nTimeString == -1; } ConErrPuts (_T("Invalid time."));