ReactOS  0.4.13-dev-100-gc8611ae
myservice.h File Reference
#include <windows.h>
#include <tchar.h>
Include dependency graph for myservice.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEBUG   1
 
#define LOG_FILE   1
 
#define LOG_EVENTLOG   2
 
#define LOG_ERROR   4
 
#define LOG_ALL   (LOG_FILE | LOG_EVENTLOG | LOG_ERROR)
 

Functions

VOID LogEvent (LPCTSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
 
VOID InitLogging ()
 

Variables

volatile BOOL bShutDown
 
volatile BOOL bPause
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG   1

Definition at line 4 of file myservice.h.

◆ LOG_ALL

#define LOG_ALL   (LOG_FILE | LOG_EVENTLOG | LOG_ERROR)

Definition at line 9 of file myservice.h.

◆ LOG_ERROR

#define LOG_ERROR   4

Definition at line 8 of file myservice.h.

◆ LOG_EVENTLOG

#define LOG_EVENTLOG   2

Definition at line 7 of file myservice.h.

◆ LOG_FILE

#define LOG_FILE   1

Definition at line 6 of file myservice.h.

Function Documentation

◆ InitLogging()

VOID InitLogging ( )

Definition at line 210 of file log.c.

211 {
212 #ifdef DEBUG
213  BOOL bRet = FALSE;
214 
216  {
218  }
219  StringCchCatW(szLogFileName, ARRAYSIZE(szLogFileName), L"\\tcpsvcs_log.log");
220 
221  ZeroMemory(&olWrite, sizeof(OVERLAPPED));
222  olWrite.Offset = 0xFFFFFFFF;
223  olWrite.OffsetHigh = 0xFFFFFFFF;
225  if (olWrite.hEvent)
226  {
228 
229  if (OpenLogFile())
230  {
231  WCHAR wcBom = 0xFEFF;
233 
234  bRet = WriteFile(hLogFile,
235  &wcBom,
236  sizeof(WCHAR),
237  &bytesWritten,
238  &olWrite);
239  if (!bRet)
240  {
242  {
243  LogToEventLog(L"Failed to write to log file",
244  GetLastError(),
245  0,
247  }
248  else
249  {
250  bRet = TRUE;
251  }
252  }
253  }
254  }
255 
256  return bRet;
257 #else
258  return TRUE;
259 #endif
260 }
#define CreateEvent
Definition: winbase.h:3562
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define TRUE
Definition: types.h:120
static HANDLE hLogFile
Definition: log.c:16
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
DWORD Offset
Definition: winbase.h:787
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define LOG_EVENTLOG
Definition: tcpsvcs.h:15
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
static OVERLAPPED olWrite
Definition: log.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
static BOOL OpenLogFile()
Definition: log.c:48
HANDLE hEvent
Definition: winbase.h:792
smooth NULL
Definition: ftsmooth.c:416
#define LOG_ERROR
Definition: tcpsvcs.h:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
static VOID LogToEventLog(LPCWSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:23
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
static WCHAR szLogFileName[MAX_PATH]
Definition: log.c:15
DWORD OffsetHigh
Definition: winbase.h:788
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:412

Referenced by _tmain().

◆ LogEvent()

VOID LogEvent ( LPCTSTR  lpMsg,
DWORD  errNum,
DWORD  exitCode,
UINT  flags 
)

Definition at line 152 of file log.c.

156 {
157 #ifdef DEBUG
158  if (flags & LOG_FILE || flags & LOG_ERROR)
159  LogToFile(lpMsg, errNum, exitCode, flags);
160 #endif
161  if (flags & LOG_EVENTLOG)
162  LogToEventLog(lpMsg, errNum, exitCode, flags);
163 }
static VOID LogToEventLog(LPCTSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:18
static BOOL LogToFile(LPCTSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:59
#define LOG_EVENTLOG
Definition: tcpsvcs.h:15
#define LOG_ERROR
Definition: tcpsvcs.h:16
GLbitfield flags
Definition: glext.h:7161

Variable Documentation

◆ bPause

volatile BOOL bPause

Definition at line 17 of file tcpsvcs.c.

Referenced by ServerCtrlHandler().

◆ bShutDown

volatile BOOL bShutDown

Definition at line 12 of file ServiceMain.c.

Referenced by ServerCtrlHandler(), and ThreadProc().