2 * TIMER.C - timer internal command.
4 * clone from 4nt timer command
7 * started - Paolo Pantaleo <paolopan@freemail.it>
12 #ifdef INCLUDE_CMD_TIMER
15 #define NCS_NOT_SPECIFIED -1
20 #define PT(format) PrintElapsedTime(GetTickCount()-cT,format)
23 //current timer Time (at wich started to count)
24 #define cT clksT[clk_n]
26 //current timer status
27 #define cS clksS[clk_n]
31 PrintElapsedTime (DWORD time
,INT format
)
35 TRACE ("PrintElapsedTime(%d,%d)",time
,format
);
40 ConOutResPrintf(STRING_TIMER_HELP1
, time
);
50 ConOutResPrintf(STRING_TIMER_HELP2
,
53 s
, cDecimalSeparator
, ms
/10);
59 INT
CommandTimer (LPTSTR param
)
61 // all timers are kept
62 static DWORD clksT
[10];
65 // set all the clocks off by default
66 static BOOL clksS
[10]={FALSE
,FALSE
,FALSE
,FALSE
,
67 FALSE
,FALSE
,FALSE
,FALSE
,FALSE
,FALSE
};
69 // TRUE if /S in command line
72 // avoid to set clk_n more than once
75 INT NewClkStatus
= NCS_NOT_SPECIFIED
;
77 // the clock number specified on the command line
85 // command line parsing variables
91 if (_tcsncmp (param
, _T("/?"), 2) == 0)
93 ConOutResPrintf(STRING_TIMER_HELP3
, cTimeSeparator
, cTimeSeparator
, cDecimalSeparator
);
99 p
= split (param
, &argc
, FALSE
, FALSE
);
102 for (i
= 0; i
< argc
; i
++)
105 if (!(_tcsicmp(&p
[i
][0],_T("on"))) && NewClkStatus
== NCS_NOT_SPECIFIED
)
107 NewClkStatus
= NCS_ON
;
112 if (!(_tcsicmp(&p
[i
][0],_T("off"))) && NewClkStatus
== NCS_NOT_SPECIFIED
)
114 NewClkStatus
= NCS_OFF
;
119 if (p
[i
][0] == _T('/'))
122 if (_istdigit(p
[i
][1]) && bCanNSet
)
124 clk_n
= p
[i
][1] - _T('0');
129 // set s(plit) option
130 if (_totupper(p
[i
][1]) == _T('S'))
137 if (_totupper(p
[i
][1]) == _T('F'))
139 iFormat
= p
[i
][2] - _T('0');
145 // do stuff (start/stop/read timer)
146 if (NewClkStatus
== NCS_ON
)
151 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
152 ConOutPuts(GetTimeString());
161 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
162 ConOutPrintf(_T("%s\n"), GetTimeString());
163 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
170 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
171 ConOutPuts(GetTimeString());
176 if (NewClkStatus
== NCS_NOT_SPECIFIED
)
181 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
182 ConOutPrintf(_T("%s\n"), GetTimeString());
183 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
190 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
191 ConOutPuts(GetTimeString());
197 if (NewClkStatus
== NCS_OFF
)
202 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
203 ConOutPrintf(_T("%s\n"), GetTimeString());
204 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
208 ConOutResPrintf (STRING_TIMER_TIME
,clk_n
,cS
?_T("ON"):_T("OFF"));
209 ConOutPuts(GetTimeString());
218 #endif /* INCLUDE_CMD_TIMER */