ReactOS  0.4.15-dev-499-g1f31905
ftime.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: LGPL, See LGPL.txt 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 <sys/timeb.h>
10 #include "bitsfixup.h"
11 
12 /******************************************************************************
13  * \name _ftime_s
14  * \brief Get the current time.
15  * \param [out] ptimeb Pointer to a structure of type struct _timeb that
16  * receives the current time.
17  * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
18  */
19 errno_t
20 CDECL
21 _ftime_s(struct _timeb *ptimeb)
22 {
23  DWORD ret;
24  TIME_ZONE_INFORMATION TimeZoneInformation;
25  FILETIME SystemTime;
26 
27  /* Validate parameters */
28  if (!MSVCRT_CHECK_PMT( ptimeb != NULL ))
29  {
30  *_errno() = EINVAL;
31  return EINVAL;
32  }
33 
34  ret = GetTimeZoneInformation(&TimeZoneInformation);
35  ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0;
36  ptimeb->timezone = (short)TimeZoneInformation.Bias;
37 
38  GetSystemTimeAsFileTime(&SystemTime);
39  ptimeb->time = (time_t)FileTimeToUnixTime(&SystemTime, &ptimeb->millitm);
40 
41  return 0;
42 }
43 
44 /******************************************************************************
45  * \name _ftime
46  * \brief Get the current time.
47  * \param [out] ptimeb Pointer to a structure of type struct _timeb that
48  * receives the current time.
49  * \note This function is for compatability and simply calls the secure
50  * version _ftime_s().
51  * \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx
52  */
53 void
54 CDECL
55 _ftime(struct _timeb *ptimeb)
56 {
57  _ftime_s(ptimeb);
58 }
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
Definition: arc.h:39
short dstflag
Definition: timeb.h:28
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
static __inline __time64_t FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
Definition: time.h:14
smooth NULL
Definition: ftsmooth.c:416
int errno_t
Definition: crtdefs.h:353
void CDECL _ftime(struct _timeb *ptimeb)
Definition: ftime.c:55
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19
int ret
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
unsigned short millitm
Definition: timeb.h:26
short timezone
Definition: timeb.h:27
#define CDECL
Definition: compat.h:21
__kernel_time_t time_t
Definition: linux.h:252
errno_t CDECL _ftime_s(struct _timeb *ptimeb)
Definition: ftime.c:21
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:252
time_t time
Definition: timeb.h:25
Definition: timeb.h:24