wined3d: Use command buffer IDs for synchronisation in wined3d_buffer_gl_sync_apple().
[wine/zf.git] / dlls / wevtsvc / wevtsvc.c
blob14c30791ff6266cee445febe5166e198514cd27d
1 /*
2 * Event Log Service
4 * Copyright 2020 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winsvc.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(eventlog);
30 static SERVICE_STATUS_HANDLE svc_handle;
31 static HANDLE done_event;
33 static void eventlog_update_status(DWORD state)
35 SERVICE_STATUS status;
37 status.dwServiceType = SERVICE_WIN32;
38 status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
39 status.dwWin32ExitCode = 0;
40 status.dwServiceSpecificExitCode = 0;
41 status.dwCheckPoint = 0;
42 status.dwWaitHint = 0;
43 status.dwControlsAccepted = 0;
44 status.dwCurrentState = state;
46 SetServiceStatus(svc_handle, &status);
49 static void WINAPI eventlog_handler(DWORD control)
51 TRACE("%#x\n", control);
53 switch (control)
55 case SERVICE_CONTROL_STOP:
56 case SERVICE_CONTROL_SHUTDOWN:
57 eventlog_update_status(SERVICE_STOP_PENDING);
58 SetEvent(done_event);
59 break;
61 default:
62 eventlog_update_status(SERVICE_RUNNING);
63 break;
67 void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
69 TRACE("starting Event Log Service\n");
71 svc_handle = RegisterServiceCtrlHandlerW(L"EventLog", eventlog_handler);
72 if (!svc_handle)
74 ERR("RegisterServiceCtrlHandler error %u\n", GetLastError());
75 return;
78 eventlog_update_status(SERVICE_RUNNING);
80 done_event = CreateEventW(NULL, TRUE, FALSE, NULL);
81 WaitForSingleObject(done_event, INFINITE);
82 CloseHandle(done_event);
84 eventlog_update_status(SERVICE_STOPPED);
86 TRACE("exiting Event Log Service\n");