ReactOS 0.4.15-dev-8339-g4028de8
timer.c File Reference
#include "precomp.h"
Include dependency graph for timer.c:

Go to the source code of this file.

Macros

#define NCS_NOT_SPECIFIED   -1
 
#define NCS_ON   1
 
#define NCS_OFF   0
 
#define PT(format)   PrintElapsedTime(GetTickCount()-cT,format)
 
#define cT   clksT[clk_n]
 
#define cS   clksS[clk_n]
 

Functions

static VOID PrintElapsedTime (DWORD time, INT format)
 
INT CommandTimer (LPTSTR param)
 

Macro Definition Documentation

◆ cS

#define cS   clksS[clk_n]

Definition at line 27 of file timer.c.

◆ cT

#define cT   clksT[clk_n]

Definition at line 24 of file timer.c.

◆ NCS_NOT_SPECIFIED

#define NCS_NOT_SPECIFIED   -1

Definition at line 15 of file timer.c.

◆ NCS_OFF

#define NCS_OFF   0

Definition at line 17 of file timer.c.

◆ NCS_ON

#define NCS_ON   1

Definition at line 16 of file timer.c.

◆ PT

Definition at line 20 of file timer.c.

Function Documentation

◆ CommandTimer()

INT CommandTimer ( LPTSTR  param)

Definition at line 59 of file timer.c.

60{
61 // all timers are kept
62 static DWORD clksT[10];
63
64 // timers status
65 // set all the clocks off by default
66 static BOOL clksS[10]={FALSE,FALSE,FALSE,FALSE,
68
69 // TRUE if /S in command line
70 BOOL bS = FALSE;
71
72 // avoid to set clk_n more than once
73 BOOL bCanNSet = TRUE;
74
75 INT NewClkStatus = NCS_NOT_SPECIFIED;
76
77 // the clock number specified on the command line
78 // 1 by default
79 INT clk_n=1;
80
81 // output format
82 INT iFormat=1;
83
84
85 // command line parsing variables
86 INT argc;
87 LPTSTR *p;
88
89 INT i;
90
91 if (_tcsncmp (param, _T("/?"), 2) == 0)
92 {
94 return 0;
95 }
96
97 nErrorLevel = 0;
98
99 p = split (param, &argc, FALSE, FALSE);
100
101 //read options
102 for (i = 0; i < argc; i++)
103 {
104 //set timer on
105 if (!(_tcsicmp(&p[i][0],_T("on"))) && NewClkStatus == NCS_NOT_SPECIFIED)
106 {
107 NewClkStatus = NCS_ON;
108 continue;
109 }
110
111 //set timer off
112 if (!(_tcsicmp(&p[i][0],_T("off"))) && NewClkStatus == NCS_NOT_SPECIFIED)
113 {
114 NewClkStatus = NCS_OFF;
115 continue;
116 }
117
118 // other options
119 if (p[i][0] == _T('/'))
120 {
121 // set timer number
122 if (_istdigit(p[i][1]) && bCanNSet)
123 {
124 clk_n = p[i][1] - _T('0');
125 bCanNSet = FALSE;
126 continue;
127 }
128
129 // set s(plit) option
130 if (_totupper(p[i][1]) == _T('S'))
131 {
132 bS = TRUE;
133 continue;
134 }
135
136 // specify format
137 if (_totupper(p[i][1]) == _T('F'))
138 {
139 iFormat = p[i][2] - _T('0');
140 continue;
141 }
142 }
143 }
144
145 // do stuff (start/stop/read timer)
146 if (NewClkStatus == NCS_ON)
147 {
149 cS=TRUE;
150
151 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
153 freep(p);
154 return 0;
155 }
156
157 if (bS)
158 {
159 if (cS)
160 {
161 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
162 ConOutPrintf(_T("%s\n"), GetTimeString());
164 freep(p);
165 return 0;
166 }
167
169 cS=TRUE;
170 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
172 freep(p);
173 return 0;
174 }
175
176 if (NewClkStatus == NCS_NOT_SPECIFIED)
177 {
178 if (cS)
179 {
180 cS=FALSE;
181 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
182 ConOutPrintf(_T("%s\n"), GetTimeString());
184 freep(p);
185 return 0;
186 }
187
189 cS=TRUE;
190 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
192 freep(p);
193 return 0;
194 }
195
196
197 if (NewClkStatus == NCS_OFF)
198 {
199 if (cS)
200 {
201 cS=FALSE;
202 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
203 ConOutPrintf(_T("%s\n"), GetTimeString());
205 freep(p);
206 return 0;
207 }
208 ConOutResPrintf (STRING_TIMER_TIME,clk_n,cS?_T("ON"):_T("OFF"));
210 freep(p);
211 return 0;
212 }
213
214 freep(p);
215 return 0;
216}
static int argc
Definition: ServiceArgs.c:12
INT nErrorLevel
Definition: cmd.c:158
TCHAR cTimeSeparator
Definition: locale.c:17
LPTSTR GetTimeString(VOID)
Definition: locale.c:70
TCHAR cDecimalSeparator
Definition: locale.c:19
#define ConOutPrintf(szStr,...)
Definition: console.h:41
#define ConOutPuts(szStr)
Definition: console.h:29
#define STRING_TIMER_HELP3
Definition: resource.h:184
#define STRING_TIMER_TIME
Definition: resource.h:215
#define NCS_OFF
Definition: timer.c:17
#define NCS_NOT_SPECIFIED
Definition: timer.c:15
#define cS
Definition: timer.c:27
static VOID PrintElapsedTime(DWORD time, INT format)
Definition: timer.c:31
#define cT
Definition: timer.c:24
#define NCS_ON
Definition: timer.c:16
static VOID freep(LPSTR *p)
Definition: cmdcons.c:98
static LPSTR * split(LPSTR s, LPINT args)
Definition: cmdcons.c:163
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _istdigit
Definition: tchar.h:1494
#define _tcsncmp
Definition: tchar.h:1428
#define _totupper
Definition: tchar.h:1509
#define ConOutResPrintf(uID,...)
Definition: replace.h:31
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3468
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcsicmp
Definition: xmlstorage.h:205

◆ PrintElapsedTime()

static VOID PrintElapsedTime ( DWORD  time,
INT  format 
)
static

Definition at line 31 of file timer.c.

32{
33 DWORD h,m,s,ms;
34
35 TRACE("PrintElapsedTime(%lu, %d)\n", time, format);
36
37 switch (format)
38 {
39 case 0:
41 break;
42
43 case 1:
44 ms = time % 1000;
45 time /= 1000;
46 s = time % 60;
47 time /=60;
48 m = time % 60;
49 h = time / 60;
53 s, cDecimalSeparator, ms/10);
54 break;
55 }
56}
#define STRING_TIMER_HELP1
Definition: resource.h:182
#define STRING_TIMER_HELP2
Definition: resource.h:183
GLdouble s
Definition: gl.h:2039
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
const GLfloat * m
Definition: glext.h:10848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
__u16 time
Definition: mkdosfs.c:8
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CommandTimer().