ReactOS  0.4.12-dev-18-gf469aca
daytime.c File Reference
#include "tcpsvcs.h"
#include <time.h>
Include dependency graph for daytime.c:

Go to the source code of this file.

Functions

static BOOL SendTime (SOCKET sock, CHAR *time)
 
DWORD WINAPI DaytimeHandler (VOID *Sock_)
 

Function Documentation

◆ DaytimeHandler()

DWORD WINAPI DaytimeHandler ( VOID Sock_)

Definition at line 29 of file daytime.c.

30 {
31  struct tm *localTime;
32  time_t aclock;
33  CHAR *pszTime;
34  DWORD retVal = 0;
35  SOCKET Sock = (SOCKET)Sock_;
36 
37  time(&aclock);
38  localTime = localtime(&aclock);
39  if (localTime)
40  {
41  pszTime = asctime(localTime);
42  if (!SendTime(Sock, pszTime))
43  retVal = 1;
44  }
45 
46  LogEvent(L"DayTime: Shutting connection down", 0, 0, LOG_FILE);
47  if (ShutdownConnection(Sock, FALSE))
48  LogEvent(L"DayTime: Connection is down", 0, 0, LOG_FILE);
49  else
50  {
51  LogEvent(L"DayTime: Connection shutdown failed", 0, 0, LOG_FILE);
52  retVal = 1;
53  }
54 
55  LogEvent(L"DayTime: Terminating thread", 0, 0, LOG_FILE);
56  ExitThread(retVal);
57 }
char CHAR
Definition: xmlstorage.h:175
__u16 time
Definition: mkdosfs.c:366
_Check_return_ _CRTIMP char *__cdecl asctime(_In_ const struct tm *_Tm)
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:327
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL ShutdownConnection(SOCKET sock, BOOL bRec)
Definition: skelserver.c:126
static const WCHAR L[]
Definition: oid.c:1087
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:426
VOID LogEvent(LPCWSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:196
__kernel_time_t time_t
Definition: linux.h:252
static BOOL SendTime(SOCKET sock, CHAR *time)
Definition: daytime.c:15
UINT_PTR SOCKET
Definition: winsock.h:47

◆ SendTime()

static BOOL SendTime ( SOCKET  sock,
CHAR time 
)
static

Definition at line 15 of file daytime.c.

Referenced by DaytimeHandler().

16 {
17  SIZE_T stringSize = strlen(time) + 1;
18  if (send(sock, time, stringSize, 0) == SOCKET_ERROR)
19  {
20  LogEvent(L"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR);
21  return FALSE;
22  }
23 
24  return TRUE;
25 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
__u16 time
Definition: mkdosfs.c:366
#define LOG_ERROR
Definition: tcpsvcs.h:16
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
static const WCHAR L[]
Definition: oid.c:1087
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID LogEvent(LPCWSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:196
Definition: tcpcore.h:1455