2 * TIMER.C - timer internal command.
4 * clone from 4nt timer command
7 * started - Paolo Pantaleo <paolopan@freemail.it>
13 #ifdef INCLUDE_CMD_TIMER
16 #define NCS_NOT_SPECIFIED -1
25 #define PT(format) PrintElapsedTime(GetTickCount()-cT,format)
28 //current timer Time (at wich started to count)
29 #define cT clksT[clk_n]
31 //current timer status
32 #define cS clksS[clk_n]
36 PrintElapsedTime (DWORD time
,INT format
)
38 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
42 DebugPrintf(_T("PrintTime(%d,%d)"),time
,format
);
48 LoadString(CMD_ModuleHandle
, STRING_TIMER_HELP1
, szMsg
, RC_STRING_MAX_SIZE
);
49 ConOutPrintf(szMsg
, time
);
59 LoadString( CMD_ModuleHandle
, STRING_TIMER_HELP2
, szMsg
, RC_STRING_MAX_SIZE
);
63 s
, cDecimalSeparator
, ms
/10);
69 INT
CommandTimer (LPTSTR cmd
, LPTSTR param
)
71 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
73 // all timers are kept
74 static DWORD clksT
[10];
77 // set all the clocks off by default
78 static BOOL clksS
[10]={FALSE
,FALSE
,FALSE
,FALSE
,
79 FALSE
,FALSE
,FALSE
,FALSE
,FALSE
,FALSE
};
81 // TRUE if /S in command line
84 // avoid to set clk_n more than once
87 INT NewClkStatus
= NCS_NOT_SPECIFIED
;
89 // the clock number specified on the command line
97 // command line parsing variables
103 if (_tcsncmp (param
, _T("/?"), 2) == 0)
105 LoadString(CMD_ModuleHandle
, STRING_TIMER_HELP3
, szMsg
, RC_STRING_MAX_SIZE
);
106 ConOutPrintf(szMsg
, cTimeSeparator
, cTimeSeparator
, cDecimalSeparator
);
112 LoadString( CMD_ModuleHandle
, STRING_TIMER_TIME
, szMsg
, RC_STRING_MAX_SIZE
);
114 p
= split (param
, &argc
, FALSE
);
117 for (i
= 0; i
< argc
; i
++)
120 if (!(_tcsicmp(&p
[i
][0],_T("on"))) && NewClkStatus
== NCS_NOT_SPECIFIED
)
122 NewClkStatus
= NCS_ON
;
127 if (!(_tcsicmp(&p
[i
][0],_T("off"))) && NewClkStatus
== NCS_NOT_SPECIFIED
)
129 NewClkStatus
= NCS_OFF
;
134 if (p
[i
][0] == _T('/'))
137 if (_istdigit(p
[i
][1]) && bCanNSet
)
139 clk_n
= p
[i
][1] - _T('0');
144 // set s(plit) option
145 if (_totupper(p
[i
][1]) == _T('S'))
152 if (_totupper(p
[i
][1]) == _T('F'))
154 iFormat
= p
[i
][2] - _T('0');
160 // do stuff (start/stop/read timer)
161 if(NewClkStatus
== NCS_ON
)
166 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
176 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
178 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
185 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
191 if (NewClkStatus
== NCS_NOT_SPECIFIED
)
196 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
198 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
205 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
212 if (NewClkStatus
== NCS_OFF
)
217 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
219 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
223 ConOutPrintf (szMsg
,clk_n
,cS
?_T("ON"):_T("OFF"));
233 #endif /* INCLUDE_CMD_TIMER */