bd70285c2d64a71f26fce8479b129bc09ed70408
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
23 #define PS ConOutPrintf(_T("Timer %d is %s: "),clk_n,cS?_T("ON"):_T("OFF")); \
27 #define PT(format) PrintElapsedTime(GetTickCount()-cT,format)
30 //current timer Time (at wich started to count)
31 #define cT clksT[clk_n]
33 //current timer status
34 #define cS clksS[clk_n]
38 PrintElapsedTime (DWORD time
,INT format
)
40 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
44 DebugPrintf(_T("PrintTime(%d,%d)"),time
,format
);
50 LoadString(CMD_ModuleHandle
, STRING_TIMER_HELP1
, szMsg
, RC_STRING_MAX_SIZE
);
51 ConOutPrintf(szMsg
, time
);
61 LoadString( CMD_ModuleHandle
, STRING_TIMER_HELP2
, szMsg
, RC_STRING_MAX_SIZE
);
65 s
, cDecimalSeparator
, ms
/10);
71 INT
CommandTimer (LPTSTR cmd
, LPTSTR param
)
73 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
75 // all timers are kept
76 static DWORD clksT
[10];
79 // set all the clocks off by default
80 static BOOL clksS
[10]={FALSE
,FALSE
,FALSE
,FALSE
,
81 FALSE
,FALSE
,FALSE
,FALSE
,FALSE
,FALSE
};
83 // TRUE if /S in command line
86 // avoid to set clk_n more than once
89 INT NewClkStatus
= NCS_NOT_SPECIFIED
;
91 // the clock number specified on the command line
99 // command line parsing variables
105 if (_tcsncmp (param
, _T("/?"), 2) == 0)
107 LoadString(CMD_ModuleHandle
, STRING_TIMER_HELP3
, szMsg
, RC_STRING_MAX_SIZE
);
108 ConOutPrintf(szMsg
, cTimeSeparator
, cTimeSeparator
, cDecimalSeparator
);
113 p
= split (param
, &argc
, FALSE
);
116 for (i
= 0; i
< argc
; i
++)
119 if (!(_tcsicmp(&p
[i
][0],_T("on"))) && NewClkStatus
== NCS_NOT_SPECIFIED
)
121 NewClkStatus
= NCS_ON
;
126 if (!(_tcsicmp(&p
[i
][0],_T("off"))) && NewClkStatus
== NCS_NOT_SPECIFIED
)
128 NewClkStatus
= NCS_OFF
;
133 if (p
[i
][0] == _T('/'))
136 if (_istdigit(p
[i
][1]) && bCanNSet
)
138 clk_n
= p
[i
][1] - _T('0');
143 // set s(plit) option
144 if (_totupper(p
[i
][1]) == _T('S'))
151 if (_totupper(p
[i
][1]) == _T('F'))
153 iFormat
= p
[i
][2] - _T('0');
159 // do stuff (start/stop/read timer)
160 if(NewClkStatus
== NCS_ON
)
174 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
186 if (NewClkStatus
== NCS_NOT_SPECIFIED
)
192 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
205 if (NewClkStatus
== NCS_OFF
)
211 PrintElapsedTime(GetTickCount()-cT
, iFormat
);
224 #endif /* INCLUDE_CMD_TIMER */