xref: /reactos/modules/rostests/tests/alive/alive.c (revision 1734f297)
1 #include <windows.h>
2 #include <stdlib.h>
3 
4 HANDLE	StandardOutput = INVALID_HANDLE_VALUE;
5 CHAR	Message [80];
6 DWORD	CharactersToWrite = 0;
7 DWORD	WrittenCharacters = 0;
8 INT	d = 0, h = 0, m = 0, s = 0;
9 
10 int
11 main (int argc, char * argv [])
12 {
13 	StandardOutput = GetStdHandle (STD_OUTPUT_HANDLE);
14 	if (INVALID_HANDLE_VALUE == StandardOutput)
15 	{
16 		return (EXIT_FAILURE);
17 	}
18 	while (TRUE)
19 	{
20 		/* Prepare the message and update it */
21 		CharactersToWrite =
22 			wsprintf (
23 				Message,
24 				"Alive for %dd %dh %d' %d\"   \r",
25 				d, h, m, s
26 				);
27 		WriteConsole (
28 			StandardOutput,
29 			Message,
30 			CharactersToWrite,
31 			& WrittenCharacters,
32 			NULL
33 			);
34 		/* suspend the execution for 1s */
35 		Sleep (1000);
36 		/* increment seconds */
37 		++ s;
38 		if (60 == s) { s = 0; ++ m; }
39 		if (60 == m) { m = 0; ++ h; }
40 		if (24 == h) { h = 0; ++ d; }
41 	}
42 	return (EXIT_SUCCESS);
43 }
44 
45 /* EOF */
46