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