mirror of
https://github.com/reactos/reactos.git
synced 2025-07-03 13:01:24 +00:00
changes to make cmd compile (not link)
svn path=/trunk/; revision=326
This commit is contained in:
parent
b172b0df42
commit
108fcceee2
101 changed files with 2576 additions and 1819 deletions
|
@ -26,7 +26,6 @@
|
||||||
* Redirection safe!
|
* Redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
* Added handling of multiple filenames.
|
* Added handling of multiple filenames.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_ATTRIB
|
#ifdef INCLUDE_CMD_ATTRIB
|
||||||
|
@ -38,6 +36,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,13 @@
|
||||||
* Unicode safe!
|
* Unicode safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _BATCH_H_INCLUDED_
|
||||||
|
#define _BATCH_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
typedef struct tagBATCHCONTEXT
|
typedef struct tagBATCHCONTEXT
|
||||||
{
|
{
|
||||||
|
@ -37,3 +40,5 @@ LPTSTR BatchParams (LPTSTR, LPTSTR);
|
||||||
VOID ExitBatch (LPTSTR);
|
VOID ExitBatch (LPTSTR);
|
||||||
BOOL Batch (LPTSTR, LPTSTR, LPTSTR);
|
BOOL Batch (LPTSTR, LPTSTR, LPTSTR);
|
||||||
LPTSTR ReadBatchLine (LPBOOL);
|
LPTSTR ReadBatchLine (LPBOOL);
|
||||||
|
|
||||||
|
#endif /* _BATCH_H_INCLUDED_ */
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_BEEP
|
#ifdef INCLUDE_CMD_BEEP
|
||||||
|
@ -48,8 +46,11 @@ INT cmd_beep (LPTSTR cmd, LPTSTR param)
|
||||||
if (bc == NULL)
|
if (bc == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,14 +25,13 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_CHCP
|
#ifdef INCLUDE_CMD_CHCP
|
||||||
|
@ -18,6 +16,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "chcp.h"
|
#include "chcp.h"
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_CLS
|
#ifdef INCLUDE_CMD_CLS
|
||||||
|
|
|
@ -105,14 +105,13 @@
|
||||||
* Replaced spawnl() by CreateProcess().
|
* Replaced spawnl() by CreateProcess().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// #include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
@ -125,7 +124,7 @@ 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 */
|
||||||
BOOL bCtrlBreak = FALSE; /* Ctrl-Break or Ctrl-C hit */
|
BOOL bCtrlBreak = FALSE; /* Ctrl-Break or Ctrl-C hit */
|
||||||
BOOL bIgnoreEcho = FALSE; /* Ignore 'newline' before 'cls' */
|
BOOL bIgnoreEcho = FALSE; /* Ignore 'newline' before 'cls' */
|
||||||
INT errorlevel = 0; /* Errorlevel of last launched external program */
|
INT nErrorLevel = 0; /* Errorlevel of last launched external program */
|
||||||
OSVERSIONINFO osvi;
|
OSVERSIONINFO osvi;
|
||||||
HANDLE hIn;
|
HANDLE hIn;
|
||||||
HANDLE hOut;
|
HANDLE hOut;
|
||||||
|
@ -179,9 +178,7 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
|
|
||||||
/* get the PATH environment variable and parse it */
|
/* get the PATH environment variable and parse it */
|
||||||
/* search the PATH environment variable for the binary */
|
/* search the PATH environment variable for the binary */
|
||||||
find_which (first, szFullName);
|
if (!SearchForExecutable (first, szFullName))
|
||||||
|
|
||||||
if (szFullName[0] == _T('\0'))
|
|
||||||
{
|
{
|
||||||
error_bad_command ();
|
error_bad_command ();
|
||||||
return;
|
return;
|
||||||
|
@ -209,7 +206,7 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
#endif
|
#endif
|
||||||
/* build command line for CreateProcess() */
|
/* build command line for CreateProcess() */
|
||||||
_tcscpy (szFullCmdLine, szFullName);
|
_tcscpy (szFullCmdLine, szFullName);
|
||||||
_tcscat (szFullCmdLine, " ");
|
_tcscat (szFullCmdLine, _T(" "));
|
||||||
_tcscat (szFullCmdLine, rest);
|
_tcscat (szFullCmdLine, rest);
|
||||||
|
|
||||||
/* fill startup info */
|
/* fill startup info */
|
||||||
|
@ -221,8 +218,10 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
|
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
|
||||||
0, NULL, NULL, &stui, &prci))
|
0, NULL, NULL, &stui, &prci))
|
||||||
{
|
{
|
||||||
|
DWORD dwExitCode;
|
||||||
WaitForSingleObject (prci.hProcess, INFINITE);
|
WaitForSingleObject (prci.hProcess, INFINITE);
|
||||||
GetExitCodeProcess (prci.hProcess, &errorlevel);
|
GetExitCodeProcess (prci.hProcess, &dwExitCode);
|
||||||
|
nErrorLevel = (INT)dwExitCode;
|
||||||
CloseHandle (prci.hThread);
|
CloseHandle (prci.hThread);
|
||||||
CloseHandle (prci.hProcess);
|
CloseHandle (prci.hProcess);
|
||||||
}
|
}
|
||||||
|
@ -688,7 +687,7 @@ ProcessInput (BOOL bFlag)
|
||||||
case _T('7'):
|
case _T('7'):
|
||||||
case _T('8'):
|
case _T('8'):
|
||||||
case _T('9'):
|
case _T('9'):
|
||||||
if (tp = FindArg (*ip - _T('0')))
|
if ((tp = FindArg (*ip - _T('0'))))
|
||||||
{
|
{
|
||||||
cp = stpcpy (cp, tp);
|
cp = stpcpy (cp, tp);
|
||||||
ip++;
|
ip++;
|
||||||
|
@ -698,12 +697,12 @@ ProcessInput (BOOL bFlag)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('?'):
|
case _T('?'):
|
||||||
cp += wsprintf (cp, _T("%u"), errorlevel);
|
cp += wsprintf (cp, _T("%u"), nErrorLevel);
|
||||||
ip++;
|
ip++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (tp = _tcschr (ip, _T('%')))
|
if ((tp = _tcschr (ip, _T('%'))))
|
||||||
{
|
{
|
||||||
char evar[512];
|
char evar[512];
|
||||||
*tp = _T('\0');
|
*tp = _T('\0');
|
||||||
|
@ -932,10 +931,13 @@ static VOID Initialize (int argc, char *argv[])
|
||||||
ShowCommands ();
|
ShowCommands ();
|
||||||
|
|
||||||
/* Set COMSPEC environment variable */
|
/* Set COMSPEC environment variable */
|
||||||
|
if (argv)
|
||||||
SetEnvironmentVariable (_T("COMSPEC"), argv[0]);
|
SetEnvironmentVariable (_T("COMSPEC"), argv[0]);
|
||||||
|
|
||||||
/* add ctrl handler */
|
/* add ctrl handler */
|
||||||
|
#if 0
|
||||||
SetConsoleCtrlHandler (NULL, TRUE);
|
SetConsoleCtrlHandler (NULL, TRUE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -952,7 +954,9 @@ static VOID Cleanup (VOID)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* remove ctrl handler */
|
/* remove ctrl handler */
|
||||||
// SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler, FALSE);
|
#if 0
|
||||||
|
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler, FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -964,7 +968,9 @@ int main (int argc, char *argv[])
|
||||||
INT nExitCode;
|
INT nExitCode;
|
||||||
|
|
||||||
AllocConsole ();
|
AllocConsole ();
|
||||||
|
#ifndef __REACTOS__
|
||||||
SetFileApisToOEM ();
|
SetFileApisToOEM ();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* check switches on command-line */
|
/* check switches on command-line */
|
||||||
Initialize (argc, argv);
|
Initialize (argc, argv);
|
||||||
|
|
|
@ -11,18 +11,37 @@
|
||||||
* Moved error messages in here
|
* Moved error messages in here
|
||||||
*
|
*
|
||||||
* 07/12/98 (Rob Lake)
|
* 07/12/98 (Rob Lake)
|
||||||
* Moved more error messages here
|
* Moved more error messages here.
|
||||||
*
|
*
|
||||||
* 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
* 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
||||||
* Added compile date to version
|
* Added compile date to version.
|
||||||
|
*
|
||||||
|
* 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Introduced a new version string.
|
||||||
|
* Thanks to Emanuele Aliberti!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #define WIN32_LEAN_AND_MEAN
|
#ifndef _CMD_H_INCLUDED_
|
||||||
|
#define _CMD_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// #include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CMD_VER "0.1 pre 1"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
|
||||||
|
#else
|
||||||
|
#ifdef __LCC__
|
||||||
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", lcc-win32]"
|
||||||
|
#else
|
||||||
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ "]"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SHELLVER "version 0.0.4 [" __DATE__"]"
|
|
||||||
|
|
||||||
#define BREAK_BATCHFILE 1
|
#define BREAK_BATCHFILE 1
|
||||||
#define BREAK_OUTOFBATCH 2
|
#define BREAK_OUTOFBATCH 2
|
||||||
|
@ -48,7 +67,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CMD.C */
|
/* Prototypes for CMD.C */
|
||||||
extern HANDLE hOut;
|
extern HANDLE hOut;
|
||||||
extern HANDLE hIn;
|
extern HANDLE hIn;
|
||||||
extern WORD wColor;
|
extern WORD wColor;
|
||||||
|
@ -56,7 +75,7 @@ extern WORD wDefColor;
|
||||||
extern BOOL bCtrlBreak;
|
extern BOOL bCtrlBreak;
|
||||||
extern BOOL bIgnoreEcho;
|
extern BOOL bIgnoreEcho;
|
||||||
extern BOOL bExit;
|
extern BOOL bExit;
|
||||||
extern int errorlevel;
|
extern INT nErrorLevel;
|
||||||
extern SHORT maxx;
|
extern SHORT maxx;
|
||||||
extern SHORT maxy;
|
extern SHORT maxy;
|
||||||
extern OSVERSIONINFO osvi;
|
extern OSVERSIONINFO osvi;
|
||||||
|
@ -70,24 +89,32 @@ int c_brk(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for ALIAS.C */
|
/* Prototypes for ALIAS.C */
|
||||||
VOID ExpandAlias (char *, int);
|
VOID ExpandAlias (LPTSTR, INT);
|
||||||
INT cmd_alias (LPTSTR, LPTSTR);
|
INT cmd_alias (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototyped for ATTRIB.C */
|
/* Prototypes for ATTRIB.C */
|
||||||
INT cmd_attrib (LPTSTR, LPTSTR);
|
INT cmd_attrib (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CLS.C */
|
/* Prototypes for BEEP.C */
|
||||||
|
INT cmd_beep (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for CALL.C */
|
||||||
|
INT cmd_call (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for CLS.C */
|
||||||
INT cmd_cls (LPTSTR, LPTSTR);
|
INT cmd_cls (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CMDINPUT.C */
|
/* Prototypes for CMDINPUT.C */
|
||||||
VOID ReadCommand (LPTSTR, INT);
|
VOID ReadCommand (LPTSTR, INT);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CMDTABLE.C */
|
/* Prototypes for CMDTABLE.C */
|
||||||
#define CMD_SPECIAL 1
|
#define CMD_SPECIAL 1
|
||||||
#define CMD_BATCHONLY 2
|
#define CMD_BATCHONLY 2
|
||||||
|
|
||||||
|
@ -99,12 +126,12 @@ typedef struct tagCOMMAND
|
||||||
} COMMAND, *LPCOMMAND;
|
} COMMAND, *LPCOMMAND;
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for COLOR.C */
|
/* Prototypes for COLOR.C */
|
||||||
VOID SetScreenColor (WORD);
|
VOID SetScreenColor (WORD);
|
||||||
INT cmd_color (LPTSTR, LPTSTR);
|
INT cmd_color (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CONSOLE.C */
|
/* Prototypes for CONSOLE.C */
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
VOID DebugPrintf (LPTSTR, ...);
|
VOID DebugPrintf (LPTSTR, ...);
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
@ -122,33 +149,33 @@ VOID ConErrChar (TCHAR);
|
||||||
VOID ConErrPuts (LPTSTR);
|
VOID ConErrPuts (LPTSTR);
|
||||||
VOID ConErrPrintf (LPTSTR, ...);
|
VOID ConErrPrintf (LPTSTR, ...);
|
||||||
|
|
||||||
|
SHORT GetCursorX (VOID);
|
||||||
SHORT wherex (VOID);
|
SHORT GetCursorY (VOID);
|
||||||
SHORT wherey (VOID);
|
VOID GetCursorXY (PSHORT, PSHORT);
|
||||||
VOID goxy (SHORT, SHORT);
|
VOID SetCursorXY (SHORT, SHORT);
|
||||||
|
|
||||||
VOID GetScreenSize (PSHORT, PSHORT);
|
VOID GetScreenSize (PSHORT, PSHORT);
|
||||||
VOID SetCursorType (BOOL, BOOL);
|
VOID SetCursorType (BOOL, BOOL);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for COPY.C */
|
/* Prototypes for COPY.C */
|
||||||
INT cmd_copy (LPTSTR, LPTSTR);
|
INT cmd_copy (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DATE.C */
|
/* Prototypes for DATE.C */
|
||||||
INT cmd_date (LPTSTR, LPTSTR);
|
INT cmd_date (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DEL.C */
|
/* Prototypes for DEL.C */
|
||||||
INT cmd_del (LPTSTR, LPTSTR);
|
INT cmd_del (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DIR.C */
|
/* Prototypes for DIR.C */
|
||||||
//int incline(int *line, unsigned flags);
|
//int incline(int *line, unsigned flags);
|
||||||
INT cmd_dir (LPTSTR, LPTSTR);
|
INT cmd_dir (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DIRSTACK.C */
|
/* Prototypes for DIRSTACK.C */
|
||||||
VOID InitDirectoryStack (VOID);
|
VOID InitDirectoryStack (VOID);
|
||||||
VOID DestroyDirectoryStack (VOID);
|
VOID DestroyDirectoryStack (VOID);
|
||||||
INT GetDirectoryStackDepth (VOID);
|
INT GetDirectoryStackDepth (VOID);
|
||||||
|
@ -156,6 +183,10 @@ INT cmd_pushd (LPTSTR, LPTSTR);
|
||||||
INT cmd_popd (LPTSTR, LPTSTR);
|
INT cmd_popd (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for ECHO.C */
|
||||||
|
INT cmd_echo (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for ERROR.C */
|
/* Prototypes for ERROR.C */
|
||||||
VOID ErrorMessage (DWORD, LPTSTR, ...);
|
VOID ErrorMessage (DWORD, LPTSTR, ...);
|
||||||
|
|
||||||
|
@ -175,7 +206,7 @@ VOID error_syntax (LPTSTR);
|
||||||
VOID msg_pause (VOID);
|
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, INT);
|
||||||
INT ShowCompletionMatches (LPTSTR, INT);
|
INT ShowCompletionMatches (LPTSTR, INT);
|
||||||
|
@ -184,28 +215,36 @@ INT ShowCompletionMatches (LPTSTR, INT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for HISTORY.C */
|
/* Prototypes for FOR.C */
|
||||||
|
INT cmd_for (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for GOTO.C */
|
||||||
|
INT cmd_goto (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for HISTORY.C */
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
VOID History (INT, LPTSTR);
|
VOID History (INT, LPTSTR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for INTERNAL.C */
|
/* Prototypes for INTERNAL.C */
|
||||||
VOID InitLastPath (VOID);
|
VOID InitLastPath (VOID);
|
||||||
VOID FreeLastPath (VOID);
|
VOID FreeLastPath (VOID);
|
||||||
int cmd_chdir(char *, char *);
|
INT cmd_chdir (LPTSTR, LPTSTR);
|
||||||
int cmd_mkdir(char *, char *);
|
INT cmd_mkdir (LPTSTR, LPTSTR);
|
||||||
int cmd_rmdir(char *, char *);
|
INT cmd_rmdir (LPTSTR, LPTSTR);
|
||||||
int internal_exit(char *, char *);
|
INT internal_exit (LPTSTR, LPTSTR);
|
||||||
int cmd_rem(char *, char *);
|
INT cmd_rem (LPTSTR, LPTSTR);
|
||||||
int cmd_showcommands(char *, char *);
|
INT cmd_showcommands (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototyped for LABEL.C */
|
/* Prototypes for LABEL.C */
|
||||||
INT cmd_label (LPTSTR, LPTSTR);
|
INT cmd_label (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for LOCALE.C */
|
/* Prototypes for LOCALE.C */
|
||||||
extern TCHAR cDateSeparator;
|
extern TCHAR cDateSeparator;
|
||||||
extern INT nDateFormat;
|
extern INT nDateFormat;
|
||||||
extern TCHAR cTimeSeparator;
|
extern TCHAR cTimeSeparator;
|
||||||
|
@ -226,23 +265,24 @@ VOID freep (LPTSTR *);
|
||||||
LPTSTR stpcpy (LPTSTR, LPTSTR);
|
LPTSTR stpcpy (LPTSTR, LPTSTR);
|
||||||
BOOL IsValidPathName (LPCTSTR);
|
BOOL IsValidPathName (LPCTSTR);
|
||||||
BOOL IsValidFileName (LPCTSTR);
|
BOOL IsValidFileName (LPCTSTR);
|
||||||
|
BOOL IsValidDirectory (LPCTSTR);
|
||||||
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for MOVE.C */
|
/* Prototypes for MOVE.C */
|
||||||
INT cmd_move (LPTSTR, LPTSTR);
|
INT cmd_move (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes from PATH.C */
|
/* Prototypes from PATH.C */
|
||||||
INT cmd_path (LPTSTR, LPTSTR);
|
INT cmd_path (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes from PROMPT.C */
|
/* Prototypes from PROMPT.C */
|
||||||
VOID PrintPrompt (VOID);
|
VOID PrintPrompt (VOID);
|
||||||
INT cmd_prompt (LPTSTR, LPTSTR);
|
INT cmd_prompt (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for REDIR.C */
|
/* Prototypes for REDIR.C */
|
||||||
#define INPUT_REDIRECTION 1
|
#define INPUT_REDIRECTION 1
|
||||||
#define OUTPUT_REDIRECTION 2
|
#define OUTPUT_REDIRECTION 2
|
||||||
#define OUTPUT_APPEND 4
|
#define OUTPUT_APPEND 4
|
||||||
|
@ -251,50 +291,48 @@ INT cmd_prompt (LPTSTR, LPTSTR);
|
||||||
INT GetRedirection (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPINT);
|
INT GetRedirection (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPINT);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for REN.C */
|
/* Prototypes for REN.C */
|
||||||
INT cmd_rename (LPTSTR, LPTSTR);
|
INT cmd_rename (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for SET.C */
|
/* Prototypes for SET.C */
|
||||||
INT cmd_set (LPTSTR, LPTSTR);
|
INT cmd_set (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for TIME.C */
|
/* Prototypes for TIME.C */
|
||||||
INT cmd_time (LPTSTR, LPTSTR);
|
INT cmd_time (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for TYPE.C */
|
/* Prototypes for TITLE.C */
|
||||||
|
INT cmd_title (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for TYPE.C */
|
||||||
INT cmd_type (LPTSTR, LPTSTR);
|
INT cmd_type (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for VER.C */
|
/* Prototypes for VER.C */
|
||||||
VOID ShortVersion (VOID);
|
VOID ShortVersion (VOID);
|
||||||
INT cmd_ver (LPTSTR, LPTSTR);
|
INT cmd_ver (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for VERIFY.C */
|
/* Prototypes for VERIFY.C */
|
||||||
INT cmd_verify (LPTSTR, LPTSTR);
|
INT cmd_verify (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for VOL.C */
|
/* Prototypes for VOL.C */
|
||||||
INT cmd_vol (LPTSTR, LPTSTR);
|
INT cmd_vol (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for WHERE.C */
|
/* Prototypes for WHERE.C */
|
||||||
BOOL find_which (LPCTSTR, LPTSTR);
|
BOOL SearchForExecutable (LPCTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
|
/* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
|
||||||
int cmd_call(char *, char *);
|
|
||||||
int cmd_echo(char *, char *);
|
|
||||||
int cmd_for(char *, char *);
|
|
||||||
int cmd_goto(char *, char *);
|
|
||||||
int cmd_if(char *, char *);
|
int cmd_if(char *, char *);
|
||||||
int cmd_pause(char *, char *);
|
int cmd_pause(char *, char *);
|
||||||
int cmd_shift(char *, char *);
|
int cmd_shift(char *, char *);
|
||||||
|
|
||||||
int cmd_beep(char *, char *);
|
#endif /* _CMD_H_INCLUDED_ */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,14 +88,12 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*
|
*
|
||||||
* 04-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 04-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Fixed input bug. A "line feed" character remined in the keyboard
|
* Fixed input bug. A "line feed" character remained in the keyboard
|
||||||
* input queue when you pressed <RETURN>. This sometimes caused
|
* input queue when you pressed <RETURN>. This sometimes caused
|
||||||
* some very strange effects.
|
* some very strange effects.
|
||||||
* Fixed some command line editing annoyances.
|
* Fixed some command line editing annoyances.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -121,11 +119,15 @@ ClearCommandLine (LPTSTR str, INT maxlen, SHORT orgx, SHORT orgy)
|
||||||
{
|
{
|
||||||
INT count;
|
INT count;
|
||||||
|
|
||||||
goxy (orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
for (count = 0; count < (INT)_tcslen (str); count++)
|
for (count = 0; count < (INT)_tcslen (str); count++)
|
||||||
ConOutChar (_T(' '));
|
ConOutChar (_T(' '));
|
||||||
|
#ifndef __REACTOS__
|
||||||
_tcsnset (str, _T('\0'), maxlen);
|
_tcsnset (str, _T('\0'), maxlen);
|
||||||
goxy (orgx, orgy);
|
#else
|
||||||
|
memset (str, 0, maxlen * sizeof(TCHAR));
|
||||||
|
#endif
|
||||||
|
SetCursorXY (orgx, orgy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,8 +152,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (bEcho)
|
if (bEcho)
|
||||||
PrintPrompt();
|
PrintPrompt();
|
||||||
|
|
||||||
orgx = wherex ();
|
GetCursorXY (&orgx, &orgy);
|
||||||
orgy = wherey ();
|
|
||||||
|
|
||||||
memset (str, 0, maxlen * sizeof (TCHAR));
|
memset (str, 0, maxlen * sizeof (TCHAR));
|
||||||
|
|
||||||
|
@ -171,29 +172,28 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
{
|
{
|
||||||
/* if at end of line */
|
/* if at end of line */
|
||||||
str[current - 1] = _T('\0');
|
str[current - 1] = _T('\0');
|
||||||
if (wherex () != 0)
|
if (GetCursorX () != 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\b \b");
|
ConOutPrintf ("\b \b");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
ConOutChar (_T(' '));
|
ConOutChar (_T(' '));
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (count = current - 1; count < charcount; count++)
|
for (count = current - 1; count < charcount; count++)
|
||||||
str[count] = str[count + 1];
|
str[count] = str[count + 1];
|
||||||
if (wherex () != 0)
|
if (GetCursorX () != 0)
|
||||||
goxy ((SHORT)(wherex () - 1), wherey ());
|
SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ());
|
||||||
else
|
else
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
curx = wherex ();
|
GetCursorXY (&curx, &cury);
|
||||||
cury = wherey ();
|
|
||||||
ConOutPrintf (_T("%s "), &str[current - 1]);
|
ConOutPrintf (_T("%s "), &str[current - 1]);
|
||||||
goxy (curx, cury);
|
SetCursorXY (curx, cury);
|
||||||
}
|
}
|
||||||
charcount--;
|
charcount--;
|
||||||
current--;
|
current--;
|
||||||
|
@ -213,10 +213,9 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
for (count = current; count < charcount; count++)
|
for (count = current; count < charcount; count++)
|
||||||
str[count] = str[count + 1];
|
str[count] = str[count + 1];
|
||||||
charcount--;
|
charcount--;
|
||||||
curx = wherex ();
|
GetCursorXY (&curx, &cury);
|
||||||
cury = wherey ();
|
|
||||||
ConOutPrintf (_T("%s "), &str[current]);
|
ConOutPrintf (_T("%s "), &str[current]);
|
||||||
goxy (curx, cury);
|
SetCursorXY (curx, cury);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -224,7 +223,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
/* goto beginning of string */
|
/* goto beginning of string */
|
||||||
if (current != 0)
|
if (current != 0)
|
||||||
{
|
{
|
||||||
goxy (orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -233,7 +232,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
/* goto end of string */
|
/* goto end of string */
|
||||||
if (current != charcount)
|
if (current != charcount)
|
||||||
{
|
{
|
||||||
goxy (orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
ConOutPrintf (_T("%s"), str);
|
ConOutPrintf (_T("%s"), str);
|
||||||
current = charcount;
|
current = charcount;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +250,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
charcount = _tcslen (str);
|
charcount = _tcslen (str);
|
||||||
current = charcount;
|
current = charcount;
|
||||||
|
|
||||||
goxy(orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
ConOutPrintf (_T("%s"), str);
|
ConOutPrintf (_T("%s"), str);
|
||||||
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
||||||
orgy--;
|
orgy--;
|
||||||
|
@ -262,15 +261,18 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (ShowCompletionMatches (str, charcount))
|
if (ShowCompletionMatches (str, charcount))
|
||||||
{
|
{
|
||||||
PrintPrompt ();
|
PrintPrompt ();
|
||||||
orgx = wherex ();
|
GetCursorXY (&orgx, &orgy);
|
||||||
orgy = wherey ();
|
|
||||||
ConOutPrintf (_T("%s"), str);
|
ConOutPrintf (_T("%s"), str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_4NT_FILENAME_COMPLETION
|
#ifdef FEATURE_4NT_FILENAME_COMPLETION
|
||||||
|
@ -330,15 +332,18 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (current > 0)
|
if (current > 0)
|
||||||
{
|
{
|
||||||
current--;
|
current--;
|
||||||
if (wherex () == 0)
|
if (GetCursorX () == 0)
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
else
|
else
|
||||||
goxy ((SHORT)(wherex () - 1), wherey ());
|
SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Beep (440, 100);
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -347,41 +352,47 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (current != charcount)
|
if (current != charcount)
|
||||||
{
|
{
|
||||||
current++;
|
current++;
|
||||||
if (wherex () == maxx - 1)
|
if (GetCursorX () == maxx - 1)
|
||||||
goxy (0, (SHORT)(wherey () + 1));
|
SetCursorXY (0, (SHORT)(GetCursorY () + 1));
|
||||||
else
|
else
|
||||||
goxy ((SHORT)(wherex () + 1), wherey ());
|
SetCursorXY ((SHORT)(GetCursorX () + 1), GetCursorY ());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
ch = ir.Event.KeyEvent.AsciiChar;
|
||||||
|
if ((ch >= 32) && (charcount != (maxlen - 2)))
|
||||||
|
{
|
||||||
|
#else
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
|
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
|
||||||
#else
|
#else
|
||||||
ch = ir.Event.KeyEvent.uChar.AsciiChar;
|
ch = ir.Event.KeyEvent.uChar.AsciiChar;
|
||||||
#endif
|
#endif /* _UNICODE */
|
||||||
if ((ch >= 32 && ch <= 255) && (charcount != (maxlen - 2)))
|
if ((ch >= 32 && ch <= 255) && (charcount != (maxlen - 2)))
|
||||||
{
|
{
|
||||||
|
#endif /* __REACTOS__ */
|
||||||
/* insert character into string... */
|
/* insert character into string... */
|
||||||
if (bInsert && current != charcount)
|
if (bInsert && current != charcount)
|
||||||
{
|
{
|
||||||
for (count = charcount; count > current; count--)
|
for (count = charcount; count > current; count--)
|
||||||
str[count] = str[count - 1];
|
str[count] = str[count - 1];
|
||||||
str[current++] = ch;
|
str[current++] = ch;
|
||||||
if (wherex () == maxx - 1)
|
if (GetCursorX () == maxx - 1)
|
||||||
{
|
{
|
||||||
curx = 0;
|
curx = 0;
|
||||||
cury = wherey () + 1;
|
cury = GetCursorY () + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
curx = wherex () + 1;
|
GetCursorXY (&curx, &cury);
|
||||||
cury = wherey ();
|
curx++;
|
||||||
}
|
}
|
||||||
ConOutPrintf (_T("%s"), &str[current - 1]);
|
ConOutPrintf (_T("%s"), &str[current - 1]);
|
||||||
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
||||||
cury--;
|
cury--;
|
||||||
goxy (curx, cury);
|
SetCursorXY (curx, cury);
|
||||||
charcount++;
|
charcount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -397,8 +408,11 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
#if 0
|
#if 0
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Beep (440, 100);
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 100);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
* Unicode ready!
|
* Unicode ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -175,6 +173,10 @@ COMMAND cmds[] =
|
||||||
{_T("time"), 0, cmd_time},
|
{_T("time"), 0, cmd_time},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_TITLE
|
||||||
|
{_T("title"), 0, cmd_title},
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TYPE
|
#ifdef INCLUDE_CMD_TYPE
|
||||||
{_T("type"), 0, cmd_type},
|
{_T("type"), 0, cmd_type},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COLOR
|
#ifdef INCLUDE_CMD_COLOR
|
||||||
|
|
|
@ -9,6 +9,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define __REACTOS__
|
||||||
|
|
||||||
|
#ifndef _CONFIG_H_INCLUDED_
|
||||||
|
#define _CONFIG_H_INCLUDED_
|
||||||
|
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif /* __REACTOS__ */
|
||||||
|
|
||||||
|
|
||||||
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
|
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
|
||||||
/*#define DEBUG */
|
/*#define DEBUG */
|
||||||
|
@ -38,22 +47,27 @@
|
||||||
/* Define one of these to select the used locale. */
|
/* Define one of these to select the used locale. */
|
||||||
/* (date and time formats etc.) used in DATE, TIME */
|
/* (date and time formats etc.) used in DATE, TIME */
|
||||||
/* DIR and PROMPT. */
|
/* DIR and PROMPT. */
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
#define LOCALE_DEFAULT
|
||||||
|
#else
|
||||||
#define LOCALE_WINDOWS /* System locale */
|
#define LOCALE_WINDOWS /* System locale */
|
||||||
/* #define LOCALE_GERMAN */ /* German locale */
|
/* #define LOCALE_GERMAN */ /* German locale */
|
||||||
/* #define LOCALE_DEFAULT */ /* United States locale */
|
/* #define LOCALE_DEFAULT */ /* United States locale */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define INCLUDE_CMD_ATTRIB
|
#define INCLUDE_CMD_ATTRIB
|
||||||
//#define INCLUDE_CMD_BREAK
|
/*#define INCLUDE_CMD_BREAK*/
|
||||||
#define INCLUDE_CMD_CHCP
|
#define INCLUDE_CMD_CHCP
|
||||||
#define INCLUDE_CMD_CHDIR
|
#define INCLUDE_CMD_CHDIR
|
||||||
#define INCLUDE_CMD_CLS
|
#define INCLUDE_CMD_CLS
|
||||||
#define INCLUDE_CMD_COLOR
|
#define INCLUDE_CMD_COLOR
|
||||||
#define INCLUDE_CMD_COPY
|
#define INCLUDE_CMD_COPY
|
||||||
//#define INCLUDE_CMD_CTTY
|
/*#define INCLUDE_CMD_CTTY*/
|
||||||
#define INCLUDE_CMD_DATE
|
#define INCLUDE_CMD_DATE
|
||||||
#define INCLUDE_CMD_DEL
|
#define INCLUDE_CMD_DEL
|
||||||
|
#ifndef __REACTOS__
|
||||||
#define INCLUDE_CMD_DIR
|
#define INCLUDE_CMD_DIR
|
||||||
|
#endif
|
||||||
#define INCLUDE_CMD_LABEL
|
#define INCLUDE_CMD_LABEL
|
||||||
#define INCLUDE_CMD_MKDIR
|
#define INCLUDE_CMD_MKDIR
|
||||||
#define INCLUDE_CMD_MOVE
|
#define INCLUDE_CMD_MOVE
|
||||||
|
@ -63,6 +77,7 @@
|
||||||
#define INCLUDE_CMD_RENAME
|
#define INCLUDE_CMD_RENAME
|
||||||
#define INCLUDE_CMD_SET
|
#define INCLUDE_CMD_SET
|
||||||
#define INCLUDE_CMD_TIME
|
#define INCLUDE_CMD_TIME
|
||||||
|
#define INCLUDE_CMD_TITLE
|
||||||
#define INCLUDE_CMD_TYPE
|
#define INCLUDE_CMD_TYPE
|
||||||
#define INCLUDE_CMD_VER
|
#define INCLUDE_CMD_VER
|
||||||
#define INCLUDE_CMD_REM
|
#define INCLUDE_CMD_REM
|
||||||
|
@ -84,3 +99,6 @@ shift
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _CONFIG_H_INCLUDED_ */
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
* started
|
* started
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ VOID DebugPrintf (LPTSTR szFormat, ...)
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szOut, szFormat, arg_ptr);
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
OutputDebugString (szOut);
|
OutputDebugString (szOut);
|
||||||
|
@ -134,7 +135,7 @@ VOID ConOutPrintf (LPTSTR szFormat, ...)
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szOut, szFormat, arg_ptr);
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
||||||
|
@ -165,7 +166,7 @@ VOID ConErrPrintf (LPTSTR szFormat, ...)
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szOut, szFormat, arg_ptr);
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
WriteFile (GetStdHandle (STD_ERROR_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
WriteFile (GetStdHandle (STD_ERROR_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
||||||
|
@ -174,10 +175,7 @@ VOID ConErrPrintf (LPTSTR szFormat, ...)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
VOID SetCursorXY (SHORT x, SHORT y)
|
||||||
* goxy -- move the cursor on the screen.
|
|
||||||
*/
|
|
||||||
VOID goxy (SHORT x, SHORT y)
|
|
||||||
{
|
{
|
||||||
COORD coPos;
|
COORD coPos;
|
||||||
|
|
||||||
|
@ -187,7 +185,18 @@ VOID goxy (SHORT x, SHORT y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHORT wherex (VOID)
|
VOID GetCursorXY (PSHORT x, PSHORT y)
|
||||||
|
{
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||||
|
|
||||||
|
*x = csbi.dwCursorPosition.X;
|
||||||
|
*y = csbi.dwCursorPosition.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SHORT GetCursorX (VOID)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
@ -197,7 +206,7 @@ SHORT wherex (VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHORT wherey (VOID)
|
SHORT GetCursorY (VOID)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
@ -229,45 +238,3 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible)
|
||||||
|
|
||||||
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID InitializePageOut (VOID)
|
|
||||||
{
|
|
||||||
sLineCount = 0;
|
|
||||||
|
|
||||||
if (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == FILE_TYPE_CHAR)
|
|
||||||
{
|
|
||||||
bPageable = TRUE;
|
|
||||||
GetScreenSize (NULL, &sMaxLines);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bPageable = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID TerminatePageOut (VOID)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int LinePageOut (LPTSTR szLine)
|
|
||||||
{
|
|
||||||
ConOutPuts (szLine);
|
|
||||||
|
|
||||||
if (bPageable)
|
|
||||||
{
|
|
||||||
sLineCount++;
|
|
||||||
if (sLineCount >= sMaxLines)
|
|
||||||
{
|
|
||||||
sLineCount = 0;
|
|
||||||
cmd_pause ("", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
* Replaced CRT io functions by Win32 io functions.
|
* Replaced CRT io functions by Win32 io functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COPY
|
#ifdef INCLUDE_CMD_COPY
|
||||||
|
@ -51,8 +49,8 @@ typedef struct tagFILES
|
||||||
|
|
||||||
|
|
||||||
static BOOL DoSwitches (LPTSTR, LPDWORD);
|
static BOOL DoSwitches (LPTSTR, LPDWORD);
|
||||||
static BOOL AddFile (LPFILES, char *, int *, int *, unsigned *);
|
static BOOL AddFile (LPFILES, char *, int *, int *, LPDWORD);
|
||||||
static BOOL AddFiles (LPFILES, char *, int *, int *, int *, unsigned *);
|
static BOOL AddFiles (LPFILES, char *, int *, int *, int *, LPDWORD);
|
||||||
static BOOL GetDestination (LPFILES, LPFILES);
|
static BOOL GetDestination (LPFILES, LPFILES);
|
||||||
static INT ParseCommand (LPFILES, int, char **, LPDWORD);
|
static INT ParseCommand (LPFILES, int, char **, LPDWORD);
|
||||||
static VOID DeleteFileList (LPFILES);
|
static VOID DeleteFileList (LPFILES);
|
||||||
|
@ -60,7 +58,8 @@ static INT Overwrite (LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL IsDirectory (LPTSTR fn)
|
static BOOL
|
||||||
|
IsDirectory (LPTSTR fn)
|
||||||
{
|
{
|
||||||
if (!IsValidFileName (fn))
|
if (!IsValidFileName (fn))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -68,7 +67,8 @@ static BOOL IsDirectory (LPTSTR fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
static BOOL
|
||||||
|
DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
||||||
{
|
{
|
||||||
if (!_tcsicmp (arg, _T("/-Y")))
|
if (!_tcsicmp (arg, _T("/-Y")))
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,7 @@ static BOOL DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
AddFile (LPFILES f, char *arg, int *source, int *dest, unsigned *flags)
|
AddFile (LPFILES f, char *arg, int *source, int *dest, LPDWORD flags)
|
||||||
{
|
{
|
||||||
if (*dest)
|
if (*dest)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ AddFile (LPFILES f, char *arg, int *source, int *dest, unsigned *flags)
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
AddFiles (LPFILES f, char *arg, int *source, int *dest,
|
AddFiles (LPFILES f, char *arg, int *source, int *dest,
|
||||||
int *count, unsigned *flags)
|
int *count, LPDWORD flags)
|
||||||
{
|
{
|
||||||
char t[128];
|
char t[128];
|
||||||
int j;
|
int j;
|
||||||
|
@ -202,7 +202,8 @@ AddFiles (LPFILES f, char *arg, int *source, int *dest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL GetDestination (LPFILES f, LPFILES dest)
|
static BOOL
|
||||||
|
GetDestination (LPFILES f, LPFILES dest)
|
||||||
{
|
{
|
||||||
LPFILES p;
|
LPFILES p;
|
||||||
LPFILES start = f;
|
LPFILES start = f;
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
* Fixed date input bug.
|
* Fixed date input bug.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DATE
|
#ifdef INCLUDE_CMD_DATE
|
||||||
|
@ -52,7 +50,7 @@ static WORD awMonths[2][13] =
|
||||||
static VOID
|
static VOID
|
||||||
PrintDate (VOID)
|
PrintDate (VOID)
|
||||||
{
|
{
|
||||||
#if 0
|
#ifdef __REACTOS__
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
|
|
||||||
GetLocalTime (&st);
|
GetLocalTime (&st);
|
||||||
|
@ -75,12 +73,13 @@ PrintDate (VOID)
|
||||||
aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay);
|
aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
TCHAR szDate[32];
|
TCHAR szDate[32];
|
||||||
|
|
||||||
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
|
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
|
||||||
szDate, sizeof (szDate));
|
szDate, sizeof (szDate));
|
||||||
ConOutPrintf (_T("Current date is: %s\n"), szDate);
|
ConOutPrintf (_T("Current date is: %s\n"), szDate);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +194,7 @@ ParseDate (LPTSTR s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if only entered two digits:
|
/* if only entered two digits: */
|
||||||
/* assume 2000's if value less than 80 */
|
/* assume 2000's if value less than 80 */
|
||||||
/* assume 1900's if value greater or equal 80 */
|
/* assume 1900's if value greater or equal 80 */
|
||||||
if (d.wYear <= 99)
|
if (d.wYear <= 99)
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
* First working version.
|
* First working version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DEL
|
#ifdef INCLUDE_CMD_DEL
|
||||||
|
@ -35,6 +33,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -97,6 +96,8 @@ static INT Prompt (LPTSTR str)
|
||||||
else if (*p == _T('\03'))
|
else if (*p == _T('\03'))
|
||||||
return PROMPT_BREAK;
|
return PROMPT_BREAK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return PROMPT_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,10 +106,11 @@
|
||||||
*
|
*
|
||||||
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Redirection safe!
|
* Redirection safe!
|
||||||
|
*
|
||||||
|
* 01-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Replaced all runtime io functions by their Win32 counterparts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DIR
|
#ifdef INCLUDE_CMD_DIR
|
||||||
|
@ -119,15 +120,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <direct.h>
|
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
/* useful macro */
|
|
||||||
#define MEM_ERR error_out_of_memory(); return 1;
|
|
||||||
|
|
||||||
|
|
||||||
/* flag definitions */
|
/* flag definitions */
|
||||||
/* Changed hex to decimal, hex wouldn't work
|
/* Changed hex to decimal, hex wouldn't work
|
||||||
* if > 8, Rob Lake 06/17/98.
|
* if > 8, Rob Lake 06/17/98.
|
||||||
|
@ -148,9 +143,9 @@ enum
|
||||||
|
|
||||||
/* Globally save the # of dirs, files and bytes,
|
/* Globally save the # of dirs, files and bytes,
|
||||||
* probabaly later pass them to functions. Rob Lake */
|
* probabaly later pass them to functions. Rob Lake */
|
||||||
long recurse_dir_cnt;
|
static ULONG recurse_dir_cnt;
|
||||||
long recurse_file_cnt;
|
static ULONG recurse_file_cnt;
|
||||||
ULARGE_INTEGER recurse_bytes;
|
static ULARGE_INTEGER recurse_bytes;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -161,7 +156,6 @@ ULARGE_INTEGER recurse_bytes;
|
||||||
*/
|
*/
|
||||||
static VOID Help (VOID)
|
static VOID Help (VOID)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
ConOutPuts (_T("Displays a list of files and subdirectories in a directory.\n"
|
ConOutPuts (_T("Displays a list of files and subdirectories in a directory.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"DIR [drive:][path][filename] [/A] [/B] [/L] [/N] [/S] [/P] [/W] [/4]\n"
|
"DIR [drive:][path][filename] [/A] [/B] [/L] [/N] [/S] [/P] [/W] [/4]\n"
|
||||||
|
@ -183,43 +177,18 @@ static VOID Help (VOID)
|
||||||
"of the - (hyphen) can turn off defined swtiches. Ex. /-W would\n"
|
"of the - (hyphen) can turn off defined swtiches. Ex. /-W would\n"
|
||||||
"turn off printing in wide format.\n"
|
"turn off printing in wide format.\n"
|
||||||
));
|
));
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
InitializePageOut ();
|
|
||||||
LinePageOut (_T("Displays a list of files and subdirectories in a directory."));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T("DIR [drive:][path][filename] [/A] [/B] [/L] [/N] [/S] [/P] [/W] [/4]"));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T(" [drive:][path][filename]"));
|
|
||||||
LinePageOut (_T(" Specifies drive, directory, and/or files to list."));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T(" /A Displays files with HIDDEN SYSTEM attributes"));
|
|
||||||
LinePageOut (_T(" default is ARCHIVE and READ ONLY"));
|
|
||||||
LinePageOut (_T(" /B Uses bare format (no heading information or summary)."));
|
|
||||||
LinePageOut (_T(" /L Uses lowercase."));
|
|
||||||
LinePageOut (_T(" /N New long list format where filenames are on the far right."));
|
|
||||||
LinePageOut (_T(" /S Displays files in specified directory and all subdirectories"));
|
|
||||||
LinePageOut (_T(" /P Pauses after each screen full"));
|
|
||||||
LinePageOut (_T(" /W Prints in wide format"));
|
|
||||||
LinePageOut (_T(" /4 Display four digit years."));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T("Switches may be present in the DIRCMD environment variable. Use"));
|
|
||||||
LinePageOut (_T("of the - (hyphen) can turn off defined swtiches. Ex. /-W would"));
|
|
||||||
LinePageOut (_T("turn off printing in wide format."));
|
|
||||||
TerminatePageOut ();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dir_read_param
|
* DirReadParam
|
||||||
*
|
*
|
||||||
* read the parameters from the command line
|
* read the parameters from the command line
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL
|
||||||
DirReadParam (char *line, char **param, LPDWORD lpFlags)
|
DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
|
||||||
{
|
{
|
||||||
int slash = 0;
|
INT slash = 0;
|
||||||
|
|
||||||
if (!line)
|
if (!line)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -340,50 +309,35 @@ DirReadParam (char *line, char **param, LPDWORD lpFlags)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* extend_file
|
* ExtendFilespec
|
||||||
*
|
*
|
||||||
* extend the filespec, possibly adding wildcards
|
* extend the filespec, possibly adding wildcards
|
||||||
*/
|
*/
|
||||||
void extend_file (char **file)
|
static VOID
|
||||||
|
ExtendFilespec (LPTSTR file)
|
||||||
{
|
{
|
||||||
LPTSTR tmp;
|
if (!file)
|
||||||
|
|
||||||
if (!*file)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* if no file spec, change to "*.*" */
|
/* if no file spec, change to "*.*" */
|
||||||
if (!**file)
|
if (*file == _T('\0'))
|
||||||
{
|
{
|
||||||
free (*file);
|
_tcscpy (file, _T("*.*"));
|
||||||
*file = _tcsdup (_T("*.*"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if starts with . add * in front */
|
/* if starts with . add * in front */
|
||||||
if (**file == _T('.'))
|
if (*file == _T('.'))
|
||||||
{
|
{
|
||||||
tmp = malloc ((_tcslen (*file) + 2) * sizeof(TCHAR));
|
memmove (&file[1], &file[0], (_tcslen (file) + 1) * sizeof(TCHAR));
|
||||||
if (tmp)
|
file[0] = _T('*');
|
||||||
{
|
|
||||||
*tmp = _T('*');
|
|
||||||
_tcscpy (&tmp[1], *file);
|
|
||||||
}
|
|
||||||
free (*file);
|
|
||||||
*file = tmp;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if no . add .* */
|
/* if no . add .* */
|
||||||
if (!_tcschr (*file, _T('.')))
|
if (!_tcschr (file, _T('.')))
|
||||||
{
|
{
|
||||||
tmp = malloc ((_tcslen (*file) + 3) * sizeof(TCHAR));
|
_tcscat (file, _T(".*"));
|
||||||
if (tmp)
|
|
||||||
{
|
|
||||||
_tcscpy (tmp, *file);
|
|
||||||
_tcscat (tmp, _T(".*"));
|
|
||||||
}
|
|
||||||
free (*file);
|
|
||||||
*file = tmp;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,65 +348,55 @@ void extend_file (char **file)
|
||||||
*
|
*
|
||||||
* split the pathspec into drive, directory, and filespec
|
* split the pathspec into drive, directory, and filespec
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
DirParsePathspec (char *pathspec, int *drive, char **dir, char **file)
|
DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec)
|
||||||
{
|
{
|
||||||
TCHAR orig_dir[MAX_PATH];
|
TCHAR szOrigPath[MAX_PATH];
|
||||||
LPTSTR start;
|
LPTSTR start;
|
||||||
LPTSTR tmp;
|
LPTSTR tmp;
|
||||||
INT i;
|
INT i;
|
||||||
INT wildcards = 0;
|
BOOL bWildcards = FALSE;
|
||||||
|
|
||||||
|
GetCurrentDirectory (MAX_PATH, szOrigPath);
|
||||||
|
|
||||||
/* get the drive and change to it */
|
/* get the drive and change to it */
|
||||||
if (pathspec[1] == _T(':'))
|
if (szPathspec[1] == _T(':'))
|
||||||
{
|
{
|
||||||
*drive = _totupper (pathspec[0]) - _T('@');
|
TCHAR szRootPath[] = _T("A:");
|
||||||
start = pathspec + 2;
|
|
||||||
_chdrive (*drive);
|
szRootPath[0] = szPathspec[0];
|
||||||
|
start = szPathspec + 2;
|
||||||
|
SetCurrentDirectory (szRootPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*drive = _getdrive ();
|
start = szPathspec;
|
||||||
start = pathspec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCurrentDirectory (MAX_PATH, orig_dir);
|
|
||||||
|
|
||||||
/* check for wildcards */
|
/* check for wildcards */
|
||||||
for (i = 0; pathspec[i]; i++)
|
for (i = 0; szPathspec[i]; i++)
|
||||||
if (pathspec[i] == _T('*') || pathspec[i] == _T('?'))
|
{
|
||||||
wildcards = 1;
|
if (szPathspec[i] == _T('*') || szPathspec[i] == _T('?'))
|
||||||
|
bWildcards = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if this spec is a directory */
|
/* check if this spec is a directory */
|
||||||
if (!wildcards)
|
if (!bWildcards)
|
||||||
{
|
{
|
||||||
if (chdir(pathspec) == 0)
|
if (SetCurrentDirectory (szPathspec))
|
||||||
{
|
{
|
||||||
*file = _tcsdup (_T("*.*"));
|
_tcscpy (szFilespec, _T("*.*"));
|
||||||
if (!*file)
|
|
||||||
|
if (!GetCurrentDirectory (MAX_PATH, szPath))
|
||||||
{
|
{
|
||||||
MEM_ERR
|
szFilespec[0] = _T('\0');
|
||||||
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
error_out_of_memory();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = getcwd (NULL, MAX_PATH);
|
SetCurrentDirectory (szOrigPath);
|
||||||
if (!tmp)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
|
|
||||||
*dir = _tcsdup (&tmp[2]);
|
|
||||||
free (tmp);
|
|
||||||
if (!*dir)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
|
|
||||||
chdir (orig_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,69 +407,50 @@ DirParsePathspec (char *pathspec, int *drive, char **dir, char **file)
|
||||||
/* if no path is specified */
|
/* if no path is specified */
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
*file = _tcsdup (start);
|
_tcscpy (szFilespec, start);
|
||||||
extend_file (file);
|
ExtendFilespec (szFilespec);
|
||||||
if (!*file)
|
|
||||||
|
if (!GetCurrentDirectory (MAX_PATH, szPath))
|
||||||
{
|
{
|
||||||
MEM_ERR
|
szFilespec[0] = _T('\0');
|
||||||
}
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
error_out_of_memory();
|
||||||
tmp = getcwd (NULL, _MAX_PATH);
|
return 1;
|
||||||
if (!tmp)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
*dir = _tcsdup (&tmp[2]);
|
|
||||||
free(tmp);
|
|
||||||
if (!*dir)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCurrentDirectory (szOrigPath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the filename */
|
/* get the filename */
|
||||||
*file = _tcsdup (tmp + 1);
|
_tcscpy (szFilespec, tmp+1);
|
||||||
extend_file (file);
|
ExtendFilespec (szFilespec);
|
||||||
if (!*file)
|
|
||||||
{
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
|
|
||||||
*tmp = 0;
|
*tmp = _T('\0');
|
||||||
|
|
||||||
/* change to this directory and get its full name */
|
/* change to this directory and get its full name */
|
||||||
if (chdir (start) < 0)
|
if (!SetCurrentDirectory (start))
|
||||||
{
|
{
|
||||||
error_path_not_found ();
|
|
||||||
*tmp = _T('\\');
|
*tmp = _T('\\');
|
||||||
free (*file);
|
szFilespec[0] = _T('\0');
|
||||||
chdir (orig_dir);
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
error_path_not_found ();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = getcwd (NULL, _MAX_PATH);
|
if (!GetCurrentDirectory (MAX_PATH, szPath))
|
||||||
if (!tmp)
|
|
||||||
{
|
{
|
||||||
free (*file);
|
*tmp = _T('\\');
|
||||||
MEM_ERR
|
szFilespec[0] = _T('\0');
|
||||||
}
|
SetCurrentDirectory (szOrigPath);
|
||||||
*dir = _tcsdup (&tmp[2]);
|
error_out_of_memory ();
|
||||||
free(tmp);
|
return 1;
|
||||||
if (!*dir)
|
|
||||||
{
|
|
||||||
free(*file);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*tmp = _T('\\');
|
*tmp = _T('\\');
|
||||||
|
|
||||||
chdir(orig_dir);
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,16 +475,16 @@ Pause (VOID)
|
||||||
* increment our line if paginating, display message at end of screen
|
* increment our line if paginating, display message at end of screen
|
||||||
*/
|
*/
|
||||||
static INT
|
static INT
|
||||||
incline (int *line, DWORD dwFlags)
|
IncLine (LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
if (!(dwFlags & DIR_PAGE))
|
if (!(dwFlags & DIR_PAGE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
(*line)++;
|
(*pLine)++;
|
||||||
|
|
||||||
if (*line >= (int)maxy - 2)
|
if (*pLine >= (int)maxy - 2)
|
||||||
{
|
{
|
||||||
*line = 0;
|
*pLine = 0;
|
||||||
return Pause ();
|
return Pause ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +498,7 @@ incline (int *line, DWORD dwFlags)
|
||||||
* print the header for the dir command
|
* print the header for the dir command
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL
|
||||||
PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
TCHAR szRootName[] = _T("A:\\");
|
TCHAR szRootName[] = _T("A:\\");
|
||||||
TCHAR szVolName[80];
|
TCHAR szVolName[80];
|
||||||
|
@ -583,7 +508,7 @@ PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* get the media ID of the drive */
|
/* get the media ID of the drive */
|
||||||
szRootName[0] = drive + _T('@');
|
szRootName[0] = szPath[0];
|
||||||
if (!GetVolumeInformation (szRootName, szVolName, 80, &dwSerialNr,
|
if (!GetVolumeInformation (szRootName, szVolName, 80, &dwSerialNr,
|
||||||
NULL, NULL, NULL, 0))
|
NULL, NULL, NULL, 0))
|
||||||
{
|
{
|
||||||
|
@ -599,13 +524,13 @@ PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
||||||
else
|
else
|
||||||
ConOutPrintf (_T(" has no label\n"));
|
ConOutPrintf (_T(" has no label\n"));
|
||||||
|
|
||||||
if (incline (line, dwFlags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* print the volume serial number if the return was successful */
|
/* print the volume serial number if the return was successful */
|
||||||
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
||||||
HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
||||||
if (incline (line, dwFlags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -618,7 +543,7 @@ PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
||||||
* insert commas into a number
|
* insert commas into a number
|
||||||
*/
|
*/
|
||||||
static INT
|
static INT
|
||||||
ConvertLong (LONG num, LPTSTR des, INT len)
|
ConvertULong (ULONG num, LPTSTR des, INT len)
|
||||||
{
|
{
|
||||||
TCHAR temp[32];
|
TCHAR temp[32];
|
||||||
INT c = 0;
|
INT c = 0;
|
||||||
|
@ -690,16 +615,17 @@ PrintFileDateTime (LPSYSTEMTIME dt, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
case 0: /* mmddyy */
|
case 0: /* mmddyy */
|
||||||
default:
|
default:
|
||||||
ConOutPrintf ("%.2d%c%.2d%c%d", dt->wMonth, cDateSeparator, dt->wDay, cDateSeparator, wYear);
|
ConOutPrintf (_T("%.2d%c%.2d%c%d"),
|
||||||
|
dt->wMonth, cDateSeparator, dt->wDay, cDateSeparator, wYear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* ddmmyy */
|
case 1: /* ddmmyy */
|
||||||
ConOutPrintf ("%.2d%c%.2d%c%d",
|
ConOutPrintf (_T("%.2d%c%.2d%c%d"),
|
||||||
dt->wDay, cDateSeparator, dt->wMonth, cDateSeparator, wYear);
|
dt->wDay, cDateSeparator, dt->wMonth, cDateSeparator, wYear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* yymmdd */
|
case 2: /* yymmdd */
|
||||||
ConOutPrintf ("%d%c%.2d%c%.2d",
|
ConOutPrintf (_T("%d%c%.2d%c%.2d"),
|
||||||
wYear, cDateSeparator, dt->wMonth, cDateSeparator, dt->wDay);
|
wYear, cDateSeparator, dt->wMonth, cDateSeparator, dt->wDay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -708,14 +634,14 @@ PrintFileDateTime (LPSYSTEMTIME dt, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
case 0: /* 12 hour format */
|
case 0: /* 12 hour format */
|
||||||
default:
|
default:
|
||||||
ConOutPrintf (" %2d%c%.2u%c",
|
ConOutPrintf (_T(" %2d%c%.2u%c"),
|
||||||
(dt->wHour == 0 ? 12 : (dt->wHour <= 12 ? dt->wHour : dt->wHour - 12)),
|
(dt->wHour == 0 ? 12 : (dt->wHour <= 12 ? dt->wHour : dt->wHour - 12)),
|
||||||
cTimeSeparator,
|
cTimeSeparator,
|
||||||
dt->wMinute, (dt->wHour <= 11 ? 'a' : 'p'));
|
dt->wMinute, (dt->wHour <= 11 ? 'a' : 'p'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* 24 hour format */
|
case 1: /* 24 hour format */
|
||||||
ConOutPrintf (" %2d%c%.2u",
|
ConOutPrintf (_T(" %2d%c%.2u"),
|
||||||
dt->wHour, cTimeSeparator, dt->wMinute);
|
dt->wHour, cTimeSeparator, dt->wMinute);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -729,33 +655,33 @@ PrintFileDateTime (LPSYSTEMTIME dt, DWORD dwFlags)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static INT
|
static INT
|
||||||
PrintSummary (int drive, long files, long dirs, ULARGE_INTEGER bytes,
|
PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes,
|
||||||
DWORD flags, int *line)
|
LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
TCHAR buffer[64];
|
TCHAR buffer[64];
|
||||||
|
|
||||||
if (flags & DIR_BARE)
|
if (dwFlags & DIR_BARE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* print number of files and bytes */
|
/* print number of files and bytes */
|
||||||
ConvertLong (files, buffer, sizeof(buffer));
|
ConvertULong (ulFiles, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %6s File%c"),
|
ConOutPrintf (_T(" %6s File%c"),
|
||||||
buffer, files == 1 ? _T(' ') : _T('s'));
|
buffer, ulFiles == 1 ? _T(' ') : _T('s'));
|
||||||
|
|
||||||
ConvertULargeInteger (bytes, buffer, sizeof(buffer));
|
ConvertULargeInteger (bytes, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %15s byte%c\n"),
|
ConOutPrintf (_T(" %15s byte%c\n"),
|
||||||
buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s'));
|
buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s'));
|
||||||
|
|
||||||
if (incline (line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* print number of dirs and bytes free */
|
/* print number of dirs and bytes free */
|
||||||
ConvertLong (dirs, buffer, sizeof(buffer));
|
ConvertULong (ulDirs, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %6s Dir%c"),
|
ConOutPrintf (_T(" %6s Dir%c"),
|
||||||
buffer, files == 1 ? _T(' ') : _T('s'));
|
buffer, ulDirs == 1 ? _T(' ') : _T('s'));
|
||||||
|
|
||||||
|
|
||||||
if (!(flags & DIR_RECURSE))
|
if (!(dwFlags & DIR_RECURSE))
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER uliFree;
|
ULARGE_INTEGER uliFree;
|
||||||
TCHAR szRoot[] = _T("A:\\");
|
TCHAR szRoot[] = _T("A:\\");
|
||||||
|
@ -764,14 +690,14 @@ PrintSummary (int drive, long files, long dirs, ULARGE_INTEGER bytes,
|
||||||
DWORD dwFreeCl;
|
DWORD dwFreeCl;
|
||||||
DWORD dwTotCl;
|
DWORD dwTotCl;
|
||||||
|
|
||||||
szRoot[0] = drive + _T('@');
|
szRoot[0] = szPath[0];
|
||||||
GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl);
|
GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl);
|
||||||
uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
|
uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
|
||||||
ConvertULargeInteger (uliFree, buffer, sizeof(buffer));
|
ConvertULargeInteger (uliFree, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %15s bytes free\n"), buffer);
|
ConOutPrintf (_T(" %15s bytes free\n"), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incline (line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -783,39 +709,37 @@ PrintSummary (int drive, long files, long dirs, ULARGE_INTEGER bytes,
|
||||||
*
|
*
|
||||||
* list the files in the directory
|
* list the files in the directory
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
dir_list (int drive, char *directory, char *filespec, int *line,
|
DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
DWORD flags)
|
|
||||||
{
|
{
|
||||||
char pathspec[_MAX_PATH],
|
TCHAR szFullPath[MAX_PATH];
|
||||||
*ext,
|
|
||||||
buffer[32];
|
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
ULARGE_INTEGER bytecount;
|
ULARGE_INTEGER bytecount;
|
||||||
long filecount = 0,
|
|
||||||
dircount = 0;
|
|
||||||
int count;
|
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
SYSTEMTIME dt;
|
SYSTEMTIME dt;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
TCHAR buffer[32];
|
||||||
|
ULONG filecount = 0;
|
||||||
|
ULONG dircount = 0;
|
||||||
|
INT count;
|
||||||
|
|
||||||
bytecount.QuadPart = 0;
|
bytecount.QuadPart = 0;
|
||||||
|
|
||||||
if (directory[strlen(directory) - 1] == '\\')
|
_tcscpy (szFullPath, szPath);
|
||||||
wsprintf(pathspec, "%c:%s%s", drive + '@', directory, filespec);
|
if (szFullPath[_tcslen(szFullPath) - 1] != _T('\\'))
|
||||||
else
|
_tcscat (szFullPath, _T("\\"));
|
||||||
wsprintf(pathspec, "%c:%s\\%s", drive + '@', directory, filespec);
|
_tcscat (szFullPath, szFilespec);
|
||||||
|
|
||||||
hFile = FindFirstFile (pathspec, &file);
|
hFile = FindFirstFile (szFullPath, &file);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/* Don't want to print anything if scanning recursively
|
/* Don't want to print anything if scanning recursively
|
||||||
* for a file. RL
|
* for a file. RL
|
||||||
*/
|
*/
|
||||||
if ((flags & DIR_RECURSE) == 0)
|
if ((dwFlags & DIR_RECURSE) == 0)
|
||||||
{
|
{
|
||||||
error_file_not_found();
|
error_file_not_found ();
|
||||||
incline(line, flags);
|
IncLine (pLine, dwFlags);
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -829,13 +753,13 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
* with nothing else
|
* with nothing else
|
||||||
* Rob Lake 06/13/98
|
* Rob Lake 06/13/98
|
||||||
*/
|
*/
|
||||||
if ((flags & DIR_BARE) == 0)
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf (" Directory of %c:%s\n", drive + '@', directory);
|
ConOutPrintf (_T(" Directory of %s\n"), szPath);
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,22 +769,23 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* next file, if user doesn't want all files */
|
/* next file, if user doesn't want all files */
|
||||||
if (!(flags & DIR_ALL) &&
|
if (!(dwFlags & DIR_ALL) &&
|
||||||
((file.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
|
((file.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
|
||||||
(file.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)))
|
(file.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* begin Rob Lake */
|
if (dwFlags & DIR_LWR)
|
||||||
if (flags & DIR_LWR)
|
|
||||||
{
|
{
|
||||||
strlwr(file.cAlternateFileName);
|
_tcslwr (file.cAlternateFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DIR_WIDE && (flags & DIR_BARE) == 0)
|
if (dwFlags & DIR_WIDE && (dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
|
ULARGE_INTEGER uliSize;
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (file.cAlternateFileName[0] == '\0')
|
if (file.cAlternateFileName[0] == _T('\0'))
|
||||||
wsprintf (buffer, _T("[%s]"), file.cFileName);
|
wsprintf (buffer, _T("[%s]"), file.cFileName);
|
||||||
else
|
else
|
||||||
wsprintf (buffer, _T("[%s]"), file.cAlternateFileName);
|
wsprintf (buffer, _T("[%s]"), file.cAlternateFileName);
|
||||||
|
@ -868,79 +793,82 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (file.cAlternateFileName[0] == '\0')
|
if (file.cAlternateFileName[0] == _T('\0'))
|
||||||
wsprintf (buffer, _T("%s"), file.cFileName);
|
wsprintf (buffer, _T("%s"), file.cFileName);
|
||||||
else
|
else
|
||||||
wsprintf (buffer, _T("%s"), file.cAlternateFileName);
|
wsprintf (buffer, _T("%s"), file.cAlternateFileName);
|
||||||
filecount++;
|
filecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConOutPrintf (_T("%-15s"), buffer);
|
ConOutPrintf (_T("%-15s"), buffer);
|
||||||
count++;
|
count++;
|
||||||
if (count == 5)
|
if (count == 5)
|
||||||
{
|
{
|
||||||
/* output 5 columns */
|
/* output 5 columns */
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: this is buggy - now overflow check */
|
uliSize.u.LowPart += file.nFileSizeLow;
|
||||||
bytecount.LowPart += file.nFileSizeLow;
|
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||||
bytecount.HighPart += file.nFileSizeHigh;
|
bytecount.QuadPart += uliSize.QuadPart;
|
||||||
|
|
||||||
/* next block 06/17/98 */
|
|
||||||
}
|
}
|
||||||
else if (flags & DIR_BARE)
|
else if (dwFlags & DIR_BARE)
|
||||||
{
|
{
|
||||||
if (strcmp(file.cFileName, ".") == 0 ||
|
ULARGE_INTEGER uliSize;
|
||||||
strcmp(file.cFileName, "..") == 0)
|
|
||||||
|
if (_tcscmp (file.cFileName, _T(".")) == 0 ||
|
||||||
|
_tcscmp (file.cFileName, _T("..")) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (flags & DIR_RECURSE)
|
if (dwFlags & DIR_RECURSE)
|
||||||
{
|
{
|
||||||
TCHAR dir[MAX_PATH];
|
TCHAR dir[MAX_PATH];
|
||||||
wsprintf (dir, _T("%c:%s\\"), drive + _T('@'), directory);
|
|
||||||
if (flags & DIR_LWR)
|
_tcscpy (dir, szPath);
|
||||||
strlwr(dir);
|
_tcscat (dir, _T("\\"));
|
||||||
|
if (dwFlags & DIR_LWR)
|
||||||
|
_tcslwr (dir);
|
||||||
ConOutPrintf (dir);
|
ConOutPrintf (dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConOutPrintf (_T("%-13s\n"), file.cFileName);
|
ConOutPrintf (_T("%-13s\n"), file.cFileName);
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
dircount++;
|
dircount++;
|
||||||
else
|
else
|
||||||
filecount++;
|
filecount++;
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* FIXME: this is buggy - no overflow check */
|
uliSize.u.LowPart += file.nFileSizeLow;
|
||||||
bytecount.LowPart += file.nFileSizeLow;
|
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||||
bytecount.HighPart += file.nFileSizeHigh;
|
bytecount.QuadPart += uliSize.QuadPart;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* end Rob Lake */
|
if (dwFlags & DIR_NEW)
|
||||||
if (flags & DIR_NEW)
|
|
||||||
{
|
{
|
||||||
/* print file date and time */
|
/* print file date and time */
|
||||||
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
||||||
{
|
{
|
||||||
FileTimeToSystemTime (&ft, &dt);
|
FileTimeToSystemTime (&ft, &dt);
|
||||||
PrintFileDateTime (&dt, flags);
|
PrintFileDateTime (&dt, dwFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print file size */
|
/* print file size */
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
ConOutPrintf (" <DIR> ");
|
ConOutPrintf (_T(" <DIR> "));
|
||||||
dircount++;
|
dircount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER uliSize;
|
ULARGE_INTEGER uliSize;
|
||||||
|
|
||||||
uliSize.LowPart = file.nFileSizeLow;
|
uliSize.u.LowPart = file.nFileSizeLow;
|
||||||
uliSize.HighPart = file.nFileSizeHigh;
|
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||||
|
|
||||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %20s"), buffer);
|
ConOutPrintf (_T(" %20s"), buffer);
|
||||||
|
@ -950,31 +878,35 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print long filename */
|
/* print long filename */
|
||||||
ConOutPrintf (" %s\n", file.cFileName);
|
ConOutPrintf (_T(" %s\n"), file.cFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (file.cFileName[0] == '.')
|
if (file.cFileName[0] == _T('.'))
|
||||||
ConOutPrintf ("%-13s ", file.cFileName);
|
ConOutPrintf (_T("%-13s "), file.cFileName);
|
||||||
else if (file.cAlternateFileName[0] == '\0')
|
else if (file.cAlternateFileName[0] == _T('\0'))
|
||||||
{
|
{
|
||||||
char szShortName[13];
|
TCHAR szShortName[13];
|
||||||
strncpy (szShortName, file.cFileName, 13);
|
LPTSTR ext;
|
||||||
ext = strchr(szShortName, '.');
|
|
||||||
|
_tcsncpy (szShortName, file.cFileName, 13);
|
||||||
|
ext = _tcschr (szShortName, _T('.'));
|
||||||
if (!ext)
|
if (!ext)
|
||||||
ext = "";
|
ext = _T("");
|
||||||
else
|
else
|
||||||
*ext++ = 0;
|
*ext++ = _T('\0');
|
||||||
ConOutPrintf ("%-8s %-3s ", szShortName, ext);
|
ConOutPrintf (_T("%-8s %-3s "), szShortName, ext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ext = strchr(file.cAlternateFileName, '.');
|
LPTSTR ext;
|
||||||
|
|
||||||
|
ext = _tcschr (file.cAlternateFileName, _T('.'));
|
||||||
if (!ext)
|
if (!ext)
|
||||||
ext = "";
|
ext = _T("");
|
||||||
else
|
else
|
||||||
*ext++ = 0;
|
*ext++ = _T('\0');
|
||||||
ConOutPrintf ("%-8s %-3s ", file.cAlternateFileName, ext);
|
ConOutPrintf (_T("%-8s %-3s "), file.cAlternateFileName, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print file size */
|
/* print file size */
|
||||||
|
@ -987,8 +919,8 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER uliSize;
|
ULARGE_INTEGER uliSize;
|
||||||
|
|
||||||
uliSize.LowPart = file.nFileSizeLow;
|
uliSize.u.LowPart = file.nFileSizeLow;
|
||||||
uliSize.HighPart = file.nFileSizeHigh;
|
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||||
|
|
||||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %10s "), buffer);
|
ConOutPrintf (_T(" %10s "), buffer);
|
||||||
|
@ -1001,27 +933,26 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
||||||
{
|
{
|
||||||
FileTimeToSystemTime (&ft, &dt);
|
FileTimeToSystemTime (&ft, &dt);
|
||||||
PrintFileDateTime (&dt, flags);
|
PrintFileDateTime (&dt, dwFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print long filename */
|
/* print long filename */
|
||||||
ConOutPrintf (" %s\n", file.cFileName);
|
ConOutPrintf (" %s\n", file.cFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (FindNextFile (hFile, &file));
|
while (FindNextFile (hFile, &file));
|
||||||
|
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
|
|
||||||
/* Rob Lake, need to make clean output */
|
/* Rob Lake, need to make clean output */
|
||||||
/* JPP 07/08/1998 added check for count != 0 */
|
/* JPP 07/08/1998 added check for count != 0 */
|
||||||
if ((flags & DIR_WIDE) && (count != 0))
|
if ((dwFlags & DIR_WIDE) && (count != 0))
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,9 +962,8 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
recurse_file_cnt += filecount;
|
recurse_file_cnt += filecount;
|
||||||
recurse_bytes.QuadPart += bytecount.QuadPart;
|
recurse_bytes.QuadPart += bytecount.QuadPart;
|
||||||
|
|
||||||
/* The code that was here is now in print_summary */
|
/* print_summary */
|
||||||
if (PrintSummary (drive, filecount, dircount,
|
if (PrintSummary (szPath, filecount, dircount, bytecount, pLine, dwFlags))
|
||||||
bytecount, flags, line) != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1049,43 +979,45 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
/*
|
/*
|
||||||
* _Read_Dir: Actual function that does recursive listing
|
* _Read_Dir: Actual function that does recursive listing
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
Read_Dir (int drive, char *parent, char *filespec, int *lines,
|
DirRead (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
DWORD flags)
|
|
||||||
{
|
{
|
||||||
char fullpath[_MAX_PATH];
|
TCHAR szFullPath[MAX_PATH];
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
|
||||||
strcpy (fullpath, parent);
|
_tcscpy (szFullPath, szPath);
|
||||||
strcat (fullpath, "\\");
|
if (szFullPath[_tcslen (szFullPath) - 1] != _T('\\'))
|
||||||
strcat (fullpath, filespec);
|
_tcscat (szFullPath, _T("\\"));
|
||||||
|
_tcscat (szFullPath, szFilespec);
|
||||||
|
|
||||||
hFile = FindFirstFile (fullpath, &file);
|
hFile = FindFirstFile (szFullPath, &file);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* don't list "." and ".." */
|
/* don't list "." and ".." */
|
||||||
if (strcmp (file.cFileName, ".") == 0 ||
|
if (_tcscmp (file.cFileName, _T(".")) == 0 ||
|
||||||
strcmp (file.cFileName, "..") == 0)
|
_tcscmp (file.cFileName, _T("..")) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (dir_list(drive, file.cFileName, filespec, lines, flags) != 0)
|
if (DirList (file.cFileName, szFilespec, pLine, dwFlags))
|
||||||
{
|
{
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if ((flags & DIR_BARE) == 0)
|
|
||||||
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf ("\n");
|
||||||
if (incline(lines, flags) != 0)
|
if (IncLine (pLine, dwFlags) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (Read_Dir(drive, file.cFileName, filespec, lines, flags) == 1)
|
|
||||||
|
if (DirRead (file.cFileName, szFilespec, pLine, dwFlags) == 1)
|
||||||
{
|
{
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1104,49 +1036,45 @@ Read_Dir (int drive, char *parent, char *filespec, int *lines,
|
||||||
/*
|
/*
|
||||||
* do_recurse: Sets up for recursive directory listing
|
* do_recurse: Sets up for recursive directory listing
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
do_recurse(int drive, char *directory, char *filespec,
|
DirRecurse (LPTSTR szPath, LPTSTR szSpec, LPINT pLine, DWORD dwFlags)
|
||||||
int *line, DWORD flags)
|
|
||||||
{
|
{
|
||||||
char cur_dir[_MAX_DIR];
|
recurse_dir_cnt = 0L;
|
||||||
|
recurse_file_cnt = 0L;
|
||||||
recurse_dir_cnt = recurse_file_cnt = 0L;
|
|
||||||
recurse_bytes.QuadPart = 0;
|
recurse_bytes.QuadPart = 0;
|
||||||
|
|
||||||
_chdrive (drive);
|
if (!PrintDirectoryHeader (szPath, pLine, dwFlags))
|
||||||
getcwd(cur_dir, sizeof(cur_dir));
|
|
||||||
|
|
||||||
if (chdir(directory) == -1)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!PrintDirectoryHeader (drive, line, flags))
|
if (DirList (szPath, szSpec, pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (dir_list(drive, directory, filespec, line, flags) != 0)
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
return 1;
|
|
||||||
if ((flags & DIR_BARE) == 0)
|
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (Read_Dir(drive, directory, filespec, line, flags) != 0)
|
|
||||||
return 1;
|
|
||||||
if ((flags & DIR_BARE) == 0)
|
|
||||||
ConOutPrintf ("Total files listed:\n");
|
|
||||||
flags &= ~DIR_RECURSE;
|
|
||||||
|
|
||||||
if (PrintSummary (drive, recurse_file_cnt,
|
if (DirRead (szPath, szSpec, pLine, dwFlags))
|
||||||
recurse_dir_cnt, recurse_bytes, flags, line) != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((flags & DIR_BARE) == 0)
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
|
ConOutPrintf (_T("Total files listed:\n"));
|
||||||
|
|
||||||
|
dwFlags &= ~DIR_RECURSE;
|
||||||
|
|
||||||
|
if (PrintSummary (szPath, recurse_file_cnt,
|
||||||
|
recurse_dir_cnt, recurse_bytes, pLine, dwFlags))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
chdir(cur_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,14 +1087,11 @@ do_recurse(int drive, char *directory, char *filespec,
|
||||||
INT cmd_dir (LPTSTR first, LPTSTR rest)
|
INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||||
{
|
{
|
||||||
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
||||||
char *param;
|
|
||||||
TCHAR dircmd[256];
|
TCHAR dircmd[256];
|
||||||
int line = 0;
|
TCHAR szPath[MAX_PATH];
|
||||||
int drive,
|
TCHAR szFilespec[MAX_PATH];
|
||||||
orig_drive;
|
LPTSTR param;
|
||||||
char *directory,
|
INT nLine = 0;
|
||||||
*filespec,
|
|
||||||
orig_dir[_MAX_DIR];
|
|
||||||
|
|
||||||
|
|
||||||
/* read the parameters from the DIRCMD environment variable */
|
/* read the parameters from the DIRCMD environment variable */
|
||||||
|
@ -1184,39 +1109,26 @@ INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||||
if (!param)
|
if (!param)
|
||||||
param = ".";
|
param = ".";
|
||||||
|
|
||||||
if (strchr(param, '/'))
|
if (_tcschr (param, _T('/')))
|
||||||
param = strtok (param, "/");
|
param = _tcstok (param, _T("/"));
|
||||||
|
|
||||||
/* save the current directory info */
|
|
||||||
orig_drive = _getdrive ();
|
|
||||||
getcwd(orig_dir, sizeof(orig_dir));
|
|
||||||
|
|
||||||
/* parse the directory info */
|
/* parse the directory info */
|
||||||
if (DirParsePathspec (param, &drive, &directory, &filespec) != 0)
|
if (DirParsePathspec (param, szPath, szFilespec))
|
||||||
{
|
|
||||||
_chdrive (orig_drive);
|
|
||||||
chdir(orig_dir);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
if (dwFlags & DIR_RECURSE)
|
if (dwFlags & DIR_RECURSE)
|
||||||
{
|
{
|
||||||
incline(&line, dwFlags);
|
IncLine (&nLine, dwFlags);
|
||||||
if (do_recurse (drive, directory, filespec, &line, dwFlags) != 0)
|
if (DirRecurse (szPath, szFilespec, &nLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
_chdrive (orig_drive);
|
|
||||||
chdir (orig_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print the header */
|
/* print the header */
|
||||||
if (!PrintDirectoryHeader (drive, &line, dwFlags))
|
if (!PrintDirectoryHeader (szPath, &nLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
chdir (orig_dir);
|
if (DirList (szPath, szFilespec, &nLine, dwFlags))
|
||||||
_chdrive (orig_drive);
|
|
||||||
|
|
||||||
if (dir_list (drive, directory, filespec, &line, dwFlags) != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef FEATURE_DIRECTORY_STACK
|
#ifdef FEATURE_DIRECTORY_STACK
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -17,12 +17,11 @@
|
||||||
* Use FormatMessage() for error reports.
|
* Use FormatMessage() for error reports.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
@ -53,10 +52,10 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szMessage, szFormat, arg_ptr);
|
_vstprintf (szMessage, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
#if 1
|
#ifndef __REACTOS__
|
||||||
|
|
||||||
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
@ -69,7 +68,6 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode);
|
ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode);
|
||||||
// ConErrPrintf (_T("No error message available!\n"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,13 @@
|
||||||
* Cleanup. Unicode safe!
|
* Cleanup. Unicode safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
|
||||||
INT curplace = 0;
|
INT curplace = 0;
|
||||||
INT start;
|
INT start;
|
||||||
INT count;
|
INT count;
|
||||||
|
@ -70,11 +68,11 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
_tcscpy (path, &str[start]);
|
_tcscpy (path, &str[start]);
|
||||||
|
|
||||||
/* look for a '.' in the filename */
|
/* look for a '.' in the filename */
|
||||||
for (count = _tcslen (directory); path[count] != 0; count++)
|
for (count = _tcslen (directory); path[count] != _T('\0'); count++)
|
||||||
{
|
{
|
||||||
if (path[count] == _T('.'))
|
if (path[count] == _T('.'))
|
||||||
{
|
{
|
||||||
found_dot = 1;
|
found_dot = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +92,8 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* ignore "." and ".." */
|
/* ignore "." and ".." */
|
||||||
if (file.cFileName[0] == _T('.'))
|
if (!_tcscmp (file.cFileName, _T(".")) ||
|
||||||
|
!_tcscmp (file.cFileName, _T("..")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_tcscpy (fname, file.cFileName);
|
_tcscpy (fname, file.cFileName);
|
||||||
|
@ -129,12 +128,20 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
_tcscat (&str[start], maxmatch);
|
_tcscat (&str[start], maxmatch);
|
||||||
|
|
||||||
if (!perfectmatch)
|
if (!perfectmatch)
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no match found */
|
/* no match found */
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +180,8 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
/* extract directory from word */
|
/* extract directory from word */
|
||||||
_tcscpy (directory, &str[start]);
|
_tcscpy (directory, &str[start]);
|
||||||
curplace = _tcslen (directory) - 1;
|
curplace = _tcslen (directory) - 1;
|
||||||
while (curplace >= 0 && directory[curplace] != _T('\\') &&
|
while (curplace >= 0 &&
|
||||||
|
directory[curplace] != _T('\\') &&
|
||||||
directory[curplace] != _T(':'))
|
directory[curplace] != _T(':'))
|
||||||
{
|
{
|
||||||
directory[curplace] = 0;
|
directory[curplace] = 0;
|
||||||
|
@ -183,7 +191,7 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
_tcscpy (path, &str[start]);
|
_tcscpy (path, &str[start]);
|
||||||
|
|
||||||
/* look for a . in the filename */
|
/* look for a . in the filename */
|
||||||
for (count = _tcslen (directory); path[count] != 0; count++)
|
for (count = _tcslen (directory); path[count] != _T('\0'); count++)
|
||||||
{
|
{
|
||||||
if (path[count] == _T('.'))
|
if (path[count] == _T('.'))
|
||||||
{
|
{
|
||||||
|
@ -191,6 +199,7 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_dot)
|
if (found_dot)
|
||||||
_tcscat (path, _T("*"));
|
_tcscat (path, _T("*"));
|
||||||
else
|
else
|
||||||
|
@ -208,7 +217,8 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* ignore . and .. */
|
/* ignore . and .. */
|
||||||
if (file.cFileName[0] == _T('.'))
|
if (!_tcscmp (file.cFileName, _T(".")) ||
|
||||||
|
!_tcscmp (file.cFileName, _T("..")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
@ -233,7 +243,11 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no match found */
|
/* no match found */
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -23,13 +23,12 @@
|
||||||
* Added help text ("/?").
|
* Added help text ("/?").
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
|
|
|
@ -20,13 +20,12 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
@ -98,7 +97,7 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
|
||||||
while (_istdigit (*pp))
|
while (_istdigit (*pp))
|
||||||
n = n * 10 + (*pp++ - _T('0'));
|
n = n * 10 + (*pp++ - _T('0'));
|
||||||
|
|
||||||
x_flag ^= (errorlevel < n) ? 0 : X_EXEC;
|
x_flag ^= (nErrorLevel < n) ? 0 : X_EXEC;
|
||||||
|
|
||||||
x_flag |= X_EMPTY; /* Syntax error if comd empty */
|
x_flag |= X_EMPTY; /* Syntax error if comd empty */
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,16 +115,19 @@
|
||||||
*
|
*
|
||||||
* 30-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 30-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Added "cd -" feature. Changes to the previous directory.
|
* Added "cd -" feature. Changes to the previous directory.
|
||||||
|
*
|
||||||
|
* 15-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Fixed bug in "cd -" feature. If the previous directory was a root
|
||||||
|
* directory, it was ignored.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -252,7 +255,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing \ if any, but ONLY if dir is not the root dir */
|
/* remove trailing \ if any, but ONLY if dir is not the root dir */
|
||||||
if (_tcslen (dir) >= 2 && dir[_tcslen (dir) - 1] == _T('\\'))
|
if (_tcslen (dir) > 3 && dir[_tcslen (dir) - 1] == _T('\\'))
|
||||||
dir[_tcslen(dir) - 1] = _T('\0');
|
dir[_tcslen(dir) - 1] = _T('\0');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* Unicode ready!
|
* Unicode ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_LABEL
|
#ifdef INCLUDE_CMD_LABEL
|
||||||
|
@ -23,6 +21,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
* Unicode safe!
|
* Unicode safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
#
|
#
|
||||||
|
# ReactOS makefile for CMD
|
||||||
#
|
#
|
||||||
|
|
||||||
LIB=../../lib
|
|
||||||
COMMON=../common
|
|
||||||
|
|
||||||
# target: raw binary (does not work right now)
|
# target: raw binary (does not work right now)
|
||||||
#all: cmd.bin
|
#all: cmd.bin
|
||||||
|
|
||||||
# target: executable (not tested/experimental)
|
# target: executable (not tested/experimental)
|
||||||
all: cmd.exe
|
all: cmd.exe
|
||||||
|
|
||||||
OBJECTS = $(COMMON)/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o cls.o cmdinput.o cmdtable.o\
|
OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o cls.o cmdinput.o cmdtable.o\
|
||||||
color.o date.o del.o dir.o echo.o err_hand.o error.o filecomp.o for.o goto.o history.o if.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 misc.o path.o pause.o redir.o ren.o set.o shift.o tempfile.o time.o type.o ver.o\
|
internal.o label.o locale.o misc.o move.o path.o pause.o prompt.o redir.o ren.o ros.o set.o shift.o time.o title.o type.o ver.o\
|
||||||
verify.o where.o
|
verify.o vol.o where.o
|
||||||
|
|
||||||
|
LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a
|
||||||
|
|
||||||
LIBS = $(LIB)/mingw32/mingw32.a $(LIB)/crtdll/crtdll.a \
|
|
||||||
$(LIB)/kernel32/kernel32.a $(LIB)/ntdll/ntdll.a
|
|
||||||
|
|
||||||
cmd.bin: $(OBJECTS)
|
cmd.bin: $(OBJECTS)
|
||||||
$(LD) -Ttext 0x10000 $(OBJECTS) $(LIBS) -o cmd.exe
|
$(LD) -Ttext 0x10000 $(OBJECTS) $(LIBS) -o cmd.exe
|
||||||
$(OBJCOPY) -O binary cmd.exe cmd.bin
|
$(OBJCOPY) -O binary cmd.exe cmd.bin
|
||||||
|
|
||||||
cmd.exe: $(OBJECTS)
|
cmd.exe: $(OBJECTS) $(LIBS)
|
||||||
$(LD) $(OBJECTS) $(LIBS) -o cmd.exe
|
$(CC) -specs=../../specs $(OBJECTS) $(LIBS) -lgcc -o cmd.exe
|
||||||
|
$(NM) --numeric-sort cmd.exe > cmd.sym
|
||||||
|
|
||||||
include ../../rules.mak
|
include ../../rules.mak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,13 @@
|
||||||
* FileGetString() seems to be working now.
|
* FileGetString() seems to be working now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <conio.h>
|
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -45,32 +42,36 @@
|
||||||
*/
|
*/
|
||||||
TCHAR cgetchar (VOID)
|
TCHAR cgetchar (VOID)
|
||||||
{
|
{
|
||||||
TCHAR ch;
|
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
#if 0
|
INPUT_RECORD irBuffer;
|
||||||
DWORD dwRead;
|
DWORD dwRead;
|
||||||
DWORD dwOldMode;
|
|
||||||
HANDLE hIn;
|
|
||||||
|
|
||||||
hIn = GetStdHandle (STD_INPUT_HANDLE);
|
do
|
||||||
ConInSwallowInput (hIn);
|
{
|
||||||
|
WaitForSingleObject (hInput, INFINITE);
|
||||||
GetConsoleMode (hIn, &dwOldMode);
|
ReadConsoleInput (hInput, &irBuffer, 1, &dwRead);
|
||||||
SetConsoleMode (hIn, 0);
|
if ((irBuffer.EventType == KEY_EVENT) &&
|
||||||
|
(irBuffer.Event.KeyEvent.bKeyDown == TRUE))
|
||||||
ReadConsole (hIn, &ch, 1, &dwRead, NULL);
|
{
|
||||||
|
if ((irBuffer.Event.KeyEvent.dwControlKeyState &
|
||||||
DebugPrintf ("[cgetchar (0x%x) \'%c\']\n", ch, ch);
|
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) &
|
||||||
|
(irBuffer.Event.KeyEvent.wVirtualKeyCode == 'C'))
|
||||||
SetConsoleMode (hIn, dwOldMode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((ch = getch()) == 0)
|
|
||||||
ch = getch() << 8;
|
|
||||||
|
|
||||||
if (ch == 3)
|
|
||||||
bCtrlBreak = TRUE;
|
bCtrlBreak = TRUE;
|
||||||
|
|
||||||
return ch;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (TRUE);
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
return irBuffer.Event.KeyEvent.AsciiChar;
|
||||||
|
#else
|
||||||
|
#ifndef _UNICODE
|
||||||
|
return irBuffer.Event.KeyEvent.uChar.AsciiChar;
|
||||||
|
#else
|
||||||
|
return irBuffer.Event.KeyEvent.uChar.UnicodeChar;
|
||||||
|
#endif /* _UNICODE */
|
||||||
|
#endif /* __REACTOS__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,6 +267,11 @@ BOOL IsValidFileName (LPCTSTR pszPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL IsValidDirectory (LPCTSTR pszPath)
|
||||||
|
{
|
||||||
|
return (GetFileAttributes (pszPath) & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
* Added "/N" option.
|
* Added "/N" option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_MOVE
|
#ifdef INCLUDE_CMD_MOVE
|
||||||
|
@ -31,6 +29,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
* Fixed Win32 environment handling.
|
* Fixed Win32 environment handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_PATH
|
#ifdef INCLUDE_CMD_PATH
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
* Unicode ready!
|
* Unicode ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_PAUSE
|
#ifdef INCLUDE_CMD_PAUSE
|
||||||
|
|
|
@ -44,17 +44,85 @@
|
||||||
* Fixed Win32 environment handling.
|
* Fixed Win32 environment handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
static VOID PrintDate (VOID)
|
||||||
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
GetLocalTime (&st);
|
||||||
|
|
||||||
|
switch (nDateFormat)
|
||||||
|
{
|
||||||
|
case 0: /* mmddyy */
|
||||||
|
default:
|
||||||
|
ConOutPrintf (_T("%s %02d%c%02d%c%04d"),
|
||||||
|
aszDayNames[st.wDayOfWeek], st.wMonth, cDateSeparator, st.wDay, cDateSeparator, st.wYear);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: /* ddmmyy */
|
||||||
|
ConOutPrintf (_T("%s %02d%c%02d%c%04d"),
|
||||||
|
aszDayNames[st.wDayOfWeek], st.wDay, cDateSeparator, st.wMonth, cDateSeparator, st.wYear);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: /* yymmdd */
|
||||||
|
ConOutPrintf (_T("%s %04d%c%02d%c%02d"),
|
||||||
|
aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
TCHAR szDate[32];
|
||||||
|
|
||||||
|
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
|
||||||
|
szDate, sizeof (szDate));
|
||||||
|
ConOutPrintf (_T("%s"), szDate);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
PrintTime (VOID)
|
||||||
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
GetLocalTime (&st);
|
||||||
|
|
||||||
|
switch (nTimeFormat)
|
||||||
|
{
|
||||||
|
case 0: /* 12 hour format */
|
||||||
|
default:
|
||||||
|
ConOutPrintf (_T("%2d%c%02d%c%02d%c%02d%c"),
|
||||||
|
(st.wHour == 0 ? 12 : (st.wHour <= 12 ? st.wHour : st.wHour - 12)),
|
||||||
|
cTimeSeparator, st.wMinute, cTimeSeparator, st.wSecond, cDecimalSeparator,
|
||||||
|
st.wMilliseconds / 10, (st.wHour <= 11 ? 'a' : 'p'));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: /* 24 hour format */
|
||||||
|
ConOutPrintf (_T("%2d%c%02d%c%02d%c%02d"),
|
||||||
|
st.wHour, cTimeSeparator, st.wMinute, cTimeSeparator,
|
||||||
|
st.wSecond, cDecimalSeparator, st.wMilliseconds / 10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
TCHAR szTime[32];
|
||||||
|
|
||||||
|
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
|
||||||
|
szTime, sizeof (szTime));
|
||||||
|
ConOutPrintf (_T("%s"), szTime);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print the command-line prompt
|
* print the command-line prompt
|
||||||
*
|
*
|
||||||
|
@ -95,13 +163,7 @@ VOID PrintPrompt(VOID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('D'):
|
case _T('D'):
|
||||||
{
|
PrintDate ();
|
||||||
TCHAR szDate[32];
|
|
||||||
|
|
||||||
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE,
|
|
||||||
NULL, NULL, szDate, sizeof (szDate));
|
|
||||||
ConOutPrintf (_T("%s"), szDate);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('E'):
|
case _T('E'):
|
||||||
|
@ -145,12 +207,7 @@ VOID PrintPrompt(VOID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('T'):
|
case _T('T'):
|
||||||
{
|
PrintTime ();
|
||||||
TCHAR szTime[32];
|
|
||||||
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL,
|
|
||||||
NULL, szTime, sizeof (szTime));
|
|
||||||
ConOutPrintf (_T("%s"), szTime);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('V'):
|
case _T('V'):
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
* Added new error AND output redirection "&>" and "&>>".
|
* Added new error AND output redirection "&>" and "&>>".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef FEATURE_REDIRECTION
|
#ifdef FEATURE_REDIRECTION
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_RENAME
|
#ifdef INCLUDE_CMD_RENAME
|
||||||
|
|
111
reactos/apps/utils/cmd/ros.c
Normal file
111
reactos/apps/utils/cmd/ros.c
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
//#include <types.h>
|
||||||
|
//#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
void* malloc(size_t _size)
|
||||||
|
{
|
||||||
|
return(HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void free(void* _ptr)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void* calloc(size_t _nmemb, size_t _size)
|
||||||
|
{
|
||||||
|
return(HeapAlloc(GetProcessHeap(),
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
_nmemb*_size));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void* realloc(void* _ptr, size_t _size)
|
||||||
|
{
|
||||||
|
return(HeapReAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
_ptr,
|
||||||
|
_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
_strdup(const char *_s)
|
||||||
|
{
|
||||||
|
char *rv;
|
||||||
|
if (_s == 0)
|
||||||
|
return 0;
|
||||||
|
rv = (char *)malloc(strlen(_s) + 1);
|
||||||
|
if (rv == 0)
|
||||||
|
return 0;
|
||||||
|
strcpy(rv, _s);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
strlen(const char *str)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
if (str == 0)
|
||||||
|
return 0;
|
||||||
|
for (s = str; *s; ++s);
|
||||||
|
return s-str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_makepath( char *path, const char *drive, const char *dir, const char *fname, const char *ext )
|
||||||
|
{
|
||||||
|
int dir_len;
|
||||||
|
if ( drive != NULL ) {
|
||||||
|
strcat(path,drive);
|
||||||
|
strcat(path,":");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dir != NULL ) {
|
||||||
|
strcat(path,dir);
|
||||||
|
if ( *dir != '\\' )
|
||||||
|
strcat(path,"\\");
|
||||||
|
dir_len = strlen(dir);
|
||||||
|
if ( *(dir + dir_len - 1) != '\\' )
|
||||||
|
strcat(path,"\\");
|
||||||
|
}
|
||||||
|
if ( fname != NULL ) {
|
||||||
|
strcat(path,fname);
|
||||||
|
if ( ext != NULL ) {
|
||||||
|
if ( *ext != '.')
|
||||||
|
strcat(path,".");
|
||||||
|
strcat(path,ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
int getch(void)
|
||||||
|
{
|
||||||
|
DWORD NumberOfCharsRead = 0;
|
||||||
|
DWORD dwWritten;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
ReadConsoleA (GetStdHandle (STD_INPUT_HANDLE), &c, 1, &NumberOfCharsRead, NULL);
|
||||||
|
|
||||||
|
if ( c == 10 )
|
||||||
|
c = 13;
|
||||||
|
|
||||||
|
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), &c, 1, &dwWritten, NULL);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -26,10 +26,11 @@
|
||||||
* 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Fixed Win32 environment handling.
|
* Fixed Win32 environment handling.
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
|
*
|
||||||
|
* 25-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Fixed little bug.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_SET
|
#ifdef INCLUDE_CMD_SET
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
/* size of environment variable buffer */
|
/* initial size of environment variable buffer */
|
||||||
#define ENV_BUFFER_SIZE 1024
|
#define ENV_BUFFER_SIZE 1024
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ INT cmd_set (LPTSTR cmd, LPTSTR param)
|
||||||
else if (dwBuffer > ENV_BUFFER_SIZE)
|
else if (dwBuffer > ENV_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
GetEnvironmentVariable (param, pszBuffer, ENV_BUFFER_SIZE);
|
GetEnvironmentVariable (param, pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConOutPrintf ("%s\n", pszBuffer);
|
ConOutPrintf ("%s\n", pszBuffer);
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
* Fixed time input bug.
|
* Fixed time input bug.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TIME
|
#ifdef INCLUDE_CMD_TIME
|
||||||
|
@ -38,7 +36,7 @@
|
||||||
static VOID
|
static VOID
|
||||||
PrintTime (VOID)
|
PrintTime (VOID)
|
||||||
{
|
{
|
||||||
#if 0
|
#ifdef __REACTOS__
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
|
|
||||||
GetLocalTime (&st);
|
GetLocalTime (&st);
|
||||||
|
@ -59,13 +57,13 @@ PrintTime (VOID)
|
||||||
st.wSecond, cDecimalSeparator, st.wMilliseconds / 10);
|
st.wSecond, cDecimalSeparator, st.wMilliseconds / 10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
TCHAR szTime[32];
|
TCHAR szTime[32];
|
||||||
|
|
||||||
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
|
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
|
||||||
szTime, sizeof (szTime));
|
szTime, sizeof (szTime));
|
||||||
ConOutPrintf (_T("Current date is: %s\n"), szTime);
|
ConOutPrintf (_T("Current date is: %s\n"), szTime);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
42
reactos/apps/utils/cmd/title.c
Normal file
42
reactos/apps/utils/cmd/title.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* title.c - title internal command.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* History:
|
||||||
|
* 1999-02-11 Emanuele Aliberti
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_TITLE
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
INT cmd_title (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
/* Do nothing if no args */
|
||||||
|
if (*param == _T('\0'))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Asking help? */
|
||||||
|
if (!_tcsncmp(param, _T("/?"), 2))
|
||||||
|
{
|
||||||
|
ConOutPuts (_T("Sets the window title for the command prompt window.\n"
|
||||||
|
"\n"
|
||||||
|
"TITLE [string]\n"
|
||||||
|
"\n"
|
||||||
|
" string Specifies the title for the command prompt window."));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetConsoleTitle (param);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* def INCLUDE_CMD_TITLE */
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -20,8 +20,6 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TYPE
|
#ifdef INCLUDE_CMD_TYPE
|
||||||
|
|
|
@ -16,24 +16,27 @@
|
||||||
*
|
*
|
||||||
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
|
*
|
||||||
|
* 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* New version info and some output changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
#define VER_HELP "display shell version info VER [/C/R/W/?]"
|
|
||||||
|
|
||||||
|
|
||||||
VOID ShortVersion (VOID)
|
VOID ShortVersion (VOID)
|
||||||
{
|
{
|
||||||
ConOutPuts (_T("\n" SHELLINFO " " SHELLVER "\n"));
|
ConOutPuts (_T("\n"
|
||||||
|
SHELLINFO "\n"
|
||||||
|
SHELLVER "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,9 +51,11 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
|
|
||||||
/* JPP 07/08/1998 clean up and shortened info. */
|
ConOutPuts (_T("\n"
|
||||||
|
SHELLINFO "\n"
|
||||||
ConOutPuts (_T("\n" SHELLINFO " " SHELLVER "\nCopyright (C) 1994-1998 Tim Norman and others."));
|
SHELLVER "\n"
|
||||||
|
"\n"
|
||||||
|
"Copyright (C) 1994-1998 Tim Norman and others."));
|
||||||
ConOutPuts (_T("Copyright (C) 1998,1999 Eric Kohl."));
|
ConOutPuts (_T("Copyright (C) 1998,1999 Eric Kohl."));
|
||||||
|
|
||||||
/* Basic copyright notice */
|
/* Basic copyright notice */
|
||||||
|
@ -67,7 +72,7 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
/* MS-DOS ver prints just help if /? is alone or not */
|
/* MS-DOS ver prints just help if /? is alone or not */
|
||||||
if (_tcsstr (param, _T("/?")) != NULL)
|
if (_tcsstr (param, _T("/?")) != NULL)
|
||||||
{
|
{
|
||||||
ConOutPuts (_T(USAGE ": " VER_HELP));
|
ConOutPuts (_T("\ndisplay shell version info\n\nVER [/C/R/W/?]"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +96,6 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
if (_totupper (param[i]) == _T('W'))
|
if (_totupper (param[i]) == _T('W'))
|
||||||
{
|
{
|
||||||
/* Warranty notice */
|
/* Warranty notice */
|
||||||
/* JPP 07/08/1998 removed extra printf calls */
|
|
||||||
ConOutPuts (_T("\n This program is distributed in the hope that it will be useful,\n"
|
ConOutPuts (_T("\n This program is distributed in the hope that it will be useful,\n"
|
||||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||||
|
@ -100,7 +104,6 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
else if (_totupper (param[i]) == _T('R'))
|
else if (_totupper (param[i]) == _T('R'))
|
||||||
{
|
{
|
||||||
/* Redistribution notice */
|
/* Redistribution notice */
|
||||||
/* JPP 07/08/1998 removed extra printf calls */
|
|
||||||
ConOutPuts (_T("\n This program is free software; you can redistribute it and/or modify\n"
|
ConOutPuts (_T("\n This program is free software; you can redistribute it and/or modify\n"
|
||||||
" it under the terms of the GNU General Public License as published by\n"
|
" it under the terms of the GNU General Public License as published by\n"
|
||||||
" the Free Software Foundation; either version 2 of the License, or\n"
|
" the Free Software Foundation; either version 2 of the License, or\n"
|
||||||
|
@ -109,16 +112,15 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
else if (_totupper (param[i]) == _T('C'))
|
else if (_totupper (param[i]) == _T('C'))
|
||||||
{
|
{
|
||||||
/* Developer listing */
|
/* Developer listing */
|
||||||
/* JPP 07/08/1998 removed extra printf calls; rearranged names */
|
ConOutPuts (_T("\nFreeDOS version written by:\n"
|
||||||
ConOutPuts (_T("\ndeveloped by:\n"
|
|
||||||
" Tim Norman Matt Rains\n"
|
" Tim Norman Matt Rains\n"
|
||||||
" Evan Jeffrey Steffen Kaiser\n"
|
" Evan Jeffrey Steffen Kaiser\n"
|
||||||
" Svante Frey Oliver Mueller\n"
|
" Svante Frey Oliver Mueller\n"
|
||||||
" Aaron Kaufman Marc Desrochers\n"
|
" Aaron Kaufman Marc Desrochers\n"
|
||||||
" Rob Lake John P Price\n"
|
" Rob Lake John P Price\n"
|
||||||
" Hans B Pufal\n"
|
" Hans B Pufal\n"
|
||||||
"\nconverted to Win32 by:\n"
|
"\nReactOS version written by:\n"
|
||||||
" Eric Kohl\n"));
|
" Eric Kohl Emanuele Aliberti\n"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,7 +132,7 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
|
|
||||||
ConOutPuts (_T("\nSend bug reports to <ekohl@abo.rhein-zeitung.de>.\n"
|
ConOutPuts (_T("\nSend bug reports to <ekohl@abo.rhein-zeitung.de>.\n"
|
||||||
/*
|
/*
|
||||||
"Updates are available at ftp://www.sid-dis.com/..."
|
"Updates are available at http://www.sid-dis.com/reactos"
|
||||||
*/
|
*/
|
||||||
));
|
));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_VERIFY
|
#ifdef INCLUDE_CMD_VERIFY
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_VOL
|
#ifdef INCLUDE_CMD_VOL
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* WHERE.C - file serch functions.
|
* WHERE.C - file search functions.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* History:
|
* History:
|
||||||
|
@ -8,14 +8,15 @@
|
||||||
* started.
|
* started.
|
||||||
*
|
*
|
||||||
* 08/08/95 (Matt Rains)
|
* 08/08/95 (Matt Rains)
|
||||||
* i have cleaned up the source code. changes now bring this source into
|
* i have cleaned up the source code. changes now bring this source
|
||||||
* guidelines for recommended programming practice.
|
* into guidelines for recommended programming practice.
|
||||||
*
|
*
|
||||||
* 12/12/95 (Steffan Kaiser & Tim Norman)
|
* 12/12/95 (Steffan Kaiser & Tim Norman)
|
||||||
* added some patches to fix some things and make more efficient
|
* added some patches to fix some things and make more efficient
|
||||||
*
|
*
|
||||||
* 1/6/96 (Tim Norman)
|
* 1/6/96 (Tim Norman)
|
||||||
* fixed a stupid pointer mistake... Thanks to everyone who noticed it!
|
* fixed a stupid pointer mistake...
|
||||||
|
* Thanks to everyone who noticed it!
|
||||||
*
|
*
|
||||||
* 8/1/96 (Tim Norman)
|
* 8/1/96 (Tim Norman)
|
||||||
* fixed a bug when getenv returns NULL
|
* fixed a bug when getenv returns NULL
|
||||||
|
@ -24,13 +25,14 @@
|
||||||
* speed improvements and bug fixes
|
* speed improvements and bug fixes
|
||||||
*
|
*
|
||||||
* 8/27/96 (Tim Norman)
|
* 8/27/96 (Tim Norman)
|
||||||
* changed code to use pointers directly into PATH environment variable
|
* changed code to use pointers directly into PATH environment
|
||||||
* rather than making our own copy. This saves some memory, but requires
|
* variable rather than making our own copy. This saves some memory,
|
||||||
* we write our own function to copy pathnames out of the variable.
|
* but requires we write our own function to copy pathnames out of
|
||||||
|
* the variable.
|
||||||
*
|
*
|
||||||
* 12/23/96 (Aaron Kaufman)
|
* 12/23/96 (Aaron Kaufman)
|
||||||
* Fixed a bug in get_paths() that did not point to the first PATH in the
|
* Fixed a bug in get_paths() that did not point to the first PATH
|
||||||
* environment variable.
|
* in the environment variable.
|
||||||
*
|
*
|
||||||
* 7/12/97 (Tim Norman)
|
* 7/12/97 (Tim Norman)
|
||||||
* Apparently, Aaron's bugfix got lost, so I fixed it again.
|
* Apparently, Aaron's bugfix got lost, so I fixed it again.
|
||||||
|
@ -42,26 +44,28 @@
|
||||||
* Rewrote find_which to use searchpath function
|
* Rewrote find_which to use searchpath function
|
||||||
*
|
*
|
||||||
* 24-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
* 24-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
||||||
* - fixed bug where didn't check all extensions when path was specified
|
* fixed bug where didn't check all extensions when path was specified
|
||||||
*
|
*
|
||||||
* 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
* 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
||||||
* - added config.h include
|
* added config.h include
|
||||||
*
|
*
|
||||||
* 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
* 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
||||||
* - fixed so that it find_which returns NULL if filename is not executable
|
* fixed so that it find_which returns NULL if filename is not
|
||||||
* (does not have .bat, .com, or .exe extention). Before command would
|
* executable (does not have .bat, .com, or .exe extention).
|
||||||
* to execute any file with any extension (opps!)
|
* Before command would to execute any file with any extension (opps!)
|
||||||
*
|
*
|
||||||
* 03-Dec_1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 03-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Changed find_which().
|
* Changed find_which().
|
||||||
*
|
*
|
||||||
* 07-Dec_1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 07-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Added ".CMD" extension.
|
* Added ".CMD" extension.
|
||||||
* Replaced numeric constant by _NR_OF_EXTENSIONS.
|
* Replaced numeric constant by _NR_OF_EXTENSIONS.
|
||||||
|
*
|
||||||
|
* 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Replaced find_which() by SearchForExecutable().
|
||||||
|
* Now files are serched with the right order of extensions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -71,91 +75,188 @@
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* initial size of environment variable buffer */
|
||||||
|
#define ENV_BUFFER_SIZE 1024
|
||||||
|
|
||||||
|
|
||||||
static LPTSTR ext[] = {".BAT", ".CMD", ".COM", ".EXE"};
|
static LPTSTR ext[] = {".BAT", ".CMD", ".COM", ".EXE"};
|
||||||
static INT nExtCount = sizeof(ext) / sizeof(LPTSTR);
|
static INT nExtCount = sizeof(ext) / sizeof(LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* searches for file using path info. */
|
/* searches for file using path info. */
|
||||||
|
|
||||||
BOOL find_which (LPCTSTR fname, LPTSTR fullbuffer)
|
BOOL
|
||||||
|
SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
|
||||||
{
|
{
|
||||||
static TCHAR temp[MAX_PATH];
|
TCHAR szPathBuffer[MAX_PATH];
|
||||||
LPTSTR fullname;
|
LPTSTR pszBuffer;
|
||||||
INT x;
|
DWORD dwBuffer;
|
||||||
|
INT n;
|
||||||
|
LPTSTR p,s,f;
|
||||||
|
|
||||||
*fullbuffer = _T('\0');
|
/* load environment varable PATH into buffer */
|
||||||
|
pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
||||||
/* if there an extension and it is in the last path component, then
|
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
|
||||||
* don't test all the extensions. */
|
if (dwBuffer == 0)
|
||||||
if (!(fullname = _tcsrchr (fname, _T('.'))) ||
|
|
||||||
_tcschr (fullname + 1, _T('\\')))
|
|
||||||
{
|
{
|
||||||
|
ConErrPrintf (_T("Not PATH environment variable found!\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (dwBuffer > ENV_BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
|
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* initialize full name buffer */
|
||||||
|
*pFullName = _T('\0');
|
||||||
|
|
||||||
|
if (!(p = _tcsrchr (pFileName, _T('.'))) ||
|
||||||
|
_tcschr (p + 1, _T('\\')))
|
||||||
|
{
|
||||||
|
/* There is no extension ==> test all the extensions. */
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf ("No filename extension!\n");
|
DebugPrintf (_T("No filename extension!\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (x = 0; x < nExtCount; x++)
|
/* search in current directory */
|
||||||
|
GetCurrentDirectory (MAX_PATH, szPathBuffer);
|
||||||
|
if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\'))
|
||||||
|
_tcscat (szPathBuffer, _T("\\"));
|
||||||
|
_tcscat (szPathBuffer, pFileName);
|
||||||
|
|
||||||
|
p = szPathBuffer + _tcslen (szPathBuffer);
|
||||||
|
|
||||||
|
for (n = 0; n < nExtCount; n++)
|
||||||
{
|
{
|
||||||
_tcscpy (temp, fname);
|
_tcscpy (p, ext[n]);
|
||||||
_tcscat (temp, ext[x]);
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf ("Checking for %s\n", temp);
|
DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer);
|
||||||
#endif
|
#endif
|
||||||
if (_tcschr (fname, _T('\\')))
|
|
||||||
|
if (IsValidFileName (szPathBuffer))
|
||||||
{
|
{
|
||||||
if (IsValidFileName (temp))
|
#ifdef _DEBUG
|
||||||
{
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
_tcscpy (fullbuffer, temp);
|
#endif
|
||||||
|
free (pszBuffer);
|
||||||
|
_tcscpy (pFullName, szPathBuffer);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* search in PATH */
|
||||||
|
s = pszBuffer;
|
||||||
|
while (s && *s)
|
||||||
|
{
|
||||||
|
f = _tcschr (s, _T(';'));
|
||||||
|
|
||||||
|
if (f)
|
||||||
|
{
|
||||||
|
_tcsncpy (szPathBuffer, s, (size_t)(f-s));
|
||||||
|
szPathBuffer[f-s] = _T('\0');
|
||||||
|
s = f + 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_searchenv (temp, _T("PATH"), fullbuffer);
|
_tcscpy (szPathBuffer, s);
|
||||||
if (*fullbuffer != '\0')
|
s = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\'))
|
||||||
|
_tcscat (szPathBuffer, _T("\\"));
|
||||||
|
_tcscat (szPathBuffer, pFileName);
|
||||||
|
|
||||||
|
p = szPathBuffer + _tcslen (szPathBuffer);
|
||||||
|
|
||||||
|
for (n = 0; n < nExtCount; n++)
|
||||||
|
{
|
||||||
|
_tcscpy (p, ext[n]);
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (IsValidFileName (szPathBuffer))
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
|
#endif
|
||||||
|
free (pszBuffer);
|
||||||
|
_tcscpy (pFullName, szPathBuffer);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* there is an extension... don't test other extensions */
|
/* There is an extension and it is in the last path component, */
|
||||||
/* make sure that the extention is one of the four */
|
/* so don't test all the extensions. */
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf ("No filename extension!\n");
|
DebugPrintf (_T("Filename extension!\n"));
|
||||||
#endif
|
#endif
|
||||||
for (x = 0; x < nExtCount; x++)
|
|
||||||
{
|
/* search in current directory */
|
||||||
if (!_tcsicmp (_tcsrchr (fname, _T('.')), ext[x]))
|
GetCurrentDirectory (MAX_PATH, szPathBuffer);
|
||||||
{
|
if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\'))
|
||||||
if (_tcschr (fname, _T('\\')))
|
_tcscat (szPathBuffer, _T("\\"));
|
||||||
{
|
_tcscat (szPathBuffer, pFileName);
|
||||||
if (IsValidFileName (fname))
|
|
||||||
{
|
|
||||||
_tcscpy (fullbuffer, fname);
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf ("Found: %s\n", fullbuffer);
|
DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
if (IsValidFileName (szPathBuffer))
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
|
#endif
|
||||||
|
free (pszBuffer);
|
||||||
|
_tcscpy (pFullName, szPathBuffer);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* search in PATH */
|
||||||
|
s = pszBuffer;
|
||||||
|
while (s && *s)
|
||||||
|
{
|
||||||
|
f = _tcschr (s, _T(';'));
|
||||||
|
|
||||||
|
if (f)
|
||||||
|
{
|
||||||
|
_tcsncpy (szPathBuffer, s, (size_t)(f-s));
|
||||||
|
szPathBuffer[f-s] = _T('\0');
|
||||||
|
s = f + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_tcscpy (szPathBuffer, s);
|
||||||
|
s = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\'))
|
||||||
|
_tcscat (szPathBuffer, _T("\\"));
|
||||||
|
_tcscat (szPathBuffer, pFileName);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf ("Checking for %s\n", fname);
|
DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer);
|
||||||
#endif
|
#endif
|
||||||
_searchenv (fname, _T("PATH"), fullbuffer);
|
if (IsValidFileName (szPathBuffer))
|
||||||
if (*fullbuffer != _T('\0'))
|
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf ("Found: %s\n", fullbuffer);
|
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
free (pszBuffer);
|
||||||
|
_tcscpy (pFullName, szPathBuffer);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
free (pszBuffer);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ typedef struct _BEEP_DEVICE_EXTENSION
|
||||||
KDPC Dpc;
|
KDPC Dpc;
|
||||||
KTIMER Timer;
|
KTIMER Timer;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
DWORD BeepOn;
|
LONG BeepOn;
|
||||||
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
/* set up device extension */
|
/* set up device extension */
|
||||||
pDeviceObject->Flags |= DO_BUFFERED_IO;
|
pDeviceObject->Flags |= DO_BUFFERED_IO;
|
||||||
pDeviceExtension = pDeviceObject->DeviceExtension;
|
pDeviceExtension = pDeviceObject->DeviceExtension;
|
||||||
pDeviceExtension->BeepOn = FALSE;
|
pDeviceExtension->BeepOn = 0; /* FALSE */
|
||||||
|
|
||||||
KeInitializeDpc (&(pDeviceExtension->Dpc),
|
KeInitializeDpc (&(pDeviceExtension->Dpc),
|
||||||
BeepDPC,
|
BeepDPC,
|
||||||
|
|
|
@ -313,11 +313,17 @@ typedef DWORD SERVICE_STATUS_HANDLE;
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
typedef unsigned short TBYTE;
|
typedef unsigned short TBYTE;
|
||||||
|
#ifndef _TCHAR_DEFINED
|
||||||
|
#define _TCHAR_DEFINED
|
||||||
typedef unsigned short TCHAR;
|
typedef unsigned short TCHAR;
|
||||||
|
#endif /* _TCHAR_DEFINED */
|
||||||
typedef unsigned short BCHAR;
|
typedef unsigned short BCHAR;
|
||||||
#else
|
#else
|
||||||
typedef unsigned char TBYTE;
|
typedef unsigned char TBYTE;
|
||||||
|
#ifndef _TCHAR_DEFINED
|
||||||
|
#define _TCHAR_DEFINED
|
||||||
typedef char TCHAR;
|
typedef char TCHAR;
|
||||||
|
#endif /* _TCHAR_DEFINED */
|
||||||
typedef BYTE BCHAR;
|
typedef BYTE BCHAR;
|
||||||
#endif /* UNICODE */
|
#endif /* UNICODE */
|
||||||
|
|
||||||
|
|
231
reactos/include/tchar.h
Normal file
231
reactos/include/tchar.h
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
/*
|
||||||
|
* tchar.h
|
||||||
|
*
|
||||||
|
* Unicode mapping layer for the standard C library. By including this
|
||||||
|
* file and using the 't' names for string functions
|
||||||
|
* (eg. _tprintf) you can make code which can be easily adapted to both
|
||||||
|
* Unicode and non-unicode environments. In a unicode enabled compile define
|
||||||
|
* _UNICODE before including tchar.h, otherwise the standard non-unicode
|
||||||
|
* library functions will be used.
|
||||||
|
*
|
||||||
|
* Note that you still need to include string.h or stdlib.h etc. to define
|
||||||
|
* the appropriate functions. Also note that there are several defines
|
||||||
|
* included for non-ANSI functions which are commonly available (but using
|
||||||
|
* the convention of prepending an underscore to non-ANSI library function
|
||||||
|
* names).
|
||||||
|
*
|
||||||
|
* This file is part of the Mingw32 package.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||||
|
*
|
||||||
|
* This source code is offered for use in the public domain. You may
|
||||||
|
* use, modify or distribute it freely.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful but
|
||||||
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||||
|
* DISCLAMED. This includes but is not limited to warranties of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* $Revision: 1.1 $
|
||||||
|
* $Author: ekohl $
|
||||||
|
* $Date: 1999/03/21 21:32:44 $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TCHAR_H_
|
||||||
|
#define _TCHAR_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: This tests _UNICODE, which is different from the UNICODE define
|
||||||
|
* used to differentiate Win32 API calls.
|
||||||
|
*/
|
||||||
|
#ifdef _UNICODE
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use TCHAR instead of char or wchar_t. It will be appropriately translated
|
||||||
|
* if _UNICODE is correctly defined (or not).
|
||||||
|
*/
|
||||||
|
#ifndef _TCHAR_DEFINED
|
||||||
|
#ifndef RC_INVOKED
|
||||||
|
typedef wchar_t TCHAR;
|
||||||
|
#endif /* Not RC_INVOKED */
|
||||||
|
#define _TCHAR_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enclose constant strings and literal characters in the _TEXT and _T macro to make
|
||||||
|
* them unicode constant strings when _UNICODE is defined.
|
||||||
|
*/
|
||||||
|
#define _TEXT(x) L ## x
|
||||||
|
#define _T(x) L ## x
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unicode functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _tprintf wprintf
|
||||||
|
#define _ftprintf fwprintf
|
||||||
|
#define _stprintf swprintf
|
||||||
|
#define _sntprintf _snwprintf
|
||||||
|
#define _vtprintf vwprintf
|
||||||
|
#define _vftprintf vfwprintf
|
||||||
|
#define _vstprintf vswprintf
|
||||||
|
#define _vsntprintf _vsnwprintf
|
||||||
|
#define _tscanf wscanf
|
||||||
|
#define _ftscanf fwscanf
|
||||||
|
#define _stscanf swscanf
|
||||||
|
#define _fgettc fgetwc
|
||||||
|
#define _fgettchar _fgetwchar
|
||||||
|
#define _fgetts fgetws
|
||||||
|
#define _fputtc fputwc
|
||||||
|
#define _fputtchar _fputwchar
|
||||||
|
#define _fputts fputws
|
||||||
|
#define _gettc getwc
|
||||||
|
#define _getts getws
|
||||||
|
#define _puttc putwc
|
||||||
|
#define _putts putws
|
||||||
|
#define _ungettc ungetwc
|
||||||
|
#define _tcstod wcstod
|
||||||
|
#define _tcstol wcstol
|
||||||
|
#define _tcstoul wcstoul
|
||||||
|
#define _tcscat wcscat
|
||||||
|
#define _tcschr wcschr
|
||||||
|
#define _tcscmp wcscmp
|
||||||
|
#define _tcscpy wcscpy
|
||||||
|
#define _tcscspn wcscspn
|
||||||
|
#define _tcslen wcslen
|
||||||
|
#define _tcsncat wcsncat
|
||||||
|
#define _tcsncmp wcsncmp
|
||||||
|
#define _tcsncpy wcsncpy
|
||||||
|
#define _tcspbrk wcspbrk
|
||||||
|
#define _tcsrchr wcsrchr
|
||||||
|
#define _tcsspn wcsspn
|
||||||
|
#define _tcsstr wcsstr
|
||||||
|
#define _tcstok wcstok
|
||||||
|
#define _tcsdup _wcsdup
|
||||||
|
#define _tcsicmp _wcsicmp
|
||||||
|
#define _tcsnicmp _wcsnicmp
|
||||||
|
#define _tcsnset _wcsnset
|
||||||
|
#define _tcsrev _wcsrev
|
||||||
|
#define _tcsset _wcsset
|
||||||
|
#define _tcslwr _wcslwr
|
||||||
|
#define _tcsupr _wcsupr
|
||||||
|
#define _tcsxfrm wcsxfrm
|
||||||
|
#define _tcscoll wcscoll
|
||||||
|
#define _tcsicoll _wcsicoll
|
||||||
|
#define _istalpha iswalpha
|
||||||
|
#define _istupper iswupper
|
||||||
|
#define _istlower iswlower
|
||||||
|
#define _istdigit iswdigit
|
||||||
|
#define _istxdigit iswxdigit
|
||||||
|
#define _istspace iswspace
|
||||||
|
#define _istpunct iswpunct
|
||||||
|
#define _istalnum iswalnum
|
||||||
|
#define _istprint iswprint
|
||||||
|
#define _istgraph iswgraph
|
||||||
|
#define _istcntrl iswcntrl
|
||||||
|
#define _istascii iswascii
|
||||||
|
#define _totupper towupper
|
||||||
|
#define _totlower towlower
|
||||||
|
#define _ttoi _wtoi
|
||||||
|
#define _tcsftime wcsftime
|
||||||
|
|
||||||
|
#else /* Not _UNICODE */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TCHAR, the type you should use instead of char.
|
||||||
|
*/
|
||||||
|
#ifndef _TCHAR_DEFINED
|
||||||
|
#ifndef RC_INVOKED
|
||||||
|
typedef char TCHAR;
|
||||||
|
#endif
|
||||||
|
#define _TCHAR_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enclose constant strings and characters in the _TEXT and _T macro.
|
||||||
|
*/
|
||||||
|
#define _TEXT(x) x
|
||||||
|
#define _T(x) x
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non-unicode (standard) functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _tprintf printf
|
||||||
|
#define _ftprintf fprintf
|
||||||
|
#define _stprintf sprintf
|
||||||
|
#define _sntprintf _snprintf
|
||||||
|
#define _vtprintf vprintf
|
||||||
|
#define _vftprintf vfprintf
|
||||||
|
#define _vstprintf vsprintf
|
||||||
|
#define _vsntprintf _vsnprintf
|
||||||
|
#define _tscanf scanf
|
||||||
|
#define _ftscanf fscanf
|
||||||
|
#define _stscanf sscanf
|
||||||
|
#define _fgettc fgetc
|
||||||
|
#define _fgettchar _fgetchar
|
||||||
|
#define _fgetts fgets
|
||||||
|
#define _fputtc fputc
|
||||||
|
#define _fputtchar _fputchar
|
||||||
|
#define _fputts fputs
|
||||||
|
#define _gettc getc
|
||||||
|
#define _getts gets
|
||||||
|
#define _puttc putc
|
||||||
|
#define _putts puts
|
||||||
|
#define _ungettc ungetc
|
||||||
|
#define _tcstod strtod
|
||||||
|
#define _tcstol strtol
|
||||||
|
#define _tcstoul strtoul
|
||||||
|
#define _tcscat strcat
|
||||||
|
#define _tcschr strchr
|
||||||
|
#define _tcscmp strcmp
|
||||||
|
#define _tcscpy strcpy
|
||||||
|
#define _tcscspn strcspn
|
||||||
|
#define _tcslen strlen
|
||||||
|
#define _tcsncat strncat
|
||||||
|
#define _tcsncmp strncmp
|
||||||
|
#define _tcsncpy strncpy
|
||||||
|
#define _tcspbrk strpbrk
|
||||||
|
#define _tcsrchr strrchr
|
||||||
|
#define _tcsspn strspn
|
||||||
|
#define _tcsstr strstr
|
||||||
|
#define _tcstok strtok
|
||||||
|
#define _tcsdup _strdup
|
||||||
|
#define _tcsicmp _stricmp
|
||||||
|
#define _tcsnicmp _strnicmp
|
||||||
|
#define _tcsnset _strnset
|
||||||
|
#define _tcsrev _strrev
|
||||||
|
#define _tcsset _strset
|
||||||
|
#define _tcslwr _strlwr
|
||||||
|
#define _tcsupr _strupr
|
||||||
|
#define _tcsxfrm strxfrm
|
||||||
|
#define _tcscoll strcoll
|
||||||
|
#define _tcsicoll _stricoll
|
||||||
|
#define _istalpha isalpha
|
||||||
|
#define _istupper isupper
|
||||||
|
#define _istlower islower
|
||||||
|
#define _istdigit isdigit
|
||||||
|
#define _istxdigit isxdigit
|
||||||
|
#define _istspace isspace
|
||||||
|
#define _istpunct ispunct
|
||||||
|
#define _istalnum isalnum
|
||||||
|
#define _istprint isprint
|
||||||
|
#define _istgraph isgraph
|
||||||
|
#define _istcntrl iscntrl
|
||||||
|
#define _istascii isascii
|
||||||
|
#define _totupper toupper
|
||||||
|
#define _totlower tolower
|
||||||
|
#define _ttoi atoi
|
||||||
|
#define _tcsftime strftime
|
||||||
|
|
||||||
|
#endif /* Not _UNICODE */
|
||||||
|
|
||||||
|
#endif /* Not _TCHAR_H_ */
|
||||||
|
|
|
@ -39,7 +39,7 @@ KERNEL_SERVICES = blue parallel keyboard null mouse serial sound ide test sdisk
|
||||||
minix vfat
|
minix vfat
|
||||||
|
|
||||||
# cmd
|
# cmd
|
||||||
APPS = hello shell
|
APPS = hello shell cmd
|
||||||
|
|
||||||
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
|
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
Binary file not shown.
|
@ -26,7 +26,6 @@
|
||||||
* Redirection safe!
|
* Redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
* Added handling of multiple filenames.
|
* Added handling of multiple filenames.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_ATTRIB
|
#ifdef INCLUDE_CMD_ATTRIB
|
||||||
|
@ -38,6 +36,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,13 @@
|
||||||
* Unicode safe!
|
* Unicode safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _BATCH_H_INCLUDED_
|
||||||
|
#define _BATCH_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
typedef struct tagBATCHCONTEXT
|
typedef struct tagBATCHCONTEXT
|
||||||
{
|
{
|
||||||
|
@ -37,3 +40,5 @@ LPTSTR BatchParams (LPTSTR, LPTSTR);
|
||||||
VOID ExitBatch (LPTSTR);
|
VOID ExitBatch (LPTSTR);
|
||||||
BOOL Batch (LPTSTR, LPTSTR, LPTSTR);
|
BOOL Batch (LPTSTR, LPTSTR, LPTSTR);
|
||||||
LPTSTR ReadBatchLine (LPBOOL);
|
LPTSTR ReadBatchLine (LPBOOL);
|
||||||
|
|
||||||
|
#endif /* _BATCH_H_INCLUDED_ */
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_BEEP
|
#ifdef INCLUDE_CMD_BEEP
|
||||||
|
@ -48,8 +46,11 @@ INT cmd_beep (LPTSTR cmd, LPTSTR param)
|
||||||
if (bc == NULL)
|
if (bc == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,14 +25,13 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_CHCP
|
#ifdef INCLUDE_CMD_CHCP
|
||||||
|
@ -18,6 +16,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "chcp.h"
|
#include "chcp.h"
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_CLS
|
#ifdef INCLUDE_CMD_CLS
|
||||||
|
|
|
@ -105,14 +105,13 @@
|
||||||
* Replaced spawnl() by CreateProcess().
|
* Replaced spawnl() by CreateProcess().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// #include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
@ -125,7 +124,7 @@ 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 */
|
||||||
BOOL bCtrlBreak = FALSE; /* Ctrl-Break or Ctrl-C hit */
|
BOOL bCtrlBreak = FALSE; /* Ctrl-Break or Ctrl-C hit */
|
||||||
BOOL bIgnoreEcho = FALSE; /* Ignore 'newline' before 'cls' */
|
BOOL bIgnoreEcho = FALSE; /* Ignore 'newline' before 'cls' */
|
||||||
INT errorlevel = 0; /* Errorlevel of last launched external program */
|
INT nErrorLevel = 0; /* Errorlevel of last launched external program */
|
||||||
OSVERSIONINFO osvi;
|
OSVERSIONINFO osvi;
|
||||||
HANDLE hIn;
|
HANDLE hIn;
|
||||||
HANDLE hOut;
|
HANDLE hOut;
|
||||||
|
@ -179,9 +178,7 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
|
|
||||||
/* get the PATH environment variable and parse it */
|
/* get the PATH environment variable and parse it */
|
||||||
/* search the PATH environment variable for the binary */
|
/* search the PATH environment variable for the binary */
|
||||||
find_which (first, szFullName);
|
if (!SearchForExecutable (first, szFullName))
|
||||||
|
|
||||||
if (szFullName[0] == _T('\0'))
|
|
||||||
{
|
{
|
||||||
error_bad_command ();
|
error_bad_command ();
|
||||||
return;
|
return;
|
||||||
|
@ -209,7 +206,7 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
#endif
|
#endif
|
||||||
/* build command line for CreateProcess() */
|
/* build command line for CreateProcess() */
|
||||||
_tcscpy (szFullCmdLine, szFullName);
|
_tcscpy (szFullCmdLine, szFullName);
|
||||||
_tcscat (szFullCmdLine, " ");
|
_tcscat (szFullCmdLine, _T(" "));
|
||||||
_tcscat (szFullCmdLine, rest);
|
_tcscat (szFullCmdLine, rest);
|
||||||
|
|
||||||
/* fill startup info */
|
/* fill startup info */
|
||||||
|
@ -221,8 +218,10 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
|
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
|
||||||
0, NULL, NULL, &stui, &prci))
|
0, NULL, NULL, &stui, &prci))
|
||||||
{
|
{
|
||||||
|
DWORD dwExitCode;
|
||||||
WaitForSingleObject (prci.hProcess, INFINITE);
|
WaitForSingleObject (prci.hProcess, INFINITE);
|
||||||
GetExitCodeProcess (prci.hProcess, &errorlevel);
|
GetExitCodeProcess (prci.hProcess, &dwExitCode);
|
||||||
|
nErrorLevel = (INT)dwExitCode;
|
||||||
CloseHandle (prci.hThread);
|
CloseHandle (prci.hThread);
|
||||||
CloseHandle (prci.hProcess);
|
CloseHandle (prci.hProcess);
|
||||||
}
|
}
|
||||||
|
@ -688,7 +687,7 @@ ProcessInput (BOOL bFlag)
|
||||||
case _T('7'):
|
case _T('7'):
|
||||||
case _T('8'):
|
case _T('8'):
|
||||||
case _T('9'):
|
case _T('9'):
|
||||||
if (tp = FindArg (*ip - _T('0')))
|
if ((tp = FindArg (*ip - _T('0'))))
|
||||||
{
|
{
|
||||||
cp = stpcpy (cp, tp);
|
cp = stpcpy (cp, tp);
|
||||||
ip++;
|
ip++;
|
||||||
|
@ -698,12 +697,12 @@ ProcessInput (BOOL bFlag)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('?'):
|
case _T('?'):
|
||||||
cp += wsprintf (cp, _T("%u"), errorlevel);
|
cp += wsprintf (cp, _T("%u"), nErrorLevel);
|
||||||
ip++;
|
ip++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (tp = _tcschr (ip, _T('%')))
|
if ((tp = _tcschr (ip, _T('%'))))
|
||||||
{
|
{
|
||||||
char evar[512];
|
char evar[512];
|
||||||
*tp = _T('\0');
|
*tp = _T('\0');
|
||||||
|
@ -932,10 +931,13 @@ static VOID Initialize (int argc, char *argv[])
|
||||||
ShowCommands ();
|
ShowCommands ();
|
||||||
|
|
||||||
/* Set COMSPEC environment variable */
|
/* Set COMSPEC environment variable */
|
||||||
|
if (argv)
|
||||||
SetEnvironmentVariable (_T("COMSPEC"), argv[0]);
|
SetEnvironmentVariable (_T("COMSPEC"), argv[0]);
|
||||||
|
|
||||||
/* add ctrl handler */
|
/* add ctrl handler */
|
||||||
|
#if 0
|
||||||
SetConsoleCtrlHandler (NULL, TRUE);
|
SetConsoleCtrlHandler (NULL, TRUE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -952,7 +954,9 @@ static VOID Cleanup (VOID)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* remove ctrl handler */
|
/* remove ctrl handler */
|
||||||
// SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler, FALSE);
|
#if 0
|
||||||
|
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler, FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -964,7 +968,9 @@ int main (int argc, char *argv[])
|
||||||
INT nExitCode;
|
INT nExitCode;
|
||||||
|
|
||||||
AllocConsole ();
|
AllocConsole ();
|
||||||
|
#ifndef __REACTOS__
|
||||||
SetFileApisToOEM ();
|
SetFileApisToOEM ();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* check switches on command-line */
|
/* check switches on command-line */
|
||||||
Initialize (argc, argv);
|
Initialize (argc, argv);
|
||||||
|
|
|
@ -11,18 +11,37 @@
|
||||||
* Moved error messages in here
|
* Moved error messages in here
|
||||||
*
|
*
|
||||||
* 07/12/98 (Rob Lake)
|
* 07/12/98 (Rob Lake)
|
||||||
* Moved more error messages here
|
* Moved more error messages here.
|
||||||
*
|
*
|
||||||
* 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
* 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
||||||
* Added compile date to version
|
* Added compile date to version.
|
||||||
|
*
|
||||||
|
* 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Introduced a new version string.
|
||||||
|
* Thanks to Emanuele Aliberti!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #define WIN32_LEAN_AND_MEAN
|
#ifndef _CMD_H_INCLUDED_
|
||||||
|
#define _CMD_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// #include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CMD_VER "0.1 pre 1"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
|
||||||
|
#else
|
||||||
|
#ifdef __LCC__
|
||||||
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", lcc-win32]"
|
||||||
|
#else
|
||||||
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ "]"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SHELLVER "version 0.0.4 [" __DATE__"]"
|
|
||||||
|
|
||||||
#define BREAK_BATCHFILE 1
|
#define BREAK_BATCHFILE 1
|
||||||
#define BREAK_OUTOFBATCH 2
|
#define BREAK_OUTOFBATCH 2
|
||||||
|
@ -48,7 +67,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CMD.C */
|
/* Prototypes for CMD.C */
|
||||||
extern HANDLE hOut;
|
extern HANDLE hOut;
|
||||||
extern HANDLE hIn;
|
extern HANDLE hIn;
|
||||||
extern WORD wColor;
|
extern WORD wColor;
|
||||||
|
@ -56,7 +75,7 @@ extern WORD wDefColor;
|
||||||
extern BOOL bCtrlBreak;
|
extern BOOL bCtrlBreak;
|
||||||
extern BOOL bIgnoreEcho;
|
extern BOOL bIgnoreEcho;
|
||||||
extern BOOL bExit;
|
extern BOOL bExit;
|
||||||
extern int errorlevel;
|
extern INT nErrorLevel;
|
||||||
extern SHORT maxx;
|
extern SHORT maxx;
|
||||||
extern SHORT maxy;
|
extern SHORT maxy;
|
||||||
extern OSVERSIONINFO osvi;
|
extern OSVERSIONINFO osvi;
|
||||||
|
@ -70,24 +89,32 @@ int c_brk(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for ALIAS.C */
|
/* Prototypes for ALIAS.C */
|
||||||
VOID ExpandAlias (char *, int);
|
VOID ExpandAlias (LPTSTR, INT);
|
||||||
INT cmd_alias (LPTSTR, LPTSTR);
|
INT cmd_alias (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototyped for ATTRIB.C */
|
/* Prototypes for ATTRIB.C */
|
||||||
INT cmd_attrib (LPTSTR, LPTSTR);
|
INT cmd_attrib (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CLS.C */
|
/* Prototypes for BEEP.C */
|
||||||
|
INT cmd_beep (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for CALL.C */
|
||||||
|
INT cmd_call (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for CLS.C */
|
||||||
INT cmd_cls (LPTSTR, LPTSTR);
|
INT cmd_cls (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CMDINPUT.C */
|
/* Prototypes for CMDINPUT.C */
|
||||||
VOID ReadCommand (LPTSTR, INT);
|
VOID ReadCommand (LPTSTR, INT);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CMDTABLE.C */
|
/* Prototypes for CMDTABLE.C */
|
||||||
#define CMD_SPECIAL 1
|
#define CMD_SPECIAL 1
|
||||||
#define CMD_BATCHONLY 2
|
#define CMD_BATCHONLY 2
|
||||||
|
|
||||||
|
@ -99,12 +126,12 @@ typedef struct tagCOMMAND
|
||||||
} COMMAND, *LPCOMMAND;
|
} COMMAND, *LPCOMMAND;
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for COLOR.C */
|
/* Prototypes for COLOR.C */
|
||||||
VOID SetScreenColor (WORD);
|
VOID SetScreenColor (WORD);
|
||||||
INT cmd_color (LPTSTR, LPTSTR);
|
INT cmd_color (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for CONSOLE.C */
|
/* Prototypes for CONSOLE.C */
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
VOID DebugPrintf (LPTSTR, ...);
|
VOID DebugPrintf (LPTSTR, ...);
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
|
@ -122,33 +149,33 @@ VOID ConErrChar (TCHAR);
|
||||||
VOID ConErrPuts (LPTSTR);
|
VOID ConErrPuts (LPTSTR);
|
||||||
VOID ConErrPrintf (LPTSTR, ...);
|
VOID ConErrPrintf (LPTSTR, ...);
|
||||||
|
|
||||||
|
SHORT GetCursorX (VOID);
|
||||||
SHORT wherex (VOID);
|
SHORT GetCursorY (VOID);
|
||||||
SHORT wherey (VOID);
|
VOID GetCursorXY (PSHORT, PSHORT);
|
||||||
VOID goxy (SHORT, SHORT);
|
VOID SetCursorXY (SHORT, SHORT);
|
||||||
|
|
||||||
VOID GetScreenSize (PSHORT, PSHORT);
|
VOID GetScreenSize (PSHORT, PSHORT);
|
||||||
VOID SetCursorType (BOOL, BOOL);
|
VOID SetCursorType (BOOL, BOOL);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for COPY.C */
|
/* Prototypes for COPY.C */
|
||||||
INT cmd_copy (LPTSTR, LPTSTR);
|
INT cmd_copy (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DATE.C */
|
/* Prototypes for DATE.C */
|
||||||
INT cmd_date (LPTSTR, LPTSTR);
|
INT cmd_date (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DEL.C */
|
/* Prototypes for DEL.C */
|
||||||
INT cmd_del (LPTSTR, LPTSTR);
|
INT cmd_del (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DIR.C */
|
/* Prototypes for DIR.C */
|
||||||
//int incline(int *line, unsigned flags);
|
//int incline(int *line, unsigned flags);
|
||||||
INT cmd_dir (LPTSTR, LPTSTR);
|
INT cmd_dir (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for DIRSTACK.C */
|
/* Prototypes for DIRSTACK.C */
|
||||||
VOID InitDirectoryStack (VOID);
|
VOID InitDirectoryStack (VOID);
|
||||||
VOID DestroyDirectoryStack (VOID);
|
VOID DestroyDirectoryStack (VOID);
|
||||||
INT GetDirectoryStackDepth (VOID);
|
INT GetDirectoryStackDepth (VOID);
|
||||||
|
@ -156,6 +183,10 @@ INT cmd_pushd (LPTSTR, LPTSTR);
|
||||||
INT cmd_popd (LPTSTR, LPTSTR);
|
INT cmd_popd (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for ECHO.C */
|
||||||
|
INT cmd_echo (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for ERROR.C */
|
/* Prototypes for ERROR.C */
|
||||||
VOID ErrorMessage (DWORD, LPTSTR, ...);
|
VOID ErrorMessage (DWORD, LPTSTR, ...);
|
||||||
|
|
||||||
|
@ -175,7 +206,7 @@ VOID error_syntax (LPTSTR);
|
||||||
VOID msg_pause (VOID);
|
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, INT);
|
||||||
INT ShowCompletionMatches (LPTSTR, INT);
|
INT ShowCompletionMatches (LPTSTR, INT);
|
||||||
|
@ -184,28 +215,36 @@ INT ShowCompletionMatches (LPTSTR, INT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for HISTORY.C */
|
/* Prototypes for FOR.C */
|
||||||
|
INT cmd_for (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for GOTO.C */
|
||||||
|
INT cmd_goto (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for HISTORY.C */
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
VOID History (INT, LPTSTR);
|
VOID History (INT, LPTSTR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for INTERNAL.C */
|
/* Prototypes for INTERNAL.C */
|
||||||
VOID InitLastPath (VOID);
|
VOID InitLastPath (VOID);
|
||||||
VOID FreeLastPath (VOID);
|
VOID FreeLastPath (VOID);
|
||||||
int cmd_chdir(char *, char *);
|
INT cmd_chdir (LPTSTR, LPTSTR);
|
||||||
int cmd_mkdir(char *, char *);
|
INT cmd_mkdir (LPTSTR, LPTSTR);
|
||||||
int cmd_rmdir(char *, char *);
|
INT cmd_rmdir (LPTSTR, LPTSTR);
|
||||||
int internal_exit(char *, char *);
|
INT internal_exit (LPTSTR, LPTSTR);
|
||||||
int cmd_rem(char *, char *);
|
INT cmd_rem (LPTSTR, LPTSTR);
|
||||||
int cmd_showcommands(char *, char *);
|
INT cmd_showcommands (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototyped for LABEL.C */
|
/* Prototypes for LABEL.C */
|
||||||
INT cmd_label (LPTSTR, LPTSTR);
|
INT cmd_label (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for LOCALE.C */
|
/* Prototypes for LOCALE.C */
|
||||||
extern TCHAR cDateSeparator;
|
extern TCHAR cDateSeparator;
|
||||||
extern INT nDateFormat;
|
extern INT nDateFormat;
|
||||||
extern TCHAR cTimeSeparator;
|
extern TCHAR cTimeSeparator;
|
||||||
|
@ -226,23 +265,24 @@ VOID freep (LPTSTR *);
|
||||||
LPTSTR stpcpy (LPTSTR, LPTSTR);
|
LPTSTR stpcpy (LPTSTR, LPTSTR);
|
||||||
BOOL IsValidPathName (LPCTSTR);
|
BOOL IsValidPathName (LPCTSTR);
|
||||||
BOOL IsValidFileName (LPCTSTR);
|
BOOL IsValidFileName (LPCTSTR);
|
||||||
|
BOOL IsValidDirectory (LPCTSTR);
|
||||||
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for MOVE.C */
|
/* Prototypes for MOVE.C */
|
||||||
INT cmd_move (LPTSTR, LPTSTR);
|
INT cmd_move (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes from PATH.C */
|
/* Prototypes from PATH.C */
|
||||||
INT cmd_path (LPTSTR, LPTSTR);
|
INT cmd_path (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes from PROMPT.C */
|
/* Prototypes from PROMPT.C */
|
||||||
VOID PrintPrompt (VOID);
|
VOID PrintPrompt (VOID);
|
||||||
INT cmd_prompt (LPTSTR, LPTSTR);
|
INT cmd_prompt (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for REDIR.C */
|
/* Prototypes for REDIR.C */
|
||||||
#define INPUT_REDIRECTION 1
|
#define INPUT_REDIRECTION 1
|
||||||
#define OUTPUT_REDIRECTION 2
|
#define OUTPUT_REDIRECTION 2
|
||||||
#define OUTPUT_APPEND 4
|
#define OUTPUT_APPEND 4
|
||||||
|
@ -251,50 +291,48 @@ INT cmd_prompt (LPTSTR, LPTSTR);
|
||||||
INT GetRedirection (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPINT);
|
INT GetRedirection (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPINT);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for REN.C */
|
/* Prototypes for REN.C */
|
||||||
INT cmd_rename (LPTSTR, LPTSTR);
|
INT cmd_rename (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for SET.C */
|
/* Prototypes for SET.C */
|
||||||
INT cmd_set (LPTSTR, LPTSTR);
|
INT cmd_set (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for TIME.C */
|
/* Prototypes for TIME.C */
|
||||||
INT cmd_time (LPTSTR, LPTSTR);
|
INT cmd_time (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for TYPE.C */
|
/* Prototypes for TITLE.C */
|
||||||
|
INT cmd_title (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for TYPE.C */
|
||||||
INT cmd_type (LPTSTR, LPTSTR);
|
INT cmd_type (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for VER.C */
|
/* Prototypes for VER.C */
|
||||||
VOID ShortVersion (VOID);
|
VOID ShortVersion (VOID);
|
||||||
INT cmd_ver (LPTSTR, LPTSTR);
|
INT cmd_ver (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for VERIFY.C */
|
/* Prototypes for VERIFY.C */
|
||||||
INT cmd_verify (LPTSTR, LPTSTR);
|
INT cmd_verify (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for VOL.C */
|
/* Prototypes for VOL.C */
|
||||||
INT cmd_vol (LPTSTR, LPTSTR);
|
INT cmd_vol (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for WHERE.C */
|
/* Prototypes for WHERE.C */
|
||||||
BOOL find_which (LPCTSTR, LPTSTR);
|
BOOL SearchForExecutable (LPCTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
|
/* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
|
||||||
int cmd_call(char *, char *);
|
|
||||||
int cmd_echo(char *, char *);
|
|
||||||
int cmd_for(char *, char *);
|
|
||||||
int cmd_goto(char *, char *);
|
|
||||||
int cmd_if(char *, char *);
|
int cmd_if(char *, char *);
|
||||||
int cmd_pause(char *, char *);
|
int cmd_pause(char *, char *);
|
||||||
int cmd_shift(char *, char *);
|
int cmd_shift(char *, char *);
|
||||||
|
|
||||||
int cmd_beep(char *, char *);
|
#endif /* _CMD_H_INCLUDED_ */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,14 +88,12 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*
|
*
|
||||||
* 04-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 04-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Fixed input bug. A "line feed" character remined in the keyboard
|
* Fixed input bug. A "line feed" character remained in the keyboard
|
||||||
* input queue when you pressed <RETURN>. This sometimes caused
|
* input queue when you pressed <RETURN>. This sometimes caused
|
||||||
* some very strange effects.
|
* some very strange effects.
|
||||||
* Fixed some command line editing annoyances.
|
* Fixed some command line editing annoyances.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -121,11 +119,15 @@ ClearCommandLine (LPTSTR str, INT maxlen, SHORT orgx, SHORT orgy)
|
||||||
{
|
{
|
||||||
INT count;
|
INT count;
|
||||||
|
|
||||||
goxy (orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
for (count = 0; count < (INT)_tcslen (str); count++)
|
for (count = 0; count < (INT)_tcslen (str); count++)
|
||||||
ConOutChar (_T(' '));
|
ConOutChar (_T(' '));
|
||||||
|
#ifndef __REACTOS__
|
||||||
_tcsnset (str, _T('\0'), maxlen);
|
_tcsnset (str, _T('\0'), maxlen);
|
||||||
goxy (orgx, orgy);
|
#else
|
||||||
|
memset (str, 0, maxlen * sizeof(TCHAR));
|
||||||
|
#endif
|
||||||
|
SetCursorXY (orgx, orgy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,8 +152,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (bEcho)
|
if (bEcho)
|
||||||
PrintPrompt();
|
PrintPrompt();
|
||||||
|
|
||||||
orgx = wherex ();
|
GetCursorXY (&orgx, &orgy);
|
||||||
orgy = wherey ();
|
|
||||||
|
|
||||||
memset (str, 0, maxlen * sizeof (TCHAR));
|
memset (str, 0, maxlen * sizeof (TCHAR));
|
||||||
|
|
||||||
|
@ -171,29 +172,28 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
{
|
{
|
||||||
/* if at end of line */
|
/* if at end of line */
|
||||||
str[current - 1] = _T('\0');
|
str[current - 1] = _T('\0');
|
||||||
if (wherex () != 0)
|
if (GetCursorX () != 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\b \b");
|
ConOutPrintf ("\b \b");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
ConOutChar (_T(' '));
|
ConOutChar (_T(' '));
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (count = current - 1; count < charcount; count++)
|
for (count = current - 1; count < charcount; count++)
|
||||||
str[count] = str[count + 1];
|
str[count] = str[count + 1];
|
||||||
if (wherex () != 0)
|
if (GetCursorX () != 0)
|
||||||
goxy ((SHORT)(wherex () - 1), wherey ());
|
SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ());
|
||||||
else
|
else
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
curx = wherex ();
|
GetCursorXY (&curx, &cury);
|
||||||
cury = wherey ();
|
|
||||||
ConOutPrintf (_T("%s "), &str[current - 1]);
|
ConOutPrintf (_T("%s "), &str[current - 1]);
|
||||||
goxy (curx, cury);
|
SetCursorXY (curx, cury);
|
||||||
}
|
}
|
||||||
charcount--;
|
charcount--;
|
||||||
current--;
|
current--;
|
||||||
|
@ -213,10 +213,9 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
for (count = current; count < charcount; count++)
|
for (count = current; count < charcount; count++)
|
||||||
str[count] = str[count + 1];
|
str[count] = str[count + 1];
|
||||||
charcount--;
|
charcount--;
|
||||||
curx = wherex ();
|
GetCursorXY (&curx, &cury);
|
||||||
cury = wherey ();
|
|
||||||
ConOutPrintf (_T("%s "), &str[current]);
|
ConOutPrintf (_T("%s "), &str[current]);
|
||||||
goxy (curx, cury);
|
SetCursorXY (curx, cury);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -224,7 +223,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
/* goto beginning of string */
|
/* goto beginning of string */
|
||||||
if (current != 0)
|
if (current != 0)
|
||||||
{
|
{
|
||||||
goxy (orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -233,7 +232,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
/* goto end of string */
|
/* goto end of string */
|
||||||
if (current != charcount)
|
if (current != charcount)
|
||||||
{
|
{
|
||||||
goxy (orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
ConOutPrintf (_T("%s"), str);
|
ConOutPrintf (_T("%s"), str);
|
||||||
current = charcount;
|
current = charcount;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +250,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
charcount = _tcslen (str);
|
charcount = _tcslen (str);
|
||||||
current = charcount;
|
current = charcount;
|
||||||
|
|
||||||
goxy(orgx, orgy);
|
SetCursorXY (orgx, orgy);
|
||||||
ConOutPrintf (_T("%s"), str);
|
ConOutPrintf (_T("%s"), str);
|
||||||
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
||||||
orgy--;
|
orgy--;
|
||||||
|
@ -262,15 +261,18 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (ShowCompletionMatches (str, charcount))
|
if (ShowCompletionMatches (str, charcount))
|
||||||
{
|
{
|
||||||
PrintPrompt ();
|
PrintPrompt ();
|
||||||
orgx = wherex ();
|
GetCursorXY (&orgx, &orgy);
|
||||||
orgy = wherey ();
|
|
||||||
ConOutPrintf (_T("%s"), str);
|
ConOutPrintf (_T("%s"), str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_4NT_FILENAME_COMPLETION
|
#ifdef FEATURE_4NT_FILENAME_COMPLETION
|
||||||
|
@ -330,15 +332,18 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (current > 0)
|
if (current > 0)
|
||||||
{
|
{
|
||||||
current--;
|
current--;
|
||||||
if (wherex () == 0)
|
if (GetCursorX () == 0)
|
||||||
goxy ((SHORT)(maxx - 1), (SHORT)(wherey () - 1));
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
else
|
else
|
||||||
goxy ((SHORT)(wherex () - 1), wherey ());
|
SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Beep (440, 100);
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -347,41 +352,47 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
if (current != charcount)
|
if (current != charcount)
|
||||||
{
|
{
|
||||||
current++;
|
current++;
|
||||||
if (wherex () == maxx - 1)
|
if (GetCursorX () == maxx - 1)
|
||||||
goxy (0, (SHORT)(wherey () + 1));
|
SetCursorXY (0, (SHORT)(GetCursorY () + 1));
|
||||||
else
|
else
|
||||||
goxy ((SHORT)(wherex () + 1), wherey ());
|
SetCursorXY ((SHORT)(GetCursorX () + 1), GetCursorY ());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
ch = ir.Event.KeyEvent.AsciiChar;
|
||||||
|
if ((ch >= 32) && (charcount != (maxlen - 2)))
|
||||||
|
{
|
||||||
|
#else
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
|
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
|
||||||
#else
|
#else
|
||||||
ch = ir.Event.KeyEvent.uChar.AsciiChar;
|
ch = ir.Event.KeyEvent.uChar.AsciiChar;
|
||||||
#endif
|
#endif /* _UNICODE */
|
||||||
if ((ch >= 32 && ch <= 255) && (charcount != (maxlen - 2)))
|
if ((ch >= 32 && ch <= 255) && (charcount != (maxlen - 2)))
|
||||||
{
|
{
|
||||||
|
#endif /* __REACTOS__ */
|
||||||
/* insert character into string... */
|
/* insert character into string... */
|
||||||
if (bInsert && current != charcount)
|
if (bInsert && current != charcount)
|
||||||
{
|
{
|
||||||
for (count = charcount; count > current; count--)
|
for (count = charcount; count > current; count--)
|
||||||
str[count] = str[count - 1];
|
str[count] = str[count - 1];
|
||||||
str[current++] = ch;
|
str[current++] = ch;
|
||||||
if (wherex () == maxx - 1)
|
if (GetCursorX () == maxx - 1)
|
||||||
{
|
{
|
||||||
curx = 0;
|
curx = 0;
|
||||||
cury = wherey () + 1;
|
cury = GetCursorY () + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
curx = wherex () + 1;
|
GetCursorXY (&curx, &cury);
|
||||||
cury = wherey ();
|
curx++;
|
||||||
}
|
}
|
||||||
ConOutPrintf (_T("%s"), &str[current - 1]);
|
ConOutPrintf (_T("%s"), &str[current - 1]);
|
||||||
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
if ((_tcslen (str) > (USHORT)(maxx - orgx)) && (orgy == maxy + 1))
|
||||||
cury--;
|
cury--;
|
||||||
goxy (curx, cury);
|
SetCursorXY (curx, cury);
|
||||||
charcount++;
|
charcount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -397,8 +408,11 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
#if 0
|
#if 0
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Beep (440, 100);
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 100);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
* Unicode ready!
|
* Unicode ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -175,6 +173,10 @@ COMMAND cmds[] =
|
||||||
{_T("time"), 0, cmd_time},
|
{_T("time"), 0, cmd_time},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_TITLE
|
||||||
|
{_T("title"), 0, cmd_title},
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TYPE
|
#ifdef INCLUDE_CMD_TYPE
|
||||||
{_T("type"), 0, cmd_type},
|
{_T("type"), 0, cmd_type},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COLOR
|
#ifdef INCLUDE_CMD_COLOR
|
||||||
|
|
|
@ -9,6 +9,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define __REACTOS__
|
||||||
|
|
||||||
|
#ifndef _CONFIG_H_INCLUDED_
|
||||||
|
#define _CONFIG_H_INCLUDED_
|
||||||
|
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif /* __REACTOS__ */
|
||||||
|
|
||||||
|
|
||||||
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
|
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
|
||||||
/*#define DEBUG */
|
/*#define DEBUG */
|
||||||
|
@ -38,22 +47,27 @@
|
||||||
/* Define one of these to select the used locale. */
|
/* Define one of these to select the used locale. */
|
||||||
/* (date and time formats etc.) used in DATE, TIME */
|
/* (date and time formats etc.) used in DATE, TIME */
|
||||||
/* DIR and PROMPT. */
|
/* DIR and PROMPT. */
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
#define LOCALE_DEFAULT
|
||||||
|
#else
|
||||||
#define LOCALE_WINDOWS /* System locale */
|
#define LOCALE_WINDOWS /* System locale */
|
||||||
/* #define LOCALE_GERMAN */ /* German locale */
|
/* #define LOCALE_GERMAN */ /* German locale */
|
||||||
/* #define LOCALE_DEFAULT */ /* United States locale */
|
/* #define LOCALE_DEFAULT */ /* United States locale */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define INCLUDE_CMD_ATTRIB
|
#define INCLUDE_CMD_ATTRIB
|
||||||
//#define INCLUDE_CMD_BREAK
|
/*#define INCLUDE_CMD_BREAK*/
|
||||||
#define INCLUDE_CMD_CHCP
|
#define INCLUDE_CMD_CHCP
|
||||||
#define INCLUDE_CMD_CHDIR
|
#define INCLUDE_CMD_CHDIR
|
||||||
#define INCLUDE_CMD_CLS
|
#define INCLUDE_CMD_CLS
|
||||||
#define INCLUDE_CMD_COLOR
|
#define INCLUDE_CMD_COLOR
|
||||||
#define INCLUDE_CMD_COPY
|
#define INCLUDE_CMD_COPY
|
||||||
//#define INCLUDE_CMD_CTTY
|
/*#define INCLUDE_CMD_CTTY*/
|
||||||
#define INCLUDE_CMD_DATE
|
#define INCLUDE_CMD_DATE
|
||||||
#define INCLUDE_CMD_DEL
|
#define INCLUDE_CMD_DEL
|
||||||
|
#ifndef __REACTOS__
|
||||||
#define INCLUDE_CMD_DIR
|
#define INCLUDE_CMD_DIR
|
||||||
|
#endif
|
||||||
#define INCLUDE_CMD_LABEL
|
#define INCLUDE_CMD_LABEL
|
||||||
#define INCLUDE_CMD_MKDIR
|
#define INCLUDE_CMD_MKDIR
|
||||||
#define INCLUDE_CMD_MOVE
|
#define INCLUDE_CMD_MOVE
|
||||||
|
@ -63,6 +77,7 @@
|
||||||
#define INCLUDE_CMD_RENAME
|
#define INCLUDE_CMD_RENAME
|
||||||
#define INCLUDE_CMD_SET
|
#define INCLUDE_CMD_SET
|
||||||
#define INCLUDE_CMD_TIME
|
#define INCLUDE_CMD_TIME
|
||||||
|
#define INCLUDE_CMD_TITLE
|
||||||
#define INCLUDE_CMD_TYPE
|
#define INCLUDE_CMD_TYPE
|
||||||
#define INCLUDE_CMD_VER
|
#define INCLUDE_CMD_VER
|
||||||
#define INCLUDE_CMD_REM
|
#define INCLUDE_CMD_REM
|
||||||
|
@ -84,3 +99,6 @@ shift
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _CONFIG_H_INCLUDED_ */
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
* started
|
* started
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ VOID DebugPrintf (LPTSTR szFormat, ...)
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szOut, szFormat, arg_ptr);
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
OutputDebugString (szOut);
|
OutputDebugString (szOut);
|
||||||
|
@ -134,7 +135,7 @@ VOID ConOutPrintf (LPTSTR szFormat, ...)
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szOut, szFormat, arg_ptr);
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
||||||
|
@ -165,7 +166,7 @@ VOID ConErrPrintf (LPTSTR szFormat, ...)
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szOut, szFormat, arg_ptr);
|
_vstprintf (szOut, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
WriteFile (GetStdHandle (STD_ERROR_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
WriteFile (GetStdHandle (STD_ERROR_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
|
||||||
|
@ -174,10 +175,7 @@ VOID ConErrPrintf (LPTSTR szFormat, ...)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
VOID SetCursorXY (SHORT x, SHORT y)
|
||||||
* goxy -- move the cursor on the screen.
|
|
||||||
*/
|
|
||||||
VOID goxy (SHORT x, SHORT y)
|
|
||||||
{
|
{
|
||||||
COORD coPos;
|
COORD coPos;
|
||||||
|
|
||||||
|
@ -187,7 +185,18 @@ VOID goxy (SHORT x, SHORT y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHORT wherex (VOID)
|
VOID GetCursorXY (PSHORT x, PSHORT y)
|
||||||
|
{
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||||
|
|
||||||
|
*x = csbi.dwCursorPosition.X;
|
||||||
|
*y = csbi.dwCursorPosition.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SHORT GetCursorX (VOID)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
@ -197,7 +206,7 @@ SHORT wherex (VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHORT wherey (VOID)
|
SHORT GetCursorY (VOID)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
@ -229,45 +238,3 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible)
|
||||||
|
|
||||||
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID InitializePageOut (VOID)
|
|
||||||
{
|
|
||||||
sLineCount = 0;
|
|
||||||
|
|
||||||
if (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == FILE_TYPE_CHAR)
|
|
||||||
{
|
|
||||||
bPageable = TRUE;
|
|
||||||
GetScreenSize (NULL, &sMaxLines);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bPageable = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID TerminatePageOut (VOID)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int LinePageOut (LPTSTR szLine)
|
|
||||||
{
|
|
||||||
ConOutPuts (szLine);
|
|
||||||
|
|
||||||
if (bPageable)
|
|
||||||
{
|
|
||||||
sLineCount++;
|
|
||||||
if (sLineCount >= sMaxLines)
|
|
||||||
{
|
|
||||||
sLineCount = 0;
|
|
||||||
cmd_pause ("", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
* Replaced CRT io functions by Win32 io functions.
|
* Replaced CRT io functions by Win32 io functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COPY
|
#ifdef INCLUDE_CMD_COPY
|
||||||
|
@ -51,8 +49,8 @@ typedef struct tagFILES
|
||||||
|
|
||||||
|
|
||||||
static BOOL DoSwitches (LPTSTR, LPDWORD);
|
static BOOL DoSwitches (LPTSTR, LPDWORD);
|
||||||
static BOOL AddFile (LPFILES, char *, int *, int *, unsigned *);
|
static BOOL AddFile (LPFILES, char *, int *, int *, LPDWORD);
|
||||||
static BOOL AddFiles (LPFILES, char *, int *, int *, int *, unsigned *);
|
static BOOL AddFiles (LPFILES, char *, int *, int *, int *, LPDWORD);
|
||||||
static BOOL GetDestination (LPFILES, LPFILES);
|
static BOOL GetDestination (LPFILES, LPFILES);
|
||||||
static INT ParseCommand (LPFILES, int, char **, LPDWORD);
|
static INT ParseCommand (LPFILES, int, char **, LPDWORD);
|
||||||
static VOID DeleteFileList (LPFILES);
|
static VOID DeleteFileList (LPFILES);
|
||||||
|
@ -60,7 +58,8 @@ static INT Overwrite (LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL IsDirectory (LPTSTR fn)
|
static BOOL
|
||||||
|
IsDirectory (LPTSTR fn)
|
||||||
{
|
{
|
||||||
if (!IsValidFileName (fn))
|
if (!IsValidFileName (fn))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -68,7 +67,8 @@ static BOOL IsDirectory (LPTSTR fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
static BOOL
|
||||||
|
DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
||||||
{
|
{
|
||||||
if (!_tcsicmp (arg, _T("/-Y")))
|
if (!_tcsicmp (arg, _T("/-Y")))
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,7 @@ static BOOL DoSwitches (LPTSTR arg, LPDWORD lpdwFlags)
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
AddFile (LPFILES f, char *arg, int *source, int *dest, unsigned *flags)
|
AddFile (LPFILES f, char *arg, int *source, int *dest, LPDWORD flags)
|
||||||
{
|
{
|
||||||
if (*dest)
|
if (*dest)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ AddFile (LPFILES f, char *arg, int *source, int *dest, unsigned *flags)
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
AddFiles (LPFILES f, char *arg, int *source, int *dest,
|
AddFiles (LPFILES f, char *arg, int *source, int *dest,
|
||||||
int *count, unsigned *flags)
|
int *count, LPDWORD flags)
|
||||||
{
|
{
|
||||||
char t[128];
|
char t[128];
|
||||||
int j;
|
int j;
|
||||||
|
@ -202,7 +202,8 @@ AddFiles (LPFILES f, char *arg, int *source, int *dest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL GetDestination (LPFILES f, LPFILES dest)
|
static BOOL
|
||||||
|
GetDestination (LPFILES f, LPFILES dest)
|
||||||
{
|
{
|
||||||
LPFILES p;
|
LPFILES p;
|
||||||
LPFILES start = f;
|
LPFILES start = f;
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
* Fixed date input bug.
|
* Fixed date input bug.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DATE
|
#ifdef INCLUDE_CMD_DATE
|
||||||
|
@ -52,7 +50,7 @@ static WORD awMonths[2][13] =
|
||||||
static VOID
|
static VOID
|
||||||
PrintDate (VOID)
|
PrintDate (VOID)
|
||||||
{
|
{
|
||||||
#if 0
|
#ifdef __REACTOS__
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
|
|
||||||
GetLocalTime (&st);
|
GetLocalTime (&st);
|
||||||
|
@ -75,12 +73,13 @@ PrintDate (VOID)
|
||||||
aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay);
|
aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
TCHAR szDate[32];
|
TCHAR szDate[32];
|
||||||
|
|
||||||
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
|
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
|
||||||
szDate, sizeof (szDate));
|
szDate, sizeof (szDate));
|
||||||
ConOutPrintf (_T("Current date is: %s\n"), szDate);
|
ConOutPrintf (_T("Current date is: %s\n"), szDate);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +194,7 @@ ParseDate (LPTSTR s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if only entered two digits:
|
/* if only entered two digits: */
|
||||||
/* assume 2000's if value less than 80 */
|
/* assume 2000's if value less than 80 */
|
||||||
/* assume 1900's if value greater or equal 80 */
|
/* assume 1900's if value greater or equal 80 */
|
||||||
if (d.wYear <= 99)
|
if (d.wYear <= 99)
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
* First working version.
|
* First working version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DEL
|
#ifdef INCLUDE_CMD_DEL
|
||||||
|
@ -35,6 +33,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -97,6 +96,8 @@ static INT Prompt (LPTSTR str)
|
||||||
else if (*p == _T('\03'))
|
else if (*p == _T('\03'))
|
||||||
return PROMPT_BREAK;
|
return PROMPT_BREAK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return PROMPT_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,10 +106,11 @@
|
||||||
*
|
*
|
||||||
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Redirection safe!
|
* Redirection safe!
|
||||||
|
*
|
||||||
|
* 01-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Replaced all runtime io functions by their Win32 counterparts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_DIR
|
#ifdef INCLUDE_CMD_DIR
|
||||||
|
@ -119,15 +120,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <direct.h>
|
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
/* useful macro */
|
|
||||||
#define MEM_ERR error_out_of_memory(); return 1;
|
|
||||||
|
|
||||||
|
|
||||||
/* flag definitions */
|
/* flag definitions */
|
||||||
/* Changed hex to decimal, hex wouldn't work
|
/* Changed hex to decimal, hex wouldn't work
|
||||||
* if > 8, Rob Lake 06/17/98.
|
* if > 8, Rob Lake 06/17/98.
|
||||||
|
@ -148,9 +143,9 @@ enum
|
||||||
|
|
||||||
/* Globally save the # of dirs, files and bytes,
|
/* Globally save the # of dirs, files and bytes,
|
||||||
* probabaly later pass them to functions. Rob Lake */
|
* probabaly later pass them to functions. Rob Lake */
|
||||||
long recurse_dir_cnt;
|
static ULONG recurse_dir_cnt;
|
||||||
long recurse_file_cnt;
|
static ULONG recurse_file_cnt;
|
||||||
ULARGE_INTEGER recurse_bytes;
|
static ULARGE_INTEGER recurse_bytes;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -161,7 +156,6 @@ ULARGE_INTEGER recurse_bytes;
|
||||||
*/
|
*/
|
||||||
static VOID Help (VOID)
|
static VOID Help (VOID)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
ConOutPuts (_T("Displays a list of files and subdirectories in a directory.\n"
|
ConOutPuts (_T("Displays a list of files and subdirectories in a directory.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"DIR [drive:][path][filename] [/A] [/B] [/L] [/N] [/S] [/P] [/W] [/4]\n"
|
"DIR [drive:][path][filename] [/A] [/B] [/L] [/N] [/S] [/P] [/W] [/4]\n"
|
||||||
|
@ -183,43 +177,18 @@ static VOID Help (VOID)
|
||||||
"of the - (hyphen) can turn off defined swtiches. Ex. /-W would\n"
|
"of the - (hyphen) can turn off defined swtiches. Ex. /-W would\n"
|
||||||
"turn off printing in wide format.\n"
|
"turn off printing in wide format.\n"
|
||||||
));
|
));
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
InitializePageOut ();
|
|
||||||
LinePageOut (_T("Displays a list of files and subdirectories in a directory."));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T("DIR [drive:][path][filename] [/A] [/B] [/L] [/N] [/S] [/P] [/W] [/4]"));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T(" [drive:][path][filename]"));
|
|
||||||
LinePageOut (_T(" Specifies drive, directory, and/or files to list."));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T(" /A Displays files with HIDDEN SYSTEM attributes"));
|
|
||||||
LinePageOut (_T(" default is ARCHIVE and READ ONLY"));
|
|
||||||
LinePageOut (_T(" /B Uses bare format (no heading information or summary)."));
|
|
||||||
LinePageOut (_T(" /L Uses lowercase."));
|
|
||||||
LinePageOut (_T(" /N New long list format where filenames are on the far right."));
|
|
||||||
LinePageOut (_T(" /S Displays files in specified directory and all subdirectories"));
|
|
||||||
LinePageOut (_T(" /P Pauses after each screen full"));
|
|
||||||
LinePageOut (_T(" /W Prints in wide format"));
|
|
||||||
LinePageOut (_T(" /4 Display four digit years."));
|
|
||||||
LinePageOut (_T(""));
|
|
||||||
LinePageOut (_T("Switches may be present in the DIRCMD environment variable. Use"));
|
|
||||||
LinePageOut (_T("of the - (hyphen) can turn off defined swtiches. Ex. /-W would"));
|
|
||||||
LinePageOut (_T("turn off printing in wide format."));
|
|
||||||
TerminatePageOut ();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dir_read_param
|
* DirReadParam
|
||||||
*
|
*
|
||||||
* read the parameters from the command line
|
* read the parameters from the command line
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL
|
||||||
DirReadParam (char *line, char **param, LPDWORD lpFlags)
|
DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
|
||||||
{
|
{
|
||||||
int slash = 0;
|
INT slash = 0;
|
||||||
|
|
||||||
if (!line)
|
if (!line)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -340,50 +309,35 @@ DirReadParam (char *line, char **param, LPDWORD lpFlags)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* extend_file
|
* ExtendFilespec
|
||||||
*
|
*
|
||||||
* extend the filespec, possibly adding wildcards
|
* extend the filespec, possibly adding wildcards
|
||||||
*/
|
*/
|
||||||
void extend_file (char **file)
|
static VOID
|
||||||
|
ExtendFilespec (LPTSTR file)
|
||||||
{
|
{
|
||||||
LPTSTR tmp;
|
if (!file)
|
||||||
|
|
||||||
if (!*file)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* if no file spec, change to "*.*" */
|
/* if no file spec, change to "*.*" */
|
||||||
if (!**file)
|
if (*file == _T('\0'))
|
||||||
{
|
{
|
||||||
free (*file);
|
_tcscpy (file, _T("*.*"));
|
||||||
*file = _tcsdup (_T("*.*"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if starts with . add * in front */
|
/* if starts with . add * in front */
|
||||||
if (**file == _T('.'))
|
if (*file == _T('.'))
|
||||||
{
|
{
|
||||||
tmp = malloc ((_tcslen (*file) + 2) * sizeof(TCHAR));
|
memmove (&file[1], &file[0], (_tcslen (file) + 1) * sizeof(TCHAR));
|
||||||
if (tmp)
|
file[0] = _T('*');
|
||||||
{
|
|
||||||
*tmp = _T('*');
|
|
||||||
_tcscpy (&tmp[1], *file);
|
|
||||||
}
|
|
||||||
free (*file);
|
|
||||||
*file = tmp;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if no . add .* */
|
/* if no . add .* */
|
||||||
if (!_tcschr (*file, _T('.')))
|
if (!_tcschr (file, _T('.')))
|
||||||
{
|
{
|
||||||
tmp = malloc ((_tcslen (*file) + 3) * sizeof(TCHAR));
|
_tcscat (file, _T(".*"));
|
||||||
if (tmp)
|
|
||||||
{
|
|
||||||
_tcscpy (tmp, *file);
|
|
||||||
_tcscat (tmp, _T(".*"));
|
|
||||||
}
|
|
||||||
free (*file);
|
|
||||||
*file = tmp;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,65 +348,55 @@ void extend_file (char **file)
|
||||||
*
|
*
|
||||||
* split the pathspec into drive, directory, and filespec
|
* split the pathspec into drive, directory, and filespec
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
DirParsePathspec (char *pathspec, int *drive, char **dir, char **file)
|
DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec)
|
||||||
{
|
{
|
||||||
TCHAR orig_dir[MAX_PATH];
|
TCHAR szOrigPath[MAX_PATH];
|
||||||
LPTSTR start;
|
LPTSTR start;
|
||||||
LPTSTR tmp;
|
LPTSTR tmp;
|
||||||
INT i;
|
INT i;
|
||||||
INT wildcards = 0;
|
BOOL bWildcards = FALSE;
|
||||||
|
|
||||||
|
GetCurrentDirectory (MAX_PATH, szOrigPath);
|
||||||
|
|
||||||
/* get the drive and change to it */
|
/* get the drive and change to it */
|
||||||
if (pathspec[1] == _T(':'))
|
if (szPathspec[1] == _T(':'))
|
||||||
{
|
{
|
||||||
*drive = _totupper (pathspec[0]) - _T('@');
|
TCHAR szRootPath[] = _T("A:");
|
||||||
start = pathspec + 2;
|
|
||||||
_chdrive (*drive);
|
szRootPath[0] = szPathspec[0];
|
||||||
|
start = szPathspec + 2;
|
||||||
|
SetCurrentDirectory (szRootPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*drive = _getdrive ();
|
start = szPathspec;
|
||||||
start = pathspec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCurrentDirectory (MAX_PATH, orig_dir);
|
|
||||||
|
|
||||||
/* check for wildcards */
|
/* check for wildcards */
|
||||||
for (i = 0; pathspec[i]; i++)
|
for (i = 0; szPathspec[i]; i++)
|
||||||
if (pathspec[i] == _T('*') || pathspec[i] == _T('?'))
|
{
|
||||||
wildcards = 1;
|
if (szPathspec[i] == _T('*') || szPathspec[i] == _T('?'))
|
||||||
|
bWildcards = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if this spec is a directory */
|
/* check if this spec is a directory */
|
||||||
if (!wildcards)
|
if (!bWildcards)
|
||||||
{
|
{
|
||||||
if (chdir(pathspec) == 0)
|
if (SetCurrentDirectory (szPathspec))
|
||||||
{
|
{
|
||||||
*file = _tcsdup (_T("*.*"));
|
_tcscpy (szFilespec, _T("*.*"));
|
||||||
if (!*file)
|
|
||||||
|
if (!GetCurrentDirectory (MAX_PATH, szPath))
|
||||||
{
|
{
|
||||||
MEM_ERR
|
szFilespec[0] = _T('\0');
|
||||||
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
error_out_of_memory();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = getcwd (NULL, MAX_PATH);
|
SetCurrentDirectory (szOrigPath);
|
||||||
if (!tmp)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
|
|
||||||
*dir = _tcsdup (&tmp[2]);
|
|
||||||
free (tmp);
|
|
||||||
if (!*dir)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
|
|
||||||
chdir (orig_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,69 +407,50 @@ DirParsePathspec (char *pathspec, int *drive, char **dir, char **file)
|
||||||
/* if no path is specified */
|
/* if no path is specified */
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
*file = _tcsdup (start);
|
_tcscpy (szFilespec, start);
|
||||||
extend_file (file);
|
ExtendFilespec (szFilespec);
|
||||||
if (!*file)
|
|
||||||
|
if (!GetCurrentDirectory (MAX_PATH, szPath))
|
||||||
{
|
{
|
||||||
MEM_ERR
|
szFilespec[0] = _T('\0');
|
||||||
}
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
error_out_of_memory();
|
||||||
tmp = getcwd (NULL, _MAX_PATH);
|
return 1;
|
||||||
if (!tmp)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
*dir = _tcsdup (&tmp[2]);
|
|
||||||
free(tmp);
|
|
||||||
if (!*dir)
|
|
||||||
{
|
|
||||||
free (*file);
|
|
||||||
chdir (orig_dir);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCurrentDirectory (szOrigPath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the filename */
|
/* get the filename */
|
||||||
*file = _tcsdup (tmp + 1);
|
_tcscpy (szFilespec, tmp+1);
|
||||||
extend_file (file);
|
ExtendFilespec (szFilespec);
|
||||||
if (!*file)
|
|
||||||
{
|
|
||||||
MEM_ERR
|
|
||||||
}
|
|
||||||
|
|
||||||
*tmp = 0;
|
*tmp = _T('\0');
|
||||||
|
|
||||||
/* change to this directory and get its full name */
|
/* change to this directory and get its full name */
|
||||||
if (chdir (start) < 0)
|
if (!SetCurrentDirectory (start))
|
||||||
{
|
{
|
||||||
error_path_not_found ();
|
|
||||||
*tmp = _T('\\');
|
*tmp = _T('\\');
|
||||||
free (*file);
|
szFilespec[0] = _T('\0');
|
||||||
chdir (orig_dir);
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
error_path_not_found ();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = getcwd (NULL, _MAX_PATH);
|
if (!GetCurrentDirectory (MAX_PATH, szPath))
|
||||||
if (!tmp)
|
|
||||||
{
|
{
|
||||||
free (*file);
|
*tmp = _T('\\');
|
||||||
MEM_ERR
|
szFilespec[0] = _T('\0');
|
||||||
}
|
SetCurrentDirectory (szOrigPath);
|
||||||
*dir = _tcsdup (&tmp[2]);
|
error_out_of_memory ();
|
||||||
free(tmp);
|
return 1;
|
||||||
if (!*dir)
|
|
||||||
{
|
|
||||||
free(*file);
|
|
||||||
MEM_ERR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*tmp = _T('\\');
|
*tmp = _T('\\');
|
||||||
|
|
||||||
chdir(orig_dir);
|
SetCurrentDirectory (szOrigPath);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,16 +475,16 @@ Pause (VOID)
|
||||||
* increment our line if paginating, display message at end of screen
|
* increment our line if paginating, display message at end of screen
|
||||||
*/
|
*/
|
||||||
static INT
|
static INT
|
||||||
incline (int *line, DWORD dwFlags)
|
IncLine (LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
if (!(dwFlags & DIR_PAGE))
|
if (!(dwFlags & DIR_PAGE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
(*line)++;
|
(*pLine)++;
|
||||||
|
|
||||||
if (*line >= (int)maxy - 2)
|
if (*pLine >= (int)maxy - 2)
|
||||||
{
|
{
|
||||||
*line = 0;
|
*pLine = 0;
|
||||||
return Pause ();
|
return Pause ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +498,7 @@ incline (int *line, DWORD dwFlags)
|
||||||
* print the header for the dir command
|
* print the header for the dir command
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL
|
||||||
PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
TCHAR szRootName[] = _T("A:\\");
|
TCHAR szRootName[] = _T("A:\\");
|
||||||
TCHAR szVolName[80];
|
TCHAR szVolName[80];
|
||||||
|
@ -583,7 +508,7 @@ PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* get the media ID of the drive */
|
/* get the media ID of the drive */
|
||||||
szRootName[0] = drive + _T('@');
|
szRootName[0] = szPath[0];
|
||||||
if (!GetVolumeInformation (szRootName, szVolName, 80, &dwSerialNr,
|
if (!GetVolumeInformation (szRootName, szVolName, 80, &dwSerialNr,
|
||||||
NULL, NULL, NULL, 0))
|
NULL, NULL, NULL, 0))
|
||||||
{
|
{
|
||||||
|
@ -599,13 +524,13 @@ PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
||||||
else
|
else
|
||||||
ConOutPrintf (_T(" has no label\n"));
|
ConOutPrintf (_T(" has no label\n"));
|
||||||
|
|
||||||
if (incline (line, dwFlags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* print the volume serial number if the return was successful */
|
/* print the volume serial number if the return was successful */
|
||||||
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
||||||
HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
||||||
if (incline (line, dwFlags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -618,7 +543,7 @@ PrintDirectoryHeader (int drive, int *line, DWORD dwFlags)
|
||||||
* insert commas into a number
|
* insert commas into a number
|
||||||
*/
|
*/
|
||||||
static INT
|
static INT
|
||||||
ConvertLong (LONG num, LPTSTR des, INT len)
|
ConvertULong (ULONG num, LPTSTR des, INT len)
|
||||||
{
|
{
|
||||||
TCHAR temp[32];
|
TCHAR temp[32];
|
||||||
INT c = 0;
|
INT c = 0;
|
||||||
|
@ -690,16 +615,17 @@ PrintFileDateTime (LPSYSTEMTIME dt, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
case 0: /* mmddyy */
|
case 0: /* mmddyy */
|
||||||
default:
|
default:
|
||||||
ConOutPrintf ("%.2d%c%.2d%c%d", dt->wMonth, cDateSeparator, dt->wDay, cDateSeparator, wYear);
|
ConOutPrintf (_T("%.2d%c%.2d%c%d"),
|
||||||
|
dt->wMonth, cDateSeparator, dt->wDay, cDateSeparator, wYear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* ddmmyy */
|
case 1: /* ddmmyy */
|
||||||
ConOutPrintf ("%.2d%c%.2d%c%d",
|
ConOutPrintf (_T("%.2d%c%.2d%c%d"),
|
||||||
dt->wDay, cDateSeparator, dt->wMonth, cDateSeparator, wYear);
|
dt->wDay, cDateSeparator, dt->wMonth, cDateSeparator, wYear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* yymmdd */
|
case 2: /* yymmdd */
|
||||||
ConOutPrintf ("%d%c%.2d%c%.2d",
|
ConOutPrintf (_T("%d%c%.2d%c%.2d"),
|
||||||
wYear, cDateSeparator, dt->wMonth, cDateSeparator, dt->wDay);
|
wYear, cDateSeparator, dt->wMonth, cDateSeparator, dt->wDay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -708,14 +634,14 @@ PrintFileDateTime (LPSYSTEMTIME dt, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
case 0: /* 12 hour format */
|
case 0: /* 12 hour format */
|
||||||
default:
|
default:
|
||||||
ConOutPrintf (" %2d%c%.2u%c",
|
ConOutPrintf (_T(" %2d%c%.2u%c"),
|
||||||
(dt->wHour == 0 ? 12 : (dt->wHour <= 12 ? dt->wHour : dt->wHour - 12)),
|
(dt->wHour == 0 ? 12 : (dt->wHour <= 12 ? dt->wHour : dt->wHour - 12)),
|
||||||
cTimeSeparator,
|
cTimeSeparator,
|
||||||
dt->wMinute, (dt->wHour <= 11 ? 'a' : 'p'));
|
dt->wMinute, (dt->wHour <= 11 ? 'a' : 'p'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* 24 hour format */
|
case 1: /* 24 hour format */
|
||||||
ConOutPrintf (" %2d%c%.2u",
|
ConOutPrintf (_T(" %2d%c%.2u"),
|
||||||
dt->wHour, cTimeSeparator, dt->wMinute);
|
dt->wHour, cTimeSeparator, dt->wMinute);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -729,33 +655,33 @@ PrintFileDateTime (LPSYSTEMTIME dt, DWORD dwFlags)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static INT
|
static INT
|
||||||
PrintSummary (int drive, long files, long dirs, ULARGE_INTEGER bytes,
|
PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes,
|
||||||
DWORD flags, int *line)
|
LPINT pLine, DWORD dwFlags)
|
||||||
{
|
{
|
||||||
TCHAR buffer[64];
|
TCHAR buffer[64];
|
||||||
|
|
||||||
if (flags & DIR_BARE)
|
if (dwFlags & DIR_BARE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* print number of files and bytes */
|
/* print number of files and bytes */
|
||||||
ConvertLong (files, buffer, sizeof(buffer));
|
ConvertULong (ulFiles, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %6s File%c"),
|
ConOutPrintf (_T(" %6s File%c"),
|
||||||
buffer, files == 1 ? _T(' ') : _T('s'));
|
buffer, ulFiles == 1 ? _T(' ') : _T('s'));
|
||||||
|
|
||||||
ConvertULargeInteger (bytes, buffer, sizeof(buffer));
|
ConvertULargeInteger (bytes, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %15s byte%c\n"),
|
ConOutPrintf (_T(" %15s byte%c\n"),
|
||||||
buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s'));
|
buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s'));
|
||||||
|
|
||||||
if (incline (line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* print number of dirs and bytes free */
|
/* print number of dirs and bytes free */
|
||||||
ConvertLong (dirs, buffer, sizeof(buffer));
|
ConvertULong (ulDirs, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %6s Dir%c"),
|
ConOutPrintf (_T(" %6s Dir%c"),
|
||||||
buffer, files == 1 ? _T(' ') : _T('s'));
|
buffer, ulDirs == 1 ? _T(' ') : _T('s'));
|
||||||
|
|
||||||
|
|
||||||
if (!(flags & DIR_RECURSE))
|
if (!(dwFlags & DIR_RECURSE))
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER uliFree;
|
ULARGE_INTEGER uliFree;
|
||||||
TCHAR szRoot[] = _T("A:\\");
|
TCHAR szRoot[] = _T("A:\\");
|
||||||
|
@ -764,14 +690,14 @@ PrintSummary (int drive, long files, long dirs, ULARGE_INTEGER bytes,
|
||||||
DWORD dwFreeCl;
|
DWORD dwFreeCl;
|
||||||
DWORD dwTotCl;
|
DWORD dwTotCl;
|
||||||
|
|
||||||
szRoot[0] = drive + _T('@');
|
szRoot[0] = szPath[0];
|
||||||
GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl);
|
GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl);
|
||||||
uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
|
uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
|
||||||
ConvertULargeInteger (uliFree, buffer, sizeof(buffer));
|
ConvertULargeInteger (uliFree, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %15s bytes free\n"), buffer);
|
ConOutPrintf (_T(" %15s bytes free\n"), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incline (line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -783,39 +709,37 @@ PrintSummary (int drive, long files, long dirs, ULARGE_INTEGER bytes,
|
||||||
*
|
*
|
||||||
* list the files in the directory
|
* list the files in the directory
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
dir_list (int drive, char *directory, char *filespec, int *line,
|
DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
DWORD flags)
|
|
||||||
{
|
{
|
||||||
char pathspec[_MAX_PATH],
|
TCHAR szFullPath[MAX_PATH];
|
||||||
*ext,
|
|
||||||
buffer[32];
|
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
ULARGE_INTEGER bytecount;
|
ULARGE_INTEGER bytecount;
|
||||||
long filecount = 0,
|
|
||||||
dircount = 0;
|
|
||||||
int count;
|
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
SYSTEMTIME dt;
|
SYSTEMTIME dt;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
TCHAR buffer[32];
|
||||||
|
ULONG filecount = 0;
|
||||||
|
ULONG dircount = 0;
|
||||||
|
INT count;
|
||||||
|
|
||||||
bytecount.QuadPart = 0;
|
bytecount.QuadPart = 0;
|
||||||
|
|
||||||
if (directory[strlen(directory) - 1] == '\\')
|
_tcscpy (szFullPath, szPath);
|
||||||
wsprintf(pathspec, "%c:%s%s", drive + '@', directory, filespec);
|
if (szFullPath[_tcslen(szFullPath) - 1] != _T('\\'))
|
||||||
else
|
_tcscat (szFullPath, _T("\\"));
|
||||||
wsprintf(pathspec, "%c:%s\\%s", drive + '@', directory, filespec);
|
_tcscat (szFullPath, szFilespec);
|
||||||
|
|
||||||
hFile = FindFirstFile (pathspec, &file);
|
hFile = FindFirstFile (szFullPath, &file);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/* Don't want to print anything if scanning recursively
|
/* Don't want to print anything if scanning recursively
|
||||||
* for a file. RL
|
* for a file. RL
|
||||||
*/
|
*/
|
||||||
if ((flags & DIR_RECURSE) == 0)
|
if ((dwFlags & DIR_RECURSE) == 0)
|
||||||
{
|
{
|
||||||
error_file_not_found();
|
error_file_not_found ();
|
||||||
incline(line, flags);
|
IncLine (pLine, dwFlags);
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -829,13 +753,13 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
* with nothing else
|
* with nothing else
|
||||||
* Rob Lake 06/13/98
|
* Rob Lake 06/13/98
|
||||||
*/
|
*/
|
||||||
if ((flags & DIR_BARE) == 0)
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf (" Directory of %c:%s\n", drive + '@', directory);
|
ConOutPrintf (_T(" Directory of %s\n"), szPath);
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,22 +769,23 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* next file, if user doesn't want all files */
|
/* next file, if user doesn't want all files */
|
||||||
if (!(flags & DIR_ALL) &&
|
if (!(dwFlags & DIR_ALL) &&
|
||||||
((file.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
|
((file.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
|
||||||
(file.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)))
|
(file.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* begin Rob Lake */
|
if (dwFlags & DIR_LWR)
|
||||||
if (flags & DIR_LWR)
|
|
||||||
{
|
{
|
||||||
strlwr(file.cAlternateFileName);
|
_tcslwr (file.cAlternateFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DIR_WIDE && (flags & DIR_BARE) == 0)
|
if (dwFlags & DIR_WIDE && (dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
|
ULARGE_INTEGER uliSize;
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (file.cAlternateFileName[0] == '\0')
|
if (file.cAlternateFileName[0] == _T('\0'))
|
||||||
wsprintf (buffer, _T("[%s]"), file.cFileName);
|
wsprintf (buffer, _T("[%s]"), file.cFileName);
|
||||||
else
|
else
|
||||||
wsprintf (buffer, _T("[%s]"), file.cAlternateFileName);
|
wsprintf (buffer, _T("[%s]"), file.cAlternateFileName);
|
||||||
|
@ -868,79 +793,82 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (file.cAlternateFileName[0] == '\0')
|
if (file.cAlternateFileName[0] == _T('\0'))
|
||||||
wsprintf (buffer, _T("%s"), file.cFileName);
|
wsprintf (buffer, _T("%s"), file.cFileName);
|
||||||
else
|
else
|
||||||
wsprintf (buffer, _T("%s"), file.cAlternateFileName);
|
wsprintf (buffer, _T("%s"), file.cAlternateFileName);
|
||||||
filecount++;
|
filecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConOutPrintf (_T("%-15s"), buffer);
|
ConOutPrintf (_T("%-15s"), buffer);
|
||||||
count++;
|
count++;
|
||||||
if (count == 5)
|
if (count == 5)
|
||||||
{
|
{
|
||||||
/* output 5 columns */
|
/* output 5 columns */
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: this is buggy - now overflow check */
|
uliSize.u.LowPart += file.nFileSizeLow;
|
||||||
bytecount.LowPart += file.nFileSizeLow;
|
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||||
bytecount.HighPart += file.nFileSizeHigh;
|
bytecount.QuadPart += uliSize.QuadPart;
|
||||||
|
|
||||||
/* next block 06/17/98 */
|
|
||||||
}
|
}
|
||||||
else if (flags & DIR_BARE)
|
else if (dwFlags & DIR_BARE)
|
||||||
{
|
{
|
||||||
if (strcmp(file.cFileName, ".") == 0 ||
|
ULARGE_INTEGER uliSize;
|
||||||
strcmp(file.cFileName, "..") == 0)
|
|
||||||
|
if (_tcscmp (file.cFileName, _T(".")) == 0 ||
|
||||||
|
_tcscmp (file.cFileName, _T("..")) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (flags & DIR_RECURSE)
|
if (dwFlags & DIR_RECURSE)
|
||||||
{
|
{
|
||||||
TCHAR dir[MAX_PATH];
|
TCHAR dir[MAX_PATH];
|
||||||
wsprintf (dir, _T("%c:%s\\"), drive + _T('@'), directory);
|
|
||||||
if (flags & DIR_LWR)
|
_tcscpy (dir, szPath);
|
||||||
strlwr(dir);
|
_tcscat (dir, _T("\\"));
|
||||||
|
if (dwFlags & DIR_LWR)
|
||||||
|
_tcslwr (dir);
|
||||||
ConOutPrintf (dir);
|
ConOutPrintf (dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConOutPrintf (_T("%-13s\n"), file.cFileName);
|
ConOutPrintf (_T("%-13s\n"), file.cFileName);
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
dircount++;
|
dircount++;
|
||||||
else
|
else
|
||||||
filecount++;
|
filecount++;
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* FIXME: this is buggy - no overflow check */
|
uliSize.u.LowPart += file.nFileSizeLow;
|
||||||
bytecount.LowPart += file.nFileSizeLow;
|
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||||
bytecount.HighPart += file.nFileSizeHigh;
|
bytecount.QuadPart += uliSize.QuadPart;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* end Rob Lake */
|
if (dwFlags & DIR_NEW)
|
||||||
if (flags & DIR_NEW)
|
|
||||||
{
|
{
|
||||||
/* print file date and time */
|
/* print file date and time */
|
||||||
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
||||||
{
|
{
|
||||||
FileTimeToSystemTime (&ft, &dt);
|
FileTimeToSystemTime (&ft, &dt);
|
||||||
PrintFileDateTime (&dt, flags);
|
PrintFileDateTime (&dt, dwFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print file size */
|
/* print file size */
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
ConOutPrintf (" <DIR> ");
|
ConOutPrintf (_T(" <DIR> "));
|
||||||
dircount++;
|
dircount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER uliSize;
|
ULARGE_INTEGER uliSize;
|
||||||
|
|
||||||
uliSize.LowPart = file.nFileSizeLow;
|
uliSize.u.LowPart = file.nFileSizeLow;
|
||||||
uliSize.HighPart = file.nFileSizeHigh;
|
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||||
|
|
||||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %20s"), buffer);
|
ConOutPrintf (_T(" %20s"), buffer);
|
||||||
|
@ -950,31 +878,35 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print long filename */
|
/* print long filename */
|
||||||
ConOutPrintf (" %s\n", file.cFileName);
|
ConOutPrintf (_T(" %s\n"), file.cFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (file.cFileName[0] == '.')
|
if (file.cFileName[0] == _T('.'))
|
||||||
ConOutPrintf ("%-13s ", file.cFileName);
|
ConOutPrintf (_T("%-13s "), file.cFileName);
|
||||||
else if (file.cAlternateFileName[0] == '\0')
|
else if (file.cAlternateFileName[0] == _T('\0'))
|
||||||
{
|
{
|
||||||
char szShortName[13];
|
TCHAR szShortName[13];
|
||||||
strncpy (szShortName, file.cFileName, 13);
|
LPTSTR ext;
|
||||||
ext = strchr(szShortName, '.');
|
|
||||||
|
_tcsncpy (szShortName, file.cFileName, 13);
|
||||||
|
ext = _tcschr (szShortName, _T('.'));
|
||||||
if (!ext)
|
if (!ext)
|
||||||
ext = "";
|
ext = _T("");
|
||||||
else
|
else
|
||||||
*ext++ = 0;
|
*ext++ = _T('\0');
|
||||||
ConOutPrintf ("%-8s %-3s ", szShortName, ext);
|
ConOutPrintf (_T("%-8s %-3s "), szShortName, ext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ext = strchr(file.cAlternateFileName, '.');
|
LPTSTR ext;
|
||||||
|
|
||||||
|
ext = _tcschr (file.cAlternateFileName, _T('.'));
|
||||||
if (!ext)
|
if (!ext)
|
||||||
ext = "";
|
ext = _T("");
|
||||||
else
|
else
|
||||||
*ext++ = 0;
|
*ext++ = _T('\0');
|
||||||
ConOutPrintf ("%-8s %-3s ", file.cAlternateFileName, ext);
|
ConOutPrintf (_T("%-8s %-3s "), file.cAlternateFileName, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print file size */
|
/* print file size */
|
||||||
|
@ -987,8 +919,8 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER uliSize;
|
ULARGE_INTEGER uliSize;
|
||||||
|
|
||||||
uliSize.LowPart = file.nFileSizeLow;
|
uliSize.u.LowPart = file.nFileSizeLow;
|
||||||
uliSize.HighPart = file.nFileSizeHigh;
|
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||||
|
|
||||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||||
ConOutPrintf (_T(" %10s "), buffer);
|
ConOutPrintf (_T(" %10s "), buffer);
|
||||||
|
@ -1001,27 +933,26 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
if (FileTimeToLocalFileTime (&file.ftLastWriteTime, &ft))
|
||||||
{
|
{
|
||||||
FileTimeToSystemTime (&ft, &dt);
|
FileTimeToSystemTime (&ft, &dt);
|
||||||
PrintFileDateTime (&dt, flags);
|
PrintFileDateTime (&dt, dwFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print long filename */
|
/* print long filename */
|
||||||
ConOutPrintf (" %s\n", file.cFileName);
|
ConOutPrintf (" %s\n", file.cFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (FindNextFile (hFile, &file));
|
while (FindNextFile (hFile, &file));
|
||||||
|
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
|
|
||||||
/* Rob Lake, need to make clean output */
|
/* Rob Lake, need to make clean output */
|
||||||
/* JPP 07/08/1998 added check for count != 0 */
|
/* JPP 07/08/1998 added check for count != 0 */
|
||||||
if ((flags & DIR_WIDE) && (count != 0))
|
if ((dwFlags & DIR_WIDE) && (count != 0))
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,9 +962,8 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
recurse_file_cnt += filecount;
|
recurse_file_cnt += filecount;
|
||||||
recurse_bytes.QuadPart += bytecount.QuadPart;
|
recurse_bytes.QuadPart += bytecount.QuadPart;
|
||||||
|
|
||||||
/* The code that was here is now in print_summary */
|
/* print_summary */
|
||||||
if (PrintSummary (drive, filecount, dircount,
|
if (PrintSummary (szPath, filecount, dircount, bytecount, pLine, dwFlags))
|
||||||
bytecount, flags, line) != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1049,43 +979,45 @@ dir_list (int drive, char *directory, char *filespec, int *line,
|
||||||
/*
|
/*
|
||||||
* _Read_Dir: Actual function that does recursive listing
|
* _Read_Dir: Actual function that does recursive listing
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
Read_Dir (int drive, char *parent, char *filespec, int *lines,
|
DirRead (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
DWORD flags)
|
|
||||||
{
|
{
|
||||||
char fullpath[_MAX_PATH];
|
TCHAR szFullPath[MAX_PATH];
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
|
||||||
strcpy (fullpath, parent);
|
_tcscpy (szFullPath, szPath);
|
||||||
strcat (fullpath, "\\");
|
if (szFullPath[_tcslen (szFullPath) - 1] != _T('\\'))
|
||||||
strcat (fullpath, filespec);
|
_tcscat (szFullPath, _T("\\"));
|
||||||
|
_tcscat (szFullPath, szFilespec);
|
||||||
|
|
||||||
hFile = FindFirstFile (fullpath, &file);
|
hFile = FindFirstFile (szFullPath, &file);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* don't list "." and ".." */
|
/* don't list "." and ".." */
|
||||||
if (strcmp (file.cFileName, ".") == 0 ||
|
if (_tcscmp (file.cFileName, _T(".")) == 0 ||
|
||||||
strcmp (file.cFileName, "..") == 0)
|
_tcscmp (file.cFileName, _T("..")) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (dir_list(drive, file.cFileName, filespec, lines, flags) != 0)
|
if (DirList (file.cFileName, szFilespec, pLine, dwFlags))
|
||||||
{
|
{
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if ((flags & DIR_BARE) == 0)
|
|
||||||
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf ("\n");
|
||||||
if (incline(lines, flags) != 0)
|
if (IncLine (pLine, dwFlags) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (Read_Dir(drive, file.cFileName, filespec, lines, flags) == 1)
|
|
||||||
|
if (DirRead (file.cFileName, szFilespec, pLine, dwFlags) == 1)
|
||||||
{
|
{
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1104,49 +1036,45 @@ Read_Dir (int drive, char *parent, char *filespec, int *lines,
|
||||||
/*
|
/*
|
||||||
* do_recurse: Sets up for recursive directory listing
|
* do_recurse: Sets up for recursive directory listing
|
||||||
*/
|
*/
|
||||||
static int
|
static INT
|
||||||
do_recurse(int drive, char *directory, char *filespec,
|
DirRecurse (LPTSTR szPath, LPTSTR szSpec, LPINT pLine, DWORD dwFlags)
|
||||||
int *line, DWORD flags)
|
|
||||||
{
|
{
|
||||||
char cur_dir[_MAX_DIR];
|
recurse_dir_cnt = 0L;
|
||||||
|
recurse_file_cnt = 0L;
|
||||||
recurse_dir_cnt = recurse_file_cnt = 0L;
|
|
||||||
recurse_bytes.QuadPart = 0;
|
recurse_bytes.QuadPart = 0;
|
||||||
|
|
||||||
_chdrive (drive);
|
if (!PrintDirectoryHeader (szPath, pLine, dwFlags))
|
||||||
getcwd(cur_dir, sizeof(cur_dir));
|
|
||||||
|
|
||||||
if (chdir(directory) == -1)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!PrintDirectoryHeader (drive, line, flags))
|
if (DirList (szPath, szSpec, pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (dir_list(drive, directory, filespec, line, flags) != 0)
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
return 1;
|
|
||||||
if ((flags & DIR_BARE) == 0)
|
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (Read_Dir(drive, directory, filespec, line, flags) != 0)
|
|
||||||
return 1;
|
|
||||||
if ((flags & DIR_BARE) == 0)
|
|
||||||
ConOutPrintf ("Total files listed:\n");
|
|
||||||
flags &= ~DIR_RECURSE;
|
|
||||||
|
|
||||||
if (PrintSummary (drive, recurse_file_cnt,
|
if (DirRead (szPath, szSpec, pLine, dwFlags))
|
||||||
recurse_dir_cnt, recurse_bytes, flags, line) != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((flags & DIR_BARE) == 0)
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
|
ConOutPrintf (_T("Total files listed:\n"));
|
||||||
|
|
||||||
|
dwFlags &= ~DIR_RECURSE;
|
||||||
|
|
||||||
|
if (PrintSummary (szPath, recurse_file_cnt,
|
||||||
|
recurse_dir_cnt, recurse_bytes, pLine, dwFlags))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if ((dwFlags & DIR_BARE) == 0)
|
||||||
{
|
{
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf (_T("\n"));
|
||||||
if (incline(line, flags) != 0)
|
if (IncLine (pLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
chdir(cur_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,14 +1087,11 @@ do_recurse(int drive, char *directory, char *filespec,
|
||||||
INT cmd_dir (LPTSTR first, LPTSTR rest)
|
INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||||
{
|
{
|
||||||
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
||||||
char *param;
|
|
||||||
TCHAR dircmd[256];
|
TCHAR dircmd[256];
|
||||||
int line = 0;
|
TCHAR szPath[MAX_PATH];
|
||||||
int drive,
|
TCHAR szFilespec[MAX_PATH];
|
||||||
orig_drive;
|
LPTSTR param;
|
||||||
char *directory,
|
INT nLine = 0;
|
||||||
*filespec,
|
|
||||||
orig_dir[_MAX_DIR];
|
|
||||||
|
|
||||||
|
|
||||||
/* read the parameters from the DIRCMD environment variable */
|
/* read the parameters from the DIRCMD environment variable */
|
||||||
|
@ -1184,39 +1109,26 @@ INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||||
if (!param)
|
if (!param)
|
||||||
param = ".";
|
param = ".";
|
||||||
|
|
||||||
if (strchr(param, '/'))
|
if (_tcschr (param, _T('/')))
|
||||||
param = strtok (param, "/");
|
param = _tcstok (param, _T("/"));
|
||||||
|
|
||||||
/* save the current directory info */
|
|
||||||
orig_drive = _getdrive ();
|
|
||||||
getcwd(orig_dir, sizeof(orig_dir));
|
|
||||||
|
|
||||||
/* parse the directory info */
|
/* parse the directory info */
|
||||||
if (DirParsePathspec (param, &drive, &directory, &filespec) != 0)
|
if (DirParsePathspec (param, szPath, szFilespec))
|
||||||
{
|
|
||||||
_chdrive (orig_drive);
|
|
||||||
chdir(orig_dir);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
if (dwFlags & DIR_RECURSE)
|
if (dwFlags & DIR_RECURSE)
|
||||||
{
|
{
|
||||||
incline(&line, dwFlags);
|
IncLine (&nLine, dwFlags);
|
||||||
if (do_recurse (drive, directory, filespec, &line, dwFlags) != 0)
|
if (DirRecurse (szPath, szFilespec, &nLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
_chdrive (orig_drive);
|
|
||||||
chdir (orig_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print the header */
|
/* print the header */
|
||||||
if (!PrintDirectoryHeader (drive, &line, dwFlags))
|
if (!PrintDirectoryHeader (szPath, &nLine, dwFlags))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
chdir (orig_dir);
|
if (DirList (szPath, szFilespec, &nLine, dwFlags))
|
||||||
_chdrive (orig_drive);
|
|
||||||
|
|
||||||
if (dir_list (drive, directory, filespec, &line, dwFlags) != 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef FEATURE_DIRECTORY_STACK
|
#ifdef FEATURE_DIRECTORY_STACK
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -17,12 +17,11 @@
|
||||||
* Use FormatMessage() for error reports.
|
* Use FormatMessage() for error reports.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
@ -53,10 +52,10 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
wvsprintf (szMessage, szFormat, arg_ptr);
|
_vstprintf (szMessage, szFormat, arg_ptr);
|
||||||
va_end (arg_ptr);
|
va_end (arg_ptr);
|
||||||
|
|
||||||
#if 1
|
#ifndef __REACTOS__
|
||||||
|
|
||||||
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
@ -69,7 +68,6 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode);
|
ConErrPrintf (_T("Unknown error! Error code: 0x%lx\n"), dwErrorCode);
|
||||||
// ConErrPrintf (_T("No error message available!\n"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,13 @@
|
||||||
* Cleanup. Unicode safe!
|
* Cleanup. Unicode safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA file;
|
WIN32_FIND_DATA file;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
|
||||||
INT curplace = 0;
|
INT curplace = 0;
|
||||||
INT start;
|
INT start;
|
||||||
INT count;
|
INT count;
|
||||||
|
@ -70,11 +68,11 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
_tcscpy (path, &str[start]);
|
_tcscpy (path, &str[start]);
|
||||||
|
|
||||||
/* look for a '.' in the filename */
|
/* look for a '.' in the filename */
|
||||||
for (count = _tcslen (directory); path[count] != 0; count++)
|
for (count = _tcslen (directory); path[count] != _T('\0'); count++)
|
||||||
{
|
{
|
||||||
if (path[count] == _T('.'))
|
if (path[count] == _T('.'))
|
||||||
{
|
{
|
||||||
found_dot = 1;
|
found_dot = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +92,8 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* ignore "." and ".." */
|
/* ignore "." and ".." */
|
||||||
if (file.cFileName[0] == _T('.'))
|
if (!_tcscmp (file.cFileName, _T(".")) ||
|
||||||
|
!_tcscmp (file.cFileName, _T("..")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_tcscpy (fname, file.cFileName);
|
_tcscpy (fname, file.cFileName);
|
||||||
|
@ -129,12 +128,20 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
_tcscat (&str[start], maxmatch);
|
_tcscat (&str[start], maxmatch);
|
||||||
|
|
||||||
if (!perfectmatch)
|
if (!perfectmatch)
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no match found */
|
/* no match found */
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +180,8 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
/* extract directory from word */
|
/* extract directory from word */
|
||||||
_tcscpy (directory, &str[start]);
|
_tcscpy (directory, &str[start]);
|
||||||
curplace = _tcslen (directory) - 1;
|
curplace = _tcslen (directory) - 1;
|
||||||
while (curplace >= 0 && directory[curplace] != _T('\\') &&
|
while (curplace >= 0 &&
|
||||||
|
directory[curplace] != _T('\\') &&
|
||||||
directory[curplace] != _T(':'))
|
directory[curplace] != _T(':'))
|
||||||
{
|
{
|
||||||
directory[curplace] = 0;
|
directory[curplace] = 0;
|
||||||
|
@ -183,7 +191,7 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
_tcscpy (path, &str[start]);
|
_tcscpy (path, &str[start]);
|
||||||
|
|
||||||
/* look for a . in the filename */
|
/* look for a . in the filename */
|
||||||
for (count = _tcslen (directory); path[count] != 0; count++)
|
for (count = _tcslen (directory); path[count] != _T('\0'); count++)
|
||||||
{
|
{
|
||||||
if (path[count] == _T('.'))
|
if (path[count] == _T('.'))
|
||||||
{
|
{
|
||||||
|
@ -191,6 +199,7 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_dot)
|
if (found_dot)
|
||||||
_tcscat (path, _T("*"));
|
_tcscat (path, _T("*"));
|
||||||
else
|
else
|
||||||
|
@ -208,7 +217,8 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* ignore . and .. */
|
/* ignore . and .. */
|
||||||
if (file.cFileName[0] == _T('.'))
|
if (!_tcscmp (file.cFileName, _T(".")) ||
|
||||||
|
!_tcscmp (file.cFileName, _T("..")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
@ -233,7 +243,11 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no match found */
|
/* no match found */
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
Beep (440, 50);
|
||||||
|
#else
|
||||||
MessageBeep (-1);
|
MessageBeep (-1);
|
||||||
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -23,13 +23,12 @@
|
||||||
* Added help text ("/?").
|
* Added help text ("/?").
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
|
|
|
@ -20,13 +20,12 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "batch.h"
|
#include "batch.h"
|
||||||
|
@ -98,7 +97,7 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
|
||||||
while (_istdigit (*pp))
|
while (_istdigit (*pp))
|
||||||
n = n * 10 + (*pp++ - _T('0'));
|
n = n * 10 + (*pp++ - _T('0'));
|
||||||
|
|
||||||
x_flag ^= (errorlevel < n) ? 0 : X_EXEC;
|
x_flag ^= (nErrorLevel < n) ? 0 : X_EXEC;
|
||||||
|
|
||||||
x_flag |= X_EMPTY; /* Syntax error if comd empty */
|
x_flag |= X_EMPTY; /* Syntax error if comd empty */
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,16 +115,19 @@
|
||||||
*
|
*
|
||||||
* 30-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 30-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Added "cd -" feature. Changes to the previous directory.
|
* Added "cd -" feature. Changes to the previous directory.
|
||||||
|
*
|
||||||
|
* 15-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Fixed bug in "cd -" feature. If the previous directory was a root
|
||||||
|
* directory, it was ignored.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -252,7 +255,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing \ if any, but ONLY if dir is not the root dir */
|
/* remove trailing \ if any, but ONLY if dir is not the root dir */
|
||||||
if (_tcslen (dir) >= 2 && dir[_tcslen (dir) - 1] == _T('\\'))
|
if (_tcslen (dir) > 3 && dir[_tcslen (dir) - 1] == _T('\\'))
|
||||||
dir[_tcslen(dir) - 1] = _T('\0');
|
dir[_tcslen(dir) - 1] = _T('\0');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* Unicode ready!
|
* Unicode ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_LABEL
|
#ifdef INCLUDE_CMD_LABEL
|
||||||
|
@ -23,6 +21,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
* Unicode safe!
|
* Unicode safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
#
|
#
|
||||||
|
# ReactOS makefile for CMD
|
||||||
#
|
#
|
||||||
|
|
||||||
LIB=../../lib
|
|
||||||
COMMON=../common
|
|
||||||
|
|
||||||
# target: raw binary (does not work right now)
|
# target: raw binary (does not work right now)
|
||||||
#all: cmd.bin
|
#all: cmd.bin
|
||||||
|
|
||||||
# target: executable (not tested/experimental)
|
# target: executable (not tested/experimental)
|
||||||
all: cmd.exe
|
all: cmd.exe
|
||||||
|
|
||||||
OBJECTS = $(COMMON)/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o cls.o cmdinput.o cmdtable.o\
|
OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o cls.o cmdinput.o cmdtable.o\
|
||||||
color.o date.o del.o dir.o echo.o err_hand.o error.o filecomp.o for.o goto.o history.o if.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 misc.o path.o pause.o redir.o ren.o set.o shift.o tempfile.o time.o type.o ver.o\
|
internal.o label.o locale.o misc.o move.o path.o pause.o prompt.o redir.o ren.o ros.o set.o shift.o time.o title.o type.o ver.o\
|
||||||
verify.o where.o
|
verify.o vol.o where.o
|
||||||
|
|
||||||
|
LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a
|
||||||
|
|
||||||
LIBS = $(LIB)/mingw32/mingw32.a $(LIB)/crtdll/crtdll.a \
|
|
||||||
$(LIB)/kernel32/kernel32.a $(LIB)/ntdll/ntdll.a
|
|
||||||
|
|
||||||
cmd.bin: $(OBJECTS)
|
cmd.bin: $(OBJECTS)
|
||||||
$(LD) -Ttext 0x10000 $(OBJECTS) $(LIBS) -o cmd.exe
|
$(LD) -Ttext 0x10000 $(OBJECTS) $(LIBS) -o cmd.exe
|
||||||
$(OBJCOPY) -O binary cmd.exe cmd.bin
|
$(OBJCOPY) -O binary cmd.exe cmd.bin
|
||||||
|
|
||||||
cmd.exe: $(OBJECTS)
|
cmd.exe: $(OBJECTS) $(LIBS)
|
||||||
$(LD) $(OBJECTS) $(LIBS) -o cmd.exe
|
$(CC) -specs=../../specs $(OBJECTS) $(LIBS) -lgcc -o cmd.exe
|
||||||
|
$(NM) --numeric-sort cmd.exe > cmd.sym
|
||||||
|
|
||||||
include ../../rules.mak
|
include ../../rules.mak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,13 @@
|
||||||
* FileGetString() seems to be working now.
|
* FileGetString() seems to be working now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <conio.h>
|
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
@ -45,32 +42,36 @@
|
||||||
*/
|
*/
|
||||||
TCHAR cgetchar (VOID)
|
TCHAR cgetchar (VOID)
|
||||||
{
|
{
|
||||||
TCHAR ch;
|
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
#if 0
|
INPUT_RECORD irBuffer;
|
||||||
DWORD dwRead;
|
DWORD dwRead;
|
||||||
DWORD dwOldMode;
|
|
||||||
HANDLE hIn;
|
|
||||||
|
|
||||||
hIn = GetStdHandle (STD_INPUT_HANDLE);
|
do
|
||||||
ConInSwallowInput (hIn);
|
{
|
||||||
|
WaitForSingleObject (hInput, INFINITE);
|
||||||
GetConsoleMode (hIn, &dwOldMode);
|
ReadConsoleInput (hInput, &irBuffer, 1, &dwRead);
|
||||||
SetConsoleMode (hIn, 0);
|
if ((irBuffer.EventType == KEY_EVENT) &&
|
||||||
|
(irBuffer.Event.KeyEvent.bKeyDown == TRUE))
|
||||||
ReadConsole (hIn, &ch, 1, &dwRead, NULL);
|
{
|
||||||
|
if ((irBuffer.Event.KeyEvent.dwControlKeyState &
|
||||||
DebugPrintf ("[cgetchar (0x%x) \'%c\']\n", ch, ch);
|
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) &
|
||||||
|
(irBuffer.Event.KeyEvent.wVirtualKeyCode == 'C'))
|
||||||
SetConsoleMode (hIn, dwOldMode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((ch = getch()) == 0)
|
|
||||||
ch = getch() << 8;
|
|
||||||
|
|
||||||
if (ch == 3)
|
|
||||||
bCtrlBreak = TRUE;
|
bCtrlBreak = TRUE;
|
||||||
|
|
||||||
return ch;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (TRUE);
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
return irBuffer.Event.KeyEvent.AsciiChar;
|
||||||
|
#else
|
||||||
|
#ifndef _UNICODE
|
||||||
|
return irBuffer.Event.KeyEvent.uChar.AsciiChar;
|
||||||
|
#else
|
||||||
|
return irBuffer.Event.KeyEvent.uChar.UnicodeChar;
|
||||||
|
#endif /* _UNICODE */
|
||||||
|
#endif /* __REACTOS__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,6 +267,11 @@ BOOL IsValidFileName (LPCTSTR pszPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL IsValidDirectory (LPCTSTR pszPath)
|
||||||
|
{
|
||||||
|
return (GetFileAttributes (pszPath) & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
* Added "/N" option.
|
* Added "/N" option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_MOVE
|
#ifdef INCLUDE_CMD_MOVE
|
||||||
|
@ -31,6 +29,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
* Fixed Win32 environment handling.
|
* Fixed Win32 environment handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_PATH
|
#ifdef INCLUDE_CMD_PATH
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
* Unicode ready!
|
* Unicode ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_PAUSE
|
#ifdef INCLUDE_CMD_PAUSE
|
||||||
|
|
|
@ -44,17 +44,85 @@
|
||||||
* Fixed Win32 environment handling.
|
* Fixed Win32 environment handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
static VOID PrintDate (VOID)
|
||||||
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
GetLocalTime (&st);
|
||||||
|
|
||||||
|
switch (nDateFormat)
|
||||||
|
{
|
||||||
|
case 0: /* mmddyy */
|
||||||
|
default:
|
||||||
|
ConOutPrintf (_T("%s %02d%c%02d%c%04d"),
|
||||||
|
aszDayNames[st.wDayOfWeek], st.wMonth, cDateSeparator, st.wDay, cDateSeparator, st.wYear);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: /* ddmmyy */
|
||||||
|
ConOutPrintf (_T("%s %02d%c%02d%c%04d"),
|
||||||
|
aszDayNames[st.wDayOfWeek], st.wDay, cDateSeparator, st.wMonth, cDateSeparator, st.wYear);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: /* yymmdd */
|
||||||
|
ConOutPrintf (_T("%s %04d%c%02d%c%02d"),
|
||||||
|
aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
TCHAR szDate[32];
|
||||||
|
|
||||||
|
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
|
||||||
|
szDate, sizeof (szDate));
|
||||||
|
ConOutPrintf (_T("%s"), szDate);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
PrintTime (VOID)
|
||||||
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
GetLocalTime (&st);
|
||||||
|
|
||||||
|
switch (nTimeFormat)
|
||||||
|
{
|
||||||
|
case 0: /* 12 hour format */
|
||||||
|
default:
|
||||||
|
ConOutPrintf (_T("%2d%c%02d%c%02d%c%02d%c"),
|
||||||
|
(st.wHour == 0 ? 12 : (st.wHour <= 12 ? st.wHour : st.wHour - 12)),
|
||||||
|
cTimeSeparator, st.wMinute, cTimeSeparator, st.wSecond, cDecimalSeparator,
|
||||||
|
st.wMilliseconds / 10, (st.wHour <= 11 ? 'a' : 'p'));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: /* 24 hour format */
|
||||||
|
ConOutPrintf (_T("%2d%c%02d%c%02d%c%02d"),
|
||||||
|
st.wHour, cTimeSeparator, st.wMinute, cTimeSeparator,
|
||||||
|
st.wSecond, cDecimalSeparator, st.wMilliseconds / 10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
TCHAR szTime[32];
|
||||||
|
|
||||||
|
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
|
||||||
|
szTime, sizeof (szTime));
|
||||||
|
ConOutPrintf (_T("%s"), szTime);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print the command-line prompt
|
* print the command-line prompt
|
||||||
*
|
*
|
||||||
|
@ -95,13 +163,7 @@ VOID PrintPrompt(VOID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('D'):
|
case _T('D'):
|
||||||
{
|
PrintDate ();
|
||||||
TCHAR szDate[32];
|
|
||||||
|
|
||||||
GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE,
|
|
||||||
NULL, NULL, szDate, sizeof (szDate));
|
|
||||||
ConOutPrintf (_T("%s"), szDate);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('E'):
|
case _T('E'):
|
||||||
|
@ -145,12 +207,7 @@ VOID PrintPrompt(VOID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('T'):
|
case _T('T'):
|
||||||
{
|
PrintTime ();
|
||||||
TCHAR szTime[32];
|
|
||||||
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL,
|
|
||||||
NULL, szTime, sizeof (szTime));
|
|
||||||
ConOutPrintf (_T("%s"), szTime);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('V'):
|
case _T('V'):
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
* Added new error AND output redirection "&>" and "&>>".
|
* Added new error AND output redirection "&>" and "&>>".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef FEATURE_REDIRECTION
|
#ifdef FEATURE_REDIRECTION
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_RENAME
|
#ifdef INCLUDE_CMD_RENAME
|
||||||
|
|
111
rosapps/cmd/ros.c
Normal file
111
rosapps/cmd/ros.c
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
//#include <types.h>
|
||||||
|
//#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
void* malloc(size_t _size)
|
||||||
|
{
|
||||||
|
return(HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void free(void* _ptr)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void* calloc(size_t _nmemb, size_t _size)
|
||||||
|
{
|
||||||
|
return(HeapAlloc(GetProcessHeap(),
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
_nmemb*_size));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void* realloc(void* _ptr, size_t _size)
|
||||||
|
{
|
||||||
|
return(HeapReAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
_ptr,
|
||||||
|
_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
_strdup(const char *_s)
|
||||||
|
{
|
||||||
|
char *rv;
|
||||||
|
if (_s == 0)
|
||||||
|
return 0;
|
||||||
|
rv = (char *)malloc(strlen(_s) + 1);
|
||||||
|
if (rv == 0)
|
||||||
|
return 0;
|
||||||
|
strcpy(rv, _s);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
strlen(const char *str)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
if (str == 0)
|
||||||
|
return 0;
|
||||||
|
for (s = str; *s; ++s);
|
||||||
|
return s-str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_makepath( char *path, const char *drive, const char *dir, const char *fname, const char *ext )
|
||||||
|
{
|
||||||
|
int dir_len;
|
||||||
|
if ( drive != NULL ) {
|
||||||
|
strcat(path,drive);
|
||||||
|
strcat(path,":");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dir != NULL ) {
|
||||||
|
strcat(path,dir);
|
||||||
|
if ( *dir != '\\' )
|
||||||
|
strcat(path,"\\");
|
||||||
|
dir_len = strlen(dir);
|
||||||
|
if ( *(dir + dir_len - 1) != '\\' )
|
||||||
|
strcat(path,"\\");
|
||||||
|
}
|
||||||
|
if ( fname != NULL ) {
|
||||||
|
strcat(path,fname);
|
||||||
|
if ( ext != NULL ) {
|
||||||
|
if ( *ext != '.')
|
||||||
|
strcat(path,".");
|
||||||
|
strcat(path,ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
int getch(void)
|
||||||
|
{
|
||||||
|
DWORD NumberOfCharsRead = 0;
|
||||||
|
DWORD dwWritten;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
ReadConsoleA (GetStdHandle (STD_INPUT_HANDLE), &c, 1, &NumberOfCharsRead, NULL);
|
||||||
|
|
||||||
|
if ( c == 10 )
|
||||||
|
c = 13;
|
||||||
|
|
||||||
|
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), &c, 1, &dwWritten, NULL);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -26,10 +26,11 @@
|
||||||
* 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Fixed Win32 environment handling.
|
* Fixed Win32 environment handling.
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
|
*
|
||||||
|
* 25-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* Fixed little bug.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_SET
|
#ifdef INCLUDE_CMD_SET
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
/* size of environment variable buffer */
|
/* initial size of environment variable buffer */
|
||||||
#define ENV_BUFFER_SIZE 1024
|
#define ENV_BUFFER_SIZE 1024
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ INT cmd_set (LPTSTR cmd, LPTSTR param)
|
||||||
else if (dwBuffer > ENV_BUFFER_SIZE)
|
else if (dwBuffer > ENV_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
GetEnvironmentVariable (param, pszBuffer, ENV_BUFFER_SIZE);
|
GetEnvironmentVariable (param, pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConOutPrintf ("%s\n", pszBuffer);
|
ConOutPrintf ("%s\n", pszBuffer);
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
* Fixed time input bug.
|
* Fixed time input bug.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TIME
|
#ifdef INCLUDE_CMD_TIME
|
||||||
|
@ -38,7 +36,7 @@
|
||||||
static VOID
|
static VOID
|
||||||
PrintTime (VOID)
|
PrintTime (VOID)
|
||||||
{
|
{
|
||||||
#if 0
|
#ifdef __REACTOS__
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
|
|
||||||
GetLocalTime (&st);
|
GetLocalTime (&st);
|
||||||
|
@ -59,13 +57,13 @@ PrintTime (VOID)
|
||||||
st.wSecond, cDecimalSeparator, st.wMilliseconds / 10);
|
st.wSecond, cDecimalSeparator, st.wMilliseconds / 10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
TCHAR szTime[32];
|
TCHAR szTime[32];
|
||||||
|
|
||||||
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
|
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
|
||||||
szTime, sizeof (szTime));
|
szTime, sizeof (szTime));
|
||||||
ConOutPrintf (_T("Current date is: %s\n"), szTime);
|
ConOutPrintf (_T("Current date is: %s\n"), szTime);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
42
rosapps/cmd/title.c
Normal file
42
rosapps/cmd/title.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* title.c - title internal command.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* History:
|
||||||
|
* 1999-02-11 Emanuele Aliberti
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_TITLE
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
INT cmd_title (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
/* Do nothing if no args */
|
||||||
|
if (*param == _T('\0'))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Asking help? */
|
||||||
|
if (!_tcsncmp(param, _T("/?"), 2))
|
||||||
|
{
|
||||||
|
ConOutPuts (_T("Sets the window title for the command prompt window.\n"
|
||||||
|
"\n"
|
||||||
|
"TITLE [string]\n"
|
||||||
|
"\n"
|
||||||
|
" string Specifies the title for the command prompt window."));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetConsoleTitle (param);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* def INCLUDE_CMD_TITLE */
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -20,8 +20,6 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TYPE
|
#ifdef INCLUDE_CMD_TYPE
|
||||||
|
|
|
@ -16,24 +16,27 @@
|
||||||
*
|
*
|
||||||
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Unicode and redirection safe!
|
* Unicode and redirection safe!
|
||||||
|
*
|
||||||
|
* 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
|
* New version info and some output changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
#define VER_HELP "display shell version info VER [/C/R/W/?]"
|
|
||||||
|
|
||||||
|
|
||||||
VOID ShortVersion (VOID)
|
VOID ShortVersion (VOID)
|
||||||
{
|
{
|
||||||
ConOutPuts (_T("\n" SHELLINFO " " SHELLVER "\n"));
|
ConOutPuts (_T("\n"
|
||||||
|
SHELLINFO "\n"
|
||||||
|
SHELLVER "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,9 +51,11 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
|
|
||||||
/* JPP 07/08/1998 clean up and shortened info. */
|
ConOutPuts (_T("\n"
|
||||||
|
SHELLINFO "\n"
|
||||||
ConOutPuts (_T("\n" SHELLINFO " " SHELLVER "\nCopyright (C) 1994-1998 Tim Norman and others."));
|
SHELLVER "\n"
|
||||||
|
"\n"
|
||||||
|
"Copyright (C) 1994-1998 Tim Norman and others."));
|
||||||
ConOutPuts (_T("Copyright (C) 1998,1999 Eric Kohl."));
|
ConOutPuts (_T("Copyright (C) 1998,1999 Eric Kohl."));
|
||||||
|
|
||||||
/* Basic copyright notice */
|
/* Basic copyright notice */
|
||||||
|
@ -67,7 +72,7 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
/* MS-DOS ver prints just help if /? is alone or not */
|
/* MS-DOS ver prints just help if /? is alone or not */
|
||||||
if (_tcsstr (param, _T("/?")) != NULL)
|
if (_tcsstr (param, _T("/?")) != NULL)
|
||||||
{
|
{
|
||||||
ConOutPuts (_T(USAGE ": " VER_HELP));
|
ConOutPuts (_T("\ndisplay shell version info\n\nVER [/C/R/W/?]"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +96,6 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
if (_totupper (param[i]) == _T('W'))
|
if (_totupper (param[i]) == _T('W'))
|
||||||
{
|
{
|
||||||
/* Warranty notice */
|
/* Warranty notice */
|
||||||
/* JPP 07/08/1998 removed extra printf calls */
|
|
||||||
ConOutPuts (_T("\n This program is distributed in the hope that it will be useful,\n"
|
ConOutPuts (_T("\n This program is distributed in the hope that it will be useful,\n"
|
||||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||||
|
@ -100,7 +104,6 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
else if (_totupper (param[i]) == _T('R'))
|
else if (_totupper (param[i]) == _T('R'))
|
||||||
{
|
{
|
||||||
/* Redistribution notice */
|
/* Redistribution notice */
|
||||||
/* JPP 07/08/1998 removed extra printf calls */
|
|
||||||
ConOutPuts (_T("\n This program is free software; you can redistribute it and/or modify\n"
|
ConOutPuts (_T("\n This program is free software; you can redistribute it and/or modify\n"
|
||||||
" it under the terms of the GNU General Public License as published by\n"
|
" it under the terms of the GNU General Public License as published by\n"
|
||||||
" the Free Software Foundation; either version 2 of the License, or\n"
|
" the Free Software Foundation; either version 2 of the License, or\n"
|
||||||
|
@ -109,16 +112,15 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
else if (_totupper (param[i]) == _T('C'))
|
else if (_totupper (param[i]) == _T('C'))
|
||||||
{
|
{
|
||||||
/* Developer listing */
|
/* Developer listing */
|
||||||
/* JPP 07/08/1998 removed extra printf calls; rearranged names */
|
ConOutPuts (_T("\nFreeDOS version written by:\n"
|
||||||
ConOutPuts (_T("\ndeveloped by:\n"
|
|
||||||
" Tim Norman Matt Rains\n"
|
" Tim Norman Matt Rains\n"
|
||||||
" Evan Jeffrey Steffen Kaiser\n"
|
" Evan Jeffrey Steffen Kaiser\n"
|
||||||
" Svante Frey Oliver Mueller\n"
|
" Svante Frey Oliver Mueller\n"
|
||||||
" Aaron Kaufman Marc Desrochers\n"
|
" Aaron Kaufman Marc Desrochers\n"
|
||||||
" Rob Lake John P Price\n"
|
" Rob Lake John P Price\n"
|
||||||
" Hans B Pufal\n"
|
" Hans B Pufal\n"
|
||||||
"\nconverted to Win32 by:\n"
|
"\nReactOS version written by:\n"
|
||||||
" Eric Kohl\n"));
|
" Eric Kohl Emanuele Aliberti\n"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,7 +132,7 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param)
|
||||||
|
|
||||||
ConOutPuts (_T("\nSend bug reports to <ekohl@abo.rhein-zeitung.de>.\n"
|
ConOutPuts (_T("\nSend bug reports to <ekohl@abo.rhein-zeitung.de>.\n"
|
||||||
/*
|
/*
|
||||||
"Updates are available at ftp://www.sid-dis.com/..."
|
"Updates are available at http://www.sid-dis.com/reactos"
|
||||||
*/
|
*/
|
||||||
));
|
));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
* Unicode and redirection ready!
|
* Unicode and redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_VERIFY
|
#ifdef INCLUDE_CMD_VERIFY
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
* Redirection ready!
|
* Redirection ready!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_VOL
|
#ifdef INCLUDE_CMD_VOL
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue