ReactOS 0.4.15-dev-8219-ge8b88cf
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),
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}
static HANDLE hLogFile
Definition: log.c:16
static OVERLAPPED olWrite
Definition: log.c:18
static WCHAR szLogFileName[MAX_PATH]
Definition: log.c:15
static BOOL OpenLogFile()
Definition: log.c:48
static VOID LogToEventLog(LPCWSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:23
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
DWORD OffsetHigh
Definition: winbase.h:816
DWORD Offset
Definition: winbase.h:815
HANDLE hEvent
Definition: winbase.h:820
#define LOG_EVENTLOG
Definition: tcpsvcs.h:15
#define LOG_ERROR
Definition: tcpsvcs.h:16
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateEvent
Definition: winbase.h:3748
__wchar_t WCHAR
Definition: xmlstorage.h:180

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 LogToFile(LPCWSTR lpMsg, DWORD errNum, DWORD exitCode, UINT flags)
Definition: log.c:67
GLbitfield flags
Definition: glext.h:7161

Variable Documentation

◆ bPause

volatile BOOL bPause
extern

Definition at line 17 of file tcpsvcs.c.

Referenced by ServerCtrlHandler().

◆ bShutDown

volatile BOOL bShutDown
extern

Definition at line 12 of file ServiceMain.c.

Referenced by ServerCtrlHandler(), and ThreadProc().