-Deactivate _invalid_parameter for now, depends on the strsafe crt implementation...
[reactos.git] / reactos / lib / sdk / crt / time_new / ftime.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS CRT library
4 * FILE: lib/sdk/crt/time/ftime.c
5 * PURPOSE: Deprecated BSD library call
6 * PROGRAMERS: Timo Kreuzer
7 */
8 #include <precomp.h>
9 #include <sec_api/time_s.h>
10 #include <sys/timeb.h>
11 #include "bitsfixup.h"
12
13 /******************************************************************************
14 * \name _ftime_s
15 * \brief Get the current time.
16 * \param [out] ptimeb Pointer to a structure of type struct _timeb that
17 * recieves the current time.
18 * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
19 */
20 errno_t
21 _ftime_s(struct _timeb *ptimeb)
22 {
23 DWORD ret;
24 TIME_ZONE_INFORMATION TimeZoneInformation;
25 FILETIME SystemTime;
26
27 /* Validate parameters */
28 if (!ptimeb)
29 {
30 #if 0
31 _invalid_parameter(0,
32 0,//__FUNCTION__,
33 _CRT_WIDE(__FILE__),
34 __LINE__,
35 0);
36 #endif
37 return EINVAL;
38 }
39
40 ret = GetTimeZoneInformation(&TimeZoneInformation);
41 ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0;
42 ptimeb->timezone = TimeZoneInformation.Bias;
43
44 GetSystemTimeAsFileTime(&SystemTime);
45 ptimeb->time = FileTimeToUnixTime(&SystemTime, &ptimeb->millitm);
46
47 return 0;
48 }
49
50 /******************************************************************************
51 * \name _ftime
52 * \brief Get the current time.
53 * \param [out] ptimeb Pointer to a structure of type struct _timeb that
54 * recieves the current time.
55 * \note This function is for compatability and simply calls the secure
56 * version _ftime_s().
57 * \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx
58 */
59 void
60 _ftime(struct _timeb *ptimeb)
61 {
62 _ftime_s(ptimeb);
63 }