jbeuhler-flexelint-bugs-found-20031128
[openafs.git] / src / WINNT / afsapplib / ctl_elapsed.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef CTL_ELAPSED_H
11 #define CTL_ELAPSED_H
12
13 /*
14  * DEFINITIONS ________________________________________________________________
15  *
16  */
17
18 #ifndef THIS_HINST
19 #define THIS_HINST  (HINSTANCE)GetModuleHandle(NULL)
20 #endif
21
22 #ifndef EXPORTED
23 #define EXPORTED
24 #endif
25
26 #ifndef limit
27 #define limit(_a,_x,_b)  min( max( (_x), (_a) ), (_b) )
28 #endif
29
30 #ifndef inlimit
31 #define inlimit(_a,_x,_b)  ( (((_x)>=(_a)) && ((_x)<=(_b))) ? TRUE : FALSE )
32 #endif
33
34 #ifndef cxRECT
35 #define cxRECT(_r)  ((_r).right - (_r).left)
36 #endif
37
38 #ifndef cyRECT
39 #define cyRECT(_r)  ((_r).bottom - (_r).top)
40 #endif
41
42
43 #define csec1SECOND    (1L)
44 #define csec1MINUTE    (60L * csec1SECOND)
45 #define csec1HOUR      (60L * csec1MINUTE)
46 #define csec1DAY       (24L * csec1HOUR)
47 #define csec1WEEK      ( 7L * csec1DAY)
48
49 #define SET_ELAPSED_TIME(_pst,_h,_m,_s) \
50                   memset (_pst, 0x00, sizeof(SYSTEMTIME)); \
51                   (_pst)->wDay = (WORD)( (_h) / 24L ); \
52                   (_pst)->wHour = (WORD)( (_h) % 24L ); \
53                   (_pst)->wMinute = (WORD)(_m); \
54                   (_pst)->wSecond = (WORD)(_s);
55
56 #define SET_ELAPSED_TIME_FROM_SECONDS(_pst,_s) \
57                   memset (_pst, 0x00, sizeof(SYSTEMTIME)); \
58                   (_pst)->wSecond = (WORD)((_s) % 60L);  \
59                   (_s) /= 60L; \
60                   (_pst)->wMinute = (WORD)((_s) % 60L); \
61                   (_s) /= 60L; \
62                   (_pst)->wHour = (WORD)((_s) % 24L); \
63                   (_s) /= 24L; \
64                   (_pst)->wDay = (WORD)(_s);
65
66 #define GET_SECONDS_FROM_ELAPSED_TIME(_pst) \
67                   ( ((ULONG)((_pst)->wSecond)) + \
68                     ((ULONG)((_pst)->wMinute) * 60L) + \
69                     ((ULONG)((_pst)->wHour) * 60L * 60L) + \
70                     ((ULONG)((_pst)->wDay) * 60L * 60L * 24L) )
71
72
73 /*
74  * PROTOTYPES _________________________________________________________________
75  *
76  */
77
78 EXPORTED BOOL RegisterElapsedClass (void);
79
80 #define ELM_GETRANGE   (WM_USER+301) // SYSTEMTIME *pTime = wp, lp;
81 #define ELM_SETRANGE   (WM_USER+302) // SYSTEMTIME *pTime = wp, lp;
82 #define ELM_GETTIME    (WM_USER+307) // SYSTEMTIME *pTime = lp;
83 #define ELM_SETTIME    (WM_USER+308) // SYSTEMTIME *pTime = lp;
84
85 #define ELN_CHANGE     0x1003  // SYSTEMTIME *pTime = lp;
86 #define ELN_UPDATE     0x1004  // SYSTEMTIME *pTime = lp;
87
88 /*
89  * void EL_GetRange (HWND hElapsed, SYSTEMTIME *pTimeMin, SYSTEMTIME *pTimeMax)
90  * void EL_SetRange (HWND hElapsed, SYSTEMTIME *pTimeMin, SYSTEMTIME *pTimeMax)
91  *
92  */
93 #define EL_GetRange(_hel,_pTimeMin,_pTimeMax) \
94         SendMessage(_hel,ELM_GETRANGE,(WPARAM)_pTimeMin,(LPARAM)_pTimeMax)
95 #define EL_SetRange(_hel,_pTimeMin,_pTimeMax) \
96         SendMessage(_hel,ELM_SETRANGE,(WPARAM)_pTimeMin,(LPARAM)_pTimeMax)
97
98 /*
99  * void EL_GetTime (HWND hElapsed, SYSTEMTIME *pTime)
100  * void EL_SetTime (HWND hElapsed, SYSTEMTIME *pTime)
101  *
102  */
103 #define EL_GetTime(_hel,_pTime) \
104         SendMessage(_hel,ELM_GETTIME,(WPARAM)0,(LPARAM)_pTime)
105 #define EL_SetTime(_hel,_pTime) \
106         SendMessage(_hel,ELM_SETTIME,(WPARAM)0,(LPARAM)_pTime)
107
108
109 #endif
110