mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
Added MSGBOX and TIMER commands.
svn path=/trunk/; revision=633
This commit is contained in:
parent
e31d342bc7
commit
ff511b446a
13 changed files with 616 additions and 152 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
|
|
||||||
#define CMD_VER "0.1 pre 5"
|
#define CMD_VER "0.1 pre 6"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
|
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
|
||||||
|
@ -259,6 +259,8 @@ extern TCHAR cDecimalSeparator;
|
||||||
extern INT nNumberGroups;
|
extern INT nNumberGroups;
|
||||||
|
|
||||||
VOID InitLocale (VOID);
|
VOID InitLocale (VOID);
|
||||||
|
VOID PrintDate (VOID);
|
||||||
|
VOID PrintTime (VOID);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for MISC.C */
|
/* Prototypes for MISC.C */
|
||||||
|
@ -277,6 +279,10 @@ BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||||
INT cmd_move (LPTSTR, LPTSTR);
|
INT cmd_move (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for MSGBOX.C */
|
||||||
|
INT CommandMsgbox (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes from PATH.C */
|
/* Prototypes from PATH.C */
|
||||||
INT cmd_path (LPTSTR, LPTSTR);
|
INT cmd_path (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
@ -311,6 +317,10 @@ INT cmd_start (LPTSTR, LPTSTR);
|
||||||
INT cmd_time (LPTSTR, LPTSTR);
|
INT cmd_time (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
|
/* Prototypes for TIMER.C */
|
||||||
|
INT CommandTimer (LPTSTR cmd, LPTSTR param);
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for TITLE.C */
|
/* Prototypes for TITLE.C */
|
||||||
INT cmd_title (LPTSTR, LPTSTR);
|
INT cmd_title (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,11 @@ COMMAND cmds[] =
|
||||||
{_T("move"), 0, cmd_move},
|
{_T("move"), 0, cmd_move},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_MSGBOX
|
||||||
|
{_T("msgbox"), 0, CommandMsgbox},
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_PATH
|
#ifdef INCLUDE_CMD_PATH
|
||||||
{_T("path"), 0, cmd_path},
|
{_T("path"), 0, cmd_path},
|
||||||
#endif
|
#endif
|
||||||
|
@ -182,6 +187,10 @@ COMMAND cmds[] =
|
||||||
{_T("time"), 0, cmd_time},
|
{_T("time"), 0, cmd_time},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_TIMER
|
||||||
|
{_T("timer"), 0, CommandTimer},
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_TITLE
|
#ifdef INCLUDE_CMD_TITLE
|
||||||
{_T("title"), 0, cmd_title},
|
{_T("title"), 0, cmd_title},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -72,6 +72,9 @@
|
||||||
#define INCLUDE_CMD_LABEL
|
#define INCLUDE_CMD_LABEL
|
||||||
#define INCLUDE_CMD_MKDIR
|
#define INCLUDE_CMD_MKDIR
|
||||||
#define INCLUDE_CMD_MOVE
|
#define INCLUDE_CMD_MOVE
|
||||||
|
#ifndef __REACTOS__
|
||||||
|
#define INCLUDE_CMD_MSGBOX
|
||||||
|
#endif
|
||||||
#define INCLUDE_CMD_PATH
|
#define INCLUDE_CMD_PATH
|
||||||
#define INCLUDE_CMD_PROMPT
|
#define INCLUDE_CMD_PROMPT
|
||||||
#define INCLUDE_CMD_RMDIR
|
#define INCLUDE_CMD_RMDIR
|
||||||
|
@ -79,6 +82,7 @@
|
||||||
#define INCLUDE_CMD_SET
|
#define INCLUDE_CMD_SET
|
||||||
#define INCLUDE_CMD_START
|
#define INCLUDE_CMD_START
|
||||||
#define INCLUDE_CMD_TIME
|
#define INCLUDE_CMD_TIME
|
||||||
|
#define INCLUDE_CMD_TIMER
|
||||||
#define INCLUDE_CMD_TITLE
|
#define INCLUDE_CMD_TITLE
|
||||||
#define INCLUDE_CMD_TYPE
|
#define INCLUDE_CMD_TYPE
|
||||||
#define INCLUDE_CMD_VER
|
#define INCLUDE_CMD_VER
|
||||||
|
|
|
@ -19,11 +19,13 @@
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define OUTPUT_BUFFER_SIZE 4096
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
VOID DebugPrintf (LPTSTR szFormat, ...)
|
VOID DebugPrintf (LPTSTR szFormat, ...)
|
||||||
{
|
{
|
||||||
TCHAR szOut[512];
|
TCHAR szOut[OUTPUT_BUFFER_SIZE];
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
|
|
||||||
|
@ -135,7 +137,7 @@ VOID ConOutPuts (LPTSTR szText)
|
||||||
VOID ConOutPrintf (LPTSTR szFormat, ...)
|
VOID ConOutPrintf (LPTSTR szFormat, ...)
|
||||||
{
|
{
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
TCHAR szOut[256];
|
TCHAR szOut[OUTPUT_BUFFER_SIZE];
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
|
@ -169,7 +171,7 @@ VOID ConErrPuts (LPTSTR szText)
|
||||||
VOID ConErrPrintf (LPTSTR szFormat, ...)
|
VOID ConErrPrintf (LPTSTR szFormat, ...)
|
||||||
{
|
{
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
TCHAR szOut[4096];
|
TCHAR szOut[OUTPUT_BUFFER_SIZE];
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start (arg_ptr, szFormat);
|
va_start (arg_ptr, szFormat);
|
||||||
|
|
|
@ -47,42 +47,6 @@ static WORD awMonths[2][13] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
|
||||||
PrintDate (VOID)
|
|
||||||
{
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
SYSTEMTIME st;
|
|
||||||
|
|
||||||
GetLocalTime (&st);
|
|
||||||
|
|
||||||
switch (nDateFormat)
|
|
||||||
{
|
|
||||||
case 0: /* mmddyy */
|
|
||||||
default:
|
|
||||||
ConOutPrintf (_T("Current date is: %s %02d%c%02d%c%04d\n"),
|
|
||||||
aszDayNames[st.wDayOfWeek], st.wMonth, cDateSeparator, st.wDay, cDateSeparator, st.wYear);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: /* ddmmyy */
|
|
||||||
ConOutPrintf (_T("Current date is: %s %02d%c%02d%c%04d\n"),
|
|
||||||
aszDayNames[st.wDayOfWeek], st.wDay, cDateSeparator, st.wMonth, cDateSeparator, st.wYear);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: /* yymmdd */
|
|
||||||
ConOutPrintf (_T("Current date is: %s %04d%c%02d%c%02d\n"),
|
|
||||||
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("Current date is: %s\n"), szDate);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
PrintDateString (VOID)
|
PrintDateString (VOID)
|
||||||
{
|
{
|
||||||
|
@ -90,17 +54,17 @@ PrintDateString (VOID)
|
||||||
{
|
{
|
||||||
case 0: /* mmddyy */
|
case 0: /* mmddyy */
|
||||||
default:
|
default:
|
||||||
ConOutPrintf (_T("Enter new date (mm%cdd%cyyyy): "),
|
ConOutPrintf (_T("\nEnter new date (mm%cdd%cyyyy): "),
|
||||||
cDateSeparator, cDateSeparator);
|
cDateSeparator, cDateSeparator);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* ddmmyy */
|
case 1: /* ddmmyy */
|
||||||
ConOutPrintf (_T("Enter new date (dd%cmm%cyyyy): "),
|
ConOutPrintf (_T("\nEnter new date (dd%cmm%cyyyy): "),
|
||||||
cDateSeparator, cDateSeparator);
|
cDateSeparator, cDateSeparator);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* yymmdd */
|
case 2: /* yymmdd */
|
||||||
ConOutPrintf (_T("Enter new date (yyyy%cmm%cdd): "),
|
ConOutPrintf (_T("\nEnter new date (yyyy%cmm%cdd): "),
|
||||||
cDateSeparator, cDateSeparator);
|
cDateSeparator, cDateSeparator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ internal.c Internal commands (DIR, RD, etc)
|
||||||
label.c Implements label command
|
label.c Implements label command
|
||||||
locale.c Locale handling code
|
locale.c Locale handling code
|
||||||
misc.c Misc. Functions
|
misc.c Misc. Functions
|
||||||
|
msgbox.c Implements msgbox command
|
||||||
move.c Implements move command
|
move.c Implements move command
|
||||||
path.c Implements path command
|
path.c Implements path command
|
||||||
pause.c Implements pause command
|
pause.c Implements pause command
|
||||||
|
@ -51,6 +52,7 @@ ren.c Implements rename command
|
||||||
set.c Implements set command
|
set.c Implements set command
|
||||||
shift.c Implements shift command
|
shift.c Implements shift command
|
||||||
time.c Implements time command
|
time.c Implements time command
|
||||||
|
timer.c Implements timer command
|
||||||
type.c Implements type command
|
type.c Implements type command
|
||||||
ver.c Implements ver command
|
ver.c Implements ver command
|
||||||
where.c Code to search path for executables
|
where.c Code to search path for executables
|
||||||
|
|
|
@ -344,7 +344,7 @@ o Added CHCP command.
|
||||||
o Fixed keyboard input bug.
|
o Fixed keyboard input bug.
|
||||||
o Rewrote DEL and MOVE commands.
|
o Rewrote DEL and MOVE commands.
|
||||||
|
|
||||||
19-Aug-1999 ReactOS CMD version 0.1 pre 5 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
29-Aug-1999 ReactOS CMD version 0.1 pre 6 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
o Cleaned up DIR command.
|
o Cleaned up DIR command.
|
||||||
o Searching for executables in the right order.
|
o Searching for executables in the right order.
|
||||||
|
@ -352,3 +352,6 @@ o Fixed some little but nasty bugs.
|
||||||
o Added TITLE command. Thanks to Emanuele Aliberti!
|
o Added TITLE command. Thanks to Emanuele Aliberti!
|
||||||
o Added "/Q", "/W" and "/Z" options to DEL command.
|
o Added "/Q", "/W" and "/Z" options to DEL command.
|
||||||
o Added CHOICE command.
|
o Added CHOICE command.
|
||||||
|
o Added TIMER command.
|
||||||
|
o Added MSGBOX command (not available under ReactOS).
|
||||||
|
|
||||||
|
|
|
@ -114,3 +114,71 @@ VOID InitLocale (VOID)
|
||||||
_tcscpy (aszDayNames[i], names[i]);
|
_tcscpy (aszDayNames[i], names[i]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID PrintTime (VOID)
|
||||||
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
GetLocalTime (&st);
|
||||||
|
|
||||||
|
switch (nTimeFormat)
|
||||||
|
{
|
||||||
|
case 0: /* 12 hour format */
|
||||||
|
default:
|
||||||
|
ConOutPrintf (_T("Current time is %2d%c%02d%c%02d%c%02d%c\n"),
|
||||||
|
(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("Current time is %2d%c%02d%c%02d%c%02d\n"),
|
||||||
|
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("Current time is: %s\n"), szTime);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ all: cmd.exe
|
||||||
OBJECTS = cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o choice.o \
|
OBJECTS = cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o choice.o \
|
||||||
cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o del.o \
|
cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o del.o \
|
||||||
dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o history.o \
|
dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o history.o \
|
||||||
if.o internal.o label.o locale.o misc.o move.o path.o pause.o \
|
if.o internal.o label.o locale.o misc.o move.o msgbox.o path.o \
|
||||||
prompt.o redir.o ren.o set.o shift.o start.o time.o title.o \
|
pause.o prompt.o redir.o ren.o set.o shift.o start.o time.o \
|
||||||
type.o ver.o verify.o vol.o where.o
|
timer.o title.o type.o ver.o verify.o vol.o where.o
|
||||||
|
|
||||||
CLEAN_FILES = *.o cmd.exe cmd.sym
|
CLEAN_FILES = *.o cmd.exe cmd.sym
|
||||||
|
|
||||||
|
|
256
rosapps/cmd/msgbox.c
Normal file
256
rosapps/cmd/msgbox.c
Normal file
|
@ -0,0 +1,256 @@
|
||||||
|
/*
|
||||||
|
* MSGBOX.C - msgbox internal command.
|
||||||
|
*
|
||||||
|
* clone from 4nt msgbox command
|
||||||
|
*
|
||||||
|
* 25 Aug 1999
|
||||||
|
* started - Dr.F <dfaustus@freemail.it>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_MSGBOX
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include "cmd.h"
|
||||||
|
//#include <assert.h>
|
||||||
|
|
||||||
|
//#include <malloc.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define U_TYPE_INIT 0
|
||||||
|
|
||||||
|
//undefine it to allow to omit arguments
|
||||||
|
//that will be replaced by default ones
|
||||||
|
#define _SYNTAX_CHECK
|
||||||
|
|
||||||
|
INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
|
||||||
|
//used to parse command line
|
||||||
|
LPTSTR tmp;
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
//command line parsing stuff
|
||||||
|
LPTSTR *p;
|
||||||
|
INT argc;
|
||||||
|
INT i;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//used to find window title (used as messagebox title)
|
||||||
|
//and to find window handle to pass to MessageBox
|
||||||
|
HWND hWnd;
|
||||||
|
TCHAR buff[2048];
|
||||||
|
|
||||||
|
//these are MessabeBox() parameters
|
||||||
|
LPTSTR title, prompt="";
|
||||||
|
UINT uType=U_TYPE_INIT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//set default title to window title
|
||||||
|
GetConsoleTitle(buff,2048);
|
||||||
|
title = buff;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||||
|
{
|
||||||
|
ConOutPuts(_T(
|
||||||
|
"display a message box and return user responce\n"
|
||||||
|
"\n"
|
||||||
|
"MSGBOX type [\"title\"] prompt\n"
|
||||||
|
"\n"
|
||||||
|
"type button displayed\n"
|
||||||
|
" possible values are: OK, OKCANCEL,\n"
|
||||||
|
" YESNO, YESNOCANCEL\n"
|
||||||
|
"title title of message box\n"
|
||||||
|
"prompt text displayed by the message box\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"ERRORLEVEL is set according the button pressed:\n"
|
||||||
|
"\n"
|
||||||
|
"YES : 10 | NO : 11\n"
|
||||||
|
"OK : 10 | CANCEL : 12\n"
|
||||||
|
));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//yes here things are quite massed up :)
|
||||||
|
|
||||||
|
|
||||||
|
//skip spaces
|
||||||
|
while(_istspace(*param))
|
||||||
|
param++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//serch for messagebox type (ok, okcancel, ...)
|
||||||
|
if (_tcsnicmp(param, _T("ok "),3 ) == 0)
|
||||||
|
{
|
||||||
|
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||||
|
param+=3;
|
||||||
|
}
|
||||||
|
else if (_tcsnicmp(param, _T("okcancel "),9 ) == 0)
|
||||||
|
{
|
||||||
|
uType |= MB_ICONQUESTION | MB_OKCANCEL;
|
||||||
|
param+=9;
|
||||||
|
}
|
||||||
|
else if (_tcsnicmp(param, _T("yesno "),6 ) == 0)
|
||||||
|
{
|
||||||
|
uType |= MB_ICONQUESTION | MB_YESNO;
|
||||||
|
param+=6;
|
||||||
|
}
|
||||||
|
else if (_tcsnicmp(param, _T("yesnocancel "), 12 ) == 0)
|
||||||
|
{
|
||||||
|
uType |= MB_ICONQUESTION | MB_YESNOCANCEL;
|
||||||
|
param+=12;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
#ifdef _SYNTAX_CHECK
|
||||||
|
error_req_param_missing ();
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//skip spaces
|
||||||
|
while(_istspace(*param))
|
||||||
|
param++;
|
||||||
|
|
||||||
|
#ifdef _SYNTAX_CHECK
|
||||||
|
//if reache end of string
|
||||||
|
//it is an error becuase we do not yet have prompt
|
||||||
|
if ( *param == 0)
|
||||||
|
{
|
||||||
|
error_req_param_missing ();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//serche for "title"
|
||||||
|
tmp = param;
|
||||||
|
|
||||||
|
if(*param == '"')
|
||||||
|
{
|
||||||
|
tmp = _tcschr(param+1,'"');
|
||||||
|
if (tmp)
|
||||||
|
{
|
||||||
|
*tmp = 0;
|
||||||
|
title = param+1;
|
||||||
|
tmp++;
|
||||||
|
param = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//skip spaces
|
||||||
|
while(_istspace(*param))
|
||||||
|
param++;
|
||||||
|
#ifdef _SYNTAX_CHECK
|
||||||
|
//get prompt
|
||||||
|
if ( *param == 0)
|
||||||
|
{
|
||||||
|
error_req_param_missing ();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
prompt = param;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p=split(param,&argc);
|
||||||
|
|
||||||
|
for(i=0;i <argc;i++)
|
||||||
|
{
|
||||||
|
if (!(_tcsicmp(&p[i][0],"ok"))) //! for ok
|
||||||
|
{
|
||||||
|
uType |= MB_ICONEXCLAMATION | MB_OK;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(_tcsicmp(&p[i][0],"okcancel"))) //? for all other
|
||||||
|
{
|
||||||
|
uType |= MB_ICONQUESTION | MB_OKCANCEL;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(_tcsicmp(&p[i][0],"yesno")))
|
||||||
|
{
|
||||||
|
uType |= MB_ICONQUESTION | MB_YESNO;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(_tcsicmp(&p[i][0],"yesnocancel")))
|
||||||
|
{
|
||||||
|
uType |= MB_ICONQUESTION | MB_YESNOCANCEL;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//quoted title
|
||||||
|
if (p[i][0] == '"')
|
||||||
|
{
|
||||||
|
//title will point to
|
||||||
|
//"title", but we need to remove the two "
|
||||||
|
title = &p[i][1];
|
||||||
|
title[_tcsclen(title)-1] = 0;
|
||||||
|
//not a grat piece of code
|
||||||
|
//but that's ok because p[i] will be deleted
|
||||||
|
//on the function exit
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//get prompt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
hWnd=FindWindow(0,buff);
|
||||||
|
//DebugPrintf("FindWindow hWnd = %d\n",hWnd);
|
||||||
|
|
||||||
|
switch (
|
||||||
|
MessageBox(hWnd,prompt,title,uType)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
case IDYES:
|
||||||
|
case IDOK:
|
||||||
|
nErrorLevel = 10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDNO:
|
||||||
|
nErrorLevel = 11;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDCANCEL:
|
||||||
|
nErrorLevel = 12;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CMD_MSGBOX */
|
|
@ -54,75 +54,6 @@
|
||||||
#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
|
||||||
*
|
*
|
||||||
|
@ -163,7 +94,7 @@ VOID PrintPrompt(VOID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('D'):
|
case _T('D'):
|
||||||
PrintDate ();
|
PrintDate ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('E'):
|
case _T('E'):
|
||||||
|
@ -207,7 +138,7 @@ VOID PrintPrompt(VOID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('T'):
|
case _T('T'):
|
||||||
PrintTime ();
|
PrintTime ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _T('V'):
|
case _T('V'):
|
||||||
|
|
|
@ -33,40 +33,6 @@
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
|
||||||
PrintTime (VOID)
|
|
||||||
{
|
|
||||||
#ifdef __REACTOS__
|
|
||||||
SYSTEMTIME st;
|
|
||||||
|
|
||||||
GetLocalTime (&st);
|
|
||||||
|
|
||||||
switch (nTimeFormat)
|
|
||||||
{
|
|
||||||
case 0: /* 12 hour format */
|
|
||||||
default:
|
|
||||||
ConOutPrintf (_T("Current time is %2d%c%02d%c%02d%c%02d%c\n"),
|
|
||||||
(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("Current time is %2d%c%02d%c%02d%c%02d\n"),
|
|
||||||
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("Current date is: %s\n"), szTime);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL ParseTime (LPTSTR s)
|
static BOOL ParseTime (LPTSTR s)
|
||||||
{
|
{
|
||||||
SYSTEMTIME t;
|
SYSTEMTIME t;
|
||||||
|
|
249
rosapps/cmd/timer.c
Normal file
249
rosapps/cmd/timer.c
Normal file
|
@ -0,0 +1,249 @@
|
||||||
|
/*
|
||||||
|
* TIMER.C - timer internal command.
|
||||||
|
*
|
||||||
|
* clone from 4nt timer command
|
||||||
|
*
|
||||||
|
* 20 Aug 1999
|
||||||
|
* started - Dr.F <dfaustus@freemail.it>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CMD_TIMER
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define NCS_NOT_SPECIFIED -1
|
||||||
|
#define NCS_ON 1
|
||||||
|
#define NCS_OFF 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//print timer status
|
||||||
|
#define PS ConOutPrintf("Timer %d is %s: ",clk_n,cS?"ON":"OFF"); \
|
||||||
|
PrintTime()
|
||||||
|
|
||||||
|
//print timer value
|
||||||
|
#define PT(format) PrintElapsedTime(GetTickCount()-cT,format)
|
||||||
|
|
||||||
|
|
||||||
|
//current timer Time (at wich started to count)
|
||||||
|
#define cT clksT[clk_n]
|
||||||
|
|
||||||
|
//current timer status
|
||||||
|
#define cS clksS[clk_n]
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
PrintElapsedTime (DWORD time,INT format)
|
||||||
|
{
|
||||||
|
|
||||||
|
DWORD h,m,s,ms;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf("PrintTime(%d,%d)",time,format);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
ConOutPrintf("Elapsed %d msecs\n",time);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
ms = time % 1000;
|
||||||
|
time /= 1000;
|
||||||
|
s = time % 60;
|
||||||
|
time /=60;
|
||||||
|
m = time % 60;
|
||||||
|
h = time / 60;
|
||||||
|
ConOutPrintf("Elapsed %02d%c%02d%c%02d%c%02d\n",
|
||||||
|
h,cTimeSeparator,
|
||||||
|
m,cTimeSeparator,
|
||||||
|
s,cDecimalSeparator,ms/10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INT CommandTimer (LPTSTR cmd, LPTSTR param)
|
||||||
|
{
|
||||||
|
//here are kept all timers
|
||||||
|
static DWORD clksT[10];
|
||||||
|
|
||||||
|
//timers status
|
||||||
|
//set all the clocks off by default
|
||||||
|
static BOOL clksS[10]={FALSE,FALSE,FALSE,FALSE,
|
||||||
|
FALSE,FALSE,FALSE,FALSE,FALSE,FALSE};
|
||||||
|
|
||||||
|
//TRUE if /S in command line
|
||||||
|
BOOL bS = FALSE;
|
||||||
|
|
||||||
|
//avoid to set clk_n more than once
|
||||||
|
BOOL bCanNSet = TRUE;
|
||||||
|
|
||||||
|
INT NewClkStatus = NCS_NOT_SPECIFIED;
|
||||||
|
|
||||||
|
//the clock number specified on the command line
|
||||||
|
//1 by default
|
||||||
|
INT clk_n=1;
|
||||||
|
|
||||||
|
// output format
|
||||||
|
INT iFormat=1;
|
||||||
|
|
||||||
|
|
||||||
|
// command line parsing variables
|
||||||
|
INT argc;
|
||||||
|
LPTSTR *p;
|
||||||
|
|
||||||
|
INT i;
|
||||||
|
|
||||||
|
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
||||||
|
{
|
||||||
|
ConOutPrintf(_T(
|
||||||
|
"allow the use of ten stopwaches.\n"
|
||||||
|
"\n"
|
||||||
|
"TIMER [ON|OFF] [/S] [/n] [/Fn]\n"
|
||||||
|
"\n"
|
||||||
|
" ON set stopwach ON\n"
|
||||||
|
" OFF set stopwach OFF\n"
|
||||||
|
" /S Split time. Return stopwach split\n"
|
||||||
|
" time without changing its value\n"
|
||||||
|
" /n Specifiy the stopwach number.\n"
|
||||||
|
" Stopwaches avaliable are 0 to 10\n"
|
||||||
|
" If it is not specified default is 1\n"
|
||||||
|
" /Fn Format for output\n"
|
||||||
|
" n can be:\n"
|
||||||
|
" 0 milliseconds\n"
|
||||||
|
" 1 hh%cmm%css%cdd\n"
|
||||||
|
"\n"),
|
||||||
|
cTimeSeparator,cTimeSeparator,cDecimalSeparator);
|
||||||
|
|
||||||
|
ConOutPrintf(_T(
|
||||||
|
"if none of ON, OFF or /S is specified the command\n"
|
||||||
|
"will toggle stopwach state\n"
|
||||||
|
"\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
p = split (param,&argc);
|
||||||
|
|
||||||
|
//read options
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
{
|
||||||
|
//set timer on
|
||||||
|
if (!(_tcsicmp(&p[i][0],"on")) && NewClkStatus == NCS_NOT_SPECIFIED)
|
||||||
|
{
|
||||||
|
NewClkStatus = NCS_ON;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set timer off
|
||||||
|
if (!(_tcsicmp(&p[i][0],"off")) && NewClkStatus == NCS_NOT_SPECIFIED)
|
||||||
|
{
|
||||||
|
NewClkStatus = NCS_OFF;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//other options
|
||||||
|
if (p[i][0] == _T('/'))
|
||||||
|
{
|
||||||
|
|
||||||
|
//set timer number
|
||||||
|
if (_istdigit(p[i][1]) && bCanNSet)
|
||||||
|
{
|
||||||
|
clk_n = p[i][1] - _T('0');
|
||||||
|
bCanNSet = FALSE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set s(plit) option
|
||||||
|
if (_totupper(p[i][1]) == _T('S'))
|
||||||
|
{
|
||||||
|
bS = TRUE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//specify format
|
||||||
|
if(_totupper(p[i][1]) == _T('F'))
|
||||||
|
{
|
||||||
|
iFormat = p[i][2] - _T('0');
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//do stuff (start/stop/read timer)
|
||||||
|
if(NewClkStatus == NCS_ON)
|
||||||
|
{
|
||||||
|
cT=GetTickCount();
|
||||||
|
cS=TRUE;
|
||||||
|
PS;
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bS)
|
||||||
|
{
|
||||||
|
if(cS)
|
||||||
|
{
|
||||||
|
PS;
|
||||||
|
PrintElapsedTime(GetTickCount()-cT, iFormat);
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cT=GetTickCount();
|
||||||
|
cS=TRUE;
|
||||||
|
PS;
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NewClkStatus == NCS_NOT_SPECIFIED)
|
||||||
|
{
|
||||||
|
if(cS){
|
||||||
|
cS=FALSE;
|
||||||
|
PS;
|
||||||
|
PrintElapsedTime(GetTickCount()-cT, iFormat);
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cT=GetTickCount();
|
||||||
|
cS=TRUE;
|
||||||
|
PS;
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(NewClkStatus == NCS_OFF)
|
||||||
|
{
|
||||||
|
if(cS)
|
||||||
|
{
|
||||||
|
cS=FALSE;
|
||||||
|
PS;
|
||||||
|
PrintElapsedTime(GetTickCount()-cT, iFormat);
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
PS;
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
freep(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CMD_TIMER */
|
||||||
|
|
Loading…
Reference in a new issue